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;
1599 if (!all_ports_stopped()) {
1600 printf("Please stop all ports first\n");
1604 RTE_ETH_FOREACH_DEV(pid) {
1605 struct rte_port *port = &ports[pid];
1606 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1608 if (!strcmp(res->name, "max-pkt-len")) {
1609 if (res->value < ETHER_MIN_LEN) {
1610 printf("max-pkt-len can not be less than %d\n",
1614 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1617 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1618 if (res->value > ETHER_MAX_LEN)
1619 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1621 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1622 port->dev_conf.rxmode.offloads = rx_offloads;
1624 printf("Unknown parameter\n");
1631 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1634 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1635 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1637 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1638 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1640 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1641 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1643 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1644 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1646 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1647 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1650 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1651 .f = cmd_config_max_pkt_len_parsed,
1653 .help_str = "port config all max-pkt-len <value>",
1655 (void *)&cmd_config_max_pkt_len_port,
1656 (void *)&cmd_config_max_pkt_len_keyword,
1657 (void *)&cmd_config_max_pkt_len_all,
1658 (void *)&cmd_config_max_pkt_len_name,
1659 (void *)&cmd_config_max_pkt_len_value,
1664 /* *** configure port MTU *** */
1665 struct cmd_config_mtu_result {
1666 cmdline_fixed_string_t port;
1667 cmdline_fixed_string_t keyword;
1668 cmdline_fixed_string_t mtu;
1674 cmd_config_mtu_parsed(void *parsed_result,
1675 __attribute__((unused)) struct cmdline *cl,
1676 __attribute__((unused)) void *data)
1678 struct cmd_config_mtu_result *res = parsed_result;
1680 if (res->value < ETHER_MIN_LEN) {
1681 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1684 port_mtu_set(res->port_id, res->value);
1687 cmdline_parse_token_string_t cmd_config_mtu_port =
1688 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1690 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1691 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1693 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1694 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1696 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1697 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1698 cmdline_parse_token_num_t cmd_config_mtu_value =
1699 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1701 cmdline_parse_inst_t cmd_config_mtu = {
1702 .f = cmd_config_mtu_parsed,
1704 .help_str = "port config mtu <port_id> <value>",
1706 (void *)&cmd_config_mtu_port,
1707 (void *)&cmd_config_mtu_keyword,
1708 (void *)&cmd_config_mtu_mtu,
1709 (void *)&cmd_config_mtu_port_id,
1710 (void *)&cmd_config_mtu_value,
1715 /* *** configure rx mode *** */
1716 struct cmd_config_rx_mode_flag {
1717 cmdline_fixed_string_t port;
1718 cmdline_fixed_string_t keyword;
1719 cmdline_fixed_string_t all;
1720 cmdline_fixed_string_t name;
1721 cmdline_fixed_string_t value;
1725 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1726 __attribute__((unused)) struct cmdline *cl,
1727 __attribute__((unused)) void *data)
1729 struct cmd_config_rx_mode_flag *res = parsed_result;
1732 if (!all_ports_stopped()) {
1733 printf("Please stop all ports first\n");
1737 RTE_ETH_FOREACH_DEV(pid) {
1738 struct rte_port *port;
1739 uint64_t rx_offloads;
1742 rx_offloads = port->dev_conf.rxmode.offloads;
1743 if (!strcmp(res->name, "crc-strip")) {
1744 if (!strcmp(res->value, "on"))
1745 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1746 else if (!strcmp(res->value, "off"))
1747 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1749 printf("Unknown parameter\n");
1752 } else if (!strcmp(res->name, "scatter")) {
1753 if (!strcmp(res->value, "on")) {
1754 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1755 } else if (!strcmp(res->value, "off")) {
1756 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1758 printf("Unknown parameter\n");
1761 } else if (!strcmp(res->name, "rx-cksum")) {
1762 if (!strcmp(res->value, "on"))
1763 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1764 else if (!strcmp(res->value, "off"))
1765 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1767 printf("Unknown parameter\n");
1770 } else if (!strcmp(res->name, "rx-timestamp")) {
1771 if (!strcmp(res->value, "on"))
1772 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1773 else if (!strcmp(res->value, "off"))
1774 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1776 printf("Unknown parameter\n");
1779 } else if (!strcmp(res->name, "hw-vlan")) {
1780 if (!strcmp(res->value, "on")) {
1781 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1782 DEV_RX_OFFLOAD_VLAN_STRIP);
1783 } else if (!strcmp(res->value, "off")) {
1784 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1785 DEV_RX_OFFLOAD_VLAN_STRIP);
1787 printf("Unknown parameter\n");
1790 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1791 if (!strcmp(res->value, "on"))
1792 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1793 else if (!strcmp(res->value, "off"))
1794 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1796 printf("Unknown parameter\n");
1799 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1800 if (!strcmp(res->value, "on"))
1801 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1802 else if (!strcmp(res->value, "off"))
1803 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1805 printf("Unknown parameter\n");
1808 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1809 if (!strcmp(res->value, "on"))
1810 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1811 else if (!strcmp(res->value, "off"))
1812 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1814 printf("Unknown parameter\n");
1817 } else if (!strcmp(res->name, "drop-en")) {
1818 if (!strcmp(res->value, "on"))
1820 else if (!strcmp(res->value, "off"))
1823 printf("Unknown parameter\n");
1827 printf("Unknown parameter\n");
1830 port->dev_conf.rxmode.offloads = rx_offloads;
1835 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1838 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1839 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1840 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1841 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1843 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1844 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1845 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1846 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1847 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1848 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1849 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1850 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1853 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1854 .f = cmd_config_rx_mode_flag_parsed,
1856 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1857 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1859 (void *)&cmd_config_rx_mode_flag_port,
1860 (void *)&cmd_config_rx_mode_flag_keyword,
1861 (void *)&cmd_config_rx_mode_flag_all,
1862 (void *)&cmd_config_rx_mode_flag_name,
1863 (void *)&cmd_config_rx_mode_flag_value,
1868 /* *** configure rss *** */
1869 struct cmd_config_rss {
1870 cmdline_fixed_string_t port;
1871 cmdline_fixed_string_t keyword;
1872 cmdline_fixed_string_t all;
1873 cmdline_fixed_string_t name;
1874 cmdline_fixed_string_t value;
1878 cmd_config_rss_parsed(void *parsed_result,
1879 __attribute__((unused)) struct cmdline *cl,
1880 __attribute__((unused)) void *data)
1882 struct cmd_config_rss *res = parsed_result;
1883 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1887 if (!strcmp(res->value, "all"))
1888 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1889 ETH_RSS_UDP | ETH_RSS_SCTP |
1891 else if (!strcmp(res->value, "ip"))
1892 rss_conf.rss_hf = ETH_RSS_IP;
1893 else if (!strcmp(res->value, "udp"))
1894 rss_conf.rss_hf = ETH_RSS_UDP;
1895 else if (!strcmp(res->value, "tcp"))
1896 rss_conf.rss_hf = ETH_RSS_TCP;
1897 else if (!strcmp(res->value, "sctp"))
1898 rss_conf.rss_hf = ETH_RSS_SCTP;
1899 else if (!strcmp(res->value, "ether"))
1900 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1901 else if (!strcmp(res->value, "port"))
1902 rss_conf.rss_hf = ETH_RSS_PORT;
1903 else if (!strcmp(res->value, "vxlan"))
1904 rss_conf.rss_hf = ETH_RSS_VXLAN;
1905 else if (!strcmp(res->value, "geneve"))
1906 rss_conf.rss_hf = ETH_RSS_GENEVE;
1907 else if (!strcmp(res->value, "nvgre"))
1908 rss_conf.rss_hf = ETH_RSS_NVGRE;
1909 else if (!strcmp(res->value, "none"))
1910 rss_conf.rss_hf = 0;
1911 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1912 atoi(res->value) < 64)
1913 rss_conf.rss_hf = 1ULL << atoi(res->value);
1915 printf("Unknown parameter\n");
1918 rss_conf.rss_key = NULL;
1919 for (i = 0; i < rte_eth_dev_count(); i++) {
1920 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1922 printf("Configuration of RSS hash at ethernet port %d "
1923 "failed with error (%d): %s.\n",
1924 i, -diag, strerror(-diag));
1928 cmdline_parse_token_string_t cmd_config_rss_port =
1929 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1930 cmdline_parse_token_string_t cmd_config_rss_keyword =
1931 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1932 cmdline_parse_token_string_t cmd_config_rss_all =
1933 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1934 cmdline_parse_token_string_t cmd_config_rss_name =
1935 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1936 cmdline_parse_token_string_t cmd_config_rss_value =
1937 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1939 cmdline_parse_inst_t cmd_config_rss = {
1940 .f = cmd_config_rss_parsed,
1942 .help_str = "port config all rss "
1943 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1945 (void *)&cmd_config_rss_port,
1946 (void *)&cmd_config_rss_keyword,
1947 (void *)&cmd_config_rss_all,
1948 (void *)&cmd_config_rss_name,
1949 (void *)&cmd_config_rss_value,
1954 /* *** configure rss hash key *** */
1955 struct cmd_config_rss_hash_key {
1956 cmdline_fixed_string_t port;
1957 cmdline_fixed_string_t config;
1959 cmdline_fixed_string_t rss_hash_key;
1960 cmdline_fixed_string_t rss_type;
1961 cmdline_fixed_string_t key;
1965 hexa_digit_to_value(char hexa_digit)
1967 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1968 return (uint8_t) (hexa_digit - '0');
1969 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1970 return (uint8_t) ((hexa_digit - 'a') + 10);
1971 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1972 return (uint8_t) ((hexa_digit - 'A') + 10);
1973 /* Invalid hexa digit */
1978 parse_and_check_key_hexa_digit(char *key, int idx)
1982 hexa_v = hexa_digit_to_value(key[idx]);
1984 printf("invalid key: character %c at position %d is not a "
1985 "valid hexa digit\n", key[idx], idx);
1990 cmd_config_rss_hash_key_parsed(void *parsed_result,
1991 __attribute__((unused)) struct cmdline *cl,
1992 __attribute__((unused)) void *data)
1994 struct cmd_config_rss_hash_key *res = parsed_result;
1995 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1999 struct rte_eth_dev_info dev_info;
2000 uint8_t hash_key_size;
2003 memset(&dev_info, 0, sizeof(dev_info));
2004 rte_eth_dev_info_get(res->port_id, &dev_info);
2005 if (dev_info.hash_key_size > 0 &&
2006 dev_info.hash_key_size <= sizeof(hash_key))
2007 hash_key_size = dev_info.hash_key_size;
2009 printf("dev_info did not provide a valid hash key size\n");
2012 /* Check the length of the RSS hash key */
2013 key_len = strlen(res->key);
2014 if (key_len != (hash_key_size * 2)) {
2015 printf("key length: %d invalid - key must be a string of %d"
2016 " hexa-decimal numbers\n",
2017 (int) key_len, hash_key_size * 2);
2020 /* Translate RSS hash key into binary representation */
2021 for (i = 0; i < hash_key_size; i++) {
2022 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2025 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2028 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2030 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2034 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2035 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2036 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2037 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2039 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2040 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2041 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2042 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2043 rss_hash_key, "rss-hash-key");
2044 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2045 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2046 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2047 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2048 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2049 "ipv6-tcp-ex#ipv6-udp-ex");
2050 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2051 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2053 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2054 .f = cmd_config_rss_hash_key_parsed,
2056 .help_str = "port config <port_id> rss-hash-key "
2057 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2058 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2059 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2060 "<string of hex digits (variable length, NIC dependent)>",
2062 (void *)&cmd_config_rss_hash_key_port,
2063 (void *)&cmd_config_rss_hash_key_config,
2064 (void *)&cmd_config_rss_hash_key_port_id,
2065 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2066 (void *)&cmd_config_rss_hash_key_rss_type,
2067 (void *)&cmd_config_rss_hash_key_value,
2072 /* *** configure port rxq/txq start/stop *** */
2073 struct cmd_config_rxtx_queue {
2074 cmdline_fixed_string_t port;
2076 cmdline_fixed_string_t rxtxq;
2078 cmdline_fixed_string_t opname;
2082 cmd_config_rxtx_queue_parsed(void *parsed_result,
2083 __attribute__((unused)) struct cmdline *cl,
2084 __attribute__((unused)) void *data)
2086 struct cmd_config_rxtx_queue *res = parsed_result;
2091 if (test_done == 0) {
2092 printf("Please stop forwarding first\n");
2096 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2099 if (port_is_started(res->portid) != 1) {
2100 printf("Please start port %u first\n", res->portid);
2104 if (!strcmp(res->rxtxq, "rxq"))
2106 else if (!strcmp(res->rxtxq, "txq"))
2109 printf("Unknown parameter\n");
2113 if (isrx && rx_queue_id_is_invalid(res->qid))
2115 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2118 if (!strcmp(res->opname, "start"))
2120 else if (!strcmp(res->opname, "stop"))
2123 printf("Unknown parameter\n");
2127 if (isstart && isrx)
2128 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2129 else if (!isstart && isrx)
2130 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2131 else if (isstart && !isrx)
2132 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2134 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2136 if (ret == -ENOTSUP)
2137 printf("Function not supported in PMD driver\n");
2140 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2141 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2142 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2143 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2144 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2145 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2146 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2147 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2148 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2149 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2152 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2153 .f = cmd_config_rxtx_queue_parsed,
2155 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2157 (void *)&cmd_config_speed_all_port,
2158 (void *)&cmd_config_rxtx_queue_portid,
2159 (void *)&cmd_config_rxtx_queue_rxtxq,
2160 (void *)&cmd_config_rxtx_queue_qid,
2161 (void *)&cmd_config_rxtx_queue_opname,
2166 /* *** Configure RSS RETA *** */
2167 struct cmd_config_rss_reta {
2168 cmdline_fixed_string_t port;
2169 cmdline_fixed_string_t keyword;
2171 cmdline_fixed_string_t name;
2172 cmdline_fixed_string_t list_name;
2173 cmdline_fixed_string_t list_of_items;
2177 parse_reta_config(const char *str,
2178 struct rte_eth_rss_reta_entry64 *reta_conf,
2179 uint16_t nb_entries)
2183 uint16_t hash_index, idx, shift;
2186 const char *p, *p0 = str;
2193 unsigned long int_fld[_NUM_FLD];
2194 char *str_fld[_NUM_FLD];
2196 while ((p = strchr(p0,'(')) != NULL) {
2198 if((p0 = strchr(p,')')) == NULL)
2202 if(size >= sizeof(s))
2205 snprintf(s, sizeof(s), "%.*s", size, p);
2206 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2208 for (i = 0; i < _NUM_FLD; i++) {
2210 int_fld[i] = strtoul(str_fld[i], &end, 0);
2211 if (errno != 0 || end == str_fld[i] ||
2216 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2217 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2219 if (hash_index >= nb_entries) {
2220 printf("Invalid RETA hash index=%d\n", hash_index);
2224 idx = hash_index / RTE_RETA_GROUP_SIZE;
2225 shift = hash_index % RTE_RETA_GROUP_SIZE;
2226 reta_conf[idx].mask |= (1ULL << shift);
2227 reta_conf[idx].reta[shift] = nb_queue;
2234 cmd_set_rss_reta_parsed(void *parsed_result,
2235 __attribute__((unused)) struct cmdline *cl,
2236 __attribute__((unused)) void *data)
2239 struct rte_eth_dev_info dev_info;
2240 struct rte_eth_rss_reta_entry64 reta_conf[8];
2241 struct cmd_config_rss_reta *res = parsed_result;
2243 memset(&dev_info, 0, sizeof(dev_info));
2244 rte_eth_dev_info_get(res->port_id, &dev_info);
2245 if (dev_info.reta_size == 0) {
2246 printf("Redirection table size is 0 which is "
2247 "invalid for RSS\n");
2250 printf("The reta size of port %d is %u\n",
2251 res->port_id, dev_info.reta_size);
2252 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2253 printf("Currently do not support more than %u entries of "
2254 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2258 memset(reta_conf, 0, sizeof(reta_conf));
2259 if (!strcmp(res->list_name, "reta")) {
2260 if (parse_reta_config(res->list_of_items, reta_conf,
2261 dev_info.reta_size)) {
2262 printf("Invalid RSS Redirection Table "
2263 "config entered\n");
2266 ret = rte_eth_dev_rss_reta_update(res->port_id,
2267 reta_conf, dev_info.reta_size);
2269 printf("Bad redirection table parameter, "
2270 "return code = %d \n", ret);
2274 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2275 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2276 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2277 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2278 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2279 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2280 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2281 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2282 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2283 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2284 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2285 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2287 cmdline_parse_inst_t cmd_config_rss_reta = {
2288 .f = cmd_set_rss_reta_parsed,
2290 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2292 (void *)&cmd_config_rss_reta_port,
2293 (void *)&cmd_config_rss_reta_keyword,
2294 (void *)&cmd_config_rss_reta_port_id,
2295 (void *)&cmd_config_rss_reta_name,
2296 (void *)&cmd_config_rss_reta_list_name,
2297 (void *)&cmd_config_rss_reta_list_of_items,
2302 /* *** SHOW PORT RETA INFO *** */
2303 struct cmd_showport_reta {
2304 cmdline_fixed_string_t show;
2305 cmdline_fixed_string_t port;
2307 cmdline_fixed_string_t rss;
2308 cmdline_fixed_string_t reta;
2310 cmdline_fixed_string_t list_of_items;
2314 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2315 uint16_t nb_entries,
2319 const char *p, *p0 = str;
2324 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2325 RTE_RETA_GROUP_SIZE;
2328 p = strchr(p0, '(');
2332 p0 = strchr(p, ')');
2336 if (size >= sizeof(s)) {
2337 printf("The string size exceeds the internal buffer size\n");
2340 snprintf(s, sizeof(s), "%.*s", size, p);
2341 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2342 if (ret <= 0 || ret != num) {
2343 printf("The bits of masks do not match the number of "
2344 "reta entries: %u\n", num);
2347 for (i = 0; i < ret; i++)
2348 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2354 cmd_showport_reta_parsed(void *parsed_result,
2355 __attribute__((unused)) struct cmdline *cl,
2356 __attribute__((unused)) void *data)
2358 struct cmd_showport_reta *res = parsed_result;
2359 struct rte_eth_rss_reta_entry64 reta_conf[8];
2360 struct rte_eth_dev_info dev_info;
2361 uint16_t max_reta_size;
2363 memset(&dev_info, 0, sizeof(dev_info));
2364 rte_eth_dev_info_get(res->port_id, &dev_info);
2365 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2366 if (res->size == 0 || res->size > max_reta_size) {
2367 printf("Invalid redirection table size: %u (1-%u)\n",
2368 res->size, max_reta_size);
2372 memset(reta_conf, 0, sizeof(reta_conf));
2373 if (showport_parse_reta_config(reta_conf, res->size,
2374 res->list_of_items) < 0) {
2375 printf("Invalid string: %s for reta masks\n",
2376 res->list_of_items);
2379 port_rss_reta_info(res->port_id, reta_conf, res->size);
2382 cmdline_parse_token_string_t cmd_showport_reta_show =
2383 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2384 cmdline_parse_token_string_t cmd_showport_reta_port =
2385 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2386 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2387 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2388 cmdline_parse_token_string_t cmd_showport_reta_rss =
2389 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2390 cmdline_parse_token_string_t cmd_showport_reta_reta =
2391 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2392 cmdline_parse_token_num_t cmd_showport_reta_size =
2393 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2394 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2395 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2396 list_of_items, NULL);
2398 cmdline_parse_inst_t cmd_showport_reta = {
2399 .f = cmd_showport_reta_parsed,
2401 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2403 (void *)&cmd_showport_reta_show,
2404 (void *)&cmd_showport_reta_port,
2405 (void *)&cmd_showport_reta_port_id,
2406 (void *)&cmd_showport_reta_rss,
2407 (void *)&cmd_showport_reta_reta,
2408 (void *)&cmd_showport_reta_size,
2409 (void *)&cmd_showport_reta_list_of_items,
2414 /* *** Show RSS hash configuration *** */
2415 struct cmd_showport_rss_hash {
2416 cmdline_fixed_string_t show;
2417 cmdline_fixed_string_t port;
2419 cmdline_fixed_string_t rss_hash;
2420 cmdline_fixed_string_t rss_type;
2421 cmdline_fixed_string_t key; /* optional argument */
2424 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2425 __attribute__((unused)) struct cmdline *cl,
2428 struct cmd_showport_rss_hash *res = parsed_result;
2430 port_rss_hash_conf_show(res->port_id, res->rss_type,
2431 show_rss_key != NULL);
2434 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2435 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2436 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2437 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2438 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2439 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2440 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2441 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2443 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2444 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2445 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2446 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2447 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2448 "ipv6-tcp-ex#ipv6-udp-ex");
2449 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2450 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2452 cmdline_parse_inst_t cmd_showport_rss_hash = {
2453 .f = cmd_showport_rss_hash_parsed,
2455 .help_str = "show port <port_id> rss-hash "
2456 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2457 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2458 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2460 (void *)&cmd_showport_rss_hash_show,
2461 (void *)&cmd_showport_rss_hash_port,
2462 (void *)&cmd_showport_rss_hash_port_id,
2463 (void *)&cmd_showport_rss_hash_rss_hash,
2464 (void *)&cmd_showport_rss_hash_rss_hash_info,
2469 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2470 .f = cmd_showport_rss_hash_parsed,
2472 .help_str = "show port <port_id> rss-hash "
2473 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2474 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2475 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2477 (void *)&cmd_showport_rss_hash_show,
2478 (void *)&cmd_showport_rss_hash_port,
2479 (void *)&cmd_showport_rss_hash_port_id,
2480 (void *)&cmd_showport_rss_hash_rss_hash,
2481 (void *)&cmd_showport_rss_hash_rss_hash_info,
2482 (void *)&cmd_showport_rss_hash_rss_key,
2487 /* *** Configure DCB *** */
2488 struct cmd_config_dcb {
2489 cmdline_fixed_string_t port;
2490 cmdline_fixed_string_t config;
2492 cmdline_fixed_string_t dcb;
2493 cmdline_fixed_string_t vt;
2494 cmdline_fixed_string_t vt_en;
2496 cmdline_fixed_string_t pfc;
2497 cmdline_fixed_string_t pfc_en;
2501 cmd_config_dcb_parsed(void *parsed_result,
2502 __attribute__((unused)) struct cmdline *cl,
2503 __attribute__((unused)) void *data)
2505 struct cmd_config_dcb *res = parsed_result;
2506 portid_t port_id = res->port_id;
2507 struct rte_port *port;
2511 port = &ports[port_id];
2512 /** Check if the port is not started **/
2513 if (port->port_status != RTE_PORT_STOPPED) {
2514 printf("Please stop port %d first\n", port_id);
2518 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2519 printf("The invalid number of traffic class,"
2520 " only 4 or 8 allowed.\n");
2524 if (nb_fwd_lcores < res->num_tcs) {
2525 printf("nb_cores shouldn't be less than number of TCs.\n");
2528 if (!strncmp(res->pfc_en, "on", 2))
2533 /* DCB in VT mode */
2534 if (!strncmp(res->vt_en, "on", 2))
2535 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2536 (enum rte_eth_nb_tcs)res->num_tcs,
2539 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2540 (enum rte_eth_nb_tcs)res->num_tcs,
2545 printf("Cannot initialize network ports.\n");
2549 cmd_reconfig_device_queue(port_id, 1, 1);
2552 cmdline_parse_token_string_t cmd_config_dcb_port =
2553 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2554 cmdline_parse_token_string_t cmd_config_dcb_config =
2555 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2556 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2557 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2558 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2559 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2560 cmdline_parse_token_string_t cmd_config_dcb_vt =
2561 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2562 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2563 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2564 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2565 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2566 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2567 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2568 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2569 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2571 cmdline_parse_inst_t cmd_config_dcb = {
2572 .f = cmd_config_dcb_parsed,
2574 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2576 (void *)&cmd_config_dcb_port,
2577 (void *)&cmd_config_dcb_config,
2578 (void *)&cmd_config_dcb_port_id,
2579 (void *)&cmd_config_dcb_dcb,
2580 (void *)&cmd_config_dcb_vt,
2581 (void *)&cmd_config_dcb_vt_en,
2582 (void *)&cmd_config_dcb_num_tcs,
2583 (void *)&cmd_config_dcb_pfc,
2584 (void *)&cmd_config_dcb_pfc_en,
2589 /* *** configure number of packets per burst *** */
2590 struct cmd_config_burst {
2591 cmdline_fixed_string_t port;
2592 cmdline_fixed_string_t keyword;
2593 cmdline_fixed_string_t all;
2594 cmdline_fixed_string_t name;
2599 cmd_config_burst_parsed(void *parsed_result,
2600 __attribute__((unused)) struct cmdline *cl,
2601 __attribute__((unused)) void *data)
2603 struct cmd_config_burst *res = parsed_result;
2605 if (!all_ports_stopped()) {
2606 printf("Please stop all ports first\n");
2610 if (!strcmp(res->name, "burst")) {
2611 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2612 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2615 nb_pkt_per_burst = res->value;
2617 printf("Unknown parameter\n");
2623 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2626 cmdline_parse_token_string_t cmd_config_burst_port =
2627 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2628 cmdline_parse_token_string_t cmd_config_burst_keyword =
2629 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2630 cmdline_parse_token_string_t cmd_config_burst_all =
2631 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2632 cmdline_parse_token_string_t cmd_config_burst_name =
2633 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2634 cmdline_parse_token_num_t cmd_config_burst_value =
2635 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2637 cmdline_parse_inst_t cmd_config_burst = {
2638 .f = cmd_config_burst_parsed,
2640 .help_str = "port config all burst <value>",
2642 (void *)&cmd_config_burst_port,
2643 (void *)&cmd_config_burst_keyword,
2644 (void *)&cmd_config_burst_all,
2645 (void *)&cmd_config_burst_name,
2646 (void *)&cmd_config_burst_value,
2651 /* *** configure rx/tx queues *** */
2652 struct cmd_config_thresh {
2653 cmdline_fixed_string_t port;
2654 cmdline_fixed_string_t keyword;
2655 cmdline_fixed_string_t all;
2656 cmdline_fixed_string_t name;
2661 cmd_config_thresh_parsed(void *parsed_result,
2662 __attribute__((unused)) struct cmdline *cl,
2663 __attribute__((unused)) void *data)
2665 struct cmd_config_thresh *res = parsed_result;
2667 if (!all_ports_stopped()) {
2668 printf("Please stop all ports first\n");
2672 if (!strcmp(res->name, "txpt"))
2673 tx_pthresh = res->value;
2674 else if(!strcmp(res->name, "txht"))
2675 tx_hthresh = res->value;
2676 else if(!strcmp(res->name, "txwt"))
2677 tx_wthresh = res->value;
2678 else if(!strcmp(res->name, "rxpt"))
2679 rx_pthresh = res->value;
2680 else if(!strcmp(res->name, "rxht"))
2681 rx_hthresh = res->value;
2682 else if(!strcmp(res->name, "rxwt"))
2683 rx_wthresh = res->value;
2685 printf("Unknown parameter\n");
2691 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2694 cmdline_parse_token_string_t cmd_config_thresh_port =
2695 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2696 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2697 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2698 cmdline_parse_token_string_t cmd_config_thresh_all =
2699 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2700 cmdline_parse_token_string_t cmd_config_thresh_name =
2701 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2702 "txpt#txht#txwt#rxpt#rxht#rxwt");
2703 cmdline_parse_token_num_t cmd_config_thresh_value =
2704 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2706 cmdline_parse_inst_t cmd_config_thresh = {
2707 .f = cmd_config_thresh_parsed,
2709 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2711 (void *)&cmd_config_thresh_port,
2712 (void *)&cmd_config_thresh_keyword,
2713 (void *)&cmd_config_thresh_all,
2714 (void *)&cmd_config_thresh_name,
2715 (void *)&cmd_config_thresh_value,
2720 /* *** configure free/rs threshold *** */
2721 struct cmd_config_threshold {
2722 cmdline_fixed_string_t port;
2723 cmdline_fixed_string_t keyword;
2724 cmdline_fixed_string_t all;
2725 cmdline_fixed_string_t name;
2730 cmd_config_threshold_parsed(void *parsed_result,
2731 __attribute__((unused)) struct cmdline *cl,
2732 __attribute__((unused)) void *data)
2734 struct cmd_config_threshold *res = parsed_result;
2736 if (!all_ports_stopped()) {
2737 printf("Please stop all ports first\n");
2741 if (!strcmp(res->name, "txfreet"))
2742 tx_free_thresh = res->value;
2743 else if (!strcmp(res->name, "txrst"))
2744 tx_rs_thresh = res->value;
2745 else if (!strcmp(res->name, "rxfreet"))
2746 rx_free_thresh = res->value;
2748 printf("Unknown parameter\n");
2754 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2757 cmdline_parse_token_string_t cmd_config_threshold_port =
2758 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2759 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2760 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2762 cmdline_parse_token_string_t cmd_config_threshold_all =
2763 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2764 cmdline_parse_token_string_t cmd_config_threshold_name =
2765 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2766 "txfreet#txrst#rxfreet");
2767 cmdline_parse_token_num_t cmd_config_threshold_value =
2768 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2770 cmdline_parse_inst_t cmd_config_threshold = {
2771 .f = cmd_config_threshold_parsed,
2773 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2775 (void *)&cmd_config_threshold_port,
2776 (void *)&cmd_config_threshold_keyword,
2777 (void *)&cmd_config_threshold_all,
2778 (void *)&cmd_config_threshold_name,
2779 (void *)&cmd_config_threshold_value,
2785 struct cmd_stop_result {
2786 cmdline_fixed_string_t stop;
2789 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2790 __attribute__((unused)) struct cmdline *cl,
2791 __attribute__((unused)) void *data)
2793 stop_packet_forwarding();
2796 cmdline_parse_token_string_t cmd_stop_stop =
2797 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2799 cmdline_parse_inst_t cmd_stop = {
2800 .f = cmd_stop_parsed,
2802 .help_str = "stop: Stop packet forwarding",
2804 (void *)&cmd_stop_stop,
2809 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2812 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2813 unsigned int *parsed_items, int check_unique_values)
2815 unsigned int nb_item;
2823 * First parse all items in the list and store their value.
2828 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2830 if ((c >= '0') && (c <= '9')) {
2831 value = (unsigned int) (value * 10 + (c - '0'));
2836 printf("character %c is not a decimal digit\n", c);
2840 printf("No valid value before comma\n");
2843 if (nb_item < max_items) {
2844 parsed_items[nb_item] = value;
2850 if (nb_item >= max_items) {
2851 printf("Number of %s = %u > %u (maximum items)\n",
2852 item_name, nb_item + 1, max_items);
2855 parsed_items[nb_item++] = value;
2856 if (! check_unique_values)
2860 * Then, check that all values in the list are differents.
2861 * No optimization here...
2863 for (i = 0; i < nb_item; i++) {
2864 for (j = i + 1; j < nb_item; j++) {
2865 if (parsed_items[j] == parsed_items[i]) {
2866 printf("duplicated %s %u at index %u and %u\n",
2867 item_name, parsed_items[i], i, j);
2875 struct cmd_set_list_result {
2876 cmdline_fixed_string_t cmd_keyword;
2877 cmdline_fixed_string_t list_name;
2878 cmdline_fixed_string_t list_of_items;
2881 static void cmd_set_list_parsed(void *parsed_result,
2882 __attribute__((unused)) struct cmdline *cl,
2883 __attribute__((unused)) void *data)
2885 struct cmd_set_list_result *res;
2887 unsigned int lcorelist[RTE_MAX_LCORE];
2888 unsigned int portlist[RTE_MAX_ETHPORTS];
2890 unsigned int nb_item;
2892 if (test_done == 0) {
2893 printf("Please stop forwarding first\n");
2897 res = parsed_result;
2898 if (!strcmp(res->list_name, "corelist")) {
2899 nb_item = parse_item_list(res->list_of_items, "core",
2901 parsed_items.lcorelist, 1);
2903 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2908 if (!strcmp(res->list_name, "portlist")) {
2909 nb_item = parse_item_list(res->list_of_items, "port",
2911 parsed_items.portlist, 1);
2913 set_fwd_ports_list(parsed_items.portlist, nb_item);
2919 cmdline_parse_token_string_t cmd_set_list_keyword =
2920 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2922 cmdline_parse_token_string_t cmd_set_list_name =
2923 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2924 "corelist#portlist");
2925 cmdline_parse_token_string_t cmd_set_list_of_items =
2926 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2929 cmdline_parse_inst_t cmd_set_fwd_list = {
2930 .f = cmd_set_list_parsed,
2932 .help_str = "set corelist|portlist <list0[,list1]*>",
2934 (void *)&cmd_set_list_keyword,
2935 (void *)&cmd_set_list_name,
2936 (void *)&cmd_set_list_of_items,
2941 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2943 struct cmd_setmask_result {
2944 cmdline_fixed_string_t set;
2945 cmdline_fixed_string_t mask;
2949 static void cmd_set_mask_parsed(void *parsed_result,
2950 __attribute__((unused)) struct cmdline *cl,
2951 __attribute__((unused)) void *data)
2953 struct cmd_setmask_result *res = parsed_result;
2955 if (test_done == 0) {
2956 printf("Please stop forwarding first\n");
2959 if (!strcmp(res->mask, "coremask")) {
2960 set_fwd_lcores_mask(res->hexavalue);
2962 } else if (!strcmp(res->mask, "portmask")) {
2963 set_fwd_ports_mask(res->hexavalue);
2968 cmdline_parse_token_string_t cmd_setmask_set =
2969 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2970 cmdline_parse_token_string_t cmd_setmask_mask =
2971 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2972 "coremask#portmask");
2973 cmdline_parse_token_num_t cmd_setmask_value =
2974 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2976 cmdline_parse_inst_t cmd_set_fwd_mask = {
2977 .f = cmd_set_mask_parsed,
2979 .help_str = "set coremask|portmask <hexadecimal value>",
2981 (void *)&cmd_setmask_set,
2982 (void *)&cmd_setmask_mask,
2983 (void *)&cmd_setmask_value,
2989 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2991 struct cmd_set_result {
2992 cmdline_fixed_string_t set;
2993 cmdline_fixed_string_t what;
2997 static void cmd_set_parsed(void *parsed_result,
2998 __attribute__((unused)) struct cmdline *cl,
2999 __attribute__((unused)) void *data)
3001 struct cmd_set_result *res = parsed_result;
3002 if (!strcmp(res->what, "nbport")) {
3003 set_fwd_ports_number(res->value);
3005 } else if (!strcmp(res->what, "nbcore")) {
3006 set_fwd_lcores_number(res->value);
3008 } else if (!strcmp(res->what, "burst"))
3009 set_nb_pkt_per_burst(res->value);
3010 else if (!strcmp(res->what, "verbose"))
3011 set_verbose_level(res->value);
3014 cmdline_parse_token_string_t cmd_set_set =
3015 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3016 cmdline_parse_token_string_t cmd_set_what =
3017 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3018 "nbport#nbcore#burst#verbose");
3019 cmdline_parse_token_num_t cmd_set_value =
3020 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3022 cmdline_parse_inst_t cmd_set_numbers = {
3023 .f = cmd_set_parsed,
3025 .help_str = "set nbport|nbcore|burst|verbose <value>",
3027 (void *)&cmd_set_set,
3028 (void *)&cmd_set_what,
3029 (void *)&cmd_set_value,
3034 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3036 struct cmd_set_txpkts_result {
3037 cmdline_fixed_string_t cmd_keyword;
3038 cmdline_fixed_string_t txpkts;
3039 cmdline_fixed_string_t seg_lengths;
3043 cmd_set_txpkts_parsed(void *parsed_result,
3044 __attribute__((unused)) struct cmdline *cl,
3045 __attribute__((unused)) void *data)
3047 struct cmd_set_txpkts_result *res;
3048 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3049 unsigned int nb_segs;
3051 res = parsed_result;
3052 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3053 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3055 set_tx_pkt_segments(seg_lengths, nb_segs);
3058 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3059 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3060 cmd_keyword, "set");
3061 cmdline_parse_token_string_t cmd_set_txpkts_name =
3062 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3064 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3065 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3068 cmdline_parse_inst_t cmd_set_txpkts = {
3069 .f = cmd_set_txpkts_parsed,
3071 .help_str = "set txpkts <len0[,len1]*>",
3073 (void *)&cmd_set_txpkts_keyword,
3074 (void *)&cmd_set_txpkts_name,
3075 (void *)&cmd_set_txpkts_lengths,
3080 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3082 struct cmd_set_txsplit_result {
3083 cmdline_fixed_string_t cmd_keyword;
3084 cmdline_fixed_string_t txsplit;
3085 cmdline_fixed_string_t mode;
3089 cmd_set_txsplit_parsed(void *parsed_result,
3090 __attribute__((unused)) struct cmdline *cl,
3091 __attribute__((unused)) void *data)
3093 struct cmd_set_txsplit_result *res;
3095 res = parsed_result;
3096 set_tx_pkt_split(res->mode);
3099 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3100 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3101 cmd_keyword, "set");
3102 cmdline_parse_token_string_t cmd_set_txsplit_name =
3103 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3104 txsplit, "txsplit");
3105 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3106 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3109 cmdline_parse_inst_t cmd_set_txsplit = {
3110 .f = cmd_set_txsplit_parsed,
3112 .help_str = "set txsplit on|off|rand",
3114 (void *)&cmd_set_txsplit_keyword,
3115 (void *)&cmd_set_txsplit_name,
3116 (void *)&cmd_set_txsplit_mode,
3121 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3122 struct cmd_rx_vlan_filter_all_result {
3123 cmdline_fixed_string_t rx_vlan;
3124 cmdline_fixed_string_t what;
3125 cmdline_fixed_string_t all;
3130 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3131 __attribute__((unused)) struct cmdline *cl,
3132 __attribute__((unused)) void *data)
3134 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3136 if (!strcmp(res->what, "add"))
3137 rx_vlan_all_filter_set(res->port_id, 1);
3139 rx_vlan_all_filter_set(res->port_id, 0);
3142 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3143 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3144 rx_vlan, "rx_vlan");
3145 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3146 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3148 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3149 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3151 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3152 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3155 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3156 .f = cmd_rx_vlan_filter_all_parsed,
3158 .help_str = "rx_vlan add|rm all <port_id>: "
3159 "Add/Remove all identifiers to/from the set of VLAN "
3160 "identifiers filtered by a port",
3162 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3163 (void *)&cmd_rx_vlan_filter_all_what,
3164 (void *)&cmd_rx_vlan_filter_all_all,
3165 (void *)&cmd_rx_vlan_filter_all_portid,
3170 /* *** VLAN OFFLOAD SET ON A PORT *** */
3171 struct cmd_vlan_offload_result {
3172 cmdline_fixed_string_t vlan;
3173 cmdline_fixed_string_t set;
3174 cmdline_fixed_string_t vlan_type;
3175 cmdline_fixed_string_t what;
3176 cmdline_fixed_string_t on;
3177 cmdline_fixed_string_t port_id;
3181 cmd_vlan_offload_parsed(void *parsed_result,
3182 __attribute__((unused)) struct cmdline *cl,
3183 __attribute__((unused)) void *data)
3186 struct cmd_vlan_offload_result *res = parsed_result;
3189 portid_t port_id = 0;
3193 len = strnlen(str, STR_TOKEN_SIZE);
3195 /* Get port_id first */
3203 tmp = strtoul(str, NULL, 0);
3204 /* If port_id greater that what portid_t can represent, return */
3205 if(tmp >= RTE_MAX_ETHPORTS)
3207 port_id = (portid_t)tmp;
3209 if (!strcmp(res->on, "on"))
3214 if (!strcmp(res->what, "strip"))
3215 rx_vlan_strip_set(port_id, on);
3216 else if(!strcmp(res->what, "stripq")){
3217 uint16_t queue_id = 0;
3219 /* No queue_id, return */
3221 printf("must specify (port,queue_id)\n");
3224 tmp = strtoul(str + i + 1, NULL, 0);
3225 /* If queue_id greater that what 16-bits can represent, return */
3229 queue_id = (uint16_t)tmp;
3230 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3232 else if (!strcmp(res->what, "filter"))
3233 rx_vlan_filter_set(port_id, on);
3235 vlan_extend_set(port_id, on);
3240 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3241 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3243 cmdline_parse_token_string_t cmd_vlan_offload_set =
3244 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3246 cmdline_parse_token_string_t cmd_vlan_offload_what =
3247 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3248 what, "strip#filter#qinq#stripq");
3249 cmdline_parse_token_string_t cmd_vlan_offload_on =
3250 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3252 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3253 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3256 cmdline_parse_inst_t cmd_vlan_offload = {
3257 .f = cmd_vlan_offload_parsed,
3259 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3260 "<port_id[,queue_id]>: "
3261 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3263 (void *)&cmd_vlan_offload_vlan,
3264 (void *)&cmd_vlan_offload_set,
3265 (void *)&cmd_vlan_offload_what,
3266 (void *)&cmd_vlan_offload_on,
3267 (void *)&cmd_vlan_offload_portid,
3272 /* *** VLAN TPID SET ON A PORT *** */
3273 struct cmd_vlan_tpid_result {
3274 cmdline_fixed_string_t vlan;
3275 cmdline_fixed_string_t set;
3276 cmdline_fixed_string_t vlan_type;
3277 cmdline_fixed_string_t what;
3283 cmd_vlan_tpid_parsed(void *parsed_result,
3284 __attribute__((unused)) struct cmdline *cl,
3285 __attribute__((unused)) void *data)
3287 struct cmd_vlan_tpid_result *res = parsed_result;
3288 enum rte_vlan_type vlan_type;
3290 if (!strcmp(res->vlan_type, "inner"))
3291 vlan_type = ETH_VLAN_TYPE_INNER;
3292 else if (!strcmp(res->vlan_type, "outer"))
3293 vlan_type = ETH_VLAN_TYPE_OUTER;
3295 printf("Unknown vlan type\n");
3298 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3301 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3302 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3304 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3305 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3307 cmdline_parse_token_string_t cmd_vlan_type =
3308 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3309 vlan_type, "inner#outer");
3310 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3311 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3313 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3314 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3316 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3317 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3320 cmdline_parse_inst_t cmd_vlan_tpid = {
3321 .f = cmd_vlan_tpid_parsed,
3323 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3324 "Set the VLAN Ether type",
3326 (void *)&cmd_vlan_tpid_vlan,
3327 (void *)&cmd_vlan_tpid_set,
3328 (void *)&cmd_vlan_type,
3329 (void *)&cmd_vlan_tpid_what,
3330 (void *)&cmd_vlan_tpid_tpid,
3331 (void *)&cmd_vlan_tpid_portid,
3336 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3337 struct cmd_rx_vlan_filter_result {
3338 cmdline_fixed_string_t rx_vlan;
3339 cmdline_fixed_string_t what;
3345 cmd_rx_vlan_filter_parsed(void *parsed_result,
3346 __attribute__((unused)) struct cmdline *cl,
3347 __attribute__((unused)) void *data)
3349 struct cmd_rx_vlan_filter_result *res = parsed_result;
3351 if (!strcmp(res->what, "add"))
3352 rx_vft_set(res->port_id, res->vlan_id, 1);
3354 rx_vft_set(res->port_id, res->vlan_id, 0);
3357 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3358 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3359 rx_vlan, "rx_vlan");
3360 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3361 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3363 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3364 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3366 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3367 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3370 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3371 .f = cmd_rx_vlan_filter_parsed,
3373 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3374 "Add/Remove a VLAN identifier to/from the set of VLAN "
3375 "identifiers filtered by a port",
3377 (void *)&cmd_rx_vlan_filter_rx_vlan,
3378 (void *)&cmd_rx_vlan_filter_what,
3379 (void *)&cmd_rx_vlan_filter_vlanid,
3380 (void *)&cmd_rx_vlan_filter_portid,
3385 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3386 struct cmd_tx_vlan_set_result {
3387 cmdline_fixed_string_t tx_vlan;
3388 cmdline_fixed_string_t set;
3394 cmd_tx_vlan_set_parsed(void *parsed_result,
3395 __attribute__((unused)) struct cmdline *cl,
3396 __attribute__((unused)) void *data)
3398 struct cmd_tx_vlan_set_result *res = parsed_result;
3400 if (!port_is_stopped(res->port_id)) {
3401 printf("Please stop port %d first\n", res->port_id);
3405 tx_vlan_set(res->port_id, res->vlan_id);
3407 cmd_reconfig_device_queue(res->port_id, 1, 1);
3410 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3411 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3412 tx_vlan, "tx_vlan");
3413 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3414 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3416 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3417 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3419 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3420 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3423 cmdline_parse_inst_t cmd_tx_vlan_set = {
3424 .f = cmd_tx_vlan_set_parsed,
3426 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3427 "Enable hardware insertion of a single VLAN header "
3428 "with a given TAG Identifier in packets sent on a port",
3430 (void *)&cmd_tx_vlan_set_tx_vlan,
3431 (void *)&cmd_tx_vlan_set_set,
3432 (void *)&cmd_tx_vlan_set_portid,
3433 (void *)&cmd_tx_vlan_set_vlanid,
3438 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3439 struct cmd_tx_vlan_set_qinq_result {
3440 cmdline_fixed_string_t tx_vlan;
3441 cmdline_fixed_string_t set;
3444 uint16_t vlan_id_outer;
3448 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3449 __attribute__((unused)) struct cmdline *cl,
3450 __attribute__((unused)) void *data)
3452 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3454 if (!port_is_stopped(res->port_id)) {
3455 printf("Please stop port %d first\n", res->port_id);
3459 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3461 cmd_reconfig_device_queue(res->port_id, 1, 1);
3464 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3465 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3466 tx_vlan, "tx_vlan");
3467 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3468 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3470 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3471 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3473 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3474 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3476 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3477 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3478 vlan_id_outer, UINT16);
3480 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3481 .f = cmd_tx_vlan_set_qinq_parsed,
3483 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3484 "Enable hardware insertion of double VLAN header "
3485 "with given TAG Identifiers in packets sent on a port",
3487 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3488 (void *)&cmd_tx_vlan_set_qinq_set,
3489 (void *)&cmd_tx_vlan_set_qinq_portid,
3490 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3491 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3496 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3497 struct cmd_tx_vlan_set_pvid_result {
3498 cmdline_fixed_string_t tx_vlan;
3499 cmdline_fixed_string_t set;
3500 cmdline_fixed_string_t pvid;
3503 cmdline_fixed_string_t mode;
3507 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3508 __attribute__((unused)) struct cmdline *cl,
3509 __attribute__((unused)) void *data)
3511 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3513 if (strcmp(res->mode, "on") == 0)
3514 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3516 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3519 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3520 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3521 tx_vlan, "tx_vlan");
3522 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3523 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3525 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3526 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3528 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3529 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3531 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3532 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3534 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3535 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3538 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3539 .f = cmd_tx_vlan_set_pvid_parsed,
3541 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3543 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3544 (void *)&cmd_tx_vlan_set_pvid_set,
3545 (void *)&cmd_tx_vlan_set_pvid_pvid,
3546 (void *)&cmd_tx_vlan_set_pvid_port_id,
3547 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3548 (void *)&cmd_tx_vlan_set_pvid_mode,
3553 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3554 struct cmd_tx_vlan_reset_result {
3555 cmdline_fixed_string_t tx_vlan;
3556 cmdline_fixed_string_t reset;
3561 cmd_tx_vlan_reset_parsed(void *parsed_result,
3562 __attribute__((unused)) struct cmdline *cl,
3563 __attribute__((unused)) void *data)
3565 struct cmd_tx_vlan_reset_result *res = parsed_result;
3567 if (!port_is_stopped(res->port_id)) {
3568 printf("Please stop port %d first\n", res->port_id);
3572 tx_vlan_reset(res->port_id);
3574 cmd_reconfig_device_queue(res->port_id, 1, 1);
3577 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3578 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3579 tx_vlan, "tx_vlan");
3580 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3581 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3583 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3584 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3587 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3588 .f = cmd_tx_vlan_reset_parsed,
3590 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3591 "VLAN header in packets sent on a port",
3593 (void *)&cmd_tx_vlan_reset_tx_vlan,
3594 (void *)&cmd_tx_vlan_reset_reset,
3595 (void *)&cmd_tx_vlan_reset_portid,
3601 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3602 struct cmd_csum_result {
3603 cmdline_fixed_string_t csum;
3604 cmdline_fixed_string_t mode;
3605 cmdline_fixed_string_t proto;
3606 cmdline_fixed_string_t hwsw;
3611 csum_show(int port_id)
3613 struct rte_eth_dev_info dev_info;
3614 uint64_t tx_offloads;
3616 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3617 printf("Parse tunnel is %s\n",
3618 (ports[port_id].parse_tunnel) ? "on" : "off");
3619 printf("IP checksum offload is %s\n",
3620 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3621 printf("UDP checksum offload is %s\n",
3622 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3623 printf("TCP checksum offload is %s\n",
3624 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3625 printf("SCTP checksum offload is %s\n",
3626 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3627 printf("Outer-Ip checksum offload is %s\n",
3628 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3630 /* display warnings if configuration is not supported by the NIC */
3631 rte_eth_dev_info_get(port_id, &dev_info);
3632 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3633 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3634 printf("Warning: hardware IP checksum enabled but not "
3635 "supported by port %d\n", port_id);
3637 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3638 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3639 printf("Warning: hardware UDP checksum enabled but not "
3640 "supported by port %d\n", port_id);
3642 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3643 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3644 printf("Warning: hardware TCP checksum enabled but not "
3645 "supported by port %d\n", port_id);
3647 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3648 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3649 printf("Warning: hardware SCTP checksum enabled but not "
3650 "supported by port %d\n", port_id);
3652 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3653 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3654 printf("Warning: hardware outer IP checksum enabled but not "
3655 "supported by port %d\n", port_id);
3660 cmd_csum_parsed(void *parsed_result,
3661 __attribute__((unused)) struct cmdline *cl,
3662 __attribute__((unused)) void *data)
3664 struct cmd_csum_result *res = parsed_result;
3666 uint64_t csum_offloads = 0;
3667 struct rte_eth_dev_info dev_info;
3669 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3670 printf("invalid port %d\n", res->port_id);
3673 if (!port_is_stopped(res->port_id)) {
3674 printf("Please stop port %d first\n", res->port_id);
3678 rte_eth_dev_info_get(res->port_id, &dev_info);
3679 if (!strcmp(res->mode, "set")) {
3681 if (!strcmp(res->hwsw, "hw"))
3684 if (!strcmp(res->proto, "ip")) {
3685 if (dev_info.tx_offload_capa &
3686 DEV_TX_OFFLOAD_IPV4_CKSUM) {
3687 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3689 printf("IP checksum offload is not supported "
3690 "by port %u\n", res->port_id);
3692 } else if (!strcmp(res->proto, "udp")) {
3693 if (dev_info.tx_offload_capa &
3694 DEV_TX_OFFLOAD_UDP_CKSUM) {
3695 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3697 printf("UDP checksum offload is not supported "
3698 "by port %u\n", res->port_id);
3700 } else if (!strcmp(res->proto, "tcp")) {
3701 if (dev_info.tx_offload_capa &
3702 DEV_TX_OFFLOAD_TCP_CKSUM) {
3703 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3705 printf("TCP checksum offload is not supported "
3706 "by port %u\n", res->port_id);
3708 } else if (!strcmp(res->proto, "sctp")) {
3709 if (dev_info.tx_offload_capa &
3710 DEV_TX_OFFLOAD_SCTP_CKSUM) {
3711 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3713 printf("SCTP checksum offload is not supported "
3714 "by port %u\n", res->port_id);
3716 } else if (!strcmp(res->proto, "outer-ip")) {
3717 if (dev_info.tx_offload_capa &
3718 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) {
3720 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3722 printf("Outer IP checksum offload is not "
3723 "supported by port %u\n", res->port_id);
3728 ports[res->port_id].dev_conf.txmode.offloads |=
3731 ports[res->port_id].dev_conf.txmode.offloads &=
3735 csum_show(res->port_id);
3737 cmd_reconfig_device_queue(res->port_id, 1, 1);
3740 cmdline_parse_token_string_t cmd_csum_csum =
3741 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3743 cmdline_parse_token_string_t cmd_csum_mode =
3744 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3746 cmdline_parse_token_string_t cmd_csum_proto =
3747 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3748 proto, "ip#tcp#udp#sctp#outer-ip");
3749 cmdline_parse_token_string_t cmd_csum_hwsw =
3750 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3752 cmdline_parse_token_num_t cmd_csum_portid =
3753 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3756 cmdline_parse_inst_t cmd_csum_set = {
3757 .f = cmd_csum_parsed,
3759 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3760 "Enable/Disable hardware calculation of L3/L4 checksum when "
3761 "using csum forward engine",
3763 (void *)&cmd_csum_csum,
3764 (void *)&cmd_csum_mode,
3765 (void *)&cmd_csum_proto,
3766 (void *)&cmd_csum_hwsw,
3767 (void *)&cmd_csum_portid,
3772 cmdline_parse_token_string_t cmd_csum_mode_show =
3773 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3776 cmdline_parse_inst_t cmd_csum_show = {
3777 .f = cmd_csum_parsed,
3779 .help_str = "csum show <port_id>: Show checksum offload configuration",
3781 (void *)&cmd_csum_csum,
3782 (void *)&cmd_csum_mode_show,
3783 (void *)&cmd_csum_portid,
3788 /* Enable/disable tunnel parsing */
3789 struct cmd_csum_tunnel_result {
3790 cmdline_fixed_string_t csum;
3791 cmdline_fixed_string_t parse;
3792 cmdline_fixed_string_t onoff;
3797 cmd_csum_tunnel_parsed(void *parsed_result,
3798 __attribute__((unused)) struct cmdline *cl,
3799 __attribute__((unused)) void *data)
3801 struct cmd_csum_tunnel_result *res = parsed_result;
3803 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3806 if (!strcmp(res->onoff, "on"))
3807 ports[res->port_id].parse_tunnel = 1;
3809 ports[res->port_id].parse_tunnel = 0;
3811 csum_show(res->port_id);
3814 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3815 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3817 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3818 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3819 parse, "parse_tunnel");
3820 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3821 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3823 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3824 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3827 cmdline_parse_inst_t cmd_csum_tunnel = {
3828 .f = cmd_csum_tunnel_parsed,
3830 .help_str = "csum parse_tunnel on|off <port_id>: "
3831 "Enable/Disable parsing of tunnels for csum engine",
3833 (void *)&cmd_csum_tunnel_csum,
3834 (void *)&cmd_csum_tunnel_parse,
3835 (void *)&cmd_csum_tunnel_onoff,
3836 (void *)&cmd_csum_tunnel_portid,
3841 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3842 struct cmd_tso_set_result {
3843 cmdline_fixed_string_t tso;
3844 cmdline_fixed_string_t mode;
3850 cmd_tso_set_parsed(void *parsed_result,
3851 __attribute__((unused)) struct cmdline *cl,
3852 __attribute__((unused)) void *data)
3854 struct cmd_tso_set_result *res = parsed_result;
3855 struct rte_eth_dev_info dev_info;
3857 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3859 if (!port_is_stopped(res->port_id)) {
3860 printf("Please stop port %d first\n", res->port_id);
3864 if (!strcmp(res->mode, "set"))
3865 ports[res->port_id].tso_segsz = res->tso_segsz;
3867 rte_eth_dev_info_get(res->port_id, &dev_info);
3868 if ((ports[res->port_id].tso_segsz != 0) &&
3869 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3870 printf("Error: TSO is not supported by port %d\n",
3875 if (ports[res->port_id].tso_segsz == 0) {
3876 ports[res->port_id].dev_conf.txmode.offloads &=
3877 ~DEV_TX_OFFLOAD_TCP_TSO;
3878 printf("TSO for non-tunneled packets is disabled\n");
3880 ports[res->port_id].dev_conf.txmode.offloads |=
3881 DEV_TX_OFFLOAD_TCP_TSO;
3882 printf("TSO segment size for non-tunneled packets is %d\n",
3883 ports[res->port_id].tso_segsz);
3886 /* display warnings if configuration is not supported by the NIC */
3887 rte_eth_dev_info_get(res->port_id, &dev_info);
3888 if ((ports[res->port_id].tso_segsz != 0) &&
3889 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3890 printf("Warning: TSO enabled but not "
3891 "supported by port %d\n", res->port_id);
3894 cmd_reconfig_device_queue(res->port_id, 1, 1);
3897 cmdline_parse_token_string_t cmd_tso_set_tso =
3898 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3900 cmdline_parse_token_string_t cmd_tso_set_mode =
3901 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3903 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3904 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3906 cmdline_parse_token_num_t cmd_tso_set_portid =
3907 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3910 cmdline_parse_inst_t cmd_tso_set = {
3911 .f = cmd_tso_set_parsed,
3913 .help_str = "tso set <tso_segsz> <port_id>: "
3914 "Set TSO segment size of non-tunneled packets for csum engine "
3917 (void *)&cmd_tso_set_tso,
3918 (void *)&cmd_tso_set_mode,
3919 (void *)&cmd_tso_set_tso_segsz,
3920 (void *)&cmd_tso_set_portid,
3925 cmdline_parse_token_string_t cmd_tso_show_mode =
3926 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3930 cmdline_parse_inst_t cmd_tso_show = {
3931 .f = cmd_tso_set_parsed,
3933 .help_str = "tso show <port_id>: "
3934 "Show TSO segment size of non-tunneled packets for csum engine",
3936 (void *)&cmd_tso_set_tso,
3937 (void *)&cmd_tso_show_mode,
3938 (void *)&cmd_tso_set_portid,
3943 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3944 struct cmd_tunnel_tso_set_result {
3945 cmdline_fixed_string_t tso;
3946 cmdline_fixed_string_t mode;
3951 static struct rte_eth_dev_info
3952 check_tunnel_tso_nic_support(portid_t port_id)
3954 struct rte_eth_dev_info dev_info;
3956 rte_eth_dev_info_get(port_id, &dev_info);
3957 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3958 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
3959 "not enabled for port %d\n", port_id);
3960 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3961 printf("Warning: GRE TUNNEL TSO not supported therefore "
3962 "not enabled for port %d\n", port_id);
3963 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3964 printf("Warning: IPIP TUNNEL TSO not supported therefore "
3965 "not enabled for port %d\n", port_id);
3966 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3967 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
3968 "not enabled for port %d\n", port_id);
3973 cmd_tunnel_tso_set_parsed(void *parsed_result,
3974 __attribute__((unused)) struct cmdline *cl,
3975 __attribute__((unused)) void *data)
3977 struct cmd_tunnel_tso_set_result *res = parsed_result;
3978 struct rte_eth_dev_info dev_info;
3980 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3982 if (!port_is_stopped(res->port_id)) {
3983 printf("Please stop port %d first\n", res->port_id);
3987 if (!strcmp(res->mode, "set"))
3988 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3990 dev_info = check_tunnel_tso_nic_support(res->port_id);
3991 if (ports[res->port_id].tunnel_tso_segsz == 0) {
3992 ports[res->port_id].dev_conf.txmode.offloads &=
3993 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
3994 DEV_TX_OFFLOAD_GRE_TNL_TSO |
3995 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
3996 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
3997 printf("TSO for tunneled packets is disabled\n");
3999 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4000 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4001 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4002 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4004 ports[res->port_id].dev_conf.txmode.offloads |=
4005 (tso_offloads & dev_info.tx_offload_capa);
4006 printf("TSO segment size for tunneled packets is %d\n",
4007 ports[res->port_id].tunnel_tso_segsz);
4009 /* Below conditions are needed to make it work:
4010 * (1) tunnel TSO is supported by the NIC;
4011 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4013 * (3) for tunneled pkts with outer L3 of IPv4,
4014 * "csum set outer-ip" must be set to hw, because after tso,
4015 * total_len of outer IP header is changed, and the checksum
4016 * of outer IP header calculated by sw should be wrong; that
4017 * is not necessary for IPv6 tunneled pkts because there's no
4018 * checksum in IP header anymore.
4021 if (!ports[res->port_id].parse_tunnel)
4022 printf("Warning: csum parse_tunnel must be set "
4023 "so that tunneled packets are recognized\n");
4024 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4025 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4026 printf("Warning: csum set outer-ip must be set to hw "
4027 "if outer L3 is IPv4; not necessary for IPv6\n");
4030 cmd_reconfig_device_queue(res->port_id, 1, 1);
4033 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4034 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4036 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4037 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4039 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4040 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4042 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4043 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4046 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4047 .f = cmd_tunnel_tso_set_parsed,
4049 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4050 "Set TSO segment size of tunneled packets for csum engine "
4053 (void *)&cmd_tunnel_tso_set_tso,
4054 (void *)&cmd_tunnel_tso_set_mode,
4055 (void *)&cmd_tunnel_tso_set_tso_segsz,
4056 (void *)&cmd_tunnel_tso_set_portid,
4061 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4062 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4066 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4067 .f = cmd_tunnel_tso_set_parsed,
4069 .help_str = "tunnel_tso show <port_id> "
4070 "Show TSO segment size of tunneled packets for csum engine",
4072 (void *)&cmd_tunnel_tso_set_tso,
4073 (void *)&cmd_tunnel_tso_show_mode,
4074 (void *)&cmd_tunnel_tso_set_portid,
4079 /* *** SET GRO FOR A PORT *** */
4080 struct cmd_gro_enable_result {
4081 cmdline_fixed_string_t cmd_set;
4082 cmdline_fixed_string_t cmd_port;
4083 cmdline_fixed_string_t cmd_keyword;
4084 cmdline_fixed_string_t cmd_onoff;
4089 cmd_gro_enable_parsed(void *parsed_result,
4090 __attribute__((unused)) struct cmdline *cl,
4091 __attribute__((unused)) void *data)
4093 struct cmd_gro_enable_result *res;
4095 res = parsed_result;
4096 if (!strcmp(res->cmd_keyword, "gro"))
4097 setup_gro(res->cmd_onoff, res->cmd_pid);
4100 cmdline_parse_token_string_t cmd_gro_enable_set =
4101 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4103 cmdline_parse_token_string_t cmd_gro_enable_port =
4104 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4105 cmd_keyword, "port");
4106 cmdline_parse_token_num_t cmd_gro_enable_pid =
4107 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4109 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4110 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4111 cmd_keyword, "gro");
4112 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4113 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4114 cmd_onoff, "on#off");
4116 cmdline_parse_inst_t cmd_gro_enable = {
4117 .f = cmd_gro_enable_parsed,
4119 .help_str = "set port <port_id> gro on|off",
4121 (void *)&cmd_gro_enable_set,
4122 (void *)&cmd_gro_enable_port,
4123 (void *)&cmd_gro_enable_pid,
4124 (void *)&cmd_gro_enable_keyword,
4125 (void *)&cmd_gro_enable_onoff,
4130 /* *** DISPLAY GRO CONFIGURATION *** */
4131 struct cmd_gro_show_result {
4132 cmdline_fixed_string_t cmd_show;
4133 cmdline_fixed_string_t cmd_port;
4134 cmdline_fixed_string_t cmd_keyword;
4139 cmd_gro_show_parsed(void *parsed_result,
4140 __attribute__((unused)) struct cmdline *cl,
4141 __attribute__((unused)) void *data)
4143 struct cmd_gro_show_result *res;
4145 res = parsed_result;
4146 if (!strcmp(res->cmd_keyword, "gro"))
4147 show_gro(res->cmd_pid);
4150 cmdline_parse_token_string_t cmd_gro_show_show =
4151 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4153 cmdline_parse_token_string_t cmd_gro_show_port =
4154 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4156 cmdline_parse_token_num_t cmd_gro_show_pid =
4157 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4159 cmdline_parse_token_string_t cmd_gro_show_keyword =
4160 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4161 cmd_keyword, "gro");
4163 cmdline_parse_inst_t cmd_gro_show = {
4164 .f = cmd_gro_show_parsed,
4166 .help_str = "show port <port_id> gro",
4168 (void *)&cmd_gro_show_show,
4169 (void *)&cmd_gro_show_port,
4170 (void *)&cmd_gro_show_pid,
4171 (void *)&cmd_gro_show_keyword,
4176 /* *** SET FLUSH CYCLES FOR GRO *** */
4177 struct cmd_gro_flush_result {
4178 cmdline_fixed_string_t cmd_set;
4179 cmdline_fixed_string_t cmd_keyword;
4180 cmdline_fixed_string_t cmd_flush;
4185 cmd_gro_flush_parsed(void *parsed_result,
4186 __attribute__((unused)) struct cmdline *cl,
4187 __attribute__((unused)) void *data)
4189 struct cmd_gro_flush_result *res;
4191 res = parsed_result;
4192 if ((!strcmp(res->cmd_keyword, "gro")) &&
4193 (!strcmp(res->cmd_flush, "flush")))
4194 setup_gro_flush_cycles(res->cmd_cycles);
4197 cmdline_parse_token_string_t cmd_gro_flush_set =
4198 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4200 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4201 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4202 cmd_keyword, "gro");
4203 cmdline_parse_token_string_t cmd_gro_flush_flush =
4204 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4205 cmd_flush, "flush");
4206 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4207 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4210 cmdline_parse_inst_t cmd_gro_flush = {
4211 .f = cmd_gro_flush_parsed,
4213 .help_str = "set gro flush <cycles>",
4215 (void *)&cmd_gro_flush_set,
4216 (void *)&cmd_gro_flush_keyword,
4217 (void *)&cmd_gro_flush_flush,
4218 (void *)&cmd_gro_flush_cycles,
4223 /* *** ENABLE/DISABLE GSO *** */
4224 struct cmd_gso_enable_result {
4225 cmdline_fixed_string_t cmd_set;
4226 cmdline_fixed_string_t cmd_port;
4227 cmdline_fixed_string_t cmd_keyword;
4228 cmdline_fixed_string_t cmd_mode;
4233 cmd_gso_enable_parsed(void *parsed_result,
4234 __attribute__((unused)) struct cmdline *cl,
4235 __attribute__((unused)) void *data)
4237 struct cmd_gso_enable_result *res;
4239 res = parsed_result;
4240 if (!strcmp(res->cmd_keyword, "gso"))
4241 setup_gso(res->cmd_mode, res->cmd_pid);
4244 cmdline_parse_token_string_t cmd_gso_enable_set =
4245 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4247 cmdline_parse_token_string_t cmd_gso_enable_port =
4248 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4250 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4251 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4252 cmd_keyword, "gso");
4253 cmdline_parse_token_string_t cmd_gso_enable_mode =
4254 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4255 cmd_mode, "on#off");
4256 cmdline_parse_token_num_t cmd_gso_enable_pid =
4257 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4260 cmdline_parse_inst_t cmd_gso_enable = {
4261 .f = cmd_gso_enable_parsed,
4263 .help_str = "set port <port_id> gso on|off",
4265 (void *)&cmd_gso_enable_set,
4266 (void *)&cmd_gso_enable_port,
4267 (void *)&cmd_gso_enable_pid,
4268 (void *)&cmd_gso_enable_keyword,
4269 (void *)&cmd_gso_enable_mode,
4274 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4275 struct cmd_gso_size_result {
4276 cmdline_fixed_string_t cmd_set;
4277 cmdline_fixed_string_t cmd_keyword;
4278 cmdline_fixed_string_t cmd_segsz;
4283 cmd_gso_size_parsed(void *parsed_result,
4284 __attribute__((unused)) struct cmdline *cl,
4285 __attribute__((unused)) void *data)
4287 struct cmd_gso_size_result *res = parsed_result;
4289 if (test_done == 0) {
4290 printf("Before setting GSO segsz, please first"
4291 " stop fowarding\n");
4295 if (!strcmp(res->cmd_keyword, "gso") &&
4296 !strcmp(res->cmd_segsz, "segsz")) {
4297 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4298 printf("gso_size should be larger than %zu."
4299 " Please input a legal value\n",
4300 RTE_GSO_SEG_SIZE_MIN);
4302 gso_max_segment_size = res->cmd_size;
4306 cmdline_parse_token_string_t cmd_gso_size_set =
4307 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4309 cmdline_parse_token_string_t cmd_gso_size_keyword =
4310 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4311 cmd_keyword, "gso");
4312 cmdline_parse_token_string_t cmd_gso_size_segsz =
4313 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4314 cmd_segsz, "segsz");
4315 cmdline_parse_token_num_t cmd_gso_size_size =
4316 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4319 cmdline_parse_inst_t cmd_gso_size = {
4320 .f = cmd_gso_size_parsed,
4322 .help_str = "set gso segsz <length>",
4324 (void *)&cmd_gso_size_set,
4325 (void *)&cmd_gso_size_keyword,
4326 (void *)&cmd_gso_size_segsz,
4327 (void *)&cmd_gso_size_size,
4332 /* *** SHOW GSO CONFIGURATION *** */
4333 struct cmd_gso_show_result {
4334 cmdline_fixed_string_t cmd_show;
4335 cmdline_fixed_string_t cmd_port;
4336 cmdline_fixed_string_t cmd_keyword;
4341 cmd_gso_show_parsed(void *parsed_result,
4342 __attribute__((unused)) struct cmdline *cl,
4343 __attribute__((unused)) void *data)
4345 struct cmd_gso_show_result *res = parsed_result;
4347 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4348 printf("invalid port id %u\n", res->cmd_pid);
4351 if (!strcmp(res->cmd_keyword, "gso")) {
4352 if (gso_ports[res->cmd_pid].enable) {
4353 printf("Max GSO'd packet size: %uB\n"
4354 "Supported GSO types: TCP/IPv4, "
4355 "VxLAN with inner TCP/IPv4 packet, "
4356 "GRE with inner TCP/IPv4 packet\n",
4357 gso_max_segment_size);
4359 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4363 cmdline_parse_token_string_t cmd_gso_show_show =
4364 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4366 cmdline_parse_token_string_t cmd_gso_show_port =
4367 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4369 cmdline_parse_token_string_t cmd_gso_show_keyword =
4370 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4371 cmd_keyword, "gso");
4372 cmdline_parse_token_num_t cmd_gso_show_pid =
4373 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4376 cmdline_parse_inst_t cmd_gso_show = {
4377 .f = cmd_gso_show_parsed,
4379 .help_str = "show port <port_id> gso",
4381 (void *)&cmd_gso_show_show,
4382 (void *)&cmd_gso_show_port,
4383 (void *)&cmd_gso_show_pid,
4384 (void *)&cmd_gso_show_keyword,
4389 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4390 struct cmd_set_flush_rx {
4391 cmdline_fixed_string_t set;
4392 cmdline_fixed_string_t flush_rx;
4393 cmdline_fixed_string_t mode;
4397 cmd_set_flush_rx_parsed(void *parsed_result,
4398 __attribute__((unused)) struct cmdline *cl,
4399 __attribute__((unused)) void *data)
4401 struct cmd_set_flush_rx *res = parsed_result;
4402 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4405 cmdline_parse_token_string_t cmd_setflushrx_set =
4406 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4408 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4409 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4410 flush_rx, "flush_rx");
4411 cmdline_parse_token_string_t cmd_setflushrx_mode =
4412 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4416 cmdline_parse_inst_t cmd_set_flush_rx = {
4417 .f = cmd_set_flush_rx_parsed,
4418 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4421 (void *)&cmd_setflushrx_set,
4422 (void *)&cmd_setflushrx_flush_rx,
4423 (void *)&cmd_setflushrx_mode,
4428 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4429 struct cmd_set_link_check {
4430 cmdline_fixed_string_t set;
4431 cmdline_fixed_string_t link_check;
4432 cmdline_fixed_string_t mode;
4436 cmd_set_link_check_parsed(void *parsed_result,
4437 __attribute__((unused)) struct cmdline *cl,
4438 __attribute__((unused)) void *data)
4440 struct cmd_set_link_check *res = parsed_result;
4441 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4444 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4445 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4447 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4448 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4449 link_check, "link_check");
4450 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4451 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4455 cmdline_parse_inst_t cmd_set_link_check = {
4456 .f = cmd_set_link_check_parsed,
4457 .help_str = "set link_check on|off: Enable/Disable link status check "
4458 "when starting/stopping a port",
4461 (void *)&cmd_setlinkcheck_set,
4462 (void *)&cmd_setlinkcheck_link_check,
4463 (void *)&cmd_setlinkcheck_mode,
4468 /* *** SET NIC BYPASS MODE *** */
4469 struct cmd_set_bypass_mode_result {
4470 cmdline_fixed_string_t set;
4471 cmdline_fixed_string_t bypass;
4472 cmdline_fixed_string_t mode;
4473 cmdline_fixed_string_t value;
4478 cmd_set_bypass_mode_parsed(void *parsed_result,
4479 __attribute__((unused)) struct cmdline *cl,
4480 __attribute__((unused)) void *data)
4482 struct cmd_set_bypass_mode_result *res = parsed_result;
4483 portid_t port_id = res->port_id;
4484 int32_t rc = -EINVAL;
4486 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4487 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4489 if (!strcmp(res->value, "bypass"))
4490 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4491 else if (!strcmp(res->value, "isolate"))
4492 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4494 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4496 /* Set the bypass mode for the relevant port. */
4497 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4500 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4503 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4504 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4506 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4507 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4509 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4510 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4512 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4513 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4514 value, "normal#bypass#isolate");
4515 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4516 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4519 cmdline_parse_inst_t cmd_set_bypass_mode = {
4520 .f = cmd_set_bypass_mode_parsed,
4521 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4522 "Set the NIC bypass mode for port_id",
4525 (void *)&cmd_setbypass_mode_set,
4526 (void *)&cmd_setbypass_mode_bypass,
4527 (void *)&cmd_setbypass_mode_mode,
4528 (void *)&cmd_setbypass_mode_value,
4529 (void *)&cmd_setbypass_mode_port,
4534 /* *** SET NIC BYPASS EVENT *** */
4535 struct cmd_set_bypass_event_result {
4536 cmdline_fixed_string_t set;
4537 cmdline_fixed_string_t bypass;
4538 cmdline_fixed_string_t event;
4539 cmdline_fixed_string_t event_value;
4540 cmdline_fixed_string_t mode;
4541 cmdline_fixed_string_t mode_value;
4546 cmd_set_bypass_event_parsed(void *parsed_result,
4547 __attribute__((unused)) struct cmdline *cl,
4548 __attribute__((unused)) void *data)
4550 int32_t rc = -EINVAL;
4551 struct cmd_set_bypass_event_result *res = parsed_result;
4552 portid_t port_id = res->port_id;
4554 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4555 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4556 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4558 if (!strcmp(res->event_value, "timeout"))
4559 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4560 else if (!strcmp(res->event_value, "os_on"))
4561 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4562 else if (!strcmp(res->event_value, "os_off"))
4563 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4564 else if (!strcmp(res->event_value, "power_on"))
4565 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4566 else if (!strcmp(res->event_value, "power_off"))
4567 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4569 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4571 if (!strcmp(res->mode_value, "bypass"))
4572 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4573 else if (!strcmp(res->mode_value, "isolate"))
4574 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4576 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4578 /* Set the watchdog timeout. */
4579 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4582 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4583 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4587 printf("Failed to set timeout value %u "
4588 "for port %d, errto code: %d.\n",
4589 bypass_timeout, port_id, rc);
4593 /* Set the bypass event to transition to bypass mode. */
4594 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4599 printf("\t Failed to set bypass event for port = %d.\n",
4603 cmdline_parse_token_string_t cmd_setbypass_event_set =
4604 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4606 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4607 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4609 cmdline_parse_token_string_t cmd_setbypass_event_event =
4610 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4612 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4613 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4614 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4615 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4616 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4618 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4619 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4620 mode_value, "normal#bypass#isolate");
4621 cmdline_parse_token_num_t cmd_setbypass_event_port =
4622 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4625 cmdline_parse_inst_t cmd_set_bypass_event = {
4626 .f = cmd_set_bypass_event_parsed,
4627 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4628 "power_off mode normal|bypass|isolate <port_id>: "
4629 "Set the NIC bypass event mode for port_id",
4632 (void *)&cmd_setbypass_event_set,
4633 (void *)&cmd_setbypass_event_bypass,
4634 (void *)&cmd_setbypass_event_event,
4635 (void *)&cmd_setbypass_event_event_value,
4636 (void *)&cmd_setbypass_event_mode,
4637 (void *)&cmd_setbypass_event_mode_value,
4638 (void *)&cmd_setbypass_event_port,
4644 /* *** SET NIC BYPASS TIMEOUT *** */
4645 struct cmd_set_bypass_timeout_result {
4646 cmdline_fixed_string_t set;
4647 cmdline_fixed_string_t bypass;
4648 cmdline_fixed_string_t timeout;
4649 cmdline_fixed_string_t value;
4653 cmd_set_bypass_timeout_parsed(void *parsed_result,
4654 __attribute__((unused)) struct cmdline *cl,
4655 __attribute__((unused)) void *data)
4657 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4659 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4660 if (!strcmp(res->value, "1.5"))
4661 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4662 else if (!strcmp(res->value, "2"))
4663 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4664 else if (!strcmp(res->value, "3"))
4665 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4666 else if (!strcmp(res->value, "4"))
4667 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4668 else if (!strcmp(res->value, "8"))
4669 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4670 else if (!strcmp(res->value, "16"))
4671 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4672 else if (!strcmp(res->value, "32"))
4673 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4675 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4679 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4680 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4682 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4683 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4685 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4686 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4687 timeout, "timeout");
4688 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4689 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4690 value, "0#1.5#2#3#4#8#16#32");
4692 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4693 .f = cmd_set_bypass_timeout_parsed,
4694 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4695 "Set the NIC bypass watchdog timeout in seconds",
4698 (void *)&cmd_setbypass_timeout_set,
4699 (void *)&cmd_setbypass_timeout_bypass,
4700 (void *)&cmd_setbypass_timeout_timeout,
4701 (void *)&cmd_setbypass_timeout_value,
4706 /* *** SHOW NIC BYPASS MODE *** */
4707 struct cmd_show_bypass_config_result {
4708 cmdline_fixed_string_t show;
4709 cmdline_fixed_string_t bypass;
4710 cmdline_fixed_string_t config;
4715 cmd_show_bypass_config_parsed(void *parsed_result,
4716 __attribute__((unused)) struct cmdline *cl,
4717 __attribute__((unused)) void *data)
4719 struct cmd_show_bypass_config_result *res = parsed_result;
4720 portid_t port_id = res->port_id;
4722 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4723 uint32_t event_mode;
4724 uint32_t bypass_mode;
4725 uint32_t timeout = bypass_timeout;
4728 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4729 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4730 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4731 {"UNKNOWN", "normal", "bypass", "isolate"};
4732 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4739 int num_events = (sizeof events) / (sizeof events[0]);
4741 /* Display the bypass mode.*/
4742 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4743 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4747 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4748 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4750 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4753 /* Display the bypass timeout.*/
4754 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4755 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4757 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4759 /* Display the bypass events and associated modes. */
4760 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4762 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4763 printf("\tFailed to get bypass mode for event = %s\n",
4766 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4767 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4769 printf("\tbypass event: %-16s = %s\n", events[i],
4775 printf("\tFailed to get bypass configuration for port = %d\n",
4779 cmdline_parse_token_string_t cmd_showbypass_config_show =
4780 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4782 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4783 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4785 cmdline_parse_token_string_t cmd_showbypass_config_config =
4786 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4788 cmdline_parse_token_num_t cmd_showbypass_config_port =
4789 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4792 cmdline_parse_inst_t cmd_show_bypass_config = {
4793 .f = cmd_show_bypass_config_parsed,
4794 .help_str = "show bypass config <port_id>: "
4795 "Show the NIC bypass config for port_id",
4798 (void *)&cmd_showbypass_config_show,
4799 (void *)&cmd_showbypass_config_bypass,
4800 (void *)&cmd_showbypass_config_config,
4801 (void *)&cmd_showbypass_config_port,
4806 #ifdef RTE_LIBRTE_PMD_BOND
4807 /* *** SET BONDING MODE *** */
4808 struct cmd_set_bonding_mode_result {
4809 cmdline_fixed_string_t set;
4810 cmdline_fixed_string_t bonding;
4811 cmdline_fixed_string_t mode;
4816 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4817 __attribute__((unused)) struct cmdline *cl,
4818 __attribute__((unused)) void *data)
4820 struct cmd_set_bonding_mode_result *res = parsed_result;
4821 portid_t port_id = res->port_id;
4823 /* Set the bonding mode for the relevant port. */
4824 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4825 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4828 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4829 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4831 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4832 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4833 bonding, "bonding");
4834 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4835 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4837 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4838 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4840 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4841 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4844 cmdline_parse_inst_t cmd_set_bonding_mode = {
4845 .f = cmd_set_bonding_mode_parsed,
4846 .help_str = "set bonding mode <mode_value> <port_id>: "
4847 "Set the bonding mode for port_id",
4850 (void *) &cmd_setbonding_mode_set,
4851 (void *) &cmd_setbonding_mode_bonding,
4852 (void *) &cmd_setbonding_mode_mode,
4853 (void *) &cmd_setbonding_mode_value,
4854 (void *) &cmd_setbonding_mode_port,
4859 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4860 struct cmd_set_bonding_lacp_dedicated_queues_result {
4861 cmdline_fixed_string_t set;
4862 cmdline_fixed_string_t bonding;
4863 cmdline_fixed_string_t lacp;
4864 cmdline_fixed_string_t dedicated_queues;
4866 cmdline_fixed_string_t mode;
4869 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4870 __attribute__((unused)) struct cmdline *cl,
4871 __attribute__((unused)) void *data)
4873 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4874 portid_t port_id = res->port_id;
4875 struct rte_port *port;
4877 port = &ports[port_id];
4879 /** Check if the port is not started **/
4880 if (port->port_status != RTE_PORT_STOPPED) {
4881 printf("Please stop port %d first\n", port_id);
4885 if (!strcmp(res->mode, "enable")) {
4886 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4887 printf("Dedicate queues for LACP control packets"
4890 printf("Enabling dedicate queues for LACP control "
4891 "packets on port %d failed\n", port_id);
4892 } else if (!strcmp(res->mode, "disable")) {
4893 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4894 printf("Dedicated queues for LACP control packets "
4897 printf("Disabling dedicated queues for LACP control "
4898 "traffic on port %d failed\n", port_id);
4902 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4903 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4905 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4906 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4907 bonding, "bonding");
4908 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4909 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4911 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4912 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4913 dedicated_queues, "dedicated_queues");
4914 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4915 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4917 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4918 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4919 mode, "enable#disable");
4921 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4922 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4923 .help_str = "set bonding lacp dedicated_queues <port_id> "
4925 "Enable/disable dedicated queues for LACP control traffic for port_id",
4928 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4929 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4930 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4931 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4932 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4933 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4938 /* *** SET BALANCE XMIT POLICY *** */
4939 struct cmd_set_bonding_balance_xmit_policy_result {
4940 cmdline_fixed_string_t set;
4941 cmdline_fixed_string_t bonding;
4942 cmdline_fixed_string_t balance_xmit_policy;
4944 cmdline_fixed_string_t policy;
4947 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4948 __attribute__((unused)) struct cmdline *cl,
4949 __attribute__((unused)) void *data)
4951 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4952 portid_t port_id = res->port_id;
4955 if (!strcmp(res->policy, "l2")) {
4956 policy = BALANCE_XMIT_POLICY_LAYER2;
4957 } else if (!strcmp(res->policy, "l23")) {
4958 policy = BALANCE_XMIT_POLICY_LAYER23;
4959 } else if (!strcmp(res->policy, "l34")) {
4960 policy = BALANCE_XMIT_POLICY_LAYER34;
4962 printf("\t Invalid xmit policy selection");
4966 /* Set the bonding mode for the relevant port. */
4967 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4968 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4973 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4974 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4976 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4977 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4978 bonding, "bonding");
4979 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4980 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4981 balance_xmit_policy, "balance_xmit_policy");
4982 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4983 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4985 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4986 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4987 policy, "l2#l23#l34");
4989 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4990 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4991 .help_str = "set bonding balance_xmit_policy <port_id> "
4993 "Set the bonding balance_xmit_policy for port_id",
4996 (void *)&cmd_setbonding_balance_xmit_policy_set,
4997 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4998 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4999 (void *)&cmd_setbonding_balance_xmit_policy_port,
5000 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5005 /* *** SHOW NIC BONDING CONFIGURATION *** */
5006 struct cmd_show_bonding_config_result {
5007 cmdline_fixed_string_t show;
5008 cmdline_fixed_string_t bonding;
5009 cmdline_fixed_string_t config;
5013 static void cmd_show_bonding_config_parsed(void *parsed_result,
5014 __attribute__((unused)) struct cmdline *cl,
5015 __attribute__((unused)) void *data)
5017 struct cmd_show_bonding_config_result *res = parsed_result;
5018 int bonding_mode, agg_mode;
5019 portid_t slaves[RTE_MAX_ETHPORTS];
5020 int num_slaves, num_active_slaves;
5023 portid_t port_id = res->port_id;
5025 /* Display the bonding mode.*/
5026 bonding_mode = rte_eth_bond_mode_get(port_id);
5027 if (bonding_mode < 0) {
5028 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5031 printf("\tBonding mode: %d\n", bonding_mode);
5033 if (bonding_mode == BONDING_MODE_BALANCE) {
5034 int balance_xmit_policy;
5036 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5037 if (balance_xmit_policy < 0) {
5038 printf("\tFailed to get balance xmit policy for port = %d\n",
5042 printf("\tBalance Xmit Policy: ");
5044 switch (balance_xmit_policy) {
5045 case BALANCE_XMIT_POLICY_LAYER2:
5046 printf("BALANCE_XMIT_POLICY_LAYER2");
5048 case BALANCE_XMIT_POLICY_LAYER23:
5049 printf("BALANCE_XMIT_POLICY_LAYER23");
5051 case BALANCE_XMIT_POLICY_LAYER34:
5052 printf("BALANCE_XMIT_POLICY_LAYER34");
5059 if (bonding_mode == BONDING_MODE_8023AD) {
5060 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5061 printf("\tIEEE802.3AD Aggregator Mode: ");
5064 printf("bandwidth");
5076 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5078 if (num_slaves < 0) {
5079 printf("\tFailed to get slave list for port = %d\n", port_id);
5082 if (num_slaves > 0) {
5083 printf("\tSlaves (%d): [", num_slaves);
5084 for (i = 0; i < num_slaves - 1; i++)
5085 printf("%d ", slaves[i]);
5087 printf("%d]\n", slaves[num_slaves - 1]);
5089 printf("\tSlaves: []\n");
5093 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5096 if (num_active_slaves < 0) {
5097 printf("\tFailed to get active slave list for port = %d\n", port_id);
5100 if (num_active_slaves > 0) {
5101 printf("\tActive Slaves (%d): [", num_active_slaves);
5102 for (i = 0; i < num_active_slaves - 1; i++)
5103 printf("%d ", slaves[i]);
5105 printf("%d]\n", slaves[num_active_slaves - 1]);
5108 printf("\tActive Slaves: []\n");
5112 primary_id = rte_eth_bond_primary_get(port_id);
5113 if (primary_id < 0) {
5114 printf("\tFailed to get primary slave for port = %d\n", port_id);
5117 printf("\tPrimary: [%d]\n", primary_id);
5121 cmdline_parse_token_string_t cmd_showbonding_config_show =
5122 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5124 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5125 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5126 bonding, "bonding");
5127 cmdline_parse_token_string_t cmd_showbonding_config_config =
5128 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5130 cmdline_parse_token_num_t cmd_showbonding_config_port =
5131 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5134 cmdline_parse_inst_t cmd_show_bonding_config = {
5135 .f = cmd_show_bonding_config_parsed,
5136 .help_str = "show bonding config <port_id>: "
5137 "Show the bonding config for port_id",
5140 (void *)&cmd_showbonding_config_show,
5141 (void *)&cmd_showbonding_config_bonding,
5142 (void *)&cmd_showbonding_config_config,
5143 (void *)&cmd_showbonding_config_port,
5148 /* *** SET BONDING PRIMARY *** */
5149 struct cmd_set_bonding_primary_result {
5150 cmdline_fixed_string_t set;
5151 cmdline_fixed_string_t bonding;
5152 cmdline_fixed_string_t primary;
5157 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5158 __attribute__((unused)) struct cmdline *cl,
5159 __attribute__((unused)) void *data)
5161 struct cmd_set_bonding_primary_result *res = parsed_result;
5162 portid_t master_port_id = res->port_id;
5163 portid_t slave_port_id = res->slave_id;
5165 /* Set the primary slave for a bonded device. */
5166 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5167 printf("\t Failed to set primary slave for port = %d.\n",
5174 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5175 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5177 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5178 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5179 bonding, "bonding");
5180 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5181 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5182 primary, "primary");
5183 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5184 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5186 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5187 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5190 cmdline_parse_inst_t cmd_set_bonding_primary = {
5191 .f = cmd_set_bonding_primary_parsed,
5192 .help_str = "set bonding primary <slave_id> <port_id>: "
5193 "Set the primary slave for port_id",
5196 (void *)&cmd_setbonding_primary_set,
5197 (void *)&cmd_setbonding_primary_bonding,
5198 (void *)&cmd_setbonding_primary_primary,
5199 (void *)&cmd_setbonding_primary_slave,
5200 (void *)&cmd_setbonding_primary_port,
5205 /* *** ADD SLAVE *** */
5206 struct cmd_add_bonding_slave_result {
5207 cmdline_fixed_string_t add;
5208 cmdline_fixed_string_t bonding;
5209 cmdline_fixed_string_t slave;
5214 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5215 __attribute__((unused)) struct cmdline *cl,
5216 __attribute__((unused)) void *data)
5218 struct cmd_add_bonding_slave_result *res = parsed_result;
5219 portid_t master_port_id = res->port_id;
5220 portid_t slave_port_id = res->slave_id;
5222 /* add the slave for a bonded device. */
5223 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5224 printf("\t Failed to add slave %d to master port = %d.\n",
5225 slave_port_id, master_port_id);
5229 set_port_slave_flag(slave_port_id);
5232 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5233 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5235 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5236 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5237 bonding, "bonding");
5238 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5239 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5241 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5242 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5244 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5245 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5248 cmdline_parse_inst_t cmd_add_bonding_slave = {
5249 .f = cmd_add_bonding_slave_parsed,
5250 .help_str = "add bonding slave <slave_id> <port_id>: "
5251 "Add a slave device to a bonded device",
5254 (void *)&cmd_addbonding_slave_add,
5255 (void *)&cmd_addbonding_slave_bonding,
5256 (void *)&cmd_addbonding_slave_slave,
5257 (void *)&cmd_addbonding_slave_slaveid,
5258 (void *)&cmd_addbonding_slave_port,
5263 /* *** REMOVE SLAVE *** */
5264 struct cmd_remove_bonding_slave_result {
5265 cmdline_fixed_string_t remove;
5266 cmdline_fixed_string_t bonding;
5267 cmdline_fixed_string_t slave;
5272 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5273 __attribute__((unused)) struct cmdline *cl,
5274 __attribute__((unused)) void *data)
5276 struct cmd_remove_bonding_slave_result *res = parsed_result;
5277 portid_t master_port_id = res->port_id;
5278 portid_t slave_port_id = res->slave_id;
5280 /* remove the slave from a bonded device. */
5281 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5282 printf("\t Failed to remove slave %d from master port = %d.\n",
5283 slave_port_id, master_port_id);
5287 clear_port_slave_flag(slave_port_id);
5290 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5291 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5293 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5294 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5295 bonding, "bonding");
5296 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5297 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5299 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5300 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5302 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5303 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5306 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5307 .f = cmd_remove_bonding_slave_parsed,
5308 .help_str = "remove bonding slave <slave_id> <port_id>: "
5309 "Remove a slave device from a bonded device",
5312 (void *)&cmd_removebonding_slave_remove,
5313 (void *)&cmd_removebonding_slave_bonding,
5314 (void *)&cmd_removebonding_slave_slave,
5315 (void *)&cmd_removebonding_slave_slaveid,
5316 (void *)&cmd_removebonding_slave_port,
5321 /* *** CREATE BONDED DEVICE *** */
5322 struct cmd_create_bonded_device_result {
5323 cmdline_fixed_string_t create;
5324 cmdline_fixed_string_t bonded;
5325 cmdline_fixed_string_t device;
5330 static int bond_dev_num = 0;
5332 static void cmd_create_bonded_device_parsed(void *parsed_result,
5333 __attribute__((unused)) struct cmdline *cl,
5334 __attribute__((unused)) void *data)
5336 struct cmd_create_bonded_device_result *res = parsed_result;
5337 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5340 if (test_done == 0) {
5341 printf("Please stop forwarding first\n");
5345 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5348 /* Create a new bonded device. */
5349 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5351 printf("\t Failed to create bonded device.\n");
5354 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5357 /* Update number of ports */
5358 nb_ports = rte_eth_dev_count();
5359 reconfig(port_id, res->socket);
5360 rte_eth_promiscuous_enable(port_id);
5365 cmdline_parse_token_string_t cmd_createbonded_device_create =
5366 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5368 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5369 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5371 cmdline_parse_token_string_t cmd_createbonded_device_device =
5372 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5374 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5375 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5377 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5378 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5381 cmdline_parse_inst_t cmd_create_bonded_device = {
5382 .f = cmd_create_bonded_device_parsed,
5383 .help_str = "create bonded device <mode> <socket>: "
5384 "Create a new bonded device with specific bonding mode and socket",
5387 (void *)&cmd_createbonded_device_create,
5388 (void *)&cmd_createbonded_device_bonded,
5389 (void *)&cmd_createbonded_device_device,
5390 (void *)&cmd_createbonded_device_mode,
5391 (void *)&cmd_createbonded_device_socket,
5396 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5397 struct cmd_set_bond_mac_addr_result {
5398 cmdline_fixed_string_t set;
5399 cmdline_fixed_string_t bonding;
5400 cmdline_fixed_string_t mac_addr;
5402 struct ether_addr address;
5405 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5406 __attribute__((unused)) struct cmdline *cl,
5407 __attribute__((unused)) void *data)
5409 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5412 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5415 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5417 /* check the return value and print it if is < 0 */
5419 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5422 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5423 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5424 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5425 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5427 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5428 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5430 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5431 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5433 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5434 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5436 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5437 .f = cmd_set_bond_mac_addr_parsed,
5439 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5441 (void *)&cmd_set_bond_mac_addr_set,
5442 (void *)&cmd_set_bond_mac_addr_bonding,
5443 (void *)&cmd_set_bond_mac_addr_mac,
5444 (void *)&cmd_set_bond_mac_addr_portnum,
5445 (void *)&cmd_set_bond_mac_addr_addr,
5451 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5452 struct cmd_set_bond_mon_period_result {
5453 cmdline_fixed_string_t set;
5454 cmdline_fixed_string_t bonding;
5455 cmdline_fixed_string_t mon_period;
5460 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5461 __attribute__((unused)) struct cmdline *cl,
5462 __attribute__((unused)) void *data)
5464 struct cmd_set_bond_mon_period_result *res = parsed_result;
5467 if (res->port_num >= nb_ports) {
5468 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5472 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5474 /* check the return value and print it if is < 0 */
5476 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5479 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5480 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5482 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5483 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5484 bonding, "bonding");
5485 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5486 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5487 mon_period, "mon_period");
5488 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5489 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5491 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5492 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5495 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5496 .f = cmd_set_bond_mon_period_parsed,
5498 .help_str = "set bonding mon_period <port_id> <period_ms>",
5500 (void *)&cmd_set_bond_mon_period_set,
5501 (void *)&cmd_set_bond_mon_period_bonding,
5502 (void *)&cmd_set_bond_mon_period_mon_period,
5503 (void *)&cmd_set_bond_mon_period_portnum,
5504 (void *)&cmd_set_bond_mon_period_period_ms,
5511 struct cmd_set_bonding_agg_mode_policy_result {
5512 cmdline_fixed_string_t set;
5513 cmdline_fixed_string_t bonding;
5514 cmdline_fixed_string_t agg_mode;
5516 cmdline_fixed_string_t policy;
5521 cmd_set_bonding_agg_mode(void *parsed_result,
5522 __attribute__((unused)) struct cmdline *cl,
5523 __attribute__((unused)) void *data)
5525 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5526 uint8_t policy = AGG_BANDWIDTH;
5528 if (res->port_num >= nb_ports) {
5529 printf("Port id %d must be less than %d\n",
5530 res->port_num, nb_ports);
5534 if (!strcmp(res->policy, "bandwidth"))
5535 policy = AGG_BANDWIDTH;
5536 else if (!strcmp(res->policy, "stable"))
5537 policy = AGG_STABLE;
5538 else if (!strcmp(res->policy, "count"))
5541 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5545 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5546 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5548 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5549 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5550 bonding, "bonding");
5552 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5553 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5554 agg_mode, "agg_mode");
5556 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5557 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5560 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5561 TOKEN_STRING_INITIALIZER(
5562 struct cmd_set_bonding_balance_xmit_policy_result,
5563 policy, "stable#bandwidth#count");
5565 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5566 .f = cmd_set_bonding_agg_mode,
5568 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5570 (void *)&cmd_set_bonding_agg_mode_set,
5571 (void *)&cmd_set_bonding_agg_mode_bonding,
5572 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5573 (void *)&cmd_set_bonding_agg_mode_portnum,
5574 (void *)&cmd_set_bonding_agg_mode_policy_string,
5580 #endif /* RTE_LIBRTE_PMD_BOND */
5582 /* *** SET FORWARDING MODE *** */
5583 struct cmd_set_fwd_mode_result {
5584 cmdline_fixed_string_t set;
5585 cmdline_fixed_string_t fwd;
5586 cmdline_fixed_string_t mode;
5589 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5590 __attribute__((unused)) struct cmdline *cl,
5591 __attribute__((unused)) void *data)
5593 struct cmd_set_fwd_mode_result *res = parsed_result;
5596 set_pkt_forwarding_mode(res->mode);
5599 cmdline_parse_token_string_t cmd_setfwd_set =
5600 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5601 cmdline_parse_token_string_t cmd_setfwd_fwd =
5602 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5603 cmdline_parse_token_string_t cmd_setfwd_mode =
5604 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5605 "" /* defined at init */);
5607 cmdline_parse_inst_t cmd_set_fwd_mode = {
5608 .f = cmd_set_fwd_mode_parsed,
5610 .help_str = NULL, /* defined at init */
5612 (void *)&cmd_setfwd_set,
5613 (void *)&cmd_setfwd_fwd,
5614 (void *)&cmd_setfwd_mode,
5619 static void cmd_set_fwd_mode_init(void)
5622 static char token[128];
5623 static char help[256];
5624 cmdline_parse_token_string_t *token_struct;
5626 modes = list_pkt_forwarding_modes();
5627 snprintf(help, sizeof(help), "set fwd %s: "
5628 "Set packet forwarding mode", modes);
5629 cmd_set_fwd_mode.help_str = help;
5631 /* string token separator is # */
5632 for (c = token; *modes != '\0'; modes++)
5637 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5638 token_struct->string_data.str = token;
5641 /* *** SET RETRY FORWARDING MODE *** */
5642 struct cmd_set_fwd_retry_mode_result {
5643 cmdline_fixed_string_t set;
5644 cmdline_fixed_string_t fwd;
5645 cmdline_fixed_string_t mode;
5646 cmdline_fixed_string_t retry;
5649 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5650 __attribute__((unused)) struct cmdline *cl,
5651 __attribute__((unused)) void *data)
5653 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5656 set_pkt_forwarding_mode(res->mode);
5659 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5660 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5662 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5663 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5665 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5666 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5668 "" /* defined at init */);
5669 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5670 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5673 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5674 .f = cmd_set_fwd_retry_mode_parsed,
5676 .help_str = NULL, /* defined at init */
5678 (void *)&cmd_setfwd_retry_set,
5679 (void *)&cmd_setfwd_retry_fwd,
5680 (void *)&cmd_setfwd_retry_mode,
5681 (void *)&cmd_setfwd_retry_retry,
5686 static void cmd_set_fwd_retry_mode_init(void)
5689 static char token[128];
5690 static char help[256];
5691 cmdline_parse_token_string_t *token_struct;
5693 modes = list_pkt_forwarding_retry_modes();
5694 snprintf(help, sizeof(help), "set fwd %s retry: "
5695 "Set packet forwarding mode with retry", modes);
5696 cmd_set_fwd_retry_mode.help_str = help;
5698 /* string token separator is # */
5699 for (c = token; *modes != '\0'; modes++)
5704 token_struct = (cmdline_parse_token_string_t *)
5705 cmd_set_fwd_retry_mode.tokens[2];
5706 token_struct->string_data.str = token;
5709 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5710 struct cmd_set_burst_tx_retry_result {
5711 cmdline_fixed_string_t set;
5712 cmdline_fixed_string_t burst;
5713 cmdline_fixed_string_t tx;
5714 cmdline_fixed_string_t delay;
5716 cmdline_fixed_string_t retry;
5720 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5721 __attribute__((unused)) struct cmdline *cl,
5722 __attribute__((unused)) void *data)
5724 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5726 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5727 && !strcmp(res->tx, "tx")) {
5728 if (!strcmp(res->delay, "delay"))
5729 burst_tx_delay_time = res->time;
5730 if (!strcmp(res->retry, "retry"))
5731 burst_tx_retry_num = res->retry_num;
5736 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5737 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5738 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5739 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5741 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5742 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5743 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5744 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5745 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5746 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5747 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5748 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5749 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5750 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5752 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5753 .f = cmd_set_burst_tx_retry_parsed,
5754 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5756 (void *)&cmd_set_burst_tx_retry_set,
5757 (void *)&cmd_set_burst_tx_retry_burst,
5758 (void *)&cmd_set_burst_tx_retry_tx,
5759 (void *)&cmd_set_burst_tx_retry_delay,
5760 (void *)&cmd_set_burst_tx_retry_time,
5761 (void *)&cmd_set_burst_tx_retry_retry,
5762 (void *)&cmd_set_burst_tx_retry_retry_num,
5767 /* *** SET PROMISC MODE *** */
5768 struct cmd_set_promisc_mode_result {
5769 cmdline_fixed_string_t set;
5770 cmdline_fixed_string_t promisc;
5771 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5772 uint16_t port_num; /* valid if "allports" argument == 0 */
5773 cmdline_fixed_string_t mode;
5776 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5777 __attribute__((unused)) struct cmdline *cl,
5780 struct cmd_set_promisc_mode_result *res = parsed_result;
5784 if (!strcmp(res->mode, "on"))
5791 RTE_ETH_FOREACH_DEV(i) {
5793 rte_eth_promiscuous_enable(i);
5795 rte_eth_promiscuous_disable(i);
5800 rte_eth_promiscuous_enable(res->port_num);
5802 rte_eth_promiscuous_disable(res->port_num);
5806 cmdline_parse_token_string_t cmd_setpromisc_set =
5807 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5808 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5809 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5811 cmdline_parse_token_string_t cmd_setpromisc_portall =
5812 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5814 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5815 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5817 cmdline_parse_token_string_t cmd_setpromisc_mode =
5818 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5821 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5822 .f = cmd_set_promisc_mode_parsed,
5824 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5826 (void *)&cmd_setpromisc_set,
5827 (void *)&cmd_setpromisc_promisc,
5828 (void *)&cmd_setpromisc_portall,
5829 (void *)&cmd_setpromisc_mode,
5834 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5835 .f = cmd_set_promisc_mode_parsed,
5837 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5839 (void *)&cmd_setpromisc_set,
5840 (void *)&cmd_setpromisc_promisc,
5841 (void *)&cmd_setpromisc_portnum,
5842 (void *)&cmd_setpromisc_mode,
5847 /* *** SET ALLMULTI MODE *** */
5848 struct cmd_set_allmulti_mode_result {
5849 cmdline_fixed_string_t set;
5850 cmdline_fixed_string_t allmulti;
5851 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5852 uint16_t port_num; /* valid if "allports" argument == 0 */
5853 cmdline_fixed_string_t mode;
5856 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5857 __attribute__((unused)) struct cmdline *cl,
5860 struct cmd_set_allmulti_mode_result *res = parsed_result;
5864 if (!strcmp(res->mode, "on"))
5871 RTE_ETH_FOREACH_DEV(i) {
5873 rte_eth_allmulticast_enable(i);
5875 rte_eth_allmulticast_disable(i);
5880 rte_eth_allmulticast_enable(res->port_num);
5882 rte_eth_allmulticast_disable(res->port_num);
5886 cmdline_parse_token_string_t cmd_setallmulti_set =
5887 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5888 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5889 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5891 cmdline_parse_token_string_t cmd_setallmulti_portall =
5892 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5894 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5895 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5897 cmdline_parse_token_string_t cmd_setallmulti_mode =
5898 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5901 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5902 .f = cmd_set_allmulti_mode_parsed,
5904 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5906 (void *)&cmd_setallmulti_set,
5907 (void *)&cmd_setallmulti_allmulti,
5908 (void *)&cmd_setallmulti_portall,
5909 (void *)&cmd_setallmulti_mode,
5914 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5915 .f = cmd_set_allmulti_mode_parsed,
5917 .help_str = "set allmulti <port_id> on|off: "
5918 "Set allmulti mode on port_id",
5920 (void *)&cmd_setallmulti_set,
5921 (void *)&cmd_setallmulti_allmulti,
5922 (void *)&cmd_setallmulti_portnum,
5923 (void *)&cmd_setallmulti_mode,
5928 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5929 struct cmd_link_flow_ctrl_set_result {
5930 cmdline_fixed_string_t set;
5931 cmdline_fixed_string_t flow_ctrl;
5932 cmdline_fixed_string_t rx;
5933 cmdline_fixed_string_t rx_lfc_mode;
5934 cmdline_fixed_string_t tx;
5935 cmdline_fixed_string_t tx_lfc_mode;
5936 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5937 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5938 cmdline_fixed_string_t autoneg_str;
5939 cmdline_fixed_string_t autoneg;
5940 cmdline_fixed_string_t hw_str;
5941 uint32_t high_water;
5942 cmdline_fixed_string_t lw_str;
5944 cmdline_fixed_string_t pt_str;
5945 uint16_t pause_time;
5946 cmdline_fixed_string_t xon_str;
5951 cmdline_parse_token_string_t cmd_lfc_set_set =
5952 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5954 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5955 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5956 flow_ctrl, "flow_ctrl");
5957 cmdline_parse_token_string_t cmd_lfc_set_rx =
5958 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5960 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5961 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5962 rx_lfc_mode, "on#off");
5963 cmdline_parse_token_string_t cmd_lfc_set_tx =
5964 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5966 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5967 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5968 tx_lfc_mode, "on#off");
5969 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5970 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5971 hw_str, "high_water");
5972 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5973 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5974 high_water, UINT32);
5975 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5976 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5977 lw_str, "low_water");
5978 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5979 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5981 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5982 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5983 pt_str, "pause_time");
5984 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5985 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5986 pause_time, UINT16);
5987 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5988 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5989 xon_str, "send_xon");
5990 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5991 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5993 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5994 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5995 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5996 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5997 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5998 mac_ctrl_frame_fwd_mode, "on#off");
5999 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6000 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6001 autoneg_str, "autoneg");
6002 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6003 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6005 cmdline_parse_token_num_t cmd_lfc_set_portid =
6006 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6009 /* forward declaration */
6011 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6014 cmdline_parse_inst_t cmd_link_flow_control_set = {
6015 .f = cmd_link_flow_ctrl_set_parsed,
6017 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6018 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6019 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6021 (void *)&cmd_lfc_set_set,
6022 (void *)&cmd_lfc_set_flow_ctrl,
6023 (void *)&cmd_lfc_set_rx,
6024 (void *)&cmd_lfc_set_rx_mode,
6025 (void *)&cmd_lfc_set_tx,
6026 (void *)&cmd_lfc_set_tx_mode,
6027 (void *)&cmd_lfc_set_high_water,
6028 (void *)&cmd_lfc_set_low_water,
6029 (void *)&cmd_lfc_set_pause_time,
6030 (void *)&cmd_lfc_set_send_xon,
6031 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6032 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6033 (void *)&cmd_lfc_set_autoneg_str,
6034 (void *)&cmd_lfc_set_autoneg,
6035 (void *)&cmd_lfc_set_portid,
6040 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6041 .f = cmd_link_flow_ctrl_set_parsed,
6042 .data = (void *)&cmd_link_flow_control_set_rx,
6043 .help_str = "set flow_ctrl rx on|off <port_id>: "
6044 "Change rx flow control parameter",
6046 (void *)&cmd_lfc_set_set,
6047 (void *)&cmd_lfc_set_flow_ctrl,
6048 (void *)&cmd_lfc_set_rx,
6049 (void *)&cmd_lfc_set_rx_mode,
6050 (void *)&cmd_lfc_set_portid,
6055 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6056 .f = cmd_link_flow_ctrl_set_parsed,
6057 .data = (void *)&cmd_link_flow_control_set_tx,
6058 .help_str = "set flow_ctrl tx on|off <port_id>: "
6059 "Change tx flow control parameter",
6061 (void *)&cmd_lfc_set_set,
6062 (void *)&cmd_lfc_set_flow_ctrl,
6063 (void *)&cmd_lfc_set_tx,
6064 (void *)&cmd_lfc_set_tx_mode,
6065 (void *)&cmd_lfc_set_portid,
6070 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6071 .f = cmd_link_flow_ctrl_set_parsed,
6072 .data = (void *)&cmd_link_flow_control_set_hw,
6073 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6074 "Change high water flow control parameter",
6076 (void *)&cmd_lfc_set_set,
6077 (void *)&cmd_lfc_set_flow_ctrl,
6078 (void *)&cmd_lfc_set_high_water_str,
6079 (void *)&cmd_lfc_set_high_water,
6080 (void *)&cmd_lfc_set_portid,
6085 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6086 .f = cmd_link_flow_ctrl_set_parsed,
6087 .data = (void *)&cmd_link_flow_control_set_lw,
6088 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6089 "Change low water flow control parameter",
6091 (void *)&cmd_lfc_set_set,
6092 (void *)&cmd_lfc_set_flow_ctrl,
6093 (void *)&cmd_lfc_set_low_water_str,
6094 (void *)&cmd_lfc_set_low_water,
6095 (void *)&cmd_lfc_set_portid,
6100 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6101 .f = cmd_link_flow_ctrl_set_parsed,
6102 .data = (void *)&cmd_link_flow_control_set_pt,
6103 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6104 "Change pause time flow control parameter",
6106 (void *)&cmd_lfc_set_set,
6107 (void *)&cmd_lfc_set_flow_ctrl,
6108 (void *)&cmd_lfc_set_pause_time_str,
6109 (void *)&cmd_lfc_set_pause_time,
6110 (void *)&cmd_lfc_set_portid,
6115 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6116 .f = cmd_link_flow_ctrl_set_parsed,
6117 .data = (void *)&cmd_link_flow_control_set_xon,
6118 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6119 "Change send_xon flow control parameter",
6121 (void *)&cmd_lfc_set_set,
6122 (void *)&cmd_lfc_set_flow_ctrl,
6123 (void *)&cmd_lfc_set_send_xon_str,
6124 (void *)&cmd_lfc_set_send_xon,
6125 (void *)&cmd_lfc_set_portid,
6130 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6131 .f = cmd_link_flow_ctrl_set_parsed,
6132 .data = (void *)&cmd_link_flow_control_set_macfwd,
6133 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6134 "Change mac ctrl fwd flow control parameter",
6136 (void *)&cmd_lfc_set_set,
6137 (void *)&cmd_lfc_set_flow_ctrl,
6138 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6139 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6140 (void *)&cmd_lfc_set_portid,
6145 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6146 .f = cmd_link_flow_ctrl_set_parsed,
6147 .data = (void *)&cmd_link_flow_control_set_autoneg,
6148 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6149 "Change autoneg flow control parameter",
6151 (void *)&cmd_lfc_set_set,
6152 (void *)&cmd_lfc_set_flow_ctrl,
6153 (void *)&cmd_lfc_set_autoneg_str,
6154 (void *)&cmd_lfc_set_autoneg,
6155 (void *)&cmd_lfc_set_portid,
6161 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6162 __attribute__((unused)) struct cmdline *cl,
6165 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6166 cmdline_parse_inst_t *cmd = data;
6167 struct rte_eth_fc_conf fc_conf;
6173 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6174 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6175 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6176 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6178 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6179 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6182 /* Partial command line, retrieve current configuration */
6184 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6186 printf("cannot get current flow ctrl parameters, return"
6187 "code = %d\n", ret);
6191 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6192 (fc_conf.mode == RTE_FC_FULL))
6194 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6195 (fc_conf.mode == RTE_FC_FULL))
6199 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6200 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6202 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6203 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6205 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6207 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6208 fc_conf.high_water = res->high_water;
6210 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6211 fc_conf.low_water = res->low_water;
6213 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6214 fc_conf.pause_time = res->pause_time;
6216 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6217 fc_conf.send_xon = res->send_xon;
6219 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6220 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6221 fc_conf.mac_ctrl_frame_fwd = 1;
6223 fc_conf.mac_ctrl_frame_fwd = 0;
6226 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6227 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6229 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6231 printf("bad flow contrl parameter, return code = %d \n", ret);
6234 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6235 struct cmd_priority_flow_ctrl_set_result {
6236 cmdline_fixed_string_t set;
6237 cmdline_fixed_string_t pfc_ctrl;
6238 cmdline_fixed_string_t rx;
6239 cmdline_fixed_string_t rx_pfc_mode;
6240 cmdline_fixed_string_t tx;
6241 cmdline_fixed_string_t tx_pfc_mode;
6242 uint32_t high_water;
6244 uint16_t pause_time;
6250 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6251 __attribute__((unused)) struct cmdline *cl,
6252 __attribute__((unused)) void *data)
6254 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6255 struct rte_eth_pfc_conf pfc_conf;
6256 int rx_fc_enable, tx_fc_enable;
6260 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6261 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6262 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6263 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6265 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6266 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6269 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6270 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6271 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6272 pfc_conf.fc.high_water = res->high_water;
6273 pfc_conf.fc.low_water = res->low_water;
6274 pfc_conf.fc.pause_time = res->pause_time;
6275 pfc_conf.priority = res->priority;
6277 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6279 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6282 cmdline_parse_token_string_t cmd_pfc_set_set =
6283 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6285 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6286 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6287 pfc_ctrl, "pfc_ctrl");
6288 cmdline_parse_token_string_t cmd_pfc_set_rx =
6289 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6291 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6292 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6293 rx_pfc_mode, "on#off");
6294 cmdline_parse_token_string_t cmd_pfc_set_tx =
6295 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6297 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6298 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6299 tx_pfc_mode, "on#off");
6300 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6301 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6302 high_water, UINT32);
6303 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6304 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6306 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6307 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6308 pause_time, UINT16);
6309 cmdline_parse_token_num_t cmd_pfc_set_priority =
6310 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6312 cmdline_parse_token_num_t cmd_pfc_set_portid =
6313 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6316 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6317 .f = cmd_priority_flow_ctrl_set_parsed,
6319 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6320 "<pause_time> <priority> <port_id>: "
6321 "Configure the Ethernet priority flow control",
6323 (void *)&cmd_pfc_set_set,
6324 (void *)&cmd_pfc_set_flow_ctrl,
6325 (void *)&cmd_pfc_set_rx,
6326 (void *)&cmd_pfc_set_rx_mode,
6327 (void *)&cmd_pfc_set_tx,
6328 (void *)&cmd_pfc_set_tx_mode,
6329 (void *)&cmd_pfc_set_high_water,
6330 (void *)&cmd_pfc_set_low_water,
6331 (void *)&cmd_pfc_set_pause_time,
6332 (void *)&cmd_pfc_set_priority,
6333 (void *)&cmd_pfc_set_portid,
6338 /* *** RESET CONFIGURATION *** */
6339 struct cmd_reset_result {
6340 cmdline_fixed_string_t reset;
6341 cmdline_fixed_string_t def;
6344 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6346 __attribute__((unused)) void *data)
6348 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6349 set_def_fwd_config();
6352 cmdline_parse_token_string_t cmd_reset_set =
6353 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6354 cmdline_parse_token_string_t cmd_reset_def =
6355 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6358 cmdline_parse_inst_t cmd_reset = {
6359 .f = cmd_reset_parsed,
6361 .help_str = "set default: Reset default forwarding configuration",
6363 (void *)&cmd_reset_set,
6364 (void *)&cmd_reset_def,
6369 /* *** START FORWARDING *** */
6370 struct cmd_start_result {
6371 cmdline_fixed_string_t start;
6374 cmdline_parse_token_string_t cmd_start_start =
6375 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6377 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6378 __attribute__((unused)) struct cmdline *cl,
6379 __attribute__((unused)) void *data)
6381 start_packet_forwarding(0);
6384 cmdline_parse_inst_t cmd_start = {
6385 .f = cmd_start_parsed,
6387 .help_str = "start: Start packet forwarding",
6389 (void *)&cmd_start_start,
6394 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6395 struct cmd_start_tx_first_result {
6396 cmdline_fixed_string_t start;
6397 cmdline_fixed_string_t tx_first;
6401 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6402 __attribute__((unused)) struct cmdline *cl,
6403 __attribute__((unused)) void *data)
6405 start_packet_forwarding(1);
6408 cmdline_parse_token_string_t cmd_start_tx_first_start =
6409 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6411 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6412 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6413 tx_first, "tx_first");
6415 cmdline_parse_inst_t cmd_start_tx_first = {
6416 .f = cmd_start_tx_first_parsed,
6418 .help_str = "start tx_first: Start packet forwarding, "
6419 "after sending 1 burst of packets",
6421 (void *)&cmd_start_tx_first_start,
6422 (void *)&cmd_start_tx_first_tx_first,
6427 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6428 struct cmd_start_tx_first_n_result {
6429 cmdline_fixed_string_t start;
6430 cmdline_fixed_string_t tx_first;
6435 cmd_start_tx_first_n_parsed(void *parsed_result,
6436 __attribute__((unused)) struct cmdline *cl,
6437 __attribute__((unused)) void *data)
6439 struct cmd_start_tx_first_n_result *res = parsed_result;
6441 start_packet_forwarding(res->tx_num);
6444 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6445 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6447 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6448 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6449 tx_first, "tx_first");
6450 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6451 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6454 cmdline_parse_inst_t cmd_start_tx_first_n = {
6455 .f = cmd_start_tx_first_n_parsed,
6457 .help_str = "start tx_first <num>: "
6458 "packet forwarding, after sending <num> bursts of packets",
6460 (void *)&cmd_start_tx_first_n_start,
6461 (void *)&cmd_start_tx_first_n_tx_first,
6462 (void *)&cmd_start_tx_first_n_tx_num,
6467 /* *** SET LINK UP *** */
6468 struct cmd_set_link_up_result {
6469 cmdline_fixed_string_t set;
6470 cmdline_fixed_string_t link_up;
6471 cmdline_fixed_string_t port;
6475 cmdline_parse_token_string_t cmd_set_link_up_set =
6476 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6477 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6478 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6480 cmdline_parse_token_string_t cmd_set_link_up_port =
6481 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6482 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6483 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6485 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6486 __attribute__((unused)) struct cmdline *cl,
6487 __attribute__((unused)) void *data)
6489 struct cmd_set_link_up_result *res = parsed_result;
6490 dev_set_link_up(res->port_id);
6493 cmdline_parse_inst_t cmd_set_link_up = {
6494 .f = cmd_set_link_up_parsed,
6496 .help_str = "set link-up port <port id>",
6498 (void *)&cmd_set_link_up_set,
6499 (void *)&cmd_set_link_up_link_up,
6500 (void *)&cmd_set_link_up_port,
6501 (void *)&cmd_set_link_up_port_id,
6506 /* *** SET LINK DOWN *** */
6507 struct cmd_set_link_down_result {
6508 cmdline_fixed_string_t set;
6509 cmdline_fixed_string_t link_down;
6510 cmdline_fixed_string_t port;
6514 cmdline_parse_token_string_t cmd_set_link_down_set =
6515 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6516 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6517 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6519 cmdline_parse_token_string_t cmd_set_link_down_port =
6520 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6521 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6522 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6524 static void cmd_set_link_down_parsed(
6525 __attribute__((unused)) void *parsed_result,
6526 __attribute__((unused)) struct cmdline *cl,
6527 __attribute__((unused)) void *data)
6529 struct cmd_set_link_down_result *res = parsed_result;
6530 dev_set_link_down(res->port_id);
6533 cmdline_parse_inst_t cmd_set_link_down = {
6534 .f = cmd_set_link_down_parsed,
6536 .help_str = "set link-down port <port id>",
6538 (void *)&cmd_set_link_down_set,
6539 (void *)&cmd_set_link_down_link_down,
6540 (void *)&cmd_set_link_down_port,
6541 (void *)&cmd_set_link_down_port_id,
6546 /* *** SHOW CFG *** */
6547 struct cmd_showcfg_result {
6548 cmdline_fixed_string_t show;
6549 cmdline_fixed_string_t cfg;
6550 cmdline_fixed_string_t what;
6553 static void cmd_showcfg_parsed(void *parsed_result,
6554 __attribute__((unused)) struct cmdline *cl,
6555 __attribute__((unused)) void *data)
6557 struct cmd_showcfg_result *res = parsed_result;
6558 if (!strcmp(res->what, "rxtx"))
6559 rxtx_config_display();
6560 else if (!strcmp(res->what, "cores"))
6561 fwd_lcores_config_display();
6562 else if (!strcmp(res->what, "fwd"))
6563 pkt_fwd_config_display(&cur_fwd_config);
6564 else if (!strcmp(res->what, "txpkts"))
6565 show_tx_pkt_segments();
6568 cmdline_parse_token_string_t cmd_showcfg_show =
6569 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6570 cmdline_parse_token_string_t cmd_showcfg_port =
6571 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6572 cmdline_parse_token_string_t cmd_showcfg_what =
6573 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6574 "rxtx#cores#fwd#txpkts");
6576 cmdline_parse_inst_t cmd_showcfg = {
6577 .f = cmd_showcfg_parsed,
6579 .help_str = "show config rxtx|cores|fwd|txpkts",
6581 (void *)&cmd_showcfg_show,
6582 (void *)&cmd_showcfg_port,
6583 (void *)&cmd_showcfg_what,
6588 /* *** SHOW ALL PORT INFO *** */
6589 struct cmd_showportall_result {
6590 cmdline_fixed_string_t show;
6591 cmdline_fixed_string_t port;
6592 cmdline_fixed_string_t what;
6593 cmdline_fixed_string_t all;
6596 static void cmd_showportall_parsed(void *parsed_result,
6597 __attribute__((unused)) struct cmdline *cl,
6598 __attribute__((unused)) void *data)
6602 struct cmd_showportall_result *res = parsed_result;
6603 if (!strcmp(res->show, "clear")) {
6604 if (!strcmp(res->what, "stats"))
6605 RTE_ETH_FOREACH_DEV(i)
6607 else if (!strcmp(res->what, "xstats"))
6608 RTE_ETH_FOREACH_DEV(i)
6609 nic_xstats_clear(i);
6610 } else if (!strcmp(res->what, "info"))
6611 RTE_ETH_FOREACH_DEV(i)
6612 port_infos_display(i);
6613 else if (!strcmp(res->what, "stats"))
6614 RTE_ETH_FOREACH_DEV(i)
6615 nic_stats_display(i);
6616 else if (!strcmp(res->what, "xstats"))
6617 RTE_ETH_FOREACH_DEV(i)
6618 nic_xstats_display(i);
6619 else if (!strcmp(res->what, "fdir"))
6620 RTE_ETH_FOREACH_DEV(i)
6622 else if (!strcmp(res->what, "stat_qmap"))
6623 RTE_ETH_FOREACH_DEV(i)
6624 nic_stats_mapping_display(i);
6625 else if (!strcmp(res->what, "dcb_tc"))
6626 RTE_ETH_FOREACH_DEV(i)
6627 port_dcb_info_display(i);
6628 else if (!strcmp(res->what, "cap"))
6629 RTE_ETH_FOREACH_DEV(i)
6630 port_offload_cap_display(i);
6633 cmdline_parse_token_string_t cmd_showportall_show =
6634 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6636 cmdline_parse_token_string_t cmd_showportall_port =
6637 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6638 cmdline_parse_token_string_t cmd_showportall_what =
6639 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6640 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6641 cmdline_parse_token_string_t cmd_showportall_all =
6642 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6643 cmdline_parse_inst_t cmd_showportall = {
6644 .f = cmd_showportall_parsed,
6646 .help_str = "show|clear port "
6647 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6649 (void *)&cmd_showportall_show,
6650 (void *)&cmd_showportall_port,
6651 (void *)&cmd_showportall_what,
6652 (void *)&cmd_showportall_all,
6657 /* *** SHOW PORT INFO *** */
6658 struct cmd_showport_result {
6659 cmdline_fixed_string_t show;
6660 cmdline_fixed_string_t port;
6661 cmdline_fixed_string_t what;
6665 static void cmd_showport_parsed(void *parsed_result,
6666 __attribute__((unused)) struct cmdline *cl,
6667 __attribute__((unused)) void *data)
6669 struct cmd_showport_result *res = parsed_result;
6670 if (!strcmp(res->show, "clear")) {
6671 if (!strcmp(res->what, "stats"))
6672 nic_stats_clear(res->portnum);
6673 else if (!strcmp(res->what, "xstats"))
6674 nic_xstats_clear(res->portnum);
6675 } else if (!strcmp(res->what, "info"))
6676 port_infos_display(res->portnum);
6677 else if (!strcmp(res->what, "stats"))
6678 nic_stats_display(res->portnum);
6679 else if (!strcmp(res->what, "xstats"))
6680 nic_xstats_display(res->portnum);
6681 else if (!strcmp(res->what, "fdir"))
6682 fdir_get_infos(res->portnum);
6683 else if (!strcmp(res->what, "stat_qmap"))
6684 nic_stats_mapping_display(res->portnum);
6685 else if (!strcmp(res->what, "dcb_tc"))
6686 port_dcb_info_display(res->portnum);
6687 else if (!strcmp(res->what, "cap"))
6688 port_offload_cap_display(res->portnum);
6691 cmdline_parse_token_string_t cmd_showport_show =
6692 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6694 cmdline_parse_token_string_t cmd_showport_port =
6695 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6696 cmdline_parse_token_string_t cmd_showport_what =
6697 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6698 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6699 cmdline_parse_token_num_t cmd_showport_portnum =
6700 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6702 cmdline_parse_inst_t cmd_showport = {
6703 .f = cmd_showport_parsed,
6705 .help_str = "show|clear port "
6706 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6709 (void *)&cmd_showport_show,
6710 (void *)&cmd_showport_port,
6711 (void *)&cmd_showport_what,
6712 (void *)&cmd_showport_portnum,
6717 /* *** SHOW QUEUE INFO *** */
6718 struct cmd_showqueue_result {
6719 cmdline_fixed_string_t show;
6720 cmdline_fixed_string_t type;
6721 cmdline_fixed_string_t what;
6727 cmd_showqueue_parsed(void *parsed_result,
6728 __attribute__((unused)) struct cmdline *cl,
6729 __attribute__((unused)) void *data)
6731 struct cmd_showqueue_result *res = parsed_result;
6733 if (!strcmp(res->type, "rxq"))
6734 rx_queue_infos_display(res->portnum, res->queuenum);
6735 else if (!strcmp(res->type, "txq"))
6736 tx_queue_infos_display(res->portnum, res->queuenum);
6739 cmdline_parse_token_string_t cmd_showqueue_show =
6740 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6741 cmdline_parse_token_string_t cmd_showqueue_type =
6742 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6743 cmdline_parse_token_string_t cmd_showqueue_what =
6744 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6745 cmdline_parse_token_num_t cmd_showqueue_portnum =
6746 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6747 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6748 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6750 cmdline_parse_inst_t cmd_showqueue = {
6751 .f = cmd_showqueue_parsed,
6753 .help_str = "show rxq|txq info <port_id> <queue_id>",
6755 (void *)&cmd_showqueue_show,
6756 (void *)&cmd_showqueue_type,
6757 (void *)&cmd_showqueue_what,
6758 (void *)&cmd_showqueue_portnum,
6759 (void *)&cmd_showqueue_queuenum,
6764 /* *** READ PORT REGISTER *** */
6765 struct cmd_read_reg_result {
6766 cmdline_fixed_string_t read;
6767 cmdline_fixed_string_t reg;
6773 cmd_read_reg_parsed(void *parsed_result,
6774 __attribute__((unused)) struct cmdline *cl,
6775 __attribute__((unused)) void *data)
6777 struct cmd_read_reg_result *res = parsed_result;
6778 port_reg_display(res->port_id, res->reg_off);
6781 cmdline_parse_token_string_t cmd_read_reg_read =
6782 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6783 cmdline_parse_token_string_t cmd_read_reg_reg =
6784 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6785 cmdline_parse_token_num_t cmd_read_reg_port_id =
6786 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6787 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6788 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6790 cmdline_parse_inst_t cmd_read_reg = {
6791 .f = cmd_read_reg_parsed,
6793 .help_str = "read reg <port_id> <reg_off>",
6795 (void *)&cmd_read_reg_read,
6796 (void *)&cmd_read_reg_reg,
6797 (void *)&cmd_read_reg_port_id,
6798 (void *)&cmd_read_reg_reg_off,
6803 /* *** READ PORT REGISTER BIT FIELD *** */
6804 struct cmd_read_reg_bit_field_result {
6805 cmdline_fixed_string_t read;
6806 cmdline_fixed_string_t regfield;
6814 cmd_read_reg_bit_field_parsed(void *parsed_result,
6815 __attribute__((unused)) struct cmdline *cl,
6816 __attribute__((unused)) void *data)
6818 struct cmd_read_reg_bit_field_result *res = parsed_result;
6819 port_reg_bit_field_display(res->port_id, res->reg_off,
6820 res->bit1_pos, res->bit2_pos);
6823 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6824 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6826 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6827 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6828 regfield, "regfield");
6829 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6830 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6832 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6833 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6835 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6836 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6838 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6839 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6842 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6843 .f = cmd_read_reg_bit_field_parsed,
6845 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6846 "Read register bit field between bit_x and bit_y included",
6848 (void *)&cmd_read_reg_bit_field_read,
6849 (void *)&cmd_read_reg_bit_field_regfield,
6850 (void *)&cmd_read_reg_bit_field_port_id,
6851 (void *)&cmd_read_reg_bit_field_reg_off,
6852 (void *)&cmd_read_reg_bit_field_bit1_pos,
6853 (void *)&cmd_read_reg_bit_field_bit2_pos,
6858 /* *** READ PORT REGISTER BIT *** */
6859 struct cmd_read_reg_bit_result {
6860 cmdline_fixed_string_t read;
6861 cmdline_fixed_string_t regbit;
6868 cmd_read_reg_bit_parsed(void *parsed_result,
6869 __attribute__((unused)) struct cmdline *cl,
6870 __attribute__((unused)) void *data)
6872 struct cmd_read_reg_bit_result *res = parsed_result;
6873 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6876 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6877 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6878 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6879 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6881 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6882 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6883 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6884 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6885 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6886 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6888 cmdline_parse_inst_t cmd_read_reg_bit = {
6889 .f = cmd_read_reg_bit_parsed,
6891 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6893 (void *)&cmd_read_reg_bit_read,
6894 (void *)&cmd_read_reg_bit_regbit,
6895 (void *)&cmd_read_reg_bit_port_id,
6896 (void *)&cmd_read_reg_bit_reg_off,
6897 (void *)&cmd_read_reg_bit_bit_pos,
6902 /* *** WRITE PORT REGISTER *** */
6903 struct cmd_write_reg_result {
6904 cmdline_fixed_string_t write;
6905 cmdline_fixed_string_t reg;
6912 cmd_write_reg_parsed(void *parsed_result,
6913 __attribute__((unused)) struct cmdline *cl,
6914 __attribute__((unused)) void *data)
6916 struct cmd_write_reg_result *res = parsed_result;
6917 port_reg_set(res->port_id, res->reg_off, res->value);
6920 cmdline_parse_token_string_t cmd_write_reg_write =
6921 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6922 cmdline_parse_token_string_t cmd_write_reg_reg =
6923 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6924 cmdline_parse_token_num_t cmd_write_reg_port_id =
6925 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6926 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6927 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6928 cmdline_parse_token_num_t cmd_write_reg_value =
6929 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6931 cmdline_parse_inst_t cmd_write_reg = {
6932 .f = cmd_write_reg_parsed,
6934 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6936 (void *)&cmd_write_reg_write,
6937 (void *)&cmd_write_reg_reg,
6938 (void *)&cmd_write_reg_port_id,
6939 (void *)&cmd_write_reg_reg_off,
6940 (void *)&cmd_write_reg_value,
6945 /* *** WRITE PORT REGISTER BIT FIELD *** */
6946 struct cmd_write_reg_bit_field_result {
6947 cmdline_fixed_string_t write;
6948 cmdline_fixed_string_t regfield;
6957 cmd_write_reg_bit_field_parsed(void *parsed_result,
6958 __attribute__((unused)) struct cmdline *cl,
6959 __attribute__((unused)) void *data)
6961 struct cmd_write_reg_bit_field_result *res = parsed_result;
6962 port_reg_bit_field_set(res->port_id, res->reg_off,
6963 res->bit1_pos, res->bit2_pos, res->value);
6966 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6967 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6969 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6970 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6971 regfield, "regfield");
6972 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6973 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6975 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6976 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6978 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6979 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6981 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6982 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6984 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6985 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6988 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6989 .f = cmd_write_reg_bit_field_parsed,
6991 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6993 "Set register bit field between bit_x and bit_y included",
6995 (void *)&cmd_write_reg_bit_field_write,
6996 (void *)&cmd_write_reg_bit_field_regfield,
6997 (void *)&cmd_write_reg_bit_field_port_id,
6998 (void *)&cmd_write_reg_bit_field_reg_off,
6999 (void *)&cmd_write_reg_bit_field_bit1_pos,
7000 (void *)&cmd_write_reg_bit_field_bit2_pos,
7001 (void *)&cmd_write_reg_bit_field_value,
7006 /* *** WRITE PORT REGISTER BIT *** */
7007 struct cmd_write_reg_bit_result {
7008 cmdline_fixed_string_t write;
7009 cmdline_fixed_string_t regbit;
7017 cmd_write_reg_bit_parsed(void *parsed_result,
7018 __attribute__((unused)) struct cmdline *cl,
7019 __attribute__((unused)) void *data)
7021 struct cmd_write_reg_bit_result *res = parsed_result;
7022 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7025 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7026 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7028 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7029 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7031 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7032 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7033 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7034 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7035 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7036 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7037 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7038 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7040 cmdline_parse_inst_t cmd_write_reg_bit = {
7041 .f = cmd_write_reg_bit_parsed,
7043 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7046 (void *)&cmd_write_reg_bit_write,
7047 (void *)&cmd_write_reg_bit_regbit,
7048 (void *)&cmd_write_reg_bit_port_id,
7049 (void *)&cmd_write_reg_bit_reg_off,
7050 (void *)&cmd_write_reg_bit_bit_pos,
7051 (void *)&cmd_write_reg_bit_value,
7056 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7057 struct cmd_read_rxd_txd_result {
7058 cmdline_fixed_string_t read;
7059 cmdline_fixed_string_t rxd_txd;
7066 cmd_read_rxd_txd_parsed(void *parsed_result,
7067 __attribute__((unused)) struct cmdline *cl,
7068 __attribute__((unused)) void *data)
7070 struct cmd_read_rxd_txd_result *res = parsed_result;
7072 if (!strcmp(res->rxd_txd, "rxd"))
7073 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7074 else if (!strcmp(res->rxd_txd, "txd"))
7075 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7078 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7079 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7080 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7081 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7083 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7084 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7085 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7086 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7087 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7088 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7090 cmdline_parse_inst_t cmd_read_rxd_txd = {
7091 .f = cmd_read_rxd_txd_parsed,
7093 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7095 (void *)&cmd_read_rxd_txd_read,
7096 (void *)&cmd_read_rxd_txd_rxd_txd,
7097 (void *)&cmd_read_rxd_txd_port_id,
7098 (void *)&cmd_read_rxd_txd_queue_id,
7099 (void *)&cmd_read_rxd_txd_desc_id,
7105 struct cmd_quit_result {
7106 cmdline_fixed_string_t quit;
7109 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7111 __attribute__((unused)) void *data)
7117 cmdline_parse_token_string_t cmd_quit_quit =
7118 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7120 cmdline_parse_inst_t cmd_quit = {
7121 .f = cmd_quit_parsed,
7123 .help_str = "quit: Exit application",
7125 (void *)&cmd_quit_quit,
7130 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7131 struct cmd_mac_addr_result {
7132 cmdline_fixed_string_t mac_addr_cmd;
7133 cmdline_fixed_string_t what;
7135 struct ether_addr address;
7138 static void cmd_mac_addr_parsed(void *parsed_result,
7139 __attribute__((unused)) struct cmdline *cl,
7140 __attribute__((unused)) void *data)
7142 struct cmd_mac_addr_result *res = parsed_result;
7145 if (strcmp(res->what, "add") == 0)
7146 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7147 else if (strcmp(res->what, "set") == 0)
7148 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7151 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7153 /* check the return value and print it if is < 0 */
7155 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7159 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7160 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7162 cmdline_parse_token_string_t cmd_mac_addr_what =
7163 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7165 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7166 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7168 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7169 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7171 cmdline_parse_inst_t cmd_mac_addr = {
7172 .f = cmd_mac_addr_parsed,
7174 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7175 "Add/Remove/Set MAC address on port_id",
7177 (void *)&cmd_mac_addr_cmd,
7178 (void *)&cmd_mac_addr_what,
7179 (void *)&cmd_mac_addr_portnum,
7180 (void *)&cmd_mac_addr_addr,
7186 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7187 struct cmd_set_qmap_result {
7188 cmdline_fixed_string_t set;
7189 cmdline_fixed_string_t qmap;
7190 cmdline_fixed_string_t what;
7197 cmd_set_qmap_parsed(void *parsed_result,
7198 __attribute__((unused)) struct cmdline *cl,
7199 __attribute__((unused)) void *data)
7201 struct cmd_set_qmap_result *res = parsed_result;
7202 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7204 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7207 cmdline_parse_token_string_t cmd_setqmap_set =
7208 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7210 cmdline_parse_token_string_t cmd_setqmap_qmap =
7211 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7213 cmdline_parse_token_string_t cmd_setqmap_what =
7214 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7216 cmdline_parse_token_num_t cmd_setqmap_portid =
7217 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7219 cmdline_parse_token_num_t cmd_setqmap_queueid =
7220 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7222 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7223 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7226 cmdline_parse_inst_t cmd_set_qmap = {
7227 .f = cmd_set_qmap_parsed,
7229 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7230 "Set statistics mapping value on tx|rx queue_id of port_id",
7232 (void *)&cmd_setqmap_set,
7233 (void *)&cmd_setqmap_qmap,
7234 (void *)&cmd_setqmap_what,
7235 (void *)&cmd_setqmap_portid,
7236 (void *)&cmd_setqmap_queueid,
7237 (void *)&cmd_setqmap_mapvalue,
7242 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7243 struct cmd_set_xstats_hide_zero_result {
7244 cmdline_fixed_string_t keyword;
7245 cmdline_fixed_string_t name;
7246 cmdline_fixed_string_t on_off;
7250 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7251 __attribute__((unused)) struct cmdline *cl,
7252 __attribute__((unused)) void *data)
7254 struct cmd_set_xstats_hide_zero_result *res;
7255 uint16_t on_off = 0;
7257 res = parsed_result;
7258 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7259 set_xstats_hide_zero(on_off);
7262 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7263 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7265 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7266 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7267 name, "xstats-hide-zero");
7268 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7269 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7272 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7273 .f = cmd_set_xstats_hide_zero_parsed,
7275 .help_str = "set xstats-hide-zero on|off",
7277 (void *)&cmd_set_xstats_hide_zero_keyword,
7278 (void *)&cmd_set_xstats_hide_zero_name,
7279 (void *)&cmd_set_xstats_hide_zero_on_off,
7284 /* *** CONFIGURE UNICAST HASH TABLE *** */
7285 struct cmd_set_uc_hash_table {
7286 cmdline_fixed_string_t set;
7287 cmdline_fixed_string_t port;
7289 cmdline_fixed_string_t what;
7290 struct ether_addr address;
7291 cmdline_fixed_string_t mode;
7295 cmd_set_uc_hash_parsed(void *parsed_result,
7296 __attribute__((unused)) struct cmdline *cl,
7297 __attribute__((unused)) void *data)
7300 struct cmd_set_uc_hash_table *res = parsed_result;
7302 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7304 if (strcmp(res->what, "uta") == 0)
7305 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7306 &res->address,(uint8_t)is_on);
7308 printf("bad unicast hash table parameter, return code = %d \n", ret);
7312 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7313 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7315 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7316 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7318 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7319 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7321 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7322 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7324 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7325 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7327 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7328 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7331 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7332 .f = cmd_set_uc_hash_parsed,
7334 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7336 (void *)&cmd_set_uc_hash_set,
7337 (void *)&cmd_set_uc_hash_port,
7338 (void *)&cmd_set_uc_hash_portid,
7339 (void *)&cmd_set_uc_hash_what,
7340 (void *)&cmd_set_uc_hash_mac,
7341 (void *)&cmd_set_uc_hash_mode,
7346 struct cmd_set_uc_all_hash_table {
7347 cmdline_fixed_string_t set;
7348 cmdline_fixed_string_t port;
7350 cmdline_fixed_string_t what;
7351 cmdline_fixed_string_t value;
7352 cmdline_fixed_string_t mode;
7356 cmd_set_uc_all_hash_parsed(void *parsed_result,
7357 __attribute__((unused)) struct cmdline *cl,
7358 __attribute__((unused)) void *data)
7361 struct cmd_set_uc_all_hash_table *res = parsed_result;
7363 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7365 if ((strcmp(res->what, "uta") == 0) &&
7366 (strcmp(res->value, "all") == 0))
7367 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7369 printf("bad unicast hash table parameter,"
7370 "return code = %d \n", ret);
7373 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7374 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7376 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7377 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7379 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7380 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7382 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7383 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7385 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7386 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7388 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7389 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7392 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7393 .f = cmd_set_uc_all_hash_parsed,
7395 .help_str = "set port <port_id> uta all on|off",
7397 (void *)&cmd_set_uc_all_hash_set,
7398 (void *)&cmd_set_uc_all_hash_port,
7399 (void *)&cmd_set_uc_all_hash_portid,
7400 (void *)&cmd_set_uc_all_hash_what,
7401 (void *)&cmd_set_uc_all_hash_value,
7402 (void *)&cmd_set_uc_all_hash_mode,
7407 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7408 struct cmd_set_vf_macvlan_filter {
7409 cmdline_fixed_string_t set;
7410 cmdline_fixed_string_t port;
7412 cmdline_fixed_string_t vf;
7414 struct ether_addr address;
7415 cmdline_fixed_string_t filter_type;
7416 cmdline_fixed_string_t mode;
7420 cmd_set_vf_macvlan_parsed(void *parsed_result,
7421 __attribute__((unused)) struct cmdline *cl,
7422 __attribute__((unused)) void *data)
7425 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7426 struct rte_eth_mac_filter filter;
7428 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7430 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7432 /* set VF MAC filter */
7436 filter.dst_id = res->vf_id;
7438 if (!strcmp(res->filter_type, "exact-mac"))
7439 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7440 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7441 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7442 else if (!strcmp(res->filter_type, "hashmac"))
7443 filter.filter_type = RTE_MAC_HASH_MATCH;
7444 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7445 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7447 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7450 ret = rte_eth_dev_filter_ctrl(res->port_id,
7451 RTE_ETH_FILTER_MACVLAN,
7455 ret = rte_eth_dev_filter_ctrl(res->port_id,
7456 RTE_ETH_FILTER_MACVLAN,
7457 RTE_ETH_FILTER_DELETE,
7461 printf("bad set MAC hash parameter, return code = %d\n", ret);
7465 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7466 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7468 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7469 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7471 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7472 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7474 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7475 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7477 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7478 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7480 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7481 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7483 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7484 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7485 filter_type, "exact-mac#exact-mac-vlan"
7486 "#hashmac#hashmac-vlan");
7487 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7488 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7491 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7492 .f = cmd_set_vf_macvlan_parsed,
7494 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7495 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7496 "Exact match rule: exact match of MAC or MAC and VLAN; "
7497 "hash match rule: hash match of MAC and exact match of VLAN",
7499 (void *)&cmd_set_vf_macvlan_set,
7500 (void *)&cmd_set_vf_macvlan_port,
7501 (void *)&cmd_set_vf_macvlan_portid,
7502 (void *)&cmd_set_vf_macvlan_vf,
7503 (void *)&cmd_set_vf_macvlan_vf_id,
7504 (void *)&cmd_set_vf_macvlan_mac,
7505 (void *)&cmd_set_vf_macvlan_filter_type,
7506 (void *)&cmd_set_vf_macvlan_mode,
7511 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7512 struct cmd_set_vf_traffic {
7513 cmdline_fixed_string_t set;
7514 cmdline_fixed_string_t port;
7516 cmdline_fixed_string_t vf;
7518 cmdline_fixed_string_t what;
7519 cmdline_fixed_string_t mode;
7523 cmd_set_vf_traffic_parsed(void *parsed_result,
7524 __attribute__((unused)) struct cmdline *cl,
7525 __attribute__((unused)) void *data)
7527 struct cmd_set_vf_traffic *res = parsed_result;
7528 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7529 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7531 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7534 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7535 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7537 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7538 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7540 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7541 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7543 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7544 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7546 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7547 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7549 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7550 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7552 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7553 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7556 cmdline_parse_inst_t cmd_set_vf_traffic = {
7557 .f = cmd_set_vf_traffic_parsed,
7559 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7561 (void *)&cmd_setvf_traffic_set,
7562 (void *)&cmd_setvf_traffic_port,
7563 (void *)&cmd_setvf_traffic_portid,
7564 (void *)&cmd_setvf_traffic_vf,
7565 (void *)&cmd_setvf_traffic_vfid,
7566 (void *)&cmd_setvf_traffic_what,
7567 (void *)&cmd_setvf_traffic_mode,
7572 /* *** CONFIGURE VF RECEIVE MODE *** */
7573 struct cmd_set_vf_rxmode {
7574 cmdline_fixed_string_t set;
7575 cmdline_fixed_string_t port;
7577 cmdline_fixed_string_t vf;
7579 cmdline_fixed_string_t what;
7580 cmdline_fixed_string_t mode;
7581 cmdline_fixed_string_t on;
7585 cmd_set_vf_rxmode_parsed(void *parsed_result,
7586 __attribute__((unused)) struct cmdline *cl,
7587 __attribute__((unused)) void *data)
7590 uint16_t rx_mode = 0;
7591 struct cmd_set_vf_rxmode *res = parsed_result;
7593 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7594 if (!strcmp(res->what,"rxmode")) {
7595 if (!strcmp(res->mode, "AUPE"))
7596 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7597 else if (!strcmp(res->mode, "ROPE"))
7598 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7599 else if (!strcmp(res->mode, "BAM"))
7600 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7601 else if (!strncmp(res->mode, "MPE",3))
7602 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7605 RTE_SET_USED(is_on);
7607 #ifdef RTE_LIBRTE_IXGBE_PMD
7608 if (ret == -ENOTSUP)
7609 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7610 rx_mode, (uint8_t)is_on);
7612 #ifdef RTE_LIBRTE_BNXT_PMD
7613 if (ret == -ENOTSUP)
7614 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7615 rx_mode, (uint8_t)is_on);
7618 printf("bad VF receive mode parameter, return code = %d \n",
7622 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7623 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7625 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7626 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7628 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7629 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7631 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7632 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7634 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7635 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7637 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7638 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7640 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7641 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7642 mode, "AUPE#ROPE#BAM#MPE");
7643 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7644 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7647 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7648 .f = cmd_set_vf_rxmode_parsed,
7650 .help_str = "set port <port_id> vf <vf_id> rxmode "
7651 "AUPE|ROPE|BAM|MPE on|off",
7653 (void *)&cmd_set_vf_rxmode_set,
7654 (void *)&cmd_set_vf_rxmode_port,
7655 (void *)&cmd_set_vf_rxmode_portid,
7656 (void *)&cmd_set_vf_rxmode_vf,
7657 (void *)&cmd_set_vf_rxmode_vfid,
7658 (void *)&cmd_set_vf_rxmode_what,
7659 (void *)&cmd_set_vf_rxmode_mode,
7660 (void *)&cmd_set_vf_rxmode_on,
7665 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7666 struct cmd_vf_mac_addr_result {
7667 cmdline_fixed_string_t mac_addr_cmd;
7668 cmdline_fixed_string_t what;
7669 cmdline_fixed_string_t port;
7671 cmdline_fixed_string_t vf;
7673 struct ether_addr address;
7676 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7677 __attribute__((unused)) struct cmdline *cl,
7678 __attribute__((unused)) void *data)
7680 struct cmd_vf_mac_addr_result *res = parsed_result;
7683 if (strcmp(res->what, "add") != 0)
7686 #ifdef RTE_LIBRTE_I40E_PMD
7687 if (ret == -ENOTSUP)
7688 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7691 #ifdef RTE_LIBRTE_BNXT_PMD
7692 if (ret == -ENOTSUP)
7693 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7698 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7702 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7703 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7704 mac_addr_cmd,"mac_addr");
7705 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7706 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7708 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7709 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7711 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7712 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7714 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7715 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7717 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7718 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7720 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7721 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7724 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7725 .f = cmd_vf_mac_addr_parsed,
7727 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7728 "Add MAC address filtering for a VF on port_id",
7730 (void *)&cmd_vf_mac_addr_cmd,
7731 (void *)&cmd_vf_mac_addr_what,
7732 (void *)&cmd_vf_mac_addr_port,
7733 (void *)&cmd_vf_mac_addr_portnum,
7734 (void *)&cmd_vf_mac_addr_vf,
7735 (void *)&cmd_vf_mac_addr_vfnum,
7736 (void *)&cmd_vf_mac_addr_addr,
7741 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7742 struct cmd_vf_rx_vlan_filter {
7743 cmdline_fixed_string_t rx_vlan;
7744 cmdline_fixed_string_t what;
7746 cmdline_fixed_string_t port;
7748 cmdline_fixed_string_t vf;
7753 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7754 __attribute__((unused)) struct cmdline *cl,
7755 __attribute__((unused)) void *data)
7757 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7760 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7762 #ifdef RTE_LIBRTE_IXGBE_PMD
7763 if (ret == -ENOTSUP)
7764 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7765 res->vlan_id, res->vf_mask, is_add);
7767 #ifdef RTE_LIBRTE_I40E_PMD
7768 if (ret == -ENOTSUP)
7769 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7770 res->vlan_id, res->vf_mask, is_add);
7772 #ifdef RTE_LIBRTE_BNXT_PMD
7773 if (ret == -ENOTSUP)
7774 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7775 res->vlan_id, res->vf_mask, is_add);
7782 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7783 res->vlan_id, res->vf_mask);
7786 printf("invalid port_id %d\n", res->port_id);
7789 printf("function not implemented or supported\n");
7792 printf("programming error: (%s)\n", strerror(-ret));
7796 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7797 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7798 rx_vlan, "rx_vlan");
7799 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7800 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7802 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7803 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7805 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7806 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7808 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7809 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7811 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7812 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7814 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7815 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7818 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7819 .f = cmd_vf_rx_vlan_filter_parsed,
7821 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7822 "(vf_mask = hexadecimal VF mask)",
7824 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7825 (void *)&cmd_vf_rx_vlan_filter_what,
7826 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7827 (void *)&cmd_vf_rx_vlan_filter_port,
7828 (void *)&cmd_vf_rx_vlan_filter_portid,
7829 (void *)&cmd_vf_rx_vlan_filter_vf,
7830 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7835 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7836 struct cmd_queue_rate_limit_result {
7837 cmdline_fixed_string_t set;
7838 cmdline_fixed_string_t port;
7840 cmdline_fixed_string_t queue;
7842 cmdline_fixed_string_t rate;
7846 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7847 __attribute__((unused)) struct cmdline *cl,
7848 __attribute__((unused)) void *data)
7850 struct cmd_queue_rate_limit_result *res = parsed_result;
7853 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7854 && (strcmp(res->queue, "queue") == 0)
7855 && (strcmp(res->rate, "rate") == 0))
7856 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7859 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7863 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7864 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7866 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7867 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7869 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7870 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7872 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7873 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7875 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7876 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7878 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7879 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7881 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7882 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7885 cmdline_parse_inst_t cmd_queue_rate_limit = {
7886 .f = cmd_queue_rate_limit_parsed,
7888 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7889 "Set rate limit for a queue on port_id",
7891 (void *)&cmd_queue_rate_limit_set,
7892 (void *)&cmd_queue_rate_limit_port,
7893 (void *)&cmd_queue_rate_limit_portnum,
7894 (void *)&cmd_queue_rate_limit_queue,
7895 (void *)&cmd_queue_rate_limit_queuenum,
7896 (void *)&cmd_queue_rate_limit_rate,
7897 (void *)&cmd_queue_rate_limit_ratenum,
7902 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7903 struct cmd_vf_rate_limit_result {
7904 cmdline_fixed_string_t set;
7905 cmdline_fixed_string_t port;
7907 cmdline_fixed_string_t vf;
7909 cmdline_fixed_string_t rate;
7911 cmdline_fixed_string_t q_msk;
7915 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7916 __attribute__((unused)) struct cmdline *cl,
7917 __attribute__((unused)) void *data)
7919 struct cmd_vf_rate_limit_result *res = parsed_result;
7922 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7923 && (strcmp(res->vf, "vf") == 0)
7924 && (strcmp(res->rate, "rate") == 0)
7925 && (strcmp(res->q_msk, "queue_mask") == 0))
7926 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7927 res->rate_num, res->q_msk_val);
7929 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7933 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7934 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7936 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7937 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7939 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7940 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7942 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7943 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7945 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7946 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7948 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7949 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7951 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7952 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7954 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7955 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7956 q_msk, "queue_mask");
7957 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7958 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7961 cmdline_parse_inst_t cmd_vf_rate_limit = {
7962 .f = cmd_vf_rate_limit_parsed,
7964 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7965 "queue_mask <queue_mask_value>: "
7966 "Set rate limit for queues of VF on port_id",
7968 (void *)&cmd_vf_rate_limit_set,
7969 (void *)&cmd_vf_rate_limit_port,
7970 (void *)&cmd_vf_rate_limit_portnum,
7971 (void *)&cmd_vf_rate_limit_vf,
7972 (void *)&cmd_vf_rate_limit_vfnum,
7973 (void *)&cmd_vf_rate_limit_rate,
7974 (void *)&cmd_vf_rate_limit_ratenum,
7975 (void *)&cmd_vf_rate_limit_q_msk,
7976 (void *)&cmd_vf_rate_limit_q_msk_val,
7981 /* *** ADD TUNNEL FILTER OF A PORT *** */
7982 struct cmd_tunnel_filter_result {
7983 cmdline_fixed_string_t cmd;
7984 cmdline_fixed_string_t what;
7986 struct ether_addr outer_mac;
7987 struct ether_addr inner_mac;
7988 cmdline_ipaddr_t ip_value;
7989 uint16_t inner_vlan;
7990 cmdline_fixed_string_t tunnel_type;
7991 cmdline_fixed_string_t filter_type;
7997 cmd_tunnel_filter_parsed(void *parsed_result,
7998 __attribute__((unused)) struct cmdline *cl,
7999 __attribute__((unused)) void *data)
8001 struct cmd_tunnel_filter_result *res = parsed_result;
8002 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8005 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8007 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8008 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8009 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8011 if (res->ip_value.family == AF_INET) {
8012 tunnel_filter_conf.ip_addr.ipv4_addr =
8013 res->ip_value.addr.ipv4.s_addr;
8014 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8016 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8017 &(res->ip_value.addr.ipv6),
8018 sizeof(struct in6_addr));
8019 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8022 if (!strcmp(res->filter_type, "imac-ivlan"))
8023 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8024 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8025 tunnel_filter_conf.filter_type =
8026 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8027 else if (!strcmp(res->filter_type, "imac-tenid"))
8028 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8029 else if (!strcmp(res->filter_type, "imac"))
8030 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8031 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8032 tunnel_filter_conf.filter_type =
8033 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8034 else if (!strcmp(res->filter_type, "oip"))
8035 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8036 else if (!strcmp(res->filter_type, "iip"))
8037 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8039 printf("The filter type is not supported");
8043 if (!strcmp(res->tunnel_type, "vxlan"))
8044 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8045 else if (!strcmp(res->tunnel_type, "nvgre"))
8046 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8047 else if (!strcmp(res->tunnel_type, "ipingre"))
8048 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8050 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8054 tunnel_filter_conf.tenant_id = res->tenant_id;
8055 tunnel_filter_conf.queue_id = res->queue_num;
8056 if (!strcmp(res->what, "add"))
8057 ret = rte_eth_dev_filter_ctrl(res->port_id,
8058 RTE_ETH_FILTER_TUNNEL,
8060 &tunnel_filter_conf);
8062 ret = rte_eth_dev_filter_ctrl(res->port_id,
8063 RTE_ETH_FILTER_TUNNEL,
8064 RTE_ETH_FILTER_DELETE,
8065 &tunnel_filter_conf);
8067 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8071 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8072 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8073 cmd, "tunnel_filter");
8074 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8075 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8077 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8078 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8080 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8081 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8083 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8084 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8086 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8087 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8088 inner_vlan, UINT16);
8089 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8090 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8092 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8093 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8094 tunnel_type, "vxlan#nvgre#ipingre");
8096 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8097 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8098 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8099 "imac#omac-imac-tenid");
8100 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8101 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8103 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8104 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8107 cmdline_parse_inst_t cmd_tunnel_filter = {
8108 .f = cmd_tunnel_filter_parsed,
8110 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8111 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8112 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8113 "<queue_id>: Add/Rm tunnel filter of a port",
8115 (void *)&cmd_tunnel_filter_cmd,
8116 (void *)&cmd_tunnel_filter_what,
8117 (void *)&cmd_tunnel_filter_port_id,
8118 (void *)&cmd_tunnel_filter_outer_mac,
8119 (void *)&cmd_tunnel_filter_inner_mac,
8120 (void *)&cmd_tunnel_filter_ip_value,
8121 (void *)&cmd_tunnel_filter_innner_vlan,
8122 (void *)&cmd_tunnel_filter_tunnel_type,
8123 (void *)&cmd_tunnel_filter_filter_type,
8124 (void *)&cmd_tunnel_filter_tenant_id,
8125 (void *)&cmd_tunnel_filter_queue_num,
8130 /* *** CONFIGURE TUNNEL UDP PORT *** */
8131 struct cmd_tunnel_udp_config {
8132 cmdline_fixed_string_t cmd;
8133 cmdline_fixed_string_t what;
8139 cmd_tunnel_udp_config_parsed(void *parsed_result,
8140 __attribute__((unused)) struct cmdline *cl,
8141 __attribute__((unused)) void *data)
8143 struct cmd_tunnel_udp_config *res = parsed_result;
8144 struct rte_eth_udp_tunnel tunnel_udp;
8147 tunnel_udp.udp_port = res->udp_port;
8149 if (!strcmp(res->cmd, "rx_vxlan_port"))
8150 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8152 if (!strcmp(res->what, "add"))
8153 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8156 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8160 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8163 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8164 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8165 cmd, "rx_vxlan_port");
8166 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8167 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8169 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8170 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8172 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8173 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8176 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8177 .f = cmd_tunnel_udp_config_parsed,
8179 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8180 "Add/Remove a tunneling UDP port filter",
8182 (void *)&cmd_tunnel_udp_config_cmd,
8183 (void *)&cmd_tunnel_udp_config_what,
8184 (void *)&cmd_tunnel_udp_config_udp_port,
8185 (void *)&cmd_tunnel_udp_config_port_id,
8190 /* *** GLOBAL CONFIG *** */
8191 struct cmd_global_config_result {
8192 cmdline_fixed_string_t cmd;
8194 cmdline_fixed_string_t cfg_type;
8199 cmd_global_config_parsed(void *parsed_result,
8200 __attribute__((unused)) struct cmdline *cl,
8201 __attribute__((unused)) void *data)
8203 struct cmd_global_config_result *res = parsed_result;
8204 struct rte_eth_global_cfg conf;
8207 memset(&conf, 0, sizeof(conf));
8208 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8209 conf.cfg.gre_key_len = res->len;
8210 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8211 RTE_ETH_FILTER_SET, &conf);
8213 printf("Global config error\n");
8216 cmdline_parse_token_string_t cmd_global_config_cmd =
8217 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8219 cmdline_parse_token_num_t cmd_global_config_port_id =
8220 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8222 cmdline_parse_token_string_t cmd_global_config_type =
8223 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8224 cfg_type, "gre-key-len");
8225 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8226 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8229 cmdline_parse_inst_t cmd_global_config = {
8230 .f = cmd_global_config_parsed,
8231 .data = (void *)NULL,
8232 .help_str = "global_config <port_id> gre-key-len <key_len>",
8234 (void *)&cmd_global_config_cmd,
8235 (void *)&cmd_global_config_port_id,
8236 (void *)&cmd_global_config_type,
8237 (void *)&cmd_global_config_gre_key_len,
8242 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8243 struct cmd_set_mirror_mask_result {
8244 cmdline_fixed_string_t set;
8245 cmdline_fixed_string_t port;
8247 cmdline_fixed_string_t mirror;
8249 cmdline_fixed_string_t what;
8250 cmdline_fixed_string_t value;
8251 cmdline_fixed_string_t dstpool;
8253 cmdline_fixed_string_t on;
8256 cmdline_parse_token_string_t cmd_mirror_mask_set =
8257 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8259 cmdline_parse_token_string_t cmd_mirror_mask_port =
8260 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8262 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8263 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8265 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8266 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8267 mirror, "mirror-rule");
8268 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8269 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8271 cmdline_parse_token_string_t cmd_mirror_mask_what =
8272 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8273 what, "pool-mirror-up#pool-mirror-down"
8275 cmdline_parse_token_string_t cmd_mirror_mask_value =
8276 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8278 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8279 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8280 dstpool, "dst-pool");
8281 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8282 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8284 cmdline_parse_token_string_t cmd_mirror_mask_on =
8285 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8289 cmd_set_mirror_mask_parsed(void *parsed_result,
8290 __attribute__((unused)) struct cmdline *cl,
8291 __attribute__((unused)) void *data)
8294 struct cmd_set_mirror_mask_result *res = parsed_result;
8295 struct rte_eth_mirror_conf mr_conf;
8297 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8299 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8301 mr_conf.dst_pool = res->dstpool_id;
8303 if (!strcmp(res->what, "pool-mirror-up")) {
8304 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8305 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8306 } else if (!strcmp(res->what, "pool-mirror-down")) {
8307 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8308 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8309 } else if (!strcmp(res->what, "vlan-mirror")) {
8310 mr_conf.rule_type = ETH_MIRROR_VLAN;
8311 nb_item = parse_item_list(res->value, "vlan",
8312 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8316 for (i = 0; i < nb_item; i++) {
8317 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8318 printf("Invalid vlan_id: must be < 4096\n");
8322 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8323 mr_conf.vlan.vlan_mask |= 1ULL << i;
8327 if (!strcmp(res->on, "on"))
8328 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8331 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8334 printf("mirror rule add error: (%s)\n", strerror(-ret));
8337 cmdline_parse_inst_t cmd_set_mirror_mask = {
8338 .f = cmd_set_mirror_mask_parsed,
8340 .help_str = "set port <port_id> mirror-rule <rule_id> "
8341 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8342 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8344 (void *)&cmd_mirror_mask_set,
8345 (void *)&cmd_mirror_mask_port,
8346 (void *)&cmd_mirror_mask_portid,
8347 (void *)&cmd_mirror_mask_mirror,
8348 (void *)&cmd_mirror_mask_ruleid,
8349 (void *)&cmd_mirror_mask_what,
8350 (void *)&cmd_mirror_mask_value,
8351 (void *)&cmd_mirror_mask_dstpool,
8352 (void *)&cmd_mirror_mask_poolid,
8353 (void *)&cmd_mirror_mask_on,
8358 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8359 struct cmd_set_mirror_link_result {
8360 cmdline_fixed_string_t set;
8361 cmdline_fixed_string_t port;
8363 cmdline_fixed_string_t mirror;
8365 cmdline_fixed_string_t what;
8366 cmdline_fixed_string_t dstpool;
8368 cmdline_fixed_string_t on;
8371 cmdline_parse_token_string_t cmd_mirror_link_set =
8372 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8374 cmdline_parse_token_string_t cmd_mirror_link_port =
8375 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8377 cmdline_parse_token_num_t cmd_mirror_link_portid =
8378 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8380 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8381 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8382 mirror, "mirror-rule");
8383 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8384 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8386 cmdline_parse_token_string_t cmd_mirror_link_what =
8387 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8388 what, "uplink-mirror#downlink-mirror");
8389 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8390 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8391 dstpool, "dst-pool");
8392 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8393 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8395 cmdline_parse_token_string_t cmd_mirror_link_on =
8396 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8400 cmd_set_mirror_link_parsed(void *parsed_result,
8401 __attribute__((unused)) struct cmdline *cl,
8402 __attribute__((unused)) void *data)
8405 struct cmd_set_mirror_link_result *res = parsed_result;
8406 struct rte_eth_mirror_conf mr_conf;
8408 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8409 if (!strcmp(res->what, "uplink-mirror"))
8410 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8412 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8414 mr_conf.dst_pool = res->dstpool_id;
8416 if (!strcmp(res->on, "on"))
8417 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8420 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8423 /* check the return value and print it if is < 0 */
8425 printf("mirror rule add error: (%s)\n", strerror(-ret));
8429 cmdline_parse_inst_t cmd_set_mirror_link = {
8430 .f = cmd_set_mirror_link_parsed,
8432 .help_str = "set port <port_id> mirror-rule <rule_id> "
8433 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8435 (void *)&cmd_mirror_link_set,
8436 (void *)&cmd_mirror_link_port,
8437 (void *)&cmd_mirror_link_portid,
8438 (void *)&cmd_mirror_link_mirror,
8439 (void *)&cmd_mirror_link_ruleid,
8440 (void *)&cmd_mirror_link_what,
8441 (void *)&cmd_mirror_link_dstpool,
8442 (void *)&cmd_mirror_link_poolid,
8443 (void *)&cmd_mirror_link_on,
8448 /* *** RESET VM MIRROR RULE *** */
8449 struct cmd_rm_mirror_rule_result {
8450 cmdline_fixed_string_t reset;
8451 cmdline_fixed_string_t port;
8453 cmdline_fixed_string_t mirror;
8457 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8458 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8460 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8461 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8463 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8464 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8466 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8467 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8468 mirror, "mirror-rule");
8469 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8470 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8474 cmd_reset_mirror_rule_parsed(void *parsed_result,
8475 __attribute__((unused)) struct cmdline *cl,
8476 __attribute__((unused)) void *data)
8479 struct cmd_set_mirror_link_result *res = parsed_result;
8481 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8483 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8486 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8487 .f = cmd_reset_mirror_rule_parsed,
8489 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8491 (void *)&cmd_rm_mirror_rule_reset,
8492 (void *)&cmd_rm_mirror_rule_port,
8493 (void *)&cmd_rm_mirror_rule_portid,
8494 (void *)&cmd_rm_mirror_rule_mirror,
8495 (void *)&cmd_rm_mirror_rule_ruleid,
8500 /* ******************************************************************************** */
8502 struct cmd_dump_result {
8503 cmdline_fixed_string_t dump;
8507 dump_struct_sizes(void)
8509 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8510 DUMP_SIZE(struct rte_mbuf);
8511 DUMP_SIZE(struct rte_mempool);
8512 DUMP_SIZE(struct rte_ring);
8516 static void cmd_dump_parsed(void *parsed_result,
8517 __attribute__((unused)) struct cmdline *cl,
8518 __attribute__((unused)) void *data)
8520 struct cmd_dump_result *res = parsed_result;
8522 if (!strcmp(res->dump, "dump_physmem"))
8523 rte_dump_physmem_layout(stdout);
8524 else if (!strcmp(res->dump, "dump_memzone"))
8525 rte_memzone_dump(stdout);
8526 else if (!strcmp(res->dump, "dump_struct_sizes"))
8527 dump_struct_sizes();
8528 else if (!strcmp(res->dump, "dump_ring"))
8529 rte_ring_list_dump(stdout);
8530 else if (!strcmp(res->dump, "dump_mempool"))
8531 rte_mempool_list_dump(stdout);
8532 else if (!strcmp(res->dump, "dump_devargs"))
8533 rte_eal_devargs_dump(stdout);
8534 else if (!strcmp(res->dump, "dump_log_types"))
8535 rte_log_dump(stdout);
8538 cmdline_parse_token_string_t cmd_dump_dump =
8539 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8542 "dump_struct_sizes#"
8548 cmdline_parse_inst_t cmd_dump = {
8549 .f = cmd_dump_parsed, /* function to call */
8550 .data = NULL, /* 2nd arg of func */
8551 .help_str = "Dump status",
8552 .tokens = { /* token list, NULL terminated */
8553 (void *)&cmd_dump_dump,
8558 /* ******************************************************************************** */
8560 struct cmd_dump_one_result {
8561 cmdline_fixed_string_t dump;
8562 cmdline_fixed_string_t name;
8565 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8566 __attribute__((unused)) void *data)
8568 struct cmd_dump_one_result *res = parsed_result;
8570 if (!strcmp(res->dump, "dump_ring")) {
8572 r = rte_ring_lookup(res->name);
8574 cmdline_printf(cl, "Cannot find ring\n");
8577 rte_ring_dump(stdout, r);
8578 } else if (!strcmp(res->dump, "dump_mempool")) {
8579 struct rte_mempool *mp;
8580 mp = rte_mempool_lookup(res->name);
8582 cmdline_printf(cl, "Cannot find mempool\n");
8585 rte_mempool_dump(stdout, mp);
8589 cmdline_parse_token_string_t cmd_dump_one_dump =
8590 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8591 "dump_ring#dump_mempool");
8593 cmdline_parse_token_string_t cmd_dump_one_name =
8594 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8596 cmdline_parse_inst_t cmd_dump_one = {
8597 .f = cmd_dump_one_parsed, /* function to call */
8598 .data = NULL, /* 2nd arg of func */
8599 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8600 .tokens = { /* token list, NULL terminated */
8601 (void *)&cmd_dump_one_dump,
8602 (void *)&cmd_dump_one_name,
8607 /* *** Add/Del syn filter *** */
8608 struct cmd_syn_filter_result {
8609 cmdline_fixed_string_t filter;
8611 cmdline_fixed_string_t ops;
8612 cmdline_fixed_string_t priority;
8613 cmdline_fixed_string_t high;
8614 cmdline_fixed_string_t queue;
8619 cmd_syn_filter_parsed(void *parsed_result,
8620 __attribute__((unused)) struct cmdline *cl,
8621 __attribute__((unused)) void *data)
8623 struct cmd_syn_filter_result *res = parsed_result;
8624 struct rte_eth_syn_filter syn_filter;
8627 ret = rte_eth_dev_filter_supported(res->port_id,
8628 RTE_ETH_FILTER_SYN);
8630 printf("syn filter is not supported on port %u.\n",
8635 memset(&syn_filter, 0, sizeof(syn_filter));
8637 if (!strcmp(res->ops, "add")) {
8638 if (!strcmp(res->high, "high"))
8639 syn_filter.hig_pri = 1;
8641 syn_filter.hig_pri = 0;
8643 syn_filter.queue = res->queue_id;
8644 ret = rte_eth_dev_filter_ctrl(res->port_id,
8649 ret = rte_eth_dev_filter_ctrl(res->port_id,
8651 RTE_ETH_FILTER_DELETE,
8655 printf("syn filter programming error: (%s)\n",
8659 cmdline_parse_token_string_t cmd_syn_filter_filter =
8660 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8661 filter, "syn_filter");
8662 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8663 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8665 cmdline_parse_token_string_t cmd_syn_filter_ops =
8666 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8668 cmdline_parse_token_string_t cmd_syn_filter_priority =
8669 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8670 priority, "priority");
8671 cmdline_parse_token_string_t cmd_syn_filter_high =
8672 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8674 cmdline_parse_token_string_t cmd_syn_filter_queue =
8675 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8677 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8678 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8681 cmdline_parse_inst_t cmd_syn_filter = {
8682 .f = cmd_syn_filter_parsed,
8684 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8685 "<queue_id>: Add/Delete syn filter",
8687 (void *)&cmd_syn_filter_filter,
8688 (void *)&cmd_syn_filter_port_id,
8689 (void *)&cmd_syn_filter_ops,
8690 (void *)&cmd_syn_filter_priority,
8691 (void *)&cmd_syn_filter_high,
8692 (void *)&cmd_syn_filter_queue,
8693 (void *)&cmd_syn_filter_queue_id,
8698 /* *** queue region set *** */
8699 struct cmd_queue_region_result {
8700 cmdline_fixed_string_t set;
8701 cmdline_fixed_string_t port;
8703 cmdline_fixed_string_t cmd;
8704 cmdline_fixed_string_t region;
8706 cmdline_fixed_string_t queue_start_index;
8708 cmdline_fixed_string_t queue_num;
8709 uint8_t queue_num_value;
8713 cmd_queue_region_parsed(void *parsed_result,
8714 __attribute__((unused)) struct cmdline *cl,
8715 __attribute__((unused)) void *data)
8717 struct cmd_queue_region_result *res = parsed_result;
8719 #ifdef RTE_LIBRTE_I40E_PMD
8720 struct rte_pmd_i40e_queue_region_conf region_conf;
8721 enum rte_pmd_i40e_queue_region_op op_type;
8724 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8727 #ifdef RTE_LIBRTE_I40E_PMD
8728 memset(®ion_conf, 0, sizeof(region_conf));
8729 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8730 region_conf.region_id = res->region_id;
8731 region_conf.queue_num = res->queue_num_value;
8732 region_conf.queue_start_index = res->queue_id;
8734 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8735 op_type, ®ion_conf);
8742 printf("function not implemented or supported\n");
8745 printf("queue region config error: (%s)\n", strerror(-ret));
8749 cmdline_parse_token_string_t cmd_queue_region_set =
8750 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8752 cmdline_parse_token_string_t cmd_queue_region_port =
8753 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8754 cmdline_parse_token_num_t cmd_queue_region_port_id =
8755 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8757 cmdline_parse_token_string_t cmd_queue_region_cmd =
8758 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8759 cmd, "queue-region");
8760 cmdline_parse_token_string_t cmd_queue_region_id =
8761 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8762 region, "region_id");
8763 cmdline_parse_token_num_t cmd_queue_region_index =
8764 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8766 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8767 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8768 queue_start_index, "queue_start_index");
8769 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8770 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8772 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8773 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8774 queue_num, "queue_num");
8775 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8776 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8777 queue_num_value, UINT8);
8779 cmdline_parse_inst_t cmd_queue_region = {
8780 .f = cmd_queue_region_parsed,
8782 .help_str = "set port <port_id> queue-region region_id <value> "
8783 "queue_start_index <value> queue_num <value>: Set a queue region",
8785 (void *)&cmd_queue_region_set,
8786 (void *)&cmd_queue_region_port,
8787 (void *)&cmd_queue_region_port_id,
8788 (void *)&cmd_queue_region_cmd,
8789 (void *)&cmd_queue_region_id,
8790 (void *)&cmd_queue_region_index,
8791 (void *)&cmd_queue_region_queue_start_index,
8792 (void *)&cmd_queue_region_queue_id,
8793 (void *)&cmd_queue_region_queue_num,
8794 (void *)&cmd_queue_region_queue_num_value,
8799 /* *** queue region and flowtype set *** */
8800 struct cmd_region_flowtype_result {
8801 cmdline_fixed_string_t set;
8802 cmdline_fixed_string_t port;
8804 cmdline_fixed_string_t cmd;
8805 cmdline_fixed_string_t region;
8807 cmdline_fixed_string_t flowtype;
8808 uint8_t flowtype_id;
8812 cmd_region_flowtype_parsed(void *parsed_result,
8813 __attribute__((unused)) struct cmdline *cl,
8814 __attribute__((unused)) void *data)
8816 struct cmd_region_flowtype_result *res = parsed_result;
8818 #ifdef RTE_LIBRTE_I40E_PMD
8819 struct rte_pmd_i40e_queue_region_conf region_conf;
8820 enum rte_pmd_i40e_queue_region_op op_type;
8823 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8826 #ifdef RTE_LIBRTE_I40E_PMD
8827 memset(®ion_conf, 0, sizeof(region_conf));
8829 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8830 region_conf.region_id = res->region_id;
8831 region_conf.hw_flowtype = res->flowtype_id;
8833 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8834 op_type, ®ion_conf);
8841 printf("function not implemented or supported\n");
8844 printf("region flowtype config error: (%s)\n", strerror(-ret));
8848 cmdline_parse_token_string_t cmd_region_flowtype_set =
8849 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8851 cmdline_parse_token_string_t cmd_region_flowtype_port =
8852 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8854 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8855 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8857 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8858 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8859 cmd, "queue-region");
8860 cmdline_parse_token_string_t cmd_region_flowtype_index =
8861 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8862 region, "region_id");
8863 cmdline_parse_token_num_t cmd_region_flowtype_id =
8864 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8866 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8867 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8868 flowtype, "flowtype");
8869 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8870 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8871 flowtype_id, UINT8);
8872 cmdline_parse_inst_t cmd_region_flowtype = {
8873 .f = cmd_region_flowtype_parsed,
8875 .help_str = "set port <port_id> queue-region region_id <value> "
8876 "flowtype <value>: Set a flowtype region index",
8878 (void *)&cmd_region_flowtype_set,
8879 (void *)&cmd_region_flowtype_port,
8880 (void *)&cmd_region_flowtype_port_index,
8881 (void *)&cmd_region_flowtype_cmd,
8882 (void *)&cmd_region_flowtype_index,
8883 (void *)&cmd_region_flowtype_id,
8884 (void *)&cmd_region_flowtype_flow_index,
8885 (void *)&cmd_region_flowtype_flow_id,
8890 /* *** User Priority (UP) to queue region (region_id) set *** */
8891 struct cmd_user_priority_region_result {
8892 cmdline_fixed_string_t set;
8893 cmdline_fixed_string_t port;
8895 cmdline_fixed_string_t cmd;
8896 cmdline_fixed_string_t user_priority;
8897 uint8_t user_priority_id;
8898 cmdline_fixed_string_t region;
8903 cmd_user_priority_region_parsed(void *parsed_result,
8904 __attribute__((unused)) struct cmdline *cl,
8905 __attribute__((unused)) void *data)
8907 struct cmd_user_priority_region_result *res = parsed_result;
8909 #ifdef RTE_LIBRTE_I40E_PMD
8910 struct rte_pmd_i40e_queue_region_conf region_conf;
8911 enum rte_pmd_i40e_queue_region_op op_type;
8914 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8917 #ifdef RTE_LIBRTE_I40E_PMD
8918 memset(®ion_conf, 0, sizeof(region_conf));
8919 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8920 region_conf.user_priority = res->user_priority_id;
8921 region_conf.region_id = res->region_id;
8923 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8924 op_type, ®ion_conf);
8931 printf("function not implemented or supported\n");
8934 printf("user_priority region config error: (%s)\n",
8939 cmdline_parse_token_string_t cmd_user_priority_region_set =
8940 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8942 cmdline_parse_token_string_t cmd_user_priority_region_port =
8943 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8945 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8946 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8948 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
8949 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8950 cmd, "queue-region");
8951 cmdline_parse_token_string_t cmd_user_priority_region_UP =
8952 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8953 user_priority, "UP");
8954 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
8955 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8956 user_priority_id, UINT8);
8957 cmdline_parse_token_string_t cmd_user_priority_region_region =
8958 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8959 region, "region_id");
8960 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
8961 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8964 cmdline_parse_inst_t cmd_user_priority_region = {
8965 .f = cmd_user_priority_region_parsed,
8967 .help_str = "set port <port_id> queue-region UP <value> "
8968 "region_id <value>: Set the mapping of User Priority (UP) "
8969 "to queue region (region_id) ",
8971 (void *)&cmd_user_priority_region_set,
8972 (void *)&cmd_user_priority_region_port,
8973 (void *)&cmd_user_priority_region_port_index,
8974 (void *)&cmd_user_priority_region_cmd,
8975 (void *)&cmd_user_priority_region_UP,
8976 (void *)&cmd_user_priority_region_UP_id,
8977 (void *)&cmd_user_priority_region_region,
8978 (void *)&cmd_user_priority_region_region_id,
8983 /* *** flush all queue region related configuration *** */
8984 struct cmd_flush_queue_region_result {
8985 cmdline_fixed_string_t set;
8986 cmdline_fixed_string_t port;
8988 cmdline_fixed_string_t cmd;
8989 cmdline_fixed_string_t flush;
8990 cmdline_fixed_string_t what;
8994 cmd_flush_queue_region_parsed(void *parsed_result,
8995 __attribute__((unused)) struct cmdline *cl,
8996 __attribute__((unused)) void *data)
8998 struct cmd_flush_queue_region_result *res = parsed_result;
9000 #ifdef RTE_LIBRTE_I40E_PMD
9001 struct rte_pmd_i40e_queue_region_conf region_conf;
9002 enum rte_pmd_i40e_queue_region_op op_type;
9005 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9008 #ifdef RTE_LIBRTE_I40E_PMD
9009 memset(®ion_conf, 0, sizeof(region_conf));
9011 if (strcmp(res->what, "on") == 0)
9012 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9014 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9016 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9017 op_type, ®ion_conf);
9024 printf("function not implemented or supported\n");
9027 printf("queue region config flush error: (%s)\n",
9032 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9033 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9035 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9036 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9038 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9039 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9041 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9042 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9043 cmd, "queue-region");
9044 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9045 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9047 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9048 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9051 cmdline_parse_inst_t cmd_flush_queue_region = {
9052 .f = cmd_flush_queue_region_parsed,
9054 .help_str = "set port <port_id> queue-region flush on|off"
9055 ": flush all queue region related configuration",
9057 (void *)&cmd_flush_queue_region_set,
9058 (void *)&cmd_flush_queue_region_port,
9059 (void *)&cmd_flush_queue_region_port_index,
9060 (void *)&cmd_flush_queue_region_cmd,
9061 (void *)&cmd_flush_queue_region_flush,
9062 (void *)&cmd_flush_queue_region_what,
9067 /* *** get all queue region related configuration info *** */
9068 struct cmd_show_queue_region_info {
9069 cmdline_fixed_string_t show;
9070 cmdline_fixed_string_t port;
9072 cmdline_fixed_string_t cmd;
9076 cmd_show_queue_region_info_parsed(void *parsed_result,
9077 __attribute__((unused)) struct cmdline *cl,
9078 __attribute__((unused)) void *data)
9080 struct cmd_show_queue_region_info *res = parsed_result;
9082 #ifdef RTE_LIBRTE_I40E_PMD
9083 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9084 enum rte_pmd_i40e_queue_region_op op_type;
9087 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9090 #ifdef RTE_LIBRTE_I40E_PMD
9091 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9093 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9095 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9096 op_type, &rte_pmd_regions);
9098 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9105 printf("function not implemented or supported\n");
9108 printf("queue region config info show error: (%s)\n",
9113 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9114 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9116 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9117 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9119 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9120 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9122 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9123 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9124 cmd, "queue-region");
9126 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9127 .f = cmd_show_queue_region_info_parsed,
9129 .help_str = "show port <port_id> queue-region"
9130 ": show all queue region related configuration info",
9132 (void *)&cmd_show_queue_region_info_get,
9133 (void *)&cmd_show_queue_region_info_port,
9134 (void *)&cmd_show_queue_region_info_port_index,
9135 (void *)&cmd_show_queue_region_info_cmd,
9140 /* *** ADD/REMOVE A 2tuple FILTER *** */
9141 struct cmd_2tuple_filter_result {
9142 cmdline_fixed_string_t filter;
9144 cmdline_fixed_string_t ops;
9145 cmdline_fixed_string_t dst_port;
9146 uint16_t dst_port_value;
9147 cmdline_fixed_string_t protocol;
9148 uint8_t protocol_value;
9149 cmdline_fixed_string_t mask;
9151 cmdline_fixed_string_t tcp_flags;
9152 uint8_t tcp_flags_value;
9153 cmdline_fixed_string_t priority;
9154 uint8_t priority_value;
9155 cmdline_fixed_string_t queue;
9160 cmd_2tuple_filter_parsed(void *parsed_result,
9161 __attribute__((unused)) struct cmdline *cl,
9162 __attribute__((unused)) void *data)
9164 struct rte_eth_ntuple_filter filter;
9165 struct cmd_2tuple_filter_result *res = parsed_result;
9168 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9170 printf("ntuple filter is not supported on port %u.\n",
9175 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9177 filter.flags = RTE_2TUPLE_FLAGS;
9178 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9179 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9180 filter.proto = res->protocol_value;
9181 filter.priority = res->priority_value;
9182 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9183 printf("nonzero tcp_flags is only meaningful"
9184 " when protocol is TCP.\n");
9187 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9188 printf("invalid TCP flags.\n");
9192 if (res->tcp_flags_value != 0) {
9193 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9194 filter.tcp_flags = res->tcp_flags_value;
9197 /* need convert to big endian. */
9198 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9199 filter.queue = res->queue_id;
9201 if (!strcmp(res->ops, "add"))
9202 ret = rte_eth_dev_filter_ctrl(res->port_id,
9203 RTE_ETH_FILTER_NTUPLE,
9207 ret = rte_eth_dev_filter_ctrl(res->port_id,
9208 RTE_ETH_FILTER_NTUPLE,
9209 RTE_ETH_FILTER_DELETE,
9212 printf("2tuple filter programming error: (%s)\n",
9217 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9218 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9219 filter, "2tuple_filter");
9220 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9221 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9223 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9224 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9226 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9227 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9228 dst_port, "dst_port");
9229 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9230 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9231 dst_port_value, UINT16);
9232 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9233 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9234 protocol, "protocol");
9235 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9236 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9237 protocol_value, UINT8);
9238 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9239 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9241 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9242 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9244 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9245 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9246 tcp_flags, "tcp_flags");
9247 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9248 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9249 tcp_flags_value, UINT8);
9250 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9251 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9252 priority, "priority");
9253 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9254 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9255 priority_value, UINT8);
9256 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9257 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9259 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9260 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9263 cmdline_parse_inst_t cmd_2tuple_filter = {
9264 .f = cmd_2tuple_filter_parsed,
9266 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9267 "<value> mask <value> tcp_flags <value> priority <value> queue "
9268 "<queue_id>: Add a 2tuple filter",
9270 (void *)&cmd_2tuple_filter_filter,
9271 (void *)&cmd_2tuple_filter_port_id,
9272 (void *)&cmd_2tuple_filter_ops,
9273 (void *)&cmd_2tuple_filter_dst_port,
9274 (void *)&cmd_2tuple_filter_dst_port_value,
9275 (void *)&cmd_2tuple_filter_protocol,
9276 (void *)&cmd_2tuple_filter_protocol_value,
9277 (void *)&cmd_2tuple_filter_mask,
9278 (void *)&cmd_2tuple_filter_mask_value,
9279 (void *)&cmd_2tuple_filter_tcp_flags,
9280 (void *)&cmd_2tuple_filter_tcp_flags_value,
9281 (void *)&cmd_2tuple_filter_priority,
9282 (void *)&cmd_2tuple_filter_priority_value,
9283 (void *)&cmd_2tuple_filter_queue,
9284 (void *)&cmd_2tuple_filter_queue_id,
9289 /* *** ADD/REMOVE A 5tuple FILTER *** */
9290 struct cmd_5tuple_filter_result {
9291 cmdline_fixed_string_t filter;
9293 cmdline_fixed_string_t ops;
9294 cmdline_fixed_string_t dst_ip;
9295 cmdline_ipaddr_t dst_ip_value;
9296 cmdline_fixed_string_t src_ip;
9297 cmdline_ipaddr_t src_ip_value;
9298 cmdline_fixed_string_t dst_port;
9299 uint16_t dst_port_value;
9300 cmdline_fixed_string_t src_port;
9301 uint16_t src_port_value;
9302 cmdline_fixed_string_t protocol;
9303 uint8_t protocol_value;
9304 cmdline_fixed_string_t mask;
9306 cmdline_fixed_string_t tcp_flags;
9307 uint8_t tcp_flags_value;
9308 cmdline_fixed_string_t priority;
9309 uint8_t priority_value;
9310 cmdline_fixed_string_t queue;
9315 cmd_5tuple_filter_parsed(void *parsed_result,
9316 __attribute__((unused)) struct cmdline *cl,
9317 __attribute__((unused)) void *data)
9319 struct rte_eth_ntuple_filter filter;
9320 struct cmd_5tuple_filter_result *res = parsed_result;
9323 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9325 printf("ntuple filter is not supported on port %u.\n",
9330 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9332 filter.flags = RTE_5TUPLE_FLAGS;
9333 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9334 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9335 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9336 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9337 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9338 filter.proto = res->protocol_value;
9339 filter.priority = res->priority_value;
9340 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9341 printf("nonzero tcp_flags is only meaningful"
9342 " when protocol is TCP.\n");
9345 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9346 printf("invalid TCP flags.\n");
9350 if (res->tcp_flags_value != 0) {
9351 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9352 filter.tcp_flags = res->tcp_flags_value;
9355 if (res->dst_ip_value.family == AF_INET)
9356 /* no need to convert, already big endian. */
9357 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9359 if (filter.dst_ip_mask == 0) {
9360 printf("can not support ipv6 involved compare.\n");
9366 if (res->src_ip_value.family == AF_INET)
9367 /* no need to convert, already big endian. */
9368 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9370 if (filter.src_ip_mask == 0) {
9371 printf("can not support ipv6 involved compare.\n");
9376 /* need convert to big endian. */
9377 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9378 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9379 filter.queue = res->queue_id;
9381 if (!strcmp(res->ops, "add"))
9382 ret = rte_eth_dev_filter_ctrl(res->port_id,
9383 RTE_ETH_FILTER_NTUPLE,
9387 ret = rte_eth_dev_filter_ctrl(res->port_id,
9388 RTE_ETH_FILTER_NTUPLE,
9389 RTE_ETH_FILTER_DELETE,
9392 printf("5tuple filter programming error: (%s)\n",
9396 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9397 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9398 filter, "5tuple_filter");
9399 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9400 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9402 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9403 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9405 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9406 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9408 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9409 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9411 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9412 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9414 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9415 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9417 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9418 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9419 dst_port, "dst_port");
9420 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9421 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9422 dst_port_value, UINT16);
9423 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9424 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9425 src_port, "src_port");
9426 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9427 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9428 src_port_value, UINT16);
9429 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9430 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9431 protocol, "protocol");
9432 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9433 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9434 protocol_value, UINT8);
9435 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9436 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9438 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9439 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9441 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9442 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9443 tcp_flags, "tcp_flags");
9444 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9445 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9446 tcp_flags_value, UINT8);
9447 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9448 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9449 priority, "priority");
9450 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9451 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9452 priority_value, UINT8);
9453 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9454 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9456 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9457 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9460 cmdline_parse_inst_t cmd_5tuple_filter = {
9461 .f = cmd_5tuple_filter_parsed,
9463 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9464 "src_ip <value> dst_port <value> src_port <value> "
9465 "protocol <value> mask <value> tcp_flags <value> "
9466 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9468 (void *)&cmd_5tuple_filter_filter,
9469 (void *)&cmd_5tuple_filter_port_id,
9470 (void *)&cmd_5tuple_filter_ops,
9471 (void *)&cmd_5tuple_filter_dst_ip,
9472 (void *)&cmd_5tuple_filter_dst_ip_value,
9473 (void *)&cmd_5tuple_filter_src_ip,
9474 (void *)&cmd_5tuple_filter_src_ip_value,
9475 (void *)&cmd_5tuple_filter_dst_port,
9476 (void *)&cmd_5tuple_filter_dst_port_value,
9477 (void *)&cmd_5tuple_filter_src_port,
9478 (void *)&cmd_5tuple_filter_src_port_value,
9479 (void *)&cmd_5tuple_filter_protocol,
9480 (void *)&cmd_5tuple_filter_protocol_value,
9481 (void *)&cmd_5tuple_filter_mask,
9482 (void *)&cmd_5tuple_filter_mask_value,
9483 (void *)&cmd_5tuple_filter_tcp_flags,
9484 (void *)&cmd_5tuple_filter_tcp_flags_value,
9485 (void *)&cmd_5tuple_filter_priority,
9486 (void *)&cmd_5tuple_filter_priority_value,
9487 (void *)&cmd_5tuple_filter_queue,
9488 (void *)&cmd_5tuple_filter_queue_id,
9493 /* *** ADD/REMOVE A flex FILTER *** */
9494 struct cmd_flex_filter_result {
9495 cmdline_fixed_string_t filter;
9496 cmdline_fixed_string_t ops;
9498 cmdline_fixed_string_t len;
9500 cmdline_fixed_string_t bytes;
9501 cmdline_fixed_string_t bytes_value;
9502 cmdline_fixed_string_t mask;
9503 cmdline_fixed_string_t mask_value;
9504 cmdline_fixed_string_t priority;
9505 uint8_t priority_value;
9506 cmdline_fixed_string_t queue;
9510 static int xdigit2val(unsigned char c)
9515 else if (isupper(c))
9523 cmd_flex_filter_parsed(void *parsed_result,
9524 __attribute__((unused)) struct cmdline *cl,
9525 __attribute__((unused)) void *data)
9528 struct rte_eth_flex_filter filter;
9529 struct cmd_flex_filter_result *res = parsed_result;
9530 char *bytes_ptr, *mask_ptr;
9531 uint16_t len, i, j = 0;
9536 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9537 printf("the len exceed the max length 128\n");
9540 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9541 filter.len = res->len_value;
9542 filter.priority = res->priority_value;
9543 filter.queue = res->queue_id;
9544 bytes_ptr = res->bytes_value;
9545 mask_ptr = res->mask_value;
9547 /* translate bytes string to array. */
9548 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9549 (bytes_ptr[1] == 'X')))
9551 len = strnlen(bytes_ptr, res->len_value * 2);
9552 if (len == 0 || (len % 8 != 0)) {
9553 printf("please check len and bytes input\n");
9556 for (i = 0; i < len; i++) {
9558 if (isxdigit(c) == 0) {
9559 /* invalid characters. */
9560 printf("invalid input\n");
9563 val = xdigit2val(c);
9566 filter.bytes[j] = byte;
9567 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9574 /* translate mask string to uint8_t array. */
9575 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9576 (mask_ptr[1] == 'X')))
9578 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9580 printf("invalid input\n");
9585 for (i = 0; i < len; i++) {
9587 if (isxdigit(c) == 0) {
9588 /* invalid characters. */
9589 printf("invalid input\n");
9592 val = xdigit2val(c);
9595 filter.mask[j] = byte;
9596 printf("mask[%d]:%02x ", j, filter.mask[j]);
9604 if (!strcmp(res->ops, "add"))
9605 ret = rte_eth_dev_filter_ctrl(res->port_id,
9606 RTE_ETH_FILTER_FLEXIBLE,
9610 ret = rte_eth_dev_filter_ctrl(res->port_id,
9611 RTE_ETH_FILTER_FLEXIBLE,
9612 RTE_ETH_FILTER_DELETE,
9616 printf("flex filter setting error: (%s)\n", strerror(-ret));
9619 cmdline_parse_token_string_t cmd_flex_filter_filter =
9620 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9621 filter, "flex_filter");
9622 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9623 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9625 cmdline_parse_token_string_t cmd_flex_filter_ops =
9626 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9628 cmdline_parse_token_string_t cmd_flex_filter_len =
9629 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9631 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9632 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9634 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9635 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9637 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9638 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9640 cmdline_parse_token_string_t cmd_flex_filter_mask =
9641 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9643 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9644 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9646 cmdline_parse_token_string_t cmd_flex_filter_priority =
9647 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9648 priority, "priority");
9649 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9650 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9651 priority_value, UINT8);
9652 cmdline_parse_token_string_t cmd_flex_filter_queue =
9653 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9655 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9656 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9658 cmdline_parse_inst_t cmd_flex_filter = {
9659 .f = cmd_flex_filter_parsed,
9661 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9662 "<value> mask <value> priority <value> queue <queue_id>: "
9663 "Add/Del a flex filter",
9665 (void *)&cmd_flex_filter_filter,
9666 (void *)&cmd_flex_filter_port_id,
9667 (void *)&cmd_flex_filter_ops,
9668 (void *)&cmd_flex_filter_len,
9669 (void *)&cmd_flex_filter_len_value,
9670 (void *)&cmd_flex_filter_bytes,
9671 (void *)&cmd_flex_filter_bytes_value,
9672 (void *)&cmd_flex_filter_mask,
9673 (void *)&cmd_flex_filter_mask_value,
9674 (void *)&cmd_flex_filter_priority,
9675 (void *)&cmd_flex_filter_priority_value,
9676 (void *)&cmd_flex_filter_queue,
9677 (void *)&cmd_flex_filter_queue_id,
9682 /* *** Filters Control *** */
9684 /* *** deal with ethertype filter *** */
9685 struct cmd_ethertype_filter_result {
9686 cmdline_fixed_string_t filter;
9688 cmdline_fixed_string_t ops;
9689 cmdline_fixed_string_t mac;
9690 struct ether_addr mac_addr;
9691 cmdline_fixed_string_t ethertype;
9692 uint16_t ethertype_value;
9693 cmdline_fixed_string_t drop;
9694 cmdline_fixed_string_t queue;
9698 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9699 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9700 filter, "ethertype_filter");
9701 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9702 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9704 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9705 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9707 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9708 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9709 mac, "mac_addr#mac_ignr");
9710 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9711 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9713 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9714 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9715 ethertype, "ethertype");
9716 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9717 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9718 ethertype_value, UINT16);
9719 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9720 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9722 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9723 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9725 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9726 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9730 cmd_ethertype_filter_parsed(void *parsed_result,
9731 __attribute__((unused)) struct cmdline *cl,
9732 __attribute__((unused)) void *data)
9734 struct cmd_ethertype_filter_result *res = parsed_result;
9735 struct rte_eth_ethertype_filter filter;
9738 ret = rte_eth_dev_filter_supported(res->port_id,
9739 RTE_ETH_FILTER_ETHERTYPE);
9741 printf("ethertype filter is not supported on port %u.\n",
9746 memset(&filter, 0, sizeof(filter));
9747 if (!strcmp(res->mac, "mac_addr")) {
9748 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9749 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9750 sizeof(struct ether_addr));
9752 if (!strcmp(res->drop, "drop"))
9753 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9754 filter.ether_type = res->ethertype_value;
9755 filter.queue = res->queue_id;
9757 if (!strcmp(res->ops, "add"))
9758 ret = rte_eth_dev_filter_ctrl(res->port_id,
9759 RTE_ETH_FILTER_ETHERTYPE,
9763 ret = rte_eth_dev_filter_ctrl(res->port_id,
9764 RTE_ETH_FILTER_ETHERTYPE,
9765 RTE_ETH_FILTER_DELETE,
9768 printf("ethertype filter programming error: (%s)\n",
9772 cmdline_parse_inst_t cmd_ethertype_filter = {
9773 .f = cmd_ethertype_filter_parsed,
9775 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9776 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9777 "Add or delete an ethertype filter entry",
9779 (void *)&cmd_ethertype_filter_filter,
9780 (void *)&cmd_ethertype_filter_port_id,
9781 (void *)&cmd_ethertype_filter_ops,
9782 (void *)&cmd_ethertype_filter_mac,
9783 (void *)&cmd_ethertype_filter_mac_addr,
9784 (void *)&cmd_ethertype_filter_ethertype,
9785 (void *)&cmd_ethertype_filter_ethertype_value,
9786 (void *)&cmd_ethertype_filter_drop,
9787 (void *)&cmd_ethertype_filter_queue,
9788 (void *)&cmd_ethertype_filter_queue_id,
9793 /* *** deal with flow director filter *** */
9794 struct cmd_flow_director_result {
9795 cmdline_fixed_string_t flow_director_filter;
9797 cmdline_fixed_string_t mode;
9798 cmdline_fixed_string_t mode_value;
9799 cmdline_fixed_string_t ops;
9800 cmdline_fixed_string_t flow;
9801 cmdline_fixed_string_t flow_type;
9802 cmdline_fixed_string_t ether;
9803 uint16_t ether_type;
9804 cmdline_fixed_string_t src;
9805 cmdline_ipaddr_t ip_src;
9807 cmdline_fixed_string_t dst;
9808 cmdline_ipaddr_t ip_dst;
9810 cmdline_fixed_string_t verify_tag;
9811 uint32_t verify_tag_value;
9812 cmdline_ipaddr_t tos;
9814 cmdline_ipaddr_t proto;
9815 uint8_t proto_value;
9816 cmdline_ipaddr_t ttl;
9818 cmdline_fixed_string_t vlan;
9819 uint16_t vlan_value;
9820 cmdline_fixed_string_t flexbytes;
9821 cmdline_fixed_string_t flexbytes_value;
9822 cmdline_fixed_string_t pf_vf;
9823 cmdline_fixed_string_t drop;
9824 cmdline_fixed_string_t queue;
9826 cmdline_fixed_string_t fd_id;
9827 uint32_t fd_id_value;
9828 cmdline_fixed_string_t mac;
9829 struct ether_addr mac_addr;
9830 cmdline_fixed_string_t tunnel;
9831 cmdline_fixed_string_t tunnel_type;
9832 cmdline_fixed_string_t tunnel_id;
9833 uint32_t tunnel_id_value;
9837 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9840 const char *p, *p0 = q_arg;
9842 unsigned long int_fld;
9843 char *str_fld[max_num];
9848 p = strchr(p0, '(');
9852 p0 = strchr(p, ')');
9857 if (size >= sizeof(s))
9860 snprintf(s, sizeof(s), "%.*s", size, p);
9861 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9862 if (ret < 0 || ret > max_num)
9864 for (i = 0; i < ret; i++) {
9866 int_fld = strtoul(str_fld[i], &end, 0);
9867 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9869 flexbytes[i] = (uint8_t)int_fld;
9875 str2flowtype(char *string)
9878 static const struct {
9881 } flowtype_str[] = {
9882 {"raw", RTE_ETH_FLOW_RAW},
9883 {"ipv4", RTE_ETH_FLOW_IPV4},
9884 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9885 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9886 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9887 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9888 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9889 {"ipv6", RTE_ETH_FLOW_IPV6},
9890 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9891 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9892 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9893 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9894 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9895 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9898 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9899 if (!strcmp(flowtype_str[i].str, string))
9900 return flowtype_str[i].type;
9903 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9904 return (uint16_t)atoi(string);
9906 return RTE_ETH_FLOW_UNKNOWN;
9909 static enum rte_eth_fdir_tunnel_type
9910 str2fdir_tunneltype(char *string)
9914 static const struct {
9916 enum rte_eth_fdir_tunnel_type type;
9917 } tunneltype_str[] = {
9918 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9919 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9922 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9923 if (!strcmp(tunneltype_str[i].str, string))
9924 return tunneltype_str[i].type;
9926 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9929 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9931 if ((ip_addr).family == AF_INET) \
9932 (ip) = (ip_addr).addr.ipv4.s_addr; \
9934 printf("invalid parameter.\n"); \
9939 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9941 if ((ip_addr).family == AF_INET6) \
9943 &((ip_addr).addr.ipv6), \
9944 sizeof(struct in6_addr)); \
9946 printf("invalid parameter.\n"); \
9952 cmd_flow_director_filter_parsed(void *parsed_result,
9953 __attribute__((unused)) struct cmdline *cl,
9954 __attribute__((unused)) void *data)
9956 struct cmd_flow_director_result *res = parsed_result;
9957 struct rte_eth_fdir_filter entry;
9958 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9960 unsigned long vf_id;
9963 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9965 printf("flow director is not supported on port %u.\n",
9969 memset(flexbytes, 0, sizeof(flexbytes));
9970 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9972 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9973 if (strcmp(res->mode_value, "MAC-VLAN")) {
9974 printf("Please set mode to MAC-VLAN.\n");
9977 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9978 if (strcmp(res->mode_value, "Tunnel")) {
9979 printf("Please set mode to Tunnel.\n");
9983 if (strcmp(res->mode_value, "IP")) {
9984 printf("Please set mode to IP.\n");
9987 entry.input.flow_type = str2flowtype(res->flow_type);
9990 ret = parse_flexbytes(res->flexbytes_value,
9992 RTE_ETH_FDIR_MAX_FLEXLEN);
9994 printf("error: Cannot parse flexbytes input.\n");
9998 switch (entry.input.flow_type) {
9999 case RTE_ETH_FLOW_FRAG_IPV4:
10000 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10001 entry.input.flow.ip4_flow.proto = res->proto_value;
10003 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10004 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10005 IPV4_ADDR_TO_UINT(res->ip_dst,
10006 entry.input.flow.ip4_flow.dst_ip);
10007 IPV4_ADDR_TO_UINT(res->ip_src,
10008 entry.input.flow.ip4_flow.src_ip);
10009 entry.input.flow.ip4_flow.tos = res->tos_value;
10010 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10011 /* need convert to big endian. */
10012 entry.input.flow.udp4_flow.dst_port =
10013 rte_cpu_to_be_16(res->port_dst);
10014 entry.input.flow.udp4_flow.src_port =
10015 rte_cpu_to_be_16(res->port_src);
10017 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10018 IPV4_ADDR_TO_UINT(res->ip_dst,
10019 entry.input.flow.sctp4_flow.ip.dst_ip);
10020 IPV4_ADDR_TO_UINT(res->ip_src,
10021 entry.input.flow.sctp4_flow.ip.src_ip);
10022 entry.input.flow.ip4_flow.tos = res->tos_value;
10023 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10024 /* need convert to big endian. */
10025 entry.input.flow.sctp4_flow.dst_port =
10026 rte_cpu_to_be_16(res->port_dst);
10027 entry.input.flow.sctp4_flow.src_port =
10028 rte_cpu_to_be_16(res->port_src);
10029 entry.input.flow.sctp4_flow.verify_tag =
10030 rte_cpu_to_be_32(res->verify_tag_value);
10032 case RTE_ETH_FLOW_FRAG_IPV6:
10033 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10034 entry.input.flow.ipv6_flow.proto = res->proto_value;
10036 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10037 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10038 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10039 entry.input.flow.ipv6_flow.dst_ip);
10040 IPV6_ADDR_TO_ARRAY(res->ip_src,
10041 entry.input.flow.ipv6_flow.src_ip);
10042 entry.input.flow.ipv6_flow.tc = res->tos_value;
10043 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10044 /* need convert to big endian. */
10045 entry.input.flow.udp6_flow.dst_port =
10046 rte_cpu_to_be_16(res->port_dst);
10047 entry.input.flow.udp6_flow.src_port =
10048 rte_cpu_to_be_16(res->port_src);
10050 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10051 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10052 entry.input.flow.sctp6_flow.ip.dst_ip);
10053 IPV6_ADDR_TO_ARRAY(res->ip_src,
10054 entry.input.flow.sctp6_flow.ip.src_ip);
10055 entry.input.flow.ipv6_flow.tc = res->tos_value;
10056 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10057 /* need convert to big endian. */
10058 entry.input.flow.sctp6_flow.dst_port =
10059 rte_cpu_to_be_16(res->port_dst);
10060 entry.input.flow.sctp6_flow.src_port =
10061 rte_cpu_to_be_16(res->port_src);
10062 entry.input.flow.sctp6_flow.verify_tag =
10063 rte_cpu_to_be_32(res->verify_tag_value);
10065 case RTE_ETH_FLOW_L2_PAYLOAD:
10066 entry.input.flow.l2_flow.ether_type =
10067 rte_cpu_to_be_16(res->ether_type);
10073 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10074 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10076 sizeof(struct ether_addr));
10078 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10079 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10081 sizeof(struct ether_addr));
10082 entry.input.flow.tunnel_flow.tunnel_type =
10083 str2fdir_tunneltype(res->tunnel_type);
10084 entry.input.flow.tunnel_flow.tunnel_id =
10085 rte_cpu_to_be_32(res->tunnel_id_value);
10088 rte_memcpy(entry.input.flow_ext.flexbytes,
10090 RTE_ETH_FDIR_MAX_FLEXLEN);
10092 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10094 entry.action.flex_off = 0; /*use 0 by default */
10095 if (!strcmp(res->drop, "drop"))
10096 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10098 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10100 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10101 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10102 if (!strcmp(res->pf_vf, "pf"))
10103 entry.input.flow_ext.is_vf = 0;
10104 else if (!strncmp(res->pf_vf, "vf", 2)) {
10105 struct rte_eth_dev_info dev_info;
10107 memset(&dev_info, 0, sizeof(dev_info));
10108 rte_eth_dev_info_get(res->port_id, &dev_info);
10110 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10111 if (errno != 0 || *end != '\0' ||
10112 vf_id >= dev_info.max_vfs) {
10113 printf("invalid parameter %s.\n", res->pf_vf);
10116 entry.input.flow_ext.is_vf = 1;
10117 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10119 printf("invalid parameter %s.\n", res->pf_vf);
10124 /* set to report FD ID by default */
10125 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10126 entry.action.rx_queue = res->queue_id;
10127 entry.soft_id = res->fd_id_value;
10128 if (!strcmp(res->ops, "add"))
10129 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10130 RTE_ETH_FILTER_ADD, &entry);
10131 else if (!strcmp(res->ops, "del"))
10132 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10133 RTE_ETH_FILTER_DELETE, &entry);
10135 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10136 RTE_ETH_FILTER_UPDATE, &entry);
10138 printf("flow director programming error: (%s)\n",
10142 cmdline_parse_token_string_t cmd_flow_director_filter =
10143 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10144 flow_director_filter, "flow_director_filter");
10145 cmdline_parse_token_num_t cmd_flow_director_port_id =
10146 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10148 cmdline_parse_token_string_t cmd_flow_director_ops =
10149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10150 ops, "add#del#update");
10151 cmdline_parse_token_string_t cmd_flow_director_flow =
10152 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10154 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10155 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10156 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10157 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
10158 cmdline_parse_token_string_t cmd_flow_director_ether =
10159 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10161 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10162 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10163 ether_type, UINT16);
10164 cmdline_parse_token_string_t cmd_flow_director_src =
10165 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10167 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10168 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10170 cmdline_parse_token_num_t cmd_flow_director_port_src =
10171 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10173 cmdline_parse_token_string_t cmd_flow_director_dst =
10174 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10176 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10177 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10179 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10180 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10182 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10183 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10184 verify_tag, "verify_tag");
10185 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10186 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10187 verify_tag_value, UINT32);
10188 cmdline_parse_token_string_t cmd_flow_director_tos =
10189 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10191 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10192 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10194 cmdline_parse_token_string_t cmd_flow_director_proto =
10195 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10197 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10198 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10199 proto_value, UINT8);
10200 cmdline_parse_token_string_t cmd_flow_director_ttl =
10201 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10203 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10204 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10206 cmdline_parse_token_string_t cmd_flow_director_vlan =
10207 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10209 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10210 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10211 vlan_value, UINT16);
10212 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10213 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10214 flexbytes, "flexbytes");
10215 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10216 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10217 flexbytes_value, NULL);
10218 cmdline_parse_token_string_t cmd_flow_director_drop =
10219 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10221 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10222 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10224 cmdline_parse_token_string_t cmd_flow_director_queue =
10225 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10227 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10228 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10230 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10231 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10233 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10234 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10235 fd_id_value, UINT32);
10237 cmdline_parse_token_string_t cmd_flow_director_mode =
10238 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10240 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10241 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10243 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10244 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10245 mode_value, "MAC-VLAN");
10246 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10247 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10248 mode_value, "Tunnel");
10249 cmdline_parse_token_string_t cmd_flow_director_mac =
10250 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10252 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10253 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10255 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10258 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10259 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10260 tunnel_type, "NVGRE#VxLAN");
10261 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10263 tunnel_id, "tunnel-id");
10264 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10265 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10266 tunnel_id_value, UINT32);
10268 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10269 .f = cmd_flow_director_filter_parsed,
10271 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10272 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10273 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10274 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10275 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10276 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10277 "fd_id <fd_id_value>: "
10278 "Add or delete an ip flow director entry on NIC",
10280 (void *)&cmd_flow_director_filter,
10281 (void *)&cmd_flow_director_port_id,
10282 (void *)&cmd_flow_director_mode,
10283 (void *)&cmd_flow_director_mode_ip,
10284 (void *)&cmd_flow_director_ops,
10285 (void *)&cmd_flow_director_flow,
10286 (void *)&cmd_flow_director_flow_type,
10287 (void *)&cmd_flow_director_src,
10288 (void *)&cmd_flow_director_ip_src,
10289 (void *)&cmd_flow_director_dst,
10290 (void *)&cmd_flow_director_ip_dst,
10291 (void *)&cmd_flow_director_tos,
10292 (void *)&cmd_flow_director_tos_value,
10293 (void *)&cmd_flow_director_proto,
10294 (void *)&cmd_flow_director_proto_value,
10295 (void *)&cmd_flow_director_ttl,
10296 (void *)&cmd_flow_director_ttl_value,
10297 (void *)&cmd_flow_director_vlan,
10298 (void *)&cmd_flow_director_vlan_value,
10299 (void *)&cmd_flow_director_flexbytes,
10300 (void *)&cmd_flow_director_flexbytes_value,
10301 (void *)&cmd_flow_director_drop,
10302 (void *)&cmd_flow_director_pf_vf,
10303 (void *)&cmd_flow_director_queue,
10304 (void *)&cmd_flow_director_queue_id,
10305 (void *)&cmd_flow_director_fd_id,
10306 (void *)&cmd_flow_director_fd_id_value,
10311 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10312 .f = cmd_flow_director_filter_parsed,
10314 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10315 "director entry on NIC",
10317 (void *)&cmd_flow_director_filter,
10318 (void *)&cmd_flow_director_port_id,
10319 (void *)&cmd_flow_director_mode,
10320 (void *)&cmd_flow_director_mode_ip,
10321 (void *)&cmd_flow_director_ops,
10322 (void *)&cmd_flow_director_flow,
10323 (void *)&cmd_flow_director_flow_type,
10324 (void *)&cmd_flow_director_src,
10325 (void *)&cmd_flow_director_ip_src,
10326 (void *)&cmd_flow_director_port_src,
10327 (void *)&cmd_flow_director_dst,
10328 (void *)&cmd_flow_director_ip_dst,
10329 (void *)&cmd_flow_director_port_dst,
10330 (void *)&cmd_flow_director_tos,
10331 (void *)&cmd_flow_director_tos_value,
10332 (void *)&cmd_flow_director_ttl,
10333 (void *)&cmd_flow_director_ttl_value,
10334 (void *)&cmd_flow_director_vlan,
10335 (void *)&cmd_flow_director_vlan_value,
10336 (void *)&cmd_flow_director_flexbytes,
10337 (void *)&cmd_flow_director_flexbytes_value,
10338 (void *)&cmd_flow_director_drop,
10339 (void *)&cmd_flow_director_pf_vf,
10340 (void *)&cmd_flow_director_queue,
10341 (void *)&cmd_flow_director_queue_id,
10342 (void *)&cmd_flow_director_fd_id,
10343 (void *)&cmd_flow_director_fd_id_value,
10348 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10349 .f = cmd_flow_director_filter_parsed,
10351 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10352 "director entry on NIC",
10354 (void *)&cmd_flow_director_filter,
10355 (void *)&cmd_flow_director_port_id,
10356 (void *)&cmd_flow_director_mode,
10357 (void *)&cmd_flow_director_mode_ip,
10358 (void *)&cmd_flow_director_ops,
10359 (void *)&cmd_flow_director_flow,
10360 (void *)&cmd_flow_director_flow_type,
10361 (void *)&cmd_flow_director_src,
10362 (void *)&cmd_flow_director_ip_src,
10363 (void *)&cmd_flow_director_port_dst,
10364 (void *)&cmd_flow_director_dst,
10365 (void *)&cmd_flow_director_ip_dst,
10366 (void *)&cmd_flow_director_port_dst,
10367 (void *)&cmd_flow_director_verify_tag,
10368 (void *)&cmd_flow_director_verify_tag_value,
10369 (void *)&cmd_flow_director_tos,
10370 (void *)&cmd_flow_director_tos_value,
10371 (void *)&cmd_flow_director_ttl,
10372 (void *)&cmd_flow_director_ttl_value,
10373 (void *)&cmd_flow_director_vlan,
10374 (void *)&cmd_flow_director_vlan_value,
10375 (void *)&cmd_flow_director_flexbytes,
10376 (void *)&cmd_flow_director_flexbytes_value,
10377 (void *)&cmd_flow_director_drop,
10378 (void *)&cmd_flow_director_pf_vf,
10379 (void *)&cmd_flow_director_queue,
10380 (void *)&cmd_flow_director_queue_id,
10381 (void *)&cmd_flow_director_fd_id,
10382 (void *)&cmd_flow_director_fd_id_value,
10387 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10388 .f = cmd_flow_director_filter_parsed,
10390 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10391 "director entry on NIC",
10393 (void *)&cmd_flow_director_filter,
10394 (void *)&cmd_flow_director_port_id,
10395 (void *)&cmd_flow_director_mode,
10396 (void *)&cmd_flow_director_mode_ip,
10397 (void *)&cmd_flow_director_ops,
10398 (void *)&cmd_flow_director_flow,
10399 (void *)&cmd_flow_director_flow_type,
10400 (void *)&cmd_flow_director_ether,
10401 (void *)&cmd_flow_director_ether_type,
10402 (void *)&cmd_flow_director_flexbytes,
10403 (void *)&cmd_flow_director_flexbytes_value,
10404 (void *)&cmd_flow_director_drop,
10405 (void *)&cmd_flow_director_pf_vf,
10406 (void *)&cmd_flow_director_queue,
10407 (void *)&cmd_flow_director_queue_id,
10408 (void *)&cmd_flow_director_fd_id,
10409 (void *)&cmd_flow_director_fd_id_value,
10414 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10415 .f = cmd_flow_director_filter_parsed,
10417 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10418 "director entry on NIC",
10420 (void *)&cmd_flow_director_filter,
10421 (void *)&cmd_flow_director_port_id,
10422 (void *)&cmd_flow_director_mode,
10423 (void *)&cmd_flow_director_mode_mac_vlan,
10424 (void *)&cmd_flow_director_ops,
10425 (void *)&cmd_flow_director_mac,
10426 (void *)&cmd_flow_director_mac_addr,
10427 (void *)&cmd_flow_director_vlan,
10428 (void *)&cmd_flow_director_vlan_value,
10429 (void *)&cmd_flow_director_flexbytes,
10430 (void *)&cmd_flow_director_flexbytes_value,
10431 (void *)&cmd_flow_director_drop,
10432 (void *)&cmd_flow_director_queue,
10433 (void *)&cmd_flow_director_queue_id,
10434 (void *)&cmd_flow_director_fd_id,
10435 (void *)&cmd_flow_director_fd_id_value,
10440 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10441 .f = cmd_flow_director_filter_parsed,
10443 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10444 "director entry on NIC",
10446 (void *)&cmd_flow_director_filter,
10447 (void *)&cmd_flow_director_port_id,
10448 (void *)&cmd_flow_director_mode,
10449 (void *)&cmd_flow_director_mode_tunnel,
10450 (void *)&cmd_flow_director_ops,
10451 (void *)&cmd_flow_director_mac,
10452 (void *)&cmd_flow_director_mac_addr,
10453 (void *)&cmd_flow_director_vlan,
10454 (void *)&cmd_flow_director_vlan_value,
10455 (void *)&cmd_flow_director_tunnel,
10456 (void *)&cmd_flow_director_tunnel_type,
10457 (void *)&cmd_flow_director_tunnel_id,
10458 (void *)&cmd_flow_director_tunnel_id_value,
10459 (void *)&cmd_flow_director_flexbytes,
10460 (void *)&cmd_flow_director_flexbytes_value,
10461 (void *)&cmd_flow_director_drop,
10462 (void *)&cmd_flow_director_queue,
10463 (void *)&cmd_flow_director_queue_id,
10464 (void *)&cmd_flow_director_fd_id,
10465 (void *)&cmd_flow_director_fd_id_value,
10470 struct cmd_flush_flow_director_result {
10471 cmdline_fixed_string_t flush_flow_director;
10475 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10476 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10477 flush_flow_director, "flush_flow_director");
10478 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10479 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10483 cmd_flush_flow_director_parsed(void *parsed_result,
10484 __attribute__((unused)) struct cmdline *cl,
10485 __attribute__((unused)) void *data)
10487 struct cmd_flow_director_result *res = parsed_result;
10490 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10492 printf("flow director is not supported on port %u.\n",
10497 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10498 RTE_ETH_FILTER_FLUSH, NULL);
10500 printf("flow director table flushing error: (%s)\n",
10504 cmdline_parse_inst_t cmd_flush_flow_director = {
10505 .f = cmd_flush_flow_director_parsed,
10507 .help_str = "flush_flow_director <port_id>: "
10508 "Flush all flow director entries of a device on NIC",
10510 (void *)&cmd_flush_flow_director_flush,
10511 (void *)&cmd_flush_flow_director_port_id,
10516 /* *** deal with flow director mask *** */
10517 struct cmd_flow_director_mask_result {
10518 cmdline_fixed_string_t flow_director_mask;
10520 cmdline_fixed_string_t mode;
10521 cmdline_fixed_string_t mode_value;
10522 cmdline_fixed_string_t vlan;
10523 uint16_t vlan_mask;
10524 cmdline_fixed_string_t src_mask;
10525 cmdline_ipaddr_t ipv4_src;
10526 cmdline_ipaddr_t ipv6_src;
10528 cmdline_fixed_string_t dst_mask;
10529 cmdline_ipaddr_t ipv4_dst;
10530 cmdline_ipaddr_t ipv6_dst;
10532 cmdline_fixed_string_t mac;
10533 uint8_t mac_addr_byte_mask;
10534 cmdline_fixed_string_t tunnel_id;
10535 uint32_t tunnel_id_mask;
10536 cmdline_fixed_string_t tunnel_type;
10537 uint8_t tunnel_type_mask;
10541 cmd_flow_director_mask_parsed(void *parsed_result,
10542 __attribute__((unused)) struct cmdline *cl,
10543 __attribute__((unused)) void *data)
10545 struct cmd_flow_director_mask_result *res = parsed_result;
10546 struct rte_eth_fdir_masks *mask;
10547 struct rte_port *port;
10549 if (res->port_id > nb_ports) {
10550 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10554 port = &ports[res->port_id];
10555 /** Check if the port is not started **/
10556 if (port->port_status != RTE_PORT_STOPPED) {
10557 printf("Please stop port %d first\n", res->port_id);
10561 mask = &port->dev_conf.fdir_conf.mask;
10563 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10564 if (strcmp(res->mode_value, "MAC-VLAN")) {
10565 printf("Please set mode to MAC-VLAN.\n");
10569 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10570 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10571 if (strcmp(res->mode_value, "Tunnel")) {
10572 printf("Please set mode to Tunnel.\n");
10576 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10577 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10578 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10579 mask->tunnel_type_mask = res->tunnel_type_mask;
10581 if (strcmp(res->mode_value, "IP")) {
10582 printf("Please set mode to IP.\n");
10586 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10587 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10588 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10589 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10590 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10591 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10592 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10595 cmd_reconfig_device_queue(res->port_id, 1, 1);
10598 cmdline_parse_token_string_t cmd_flow_director_mask =
10599 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10600 flow_director_mask, "flow_director_mask");
10601 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10602 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10604 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10605 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10607 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10608 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10609 vlan_mask, UINT16);
10610 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10611 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10612 src_mask, "src_mask");
10613 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10614 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10616 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10617 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10619 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10620 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10622 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10623 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10624 dst_mask, "dst_mask");
10625 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10626 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10628 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10629 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10631 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10632 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10635 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10636 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10638 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10639 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10641 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10642 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10643 mode_value, "MAC-VLAN");
10644 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10645 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10646 mode_value, "Tunnel");
10647 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10648 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10650 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10651 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10652 mac_addr_byte_mask, UINT8);
10653 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10654 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10655 tunnel_type, "tunnel-type");
10656 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10657 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10658 tunnel_type_mask, UINT8);
10659 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10660 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10661 tunnel_id, "tunnel-id");
10662 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10663 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10664 tunnel_id_mask, UINT32);
10666 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10667 .f = cmd_flow_director_mask_parsed,
10669 .help_str = "flow_director_mask ... : "
10670 "Set IP mode flow director's mask on NIC",
10672 (void *)&cmd_flow_director_mask,
10673 (void *)&cmd_flow_director_mask_port_id,
10674 (void *)&cmd_flow_director_mask_mode,
10675 (void *)&cmd_flow_director_mask_mode_ip,
10676 (void *)&cmd_flow_director_mask_vlan,
10677 (void *)&cmd_flow_director_mask_vlan_value,
10678 (void *)&cmd_flow_director_mask_src,
10679 (void *)&cmd_flow_director_mask_ipv4_src,
10680 (void *)&cmd_flow_director_mask_ipv6_src,
10681 (void *)&cmd_flow_director_mask_port_src,
10682 (void *)&cmd_flow_director_mask_dst,
10683 (void *)&cmd_flow_director_mask_ipv4_dst,
10684 (void *)&cmd_flow_director_mask_ipv6_dst,
10685 (void *)&cmd_flow_director_mask_port_dst,
10690 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10691 .f = cmd_flow_director_mask_parsed,
10693 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10694 "flow director's mask on NIC",
10696 (void *)&cmd_flow_director_mask,
10697 (void *)&cmd_flow_director_mask_port_id,
10698 (void *)&cmd_flow_director_mask_mode,
10699 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10700 (void *)&cmd_flow_director_mask_vlan,
10701 (void *)&cmd_flow_director_mask_vlan_value,
10706 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10707 .f = cmd_flow_director_mask_parsed,
10709 .help_str = "flow_director_mask ... : Set tunnel mode "
10710 "flow director's mask on NIC",
10712 (void *)&cmd_flow_director_mask,
10713 (void *)&cmd_flow_director_mask_port_id,
10714 (void *)&cmd_flow_director_mask_mode,
10715 (void *)&cmd_flow_director_mask_mode_tunnel,
10716 (void *)&cmd_flow_director_mask_vlan,
10717 (void *)&cmd_flow_director_mask_vlan_value,
10718 (void *)&cmd_flow_director_mask_mac,
10719 (void *)&cmd_flow_director_mask_mac_value,
10720 (void *)&cmd_flow_director_mask_tunnel_type,
10721 (void *)&cmd_flow_director_mask_tunnel_type_value,
10722 (void *)&cmd_flow_director_mask_tunnel_id,
10723 (void *)&cmd_flow_director_mask_tunnel_id_value,
10728 /* *** deal with flow director mask on flexible payload *** */
10729 struct cmd_flow_director_flex_mask_result {
10730 cmdline_fixed_string_t flow_director_flexmask;
10732 cmdline_fixed_string_t flow;
10733 cmdline_fixed_string_t flow_type;
10734 cmdline_fixed_string_t mask;
10738 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10739 __attribute__((unused)) struct cmdline *cl,
10740 __attribute__((unused)) void *data)
10742 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10743 struct rte_eth_fdir_info fdir_info;
10744 struct rte_eth_fdir_flex_mask flex_mask;
10745 struct rte_port *port;
10746 uint32_t flow_type_mask;
10750 if (res->port_id > nb_ports) {
10751 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10755 port = &ports[res->port_id];
10756 /** Check if the port is not started **/
10757 if (port->port_status != RTE_PORT_STOPPED) {
10758 printf("Please stop port %d first\n", res->port_id);
10762 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10763 ret = parse_flexbytes(res->mask,
10765 RTE_ETH_FDIR_MAX_FLEXLEN);
10767 printf("error: Cannot parse mask input.\n");
10771 memset(&fdir_info, 0, sizeof(fdir_info));
10772 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10773 RTE_ETH_FILTER_INFO, &fdir_info);
10775 printf("Cannot get FDir filter info\n");
10779 if (!strcmp(res->flow_type, "none")) {
10780 /* means don't specify the flow type */
10781 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10782 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10783 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10784 0, sizeof(struct rte_eth_fdir_flex_mask));
10785 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10786 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10788 sizeof(struct rte_eth_fdir_flex_mask));
10789 cmd_reconfig_device_queue(res->port_id, 1, 1);
10792 flow_type_mask = fdir_info.flow_types_mask[0];
10793 if (!strcmp(res->flow_type, "all")) {
10794 if (!flow_type_mask) {
10795 printf("No flow type supported\n");
10798 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10799 if (flow_type_mask & (1 << i)) {
10800 flex_mask.flow_type = i;
10801 fdir_set_flex_mask(res->port_id, &flex_mask);
10804 cmd_reconfig_device_queue(res->port_id, 1, 1);
10807 flex_mask.flow_type = str2flowtype(res->flow_type);
10808 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10809 printf("Flow type %s not supported on port %d\n",
10810 res->flow_type, res->port_id);
10813 fdir_set_flex_mask(res->port_id, &flex_mask);
10814 cmd_reconfig_device_queue(res->port_id, 1, 1);
10817 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10818 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10819 flow_director_flexmask,
10820 "flow_director_flex_mask");
10821 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10822 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10824 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10825 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10827 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10828 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10829 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10830 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10831 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10832 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10835 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10836 .f = cmd_flow_director_flex_mask_parsed,
10838 .help_str = "flow_director_flex_mask ... : "
10839 "Set flow director's flex mask on NIC",
10841 (void *)&cmd_flow_director_flexmask,
10842 (void *)&cmd_flow_director_flexmask_port_id,
10843 (void *)&cmd_flow_director_flexmask_flow,
10844 (void *)&cmd_flow_director_flexmask_flow_type,
10845 (void *)&cmd_flow_director_flexmask_mask,
10850 /* *** deal with flow director flexible payload configuration *** */
10851 struct cmd_flow_director_flexpayload_result {
10852 cmdline_fixed_string_t flow_director_flexpayload;
10854 cmdline_fixed_string_t payload_layer;
10855 cmdline_fixed_string_t payload_cfg;
10859 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10862 const char *p, *p0 = q_arg;
10864 unsigned long int_fld;
10865 char *str_fld[max_num];
10870 p = strchr(p0, '(');
10874 p0 = strchr(p, ')');
10879 if (size >= sizeof(s))
10882 snprintf(s, sizeof(s), "%.*s", size, p);
10883 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10884 if (ret < 0 || ret > max_num)
10886 for (i = 0; i < ret; i++) {
10888 int_fld = strtoul(str_fld[i], &end, 0);
10889 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10891 offsets[i] = (uint16_t)int_fld;
10897 cmd_flow_director_flxpld_parsed(void *parsed_result,
10898 __attribute__((unused)) struct cmdline *cl,
10899 __attribute__((unused)) void *data)
10901 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10902 struct rte_eth_flex_payload_cfg flex_cfg;
10903 struct rte_port *port;
10906 if (res->port_id > nb_ports) {
10907 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10911 port = &ports[res->port_id];
10912 /** Check if the port is not started **/
10913 if (port->port_status != RTE_PORT_STOPPED) {
10914 printf("Please stop port %d first\n", res->port_id);
10918 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10920 if (!strcmp(res->payload_layer, "raw"))
10921 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10922 else if (!strcmp(res->payload_layer, "l2"))
10923 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10924 else if (!strcmp(res->payload_layer, "l3"))
10925 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10926 else if (!strcmp(res->payload_layer, "l4"))
10927 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10929 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10930 RTE_ETH_FDIR_MAX_FLEXLEN);
10932 printf("error: Cannot parse flex payload input.\n");
10936 fdir_set_flex_payload(res->port_id, &flex_cfg);
10937 cmd_reconfig_device_queue(res->port_id, 1, 1);
10940 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10941 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10942 flow_director_flexpayload,
10943 "flow_director_flex_payload");
10944 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10945 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10947 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10948 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10949 payload_layer, "raw#l2#l3#l4");
10950 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10951 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10952 payload_cfg, NULL);
10954 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10955 .f = cmd_flow_director_flxpld_parsed,
10957 .help_str = "flow_director_flexpayload ... : "
10958 "Set flow director's flex payload on NIC",
10960 (void *)&cmd_flow_director_flexpayload,
10961 (void *)&cmd_flow_director_flexpayload_port_id,
10962 (void *)&cmd_flow_director_flexpayload_payload_layer,
10963 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10968 /* Generic flow interface command. */
10969 extern cmdline_parse_inst_t cmd_flow;
10971 /* *** Classification Filters Control *** */
10972 /* *** Get symmetric hash enable per port *** */
10973 struct cmd_get_sym_hash_ena_per_port_result {
10974 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10979 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10980 __rte_unused struct cmdline *cl,
10981 __rte_unused void *data)
10983 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10984 struct rte_eth_hash_filter_info info;
10987 if (rte_eth_dev_filter_supported(res->port_id,
10988 RTE_ETH_FILTER_HASH) < 0) {
10989 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10994 memset(&info, 0, sizeof(info));
10995 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10996 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10997 RTE_ETH_FILTER_GET, &info);
11000 printf("Cannot get symmetric hash enable per port "
11001 "on port %u\n", res->port_id);
11005 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11006 "enabled" : "disabled", res->port_id);
11009 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11010 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11011 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11012 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11013 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11016 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11017 .f = cmd_get_sym_hash_per_port_parsed,
11019 .help_str = "get_sym_hash_ena_per_port <port_id>",
11021 (void *)&cmd_get_sym_hash_ena_per_port_all,
11022 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11027 /* *** Set symmetric hash enable per port *** */
11028 struct cmd_set_sym_hash_ena_per_port_result {
11029 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11030 cmdline_fixed_string_t enable;
11035 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11036 __rte_unused struct cmdline *cl,
11037 __rte_unused void *data)
11039 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11040 struct rte_eth_hash_filter_info info;
11043 if (rte_eth_dev_filter_supported(res->port_id,
11044 RTE_ETH_FILTER_HASH) < 0) {
11045 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11050 memset(&info, 0, sizeof(info));
11051 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11052 if (!strcmp(res->enable, "enable"))
11053 info.info.enable = 1;
11054 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11055 RTE_ETH_FILTER_SET, &info);
11057 printf("Cannot set symmetric hash enable per port on "
11058 "port %u\n", res->port_id);
11061 printf("Symmetric hash has been set to %s on port %u\n",
11062 res->enable, res->port_id);
11065 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11066 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11067 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11068 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11069 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11071 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11072 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11073 enable, "enable#disable");
11075 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11076 .f = cmd_set_sym_hash_per_port_parsed,
11078 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11080 (void *)&cmd_set_sym_hash_ena_per_port_all,
11081 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11082 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11087 /* Get global config of hash function */
11088 struct cmd_get_hash_global_config_result {
11089 cmdline_fixed_string_t get_hash_global_config;
11094 flowtype_to_str(uint16_t ftype)
11100 } ftype_table[] = {
11101 {"ipv4", RTE_ETH_FLOW_IPV4},
11102 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11103 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11104 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11105 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11106 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11107 {"ipv6", RTE_ETH_FLOW_IPV6},
11108 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11109 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11110 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11111 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11112 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11113 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11114 {"port", RTE_ETH_FLOW_PORT},
11115 {"vxlan", RTE_ETH_FLOW_VXLAN},
11116 {"geneve", RTE_ETH_FLOW_GENEVE},
11117 {"nvgre", RTE_ETH_FLOW_NVGRE},
11120 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11121 if (ftype_table[i].ftype == ftype)
11122 return ftype_table[i].str;
11129 cmd_get_hash_global_config_parsed(void *parsed_result,
11130 __rte_unused struct cmdline *cl,
11131 __rte_unused void *data)
11133 struct cmd_get_hash_global_config_result *res = parsed_result;
11134 struct rte_eth_hash_filter_info info;
11135 uint32_t idx, offset;
11140 if (rte_eth_dev_filter_supported(res->port_id,
11141 RTE_ETH_FILTER_HASH) < 0) {
11142 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11147 memset(&info, 0, sizeof(info));
11148 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11149 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11150 RTE_ETH_FILTER_GET, &info);
11152 printf("Cannot get hash global configurations by port %d\n",
11157 switch (info.info.global_conf.hash_func) {
11158 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11159 printf("Hash function is Toeplitz\n");
11161 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11162 printf("Hash function is Simple XOR\n");
11165 printf("Unknown hash function\n");
11169 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11170 idx = i / UINT32_BIT;
11171 offset = i % UINT32_BIT;
11172 if (!(info.info.global_conf.valid_bit_mask[idx] &
11175 str = flowtype_to_str(i);
11178 printf("Symmetric hash is %s globally for flow type %s "
11180 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11181 (1UL << offset)) ? "enabled" : "disabled"), str,
11186 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11187 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11188 get_hash_global_config, "get_hash_global_config");
11189 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11190 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11193 cmdline_parse_inst_t cmd_get_hash_global_config = {
11194 .f = cmd_get_hash_global_config_parsed,
11196 .help_str = "get_hash_global_config <port_id>",
11198 (void *)&cmd_get_hash_global_config_all,
11199 (void *)&cmd_get_hash_global_config_port_id,
11204 /* Set global config of hash function */
11205 struct cmd_set_hash_global_config_result {
11206 cmdline_fixed_string_t set_hash_global_config;
11208 cmdline_fixed_string_t hash_func;
11209 cmdline_fixed_string_t flow_type;
11210 cmdline_fixed_string_t enable;
11214 cmd_set_hash_global_config_parsed(void *parsed_result,
11215 __rte_unused struct cmdline *cl,
11216 __rte_unused void *data)
11218 struct cmd_set_hash_global_config_result *res = parsed_result;
11219 struct rte_eth_hash_filter_info info;
11220 uint32_t ftype, idx, offset;
11223 if (rte_eth_dev_filter_supported(res->port_id,
11224 RTE_ETH_FILTER_HASH) < 0) {
11225 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11229 memset(&info, 0, sizeof(info));
11230 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11231 if (!strcmp(res->hash_func, "toeplitz"))
11232 info.info.global_conf.hash_func =
11233 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11234 else if (!strcmp(res->hash_func, "simple_xor"))
11235 info.info.global_conf.hash_func =
11236 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11237 else if (!strcmp(res->hash_func, "default"))
11238 info.info.global_conf.hash_func =
11239 RTE_ETH_HASH_FUNCTION_DEFAULT;
11241 ftype = str2flowtype(res->flow_type);
11242 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11243 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11244 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11245 if (!strcmp(res->enable, "enable"))
11246 info.info.global_conf.sym_hash_enable_mask[idx] |=
11248 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11249 RTE_ETH_FILTER_SET, &info);
11251 printf("Cannot set global hash configurations by port %d\n",
11254 printf("Global hash configurations have been set "
11255 "succcessfully by port %d\n", res->port_id);
11258 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11259 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11260 set_hash_global_config, "set_hash_global_config");
11261 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11262 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11264 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11265 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11266 hash_func, "toeplitz#simple_xor#default");
11267 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11268 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11270 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11271 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11272 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11273 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11274 enable, "enable#disable");
11276 cmdline_parse_inst_t cmd_set_hash_global_config = {
11277 .f = cmd_set_hash_global_config_parsed,
11279 .help_str = "set_hash_global_config <port_id> "
11280 "toeplitz|simple_xor|default "
11281 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11282 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11283 "l2_payload enable|disable",
11285 (void *)&cmd_set_hash_global_config_all,
11286 (void *)&cmd_set_hash_global_config_port_id,
11287 (void *)&cmd_set_hash_global_config_hash_func,
11288 (void *)&cmd_set_hash_global_config_flow_type,
11289 (void *)&cmd_set_hash_global_config_enable,
11294 /* Set hash input set */
11295 struct cmd_set_hash_input_set_result {
11296 cmdline_fixed_string_t set_hash_input_set;
11298 cmdline_fixed_string_t flow_type;
11299 cmdline_fixed_string_t inset_field;
11300 cmdline_fixed_string_t select;
11303 static enum rte_eth_input_set_field
11304 str2inset(char *string)
11308 static const struct {
11310 enum rte_eth_input_set_field inset;
11311 } inset_table[] = {
11312 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11313 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11314 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11315 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11316 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11317 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11318 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11319 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11320 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11321 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11322 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11323 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11324 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11325 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11326 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11327 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11328 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11329 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11330 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11331 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11332 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11333 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11334 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11335 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11336 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11337 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11338 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11339 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11340 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11341 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11342 {"none", RTE_ETH_INPUT_SET_NONE},
11345 for (i = 0; i < RTE_DIM(inset_table); i++) {
11346 if (!strcmp(string, inset_table[i].str))
11347 return inset_table[i].inset;
11350 return RTE_ETH_INPUT_SET_UNKNOWN;
11354 cmd_set_hash_input_set_parsed(void *parsed_result,
11355 __rte_unused struct cmdline *cl,
11356 __rte_unused void *data)
11358 struct cmd_set_hash_input_set_result *res = parsed_result;
11359 struct rte_eth_hash_filter_info info;
11361 memset(&info, 0, sizeof(info));
11362 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11363 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11364 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11365 info.info.input_set_conf.inset_size = 1;
11366 if (!strcmp(res->select, "select"))
11367 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11368 else if (!strcmp(res->select, "add"))
11369 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11370 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11371 RTE_ETH_FILTER_SET, &info);
11374 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11375 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11376 set_hash_input_set, "set_hash_input_set");
11377 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11378 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11380 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11381 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11383 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11384 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11386 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11387 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11388 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11389 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11390 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11392 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11393 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11394 select, "select#add");
11396 cmdline_parse_inst_t cmd_set_hash_input_set = {
11397 .f = cmd_set_hash_input_set_parsed,
11399 .help_str = "set_hash_input_set <port_id> "
11400 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11401 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11402 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11403 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11404 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11405 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11406 "fld-7th|fld-8th|none select|add",
11408 (void *)&cmd_set_hash_input_set_cmd,
11409 (void *)&cmd_set_hash_input_set_port_id,
11410 (void *)&cmd_set_hash_input_set_flow_type,
11411 (void *)&cmd_set_hash_input_set_field,
11412 (void *)&cmd_set_hash_input_set_select,
11417 /* Set flow director input set */
11418 struct cmd_set_fdir_input_set_result {
11419 cmdline_fixed_string_t set_fdir_input_set;
11421 cmdline_fixed_string_t flow_type;
11422 cmdline_fixed_string_t inset_field;
11423 cmdline_fixed_string_t select;
11427 cmd_set_fdir_input_set_parsed(void *parsed_result,
11428 __rte_unused struct cmdline *cl,
11429 __rte_unused void *data)
11431 struct cmd_set_fdir_input_set_result *res = parsed_result;
11432 struct rte_eth_fdir_filter_info info;
11434 memset(&info, 0, sizeof(info));
11435 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11436 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11437 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11438 info.info.input_set_conf.inset_size = 1;
11439 if (!strcmp(res->select, "select"))
11440 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11441 else if (!strcmp(res->select, "add"))
11442 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11443 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11444 RTE_ETH_FILTER_SET, &info);
11447 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11448 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11449 set_fdir_input_set, "set_fdir_input_set");
11450 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11451 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11453 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11454 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11456 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11457 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11458 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11459 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11461 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11462 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11463 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11464 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11465 "sctp-veri-tag#none");
11466 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11467 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11468 select, "select#add");
11470 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11471 .f = cmd_set_fdir_input_set_parsed,
11473 .help_str = "set_fdir_input_set <port_id> "
11474 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11475 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11476 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11477 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11478 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11479 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11480 "sctp-veri-tag|none select|add",
11482 (void *)&cmd_set_fdir_input_set_cmd,
11483 (void *)&cmd_set_fdir_input_set_port_id,
11484 (void *)&cmd_set_fdir_input_set_flow_type,
11485 (void *)&cmd_set_fdir_input_set_field,
11486 (void *)&cmd_set_fdir_input_set_select,
11491 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11492 struct cmd_mcast_addr_result {
11493 cmdline_fixed_string_t mcast_addr_cmd;
11494 cmdline_fixed_string_t what;
11496 struct ether_addr mc_addr;
11499 static void cmd_mcast_addr_parsed(void *parsed_result,
11500 __attribute__((unused)) struct cmdline *cl,
11501 __attribute__((unused)) void *data)
11503 struct cmd_mcast_addr_result *res = parsed_result;
11505 if (!is_multicast_ether_addr(&res->mc_addr)) {
11506 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11507 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11508 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11509 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11512 if (strcmp(res->what, "add") == 0)
11513 mcast_addr_add(res->port_num, &res->mc_addr);
11515 mcast_addr_remove(res->port_num, &res->mc_addr);
11518 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11519 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11520 mcast_addr_cmd, "mcast_addr");
11521 cmdline_parse_token_string_t cmd_mcast_addr_what =
11522 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11524 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11525 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11526 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11527 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11529 cmdline_parse_inst_t cmd_mcast_addr = {
11530 .f = cmd_mcast_addr_parsed,
11532 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11533 "Add/Remove multicast MAC address on port_id",
11535 (void *)&cmd_mcast_addr_cmd,
11536 (void *)&cmd_mcast_addr_what,
11537 (void *)&cmd_mcast_addr_portnum,
11538 (void *)&cmd_mcast_addr_addr,
11543 /* l2 tunnel config
11544 * only support E-tag now.
11547 /* Ether type config */
11548 struct cmd_config_l2_tunnel_eth_type_result {
11549 cmdline_fixed_string_t port;
11550 cmdline_fixed_string_t config;
11551 cmdline_fixed_string_t all;
11553 cmdline_fixed_string_t l2_tunnel;
11554 cmdline_fixed_string_t l2_tunnel_type;
11555 cmdline_fixed_string_t eth_type;
11556 uint16_t eth_type_val;
11559 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11560 TOKEN_STRING_INITIALIZER
11561 (struct cmd_config_l2_tunnel_eth_type_result,
11563 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11564 TOKEN_STRING_INITIALIZER
11565 (struct cmd_config_l2_tunnel_eth_type_result,
11567 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11568 TOKEN_STRING_INITIALIZER
11569 (struct cmd_config_l2_tunnel_eth_type_result,
11571 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11572 TOKEN_NUM_INITIALIZER
11573 (struct cmd_config_l2_tunnel_eth_type_result,
11575 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11576 TOKEN_STRING_INITIALIZER
11577 (struct cmd_config_l2_tunnel_eth_type_result,
11578 l2_tunnel, "l2-tunnel");
11579 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11580 TOKEN_STRING_INITIALIZER
11581 (struct cmd_config_l2_tunnel_eth_type_result,
11582 l2_tunnel_type, "E-tag");
11583 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11584 TOKEN_STRING_INITIALIZER
11585 (struct cmd_config_l2_tunnel_eth_type_result,
11586 eth_type, "ether-type");
11587 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11588 TOKEN_NUM_INITIALIZER
11589 (struct cmd_config_l2_tunnel_eth_type_result,
11590 eth_type_val, UINT16);
11592 static enum rte_eth_tunnel_type
11593 str2fdir_l2_tunnel_type(char *string)
11597 static const struct {
11599 enum rte_eth_tunnel_type type;
11600 } l2_tunnel_type_str[] = {
11601 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11604 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11605 if (!strcmp(l2_tunnel_type_str[i].str, string))
11606 return l2_tunnel_type_str[i].type;
11608 return RTE_TUNNEL_TYPE_NONE;
11611 /* ether type config for all ports */
11613 cmd_config_l2_tunnel_eth_type_all_parsed
11614 (void *parsed_result,
11615 __attribute__((unused)) struct cmdline *cl,
11616 __attribute__((unused)) void *data)
11618 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11619 struct rte_eth_l2_tunnel_conf entry;
11622 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11623 entry.ether_type = res->eth_type_val;
11625 RTE_ETH_FOREACH_DEV(pid) {
11626 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11630 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11631 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11633 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11635 (void *)&cmd_config_l2_tunnel_eth_type_port,
11636 (void *)&cmd_config_l2_tunnel_eth_type_config,
11637 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11638 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11639 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11640 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11641 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11646 /* ether type config for a specific port */
11648 cmd_config_l2_tunnel_eth_type_specific_parsed(
11649 void *parsed_result,
11650 __attribute__((unused)) struct cmdline *cl,
11651 __attribute__((unused)) void *data)
11653 struct cmd_config_l2_tunnel_eth_type_result *res =
11655 struct rte_eth_l2_tunnel_conf entry;
11657 if (port_id_is_invalid(res->id, ENABLED_WARN))
11660 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11661 entry.ether_type = res->eth_type_val;
11663 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11666 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11667 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11669 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11671 (void *)&cmd_config_l2_tunnel_eth_type_port,
11672 (void *)&cmd_config_l2_tunnel_eth_type_config,
11673 (void *)&cmd_config_l2_tunnel_eth_type_id,
11674 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11675 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11676 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11677 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11682 /* Enable/disable l2 tunnel */
11683 struct cmd_config_l2_tunnel_en_dis_result {
11684 cmdline_fixed_string_t port;
11685 cmdline_fixed_string_t config;
11686 cmdline_fixed_string_t all;
11688 cmdline_fixed_string_t l2_tunnel;
11689 cmdline_fixed_string_t l2_tunnel_type;
11690 cmdline_fixed_string_t en_dis;
11693 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11694 TOKEN_STRING_INITIALIZER
11695 (struct cmd_config_l2_tunnel_en_dis_result,
11697 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11698 TOKEN_STRING_INITIALIZER
11699 (struct cmd_config_l2_tunnel_en_dis_result,
11701 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11702 TOKEN_STRING_INITIALIZER
11703 (struct cmd_config_l2_tunnel_en_dis_result,
11705 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11706 TOKEN_NUM_INITIALIZER
11707 (struct cmd_config_l2_tunnel_en_dis_result,
11709 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11710 TOKEN_STRING_INITIALIZER
11711 (struct cmd_config_l2_tunnel_en_dis_result,
11712 l2_tunnel, "l2-tunnel");
11713 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11714 TOKEN_STRING_INITIALIZER
11715 (struct cmd_config_l2_tunnel_en_dis_result,
11716 l2_tunnel_type, "E-tag");
11717 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11718 TOKEN_STRING_INITIALIZER
11719 (struct cmd_config_l2_tunnel_en_dis_result,
11720 en_dis, "enable#disable");
11722 /* enable/disable l2 tunnel for all ports */
11724 cmd_config_l2_tunnel_en_dis_all_parsed(
11725 void *parsed_result,
11726 __attribute__((unused)) struct cmdline *cl,
11727 __attribute__((unused)) void *data)
11729 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11730 struct rte_eth_l2_tunnel_conf entry;
11734 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11736 if (!strcmp("enable", res->en_dis))
11741 RTE_ETH_FOREACH_DEV(pid) {
11742 rte_eth_dev_l2_tunnel_offload_set(pid,
11744 ETH_L2_TUNNEL_ENABLE_MASK,
11749 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11750 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11752 .help_str = "port config all l2-tunnel E-tag enable|disable",
11754 (void *)&cmd_config_l2_tunnel_en_dis_port,
11755 (void *)&cmd_config_l2_tunnel_en_dis_config,
11756 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11757 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11758 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11759 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11764 /* enable/disable l2 tunnel for a port */
11766 cmd_config_l2_tunnel_en_dis_specific_parsed(
11767 void *parsed_result,
11768 __attribute__((unused)) struct cmdline *cl,
11769 __attribute__((unused)) void *data)
11771 struct cmd_config_l2_tunnel_en_dis_result *res =
11773 struct rte_eth_l2_tunnel_conf entry;
11775 if (port_id_is_invalid(res->id, ENABLED_WARN))
11778 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11780 if (!strcmp("enable", res->en_dis))
11781 rte_eth_dev_l2_tunnel_offload_set(res->id,
11783 ETH_L2_TUNNEL_ENABLE_MASK,
11786 rte_eth_dev_l2_tunnel_offload_set(res->id,
11788 ETH_L2_TUNNEL_ENABLE_MASK,
11792 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11793 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11795 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11797 (void *)&cmd_config_l2_tunnel_en_dis_port,
11798 (void *)&cmd_config_l2_tunnel_en_dis_config,
11799 (void *)&cmd_config_l2_tunnel_en_dis_id,
11800 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11801 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11802 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11807 /* E-tag configuration */
11809 /* Common result structure for all E-tag configuration */
11810 struct cmd_config_e_tag_result {
11811 cmdline_fixed_string_t e_tag;
11812 cmdline_fixed_string_t set;
11813 cmdline_fixed_string_t insertion;
11814 cmdline_fixed_string_t stripping;
11815 cmdline_fixed_string_t forwarding;
11816 cmdline_fixed_string_t filter;
11817 cmdline_fixed_string_t add;
11818 cmdline_fixed_string_t del;
11819 cmdline_fixed_string_t on;
11820 cmdline_fixed_string_t off;
11821 cmdline_fixed_string_t on_off;
11822 cmdline_fixed_string_t port_tag_id;
11823 uint32_t port_tag_id_val;
11824 cmdline_fixed_string_t e_tag_id;
11825 uint16_t e_tag_id_val;
11826 cmdline_fixed_string_t dst_pool;
11827 uint8_t dst_pool_val;
11828 cmdline_fixed_string_t port;
11830 cmdline_fixed_string_t vf;
11834 /* Common CLI fields for all E-tag configuration */
11835 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11836 TOKEN_STRING_INITIALIZER
11837 (struct cmd_config_e_tag_result,
11839 cmdline_parse_token_string_t cmd_config_e_tag_set =
11840 TOKEN_STRING_INITIALIZER
11841 (struct cmd_config_e_tag_result,
11843 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11844 TOKEN_STRING_INITIALIZER
11845 (struct cmd_config_e_tag_result,
11846 insertion, "insertion");
11847 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11848 TOKEN_STRING_INITIALIZER
11849 (struct cmd_config_e_tag_result,
11850 stripping, "stripping");
11851 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11852 TOKEN_STRING_INITIALIZER
11853 (struct cmd_config_e_tag_result,
11854 forwarding, "forwarding");
11855 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11856 TOKEN_STRING_INITIALIZER
11857 (struct cmd_config_e_tag_result,
11859 cmdline_parse_token_string_t cmd_config_e_tag_add =
11860 TOKEN_STRING_INITIALIZER
11861 (struct cmd_config_e_tag_result,
11863 cmdline_parse_token_string_t cmd_config_e_tag_del =
11864 TOKEN_STRING_INITIALIZER
11865 (struct cmd_config_e_tag_result,
11867 cmdline_parse_token_string_t cmd_config_e_tag_on =
11868 TOKEN_STRING_INITIALIZER
11869 (struct cmd_config_e_tag_result,
11871 cmdline_parse_token_string_t cmd_config_e_tag_off =
11872 TOKEN_STRING_INITIALIZER
11873 (struct cmd_config_e_tag_result,
11875 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11876 TOKEN_STRING_INITIALIZER
11877 (struct cmd_config_e_tag_result,
11879 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11880 TOKEN_STRING_INITIALIZER
11881 (struct cmd_config_e_tag_result,
11882 port_tag_id, "port-tag-id");
11883 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11884 TOKEN_NUM_INITIALIZER
11885 (struct cmd_config_e_tag_result,
11886 port_tag_id_val, UINT32);
11887 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11888 TOKEN_STRING_INITIALIZER
11889 (struct cmd_config_e_tag_result,
11890 e_tag_id, "e-tag-id");
11891 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11892 TOKEN_NUM_INITIALIZER
11893 (struct cmd_config_e_tag_result,
11894 e_tag_id_val, UINT16);
11895 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11896 TOKEN_STRING_INITIALIZER
11897 (struct cmd_config_e_tag_result,
11898 dst_pool, "dst-pool");
11899 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11900 TOKEN_NUM_INITIALIZER
11901 (struct cmd_config_e_tag_result,
11902 dst_pool_val, UINT8);
11903 cmdline_parse_token_string_t cmd_config_e_tag_port =
11904 TOKEN_STRING_INITIALIZER
11905 (struct cmd_config_e_tag_result,
11907 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11908 TOKEN_NUM_INITIALIZER
11909 (struct cmd_config_e_tag_result,
11911 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11912 TOKEN_STRING_INITIALIZER
11913 (struct cmd_config_e_tag_result,
11915 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11916 TOKEN_NUM_INITIALIZER
11917 (struct cmd_config_e_tag_result,
11920 /* E-tag insertion configuration */
11922 cmd_config_e_tag_insertion_en_parsed(
11923 void *parsed_result,
11924 __attribute__((unused)) struct cmdline *cl,
11925 __attribute__((unused)) void *data)
11927 struct cmd_config_e_tag_result *res =
11929 struct rte_eth_l2_tunnel_conf entry;
11931 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11934 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11935 entry.tunnel_id = res->port_tag_id_val;
11936 entry.vf_id = res->vf_id;
11937 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11939 ETH_L2_TUNNEL_INSERTION_MASK,
11944 cmd_config_e_tag_insertion_dis_parsed(
11945 void *parsed_result,
11946 __attribute__((unused)) struct cmdline *cl,
11947 __attribute__((unused)) void *data)
11949 struct cmd_config_e_tag_result *res =
11951 struct rte_eth_l2_tunnel_conf entry;
11953 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11956 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11957 entry.vf_id = res->vf_id;
11959 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11961 ETH_L2_TUNNEL_INSERTION_MASK,
11965 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11966 .f = cmd_config_e_tag_insertion_en_parsed,
11968 .help_str = "E-tag ... : E-tag insertion enable",
11970 (void *)&cmd_config_e_tag_e_tag,
11971 (void *)&cmd_config_e_tag_set,
11972 (void *)&cmd_config_e_tag_insertion,
11973 (void *)&cmd_config_e_tag_on,
11974 (void *)&cmd_config_e_tag_port_tag_id,
11975 (void *)&cmd_config_e_tag_port_tag_id_val,
11976 (void *)&cmd_config_e_tag_port,
11977 (void *)&cmd_config_e_tag_port_id,
11978 (void *)&cmd_config_e_tag_vf,
11979 (void *)&cmd_config_e_tag_vf_id,
11984 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11985 .f = cmd_config_e_tag_insertion_dis_parsed,
11987 .help_str = "E-tag ... : E-tag insertion disable",
11989 (void *)&cmd_config_e_tag_e_tag,
11990 (void *)&cmd_config_e_tag_set,
11991 (void *)&cmd_config_e_tag_insertion,
11992 (void *)&cmd_config_e_tag_off,
11993 (void *)&cmd_config_e_tag_port,
11994 (void *)&cmd_config_e_tag_port_id,
11995 (void *)&cmd_config_e_tag_vf,
11996 (void *)&cmd_config_e_tag_vf_id,
12001 /* E-tag stripping configuration */
12003 cmd_config_e_tag_stripping_parsed(
12004 void *parsed_result,
12005 __attribute__((unused)) struct cmdline *cl,
12006 __attribute__((unused)) void *data)
12008 struct cmd_config_e_tag_result *res =
12010 struct rte_eth_l2_tunnel_conf entry;
12012 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12015 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12017 if (!strcmp(res->on_off, "on"))
12018 rte_eth_dev_l2_tunnel_offload_set
12021 ETH_L2_TUNNEL_STRIPPING_MASK,
12024 rte_eth_dev_l2_tunnel_offload_set
12027 ETH_L2_TUNNEL_STRIPPING_MASK,
12031 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12032 .f = cmd_config_e_tag_stripping_parsed,
12034 .help_str = "E-tag ... : E-tag stripping enable/disable",
12036 (void *)&cmd_config_e_tag_e_tag,
12037 (void *)&cmd_config_e_tag_set,
12038 (void *)&cmd_config_e_tag_stripping,
12039 (void *)&cmd_config_e_tag_on_off,
12040 (void *)&cmd_config_e_tag_port,
12041 (void *)&cmd_config_e_tag_port_id,
12046 /* E-tag forwarding configuration */
12048 cmd_config_e_tag_forwarding_parsed(
12049 void *parsed_result,
12050 __attribute__((unused)) struct cmdline *cl,
12051 __attribute__((unused)) void *data)
12053 struct cmd_config_e_tag_result *res = parsed_result;
12054 struct rte_eth_l2_tunnel_conf entry;
12056 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12059 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12061 if (!strcmp(res->on_off, "on"))
12062 rte_eth_dev_l2_tunnel_offload_set
12065 ETH_L2_TUNNEL_FORWARDING_MASK,
12068 rte_eth_dev_l2_tunnel_offload_set
12071 ETH_L2_TUNNEL_FORWARDING_MASK,
12075 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12076 .f = cmd_config_e_tag_forwarding_parsed,
12078 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12080 (void *)&cmd_config_e_tag_e_tag,
12081 (void *)&cmd_config_e_tag_set,
12082 (void *)&cmd_config_e_tag_forwarding,
12083 (void *)&cmd_config_e_tag_on_off,
12084 (void *)&cmd_config_e_tag_port,
12085 (void *)&cmd_config_e_tag_port_id,
12090 /* E-tag filter configuration */
12092 cmd_config_e_tag_filter_add_parsed(
12093 void *parsed_result,
12094 __attribute__((unused)) struct cmdline *cl,
12095 __attribute__((unused)) void *data)
12097 struct cmd_config_e_tag_result *res = parsed_result;
12098 struct rte_eth_l2_tunnel_conf entry;
12101 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12104 if (res->e_tag_id_val > 0x3fff) {
12105 printf("e-tag-id must be equal or less than 0x3fff.\n");
12109 ret = rte_eth_dev_filter_supported(res->port_id,
12110 RTE_ETH_FILTER_L2_TUNNEL);
12112 printf("E-tag filter is not supported on port %u.\n",
12117 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12118 entry.tunnel_id = res->e_tag_id_val;
12119 entry.pool = res->dst_pool_val;
12121 ret = rte_eth_dev_filter_ctrl(res->port_id,
12122 RTE_ETH_FILTER_L2_TUNNEL,
12123 RTE_ETH_FILTER_ADD,
12126 printf("E-tag filter programming error: (%s)\n",
12130 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12131 .f = cmd_config_e_tag_filter_add_parsed,
12133 .help_str = "E-tag ... : E-tag filter add",
12135 (void *)&cmd_config_e_tag_e_tag,
12136 (void *)&cmd_config_e_tag_set,
12137 (void *)&cmd_config_e_tag_filter,
12138 (void *)&cmd_config_e_tag_add,
12139 (void *)&cmd_config_e_tag_e_tag_id,
12140 (void *)&cmd_config_e_tag_e_tag_id_val,
12141 (void *)&cmd_config_e_tag_dst_pool,
12142 (void *)&cmd_config_e_tag_dst_pool_val,
12143 (void *)&cmd_config_e_tag_port,
12144 (void *)&cmd_config_e_tag_port_id,
12150 cmd_config_e_tag_filter_del_parsed(
12151 void *parsed_result,
12152 __attribute__((unused)) struct cmdline *cl,
12153 __attribute__((unused)) void *data)
12155 struct cmd_config_e_tag_result *res = parsed_result;
12156 struct rte_eth_l2_tunnel_conf entry;
12159 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12162 if (res->e_tag_id_val > 0x3fff) {
12163 printf("e-tag-id must be less than 0x3fff.\n");
12167 ret = rte_eth_dev_filter_supported(res->port_id,
12168 RTE_ETH_FILTER_L2_TUNNEL);
12170 printf("E-tag filter is not supported on port %u.\n",
12175 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12176 entry.tunnel_id = res->e_tag_id_val;
12178 ret = rte_eth_dev_filter_ctrl(res->port_id,
12179 RTE_ETH_FILTER_L2_TUNNEL,
12180 RTE_ETH_FILTER_DELETE,
12183 printf("E-tag filter programming error: (%s)\n",
12187 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12188 .f = cmd_config_e_tag_filter_del_parsed,
12190 .help_str = "E-tag ... : E-tag filter delete",
12192 (void *)&cmd_config_e_tag_e_tag,
12193 (void *)&cmd_config_e_tag_set,
12194 (void *)&cmd_config_e_tag_filter,
12195 (void *)&cmd_config_e_tag_del,
12196 (void *)&cmd_config_e_tag_e_tag_id,
12197 (void *)&cmd_config_e_tag_e_tag_id_val,
12198 (void *)&cmd_config_e_tag_port,
12199 (void *)&cmd_config_e_tag_port_id,
12204 /* vf vlan anti spoof configuration */
12206 /* Common result structure for vf vlan anti spoof */
12207 struct cmd_vf_vlan_anti_spoof_result {
12208 cmdline_fixed_string_t set;
12209 cmdline_fixed_string_t vf;
12210 cmdline_fixed_string_t vlan;
12211 cmdline_fixed_string_t antispoof;
12214 cmdline_fixed_string_t on_off;
12217 /* Common CLI fields for vf vlan anti spoof enable disable */
12218 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12219 TOKEN_STRING_INITIALIZER
12220 (struct cmd_vf_vlan_anti_spoof_result,
12222 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12223 TOKEN_STRING_INITIALIZER
12224 (struct cmd_vf_vlan_anti_spoof_result,
12226 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12227 TOKEN_STRING_INITIALIZER
12228 (struct cmd_vf_vlan_anti_spoof_result,
12230 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12231 TOKEN_STRING_INITIALIZER
12232 (struct cmd_vf_vlan_anti_spoof_result,
12233 antispoof, "antispoof");
12234 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12235 TOKEN_NUM_INITIALIZER
12236 (struct cmd_vf_vlan_anti_spoof_result,
12238 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12239 TOKEN_NUM_INITIALIZER
12240 (struct cmd_vf_vlan_anti_spoof_result,
12242 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12243 TOKEN_STRING_INITIALIZER
12244 (struct cmd_vf_vlan_anti_spoof_result,
12248 cmd_set_vf_vlan_anti_spoof_parsed(
12249 void *parsed_result,
12250 __attribute__((unused)) struct cmdline *cl,
12251 __attribute__((unused)) void *data)
12253 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12254 int ret = -ENOTSUP;
12256 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12258 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12261 #ifdef RTE_LIBRTE_IXGBE_PMD
12262 if (ret == -ENOTSUP)
12263 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12264 res->vf_id, is_on);
12266 #ifdef RTE_LIBRTE_I40E_PMD
12267 if (ret == -ENOTSUP)
12268 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12269 res->vf_id, is_on);
12271 #ifdef RTE_LIBRTE_BNXT_PMD
12272 if (ret == -ENOTSUP)
12273 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12274 res->vf_id, is_on);
12281 printf("invalid vf_id %d\n", res->vf_id);
12284 printf("invalid port_id %d\n", res->port_id);
12287 printf("function not implemented\n");
12290 printf("programming error: (%s)\n", strerror(-ret));
12294 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12295 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12297 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12299 (void *)&cmd_vf_vlan_anti_spoof_set,
12300 (void *)&cmd_vf_vlan_anti_spoof_vf,
12301 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12302 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12303 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12304 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12305 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12310 /* vf mac anti spoof configuration */
12312 /* Common result structure for vf mac anti spoof */
12313 struct cmd_vf_mac_anti_spoof_result {
12314 cmdline_fixed_string_t set;
12315 cmdline_fixed_string_t vf;
12316 cmdline_fixed_string_t mac;
12317 cmdline_fixed_string_t antispoof;
12320 cmdline_fixed_string_t on_off;
12323 /* Common CLI fields for vf mac anti spoof enable disable */
12324 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12325 TOKEN_STRING_INITIALIZER
12326 (struct cmd_vf_mac_anti_spoof_result,
12328 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12329 TOKEN_STRING_INITIALIZER
12330 (struct cmd_vf_mac_anti_spoof_result,
12332 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12333 TOKEN_STRING_INITIALIZER
12334 (struct cmd_vf_mac_anti_spoof_result,
12336 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12337 TOKEN_STRING_INITIALIZER
12338 (struct cmd_vf_mac_anti_spoof_result,
12339 antispoof, "antispoof");
12340 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12341 TOKEN_NUM_INITIALIZER
12342 (struct cmd_vf_mac_anti_spoof_result,
12344 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12345 TOKEN_NUM_INITIALIZER
12346 (struct cmd_vf_mac_anti_spoof_result,
12348 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12349 TOKEN_STRING_INITIALIZER
12350 (struct cmd_vf_mac_anti_spoof_result,
12354 cmd_set_vf_mac_anti_spoof_parsed(
12355 void *parsed_result,
12356 __attribute__((unused)) struct cmdline *cl,
12357 __attribute__((unused)) void *data)
12359 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12360 int ret = -ENOTSUP;
12362 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12364 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12367 #ifdef RTE_LIBRTE_IXGBE_PMD
12368 if (ret == -ENOTSUP)
12369 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12370 res->vf_id, is_on);
12372 #ifdef RTE_LIBRTE_I40E_PMD
12373 if (ret == -ENOTSUP)
12374 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12375 res->vf_id, is_on);
12377 #ifdef RTE_LIBRTE_BNXT_PMD
12378 if (ret == -ENOTSUP)
12379 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12380 res->vf_id, is_on);
12387 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12390 printf("invalid port_id %d\n", res->port_id);
12393 printf("function not implemented\n");
12396 printf("programming error: (%s)\n", strerror(-ret));
12400 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12401 .f = cmd_set_vf_mac_anti_spoof_parsed,
12403 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12405 (void *)&cmd_vf_mac_anti_spoof_set,
12406 (void *)&cmd_vf_mac_anti_spoof_vf,
12407 (void *)&cmd_vf_mac_anti_spoof_mac,
12408 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12409 (void *)&cmd_vf_mac_anti_spoof_port_id,
12410 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12411 (void *)&cmd_vf_mac_anti_spoof_on_off,
12416 /* vf vlan strip queue configuration */
12418 /* Common result structure for vf mac anti spoof */
12419 struct cmd_vf_vlan_stripq_result {
12420 cmdline_fixed_string_t set;
12421 cmdline_fixed_string_t vf;
12422 cmdline_fixed_string_t vlan;
12423 cmdline_fixed_string_t stripq;
12426 cmdline_fixed_string_t on_off;
12429 /* Common CLI fields for vf vlan strip enable disable */
12430 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12431 TOKEN_STRING_INITIALIZER
12432 (struct cmd_vf_vlan_stripq_result,
12434 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12435 TOKEN_STRING_INITIALIZER
12436 (struct cmd_vf_vlan_stripq_result,
12438 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12439 TOKEN_STRING_INITIALIZER
12440 (struct cmd_vf_vlan_stripq_result,
12442 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12443 TOKEN_STRING_INITIALIZER
12444 (struct cmd_vf_vlan_stripq_result,
12446 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12447 TOKEN_NUM_INITIALIZER
12448 (struct cmd_vf_vlan_stripq_result,
12450 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12451 TOKEN_NUM_INITIALIZER
12452 (struct cmd_vf_vlan_stripq_result,
12454 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12455 TOKEN_STRING_INITIALIZER
12456 (struct cmd_vf_vlan_stripq_result,
12460 cmd_set_vf_vlan_stripq_parsed(
12461 void *parsed_result,
12462 __attribute__((unused)) struct cmdline *cl,
12463 __attribute__((unused)) void *data)
12465 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12466 int ret = -ENOTSUP;
12468 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12470 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12473 #ifdef RTE_LIBRTE_IXGBE_PMD
12474 if (ret == -ENOTSUP)
12475 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12476 res->vf_id, is_on);
12478 #ifdef RTE_LIBRTE_I40E_PMD
12479 if (ret == -ENOTSUP)
12480 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12481 res->vf_id, is_on);
12483 #ifdef RTE_LIBRTE_BNXT_PMD
12484 if (ret == -ENOTSUP)
12485 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12486 res->vf_id, is_on);
12493 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12496 printf("invalid port_id %d\n", res->port_id);
12499 printf("function not implemented\n");
12502 printf("programming error: (%s)\n", strerror(-ret));
12506 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12507 .f = cmd_set_vf_vlan_stripq_parsed,
12509 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12511 (void *)&cmd_vf_vlan_stripq_set,
12512 (void *)&cmd_vf_vlan_stripq_vf,
12513 (void *)&cmd_vf_vlan_stripq_vlan,
12514 (void *)&cmd_vf_vlan_stripq_stripq,
12515 (void *)&cmd_vf_vlan_stripq_port_id,
12516 (void *)&cmd_vf_vlan_stripq_vf_id,
12517 (void *)&cmd_vf_vlan_stripq_on_off,
12522 /* vf vlan insert configuration */
12524 /* Common result structure for vf vlan insert */
12525 struct cmd_vf_vlan_insert_result {
12526 cmdline_fixed_string_t set;
12527 cmdline_fixed_string_t vf;
12528 cmdline_fixed_string_t vlan;
12529 cmdline_fixed_string_t insert;
12535 /* Common CLI fields for vf vlan insert enable disable */
12536 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12537 TOKEN_STRING_INITIALIZER
12538 (struct cmd_vf_vlan_insert_result,
12540 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12541 TOKEN_STRING_INITIALIZER
12542 (struct cmd_vf_vlan_insert_result,
12544 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12545 TOKEN_STRING_INITIALIZER
12546 (struct cmd_vf_vlan_insert_result,
12548 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12549 TOKEN_STRING_INITIALIZER
12550 (struct cmd_vf_vlan_insert_result,
12552 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12553 TOKEN_NUM_INITIALIZER
12554 (struct cmd_vf_vlan_insert_result,
12556 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12557 TOKEN_NUM_INITIALIZER
12558 (struct cmd_vf_vlan_insert_result,
12560 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12561 TOKEN_NUM_INITIALIZER
12562 (struct cmd_vf_vlan_insert_result,
12566 cmd_set_vf_vlan_insert_parsed(
12567 void *parsed_result,
12568 __attribute__((unused)) struct cmdline *cl,
12569 __attribute__((unused)) void *data)
12571 struct cmd_vf_vlan_insert_result *res = parsed_result;
12572 int ret = -ENOTSUP;
12574 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12577 #ifdef RTE_LIBRTE_IXGBE_PMD
12578 if (ret == -ENOTSUP)
12579 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12582 #ifdef RTE_LIBRTE_I40E_PMD
12583 if (ret == -ENOTSUP)
12584 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12587 #ifdef RTE_LIBRTE_BNXT_PMD
12588 if (ret == -ENOTSUP)
12589 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12597 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12600 printf("invalid port_id %d\n", res->port_id);
12603 printf("function not implemented\n");
12606 printf("programming error: (%s)\n", strerror(-ret));
12610 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12611 .f = cmd_set_vf_vlan_insert_parsed,
12613 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12615 (void *)&cmd_vf_vlan_insert_set,
12616 (void *)&cmd_vf_vlan_insert_vf,
12617 (void *)&cmd_vf_vlan_insert_vlan,
12618 (void *)&cmd_vf_vlan_insert_insert,
12619 (void *)&cmd_vf_vlan_insert_port_id,
12620 (void *)&cmd_vf_vlan_insert_vf_id,
12621 (void *)&cmd_vf_vlan_insert_vlan_id,
12626 /* tx loopback configuration */
12628 /* Common result structure for tx loopback */
12629 struct cmd_tx_loopback_result {
12630 cmdline_fixed_string_t set;
12631 cmdline_fixed_string_t tx;
12632 cmdline_fixed_string_t loopback;
12634 cmdline_fixed_string_t on_off;
12637 /* Common CLI fields for tx loopback enable disable */
12638 cmdline_parse_token_string_t cmd_tx_loopback_set =
12639 TOKEN_STRING_INITIALIZER
12640 (struct cmd_tx_loopback_result,
12642 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12643 TOKEN_STRING_INITIALIZER
12644 (struct cmd_tx_loopback_result,
12646 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12647 TOKEN_STRING_INITIALIZER
12648 (struct cmd_tx_loopback_result,
12649 loopback, "loopback");
12650 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12651 TOKEN_NUM_INITIALIZER
12652 (struct cmd_tx_loopback_result,
12654 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12655 TOKEN_STRING_INITIALIZER
12656 (struct cmd_tx_loopback_result,
12660 cmd_set_tx_loopback_parsed(
12661 void *parsed_result,
12662 __attribute__((unused)) struct cmdline *cl,
12663 __attribute__((unused)) void *data)
12665 struct cmd_tx_loopback_result *res = parsed_result;
12666 int ret = -ENOTSUP;
12668 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12670 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12673 #ifdef RTE_LIBRTE_IXGBE_PMD
12674 if (ret == -ENOTSUP)
12675 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12677 #ifdef RTE_LIBRTE_I40E_PMD
12678 if (ret == -ENOTSUP)
12679 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12681 #ifdef RTE_LIBRTE_BNXT_PMD
12682 if (ret == -ENOTSUP)
12683 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12690 printf("invalid is_on %d\n", is_on);
12693 printf("invalid port_id %d\n", res->port_id);
12696 printf("function not implemented\n");
12699 printf("programming error: (%s)\n", strerror(-ret));
12703 cmdline_parse_inst_t cmd_set_tx_loopback = {
12704 .f = cmd_set_tx_loopback_parsed,
12706 .help_str = "set tx loopback <port_id> on|off",
12708 (void *)&cmd_tx_loopback_set,
12709 (void *)&cmd_tx_loopback_tx,
12710 (void *)&cmd_tx_loopback_loopback,
12711 (void *)&cmd_tx_loopback_port_id,
12712 (void *)&cmd_tx_loopback_on_off,
12717 /* all queues drop enable configuration */
12719 /* Common result structure for all queues drop enable */
12720 struct cmd_all_queues_drop_en_result {
12721 cmdline_fixed_string_t set;
12722 cmdline_fixed_string_t all;
12723 cmdline_fixed_string_t queues;
12724 cmdline_fixed_string_t drop;
12726 cmdline_fixed_string_t on_off;
12729 /* Common CLI fields for tx loopback enable disable */
12730 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12731 TOKEN_STRING_INITIALIZER
12732 (struct cmd_all_queues_drop_en_result,
12734 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12735 TOKEN_STRING_INITIALIZER
12736 (struct cmd_all_queues_drop_en_result,
12738 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12739 TOKEN_STRING_INITIALIZER
12740 (struct cmd_all_queues_drop_en_result,
12742 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12743 TOKEN_STRING_INITIALIZER
12744 (struct cmd_all_queues_drop_en_result,
12746 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12747 TOKEN_NUM_INITIALIZER
12748 (struct cmd_all_queues_drop_en_result,
12750 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12751 TOKEN_STRING_INITIALIZER
12752 (struct cmd_all_queues_drop_en_result,
12756 cmd_set_all_queues_drop_en_parsed(
12757 void *parsed_result,
12758 __attribute__((unused)) struct cmdline *cl,
12759 __attribute__((unused)) void *data)
12761 struct cmd_all_queues_drop_en_result *res = parsed_result;
12762 int ret = -ENOTSUP;
12763 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12765 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12768 #ifdef RTE_LIBRTE_IXGBE_PMD
12769 if (ret == -ENOTSUP)
12770 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12772 #ifdef RTE_LIBRTE_BNXT_PMD
12773 if (ret == -ENOTSUP)
12774 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12780 printf("invalid is_on %d\n", is_on);
12783 printf("invalid port_id %d\n", res->port_id);
12786 printf("function not implemented\n");
12789 printf("programming error: (%s)\n", strerror(-ret));
12793 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12794 .f = cmd_set_all_queues_drop_en_parsed,
12796 .help_str = "set all queues drop <port_id> on|off",
12798 (void *)&cmd_all_queues_drop_en_set,
12799 (void *)&cmd_all_queues_drop_en_all,
12800 (void *)&cmd_all_queues_drop_en_queues,
12801 (void *)&cmd_all_queues_drop_en_drop,
12802 (void *)&cmd_all_queues_drop_en_port_id,
12803 (void *)&cmd_all_queues_drop_en_on_off,
12808 /* vf split drop enable configuration */
12810 /* Common result structure for vf split drop enable */
12811 struct cmd_vf_split_drop_en_result {
12812 cmdline_fixed_string_t set;
12813 cmdline_fixed_string_t vf;
12814 cmdline_fixed_string_t split;
12815 cmdline_fixed_string_t drop;
12818 cmdline_fixed_string_t on_off;
12821 /* Common CLI fields for vf split drop enable disable */
12822 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12823 TOKEN_STRING_INITIALIZER
12824 (struct cmd_vf_split_drop_en_result,
12826 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12827 TOKEN_STRING_INITIALIZER
12828 (struct cmd_vf_split_drop_en_result,
12830 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12831 TOKEN_STRING_INITIALIZER
12832 (struct cmd_vf_split_drop_en_result,
12834 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12835 TOKEN_STRING_INITIALIZER
12836 (struct cmd_vf_split_drop_en_result,
12838 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12839 TOKEN_NUM_INITIALIZER
12840 (struct cmd_vf_split_drop_en_result,
12842 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12843 TOKEN_NUM_INITIALIZER
12844 (struct cmd_vf_split_drop_en_result,
12846 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12847 TOKEN_STRING_INITIALIZER
12848 (struct cmd_vf_split_drop_en_result,
12852 cmd_set_vf_split_drop_en_parsed(
12853 void *parsed_result,
12854 __attribute__((unused)) struct cmdline *cl,
12855 __attribute__((unused)) void *data)
12857 struct cmd_vf_split_drop_en_result *res = parsed_result;
12858 int ret = -ENOTSUP;
12859 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12861 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12864 #ifdef RTE_LIBRTE_IXGBE_PMD
12865 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12872 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12875 printf("invalid port_id %d\n", res->port_id);
12878 printf("not supported on port %d\n", res->port_id);
12881 printf("programming error: (%s)\n", strerror(-ret));
12885 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12886 .f = cmd_set_vf_split_drop_en_parsed,
12888 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12890 (void *)&cmd_vf_split_drop_en_set,
12891 (void *)&cmd_vf_split_drop_en_vf,
12892 (void *)&cmd_vf_split_drop_en_split,
12893 (void *)&cmd_vf_split_drop_en_drop,
12894 (void *)&cmd_vf_split_drop_en_port_id,
12895 (void *)&cmd_vf_split_drop_en_vf_id,
12896 (void *)&cmd_vf_split_drop_en_on_off,
12901 /* vf mac address configuration */
12903 /* Common result structure for vf mac address */
12904 struct cmd_set_vf_mac_addr_result {
12905 cmdline_fixed_string_t set;
12906 cmdline_fixed_string_t vf;
12907 cmdline_fixed_string_t mac;
12908 cmdline_fixed_string_t addr;
12911 struct ether_addr mac_addr;
12915 /* Common CLI fields for vf split drop enable disable */
12916 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12917 TOKEN_STRING_INITIALIZER
12918 (struct cmd_set_vf_mac_addr_result,
12920 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12921 TOKEN_STRING_INITIALIZER
12922 (struct cmd_set_vf_mac_addr_result,
12924 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12925 TOKEN_STRING_INITIALIZER
12926 (struct cmd_set_vf_mac_addr_result,
12928 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12929 TOKEN_STRING_INITIALIZER
12930 (struct cmd_set_vf_mac_addr_result,
12932 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12933 TOKEN_NUM_INITIALIZER
12934 (struct cmd_set_vf_mac_addr_result,
12936 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12937 TOKEN_NUM_INITIALIZER
12938 (struct cmd_set_vf_mac_addr_result,
12940 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12941 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12945 cmd_set_vf_mac_addr_parsed(
12946 void *parsed_result,
12947 __attribute__((unused)) struct cmdline *cl,
12948 __attribute__((unused)) void *data)
12950 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12951 int ret = -ENOTSUP;
12953 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12956 #ifdef RTE_LIBRTE_IXGBE_PMD
12957 if (ret == -ENOTSUP)
12958 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12961 #ifdef RTE_LIBRTE_I40E_PMD
12962 if (ret == -ENOTSUP)
12963 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12966 #ifdef RTE_LIBRTE_BNXT_PMD
12967 if (ret == -ENOTSUP)
12968 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12976 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12979 printf("invalid port_id %d\n", res->port_id);
12982 printf("function not implemented\n");
12985 printf("programming error: (%s)\n", strerror(-ret));
12989 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12990 .f = cmd_set_vf_mac_addr_parsed,
12992 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12994 (void *)&cmd_set_vf_mac_addr_set,
12995 (void *)&cmd_set_vf_mac_addr_vf,
12996 (void *)&cmd_set_vf_mac_addr_mac,
12997 (void *)&cmd_set_vf_mac_addr_addr,
12998 (void *)&cmd_set_vf_mac_addr_port_id,
12999 (void *)&cmd_set_vf_mac_addr_vf_id,
13000 (void *)&cmd_set_vf_mac_addr_mac_addr,
13005 /* MACsec configuration */
13007 /* Common result structure for MACsec offload enable */
13008 struct cmd_macsec_offload_on_result {
13009 cmdline_fixed_string_t set;
13010 cmdline_fixed_string_t macsec;
13011 cmdline_fixed_string_t offload;
13013 cmdline_fixed_string_t on;
13014 cmdline_fixed_string_t encrypt;
13015 cmdline_fixed_string_t en_on_off;
13016 cmdline_fixed_string_t replay_protect;
13017 cmdline_fixed_string_t rp_on_off;
13020 /* Common CLI fields for MACsec offload disable */
13021 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13022 TOKEN_STRING_INITIALIZER
13023 (struct cmd_macsec_offload_on_result,
13025 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13026 TOKEN_STRING_INITIALIZER
13027 (struct cmd_macsec_offload_on_result,
13029 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13030 TOKEN_STRING_INITIALIZER
13031 (struct cmd_macsec_offload_on_result,
13032 offload, "offload");
13033 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13034 TOKEN_NUM_INITIALIZER
13035 (struct cmd_macsec_offload_on_result,
13037 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13038 TOKEN_STRING_INITIALIZER
13039 (struct cmd_macsec_offload_on_result,
13041 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13042 TOKEN_STRING_INITIALIZER
13043 (struct cmd_macsec_offload_on_result,
13044 encrypt, "encrypt");
13045 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13046 TOKEN_STRING_INITIALIZER
13047 (struct cmd_macsec_offload_on_result,
13048 en_on_off, "on#off");
13049 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13050 TOKEN_STRING_INITIALIZER
13051 (struct cmd_macsec_offload_on_result,
13052 replay_protect, "replay-protect");
13053 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13054 TOKEN_STRING_INITIALIZER
13055 (struct cmd_macsec_offload_on_result,
13056 rp_on_off, "on#off");
13059 cmd_set_macsec_offload_on_parsed(
13060 void *parsed_result,
13061 __attribute__((unused)) struct cmdline *cl,
13062 __attribute__((unused)) void *data)
13064 struct cmd_macsec_offload_on_result *res = parsed_result;
13065 int ret = -ENOTSUP;
13066 portid_t port_id = res->port_id;
13067 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13068 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13069 struct rte_eth_dev_info dev_info;
13071 if (port_id_is_invalid(port_id, ENABLED_WARN))
13073 if (!port_is_stopped(port_id)) {
13074 printf("Please stop port %d first\n", port_id);
13078 rte_eth_dev_info_get(port_id, &dev_info);
13079 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13080 #ifdef RTE_LIBRTE_IXGBE_PMD
13081 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13089 ports[port_id].dev_conf.txmode.offloads |=
13090 DEV_TX_OFFLOAD_MACSEC_INSERT;
13091 cmd_reconfig_device_queue(port_id, 1, 1);
13094 printf("invalid port_id %d\n", port_id);
13097 printf("not supported on port %d\n", port_id);
13100 printf("programming error: (%s)\n", strerror(-ret));
13104 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13105 .f = cmd_set_macsec_offload_on_parsed,
13107 .help_str = "set macsec offload <port_id> on "
13108 "encrypt on|off replay-protect on|off",
13110 (void *)&cmd_macsec_offload_on_set,
13111 (void *)&cmd_macsec_offload_on_macsec,
13112 (void *)&cmd_macsec_offload_on_offload,
13113 (void *)&cmd_macsec_offload_on_port_id,
13114 (void *)&cmd_macsec_offload_on_on,
13115 (void *)&cmd_macsec_offload_on_encrypt,
13116 (void *)&cmd_macsec_offload_on_en_on_off,
13117 (void *)&cmd_macsec_offload_on_replay_protect,
13118 (void *)&cmd_macsec_offload_on_rp_on_off,
13123 /* Common result structure for MACsec offload disable */
13124 struct cmd_macsec_offload_off_result {
13125 cmdline_fixed_string_t set;
13126 cmdline_fixed_string_t macsec;
13127 cmdline_fixed_string_t offload;
13129 cmdline_fixed_string_t off;
13132 /* Common CLI fields for MACsec offload disable */
13133 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13134 TOKEN_STRING_INITIALIZER
13135 (struct cmd_macsec_offload_off_result,
13137 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13138 TOKEN_STRING_INITIALIZER
13139 (struct cmd_macsec_offload_off_result,
13141 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13142 TOKEN_STRING_INITIALIZER
13143 (struct cmd_macsec_offload_off_result,
13144 offload, "offload");
13145 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13146 TOKEN_NUM_INITIALIZER
13147 (struct cmd_macsec_offload_off_result,
13149 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13150 TOKEN_STRING_INITIALIZER
13151 (struct cmd_macsec_offload_off_result,
13155 cmd_set_macsec_offload_off_parsed(
13156 void *parsed_result,
13157 __attribute__((unused)) struct cmdline *cl,
13158 __attribute__((unused)) void *data)
13160 struct cmd_macsec_offload_off_result *res = parsed_result;
13161 int ret = -ENOTSUP;
13162 struct rte_eth_dev_info dev_info;
13163 portid_t port_id = res->port_id;
13165 if (port_id_is_invalid(port_id, ENABLED_WARN))
13167 if (!port_is_stopped(port_id)) {
13168 printf("Please stop port %d first\n", port_id);
13172 rte_eth_dev_info_get(port_id, &dev_info);
13173 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13174 #ifdef RTE_LIBRTE_IXGBE_PMD
13175 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13180 ports[port_id].dev_conf.txmode.offloads &=
13181 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13182 cmd_reconfig_device_queue(port_id, 1, 1);
13185 printf("invalid port_id %d\n", port_id);
13188 printf("not supported on port %d\n", port_id);
13191 printf("programming error: (%s)\n", strerror(-ret));
13195 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13196 .f = cmd_set_macsec_offload_off_parsed,
13198 .help_str = "set macsec offload <port_id> off",
13200 (void *)&cmd_macsec_offload_off_set,
13201 (void *)&cmd_macsec_offload_off_macsec,
13202 (void *)&cmd_macsec_offload_off_offload,
13203 (void *)&cmd_macsec_offload_off_port_id,
13204 (void *)&cmd_macsec_offload_off_off,
13209 /* Common result structure for MACsec secure connection configure */
13210 struct cmd_macsec_sc_result {
13211 cmdline_fixed_string_t set;
13212 cmdline_fixed_string_t macsec;
13213 cmdline_fixed_string_t sc;
13214 cmdline_fixed_string_t tx_rx;
13216 struct ether_addr mac;
13220 /* Common CLI fields for MACsec secure connection configure */
13221 cmdline_parse_token_string_t cmd_macsec_sc_set =
13222 TOKEN_STRING_INITIALIZER
13223 (struct cmd_macsec_sc_result,
13225 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13226 TOKEN_STRING_INITIALIZER
13227 (struct cmd_macsec_sc_result,
13229 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13230 TOKEN_STRING_INITIALIZER
13231 (struct cmd_macsec_sc_result,
13233 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13234 TOKEN_STRING_INITIALIZER
13235 (struct cmd_macsec_sc_result,
13237 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13238 TOKEN_NUM_INITIALIZER
13239 (struct cmd_macsec_sc_result,
13241 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13242 TOKEN_ETHERADDR_INITIALIZER
13243 (struct cmd_macsec_sc_result,
13245 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13246 TOKEN_NUM_INITIALIZER
13247 (struct cmd_macsec_sc_result,
13251 cmd_set_macsec_sc_parsed(
13252 void *parsed_result,
13253 __attribute__((unused)) struct cmdline *cl,
13254 __attribute__((unused)) void *data)
13256 struct cmd_macsec_sc_result *res = parsed_result;
13257 int ret = -ENOTSUP;
13258 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13260 #ifdef RTE_LIBRTE_IXGBE_PMD
13262 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13263 res->mac.addr_bytes) :
13264 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13265 res->mac.addr_bytes, res->pi);
13267 RTE_SET_USED(is_tx);
13273 printf("invalid port_id %d\n", res->port_id);
13276 printf("not supported on port %d\n", res->port_id);
13279 printf("programming error: (%s)\n", strerror(-ret));
13283 cmdline_parse_inst_t cmd_set_macsec_sc = {
13284 .f = cmd_set_macsec_sc_parsed,
13286 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13288 (void *)&cmd_macsec_sc_set,
13289 (void *)&cmd_macsec_sc_macsec,
13290 (void *)&cmd_macsec_sc_sc,
13291 (void *)&cmd_macsec_sc_tx_rx,
13292 (void *)&cmd_macsec_sc_port_id,
13293 (void *)&cmd_macsec_sc_mac,
13294 (void *)&cmd_macsec_sc_pi,
13299 /* Common result structure for MACsec secure connection configure */
13300 struct cmd_macsec_sa_result {
13301 cmdline_fixed_string_t set;
13302 cmdline_fixed_string_t macsec;
13303 cmdline_fixed_string_t sa;
13304 cmdline_fixed_string_t tx_rx;
13309 cmdline_fixed_string_t key;
13312 /* Common CLI fields for MACsec secure connection configure */
13313 cmdline_parse_token_string_t cmd_macsec_sa_set =
13314 TOKEN_STRING_INITIALIZER
13315 (struct cmd_macsec_sa_result,
13317 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13318 TOKEN_STRING_INITIALIZER
13319 (struct cmd_macsec_sa_result,
13321 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13322 TOKEN_STRING_INITIALIZER
13323 (struct cmd_macsec_sa_result,
13325 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13326 TOKEN_STRING_INITIALIZER
13327 (struct cmd_macsec_sa_result,
13329 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13330 TOKEN_NUM_INITIALIZER
13331 (struct cmd_macsec_sa_result,
13333 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13334 TOKEN_NUM_INITIALIZER
13335 (struct cmd_macsec_sa_result,
13337 cmdline_parse_token_num_t cmd_macsec_sa_an =
13338 TOKEN_NUM_INITIALIZER
13339 (struct cmd_macsec_sa_result,
13341 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13342 TOKEN_NUM_INITIALIZER
13343 (struct cmd_macsec_sa_result,
13345 cmdline_parse_token_string_t cmd_macsec_sa_key =
13346 TOKEN_STRING_INITIALIZER
13347 (struct cmd_macsec_sa_result,
13351 cmd_set_macsec_sa_parsed(
13352 void *parsed_result,
13353 __attribute__((unused)) struct cmdline *cl,
13354 __attribute__((unused)) void *data)
13356 struct cmd_macsec_sa_result *res = parsed_result;
13357 int ret = -ENOTSUP;
13358 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13359 uint8_t key[16] = { 0 };
13365 key_len = strlen(res->key) / 2;
13369 for (i = 0; i < key_len; i++) {
13370 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13373 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13376 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13379 #ifdef RTE_LIBRTE_IXGBE_PMD
13381 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13382 res->idx, res->an, res->pn, key) :
13383 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13384 res->idx, res->an, res->pn, key);
13386 RTE_SET_USED(is_tx);
13393 printf("invalid idx %d or an %d\n", res->idx, res->an);
13396 printf("invalid port_id %d\n", res->port_id);
13399 printf("not supported on port %d\n", res->port_id);
13402 printf("programming error: (%s)\n", strerror(-ret));
13406 cmdline_parse_inst_t cmd_set_macsec_sa = {
13407 .f = cmd_set_macsec_sa_parsed,
13409 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13411 (void *)&cmd_macsec_sa_set,
13412 (void *)&cmd_macsec_sa_macsec,
13413 (void *)&cmd_macsec_sa_sa,
13414 (void *)&cmd_macsec_sa_tx_rx,
13415 (void *)&cmd_macsec_sa_port_id,
13416 (void *)&cmd_macsec_sa_idx,
13417 (void *)&cmd_macsec_sa_an,
13418 (void *)&cmd_macsec_sa_pn,
13419 (void *)&cmd_macsec_sa_key,
13424 /* VF unicast promiscuous mode configuration */
13426 /* Common result structure for VF unicast promiscuous mode */
13427 struct cmd_vf_promisc_result {
13428 cmdline_fixed_string_t set;
13429 cmdline_fixed_string_t vf;
13430 cmdline_fixed_string_t promisc;
13433 cmdline_fixed_string_t on_off;
13436 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13437 cmdline_parse_token_string_t cmd_vf_promisc_set =
13438 TOKEN_STRING_INITIALIZER
13439 (struct cmd_vf_promisc_result,
13441 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13442 TOKEN_STRING_INITIALIZER
13443 (struct cmd_vf_promisc_result,
13445 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13446 TOKEN_STRING_INITIALIZER
13447 (struct cmd_vf_promisc_result,
13448 promisc, "promisc");
13449 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13450 TOKEN_NUM_INITIALIZER
13451 (struct cmd_vf_promisc_result,
13453 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13454 TOKEN_NUM_INITIALIZER
13455 (struct cmd_vf_promisc_result,
13457 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13458 TOKEN_STRING_INITIALIZER
13459 (struct cmd_vf_promisc_result,
13463 cmd_set_vf_promisc_parsed(
13464 void *parsed_result,
13465 __attribute__((unused)) struct cmdline *cl,
13466 __attribute__((unused)) void *data)
13468 struct cmd_vf_promisc_result *res = parsed_result;
13469 int ret = -ENOTSUP;
13471 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13473 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13476 #ifdef RTE_LIBRTE_I40E_PMD
13477 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13478 res->vf_id, is_on);
13485 printf("invalid vf_id %d\n", res->vf_id);
13488 printf("invalid port_id %d\n", res->port_id);
13491 printf("function not implemented\n");
13494 printf("programming error: (%s)\n", strerror(-ret));
13498 cmdline_parse_inst_t cmd_set_vf_promisc = {
13499 .f = cmd_set_vf_promisc_parsed,
13501 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13502 "Set unicast promiscuous mode for a VF from the PF",
13504 (void *)&cmd_vf_promisc_set,
13505 (void *)&cmd_vf_promisc_vf,
13506 (void *)&cmd_vf_promisc_promisc,
13507 (void *)&cmd_vf_promisc_port_id,
13508 (void *)&cmd_vf_promisc_vf_id,
13509 (void *)&cmd_vf_promisc_on_off,
13514 /* VF multicast promiscuous mode configuration */
13516 /* Common result structure for VF multicast promiscuous mode */
13517 struct cmd_vf_allmulti_result {
13518 cmdline_fixed_string_t set;
13519 cmdline_fixed_string_t vf;
13520 cmdline_fixed_string_t allmulti;
13523 cmdline_fixed_string_t on_off;
13526 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13527 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13528 TOKEN_STRING_INITIALIZER
13529 (struct cmd_vf_allmulti_result,
13531 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13532 TOKEN_STRING_INITIALIZER
13533 (struct cmd_vf_allmulti_result,
13535 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13536 TOKEN_STRING_INITIALIZER
13537 (struct cmd_vf_allmulti_result,
13538 allmulti, "allmulti");
13539 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13540 TOKEN_NUM_INITIALIZER
13541 (struct cmd_vf_allmulti_result,
13543 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13544 TOKEN_NUM_INITIALIZER
13545 (struct cmd_vf_allmulti_result,
13547 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13548 TOKEN_STRING_INITIALIZER
13549 (struct cmd_vf_allmulti_result,
13553 cmd_set_vf_allmulti_parsed(
13554 void *parsed_result,
13555 __attribute__((unused)) struct cmdline *cl,
13556 __attribute__((unused)) void *data)
13558 struct cmd_vf_allmulti_result *res = parsed_result;
13559 int ret = -ENOTSUP;
13561 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13563 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13566 #ifdef RTE_LIBRTE_I40E_PMD
13567 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13568 res->vf_id, is_on);
13575 printf("invalid vf_id %d\n", res->vf_id);
13578 printf("invalid port_id %d\n", res->port_id);
13581 printf("function not implemented\n");
13584 printf("programming error: (%s)\n", strerror(-ret));
13588 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13589 .f = cmd_set_vf_allmulti_parsed,
13591 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13592 "Set multicast promiscuous mode for a VF from the PF",
13594 (void *)&cmd_vf_allmulti_set,
13595 (void *)&cmd_vf_allmulti_vf,
13596 (void *)&cmd_vf_allmulti_allmulti,
13597 (void *)&cmd_vf_allmulti_port_id,
13598 (void *)&cmd_vf_allmulti_vf_id,
13599 (void *)&cmd_vf_allmulti_on_off,
13604 /* vf broadcast mode configuration */
13606 /* Common result structure for vf broadcast */
13607 struct cmd_set_vf_broadcast_result {
13608 cmdline_fixed_string_t set;
13609 cmdline_fixed_string_t vf;
13610 cmdline_fixed_string_t broadcast;
13613 cmdline_fixed_string_t on_off;
13616 /* Common CLI fields for vf broadcast enable disable */
13617 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13618 TOKEN_STRING_INITIALIZER
13619 (struct cmd_set_vf_broadcast_result,
13621 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13622 TOKEN_STRING_INITIALIZER
13623 (struct cmd_set_vf_broadcast_result,
13625 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13626 TOKEN_STRING_INITIALIZER
13627 (struct cmd_set_vf_broadcast_result,
13628 broadcast, "broadcast");
13629 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13630 TOKEN_NUM_INITIALIZER
13631 (struct cmd_set_vf_broadcast_result,
13633 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13634 TOKEN_NUM_INITIALIZER
13635 (struct cmd_set_vf_broadcast_result,
13637 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13638 TOKEN_STRING_INITIALIZER
13639 (struct cmd_set_vf_broadcast_result,
13643 cmd_set_vf_broadcast_parsed(
13644 void *parsed_result,
13645 __attribute__((unused)) struct cmdline *cl,
13646 __attribute__((unused)) void *data)
13648 struct cmd_set_vf_broadcast_result *res = parsed_result;
13649 int ret = -ENOTSUP;
13651 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13653 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13656 #ifdef RTE_LIBRTE_I40E_PMD
13657 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13658 res->vf_id, is_on);
13665 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13668 printf("invalid port_id %d\n", res->port_id);
13671 printf("function not implemented\n");
13674 printf("programming error: (%s)\n", strerror(-ret));
13678 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13679 .f = cmd_set_vf_broadcast_parsed,
13681 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13683 (void *)&cmd_set_vf_broadcast_set,
13684 (void *)&cmd_set_vf_broadcast_vf,
13685 (void *)&cmd_set_vf_broadcast_broadcast,
13686 (void *)&cmd_set_vf_broadcast_port_id,
13687 (void *)&cmd_set_vf_broadcast_vf_id,
13688 (void *)&cmd_set_vf_broadcast_on_off,
13693 /* vf vlan tag configuration */
13695 /* Common result structure for vf vlan tag */
13696 struct cmd_set_vf_vlan_tag_result {
13697 cmdline_fixed_string_t set;
13698 cmdline_fixed_string_t vf;
13699 cmdline_fixed_string_t vlan;
13700 cmdline_fixed_string_t tag;
13703 cmdline_fixed_string_t on_off;
13706 /* Common CLI fields for vf vlan tag enable disable */
13707 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13708 TOKEN_STRING_INITIALIZER
13709 (struct cmd_set_vf_vlan_tag_result,
13711 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13712 TOKEN_STRING_INITIALIZER
13713 (struct cmd_set_vf_vlan_tag_result,
13715 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13716 TOKEN_STRING_INITIALIZER
13717 (struct cmd_set_vf_vlan_tag_result,
13719 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13720 TOKEN_STRING_INITIALIZER
13721 (struct cmd_set_vf_vlan_tag_result,
13723 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13724 TOKEN_NUM_INITIALIZER
13725 (struct cmd_set_vf_vlan_tag_result,
13727 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13728 TOKEN_NUM_INITIALIZER
13729 (struct cmd_set_vf_vlan_tag_result,
13731 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13732 TOKEN_STRING_INITIALIZER
13733 (struct cmd_set_vf_vlan_tag_result,
13737 cmd_set_vf_vlan_tag_parsed(
13738 void *parsed_result,
13739 __attribute__((unused)) struct cmdline *cl,
13740 __attribute__((unused)) void *data)
13742 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13743 int ret = -ENOTSUP;
13745 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13747 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13750 #ifdef RTE_LIBRTE_I40E_PMD
13751 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13752 res->vf_id, is_on);
13759 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13762 printf("invalid port_id %d\n", res->port_id);
13765 printf("function not implemented\n");
13768 printf("programming error: (%s)\n", strerror(-ret));
13772 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13773 .f = cmd_set_vf_vlan_tag_parsed,
13775 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13777 (void *)&cmd_set_vf_vlan_tag_set,
13778 (void *)&cmd_set_vf_vlan_tag_vf,
13779 (void *)&cmd_set_vf_vlan_tag_vlan,
13780 (void *)&cmd_set_vf_vlan_tag_tag,
13781 (void *)&cmd_set_vf_vlan_tag_port_id,
13782 (void *)&cmd_set_vf_vlan_tag_vf_id,
13783 (void *)&cmd_set_vf_vlan_tag_on_off,
13788 /* Common definition of VF and TC TX bandwidth configuration */
13789 struct cmd_vf_tc_bw_result {
13790 cmdline_fixed_string_t set;
13791 cmdline_fixed_string_t vf;
13792 cmdline_fixed_string_t tc;
13793 cmdline_fixed_string_t tx;
13794 cmdline_fixed_string_t min_bw;
13795 cmdline_fixed_string_t max_bw;
13796 cmdline_fixed_string_t strict_link_prio;
13801 cmdline_fixed_string_t bw_list;
13805 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13806 TOKEN_STRING_INITIALIZER
13807 (struct cmd_vf_tc_bw_result,
13809 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13810 TOKEN_STRING_INITIALIZER
13811 (struct cmd_vf_tc_bw_result,
13813 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13814 TOKEN_STRING_INITIALIZER
13815 (struct cmd_vf_tc_bw_result,
13817 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13818 TOKEN_STRING_INITIALIZER
13819 (struct cmd_vf_tc_bw_result,
13821 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13822 TOKEN_STRING_INITIALIZER
13823 (struct cmd_vf_tc_bw_result,
13824 strict_link_prio, "strict-link-priority");
13825 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13826 TOKEN_STRING_INITIALIZER
13827 (struct cmd_vf_tc_bw_result,
13828 min_bw, "min-bandwidth");
13829 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13830 TOKEN_STRING_INITIALIZER
13831 (struct cmd_vf_tc_bw_result,
13832 max_bw, "max-bandwidth");
13833 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13834 TOKEN_NUM_INITIALIZER
13835 (struct cmd_vf_tc_bw_result,
13837 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13838 TOKEN_NUM_INITIALIZER
13839 (struct cmd_vf_tc_bw_result,
13841 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13842 TOKEN_NUM_INITIALIZER
13843 (struct cmd_vf_tc_bw_result,
13845 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13846 TOKEN_NUM_INITIALIZER
13847 (struct cmd_vf_tc_bw_result,
13849 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13850 TOKEN_STRING_INITIALIZER
13851 (struct cmd_vf_tc_bw_result,
13853 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13854 TOKEN_NUM_INITIALIZER
13855 (struct cmd_vf_tc_bw_result,
13858 /* VF max bandwidth setting */
13860 cmd_vf_max_bw_parsed(
13861 void *parsed_result,
13862 __attribute__((unused)) struct cmdline *cl,
13863 __attribute__((unused)) void *data)
13865 struct cmd_vf_tc_bw_result *res = parsed_result;
13866 int ret = -ENOTSUP;
13868 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13871 #ifdef RTE_LIBRTE_I40E_PMD
13872 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13873 res->vf_id, res->bw);
13880 printf("invalid vf_id %d or bandwidth %d\n",
13881 res->vf_id, res->bw);
13884 printf("invalid port_id %d\n", res->port_id);
13887 printf("function not implemented\n");
13890 printf("programming error: (%s)\n", strerror(-ret));
13894 cmdline_parse_inst_t cmd_vf_max_bw = {
13895 .f = cmd_vf_max_bw_parsed,
13897 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13899 (void *)&cmd_vf_tc_bw_set,
13900 (void *)&cmd_vf_tc_bw_vf,
13901 (void *)&cmd_vf_tc_bw_tx,
13902 (void *)&cmd_vf_tc_bw_max_bw,
13903 (void *)&cmd_vf_tc_bw_port_id,
13904 (void *)&cmd_vf_tc_bw_vf_id,
13905 (void *)&cmd_vf_tc_bw_bw,
13911 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13916 const char *p, *p0 = str;
13923 p = strchr(p0, '(');
13925 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13929 p0 = strchr(p, ')');
13931 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13935 if (size >= sizeof(s)) {
13936 printf("The string size exceeds the internal buffer size\n");
13939 snprintf(s, sizeof(s), "%.*s", size, p);
13940 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13942 printf("Failed to get the bandwidth list. ");
13946 for (i = 0; i < ret; i++)
13947 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13952 /* TC min bandwidth setting */
13954 cmd_vf_tc_min_bw_parsed(
13955 void *parsed_result,
13956 __attribute__((unused)) struct cmdline *cl,
13957 __attribute__((unused)) void *data)
13959 struct cmd_vf_tc_bw_result *res = parsed_result;
13962 int ret = -ENOTSUP;
13964 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13967 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13971 #ifdef RTE_LIBRTE_I40E_PMD
13972 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13980 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13983 printf("invalid port_id %d\n", res->port_id);
13986 printf("function not implemented\n");
13989 printf("programming error: (%s)\n", strerror(-ret));
13993 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13994 .f = cmd_vf_tc_min_bw_parsed,
13996 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13997 " <bw1, bw2, ...>",
13999 (void *)&cmd_vf_tc_bw_set,
14000 (void *)&cmd_vf_tc_bw_vf,
14001 (void *)&cmd_vf_tc_bw_tc,
14002 (void *)&cmd_vf_tc_bw_tx,
14003 (void *)&cmd_vf_tc_bw_min_bw,
14004 (void *)&cmd_vf_tc_bw_port_id,
14005 (void *)&cmd_vf_tc_bw_vf_id,
14006 (void *)&cmd_vf_tc_bw_bw_list,
14012 cmd_tc_min_bw_parsed(
14013 void *parsed_result,
14014 __attribute__((unused)) struct cmdline *cl,
14015 __attribute__((unused)) void *data)
14017 struct cmd_vf_tc_bw_result *res = parsed_result;
14018 struct rte_port *port;
14021 int ret = -ENOTSUP;
14023 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14026 port = &ports[res->port_id];
14027 /** Check if the port is not started **/
14028 if (port->port_status != RTE_PORT_STOPPED) {
14029 printf("Please stop port %d first\n", res->port_id);
14033 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14037 #ifdef RTE_LIBRTE_IXGBE_PMD
14038 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14045 printf("invalid bandwidth\n");
14048 printf("invalid port_id %d\n", res->port_id);
14051 printf("function not implemented\n");
14054 printf("programming error: (%s)\n", strerror(-ret));
14058 cmdline_parse_inst_t cmd_tc_min_bw = {
14059 .f = cmd_tc_min_bw_parsed,
14061 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14063 (void *)&cmd_vf_tc_bw_set,
14064 (void *)&cmd_vf_tc_bw_tc,
14065 (void *)&cmd_vf_tc_bw_tx,
14066 (void *)&cmd_vf_tc_bw_min_bw,
14067 (void *)&cmd_vf_tc_bw_port_id,
14068 (void *)&cmd_vf_tc_bw_bw_list,
14073 /* TC max bandwidth setting */
14075 cmd_vf_tc_max_bw_parsed(
14076 void *parsed_result,
14077 __attribute__((unused)) struct cmdline *cl,
14078 __attribute__((unused)) void *data)
14080 struct cmd_vf_tc_bw_result *res = parsed_result;
14081 int ret = -ENOTSUP;
14083 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14086 #ifdef RTE_LIBRTE_I40E_PMD
14087 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14088 res->tc_no, res->bw);
14095 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14096 res->vf_id, res->tc_no, res->bw);
14099 printf("invalid port_id %d\n", res->port_id);
14102 printf("function not implemented\n");
14105 printf("programming error: (%s)\n", strerror(-ret));
14109 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14110 .f = cmd_vf_tc_max_bw_parsed,
14112 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14115 (void *)&cmd_vf_tc_bw_set,
14116 (void *)&cmd_vf_tc_bw_vf,
14117 (void *)&cmd_vf_tc_bw_tc,
14118 (void *)&cmd_vf_tc_bw_tx,
14119 (void *)&cmd_vf_tc_bw_max_bw,
14120 (void *)&cmd_vf_tc_bw_port_id,
14121 (void *)&cmd_vf_tc_bw_vf_id,
14122 (void *)&cmd_vf_tc_bw_tc_no,
14123 (void *)&cmd_vf_tc_bw_bw,
14129 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14131 /* *** Set Port default Traffic Management Hierarchy *** */
14132 struct cmd_set_port_tm_hierarchy_default_result {
14133 cmdline_fixed_string_t set;
14134 cmdline_fixed_string_t port;
14135 cmdline_fixed_string_t tm;
14136 cmdline_fixed_string_t hierarchy;
14137 cmdline_fixed_string_t def;
14141 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14142 TOKEN_STRING_INITIALIZER(
14143 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14144 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14145 TOKEN_STRING_INITIALIZER(
14146 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14147 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14148 TOKEN_STRING_INITIALIZER(
14149 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14150 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14151 TOKEN_STRING_INITIALIZER(
14152 struct cmd_set_port_tm_hierarchy_default_result,
14153 hierarchy, "hierarchy");
14154 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14155 TOKEN_STRING_INITIALIZER(
14156 struct cmd_set_port_tm_hierarchy_default_result,
14158 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14159 TOKEN_NUM_INITIALIZER(
14160 struct cmd_set_port_tm_hierarchy_default_result,
14163 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14164 __attribute__((unused)) struct cmdline *cl,
14165 __attribute__((unused)) void *data)
14167 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14168 struct rte_port *p;
14169 portid_t port_id = res->port_id;
14171 if (port_id_is_invalid(port_id, ENABLED_WARN))
14174 p = &ports[port_id];
14177 if (p->softport.tm_flag == 0) {
14178 printf(" tm not enabled on port %u (error)\n", port_id);
14182 /* Forward mode: tm */
14183 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14184 printf(" tm mode not enabled(error)\n");
14188 /* Set the default tm hierarchy */
14189 p->softport.tm.default_hierarchy_enable = 1;
14192 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14193 .f = cmd_set_port_tm_hierarchy_default_parsed,
14195 .help_str = "set port tm hierarchy default <port_id>",
14197 (void *)&cmd_set_port_tm_hierarchy_default_set,
14198 (void *)&cmd_set_port_tm_hierarchy_default_port,
14199 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14200 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14201 (void *)&cmd_set_port_tm_hierarchy_default_default,
14202 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14208 /* Strict link priority scheduling mode setting */
14210 cmd_strict_link_prio_parsed(
14211 void *parsed_result,
14212 __attribute__((unused)) struct cmdline *cl,
14213 __attribute__((unused)) void *data)
14215 struct cmd_vf_tc_bw_result *res = parsed_result;
14216 int ret = -ENOTSUP;
14218 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14221 #ifdef RTE_LIBRTE_I40E_PMD
14222 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14229 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14232 printf("invalid port_id %d\n", res->port_id);
14235 printf("function not implemented\n");
14238 printf("programming error: (%s)\n", strerror(-ret));
14242 cmdline_parse_inst_t cmd_strict_link_prio = {
14243 .f = cmd_strict_link_prio_parsed,
14245 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14247 (void *)&cmd_vf_tc_bw_set,
14248 (void *)&cmd_vf_tc_bw_tx,
14249 (void *)&cmd_vf_tc_bw_strict_link_prio,
14250 (void *)&cmd_vf_tc_bw_port_id,
14251 (void *)&cmd_vf_tc_bw_tc_map,
14256 /* Load dynamic device personalization*/
14257 struct cmd_ddp_add_result {
14258 cmdline_fixed_string_t ddp;
14259 cmdline_fixed_string_t add;
14264 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14265 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14266 cmdline_parse_token_string_t cmd_ddp_add_add =
14267 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14268 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14269 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14270 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14271 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14274 cmd_ddp_add_parsed(
14275 void *parsed_result,
14276 __attribute__((unused)) struct cmdline *cl,
14277 __attribute__((unused)) void *data)
14279 struct cmd_ddp_add_result *res = parsed_result;
14285 int ret = -ENOTSUP;
14287 if (res->port_id > nb_ports) {
14288 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14292 if (!all_ports_stopped()) {
14293 printf("Please stop all ports first\n");
14297 filepath = strdup(res->filepath);
14298 if (filepath == NULL) {
14299 printf("Failed to allocate memory\n");
14302 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14304 buff = open_ddp_package_file(file_fld[0], &size);
14306 free((void *)filepath);
14310 #ifdef RTE_LIBRTE_I40E_PMD
14311 if (ret == -ENOTSUP)
14312 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14314 RTE_PMD_I40E_PKG_OP_WR_ADD);
14317 if (ret == -EEXIST)
14318 printf("Profile has already existed.\n");
14320 printf("Failed to load profile.\n");
14321 else if (file_num == 2)
14322 save_ddp_package_file(file_fld[1], buff, size);
14324 close_ddp_package_file(buff);
14325 free((void *)filepath);
14328 cmdline_parse_inst_t cmd_ddp_add = {
14329 .f = cmd_ddp_add_parsed,
14331 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14333 (void *)&cmd_ddp_add_ddp,
14334 (void *)&cmd_ddp_add_add,
14335 (void *)&cmd_ddp_add_port_id,
14336 (void *)&cmd_ddp_add_filepath,
14341 /* Delete dynamic device personalization*/
14342 struct cmd_ddp_del_result {
14343 cmdline_fixed_string_t ddp;
14344 cmdline_fixed_string_t del;
14349 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14350 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14351 cmdline_parse_token_string_t cmd_ddp_del_del =
14352 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14353 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14354 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14355 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14356 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14359 cmd_ddp_del_parsed(
14360 void *parsed_result,
14361 __attribute__((unused)) struct cmdline *cl,
14362 __attribute__((unused)) void *data)
14364 struct cmd_ddp_del_result *res = parsed_result;
14367 int ret = -ENOTSUP;
14369 if (res->port_id > nb_ports) {
14370 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14374 if (!all_ports_stopped()) {
14375 printf("Please stop all ports first\n");
14379 buff = open_ddp_package_file(res->filepath, &size);
14383 #ifdef RTE_LIBRTE_I40E_PMD
14384 if (ret == -ENOTSUP)
14385 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14387 RTE_PMD_I40E_PKG_OP_WR_DEL);
14390 if (ret == -EACCES)
14391 printf("Profile does not exist.\n");
14393 printf("Failed to delete profile.\n");
14395 close_ddp_package_file(buff);
14398 cmdline_parse_inst_t cmd_ddp_del = {
14399 .f = cmd_ddp_del_parsed,
14401 .help_str = "ddp del <port_id> <profile_path>",
14403 (void *)&cmd_ddp_del_ddp,
14404 (void *)&cmd_ddp_del_del,
14405 (void *)&cmd_ddp_del_port_id,
14406 (void *)&cmd_ddp_del_filepath,
14411 /* Get dynamic device personalization profile info */
14412 struct cmd_ddp_info_result {
14413 cmdline_fixed_string_t ddp;
14414 cmdline_fixed_string_t get;
14415 cmdline_fixed_string_t info;
14419 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14420 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14421 cmdline_parse_token_string_t cmd_ddp_info_get =
14422 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14423 cmdline_parse_token_string_t cmd_ddp_info_info =
14424 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14425 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14426 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14429 cmd_ddp_info_parsed(
14430 void *parsed_result,
14431 __attribute__((unused)) struct cmdline *cl,
14432 __attribute__((unused)) void *data)
14434 struct cmd_ddp_info_result *res = parsed_result;
14437 int ret = -ENOTSUP;
14438 #ifdef RTE_LIBRTE_I40E_PMD
14441 uint32_t buff_size = 0;
14442 struct rte_pmd_i40e_profile_info info;
14443 uint32_t dev_num = 0;
14444 struct rte_pmd_i40e_ddp_device_id *devs;
14445 uint32_t proto_num = 0;
14446 struct rte_pmd_i40e_proto_info *proto = NULL;
14447 uint32_t pctype_num = 0;
14448 struct rte_pmd_i40e_ptype_info *pctype;
14449 uint32_t ptype_num = 0;
14450 struct rte_pmd_i40e_ptype_info *ptype;
14455 pkg = open_ddp_package_file(res->filepath, &pkg_size);
14459 #ifdef RTE_LIBRTE_I40E_PMD
14460 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14461 (uint8_t *)&info, sizeof(info),
14462 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14464 printf("Global Track id: 0x%x\n", info.track_id);
14465 printf("Global Version: %d.%d.%d.%d\n",
14466 info.version.major,
14467 info.version.minor,
14468 info.version.update,
14469 info.version.draft);
14470 printf("Global Package name: %s\n\n", info.name);
14473 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14474 (uint8_t *)&info, sizeof(info),
14475 RTE_PMD_I40E_PKG_INFO_HEADER);
14477 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14478 printf("i40e Profile Version: %d.%d.%d.%d\n",
14479 info.version.major,
14480 info.version.minor,
14481 info.version.update,
14482 info.version.draft);
14483 printf("i40e Profile name: %s\n\n", info.name);
14486 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14487 (uint8_t *)&buff_size, sizeof(buff_size),
14488 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14489 if (!ret && buff_size) {
14490 buff = (uint8_t *)malloc(buff_size);
14492 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14494 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14496 printf("Package Notes:\n%s\n\n", buff);
14501 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14502 (uint8_t *)&dev_num, sizeof(dev_num),
14503 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14504 if (!ret && dev_num) {
14505 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14506 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14508 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14509 (uint8_t *)devs, buff_size,
14510 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14512 printf("List of supported devices:\n");
14513 for (i = 0; i < dev_num; i++) {
14514 printf(" %04X:%04X %04X:%04X\n",
14515 devs[i].vendor_dev_id >> 16,
14516 devs[i].vendor_dev_id & 0xFFFF,
14517 devs[i].sub_vendor_dev_id >> 16,
14518 devs[i].sub_vendor_dev_id & 0xFFFF);
14526 /* get information about protocols and packet types */
14527 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14528 (uint8_t *)&proto_num, sizeof(proto_num),
14529 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14530 if (ret || !proto_num)
14531 goto no_print_return;
14533 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14534 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14536 goto no_print_return;
14538 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14540 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14542 printf("List of used protocols:\n");
14543 for (i = 0; i < proto_num; i++)
14544 printf(" %2u: %s\n", proto[i].proto_id,
14548 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14549 (uint8_t *)&pctype_num, sizeof(pctype_num),
14550 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14551 if (ret || !pctype_num)
14552 goto no_print_pctypes;
14554 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14555 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14557 goto no_print_pctypes;
14559 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14561 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14564 goto no_print_pctypes;
14567 printf("List of defined packet classification types:\n");
14568 for (i = 0; i < pctype_num; i++) {
14569 printf(" %2u:", pctype[i].ptype_id);
14570 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14571 proto_id = pctype[i].protocols[j];
14572 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14573 for (n = 0; n < proto_num; n++) {
14574 if (proto[n].proto_id == proto_id) {
14575 printf(" %s", proto[n].name);
14588 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14590 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14591 if (ret || !ptype_num)
14592 goto no_print_return;
14594 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14595 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14597 goto no_print_return;
14599 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14601 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14604 goto no_print_return;
14606 printf("List of defined packet types:\n");
14607 for (i = 0; i < ptype_num; i++) {
14608 printf(" %2u:", ptype[i].ptype_id);
14609 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14610 proto_id = ptype[i].protocols[j];
14611 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14612 for (n = 0; n < proto_num; n++) {
14613 if (proto[n].proto_id == proto_id) {
14614 printf(" %s", proto[n].name);
14630 if (ret == -ENOTSUP)
14631 printf("Function not supported in PMD driver\n");
14632 close_ddp_package_file(pkg);
14635 cmdline_parse_inst_t cmd_ddp_get_info = {
14636 .f = cmd_ddp_info_parsed,
14638 .help_str = "ddp get info <profile_path>",
14640 (void *)&cmd_ddp_info_ddp,
14641 (void *)&cmd_ddp_info_get,
14642 (void *)&cmd_ddp_info_info,
14643 (void *)&cmd_ddp_info_filepath,
14648 /* Get dynamic device personalization profile info list*/
14649 #define PROFILE_INFO_SIZE 48
14650 #define MAX_PROFILE_NUM 16
14652 struct cmd_ddp_get_list_result {
14653 cmdline_fixed_string_t ddp;
14654 cmdline_fixed_string_t get;
14655 cmdline_fixed_string_t list;
14659 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14660 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14661 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14662 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14663 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14664 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14665 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14666 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14669 cmd_ddp_get_list_parsed(
14670 void *parsed_result,
14671 __attribute__((unused)) struct cmdline *cl,
14672 __attribute__((unused)) void *data)
14674 struct cmd_ddp_get_list_result *res = parsed_result;
14675 #ifdef RTE_LIBRTE_I40E_PMD
14676 struct rte_pmd_i40e_profile_list *p_list;
14677 struct rte_pmd_i40e_profile_info *p_info;
14682 int ret = -ENOTSUP;
14684 if (res->port_id > nb_ports) {
14685 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14689 #ifdef RTE_LIBRTE_I40E_PMD
14690 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14691 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14693 printf("%s: Failed to malloc buffer\n", __func__);
14695 if (ret == -ENOTSUP)
14696 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14697 (uint8_t *)p_list, size);
14700 p_num = p_list->p_count;
14701 printf("Profile number is: %d\n\n", p_num);
14703 for (i = 0; i < p_num; i++) {
14704 p_info = &p_list->p_info[i];
14705 printf("Profile %d:\n", i);
14706 printf("Track id: 0x%x\n", p_info->track_id);
14707 printf("Version: %d.%d.%d.%d\n",
14708 p_info->version.major,
14709 p_info->version.minor,
14710 p_info->version.update,
14711 p_info->version.draft);
14712 printf("Profile name: %s\n\n", p_info->name);
14720 printf("Failed to get ddp list\n");
14723 cmdline_parse_inst_t cmd_ddp_get_list = {
14724 .f = cmd_ddp_get_list_parsed,
14726 .help_str = "ddp get list <port_id>",
14728 (void *)&cmd_ddp_get_list_ddp,
14729 (void *)&cmd_ddp_get_list_get,
14730 (void *)&cmd_ddp_get_list_list,
14731 (void *)&cmd_ddp_get_list_port_id,
14736 /* show vf stats */
14738 /* Common result structure for show vf stats */
14739 struct cmd_show_vf_stats_result {
14740 cmdline_fixed_string_t show;
14741 cmdline_fixed_string_t vf;
14742 cmdline_fixed_string_t stats;
14747 /* Common CLI fields show vf stats*/
14748 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14749 TOKEN_STRING_INITIALIZER
14750 (struct cmd_show_vf_stats_result,
14752 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14753 TOKEN_STRING_INITIALIZER
14754 (struct cmd_show_vf_stats_result,
14756 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14757 TOKEN_STRING_INITIALIZER
14758 (struct cmd_show_vf_stats_result,
14760 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14761 TOKEN_NUM_INITIALIZER
14762 (struct cmd_show_vf_stats_result,
14764 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14765 TOKEN_NUM_INITIALIZER
14766 (struct cmd_show_vf_stats_result,
14770 cmd_show_vf_stats_parsed(
14771 void *parsed_result,
14772 __attribute__((unused)) struct cmdline *cl,
14773 __attribute__((unused)) void *data)
14775 struct cmd_show_vf_stats_result *res = parsed_result;
14776 struct rte_eth_stats stats;
14777 int ret = -ENOTSUP;
14778 static const char *nic_stats_border = "########################";
14780 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14783 memset(&stats, 0, sizeof(stats));
14785 #ifdef RTE_LIBRTE_I40E_PMD
14786 if (ret == -ENOTSUP)
14787 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14791 #ifdef RTE_LIBRTE_BNXT_PMD
14792 if (ret == -ENOTSUP)
14793 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14802 printf("invalid vf_id %d\n", res->vf_id);
14805 printf("invalid port_id %d\n", res->port_id);
14808 printf("function not implemented\n");
14811 printf("programming error: (%s)\n", strerror(-ret));
14814 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14815 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14817 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14819 stats.ipackets, stats.imissed, stats.ibytes);
14820 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14821 printf(" RX-nombuf: %-10"PRIu64"\n",
14823 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14825 stats.opackets, stats.oerrors, stats.obytes);
14827 printf(" %s############################%s\n",
14828 nic_stats_border, nic_stats_border);
14831 cmdline_parse_inst_t cmd_show_vf_stats = {
14832 .f = cmd_show_vf_stats_parsed,
14834 .help_str = "show vf stats <port_id> <vf_id>",
14836 (void *)&cmd_show_vf_stats_show,
14837 (void *)&cmd_show_vf_stats_vf,
14838 (void *)&cmd_show_vf_stats_stats,
14839 (void *)&cmd_show_vf_stats_port_id,
14840 (void *)&cmd_show_vf_stats_vf_id,
14845 /* clear vf stats */
14847 /* Common result structure for clear vf stats */
14848 struct cmd_clear_vf_stats_result {
14849 cmdline_fixed_string_t clear;
14850 cmdline_fixed_string_t vf;
14851 cmdline_fixed_string_t stats;
14856 /* Common CLI fields clear vf stats*/
14857 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14858 TOKEN_STRING_INITIALIZER
14859 (struct cmd_clear_vf_stats_result,
14861 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14862 TOKEN_STRING_INITIALIZER
14863 (struct cmd_clear_vf_stats_result,
14865 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14866 TOKEN_STRING_INITIALIZER
14867 (struct cmd_clear_vf_stats_result,
14869 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14870 TOKEN_NUM_INITIALIZER
14871 (struct cmd_clear_vf_stats_result,
14873 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14874 TOKEN_NUM_INITIALIZER
14875 (struct cmd_clear_vf_stats_result,
14879 cmd_clear_vf_stats_parsed(
14880 void *parsed_result,
14881 __attribute__((unused)) struct cmdline *cl,
14882 __attribute__((unused)) void *data)
14884 struct cmd_clear_vf_stats_result *res = parsed_result;
14885 int ret = -ENOTSUP;
14887 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14890 #ifdef RTE_LIBRTE_I40E_PMD
14891 if (ret == -ENOTSUP)
14892 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14895 #ifdef RTE_LIBRTE_BNXT_PMD
14896 if (ret == -ENOTSUP)
14897 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14905 printf("invalid vf_id %d\n", res->vf_id);
14908 printf("invalid port_id %d\n", res->port_id);
14911 printf("function not implemented\n");
14914 printf("programming error: (%s)\n", strerror(-ret));
14918 cmdline_parse_inst_t cmd_clear_vf_stats = {
14919 .f = cmd_clear_vf_stats_parsed,
14921 .help_str = "clear vf stats <port_id> <vf_id>",
14923 (void *)&cmd_clear_vf_stats_clear,
14924 (void *)&cmd_clear_vf_stats_vf,
14925 (void *)&cmd_clear_vf_stats_stats,
14926 (void *)&cmd_clear_vf_stats_port_id,
14927 (void *)&cmd_clear_vf_stats_vf_id,
14932 /* port config pctype mapping reset */
14934 /* Common result structure for port config pctype mapping reset */
14935 struct cmd_pctype_mapping_reset_result {
14936 cmdline_fixed_string_t port;
14937 cmdline_fixed_string_t config;
14939 cmdline_fixed_string_t pctype;
14940 cmdline_fixed_string_t mapping;
14941 cmdline_fixed_string_t reset;
14944 /* Common CLI fields for port config pctype mapping reset*/
14945 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14946 TOKEN_STRING_INITIALIZER
14947 (struct cmd_pctype_mapping_reset_result,
14949 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14950 TOKEN_STRING_INITIALIZER
14951 (struct cmd_pctype_mapping_reset_result,
14953 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14954 TOKEN_NUM_INITIALIZER
14955 (struct cmd_pctype_mapping_reset_result,
14957 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14958 TOKEN_STRING_INITIALIZER
14959 (struct cmd_pctype_mapping_reset_result,
14961 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14962 TOKEN_STRING_INITIALIZER
14963 (struct cmd_pctype_mapping_reset_result,
14964 mapping, "mapping");
14965 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14966 TOKEN_STRING_INITIALIZER
14967 (struct cmd_pctype_mapping_reset_result,
14971 cmd_pctype_mapping_reset_parsed(
14972 void *parsed_result,
14973 __attribute__((unused)) struct cmdline *cl,
14974 __attribute__((unused)) void *data)
14976 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14977 int ret = -ENOTSUP;
14979 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14982 #ifdef RTE_LIBRTE_I40E_PMD
14983 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14990 printf("invalid port_id %d\n", res->port_id);
14993 printf("function not implemented\n");
14996 printf("programming error: (%s)\n", strerror(-ret));
15000 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15001 .f = cmd_pctype_mapping_reset_parsed,
15003 .help_str = "port config <port_id> pctype mapping reset",
15005 (void *)&cmd_pctype_mapping_reset_port,
15006 (void *)&cmd_pctype_mapping_reset_config,
15007 (void *)&cmd_pctype_mapping_reset_port_id,
15008 (void *)&cmd_pctype_mapping_reset_pctype,
15009 (void *)&cmd_pctype_mapping_reset_mapping,
15010 (void *)&cmd_pctype_mapping_reset_reset,
15015 /* show port pctype mapping */
15017 /* Common result structure for show port pctype mapping */
15018 struct cmd_pctype_mapping_get_result {
15019 cmdline_fixed_string_t show;
15020 cmdline_fixed_string_t port;
15022 cmdline_fixed_string_t pctype;
15023 cmdline_fixed_string_t mapping;
15026 /* Common CLI fields for pctype mapping get */
15027 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15028 TOKEN_STRING_INITIALIZER
15029 (struct cmd_pctype_mapping_get_result,
15031 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15032 TOKEN_STRING_INITIALIZER
15033 (struct cmd_pctype_mapping_get_result,
15035 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15036 TOKEN_NUM_INITIALIZER
15037 (struct cmd_pctype_mapping_get_result,
15039 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15040 TOKEN_STRING_INITIALIZER
15041 (struct cmd_pctype_mapping_get_result,
15043 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15044 TOKEN_STRING_INITIALIZER
15045 (struct cmd_pctype_mapping_get_result,
15046 mapping, "mapping");
15049 cmd_pctype_mapping_get_parsed(
15050 void *parsed_result,
15051 __attribute__((unused)) struct cmdline *cl,
15052 __attribute__((unused)) void *data)
15054 struct cmd_pctype_mapping_get_result *res = parsed_result;
15055 int ret = -ENOTSUP;
15056 #ifdef RTE_LIBRTE_I40E_PMD
15057 struct rte_pmd_i40e_flow_type_mapping
15058 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15059 int i, j, first_pctype;
15062 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15065 #ifdef RTE_LIBRTE_I40E_PMD
15066 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15073 printf("invalid port_id %d\n", res->port_id);
15076 printf("function not implemented\n");
15079 printf("programming error: (%s)\n", strerror(-ret));
15083 #ifdef RTE_LIBRTE_I40E_PMD
15084 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15085 if (mapping[i].pctype != 0ULL) {
15088 printf("pctype: ");
15089 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15090 if (mapping[i].pctype & (1ULL << j)) {
15091 printf(first_pctype ?
15092 "%02d" : ",%02d", j);
15096 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15102 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15103 .f = cmd_pctype_mapping_get_parsed,
15105 .help_str = "show port <port_id> pctype mapping",
15107 (void *)&cmd_pctype_mapping_get_show,
15108 (void *)&cmd_pctype_mapping_get_port,
15109 (void *)&cmd_pctype_mapping_get_port_id,
15110 (void *)&cmd_pctype_mapping_get_pctype,
15111 (void *)&cmd_pctype_mapping_get_mapping,
15116 /* port config pctype mapping update */
15118 /* Common result structure for port config pctype mapping update */
15119 struct cmd_pctype_mapping_update_result {
15120 cmdline_fixed_string_t port;
15121 cmdline_fixed_string_t config;
15123 cmdline_fixed_string_t pctype;
15124 cmdline_fixed_string_t mapping;
15125 cmdline_fixed_string_t update;
15126 cmdline_fixed_string_t pctype_list;
15127 uint16_t flow_type;
15130 /* Common CLI fields for pctype mapping update*/
15131 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15132 TOKEN_STRING_INITIALIZER
15133 (struct cmd_pctype_mapping_update_result,
15135 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15136 TOKEN_STRING_INITIALIZER
15137 (struct cmd_pctype_mapping_update_result,
15139 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15140 TOKEN_NUM_INITIALIZER
15141 (struct cmd_pctype_mapping_update_result,
15143 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15144 TOKEN_STRING_INITIALIZER
15145 (struct cmd_pctype_mapping_update_result,
15147 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15148 TOKEN_STRING_INITIALIZER
15149 (struct cmd_pctype_mapping_update_result,
15150 mapping, "mapping");
15151 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15152 TOKEN_STRING_INITIALIZER
15153 (struct cmd_pctype_mapping_update_result,
15155 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15156 TOKEN_STRING_INITIALIZER
15157 (struct cmd_pctype_mapping_update_result,
15158 pctype_list, NULL);
15159 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15160 TOKEN_NUM_INITIALIZER
15161 (struct cmd_pctype_mapping_update_result,
15162 flow_type, UINT16);
15165 cmd_pctype_mapping_update_parsed(
15166 void *parsed_result,
15167 __attribute__((unused)) struct cmdline *cl,
15168 __attribute__((unused)) void *data)
15170 struct cmd_pctype_mapping_update_result *res = parsed_result;
15171 int ret = -ENOTSUP;
15172 #ifdef RTE_LIBRTE_I40E_PMD
15173 struct rte_pmd_i40e_flow_type_mapping mapping;
15175 unsigned int nb_item;
15176 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15179 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15182 #ifdef RTE_LIBRTE_I40E_PMD
15183 nb_item = parse_item_list(res->pctype_list, "pctypes",
15184 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15185 mapping.flow_type = res->flow_type;
15186 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15187 mapping.pctype |= (1ULL << pctype_list[i]);
15188 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15198 printf("invalid pctype or flow type\n");
15201 printf("invalid port_id %d\n", res->port_id);
15204 printf("function not implemented\n");
15207 printf("programming error: (%s)\n", strerror(-ret));
15211 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15212 .f = cmd_pctype_mapping_update_parsed,
15214 .help_str = "port config <port_id> pctype mapping update"
15215 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15217 (void *)&cmd_pctype_mapping_update_port,
15218 (void *)&cmd_pctype_mapping_update_config,
15219 (void *)&cmd_pctype_mapping_update_port_id,
15220 (void *)&cmd_pctype_mapping_update_pctype,
15221 (void *)&cmd_pctype_mapping_update_mapping,
15222 (void *)&cmd_pctype_mapping_update_update,
15223 (void *)&cmd_pctype_mapping_update_pc_type,
15224 (void *)&cmd_pctype_mapping_update_flow_type,
15229 /* ptype mapping get */
15231 /* Common result structure for ptype mapping get */
15232 struct cmd_ptype_mapping_get_result {
15233 cmdline_fixed_string_t ptype;
15234 cmdline_fixed_string_t mapping;
15235 cmdline_fixed_string_t get;
15237 uint8_t valid_only;
15240 /* Common CLI fields for ptype mapping get */
15241 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15242 TOKEN_STRING_INITIALIZER
15243 (struct cmd_ptype_mapping_get_result,
15245 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15246 TOKEN_STRING_INITIALIZER
15247 (struct cmd_ptype_mapping_get_result,
15248 mapping, "mapping");
15249 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15250 TOKEN_STRING_INITIALIZER
15251 (struct cmd_ptype_mapping_get_result,
15253 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15254 TOKEN_NUM_INITIALIZER
15255 (struct cmd_ptype_mapping_get_result,
15257 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15258 TOKEN_NUM_INITIALIZER
15259 (struct cmd_ptype_mapping_get_result,
15260 valid_only, UINT8);
15263 cmd_ptype_mapping_get_parsed(
15264 void *parsed_result,
15265 __attribute__((unused)) struct cmdline *cl,
15266 __attribute__((unused)) void *data)
15268 struct cmd_ptype_mapping_get_result *res = parsed_result;
15269 int ret = -ENOTSUP;
15270 #ifdef RTE_LIBRTE_I40E_PMD
15271 int max_ptype_num = 256;
15272 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15277 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15280 #ifdef RTE_LIBRTE_I40E_PMD
15281 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15292 printf("invalid port_id %d\n", res->port_id);
15295 printf("function not implemented\n");
15298 printf("programming error: (%s)\n", strerror(-ret));
15301 #ifdef RTE_LIBRTE_I40E_PMD
15303 for (i = 0; i < count; i++)
15304 printf("%3d\t0x%08x\n",
15305 mapping[i].hw_ptype, mapping[i].sw_ptype);
15310 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15311 .f = cmd_ptype_mapping_get_parsed,
15313 .help_str = "ptype mapping get <port_id> <valid_only>",
15315 (void *)&cmd_ptype_mapping_get_ptype,
15316 (void *)&cmd_ptype_mapping_get_mapping,
15317 (void *)&cmd_ptype_mapping_get_get,
15318 (void *)&cmd_ptype_mapping_get_port_id,
15319 (void *)&cmd_ptype_mapping_get_valid_only,
15324 /* ptype mapping replace */
15326 /* Common result structure for ptype mapping replace */
15327 struct cmd_ptype_mapping_replace_result {
15328 cmdline_fixed_string_t ptype;
15329 cmdline_fixed_string_t mapping;
15330 cmdline_fixed_string_t replace;
15337 /* Common CLI fields for ptype mapping replace */
15338 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15339 TOKEN_STRING_INITIALIZER
15340 (struct cmd_ptype_mapping_replace_result,
15342 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15343 TOKEN_STRING_INITIALIZER
15344 (struct cmd_ptype_mapping_replace_result,
15345 mapping, "mapping");
15346 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15347 TOKEN_STRING_INITIALIZER
15348 (struct cmd_ptype_mapping_replace_result,
15349 replace, "replace");
15350 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15351 TOKEN_NUM_INITIALIZER
15352 (struct cmd_ptype_mapping_replace_result,
15354 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15355 TOKEN_NUM_INITIALIZER
15356 (struct cmd_ptype_mapping_replace_result,
15358 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15359 TOKEN_NUM_INITIALIZER
15360 (struct cmd_ptype_mapping_replace_result,
15362 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15363 TOKEN_NUM_INITIALIZER
15364 (struct cmd_ptype_mapping_replace_result,
15368 cmd_ptype_mapping_replace_parsed(
15369 void *parsed_result,
15370 __attribute__((unused)) struct cmdline *cl,
15371 __attribute__((unused)) void *data)
15373 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15374 int ret = -ENOTSUP;
15376 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15379 #ifdef RTE_LIBRTE_I40E_PMD
15380 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15390 printf("invalid ptype 0x%8x or 0x%8x\n",
15391 res->target, res->pkt_type);
15394 printf("invalid port_id %d\n", res->port_id);
15397 printf("function not implemented\n");
15400 printf("programming error: (%s)\n", strerror(-ret));
15404 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15405 .f = cmd_ptype_mapping_replace_parsed,
15408 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15410 (void *)&cmd_ptype_mapping_replace_ptype,
15411 (void *)&cmd_ptype_mapping_replace_mapping,
15412 (void *)&cmd_ptype_mapping_replace_replace,
15413 (void *)&cmd_ptype_mapping_replace_port_id,
15414 (void *)&cmd_ptype_mapping_replace_target,
15415 (void *)&cmd_ptype_mapping_replace_mask,
15416 (void *)&cmd_ptype_mapping_replace_pkt_type,
15421 /* ptype mapping reset */
15423 /* Common result structure for ptype mapping reset */
15424 struct cmd_ptype_mapping_reset_result {
15425 cmdline_fixed_string_t ptype;
15426 cmdline_fixed_string_t mapping;
15427 cmdline_fixed_string_t reset;
15431 /* Common CLI fields for ptype mapping reset*/
15432 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15433 TOKEN_STRING_INITIALIZER
15434 (struct cmd_ptype_mapping_reset_result,
15436 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15437 TOKEN_STRING_INITIALIZER
15438 (struct cmd_ptype_mapping_reset_result,
15439 mapping, "mapping");
15440 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15441 TOKEN_STRING_INITIALIZER
15442 (struct cmd_ptype_mapping_reset_result,
15444 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15445 TOKEN_NUM_INITIALIZER
15446 (struct cmd_ptype_mapping_reset_result,
15450 cmd_ptype_mapping_reset_parsed(
15451 void *parsed_result,
15452 __attribute__((unused)) struct cmdline *cl,
15453 __attribute__((unused)) void *data)
15455 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15456 int ret = -ENOTSUP;
15458 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15461 #ifdef RTE_LIBRTE_I40E_PMD
15462 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15469 printf("invalid port_id %d\n", res->port_id);
15472 printf("function not implemented\n");
15475 printf("programming error: (%s)\n", strerror(-ret));
15479 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15480 .f = cmd_ptype_mapping_reset_parsed,
15482 .help_str = "ptype mapping reset <port_id>",
15484 (void *)&cmd_ptype_mapping_reset_ptype,
15485 (void *)&cmd_ptype_mapping_reset_mapping,
15486 (void *)&cmd_ptype_mapping_reset_reset,
15487 (void *)&cmd_ptype_mapping_reset_port_id,
15492 /* ptype mapping update */
15494 /* Common result structure for ptype mapping update */
15495 struct cmd_ptype_mapping_update_result {
15496 cmdline_fixed_string_t ptype;
15497 cmdline_fixed_string_t mapping;
15498 cmdline_fixed_string_t reset;
15504 /* Common CLI fields for ptype mapping update*/
15505 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15506 TOKEN_STRING_INITIALIZER
15507 (struct cmd_ptype_mapping_update_result,
15509 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15510 TOKEN_STRING_INITIALIZER
15511 (struct cmd_ptype_mapping_update_result,
15512 mapping, "mapping");
15513 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15514 TOKEN_STRING_INITIALIZER
15515 (struct cmd_ptype_mapping_update_result,
15517 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15518 TOKEN_NUM_INITIALIZER
15519 (struct cmd_ptype_mapping_update_result,
15521 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15522 TOKEN_NUM_INITIALIZER
15523 (struct cmd_ptype_mapping_update_result,
15525 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15526 TOKEN_NUM_INITIALIZER
15527 (struct cmd_ptype_mapping_update_result,
15531 cmd_ptype_mapping_update_parsed(
15532 void *parsed_result,
15533 __attribute__((unused)) struct cmdline *cl,
15534 __attribute__((unused)) void *data)
15536 struct cmd_ptype_mapping_update_result *res = parsed_result;
15537 int ret = -ENOTSUP;
15538 #ifdef RTE_LIBRTE_I40E_PMD
15539 struct rte_pmd_i40e_ptype_mapping mapping;
15541 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15544 #ifdef RTE_LIBRTE_I40E_PMD
15545 mapping.hw_ptype = res->hw_ptype;
15546 mapping.sw_ptype = res->sw_ptype;
15547 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15557 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15560 printf("invalid port_id %d\n", res->port_id);
15563 printf("function not implemented\n");
15566 printf("programming error: (%s)\n", strerror(-ret));
15570 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15571 .f = cmd_ptype_mapping_update_parsed,
15573 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15575 (void *)&cmd_ptype_mapping_update_ptype,
15576 (void *)&cmd_ptype_mapping_update_mapping,
15577 (void *)&cmd_ptype_mapping_update_update,
15578 (void *)&cmd_ptype_mapping_update_port_id,
15579 (void *)&cmd_ptype_mapping_update_hw_ptype,
15580 (void *)&cmd_ptype_mapping_update_sw_ptype,
15585 /* Common result structure for file commands */
15586 struct cmd_cmdfile_result {
15587 cmdline_fixed_string_t load;
15588 cmdline_fixed_string_t filename;
15591 /* Common CLI fields for file commands */
15592 cmdline_parse_token_string_t cmd_load_cmdfile =
15593 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15594 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15595 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15598 cmd_load_from_file_parsed(
15599 void *parsed_result,
15600 __attribute__((unused)) struct cmdline *cl,
15601 __attribute__((unused)) void *data)
15603 struct cmd_cmdfile_result *res = parsed_result;
15605 cmdline_read_from_file(res->filename);
15608 cmdline_parse_inst_t cmd_load_from_file = {
15609 .f = cmd_load_from_file_parsed,
15611 .help_str = "load <filename>",
15613 (void *)&cmd_load_cmdfile,
15614 (void *)&cmd_load_cmdfile_filename,
15619 /* ******************************************************************************** */
15621 /* list of instructions */
15622 cmdline_parse_ctx_t main_ctx[] = {
15623 (cmdline_parse_inst_t *)&cmd_help_brief,
15624 (cmdline_parse_inst_t *)&cmd_help_long,
15625 (cmdline_parse_inst_t *)&cmd_quit,
15626 (cmdline_parse_inst_t *)&cmd_load_from_file,
15627 (cmdline_parse_inst_t *)&cmd_showport,
15628 (cmdline_parse_inst_t *)&cmd_showqueue,
15629 (cmdline_parse_inst_t *)&cmd_showportall,
15630 (cmdline_parse_inst_t *)&cmd_showcfg,
15631 (cmdline_parse_inst_t *)&cmd_start,
15632 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15633 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15634 (cmdline_parse_inst_t *)&cmd_set_link_up,
15635 (cmdline_parse_inst_t *)&cmd_set_link_down,
15636 (cmdline_parse_inst_t *)&cmd_reset,
15637 (cmdline_parse_inst_t *)&cmd_set_numbers,
15638 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15639 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15640 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15641 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15642 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15643 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15644 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15645 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15646 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15647 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15648 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15649 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15650 (cmdline_parse_inst_t *)&cmd_set_link_check,
15651 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15652 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15653 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15654 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15655 #ifdef RTE_LIBRTE_PMD_BOND
15656 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15657 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15658 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15659 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15660 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15661 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15662 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15663 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15664 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15665 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15666 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15668 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15669 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15670 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15671 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15672 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15673 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15674 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15675 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15676 (cmdline_parse_inst_t *)&cmd_csum_set,
15677 (cmdline_parse_inst_t *)&cmd_csum_show,
15678 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15679 (cmdline_parse_inst_t *)&cmd_tso_set,
15680 (cmdline_parse_inst_t *)&cmd_tso_show,
15681 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15682 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15683 (cmdline_parse_inst_t *)&cmd_gro_enable,
15684 (cmdline_parse_inst_t *)&cmd_gro_flush,
15685 (cmdline_parse_inst_t *)&cmd_gro_show,
15686 (cmdline_parse_inst_t *)&cmd_gso_enable,
15687 (cmdline_parse_inst_t *)&cmd_gso_size,
15688 (cmdline_parse_inst_t *)&cmd_gso_show,
15689 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15690 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15691 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15692 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15693 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15694 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15695 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15696 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15697 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15698 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15699 (cmdline_parse_inst_t *)&cmd_config_dcb,
15700 (cmdline_parse_inst_t *)&cmd_read_reg,
15701 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15702 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15703 (cmdline_parse_inst_t *)&cmd_write_reg,
15704 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15705 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15706 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15707 (cmdline_parse_inst_t *)&cmd_stop,
15708 (cmdline_parse_inst_t *)&cmd_mac_addr,
15709 (cmdline_parse_inst_t *)&cmd_set_qmap,
15710 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
15711 (cmdline_parse_inst_t *)&cmd_operate_port,
15712 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15713 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15714 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15715 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15716 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15717 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15718 (cmdline_parse_inst_t *)&cmd_config_mtu,
15719 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15720 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15721 (cmdline_parse_inst_t *)&cmd_config_rss,
15722 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15723 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15724 (cmdline_parse_inst_t *)&cmd_showport_reta,
15725 (cmdline_parse_inst_t *)&cmd_config_burst,
15726 (cmdline_parse_inst_t *)&cmd_config_thresh,
15727 (cmdline_parse_inst_t *)&cmd_config_threshold,
15728 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15729 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15730 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15731 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15732 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15733 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15734 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15735 (cmdline_parse_inst_t *)&cmd_global_config,
15736 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15737 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15738 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15739 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15740 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15741 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15742 (cmdline_parse_inst_t *)&cmd_dump,
15743 (cmdline_parse_inst_t *)&cmd_dump_one,
15744 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15745 (cmdline_parse_inst_t *)&cmd_syn_filter,
15746 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15747 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15748 (cmdline_parse_inst_t *)&cmd_flex_filter,
15749 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15750 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15751 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15752 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15753 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15754 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15755 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15756 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15757 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15758 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15759 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15760 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15761 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15762 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15763 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15764 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15765 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15766 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15767 (cmdline_parse_inst_t *)&cmd_flow,
15768 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
15769 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15770 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15771 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15772 (cmdline_parse_inst_t *)&cmd_create_port_meter,
15773 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
15774 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
15775 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15776 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15777 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
15778 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15779 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15780 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15781 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15782 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15783 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15784 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15785 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15786 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15787 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15788 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15789 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15790 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15791 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15792 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15793 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15794 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15795 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15796 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15797 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15798 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15799 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15800 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15801 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15802 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15803 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15804 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15805 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15806 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15807 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15808 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15809 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15810 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15811 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15812 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15813 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15814 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15815 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15816 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15817 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15818 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15820 (cmdline_parse_inst_t *)&cmd_ddp_add,
15821 (cmdline_parse_inst_t *)&cmd_ddp_del,
15822 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15823 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15824 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15825 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15826 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15827 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15828 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15829 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15831 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15832 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15833 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15834 (cmdline_parse_inst_t *)&cmd_queue_region,
15835 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15836 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15837 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15838 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15839 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15840 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15841 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15842 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15843 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15844 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15845 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15846 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15847 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15848 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15849 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15850 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
15851 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
15852 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
15853 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
15854 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
15855 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
15859 /* read cmdline commands from file */
15861 cmdline_read_from_file(const char *filename)
15863 struct cmdline *cl;
15865 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15867 printf("Failed to create file based cmdline context: %s\n",
15872 cmdline_interact(cl);
15877 printf("Read CLI commands from %s\n", filename);
15880 /* prompt function, called from main on MASTER lcore */
15884 /* initialize non-constant commands */
15885 cmd_set_fwd_mode_init();
15886 cmd_set_fwd_retry_mode_init();
15888 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15889 if (testpmd_cl == NULL)
15891 cmdline_interact(testpmd_cl);
15892 cmdline_stdin_exit(testpmd_cl);
15898 if (testpmd_cl != NULL)
15899 cmdline_quit(testpmd_cl);
15903 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15905 if (id == (portid_t)RTE_PORT_ALL) {
15908 RTE_ETH_FOREACH_DEV(pid) {
15909 /* check if need_reconfig has been set to 1 */
15910 if (ports[pid].need_reconfig == 0)
15911 ports[pid].need_reconfig = dev;
15912 /* check if need_reconfig_queues has been set to 1 */
15913 if (ports[pid].need_reconfig_queues == 0)
15914 ports[pid].need_reconfig_queues = queue;
15916 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15917 /* check if need_reconfig has been set to 1 */
15918 if (ports[id].need_reconfig == 0)
15919 ports[id].need_reconfig = dev;
15920 /* check if need_reconfig_queues has been set to 1 */
15921 if (ports[id].need_reconfig_queues == 0)
15922 ports[id].need_reconfig_queues = queue;