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_DPAA_PMD
93 #include <rte_pmd_dpaa.h>
95 #ifdef RTE_LIBRTE_IXGBE_PMD
96 #include <rte_pmd_ixgbe.h>
98 #ifdef RTE_LIBRTE_I40E_PMD
99 #include <rte_pmd_i40e.h>
101 #ifdef RTE_LIBRTE_BNXT_PMD
102 #include <rte_pmd_bnxt.h>
105 #include "cmdline_mtr.h"
106 #include "cmdline_tm.h"
108 static struct cmdline *testpmd_cl;
110 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
112 /* *** Help command with introduction. *** */
113 struct cmd_help_brief_result {
114 cmdline_fixed_string_t help;
117 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
119 __attribute__((unused)) void *data)
124 "Help is available for the following sections:\n\n"
125 " help control : Start and stop forwarding.\n"
126 " help display : Displaying port, stats and config "
128 " help config : Configuration information.\n"
129 " help ports : Configuring ports.\n"
130 " help registers : Reading and setting port registers.\n"
131 " help filters : Filters configuration help.\n"
132 " help all : All of the above sections.\n\n"
137 cmdline_parse_token_string_t cmd_help_brief_help =
138 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
140 cmdline_parse_inst_t cmd_help_brief = {
141 .f = cmd_help_brief_parsed,
143 .help_str = "help: Show help",
145 (void *)&cmd_help_brief_help,
150 /* *** Help command with help sections. *** */
151 struct cmd_help_long_result {
152 cmdline_fixed_string_t help;
153 cmdline_fixed_string_t section;
156 static void cmd_help_long_parsed(void *parsed_result,
158 __attribute__((unused)) void *data)
161 struct cmd_help_long_result *res = parsed_result;
163 if (!strcmp(res->section, "all"))
166 if (show_all || !strcmp(res->section, "control")) {
171 "Control forwarding:\n"
172 "-------------------\n\n"
175 " Start packet forwarding with current configuration.\n\n"
178 " Start packet forwarding with current config"
179 " after sending one burst of packets.\n\n"
182 " Stop packet forwarding, and display accumulated"
186 " Quit to prompt.\n\n"
190 if (show_all || !strcmp(res->section, "display")) {
198 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
199 " Display information for port_id, or all.\n\n"
201 "show port X rss reta (size) (mask0,mask1,...)\n"
202 " Display the rss redirection table entry indicated"
203 " by masks on port X. size is used to indicate the"
204 " hardware supported reta size\n\n"
206 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
207 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
208 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
209 " Display the RSS hash functions and RSS hash key"
212 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
213 " Clear information for port_id, or all.\n\n"
215 "show (rxq|txq) info (port_id) (queue_id)\n"
216 " Display information for configured RX/TX queue.\n\n"
218 "show config (rxtx|cores|fwd|txpkts)\n"
219 " Display the given configuration.\n\n"
221 "read rxd (port_id) (queue_id) (rxd_id)\n"
222 " Display an RX descriptor of a port RX queue.\n\n"
224 "read txd (port_id) (queue_id) (txd_id)\n"
225 " Display a TX descriptor of a port TX queue.\n\n"
227 "ddp get list (port_id)\n"
228 " Get ddp profile info list\n\n"
230 "ddp get info (profile_path)\n"
231 " Get ddp profile information.\n\n"
233 "show vf stats (port_id) (vf_id)\n"
234 " Display a VF's statistics.\n\n"
236 "clear vf stats (port_id) (vf_id)\n"
237 " Reset a VF's statistics.\n\n"
239 "show port (port_id) pctype mapping\n"
240 " Get flow ptype to pctype mapping on a port\n\n"
242 "show port meter stats (port_id) (meter_id) (clear)\n"
243 " Get meter stats on a port\n\n"
244 "show port tm cap (port_id)\n"
245 " Display the port TM capability.\n\n"
247 "show port tm level cap (port_id) (level_id)\n"
248 " Display the port TM hierarchical level capability.\n\n"
250 "show port tm node cap (port_id) (node_id)\n"
251 " Display the port TM node capability.\n\n"
253 "show port tm node type (port_id) (node_id)\n"
254 " Display the port TM node type.\n\n"
256 "show port tm node stats (port_id) (node_id) (clear)\n"
257 " Display the port TM node stats.\n\n"
262 if (show_all || !strcmp(res->section, "config")) {
268 "Configuration changes only become active when"
269 " forwarding is started/restarted.\n\n"
272 " Reset forwarding to the default configuration.\n\n"
274 "set verbose (level)\n"
275 " Set the debug verbosity level X.\n\n"
278 " Set number of ports.\n\n"
281 " Set number of cores.\n\n"
283 "set coremask (mask)\n"
284 " Set the forwarding cores hexadecimal mask.\n\n"
286 "set portmask (mask)\n"
287 " Set the forwarding ports hexadecimal mask.\n\n"
290 " Set number of packets per burst.\n\n"
292 "set burst tx delay (microseconds) retry (num)\n"
293 " Set the transmit delay time and number of retries,"
294 " effective when retry is enabled.\n\n"
296 "set txpkts (x[,y]*)\n"
297 " Set the length of each segment of TXONLY"
298 " and optionally CSUM packets.\n\n"
300 "set txsplit (off|on|rand)\n"
301 " Set the split policy for the TX packets."
302 " Right now only applicable for CSUM and TXONLY"
305 "set corelist (x[,y]*)\n"
306 " Set the list of forwarding cores.\n\n"
308 "set portlist (x[,y]*)\n"
309 " Set the list of forwarding ports.\n\n"
311 "set tx loopback (port_id) (on|off)\n"
312 " Enable or disable tx loopback.\n\n"
314 "set all queues drop (port_id) (on|off)\n"
315 " Set drop enable bit for all queues.\n\n"
317 "set vf split drop (port_id) (vf_id) (on|off)\n"
318 " Set split drop enable bit for a VF from the PF.\n\n"
320 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
321 " Set MAC antispoof for a VF from the PF.\n\n"
323 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
324 " Enable MACsec offload.\n\n"
326 "set macsec offload (port_id) off\n"
327 " Disable MACsec offload.\n\n"
329 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
330 " Configure MACsec secure connection (SC).\n\n"
332 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
333 " Configure MACsec secure association (SA).\n\n"
335 "set vf broadcast (port_id) (vf_id) (on|off)\n"
336 " Set VF broadcast for a VF from the PF.\n\n"
338 "vlan set strip (on|off) (port_id)\n"
339 " Set the VLAN strip on a port.\n\n"
341 "vlan set stripq (on|off) (port_id,queue_id)\n"
342 " Set the VLAN strip for a queue on a port.\n\n"
344 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
345 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
347 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
348 " Set VLAN insert for a VF from the PF.\n\n"
350 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
351 " Set VLAN antispoof for a VF from the PF.\n\n"
353 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
354 " Set VLAN tag for a VF from the PF.\n\n"
356 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
357 " Set a VF's max bandwidth(Mbps).\n\n"
359 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
360 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
362 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
363 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
365 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
366 " Set some TCs' strict link priority mode on a physical port.\n\n"
368 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
369 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
371 "vlan set filter (on|off) (port_id)\n"
372 " Set the VLAN filter on a port.\n\n"
374 "vlan set qinq (on|off) (port_id)\n"
375 " Set the VLAN QinQ (extended queue in queue)"
378 "vlan set (inner|outer) tpid (value) (port_id)\n"
379 " Set the VLAN TPID for Packet Filtering on"
382 "rx_vlan add (vlan_id|all) (port_id)\n"
383 " Add a vlan_id, or all identifiers, to the set"
384 " of VLAN identifiers filtered by port_id.\n\n"
386 "rx_vlan rm (vlan_id|all) (port_id)\n"
387 " Remove a vlan_id, or all identifiers, from the set"
388 " of VLAN identifiers filtered by port_id.\n\n"
390 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
391 " Add a vlan_id, to the set of VLAN identifiers"
392 "filtered for VF(s) from port_id.\n\n"
394 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
395 " Remove a vlan_id, to the set of VLAN identifiers"
396 "filtered for VF(s) from port_id.\n\n"
398 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
399 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
400 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
401 " add a tunnel filter of a port.\n\n"
403 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
404 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
405 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
406 " remove a tunnel filter of a port.\n\n"
408 "rx_vxlan_port add (udp_port) (port_id)\n"
409 " Add an UDP port for VXLAN packet filter on a port\n\n"
411 "rx_vxlan_port rm (udp_port) (port_id)\n"
412 " Remove an UDP port for VXLAN packet filter on a port\n\n"
414 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
415 " Set hardware insertion of VLAN IDs (single or double VLAN "
416 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
418 "tx_vlan set pvid port_id vlan_id (on|off)\n"
419 " Set port based TX VLAN insertion.\n\n"
421 "tx_vlan reset (port_id)\n"
422 " Disable hardware insertion of a VLAN header in"
423 " packets sent on a port.\n\n"
425 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
426 " Select hardware or software calculation of the"
427 " checksum when transmitting a packet using the"
428 " csum forward engine.\n"
429 " ip|udp|tcp|sctp always concern the inner layer.\n"
430 " outer-ip concerns the outer IP layer in"
431 " case the packet is recognized as a tunnel packet by"
432 " the forward engine (vxlan, gre and ipip are supported)\n"
433 " Please check the NIC datasheet for HW limits.\n\n"
435 "csum parse-tunnel (on|off) (tx_port_id)\n"
436 " If disabled, treat tunnel packets as non-tunneled"
437 " packets (treat inner headers as payload). The port\n"
438 " argument is the port used for TX in csum forward"
441 "csum show (port_id)\n"
442 " Display tx checksum offload configuration\n\n"
444 "tso set (segsize) (portid)\n"
445 " Enable TCP Segmentation Offload in csum forward"
447 " Please check the NIC datasheet for HW limits.\n\n"
450 " Display the status of TCP Segmentation Offload.\n\n"
452 "set port (port_id) gro on|off\n"
453 " Enable or disable Generic Receive Offload in"
454 " csum forwarding engine.\n\n"
456 "show port (port_id) gro\n"
457 " Display GRO configuration.\n\n"
459 "set gro flush (cycles)\n"
460 " Set the cycle to flush GROed packets from"
461 " reassembly tables.\n\n"
463 "set port (port_id) gso (on|off)"
464 " Enable or disable Generic Segmentation Offload in"
465 " csum forwarding engine.\n\n"
467 "set gso segsz (length)\n"
468 " Set max packet length for output GSO segments,"
469 " including packet header and payload.\n\n"
471 "show port (port_id) gso\n"
472 " Show GSO configuration.\n\n"
475 " Set packet forwarding mode.\n\n"
477 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
478 " Add a MAC address on port_id.\n\n"
480 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
481 " Remove a MAC address from port_id.\n\n"
483 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
484 " Set the default MAC address for port_id.\n\n"
486 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
487 " Add a MAC address for a VF on the port.\n\n"
489 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
490 " Set the MAC address for a VF from the PF.\n\n"
492 "set eth-peer (port_id) (peer_addr)\n"
493 " set the peer address for certain port.\n\n"
495 "set port (port_id) uta (mac_address|all) (on|off)\n"
496 " Add/Remove a or all unicast hash filter(s)"
499 "set promisc (port_id|all) (on|off)\n"
500 " Set the promiscuous mode on port_id, or all.\n\n"
502 "set allmulti (port_id|all) (on|off)\n"
503 " Set the allmulti mode on port_id, or all.\n\n"
505 "set vf promisc (port_id) (vf_id) (on|off)\n"
506 " Set unicast promiscuous mode for a VF from the PF.\n\n"
508 "set vf allmulti (port_id) (vf_id) (on|off)\n"
509 " Set multicast promiscuous mode for a VF from the PF.\n\n"
511 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
512 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
513 " (on|off) autoneg (on|off) (port_id)\n"
514 "set flow_ctrl rx (on|off) (portid)\n"
515 "set flow_ctrl tx (on|off) (portid)\n"
516 "set flow_ctrl high_water (high_water) (portid)\n"
517 "set flow_ctrl low_water (low_water) (portid)\n"
518 "set flow_ctrl pause_time (pause_time) (portid)\n"
519 "set flow_ctrl send_xon (send_xon) (portid)\n"
520 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
521 "set flow_ctrl autoneg (on|off) (port_id)\n"
522 " Set the link flow control parameter on a port.\n\n"
524 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
525 " (low_water) (pause_time) (priority) (port_id)\n"
526 " Set the priority flow control parameter on a"
529 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
530 " Set statistics mapping (qmapping 0..15) for RX/TX"
532 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
533 " on port 0 to mapping 5.\n\n"
535 "set xstats-hide-zero on|off\n"
536 " Set the option to hide the zero values"
537 " for xstats display.\n"
539 "set port (port_id) vf (vf_id) rx|tx on|off\n"
540 " Enable/Disable a VF receive/tranmit from a port\n\n"
542 "set port (port_id) vf (vf_id) (mac_addr)"
543 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
544 " Add/Remove unicast or multicast MAC addr filter"
547 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
549 " AUPE:accepts untagged VLAN;"
550 "ROPE:accept unicast hash\n\n"
551 " BAM:accepts broadcast packets;"
552 "MPE:accepts all multicast packets\n\n"
553 " Enable/Disable a VF receive mode of a port\n\n"
555 "set port (port_id) queue (queue_id) rate (rate_num)\n"
556 " Set rate limit for a queue of a port\n\n"
558 "set port (port_id) vf (vf_id) rate (rate_num) "
559 "queue_mask (queue_mask_value)\n"
560 " Set rate limit for queues in VF of a port\n\n"
562 "set port (port_id) mirror-rule (rule_id)"
563 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
564 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
565 " Set pool or vlan type mirror rule on a port.\n"
566 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
567 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
570 "set port (port_id) mirror-rule (rule_id)"
571 " (uplink-mirror|downlink-mirror) dst-pool"
572 " (pool_id) (on|off)\n"
573 " Set uplink or downlink type mirror rule on a port.\n"
574 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
575 " 0 on' enable mirror income traffic to pool 0.\n\n"
577 "reset port (port_id) mirror-rule (rule_id)\n"
578 " Reset a mirror rule.\n\n"
580 "set flush_rx (on|off)\n"
581 " Flush (default) or don't flush RX streams before"
582 " forwarding. Mainly used with PCAP drivers.\n\n"
584 "set bypass mode (normal|bypass|isolate) (port_id)\n"
585 " Set the bypass mode for the lowest port on bypass enabled"
588 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
589 "mode (normal|bypass|isolate) (port_id)\n"
590 " Set the event required to initiate specified bypass mode for"
591 " the lowest port on a bypass enabled NIC where:\n"
592 " timeout = enable bypass after watchdog timeout.\n"
593 " os_on = enable bypass when OS/board is powered on.\n"
594 " os_off = enable bypass when OS/board is powered off.\n"
595 " power_on = enable bypass when power supply is turned on.\n"
596 " power_off = enable bypass when power supply is turned off."
599 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
600 " Set the bypass watchdog timeout to 'n' seconds"
601 " where 0 = instant.\n\n"
603 "show bypass config (port_id)\n"
604 " Show the bypass configuration for a bypass enabled NIC"
605 " using the lowest port on the NIC.\n\n"
607 #ifdef RTE_LIBRTE_PMD_BOND
608 "create bonded device (mode) (socket)\n"
609 " Create a new bonded device with specific bonding mode and socket.\n\n"
611 "add bonding slave (slave_id) (port_id)\n"
612 " Add a slave device to a bonded device.\n\n"
614 "remove bonding slave (slave_id) (port_id)\n"
615 " Remove a slave device from a bonded device.\n\n"
617 "set bonding mode (value) (port_id)\n"
618 " Set the bonding mode on a bonded device.\n\n"
620 "set bonding primary (slave_id) (port_id)\n"
621 " Set the primary slave for a bonded device.\n\n"
623 "show bonding config (port_id)\n"
624 " Show the bonding config for port_id.\n\n"
626 "set bonding mac_addr (port_id) (address)\n"
627 " Set the MAC address of a bonded device.\n\n"
629 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
630 " Set Aggregation mode for IEEE802.3AD (mode 4)"
632 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
633 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
635 "set bonding mon_period (port_id) (value)\n"
636 " Set the bonding link status monitoring polling period in ms.\n\n"
638 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
639 " Enable/disable dedicated queues for LACP control traffic.\n\n"
642 "set link-up port (port_id)\n"
643 " Set link up for a port.\n\n"
645 "set link-down port (port_id)\n"
646 " Set link down for a port.\n\n"
648 "E-tag set insertion on port-tag-id (value)"
649 " port (port_id) vf (vf_id)\n"
650 " Enable E-tag insertion for a VF on a port\n\n"
652 "E-tag set insertion off port (port_id) vf (vf_id)\n"
653 " Disable E-tag insertion for a VF on a port\n\n"
655 "E-tag set stripping (on|off) port (port_id)\n"
656 " Enable/disable E-tag stripping on a port\n\n"
658 "E-tag set forwarding (on|off) port (port_id)\n"
659 " Enable/disable E-tag based forwarding"
662 "E-tag set filter add e-tag-id (value) dst-pool"
663 " (pool_id) port (port_id)\n"
664 " Add an E-tag forwarding filter on a port\n\n"
666 "E-tag set filter del e-tag-id (value) port (port_id)\n"
667 " Delete an E-tag forwarding filter on a port\n\n"
669 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
670 "set port tm hierarchy default (port_id)\n"
671 " Set default traffic Management hierarchy on a port\n\n"
674 "ddp add (port_id) (profile_path[,output_path])\n"
675 " Load a profile package on a port\n\n"
677 "ddp del (port_id) (profile_path)\n"
678 " Delete a profile package from a port\n\n"
680 "ptype mapping get (port_id) (valid_only)\n"
681 " Get ptype mapping on a port\n\n"
683 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
684 " Replace target with the pkt_type in ptype mapping\n\n"
686 "ptype mapping reset (port_id)\n"
687 " Reset ptype mapping on a port\n\n"
689 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
690 " Update a ptype mapping item on a port\n\n"
692 "set port (port_id) queue-region region_id (value) "
693 "queue_start_index (value) queue_num (value)\n"
694 " Set a queue region on a port\n\n"
696 "set port (port_id) queue-region region_id (value) "
698 " Set a flowtype region index on a port\n\n"
700 "set port (port_id) queue-region UP (value) region_id (value)\n"
701 " Set the mapping of User Priority to "
702 "queue region on a port\n\n"
704 "set port (port_id) queue-region flush (on|off)\n"
705 " flush all queue region related configuration\n\n"
707 "show port meter cap (port_id)\n"
708 " Show port meter capability information\n\n"
710 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
711 " meter profile add - srtcm rfc 2697\n\n"
713 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
714 " meter profile add - trtcm rfc 2698\n\n"
716 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
717 " meter profile add - trtcm rfc 4115\n\n"
719 "del port meter profile (port_id) (profile_id)\n"
720 " meter profile delete\n\n"
722 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
723 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
724 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
725 "(dscp_tbl_entry63)]\n"
728 "enable port meter (port_id) (mtr_id)\n"
731 "disable port meter (port_id) (mtr_id)\n"
734 "del port meter (port_id) (mtr_id)\n"
737 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
738 " meter update meter profile\n\n"
740 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
741 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
742 " update meter dscp table entries\n\n"
744 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
745 "(action0) [(action1) (action2)]\n"
746 " meter update policer action\n\n"
748 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
749 " meter update stats\n\n"
751 "show port (port_id) queue-region\n"
752 " show all queue region related configuration info\n\n"
754 "add port tm node shaper profile (port_id) (shaper_profile_id)"
755 " (tb_rate) (tb_size) (packet_length_adjust)\n"
756 " Add port tm node private shaper profile.\n\n"
758 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
759 " Delete port tm node private shaper profile.\n\n"
761 "add port tm node shared shaper (port_id) (shared_shaper_id)"
762 " (shaper_profile_id)\n"
763 " Add/update port tm node shared shaper.\n\n"
765 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
766 " Delete port tm node shared shaper.\n\n"
768 "set port tm node shaper profile (port_id) (node_id)"
769 " (shaper_profile_id)\n"
770 " Set port tm node shaper profile.\n\n"
772 "add port tm node wred profile (port_id) (wred_profile_id)"
773 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
774 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
775 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
776 " Add port tm node wred profile.\n\n"
778 "del port tm node wred profile (port_id) (wred_profile_id)\n"
779 " Delete port tm node wred profile.\n\n"
781 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
782 " (priority) (weight) (level_id) (shaper_profile_id)"
783 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
784 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
785 " Add port tm nonleaf node.\n\n"
787 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
788 " (priority) (weight) (level_id) (shaper_profile_id)"
789 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
790 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
791 " Add port tm leaf node.\n\n"
793 "del port tm node (port_id) (node_id)\n"
794 " Delete port tm node.\n\n"
796 "set port tm node parent (port_id) (node_id) (parent_node_id)"
797 " (priority) (weight)\n"
798 " Set port tm node parent.\n\n"
800 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
801 " Commit tm hierarchy.\n\n"
803 , list_pkt_forwarding_modes()
807 if (show_all || !strcmp(res->section, "ports")) {
813 "----------------\n\n"
815 "port start (port_id|all)\n"
816 " Start all ports or port_id.\n\n"
818 "port stop (port_id|all)\n"
819 " Stop all ports or port_id.\n\n"
821 "port close (port_id|all)\n"
822 " Close all ports or port_id.\n\n"
824 "port attach (ident)\n"
825 " Attach physical or virtual dev by pci address or virtual device name\n\n"
827 "port detach (port_id)\n"
828 " Detach physical or virtual dev by port_id\n\n"
830 "port config (port_id|all)"
831 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
832 " duplex (half|full|auto)\n"
833 " Set speed and duplex for all ports or port_id\n\n"
835 "port config all (rxq|txq|rxd|txd) (value)\n"
836 " Set number for rxq/txq/rxd/txd.\n\n"
838 "port config all max-pkt-len (value)\n"
839 " Set the max packet length.\n\n"
841 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
842 "hw-vlan-strip|hw-vlan-extend|drop-en)"
844 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
847 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
848 "geneve|nvgre|none|<flowtype_id>)\n"
849 " Set the RSS mode.\n\n"
851 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
852 " Set the RSS redirection table.\n\n"
854 "port config (port_id) dcb vt (on|off) (traffic_class)"
856 " Set the DCB mode.\n\n"
858 "port config all burst (value)\n"
859 " Set the number of packets per burst.\n\n"
861 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
863 " Set the ring prefetch/host/writeback threshold"
864 " for tx/rx queue.\n\n"
866 "port config all (txfreet|txrst|rxfreet) (value)\n"
867 " Set free threshold for rx/tx, or set"
868 " tx rs bit threshold.\n\n"
869 "port config mtu X value\n"
870 " Set the MTU of port X to a given value\n\n"
872 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
873 " Start/stop a rx/tx queue of port X. Only take effect"
874 " when port X is started\n\n"
876 "port config (port_id|all) l2-tunnel E-tag ether-type"
878 " Set the value of E-tag ether-type.\n\n"
880 "port config (port_id|all) l2-tunnel E-tag"
881 " (enable|disable)\n"
882 " Enable/disable the E-tag support.\n\n"
884 "port config (port_id) pctype mapping reset\n"
885 " Reset flow type to pctype mapping on a port\n\n"
887 "port config (port_id) pctype mapping update"
888 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
889 " Update a flow type to pctype mapping item on a port\n\n"
891 "port config (port_id) pctype (pctype_id) hash_inset|"
892 "fdir_inset|fdir_flx_inset get|set|clear field\n"
894 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
896 "port config (port_id) pctype (pctype_id) hash_inset|"
897 "fdir_inset|fdir_flx_inset clear all"
898 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
902 if (show_all || !strcmp(res->section, "registers")) {
910 "read reg (port_id) (address)\n"
911 " Display value of a port register.\n\n"
913 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
914 " Display a port register bit field.\n\n"
916 "read regbit (port_id) (address) (bit_x)\n"
917 " Display a single port register bit.\n\n"
919 "write reg (port_id) (address) (value)\n"
920 " Set value of a port register.\n\n"
922 "write regfield (port_id) (address) (bit_x) (bit_y)"
924 " Set bit field of a port register.\n\n"
926 "write regbit (port_id) (address) (bit_x) (value)\n"
927 " Set single bit value of a port register.\n\n"
930 if (show_all || !strcmp(res->section, "filters")) {
938 "ethertype_filter (port_id) (add|del)"
939 " (mac_addr|mac_ignr) (mac_address) ethertype"
940 " (ether_type) (drop|fwd) queue (queue_id)\n"
941 " Add/Del an ethertype filter.\n\n"
943 "2tuple_filter (port_id) (add|del)"
944 " dst_port (dst_port_value) protocol (protocol_value)"
945 " mask (mask_value) tcp_flags (tcp_flags_value)"
946 " priority (prio_value) queue (queue_id)\n"
947 " Add/Del a 2tuple filter.\n\n"
949 "5tuple_filter (port_id) (add|del)"
950 " dst_ip (dst_address) src_ip (src_address)"
951 " dst_port (dst_port_value) src_port (src_port_value)"
952 " protocol (protocol_value)"
953 " mask (mask_value) tcp_flags (tcp_flags_value)"
954 " priority (prio_value) queue (queue_id)\n"
955 " Add/Del a 5tuple filter.\n\n"
957 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
958 " Add/Del syn filter.\n\n"
960 "flex_filter (port_id) (add|del) len (len_value)"
961 " bytes (bytes_value) mask (mask_value)"
962 " priority (prio_value) queue (queue_id)\n"
963 " Add/Del a flex filter.\n\n"
965 "flow_director_filter (port_id) mode IP (add|del|update)"
966 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
967 " src (src_ip_address) dst (dst_ip_address)"
968 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
969 " vlan (vlan_value) flexbytes (flexbytes_value)"
970 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
971 " fd_id (fd_id_value)\n"
972 " Add/Del an IP type flow director filter.\n\n"
974 "flow_director_filter (port_id) mode IP (add|del|update)"
975 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
976 " src (src_ip_address) (src_port)"
977 " dst (dst_ip_address) (dst_port)"
978 " tos (tos_value) ttl (ttl_value)"
979 " vlan (vlan_value) flexbytes (flexbytes_value)"
980 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
981 " fd_id (fd_id_value)\n"
982 " Add/Del an UDP/TCP type flow director filter.\n\n"
984 "flow_director_filter (port_id) mode IP (add|del|update)"
985 " flow (ipv4-sctp|ipv6-sctp)"
986 " src (src_ip_address) (src_port)"
987 " dst (dst_ip_address) (dst_port)"
988 " tag (verification_tag) "
989 " tos (tos_value) ttl (ttl_value)"
991 " flexbytes (flexbytes_value) (drop|fwd)"
992 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
993 " Add/Del a SCTP type flow director filter.\n\n"
995 "flow_director_filter (port_id) mode IP (add|del|update)"
996 " flow l2_payload ether (ethertype)"
997 " flexbytes (flexbytes_value) (drop|fwd)"
998 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
999 " Add/Del a l2 payload type flow director filter.\n\n"
1001 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1002 " mac (mac_address) vlan (vlan_value)"
1003 " flexbytes (flexbytes_value) (drop|fwd)"
1004 " queue (queue_id) fd_id (fd_id_value)\n"
1005 " Add/Del a MAC-VLAN flow director filter.\n\n"
1007 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1008 " mac (mac_address) vlan (vlan_value)"
1009 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1010 " flexbytes (flexbytes_value) (drop|fwd)"
1011 " queue (queue_id) fd_id (fd_id_value)\n"
1012 " Add/Del a Tunnel flow director filter.\n\n"
1014 "flow_director_filter (port_id) mode raw (add|del|update)"
1015 " flow (flow_id) (drop|fwd) queue (queue_id)"
1016 " fd_id (fd_id_value) packet (packet file name)\n"
1017 " Add/Del a raw type flow director filter.\n\n"
1019 "flush_flow_director (port_id)\n"
1020 " Flush all flow director entries of a device.\n\n"
1022 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1023 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1024 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1025 " Set flow director IP mask.\n\n"
1027 "flow_director_mask (port_id) mode MAC-VLAN"
1028 " vlan (vlan_value)\n"
1029 " Set flow director MAC-VLAN mask.\n\n"
1031 "flow_director_mask (port_id) mode Tunnel"
1032 " vlan (vlan_value) mac (mac_value)"
1033 " tunnel-type (tunnel_type_value)"
1034 " tunnel-id (tunnel_id_value)\n"
1035 " Set flow director Tunnel mask.\n\n"
1037 "flow_director_flex_mask (port_id)"
1038 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1039 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1041 " Configure mask of flex payload.\n\n"
1043 "flow_director_flex_payload (port_id)"
1044 " (raw|l2|l3|l4) (config)\n"
1045 " Configure flex payload selection.\n\n"
1047 "get_sym_hash_ena_per_port (port_id)\n"
1048 " get symmetric hash enable configuration per port.\n\n"
1050 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1051 " set symmetric hash enable configuration per port"
1052 " to enable or disable.\n\n"
1054 "get_hash_global_config (port_id)\n"
1055 " Get the global configurations of hash filters.\n\n"
1057 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1058 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1059 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1060 " (enable|disable)\n"
1061 " Set the global configurations of hash filters.\n\n"
1063 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1064 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1065 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1066 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1067 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1068 "ipv6-next-header|udp-src-port|udp-dst-port|"
1069 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1070 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1071 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1072 "fld-8th|none) (select|add)\n"
1073 " Set the input set for hash.\n\n"
1075 "set_fdir_input_set (port_id) "
1076 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1077 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1078 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1079 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1080 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1081 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1082 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1084 " Set the input set for FDir.\n\n"
1086 "flow validate {port_id}"
1087 " [group {group_id}] [priority {level}]"
1088 " [ingress] [egress]"
1089 " pattern {item} [/ {item} [...]] / end"
1090 " actions {action} [/ {action} [...]] / end\n"
1091 " Check whether a flow rule can be created.\n\n"
1093 "flow create {port_id}"
1094 " [group {group_id}] [priority {level}]"
1095 " [ingress] [egress]"
1096 " pattern {item} [/ {item} [...]] / end"
1097 " actions {action} [/ {action} [...]] / end\n"
1098 " Create a flow rule.\n\n"
1100 "flow destroy {port_id} rule {rule_id} [...]\n"
1101 " Destroy specific flow rules.\n\n"
1103 "flow flush {port_id}\n"
1104 " Destroy all flow rules.\n\n"
1106 "flow query {port_id} {rule_id} {action}\n"
1107 " Query an existing flow rule.\n\n"
1109 "flow list {port_id} [group {group_id}] [...]\n"
1110 " List existing flow rules sorted by priority,"
1111 " filtered by group identifiers.\n\n"
1113 "flow isolate {port_id} {boolean}\n"
1114 " Restrict ingress traffic to the defined"
1120 cmdline_parse_token_string_t cmd_help_long_help =
1121 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1123 cmdline_parse_token_string_t cmd_help_long_section =
1124 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1125 "all#control#display#config#"
1126 "ports#registers#filters");
1128 cmdline_parse_inst_t cmd_help_long = {
1129 .f = cmd_help_long_parsed,
1131 .help_str = "help all|control|display|config|ports|register|filters: "
1134 (void *)&cmd_help_long_help,
1135 (void *)&cmd_help_long_section,
1141 /* *** start/stop/close all ports *** */
1142 struct cmd_operate_port_result {
1143 cmdline_fixed_string_t keyword;
1144 cmdline_fixed_string_t name;
1145 cmdline_fixed_string_t value;
1148 static void cmd_operate_port_parsed(void *parsed_result,
1149 __attribute__((unused)) struct cmdline *cl,
1150 __attribute__((unused)) void *data)
1152 struct cmd_operate_port_result *res = parsed_result;
1154 if (!strcmp(res->name, "start"))
1155 start_port(RTE_PORT_ALL);
1156 else if (!strcmp(res->name, "stop"))
1157 stop_port(RTE_PORT_ALL);
1158 else if (!strcmp(res->name, "close"))
1159 close_port(RTE_PORT_ALL);
1160 else if (!strcmp(res->name, "reset"))
1161 reset_port(RTE_PORT_ALL);
1163 printf("Unknown parameter\n");
1166 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1167 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1169 cmdline_parse_token_string_t cmd_operate_port_all_port =
1170 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1171 "start#stop#close#reset");
1172 cmdline_parse_token_string_t cmd_operate_port_all_all =
1173 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1175 cmdline_parse_inst_t cmd_operate_port = {
1176 .f = cmd_operate_port_parsed,
1178 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1180 (void *)&cmd_operate_port_all_cmd,
1181 (void *)&cmd_operate_port_all_port,
1182 (void *)&cmd_operate_port_all_all,
1187 /* *** start/stop/close specific port *** */
1188 struct cmd_operate_specific_port_result {
1189 cmdline_fixed_string_t keyword;
1190 cmdline_fixed_string_t name;
1194 static void cmd_operate_specific_port_parsed(void *parsed_result,
1195 __attribute__((unused)) struct cmdline *cl,
1196 __attribute__((unused)) void *data)
1198 struct cmd_operate_specific_port_result *res = parsed_result;
1200 if (!strcmp(res->name, "start"))
1201 start_port(res->value);
1202 else if (!strcmp(res->name, "stop"))
1203 stop_port(res->value);
1204 else if (!strcmp(res->name, "close"))
1205 close_port(res->value);
1206 else if (!strcmp(res->name, "reset"))
1207 reset_port(res->value);
1209 printf("Unknown parameter\n");
1212 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1213 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1215 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1216 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1217 name, "start#stop#close#reset");
1218 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1219 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1222 cmdline_parse_inst_t cmd_operate_specific_port = {
1223 .f = cmd_operate_specific_port_parsed,
1225 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1227 (void *)&cmd_operate_specific_port_cmd,
1228 (void *)&cmd_operate_specific_port_port,
1229 (void *)&cmd_operate_specific_port_id,
1234 /* *** attach a specified port *** */
1235 struct cmd_operate_attach_port_result {
1236 cmdline_fixed_string_t port;
1237 cmdline_fixed_string_t keyword;
1238 cmdline_fixed_string_t identifier;
1241 static void cmd_operate_attach_port_parsed(void *parsed_result,
1242 __attribute__((unused)) struct cmdline *cl,
1243 __attribute__((unused)) void *data)
1245 struct cmd_operate_attach_port_result *res = parsed_result;
1247 if (!strcmp(res->keyword, "attach"))
1248 attach_port(res->identifier);
1250 printf("Unknown parameter\n");
1253 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1254 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1256 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1257 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1259 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1260 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1263 cmdline_parse_inst_t cmd_operate_attach_port = {
1264 .f = cmd_operate_attach_port_parsed,
1266 .help_str = "port attach <identifier>: "
1267 "(identifier: pci address or virtual dev name)",
1269 (void *)&cmd_operate_attach_port_port,
1270 (void *)&cmd_operate_attach_port_keyword,
1271 (void *)&cmd_operate_attach_port_identifier,
1276 /* *** detach a specified port *** */
1277 struct cmd_operate_detach_port_result {
1278 cmdline_fixed_string_t port;
1279 cmdline_fixed_string_t keyword;
1283 static void cmd_operate_detach_port_parsed(void *parsed_result,
1284 __attribute__((unused)) struct cmdline *cl,
1285 __attribute__((unused)) void *data)
1287 struct cmd_operate_detach_port_result *res = parsed_result;
1289 if (!strcmp(res->keyword, "detach"))
1290 detach_port(res->port_id);
1292 printf("Unknown parameter\n");
1295 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1296 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1298 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1299 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1301 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1302 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1305 cmdline_parse_inst_t cmd_operate_detach_port = {
1306 .f = cmd_operate_detach_port_parsed,
1308 .help_str = "port detach <port_id>",
1310 (void *)&cmd_operate_detach_port_port,
1311 (void *)&cmd_operate_detach_port_keyword,
1312 (void *)&cmd_operate_detach_port_port_id,
1317 /* *** configure speed for all ports *** */
1318 struct cmd_config_speed_all {
1319 cmdline_fixed_string_t port;
1320 cmdline_fixed_string_t keyword;
1321 cmdline_fixed_string_t all;
1322 cmdline_fixed_string_t item1;
1323 cmdline_fixed_string_t item2;
1324 cmdline_fixed_string_t value1;
1325 cmdline_fixed_string_t value2;
1329 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1334 if (!strcmp(duplexstr, "half")) {
1335 duplex = ETH_LINK_HALF_DUPLEX;
1336 } else if (!strcmp(duplexstr, "full")) {
1337 duplex = ETH_LINK_FULL_DUPLEX;
1338 } else if (!strcmp(duplexstr, "auto")) {
1339 duplex = ETH_LINK_FULL_DUPLEX;
1341 printf("Unknown duplex parameter\n");
1345 if (!strcmp(speedstr, "10")) {
1346 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1347 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1348 } else if (!strcmp(speedstr, "100")) {
1349 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1350 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1352 if (duplex != ETH_LINK_FULL_DUPLEX) {
1353 printf("Invalid speed/duplex parameters\n");
1356 if (!strcmp(speedstr, "1000")) {
1357 *speed = ETH_LINK_SPEED_1G;
1358 } else if (!strcmp(speedstr, "10000")) {
1359 *speed = ETH_LINK_SPEED_10G;
1360 } else if (!strcmp(speedstr, "25000")) {
1361 *speed = ETH_LINK_SPEED_25G;
1362 } else if (!strcmp(speedstr, "40000")) {
1363 *speed = ETH_LINK_SPEED_40G;
1364 } else if (!strcmp(speedstr, "50000")) {
1365 *speed = ETH_LINK_SPEED_50G;
1366 } else if (!strcmp(speedstr, "100000")) {
1367 *speed = ETH_LINK_SPEED_100G;
1368 } else if (!strcmp(speedstr, "auto")) {
1369 *speed = ETH_LINK_SPEED_AUTONEG;
1371 printf("Unknown speed parameter\n");
1380 cmd_config_speed_all_parsed(void *parsed_result,
1381 __attribute__((unused)) struct cmdline *cl,
1382 __attribute__((unused)) void *data)
1384 struct cmd_config_speed_all *res = parsed_result;
1385 uint32_t link_speed;
1388 if (!all_ports_stopped()) {
1389 printf("Please stop all ports first\n");
1393 if (parse_and_check_speed_duplex(res->value1, res->value2,
1397 RTE_ETH_FOREACH_DEV(pid) {
1398 ports[pid].dev_conf.link_speeds = link_speed;
1401 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1404 cmdline_parse_token_string_t cmd_config_speed_all_port =
1405 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1406 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1407 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1409 cmdline_parse_token_string_t cmd_config_speed_all_all =
1410 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1411 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1412 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1413 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1414 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1415 "10#100#1000#10000#25000#40000#50000#100000#auto");
1416 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1417 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1418 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1419 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1422 cmdline_parse_inst_t cmd_config_speed_all = {
1423 .f = cmd_config_speed_all_parsed,
1425 .help_str = "port config all speed "
1426 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1429 (void *)&cmd_config_speed_all_port,
1430 (void *)&cmd_config_speed_all_keyword,
1431 (void *)&cmd_config_speed_all_all,
1432 (void *)&cmd_config_speed_all_item1,
1433 (void *)&cmd_config_speed_all_value1,
1434 (void *)&cmd_config_speed_all_item2,
1435 (void *)&cmd_config_speed_all_value2,
1440 /* *** configure speed for specific port *** */
1441 struct cmd_config_speed_specific {
1442 cmdline_fixed_string_t port;
1443 cmdline_fixed_string_t keyword;
1445 cmdline_fixed_string_t item1;
1446 cmdline_fixed_string_t item2;
1447 cmdline_fixed_string_t value1;
1448 cmdline_fixed_string_t value2;
1452 cmd_config_speed_specific_parsed(void *parsed_result,
1453 __attribute__((unused)) struct cmdline *cl,
1454 __attribute__((unused)) void *data)
1456 struct cmd_config_speed_specific *res = parsed_result;
1457 uint32_t link_speed;
1459 if (!all_ports_stopped()) {
1460 printf("Please stop all ports first\n");
1464 if (port_id_is_invalid(res->id, ENABLED_WARN))
1467 if (parse_and_check_speed_duplex(res->value1, res->value2,
1471 ports[res->id].dev_conf.link_speeds = link_speed;
1473 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1477 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1478 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1480 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1481 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1483 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1484 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1485 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1486 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1488 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1489 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1490 "10#100#1000#10000#25000#40000#50000#100000#auto");
1491 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1492 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1494 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1495 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1498 cmdline_parse_inst_t cmd_config_speed_specific = {
1499 .f = cmd_config_speed_specific_parsed,
1501 .help_str = "port config <port_id> speed "
1502 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1505 (void *)&cmd_config_speed_specific_port,
1506 (void *)&cmd_config_speed_specific_keyword,
1507 (void *)&cmd_config_speed_specific_id,
1508 (void *)&cmd_config_speed_specific_item1,
1509 (void *)&cmd_config_speed_specific_value1,
1510 (void *)&cmd_config_speed_specific_item2,
1511 (void *)&cmd_config_speed_specific_value2,
1516 /* *** configure txq/rxq, txd/rxd *** */
1517 struct cmd_config_rx_tx {
1518 cmdline_fixed_string_t port;
1519 cmdline_fixed_string_t keyword;
1520 cmdline_fixed_string_t all;
1521 cmdline_fixed_string_t name;
1526 cmd_config_rx_tx_parsed(void *parsed_result,
1527 __attribute__((unused)) struct cmdline *cl,
1528 __attribute__((unused)) void *data)
1530 struct cmd_config_rx_tx *res = parsed_result;
1532 if (!all_ports_stopped()) {
1533 printf("Please stop all ports first\n");
1536 if (!strcmp(res->name, "rxq")) {
1537 if (!res->value && !nb_txq) {
1538 printf("Warning: Either rx or tx queues should be non zero\n");
1541 nb_rxq = res->value;
1543 else if (!strcmp(res->name, "txq")) {
1544 if (!res->value && !nb_rxq) {
1545 printf("Warning: Either rx or tx queues should be non zero\n");
1548 nb_txq = res->value;
1550 else if (!strcmp(res->name, "rxd")) {
1551 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1552 printf("rxd %d invalid - must be > 0 && <= %d\n",
1553 res->value, RTE_TEST_RX_DESC_MAX);
1556 nb_rxd = res->value;
1557 } else if (!strcmp(res->name, "txd")) {
1558 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1559 printf("txd %d invalid - must be > 0 && <= %d\n",
1560 res->value, RTE_TEST_TX_DESC_MAX);
1563 nb_txd = res->value;
1565 printf("Unknown parameter\n");
1573 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1576 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1577 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1578 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1579 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1580 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1581 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1582 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1583 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1585 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1586 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1588 cmdline_parse_inst_t cmd_config_rx_tx = {
1589 .f = cmd_config_rx_tx_parsed,
1591 .help_str = "port config all rxq|txq|rxd|txd <value>",
1593 (void *)&cmd_config_rx_tx_port,
1594 (void *)&cmd_config_rx_tx_keyword,
1595 (void *)&cmd_config_rx_tx_all,
1596 (void *)&cmd_config_rx_tx_name,
1597 (void *)&cmd_config_rx_tx_value,
1602 /* *** config max packet length *** */
1603 struct cmd_config_max_pkt_len_result {
1604 cmdline_fixed_string_t port;
1605 cmdline_fixed_string_t keyword;
1606 cmdline_fixed_string_t all;
1607 cmdline_fixed_string_t name;
1612 cmd_config_max_pkt_len_parsed(void *parsed_result,
1613 __attribute__((unused)) struct cmdline *cl,
1614 __attribute__((unused)) void *data)
1616 struct cmd_config_max_pkt_len_result *res = parsed_result;
1619 if (!all_ports_stopped()) {
1620 printf("Please stop all ports first\n");
1624 RTE_ETH_FOREACH_DEV(pid) {
1625 struct rte_port *port = &ports[pid];
1626 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1628 if (!strcmp(res->name, "max-pkt-len")) {
1629 if (res->value < ETHER_MIN_LEN) {
1630 printf("max-pkt-len can not be less than %d\n",
1634 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1637 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1638 if (res->value > ETHER_MAX_LEN)
1639 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1641 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1642 port->dev_conf.rxmode.offloads = rx_offloads;
1644 printf("Unknown parameter\n");
1651 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1654 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1655 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1657 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1660 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1661 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1663 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1666 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1667 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1670 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1671 .f = cmd_config_max_pkt_len_parsed,
1673 .help_str = "port config all max-pkt-len <value>",
1675 (void *)&cmd_config_max_pkt_len_port,
1676 (void *)&cmd_config_max_pkt_len_keyword,
1677 (void *)&cmd_config_max_pkt_len_all,
1678 (void *)&cmd_config_max_pkt_len_name,
1679 (void *)&cmd_config_max_pkt_len_value,
1684 /* *** configure port MTU *** */
1685 struct cmd_config_mtu_result {
1686 cmdline_fixed_string_t port;
1687 cmdline_fixed_string_t keyword;
1688 cmdline_fixed_string_t mtu;
1694 cmd_config_mtu_parsed(void *parsed_result,
1695 __attribute__((unused)) struct cmdline *cl,
1696 __attribute__((unused)) void *data)
1698 struct cmd_config_mtu_result *res = parsed_result;
1700 if (res->value < ETHER_MIN_LEN) {
1701 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1704 port_mtu_set(res->port_id, res->value);
1707 cmdline_parse_token_string_t cmd_config_mtu_port =
1708 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1710 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1711 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1713 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1716 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1717 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1718 cmdline_parse_token_num_t cmd_config_mtu_value =
1719 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1721 cmdline_parse_inst_t cmd_config_mtu = {
1722 .f = cmd_config_mtu_parsed,
1724 .help_str = "port config mtu <port_id> <value>",
1726 (void *)&cmd_config_mtu_port,
1727 (void *)&cmd_config_mtu_keyword,
1728 (void *)&cmd_config_mtu_mtu,
1729 (void *)&cmd_config_mtu_port_id,
1730 (void *)&cmd_config_mtu_value,
1735 /* *** configure rx mode *** */
1736 struct cmd_config_rx_mode_flag {
1737 cmdline_fixed_string_t port;
1738 cmdline_fixed_string_t keyword;
1739 cmdline_fixed_string_t all;
1740 cmdline_fixed_string_t name;
1741 cmdline_fixed_string_t value;
1745 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1746 __attribute__((unused)) struct cmdline *cl,
1747 __attribute__((unused)) void *data)
1749 struct cmd_config_rx_mode_flag *res = parsed_result;
1752 if (!all_ports_stopped()) {
1753 printf("Please stop all ports first\n");
1757 RTE_ETH_FOREACH_DEV(pid) {
1758 struct rte_port *port;
1759 uint64_t rx_offloads;
1762 rx_offloads = port->dev_conf.rxmode.offloads;
1763 if (!strcmp(res->name, "crc-strip")) {
1764 if (!strcmp(res->value, "on"))
1765 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1766 else if (!strcmp(res->value, "off"))
1767 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1769 printf("Unknown parameter\n");
1772 } else if (!strcmp(res->name, "scatter")) {
1773 if (!strcmp(res->value, "on")) {
1774 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1775 } else if (!strcmp(res->value, "off")) {
1776 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1778 printf("Unknown parameter\n");
1781 } else if (!strcmp(res->name, "rx-cksum")) {
1782 if (!strcmp(res->value, "on"))
1783 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1784 else if (!strcmp(res->value, "off"))
1785 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1787 printf("Unknown parameter\n");
1790 } else if (!strcmp(res->name, "rx-timestamp")) {
1791 if (!strcmp(res->value, "on"))
1792 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1793 else if (!strcmp(res->value, "off"))
1794 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1796 printf("Unknown parameter\n");
1799 } else if (!strcmp(res->name, "hw-vlan")) {
1800 if (!strcmp(res->value, "on")) {
1801 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1802 DEV_RX_OFFLOAD_VLAN_STRIP);
1803 } else if (!strcmp(res->value, "off")) {
1804 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1805 DEV_RX_OFFLOAD_VLAN_STRIP);
1807 printf("Unknown parameter\n");
1810 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1811 if (!strcmp(res->value, "on"))
1812 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1813 else if (!strcmp(res->value, "off"))
1814 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1816 printf("Unknown parameter\n");
1819 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1820 if (!strcmp(res->value, "on"))
1821 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1822 else if (!strcmp(res->value, "off"))
1823 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1825 printf("Unknown parameter\n");
1828 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1829 if (!strcmp(res->value, "on"))
1830 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1831 else if (!strcmp(res->value, "off"))
1832 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1834 printf("Unknown parameter\n");
1837 } else if (!strcmp(res->name, "drop-en")) {
1838 if (!strcmp(res->value, "on"))
1840 else if (!strcmp(res->value, "off"))
1843 printf("Unknown parameter\n");
1847 printf("Unknown parameter\n");
1850 port->dev_conf.rxmode.offloads = rx_offloads;
1855 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1858 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1859 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1860 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1861 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1863 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1864 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1865 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1866 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1867 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1868 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1869 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1870 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1873 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1874 .f = cmd_config_rx_mode_flag_parsed,
1876 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1877 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1879 (void *)&cmd_config_rx_mode_flag_port,
1880 (void *)&cmd_config_rx_mode_flag_keyword,
1881 (void *)&cmd_config_rx_mode_flag_all,
1882 (void *)&cmd_config_rx_mode_flag_name,
1883 (void *)&cmd_config_rx_mode_flag_value,
1888 /* *** configure rss *** */
1889 struct cmd_config_rss {
1890 cmdline_fixed_string_t port;
1891 cmdline_fixed_string_t keyword;
1892 cmdline_fixed_string_t all;
1893 cmdline_fixed_string_t name;
1894 cmdline_fixed_string_t value;
1898 cmd_config_rss_parsed(void *parsed_result,
1899 __attribute__((unused)) struct cmdline *cl,
1900 __attribute__((unused)) void *data)
1902 struct cmd_config_rss *res = parsed_result;
1903 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1907 if (!strcmp(res->value, "all"))
1908 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1909 ETH_RSS_UDP | ETH_RSS_SCTP |
1911 else if (!strcmp(res->value, "ip"))
1912 rss_conf.rss_hf = ETH_RSS_IP;
1913 else if (!strcmp(res->value, "udp"))
1914 rss_conf.rss_hf = ETH_RSS_UDP;
1915 else if (!strcmp(res->value, "tcp"))
1916 rss_conf.rss_hf = ETH_RSS_TCP;
1917 else if (!strcmp(res->value, "sctp"))
1918 rss_conf.rss_hf = ETH_RSS_SCTP;
1919 else if (!strcmp(res->value, "ether"))
1920 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1921 else if (!strcmp(res->value, "port"))
1922 rss_conf.rss_hf = ETH_RSS_PORT;
1923 else if (!strcmp(res->value, "vxlan"))
1924 rss_conf.rss_hf = ETH_RSS_VXLAN;
1925 else if (!strcmp(res->value, "geneve"))
1926 rss_conf.rss_hf = ETH_RSS_GENEVE;
1927 else if (!strcmp(res->value, "nvgre"))
1928 rss_conf.rss_hf = ETH_RSS_NVGRE;
1929 else if (!strcmp(res->value, "none"))
1930 rss_conf.rss_hf = 0;
1931 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1932 atoi(res->value) < 64)
1933 rss_conf.rss_hf = 1ULL << atoi(res->value);
1935 printf("Unknown parameter\n");
1938 rss_conf.rss_key = NULL;
1939 for (i = 0; i < rte_eth_dev_count(); i++) {
1940 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1942 printf("Configuration of RSS hash at ethernet port %d "
1943 "failed with error (%d): %s.\n",
1944 i, -diag, strerror(-diag));
1948 cmdline_parse_token_string_t cmd_config_rss_port =
1949 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1950 cmdline_parse_token_string_t cmd_config_rss_keyword =
1951 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1952 cmdline_parse_token_string_t cmd_config_rss_all =
1953 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1954 cmdline_parse_token_string_t cmd_config_rss_name =
1955 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1956 cmdline_parse_token_string_t cmd_config_rss_value =
1957 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1959 cmdline_parse_inst_t cmd_config_rss = {
1960 .f = cmd_config_rss_parsed,
1962 .help_str = "port config all rss "
1963 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1965 (void *)&cmd_config_rss_port,
1966 (void *)&cmd_config_rss_keyword,
1967 (void *)&cmd_config_rss_all,
1968 (void *)&cmd_config_rss_name,
1969 (void *)&cmd_config_rss_value,
1974 /* *** configure rss hash key *** */
1975 struct cmd_config_rss_hash_key {
1976 cmdline_fixed_string_t port;
1977 cmdline_fixed_string_t config;
1979 cmdline_fixed_string_t rss_hash_key;
1980 cmdline_fixed_string_t rss_type;
1981 cmdline_fixed_string_t key;
1985 hexa_digit_to_value(char hexa_digit)
1987 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1988 return (uint8_t) (hexa_digit - '0');
1989 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1990 return (uint8_t) ((hexa_digit - 'a') + 10);
1991 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1992 return (uint8_t) ((hexa_digit - 'A') + 10);
1993 /* Invalid hexa digit */
1998 parse_and_check_key_hexa_digit(char *key, int idx)
2002 hexa_v = hexa_digit_to_value(key[idx]);
2004 printf("invalid key: character %c at position %d is not a "
2005 "valid hexa digit\n", key[idx], idx);
2010 cmd_config_rss_hash_key_parsed(void *parsed_result,
2011 __attribute__((unused)) struct cmdline *cl,
2012 __attribute__((unused)) void *data)
2014 struct cmd_config_rss_hash_key *res = parsed_result;
2015 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2019 struct rte_eth_dev_info dev_info;
2020 uint8_t hash_key_size;
2023 memset(&dev_info, 0, sizeof(dev_info));
2024 rte_eth_dev_info_get(res->port_id, &dev_info);
2025 if (dev_info.hash_key_size > 0 &&
2026 dev_info.hash_key_size <= sizeof(hash_key))
2027 hash_key_size = dev_info.hash_key_size;
2029 printf("dev_info did not provide a valid hash key size\n");
2032 /* Check the length of the RSS hash key */
2033 key_len = strlen(res->key);
2034 if (key_len != (hash_key_size * 2)) {
2035 printf("key length: %d invalid - key must be a string of %d"
2036 " hexa-decimal numbers\n",
2037 (int) key_len, hash_key_size * 2);
2040 /* Translate RSS hash key into binary representation */
2041 for (i = 0; i < hash_key_size; i++) {
2042 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2045 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2048 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2050 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2054 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2055 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2056 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2059 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2060 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2061 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2062 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2063 rss_hash_key, "rss-hash-key");
2064 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2065 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2066 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2067 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2068 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2069 "ipv6-tcp-ex#ipv6-udp-ex");
2070 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2071 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2073 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2074 .f = cmd_config_rss_hash_key_parsed,
2076 .help_str = "port config <port_id> rss-hash-key "
2077 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2078 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2079 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2080 "<string of hex digits (variable length, NIC dependent)>",
2082 (void *)&cmd_config_rss_hash_key_port,
2083 (void *)&cmd_config_rss_hash_key_config,
2084 (void *)&cmd_config_rss_hash_key_port_id,
2085 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2086 (void *)&cmd_config_rss_hash_key_rss_type,
2087 (void *)&cmd_config_rss_hash_key_value,
2092 /* *** configure port rxq/txq start/stop *** */
2093 struct cmd_config_rxtx_queue {
2094 cmdline_fixed_string_t port;
2096 cmdline_fixed_string_t rxtxq;
2098 cmdline_fixed_string_t opname;
2102 cmd_config_rxtx_queue_parsed(void *parsed_result,
2103 __attribute__((unused)) struct cmdline *cl,
2104 __attribute__((unused)) void *data)
2106 struct cmd_config_rxtx_queue *res = parsed_result;
2111 if (test_done == 0) {
2112 printf("Please stop forwarding first\n");
2116 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2119 if (port_is_started(res->portid) != 1) {
2120 printf("Please start port %u first\n", res->portid);
2124 if (!strcmp(res->rxtxq, "rxq"))
2126 else if (!strcmp(res->rxtxq, "txq"))
2129 printf("Unknown parameter\n");
2133 if (isrx && rx_queue_id_is_invalid(res->qid))
2135 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2138 if (!strcmp(res->opname, "start"))
2140 else if (!strcmp(res->opname, "stop"))
2143 printf("Unknown parameter\n");
2147 if (isstart && isrx)
2148 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2149 else if (!isstart && isrx)
2150 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2151 else if (isstart && !isrx)
2152 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2154 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2156 if (ret == -ENOTSUP)
2157 printf("Function not supported in PMD driver\n");
2160 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2161 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2162 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2163 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2164 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2165 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2166 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2167 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2168 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2169 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2172 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2173 .f = cmd_config_rxtx_queue_parsed,
2175 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2177 (void *)&cmd_config_speed_all_port,
2178 (void *)&cmd_config_rxtx_queue_portid,
2179 (void *)&cmd_config_rxtx_queue_rxtxq,
2180 (void *)&cmd_config_rxtx_queue_qid,
2181 (void *)&cmd_config_rxtx_queue_opname,
2186 /* *** Configure RSS RETA *** */
2187 struct cmd_config_rss_reta {
2188 cmdline_fixed_string_t port;
2189 cmdline_fixed_string_t keyword;
2191 cmdline_fixed_string_t name;
2192 cmdline_fixed_string_t list_name;
2193 cmdline_fixed_string_t list_of_items;
2197 parse_reta_config(const char *str,
2198 struct rte_eth_rss_reta_entry64 *reta_conf,
2199 uint16_t nb_entries)
2203 uint16_t hash_index, idx, shift;
2206 const char *p, *p0 = str;
2213 unsigned long int_fld[_NUM_FLD];
2214 char *str_fld[_NUM_FLD];
2216 while ((p = strchr(p0,'(')) != NULL) {
2218 if((p0 = strchr(p,')')) == NULL)
2222 if(size >= sizeof(s))
2225 snprintf(s, sizeof(s), "%.*s", size, p);
2226 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2228 for (i = 0; i < _NUM_FLD; i++) {
2230 int_fld[i] = strtoul(str_fld[i], &end, 0);
2231 if (errno != 0 || end == str_fld[i] ||
2236 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2237 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2239 if (hash_index >= nb_entries) {
2240 printf("Invalid RETA hash index=%d\n", hash_index);
2244 idx = hash_index / RTE_RETA_GROUP_SIZE;
2245 shift = hash_index % RTE_RETA_GROUP_SIZE;
2246 reta_conf[idx].mask |= (1ULL << shift);
2247 reta_conf[idx].reta[shift] = nb_queue;
2254 cmd_set_rss_reta_parsed(void *parsed_result,
2255 __attribute__((unused)) struct cmdline *cl,
2256 __attribute__((unused)) void *data)
2259 struct rte_eth_dev_info dev_info;
2260 struct rte_eth_rss_reta_entry64 reta_conf[8];
2261 struct cmd_config_rss_reta *res = parsed_result;
2263 memset(&dev_info, 0, sizeof(dev_info));
2264 rte_eth_dev_info_get(res->port_id, &dev_info);
2265 if (dev_info.reta_size == 0) {
2266 printf("Redirection table size is 0 which is "
2267 "invalid for RSS\n");
2270 printf("The reta size of port %d is %u\n",
2271 res->port_id, dev_info.reta_size);
2272 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2273 printf("Currently do not support more than %u entries of "
2274 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2278 memset(reta_conf, 0, sizeof(reta_conf));
2279 if (!strcmp(res->list_name, "reta")) {
2280 if (parse_reta_config(res->list_of_items, reta_conf,
2281 dev_info.reta_size)) {
2282 printf("Invalid RSS Redirection Table "
2283 "config entered\n");
2286 ret = rte_eth_dev_rss_reta_update(res->port_id,
2287 reta_conf, dev_info.reta_size);
2289 printf("Bad redirection table parameter, "
2290 "return code = %d \n", ret);
2294 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2295 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2296 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2297 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2298 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2299 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2300 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2301 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2302 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2303 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2304 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2305 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2307 cmdline_parse_inst_t cmd_config_rss_reta = {
2308 .f = cmd_set_rss_reta_parsed,
2310 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2312 (void *)&cmd_config_rss_reta_port,
2313 (void *)&cmd_config_rss_reta_keyword,
2314 (void *)&cmd_config_rss_reta_port_id,
2315 (void *)&cmd_config_rss_reta_name,
2316 (void *)&cmd_config_rss_reta_list_name,
2317 (void *)&cmd_config_rss_reta_list_of_items,
2322 /* *** SHOW PORT RETA INFO *** */
2323 struct cmd_showport_reta {
2324 cmdline_fixed_string_t show;
2325 cmdline_fixed_string_t port;
2327 cmdline_fixed_string_t rss;
2328 cmdline_fixed_string_t reta;
2330 cmdline_fixed_string_t list_of_items;
2334 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2335 uint16_t nb_entries,
2339 const char *p, *p0 = str;
2344 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2345 RTE_RETA_GROUP_SIZE;
2348 p = strchr(p0, '(');
2352 p0 = strchr(p, ')');
2356 if (size >= sizeof(s)) {
2357 printf("The string size exceeds the internal buffer size\n");
2360 snprintf(s, sizeof(s), "%.*s", size, p);
2361 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2362 if (ret <= 0 || ret != num) {
2363 printf("The bits of masks do not match the number of "
2364 "reta entries: %u\n", num);
2367 for (i = 0; i < ret; i++)
2368 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2374 cmd_showport_reta_parsed(void *parsed_result,
2375 __attribute__((unused)) struct cmdline *cl,
2376 __attribute__((unused)) void *data)
2378 struct cmd_showport_reta *res = parsed_result;
2379 struct rte_eth_rss_reta_entry64 reta_conf[8];
2380 struct rte_eth_dev_info dev_info;
2381 uint16_t max_reta_size;
2383 memset(&dev_info, 0, sizeof(dev_info));
2384 rte_eth_dev_info_get(res->port_id, &dev_info);
2385 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2386 if (res->size == 0 || res->size > max_reta_size) {
2387 printf("Invalid redirection table size: %u (1-%u)\n",
2388 res->size, max_reta_size);
2392 memset(reta_conf, 0, sizeof(reta_conf));
2393 if (showport_parse_reta_config(reta_conf, res->size,
2394 res->list_of_items) < 0) {
2395 printf("Invalid string: %s for reta masks\n",
2396 res->list_of_items);
2399 port_rss_reta_info(res->port_id, reta_conf, res->size);
2402 cmdline_parse_token_string_t cmd_showport_reta_show =
2403 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2404 cmdline_parse_token_string_t cmd_showport_reta_port =
2405 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2406 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2407 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2408 cmdline_parse_token_string_t cmd_showport_reta_rss =
2409 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2410 cmdline_parse_token_string_t cmd_showport_reta_reta =
2411 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2412 cmdline_parse_token_num_t cmd_showport_reta_size =
2413 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2414 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2415 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2416 list_of_items, NULL);
2418 cmdline_parse_inst_t cmd_showport_reta = {
2419 .f = cmd_showport_reta_parsed,
2421 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2423 (void *)&cmd_showport_reta_show,
2424 (void *)&cmd_showport_reta_port,
2425 (void *)&cmd_showport_reta_port_id,
2426 (void *)&cmd_showport_reta_rss,
2427 (void *)&cmd_showport_reta_reta,
2428 (void *)&cmd_showport_reta_size,
2429 (void *)&cmd_showport_reta_list_of_items,
2434 /* *** Show RSS hash configuration *** */
2435 struct cmd_showport_rss_hash {
2436 cmdline_fixed_string_t show;
2437 cmdline_fixed_string_t port;
2439 cmdline_fixed_string_t rss_hash;
2440 cmdline_fixed_string_t rss_type;
2441 cmdline_fixed_string_t key; /* optional argument */
2444 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2445 __attribute__((unused)) struct cmdline *cl,
2448 struct cmd_showport_rss_hash *res = parsed_result;
2450 port_rss_hash_conf_show(res->port_id, res->rss_type,
2451 show_rss_key != NULL);
2454 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2455 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2456 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2457 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2458 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2459 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2460 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2461 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2463 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2464 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2465 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2466 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2467 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2468 "ipv6-tcp-ex#ipv6-udp-ex");
2469 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2470 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2472 cmdline_parse_inst_t cmd_showport_rss_hash = {
2473 .f = cmd_showport_rss_hash_parsed,
2475 .help_str = "show port <port_id> rss-hash "
2476 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2477 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2478 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2480 (void *)&cmd_showport_rss_hash_show,
2481 (void *)&cmd_showport_rss_hash_port,
2482 (void *)&cmd_showport_rss_hash_port_id,
2483 (void *)&cmd_showport_rss_hash_rss_hash,
2484 (void *)&cmd_showport_rss_hash_rss_hash_info,
2489 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2490 .f = cmd_showport_rss_hash_parsed,
2492 .help_str = "show port <port_id> rss-hash "
2493 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2494 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2495 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2497 (void *)&cmd_showport_rss_hash_show,
2498 (void *)&cmd_showport_rss_hash_port,
2499 (void *)&cmd_showport_rss_hash_port_id,
2500 (void *)&cmd_showport_rss_hash_rss_hash,
2501 (void *)&cmd_showport_rss_hash_rss_hash_info,
2502 (void *)&cmd_showport_rss_hash_rss_key,
2507 /* *** Configure DCB *** */
2508 struct cmd_config_dcb {
2509 cmdline_fixed_string_t port;
2510 cmdline_fixed_string_t config;
2512 cmdline_fixed_string_t dcb;
2513 cmdline_fixed_string_t vt;
2514 cmdline_fixed_string_t vt_en;
2516 cmdline_fixed_string_t pfc;
2517 cmdline_fixed_string_t pfc_en;
2521 cmd_config_dcb_parsed(void *parsed_result,
2522 __attribute__((unused)) struct cmdline *cl,
2523 __attribute__((unused)) void *data)
2525 struct cmd_config_dcb *res = parsed_result;
2526 portid_t port_id = res->port_id;
2527 struct rte_port *port;
2531 port = &ports[port_id];
2532 /** Check if the port is not started **/
2533 if (port->port_status != RTE_PORT_STOPPED) {
2534 printf("Please stop port %d first\n", port_id);
2538 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2539 printf("The invalid number of traffic class,"
2540 " only 4 or 8 allowed.\n");
2544 if (nb_fwd_lcores < res->num_tcs) {
2545 printf("nb_cores shouldn't be less than number of TCs.\n");
2548 if (!strncmp(res->pfc_en, "on", 2))
2553 /* DCB in VT mode */
2554 if (!strncmp(res->vt_en, "on", 2))
2555 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2556 (enum rte_eth_nb_tcs)res->num_tcs,
2559 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2560 (enum rte_eth_nb_tcs)res->num_tcs,
2565 printf("Cannot initialize network ports.\n");
2569 cmd_reconfig_device_queue(port_id, 1, 1);
2572 cmdline_parse_token_string_t cmd_config_dcb_port =
2573 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2574 cmdline_parse_token_string_t cmd_config_dcb_config =
2575 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2576 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2577 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2578 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2579 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2580 cmdline_parse_token_string_t cmd_config_dcb_vt =
2581 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2582 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2583 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2584 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2585 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2586 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2587 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2588 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2589 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2591 cmdline_parse_inst_t cmd_config_dcb = {
2592 .f = cmd_config_dcb_parsed,
2594 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2596 (void *)&cmd_config_dcb_port,
2597 (void *)&cmd_config_dcb_config,
2598 (void *)&cmd_config_dcb_port_id,
2599 (void *)&cmd_config_dcb_dcb,
2600 (void *)&cmd_config_dcb_vt,
2601 (void *)&cmd_config_dcb_vt_en,
2602 (void *)&cmd_config_dcb_num_tcs,
2603 (void *)&cmd_config_dcb_pfc,
2604 (void *)&cmd_config_dcb_pfc_en,
2609 /* *** configure number of packets per burst *** */
2610 struct cmd_config_burst {
2611 cmdline_fixed_string_t port;
2612 cmdline_fixed_string_t keyword;
2613 cmdline_fixed_string_t all;
2614 cmdline_fixed_string_t name;
2619 cmd_config_burst_parsed(void *parsed_result,
2620 __attribute__((unused)) struct cmdline *cl,
2621 __attribute__((unused)) void *data)
2623 struct cmd_config_burst *res = parsed_result;
2625 if (!all_ports_stopped()) {
2626 printf("Please stop all ports first\n");
2630 if (!strcmp(res->name, "burst")) {
2631 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2632 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2635 nb_pkt_per_burst = res->value;
2637 printf("Unknown parameter\n");
2643 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2646 cmdline_parse_token_string_t cmd_config_burst_port =
2647 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2648 cmdline_parse_token_string_t cmd_config_burst_keyword =
2649 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2650 cmdline_parse_token_string_t cmd_config_burst_all =
2651 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2652 cmdline_parse_token_string_t cmd_config_burst_name =
2653 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2654 cmdline_parse_token_num_t cmd_config_burst_value =
2655 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2657 cmdline_parse_inst_t cmd_config_burst = {
2658 .f = cmd_config_burst_parsed,
2660 .help_str = "port config all burst <value>",
2662 (void *)&cmd_config_burst_port,
2663 (void *)&cmd_config_burst_keyword,
2664 (void *)&cmd_config_burst_all,
2665 (void *)&cmd_config_burst_name,
2666 (void *)&cmd_config_burst_value,
2671 /* *** configure rx/tx queues *** */
2672 struct cmd_config_thresh {
2673 cmdline_fixed_string_t port;
2674 cmdline_fixed_string_t keyword;
2675 cmdline_fixed_string_t all;
2676 cmdline_fixed_string_t name;
2681 cmd_config_thresh_parsed(void *parsed_result,
2682 __attribute__((unused)) struct cmdline *cl,
2683 __attribute__((unused)) void *data)
2685 struct cmd_config_thresh *res = parsed_result;
2687 if (!all_ports_stopped()) {
2688 printf("Please stop all ports first\n");
2692 if (!strcmp(res->name, "txpt"))
2693 tx_pthresh = res->value;
2694 else if(!strcmp(res->name, "txht"))
2695 tx_hthresh = res->value;
2696 else if(!strcmp(res->name, "txwt"))
2697 tx_wthresh = res->value;
2698 else if(!strcmp(res->name, "rxpt"))
2699 rx_pthresh = res->value;
2700 else if(!strcmp(res->name, "rxht"))
2701 rx_hthresh = res->value;
2702 else if(!strcmp(res->name, "rxwt"))
2703 rx_wthresh = res->value;
2705 printf("Unknown parameter\n");
2711 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2714 cmdline_parse_token_string_t cmd_config_thresh_port =
2715 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2716 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2717 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2718 cmdline_parse_token_string_t cmd_config_thresh_all =
2719 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2720 cmdline_parse_token_string_t cmd_config_thresh_name =
2721 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2722 "txpt#txht#txwt#rxpt#rxht#rxwt");
2723 cmdline_parse_token_num_t cmd_config_thresh_value =
2724 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2726 cmdline_parse_inst_t cmd_config_thresh = {
2727 .f = cmd_config_thresh_parsed,
2729 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2731 (void *)&cmd_config_thresh_port,
2732 (void *)&cmd_config_thresh_keyword,
2733 (void *)&cmd_config_thresh_all,
2734 (void *)&cmd_config_thresh_name,
2735 (void *)&cmd_config_thresh_value,
2740 /* *** configure free/rs threshold *** */
2741 struct cmd_config_threshold {
2742 cmdline_fixed_string_t port;
2743 cmdline_fixed_string_t keyword;
2744 cmdline_fixed_string_t all;
2745 cmdline_fixed_string_t name;
2750 cmd_config_threshold_parsed(void *parsed_result,
2751 __attribute__((unused)) struct cmdline *cl,
2752 __attribute__((unused)) void *data)
2754 struct cmd_config_threshold *res = parsed_result;
2756 if (!all_ports_stopped()) {
2757 printf("Please stop all ports first\n");
2761 if (!strcmp(res->name, "txfreet"))
2762 tx_free_thresh = res->value;
2763 else if (!strcmp(res->name, "txrst"))
2764 tx_rs_thresh = res->value;
2765 else if (!strcmp(res->name, "rxfreet"))
2766 rx_free_thresh = res->value;
2768 printf("Unknown parameter\n");
2774 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2777 cmdline_parse_token_string_t cmd_config_threshold_port =
2778 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2779 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2780 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2782 cmdline_parse_token_string_t cmd_config_threshold_all =
2783 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2784 cmdline_parse_token_string_t cmd_config_threshold_name =
2785 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2786 "txfreet#txrst#rxfreet");
2787 cmdline_parse_token_num_t cmd_config_threshold_value =
2788 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2790 cmdline_parse_inst_t cmd_config_threshold = {
2791 .f = cmd_config_threshold_parsed,
2793 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2795 (void *)&cmd_config_threshold_port,
2796 (void *)&cmd_config_threshold_keyword,
2797 (void *)&cmd_config_threshold_all,
2798 (void *)&cmd_config_threshold_name,
2799 (void *)&cmd_config_threshold_value,
2805 struct cmd_stop_result {
2806 cmdline_fixed_string_t stop;
2809 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2810 __attribute__((unused)) struct cmdline *cl,
2811 __attribute__((unused)) void *data)
2813 stop_packet_forwarding();
2816 cmdline_parse_token_string_t cmd_stop_stop =
2817 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2819 cmdline_parse_inst_t cmd_stop = {
2820 .f = cmd_stop_parsed,
2822 .help_str = "stop: Stop packet forwarding",
2824 (void *)&cmd_stop_stop,
2829 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2832 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2833 unsigned int *parsed_items, int check_unique_values)
2835 unsigned int nb_item;
2843 * First parse all items in the list and store their value.
2848 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2850 if ((c >= '0') && (c <= '9')) {
2851 value = (unsigned int) (value * 10 + (c - '0'));
2856 printf("character %c is not a decimal digit\n", c);
2860 printf("No valid value before comma\n");
2863 if (nb_item < max_items) {
2864 parsed_items[nb_item] = value;
2870 if (nb_item >= max_items) {
2871 printf("Number of %s = %u > %u (maximum items)\n",
2872 item_name, nb_item + 1, max_items);
2875 parsed_items[nb_item++] = value;
2876 if (! check_unique_values)
2880 * Then, check that all values in the list are differents.
2881 * No optimization here...
2883 for (i = 0; i < nb_item; i++) {
2884 for (j = i + 1; j < nb_item; j++) {
2885 if (parsed_items[j] == parsed_items[i]) {
2886 printf("duplicated %s %u at index %u and %u\n",
2887 item_name, parsed_items[i], i, j);
2895 struct cmd_set_list_result {
2896 cmdline_fixed_string_t cmd_keyword;
2897 cmdline_fixed_string_t list_name;
2898 cmdline_fixed_string_t list_of_items;
2901 static void cmd_set_list_parsed(void *parsed_result,
2902 __attribute__((unused)) struct cmdline *cl,
2903 __attribute__((unused)) void *data)
2905 struct cmd_set_list_result *res;
2907 unsigned int lcorelist[RTE_MAX_LCORE];
2908 unsigned int portlist[RTE_MAX_ETHPORTS];
2910 unsigned int nb_item;
2912 if (test_done == 0) {
2913 printf("Please stop forwarding first\n");
2917 res = parsed_result;
2918 if (!strcmp(res->list_name, "corelist")) {
2919 nb_item = parse_item_list(res->list_of_items, "core",
2921 parsed_items.lcorelist, 1);
2923 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2928 if (!strcmp(res->list_name, "portlist")) {
2929 nb_item = parse_item_list(res->list_of_items, "port",
2931 parsed_items.portlist, 1);
2933 set_fwd_ports_list(parsed_items.portlist, nb_item);
2939 cmdline_parse_token_string_t cmd_set_list_keyword =
2940 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2942 cmdline_parse_token_string_t cmd_set_list_name =
2943 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2944 "corelist#portlist");
2945 cmdline_parse_token_string_t cmd_set_list_of_items =
2946 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2949 cmdline_parse_inst_t cmd_set_fwd_list = {
2950 .f = cmd_set_list_parsed,
2952 .help_str = "set corelist|portlist <list0[,list1]*>",
2954 (void *)&cmd_set_list_keyword,
2955 (void *)&cmd_set_list_name,
2956 (void *)&cmd_set_list_of_items,
2961 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2963 struct cmd_setmask_result {
2964 cmdline_fixed_string_t set;
2965 cmdline_fixed_string_t mask;
2969 static void cmd_set_mask_parsed(void *parsed_result,
2970 __attribute__((unused)) struct cmdline *cl,
2971 __attribute__((unused)) void *data)
2973 struct cmd_setmask_result *res = parsed_result;
2975 if (test_done == 0) {
2976 printf("Please stop forwarding first\n");
2979 if (!strcmp(res->mask, "coremask")) {
2980 set_fwd_lcores_mask(res->hexavalue);
2982 } else if (!strcmp(res->mask, "portmask")) {
2983 set_fwd_ports_mask(res->hexavalue);
2988 cmdline_parse_token_string_t cmd_setmask_set =
2989 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2990 cmdline_parse_token_string_t cmd_setmask_mask =
2991 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2992 "coremask#portmask");
2993 cmdline_parse_token_num_t cmd_setmask_value =
2994 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2996 cmdline_parse_inst_t cmd_set_fwd_mask = {
2997 .f = cmd_set_mask_parsed,
2999 .help_str = "set coremask|portmask <hexadecimal value>",
3001 (void *)&cmd_setmask_set,
3002 (void *)&cmd_setmask_mask,
3003 (void *)&cmd_setmask_value,
3009 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3011 struct cmd_set_result {
3012 cmdline_fixed_string_t set;
3013 cmdline_fixed_string_t what;
3017 static void cmd_set_parsed(void *parsed_result,
3018 __attribute__((unused)) struct cmdline *cl,
3019 __attribute__((unused)) void *data)
3021 struct cmd_set_result *res = parsed_result;
3022 if (!strcmp(res->what, "nbport")) {
3023 set_fwd_ports_number(res->value);
3025 } else if (!strcmp(res->what, "nbcore")) {
3026 set_fwd_lcores_number(res->value);
3028 } else if (!strcmp(res->what, "burst"))
3029 set_nb_pkt_per_burst(res->value);
3030 else if (!strcmp(res->what, "verbose"))
3031 set_verbose_level(res->value);
3034 cmdline_parse_token_string_t cmd_set_set =
3035 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3036 cmdline_parse_token_string_t cmd_set_what =
3037 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3038 "nbport#nbcore#burst#verbose");
3039 cmdline_parse_token_num_t cmd_set_value =
3040 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3042 cmdline_parse_inst_t cmd_set_numbers = {
3043 .f = cmd_set_parsed,
3045 .help_str = "set nbport|nbcore|burst|verbose <value>",
3047 (void *)&cmd_set_set,
3048 (void *)&cmd_set_what,
3049 (void *)&cmd_set_value,
3054 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3056 struct cmd_set_txpkts_result {
3057 cmdline_fixed_string_t cmd_keyword;
3058 cmdline_fixed_string_t txpkts;
3059 cmdline_fixed_string_t seg_lengths;
3063 cmd_set_txpkts_parsed(void *parsed_result,
3064 __attribute__((unused)) struct cmdline *cl,
3065 __attribute__((unused)) void *data)
3067 struct cmd_set_txpkts_result *res;
3068 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3069 unsigned int nb_segs;
3071 res = parsed_result;
3072 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3073 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3075 set_tx_pkt_segments(seg_lengths, nb_segs);
3078 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3079 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3080 cmd_keyword, "set");
3081 cmdline_parse_token_string_t cmd_set_txpkts_name =
3082 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3084 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3085 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3088 cmdline_parse_inst_t cmd_set_txpkts = {
3089 .f = cmd_set_txpkts_parsed,
3091 .help_str = "set txpkts <len0[,len1]*>",
3093 (void *)&cmd_set_txpkts_keyword,
3094 (void *)&cmd_set_txpkts_name,
3095 (void *)&cmd_set_txpkts_lengths,
3100 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3102 struct cmd_set_txsplit_result {
3103 cmdline_fixed_string_t cmd_keyword;
3104 cmdline_fixed_string_t txsplit;
3105 cmdline_fixed_string_t mode;
3109 cmd_set_txsplit_parsed(void *parsed_result,
3110 __attribute__((unused)) struct cmdline *cl,
3111 __attribute__((unused)) void *data)
3113 struct cmd_set_txsplit_result *res;
3115 res = parsed_result;
3116 set_tx_pkt_split(res->mode);
3119 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3120 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3121 cmd_keyword, "set");
3122 cmdline_parse_token_string_t cmd_set_txsplit_name =
3123 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3124 txsplit, "txsplit");
3125 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3126 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3129 cmdline_parse_inst_t cmd_set_txsplit = {
3130 .f = cmd_set_txsplit_parsed,
3132 .help_str = "set txsplit on|off|rand",
3134 (void *)&cmd_set_txsplit_keyword,
3135 (void *)&cmd_set_txsplit_name,
3136 (void *)&cmd_set_txsplit_mode,
3141 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3142 struct cmd_rx_vlan_filter_all_result {
3143 cmdline_fixed_string_t rx_vlan;
3144 cmdline_fixed_string_t what;
3145 cmdline_fixed_string_t all;
3150 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3151 __attribute__((unused)) struct cmdline *cl,
3152 __attribute__((unused)) void *data)
3154 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3156 if (!strcmp(res->what, "add"))
3157 rx_vlan_all_filter_set(res->port_id, 1);
3159 rx_vlan_all_filter_set(res->port_id, 0);
3162 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3163 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3164 rx_vlan, "rx_vlan");
3165 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3166 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3168 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3169 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3171 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3172 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3175 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3176 .f = cmd_rx_vlan_filter_all_parsed,
3178 .help_str = "rx_vlan add|rm all <port_id>: "
3179 "Add/Remove all identifiers to/from the set of VLAN "
3180 "identifiers filtered by a port",
3182 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3183 (void *)&cmd_rx_vlan_filter_all_what,
3184 (void *)&cmd_rx_vlan_filter_all_all,
3185 (void *)&cmd_rx_vlan_filter_all_portid,
3190 /* *** VLAN OFFLOAD SET ON A PORT *** */
3191 struct cmd_vlan_offload_result {
3192 cmdline_fixed_string_t vlan;
3193 cmdline_fixed_string_t set;
3194 cmdline_fixed_string_t vlan_type;
3195 cmdline_fixed_string_t what;
3196 cmdline_fixed_string_t on;
3197 cmdline_fixed_string_t port_id;
3201 cmd_vlan_offload_parsed(void *parsed_result,
3202 __attribute__((unused)) struct cmdline *cl,
3203 __attribute__((unused)) void *data)
3206 struct cmd_vlan_offload_result *res = parsed_result;
3209 portid_t port_id = 0;
3213 len = strnlen(str, STR_TOKEN_SIZE);
3215 /* Get port_id first */
3223 tmp = strtoul(str, NULL, 0);
3224 /* If port_id greater that what portid_t can represent, return */
3225 if(tmp >= RTE_MAX_ETHPORTS)
3227 port_id = (portid_t)tmp;
3229 if (!strcmp(res->on, "on"))
3234 if (!strcmp(res->what, "strip"))
3235 rx_vlan_strip_set(port_id, on);
3236 else if(!strcmp(res->what, "stripq")){
3237 uint16_t queue_id = 0;
3239 /* No queue_id, return */
3241 printf("must specify (port,queue_id)\n");
3244 tmp = strtoul(str + i + 1, NULL, 0);
3245 /* If queue_id greater that what 16-bits can represent, return */
3249 queue_id = (uint16_t)tmp;
3250 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3252 else if (!strcmp(res->what, "filter"))
3253 rx_vlan_filter_set(port_id, on);
3255 vlan_extend_set(port_id, on);
3260 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3261 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3263 cmdline_parse_token_string_t cmd_vlan_offload_set =
3264 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3266 cmdline_parse_token_string_t cmd_vlan_offload_what =
3267 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3268 what, "strip#filter#qinq#stripq");
3269 cmdline_parse_token_string_t cmd_vlan_offload_on =
3270 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3272 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3273 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3276 cmdline_parse_inst_t cmd_vlan_offload = {
3277 .f = cmd_vlan_offload_parsed,
3279 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3280 "<port_id[,queue_id]>: "
3281 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3283 (void *)&cmd_vlan_offload_vlan,
3284 (void *)&cmd_vlan_offload_set,
3285 (void *)&cmd_vlan_offload_what,
3286 (void *)&cmd_vlan_offload_on,
3287 (void *)&cmd_vlan_offload_portid,
3292 /* *** VLAN TPID SET ON A PORT *** */
3293 struct cmd_vlan_tpid_result {
3294 cmdline_fixed_string_t vlan;
3295 cmdline_fixed_string_t set;
3296 cmdline_fixed_string_t vlan_type;
3297 cmdline_fixed_string_t what;
3303 cmd_vlan_tpid_parsed(void *parsed_result,
3304 __attribute__((unused)) struct cmdline *cl,
3305 __attribute__((unused)) void *data)
3307 struct cmd_vlan_tpid_result *res = parsed_result;
3308 enum rte_vlan_type vlan_type;
3310 if (!strcmp(res->vlan_type, "inner"))
3311 vlan_type = ETH_VLAN_TYPE_INNER;
3312 else if (!strcmp(res->vlan_type, "outer"))
3313 vlan_type = ETH_VLAN_TYPE_OUTER;
3315 printf("Unknown vlan type\n");
3318 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3321 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3322 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3324 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3325 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3327 cmdline_parse_token_string_t cmd_vlan_type =
3328 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3329 vlan_type, "inner#outer");
3330 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3331 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3333 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3334 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3336 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3337 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3340 cmdline_parse_inst_t cmd_vlan_tpid = {
3341 .f = cmd_vlan_tpid_parsed,
3343 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3344 "Set the VLAN Ether type",
3346 (void *)&cmd_vlan_tpid_vlan,
3347 (void *)&cmd_vlan_tpid_set,
3348 (void *)&cmd_vlan_type,
3349 (void *)&cmd_vlan_tpid_what,
3350 (void *)&cmd_vlan_tpid_tpid,
3351 (void *)&cmd_vlan_tpid_portid,
3356 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3357 struct cmd_rx_vlan_filter_result {
3358 cmdline_fixed_string_t rx_vlan;
3359 cmdline_fixed_string_t what;
3365 cmd_rx_vlan_filter_parsed(void *parsed_result,
3366 __attribute__((unused)) struct cmdline *cl,
3367 __attribute__((unused)) void *data)
3369 struct cmd_rx_vlan_filter_result *res = parsed_result;
3371 if (!strcmp(res->what, "add"))
3372 rx_vft_set(res->port_id, res->vlan_id, 1);
3374 rx_vft_set(res->port_id, res->vlan_id, 0);
3377 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3378 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3379 rx_vlan, "rx_vlan");
3380 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3381 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3383 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3384 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3386 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3387 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3390 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3391 .f = cmd_rx_vlan_filter_parsed,
3393 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3394 "Add/Remove a VLAN identifier to/from the set of VLAN "
3395 "identifiers filtered by a port",
3397 (void *)&cmd_rx_vlan_filter_rx_vlan,
3398 (void *)&cmd_rx_vlan_filter_what,
3399 (void *)&cmd_rx_vlan_filter_vlanid,
3400 (void *)&cmd_rx_vlan_filter_portid,
3405 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3406 struct cmd_tx_vlan_set_result {
3407 cmdline_fixed_string_t tx_vlan;
3408 cmdline_fixed_string_t set;
3414 cmd_tx_vlan_set_parsed(void *parsed_result,
3415 __attribute__((unused)) struct cmdline *cl,
3416 __attribute__((unused)) void *data)
3418 struct cmd_tx_vlan_set_result *res = parsed_result;
3420 if (!port_is_stopped(res->port_id)) {
3421 printf("Please stop port %d first\n", res->port_id);
3425 tx_vlan_set(res->port_id, res->vlan_id);
3427 cmd_reconfig_device_queue(res->port_id, 1, 1);
3430 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3431 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3432 tx_vlan, "tx_vlan");
3433 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3434 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3436 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3437 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3439 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3440 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3443 cmdline_parse_inst_t cmd_tx_vlan_set = {
3444 .f = cmd_tx_vlan_set_parsed,
3446 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3447 "Enable hardware insertion of a single VLAN header "
3448 "with a given TAG Identifier in packets sent on a port",
3450 (void *)&cmd_tx_vlan_set_tx_vlan,
3451 (void *)&cmd_tx_vlan_set_set,
3452 (void *)&cmd_tx_vlan_set_portid,
3453 (void *)&cmd_tx_vlan_set_vlanid,
3458 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3459 struct cmd_tx_vlan_set_qinq_result {
3460 cmdline_fixed_string_t tx_vlan;
3461 cmdline_fixed_string_t set;
3464 uint16_t vlan_id_outer;
3468 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3469 __attribute__((unused)) struct cmdline *cl,
3470 __attribute__((unused)) void *data)
3472 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3474 if (!port_is_stopped(res->port_id)) {
3475 printf("Please stop port %d first\n", res->port_id);
3479 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3481 cmd_reconfig_device_queue(res->port_id, 1, 1);
3484 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3485 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3486 tx_vlan, "tx_vlan");
3487 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3488 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3490 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3491 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3493 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3494 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3496 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3497 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3498 vlan_id_outer, UINT16);
3500 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3501 .f = cmd_tx_vlan_set_qinq_parsed,
3503 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3504 "Enable hardware insertion of double VLAN header "
3505 "with given TAG Identifiers in packets sent on a port",
3507 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3508 (void *)&cmd_tx_vlan_set_qinq_set,
3509 (void *)&cmd_tx_vlan_set_qinq_portid,
3510 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3511 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3516 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3517 struct cmd_tx_vlan_set_pvid_result {
3518 cmdline_fixed_string_t tx_vlan;
3519 cmdline_fixed_string_t set;
3520 cmdline_fixed_string_t pvid;
3523 cmdline_fixed_string_t mode;
3527 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3528 __attribute__((unused)) struct cmdline *cl,
3529 __attribute__((unused)) void *data)
3531 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3533 if (strcmp(res->mode, "on") == 0)
3534 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3536 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3539 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3540 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3541 tx_vlan, "tx_vlan");
3542 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3543 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3545 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3546 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3548 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3549 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3551 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3552 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3554 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3555 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3558 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3559 .f = cmd_tx_vlan_set_pvid_parsed,
3561 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3563 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3564 (void *)&cmd_tx_vlan_set_pvid_set,
3565 (void *)&cmd_tx_vlan_set_pvid_pvid,
3566 (void *)&cmd_tx_vlan_set_pvid_port_id,
3567 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3568 (void *)&cmd_tx_vlan_set_pvid_mode,
3573 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3574 struct cmd_tx_vlan_reset_result {
3575 cmdline_fixed_string_t tx_vlan;
3576 cmdline_fixed_string_t reset;
3581 cmd_tx_vlan_reset_parsed(void *parsed_result,
3582 __attribute__((unused)) struct cmdline *cl,
3583 __attribute__((unused)) void *data)
3585 struct cmd_tx_vlan_reset_result *res = parsed_result;
3587 if (!port_is_stopped(res->port_id)) {
3588 printf("Please stop port %d first\n", res->port_id);
3592 tx_vlan_reset(res->port_id);
3594 cmd_reconfig_device_queue(res->port_id, 1, 1);
3597 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3598 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3599 tx_vlan, "tx_vlan");
3600 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3601 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3603 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3604 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3607 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3608 .f = cmd_tx_vlan_reset_parsed,
3610 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3611 "VLAN header in packets sent on a port",
3613 (void *)&cmd_tx_vlan_reset_tx_vlan,
3614 (void *)&cmd_tx_vlan_reset_reset,
3615 (void *)&cmd_tx_vlan_reset_portid,
3621 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3622 struct cmd_csum_result {
3623 cmdline_fixed_string_t csum;
3624 cmdline_fixed_string_t mode;
3625 cmdline_fixed_string_t proto;
3626 cmdline_fixed_string_t hwsw;
3631 csum_show(int port_id)
3633 struct rte_eth_dev_info dev_info;
3634 uint64_t tx_offloads;
3636 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3637 printf("Parse tunnel is %s\n",
3638 (ports[port_id].parse_tunnel) ? "on" : "off");
3639 printf("IP checksum offload is %s\n",
3640 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3641 printf("UDP checksum offload is %s\n",
3642 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3643 printf("TCP checksum offload is %s\n",
3644 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3645 printf("SCTP checksum offload is %s\n",
3646 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3647 printf("Outer-Ip checksum offload is %s\n",
3648 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3650 /* display warnings if configuration is not supported by the NIC */
3651 rte_eth_dev_info_get(port_id, &dev_info);
3652 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3653 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3654 printf("Warning: hardware IP checksum enabled but not "
3655 "supported by port %d\n", port_id);
3657 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3658 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3659 printf("Warning: hardware UDP checksum enabled but not "
3660 "supported by port %d\n", port_id);
3662 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3663 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3664 printf("Warning: hardware TCP checksum enabled but not "
3665 "supported by port %d\n", port_id);
3667 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3668 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3669 printf("Warning: hardware SCTP checksum enabled but not "
3670 "supported by port %d\n", port_id);
3672 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3673 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3674 printf("Warning: hardware outer IP checksum enabled but not "
3675 "supported by port %d\n", port_id);
3680 cmd_csum_parsed(void *parsed_result,
3681 __attribute__((unused)) struct cmdline *cl,
3682 __attribute__((unused)) void *data)
3684 struct cmd_csum_result *res = parsed_result;
3686 uint64_t csum_offloads = 0;
3687 struct rte_eth_dev_info dev_info;
3689 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3690 printf("invalid port %d\n", res->port_id);
3693 if (!port_is_stopped(res->port_id)) {
3694 printf("Please stop port %d first\n", res->port_id);
3698 rte_eth_dev_info_get(res->port_id, &dev_info);
3699 if (!strcmp(res->mode, "set")) {
3701 if (!strcmp(res->hwsw, "hw"))
3704 if (!strcmp(res->proto, "ip")) {
3705 if (dev_info.tx_offload_capa &
3706 DEV_TX_OFFLOAD_IPV4_CKSUM) {
3707 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3709 printf("IP checksum offload is not supported "
3710 "by port %u\n", res->port_id);
3712 } else if (!strcmp(res->proto, "udp")) {
3713 if (dev_info.tx_offload_capa &
3714 DEV_TX_OFFLOAD_UDP_CKSUM) {
3715 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3717 printf("UDP checksum offload is not supported "
3718 "by port %u\n", res->port_id);
3720 } else if (!strcmp(res->proto, "tcp")) {
3721 if (dev_info.tx_offload_capa &
3722 DEV_TX_OFFLOAD_TCP_CKSUM) {
3723 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3725 printf("TCP checksum offload is not supported "
3726 "by port %u\n", res->port_id);
3728 } else if (!strcmp(res->proto, "sctp")) {
3729 if (dev_info.tx_offload_capa &
3730 DEV_TX_OFFLOAD_SCTP_CKSUM) {
3731 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3733 printf("SCTP checksum offload is not supported "
3734 "by port %u\n", res->port_id);
3736 } else if (!strcmp(res->proto, "outer-ip")) {
3737 if (dev_info.tx_offload_capa &
3738 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) {
3740 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3742 printf("Outer IP checksum offload is not "
3743 "supported by port %u\n", res->port_id);
3748 ports[res->port_id].dev_conf.txmode.offloads |=
3751 ports[res->port_id].dev_conf.txmode.offloads &=
3755 csum_show(res->port_id);
3757 cmd_reconfig_device_queue(res->port_id, 1, 1);
3760 cmdline_parse_token_string_t cmd_csum_csum =
3761 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3763 cmdline_parse_token_string_t cmd_csum_mode =
3764 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3766 cmdline_parse_token_string_t cmd_csum_proto =
3767 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3768 proto, "ip#tcp#udp#sctp#outer-ip");
3769 cmdline_parse_token_string_t cmd_csum_hwsw =
3770 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3772 cmdline_parse_token_num_t cmd_csum_portid =
3773 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3776 cmdline_parse_inst_t cmd_csum_set = {
3777 .f = cmd_csum_parsed,
3779 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3780 "Enable/Disable hardware calculation of L3/L4 checksum when "
3781 "using csum forward engine",
3783 (void *)&cmd_csum_csum,
3784 (void *)&cmd_csum_mode,
3785 (void *)&cmd_csum_proto,
3786 (void *)&cmd_csum_hwsw,
3787 (void *)&cmd_csum_portid,
3792 cmdline_parse_token_string_t cmd_csum_mode_show =
3793 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3796 cmdline_parse_inst_t cmd_csum_show = {
3797 .f = cmd_csum_parsed,
3799 .help_str = "csum show <port_id>: Show checksum offload configuration",
3801 (void *)&cmd_csum_csum,
3802 (void *)&cmd_csum_mode_show,
3803 (void *)&cmd_csum_portid,
3808 /* Enable/disable tunnel parsing */
3809 struct cmd_csum_tunnel_result {
3810 cmdline_fixed_string_t csum;
3811 cmdline_fixed_string_t parse;
3812 cmdline_fixed_string_t onoff;
3817 cmd_csum_tunnel_parsed(void *parsed_result,
3818 __attribute__((unused)) struct cmdline *cl,
3819 __attribute__((unused)) void *data)
3821 struct cmd_csum_tunnel_result *res = parsed_result;
3823 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3826 if (!strcmp(res->onoff, "on"))
3827 ports[res->port_id].parse_tunnel = 1;
3829 ports[res->port_id].parse_tunnel = 0;
3831 csum_show(res->port_id);
3834 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3835 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3837 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3838 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3839 parse, "parse_tunnel");
3840 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3841 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3843 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3844 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3847 cmdline_parse_inst_t cmd_csum_tunnel = {
3848 .f = cmd_csum_tunnel_parsed,
3850 .help_str = "csum parse_tunnel on|off <port_id>: "
3851 "Enable/Disable parsing of tunnels for csum engine",
3853 (void *)&cmd_csum_tunnel_csum,
3854 (void *)&cmd_csum_tunnel_parse,
3855 (void *)&cmd_csum_tunnel_onoff,
3856 (void *)&cmd_csum_tunnel_portid,
3861 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3862 struct cmd_tso_set_result {
3863 cmdline_fixed_string_t tso;
3864 cmdline_fixed_string_t mode;
3870 cmd_tso_set_parsed(void *parsed_result,
3871 __attribute__((unused)) struct cmdline *cl,
3872 __attribute__((unused)) void *data)
3874 struct cmd_tso_set_result *res = parsed_result;
3875 struct rte_eth_dev_info dev_info;
3877 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3879 if (!port_is_stopped(res->port_id)) {
3880 printf("Please stop port %d first\n", res->port_id);
3884 if (!strcmp(res->mode, "set"))
3885 ports[res->port_id].tso_segsz = res->tso_segsz;
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("Error: TSO is not supported by port %d\n",
3895 if (ports[res->port_id].tso_segsz == 0) {
3896 ports[res->port_id].dev_conf.txmode.offloads &=
3897 ~DEV_TX_OFFLOAD_TCP_TSO;
3898 printf("TSO for non-tunneled packets is disabled\n");
3900 ports[res->port_id].dev_conf.txmode.offloads |=
3901 DEV_TX_OFFLOAD_TCP_TSO;
3902 printf("TSO segment size for non-tunneled packets is %d\n",
3903 ports[res->port_id].tso_segsz);
3906 /* display warnings if configuration is not supported by the NIC */
3907 rte_eth_dev_info_get(res->port_id, &dev_info);
3908 if ((ports[res->port_id].tso_segsz != 0) &&
3909 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3910 printf("Warning: TSO enabled but not "
3911 "supported by port %d\n", res->port_id);
3914 cmd_reconfig_device_queue(res->port_id, 1, 1);
3917 cmdline_parse_token_string_t cmd_tso_set_tso =
3918 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3920 cmdline_parse_token_string_t cmd_tso_set_mode =
3921 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3923 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3924 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3926 cmdline_parse_token_num_t cmd_tso_set_portid =
3927 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3930 cmdline_parse_inst_t cmd_tso_set = {
3931 .f = cmd_tso_set_parsed,
3933 .help_str = "tso set <tso_segsz> <port_id>: "
3934 "Set TSO segment size of non-tunneled packets for csum engine "
3937 (void *)&cmd_tso_set_tso,
3938 (void *)&cmd_tso_set_mode,
3939 (void *)&cmd_tso_set_tso_segsz,
3940 (void *)&cmd_tso_set_portid,
3945 cmdline_parse_token_string_t cmd_tso_show_mode =
3946 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3950 cmdline_parse_inst_t cmd_tso_show = {
3951 .f = cmd_tso_set_parsed,
3953 .help_str = "tso show <port_id>: "
3954 "Show TSO segment size of non-tunneled packets for csum engine",
3956 (void *)&cmd_tso_set_tso,
3957 (void *)&cmd_tso_show_mode,
3958 (void *)&cmd_tso_set_portid,
3963 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3964 struct cmd_tunnel_tso_set_result {
3965 cmdline_fixed_string_t tso;
3966 cmdline_fixed_string_t mode;
3971 static struct rte_eth_dev_info
3972 check_tunnel_tso_nic_support(portid_t port_id)
3974 struct rte_eth_dev_info dev_info;
3976 rte_eth_dev_info_get(port_id, &dev_info);
3977 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3978 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
3979 "not enabled for port %d\n", port_id);
3980 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3981 printf("Warning: GRE TUNNEL TSO not supported therefore "
3982 "not enabled for port %d\n", port_id);
3983 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3984 printf("Warning: IPIP TUNNEL TSO not supported therefore "
3985 "not enabled for port %d\n", port_id);
3986 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3987 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
3988 "not enabled for port %d\n", port_id);
3993 cmd_tunnel_tso_set_parsed(void *parsed_result,
3994 __attribute__((unused)) struct cmdline *cl,
3995 __attribute__((unused)) void *data)
3997 struct cmd_tunnel_tso_set_result *res = parsed_result;
3998 struct rte_eth_dev_info dev_info;
4000 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4002 if (!port_is_stopped(res->port_id)) {
4003 printf("Please stop port %d first\n", res->port_id);
4007 if (!strcmp(res->mode, "set"))
4008 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4010 dev_info = check_tunnel_tso_nic_support(res->port_id);
4011 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4012 ports[res->port_id].dev_conf.txmode.offloads &=
4013 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4014 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4015 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4016 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4017 printf("TSO for tunneled packets is disabled\n");
4019 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4020 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4021 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4022 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4024 ports[res->port_id].dev_conf.txmode.offloads |=
4025 (tso_offloads & dev_info.tx_offload_capa);
4026 printf("TSO segment size for tunneled packets is %d\n",
4027 ports[res->port_id].tunnel_tso_segsz);
4029 /* Below conditions are needed to make it work:
4030 * (1) tunnel TSO is supported by the NIC;
4031 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4033 * (3) for tunneled pkts with outer L3 of IPv4,
4034 * "csum set outer-ip" must be set to hw, because after tso,
4035 * total_len of outer IP header is changed, and the checksum
4036 * of outer IP header calculated by sw should be wrong; that
4037 * is not necessary for IPv6 tunneled pkts because there's no
4038 * checksum in IP header anymore.
4041 if (!ports[res->port_id].parse_tunnel)
4042 printf("Warning: csum parse_tunnel must be set "
4043 "so that tunneled packets are recognized\n");
4044 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4045 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4046 printf("Warning: csum set outer-ip must be set to hw "
4047 "if outer L3 is IPv4; not necessary for IPv6\n");
4050 cmd_reconfig_device_queue(res->port_id, 1, 1);
4053 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4054 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4056 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4057 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4059 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4060 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4062 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4063 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4066 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4067 .f = cmd_tunnel_tso_set_parsed,
4069 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4070 "Set TSO segment size of tunneled packets for csum engine "
4073 (void *)&cmd_tunnel_tso_set_tso,
4074 (void *)&cmd_tunnel_tso_set_mode,
4075 (void *)&cmd_tunnel_tso_set_tso_segsz,
4076 (void *)&cmd_tunnel_tso_set_portid,
4081 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4082 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4086 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4087 .f = cmd_tunnel_tso_set_parsed,
4089 .help_str = "tunnel_tso show <port_id> "
4090 "Show TSO segment size of tunneled packets for csum engine",
4092 (void *)&cmd_tunnel_tso_set_tso,
4093 (void *)&cmd_tunnel_tso_show_mode,
4094 (void *)&cmd_tunnel_tso_set_portid,
4099 /* *** SET GRO FOR A PORT *** */
4100 struct cmd_gro_enable_result {
4101 cmdline_fixed_string_t cmd_set;
4102 cmdline_fixed_string_t cmd_port;
4103 cmdline_fixed_string_t cmd_keyword;
4104 cmdline_fixed_string_t cmd_onoff;
4109 cmd_gro_enable_parsed(void *parsed_result,
4110 __attribute__((unused)) struct cmdline *cl,
4111 __attribute__((unused)) void *data)
4113 struct cmd_gro_enable_result *res;
4115 res = parsed_result;
4116 if (!strcmp(res->cmd_keyword, "gro"))
4117 setup_gro(res->cmd_onoff, res->cmd_pid);
4120 cmdline_parse_token_string_t cmd_gro_enable_set =
4121 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4123 cmdline_parse_token_string_t cmd_gro_enable_port =
4124 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4125 cmd_keyword, "port");
4126 cmdline_parse_token_num_t cmd_gro_enable_pid =
4127 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4129 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4130 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4131 cmd_keyword, "gro");
4132 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4133 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4134 cmd_onoff, "on#off");
4136 cmdline_parse_inst_t cmd_gro_enable = {
4137 .f = cmd_gro_enable_parsed,
4139 .help_str = "set port <port_id> gro on|off",
4141 (void *)&cmd_gro_enable_set,
4142 (void *)&cmd_gro_enable_port,
4143 (void *)&cmd_gro_enable_pid,
4144 (void *)&cmd_gro_enable_keyword,
4145 (void *)&cmd_gro_enable_onoff,
4150 /* *** DISPLAY GRO CONFIGURATION *** */
4151 struct cmd_gro_show_result {
4152 cmdline_fixed_string_t cmd_show;
4153 cmdline_fixed_string_t cmd_port;
4154 cmdline_fixed_string_t cmd_keyword;
4159 cmd_gro_show_parsed(void *parsed_result,
4160 __attribute__((unused)) struct cmdline *cl,
4161 __attribute__((unused)) void *data)
4163 struct cmd_gro_show_result *res;
4165 res = parsed_result;
4166 if (!strcmp(res->cmd_keyword, "gro"))
4167 show_gro(res->cmd_pid);
4170 cmdline_parse_token_string_t cmd_gro_show_show =
4171 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4173 cmdline_parse_token_string_t cmd_gro_show_port =
4174 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4176 cmdline_parse_token_num_t cmd_gro_show_pid =
4177 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4179 cmdline_parse_token_string_t cmd_gro_show_keyword =
4180 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4181 cmd_keyword, "gro");
4183 cmdline_parse_inst_t cmd_gro_show = {
4184 .f = cmd_gro_show_parsed,
4186 .help_str = "show port <port_id> gro",
4188 (void *)&cmd_gro_show_show,
4189 (void *)&cmd_gro_show_port,
4190 (void *)&cmd_gro_show_pid,
4191 (void *)&cmd_gro_show_keyword,
4196 /* *** SET FLUSH CYCLES FOR GRO *** */
4197 struct cmd_gro_flush_result {
4198 cmdline_fixed_string_t cmd_set;
4199 cmdline_fixed_string_t cmd_keyword;
4200 cmdline_fixed_string_t cmd_flush;
4205 cmd_gro_flush_parsed(void *parsed_result,
4206 __attribute__((unused)) struct cmdline *cl,
4207 __attribute__((unused)) void *data)
4209 struct cmd_gro_flush_result *res;
4211 res = parsed_result;
4212 if ((!strcmp(res->cmd_keyword, "gro")) &&
4213 (!strcmp(res->cmd_flush, "flush")))
4214 setup_gro_flush_cycles(res->cmd_cycles);
4217 cmdline_parse_token_string_t cmd_gro_flush_set =
4218 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4220 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4221 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4222 cmd_keyword, "gro");
4223 cmdline_parse_token_string_t cmd_gro_flush_flush =
4224 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4225 cmd_flush, "flush");
4226 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4227 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4230 cmdline_parse_inst_t cmd_gro_flush = {
4231 .f = cmd_gro_flush_parsed,
4233 .help_str = "set gro flush <cycles>",
4235 (void *)&cmd_gro_flush_set,
4236 (void *)&cmd_gro_flush_keyword,
4237 (void *)&cmd_gro_flush_flush,
4238 (void *)&cmd_gro_flush_cycles,
4243 /* *** ENABLE/DISABLE GSO *** */
4244 struct cmd_gso_enable_result {
4245 cmdline_fixed_string_t cmd_set;
4246 cmdline_fixed_string_t cmd_port;
4247 cmdline_fixed_string_t cmd_keyword;
4248 cmdline_fixed_string_t cmd_mode;
4253 cmd_gso_enable_parsed(void *parsed_result,
4254 __attribute__((unused)) struct cmdline *cl,
4255 __attribute__((unused)) void *data)
4257 struct cmd_gso_enable_result *res;
4259 res = parsed_result;
4260 if (!strcmp(res->cmd_keyword, "gso"))
4261 setup_gso(res->cmd_mode, res->cmd_pid);
4264 cmdline_parse_token_string_t cmd_gso_enable_set =
4265 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4267 cmdline_parse_token_string_t cmd_gso_enable_port =
4268 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4270 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4271 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4272 cmd_keyword, "gso");
4273 cmdline_parse_token_string_t cmd_gso_enable_mode =
4274 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4275 cmd_mode, "on#off");
4276 cmdline_parse_token_num_t cmd_gso_enable_pid =
4277 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4280 cmdline_parse_inst_t cmd_gso_enable = {
4281 .f = cmd_gso_enable_parsed,
4283 .help_str = "set port <port_id> gso on|off",
4285 (void *)&cmd_gso_enable_set,
4286 (void *)&cmd_gso_enable_port,
4287 (void *)&cmd_gso_enable_pid,
4288 (void *)&cmd_gso_enable_keyword,
4289 (void *)&cmd_gso_enable_mode,
4294 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4295 struct cmd_gso_size_result {
4296 cmdline_fixed_string_t cmd_set;
4297 cmdline_fixed_string_t cmd_keyword;
4298 cmdline_fixed_string_t cmd_segsz;
4303 cmd_gso_size_parsed(void *parsed_result,
4304 __attribute__((unused)) struct cmdline *cl,
4305 __attribute__((unused)) void *data)
4307 struct cmd_gso_size_result *res = parsed_result;
4309 if (test_done == 0) {
4310 printf("Before setting GSO segsz, please first"
4311 " stop fowarding\n");
4315 if (!strcmp(res->cmd_keyword, "gso") &&
4316 !strcmp(res->cmd_segsz, "segsz")) {
4317 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4318 printf("gso_size should be larger than %zu."
4319 " Please input a legal value\n",
4320 RTE_GSO_SEG_SIZE_MIN);
4322 gso_max_segment_size = res->cmd_size;
4326 cmdline_parse_token_string_t cmd_gso_size_set =
4327 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4329 cmdline_parse_token_string_t cmd_gso_size_keyword =
4330 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4331 cmd_keyword, "gso");
4332 cmdline_parse_token_string_t cmd_gso_size_segsz =
4333 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4334 cmd_segsz, "segsz");
4335 cmdline_parse_token_num_t cmd_gso_size_size =
4336 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4339 cmdline_parse_inst_t cmd_gso_size = {
4340 .f = cmd_gso_size_parsed,
4342 .help_str = "set gso segsz <length>",
4344 (void *)&cmd_gso_size_set,
4345 (void *)&cmd_gso_size_keyword,
4346 (void *)&cmd_gso_size_segsz,
4347 (void *)&cmd_gso_size_size,
4352 /* *** SHOW GSO CONFIGURATION *** */
4353 struct cmd_gso_show_result {
4354 cmdline_fixed_string_t cmd_show;
4355 cmdline_fixed_string_t cmd_port;
4356 cmdline_fixed_string_t cmd_keyword;
4361 cmd_gso_show_parsed(void *parsed_result,
4362 __attribute__((unused)) struct cmdline *cl,
4363 __attribute__((unused)) void *data)
4365 struct cmd_gso_show_result *res = parsed_result;
4367 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4368 printf("invalid port id %u\n", res->cmd_pid);
4371 if (!strcmp(res->cmd_keyword, "gso")) {
4372 if (gso_ports[res->cmd_pid].enable) {
4373 printf("Max GSO'd packet size: %uB\n"
4374 "Supported GSO types: TCP/IPv4, "
4375 "VxLAN with inner TCP/IPv4 packet, "
4376 "GRE with inner TCP/IPv4 packet\n",
4377 gso_max_segment_size);
4379 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4383 cmdline_parse_token_string_t cmd_gso_show_show =
4384 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4386 cmdline_parse_token_string_t cmd_gso_show_port =
4387 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4389 cmdline_parse_token_string_t cmd_gso_show_keyword =
4390 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4391 cmd_keyword, "gso");
4392 cmdline_parse_token_num_t cmd_gso_show_pid =
4393 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4396 cmdline_parse_inst_t cmd_gso_show = {
4397 .f = cmd_gso_show_parsed,
4399 .help_str = "show port <port_id> gso",
4401 (void *)&cmd_gso_show_show,
4402 (void *)&cmd_gso_show_port,
4403 (void *)&cmd_gso_show_pid,
4404 (void *)&cmd_gso_show_keyword,
4409 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4410 struct cmd_set_flush_rx {
4411 cmdline_fixed_string_t set;
4412 cmdline_fixed_string_t flush_rx;
4413 cmdline_fixed_string_t mode;
4417 cmd_set_flush_rx_parsed(void *parsed_result,
4418 __attribute__((unused)) struct cmdline *cl,
4419 __attribute__((unused)) void *data)
4421 struct cmd_set_flush_rx *res = parsed_result;
4422 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4425 cmdline_parse_token_string_t cmd_setflushrx_set =
4426 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4428 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4429 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4430 flush_rx, "flush_rx");
4431 cmdline_parse_token_string_t cmd_setflushrx_mode =
4432 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4436 cmdline_parse_inst_t cmd_set_flush_rx = {
4437 .f = cmd_set_flush_rx_parsed,
4438 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4441 (void *)&cmd_setflushrx_set,
4442 (void *)&cmd_setflushrx_flush_rx,
4443 (void *)&cmd_setflushrx_mode,
4448 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4449 struct cmd_set_link_check {
4450 cmdline_fixed_string_t set;
4451 cmdline_fixed_string_t link_check;
4452 cmdline_fixed_string_t mode;
4456 cmd_set_link_check_parsed(void *parsed_result,
4457 __attribute__((unused)) struct cmdline *cl,
4458 __attribute__((unused)) void *data)
4460 struct cmd_set_link_check *res = parsed_result;
4461 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4464 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4465 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4467 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4468 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4469 link_check, "link_check");
4470 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4471 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4475 cmdline_parse_inst_t cmd_set_link_check = {
4476 .f = cmd_set_link_check_parsed,
4477 .help_str = "set link_check on|off: Enable/Disable link status check "
4478 "when starting/stopping a port",
4481 (void *)&cmd_setlinkcheck_set,
4482 (void *)&cmd_setlinkcheck_link_check,
4483 (void *)&cmd_setlinkcheck_mode,
4488 /* *** SET NIC BYPASS MODE *** */
4489 struct cmd_set_bypass_mode_result {
4490 cmdline_fixed_string_t set;
4491 cmdline_fixed_string_t bypass;
4492 cmdline_fixed_string_t mode;
4493 cmdline_fixed_string_t value;
4498 cmd_set_bypass_mode_parsed(void *parsed_result,
4499 __attribute__((unused)) struct cmdline *cl,
4500 __attribute__((unused)) void *data)
4502 struct cmd_set_bypass_mode_result *res = parsed_result;
4503 portid_t port_id = res->port_id;
4504 int32_t rc = -EINVAL;
4506 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4507 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4509 if (!strcmp(res->value, "bypass"))
4510 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4511 else if (!strcmp(res->value, "isolate"))
4512 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4514 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4516 /* Set the bypass mode for the relevant port. */
4517 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4520 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4523 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4524 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4526 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4527 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4529 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4530 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4532 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4533 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4534 value, "normal#bypass#isolate");
4535 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4536 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4539 cmdline_parse_inst_t cmd_set_bypass_mode = {
4540 .f = cmd_set_bypass_mode_parsed,
4541 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4542 "Set the NIC bypass mode for port_id",
4545 (void *)&cmd_setbypass_mode_set,
4546 (void *)&cmd_setbypass_mode_bypass,
4547 (void *)&cmd_setbypass_mode_mode,
4548 (void *)&cmd_setbypass_mode_value,
4549 (void *)&cmd_setbypass_mode_port,
4554 /* *** SET NIC BYPASS EVENT *** */
4555 struct cmd_set_bypass_event_result {
4556 cmdline_fixed_string_t set;
4557 cmdline_fixed_string_t bypass;
4558 cmdline_fixed_string_t event;
4559 cmdline_fixed_string_t event_value;
4560 cmdline_fixed_string_t mode;
4561 cmdline_fixed_string_t mode_value;
4566 cmd_set_bypass_event_parsed(void *parsed_result,
4567 __attribute__((unused)) struct cmdline *cl,
4568 __attribute__((unused)) void *data)
4570 int32_t rc = -EINVAL;
4571 struct cmd_set_bypass_event_result *res = parsed_result;
4572 portid_t port_id = res->port_id;
4574 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4575 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4576 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4578 if (!strcmp(res->event_value, "timeout"))
4579 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4580 else if (!strcmp(res->event_value, "os_on"))
4581 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4582 else if (!strcmp(res->event_value, "os_off"))
4583 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4584 else if (!strcmp(res->event_value, "power_on"))
4585 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4586 else if (!strcmp(res->event_value, "power_off"))
4587 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4589 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4591 if (!strcmp(res->mode_value, "bypass"))
4592 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4593 else if (!strcmp(res->mode_value, "isolate"))
4594 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4596 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4598 /* Set the watchdog timeout. */
4599 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4602 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4603 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4607 printf("Failed to set timeout value %u "
4608 "for port %d, errto code: %d.\n",
4609 bypass_timeout, port_id, rc);
4613 /* Set the bypass event to transition to bypass mode. */
4614 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4619 printf("\t Failed to set bypass event for port = %d.\n",
4623 cmdline_parse_token_string_t cmd_setbypass_event_set =
4624 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4626 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4627 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4629 cmdline_parse_token_string_t cmd_setbypass_event_event =
4630 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4632 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4633 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4634 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4635 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4636 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4638 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4639 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4640 mode_value, "normal#bypass#isolate");
4641 cmdline_parse_token_num_t cmd_setbypass_event_port =
4642 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4645 cmdline_parse_inst_t cmd_set_bypass_event = {
4646 .f = cmd_set_bypass_event_parsed,
4647 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4648 "power_off mode normal|bypass|isolate <port_id>: "
4649 "Set the NIC bypass event mode for port_id",
4652 (void *)&cmd_setbypass_event_set,
4653 (void *)&cmd_setbypass_event_bypass,
4654 (void *)&cmd_setbypass_event_event,
4655 (void *)&cmd_setbypass_event_event_value,
4656 (void *)&cmd_setbypass_event_mode,
4657 (void *)&cmd_setbypass_event_mode_value,
4658 (void *)&cmd_setbypass_event_port,
4664 /* *** SET NIC BYPASS TIMEOUT *** */
4665 struct cmd_set_bypass_timeout_result {
4666 cmdline_fixed_string_t set;
4667 cmdline_fixed_string_t bypass;
4668 cmdline_fixed_string_t timeout;
4669 cmdline_fixed_string_t value;
4673 cmd_set_bypass_timeout_parsed(void *parsed_result,
4674 __attribute__((unused)) struct cmdline *cl,
4675 __attribute__((unused)) void *data)
4677 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4679 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4680 if (!strcmp(res->value, "1.5"))
4681 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4682 else if (!strcmp(res->value, "2"))
4683 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4684 else if (!strcmp(res->value, "3"))
4685 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4686 else if (!strcmp(res->value, "4"))
4687 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4688 else if (!strcmp(res->value, "8"))
4689 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4690 else if (!strcmp(res->value, "16"))
4691 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4692 else if (!strcmp(res->value, "32"))
4693 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4695 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4699 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4700 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4702 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4703 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4705 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4706 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4707 timeout, "timeout");
4708 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4709 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4710 value, "0#1.5#2#3#4#8#16#32");
4712 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4713 .f = cmd_set_bypass_timeout_parsed,
4714 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4715 "Set the NIC bypass watchdog timeout in seconds",
4718 (void *)&cmd_setbypass_timeout_set,
4719 (void *)&cmd_setbypass_timeout_bypass,
4720 (void *)&cmd_setbypass_timeout_timeout,
4721 (void *)&cmd_setbypass_timeout_value,
4726 /* *** SHOW NIC BYPASS MODE *** */
4727 struct cmd_show_bypass_config_result {
4728 cmdline_fixed_string_t show;
4729 cmdline_fixed_string_t bypass;
4730 cmdline_fixed_string_t config;
4735 cmd_show_bypass_config_parsed(void *parsed_result,
4736 __attribute__((unused)) struct cmdline *cl,
4737 __attribute__((unused)) void *data)
4739 struct cmd_show_bypass_config_result *res = parsed_result;
4740 portid_t port_id = res->port_id;
4742 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4743 uint32_t event_mode;
4744 uint32_t bypass_mode;
4745 uint32_t timeout = bypass_timeout;
4748 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4749 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4750 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4751 {"UNKNOWN", "normal", "bypass", "isolate"};
4752 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4759 int num_events = (sizeof events) / (sizeof events[0]);
4761 /* Display the bypass mode.*/
4762 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4763 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4767 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4768 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4770 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4773 /* Display the bypass timeout.*/
4774 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4775 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4777 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4779 /* Display the bypass events and associated modes. */
4780 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4782 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4783 printf("\tFailed to get bypass mode for event = %s\n",
4786 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4787 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4789 printf("\tbypass event: %-16s = %s\n", events[i],
4795 printf("\tFailed to get bypass configuration for port = %d\n",
4799 cmdline_parse_token_string_t cmd_showbypass_config_show =
4800 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4802 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4803 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4805 cmdline_parse_token_string_t cmd_showbypass_config_config =
4806 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4808 cmdline_parse_token_num_t cmd_showbypass_config_port =
4809 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4812 cmdline_parse_inst_t cmd_show_bypass_config = {
4813 .f = cmd_show_bypass_config_parsed,
4814 .help_str = "show bypass config <port_id>: "
4815 "Show the NIC bypass config for port_id",
4818 (void *)&cmd_showbypass_config_show,
4819 (void *)&cmd_showbypass_config_bypass,
4820 (void *)&cmd_showbypass_config_config,
4821 (void *)&cmd_showbypass_config_port,
4826 #ifdef RTE_LIBRTE_PMD_BOND
4827 /* *** SET BONDING MODE *** */
4828 struct cmd_set_bonding_mode_result {
4829 cmdline_fixed_string_t set;
4830 cmdline_fixed_string_t bonding;
4831 cmdline_fixed_string_t mode;
4836 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4837 __attribute__((unused)) struct cmdline *cl,
4838 __attribute__((unused)) void *data)
4840 struct cmd_set_bonding_mode_result *res = parsed_result;
4841 portid_t port_id = res->port_id;
4843 /* Set the bonding mode for the relevant port. */
4844 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4845 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4848 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4849 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4851 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4852 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4853 bonding, "bonding");
4854 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4855 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4857 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4858 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4860 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4861 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4864 cmdline_parse_inst_t cmd_set_bonding_mode = {
4865 .f = cmd_set_bonding_mode_parsed,
4866 .help_str = "set bonding mode <mode_value> <port_id>: "
4867 "Set the bonding mode for port_id",
4870 (void *) &cmd_setbonding_mode_set,
4871 (void *) &cmd_setbonding_mode_bonding,
4872 (void *) &cmd_setbonding_mode_mode,
4873 (void *) &cmd_setbonding_mode_value,
4874 (void *) &cmd_setbonding_mode_port,
4879 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4880 struct cmd_set_bonding_lacp_dedicated_queues_result {
4881 cmdline_fixed_string_t set;
4882 cmdline_fixed_string_t bonding;
4883 cmdline_fixed_string_t lacp;
4884 cmdline_fixed_string_t dedicated_queues;
4886 cmdline_fixed_string_t mode;
4889 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4890 __attribute__((unused)) struct cmdline *cl,
4891 __attribute__((unused)) void *data)
4893 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4894 portid_t port_id = res->port_id;
4895 struct rte_port *port;
4897 port = &ports[port_id];
4899 /** Check if the port is not started **/
4900 if (port->port_status != RTE_PORT_STOPPED) {
4901 printf("Please stop port %d first\n", port_id);
4905 if (!strcmp(res->mode, "enable")) {
4906 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4907 printf("Dedicate queues for LACP control packets"
4910 printf("Enabling dedicate queues for LACP control "
4911 "packets on port %d failed\n", port_id);
4912 } else if (!strcmp(res->mode, "disable")) {
4913 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4914 printf("Dedicated queues for LACP control packets "
4917 printf("Disabling dedicated queues for LACP control "
4918 "traffic on port %d failed\n", port_id);
4922 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4923 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4925 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4926 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4927 bonding, "bonding");
4928 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4929 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4931 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4932 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4933 dedicated_queues, "dedicated_queues");
4934 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4935 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4937 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4938 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4939 mode, "enable#disable");
4941 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4942 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4943 .help_str = "set bonding lacp dedicated_queues <port_id> "
4945 "Enable/disable dedicated queues for LACP control traffic for port_id",
4948 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4949 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4950 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4951 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4952 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4953 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4958 /* *** SET BALANCE XMIT POLICY *** */
4959 struct cmd_set_bonding_balance_xmit_policy_result {
4960 cmdline_fixed_string_t set;
4961 cmdline_fixed_string_t bonding;
4962 cmdline_fixed_string_t balance_xmit_policy;
4964 cmdline_fixed_string_t policy;
4967 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4968 __attribute__((unused)) struct cmdline *cl,
4969 __attribute__((unused)) void *data)
4971 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4972 portid_t port_id = res->port_id;
4975 if (!strcmp(res->policy, "l2")) {
4976 policy = BALANCE_XMIT_POLICY_LAYER2;
4977 } else if (!strcmp(res->policy, "l23")) {
4978 policy = BALANCE_XMIT_POLICY_LAYER23;
4979 } else if (!strcmp(res->policy, "l34")) {
4980 policy = BALANCE_XMIT_POLICY_LAYER34;
4982 printf("\t Invalid xmit policy selection");
4986 /* Set the bonding mode for the relevant port. */
4987 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4988 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4993 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4994 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4996 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4997 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4998 bonding, "bonding");
4999 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5000 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5001 balance_xmit_policy, "balance_xmit_policy");
5002 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5003 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5005 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5006 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5007 policy, "l2#l23#l34");
5009 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5010 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5011 .help_str = "set bonding balance_xmit_policy <port_id> "
5013 "Set the bonding balance_xmit_policy for port_id",
5016 (void *)&cmd_setbonding_balance_xmit_policy_set,
5017 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5018 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5019 (void *)&cmd_setbonding_balance_xmit_policy_port,
5020 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5025 /* *** SHOW NIC BONDING CONFIGURATION *** */
5026 struct cmd_show_bonding_config_result {
5027 cmdline_fixed_string_t show;
5028 cmdline_fixed_string_t bonding;
5029 cmdline_fixed_string_t config;
5033 static void cmd_show_bonding_config_parsed(void *parsed_result,
5034 __attribute__((unused)) struct cmdline *cl,
5035 __attribute__((unused)) void *data)
5037 struct cmd_show_bonding_config_result *res = parsed_result;
5038 int bonding_mode, agg_mode;
5039 portid_t slaves[RTE_MAX_ETHPORTS];
5040 int num_slaves, num_active_slaves;
5043 portid_t port_id = res->port_id;
5045 /* Display the bonding mode.*/
5046 bonding_mode = rte_eth_bond_mode_get(port_id);
5047 if (bonding_mode < 0) {
5048 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5051 printf("\tBonding mode: %d\n", bonding_mode);
5053 if (bonding_mode == BONDING_MODE_BALANCE) {
5054 int balance_xmit_policy;
5056 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5057 if (balance_xmit_policy < 0) {
5058 printf("\tFailed to get balance xmit policy for port = %d\n",
5062 printf("\tBalance Xmit Policy: ");
5064 switch (balance_xmit_policy) {
5065 case BALANCE_XMIT_POLICY_LAYER2:
5066 printf("BALANCE_XMIT_POLICY_LAYER2");
5068 case BALANCE_XMIT_POLICY_LAYER23:
5069 printf("BALANCE_XMIT_POLICY_LAYER23");
5071 case BALANCE_XMIT_POLICY_LAYER34:
5072 printf("BALANCE_XMIT_POLICY_LAYER34");
5079 if (bonding_mode == BONDING_MODE_8023AD) {
5080 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5081 printf("\tIEEE802.3AD Aggregator Mode: ");
5084 printf("bandwidth");
5096 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5098 if (num_slaves < 0) {
5099 printf("\tFailed to get slave list for port = %d\n", port_id);
5102 if (num_slaves > 0) {
5103 printf("\tSlaves (%d): [", num_slaves);
5104 for (i = 0; i < num_slaves - 1; i++)
5105 printf("%d ", slaves[i]);
5107 printf("%d]\n", slaves[num_slaves - 1]);
5109 printf("\tSlaves: []\n");
5113 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5116 if (num_active_slaves < 0) {
5117 printf("\tFailed to get active slave list for port = %d\n", port_id);
5120 if (num_active_slaves > 0) {
5121 printf("\tActive Slaves (%d): [", num_active_slaves);
5122 for (i = 0; i < num_active_slaves - 1; i++)
5123 printf("%d ", slaves[i]);
5125 printf("%d]\n", slaves[num_active_slaves - 1]);
5128 printf("\tActive Slaves: []\n");
5132 primary_id = rte_eth_bond_primary_get(port_id);
5133 if (primary_id < 0) {
5134 printf("\tFailed to get primary slave for port = %d\n", port_id);
5137 printf("\tPrimary: [%d]\n", primary_id);
5141 cmdline_parse_token_string_t cmd_showbonding_config_show =
5142 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5144 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5145 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5146 bonding, "bonding");
5147 cmdline_parse_token_string_t cmd_showbonding_config_config =
5148 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5150 cmdline_parse_token_num_t cmd_showbonding_config_port =
5151 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5154 cmdline_parse_inst_t cmd_show_bonding_config = {
5155 .f = cmd_show_bonding_config_parsed,
5156 .help_str = "show bonding config <port_id>: "
5157 "Show the bonding config for port_id",
5160 (void *)&cmd_showbonding_config_show,
5161 (void *)&cmd_showbonding_config_bonding,
5162 (void *)&cmd_showbonding_config_config,
5163 (void *)&cmd_showbonding_config_port,
5168 /* *** SET BONDING PRIMARY *** */
5169 struct cmd_set_bonding_primary_result {
5170 cmdline_fixed_string_t set;
5171 cmdline_fixed_string_t bonding;
5172 cmdline_fixed_string_t primary;
5177 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5178 __attribute__((unused)) struct cmdline *cl,
5179 __attribute__((unused)) void *data)
5181 struct cmd_set_bonding_primary_result *res = parsed_result;
5182 portid_t master_port_id = res->port_id;
5183 portid_t slave_port_id = res->slave_id;
5185 /* Set the primary slave for a bonded device. */
5186 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5187 printf("\t Failed to set primary slave for port = %d.\n",
5194 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5195 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5197 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5198 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5199 bonding, "bonding");
5200 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5201 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5202 primary, "primary");
5203 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5204 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5206 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5207 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5210 cmdline_parse_inst_t cmd_set_bonding_primary = {
5211 .f = cmd_set_bonding_primary_parsed,
5212 .help_str = "set bonding primary <slave_id> <port_id>: "
5213 "Set the primary slave for port_id",
5216 (void *)&cmd_setbonding_primary_set,
5217 (void *)&cmd_setbonding_primary_bonding,
5218 (void *)&cmd_setbonding_primary_primary,
5219 (void *)&cmd_setbonding_primary_slave,
5220 (void *)&cmd_setbonding_primary_port,
5225 /* *** ADD SLAVE *** */
5226 struct cmd_add_bonding_slave_result {
5227 cmdline_fixed_string_t add;
5228 cmdline_fixed_string_t bonding;
5229 cmdline_fixed_string_t slave;
5234 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5235 __attribute__((unused)) struct cmdline *cl,
5236 __attribute__((unused)) void *data)
5238 struct cmd_add_bonding_slave_result *res = parsed_result;
5239 portid_t master_port_id = res->port_id;
5240 portid_t slave_port_id = res->slave_id;
5242 /* add the slave for a bonded device. */
5243 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5244 printf("\t Failed to add slave %d to master port = %d.\n",
5245 slave_port_id, master_port_id);
5249 set_port_slave_flag(slave_port_id);
5252 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5253 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5255 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5256 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5257 bonding, "bonding");
5258 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5259 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5261 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5262 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5264 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5265 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5268 cmdline_parse_inst_t cmd_add_bonding_slave = {
5269 .f = cmd_add_bonding_slave_parsed,
5270 .help_str = "add bonding slave <slave_id> <port_id>: "
5271 "Add a slave device to a bonded device",
5274 (void *)&cmd_addbonding_slave_add,
5275 (void *)&cmd_addbonding_slave_bonding,
5276 (void *)&cmd_addbonding_slave_slave,
5277 (void *)&cmd_addbonding_slave_slaveid,
5278 (void *)&cmd_addbonding_slave_port,
5283 /* *** REMOVE SLAVE *** */
5284 struct cmd_remove_bonding_slave_result {
5285 cmdline_fixed_string_t remove;
5286 cmdline_fixed_string_t bonding;
5287 cmdline_fixed_string_t slave;
5292 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5293 __attribute__((unused)) struct cmdline *cl,
5294 __attribute__((unused)) void *data)
5296 struct cmd_remove_bonding_slave_result *res = parsed_result;
5297 portid_t master_port_id = res->port_id;
5298 portid_t slave_port_id = res->slave_id;
5300 /* remove the slave from a bonded device. */
5301 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5302 printf("\t Failed to remove slave %d from master port = %d.\n",
5303 slave_port_id, master_port_id);
5307 clear_port_slave_flag(slave_port_id);
5310 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5311 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5313 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5314 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5315 bonding, "bonding");
5316 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5317 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5319 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5320 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5322 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5323 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5326 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5327 .f = cmd_remove_bonding_slave_parsed,
5328 .help_str = "remove bonding slave <slave_id> <port_id>: "
5329 "Remove a slave device from a bonded device",
5332 (void *)&cmd_removebonding_slave_remove,
5333 (void *)&cmd_removebonding_slave_bonding,
5334 (void *)&cmd_removebonding_slave_slave,
5335 (void *)&cmd_removebonding_slave_slaveid,
5336 (void *)&cmd_removebonding_slave_port,
5341 /* *** CREATE BONDED DEVICE *** */
5342 struct cmd_create_bonded_device_result {
5343 cmdline_fixed_string_t create;
5344 cmdline_fixed_string_t bonded;
5345 cmdline_fixed_string_t device;
5350 static int bond_dev_num = 0;
5352 static void cmd_create_bonded_device_parsed(void *parsed_result,
5353 __attribute__((unused)) struct cmdline *cl,
5354 __attribute__((unused)) void *data)
5356 struct cmd_create_bonded_device_result *res = parsed_result;
5357 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5360 if (test_done == 0) {
5361 printf("Please stop forwarding first\n");
5365 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5368 /* Create a new bonded device. */
5369 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5371 printf("\t Failed to create bonded device.\n");
5374 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5377 /* Update number of ports */
5378 nb_ports = rte_eth_dev_count();
5379 reconfig(port_id, res->socket);
5380 rte_eth_promiscuous_enable(port_id);
5385 cmdline_parse_token_string_t cmd_createbonded_device_create =
5386 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5388 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5389 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5391 cmdline_parse_token_string_t cmd_createbonded_device_device =
5392 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5394 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5395 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5397 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5398 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5401 cmdline_parse_inst_t cmd_create_bonded_device = {
5402 .f = cmd_create_bonded_device_parsed,
5403 .help_str = "create bonded device <mode> <socket>: "
5404 "Create a new bonded device with specific bonding mode and socket",
5407 (void *)&cmd_createbonded_device_create,
5408 (void *)&cmd_createbonded_device_bonded,
5409 (void *)&cmd_createbonded_device_device,
5410 (void *)&cmd_createbonded_device_mode,
5411 (void *)&cmd_createbonded_device_socket,
5416 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5417 struct cmd_set_bond_mac_addr_result {
5418 cmdline_fixed_string_t set;
5419 cmdline_fixed_string_t bonding;
5420 cmdline_fixed_string_t mac_addr;
5422 struct ether_addr address;
5425 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5426 __attribute__((unused)) struct cmdline *cl,
5427 __attribute__((unused)) void *data)
5429 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5432 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5435 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5437 /* check the return value and print it if is < 0 */
5439 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5442 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5443 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5444 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5445 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5447 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5448 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5450 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5451 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5453 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5454 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5456 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5457 .f = cmd_set_bond_mac_addr_parsed,
5459 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5461 (void *)&cmd_set_bond_mac_addr_set,
5462 (void *)&cmd_set_bond_mac_addr_bonding,
5463 (void *)&cmd_set_bond_mac_addr_mac,
5464 (void *)&cmd_set_bond_mac_addr_portnum,
5465 (void *)&cmd_set_bond_mac_addr_addr,
5471 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5472 struct cmd_set_bond_mon_period_result {
5473 cmdline_fixed_string_t set;
5474 cmdline_fixed_string_t bonding;
5475 cmdline_fixed_string_t mon_period;
5480 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5481 __attribute__((unused)) struct cmdline *cl,
5482 __attribute__((unused)) void *data)
5484 struct cmd_set_bond_mon_period_result *res = parsed_result;
5487 if (res->port_num >= nb_ports) {
5488 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5492 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5494 /* check the return value and print it if is < 0 */
5496 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5499 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5500 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5502 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5503 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5504 bonding, "bonding");
5505 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5506 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5507 mon_period, "mon_period");
5508 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5509 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5511 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5512 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5515 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5516 .f = cmd_set_bond_mon_period_parsed,
5518 .help_str = "set bonding mon_period <port_id> <period_ms>",
5520 (void *)&cmd_set_bond_mon_period_set,
5521 (void *)&cmd_set_bond_mon_period_bonding,
5522 (void *)&cmd_set_bond_mon_period_mon_period,
5523 (void *)&cmd_set_bond_mon_period_portnum,
5524 (void *)&cmd_set_bond_mon_period_period_ms,
5531 struct cmd_set_bonding_agg_mode_policy_result {
5532 cmdline_fixed_string_t set;
5533 cmdline_fixed_string_t bonding;
5534 cmdline_fixed_string_t agg_mode;
5536 cmdline_fixed_string_t policy;
5541 cmd_set_bonding_agg_mode(void *parsed_result,
5542 __attribute__((unused)) struct cmdline *cl,
5543 __attribute__((unused)) void *data)
5545 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5546 uint8_t policy = AGG_BANDWIDTH;
5548 if (res->port_num >= nb_ports) {
5549 printf("Port id %d must be less than %d\n",
5550 res->port_num, nb_ports);
5554 if (!strcmp(res->policy, "bandwidth"))
5555 policy = AGG_BANDWIDTH;
5556 else if (!strcmp(res->policy, "stable"))
5557 policy = AGG_STABLE;
5558 else if (!strcmp(res->policy, "count"))
5561 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5565 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5566 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5568 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5569 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5570 bonding, "bonding");
5572 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5573 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5574 agg_mode, "agg_mode");
5576 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5577 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5580 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5581 TOKEN_STRING_INITIALIZER(
5582 struct cmd_set_bonding_balance_xmit_policy_result,
5583 policy, "stable#bandwidth#count");
5585 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5586 .f = cmd_set_bonding_agg_mode,
5588 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5590 (void *)&cmd_set_bonding_agg_mode_set,
5591 (void *)&cmd_set_bonding_agg_mode_bonding,
5592 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5593 (void *)&cmd_set_bonding_agg_mode_portnum,
5594 (void *)&cmd_set_bonding_agg_mode_policy_string,
5600 #endif /* RTE_LIBRTE_PMD_BOND */
5602 /* *** SET FORWARDING MODE *** */
5603 struct cmd_set_fwd_mode_result {
5604 cmdline_fixed_string_t set;
5605 cmdline_fixed_string_t fwd;
5606 cmdline_fixed_string_t mode;
5609 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5610 __attribute__((unused)) struct cmdline *cl,
5611 __attribute__((unused)) void *data)
5613 struct cmd_set_fwd_mode_result *res = parsed_result;
5616 set_pkt_forwarding_mode(res->mode);
5619 cmdline_parse_token_string_t cmd_setfwd_set =
5620 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5621 cmdline_parse_token_string_t cmd_setfwd_fwd =
5622 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5623 cmdline_parse_token_string_t cmd_setfwd_mode =
5624 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5625 "" /* defined at init */);
5627 cmdline_parse_inst_t cmd_set_fwd_mode = {
5628 .f = cmd_set_fwd_mode_parsed,
5630 .help_str = NULL, /* defined at init */
5632 (void *)&cmd_setfwd_set,
5633 (void *)&cmd_setfwd_fwd,
5634 (void *)&cmd_setfwd_mode,
5639 static void cmd_set_fwd_mode_init(void)
5642 static char token[128];
5643 static char help[256];
5644 cmdline_parse_token_string_t *token_struct;
5646 modes = list_pkt_forwarding_modes();
5647 snprintf(help, sizeof(help), "set fwd %s: "
5648 "Set packet forwarding mode", modes);
5649 cmd_set_fwd_mode.help_str = help;
5651 /* string token separator is # */
5652 for (c = token; *modes != '\0'; modes++)
5657 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5658 token_struct->string_data.str = token;
5661 /* *** SET RETRY FORWARDING MODE *** */
5662 struct cmd_set_fwd_retry_mode_result {
5663 cmdline_fixed_string_t set;
5664 cmdline_fixed_string_t fwd;
5665 cmdline_fixed_string_t mode;
5666 cmdline_fixed_string_t retry;
5669 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5670 __attribute__((unused)) struct cmdline *cl,
5671 __attribute__((unused)) void *data)
5673 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5676 set_pkt_forwarding_mode(res->mode);
5679 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5680 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5682 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5683 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5685 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5686 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5688 "" /* defined at init */);
5689 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5690 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5693 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5694 .f = cmd_set_fwd_retry_mode_parsed,
5696 .help_str = NULL, /* defined at init */
5698 (void *)&cmd_setfwd_retry_set,
5699 (void *)&cmd_setfwd_retry_fwd,
5700 (void *)&cmd_setfwd_retry_mode,
5701 (void *)&cmd_setfwd_retry_retry,
5706 static void cmd_set_fwd_retry_mode_init(void)
5709 static char token[128];
5710 static char help[256];
5711 cmdline_parse_token_string_t *token_struct;
5713 modes = list_pkt_forwarding_retry_modes();
5714 snprintf(help, sizeof(help), "set fwd %s retry: "
5715 "Set packet forwarding mode with retry", modes);
5716 cmd_set_fwd_retry_mode.help_str = help;
5718 /* string token separator is # */
5719 for (c = token; *modes != '\0'; modes++)
5724 token_struct = (cmdline_parse_token_string_t *)
5725 cmd_set_fwd_retry_mode.tokens[2];
5726 token_struct->string_data.str = token;
5729 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5730 struct cmd_set_burst_tx_retry_result {
5731 cmdline_fixed_string_t set;
5732 cmdline_fixed_string_t burst;
5733 cmdline_fixed_string_t tx;
5734 cmdline_fixed_string_t delay;
5736 cmdline_fixed_string_t retry;
5740 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5741 __attribute__((unused)) struct cmdline *cl,
5742 __attribute__((unused)) void *data)
5744 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5746 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5747 && !strcmp(res->tx, "tx")) {
5748 if (!strcmp(res->delay, "delay"))
5749 burst_tx_delay_time = res->time;
5750 if (!strcmp(res->retry, "retry"))
5751 burst_tx_retry_num = res->retry_num;
5756 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5757 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5758 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5759 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5761 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5762 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5763 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5765 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5766 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5767 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5768 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5769 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5770 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5772 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5773 .f = cmd_set_burst_tx_retry_parsed,
5774 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5776 (void *)&cmd_set_burst_tx_retry_set,
5777 (void *)&cmd_set_burst_tx_retry_burst,
5778 (void *)&cmd_set_burst_tx_retry_tx,
5779 (void *)&cmd_set_burst_tx_retry_delay,
5780 (void *)&cmd_set_burst_tx_retry_time,
5781 (void *)&cmd_set_burst_tx_retry_retry,
5782 (void *)&cmd_set_burst_tx_retry_retry_num,
5787 /* *** SET PROMISC MODE *** */
5788 struct cmd_set_promisc_mode_result {
5789 cmdline_fixed_string_t set;
5790 cmdline_fixed_string_t promisc;
5791 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5792 uint16_t port_num; /* valid if "allports" argument == 0 */
5793 cmdline_fixed_string_t mode;
5796 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5797 __attribute__((unused)) struct cmdline *cl,
5800 struct cmd_set_promisc_mode_result *res = parsed_result;
5804 if (!strcmp(res->mode, "on"))
5811 RTE_ETH_FOREACH_DEV(i) {
5813 rte_eth_promiscuous_enable(i);
5815 rte_eth_promiscuous_disable(i);
5820 rte_eth_promiscuous_enable(res->port_num);
5822 rte_eth_promiscuous_disable(res->port_num);
5826 cmdline_parse_token_string_t cmd_setpromisc_set =
5827 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5828 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5829 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5831 cmdline_parse_token_string_t cmd_setpromisc_portall =
5832 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5834 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5835 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5837 cmdline_parse_token_string_t cmd_setpromisc_mode =
5838 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5841 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5842 .f = cmd_set_promisc_mode_parsed,
5844 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5846 (void *)&cmd_setpromisc_set,
5847 (void *)&cmd_setpromisc_promisc,
5848 (void *)&cmd_setpromisc_portall,
5849 (void *)&cmd_setpromisc_mode,
5854 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5855 .f = cmd_set_promisc_mode_parsed,
5857 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5859 (void *)&cmd_setpromisc_set,
5860 (void *)&cmd_setpromisc_promisc,
5861 (void *)&cmd_setpromisc_portnum,
5862 (void *)&cmd_setpromisc_mode,
5867 /* *** SET ALLMULTI MODE *** */
5868 struct cmd_set_allmulti_mode_result {
5869 cmdline_fixed_string_t set;
5870 cmdline_fixed_string_t allmulti;
5871 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5872 uint16_t port_num; /* valid if "allports" argument == 0 */
5873 cmdline_fixed_string_t mode;
5876 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5877 __attribute__((unused)) struct cmdline *cl,
5880 struct cmd_set_allmulti_mode_result *res = parsed_result;
5884 if (!strcmp(res->mode, "on"))
5891 RTE_ETH_FOREACH_DEV(i) {
5893 rte_eth_allmulticast_enable(i);
5895 rte_eth_allmulticast_disable(i);
5900 rte_eth_allmulticast_enable(res->port_num);
5902 rte_eth_allmulticast_disable(res->port_num);
5906 cmdline_parse_token_string_t cmd_setallmulti_set =
5907 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5908 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5911 cmdline_parse_token_string_t cmd_setallmulti_portall =
5912 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5914 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5915 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5917 cmdline_parse_token_string_t cmd_setallmulti_mode =
5918 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5921 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5922 .f = cmd_set_allmulti_mode_parsed,
5924 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5926 (void *)&cmd_setallmulti_set,
5927 (void *)&cmd_setallmulti_allmulti,
5928 (void *)&cmd_setallmulti_portall,
5929 (void *)&cmd_setallmulti_mode,
5934 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5935 .f = cmd_set_allmulti_mode_parsed,
5937 .help_str = "set allmulti <port_id> on|off: "
5938 "Set allmulti mode on port_id",
5940 (void *)&cmd_setallmulti_set,
5941 (void *)&cmd_setallmulti_allmulti,
5942 (void *)&cmd_setallmulti_portnum,
5943 (void *)&cmd_setallmulti_mode,
5948 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5949 struct cmd_link_flow_ctrl_set_result {
5950 cmdline_fixed_string_t set;
5951 cmdline_fixed_string_t flow_ctrl;
5952 cmdline_fixed_string_t rx;
5953 cmdline_fixed_string_t rx_lfc_mode;
5954 cmdline_fixed_string_t tx;
5955 cmdline_fixed_string_t tx_lfc_mode;
5956 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5957 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5958 cmdline_fixed_string_t autoneg_str;
5959 cmdline_fixed_string_t autoneg;
5960 cmdline_fixed_string_t hw_str;
5961 uint32_t high_water;
5962 cmdline_fixed_string_t lw_str;
5964 cmdline_fixed_string_t pt_str;
5965 uint16_t pause_time;
5966 cmdline_fixed_string_t xon_str;
5971 cmdline_parse_token_string_t cmd_lfc_set_set =
5972 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5974 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5975 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5976 flow_ctrl, "flow_ctrl");
5977 cmdline_parse_token_string_t cmd_lfc_set_rx =
5978 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5980 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5981 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5982 rx_lfc_mode, "on#off");
5983 cmdline_parse_token_string_t cmd_lfc_set_tx =
5984 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5986 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5987 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5988 tx_lfc_mode, "on#off");
5989 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5990 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5991 hw_str, "high_water");
5992 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5993 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5994 high_water, UINT32);
5995 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5996 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5997 lw_str, "low_water");
5998 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5999 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6001 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6002 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6003 pt_str, "pause_time");
6004 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6005 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6006 pause_time, UINT16);
6007 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6008 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6009 xon_str, "send_xon");
6010 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6011 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6013 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6014 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6015 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6016 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6017 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6018 mac_ctrl_frame_fwd_mode, "on#off");
6019 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6020 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6021 autoneg_str, "autoneg");
6022 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6023 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6025 cmdline_parse_token_num_t cmd_lfc_set_portid =
6026 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6029 /* forward declaration */
6031 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6034 cmdline_parse_inst_t cmd_link_flow_control_set = {
6035 .f = cmd_link_flow_ctrl_set_parsed,
6037 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6038 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6039 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6041 (void *)&cmd_lfc_set_set,
6042 (void *)&cmd_lfc_set_flow_ctrl,
6043 (void *)&cmd_lfc_set_rx,
6044 (void *)&cmd_lfc_set_rx_mode,
6045 (void *)&cmd_lfc_set_tx,
6046 (void *)&cmd_lfc_set_tx_mode,
6047 (void *)&cmd_lfc_set_high_water,
6048 (void *)&cmd_lfc_set_low_water,
6049 (void *)&cmd_lfc_set_pause_time,
6050 (void *)&cmd_lfc_set_send_xon,
6051 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6052 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6053 (void *)&cmd_lfc_set_autoneg_str,
6054 (void *)&cmd_lfc_set_autoneg,
6055 (void *)&cmd_lfc_set_portid,
6060 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6061 .f = cmd_link_flow_ctrl_set_parsed,
6062 .data = (void *)&cmd_link_flow_control_set_rx,
6063 .help_str = "set flow_ctrl rx on|off <port_id>: "
6064 "Change rx flow control parameter",
6066 (void *)&cmd_lfc_set_set,
6067 (void *)&cmd_lfc_set_flow_ctrl,
6068 (void *)&cmd_lfc_set_rx,
6069 (void *)&cmd_lfc_set_rx_mode,
6070 (void *)&cmd_lfc_set_portid,
6075 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6076 .f = cmd_link_flow_ctrl_set_parsed,
6077 .data = (void *)&cmd_link_flow_control_set_tx,
6078 .help_str = "set flow_ctrl tx on|off <port_id>: "
6079 "Change tx flow control parameter",
6081 (void *)&cmd_lfc_set_set,
6082 (void *)&cmd_lfc_set_flow_ctrl,
6083 (void *)&cmd_lfc_set_tx,
6084 (void *)&cmd_lfc_set_tx_mode,
6085 (void *)&cmd_lfc_set_portid,
6090 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6091 .f = cmd_link_flow_ctrl_set_parsed,
6092 .data = (void *)&cmd_link_flow_control_set_hw,
6093 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6094 "Change high water flow control parameter",
6096 (void *)&cmd_lfc_set_set,
6097 (void *)&cmd_lfc_set_flow_ctrl,
6098 (void *)&cmd_lfc_set_high_water_str,
6099 (void *)&cmd_lfc_set_high_water,
6100 (void *)&cmd_lfc_set_portid,
6105 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6106 .f = cmd_link_flow_ctrl_set_parsed,
6107 .data = (void *)&cmd_link_flow_control_set_lw,
6108 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6109 "Change low water flow control parameter",
6111 (void *)&cmd_lfc_set_set,
6112 (void *)&cmd_lfc_set_flow_ctrl,
6113 (void *)&cmd_lfc_set_low_water_str,
6114 (void *)&cmd_lfc_set_low_water,
6115 (void *)&cmd_lfc_set_portid,
6120 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6121 .f = cmd_link_flow_ctrl_set_parsed,
6122 .data = (void *)&cmd_link_flow_control_set_pt,
6123 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6124 "Change pause time flow control parameter",
6126 (void *)&cmd_lfc_set_set,
6127 (void *)&cmd_lfc_set_flow_ctrl,
6128 (void *)&cmd_lfc_set_pause_time_str,
6129 (void *)&cmd_lfc_set_pause_time,
6130 (void *)&cmd_lfc_set_portid,
6135 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6136 .f = cmd_link_flow_ctrl_set_parsed,
6137 .data = (void *)&cmd_link_flow_control_set_xon,
6138 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6139 "Change send_xon flow control parameter",
6141 (void *)&cmd_lfc_set_set,
6142 (void *)&cmd_lfc_set_flow_ctrl,
6143 (void *)&cmd_lfc_set_send_xon_str,
6144 (void *)&cmd_lfc_set_send_xon,
6145 (void *)&cmd_lfc_set_portid,
6150 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6151 .f = cmd_link_flow_ctrl_set_parsed,
6152 .data = (void *)&cmd_link_flow_control_set_macfwd,
6153 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6154 "Change mac ctrl fwd flow control parameter",
6156 (void *)&cmd_lfc_set_set,
6157 (void *)&cmd_lfc_set_flow_ctrl,
6158 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6159 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6160 (void *)&cmd_lfc_set_portid,
6165 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6166 .f = cmd_link_flow_ctrl_set_parsed,
6167 .data = (void *)&cmd_link_flow_control_set_autoneg,
6168 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6169 "Change autoneg flow control parameter",
6171 (void *)&cmd_lfc_set_set,
6172 (void *)&cmd_lfc_set_flow_ctrl,
6173 (void *)&cmd_lfc_set_autoneg_str,
6174 (void *)&cmd_lfc_set_autoneg,
6175 (void *)&cmd_lfc_set_portid,
6181 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6182 __attribute__((unused)) struct cmdline *cl,
6185 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6186 cmdline_parse_inst_t *cmd = data;
6187 struct rte_eth_fc_conf fc_conf;
6193 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6194 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6195 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6196 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6198 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6199 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6202 /* Partial command line, retrieve current configuration */
6204 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6206 printf("cannot get current flow ctrl parameters, return"
6207 "code = %d\n", ret);
6211 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6212 (fc_conf.mode == RTE_FC_FULL))
6214 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6215 (fc_conf.mode == RTE_FC_FULL))
6219 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6220 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6222 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6223 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6225 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6227 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6228 fc_conf.high_water = res->high_water;
6230 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6231 fc_conf.low_water = res->low_water;
6233 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6234 fc_conf.pause_time = res->pause_time;
6236 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6237 fc_conf.send_xon = res->send_xon;
6239 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6240 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6241 fc_conf.mac_ctrl_frame_fwd = 1;
6243 fc_conf.mac_ctrl_frame_fwd = 0;
6246 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6247 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6249 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6251 printf("bad flow contrl parameter, return code = %d \n", ret);
6254 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6255 struct cmd_priority_flow_ctrl_set_result {
6256 cmdline_fixed_string_t set;
6257 cmdline_fixed_string_t pfc_ctrl;
6258 cmdline_fixed_string_t rx;
6259 cmdline_fixed_string_t rx_pfc_mode;
6260 cmdline_fixed_string_t tx;
6261 cmdline_fixed_string_t tx_pfc_mode;
6262 uint32_t high_water;
6264 uint16_t pause_time;
6270 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6271 __attribute__((unused)) struct cmdline *cl,
6272 __attribute__((unused)) void *data)
6274 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6275 struct rte_eth_pfc_conf pfc_conf;
6276 int rx_fc_enable, tx_fc_enable;
6280 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6281 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6282 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6283 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6285 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6286 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6289 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6290 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6291 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6292 pfc_conf.fc.high_water = res->high_water;
6293 pfc_conf.fc.low_water = res->low_water;
6294 pfc_conf.fc.pause_time = res->pause_time;
6295 pfc_conf.priority = res->priority;
6297 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6299 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6302 cmdline_parse_token_string_t cmd_pfc_set_set =
6303 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6305 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6306 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6307 pfc_ctrl, "pfc_ctrl");
6308 cmdline_parse_token_string_t cmd_pfc_set_rx =
6309 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6311 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6312 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6313 rx_pfc_mode, "on#off");
6314 cmdline_parse_token_string_t cmd_pfc_set_tx =
6315 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6317 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6318 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6319 tx_pfc_mode, "on#off");
6320 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6321 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6322 high_water, UINT32);
6323 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6324 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6326 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6327 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6328 pause_time, UINT16);
6329 cmdline_parse_token_num_t cmd_pfc_set_priority =
6330 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6332 cmdline_parse_token_num_t cmd_pfc_set_portid =
6333 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6336 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6337 .f = cmd_priority_flow_ctrl_set_parsed,
6339 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6340 "<pause_time> <priority> <port_id>: "
6341 "Configure the Ethernet priority flow control",
6343 (void *)&cmd_pfc_set_set,
6344 (void *)&cmd_pfc_set_flow_ctrl,
6345 (void *)&cmd_pfc_set_rx,
6346 (void *)&cmd_pfc_set_rx_mode,
6347 (void *)&cmd_pfc_set_tx,
6348 (void *)&cmd_pfc_set_tx_mode,
6349 (void *)&cmd_pfc_set_high_water,
6350 (void *)&cmd_pfc_set_low_water,
6351 (void *)&cmd_pfc_set_pause_time,
6352 (void *)&cmd_pfc_set_priority,
6353 (void *)&cmd_pfc_set_portid,
6358 /* *** RESET CONFIGURATION *** */
6359 struct cmd_reset_result {
6360 cmdline_fixed_string_t reset;
6361 cmdline_fixed_string_t def;
6364 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6366 __attribute__((unused)) void *data)
6368 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6369 set_def_fwd_config();
6372 cmdline_parse_token_string_t cmd_reset_set =
6373 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6374 cmdline_parse_token_string_t cmd_reset_def =
6375 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6378 cmdline_parse_inst_t cmd_reset = {
6379 .f = cmd_reset_parsed,
6381 .help_str = "set default: Reset default forwarding configuration",
6383 (void *)&cmd_reset_set,
6384 (void *)&cmd_reset_def,
6389 /* *** START FORWARDING *** */
6390 struct cmd_start_result {
6391 cmdline_fixed_string_t start;
6394 cmdline_parse_token_string_t cmd_start_start =
6395 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6397 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6398 __attribute__((unused)) struct cmdline *cl,
6399 __attribute__((unused)) void *data)
6401 start_packet_forwarding(0);
6404 cmdline_parse_inst_t cmd_start = {
6405 .f = cmd_start_parsed,
6407 .help_str = "start: Start packet forwarding",
6409 (void *)&cmd_start_start,
6414 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6415 struct cmd_start_tx_first_result {
6416 cmdline_fixed_string_t start;
6417 cmdline_fixed_string_t tx_first;
6421 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6422 __attribute__((unused)) struct cmdline *cl,
6423 __attribute__((unused)) void *data)
6425 start_packet_forwarding(1);
6428 cmdline_parse_token_string_t cmd_start_tx_first_start =
6429 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6431 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6432 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6433 tx_first, "tx_first");
6435 cmdline_parse_inst_t cmd_start_tx_first = {
6436 .f = cmd_start_tx_first_parsed,
6438 .help_str = "start tx_first: Start packet forwarding, "
6439 "after sending 1 burst of packets",
6441 (void *)&cmd_start_tx_first_start,
6442 (void *)&cmd_start_tx_first_tx_first,
6447 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6448 struct cmd_start_tx_first_n_result {
6449 cmdline_fixed_string_t start;
6450 cmdline_fixed_string_t tx_first;
6455 cmd_start_tx_first_n_parsed(void *parsed_result,
6456 __attribute__((unused)) struct cmdline *cl,
6457 __attribute__((unused)) void *data)
6459 struct cmd_start_tx_first_n_result *res = parsed_result;
6461 start_packet_forwarding(res->tx_num);
6464 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6465 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6467 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6468 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6469 tx_first, "tx_first");
6470 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6471 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6474 cmdline_parse_inst_t cmd_start_tx_first_n = {
6475 .f = cmd_start_tx_first_n_parsed,
6477 .help_str = "start tx_first <num>: "
6478 "packet forwarding, after sending <num> bursts of packets",
6480 (void *)&cmd_start_tx_first_n_start,
6481 (void *)&cmd_start_tx_first_n_tx_first,
6482 (void *)&cmd_start_tx_first_n_tx_num,
6487 /* *** SET LINK UP *** */
6488 struct cmd_set_link_up_result {
6489 cmdline_fixed_string_t set;
6490 cmdline_fixed_string_t link_up;
6491 cmdline_fixed_string_t port;
6495 cmdline_parse_token_string_t cmd_set_link_up_set =
6496 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6497 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6498 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6500 cmdline_parse_token_string_t cmd_set_link_up_port =
6501 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6502 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6503 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6505 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6506 __attribute__((unused)) struct cmdline *cl,
6507 __attribute__((unused)) void *data)
6509 struct cmd_set_link_up_result *res = parsed_result;
6510 dev_set_link_up(res->port_id);
6513 cmdline_parse_inst_t cmd_set_link_up = {
6514 .f = cmd_set_link_up_parsed,
6516 .help_str = "set link-up port <port id>",
6518 (void *)&cmd_set_link_up_set,
6519 (void *)&cmd_set_link_up_link_up,
6520 (void *)&cmd_set_link_up_port,
6521 (void *)&cmd_set_link_up_port_id,
6526 /* *** SET LINK DOWN *** */
6527 struct cmd_set_link_down_result {
6528 cmdline_fixed_string_t set;
6529 cmdline_fixed_string_t link_down;
6530 cmdline_fixed_string_t port;
6534 cmdline_parse_token_string_t cmd_set_link_down_set =
6535 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6536 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6537 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6539 cmdline_parse_token_string_t cmd_set_link_down_port =
6540 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6541 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6542 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6544 static void cmd_set_link_down_parsed(
6545 __attribute__((unused)) void *parsed_result,
6546 __attribute__((unused)) struct cmdline *cl,
6547 __attribute__((unused)) void *data)
6549 struct cmd_set_link_down_result *res = parsed_result;
6550 dev_set_link_down(res->port_id);
6553 cmdline_parse_inst_t cmd_set_link_down = {
6554 .f = cmd_set_link_down_parsed,
6556 .help_str = "set link-down port <port id>",
6558 (void *)&cmd_set_link_down_set,
6559 (void *)&cmd_set_link_down_link_down,
6560 (void *)&cmd_set_link_down_port,
6561 (void *)&cmd_set_link_down_port_id,
6566 /* *** SHOW CFG *** */
6567 struct cmd_showcfg_result {
6568 cmdline_fixed_string_t show;
6569 cmdline_fixed_string_t cfg;
6570 cmdline_fixed_string_t what;
6573 static void cmd_showcfg_parsed(void *parsed_result,
6574 __attribute__((unused)) struct cmdline *cl,
6575 __attribute__((unused)) void *data)
6577 struct cmd_showcfg_result *res = parsed_result;
6578 if (!strcmp(res->what, "rxtx"))
6579 rxtx_config_display();
6580 else if (!strcmp(res->what, "cores"))
6581 fwd_lcores_config_display();
6582 else if (!strcmp(res->what, "fwd"))
6583 pkt_fwd_config_display(&cur_fwd_config);
6584 else if (!strcmp(res->what, "txpkts"))
6585 show_tx_pkt_segments();
6588 cmdline_parse_token_string_t cmd_showcfg_show =
6589 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6590 cmdline_parse_token_string_t cmd_showcfg_port =
6591 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6592 cmdline_parse_token_string_t cmd_showcfg_what =
6593 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6594 "rxtx#cores#fwd#txpkts");
6596 cmdline_parse_inst_t cmd_showcfg = {
6597 .f = cmd_showcfg_parsed,
6599 .help_str = "show config rxtx|cores|fwd|txpkts",
6601 (void *)&cmd_showcfg_show,
6602 (void *)&cmd_showcfg_port,
6603 (void *)&cmd_showcfg_what,
6608 /* *** SHOW ALL PORT INFO *** */
6609 struct cmd_showportall_result {
6610 cmdline_fixed_string_t show;
6611 cmdline_fixed_string_t port;
6612 cmdline_fixed_string_t what;
6613 cmdline_fixed_string_t all;
6616 static void cmd_showportall_parsed(void *parsed_result,
6617 __attribute__((unused)) struct cmdline *cl,
6618 __attribute__((unused)) void *data)
6622 struct cmd_showportall_result *res = parsed_result;
6623 if (!strcmp(res->show, "clear")) {
6624 if (!strcmp(res->what, "stats"))
6625 RTE_ETH_FOREACH_DEV(i)
6627 else if (!strcmp(res->what, "xstats"))
6628 RTE_ETH_FOREACH_DEV(i)
6629 nic_xstats_clear(i);
6630 } else if (!strcmp(res->what, "info"))
6631 RTE_ETH_FOREACH_DEV(i)
6632 port_infos_display(i);
6633 else if (!strcmp(res->what, "stats"))
6634 RTE_ETH_FOREACH_DEV(i)
6635 nic_stats_display(i);
6636 else if (!strcmp(res->what, "xstats"))
6637 RTE_ETH_FOREACH_DEV(i)
6638 nic_xstats_display(i);
6639 else if (!strcmp(res->what, "fdir"))
6640 RTE_ETH_FOREACH_DEV(i)
6642 else if (!strcmp(res->what, "stat_qmap"))
6643 RTE_ETH_FOREACH_DEV(i)
6644 nic_stats_mapping_display(i);
6645 else if (!strcmp(res->what, "dcb_tc"))
6646 RTE_ETH_FOREACH_DEV(i)
6647 port_dcb_info_display(i);
6648 else if (!strcmp(res->what, "cap"))
6649 RTE_ETH_FOREACH_DEV(i)
6650 port_offload_cap_display(i);
6653 cmdline_parse_token_string_t cmd_showportall_show =
6654 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6656 cmdline_parse_token_string_t cmd_showportall_port =
6657 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6658 cmdline_parse_token_string_t cmd_showportall_what =
6659 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6660 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6661 cmdline_parse_token_string_t cmd_showportall_all =
6662 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6663 cmdline_parse_inst_t cmd_showportall = {
6664 .f = cmd_showportall_parsed,
6666 .help_str = "show|clear port "
6667 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6669 (void *)&cmd_showportall_show,
6670 (void *)&cmd_showportall_port,
6671 (void *)&cmd_showportall_what,
6672 (void *)&cmd_showportall_all,
6677 /* *** SHOW PORT INFO *** */
6678 struct cmd_showport_result {
6679 cmdline_fixed_string_t show;
6680 cmdline_fixed_string_t port;
6681 cmdline_fixed_string_t what;
6685 static void cmd_showport_parsed(void *parsed_result,
6686 __attribute__((unused)) struct cmdline *cl,
6687 __attribute__((unused)) void *data)
6689 struct cmd_showport_result *res = parsed_result;
6690 if (!strcmp(res->show, "clear")) {
6691 if (!strcmp(res->what, "stats"))
6692 nic_stats_clear(res->portnum);
6693 else if (!strcmp(res->what, "xstats"))
6694 nic_xstats_clear(res->portnum);
6695 } else if (!strcmp(res->what, "info"))
6696 port_infos_display(res->portnum);
6697 else if (!strcmp(res->what, "stats"))
6698 nic_stats_display(res->portnum);
6699 else if (!strcmp(res->what, "xstats"))
6700 nic_xstats_display(res->portnum);
6701 else if (!strcmp(res->what, "fdir"))
6702 fdir_get_infos(res->portnum);
6703 else if (!strcmp(res->what, "stat_qmap"))
6704 nic_stats_mapping_display(res->portnum);
6705 else if (!strcmp(res->what, "dcb_tc"))
6706 port_dcb_info_display(res->portnum);
6707 else if (!strcmp(res->what, "cap"))
6708 port_offload_cap_display(res->portnum);
6711 cmdline_parse_token_string_t cmd_showport_show =
6712 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6714 cmdline_parse_token_string_t cmd_showport_port =
6715 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6716 cmdline_parse_token_string_t cmd_showport_what =
6717 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6718 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6719 cmdline_parse_token_num_t cmd_showport_portnum =
6720 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6722 cmdline_parse_inst_t cmd_showport = {
6723 .f = cmd_showport_parsed,
6725 .help_str = "show|clear port "
6726 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6729 (void *)&cmd_showport_show,
6730 (void *)&cmd_showport_port,
6731 (void *)&cmd_showport_what,
6732 (void *)&cmd_showport_portnum,
6737 /* *** SHOW QUEUE INFO *** */
6738 struct cmd_showqueue_result {
6739 cmdline_fixed_string_t show;
6740 cmdline_fixed_string_t type;
6741 cmdline_fixed_string_t what;
6747 cmd_showqueue_parsed(void *parsed_result,
6748 __attribute__((unused)) struct cmdline *cl,
6749 __attribute__((unused)) void *data)
6751 struct cmd_showqueue_result *res = parsed_result;
6753 if (!strcmp(res->type, "rxq"))
6754 rx_queue_infos_display(res->portnum, res->queuenum);
6755 else if (!strcmp(res->type, "txq"))
6756 tx_queue_infos_display(res->portnum, res->queuenum);
6759 cmdline_parse_token_string_t cmd_showqueue_show =
6760 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6761 cmdline_parse_token_string_t cmd_showqueue_type =
6762 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6763 cmdline_parse_token_string_t cmd_showqueue_what =
6764 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6765 cmdline_parse_token_num_t cmd_showqueue_portnum =
6766 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6767 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6768 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6770 cmdline_parse_inst_t cmd_showqueue = {
6771 .f = cmd_showqueue_parsed,
6773 .help_str = "show rxq|txq info <port_id> <queue_id>",
6775 (void *)&cmd_showqueue_show,
6776 (void *)&cmd_showqueue_type,
6777 (void *)&cmd_showqueue_what,
6778 (void *)&cmd_showqueue_portnum,
6779 (void *)&cmd_showqueue_queuenum,
6784 /* *** READ PORT REGISTER *** */
6785 struct cmd_read_reg_result {
6786 cmdline_fixed_string_t read;
6787 cmdline_fixed_string_t reg;
6793 cmd_read_reg_parsed(void *parsed_result,
6794 __attribute__((unused)) struct cmdline *cl,
6795 __attribute__((unused)) void *data)
6797 struct cmd_read_reg_result *res = parsed_result;
6798 port_reg_display(res->port_id, res->reg_off);
6801 cmdline_parse_token_string_t cmd_read_reg_read =
6802 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6803 cmdline_parse_token_string_t cmd_read_reg_reg =
6804 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6805 cmdline_parse_token_num_t cmd_read_reg_port_id =
6806 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6807 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6808 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6810 cmdline_parse_inst_t cmd_read_reg = {
6811 .f = cmd_read_reg_parsed,
6813 .help_str = "read reg <port_id> <reg_off>",
6815 (void *)&cmd_read_reg_read,
6816 (void *)&cmd_read_reg_reg,
6817 (void *)&cmd_read_reg_port_id,
6818 (void *)&cmd_read_reg_reg_off,
6823 /* *** READ PORT REGISTER BIT FIELD *** */
6824 struct cmd_read_reg_bit_field_result {
6825 cmdline_fixed_string_t read;
6826 cmdline_fixed_string_t regfield;
6834 cmd_read_reg_bit_field_parsed(void *parsed_result,
6835 __attribute__((unused)) struct cmdline *cl,
6836 __attribute__((unused)) void *data)
6838 struct cmd_read_reg_bit_field_result *res = parsed_result;
6839 port_reg_bit_field_display(res->port_id, res->reg_off,
6840 res->bit1_pos, res->bit2_pos);
6843 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6844 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6846 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6847 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6848 regfield, "regfield");
6849 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6850 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6852 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6853 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6855 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6856 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6858 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6859 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6862 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6863 .f = cmd_read_reg_bit_field_parsed,
6865 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6866 "Read register bit field between bit_x and bit_y included",
6868 (void *)&cmd_read_reg_bit_field_read,
6869 (void *)&cmd_read_reg_bit_field_regfield,
6870 (void *)&cmd_read_reg_bit_field_port_id,
6871 (void *)&cmd_read_reg_bit_field_reg_off,
6872 (void *)&cmd_read_reg_bit_field_bit1_pos,
6873 (void *)&cmd_read_reg_bit_field_bit2_pos,
6878 /* *** READ PORT REGISTER BIT *** */
6879 struct cmd_read_reg_bit_result {
6880 cmdline_fixed_string_t read;
6881 cmdline_fixed_string_t regbit;
6888 cmd_read_reg_bit_parsed(void *parsed_result,
6889 __attribute__((unused)) struct cmdline *cl,
6890 __attribute__((unused)) void *data)
6892 struct cmd_read_reg_bit_result *res = parsed_result;
6893 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6896 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6897 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6898 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6899 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6901 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6902 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6903 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6904 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6905 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6906 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6908 cmdline_parse_inst_t cmd_read_reg_bit = {
6909 .f = cmd_read_reg_bit_parsed,
6911 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6913 (void *)&cmd_read_reg_bit_read,
6914 (void *)&cmd_read_reg_bit_regbit,
6915 (void *)&cmd_read_reg_bit_port_id,
6916 (void *)&cmd_read_reg_bit_reg_off,
6917 (void *)&cmd_read_reg_bit_bit_pos,
6922 /* *** WRITE PORT REGISTER *** */
6923 struct cmd_write_reg_result {
6924 cmdline_fixed_string_t write;
6925 cmdline_fixed_string_t reg;
6932 cmd_write_reg_parsed(void *parsed_result,
6933 __attribute__((unused)) struct cmdline *cl,
6934 __attribute__((unused)) void *data)
6936 struct cmd_write_reg_result *res = parsed_result;
6937 port_reg_set(res->port_id, res->reg_off, res->value);
6940 cmdline_parse_token_string_t cmd_write_reg_write =
6941 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6942 cmdline_parse_token_string_t cmd_write_reg_reg =
6943 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6944 cmdline_parse_token_num_t cmd_write_reg_port_id =
6945 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6946 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6947 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6948 cmdline_parse_token_num_t cmd_write_reg_value =
6949 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6951 cmdline_parse_inst_t cmd_write_reg = {
6952 .f = cmd_write_reg_parsed,
6954 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6956 (void *)&cmd_write_reg_write,
6957 (void *)&cmd_write_reg_reg,
6958 (void *)&cmd_write_reg_port_id,
6959 (void *)&cmd_write_reg_reg_off,
6960 (void *)&cmd_write_reg_value,
6965 /* *** WRITE PORT REGISTER BIT FIELD *** */
6966 struct cmd_write_reg_bit_field_result {
6967 cmdline_fixed_string_t write;
6968 cmdline_fixed_string_t regfield;
6977 cmd_write_reg_bit_field_parsed(void *parsed_result,
6978 __attribute__((unused)) struct cmdline *cl,
6979 __attribute__((unused)) void *data)
6981 struct cmd_write_reg_bit_field_result *res = parsed_result;
6982 port_reg_bit_field_set(res->port_id, res->reg_off,
6983 res->bit1_pos, res->bit2_pos, res->value);
6986 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6987 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6989 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6990 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6991 regfield, "regfield");
6992 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6993 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6995 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6996 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6998 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6999 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7001 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7002 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7004 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7005 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7008 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7009 .f = cmd_write_reg_bit_field_parsed,
7011 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7013 "Set register bit field between bit_x and bit_y included",
7015 (void *)&cmd_write_reg_bit_field_write,
7016 (void *)&cmd_write_reg_bit_field_regfield,
7017 (void *)&cmd_write_reg_bit_field_port_id,
7018 (void *)&cmd_write_reg_bit_field_reg_off,
7019 (void *)&cmd_write_reg_bit_field_bit1_pos,
7020 (void *)&cmd_write_reg_bit_field_bit2_pos,
7021 (void *)&cmd_write_reg_bit_field_value,
7026 /* *** WRITE PORT REGISTER BIT *** */
7027 struct cmd_write_reg_bit_result {
7028 cmdline_fixed_string_t write;
7029 cmdline_fixed_string_t regbit;
7037 cmd_write_reg_bit_parsed(void *parsed_result,
7038 __attribute__((unused)) struct cmdline *cl,
7039 __attribute__((unused)) void *data)
7041 struct cmd_write_reg_bit_result *res = parsed_result;
7042 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7045 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7046 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7048 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7049 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7051 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7052 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7053 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7054 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7055 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7056 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7057 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7058 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7060 cmdline_parse_inst_t cmd_write_reg_bit = {
7061 .f = cmd_write_reg_bit_parsed,
7063 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7066 (void *)&cmd_write_reg_bit_write,
7067 (void *)&cmd_write_reg_bit_regbit,
7068 (void *)&cmd_write_reg_bit_port_id,
7069 (void *)&cmd_write_reg_bit_reg_off,
7070 (void *)&cmd_write_reg_bit_bit_pos,
7071 (void *)&cmd_write_reg_bit_value,
7076 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7077 struct cmd_read_rxd_txd_result {
7078 cmdline_fixed_string_t read;
7079 cmdline_fixed_string_t rxd_txd;
7086 cmd_read_rxd_txd_parsed(void *parsed_result,
7087 __attribute__((unused)) struct cmdline *cl,
7088 __attribute__((unused)) void *data)
7090 struct cmd_read_rxd_txd_result *res = parsed_result;
7092 if (!strcmp(res->rxd_txd, "rxd"))
7093 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7094 else if (!strcmp(res->rxd_txd, "txd"))
7095 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7098 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7099 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7100 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7101 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7103 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7104 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7105 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7106 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7107 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7108 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7110 cmdline_parse_inst_t cmd_read_rxd_txd = {
7111 .f = cmd_read_rxd_txd_parsed,
7113 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7115 (void *)&cmd_read_rxd_txd_read,
7116 (void *)&cmd_read_rxd_txd_rxd_txd,
7117 (void *)&cmd_read_rxd_txd_port_id,
7118 (void *)&cmd_read_rxd_txd_queue_id,
7119 (void *)&cmd_read_rxd_txd_desc_id,
7125 struct cmd_quit_result {
7126 cmdline_fixed_string_t quit;
7129 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7131 __attribute__((unused)) void *data)
7137 cmdline_parse_token_string_t cmd_quit_quit =
7138 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7140 cmdline_parse_inst_t cmd_quit = {
7141 .f = cmd_quit_parsed,
7143 .help_str = "quit: Exit application",
7145 (void *)&cmd_quit_quit,
7150 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7151 struct cmd_mac_addr_result {
7152 cmdline_fixed_string_t mac_addr_cmd;
7153 cmdline_fixed_string_t what;
7155 struct ether_addr address;
7158 static void cmd_mac_addr_parsed(void *parsed_result,
7159 __attribute__((unused)) struct cmdline *cl,
7160 __attribute__((unused)) void *data)
7162 struct cmd_mac_addr_result *res = parsed_result;
7165 if (strcmp(res->what, "add") == 0)
7166 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7167 else if (strcmp(res->what, "set") == 0)
7168 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7171 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7173 /* check the return value and print it if is < 0 */
7175 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7179 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7180 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7182 cmdline_parse_token_string_t cmd_mac_addr_what =
7183 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7185 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7186 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7188 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7189 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7191 cmdline_parse_inst_t cmd_mac_addr = {
7192 .f = cmd_mac_addr_parsed,
7194 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7195 "Add/Remove/Set MAC address on port_id",
7197 (void *)&cmd_mac_addr_cmd,
7198 (void *)&cmd_mac_addr_what,
7199 (void *)&cmd_mac_addr_portnum,
7200 (void *)&cmd_mac_addr_addr,
7205 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7206 struct cmd_eth_peer_result {
7207 cmdline_fixed_string_t set;
7208 cmdline_fixed_string_t eth_peer;
7210 cmdline_fixed_string_t peer_addr;
7213 static void cmd_set_eth_peer_parsed(void *parsed_result,
7214 __attribute__((unused)) struct cmdline *cl,
7215 __attribute__((unused)) void *data)
7217 struct cmd_eth_peer_result *res = parsed_result;
7219 if (test_done == 0) {
7220 printf("Please stop forwarding first\n");
7223 if (!strcmp(res->eth_peer, "eth-peer")) {
7224 set_fwd_eth_peer(res->port_id, res->peer_addr);
7228 cmdline_parse_token_string_t cmd_eth_peer_set =
7229 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7230 cmdline_parse_token_string_t cmd_eth_peer =
7231 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7232 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7233 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7234 cmdline_parse_token_string_t cmd_eth_peer_addr =
7235 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7237 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7238 .f = cmd_set_eth_peer_parsed,
7240 .help_str = "set eth-peer <port_id> <peer_mac>",
7242 (void *)&cmd_eth_peer_set,
7243 (void *)&cmd_eth_peer,
7244 (void *)&cmd_eth_peer_port_id,
7245 (void *)&cmd_eth_peer_addr,
7250 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7251 struct cmd_set_qmap_result {
7252 cmdline_fixed_string_t set;
7253 cmdline_fixed_string_t qmap;
7254 cmdline_fixed_string_t what;
7261 cmd_set_qmap_parsed(void *parsed_result,
7262 __attribute__((unused)) struct cmdline *cl,
7263 __attribute__((unused)) void *data)
7265 struct cmd_set_qmap_result *res = parsed_result;
7266 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7268 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7271 cmdline_parse_token_string_t cmd_setqmap_set =
7272 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7274 cmdline_parse_token_string_t cmd_setqmap_qmap =
7275 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7277 cmdline_parse_token_string_t cmd_setqmap_what =
7278 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7280 cmdline_parse_token_num_t cmd_setqmap_portid =
7281 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7283 cmdline_parse_token_num_t cmd_setqmap_queueid =
7284 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7286 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7287 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7290 cmdline_parse_inst_t cmd_set_qmap = {
7291 .f = cmd_set_qmap_parsed,
7293 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7294 "Set statistics mapping value on tx|rx queue_id of port_id",
7296 (void *)&cmd_setqmap_set,
7297 (void *)&cmd_setqmap_qmap,
7298 (void *)&cmd_setqmap_what,
7299 (void *)&cmd_setqmap_portid,
7300 (void *)&cmd_setqmap_queueid,
7301 (void *)&cmd_setqmap_mapvalue,
7306 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7307 struct cmd_set_xstats_hide_zero_result {
7308 cmdline_fixed_string_t keyword;
7309 cmdline_fixed_string_t name;
7310 cmdline_fixed_string_t on_off;
7314 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7315 __attribute__((unused)) struct cmdline *cl,
7316 __attribute__((unused)) void *data)
7318 struct cmd_set_xstats_hide_zero_result *res;
7319 uint16_t on_off = 0;
7321 res = parsed_result;
7322 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7323 set_xstats_hide_zero(on_off);
7326 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7327 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7329 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7330 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7331 name, "xstats-hide-zero");
7332 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7333 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7336 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7337 .f = cmd_set_xstats_hide_zero_parsed,
7339 .help_str = "set xstats-hide-zero on|off",
7341 (void *)&cmd_set_xstats_hide_zero_keyword,
7342 (void *)&cmd_set_xstats_hide_zero_name,
7343 (void *)&cmd_set_xstats_hide_zero_on_off,
7348 /* *** CONFIGURE UNICAST HASH TABLE *** */
7349 struct cmd_set_uc_hash_table {
7350 cmdline_fixed_string_t set;
7351 cmdline_fixed_string_t port;
7353 cmdline_fixed_string_t what;
7354 struct ether_addr address;
7355 cmdline_fixed_string_t mode;
7359 cmd_set_uc_hash_parsed(void *parsed_result,
7360 __attribute__((unused)) struct cmdline *cl,
7361 __attribute__((unused)) void *data)
7364 struct cmd_set_uc_hash_table *res = parsed_result;
7366 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7368 if (strcmp(res->what, "uta") == 0)
7369 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7370 &res->address,(uint8_t)is_on);
7372 printf("bad unicast hash table parameter, return code = %d \n", ret);
7376 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7377 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7379 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7380 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7382 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7383 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7385 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7386 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7388 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7389 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7391 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7392 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7395 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7396 .f = cmd_set_uc_hash_parsed,
7398 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7400 (void *)&cmd_set_uc_hash_set,
7401 (void *)&cmd_set_uc_hash_port,
7402 (void *)&cmd_set_uc_hash_portid,
7403 (void *)&cmd_set_uc_hash_what,
7404 (void *)&cmd_set_uc_hash_mac,
7405 (void *)&cmd_set_uc_hash_mode,
7410 struct cmd_set_uc_all_hash_table {
7411 cmdline_fixed_string_t set;
7412 cmdline_fixed_string_t port;
7414 cmdline_fixed_string_t what;
7415 cmdline_fixed_string_t value;
7416 cmdline_fixed_string_t mode;
7420 cmd_set_uc_all_hash_parsed(void *parsed_result,
7421 __attribute__((unused)) struct cmdline *cl,
7422 __attribute__((unused)) void *data)
7425 struct cmd_set_uc_all_hash_table *res = parsed_result;
7427 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7429 if ((strcmp(res->what, "uta") == 0) &&
7430 (strcmp(res->value, "all") == 0))
7431 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7433 printf("bad unicast hash table parameter,"
7434 "return code = %d \n", ret);
7437 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7438 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7440 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7441 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7443 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7444 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7446 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7447 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7449 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7450 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7452 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7453 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7456 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7457 .f = cmd_set_uc_all_hash_parsed,
7459 .help_str = "set port <port_id> uta all on|off",
7461 (void *)&cmd_set_uc_all_hash_set,
7462 (void *)&cmd_set_uc_all_hash_port,
7463 (void *)&cmd_set_uc_all_hash_portid,
7464 (void *)&cmd_set_uc_all_hash_what,
7465 (void *)&cmd_set_uc_all_hash_value,
7466 (void *)&cmd_set_uc_all_hash_mode,
7471 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7472 struct cmd_set_vf_macvlan_filter {
7473 cmdline_fixed_string_t set;
7474 cmdline_fixed_string_t port;
7476 cmdline_fixed_string_t vf;
7478 struct ether_addr address;
7479 cmdline_fixed_string_t filter_type;
7480 cmdline_fixed_string_t mode;
7484 cmd_set_vf_macvlan_parsed(void *parsed_result,
7485 __attribute__((unused)) struct cmdline *cl,
7486 __attribute__((unused)) void *data)
7489 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7490 struct rte_eth_mac_filter filter;
7492 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7494 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7496 /* set VF MAC filter */
7500 filter.dst_id = res->vf_id;
7502 if (!strcmp(res->filter_type, "exact-mac"))
7503 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7504 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7505 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7506 else if (!strcmp(res->filter_type, "hashmac"))
7507 filter.filter_type = RTE_MAC_HASH_MATCH;
7508 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7509 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7511 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7514 ret = rte_eth_dev_filter_ctrl(res->port_id,
7515 RTE_ETH_FILTER_MACVLAN,
7519 ret = rte_eth_dev_filter_ctrl(res->port_id,
7520 RTE_ETH_FILTER_MACVLAN,
7521 RTE_ETH_FILTER_DELETE,
7525 printf("bad set MAC hash parameter, return code = %d\n", ret);
7529 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7530 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7532 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7533 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7535 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7536 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7538 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7539 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7541 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7542 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7544 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7545 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7547 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7548 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7549 filter_type, "exact-mac#exact-mac-vlan"
7550 "#hashmac#hashmac-vlan");
7551 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7552 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7555 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7556 .f = cmd_set_vf_macvlan_parsed,
7558 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7559 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7560 "Exact match rule: exact match of MAC or MAC and VLAN; "
7561 "hash match rule: hash match of MAC and exact match of VLAN",
7563 (void *)&cmd_set_vf_macvlan_set,
7564 (void *)&cmd_set_vf_macvlan_port,
7565 (void *)&cmd_set_vf_macvlan_portid,
7566 (void *)&cmd_set_vf_macvlan_vf,
7567 (void *)&cmd_set_vf_macvlan_vf_id,
7568 (void *)&cmd_set_vf_macvlan_mac,
7569 (void *)&cmd_set_vf_macvlan_filter_type,
7570 (void *)&cmd_set_vf_macvlan_mode,
7575 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7576 struct cmd_set_vf_traffic {
7577 cmdline_fixed_string_t set;
7578 cmdline_fixed_string_t port;
7580 cmdline_fixed_string_t vf;
7582 cmdline_fixed_string_t what;
7583 cmdline_fixed_string_t mode;
7587 cmd_set_vf_traffic_parsed(void *parsed_result,
7588 __attribute__((unused)) struct cmdline *cl,
7589 __attribute__((unused)) void *data)
7591 struct cmd_set_vf_traffic *res = parsed_result;
7592 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7593 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7595 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7598 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7599 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7601 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7602 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7604 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7605 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7607 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7608 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7610 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7611 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7613 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7614 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7616 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7617 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7620 cmdline_parse_inst_t cmd_set_vf_traffic = {
7621 .f = cmd_set_vf_traffic_parsed,
7623 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7625 (void *)&cmd_setvf_traffic_set,
7626 (void *)&cmd_setvf_traffic_port,
7627 (void *)&cmd_setvf_traffic_portid,
7628 (void *)&cmd_setvf_traffic_vf,
7629 (void *)&cmd_setvf_traffic_vfid,
7630 (void *)&cmd_setvf_traffic_what,
7631 (void *)&cmd_setvf_traffic_mode,
7636 /* *** CONFIGURE VF RECEIVE MODE *** */
7637 struct cmd_set_vf_rxmode {
7638 cmdline_fixed_string_t set;
7639 cmdline_fixed_string_t port;
7641 cmdline_fixed_string_t vf;
7643 cmdline_fixed_string_t what;
7644 cmdline_fixed_string_t mode;
7645 cmdline_fixed_string_t on;
7649 cmd_set_vf_rxmode_parsed(void *parsed_result,
7650 __attribute__((unused)) struct cmdline *cl,
7651 __attribute__((unused)) void *data)
7654 uint16_t rx_mode = 0;
7655 struct cmd_set_vf_rxmode *res = parsed_result;
7657 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7658 if (!strcmp(res->what,"rxmode")) {
7659 if (!strcmp(res->mode, "AUPE"))
7660 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7661 else if (!strcmp(res->mode, "ROPE"))
7662 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7663 else if (!strcmp(res->mode, "BAM"))
7664 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7665 else if (!strncmp(res->mode, "MPE",3))
7666 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7669 RTE_SET_USED(is_on);
7671 #ifdef RTE_LIBRTE_IXGBE_PMD
7672 if (ret == -ENOTSUP)
7673 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7674 rx_mode, (uint8_t)is_on);
7676 #ifdef RTE_LIBRTE_BNXT_PMD
7677 if (ret == -ENOTSUP)
7678 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7679 rx_mode, (uint8_t)is_on);
7682 printf("bad VF receive mode parameter, return code = %d \n",
7686 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7687 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7689 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7690 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7692 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7693 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7695 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7696 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7698 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7699 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7701 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7702 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7704 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7705 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7706 mode, "AUPE#ROPE#BAM#MPE");
7707 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7708 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7711 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7712 .f = cmd_set_vf_rxmode_parsed,
7714 .help_str = "set port <port_id> vf <vf_id> rxmode "
7715 "AUPE|ROPE|BAM|MPE on|off",
7717 (void *)&cmd_set_vf_rxmode_set,
7718 (void *)&cmd_set_vf_rxmode_port,
7719 (void *)&cmd_set_vf_rxmode_portid,
7720 (void *)&cmd_set_vf_rxmode_vf,
7721 (void *)&cmd_set_vf_rxmode_vfid,
7722 (void *)&cmd_set_vf_rxmode_what,
7723 (void *)&cmd_set_vf_rxmode_mode,
7724 (void *)&cmd_set_vf_rxmode_on,
7729 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7730 struct cmd_vf_mac_addr_result {
7731 cmdline_fixed_string_t mac_addr_cmd;
7732 cmdline_fixed_string_t what;
7733 cmdline_fixed_string_t port;
7735 cmdline_fixed_string_t vf;
7737 struct ether_addr address;
7740 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7741 __attribute__((unused)) struct cmdline *cl,
7742 __attribute__((unused)) void *data)
7744 struct cmd_vf_mac_addr_result *res = parsed_result;
7747 if (strcmp(res->what, "add") != 0)
7750 #ifdef RTE_LIBRTE_I40E_PMD
7751 if (ret == -ENOTSUP)
7752 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7755 #ifdef RTE_LIBRTE_BNXT_PMD
7756 if (ret == -ENOTSUP)
7757 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7762 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7766 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7767 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7768 mac_addr_cmd,"mac_addr");
7769 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7770 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7772 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7773 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7775 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7776 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7778 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7779 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7781 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7782 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7784 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7785 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7788 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7789 .f = cmd_vf_mac_addr_parsed,
7791 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7792 "Add MAC address filtering for a VF on port_id",
7794 (void *)&cmd_vf_mac_addr_cmd,
7795 (void *)&cmd_vf_mac_addr_what,
7796 (void *)&cmd_vf_mac_addr_port,
7797 (void *)&cmd_vf_mac_addr_portnum,
7798 (void *)&cmd_vf_mac_addr_vf,
7799 (void *)&cmd_vf_mac_addr_vfnum,
7800 (void *)&cmd_vf_mac_addr_addr,
7805 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7806 struct cmd_vf_rx_vlan_filter {
7807 cmdline_fixed_string_t rx_vlan;
7808 cmdline_fixed_string_t what;
7810 cmdline_fixed_string_t port;
7812 cmdline_fixed_string_t vf;
7817 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7818 __attribute__((unused)) struct cmdline *cl,
7819 __attribute__((unused)) void *data)
7821 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7824 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7826 #ifdef RTE_LIBRTE_IXGBE_PMD
7827 if (ret == -ENOTSUP)
7828 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7829 res->vlan_id, res->vf_mask, is_add);
7831 #ifdef RTE_LIBRTE_I40E_PMD
7832 if (ret == -ENOTSUP)
7833 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7834 res->vlan_id, res->vf_mask, is_add);
7836 #ifdef RTE_LIBRTE_BNXT_PMD
7837 if (ret == -ENOTSUP)
7838 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7839 res->vlan_id, res->vf_mask, is_add);
7846 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7847 res->vlan_id, res->vf_mask);
7850 printf("invalid port_id %d\n", res->port_id);
7853 printf("function not implemented or supported\n");
7856 printf("programming error: (%s)\n", strerror(-ret));
7860 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7861 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7862 rx_vlan, "rx_vlan");
7863 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7864 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7866 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7867 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7869 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7870 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7872 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7873 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7875 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7876 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7878 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7879 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7882 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7883 .f = cmd_vf_rx_vlan_filter_parsed,
7885 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7886 "(vf_mask = hexadecimal VF mask)",
7888 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7889 (void *)&cmd_vf_rx_vlan_filter_what,
7890 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7891 (void *)&cmd_vf_rx_vlan_filter_port,
7892 (void *)&cmd_vf_rx_vlan_filter_portid,
7893 (void *)&cmd_vf_rx_vlan_filter_vf,
7894 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7899 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7900 struct cmd_queue_rate_limit_result {
7901 cmdline_fixed_string_t set;
7902 cmdline_fixed_string_t port;
7904 cmdline_fixed_string_t queue;
7906 cmdline_fixed_string_t rate;
7910 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7911 __attribute__((unused)) struct cmdline *cl,
7912 __attribute__((unused)) void *data)
7914 struct cmd_queue_rate_limit_result *res = parsed_result;
7917 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7918 && (strcmp(res->queue, "queue") == 0)
7919 && (strcmp(res->rate, "rate") == 0))
7920 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7923 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7927 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7928 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7930 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7931 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7933 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7934 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7936 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7937 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7939 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7940 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7942 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7943 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7945 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7946 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7949 cmdline_parse_inst_t cmd_queue_rate_limit = {
7950 .f = cmd_queue_rate_limit_parsed,
7952 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7953 "Set rate limit for a queue on port_id",
7955 (void *)&cmd_queue_rate_limit_set,
7956 (void *)&cmd_queue_rate_limit_port,
7957 (void *)&cmd_queue_rate_limit_portnum,
7958 (void *)&cmd_queue_rate_limit_queue,
7959 (void *)&cmd_queue_rate_limit_queuenum,
7960 (void *)&cmd_queue_rate_limit_rate,
7961 (void *)&cmd_queue_rate_limit_ratenum,
7966 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7967 struct cmd_vf_rate_limit_result {
7968 cmdline_fixed_string_t set;
7969 cmdline_fixed_string_t port;
7971 cmdline_fixed_string_t vf;
7973 cmdline_fixed_string_t rate;
7975 cmdline_fixed_string_t q_msk;
7979 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7980 __attribute__((unused)) struct cmdline *cl,
7981 __attribute__((unused)) void *data)
7983 struct cmd_vf_rate_limit_result *res = parsed_result;
7986 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7987 && (strcmp(res->vf, "vf") == 0)
7988 && (strcmp(res->rate, "rate") == 0)
7989 && (strcmp(res->q_msk, "queue_mask") == 0))
7990 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7991 res->rate_num, res->q_msk_val);
7993 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7997 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7998 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8000 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8001 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8003 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8004 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8006 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8007 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8009 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8010 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8012 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8013 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8015 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8016 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8018 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8019 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8020 q_msk, "queue_mask");
8021 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8022 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8025 cmdline_parse_inst_t cmd_vf_rate_limit = {
8026 .f = cmd_vf_rate_limit_parsed,
8028 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8029 "queue_mask <queue_mask_value>: "
8030 "Set rate limit for queues of VF on port_id",
8032 (void *)&cmd_vf_rate_limit_set,
8033 (void *)&cmd_vf_rate_limit_port,
8034 (void *)&cmd_vf_rate_limit_portnum,
8035 (void *)&cmd_vf_rate_limit_vf,
8036 (void *)&cmd_vf_rate_limit_vfnum,
8037 (void *)&cmd_vf_rate_limit_rate,
8038 (void *)&cmd_vf_rate_limit_ratenum,
8039 (void *)&cmd_vf_rate_limit_q_msk,
8040 (void *)&cmd_vf_rate_limit_q_msk_val,
8045 /* *** ADD TUNNEL FILTER OF A PORT *** */
8046 struct cmd_tunnel_filter_result {
8047 cmdline_fixed_string_t cmd;
8048 cmdline_fixed_string_t what;
8050 struct ether_addr outer_mac;
8051 struct ether_addr inner_mac;
8052 cmdline_ipaddr_t ip_value;
8053 uint16_t inner_vlan;
8054 cmdline_fixed_string_t tunnel_type;
8055 cmdline_fixed_string_t filter_type;
8061 cmd_tunnel_filter_parsed(void *parsed_result,
8062 __attribute__((unused)) struct cmdline *cl,
8063 __attribute__((unused)) void *data)
8065 struct cmd_tunnel_filter_result *res = parsed_result;
8066 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8069 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8071 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8072 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8073 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8075 if (res->ip_value.family == AF_INET) {
8076 tunnel_filter_conf.ip_addr.ipv4_addr =
8077 res->ip_value.addr.ipv4.s_addr;
8078 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8080 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8081 &(res->ip_value.addr.ipv6),
8082 sizeof(struct in6_addr));
8083 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8086 if (!strcmp(res->filter_type, "imac-ivlan"))
8087 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8088 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8089 tunnel_filter_conf.filter_type =
8090 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8091 else if (!strcmp(res->filter_type, "imac-tenid"))
8092 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8093 else if (!strcmp(res->filter_type, "imac"))
8094 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8095 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8096 tunnel_filter_conf.filter_type =
8097 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8098 else if (!strcmp(res->filter_type, "oip"))
8099 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8100 else if (!strcmp(res->filter_type, "iip"))
8101 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8103 printf("The filter type is not supported");
8107 if (!strcmp(res->tunnel_type, "vxlan"))
8108 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8109 else if (!strcmp(res->tunnel_type, "nvgre"))
8110 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8111 else if (!strcmp(res->tunnel_type, "ipingre"))
8112 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8114 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8118 tunnel_filter_conf.tenant_id = res->tenant_id;
8119 tunnel_filter_conf.queue_id = res->queue_num;
8120 if (!strcmp(res->what, "add"))
8121 ret = rte_eth_dev_filter_ctrl(res->port_id,
8122 RTE_ETH_FILTER_TUNNEL,
8124 &tunnel_filter_conf);
8126 ret = rte_eth_dev_filter_ctrl(res->port_id,
8127 RTE_ETH_FILTER_TUNNEL,
8128 RTE_ETH_FILTER_DELETE,
8129 &tunnel_filter_conf);
8131 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8135 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8136 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8137 cmd, "tunnel_filter");
8138 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8139 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8141 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8142 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8144 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8145 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8147 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8148 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8150 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8151 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8152 inner_vlan, UINT16);
8153 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8154 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8156 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8157 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8158 tunnel_type, "vxlan#nvgre#ipingre");
8160 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8161 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8162 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8163 "imac#omac-imac-tenid");
8164 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8165 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8167 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8168 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8171 cmdline_parse_inst_t cmd_tunnel_filter = {
8172 .f = cmd_tunnel_filter_parsed,
8174 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8175 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8176 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8177 "<queue_id>: Add/Rm tunnel filter of a port",
8179 (void *)&cmd_tunnel_filter_cmd,
8180 (void *)&cmd_tunnel_filter_what,
8181 (void *)&cmd_tunnel_filter_port_id,
8182 (void *)&cmd_tunnel_filter_outer_mac,
8183 (void *)&cmd_tunnel_filter_inner_mac,
8184 (void *)&cmd_tunnel_filter_ip_value,
8185 (void *)&cmd_tunnel_filter_innner_vlan,
8186 (void *)&cmd_tunnel_filter_tunnel_type,
8187 (void *)&cmd_tunnel_filter_filter_type,
8188 (void *)&cmd_tunnel_filter_tenant_id,
8189 (void *)&cmd_tunnel_filter_queue_num,
8194 /* *** CONFIGURE TUNNEL UDP PORT *** */
8195 struct cmd_tunnel_udp_config {
8196 cmdline_fixed_string_t cmd;
8197 cmdline_fixed_string_t what;
8203 cmd_tunnel_udp_config_parsed(void *parsed_result,
8204 __attribute__((unused)) struct cmdline *cl,
8205 __attribute__((unused)) void *data)
8207 struct cmd_tunnel_udp_config *res = parsed_result;
8208 struct rte_eth_udp_tunnel tunnel_udp;
8211 tunnel_udp.udp_port = res->udp_port;
8213 if (!strcmp(res->cmd, "rx_vxlan_port"))
8214 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8216 if (!strcmp(res->what, "add"))
8217 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8220 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8224 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8227 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8228 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8229 cmd, "rx_vxlan_port");
8230 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8231 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8233 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8234 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8236 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8237 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8240 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8241 .f = cmd_tunnel_udp_config_parsed,
8243 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8244 "Add/Remove a tunneling UDP port filter",
8246 (void *)&cmd_tunnel_udp_config_cmd,
8247 (void *)&cmd_tunnel_udp_config_what,
8248 (void *)&cmd_tunnel_udp_config_udp_port,
8249 (void *)&cmd_tunnel_udp_config_port_id,
8254 /* *** GLOBAL CONFIG *** */
8255 struct cmd_global_config_result {
8256 cmdline_fixed_string_t cmd;
8258 cmdline_fixed_string_t cfg_type;
8263 cmd_global_config_parsed(void *parsed_result,
8264 __attribute__((unused)) struct cmdline *cl,
8265 __attribute__((unused)) void *data)
8267 struct cmd_global_config_result *res = parsed_result;
8268 struct rte_eth_global_cfg conf;
8271 memset(&conf, 0, sizeof(conf));
8272 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8273 conf.cfg.gre_key_len = res->len;
8274 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8275 RTE_ETH_FILTER_SET, &conf);
8277 printf("Global config error\n");
8280 cmdline_parse_token_string_t cmd_global_config_cmd =
8281 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8283 cmdline_parse_token_num_t cmd_global_config_port_id =
8284 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8286 cmdline_parse_token_string_t cmd_global_config_type =
8287 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8288 cfg_type, "gre-key-len");
8289 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8290 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8293 cmdline_parse_inst_t cmd_global_config = {
8294 .f = cmd_global_config_parsed,
8295 .data = (void *)NULL,
8296 .help_str = "global_config <port_id> gre-key-len <key_len>",
8298 (void *)&cmd_global_config_cmd,
8299 (void *)&cmd_global_config_port_id,
8300 (void *)&cmd_global_config_type,
8301 (void *)&cmd_global_config_gre_key_len,
8306 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8307 struct cmd_set_mirror_mask_result {
8308 cmdline_fixed_string_t set;
8309 cmdline_fixed_string_t port;
8311 cmdline_fixed_string_t mirror;
8313 cmdline_fixed_string_t what;
8314 cmdline_fixed_string_t value;
8315 cmdline_fixed_string_t dstpool;
8317 cmdline_fixed_string_t on;
8320 cmdline_parse_token_string_t cmd_mirror_mask_set =
8321 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8323 cmdline_parse_token_string_t cmd_mirror_mask_port =
8324 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8326 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8327 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8329 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8330 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8331 mirror, "mirror-rule");
8332 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8333 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8335 cmdline_parse_token_string_t cmd_mirror_mask_what =
8336 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8337 what, "pool-mirror-up#pool-mirror-down"
8339 cmdline_parse_token_string_t cmd_mirror_mask_value =
8340 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8342 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8343 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8344 dstpool, "dst-pool");
8345 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8346 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8348 cmdline_parse_token_string_t cmd_mirror_mask_on =
8349 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8353 cmd_set_mirror_mask_parsed(void *parsed_result,
8354 __attribute__((unused)) struct cmdline *cl,
8355 __attribute__((unused)) void *data)
8358 struct cmd_set_mirror_mask_result *res = parsed_result;
8359 struct rte_eth_mirror_conf mr_conf;
8361 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8363 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8365 mr_conf.dst_pool = res->dstpool_id;
8367 if (!strcmp(res->what, "pool-mirror-up")) {
8368 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8369 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8370 } else if (!strcmp(res->what, "pool-mirror-down")) {
8371 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8372 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8373 } else if (!strcmp(res->what, "vlan-mirror")) {
8374 mr_conf.rule_type = ETH_MIRROR_VLAN;
8375 nb_item = parse_item_list(res->value, "vlan",
8376 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8380 for (i = 0; i < nb_item; i++) {
8381 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8382 printf("Invalid vlan_id: must be < 4096\n");
8386 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8387 mr_conf.vlan.vlan_mask |= 1ULL << i;
8391 if (!strcmp(res->on, "on"))
8392 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8395 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8398 printf("mirror rule add error: (%s)\n", strerror(-ret));
8401 cmdline_parse_inst_t cmd_set_mirror_mask = {
8402 .f = cmd_set_mirror_mask_parsed,
8404 .help_str = "set port <port_id> mirror-rule <rule_id> "
8405 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8406 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8408 (void *)&cmd_mirror_mask_set,
8409 (void *)&cmd_mirror_mask_port,
8410 (void *)&cmd_mirror_mask_portid,
8411 (void *)&cmd_mirror_mask_mirror,
8412 (void *)&cmd_mirror_mask_ruleid,
8413 (void *)&cmd_mirror_mask_what,
8414 (void *)&cmd_mirror_mask_value,
8415 (void *)&cmd_mirror_mask_dstpool,
8416 (void *)&cmd_mirror_mask_poolid,
8417 (void *)&cmd_mirror_mask_on,
8422 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8423 struct cmd_set_mirror_link_result {
8424 cmdline_fixed_string_t set;
8425 cmdline_fixed_string_t port;
8427 cmdline_fixed_string_t mirror;
8429 cmdline_fixed_string_t what;
8430 cmdline_fixed_string_t dstpool;
8432 cmdline_fixed_string_t on;
8435 cmdline_parse_token_string_t cmd_mirror_link_set =
8436 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8438 cmdline_parse_token_string_t cmd_mirror_link_port =
8439 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8441 cmdline_parse_token_num_t cmd_mirror_link_portid =
8442 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8444 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8445 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8446 mirror, "mirror-rule");
8447 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8448 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8450 cmdline_parse_token_string_t cmd_mirror_link_what =
8451 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8452 what, "uplink-mirror#downlink-mirror");
8453 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8454 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8455 dstpool, "dst-pool");
8456 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8457 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8459 cmdline_parse_token_string_t cmd_mirror_link_on =
8460 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8464 cmd_set_mirror_link_parsed(void *parsed_result,
8465 __attribute__((unused)) struct cmdline *cl,
8466 __attribute__((unused)) void *data)
8469 struct cmd_set_mirror_link_result *res = parsed_result;
8470 struct rte_eth_mirror_conf mr_conf;
8472 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8473 if (!strcmp(res->what, "uplink-mirror"))
8474 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8476 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8478 mr_conf.dst_pool = res->dstpool_id;
8480 if (!strcmp(res->on, "on"))
8481 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8484 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8487 /* check the return value and print it if is < 0 */
8489 printf("mirror rule add error: (%s)\n", strerror(-ret));
8493 cmdline_parse_inst_t cmd_set_mirror_link = {
8494 .f = cmd_set_mirror_link_parsed,
8496 .help_str = "set port <port_id> mirror-rule <rule_id> "
8497 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8499 (void *)&cmd_mirror_link_set,
8500 (void *)&cmd_mirror_link_port,
8501 (void *)&cmd_mirror_link_portid,
8502 (void *)&cmd_mirror_link_mirror,
8503 (void *)&cmd_mirror_link_ruleid,
8504 (void *)&cmd_mirror_link_what,
8505 (void *)&cmd_mirror_link_dstpool,
8506 (void *)&cmd_mirror_link_poolid,
8507 (void *)&cmd_mirror_link_on,
8512 /* *** RESET VM MIRROR RULE *** */
8513 struct cmd_rm_mirror_rule_result {
8514 cmdline_fixed_string_t reset;
8515 cmdline_fixed_string_t port;
8517 cmdline_fixed_string_t mirror;
8521 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8522 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8524 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8525 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8527 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8528 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8530 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8531 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8532 mirror, "mirror-rule");
8533 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8534 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8538 cmd_reset_mirror_rule_parsed(void *parsed_result,
8539 __attribute__((unused)) struct cmdline *cl,
8540 __attribute__((unused)) void *data)
8543 struct cmd_set_mirror_link_result *res = parsed_result;
8545 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8547 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8550 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8551 .f = cmd_reset_mirror_rule_parsed,
8553 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8555 (void *)&cmd_rm_mirror_rule_reset,
8556 (void *)&cmd_rm_mirror_rule_port,
8557 (void *)&cmd_rm_mirror_rule_portid,
8558 (void *)&cmd_rm_mirror_rule_mirror,
8559 (void *)&cmd_rm_mirror_rule_ruleid,
8564 /* ******************************************************************************** */
8566 struct cmd_dump_result {
8567 cmdline_fixed_string_t dump;
8571 dump_struct_sizes(void)
8573 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8574 DUMP_SIZE(struct rte_mbuf);
8575 DUMP_SIZE(struct rte_mempool);
8576 DUMP_SIZE(struct rte_ring);
8580 static void cmd_dump_parsed(void *parsed_result,
8581 __attribute__((unused)) struct cmdline *cl,
8582 __attribute__((unused)) void *data)
8584 struct cmd_dump_result *res = parsed_result;
8586 if (!strcmp(res->dump, "dump_physmem"))
8587 rte_dump_physmem_layout(stdout);
8588 else if (!strcmp(res->dump, "dump_memzone"))
8589 rte_memzone_dump(stdout);
8590 else if (!strcmp(res->dump, "dump_struct_sizes"))
8591 dump_struct_sizes();
8592 else if (!strcmp(res->dump, "dump_ring"))
8593 rte_ring_list_dump(stdout);
8594 else if (!strcmp(res->dump, "dump_mempool"))
8595 rte_mempool_list_dump(stdout);
8596 else if (!strcmp(res->dump, "dump_devargs"))
8597 rte_eal_devargs_dump(stdout);
8598 else if (!strcmp(res->dump, "dump_log_types"))
8599 rte_log_dump(stdout);
8602 cmdline_parse_token_string_t cmd_dump_dump =
8603 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8606 "dump_struct_sizes#"
8612 cmdline_parse_inst_t cmd_dump = {
8613 .f = cmd_dump_parsed, /* function to call */
8614 .data = NULL, /* 2nd arg of func */
8615 .help_str = "Dump status",
8616 .tokens = { /* token list, NULL terminated */
8617 (void *)&cmd_dump_dump,
8622 /* ******************************************************************************** */
8624 struct cmd_dump_one_result {
8625 cmdline_fixed_string_t dump;
8626 cmdline_fixed_string_t name;
8629 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8630 __attribute__((unused)) void *data)
8632 struct cmd_dump_one_result *res = parsed_result;
8634 if (!strcmp(res->dump, "dump_ring")) {
8636 r = rte_ring_lookup(res->name);
8638 cmdline_printf(cl, "Cannot find ring\n");
8641 rte_ring_dump(stdout, r);
8642 } else if (!strcmp(res->dump, "dump_mempool")) {
8643 struct rte_mempool *mp;
8644 mp = rte_mempool_lookup(res->name);
8646 cmdline_printf(cl, "Cannot find mempool\n");
8649 rte_mempool_dump(stdout, mp);
8653 cmdline_parse_token_string_t cmd_dump_one_dump =
8654 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8655 "dump_ring#dump_mempool");
8657 cmdline_parse_token_string_t cmd_dump_one_name =
8658 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8660 cmdline_parse_inst_t cmd_dump_one = {
8661 .f = cmd_dump_one_parsed, /* function to call */
8662 .data = NULL, /* 2nd arg of func */
8663 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8664 .tokens = { /* token list, NULL terminated */
8665 (void *)&cmd_dump_one_dump,
8666 (void *)&cmd_dump_one_name,
8671 /* *** Add/Del syn filter *** */
8672 struct cmd_syn_filter_result {
8673 cmdline_fixed_string_t filter;
8675 cmdline_fixed_string_t ops;
8676 cmdline_fixed_string_t priority;
8677 cmdline_fixed_string_t high;
8678 cmdline_fixed_string_t queue;
8683 cmd_syn_filter_parsed(void *parsed_result,
8684 __attribute__((unused)) struct cmdline *cl,
8685 __attribute__((unused)) void *data)
8687 struct cmd_syn_filter_result *res = parsed_result;
8688 struct rte_eth_syn_filter syn_filter;
8691 ret = rte_eth_dev_filter_supported(res->port_id,
8692 RTE_ETH_FILTER_SYN);
8694 printf("syn filter is not supported on port %u.\n",
8699 memset(&syn_filter, 0, sizeof(syn_filter));
8701 if (!strcmp(res->ops, "add")) {
8702 if (!strcmp(res->high, "high"))
8703 syn_filter.hig_pri = 1;
8705 syn_filter.hig_pri = 0;
8707 syn_filter.queue = res->queue_id;
8708 ret = rte_eth_dev_filter_ctrl(res->port_id,
8713 ret = rte_eth_dev_filter_ctrl(res->port_id,
8715 RTE_ETH_FILTER_DELETE,
8719 printf("syn filter programming error: (%s)\n",
8723 cmdline_parse_token_string_t cmd_syn_filter_filter =
8724 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8725 filter, "syn_filter");
8726 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8727 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8729 cmdline_parse_token_string_t cmd_syn_filter_ops =
8730 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8732 cmdline_parse_token_string_t cmd_syn_filter_priority =
8733 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8734 priority, "priority");
8735 cmdline_parse_token_string_t cmd_syn_filter_high =
8736 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8738 cmdline_parse_token_string_t cmd_syn_filter_queue =
8739 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8741 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8742 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8745 cmdline_parse_inst_t cmd_syn_filter = {
8746 .f = cmd_syn_filter_parsed,
8748 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8749 "<queue_id>: Add/Delete syn filter",
8751 (void *)&cmd_syn_filter_filter,
8752 (void *)&cmd_syn_filter_port_id,
8753 (void *)&cmd_syn_filter_ops,
8754 (void *)&cmd_syn_filter_priority,
8755 (void *)&cmd_syn_filter_high,
8756 (void *)&cmd_syn_filter_queue,
8757 (void *)&cmd_syn_filter_queue_id,
8762 /* *** queue region set *** */
8763 struct cmd_queue_region_result {
8764 cmdline_fixed_string_t set;
8765 cmdline_fixed_string_t port;
8767 cmdline_fixed_string_t cmd;
8768 cmdline_fixed_string_t region;
8770 cmdline_fixed_string_t queue_start_index;
8772 cmdline_fixed_string_t queue_num;
8773 uint8_t queue_num_value;
8777 cmd_queue_region_parsed(void *parsed_result,
8778 __attribute__((unused)) struct cmdline *cl,
8779 __attribute__((unused)) void *data)
8781 struct cmd_queue_region_result *res = parsed_result;
8783 #ifdef RTE_LIBRTE_I40E_PMD
8784 struct rte_pmd_i40e_queue_region_conf region_conf;
8785 enum rte_pmd_i40e_queue_region_op op_type;
8788 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8791 #ifdef RTE_LIBRTE_I40E_PMD
8792 memset(®ion_conf, 0, sizeof(region_conf));
8793 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8794 region_conf.region_id = res->region_id;
8795 region_conf.queue_num = res->queue_num_value;
8796 region_conf.queue_start_index = res->queue_id;
8798 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8799 op_type, ®ion_conf);
8806 printf("function not implemented or supported\n");
8809 printf("queue region config error: (%s)\n", strerror(-ret));
8813 cmdline_parse_token_string_t cmd_queue_region_set =
8814 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8816 cmdline_parse_token_string_t cmd_queue_region_port =
8817 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8818 cmdline_parse_token_num_t cmd_queue_region_port_id =
8819 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8821 cmdline_parse_token_string_t cmd_queue_region_cmd =
8822 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8823 cmd, "queue-region");
8824 cmdline_parse_token_string_t cmd_queue_region_id =
8825 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8826 region, "region_id");
8827 cmdline_parse_token_num_t cmd_queue_region_index =
8828 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8830 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8831 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8832 queue_start_index, "queue_start_index");
8833 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8834 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8836 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8837 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8838 queue_num, "queue_num");
8839 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8840 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8841 queue_num_value, UINT8);
8843 cmdline_parse_inst_t cmd_queue_region = {
8844 .f = cmd_queue_region_parsed,
8846 .help_str = "set port <port_id> queue-region region_id <value> "
8847 "queue_start_index <value> queue_num <value>: Set a queue region",
8849 (void *)&cmd_queue_region_set,
8850 (void *)&cmd_queue_region_port,
8851 (void *)&cmd_queue_region_port_id,
8852 (void *)&cmd_queue_region_cmd,
8853 (void *)&cmd_queue_region_id,
8854 (void *)&cmd_queue_region_index,
8855 (void *)&cmd_queue_region_queue_start_index,
8856 (void *)&cmd_queue_region_queue_id,
8857 (void *)&cmd_queue_region_queue_num,
8858 (void *)&cmd_queue_region_queue_num_value,
8863 /* *** queue region and flowtype set *** */
8864 struct cmd_region_flowtype_result {
8865 cmdline_fixed_string_t set;
8866 cmdline_fixed_string_t port;
8868 cmdline_fixed_string_t cmd;
8869 cmdline_fixed_string_t region;
8871 cmdline_fixed_string_t flowtype;
8872 uint8_t flowtype_id;
8876 cmd_region_flowtype_parsed(void *parsed_result,
8877 __attribute__((unused)) struct cmdline *cl,
8878 __attribute__((unused)) void *data)
8880 struct cmd_region_flowtype_result *res = parsed_result;
8882 #ifdef RTE_LIBRTE_I40E_PMD
8883 struct rte_pmd_i40e_queue_region_conf region_conf;
8884 enum rte_pmd_i40e_queue_region_op op_type;
8887 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8890 #ifdef RTE_LIBRTE_I40E_PMD
8891 memset(®ion_conf, 0, sizeof(region_conf));
8893 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8894 region_conf.region_id = res->region_id;
8895 region_conf.hw_flowtype = res->flowtype_id;
8897 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8898 op_type, ®ion_conf);
8905 printf("function not implemented or supported\n");
8908 printf("region flowtype config error: (%s)\n", strerror(-ret));
8912 cmdline_parse_token_string_t cmd_region_flowtype_set =
8913 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8915 cmdline_parse_token_string_t cmd_region_flowtype_port =
8916 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8918 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8919 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8921 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8922 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8923 cmd, "queue-region");
8924 cmdline_parse_token_string_t cmd_region_flowtype_index =
8925 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8926 region, "region_id");
8927 cmdline_parse_token_num_t cmd_region_flowtype_id =
8928 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8930 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8931 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8932 flowtype, "flowtype");
8933 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8934 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8935 flowtype_id, UINT8);
8936 cmdline_parse_inst_t cmd_region_flowtype = {
8937 .f = cmd_region_flowtype_parsed,
8939 .help_str = "set port <port_id> queue-region region_id <value> "
8940 "flowtype <value>: Set a flowtype region index",
8942 (void *)&cmd_region_flowtype_set,
8943 (void *)&cmd_region_flowtype_port,
8944 (void *)&cmd_region_flowtype_port_index,
8945 (void *)&cmd_region_flowtype_cmd,
8946 (void *)&cmd_region_flowtype_index,
8947 (void *)&cmd_region_flowtype_id,
8948 (void *)&cmd_region_flowtype_flow_index,
8949 (void *)&cmd_region_flowtype_flow_id,
8954 /* *** User Priority (UP) to queue region (region_id) set *** */
8955 struct cmd_user_priority_region_result {
8956 cmdline_fixed_string_t set;
8957 cmdline_fixed_string_t port;
8959 cmdline_fixed_string_t cmd;
8960 cmdline_fixed_string_t user_priority;
8961 uint8_t user_priority_id;
8962 cmdline_fixed_string_t region;
8967 cmd_user_priority_region_parsed(void *parsed_result,
8968 __attribute__((unused)) struct cmdline *cl,
8969 __attribute__((unused)) void *data)
8971 struct cmd_user_priority_region_result *res = parsed_result;
8973 #ifdef RTE_LIBRTE_I40E_PMD
8974 struct rte_pmd_i40e_queue_region_conf region_conf;
8975 enum rte_pmd_i40e_queue_region_op op_type;
8978 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8981 #ifdef RTE_LIBRTE_I40E_PMD
8982 memset(®ion_conf, 0, sizeof(region_conf));
8983 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8984 region_conf.user_priority = res->user_priority_id;
8985 region_conf.region_id = res->region_id;
8987 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8988 op_type, ®ion_conf);
8995 printf("function not implemented or supported\n");
8998 printf("user_priority region config error: (%s)\n",
9003 cmdline_parse_token_string_t cmd_user_priority_region_set =
9004 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9006 cmdline_parse_token_string_t cmd_user_priority_region_port =
9007 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9009 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9010 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9012 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9013 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9014 cmd, "queue-region");
9015 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9016 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9017 user_priority, "UP");
9018 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9019 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9020 user_priority_id, UINT8);
9021 cmdline_parse_token_string_t cmd_user_priority_region_region =
9022 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9023 region, "region_id");
9024 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9025 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9028 cmdline_parse_inst_t cmd_user_priority_region = {
9029 .f = cmd_user_priority_region_parsed,
9031 .help_str = "set port <port_id> queue-region UP <value> "
9032 "region_id <value>: Set the mapping of User Priority (UP) "
9033 "to queue region (region_id) ",
9035 (void *)&cmd_user_priority_region_set,
9036 (void *)&cmd_user_priority_region_port,
9037 (void *)&cmd_user_priority_region_port_index,
9038 (void *)&cmd_user_priority_region_cmd,
9039 (void *)&cmd_user_priority_region_UP,
9040 (void *)&cmd_user_priority_region_UP_id,
9041 (void *)&cmd_user_priority_region_region,
9042 (void *)&cmd_user_priority_region_region_id,
9047 /* *** flush all queue region related configuration *** */
9048 struct cmd_flush_queue_region_result {
9049 cmdline_fixed_string_t set;
9050 cmdline_fixed_string_t port;
9052 cmdline_fixed_string_t cmd;
9053 cmdline_fixed_string_t flush;
9054 cmdline_fixed_string_t what;
9058 cmd_flush_queue_region_parsed(void *parsed_result,
9059 __attribute__((unused)) struct cmdline *cl,
9060 __attribute__((unused)) void *data)
9062 struct cmd_flush_queue_region_result *res = parsed_result;
9064 #ifdef RTE_LIBRTE_I40E_PMD
9065 struct rte_pmd_i40e_queue_region_conf region_conf;
9066 enum rte_pmd_i40e_queue_region_op op_type;
9069 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9072 #ifdef RTE_LIBRTE_I40E_PMD
9073 memset(®ion_conf, 0, sizeof(region_conf));
9075 if (strcmp(res->what, "on") == 0)
9076 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9078 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9080 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9081 op_type, ®ion_conf);
9088 printf("function not implemented or supported\n");
9091 printf("queue region config flush error: (%s)\n",
9096 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9097 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9099 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9100 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9102 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9103 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9105 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9106 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9107 cmd, "queue-region");
9108 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9109 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9111 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9112 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9115 cmdline_parse_inst_t cmd_flush_queue_region = {
9116 .f = cmd_flush_queue_region_parsed,
9118 .help_str = "set port <port_id> queue-region flush on|off"
9119 ": flush all queue region related configuration",
9121 (void *)&cmd_flush_queue_region_set,
9122 (void *)&cmd_flush_queue_region_port,
9123 (void *)&cmd_flush_queue_region_port_index,
9124 (void *)&cmd_flush_queue_region_cmd,
9125 (void *)&cmd_flush_queue_region_flush,
9126 (void *)&cmd_flush_queue_region_what,
9131 /* *** get all queue region related configuration info *** */
9132 struct cmd_show_queue_region_info {
9133 cmdline_fixed_string_t show;
9134 cmdline_fixed_string_t port;
9136 cmdline_fixed_string_t cmd;
9140 cmd_show_queue_region_info_parsed(void *parsed_result,
9141 __attribute__((unused)) struct cmdline *cl,
9142 __attribute__((unused)) void *data)
9144 struct cmd_show_queue_region_info *res = parsed_result;
9146 #ifdef RTE_LIBRTE_I40E_PMD
9147 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9148 enum rte_pmd_i40e_queue_region_op op_type;
9151 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9154 #ifdef RTE_LIBRTE_I40E_PMD
9155 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9157 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9159 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9160 op_type, &rte_pmd_regions);
9162 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9169 printf("function not implemented or supported\n");
9172 printf("queue region config info show error: (%s)\n",
9177 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9178 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9180 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9181 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9183 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9184 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9186 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9187 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9188 cmd, "queue-region");
9190 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9191 .f = cmd_show_queue_region_info_parsed,
9193 .help_str = "show port <port_id> queue-region"
9194 ": show all queue region related configuration info",
9196 (void *)&cmd_show_queue_region_info_get,
9197 (void *)&cmd_show_queue_region_info_port,
9198 (void *)&cmd_show_queue_region_info_port_index,
9199 (void *)&cmd_show_queue_region_info_cmd,
9204 /* *** ADD/REMOVE A 2tuple FILTER *** */
9205 struct cmd_2tuple_filter_result {
9206 cmdline_fixed_string_t filter;
9208 cmdline_fixed_string_t ops;
9209 cmdline_fixed_string_t dst_port;
9210 uint16_t dst_port_value;
9211 cmdline_fixed_string_t protocol;
9212 uint8_t protocol_value;
9213 cmdline_fixed_string_t mask;
9215 cmdline_fixed_string_t tcp_flags;
9216 uint8_t tcp_flags_value;
9217 cmdline_fixed_string_t priority;
9218 uint8_t priority_value;
9219 cmdline_fixed_string_t queue;
9224 cmd_2tuple_filter_parsed(void *parsed_result,
9225 __attribute__((unused)) struct cmdline *cl,
9226 __attribute__((unused)) void *data)
9228 struct rte_eth_ntuple_filter filter;
9229 struct cmd_2tuple_filter_result *res = parsed_result;
9232 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9234 printf("ntuple filter is not supported on port %u.\n",
9239 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9241 filter.flags = RTE_2TUPLE_FLAGS;
9242 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9243 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9244 filter.proto = res->protocol_value;
9245 filter.priority = res->priority_value;
9246 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9247 printf("nonzero tcp_flags is only meaningful"
9248 " when protocol is TCP.\n");
9251 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9252 printf("invalid TCP flags.\n");
9256 if (res->tcp_flags_value != 0) {
9257 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9258 filter.tcp_flags = res->tcp_flags_value;
9261 /* need convert to big endian. */
9262 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9263 filter.queue = res->queue_id;
9265 if (!strcmp(res->ops, "add"))
9266 ret = rte_eth_dev_filter_ctrl(res->port_id,
9267 RTE_ETH_FILTER_NTUPLE,
9271 ret = rte_eth_dev_filter_ctrl(res->port_id,
9272 RTE_ETH_FILTER_NTUPLE,
9273 RTE_ETH_FILTER_DELETE,
9276 printf("2tuple filter programming error: (%s)\n",
9281 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9282 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9283 filter, "2tuple_filter");
9284 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9285 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9287 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9288 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9290 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9291 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9292 dst_port, "dst_port");
9293 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9294 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9295 dst_port_value, UINT16);
9296 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9297 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9298 protocol, "protocol");
9299 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9300 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9301 protocol_value, UINT8);
9302 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9303 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9305 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9306 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9308 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9309 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9310 tcp_flags, "tcp_flags");
9311 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9312 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9313 tcp_flags_value, UINT8);
9314 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9315 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9316 priority, "priority");
9317 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9318 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9319 priority_value, UINT8);
9320 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9321 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9323 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9324 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9327 cmdline_parse_inst_t cmd_2tuple_filter = {
9328 .f = cmd_2tuple_filter_parsed,
9330 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9331 "<value> mask <value> tcp_flags <value> priority <value> queue "
9332 "<queue_id>: Add a 2tuple filter",
9334 (void *)&cmd_2tuple_filter_filter,
9335 (void *)&cmd_2tuple_filter_port_id,
9336 (void *)&cmd_2tuple_filter_ops,
9337 (void *)&cmd_2tuple_filter_dst_port,
9338 (void *)&cmd_2tuple_filter_dst_port_value,
9339 (void *)&cmd_2tuple_filter_protocol,
9340 (void *)&cmd_2tuple_filter_protocol_value,
9341 (void *)&cmd_2tuple_filter_mask,
9342 (void *)&cmd_2tuple_filter_mask_value,
9343 (void *)&cmd_2tuple_filter_tcp_flags,
9344 (void *)&cmd_2tuple_filter_tcp_flags_value,
9345 (void *)&cmd_2tuple_filter_priority,
9346 (void *)&cmd_2tuple_filter_priority_value,
9347 (void *)&cmd_2tuple_filter_queue,
9348 (void *)&cmd_2tuple_filter_queue_id,
9353 /* *** ADD/REMOVE A 5tuple FILTER *** */
9354 struct cmd_5tuple_filter_result {
9355 cmdline_fixed_string_t filter;
9357 cmdline_fixed_string_t ops;
9358 cmdline_fixed_string_t dst_ip;
9359 cmdline_ipaddr_t dst_ip_value;
9360 cmdline_fixed_string_t src_ip;
9361 cmdline_ipaddr_t src_ip_value;
9362 cmdline_fixed_string_t dst_port;
9363 uint16_t dst_port_value;
9364 cmdline_fixed_string_t src_port;
9365 uint16_t src_port_value;
9366 cmdline_fixed_string_t protocol;
9367 uint8_t protocol_value;
9368 cmdline_fixed_string_t mask;
9370 cmdline_fixed_string_t tcp_flags;
9371 uint8_t tcp_flags_value;
9372 cmdline_fixed_string_t priority;
9373 uint8_t priority_value;
9374 cmdline_fixed_string_t queue;
9379 cmd_5tuple_filter_parsed(void *parsed_result,
9380 __attribute__((unused)) struct cmdline *cl,
9381 __attribute__((unused)) void *data)
9383 struct rte_eth_ntuple_filter filter;
9384 struct cmd_5tuple_filter_result *res = parsed_result;
9387 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9389 printf("ntuple filter is not supported on port %u.\n",
9394 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9396 filter.flags = RTE_5TUPLE_FLAGS;
9397 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9398 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9399 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9400 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9401 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9402 filter.proto = res->protocol_value;
9403 filter.priority = res->priority_value;
9404 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9405 printf("nonzero tcp_flags is only meaningful"
9406 " when protocol is TCP.\n");
9409 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9410 printf("invalid TCP flags.\n");
9414 if (res->tcp_flags_value != 0) {
9415 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9416 filter.tcp_flags = res->tcp_flags_value;
9419 if (res->dst_ip_value.family == AF_INET)
9420 /* no need to convert, already big endian. */
9421 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9423 if (filter.dst_ip_mask == 0) {
9424 printf("can not support ipv6 involved compare.\n");
9430 if (res->src_ip_value.family == AF_INET)
9431 /* no need to convert, already big endian. */
9432 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9434 if (filter.src_ip_mask == 0) {
9435 printf("can not support ipv6 involved compare.\n");
9440 /* need convert to big endian. */
9441 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9442 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9443 filter.queue = res->queue_id;
9445 if (!strcmp(res->ops, "add"))
9446 ret = rte_eth_dev_filter_ctrl(res->port_id,
9447 RTE_ETH_FILTER_NTUPLE,
9451 ret = rte_eth_dev_filter_ctrl(res->port_id,
9452 RTE_ETH_FILTER_NTUPLE,
9453 RTE_ETH_FILTER_DELETE,
9456 printf("5tuple filter programming error: (%s)\n",
9460 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9461 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9462 filter, "5tuple_filter");
9463 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9464 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9466 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9467 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9469 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9470 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9472 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9473 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9475 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9476 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9478 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9479 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9481 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9482 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9483 dst_port, "dst_port");
9484 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9485 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9486 dst_port_value, UINT16);
9487 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9488 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9489 src_port, "src_port");
9490 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9491 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9492 src_port_value, UINT16);
9493 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9494 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9495 protocol, "protocol");
9496 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9497 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9498 protocol_value, UINT8);
9499 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9500 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9502 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9503 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9505 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9506 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9507 tcp_flags, "tcp_flags");
9508 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9509 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9510 tcp_flags_value, UINT8);
9511 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9512 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9513 priority, "priority");
9514 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9515 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9516 priority_value, UINT8);
9517 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9518 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9520 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9521 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9524 cmdline_parse_inst_t cmd_5tuple_filter = {
9525 .f = cmd_5tuple_filter_parsed,
9527 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9528 "src_ip <value> dst_port <value> src_port <value> "
9529 "protocol <value> mask <value> tcp_flags <value> "
9530 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9532 (void *)&cmd_5tuple_filter_filter,
9533 (void *)&cmd_5tuple_filter_port_id,
9534 (void *)&cmd_5tuple_filter_ops,
9535 (void *)&cmd_5tuple_filter_dst_ip,
9536 (void *)&cmd_5tuple_filter_dst_ip_value,
9537 (void *)&cmd_5tuple_filter_src_ip,
9538 (void *)&cmd_5tuple_filter_src_ip_value,
9539 (void *)&cmd_5tuple_filter_dst_port,
9540 (void *)&cmd_5tuple_filter_dst_port_value,
9541 (void *)&cmd_5tuple_filter_src_port,
9542 (void *)&cmd_5tuple_filter_src_port_value,
9543 (void *)&cmd_5tuple_filter_protocol,
9544 (void *)&cmd_5tuple_filter_protocol_value,
9545 (void *)&cmd_5tuple_filter_mask,
9546 (void *)&cmd_5tuple_filter_mask_value,
9547 (void *)&cmd_5tuple_filter_tcp_flags,
9548 (void *)&cmd_5tuple_filter_tcp_flags_value,
9549 (void *)&cmd_5tuple_filter_priority,
9550 (void *)&cmd_5tuple_filter_priority_value,
9551 (void *)&cmd_5tuple_filter_queue,
9552 (void *)&cmd_5tuple_filter_queue_id,
9557 /* *** ADD/REMOVE A flex FILTER *** */
9558 struct cmd_flex_filter_result {
9559 cmdline_fixed_string_t filter;
9560 cmdline_fixed_string_t ops;
9562 cmdline_fixed_string_t len;
9564 cmdline_fixed_string_t bytes;
9565 cmdline_fixed_string_t bytes_value;
9566 cmdline_fixed_string_t mask;
9567 cmdline_fixed_string_t mask_value;
9568 cmdline_fixed_string_t priority;
9569 uint8_t priority_value;
9570 cmdline_fixed_string_t queue;
9574 static int xdigit2val(unsigned char c)
9579 else if (isupper(c))
9587 cmd_flex_filter_parsed(void *parsed_result,
9588 __attribute__((unused)) struct cmdline *cl,
9589 __attribute__((unused)) void *data)
9592 struct rte_eth_flex_filter filter;
9593 struct cmd_flex_filter_result *res = parsed_result;
9594 char *bytes_ptr, *mask_ptr;
9595 uint16_t len, i, j = 0;
9600 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9601 printf("the len exceed the max length 128\n");
9604 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9605 filter.len = res->len_value;
9606 filter.priority = res->priority_value;
9607 filter.queue = res->queue_id;
9608 bytes_ptr = res->bytes_value;
9609 mask_ptr = res->mask_value;
9611 /* translate bytes string to array. */
9612 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9613 (bytes_ptr[1] == 'X')))
9615 len = strnlen(bytes_ptr, res->len_value * 2);
9616 if (len == 0 || (len % 8 != 0)) {
9617 printf("please check len and bytes input\n");
9620 for (i = 0; i < len; i++) {
9622 if (isxdigit(c) == 0) {
9623 /* invalid characters. */
9624 printf("invalid input\n");
9627 val = xdigit2val(c);
9630 filter.bytes[j] = byte;
9631 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9638 /* translate mask string to uint8_t array. */
9639 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9640 (mask_ptr[1] == 'X')))
9642 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9644 printf("invalid input\n");
9649 for (i = 0; i < len; i++) {
9651 if (isxdigit(c) == 0) {
9652 /* invalid characters. */
9653 printf("invalid input\n");
9656 val = xdigit2val(c);
9659 filter.mask[j] = byte;
9660 printf("mask[%d]:%02x ", j, filter.mask[j]);
9668 if (!strcmp(res->ops, "add"))
9669 ret = rte_eth_dev_filter_ctrl(res->port_id,
9670 RTE_ETH_FILTER_FLEXIBLE,
9674 ret = rte_eth_dev_filter_ctrl(res->port_id,
9675 RTE_ETH_FILTER_FLEXIBLE,
9676 RTE_ETH_FILTER_DELETE,
9680 printf("flex filter setting error: (%s)\n", strerror(-ret));
9683 cmdline_parse_token_string_t cmd_flex_filter_filter =
9684 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9685 filter, "flex_filter");
9686 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9687 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9689 cmdline_parse_token_string_t cmd_flex_filter_ops =
9690 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9692 cmdline_parse_token_string_t cmd_flex_filter_len =
9693 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9695 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9696 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9698 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9699 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9701 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9702 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9704 cmdline_parse_token_string_t cmd_flex_filter_mask =
9705 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9707 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9708 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9710 cmdline_parse_token_string_t cmd_flex_filter_priority =
9711 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9712 priority, "priority");
9713 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9714 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9715 priority_value, UINT8);
9716 cmdline_parse_token_string_t cmd_flex_filter_queue =
9717 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9719 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9720 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9722 cmdline_parse_inst_t cmd_flex_filter = {
9723 .f = cmd_flex_filter_parsed,
9725 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9726 "<value> mask <value> priority <value> queue <queue_id>: "
9727 "Add/Del a flex filter",
9729 (void *)&cmd_flex_filter_filter,
9730 (void *)&cmd_flex_filter_port_id,
9731 (void *)&cmd_flex_filter_ops,
9732 (void *)&cmd_flex_filter_len,
9733 (void *)&cmd_flex_filter_len_value,
9734 (void *)&cmd_flex_filter_bytes,
9735 (void *)&cmd_flex_filter_bytes_value,
9736 (void *)&cmd_flex_filter_mask,
9737 (void *)&cmd_flex_filter_mask_value,
9738 (void *)&cmd_flex_filter_priority,
9739 (void *)&cmd_flex_filter_priority_value,
9740 (void *)&cmd_flex_filter_queue,
9741 (void *)&cmd_flex_filter_queue_id,
9746 /* *** Filters Control *** */
9748 /* *** deal with ethertype filter *** */
9749 struct cmd_ethertype_filter_result {
9750 cmdline_fixed_string_t filter;
9752 cmdline_fixed_string_t ops;
9753 cmdline_fixed_string_t mac;
9754 struct ether_addr mac_addr;
9755 cmdline_fixed_string_t ethertype;
9756 uint16_t ethertype_value;
9757 cmdline_fixed_string_t drop;
9758 cmdline_fixed_string_t queue;
9762 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9763 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9764 filter, "ethertype_filter");
9765 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9766 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9768 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9769 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9771 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9772 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9773 mac, "mac_addr#mac_ignr");
9774 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9775 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9777 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9778 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9779 ethertype, "ethertype");
9780 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9781 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9782 ethertype_value, UINT16);
9783 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9784 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9786 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9787 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9789 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9790 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9794 cmd_ethertype_filter_parsed(void *parsed_result,
9795 __attribute__((unused)) struct cmdline *cl,
9796 __attribute__((unused)) void *data)
9798 struct cmd_ethertype_filter_result *res = parsed_result;
9799 struct rte_eth_ethertype_filter filter;
9802 ret = rte_eth_dev_filter_supported(res->port_id,
9803 RTE_ETH_FILTER_ETHERTYPE);
9805 printf("ethertype filter is not supported on port %u.\n",
9810 memset(&filter, 0, sizeof(filter));
9811 if (!strcmp(res->mac, "mac_addr")) {
9812 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9813 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9814 sizeof(struct ether_addr));
9816 if (!strcmp(res->drop, "drop"))
9817 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9818 filter.ether_type = res->ethertype_value;
9819 filter.queue = res->queue_id;
9821 if (!strcmp(res->ops, "add"))
9822 ret = rte_eth_dev_filter_ctrl(res->port_id,
9823 RTE_ETH_FILTER_ETHERTYPE,
9827 ret = rte_eth_dev_filter_ctrl(res->port_id,
9828 RTE_ETH_FILTER_ETHERTYPE,
9829 RTE_ETH_FILTER_DELETE,
9832 printf("ethertype filter programming error: (%s)\n",
9836 cmdline_parse_inst_t cmd_ethertype_filter = {
9837 .f = cmd_ethertype_filter_parsed,
9839 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9840 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9841 "Add or delete an ethertype filter entry",
9843 (void *)&cmd_ethertype_filter_filter,
9844 (void *)&cmd_ethertype_filter_port_id,
9845 (void *)&cmd_ethertype_filter_ops,
9846 (void *)&cmd_ethertype_filter_mac,
9847 (void *)&cmd_ethertype_filter_mac_addr,
9848 (void *)&cmd_ethertype_filter_ethertype,
9849 (void *)&cmd_ethertype_filter_ethertype_value,
9850 (void *)&cmd_ethertype_filter_drop,
9851 (void *)&cmd_ethertype_filter_queue,
9852 (void *)&cmd_ethertype_filter_queue_id,
9857 /* *** deal with flow director filter *** */
9858 struct cmd_flow_director_result {
9859 cmdline_fixed_string_t flow_director_filter;
9861 cmdline_fixed_string_t mode;
9862 cmdline_fixed_string_t mode_value;
9863 cmdline_fixed_string_t ops;
9864 cmdline_fixed_string_t flow;
9865 cmdline_fixed_string_t flow_type;
9866 cmdline_fixed_string_t ether;
9867 uint16_t ether_type;
9868 cmdline_fixed_string_t src;
9869 cmdline_ipaddr_t ip_src;
9871 cmdline_fixed_string_t dst;
9872 cmdline_ipaddr_t ip_dst;
9874 cmdline_fixed_string_t verify_tag;
9875 uint32_t verify_tag_value;
9876 cmdline_ipaddr_t tos;
9878 cmdline_ipaddr_t proto;
9879 uint8_t proto_value;
9880 cmdline_ipaddr_t ttl;
9882 cmdline_fixed_string_t vlan;
9883 uint16_t vlan_value;
9884 cmdline_fixed_string_t flexbytes;
9885 cmdline_fixed_string_t flexbytes_value;
9886 cmdline_fixed_string_t pf_vf;
9887 cmdline_fixed_string_t drop;
9888 cmdline_fixed_string_t queue;
9890 cmdline_fixed_string_t fd_id;
9891 uint32_t fd_id_value;
9892 cmdline_fixed_string_t mac;
9893 struct ether_addr mac_addr;
9894 cmdline_fixed_string_t tunnel;
9895 cmdline_fixed_string_t tunnel_type;
9896 cmdline_fixed_string_t tunnel_id;
9897 uint32_t tunnel_id_value;
9898 cmdline_fixed_string_t packet;
9903 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9906 const char *p, *p0 = q_arg;
9908 unsigned long int_fld;
9909 char *str_fld[max_num];
9914 p = strchr(p0, '(');
9918 p0 = strchr(p, ')');
9923 if (size >= sizeof(s))
9926 snprintf(s, sizeof(s), "%.*s", size, p);
9927 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9928 if (ret < 0 || ret > max_num)
9930 for (i = 0; i < ret; i++) {
9932 int_fld = strtoul(str_fld[i], &end, 0);
9933 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9935 flexbytes[i] = (uint8_t)int_fld;
9941 str2flowtype(char *string)
9944 static const struct {
9947 } flowtype_str[] = {
9948 {"raw", RTE_ETH_FLOW_RAW},
9949 {"ipv4", RTE_ETH_FLOW_IPV4},
9950 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9951 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9952 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9953 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9954 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9955 {"ipv6", RTE_ETH_FLOW_IPV6},
9956 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9957 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9958 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9959 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9960 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9961 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9964 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9965 if (!strcmp(flowtype_str[i].str, string))
9966 return flowtype_str[i].type;
9969 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9970 return (uint16_t)atoi(string);
9972 return RTE_ETH_FLOW_UNKNOWN;
9975 static enum rte_eth_fdir_tunnel_type
9976 str2fdir_tunneltype(char *string)
9980 static const struct {
9982 enum rte_eth_fdir_tunnel_type type;
9983 } tunneltype_str[] = {
9984 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9985 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9988 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9989 if (!strcmp(tunneltype_str[i].str, string))
9990 return tunneltype_str[i].type;
9992 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9995 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9997 if ((ip_addr).family == AF_INET) \
9998 (ip) = (ip_addr).addr.ipv4.s_addr; \
10000 printf("invalid parameter.\n"); \
10005 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10007 if ((ip_addr).family == AF_INET6) \
10008 rte_memcpy(&(ip), \
10009 &((ip_addr).addr.ipv6), \
10010 sizeof(struct in6_addr)); \
10012 printf("invalid parameter.\n"); \
10018 cmd_flow_director_filter_parsed(void *parsed_result,
10019 __attribute__((unused)) struct cmdline *cl,
10020 __attribute__((unused)) void *data)
10022 struct cmd_flow_director_result *res = parsed_result;
10023 struct rte_eth_fdir_filter entry;
10024 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10026 unsigned long vf_id;
10029 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10031 printf("flow director is not supported on port %u.\n",
10035 memset(flexbytes, 0, sizeof(flexbytes));
10036 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10038 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10039 if (strcmp(res->mode_value, "MAC-VLAN")) {
10040 printf("Please set mode to MAC-VLAN.\n");
10043 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10044 if (strcmp(res->mode_value, "Tunnel")) {
10045 printf("Please set mode to Tunnel.\n");
10049 if (!strcmp(res->mode_value, "raw")) {
10050 #ifdef RTE_LIBRTE_I40E_PMD
10051 struct rte_pmd_i40e_flow_type_mapping
10052 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10053 struct rte_pmd_i40e_pkt_template_conf conf;
10054 uint16_t flow_type = str2flowtype(res->flow_type);
10055 uint16_t i, port = res->port_id;
10058 memset(&conf, 0, sizeof(conf));
10060 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10061 printf("Invalid flow type specified.\n");
10064 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10068 if (mapping[flow_type].pctype == 0ULL) {
10069 printf("Invalid flow type specified.\n");
10072 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10073 if (mapping[flow_type].pctype & (1ULL << i)) {
10074 conf.input.pctype = i;
10079 conf.input.packet = open_file(res->filepath,
10080 &conf.input.length);
10081 if (!conf.input.packet)
10083 if (!strcmp(res->drop, "drop"))
10084 conf.action.behavior =
10085 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10087 conf.action.behavior =
10088 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10089 conf.action.report_status =
10090 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10091 conf.action.rx_queue = res->queue_id;
10092 conf.soft_id = res->fd_id_value;
10093 add = strcmp(res->ops, "del") ? 1 : 0;
10094 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10098 printf("flow director config error: (%s)\n",
10100 close_file(conf.input.packet);
10103 } else if (strcmp(res->mode_value, "IP")) {
10104 printf("Please set mode to IP or raw.\n");
10107 entry.input.flow_type = str2flowtype(res->flow_type);
10110 ret = parse_flexbytes(res->flexbytes_value,
10112 RTE_ETH_FDIR_MAX_FLEXLEN);
10114 printf("error: Cannot parse flexbytes input.\n");
10118 switch (entry.input.flow_type) {
10119 case RTE_ETH_FLOW_FRAG_IPV4:
10120 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10121 entry.input.flow.ip4_flow.proto = res->proto_value;
10123 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10124 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10125 IPV4_ADDR_TO_UINT(res->ip_dst,
10126 entry.input.flow.ip4_flow.dst_ip);
10127 IPV4_ADDR_TO_UINT(res->ip_src,
10128 entry.input.flow.ip4_flow.src_ip);
10129 entry.input.flow.ip4_flow.tos = res->tos_value;
10130 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10131 /* need convert to big endian. */
10132 entry.input.flow.udp4_flow.dst_port =
10133 rte_cpu_to_be_16(res->port_dst);
10134 entry.input.flow.udp4_flow.src_port =
10135 rte_cpu_to_be_16(res->port_src);
10137 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10138 IPV4_ADDR_TO_UINT(res->ip_dst,
10139 entry.input.flow.sctp4_flow.ip.dst_ip);
10140 IPV4_ADDR_TO_UINT(res->ip_src,
10141 entry.input.flow.sctp4_flow.ip.src_ip);
10142 entry.input.flow.ip4_flow.tos = res->tos_value;
10143 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10144 /* need convert to big endian. */
10145 entry.input.flow.sctp4_flow.dst_port =
10146 rte_cpu_to_be_16(res->port_dst);
10147 entry.input.flow.sctp4_flow.src_port =
10148 rte_cpu_to_be_16(res->port_src);
10149 entry.input.flow.sctp4_flow.verify_tag =
10150 rte_cpu_to_be_32(res->verify_tag_value);
10152 case RTE_ETH_FLOW_FRAG_IPV6:
10153 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10154 entry.input.flow.ipv6_flow.proto = res->proto_value;
10156 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10157 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10158 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10159 entry.input.flow.ipv6_flow.dst_ip);
10160 IPV6_ADDR_TO_ARRAY(res->ip_src,
10161 entry.input.flow.ipv6_flow.src_ip);
10162 entry.input.flow.ipv6_flow.tc = res->tos_value;
10163 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10164 /* need convert to big endian. */
10165 entry.input.flow.udp6_flow.dst_port =
10166 rte_cpu_to_be_16(res->port_dst);
10167 entry.input.flow.udp6_flow.src_port =
10168 rte_cpu_to_be_16(res->port_src);
10170 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10171 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10172 entry.input.flow.sctp6_flow.ip.dst_ip);
10173 IPV6_ADDR_TO_ARRAY(res->ip_src,
10174 entry.input.flow.sctp6_flow.ip.src_ip);
10175 entry.input.flow.ipv6_flow.tc = res->tos_value;
10176 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10177 /* need convert to big endian. */
10178 entry.input.flow.sctp6_flow.dst_port =
10179 rte_cpu_to_be_16(res->port_dst);
10180 entry.input.flow.sctp6_flow.src_port =
10181 rte_cpu_to_be_16(res->port_src);
10182 entry.input.flow.sctp6_flow.verify_tag =
10183 rte_cpu_to_be_32(res->verify_tag_value);
10185 case RTE_ETH_FLOW_L2_PAYLOAD:
10186 entry.input.flow.l2_flow.ether_type =
10187 rte_cpu_to_be_16(res->ether_type);
10193 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10194 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10196 sizeof(struct ether_addr));
10198 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10199 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10201 sizeof(struct ether_addr));
10202 entry.input.flow.tunnel_flow.tunnel_type =
10203 str2fdir_tunneltype(res->tunnel_type);
10204 entry.input.flow.tunnel_flow.tunnel_id =
10205 rte_cpu_to_be_32(res->tunnel_id_value);
10208 rte_memcpy(entry.input.flow_ext.flexbytes,
10210 RTE_ETH_FDIR_MAX_FLEXLEN);
10212 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10214 entry.action.flex_off = 0; /*use 0 by default */
10215 if (!strcmp(res->drop, "drop"))
10216 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10218 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10220 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10221 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10222 if (!strcmp(res->pf_vf, "pf"))
10223 entry.input.flow_ext.is_vf = 0;
10224 else if (!strncmp(res->pf_vf, "vf", 2)) {
10225 struct rte_eth_dev_info dev_info;
10227 memset(&dev_info, 0, sizeof(dev_info));
10228 rte_eth_dev_info_get(res->port_id, &dev_info);
10230 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10231 if (errno != 0 || *end != '\0' ||
10232 vf_id >= dev_info.max_vfs) {
10233 printf("invalid parameter %s.\n", res->pf_vf);
10236 entry.input.flow_ext.is_vf = 1;
10237 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10239 printf("invalid parameter %s.\n", res->pf_vf);
10244 /* set to report FD ID by default */
10245 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10246 entry.action.rx_queue = res->queue_id;
10247 entry.soft_id = res->fd_id_value;
10248 if (!strcmp(res->ops, "add"))
10249 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10250 RTE_ETH_FILTER_ADD, &entry);
10251 else if (!strcmp(res->ops, "del"))
10252 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10253 RTE_ETH_FILTER_DELETE, &entry);
10255 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10256 RTE_ETH_FILTER_UPDATE, &entry);
10258 printf("flow director programming error: (%s)\n",
10262 cmdline_parse_token_string_t cmd_flow_director_filter =
10263 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10264 flow_director_filter, "flow_director_filter");
10265 cmdline_parse_token_num_t cmd_flow_director_port_id =
10266 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10268 cmdline_parse_token_string_t cmd_flow_director_ops =
10269 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10270 ops, "add#del#update");
10271 cmdline_parse_token_string_t cmd_flow_director_flow =
10272 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10274 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10275 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10277 cmdline_parse_token_string_t cmd_flow_director_ether =
10278 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10280 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10281 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10282 ether_type, UINT16);
10283 cmdline_parse_token_string_t cmd_flow_director_src =
10284 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10286 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10287 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10289 cmdline_parse_token_num_t cmd_flow_director_port_src =
10290 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10292 cmdline_parse_token_string_t cmd_flow_director_dst =
10293 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10295 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10296 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10298 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10299 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10301 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10302 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10303 verify_tag, "verify_tag");
10304 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10305 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10306 verify_tag_value, UINT32);
10307 cmdline_parse_token_string_t cmd_flow_director_tos =
10308 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10310 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10311 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10313 cmdline_parse_token_string_t cmd_flow_director_proto =
10314 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10316 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10317 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10318 proto_value, UINT8);
10319 cmdline_parse_token_string_t cmd_flow_director_ttl =
10320 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10322 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10323 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10325 cmdline_parse_token_string_t cmd_flow_director_vlan =
10326 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10328 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10329 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10330 vlan_value, UINT16);
10331 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10332 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10333 flexbytes, "flexbytes");
10334 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10335 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10336 flexbytes_value, NULL);
10337 cmdline_parse_token_string_t cmd_flow_director_drop =
10338 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10340 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10341 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10343 cmdline_parse_token_string_t cmd_flow_director_queue =
10344 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10346 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10347 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10349 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10350 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10352 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10353 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10354 fd_id_value, UINT32);
10356 cmdline_parse_token_string_t cmd_flow_director_mode =
10357 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10359 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10360 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10362 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10363 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10364 mode_value, "MAC-VLAN");
10365 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10366 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10367 mode_value, "Tunnel");
10368 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10369 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10370 mode_value, "raw");
10371 cmdline_parse_token_string_t cmd_flow_director_mac =
10372 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10374 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10375 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10377 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10378 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10380 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10381 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10382 tunnel_type, "NVGRE#VxLAN");
10383 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10384 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10385 tunnel_id, "tunnel-id");
10386 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10387 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10388 tunnel_id_value, UINT32);
10389 cmdline_parse_token_string_t cmd_flow_director_packet =
10390 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10392 cmdline_parse_token_string_t cmd_flow_director_filepath =
10393 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10396 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10397 .f = cmd_flow_director_filter_parsed,
10399 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10400 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10401 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10402 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10403 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10404 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10405 "fd_id <fd_id_value>: "
10406 "Add or delete an ip flow director entry on NIC",
10408 (void *)&cmd_flow_director_filter,
10409 (void *)&cmd_flow_director_port_id,
10410 (void *)&cmd_flow_director_mode,
10411 (void *)&cmd_flow_director_mode_ip,
10412 (void *)&cmd_flow_director_ops,
10413 (void *)&cmd_flow_director_flow,
10414 (void *)&cmd_flow_director_flow_type,
10415 (void *)&cmd_flow_director_src,
10416 (void *)&cmd_flow_director_ip_src,
10417 (void *)&cmd_flow_director_dst,
10418 (void *)&cmd_flow_director_ip_dst,
10419 (void *)&cmd_flow_director_tos,
10420 (void *)&cmd_flow_director_tos_value,
10421 (void *)&cmd_flow_director_proto,
10422 (void *)&cmd_flow_director_proto_value,
10423 (void *)&cmd_flow_director_ttl,
10424 (void *)&cmd_flow_director_ttl_value,
10425 (void *)&cmd_flow_director_vlan,
10426 (void *)&cmd_flow_director_vlan_value,
10427 (void *)&cmd_flow_director_flexbytes,
10428 (void *)&cmd_flow_director_flexbytes_value,
10429 (void *)&cmd_flow_director_drop,
10430 (void *)&cmd_flow_director_pf_vf,
10431 (void *)&cmd_flow_director_queue,
10432 (void *)&cmd_flow_director_queue_id,
10433 (void *)&cmd_flow_director_fd_id,
10434 (void *)&cmd_flow_director_fd_id_value,
10439 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10440 .f = cmd_flow_director_filter_parsed,
10442 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10443 "director entry on NIC",
10445 (void *)&cmd_flow_director_filter,
10446 (void *)&cmd_flow_director_port_id,
10447 (void *)&cmd_flow_director_mode,
10448 (void *)&cmd_flow_director_mode_ip,
10449 (void *)&cmd_flow_director_ops,
10450 (void *)&cmd_flow_director_flow,
10451 (void *)&cmd_flow_director_flow_type,
10452 (void *)&cmd_flow_director_src,
10453 (void *)&cmd_flow_director_ip_src,
10454 (void *)&cmd_flow_director_port_src,
10455 (void *)&cmd_flow_director_dst,
10456 (void *)&cmd_flow_director_ip_dst,
10457 (void *)&cmd_flow_director_port_dst,
10458 (void *)&cmd_flow_director_tos,
10459 (void *)&cmd_flow_director_tos_value,
10460 (void *)&cmd_flow_director_ttl,
10461 (void *)&cmd_flow_director_ttl_value,
10462 (void *)&cmd_flow_director_vlan,
10463 (void *)&cmd_flow_director_vlan_value,
10464 (void *)&cmd_flow_director_flexbytes,
10465 (void *)&cmd_flow_director_flexbytes_value,
10466 (void *)&cmd_flow_director_drop,
10467 (void *)&cmd_flow_director_pf_vf,
10468 (void *)&cmd_flow_director_queue,
10469 (void *)&cmd_flow_director_queue_id,
10470 (void *)&cmd_flow_director_fd_id,
10471 (void *)&cmd_flow_director_fd_id_value,
10476 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10477 .f = cmd_flow_director_filter_parsed,
10479 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10480 "director entry on NIC",
10482 (void *)&cmd_flow_director_filter,
10483 (void *)&cmd_flow_director_port_id,
10484 (void *)&cmd_flow_director_mode,
10485 (void *)&cmd_flow_director_mode_ip,
10486 (void *)&cmd_flow_director_ops,
10487 (void *)&cmd_flow_director_flow,
10488 (void *)&cmd_flow_director_flow_type,
10489 (void *)&cmd_flow_director_src,
10490 (void *)&cmd_flow_director_ip_src,
10491 (void *)&cmd_flow_director_port_dst,
10492 (void *)&cmd_flow_director_dst,
10493 (void *)&cmd_flow_director_ip_dst,
10494 (void *)&cmd_flow_director_port_dst,
10495 (void *)&cmd_flow_director_verify_tag,
10496 (void *)&cmd_flow_director_verify_tag_value,
10497 (void *)&cmd_flow_director_tos,
10498 (void *)&cmd_flow_director_tos_value,
10499 (void *)&cmd_flow_director_ttl,
10500 (void *)&cmd_flow_director_ttl_value,
10501 (void *)&cmd_flow_director_vlan,
10502 (void *)&cmd_flow_director_vlan_value,
10503 (void *)&cmd_flow_director_flexbytes,
10504 (void *)&cmd_flow_director_flexbytes_value,
10505 (void *)&cmd_flow_director_drop,
10506 (void *)&cmd_flow_director_pf_vf,
10507 (void *)&cmd_flow_director_queue,
10508 (void *)&cmd_flow_director_queue_id,
10509 (void *)&cmd_flow_director_fd_id,
10510 (void *)&cmd_flow_director_fd_id_value,
10515 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10516 .f = cmd_flow_director_filter_parsed,
10518 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10519 "director entry on NIC",
10521 (void *)&cmd_flow_director_filter,
10522 (void *)&cmd_flow_director_port_id,
10523 (void *)&cmd_flow_director_mode,
10524 (void *)&cmd_flow_director_mode_ip,
10525 (void *)&cmd_flow_director_ops,
10526 (void *)&cmd_flow_director_flow,
10527 (void *)&cmd_flow_director_flow_type,
10528 (void *)&cmd_flow_director_ether,
10529 (void *)&cmd_flow_director_ether_type,
10530 (void *)&cmd_flow_director_flexbytes,
10531 (void *)&cmd_flow_director_flexbytes_value,
10532 (void *)&cmd_flow_director_drop,
10533 (void *)&cmd_flow_director_pf_vf,
10534 (void *)&cmd_flow_director_queue,
10535 (void *)&cmd_flow_director_queue_id,
10536 (void *)&cmd_flow_director_fd_id,
10537 (void *)&cmd_flow_director_fd_id_value,
10542 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10543 .f = cmd_flow_director_filter_parsed,
10545 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10546 "director entry on NIC",
10548 (void *)&cmd_flow_director_filter,
10549 (void *)&cmd_flow_director_port_id,
10550 (void *)&cmd_flow_director_mode,
10551 (void *)&cmd_flow_director_mode_mac_vlan,
10552 (void *)&cmd_flow_director_ops,
10553 (void *)&cmd_flow_director_mac,
10554 (void *)&cmd_flow_director_mac_addr,
10555 (void *)&cmd_flow_director_vlan,
10556 (void *)&cmd_flow_director_vlan_value,
10557 (void *)&cmd_flow_director_flexbytes,
10558 (void *)&cmd_flow_director_flexbytes_value,
10559 (void *)&cmd_flow_director_drop,
10560 (void *)&cmd_flow_director_queue,
10561 (void *)&cmd_flow_director_queue_id,
10562 (void *)&cmd_flow_director_fd_id,
10563 (void *)&cmd_flow_director_fd_id_value,
10568 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10569 .f = cmd_flow_director_filter_parsed,
10571 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10572 "director entry on NIC",
10574 (void *)&cmd_flow_director_filter,
10575 (void *)&cmd_flow_director_port_id,
10576 (void *)&cmd_flow_director_mode,
10577 (void *)&cmd_flow_director_mode_tunnel,
10578 (void *)&cmd_flow_director_ops,
10579 (void *)&cmd_flow_director_mac,
10580 (void *)&cmd_flow_director_mac_addr,
10581 (void *)&cmd_flow_director_vlan,
10582 (void *)&cmd_flow_director_vlan_value,
10583 (void *)&cmd_flow_director_tunnel,
10584 (void *)&cmd_flow_director_tunnel_type,
10585 (void *)&cmd_flow_director_tunnel_id,
10586 (void *)&cmd_flow_director_tunnel_id_value,
10587 (void *)&cmd_flow_director_flexbytes,
10588 (void *)&cmd_flow_director_flexbytes_value,
10589 (void *)&cmd_flow_director_drop,
10590 (void *)&cmd_flow_director_queue,
10591 (void *)&cmd_flow_director_queue_id,
10592 (void *)&cmd_flow_director_fd_id,
10593 (void *)&cmd_flow_director_fd_id_value,
10598 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10599 .f = cmd_flow_director_filter_parsed,
10601 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10602 "director entry on NIC",
10604 (void *)&cmd_flow_director_filter,
10605 (void *)&cmd_flow_director_port_id,
10606 (void *)&cmd_flow_director_mode,
10607 (void *)&cmd_flow_director_mode_raw,
10608 (void *)&cmd_flow_director_ops,
10609 (void *)&cmd_flow_director_flow,
10610 (void *)&cmd_flow_director_flow_type,
10611 (void *)&cmd_flow_director_drop,
10612 (void *)&cmd_flow_director_queue,
10613 (void *)&cmd_flow_director_queue_id,
10614 (void *)&cmd_flow_director_fd_id,
10615 (void *)&cmd_flow_director_fd_id_value,
10616 (void *)&cmd_flow_director_packet,
10617 (void *)&cmd_flow_director_filepath,
10622 struct cmd_flush_flow_director_result {
10623 cmdline_fixed_string_t flush_flow_director;
10627 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10628 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10629 flush_flow_director, "flush_flow_director");
10630 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10631 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10635 cmd_flush_flow_director_parsed(void *parsed_result,
10636 __attribute__((unused)) struct cmdline *cl,
10637 __attribute__((unused)) void *data)
10639 struct cmd_flow_director_result *res = parsed_result;
10642 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10644 printf("flow director is not supported on port %u.\n",
10649 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10650 RTE_ETH_FILTER_FLUSH, NULL);
10652 printf("flow director table flushing error: (%s)\n",
10656 cmdline_parse_inst_t cmd_flush_flow_director = {
10657 .f = cmd_flush_flow_director_parsed,
10659 .help_str = "flush_flow_director <port_id>: "
10660 "Flush all flow director entries of a device on NIC",
10662 (void *)&cmd_flush_flow_director_flush,
10663 (void *)&cmd_flush_flow_director_port_id,
10668 /* *** deal with flow director mask *** */
10669 struct cmd_flow_director_mask_result {
10670 cmdline_fixed_string_t flow_director_mask;
10672 cmdline_fixed_string_t mode;
10673 cmdline_fixed_string_t mode_value;
10674 cmdline_fixed_string_t vlan;
10675 uint16_t vlan_mask;
10676 cmdline_fixed_string_t src_mask;
10677 cmdline_ipaddr_t ipv4_src;
10678 cmdline_ipaddr_t ipv6_src;
10680 cmdline_fixed_string_t dst_mask;
10681 cmdline_ipaddr_t ipv4_dst;
10682 cmdline_ipaddr_t ipv6_dst;
10684 cmdline_fixed_string_t mac;
10685 uint8_t mac_addr_byte_mask;
10686 cmdline_fixed_string_t tunnel_id;
10687 uint32_t tunnel_id_mask;
10688 cmdline_fixed_string_t tunnel_type;
10689 uint8_t tunnel_type_mask;
10693 cmd_flow_director_mask_parsed(void *parsed_result,
10694 __attribute__((unused)) struct cmdline *cl,
10695 __attribute__((unused)) void *data)
10697 struct cmd_flow_director_mask_result *res = parsed_result;
10698 struct rte_eth_fdir_masks *mask;
10699 struct rte_port *port;
10701 if (res->port_id > nb_ports) {
10702 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10706 port = &ports[res->port_id];
10707 /** Check if the port is not started **/
10708 if (port->port_status != RTE_PORT_STOPPED) {
10709 printf("Please stop port %d first\n", res->port_id);
10713 mask = &port->dev_conf.fdir_conf.mask;
10715 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10716 if (strcmp(res->mode_value, "MAC-VLAN")) {
10717 printf("Please set mode to MAC-VLAN.\n");
10721 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10722 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10723 if (strcmp(res->mode_value, "Tunnel")) {
10724 printf("Please set mode to Tunnel.\n");
10728 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10729 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10730 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10731 mask->tunnel_type_mask = res->tunnel_type_mask;
10733 if (strcmp(res->mode_value, "IP")) {
10734 printf("Please set mode to IP.\n");
10738 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10739 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10740 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10741 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10742 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10743 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10744 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10747 cmd_reconfig_device_queue(res->port_id, 1, 1);
10750 cmdline_parse_token_string_t cmd_flow_director_mask =
10751 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10752 flow_director_mask, "flow_director_mask");
10753 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10754 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10756 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10757 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10759 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10760 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10761 vlan_mask, UINT16);
10762 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10763 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10764 src_mask, "src_mask");
10765 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10766 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10768 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10769 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10771 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10772 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10774 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10776 dst_mask, "dst_mask");
10777 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10778 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10780 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10781 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10783 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10784 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10787 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10788 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10790 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10791 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10793 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10794 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10795 mode_value, "MAC-VLAN");
10796 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10797 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10798 mode_value, "Tunnel");
10799 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10800 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10802 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10803 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10804 mac_addr_byte_mask, UINT8);
10805 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10806 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10807 tunnel_type, "tunnel-type");
10808 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10809 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10810 tunnel_type_mask, UINT8);
10811 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10812 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10813 tunnel_id, "tunnel-id");
10814 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10815 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10816 tunnel_id_mask, UINT32);
10818 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10819 .f = cmd_flow_director_mask_parsed,
10821 .help_str = "flow_director_mask ... : "
10822 "Set IP mode flow director's mask on NIC",
10824 (void *)&cmd_flow_director_mask,
10825 (void *)&cmd_flow_director_mask_port_id,
10826 (void *)&cmd_flow_director_mask_mode,
10827 (void *)&cmd_flow_director_mask_mode_ip,
10828 (void *)&cmd_flow_director_mask_vlan,
10829 (void *)&cmd_flow_director_mask_vlan_value,
10830 (void *)&cmd_flow_director_mask_src,
10831 (void *)&cmd_flow_director_mask_ipv4_src,
10832 (void *)&cmd_flow_director_mask_ipv6_src,
10833 (void *)&cmd_flow_director_mask_port_src,
10834 (void *)&cmd_flow_director_mask_dst,
10835 (void *)&cmd_flow_director_mask_ipv4_dst,
10836 (void *)&cmd_flow_director_mask_ipv6_dst,
10837 (void *)&cmd_flow_director_mask_port_dst,
10842 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10843 .f = cmd_flow_director_mask_parsed,
10845 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10846 "flow director's mask on NIC",
10848 (void *)&cmd_flow_director_mask,
10849 (void *)&cmd_flow_director_mask_port_id,
10850 (void *)&cmd_flow_director_mask_mode,
10851 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10852 (void *)&cmd_flow_director_mask_vlan,
10853 (void *)&cmd_flow_director_mask_vlan_value,
10858 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10859 .f = cmd_flow_director_mask_parsed,
10861 .help_str = "flow_director_mask ... : Set tunnel mode "
10862 "flow director's mask on NIC",
10864 (void *)&cmd_flow_director_mask,
10865 (void *)&cmd_flow_director_mask_port_id,
10866 (void *)&cmd_flow_director_mask_mode,
10867 (void *)&cmd_flow_director_mask_mode_tunnel,
10868 (void *)&cmd_flow_director_mask_vlan,
10869 (void *)&cmd_flow_director_mask_vlan_value,
10870 (void *)&cmd_flow_director_mask_mac,
10871 (void *)&cmd_flow_director_mask_mac_value,
10872 (void *)&cmd_flow_director_mask_tunnel_type,
10873 (void *)&cmd_flow_director_mask_tunnel_type_value,
10874 (void *)&cmd_flow_director_mask_tunnel_id,
10875 (void *)&cmd_flow_director_mask_tunnel_id_value,
10880 /* *** deal with flow director mask on flexible payload *** */
10881 struct cmd_flow_director_flex_mask_result {
10882 cmdline_fixed_string_t flow_director_flexmask;
10884 cmdline_fixed_string_t flow;
10885 cmdline_fixed_string_t flow_type;
10886 cmdline_fixed_string_t mask;
10890 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10891 __attribute__((unused)) struct cmdline *cl,
10892 __attribute__((unused)) void *data)
10894 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10895 struct rte_eth_fdir_info fdir_info;
10896 struct rte_eth_fdir_flex_mask flex_mask;
10897 struct rte_port *port;
10898 uint32_t flow_type_mask;
10902 if (res->port_id > nb_ports) {
10903 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10907 port = &ports[res->port_id];
10908 /** Check if the port is not started **/
10909 if (port->port_status != RTE_PORT_STOPPED) {
10910 printf("Please stop port %d first\n", res->port_id);
10914 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10915 ret = parse_flexbytes(res->mask,
10917 RTE_ETH_FDIR_MAX_FLEXLEN);
10919 printf("error: Cannot parse mask input.\n");
10923 memset(&fdir_info, 0, sizeof(fdir_info));
10924 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10925 RTE_ETH_FILTER_INFO, &fdir_info);
10927 printf("Cannot get FDir filter info\n");
10931 if (!strcmp(res->flow_type, "none")) {
10932 /* means don't specify the flow type */
10933 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10934 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10935 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10936 0, sizeof(struct rte_eth_fdir_flex_mask));
10937 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10938 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10940 sizeof(struct rte_eth_fdir_flex_mask));
10941 cmd_reconfig_device_queue(res->port_id, 1, 1);
10944 flow_type_mask = fdir_info.flow_types_mask[0];
10945 if (!strcmp(res->flow_type, "all")) {
10946 if (!flow_type_mask) {
10947 printf("No flow type supported\n");
10950 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10951 if (flow_type_mask & (1 << i)) {
10952 flex_mask.flow_type = i;
10953 fdir_set_flex_mask(res->port_id, &flex_mask);
10956 cmd_reconfig_device_queue(res->port_id, 1, 1);
10959 flex_mask.flow_type = str2flowtype(res->flow_type);
10960 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10961 printf("Flow type %s not supported on port %d\n",
10962 res->flow_type, res->port_id);
10965 fdir_set_flex_mask(res->port_id, &flex_mask);
10966 cmd_reconfig_device_queue(res->port_id, 1, 1);
10969 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10970 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10971 flow_director_flexmask,
10972 "flow_director_flex_mask");
10973 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10974 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10976 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10977 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10979 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10980 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10981 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10982 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10983 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10984 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10987 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10988 .f = cmd_flow_director_flex_mask_parsed,
10990 .help_str = "flow_director_flex_mask ... : "
10991 "Set flow director's flex mask on NIC",
10993 (void *)&cmd_flow_director_flexmask,
10994 (void *)&cmd_flow_director_flexmask_port_id,
10995 (void *)&cmd_flow_director_flexmask_flow,
10996 (void *)&cmd_flow_director_flexmask_flow_type,
10997 (void *)&cmd_flow_director_flexmask_mask,
11002 /* *** deal with flow director flexible payload configuration *** */
11003 struct cmd_flow_director_flexpayload_result {
11004 cmdline_fixed_string_t flow_director_flexpayload;
11006 cmdline_fixed_string_t payload_layer;
11007 cmdline_fixed_string_t payload_cfg;
11011 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11014 const char *p, *p0 = q_arg;
11016 unsigned long int_fld;
11017 char *str_fld[max_num];
11022 p = strchr(p0, '(');
11026 p0 = strchr(p, ')');
11031 if (size >= sizeof(s))
11034 snprintf(s, sizeof(s), "%.*s", size, p);
11035 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11036 if (ret < 0 || ret > max_num)
11038 for (i = 0; i < ret; i++) {
11040 int_fld = strtoul(str_fld[i], &end, 0);
11041 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11043 offsets[i] = (uint16_t)int_fld;
11049 cmd_flow_director_flxpld_parsed(void *parsed_result,
11050 __attribute__((unused)) struct cmdline *cl,
11051 __attribute__((unused)) void *data)
11053 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11054 struct rte_eth_flex_payload_cfg flex_cfg;
11055 struct rte_port *port;
11058 if (res->port_id > nb_ports) {
11059 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
11063 port = &ports[res->port_id];
11064 /** Check if the port is not started **/
11065 if (port->port_status != RTE_PORT_STOPPED) {
11066 printf("Please stop port %d first\n", res->port_id);
11070 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11072 if (!strcmp(res->payload_layer, "raw"))
11073 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11074 else if (!strcmp(res->payload_layer, "l2"))
11075 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11076 else if (!strcmp(res->payload_layer, "l3"))
11077 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11078 else if (!strcmp(res->payload_layer, "l4"))
11079 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11081 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11082 RTE_ETH_FDIR_MAX_FLEXLEN);
11084 printf("error: Cannot parse flex payload input.\n");
11088 fdir_set_flex_payload(res->port_id, &flex_cfg);
11089 cmd_reconfig_device_queue(res->port_id, 1, 1);
11092 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11093 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11094 flow_director_flexpayload,
11095 "flow_director_flex_payload");
11096 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11097 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11099 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11100 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11101 payload_layer, "raw#l2#l3#l4");
11102 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11103 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11104 payload_cfg, NULL);
11106 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11107 .f = cmd_flow_director_flxpld_parsed,
11109 .help_str = "flow_director_flexpayload ... : "
11110 "Set flow director's flex payload on NIC",
11112 (void *)&cmd_flow_director_flexpayload,
11113 (void *)&cmd_flow_director_flexpayload_port_id,
11114 (void *)&cmd_flow_director_flexpayload_payload_layer,
11115 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11120 /* Generic flow interface command. */
11121 extern cmdline_parse_inst_t cmd_flow;
11123 /* *** Classification Filters Control *** */
11124 /* *** Get symmetric hash enable per port *** */
11125 struct cmd_get_sym_hash_ena_per_port_result {
11126 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11131 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11132 __rte_unused struct cmdline *cl,
11133 __rte_unused void *data)
11135 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11136 struct rte_eth_hash_filter_info info;
11139 if (rte_eth_dev_filter_supported(res->port_id,
11140 RTE_ETH_FILTER_HASH) < 0) {
11141 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11146 memset(&info, 0, sizeof(info));
11147 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11148 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11149 RTE_ETH_FILTER_GET, &info);
11152 printf("Cannot get symmetric hash enable per port "
11153 "on port %u\n", res->port_id);
11157 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11158 "enabled" : "disabled", res->port_id);
11161 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11162 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11163 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11164 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11165 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11168 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11169 .f = cmd_get_sym_hash_per_port_parsed,
11171 .help_str = "get_sym_hash_ena_per_port <port_id>",
11173 (void *)&cmd_get_sym_hash_ena_per_port_all,
11174 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11179 /* *** Set symmetric hash enable per port *** */
11180 struct cmd_set_sym_hash_ena_per_port_result {
11181 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11182 cmdline_fixed_string_t enable;
11187 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11188 __rte_unused struct cmdline *cl,
11189 __rte_unused void *data)
11191 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11192 struct rte_eth_hash_filter_info info;
11195 if (rte_eth_dev_filter_supported(res->port_id,
11196 RTE_ETH_FILTER_HASH) < 0) {
11197 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11202 memset(&info, 0, sizeof(info));
11203 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11204 if (!strcmp(res->enable, "enable"))
11205 info.info.enable = 1;
11206 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11207 RTE_ETH_FILTER_SET, &info);
11209 printf("Cannot set symmetric hash enable per port on "
11210 "port %u\n", res->port_id);
11213 printf("Symmetric hash has been set to %s on port %u\n",
11214 res->enable, res->port_id);
11217 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11218 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11219 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11220 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11221 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11223 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11224 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11225 enable, "enable#disable");
11227 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11228 .f = cmd_set_sym_hash_per_port_parsed,
11230 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11232 (void *)&cmd_set_sym_hash_ena_per_port_all,
11233 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11234 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11239 /* Get global config of hash function */
11240 struct cmd_get_hash_global_config_result {
11241 cmdline_fixed_string_t get_hash_global_config;
11246 flowtype_to_str(uint16_t ftype)
11252 } ftype_table[] = {
11253 {"ipv4", RTE_ETH_FLOW_IPV4},
11254 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11255 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11256 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11257 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11258 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11259 {"ipv6", RTE_ETH_FLOW_IPV6},
11260 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11261 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11262 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11263 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11264 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11265 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11266 {"port", RTE_ETH_FLOW_PORT},
11267 {"vxlan", RTE_ETH_FLOW_VXLAN},
11268 {"geneve", RTE_ETH_FLOW_GENEVE},
11269 {"nvgre", RTE_ETH_FLOW_NVGRE},
11272 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11273 if (ftype_table[i].ftype == ftype)
11274 return ftype_table[i].str;
11281 cmd_get_hash_global_config_parsed(void *parsed_result,
11282 __rte_unused struct cmdline *cl,
11283 __rte_unused void *data)
11285 struct cmd_get_hash_global_config_result *res = parsed_result;
11286 struct rte_eth_hash_filter_info info;
11287 uint32_t idx, offset;
11292 if (rte_eth_dev_filter_supported(res->port_id,
11293 RTE_ETH_FILTER_HASH) < 0) {
11294 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11299 memset(&info, 0, sizeof(info));
11300 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11301 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11302 RTE_ETH_FILTER_GET, &info);
11304 printf("Cannot get hash global configurations by port %d\n",
11309 switch (info.info.global_conf.hash_func) {
11310 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11311 printf("Hash function is Toeplitz\n");
11313 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11314 printf("Hash function is Simple XOR\n");
11317 printf("Unknown hash function\n");
11321 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11322 idx = i / UINT32_BIT;
11323 offset = i % UINT32_BIT;
11324 if (!(info.info.global_conf.valid_bit_mask[idx] &
11327 str = flowtype_to_str(i);
11330 printf("Symmetric hash is %s globally for flow type %s "
11332 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11333 (1UL << offset)) ? "enabled" : "disabled"), str,
11338 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11339 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11340 get_hash_global_config, "get_hash_global_config");
11341 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11342 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11345 cmdline_parse_inst_t cmd_get_hash_global_config = {
11346 .f = cmd_get_hash_global_config_parsed,
11348 .help_str = "get_hash_global_config <port_id>",
11350 (void *)&cmd_get_hash_global_config_all,
11351 (void *)&cmd_get_hash_global_config_port_id,
11356 /* Set global config of hash function */
11357 struct cmd_set_hash_global_config_result {
11358 cmdline_fixed_string_t set_hash_global_config;
11360 cmdline_fixed_string_t hash_func;
11361 cmdline_fixed_string_t flow_type;
11362 cmdline_fixed_string_t enable;
11366 cmd_set_hash_global_config_parsed(void *parsed_result,
11367 __rte_unused struct cmdline *cl,
11368 __rte_unused void *data)
11370 struct cmd_set_hash_global_config_result *res = parsed_result;
11371 struct rte_eth_hash_filter_info info;
11372 uint32_t ftype, idx, offset;
11375 if (rte_eth_dev_filter_supported(res->port_id,
11376 RTE_ETH_FILTER_HASH) < 0) {
11377 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11381 memset(&info, 0, sizeof(info));
11382 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11383 if (!strcmp(res->hash_func, "toeplitz"))
11384 info.info.global_conf.hash_func =
11385 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11386 else if (!strcmp(res->hash_func, "simple_xor"))
11387 info.info.global_conf.hash_func =
11388 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11389 else if (!strcmp(res->hash_func, "default"))
11390 info.info.global_conf.hash_func =
11391 RTE_ETH_HASH_FUNCTION_DEFAULT;
11393 ftype = str2flowtype(res->flow_type);
11394 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11395 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11396 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11397 if (!strcmp(res->enable, "enable"))
11398 info.info.global_conf.sym_hash_enable_mask[idx] |=
11400 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11401 RTE_ETH_FILTER_SET, &info);
11403 printf("Cannot set global hash configurations by port %d\n",
11406 printf("Global hash configurations have been set "
11407 "succcessfully by port %d\n", res->port_id);
11410 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11411 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11412 set_hash_global_config, "set_hash_global_config");
11413 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11414 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11416 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11417 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11418 hash_func, "toeplitz#simple_xor#default");
11419 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11420 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11422 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11423 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11424 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11425 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11426 enable, "enable#disable");
11428 cmdline_parse_inst_t cmd_set_hash_global_config = {
11429 .f = cmd_set_hash_global_config_parsed,
11431 .help_str = "set_hash_global_config <port_id> "
11432 "toeplitz|simple_xor|default "
11433 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11434 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11435 "l2_payload enable|disable",
11437 (void *)&cmd_set_hash_global_config_all,
11438 (void *)&cmd_set_hash_global_config_port_id,
11439 (void *)&cmd_set_hash_global_config_hash_func,
11440 (void *)&cmd_set_hash_global_config_flow_type,
11441 (void *)&cmd_set_hash_global_config_enable,
11446 /* Set hash input set */
11447 struct cmd_set_hash_input_set_result {
11448 cmdline_fixed_string_t set_hash_input_set;
11450 cmdline_fixed_string_t flow_type;
11451 cmdline_fixed_string_t inset_field;
11452 cmdline_fixed_string_t select;
11455 static enum rte_eth_input_set_field
11456 str2inset(char *string)
11460 static const struct {
11462 enum rte_eth_input_set_field inset;
11463 } inset_table[] = {
11464 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11465 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11466 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11467 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11468 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11469 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11470 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11471 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11472 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11473 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11474 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11475 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11476 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11477 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11478 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11479 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11480 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11481 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11482 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11483 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11484 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11485 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11486 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11487 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11488 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11489 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11490 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11491 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11492 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11493 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11494 {"none", RTE_ETH_INPUT_SET_NONE},
11497 for (i = 0; i < RTE_DIM(inset_table); i++) {
11498 if (!strcmp(string, inset_table[i].str))
11499 return inset_table[i].inset;
11502 return RTE_ETH_INPUT_SET_UNKNOWN;
11506 cmd_set_hash_input_set_parsed(void *parsed_result,
11507 __rte_unused struct cmdline *cl,
11508 __rte_unused void *data)
11510 struct cmd_set_hash_input_set_result *res = parsed_result;
11511 struct rte_eth_hash_filter_info info;
11513 memset(&info, 0, sizeof(info));
11514 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11515 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11516 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11517 info.info.input_set_conf.inset_size = 1;
11518 if (!strcmp(res->select, "select"))
11519 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11520 else if (!strcmp(res->select, "add"))
11521 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11522 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11523 RTE_ETH_FILTER_SET, &info);
11526 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11527 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11528 set_hash_input_set, "set_hash_input_set");
11529 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11530 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11532 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11533 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11535 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11536 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11538 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11539 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11540 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11541 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11542 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11544 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11545 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11546 select, "select#add");
11548 cmdline_parse_inst_t cmd_set_hash_input_set = {
11549 .f = cmd_set_hash_input_set_parsed,
11551 .help_str = "set_hash_input_set <port_id> "
11552 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11553 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11554 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11555 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11556 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11557 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11558 "fld-7th|fld-8th|none select|add",
11560 (void *)&cmd_set_hash_input_set_cmd,
11561 (void *)&cmd_set_hash_input_set_port_id,
11562 (void *)&cmd_set_hash_input_set_flow_type,
11563 (void *)&cmd_set_hash_input_set_field,
11564 (void *)&cmd_set_hash_input_set_select,
11569 /* Set flow director input set */
11570 struct cmd_set_fdir_input_set_result {
11571 cmdline_fixed_string_t set_fdir_input_set;
11573 cmdline_fixed_string_t flow_type;
11574 cmdline_fixed_string_t inset_field;
11575 cmdline_fixed_string_t select;
11579 cmd_set_fdir_input_set_parsed(void *parsed_result,
11580 __rte_unused struct cmdline *cl,
11581 __rte_unused void *data)
11583 struct cmd_set_fdir_input_set_result *res = parsed_result;
11584 struct rte_eth_fdir_filter_info info;
11586 memset(&info, 0, sizeof(info));
11587 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11588 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11589 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11590 info.info.input_set_conf.inset_size = 1;
11591 if (!strcmp(res->select, "select"))
11592 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11593 else if (!strcmp(res->select, "add"))
11594 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11595 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11596 RTE_ETH_FILTER_SET, &info);
11599 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11600 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11601 set_fdir_input_set, "set_fdir_input_set");
11602 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11603 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11605 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11606 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11608 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11609 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11610 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11611 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11613 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11614 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11615 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11616 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11617 "sctp-veri-tag#none");
11618 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11619 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11620 select, "select#add");
11622 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11623 .f = cmd_set_fdir_input_set_parsed,
11625 .help_str = "set_fdir_input_set <port_id> "
11626 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11627 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11628 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11629 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11630 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11631 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11632 "sctp-veri-tag|none select|add",
11634 (void *)&cmd_set_fdir_input_set_cmd,
11635 (void *)&cmd_set_fdir_input_set_port_id,
11636 (void *)&cmd_set_fdir_input_set_flow_type,
11637 (void *)&cmd_set_fdir_input_set_field,
11638 (void *)&cmd_set_fdir_input_set_select,
11643 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11644 struct cmd_mcast_addr_result {
11645 cmdline_fixed_string_t mcast_addr_cmd;
11646 cmdline_fixed_string_t what;
11648 struct ether_addr mc_addr;
11651 static void cmd_mcast_addr_parsed(void *parsed_result,
11652 __attribute__((unused)) struct cmdline *cl,
11653 __attribute__((unused)) void *data)
11655 struct cmd_mcast_addr_result *res = parsed_result;
11657 if (!is_multicast_ether_addr(&res->mc_addr)) {
11658 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11659 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11660 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11661 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11664 if (strcmp(res->what, "add") == 0)
11665 mcast_addr_add(res->port_num, &res->mc_addr);
11667 mcast_addr_remove(res->port_num, &res->mc_addr);
11670 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11671 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11672 mcast_addr_cmd, "mcast_addr");
11673 cmdline_parse_token_string_t cmd_mcast_addr_what =
11674 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11676 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11677 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11678 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11679 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11681 cmdline_parse_inst_t cmd_mcast_addr = {
11682 .f = cmd_mcast_addr_parsed,
11684 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11685 "Add/Remove multicast MAC address on port_id",
11687 (void *)&cmd_mcast_addr_cmd,
11688 (void *)&cmd_mcast_addr_what,
11689 (void *)&cmd_mcast_addr_portnum,
11690 (void *)&cmd_mcast_addr_addr,
11695 /* l2 tunnel config
11696 * only support E-tag now.
11699 /* Ether type config */
11700 struct cmd_config_l2_tunnel_eth_type_result {
11701 cmdline_fixed_string_t port;
11702 cmdline_fixed_string_t config;
11703 cmdline_fixed_string_t all;
11705 cmdline_fixed_string_t l2_tunnel;
11706 cmdline_fixed_string_t l2_tunnel_type;
11707 cmdline_fixed_string_t eth_type;
11708 uint16_t eth_type_val;
11711 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11712 TOKEN_STRING_INITIALIZER
11713 (struct cmd_config_l2_tunnel_eth_type_result,
11715 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11716 TOKEN_STRING_INITIALIZER
11717 (struct cmd_config_l2_tunnel_eth_type_result,
11719 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11720 TOKEN_STRING_INITIALIZER
11721 (struct cmd_config_l2_tunnel_eth_type_result,
11723 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11724 TOKEN_NUM_INITIALIZER
11725 (struct cmd_config_l2_tunnel_eth_type_result,
11727 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11728 TOKEN_STRING_INITIALIZER
11729 (struct cmd_config_l2_tunnel_eth_type_result,
11730 l2_tunnel, "l2-tunnel");
11731 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11732 TOKEN_STRING_INITIALIZER
11733 (struct cmd_config_l2_tunnel_eth_type_result,
11734 l2_tunnel_type, "E-tag");
11735 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11736 TOKEN_STRING_INITIALIZER
11737 (struct cmd_config_l2_tunnel_eth_type_result,
11738 eth_type, "ether-type");
11739 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11740 TOKEN_NUM_INITIALIZER
11741 (struct cmd_config_l2_tunnel_eth_type_result,
11742 eth_type_val, UINT16);
11744 static enum rte_eth_tunnel_type
11745 str2fdir_l2_tunnel_type(char *string)
11749 static const struct {
11751 enum rte_eth_tunnel_type type;
11752 } l2_tunnel_type_str[] = {
11753 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11756 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11757 if (!strcmp(l2_tunnel_type_str[i].str, string))
11758 return l2_tunnel_type_str[i].type;
11760 return RTE_TUNNEL_TYPE_NONE;
11763 /* ether type config for all ports */
11765 cmd_config_l2_tunnel_eth_type_all_parsed
11766 (void *parsed_result,
11767 __attribute__((unused)) struct cmdline *cl,
11768 __attribute__((unused)) void *data)
11770 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11771 struct rte_eth_l2_tunnel_conf entry;
11774 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11775 entry.ether_type = res->eth_type_val;
11777 RTE_ETH_FOREACH_DEV(pid) {
11778 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11782 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11783 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11785 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11787 (void *)&cmd_config_l2_tunnel_eth_type_port,
11788 (void *)&cmd_config_l2_tunnel_eth_type_config,
11789 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11790 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11791 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11792 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11793 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11798 /* ether type config for a specific port */
11800 cmd_config_l2_tunnel_eth_type_specific_parsed(
11801 void *parsed_result,
11802 __attribute__((unused)) struct cmdline *cl,
11803 __attribute__((unused)) void *data)
11805 struct cmd_config_l2_tunnel_eth_type_result *res =
11807 struct rte_eth_l2_tunnel_conf entry;
11809 if (port_id_is_invalid(res->id, ENABLED_WARN))
11812 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11813 entry.ether_type = res->eth_type_val;
11815 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11818 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11819 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11821 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11823 (void *)&cmd_config_l2_tunnel_eth_type_port,
11824 (void *)&cmd_config_l2_tunnel_eth_type_config,
11825 (void *)&cmd_config_l2_tunnel_eth_type_id,
11826 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11827 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11828 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11829 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11834 /* Enable/disable l2 tunnel */
11835 struct cmd_config_l2_tunnel_en_dis_result {
11836 cmdline_fixed_string_t port;
11837 cmdline_fixed_string_t config;
11838 cmdline_fixed_string_t all;
11840 cmdline_fixed_string_t l2_tunnel;
11841 cmdline_fixed_string_t l2_tunnel_type;
11842 cmdline_fixed_string_t en_dis;
11845 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11846 TOKEN_STRING_INITIALIZER
11847 (struct cmd_config_l2_tunnel_en_dis_result,
11849 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11850 TOKEN_STRING_INITIALIZER
11851 (struct cmd_config_l2_tunnel_en_dis_result,
11853 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11854 TOKEN_STRING_INITIALIZER
11855 (struct cmd_config_l2_tunnel_en_dis_result,
11857 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11858 TOKEN_NUM_INITIALIZER
11859 (struct cmd_config_l2_tunnel_en_dis_result,
11861 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11862 TOKEN_STRING_INITIALIZER
11863 (struct cmd_config_l2_tunnel_en_dis_result,
11864 l2_tunnel, "l2-tunnel");
11865 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11866 TOKEN_STRING_INITIALIZER
11867 (struct cmd_config_l2_tunnel_en_dis_result,
11868 l2_tunnel_type, "E-tag");
11869 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11870 TOKEN_STRING_INITIALIZER
11871 (struct cmd_config_l2_tunnel_en_dis_result,
11872 en_dis, "enable#disable");
11874 /* enable/disable l2 tunnel for all ports */
11876 cmd_config_l2_tunnel_en_dis_all_parsed(
11877 void *parsed_result,
11878 __attribute__((unused)) struct cmdline *cl,
11879 __attribute__((unused)) void *data)
11881 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11882 struct rte_eth_l2_tunnel_conf entry;
11886 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11888 if (!strcmp("enable", res->en_dis))
11893 RTE_ETH_FOREACH_DEV(pid) {
11894 rte_eth_dev_l2_tunnel_offload_set(pid,
11896 ETH_L2_TUNNEL_ENABLE_MASK,
11901 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11902 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11904 .help_str = "port config all l2-tunnel E-tag enable|disable",
11906 (void *)&cmd_config_l2_tunnel_en_dis_port,
11907 (void *)&cmd_config_l2_tunnel_en_dis_config,
11908 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11909 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11910 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11911 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11916 /* enable/disable l2 tunnel for a port */
11918 cmd_config_l2_tunnel_en_dis_specific_parsed(
11919 void *parsed_result,
11920 __attribute__((unused)) struct cmdline *cl,
11921 __attribute__((unused)) void *data)
11923 struct cmd_config_l2_tunnel_en_dis_result *res =
11925 struct rte_eth_l2_tunnel_conf entry;
11927 if (port_id_is_invalid(res->id, ENABLED_WARN))
11930 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11932 if (!strcmp("enable", res->en_dis))
11933 rte_eth_dev_l2_tunnel_offload_set(res->id,
11935 ETH_L2_TUNNEL_ENABLE_MASK,
11938 rte_eth_dev_l2_tunnel_offload_set(res->id,
11940 ETH_L2_TUNNEL_ENABLE_MASK,
11944 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11945 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11947 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11949 (void *)&cmd_config_l2_tunnel_en_dis_port,
11950 (void *)&cmd_config_l2_tunnel_en_dis_config,
11951 (void *)&cmd_config_l2_tunnel_en_dis_id,
11952 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11953 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11954 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11959 /* E-tag configuration */
11961 /* Common result structure for all E-tag configuration */
11962 struct cmd_config_e_tag_result {
11963 cmdline_fixed_string_t e_tag;
11964 cmdline_fixed_string_t set;
11965 cmdline_fixed_string_t insertion;
11966 cmdline_fixed_string_t stripping;
11967 cmdline_fixed_string_t forwarding;
11968 cmdline_fixed_string_t filter;
11969 cmdline_fixed_string_t add;
11970 cmdline_fixed_string_t del;
11971 cmdline_fixed_string_t on;
11972 cmdline_fixed_string_t off;
11973 cmdline_fixed_string_t on_off;
11974 cmdline_fixed_string_t port_tag_id;
11975 uint32_t port_tag_id_val;
11976 cmdline_fixed_string_t e_tag_id;
11977 uint16_t e_tag_id_val;
11978 cmdline_fixed_string_t dst_pool;
11979 uint8_t dst_pool_val;
11980 cmdline_fixed_string_t port;
11982 cmdline_fixed_string_t vf;
11986 /* Common CLI fields for all E-tag configuration */
11987 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11988 TOKEN_STRING_INITIALIZER
11989 (struct cmd_config_e_tag_result,
11991 cmdline_parse_token_string_t cmd_config_e_tag_set =
11992 TOKEN_STRING_INITIALIZER
11993 (struct cmd_config_e_tag_result,
11995 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11996 TOKEN_STRING_INITIALIZER
11997 (struct cmd_config_e_tag_result,
11998 insertion, "insertion");
11999 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12000 TOKEN_STRING_INITIALIZER
12001 (struct cmd_config_e_tag_result,
12002 stripping, "stripping");
12003 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12004 TOKEN_STRING_INITIALIZER
12005 (struct cmd_config_e_tag_result,
12006 forwarding, "forwarding");
12007 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12008 TOKEN_STRING_INITIALIZER
12009 (struct cmd_config_e_tag_result,
12011 cmdline_parse_token_string_t cmd_config_e_tag_add =
12012 TOKEN_STRING_INITIALIZER
12013 (struct cmd_config_e_tag_result,
12015 cmdline_parse_token_string_t cmd_config_e_tag_del =
12016 TOKEN_STRING_INITIALIZER
12017 (struct cmd_config_e_tag_result,
12019 cmdline_parse_token_string_t cmd_config_e_tag_on =
12020 TOKEN_STRING_INITIALIZER
12021 (struct cmd_config_e_tag_result,
12023 cmdline_parse_token_string_t cmd_config_e_tag_off =
12024 TOKEN_STRING_INITIALIZER
12025 (struct cmd_config_e_tag_result,
12027 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12028 TOKEN_STRING_INITIALIZER
12029 (struct cmd_config_e_tag_result,
12031 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12032 TOKEN_STRING_INITIALIZER
12033 (struct cmd_config_e_tag_result,
12034 port_tag_id, "port-tag-id");
12035 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12036 TOKEN_NUM_INITIALIZER
12037 (struct cmd_config_e_tag_result,
12038 port_tag_id_val, UINT32);
12039 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12040 TOKEN_STRING_INITIALIZER
12041 (struct cmd_config_e_tag_result,
12042 e_tag_id, "e-tag-id");
12043 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12044 TOKEN_NUM_INITIALIZER
12045 (struct cmd_config_e_tag_result,
12046 e_tag_id_val, UINT16);
12047 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12048 TOKEN_STRING_INITIALIZER
12049 (struct cmd_config_e_tag_result,
12050 dst_pool, "dst-pool");
12051 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12052 TOKEN_NUM_INITIALIZER
12053 (struct cmd_config_e_tag_result,
12054 dst_pool_val, UINT8);
12055 cmdline_parse_token_string_t cmd_config_e_tag_port =
12056 TOKEN_STRING_INITIALIZER
12057 (struct cmd_config_e_tag_result,
12059 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12060 TOKEN_NUM_INITIALIZER
12061 (struct cmd_config_e_tag_result,
12063 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12064 TOKEN_STRING_INITIALIZER
12065 (struct cmd_config_e_tag_result,
12067 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12068 TOKEN_NUM_INITIALIZER
12069 (struct cmd_config_e_tag_result,
12072 /* E-tag insertion configuration */
12074 cmd_config_e_tag_insertion_en_parsed(
12075 void *parsed_result,
12076 __attribute__((unused)) struct cmdline *cl,
12077 __attribute__((unused)) void *data)
12079 struct cmd_config_e_tag_result *res =
12081 struct rte_eth_l2_tunnel_conf entry;
12083 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12086 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12087 entry.tunnel_id = res->port_tag_id_val;
12088 entry.vf_id = res->vf_id;
12089 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12091 ETH_L2_TUNNEL_INSERTION_MASK,
12096 cmd_config_e_tag_insertion_dis_parsed(
12097 void *parsed_result,
12098 __attribute__((unused)) struct cmdline *cl,
12099 __attribute__((unused)) void *data)
12101 struct cmd_config_e_tag_result *res =
12103 struct rte_eth_l2_tunnel_conf entry;
12105 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12108 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12109 entry.vf_id = res->vf_id;
12111 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12113 ETH_L2_TUNNEL_INSERTION_MASK,
12117 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12118 .f = cmd_config_e_tag_insertion_en_parsed,
12120 .help_str = "E-tag ... : E-tag insertion enable",
12122 (void *)&cmd_config_e_tag_e_tag,
12123 (void *)&cmd_config_e_tag_set,
12124 (void *)&cmd_config_e_tag_insertion,
12125 (void *)&cmd_config_e_tag_on,
12126 (void *)&cmd_config_e_tag_port_tag_id,
12127 (void *)&cmd_config_e_tag_port_tag_id_val,
12128 (void *)&cmd_config_e_tag_port,
12129 (void *)&cmd_config_e_tag_port_id,
12130 (void *)&cmd_config_e_tag_vf,
12131 (void *)&cmd_config_e_tag_vf_id,
12136 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12137 .f = cmd_config_e_tag_insertion_dis_parsed,
12139 .help_str = "E-tag ... : E-tag insertion disable",
12141 (void *)&cmd_config_e_tag_e_tag,
12142 (void *)&cmd_config_e_tag_set,
12143 (void *)&cmd_config_e_tag_insertion,
12144 (void *)&cmd_config_e_tag_off,
12145 (void *)&cmd_config_e_tag_port,
12146 (void *)&cmd_config_e_tag_port_id,
12147 (void *)&cmd_config_e_tag_vf,
12148 (void *)&cmd_config_e_tag_vf_id,
12153 /* E-tag stripping configuration */
12155 cmd_config_e_tag_stripping_parsed(
12156 void *parsed_result,
12157 __attribute__((unused)) struct cmdline *cl,
12158 __attribute__((unused)) void *data)
12160 struct cmd_config_e_tag_result *res =
12162 struct rte_eth_l2_tunnel_conf entry;
12164 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12167 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12169 if (!strcmp(res->on_off, "on"))
12170 rte_eth_dev_l2_tunnel_offload_set
12173 ETH_L2_TUNNEL_STRIPPING_MASK,
12176 rte_eth_dev_l2_tunnel_offload_set
12179 ETH_L2_TUNNEL_STRIPPING_MASK,
12183 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12184 .f = cmd_config_e_tag_stripping_parsed,
12186 .help_str = "E-tag ... : E-tag stripping enable/disable",
12188 (void *)&cmd_config_e_tag_e_tag,
12189 (void *)&cmd_config_e_tag_set,
12190 (void *)&cmd_config_e_tag_stripping,
12191 (void *)&cmd_config_e_tag_on_off,
12192 (void *)&cmd_config_e_tag_port,
12193 (void *)&cmd_config_e_tag_port_id,
12198 /* E-tag forwarding configuration */
12200 cmd_config_e_tag_forwarding_parsed(
12201 void *parsed_result,
12202 __attribute__((unused)) struct cmdline *cl,
12203 __attribute__((unused)) void *data)
12205 struct cmd_config_e_tag_result *res = parsed_result;
12206 struct rte_eth_l2_tunnel_conf entry;
12208 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12211 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12213 if (!strcmp(res->on_off, "on"))
12214 rte_eth_dev_l2_tunnel_offload_set
12217 ETH_L2_TUNNEL_FORWARDING_MASK,
12220 rte_eth_dev_l2_tunnel_offload_set
12223 ETH_L2_TUNNEL_FORWARDING_MASK,
12227 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12228 .f = cmd_config_e_tag_forwarding_parsed,
12230 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12232 (void *)&cmd_config_e_tag_e_tag,
12233 (void *)&cmd_config_e_tag_set,
12234 (void *)&cmd_config_e_tag_forwarding,
12235 (void *)&cmd_config_e_tag_on_off,
12236 (void *)&cmd_config_e_tag_port,
12237 (void *)&cmd_config_e_tag_port_id,
12242 /* E-tag filter configuration */
12244 cmd_config_e_tag_filter_add_parsed(
12245 void *parsed_result,
12246 __attribute__((unused)) struct cmdline *cl,
12247 __attribute__((unused)) void *data)
12249 struct cmd_config_e_tag_result *res = parsed_result;
12250 struct rte_eth_l2_tunnel_conf entry;
12253 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12256 if (res->e_tag_id_val > 0x3fff) {
12257 printf("e-tag-id must be equal or less than 0x3fff.\n");
12261 ret = rte_eth_dev_filter_supported(res->port_id,
12262 RTE_ETH_FILTER_L2_TUNNEL);
12264 printf("E-tag filter is not supported on port %u.\n",
12269 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12270 entry.tunnel_id = res->e_tag_id_val;
12271 entry.pool = res->dst_pool_val;
12273 ret = rte_eth_dev_filter_ctrl(res->port_id,
12274 RTE_ETH_FILTER_L2_TUNNEL,
12275 RTE_ETH_FILTER_ADD,
12278 printf("E-tag filter programming error: (%s)\n",
12282 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12283 .f = cmd_config_e_tag_filter_add_parsed,
12285 .help_str = "E-tag ... : E-tag filter add",
12287 (void *)&cmd_config_e_tag_e_tag,
12288 (void *)&cmd_config_e_tag_set,
12289 (void *)&cmd_config_e_tag_filter,
12290 (void *)&cmd_config_e_tag_add,
12291 (void *)&cmd_config_e_tag_e_tag_id,
12292 (void *)&cmd_config_e_tag_e_tag_id_val,
12293 (void *)&cmd_config_e_tag_dst_pool,
12294 (void *)&cmd_config_e_tag_dst_pool_val,
12295 (void *)&cmd_config_e_tag_port,
12296 (void *)&cmd_config_e_tag_port_id,
12302 cmd_config_e_tag_filter_del_parsed(
12303 void *parsed_result,
12304 __attribute__((unused)) struct cmdline *cl,
12305 __attribute__((unused)) void *data)
12307 struct cmd_config_e_tag_result *res = parsed_result;
12308 struct rte_eth_l2_tunnel_conf entry;
12311 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12314 if (res->e_tag_id_val > 0x3fff) {
12315 printf("e-tag-id must be less than 0x3fff.\n");
12319 ret = rte_eth_dev_filter_supported(res->port_id,
12320 RTE_ETH_FILTER_L2_TUNNEL);
12322 printf("E-tag filter is not supported on port %u.\n",
12327 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12328 entry.tunnel_id = res->e_tag_id_val;
12330 ret = rte_eth_dev_filter_ctrl(res->port_id,
12331 RTE_ETH_FILTER_L2_TUNNEL,
12332 RTE_ETH_FILTER_DELETE,
12335 printf("E-tag filter programming error: (%s)\n",
12339 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12340 .f = cmd_config_e_tag_filter_del_parsed,
12342 .help_str = "E-tag ... : E-tag filter delete",
12344 (void *)&cmd_config_e_tag_e_tag,
12345 (void *)&cmd_config_e_tag_set,
12346 (void *)&cmd_config_e_tag_filter,
12347 (void *)&cmd_config_e_tag_del,
12348 (void *)&cmd_config_e_tag_e_tag_id,
12349 (void *)&cmd_config_e_tag_e_tag_id_val,
12350 (void *)&cmd_config_e_tag_port,
12351 (void *)&cmd_config_e_tag_port_id,
12356 /* vf vlan anti spoof configuration */
12358 /* Common result structure for vf vlan anti spoof */
12359 struct cmd_vf_vlan_anti_spoof_result {
12360 cmdline_fixed_string_t set;
12361 cmdline_fixed_string_t vf;
12362 cmdline_fixed_string_t vlan;
12363 cmdline_fixed_string_t antispoof;
12366 cmdline_fixed_string_t on_off;
12369 /* Common CLI fields for vf vlan anti spoof enable disable */
12370 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12371 TOKEN_STRING_INITIALIZER
12372 (struct cmd_vf_vlan_anti_spoof_result,
12374 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12375 TOKEN_STRING_INITIALIZER
12376 (struct cmd_vf_vlan_anti_spoof_result,
12378 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12379 TOKEN_STRING_INITIALIZER
12380 (struct cmd_vf_vlan_anti_spoof_result,
12382 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12383 TOKEN_STRING_INITIALIZER
12384 (struct cmd_vf_vlan_anti_spoof_result,
12385 antispoof, "antispoof");
12386 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12387 TOKEN_NUM_INITIALIZER
12388 (struct cmd_vf_vlan_anti_spoof_result,
12390 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12391 TOKEN_NUM_INITIALIZER
12392 (struct cmd_vf_vlan_anti_spoof_result,
12394 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12395 TOKEN_STRING_INITIALIZER
12396 (struct cmd_vf_vlan_anti_spoof_result,
12400 cmd_set_vf_vlan_anti_spoof_parsed(
12401 void *parsed_result,
12402 __attribute__((unused)) struct cmdline *cl,
12403 __attribute__((unused)) void *data)
12405 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12406 int ret = -ENOTSUP;
12408 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12410 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12413 #ifdef RTE_LIBRTE_IXGBE_PMD
12414 if (ret == -ENOTSUP)
12415 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12416 res->vf_id, is_on);
12418 #ifdef RTE_LIBRTE_I40E_PMD
12419 if (ret == -ENOTSUP)
12420 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12421 res->vf_id, is_on);
12423 #ifdef RTE_LIBRTE_BNXT_PMD
12424 if (ret == -ENOTSUP)
12425 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12426 res->vf_id, is_on);
12433 printf("invalid vf_id %d\n", res->vf_id);
12436 printf("invalid port_id %d\n", res->port_id);
12439 printf("function not implemented\n");
12442 printf("programming error: (%s)\n", strerror(-ret));
12446 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12447 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12449 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12451 (void *)&cmd_vf_vlan_anti_spoof_set,
12452 (void *)&cmd_vf_vlan_anti_spoof_vf,
12453 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12454 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12455 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12456 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12457 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12462 /* vf mac anti spoof configuration */
12464 /* Common result structure for vf mac anti spoof */
12465 struct cmd_vf_mac_anti_spoof_result {
12466 cmdline_fixed_string_t set;
12467 cmdline_fixed_string_t vf;
12468 cmdline_fixed_string_t mac;
12469 cmdline_fixed_string_t antispoof;
12472 cmdline_fixed_string_t on_off;
12475 /* Common CLI fields for vf mac anti spoof enable disable */
12476 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12477 TOKEN_STRING_INITIALIZER
12478 (struct cmd_vf_mac_anti_spoof_result,
12480 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12481 TOKEN_STRING_INITIALIZER
12482 (struct cmd_vf_mac_anti_spoof_result,
12484 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12485 TOKEN_STRING_INITIALIZER
12486 (struct cmd_vf_mac_anti_spoof_result,
12488 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12489 TOKEN_STRING_INITIALIZER
12490 (struct cmd_vf_mac_anti_spoof_result,
12491 antispoof, "antispoof");
12492 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12493 TOKEN_NUM_INITIALIZER
12494 (struct cmd_vf_mac_anti_spoof_result,
12496 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12497 TOKEN_NUM_INITIALIZER
12498 (struct cmd_vf_mac_anti_spoof_result,
12500 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12501 TOKEN_STRING_INITIALIZER
12502 (struct cmd_vf_mac_anti_spoof_result,
12506 cmd_set_vf_mac_anti_spoof_parsed(
12507 void *parsed_result,
12508 __attribute__((unused)) struct cmdline *cl,
12509 __attribute__((unused)) void *data)
12511 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12512 int ret = -ENOTSUP;
12514 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12516 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12519 #ifdef RTE_LIBRTE_IXGBE_PMD
12520 if (ret == -ENOTSUP)
12521 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12522 res->vf_id, is_on);
12524 #ifdef RTE_LIBRTE_I40E_PMD
12525 if (ret == -ENOTSUP)
12526 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12527 res->vf_id, is_on);
12529 #ifdef RTE_LIBRTE_BNXT_PMD
12530 if (ret == -ENOTSUP)
12531 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12532 res->vf_id, is_on);
12539 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12542 printf("invalid port_id %d\n", res->port_id);
12545 printf("function not implemented\n");
12548 printf("programming error: (%s)\n", strerror(-ret));
12552 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12553 .f = cmd_set_vf_mac_anti_spoof_parsed,
12555 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12557 (void *)&cmd_vf_mac_anti_spoof_set,
12558 (void *)&cmd_vf_mac_anti_spoof_vf,
12559 (void *)&cmd_vf_mac_anti_spoof_mac,
12560 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12561 (void *)&cmd_vf_mac_anti_spoof_port_id,
12562 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12563 (void *)&cmd_vf_mac_anti_spoof_on_off,
12568 /* vf vlan strip queue configuration */
12570 /* Common result structure for vf mac anti spoof */
12571 struct cmd_vf_vlan_stripq_result {
12572 cmdline_fixed_string_t set;
12573 cmdline_fixed_string_t vf;
12574 cmdline_fixed_string_t vlan;
12575 cmdline_fixed_string_t stripq;
12578 cmdline_fixed_string_t on_off;
12581 /* Common CLI fields for vf vlan strip enable disable */
12582 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12583 TOKEN_STRING_INITIALIZER
12584 (struct cmd_vf_vlan_stripq_result,
12586 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12587 TOKEN_STRING_INITIALIZER
12588 (struct cmd_vf_vlan_stripq_result,
12590 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12591 TOKEN_STRING_INITIALIZER
12592 (struct cmd_vf_vlan_stripq_result,
12594 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12595 TOKEN_STRING_INITIALIZER
12596 (struct cmd_vf_vlan_stripq_result,
12598 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12599 TOKEN_NUM_INITIALIZER
12600 (struct cmd_vf_vlan_stripq_result,
12602 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12603 TOKEN_NUM_INITIALIZER
12604 (struct cmd_vf_vlan_stripq_result,
12606 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12607 TOKEN_STRING_INITIALIZER
12608 (struct cmd_vf_vlan_stripq_result,
12612 cmd_set_vf_vlan_stripq_parsed(
12613 void *parsed_result,
12614 __attribute__((unused)) struct cmdline *cl,
12615 __attribute__((unused)) void *data)
12617 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12618 int ret = -ENOTSUP;
12620 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12622 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12625 #ifdef RTE_LIBRTE_IXGBE_PMD
12626 if (ret == -ENOTSUP)
12627 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12628 res->vf_id, is_on);
12630 #ifdef RTE_LIBRTE_I40E_PMD
12631 if (ret == -ENOTSUP)
12632 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12633 res->vf_id, is_on);
12635 #ifdef RTE_LIBRTE_BNXT_PMD
12636 if (ret == -ENOTSUP)
12637 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12638 res->vf_id, is_on);
12645 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12648 printf("invalid port_id %d\n", res->port_id);
12651 printf("function not implemented\n");
12654 printf("programming error: (%s)\n", strerror(-ret));
12658 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12659 .f = cmd_set_vf_vlan_stripq_parsed,
12661 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12663 (void *)&cmd_vf_vlan_stripq_set,
12664 (void *)&cmd_vf_vlan_stripq_vf,
12665 (void *)&cmd_vf_vlan_stripq_vlan,
12666 (void *)&cmd_vf_vlan_stripq_stripq,
12667 (void *)&cmd_vf_vlan_stripq_port_id,
12668 (void *)&cmd_vf_vlan_stripq_vf_id,
12669 (void *)&cmd_vf_vlan_stripq_on_off,
12674 /* vf vlan insert configuration */
12676 /* Common result structure for vf vlan insert */
12677 struct cmd_vf_vlan_insert_result {
12678 cmdline_fixed_string_t set;
12679 cmdline_fixed_string_t vf;
12680 cmdline_fixed_string_t vlan;
12681 cmdline_fixed_string_t insert;
12687 /* Common CLI fields for vf vlan insert enable disable */
12688 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12689 TOKEN_STRING_INITIALIZER
12690 (struct cmd_vf_vlan_insert_result,
12692 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12693 TOKEN_STRING_INITIALIZER
12694 (struct cmd_vf_vlan_insert_result,
12696 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12697 TOKEN_STRING_INITIALIZER
12698 (struct cmd_vf_vlan_insert_result,
12700 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12701 TOKEN_STRING_INITIALIZER
12702 (struct cmd_vf_vlan_insert_result,
12704 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12705 TOKEN_NUM_INITIALIZER
12706 (struct cmd_vf_vlan_insert_result,
12708 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12709 TOKEN_NUM_INITIALIZER
12710 (struct cmd_vf_vlan_insert_result,
12712 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12713 TOKEN_NUM_INITIALIZER
12714 (struct cmd_vf_vlan_insert_result,
12718 cmd_set_vf_vlan_insert_parsed(
12719 void *parsed_result,
12720 __attribute__((unused)) struct cmdline *cl,
12721 __attribute__((unused)) void *data)
12723 struct cmd_vf_vlan_insert_result *res = parsed_result;
12724 int ret = -ENOTSUP;
12726 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12729 #ifdef RTE_LIBRTE_IXGBE_PMD
12730 if (ret == -ENOTSUP)
12731 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12734 #ifdef RTE_LIBRTE_I40E_PMD
12735 if (ret == -ENOTSUP)
12736 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12739 #ifdef RTE_LIBRTE_BNXT_PMD
12740 if (ret == -ENOTSUP)
12741 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12749 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12752 printf("invalid port_id %d\n", res->port_id);
12755 printf("function not implemented\n");
12758 printf("programming error: (%s)\n", strerror(-ret));
12762 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12763 .f = cmd_set_vf_vlan_insert_parsed,
12765 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12767 (void *)&cmd_vf_vlan_insert_set,
12768 (void *)&cmd_vf_vlan_insert_vf,
12769 (void *)&cmd_vf_vlan_insert_vlan,
12770 (void *)&cmd_vf_vlan_insert_insert,
12771 (void *)&cmd_vf_vlan_insert_port_id,
12772 (void *)&cmd_vf_vlan_insert_vf_id,
12773 (void *)&cmd_vf_vlan_insert_vlan_id,
12778 /* tx loopback configuration */
12780 /* Common result structure for tx loopback */
12781 struct cmd_tx_loopback_result {
12782 cmdline_fixed_string_t set;
12783 cmdline_fixed_string_t tx;
12784 cmdline_fixed_string_t loopback;
12786 cmdline_fixed_string_t on_off;
12789 /* Common CLI fields for tx loopback enable disable */
12790 cmdline_parse_token_string_t cmd_tx_loopback_set =
12791 TOKEN_STRING_INITIALIZER
12792 (struct cmd_tx_loopback_result,
12794 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12795 TOKEN_STRING_INITIALIZER
12796 (struct cmd_tx_loopback_result,
12798 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12799 TOKEN_STRING_INITIALIZER
12800 (struct cmd_tx_loopback_result,
12801 loopback, "loopback");
12802 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12803 TOKEN_NUM_INITIALIZER
12804 (struct cmd_tx_loopback_result,
12806 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12807 TOKEN_STRING_INITIALIZER
12808 (struct cmd_tx_loopback_result,
12812 cmd_set_tx_loopback_parsed(
12813 void *parsed_result,
12814 __attribute__((unused)) struct cmdline *cl,
12815 __attribute__((unused)) void *data)
12817 struct cmd_tx_loopback_result *res = parsed_result;
12818 int ret = -ENOTSUP;
12820 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12822 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12825 #ifdef RTE_LIBRTE_IXGBE_PMD
12826 if (ret == -ENOTSUP)
12827 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12829 #ifdef RTE_LIBRTE_I40E_PMD
12830 if (ret == -ENOTSUP)
12831 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12833 #ifdef RTE_LIBRTE_BNXT_PMD
12834 if (ret == -ENOTSUP)
12835 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12837 #ifdef RTE_LIBRTE_DPAA_PMD
12838 if (ret == -ENOTSUP)
12839 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
12846 printf("invalid is_on %d\n", is_on);
12849 printf("invalid port_id %d\n", res->port_id);
12852 printf("function not implemented\n");
12855 printf("programming error: (%s)\n", strerror(-ret));
12859 cmdline_parse_inst_t cmd_set_tx_loopback = {
12860 .f = cmd_set_tx_loopback_parsed,
12862 .help_str = "set tx loopback <port_id> on|off",
12864 (void *)&cmd_tx_loopback_set,
12865 (void *)&cmd_tx_loopback_tx,
12866 (void *)&cmd_tx_loopback_loopback,
12867 (void *)&cmd_tx_loopback_port_id,
12868 (void *)&cmd_tx_loopback_on_off,
12873 /* all queues drop enable configuration */
12875 /* Common result structure for all queues drop enable */
12876 struct cmd_all_queues_drop_en_result {
12877 cmdline_fixed_string_t set;
12878 cmdline_fixed_string_t all;
12879 cmdline_fixed_string_t queues;
12880 cmdline_fixed_string_t drop;
12882 cmdline_fixed_string_t on_off;
12885 /* Common CLI fields for tx loopback enable disable */
12886 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12887 TOKEN_STRING_INITIALIZER
12888 (struct cmd_all_queues_drop_en_result,
12890 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12891 TOKEN_STRING_INITIALIZER
12892 (struct cmd_all_queues_drop_en_result,
12894 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12895 TOKEN_STRING_INITIALIZER
12896 (struct cmd_all_queues_drop_en_result,
12898 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12899 TOKEN_STRING_INITIALIZER
12900 (struct cmd_all_queues_drop_en_result,
12902 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12903 TOKEN_NUM_INITIALIZER
12904 (struct cmd_all_queues_drop_en_result,
12906 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12907 TOKEN_STRING_INITIALIZER
12908 (struct cmd_all_queues_drop_en_result,
12912 cmd_set_all_queues_drop_en_parsed(
12913 void *parsed_result,
12914 __attribute__((unused)) struct cmdline *cl,
12915 __attribute__((unused)) void *data)
12917 struct cmd_all_queues_drop_en_result *res = parsed_result;
12918 int ret = -ENOTSUP;
12919 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12921 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12924 #ifdef RTE_LIBRTE_IXGBE_PMD
12925 if (ret == -ENOTSUP)
12926 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12928 #ifdef RTE_LIBRTE_BNXT_PMD
12929 if (ret == -ENOTSUP)
12930 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12936 printf("invalid is_on %d\n", is_on);
12939 printf("invalid port_id %d\n", res->port_id);
12942 printf("function not implemented\n");
12945 printf("programming error: (%s)\n", strerror(-ret));
12949 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12950 .f = cmd_set_all_queues_drop_en_parsed,
12952 .help_str = "set all queues drop <port_id> on|off",
12954 (void *)&cmd_all_queues_drop_en_set,
12955 (void *)&cmd_all_queues_drop_en_all,
12956 (void *)&cmd_all_queues_drop_en_queues,
12957 (void *)&cmd_all_queues_drop_en_drop,
12958 (void *)&cmd_all_queues_drop_en_port_id,
12959 (void *)&cmd_all_queues_drop_en_on_off,
12964 /* vf split drop enable configuration */
12966 /* Common result structure for vf split drop enable */
12967 struct cmd_vf_split_drop_en_result {
12968 cmdline_fixed_string_t set;
12969 cmdline_fixed_string_t vf;
12970 cmdline_fixed_string_t split;
12971 cmdline_fixed_string_t drop;
12974 cmdline_fixed_string_t on_off;
12977 /* Common CLI fields for vf split drop enable disable */
12978 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12979 TOKEN_STRING_INITIALIZER
12980 (struct cmd_vf_split_drop_en_result,
12982 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12983 TOKEN_STRING_INITIALIZER
12984 (struct cmd_vf_split_drop_en_result,
12986 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12987 TOKEN_STRING_INITIALIZER
12988 (struct cmd_vf_split_drop_en_result,
12990 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12991 TOKEN_STRING_INITIALIZER
12992 (struct cmd_vf_split_drop_en_result,
12994 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12995 TOKEN_NUM_INITIALIZER
12996 (struct cmd_vf_split_drop_en_result,
12998 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12999 TOKEN_NUM_INITIALIZER
13000 (struct cmd_vf_split_drop_en_result,
13002 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13003 TOKEN_STRING_INITIALIZER
13004 (struct cmd_vf_split_drop_en_result,
13008 cmd_set_vf_split_drop_en_parsed(
13009 void *parsed_result,
13010 __attribute__((unused)) struct cmdline *cl,
13011 __attribute__((unused)) void *data)
13013 struct cmd_vf_split_drop_en_result *res = parsed_result;
13014 int ret = -ENOTSUP;
13015 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13017 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13020 #ifdef RTE_LIBRTE_IXGBE_PMD
13021 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13028 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13031 printf("invalid port_id %d\n", res->port_id);
13034 printf("not supported on port %d\n", res->port_id);
13037 printf("programming error: (%s)\n", strerror(-ret));
13041 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13042 .f = cmd_set_vf_split_drop_en_parsed,
13044 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13046 (void *)&cmd_vf_split_drop_en_set,
13047 (void *)&cmd_vf_split_drop_en_vf,
13048 (void *)&cmd_vf_split_drop_en_split,
13049 (void *)&cmd_vf_split_drop_en_drop,
13050 (void *)&cmd_vf_split_drop_en_port_id,
13051 (void *)&cmd_vf_split_drop_en_vf_id,
13052 (void *)&cmd_vf_split_drop_en_on_off,
13057 /* vf mac address configuration */
13059 /* Common result structure for vf mac address */
13060 struct cmd_set_vf_mac_addr_result {
13061 cmdline_fixed_string_t set;
13062 cmdline_fixed_string_t vf;
13063 cmdline_fixed_string_t mac;
13064 cmdline_fixed_string_t addr;
13067 struct ether_addr mac_addr;
13071 /* Common CLI fields for vf split drop enable disable */
13072 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13073 TOKEN_STRING_INITIALIZER
13074 (struct cmd_set_vf_mac_addr_result,
13076 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13077 TOKEN_STRING_INITIALIZER
13078 (struct cmd_set_vf_mac_addr_result,
13080 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13081 TOKEN_STRING_INITIALIZER
13082 (struct cmd_set_vf_mac_addr_result,
13084 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13085 TOKEN_STRING_INITIALIZER
13086 (struct cmd_set_vf_mac_addr_result,
13088 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13089 TOKEN_NUM_INITIALIZER
13090 (struct cmd_set_vf_mac_addr_result,
13092 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13093 TOKEN_NUM_INITIALIZER
13094 (struct cmd_set_vf_mac_addr_result,
13096 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13097 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13101 cmd_set_vf_mac_addr_parsed(
13102 void *parsed_result,
13103 __attribute__((unused)) struct cmdline *cl,
13104 __attribute__((unused)) void *data)
13106 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13107 int ret = -ENOTSUP;
13109 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13112 #ifdef RTE_LIBRTE_IXGBE_PMD
13113 if (ret == -ENOTSUP)
13114 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13117 #ifdef RTE_LIBRTE_I40E_PMD
13118 if (ret == -ENOTSUP)
13119 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13122 #ifdef RTE_LIBRTE_BNXT_PMD
13123 if (ret == -ENOTSUP)
13124 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13132 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13135 printf("invalid port_id %d\n", res->port_id);
13138 printf("function not implemented\n");
13141 printf("programming error: (%s)\n", strerror(-ret));
13145 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13146 .f = cmd_set_vf_mac_addr_parsed,
13148 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13150 (void *)&cmd_set_vf_mac_addr_set,
13151 (void *)&cmd_set_vf_mac_addr_vf,
13152 (void *)&cmd_set_vf_mac_addr_mac,
13153 (void *)&cmd_set_vf_mac_addr_addr,
13154 (void *)&cmd_set_vf_mac_addr_port_id,
13155 (void *)&cmd_set_vf_mac_addr_vf_id,
13156 (void *)&cmd_set_vf_mac_addr_mac_addr,
13161 /* MACsec configuration */
13163 /* Common result structure for MACsec offload enable */
13164 struct cmd_macsec_offload_on_result {
13165 cmdline_fixed_string_t set;
13166 cmdline_fixed_string_t macsec;
13167 cmdline_fixed_string_t offload;
13169 cmdline_fixed_string_t on;
13170 cmdline_fixed_string_t encrypt;
13171 cmdline_fixed_string_t en_on_off;
13172 cmdline_fixed_string_t replay_protect;
13173 cmdline_fixed_string_t rp_on_off;
13176 /* Common CLI fields for MACsec offload disable */
13177 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13178 TOKEN_STRING_INITIALIZER
13179 (struct cmd_macsec_offload_on_result,
13181 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13182 TOKEN_STRING_INITIALIZER
13183 (struct cmd_macsec_offload_on_result,
13185 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13186 TOKEN_STRING_INITIALIZER
13187 (struct cmd_macsec_offload_on_result,
13188 offload, "offload");
13189 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13190 TOKEN_NUM_INITIALIZER
13191 (struct cmd_macsec_offload_on_result,
13193 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13194 TOKEN_STRING_INITIALIZER
13195 (struct cmd_macsec_offload_on_result,
13197 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13198 TOKEN_STRING_INITIALIZER
13199 (struct cmd_macsec_offload_on_result,
13200 encrypt, "encrypt");
13201 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13202 TOKEN_STRING_INITIALIZER
13203 (struct cmd_macsec_offload_on_result,
13204 en_on_off, "on#off");
13205 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13206 TOKEN_STRING_INITIALIZER
13207 (struct cmd_macsec_offload_on_result,
13208 replay_protect, "replay-protect");
13209 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13210 TOKEN_STRING_INITIALIZER
13211 (struct cmd_macsec_offload_on_result,
13212 rp_on_off, "on#off");
13215 cmd_set_macsec_offload_on_parsed(
13216 void *parsed_result,
13217 __attribute__((unused)) struct cmdline *cl,
13218 __attribute__((unused)) void *data)
13220 struct cmd_macsec_offload_on_result *res = parsed_result;
13221 int ret = -ENOTSUP;
13222 portid_t port_id = res->port_id;
13223 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13224 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13225 struct rte_eth_dev_info dev_info;
13227 if (port_id_is_invalid(port_id, ENABLED_WARN))
13229 if (!port_is_stopped(port_id)) {
13230 printf("Please stop port %d first\n", port_id);
13234 rte_eth_dev_info_get(port_id, &dev_info);
13235 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13236 #ifdef RTE_LIBRTE_IXGBE_PMD
13237 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13245 ports[port_id].dev_conf.txmode.offloads |=
13246 DEV_TX_OFFLOAD_MACSEC_INSERT;
13247 cmd_reconfig_device_queue(port_id, 1, 1);
13250 printf("invalid port_id %d\n", port_id);
13253 printf("not supported on port %d\n", port_id);
13256 printf("programming error: (%s)\n", strerror(-ret));
13260 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13261 .f = cmd_set_macsec_offload_on_parsed,
13263 .help_str = "set macsec offload <port_id> on "
13264 "encrypt on|off replay-protect on|off",
13266 (void *)&cmd_macsec_offload_on_set,
13267 (void *)&cmd_macsec_offload_on_macsec,
13268 (void *)&cmd_macsec_offload_on_offload,
13269 (void *)&cmd_macsec_offload_on_port_id,
13270 (void *)&cmd_macsec_offload_on_on,
13271 (void *)&cmd_macsec_offload_on_encrypt,
13272 (void *)&cmd_macsec_offload_on_en_on_off,
13273 (void *)&cmd_macsec_offload_on_replay_protect,
13274 (void *)&cmd_macsec_offload_on_rp_on_off,
13279 /* Common result structure for MACsec offload disable */
13280 struct cmd_macsec_offload_off_result {
13281 cmdline_fixed_string_t set;
13282 cmdline_fixed_string_t macsec;
13283 cmdline_fixed_string_t offload;
13285 cmdline_fixed_string_t off;
13288 /* Common CLI fields for MACsec offload disable */
13289 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13290 TOKEN_STRING_INITIALIZER
13291 (struct cmd_macsec_offload_off_result,
13293 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13294 TOKEN_STRING_INITIALIZER
13295 (struct cmd_macsec_offload_off_result,
13297 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13298 TOKEN_STRING_INITIALIZER
13299 (struct cmd_macsec_offload_off_result,
13300 offload, "offload");
13301 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13302 TOKEN_NUM_INITIALIZER
13303 (struct cmd_macsec_offload_off_result,
13305 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13306 TOKEN_STRING_INITIALIZER
13307 (struct cmd_macsec_offload_off_result,
13311 cmd_set_macsec_offload_off_parsed(
13312 void *parsed_result,
13313 __attribute__((unused)) struct cmdline *cl,
13314 __attribute__((unused)) void *data)
13316 struct cmd_macsec_offload_off_result *res = parsed_result;
13317 int ret = -ENOTSUP;
13318 struct rte_eth_dev_info dev_info;
13319 portid_t port_id = res->port_id;
13321 if (port_id_is_invalid(port_id, ENABLED_WARN))
13323 if (!port_is_stopped(port_id)) {
13324 printf("Please stop port %d first\n", port_id);
13328 rte_eth_dev_info_get(port_id, &dev_info);
13329 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13330 #ifdef RTE_LIBRTE_IXGBE_PMD
13331 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13336 ports[port_id].dev_conf.txmode.offloads &=
13337 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13338 cmd_reconfig_device_queue(port_id, 1, 1);
13341 printf("invalid port_id %d\n", port_id);
13344 printf("not supported on port %d\n", port_id);
13347 printf("programming error: (%s)\n", strerror(-ret));
13351 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13352 .f = cmd_set_macsec_offload_off_parsed,
13354 .help_str = "set macsec offload <port_id> off",
13356 (void *)&cmd_macsec_offload_off_set,
13357 (void *)&cmd_macsec_offload_off_macsec,
13358 (void *)&cmd_macsec_offload_off_offload,
13359 (void *)&cmd_macsec_offload_off_port_id,
13360 (void *)&cmd_macsec_offload_off_off,
13365 /* Common result structure for MACsec secure connection configure */
13366 struct cmd_macsec_sc_result {
13367 cmdline_fixed_string_t set;
13368 cmdline_fixed_string_t macsec;
13369 cmdline_fixed_string_t sc;
13370 cmdline_fixed_string_t tx_rx;
13372 struct ether_addr mac;
13376 /* Common CLI fields for MACsec secure connection configure */
13377 cmdline_parse_token_string_t cmd_macsec_sc_set =
13378 TOKEN_STRING_INITIALIZER
13379 (struct cmd_macsec_sc_result,
13381 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13382 TOKEN_STRING_INITIALIZER
13383 (struct cmd_macsec_sc_result,
13385 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13386 TOKEN_STRING_INITIALIZER
13387 (struct cmd_macsec_sc_result,
13389 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13390 TOKEN_STRING_INITIALIZER
13391 (struct cmd_macsec_sc_result,
13393 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13394 TOKEN_NUM_INITIALIZER
13395 (struct cmd_macsec_sc_result,
13397 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13398 TOKEN_ETHERADDR_INITIALIZER
13399 (struct cmd_macsec_sc_result,
13401 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13402 TOKEN_NUM_INITIALIZER
13403 (struct cmd_macsec_sc_result,
13407 cmd_set_macsec_sc_parsed(
13408 void *parsed_result,
13409 __attribute__((unused)) struct cmdline *cl,
13410 __attribute__((unused)) void *data)
13412 struct cmd_macsec_sc_result *res = parsed_result;
13413 int ret = -ENOTSUP;
13414 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13416 #ifdef RTE_LIBRTE_IXGBE_PMD
13418 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13419 res->mac.addr_bytes) :
13420 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13421 res->mac.addr_bytes, res->pi);
13423 RTE_SET_USED(is_tx);
13429 printf("invalid port_id %d\n", res->port_id);
13432 printf("not supported on port %d\n", res->port_id);
13435 printf("programming error: (%s)\n", strerror(-ret));
13439 cmdline_parse_inst_t cmd_set_macsec_sc = {
13440 .f = cmd_set_macsec_sc_parsed,
13442 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13444 (void *)&cmd_macsec_sc_set,
13445 (void *)&cmd_macsec_sc_macsec,
13446 (void *)&cmd_macsec_sc_sc,
13447 (void *)&cmd_macsec_sc_tx_rx,
13448 (void *)&cmd_macsec_sc_port_id,
13449 (void *)&cmd_macsec_sc_mac,
13450 (void *)&cmd_macsec_sc_pi,
13455 /* Common result structure for MACsec secure connection configure */
13456 struct cmd_macsec_sa_result {
13457 cmdline_fixed_string_t set;
13458 cmdline_fixed_string_t macsec;
13459 cmdline_fixed_string_t sa;
13460 cmdline_fixed_string_t tx_rx;
13465 cmdline_fixed_string_t key;
13468 /* Common CLI fields for MACsec secure connection configure */
13469 cmdline_parse_token_string_t cmd_macsec_sa_set =
13470 TOKEN_STRING_INITIALIZER
13471 (struct cmd_macsec_sa_result,
13473 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13474 TOKEN_STRING_INITIALIZER
13475 (struct cmd_macsec_sa_result,
13477 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13478 TOKEN_STRING_INITIALIZER
13479 (struct cmd_macsec_sa_result,
13481 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13482 TOKEN_STRING_INITIALIZER
13483 (struct cmd_macsec_sa_result,
13485 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13486 TOKEN_NUM_INITIALIZER
13487 (struct cmd_macsec_sa_result,
13489 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13490 TOKEN_NUM_INITIALIZER
13491 (struct cmd_macsec_sa_result,
13493 cmdline_parse_token_num_t cmd_macsec_sa_an =
13494 TOKEN_NUM_INITIALIZER
13495 (struct cmd_macsec_sa_result,
13497 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13498 TOKEN_NUM_INITIALIZER
13499 (struct cmd_macsec_sa_result,
13501 cmdline_parse_token_string_t cmd_macsec_sa_key =
13502 TOKEN_STRING_INITIALIZER
13503 (struct cmd_macsec_sa_result,
13507 cmd_set_macsec_sa_parsed(
13508 void *parsed_result,
13509 __attribute__((unused)) struct cmdline *cl,
13510 __attribute__((unused)) void *data)
13512 struct cmd_macsec_sa_result *res = parsed_result;
13513 int ret = -ENOTSUP;
13514 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13515 uint8_t key[16] = { 0 };
13521 key_len = strlen(res->key) / 2;
13525 for (i = 0; i < key_len; i++) {
13526 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13529 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13532 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13535 #ifdef RTE_LIBRTE_IXGBE_PMD
13537 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13538 res->idx, res->an, res->pn, key) :
13539 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13540 res->idx, res->an, res->pn, key);
13542 RTE_SET_USED(is_tx);
13549 printf("invalid idx %d or an %d\n", res->idx, res->an);
13552 printf("invalid port_id %d\n", res->port_id);
13555 printf("not supported on port %d\n", res->port_id);
13558 printf("programming error: (%s)\n", strerror(-ret));
13562 cmdline_parse_inst_t cmd_set_macsec_sa = {
13563 .f = cmd_set_macsec_sa_parsed,
13565 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13567 (void *)&cmd_macsec_sa_set,
13568 (void *)&cmd_macsec_sa_macsec,
13569 (void *)&cmd_macsec_sa_sa,
13570 (void *)&cmd_macsec_sa_tx_rx,
13571 (void *)&cmd_macsec_sa_port_id,
13572 (void *)&cmd_macsec_sa_idx,
13573 (void *)&cmd_macsec_sa_an,
13574 (void *)&cmd_macsec_sa_pn,
13575 (void *)&cmd_macsec_sa_key,
13580 /* VF unicast promiscuous mode configuration */
13582 /* Common result structure for VF unicast promiscuous mode */
13583 struct cmd_vf_promisc_result {
13584 cmdline_fixed_string_t set;
13585 cmdline_fixed_string_t vf;
13586 cmdline_fixed_string_t promisc;
13589 cmdline_fixed_string_t on_off;
13592 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13593 cmdline_parse_token_string_t cmd_vf_promisc_set =
13594 TOKEN_STRING_INITIALIZER
13595 (struct cmd_vf_promisc_result,
13597 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13598 TOKEN_STRING_INITIALIZER
13599 (struct cmd_vf_promisc_result,
13601 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13602 TOKEN_STRING_INITIALIZER
13603 (struct cmd_vf_promisc_result,
13604 promisc, "promisc");
13605 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13606 TOKEN_NUM_INITIALIZER
13607 (struct cmd_vf_promisc_result,
13609 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13610 TOKEN_NUM_INITIALIZER
13611 (struct cmd_vf_promisc_result,
13613 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13614 TOKEN_STRING_INITIALIZER
13615 (struct cmd_vf_promisc_result,
13619 cmd_set_vf_promisc_parsed(
13620 void *parsed_result,
13621 __attribute__((unused)) struct cmdline *cl,
13622 __attribute__((unused)) void *data)
13624 struct cmd_vf_promisc_result *res = parsed_result;
13625 int ret = -ENOTSUP;
13627 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13629 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13632 #ifdef RTE_LIBRTE_I40E_PMD
13633 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13634 res->vf_id, is_on);
13641 printf("invalid vf_id %d\n", res->vf_id);
13644 printf("invalid port_id %d\n", res->port_id);
13647 printf("function not implemented\n");
13650 printf("programming error: (%s)\n", strerror(-ret));
13654 cmdline_parse_inst_t cmd_set_vf_promisc = {
13655 .f = cmd_set_vf_promisc_parsed,
13657 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13658 "Set unicast promiscuous mode for a VF from the PF",
13660 (void *)&cmd_vf_promisc_set,
13661 (void *)&cmd_vf_promisc_vf,
13662 (void *)&cmd_vf_promisc_promisc,
13663 (void *)&cmd_vf_promisc_port_id,
13664 (void *)&cmd_vf_promisc_vf_id,
13665 (void *)&cmd_vf_promisc_on_off,
13670 /* VF multicast promiscuous mode configuration */
13672 /* Common result structure for VF multicast promiscuous mode */
13673 struct cmd_vf_allmulti_result {
13674 cmdline_fixed_string_t set;
13675 cmdline_fixed_string_t vf;
13676 cmdline_fixed_string_t allmulti;
13679 cmdline_fixed_string_t on_off;
13682 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13683 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13684 TOKEN_STRING_INITIALIZER
13685 (struct cmd_vf_allmulti_result,
13687 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13688 TOKEN_STRING_INITIALIZER
13689 (struct cmd_vf_allmulti_result,
13691 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13692 TOKEN_STRING_INITIALIZER
13693 (struct cmd_vf_allmulti_result,
13694 allmulti, "allmulti");
13695 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13696 TOKEN_NUM_INITIALIZER
13697 (struct cmd_vf_allmulti_result,
13699 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13700 TOKEN_NUM_INITIALIZER
13701 (struct cmd_vf_allmulti_result,
13703 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13704 TOKEN_STRING_INITIALIZER
13705 (struct cmd_vf_allmulti_result,
13709 cmd_set_vf_allmulti_parsed(
13710 void *parsed_result,
13711 __attribute__((unused)) struct cmdline *cl,
13712 __attribute__((unused)) void *data)
13714 struct cmd_vf_allmulti_result *res = parsed_result;
13715 int ret = -ENOTSUP;
13717 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13719 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13722 #ifdef RTE_LIBRTE_I40E_PMD
13723 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13724 res->vf_id, is_on);
13731 printf("invalid vf_id %d\n", res->vf_id);
13734 printf("invalid port_id %d\n", res->port_id);
13737 printf("function not implemented\n");
13740 printf("programming error: (%s)\n", strerror(-ret));
13744 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13745 .f = cmd_set_vf_allmulti_parsed,
13747 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13748 "Set multicast promiscuous mode for a VF from the PF",
13750 (void *)&cmd_vf_allmulti_set,
13751 (void *)&cmd_vf_allmulti_vf,
13752 (void *)&cmd_vf_allmulti_allmulti,
13753 (void *)&cmd_vf_allmulti_port_id,
13754 (void *)&cmd_vf_allmulti_vf_id,
13755 (void *)&cmd_vf_allmulti_on_off,
13760 /* vf broadcast mode configuration */
13762 /* Common result structure for vf broadcast */
13763 struct cmd_set_vf_broadcast_result {
13764 cmdline_fixed_string_t set;
13765 cmdline_fixed_string_t vf;
13766 cmdline_fixed_string_t broadcast;
13769 cmdline_fixed_string_t on_off;
13772 /* Common CLI fields for vf broadcast enable disable */
13773 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13774 TOKEN_STRING_INITIALIZER
13775 (struct cmd_set_vf_broadcast_result,
13777 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13778 TOKEN_STRING_INITIALIZER
13779 (struct cmd_set_vf_broadcast_result,
13781 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13782 TOKEN_STRING_INITIALIZER
13783 (struct cmd_set_vf_broadcast_result,
13784 broadcast, "broadcast");
13785 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13786 TOKEN_NUM_INITIALIZER
13787 (struct cmd_set_vf_broadcast_result,
13789 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13790 TOKEN_NUM_INITIALIZER
13791 (struct cmd_set_vf_broadcast_result,
13793 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13794 TOKEN_STRING_INITIALIZER
13795 (struct cmd_set_vf_broadcast_result,
13799 cmd_set_vf_broadcast_parsed(
13800 void *parsed_result,
13801 __attribute__((unused)) struct cmdline *cl,
13802 __attribute__((unused)) void *data)
13804 struct cmd_set_vf_broadcast_result *res = parsed_result;
13805 int ret = -ENOTSUP;
13807 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13809 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13812 #ifdef RTE_LIBRTE_I40E_PMD
13813 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13814 res->vf_id, is_on);
13821 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13824 printf("invalid port_id %d\n", res->port_id);
13827 printf("function not implemented\n");
13830 printf("programming error: (%s)\n", strerror(-ret));
13834 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13835 .f = cmd_set_vf_broadcast_parsed,
13837 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13839 (void *)&cmd_set_vf_broadcast_set,
13840 (void *)&cmd_set_vf_broadcast_vf,
13841 (void *)&cmd_set_vf_broadcast_broadcast,
13842 (void *)&cmd_set_vf_broadcast_port_id,
13843 (void *)&cmd_set_vf_broadcast_vf_id,
13844 (void *)&cmd_set_vf_broadcast_on_off,
13849 /* vf vlan tag configuration */
13851 /* Common result structure for vf vlan tag */
13852 struct cmd_set_vf_vlan_tag_result {
13853 cmdline_fixed_string_t set;
13854 cmdline_fixed_string_t vf;
13855 cmdline_fixed_string_t vlan;
13856 cmdline_fixed_string_t tag;
13859 cmdline_fixed_string_t on_off;
13862 /* Common CLI fields for vf vlan tag enable disable */
13863 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13864 TOKEN_STRING_INITIALIZER
13865 (struct cmd_set_vf_vlan_tag_result,
13867 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13868 TOKEN_STRING_INITIALIZER
13869 (struct cmd_set_vf_vlan_tag_result,
13871 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13872 TOKEN_STRING_INITIALIZER
13873 (struct cmd_set_vf_vlan_tag_result,
13875 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13876 TOKEN_STRING_INITIALIZER
13877 (struct cmd_set_vf_vlan_tag_result,
13879 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13880 TOKEN_NUM_INITIALIZER
13881 (struct cmd_set_vf_vlan_tag_result,
13883 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13884 TOKEN_NUM_INITIALIZER
13885 (struct cmd_set_vf_vlan_tag_result,
13887 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13888 TOKEN_STRING_INITIALIZER
13889 (struct cmd_set_vf_vlan_tag_result,
13893 cmd_set_vf_vlan_tag_parsed(
13894 void *parsed_result,
13895 __attribute__((unused)) struct cmdline *cl,
13896 __attribute__((unused)) void *data)
13898 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13899 int ret = -ENOTSUP;
13901 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13903 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13906 #ifdef RTE_LIBRTE_I40E_PMD
13907 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13908 res->vf_id, is_on);
13915 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13918 printf("invalid port_id %d\n", res->port_id);
13921 printf("function not implemented\n");
13924 printf("programming error: (%s)\n", strerror(-ret));
13928 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13929 .f = cmd_set_vf_vlan_tag_parsed,
13931 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13933 (void *)&cmd_set_vf_vlan_tag_set,
13934 (void *)&cmd_set_vf_vlan_tag_vf,
13935 (void *)&cmd_set_vf_vlan_tag_vlan,
13936 (void *)&cmd_set_vf_vlan_tag_tag,
13937 (void *)&cmd_set_vf_vlan_tag_port_id,
13938 (void *)&cmd_set_vf_vlan_tag_vf_id,
13939 (void *)&cmd_set_vf_vlan_tag_on_off,
13944 /* Common definition of VF and TC TX bandwidth configuration */
13945 struct cmd_vf_tc_bw_result {
13946 cmdline_fixed_string_t set;
13947 cmdline_fixed_string_t vf;
13948 cmdline_fixed_string_t tc;
13949 cmdline_fixed_string_t tx;
13950 cmdline_fixed_string_t min_bw;
13951 cmdline_fixed_string_t max_bw;
13952 cmdline_fixed_string_t strict_link_prio;
13957 cmdline_fixed_string_t bw_list;
13961 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13962 TOKEN_STRING_INITIALIZER
13963 (struct cmd_vf_tc_bw_result,
13965 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13966 TOKEN_STRING_INITIALIZER
13967 (struct cmd_vf_tc_bw_result,
13969 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13970 TOKEN_STRING_INITIALIZER
13971 (struct cmd_vf_tc_bw_result,
13973 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13974 TOKEN_STRING_INITIALIZER
13975 (struct cmd_vf_tc_bw_result,
13977 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13978 TOKEN_STRING_INITIALIZER
13979 (struct cmd_vf_tc_bw_result,
13980 strict_link_prio, "strict-link-priority");
13981 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13982 TOKEN_STRING_INITIALIZER
13983 (struct cmd_vf_tc_bw_result,
13984 min_bw, "min-bandwidth");
13985 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13986 TOKEN_STRING_INITIALIZER
13987 (struct cmd_vf_tc_bw_result,
13988 max_bw, "max-bandwidth");
13989 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13990 TOKEN_NUM_INITIALIZER
13991 (struct cmd_vf_tc_bw_result,
13993 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13994 TOKEN_NUM_INITIALIZER
13995 (struct cmd_vf_tc_bw_result,
13997 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13998 TOKEN_NUM_INITIALIZER
13999 (struct cmd_vf_tc_bw_result,
14001 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14002 TOKEN_NUM_INITIALIZER
14003 (struct cmd_vf_tc_bw_result,
14005 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14006 TOKEN_STRING_INITIALIZER
14007 (struct cmd_vf_tc_bw_result,
14009 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14010 TOKEN_NUM_INITIALIZER
14011 (struct cmd_vf_tc_bw_result,
14014 /* VF max bandwidth setting */
14016 cmd_vf_max_bw_parsed(
14017 void *parsed_result,
14018 __attribute__((unused)) struct cmdline *cl,
14019 __attribute__((unused)) void *data)
14021 struct cmd_vf_tc_bw_result *res = parsed_result;
14022 int ret = -ENOTSUP;
14024 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14027 #ifdef RTE_LIBRTE_I40E_PMD
14028 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14029 res->vf_id, res->bw);
14036 printf("invalid vf_id %d or bandwidth %d\n",
14037 res->vf_id, res->bw);
14040 printf("invalid port_id %d\n", res->port_id);
14043 printf("function not implemented\n");
14046 printf("programming error: (%s)\n", strerror(-ret));
14050 cmdline_parse_inst_t cmd_vf_max_bw = {
14051 .f = cmd_vf_max_bw_parsed,
14053 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14055 (void *)&cmd_vf_tc_bw_set,
14056 (void *)&cmd_vf_tc_bw_vf,
14057 (void *)&cmd_vf_tc_bw_tx,
14058 (void *)&cmd_vf_tc_bw_max_bw,
14059 (void *)&cmd_vf_tc_bw_port_id,
14060 (void *)&cmd_vf_tc_bw_vf_id,
14061 (void *)&cmd_vf_tc_bw_bw,
14067 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14072 const char *p, *p0 = str;
14079 p = strchr(p0, '(');
14081 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14085 p0 = strchr(p, ')');
14087 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14091 if (size >= sizeof(s)) {
14092 printf("The string size exceeds the internal buffer size\n");
14095 snprintf(s, sizeof(s), "%.*s", size, p);
14096 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14098 printf("Failed to get the bandwidth list. ");
14102 for (i = 0; i < ret; i++)
14103 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14108 /* TC min bandwidth setting */
14110 cmd_vf_tc_min_bw_parsed(
14111 void *parsed_result,
14112 __attribute__((unused)) struct cmdline *cl,
14113 __attribute__((unused)) void *data)
14115 struct cmd_vf_tc_bw_result *res = parsed_result;
14118 int ret = -ENOTSUP;
14120 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14123 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14127 #ifdef RTE_LIBRTE_I40E_PMD
14128 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14136 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14139 printf("invalid port_id %d\n", res->port_id);
14142 printf("function not implemented\n");
14145 printf("programming error: (%s)\n", strerror(-ret));
14149 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14150 .f = cmd_vf_tc_min_bw_parsed,
14152 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14153 " <bw1, bw2, ...>",
14155 (void *)&cmd_vf_tc_bw_set,
14156 (void *)&cmd_vf_tc_bw_vf,
14157 (void *)&cmd_vf_tc_bw_tc,
14158 (void *)&cmd_vf_tc_bw_tx,
14159 (void *)&cmd_vf_tc_bw_min_bw,
14160 (void *)&cmd_vf_tc_bw_port_id,
14161 (void *)&cmd_vf_tc_bw_vf_id,
14162 (void *)&cmd_vf_tc_bw_bw_list,
14168 cmd_tc_min_bw_parsed(
14169 void *parsed_result,
14170 __attribute__((unused)) struct cmdline *cl,
14171 __attribute__((unused)) void *data)
14173 struct cmd_vf_tc_bw_result *res = parsed_result;
14174 struct rte_port *port;
14177 int ret = -ENOTSUP;
14179 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14182 port = &ports[res->port_id];
14183 /** Check if the port is not started **/
14184 if (port->port_status != RTE_PORT_STOPPED) {
14185 printf("Please stop port %d first\n", res->port_id);
14189 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14193 #ifdef RTE_LIBRTE_IXGBE_PMD
14194 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14201 printf("invalid bandwidth\n");
14204 printf("invalid port_id %d\n", res->port_id);
14207 printf("function not implemented\n");
14210 printf("programming error: (%s)\n", strerror(-ret));
14214 cmdline_parse_inst_t cmd_tc_min_bw = {
14215 .f = cmd_tc_min_bw_parsed,
14217 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14219 (void *)&cmd_vf_tc_bw_set,
14220 (void *)&cmd_vf_tc_bw_tc,
14221 (void *)&cmd_vf_tc_bw_tx,
14222 (void *)&cmd_vf_tc_bw_min_bw,
14223 (void *)&cmd_vf_tc_bw_port_id,
14224 (void *)&cmd_vf_tc_bw_bw_list,
14229 /* TC max bandwidth setting */
14231 cmd_vf_tc_max_bw_parsed(
14232 void *parsed_result,
14233 __attribute__((unused)) struct cmdline *cl,
14234 __attribute__((unused)) void *data)
14236 struct cmd_vf_tc_bw_result *res = parsed_result;
14237 int ret = -ENOTSUP;
14239 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14242 #ifdef RTE_LIBRTE_I40E_PMD
14243 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14244 res->tc_no, res->bw);
14251 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14252 res->vf_id, res->tc_no, res->bw);
14255 printf("invalid port_id %d\n", res->port_id);
14258 printf("function not implemented\n");
14261 printf("programming error: (%s)\n", strerror(-ret));
14265 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14266 .f = cmd_vf_tc_max_bw_parsed,
14268 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14271 (void *)&cmd_vf_tc_bw_set,
14272 (void *)&cmd_vf_tc_bw_vf,
14273 (void *)&cmd_vf_tc_bw_tc,
14274 (void *)&cmd_vf_tc_bw_tx,
14275 (void *)&cmd_vf_tc_bw_max_bw,
14276 (void *)&cmd_vf_tc_bw_port_id,
14277 (void *)&cmd_vf_tc_bw_vf_id,
14278 (void *)&cmd_vf_tc_bw_tc_no,
14279 (void *)&cmd_vf_tc_bw_bw,
14285 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14287 /* *** Set Port default Traffic Management Hierarchy *** */
14288 struct cmd_set_port_tm_hierarchy_default_result {
14289 cmdline_fixed_string_t set;
14290 cmdline_fixed_string_t port;
14291 cmdline_fixed_string_t tm;
14292 cmdline_fixed_string_t hierarchy;
14293 cmdline_fixed_string_t def;
14297 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14298 TOKEN_STRING_INITIALIZER(
14299 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14300 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14301 TOKEN_STRING_INITIALIZER(
14302 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14303 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14304 TOKEN_STRING_INITIALIZER(
14305 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14306 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14307 TOKEN_STRING_INITIALIZER(
14308 struct cmd_set_port_tm_hierarchy_default_result,
14309 hierarchy, "hierarchy");
14310 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14311 TOKEN_STRING_INITIALIZER(
14312 struct cmd_set_port_tm_hierarchy_default_result,
14314 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14315 TOKEN_NUM_INITIALIZER(
14316 struct cmd_set_port_tm_hierarchy_default_result,
14319 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14320 __attribute__((unused)) struct cmdline *cl,
14321 __attribute__((unused)) void *data)
14323 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14324 struct rte_port *p;
14325 portid_t port_id = res->port_id;
14327 if (port_id_is_invalid(port_id, ENABLED_WARN))
14330 p = &ports[port_id];
14333 if (p->softport.tm_flag == 0) {
14334 printf(" tm not enabled on port %u (error)\n", port_id);
14338 /* Forward mode: tm */
14339 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14340 printf(" tm mode not enabled(error)\n");
14344 /* Set the default tm hierarchy */
14345 p->softport.tm.default_hierarchy_enable = 1;
14348 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14349 .f = cmd_set_port_tm_hierarchy_default_parsed,
14351 .help_str = "set port tm hierarchy default <port_id>",
14353 (void *)&cmd_set_port_tm_hierarchy_default_set,
14354 (void *)&cmd_set_port_tm_hierarchy_default_port,
14355 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14356 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14357 (void *)&cmd_set_port_tm_hierarchy_default_default,
14358 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14364 /* Strict link priority scheduling mode setting */
14366 cmd_strict_link_prio_parsed(
14367 void *parsed_result,
14368 __attribute__((unused)) struct cmdline *cl,
14369 __attribute__((unused)) void *data)
14371 struct cmd_vf_tc_bw_result *res = parsed_result;
14372 int ret = -ENOTSUP;
14374 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14377 #ifdef RTE_LIBRTE_I40E_PMD
14378 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14385 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14388 printf("invalid port_id %d\n", res->port_id);
14391 printf("function not implemented\n");
14394 printf("programming error: (%s)\n", strerror(-ret));
14398 cmdline_parse_inst_t cmd_strict_link_prio = {
14399 .f = cmd_strict_link_prio_parsed,
14401 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14403 (void *)&cmd_vf_tc_bw_set,
14404 (void *)&cmd_vf_tc_bw_tx,
14405 (void *)&cmd_vf_tc_bw_strict_link_prio,
14406 (void *)&cmd_vf_tc_bw_port_id,
14407 (void *)&cmd_vf_tc_bw_tc_map,
14412 /* Load dynamic device personalization*/
14413 struct cmd_ddp_add_result {
14414 cmdline_fixed_string_t ddp;
14415 cmdline_fixed_string_t add;
14420 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14421 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14422 cmdline_parse_token_string_t cmd_ddp_add_add =
14423 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14424 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14425 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14426 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14427 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14430 cmd_ddp_add_parsed(
14431 void *parsed_result,
14432 __attribute__((unused)) struct cmdline *cl,
14433 __attribute__((unused)) void *data)
14435 struct cmd_ddp_add_result *res = parsed_result;
14441 int ret = -ENOTSUP;
14443 if (res->port_id > nb_ports) {
14444 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14448 if (!all_ports_stopped()) {
14449 printf("Please stop all ports first\n");
14453 filepath = strdup(res->filepath);
14454 if (filepath == NULL) {
14455 printf("Failed to allocate memory\n");
14458 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14460 buff = open_file(file_fld[0], &size);
14462 free((void *)filepath);
14466 #ifdef RTE_LIBRTE_I40E_PMD
14467 if (ret == -ENOTSUP)
14468 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14470 RTE_PMD_I40E_PKG_OP_WR_ADD);
14473 if (ret == -EEXIST)
14474 printf("Profile has already existed.\n");
14476 printf("Failed to load profile.\n");
14477 else if (file_num == 2)
14478 save_file(file_fld[1], buff, size);
14481 free((void *)filepath);
14484 cmdline_parse_inst_t cmd_ddp_add = {
14485 .f = cmd_ddp_add_parsed,
14487 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14489 (void *)&cmd_ddp_add_ddp,
14490 (void *)&cmd_ddp_add_add,
14491 (void *)&cmd_ddp_add_port_id,
14492 (void *)&cmd_ddp_add_filepath,
14497 /* Delete dynamic device personalization*/
14498 struct cmd_ddp_del_result {
14499 cmdline_fixed_string_t ddp;
14500 cmdline_fixed_string_t del;
14505 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14506 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14507 cmdline_parse_token_string_t cmd_ddp_del_del =
14508 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14509 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14510 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14511 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14512 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14515 cmd_ddp_del_parsed(
14516 void *parsed_result,
14517 __attribute__((unused)) struct cmdline *cl,
14518 __attribute__((unused)) void *data)
14520 struct cmd_ddp_del_result *res = parsed_result;
14523 int ret = -ENOTSUP;
14525 if (res->port_id > nb_ports) {
14526 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14530 if (!all_ports_stopped()) {
14531 printf("Please stop all ports first\n");
14535 buff = open_file(res->filepath, &size);
14539 #ifdef RTE_LIBRTE_I40E_PMD
14540 if (ret == -ENOTSUP)
14541 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14543 RTE_PMD_I40E_PKG_OP_WR_DEL);
14546 if (ret == -EACCES)
14547 printf("Profile does not exist.\n");
14549 printf("Failed to delete profile.\n");
14554 cmdline_parse_inst_t cmd_ddp_del = {
14555 .f = cmd_ddp_del_parsed,
14557 .help_str = "ddp del <port_id> <profile_path>",
14559 (void *)&cmd_ddp_del_ddp,
14560 (void *)&cmd_ddp_del_del,
14561 (void *)&cmd_ddp_del_port_id,
14562 (void *)&cmd_ddp_del_filepath,
14567 /* Get dynamic device personalization profile info */
14568 struct cmd_ddp_info_result {
14569 cmdline_fixed_string_t ddp;
14570 cmdline_fixed_string_t get;
14571 cmdline_fixed_string_t info;
14575 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14576 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14577 cmdline_parse_token_string_t cmd_ddp_info_get =
14578 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14579 cmdline_parse_token_string_t cmd_ddp_info_info =
14580 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14581 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14582 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14585 cmd_ddp_info_parsed(
14586 void *parsed_result,
14587 __attribute__((unused)) struct cmdline *cl,
14588 __attribute__((unused)) void *data)
14590 struct cmd_ddp_info_result *res = parsed_result;
14593 int ret = -ENOTSUP;
14594 #ifdef RTE_LIBRTE_I40E_PMD
14597 uint32_t buff_size = 0;
14598 struct rte_pmd_i40e_profile_info info;
14599 uint32_t dev_num = 0;
14600 struct rte_pmd_i40e_ddp_device_id *devs;
14601 uint32_t proto_num = 0;
14602 struct rte_pmd_i40e_proto_info *proto = NULL;
14603 uint32_t pctype_num = 0;
14604 struct rte_pmd_i40e_ptype_info *pctype;
14605 uint32_t ptype_num = 0;
14606 struct rte_pmd_i40e_ptype_info *ptype;
14611 pkg = open_file(res->filepath, &pkg_size);
14615 #ifdef RTE_LIBRTE_I40E_PMD
14616 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14617 (uint8_t *)&info, sizeof(info),
14618 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14620 printf("Global Track id: 0x%x\n", info.track_id);
14621 printf("Global Version: %d.%d.%d.%d\n",
14622 info.version.major,
14623 info.version.minor,
14624 info.version.update,
14625 info.version.draft);
14626 printf("Global Package name: %s\n\n", info.name);
14629 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14630 (uint8_t *)&info, sizeof(info),
14631 RTE_PMD_I40E_PKG_INFO_HEADER);
14633 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14634 printf("i40e Profile Version: %d.%d.%d.%d\n",
14635 info.version.major,
14636 info.version.minor,
14637 info.version.update,
14638 info.version.draft);
14639 printf("i40e Profile name: %s\n\n", info.name);
14642 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14643 (uint8_t *)&buff_size, sizeof(buff_size),
14644 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14645 if (!ret && buff_size) {
14646 buff = (uint8_t *)malloc(buff_size);
14648 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14650 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14652 printf("Package Notes:\n%s\n\n", buff);
14657 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14658 (uint8_t *)&dev_num, sizeof(dev_num),
14659 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14660 if (!ret && dev_num) {
14661 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14662 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14664 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14665 (uint8_t *)devs, buff_size,
14666 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14668 printf("List of supported devices:\n");
14669 for (i = 0; i < dev_num; i++) {
14670 printf(" %04X:%04X %04X:%04X\n",
14671 devs[i].vendor_dev_id >> 16,
14672 devs[i].vendor_dev_id & 0xFFFF,
14673 devs[i].sub_vendor_dev_id >> 16,
14674 devs[i].sub_vendor_dev_id & 0xFFFF);
14682 /* get information about protocols and packet types */
14683 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14684 (uint8_t *)&proto_num, sizeof(proto_num),
14685 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14686 if (ret || !proto_num)
14687 goto no_print_return;
14689 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14690 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14692 goto no_print_return;
14694 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14696 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14698 printf("List of used protocols:\n");
14699 for (i = 0; i < proto_num; i++)
14700 printf(" %2u: %s\n", proto[i].proto_id,
14704 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14705 (uint8_t *)&pctype_num, sizeof(pctype_num),
14706 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14707 if (ret || !pctype_num)
14708 goto no_print_pctypes;
14710 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14711 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14713 goto no_print_pctypes;
14715 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14717 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14720 goto no_print_pctypes;
14723 printf("List of defined packet classification types:\n");
14724 for (i = 0; i < pctype_num; i++) {
14725 printf(" %2u:", pctype[i].ptype_id);
14726 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14727 proto_id = pctype[i].protocols[j];
14728 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14729 for (n = 0; n < proto_num; n++) {
14730 if (proto[n].proto_id == proto_id) {
14731 printf(" %s", proto[n].name);
14744 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14746 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14747 if (ret || !ptype_num)
14748 goto no_print_return;
14750 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14751 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14753 goto no_print_return;
14755 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14757 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14760 goto no_print_return;
14762 printf("List of defined packet types:\n");
14763 for (i = 0; i < ptype_num; i++) {
14764 printf(" %2u:", ptype[i].ptype_id);
14765 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14766 proto_id = ptype[i].protocols[j];
14767 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14768 for (n = 0; n < proto_num; n++) {
14769 if (proto[n].proto_id == proto_id) {
14770 printf(" %s", proto[n].name);
14786 if (ret == -ENOTSUP)
14787 printf("Function not supported in PMD driver\n");
14791 cmdline_parse_inst_t cmd_ddp_get_info = {
14792 .f = cmd_ddp_info_parsed,
14794 .help_str = "ddp get info <profile_path>",
14796 (void *)&cmd_ddp_info_ddp,
14797 (void *)&cmd_ddp_info_get,
14798 (void *)&cmd_ddp_info_info,
14799 (void *)&cmd_ddp_info_filepath,
14804 /* Get dynamic device personalization profile info list*/
14805 #define PROFILE_INFO_SIZE 48
14806 #define MAX_PROFILE_NUM 16
14808 struct cmd_ddp_get_list_result {
14809 cmdline_fixed_string_t ddp;
14810 cmdline_fixed_string_t get;
14811 cmdline_fixed_string_t list;
14815 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14816 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14817 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14818 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14819 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14820 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14821 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14822 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14825 cmd_ddp_get_list_parsed(
14826 void *parsed_result,
14827 __attribute__((unused)) struct cmdline *cl,
14828 __attribute__((unused)) void *data)
14830 struct cmd_ddp_get_list_result *res = parsed_result;
14831 #ifdef RTE_LIBRTE_I40E_PMD
14832 struct rte_pmd_i40e_profile_list *p_list;
14833 struct rte_pmd_i40e_profile_info *p_info;
14838 int ret = -ENOTSUP;
14840 if (res->port_id > nb_ports) {
14841 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14845 #ifdef RTE_LIBRTE_I40E_PMD
14846 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14847 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14849 printf("%s: Failed to malloc buffer\n", __func__);
14851 if (ret == -ENOTSUP)
14852 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14853 (uint8_t *)p_list, size);
14856 p_num = p_list->p_count;
14857 printf("Profile number is: %d\n\n", p_num);
14859 for (i = 0; i < p_num; i++) {
14860 p_info = &p_list->p_info[i];
14861 printf("Profile %d:\n", i);
14862 printf("Track id: 0x%x\n", p_info->track_id);
14863 printf("Version: %d.%d.%d.%d\n",
14864 p_info->version.major,
14865 p_info->version.minor,
14866 p_info->version.update,
14867 p_info->version.draft);
14868 printf("Profile name: %s\n\n", p_info->name);
14876 printf("Failed to get ddp list\n");
14879 cmdline_parse_inst_t cmd_ddp_get_list = {
14880 .f = cmd_ddp_get_list_parsed,
14882 .help_str = "ddp get list <port_id>",
14884 (void *)&cmd_ddp_get_list_ddp,
14885 (void *)&cmd_ddp_get_list_get,
14886 (void *)&cmd_ddp_get_list_list,
14887 (void *)&cmd_ddp_get_list_port_id,
14892 /* Configure input set */
14893 struct cmd_cfg_input_set_result {
14894 cmdline_fixed_string_t port;
14895 cmdline_fixed_string_t cfg;
14897 cmdline_fixed_string_t pctype;
14899 cmdline_fixed_string_t inset_type;
14900 cmdline_fixed_string_t opt;
14901 cmdline_fixed_string_t field;
14906 cmd_cfg_input_set_parsed(
14907 void *parsed_result,
14908 __attribute__((unused)) struct cmdline *cl,
14909 __attribute__((unused)) void *data)
14911 struct cmd_cfg_input_set_result *res = parsed_result;
14912 #ifdef RTE_LIBRTE_I40E_PMD
14913 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14914 struct rte_pmd_i40e_inset inset;
14916 int ret = -ENOTSUP;
14918 if (res->port_id > nb_ports) {
14919 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14923 if (!all_ports_stopped()) {
14924 printf("Please stop all ports first\n");
14928 #ifdef RTE_LIBRTE_I40E_PMD
14929 if (!strcmp(res->inset_type, "hash_inset"))
14930 inset_type = INSET_HASH;
14931 else if (!strcmp(res->inset_type, "fdir_inset"))
14932 inset_type = INSET_FDIR;
14933 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14934 inset_type = INSET_FDIR_FLX;
14935 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14936 &inset, inset_type);
14938 printf("Failed to get input set.\n");
14942 if (!strcmp(res->opt, "get")) {
14943 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14946 printf("Field index %d is enabled.\n", res->field_idx);
14948 printf("Field index %d is disabled.\n", res->field_idx);
14950 } else if (!strcmp(res->opt, "set"))
14951 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14953 else if (!strcmp(res->opt, "clear"))
14954 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14957 printf("Failed to configure input set field.\n");
14961 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14962 &inset, inset_type);
14964 printf("Failed to set input set.\n");
14969 if (ret == -ENOTSUP)
14970 printf("Function not supported\n");
14973 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14974 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14976 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14977 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14979 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14980 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14982 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14983 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14985 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14986 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14988 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14989 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14991 "hash_inset#fdir_inset#fdir_flx_inset");
14992 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14993 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14994 opt, "get#set#clear");
14995 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14996 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14998 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14999 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15002 cmdline_parse_inst_t cmd_cfg_input_set = {
15003 .f = cmd_cfg_input_set_parsed,
15005 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15006 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15008 (void *)&cmd_cfg_input_set_port,
15009 (void *)&cmd_cfg_input_set_cfg,
15010 (void *)&cmd_cfg_input_set_port_id,
15011 (void *)&cmd_cfg_input_set_pctype,
15012 (void *)&cmd_cfg_input_set_pctype_id,
15013 (void *)&cmd_cfg_input_set_inset_type,
15014 (void *)&cmd_cfg_input_set_opt,
15015 (void *)&cmd_cfg_input_set_field,
15016 (void *)&cmd_cfg_input_set_field_idx,
15021 /* Clear input set */
15022 struct cmd_clear_input_set_result {
15023 cmdline_fixed_string_t port;
15024 cmdline_fixed_string_t cfg;
15026 cmdline_fixed_string_t pctype;
15028 cmdline_fixed_string_t inset_type;
15029 cmdline_fixed_string_t clear;
15030 cmdline_fixed_string_t all;
15034 cmd_clear_input_set_parsed(
15035 void *parsed_result,
15036 __attribute__((unused)) struct cmdline *cl,
15037 __attribute__((unused)) void *data)
15039 struct cmd_clear_input_set_result *res = parsed_result;
15040 #ifdef RTE_LIBRTE_I40E_PMD
15041 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15042 struct rte_pmd_i40e_inset inset;
15044 int ret = -ENOTSUP;
15046 if (res->port_id > nb_ports) {
15047 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
15051 if (!all_ports_stopped()) {
15052 printf("Please stop all ports first\n");
15056 #ifdef RTE_LIBRTE_I40E_PMD
15057 if (!strcmp(res->inset_type, "hash_inset"))
15058 inset_type = INSET_HASH;
15059 else if (!strcmp(res->inset_type, "fdir_inset"))
15060 inset_type = INSET_FDIR;
15061 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15062 inset_type = INSET_FDIR_FLX;
15064 memset(&inset, 0, sizeof(inset));
15066 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15067 &inset, inset_type);
15069 printf("Failed to clear input set.\n");
15075 if (ret == -ENOTSUP)
15076 printf("Function not supported\n");
15079 cmdline_parse_token_string_t cmd_clear_input_set_port =
15080 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15082 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15083 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15085 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15086 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15088 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15089 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15091 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15092 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15094 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15095 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15097 "hash_inset#fdir_inset#fdir_flx_inset");
15098 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15099 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15101 cmdline_parse_token_string_t cmd_clear_input_set_all =
15102 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15105 cmdline_parse_inst_t cmd_clear_input_set = {
15106 .f = cmd_clear_input_set_parsed,
15108 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15109 "fdir_inset|fdir_flx_inset clear all",
15111 (void *)&cmd_clear_input_set_port,
15112 (void *)&cmd_clear_input_set_cfg,
15113 (void *)&cmd_clear_input_set_port_id,
15114 (void *)&cmd_clear_input_set_pctype,
15115 (void *)&cmd_clear_input_set_pctype_id,
15116 (void *)&cmd_clear_input_set_inset_type,
15117 (void *)&cmd_clear_input_set_clear,
15118 (void *)&cmd_clear_input_set_all,
15123 /* show vf stats */
15125 /* Common result structure for show vf stats */
15126 struct cmd_show_vf_stats_result {
15127 cmdline_fixed_string_t show;
15128 cmdline_fixed_string_t vf;
15129 cmdline_fixed_string_t stats;
15134 /* Common CLI fields show vf stats*/
15135 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15136 TOKEN_STRING_INITIALIZER
15137 (struct cmd_show_vf_stats_result,
15139 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15140 TOKEN_STRING_INITIALIZER
15141 (struct cmd_show_vf_stats_result,
15143 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15144 TOKEN_STRING_INITIALIZER
15145 (struct cmd_show_vf_stats_result,
15147 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15148 TOKEN_NUM_INITIALIZER
15149 (struct cmd_show_vf_stats_result,
15151 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15152 TOKEN_NUM_INITIALIZER
15153 (struct cmd_show_vf_stats_result,
15157 cmd_show_vf_stats_parsed(
15158 void *parsed_result,
15159 __attribute__((unused)) struct cmdline *cl,
15160 __attribute__((unused)) void *data)
15162 struct cmd_show_vf_stats_result *res = parsed_result;
15163 struct rte_eth_stats stats;
15164 int ret = -ENOTSUP;
15165 static const char *nic_stats_border = "########################";
15167 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15170 memset(&stats, 0, sizeof(stats));
15172 #ifdef RTE_LIBRTE_I40E_PMD
15173 if (ret == -ENOTSUP)
15174 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15178 #ifdef RTE_LIBRTE_BNXT_PMD
15179 if (ret == -ENOTSUP)
15180 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15189 printf("invalid vf_id %d\n", res->vf_id);
15192 printf("invalid port_id %d\n", res->port_id);
15195 printf("function not implemented\n");
15198 printf("programming error: (%s)\n", strerror(-ret));
15201 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15202 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15204 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15206 stats.ipackets, stats.imissed, stats.ibytes);
15207 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15208 printf(" RX-nombuf: %-10"PRIu64"\n",
15210 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15212 stats.opackets, stats.oerrors, stats.obytes);
15214 printf(" %s############################%s\n",
15215 nic_stats_border, nic_stats_border);
15218 cmdline_parse_inst_t cmd_show_vf_stats = {
15219 .f = cmd_show_vf_stats_parsed,
15221 .help_str = "show vf stats <port_id> <vf_id>",
15223 (void *)&cmd_show_vf_stats_show,
15224 (void *)&cmd_show_vf_stats_vf,
15225 (void *)&cmd_show_vf_stats_stats,
15226 (void *)&cmd_show_vf_stats_port_id,
15227 (void *)&cmd_show_vf_stats_vf_id,
15232 /* clear vf stats */
15234 /* Common result structure for clear vf stats */
15235 struct cmd_clear_vf_stats_result {
15236 cmdline_fixed_string_t clear;
15237 cmdline_fixed_string_t vf;
15238 cmdline_fixed_string_t stats;
15243 /* Common CLI fields clear vf stats*/
15244 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15245 TOKEN_STRING_INITIALIZER
15246 (struct cmd_clear_vf_stats_result,
15248 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15249 TOKEN_STRING_INITIALIZER
15250 (struct cmd_clear_vf_stats_result,
15252 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15253 TOKEN_STRING_INITIALIZER
15254 (struct cmd_clear_vf_stats_result,
15256 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15257 TOKEN_NUM_INITIALIZER
15258 (struct cmd_clear_vf_stats_result,
15260 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15261 TOKEN_NUM_INITIALIZER
15262 (struct cmd_clear_vf_stats_result,
15266 cmd_clear_vf_stats_parsed(
15267 void *parsed_result,
15268 __attribute__((unused)) struct cmdline *cl,
15269 __attribute__((unused)) void *data)
15271 struct cmd_clear_vf_stats_result *res = parsed_result;
15272 int ret = -ENOTSUP;
15274 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15277 #ifdef RTE_LIBRTE_I40E_PMD
15278 if (ret == -ENOTSUP)
15279 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15282 #ifdef RTE_LIBRTE_BNXT_PMD
15283 if (ret == -ENOTSUP)
15284 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15292 printf("invalid vf_id %d\n", res->vf_id);
15295 printf("invalid port_id %d\n", res->port_id);
15298 printf("function not implemented\n");
15301 printf("programming error: (%s)\n", strerror(-ret));
15305 cmdline_parse_inst_t cmd_clear_vf_stats = {
15306 .f = cmd_clear_vf_stats_parsed,
15308 .help_str = "clear vf stats <port_id> <vf_id>",
15310 (void *)&cmd_clear_vf_stats_clear,
15311 (void *)&cmd_clear_vf_stats_vf,
15312 (void *)&cmd_clear_vf_stats_stats,
15313 (void *)&cmd_clear_vf_stats_port_id,
15314 (void *)&cmd_clear_vf_stats_vf_id,
15319 /* port config pctype mapping reset */
15321 /* Common result structure for port config pctype mapping reset */
15322 struct cmd_pctype_mapping_reset_result {
15323 cmdline_fixed_string_t port;
15324 cmdline_fixed_string_t config;
15326 cmdline_fixed_string_t pctype;
15327 cmdline_fixed_string_t mapping;
15328 cmdline_fixed_string_t reset;
15331 /* Common CLI fields for port config pctype mapping reset*/
15332 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15333 TOKEN_STRING_INITIALIZER
15334 (struct cmd_pctype_mapping_reset_result,
15336 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15337 TOKEN_STRING_INITIALIZER
15338 (struct cmd_pctype_mapping_reset_result,
15340 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15341 TOKEN_NUM_INITIALIZER
15342 (struct cmd_pctype_mapping_reset_result,
15344 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15345 TOKEN_STRING_INITIALIZER
15346 (struct cmd_pctype_mapping_reset_result,
15348 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15349 TOKEN_STRING_INITIALIZER
15350 (struct cmd_pctype_mapping_reset_result,
15351 mapping, "mapping");
15352 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15353 TOKEN_STRING_INITIALIZER
15354 (struct cmd_pctype_mapping_reset_result,
15358 cmd_pctype_mapping_reset_parsed(
15359 void *parsed_result,
15360 __attribute__((unused)) struct cmdline *cl,
15361 __attribute__((unused)) void *data)
15363 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15364 int ret = -ENOTSUP;
15366 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15369 #ifdef RTE_LIBRTE_I40E_PMD
15370 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15377 printf("invalid port_id %d\n", res->port_id);
15380 printf("function not implemented\n");
15383 printf("programming error: (%s)\n", strerror(-ret));
15387 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15388 .f = cmd_pctype_mapping_reset_parsed,
15390 .help_str = "port config <port_id> pctype mapping reset",
15392 (void *)&cmd_pctype_mapping_reset_port,
15393 (void *)&cmd_pctype_mapping_reset_config,
15394 (void *)&cmd_pctype_mapping_reset_port_id,
15395 (void *)&cmd_pctype_mapping_reset_pctype,
15396 (void *)&cmd_pctype_mapping_reset_mapping,
15397 (void *)&cmd_pctype_mapping_reset_reset,
15402 /* show port pctype mapping */
15404 /* Common result structure for show port pctype mapping */
15405 struct cmd_pctype_mapping_get_result {
15406 cmdline_fixed_string_t show;
15407 cmdline_fixed_string_t port;
15409 cmdline_fixed_string_t pctype;
15410 cmdline_fixed_string_t mapping;
15413 /* Common CLI fields for pctype mapping get */
15414 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15415 TOKEN_STRING_INITIALIZER
15416 (struct cmd_pctype_mapping_get_result,
15418 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15419 TOKEN_STRING_INITIALIZER
15420 (struct cmd_pctype_mapping_get_result,
15422 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15423 TOKEN_NUM_INITIALIZER
15424 (struct cmd_pctype_mapping_get_result,
15426 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15427 TOKEN_STRING_INITIALIZER
15428 (struct cmd_pctype_mapping_get_result,
15430 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15431 TOKEN_STRING_INITIALIZER
15432 (struct cmd_pctype_mapping_get_result,
15433 mapping, "mapping");
15436 cmd_pctype_mapping_get_parsed(
15437 void *parsed_result,
15438 __attribute__((unused)) struct cmdline *cl,
15439 __attribute__((unused)) void *data)
15441 struct cmd_pctype_mapping_get_result *res = parsed_result;
15442 int ret = -ENOTSUP;
15443 #ifdef RTE_LIBRTE_I40E_PMD
15444 struct rte_pmd_i40e_flow_type_mapping
15445 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15446 int i, j, first_pctype;
15449 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15452 #ifdef RTE_LIBRTE_I40E_PMD
15453 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15460 printf("invalid port_id %d\n", res->port_id);
15463 printf("function not implemented\n");
15466 printf("programming error: (%s)\n", strerror(-ret));
15470 #ifdef RTE_LIBRTE_I40E_PMD
15471 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15472 if (mapping[i].pctype != 0ULL) {
15475 printf("pctype: ");
15476 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15477 if (mapping[i].pctype & (1ULL << j)) {
15478 printf(first_pctype ?
15479 "%02d" : ",%02d", j);
15483 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15489 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15490 .f = cmd_pctype_mapping_get_parsed,
15492 .help_str = "show port <port_id> pctype mapping",
15494 (void *)&cmd_pctype_mapping_get_show,
15495 (void *)&cmd_pctype_mapping_get_port,
15496 (void *)&cmd_pctype_mapping_get_port_id,
15497 (void *)&cmd_pctype_mapping_get_pctype,
15498 (void *)&cmd_pctype_mapping_get_mapping,
15503 /* port config pctype mapping update */
15505 /* Common result structure for port config pctype mapping update */
15506 struct cmd_pctype_mapping_update_result {
15507 cmdline_fixed_string_t port;
15508 cmdline_fixed_string_t config;
15510 cmdline_fixed_string_t pctype;
15511 cmdline_fixed_string_t mapping;
15512 cmdline_fixed_string_t update;
15513 cmdline_fixed_string_t pctype_list;
15514 uint16_t flow_type;
15517 /* Common CLI fields for pctype mapping update*/
15518 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15519 TOKEN_STRING_INITIALIZER
15520 (struct cmd_pctype_mapping_update_result,
15522 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15523 TOKEN_STRING_INITIALIZER
15524 (struct cmd_pctype_mapping_update_result,
15526 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15527 TOKEN_NUM_INITIALIZER
15528 (struct cmd_pctype_mapping_update_result,
15530 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15531 TOKEN_STRING_INITIALIZER
15532 (struct cmd_pctype_mapping_update_result,
15534 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15535 TOKEN_STRING_INITIALIZER
15536 (struct cmd_pctype_mapping_update_result,
15537 mapping, "mapping");
15538 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15539 TOKEN_STRING_INITIALIZER
15540 (struct cmd_pctype_mapping_update_result,
15542 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15543 TOKEN_STRING_INITIALIZER
15544 (struct cmd_pctype_mapping_update_result,
15545 pctype_list, NULL);
15546 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15547 TOKEN_NUM_INITIALIZER
15548 (struct cmd_pctype_mapping_update_result,
15549 flow_type, UINT16);
15552 cmd_pctype_mapping_update_parsed(
15553 void *parsed_result,
15554 __attribute__((unused)) struct cmdline *cl,
15555 __attribute__((unused)) void *data)
15557 struct cmd_pctype_mapping_update_result *res = parsed_result;
15558 int ret = -ENOTSUP;
15559 #ifdef RTE_LIBRTE_I40E_PMD
15560 struct rte_pmd_i40e_flow_type_mapping mapping;
15562 unsigned int nb_item;
15563 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15566 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15569 #ifdef RTE_LIBRTE_I40E_PMD
15570 nb_item = parse_item_list(res->pctype_list, "pctypes",
15571 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15572 mapping.flow_type = res->flow_type;
15573 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15574 mapping.pctype |= (1ULL << pctype_list[i]);
15575 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15585 printf("invalid pctype or flow type\n");
15588 printf("invalid port_id %d\n", res->port_id);
15591 printf("function not implemented\n");
15594 printf("programming error: (%s)\n", strerror(-ret));
15598 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15599 .f = cmd_pctype_mapping_update_parsed,
15601 .help_str = "port config <port_id> pctype mapping update"
15602 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15604 (void *)&cmd_pctype_mapping_update_port,
15605 (void *)&cmd_pctype_mapping_update_config,
15606 (void *)&cmd_pctype_mapping_update_port_id,
15607 (void *)&cmd_pctype_mapping_update_pctype,
15608 (void *)&cmd_pctype_mapping_update_mapping,
15609 (void *)&cmd_pctype_mapping_update_update,
15610 (void *)&cmd_pctype_mapping_update_pc_type,
15611 (void *)&cmd_pctype_mapping_update_flow_type,
15616 /* ptype mapping get */
15618 /* Common result structure for ptype mapping get */
15619 struct cmd_ptype_mapping_get_result {
15620 cmdline_fixed_string_t ptype;
15621 cmdline_fixed_string_t mapping;
15622 cmdline_fixed_string_t get;
15624 uint8_t valid_only;
15627 /* Common CLI fields for ptype mapping get */
15628 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15629 TOKEN_STRING_INITIALIZER
15630 (struct cmd_ptype_mapping_get_result,
15632 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15633 TOKEN_STRING_INITIALIZER
15634 (struct cmd_ptype_mapping_get_result,
15635 mapping, "mapping");
15636 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15637 TOKEN_STRING_INITIALIZER
15638 (struct cmd_ptype_mapping_get_result,
15640 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15641 TOKEN_NUM_INITIALIZER
15642 (struct cmd_ptype_mapping_get_result,
15644 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15645 TOKEN_NUM_INITIALIZER
15646 (struct cmd_ptype_mapping_get_result,
15647 valid_only, UINT8);
15650 cmd_ptype_mapping_get_parsed(
15651 void *parsed_result,
15652 __attribute__((unused)) struct cmdline *cl,
15653 __attribute__((unused)) void *data)
15655 struct cmd_ptype_mapping_get_result *res = parsed_result;
15656 int ret = -ENOTSUP;
15657 #ifdef RTE_LIBRTE_I40E_PMD
15658 int max_ptype_num = 256;
15659 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15664 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15667 #ifdef RTE_LIBRTE_I40E_PMD
15668 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15679 printf("invalid port_id %d\n", res->port_id);
15682 printf("function not implemented\n");
15685 printf("programming error: (%s)\n", strerror(-ret));
15688 #ifdef RTE_LIBRTE_I40E_PMD
15690 for (i = 0; i < count; i++)
15691 printf("%3d\t0x%08x\n",
15692 mapping[i].hw_ptype, mapping[i].sw_ptype);
15697 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15698 .f = cmd_ptype_mapping_get_parsed,
15700 .help_str = "ptype mapping get <port_id> <valid_only>",
15702 (void *)&cmd_ptype_mapping_get_ptype,
15703 (void *)&cmd_ptype_mapping_get_mapping,
15704 (void *)&cmd_ptype_mapping_get_get,
15705 (void *)&cmd_ptype_mapping_get_port_id,
15706 (void *)&cmd_ptype_mapping_get_valid_only,
15711 /* ptype mapping replace */
15713 /* Common result structure for ptype mapping replace */
15714 struct cmd_ptype_mapping_replace_result {
15715 cmdline_fixed_string_t ptype;
15716 cmdline_fixed_string_t mapping;
15717 cmdline_fixed_string_t replace;
15724 /* Common CLI fields for ptype mapping replace */
15725 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15726 TOKEN_STRING_INITIALIZER
15727 (struct cmd_ptype_mapping_replace_result,
15729 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15730 TOKEN_STRING_INITIALIZER
15731 (struct cmd_ptype_mapping_replace_result,
15732 mapping, "mapping");
15733 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15734 TOKEN_STRING_INITIALIZER
15735 (struct cmd_ptype_mapping_replace_result,
15736 replace, "replace");
15737 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15738 TOKEN_NUM_INITIALIZER
15739 (struct cmd_ptype_mapping_replace_result,
15741 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15742 TOKEN_NUM_INITIALIZER
15743 (struct cmd_ptype_mapping_replace_result,
15745 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15746 TOKEN_NUM_INITIALIZER
15747 (struct cmd_ptype_mapping_replace_result,
15749 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15750 TOKEN_NUM_INITIALIZER
15751 (struct cmd_ptype_mapping_replace_result,
15755 cmd_ptype_mapping_replace_parsed(
15756 void *parsed_result,
15757 __attribute__((unused)) struct cmdline *cl,
15758 __attribute__((unused)) void *data)
15760 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15761 int ret = -ENOTSUP;
15763 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15766 #ifdef RTE_LIBRTE_I40E_PMD
15767 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15777 printf("invalid ptype 0x%8x or 0x%8x\n",
15778 res->target, res->pkt_type);
15781 printf("invalid port_id %d\n", res->port_id);
15784 printf("function not implemented\n");
15787 printf("programming error: (%s)\n", strerror(-ret));
15791 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15792 .f = cmd_ptype_mapping_replace_parsed,
15795 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15797 (void *)&cmd_ptype_mapping_replace_ptype,
15798 (void *)&cmd_ptype_mapping_replace_mapping,
15799 (void *)&cmd_ptype_mapping_replace_replace,
15800 (void *)&cmd_ptype_mapping_replace_port_id,
15801 (void *)&cmd_ptype_mapping_replace_target,
15802 (void *)&cmd_ptype_mapping_replace_mask,
15803 (void *)&cmd_ptype_mapping_replace_pkt_type,
15808 /* ptype mapping reset */
15810 /* Common result structure for ptype mapping reset */
15811 struct cmd_ptype_mapping_reset_result {
15812 cmdline_fixed_string_t ptype;
15813 cmdline_fixed_string_t mapping;
15814 cmdline_fixed_string_t reset;
15818 /* Common CLI fields for ptype mapping reset*/
15819 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15820 TOKEN_STRING_INITIALIZER
15821 (struct cmd_ptype_mapping_reset_result,
15823 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15824 TOKEN_STRING_INITIALIZER
15825 (struct cmd_ptype_mapping_reset_result,
15826 mapping, "mapping");
15827 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15828 TOKEN_STRING_INITIALIZER
15829 (struct cmd_ptype_mapping_reset_result,
15831 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15832 TOKEN_NUM_INITIALIZER
15833 (struct cmd_ptype_mapping_reset_result,
15837 cmd_ptype_mapping_reset_parsed(
15838 void *parsed_result,
15839 __attribute__((unused)) struct cmdline *cl,
15840 __attribute__((unused)) void *data)
15842 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15843 int ret = -ENOTSUP;
15845 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15848 #ifdef RTE_LIBRTE_I40E_PMD
15849 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15856 printf("invalid port_id %d\n", res->port_id);
15859 printf("function not implemented\n");
15862 printf("programming error: (%s)\n", strerror(-ret));
15866 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15867 .f = cmd_ptype_mapping_reset_parsed,
15869 .help_str = "ptype mapping reset <port_id>",
15871 (void *)&cmd_ptype_mapping_reset_ptype,
15872 (void *)&cmd_ptype_mapping_reset_mapping,
15873 (void *)&cmd_ptype_mapping_reset_reset,
15874 (void *)&cmd_ptype_mapping_reset_port_id,
15879 /* ptype mapping update */
15881 /* Common result structure for ptype mapping update */
15882 struct cmd_ptype_mapping_update_result {
15883 cmdline_fixed_string_t ptype;
15884 cmdline_fixed_string_t mapping;
15885 cmdline_fixed_string_t reset;
15891 /* Common CLI fields for ptype mapping update*/
15892 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15893 TOKEN_STRING_INITIALIZER
15894 (struct cmd_ptype_mapping_update_result,
15896 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15897 TOKEN_STRING_INITIALIZER
15898 (struct cmd_ptype_mapping_update_result,
15899 mapping, "mapping");
15900 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15901 TOKEN_STRING_INITIALIZER
15902 (struct cmd_ptype_mapping_update_result,
15904 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15905 TOKEN_NUM_INITIALIZER
15906 (struct cmd_ptype_mapping_update_result,
15908 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15909 TOKEN_NUM_INITIALIZER
15910 (struct cmd_ptype_mapping_update_result,
15912 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15913 TOKEN_NUM_INITIALIZER
15914 (struct cmd_ptype_mapping_update_result,
15918 cmd_ptype_mapping_update_parsed(
15919 void *parsed_result,
15920 __attribute__((unused)) struct cmdline *cl,
15921 __attribute__((unused)) void *data)
15923 struct cmd_ptype_mapping_update_result *res = parsed_result;
15924 int ret = -ENOTSUP;
15925 #ifdef RTE_LIBRTE_I40E_PMD
15926 struct rte_pmd_i40e_ptype_mapping mapping;
15928 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15931 #ifdef RTE_LIBRTE_I40E_PMD
15932 mapping.hw_ptype = res->hw_ptype;
15933 mapping.sw_ptype = res->sw_ptype;
15934 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15944 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15947 printf("invalid port_id %d\n", res->port_id);
15950 printf("function not implemented\n");
15953 printf("programming error: (%s)\n", strerror(-ret));
15957 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15958 .f = cmd_ptype_mapping_update_parsed,
15960 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15962 (void *)&cmd_ptype_mapping_update_ptype,
15963 (void *)&cmd_ptype_mapping_update_mapping,
15964 (void *)&cmd_ptype_mapping_update_update,
15965 (void *)&cmd_ptype_mapping_update_port_id,
15966 (void *)&cmd_ptype_mapping_update_hw_ptype,
15967 (void *)&cmd_ptype_mapping_update_sw_ptype,
15972 /* Common result structure for file commands */
15973 struct cmd_cmdfile_result {
15974 cmdline_fixed_string_t load;
15975 cmdline_fixed_string_t filename;
15978 /* Common CLI fields for file commands */
15979 cmdline_parse_token_string_t cmd_load_cmdfile =
15980 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15981 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15982 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15985 cmd_load_from_file_parsed(
15986 void *parsed_result,
15987 __attribute__((unused)) struct cmdline *cl,
15988 __attribute__((unused)) void *data)
15990 struct cmd_cmdfile_result *res = parsed_result;
15992 cmdline_read_from_file(res->filename);
15995 cmdline_parse_inst_t cmd_load_from_file = {
15996 .f = cmd_load_from_file_parsed,
15998 .help_str = "load <filename>",
16000 (void *)&cmd_load_cmdfile,
16001 (void *)&cmd_load_cmdfile_filename,
16006 /* ******************************************************************************** */
16008 /* list of instructions */
16009 cmdline_parse_ctx_t main_ctx[] = {
16010 (cmdline_parse_inst_t *)&cmd_help_brief,
16011 (cmdline_parse_inst_t *)&cmd_help_long,
16012 (cmdline_parse_inst_t *)&cmd_quit,
16013 (cmdline_parse_inst_t *)&cmd_load_from_file,
16014 (cmdline_parse_inst_t *)&cmd_showport,
16015 (cmdline_parse_inst_t *)&cmd_showqueue,
16016 (cmdline_parse_inst_t *)&cmd_showportall,
16017 (cmdline_parse_inst_t *)&cmd_showcfg,
16018 (cmdline_parse_inst_t *)&cmd_start,
16019 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16020 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16021 (cmdline_parse_inst_t *)&cmd_set_link_up,
16022 (cmdline_parse_inst_t *)&cmd_set_link_down,
16023 (cmdline_parse_inst_t *)&cmd_reset,
16024 (cmdline_parse_inst_t *)&cmd_set_numbers,
16025 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16026 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16027 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16028 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16029 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16030 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16031 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16032 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16033 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16034 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16035 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16036 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16037 (cmdline_parse_inst_t *)&cmd_set_link_check,
16038 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16039 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16040 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16041 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16042 #ifdef RTE_LIBRTE_PMD_BOND
16043 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16044 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16045 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16046 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16047 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16048 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16049 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16050 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16051 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16052 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16053 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16055 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16056 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16057 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16058 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16059 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16060 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16061 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16062 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16063 (cmdline_parse_inst_t *)&cmd_csum_set,
16064 (cmdline_parse_inst_t *)&cmd_csum_show,
16065 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16066 (cmdline_parse_inst_t *)&cmd_tso_set,
16067 (cmdline_parse_inst_t *)&cmd_tso_show,
16068 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16069 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16070 (cmdline_parse_inst_t *)&cmd_gro_enable,
16071 (cmdline_parse_inst_t *)&cmd_gro_flush,
16072 (cmdline_parse_inst_t *)&cmd_gro_show,
16073 (cmdline_parse_inst_t *)&cmd_gso_enable,
16074 (cmdline_parse_inst_t *)&cmd_gso_size,
16075 (cmdline_parse_inst_t *)&cmd_gso_show,
16076 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16077 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16078 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16079 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16080 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16081 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16082 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16083 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16084 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16085 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16086 (cmdline_parse_inst_t *)&cmd_config_dcb,
16087 (cmdline_parse_inst_t *)&cmd_read_reg,
16088 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16089 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16090 (cmdline_parse_inst_t *)&cmd_write_reg,
16091 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16092 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16093 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16094 (cmdline_parse_inst_t *)&cmd_stop,
16095 (cmdline_parse_inst_t *)&cmd_mac_addr,
16096 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16097 (cmdline_parse_inst_t *)&cmd_set_qmap,
16098 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16099 (cmdline_parse_inst_t *)&cmd_operate_port,
16100 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16101 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16102 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16103 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16104 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16105 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16106 (cmdline_parse_inst_t *)&cmd_config_mtu,
16107 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16108 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16109 (cmdline_parse_inst_t *)&cmd_config_rss,
16110 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16111 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16112 (cmdline_parse_inst_t *)&cmd_showport_reta,
16113 (cmdline_parse_inst_t *)&cmd_config_burst,
16114 (cmdline_parse_inst_t *)&cmd_config_thresh,
16115 (cmdline_parse_inst_t *)&cmd_config_threshold,
16116 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16117 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16118 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16119 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16120 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16121 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16122 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16123 (cmdline_parse_inst_t *)&cmd_global_config,
16124 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16125 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16126 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16127 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16128 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16129 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16130 (cmdline_parse_inst_t *)&cmd_dump,
16131 (cmdline_parse_inst_t *)&cmd_dump_one,
16132 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16133 (cmdline_parse_inst_t *)&cmd_syn_filter,
16134 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16135 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16136 (cmdline_parse_inst_t *)&cmd_flex_filter,
16137 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16138 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16139 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16140 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16141 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16142 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16143 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16144 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16145 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16146 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16147 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16148 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16149 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16150 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16151 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16152 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16153 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16154 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16155 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16156 (cmdline_parse_inst_t *)&cmd_flow,
16157 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16158 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16159 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16160 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16161 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16162 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16163 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16164 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16165 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16166 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16167 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16168 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16169 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16170 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16171 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16172 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16173 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16174 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16175 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16176 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16177 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16178 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16179 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16180 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16181 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16182 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16183 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16184 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16185 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16186 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16187 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16188 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16189 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16190 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16191 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16192 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16193 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16194 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16195 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16196 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16197 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16198 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16199 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16200 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16201 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16202 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16203 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16204 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16205 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16206 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16207 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16209 (cmdline_parse_inst_t *)&cmd_ddp_add,
16210 (cmdline_parse_inst_t *)&cmd_ddp_del,
16211 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16212 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16213 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16214 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16215 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16216 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16217 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16218 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16219 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16220 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16222 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16223 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16224 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16225 (cmdline_parse_inst_t *)&cmd_queue_region,
16226 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16227 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16228 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16229 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16230 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16231 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16232 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16233 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16234 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16235 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16236 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16237 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16238 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16239 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16240 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16241 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16242 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16243 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16244 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16245 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16246 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16250 /* read cmdline commands from file */
16252 cmdline_read_from_file(const char *filename)
16254 struct cmdline *cl;
16256 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16258 printf("Failed to create file based cmdline context: %s\n",
16263 cmdline_interact(cl);
16268 printf("Read CLI commands from %s\n", filename);
16271 /* prompt function, called from main on MASTER lcore */
16275 /* initialize non-constant commands */
16276 cmd_set_fwd_mode_init();
16277 cmd_set_fwd_retry_mode_init();
16279 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16280 if (testpmd_cl == NULL)
16282 cmdline_interact(testpmd_cl);
16283 cmdline_stdin_exit(testpmd_cl);
16289 if (testpmd_cl != NULL)
16290 cmdline_quit(testpmd_cl);
16294 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16296 if (id == (portid_t)RTE_PORT_ALL) {
16299 RTE_ETH_FOREACH_DEV(pid) {
16300 /* check if need_reconfig has been set to 1 */
16301 if (ports[pid].need_reconfig == 0)
16302 ports[pid].need_reconfig = dev;
16303 /* check if need_reconfig_queues has been set to 1 */
16304 if (ports[pid].need_reconfig_queues == 0)
16305 ports[pid].need_reconfig_queues = queue;
16307 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16308 /* check if need_reconfig has been set to 1 */
16309 if (ports[id].need_reconfig == 0)
16310 ports[id].need_reconfig = dev;
16311 /* check if need_reconfig_queues has been set to 1 */
16312 if (ports[id].need_reconfig_queues == 0)
16313 ports[id].need_reconfig_queues = queue;