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 if (check_nb_rxq(res->value) != 0)
1543 nb_rxq = res->value;
1545 else if (!strcmp(res->name, "txq")) {
1546 if (!res->value && !nb_rxq) {
1547 printf("Warning: Either rx or tx queues should be non zero\n");
1550 nb_txq = res->value;
1552 else if (!strcmp(res->name, "rxd")) {
1553 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1554 printf("rxd %d invalid - must be > 0 && <= %d\n",
1555 res->value, RTE_TEST_RX_DESC_MAX);
1558 nb_rxd = res->value;
1559 } else if (!strcmp(res->name, "txd")) {
1560 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1561 printf("txd %d invalid - must be > 0 && <= %d\n",
1562 res->value, RTE_TEST_TX_DESC_MAX);
1565 nb_txd = res->value;
1567 printf("Unknown parameter\n");
1575 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1578 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1579 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1580 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1581 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1582 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1583 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1584 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1585 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1587 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1588 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1590 cmdline_parse_inst_t cmd_config_rx_tx = {
1591 .f = cmd_config_rx_tx_parsed,
1593 .help_str = "port config all rxq|txq|rxd|txd <value>",
1595 (void *)&cmd_config_rx_tx_port,
1596 (void *)&cmd_config_rx_tx_keyword,
1597 (void *)&cmd_config_rx_tx_all,
1598 (void *)&cmd_config_rx_tx_name,
1599 (void *)&cmd_config_rx_tx_value,
1604 /* *** config max packet length *** */
1605 struct cmd_config_max_pkt_len_result {
1606 cmdline_fixed_string_t port;
1607 cmdline_fixed_string_t keyword;
1608 cmdline_fixed_string_t all;
1609 cmdline_fixed_string_t name;
1614 cmd_config_max_pkt_len_parsed(void *parsed_result,
1615 __attribute__((unused)) struct cmdline *cl,
1616 __attribute__((unused)) void *data)
1618 struct cmd_config_max_pkt_len_result *res = parsed_result;
1621 if (!all_ports_stopped()) {
1622 printf("Please stop all ports first\n");
1626 RTE_ETH_FOREACH_DEV(pid) {
1627 struct rte_port *port = &ports[pid];
1628 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1630 if (!strcmp(res->name, "max-pkt-len")) {
1631 if (res->value < ETHER_MIN_LEN) {
1632 printf("max-pkt-len can not be less than %d\n",
1636 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1639 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1640 if (res->value > ETHER_MAX_LEN)
1641 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1643 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1644 port->dev_conf.rxmode.offloads = rx_offloads;
1646 printf("Unknown parameter\n");
1653 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1656 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1657 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1659 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1660 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1662 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1663 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1665 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1668 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1669 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1672 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1673 .f = cmd_config_max_pkt_len_parsed,
1675 .help_str = "port config all max-pkt-len <value>",
1677 (void *)&cmd_config_max_pkt_len_port,
1678 (void *)&cmd_config_max_pkt_len_keyword,
1679 (void *)&cmd_config_max_pkt_len_all,
1680 (void *)&cmd_config_max_pkt_len_name,
1681 (void *)&cmd_config_max_pkt_len_value,
1686 /* *** configure port MTU *** */
1687 struct cmd_config_mtu_result {
1688 cmdline_fixed_string_t port;
1689 cmdline_fixed_string_t keyword;
1690 cmdline_fixed_string_t mtu;
1696 cmd_config_mtu_parsed(void *parsed_result,
1697 __attribute__((unused)) struct cmdline *cl,
1698 __attribute__((unused)) void *data)
1700 struct cmd_config_mtu_result *res = parsed_result;
1702 if (res->value < ETHER_MIN_LEN) {
1703 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1706 port_mtu_set(res->port_id, res->value);
1709 cmdline_parse_token_string_t cmd_config_mtu_port =
1710 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1712 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1713 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1715 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1716 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1718 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1719 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1720 cmdline_parse_token_num_t cmd_config_mtu_value =
1721 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1723 cmdline_parse_inst_t cmd_config_mtu = {
1724 .f = cmd_config_mtu_parsed,
1726 .help_str = "port config mtu <port_id> <value>",
1728 (void *)&cmd_config_mtu_port,
1729 (void *)&cmd_config_mtu_keyword,
1730 (void *)&cmd_config_mtu_mtu,
1731 (void *)&cmd_config_mtu_port_id,
1732 (void *)&cmd_config_mtu_value,
1737 /* *** configure rx mode *** */
1738 struct cmd_config_rx_mode_flag {
1739 cmdline_fixed_string_t port;
1740 cmdline_fixed_string_t keyword;
1741 cmdline_fixed_string_t all;
1742 cmdline_fixed_string_t name;
1743 cmdline_fixed_string_t value;
1747 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1748 __attribute__((unused)) struct cmdline *cl,
1749 __attribute__((unused)) void *data)
1751 struct cmd_config_rx_mode_flag *res = parsed_result;
1754 if (!all_ports_stopped()) {
1755 printf("Please stop all ports first\n");
1759 RTE_ETH_FOREACH_DEV(pid) {
1760 struct rte_port *port;
1761 uint64_t rx_offloads;
1764 rx_offloads = port->dev_conf.rxmode.offloads;
1765 if (!strcmp(res->name, "crc-strip")) {
1766 if (!strcmp(res->value, "on"))
1767 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1768 else if (!strcmp(res->value, "off"))
1769 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1771 printf("Unknown parameter\n");
1774 } else if (!strcmp(res->name, "scatter")) {
1775 if (!strcmp(res->value, "on")) {
1776 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1777 } else if (!strcmp(res->value, "off")) {
1778 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1780 printf("Unknown parameter\n");
1783 } else if (!strcmp(res->name, "rx-cksum")) {
1784 if (!strcmp(res->value, "on"))
1785 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1786 else if (!strcmp(res->value, "off"))
1787 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1789 printf("Unknown parameter\n");
1792 } else if (!strcmp(res->name, "rx-timestamp")) {
1793 if (!strcmp(res->value, "on"))
1794 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1795 else if (!strcmp(res->value, "off"))
1796 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1798 printf("Unknown parameter\n");
1801 } else if (!strcmp(res->name, "hw-vlan")) {
1802 if (!strcmp(res->value, "on")) {
1803 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1804 DEV_RX_OFFLOAD_VLAN_STRIP);
1805 } else if (!strcmp(res->value, "off")) {
1806 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1807 DEV_RX_OFFLOAD_VLAN_STRIP);
1809 printf("Unknown parameter\n");
1812 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1813 if (!strcmp(res->value, "on"))
1814 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1815 else if (!strcmp(res->value, "off"))
1816 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1818 printf("Unknown parameter\n");
1821 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1822 if (!strcmp(res->value, "on"))
1823 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1824 else if (!strcmp(res->value, "off"))
1825 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1827 printf("Unknown parameter\n");
1830 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1831 if (!strcmp(res->value, "on"))
1832 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1833 else if (!strcmp(res->value, "off"))
1834 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1836 printf("Unknown parameter\n");
1839 } else if (!strcmp(res->name, "drop-en")) {
1840 if (!strcmp(res->value, "on"))
1842 else if (!strcmp(res->value, "off"))
1845 printf("Unknown parameter\n");
1849 printf("Unknown parameter\n");
1852 port->dev_conf.rxmode.offloads = rx_offloads;
1857 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1860 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1861 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1862 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1863 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1865 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1866 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1867 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1868 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1869 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1870 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1871 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1872 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1875 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1876 .f = cmd_config_rx_mode_flag_parsed,
1878 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1879 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1881 (void *)&cmd_config_rx_mode_flag_port,
1882 (void *)&cmd_config_rx_mode_flag_keyword,
1883 (void *)&cmd_config_rx_mode_flag_all,
1884 (void *)&cmd_config_rx_mode_flag_name,
1885 (void *)&cmd_config_rx_mode_flag_value,
1890 /* *** configure rss *** */
1891 struct cmd_config_rss {
1892 cmdline_fixed_string_t port;
1893 cmdline_fixed_string_t keyword;
1894 cmdline_fixed_string_t all;
1895 cmdline_fixed_string_t name;
1896 cmdline_fixed_string_t value;
1900 cmd_config_rss_parsed(void *parsed_result,
1901 __attribute__((unused)) struct cmdline *cl,
1902 __attribute__((unused)) void *data)
1904 struct cmd_config_rss *res = parsed_result;
1905 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1909 if (!strcmp(res->value, "all"))
1910 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1911 ETH_RSS_UDP | ETH_RSS_SCTP |
1913 else if (!strcmp(res->value, "ip"))
1914 rss_conf.rss_hf = ETH_RSS_IP;
1915 else if (!strcmp(res->value, "udp"))
1916 rss_conf.rss_hf = ETH_RSS_UDP;
1917 else if (!strcmp(res->value, "tcp"))
1918 rss_conf.rss_hf = ETH_RSS_TCP;
1919 else if (!strcmp(res->value, "sctp"))
1920 rss_conf.rss_hf = ETH_RSS_SCTP;
1921 else if (!strcmp(res->value, "ether"))
1922 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1923 else if (!strcmp(res->value, "port"))
1924 rss_conf.rss_hf = ETH_RSS_PORT;
1925 else if (!strcmp(res->value, "vxlan"))
1926 rss_conf.rss_hf = ETH_RSS_VXLAN;
1927 else if (!strcmp(res->value, "geneve"))
1928 rss_conf.rss_hf = ETH_RSS_GENEVE;
1929 else if (!strcmp(res->value, "nvgre"))
1930 rss_conf.rss_hf = ETH_RSS_NVGRE;
1931 else if (!strcmp(res->value, "none"))
1932 rss_conf.rss_hf = 0;
1933 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1934 atoi(res->value) < 64)
1935 rss_conf.rss_hf = 1ULL << atoi(res->value);
1937 printf("Unknown parameter\n");
1940 rss_conf.rss_key = NULL;
1941 for (i = 0; i < rte_eth_dev_count(); i++) {
1942 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1944 printf("Configuration of RSS hash at ethernet port %d "
1945 "failed with error (%d): %s.\n",
1946 i, -diag, strerror(-diag));
1950 cmdline_parse_token_string_t cmd_config_rss_port =
1951 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1952 cmdline_parse_token_string_t cmd_config_rss_keyword =
1953 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1954 cmdline_parse_token_string_t cmd_config_rss_all =
1955 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1956 cmdline_parse_token_string_t cmd_config_rss_name =
1957 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1958 cmdline_parse_token_string_t cmd_config_rss_value =
1959 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1961 cmdline_parse_inst_t cmd_config_rss = {
1962 .f = cmd_config_rss_parsed,
1964 .help_str = "port config all rss "
1965 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1967 (void *)&cmd_config_rss_port,
1968 (void *)&cmd_config_rss_keyword,
1969 (void *)&cmd_config_rss_all,
1970 (void *)&cmd_config_rss_name,
1971 (void *)&cmd_config_rss_value,
1976 /* *** configure rss hash key *** */
1977 struct cmd_config_rss_hash_key {
1978 cmdline_fixed_string_t port;
1979 cmdline_fixed_string_t config;
1981 cmdline_fixed_string_t rss_hash_key;
1982 cmdline_fixed_string_t rss_type;
1983 cmdline_fixed_string_t key;
1987 hexa_digit_to_value(char hexa_digit)
1989 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1990 return (uint8_t) (hexa_digit - '0');
1991 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1992 return (uint8_t) ((hexa_digit - 'a') + 10);
1993 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1994 return (uint8_t) ((hexa_digit - 'A') + 10);
1995 /* Invalid hexa digit */
2000 parse_and_check_key_hexa_digit(char *key, int idx)
2004 hexa_v = hexa_digit_to_value(key[idx]);
2006 printf("invalid key: character %c at position %d is not a "
2007 "valid hexa digit\n", key[idx], idx);
2012 cmd_config_rss_hash_key_parsed(void *parsed_result,
2013 __attribute__((unused)) struct cmdline *cl,
2014 __attribute__((unused)) void *data)
2016 struct cmd_config_rss_hash_key *res = parsed_result;
2017 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2021 struct rte_eth_dev_info dev_info;
2022 uint8_t hash_key_size;
2025 memset(&dev_info, 0, sizeof(dev_info));
2026 rte_eth_dev_info_get(res->port_id, &dev_info);
2027 if (dev_info.hash_key_size > 0 &&
2028 dev_info.hash_key_size <= sizeof(hash_key))
2029 hash_key_size = dev_info.hash_key_size;
2031 printf("dev_info did not provide a valid hash key size\n");
2034 /* Check the length of the RSS hash key */
2035 key_len = strlen(res->key);
2036 if (key_len != (hash_key_size * 2)) {
2037 printf("key length: %d invalid - key must be a string of %d"
2038 " hexa-decimal numbers\n",
2039 (int) key_len, hash_key_size * 2);
2042 /* Translate RSS hash key into binary representation */
2043 for (i = 0; i < hash_key_size; i++) {
2044 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2047 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2050 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2052 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2056 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2058 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2059 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2061 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2062 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2063 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2065 rss_hash_key, "rss-hash-key");
2066 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2068 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2069 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2070 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2071 "ipv6-tcp-ex#ipv6-udp-ex");
2072 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2073 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2075 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2076 .f = cmd_config_rss_hash_key_parsed,
2078 .help_str = "port config <port_id> rss-hash-key "
2079 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2080 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2081 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2082 "<string of hex digits (variable length, NIC dependent)>",
2084 (void *)&cmd_config_rss_hash_key_port,
2085 (void *)&cmd_config_rss_hash_key_config,
2086 (void *)&cmd_config_rss_hash_key_port_id,
2087 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2088 (void *)&cmd_config_rss_hash_key_rss_type,
2089 (void *)&cmd_config_rss_hash_key_value,
2094 /* *** configure port rxq/txq start/stop *** */
2095 struct cmd_config_rxtx_queue {
2096 cmdline_fixed_string_t port;
2098 cmdline_fixed_string_t rxtxq;
2100 cmdline_fixed_string_t opname;
2104 cmd_config_rxtx_queue_parsed(void *parsed_result,
2105 __attribute__((unused)) struct cmdline *cl,
2106 __attribute__((unused)) void *data)
2108 struct cmd_config_rxtx_queue *res = parsed_result;
2113 if (test_done == 0) {
2114 printf("Please stop forwarding first\n");
2118 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2121 if (port_is_started(res->portid) != 1) {
2122 printf("Please start port %u first\n", res->portid);
2126 if (!strcmp(res->rxtxq, "rxq"))
2128 else if (!strcmp(res->rxtxq, "txq"))
2131 printf("Unknown parameter\n");
2135 if (isrx && rx_queue_id_is_invalid(res->qid))
2137 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2140 if (!strcmp(res->opname, "start"))
2142 else if (!strcmp(res->opname, "stop"))
2145 printf("Unknown parameter\n");
2149 if (isstart && isrx)
2150 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2151 else if (!isstart && isrx)
2152 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2153 else if (isstart && !isrx)
2154 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2156 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2158 if (ret == -ENOTSUP)
2159 printf("Function not supported in PMD driver\n");
2162 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2163 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2164 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2165 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2166 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2167 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2168 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2169 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2170 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2171 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2174 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2175 .f = cmd_config_rxtx_queue_parsed,
2177 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2179 (void *)&cmd_config_speed_all_port,
2180 (void *)&cmd_config_rxtx_queue_portid,
2181 (void *)&cmd_config_rxtx_queue_rxtxq,
2182 (void *)&cmd_config_rxtx_queue_qid,
2183 (void *)&cmd_config_rxtx_queue_opname,
2188 /* *** Configure RSS RETA *** */
2189 struct cmd_config_rss_reta {
2190 cmdline_fixed_string_t port;
2191 cmdline_fixed_string_t keyword;
2193 cmdline_fixed_string_t name;
2194 cmdline_fixed_string_t list_name;
2195 cmdline_fixed_string_t list_of_items;
2199 parse_reta_config(const char *str,
2200 struct rte_eth_rss_reta_entry64 *reta_conf,
2201 uint16_t nb_entries)
2205 uint16_t hash_index, idx, shift;
2208 const char *p, *p0 = str;
2215 unsigned long int_fld[_NUM_FLD];
2216 char *str_fld[_NUM_FLD];
2218 while ((p = strchr(p0,'(')) != NULL) {
2220 if((p0 = strchr(p,')')) == NULL)
2224 if(size >= sizeof(s))
2227 snprintf(s, sizeof(s), "%.*s", size, p);
2228 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2230 for (i = 0; i < _NUM_FLD; i++) {
2232 int_fld[i] = strtoul(str_fld[i], &end, 0);
2233 if (errno != 0 || end == str_fld[i] ||
2238 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2239 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2241 if (hash_index >= nb_entries) {
2242 printf("Invalid RETA hash index=%d\n", hash_index);
2246 idx = hash_index / RTE_RETA_GROUP_SIZE;
2247 shift = hash_index % RTE_RETA_GROUP_SIZE;
2248 reta_conf[idx].mask |= (1ULL << shift);
2249 reta_conf[idx].reta[shift] = nb_queue;
2256 cmd_set_rss_reta_parsed(void *parsed_result,
2257 __attribute__((unused)) struct cmdline *cl,
2258 __attribute__((unused)) void *data)
2261 struct rte_eth_dev_info dev_info;
2262 struct rte_eth_rss_reta_entry64 reta_conf[8];
2263 struct cmd_config_rss_reta *res = parsed_result;
2265 memset(&dev_info, 0, sizeof(dev_info));
2266 rte_eth_dev_info_get(res->port_id, &dev_info);
2267 if (dev_info.reta_size == 0) {
2268 printf("Redirection table size is 0 which is "
2269 "invalid for RSS\n");
2272 printf("The reta size of port %d is %u\n",
2273 res->port_id, dev_info.reta_size);
2274 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2275 printf("Currently do not support more than %u entries of "
2276 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2280 memset(reta_conf, 0, sizeof(reta_conf));
2281 if (!strcmp(res->list_name, "reta")) {
2282 if (parse_reta_config(res->list_of_items, reta_conf,
2283 dev_info.reta_size)) {
2284 printf("Invalid RSS Redirection Table "
2285 "config entered\n");
2288 ret = rte_eth_dev_rss_reta_update(res->port_id,
2289 reta_conf, dev_info.reta_size);
2291 printf("Bad redirection table parameter, "
2292 "return code = %d \n", ret);
2296 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2297 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2298 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2299 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2300 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2301 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2302 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2303 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2304 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2305 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2306 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2307 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2309 cmdline_parse_inst_t cmd_config_rss_reta = {
2310 .f = cmd_set_rss_reta_parsed,
2312 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2314 (void *)&cmd_config_rss_reta_port,
2315 (void *)&cmd_config_rss_reta_keyword,
2316 (void *)&cmd_config_rss_reta_port_id,
2317 (void *)&cmd_config_rss_reta_name,
2318 (void *)&cmd_config_rss_reta_list_name,
2319 (void *)&cmd_config_rss_reta_list_of_items,
2324 /* *** SHOW PORT RETA INFO *** */
2325 struct cmd_showport_reta {
2326 cmdline_fixed_string_t show;
2327 cmdline_fixed_string_t port;
2329 cmdline_fixed_string_t rss;
2330 cmdline_fixed_string_t reta;
2332 cmdline_fixed_string_t list_of_items;
2336 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2337 uint16_t nb_entries,
2341 const char *p, *p0 = str;
2346 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2347 RTE_RETA_GROUP_SIZE;
2350 p = strchr(p0, '(');
2354 p0 = strchr(p, ')');
2358 if (size >= sizeof(s)) {
2359 printf("The string size exceeds the internal buffer size\n");
2362 snprintf(s, sizeof(s), "%.*s", size, p);
2363 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2364 if (ret <= 0 || ret != num) {
2365 printf("The bits of masks do not match the number of "
2366 "reta entries: %u\n", num);
2369 for (i = 0; i < ret; i++)
2370 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2376 cmd_showport_reta_parsed(void *parsed_result,
2377 __attribute__((unused)) struct cmdline *cl,
2378 __attribute__((unused)) void *data)
2380 struct cmd_showport_reta *res = parsed_result;
2381 struct rte_eth_rss_reta_entry64 reta_conf[8];
2382 struct rte_eth_dev_info dev_info;
2383 uint16_t max_reta_size;
2385 memset(&dev_info, 0, sizeof(dev_info));
2386 rte_eth_dev_info_get(res->port_id, &dev_info);
2387 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2388 if (res->size == 0 || res->size > max_reta_size) {
2389 printf("Invalid redirection table size: %u (1-%u)\n",
2390 res->size, max_reta_size);
2394 memset(reta_conf, 0, sizeof(reta_conf));
2395 if (showport_parse_reta_config(reta_conf, res->size,
2396 res->list_of_items) < 0) {
2397 printf("Invalid string: %s for reta masks\n",
2398 res->list_of_items);
2401 port_rss_reta_info(res->port_id, reta_conf, res->size);
2404 cmdline_parse_token_string_t cmd_showport_reta_show =
2405 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2406 cmdline_parse_token_string_t cmd_showport_reta_port =
2407 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2408 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2409 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2410 cmdline_parse_token_string_t cmd_showport_reta_rss =
2411 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2412 cmdline_parse_token_string_t cmd_showport_reta_reta =
2413 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2414 cmdline_parse_token_num_t cmd_showport_reta_size =
2415 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2416 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2417 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2418 list_of_items, NULL);
2420 cmdline_parse_inst_t cmd_showport_reta = {
2421 .f = cmd_showport_reta_parsed,
2423 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2425 (void *)&cmd_showport_reta_show,
2426 (void *)&cmd_showport_reta_port,
2427 (void *)&cmd_showport_reta_port_id,
2428 (void *)&cmd_showport_reta_rss,
2429 (void *)&cmd_showport_reta_reta,
2430 (void *)&cmd_showport_reta_size,
2431 (void *)&cmd_showport_reta_list_of_items,
2436 /* *** Show RSS hash configuration *** */
2437 struct cmd_showport_rss_hash {
2438 cmdline_fixed_string_t show;
2439 cmdline_fixed_string_t port;
2441 cmdline_fixed_string_t rss_hash;
2442 cmdline_fixed_string_t rss_type;
2443 cmdline_fixed_string_t key; /* optional argument */
2446 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2447 __attribute__((unused)) struct cmdline *cl,
2450 struct cmd_showport_rss_hash *res = parsed_result;
2452 port_rss_hash_conf_show(res->port_id, res->rss_type,
2453 show_rss_key != NULL);
2456 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2457 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2458 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2459 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2460 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2461 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2462 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2463 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2465 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2466 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2467 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2468 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2469 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2470 "ipv6-tcp-ex#ipv6-udp-ex");
2471 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2472 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2474 cmdline_parse_inst_t cmd_showport_rss_hash = {
2475 .f = cmd_showport_rss_hash_parsed,
2477 .help_str = "show port <port_id> rss-hash "
2478 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2479 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2480 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2482 (void *)&cmd_showport_rss_hash_show,
2483 (void *)&cmd_showport_rss_hash_port,
2484 (void *)&cmd_showport_rss_hash_port_id,
2485 (void *)&cmd_showport_rss_hash_rss_hash,
2486 (void *)&cmd_showport_rss_hash_rss_hash_info,
2491 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2492 .f = cmd_showport_rss_hash_parsed,
2494 .help_str = "show port <port_id> rss-hash "
2495 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2496 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2497 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2499 (void *)&cmd_showport_rss_hash_show,
2500 (void *)&cmd_showport_rss_hash_port,
2501 (void *)&cmd_showport_rss_hash_port_id,
2502 (void *)&cmd_showport_rss_hash_rss_hash,
2503 (void *)&cmd_showport_rss_hash_rss_hash_info,
2504 (void *)&cmd_showport_rss_hash_rss_key,
2509 /* *** Configure DCB *** */
2510 struct cmd_config_dcb {
2511 cmdline_fixed_string_t port;
2512 cmdline_fixed_string_t config;
2514 cmdline_fixed_string_t dcb;
2515 cmdline_fixed_string_t vt;
2516 cmdline_fixed_string_t vt_en;
2518 cmdline_fixed_string_t pfc;
2519 cmdline_fixed_string_t pfc_en;
2523 cmd_config_dcb_parsed(void *parsed_result,
2524 __attribute__((unused)) struct cmdline *cl,
2525 __attribute__((unused)) void *data)
2527 struct cmd_config_dcb *res = parsed_result;
2528 portid_t port_id = res->port_id;
2529 struct rte_port *port;
2533 port = &ports[port_id];
2534 /** Check if the port is not started **/
2535 if (port->port_status != RTE_PORT_STOPPED) {
2536 printf("Please stop port %d first\n", port_id);
2540 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2541 printf("The invalid number of traffic class,"
2542 " only 4 or 8 allowed.\n");
2546 if (nb_fwd_lcores < res->num_tcs) {
2547 printf("nb_cores shouldn't be less than number of TCs.\n");
2550 if (!strncmp(res->pfc_en, "on", 2))
2555 /* DCB in VT mode */
2556 if (!strncmp(res->vt_en, "on", 2))
2557 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2558 (enum rte_eth_nb_tcs)res->num_tcs,
2561 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2562 (enum rte_eth_nb_tcs)res->num_tcs,
2567 printf("Cannot initialize network ports.\n");
2571 cmd_reconfig_device_queue(port_id, 1, 1);
2574 cmdline_parse_token_string_t cmd_config_dcb_port =
2575 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2576 cmdline_parse_token_string_t cmd_config_dcb_config =
2577 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2578 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2579 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2580 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2581 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2582 cmdline_parse_token_string_t cmd_config_dcb_vt =
2583 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2584 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2585 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2586 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2587 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2588 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2589 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2590 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2591 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2593 cmdline_parse_inst_t cmd_config_dcb = {
2594 .f = cmd_config_dcb_parsed,
2596 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2598 (void *)&cmd_config_dcb_port,
2599 (void *)&cmd_config_dcb_config,
2600 (void *)&cmd_config_dcb_port_id,
2601 (void *)&cmd_config_dcb_dcb,
2602 (void *)&cmd_config_dcb_vt,
2603 (void *)&cmd_config_dcb_vt_en,
2604 (void *)&cmd_config_dcb_num_tcs,
2605 (void *)&cmd_config_dcb_pfc,
2606 (void *)&cmd_config_dcb_pfc_en,
2611 /* *** configure number of packets per burst *** */
2612 struct cmd_config_burst {
2613 cmdline_fixed_string_t port;
2614 cmdline_fixed_string_t keyword;
2615 cmdline_fixed_string_t all;
2616 cmdline_fixed_string_t name;
2621 cmd_config_burst_parsed(void *parsed_result,
2622 __attribute__((unused)) struct cmdline *cl,
2623 __attribute__((unused)) void *data)
2625 struct cmd_config_burst *res = parsed_result;
2627 if (!all_ports_stopped()) {
2628 printf("Please stop all ports first\n");
2632 if (!strcmp(res->name, "burst")) {
2633 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2634 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2637 nb_pkt_per_burst = res->value;
2639 printf("Unknown parameter\n");
2645 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2648 cmdline_parse_token_string_t cmd_config_burst_port =
2649 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2650 cmdline_parse_token_string_t cmd_config_burst_keyword =
2651 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2652 cmdline_parse_token_string_t cmd_config_burst_all =
2653 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2654 cmdline_parse_token_string_t cmd_config_burst_name =
2655 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2656 cmdline_parse_token_num_t cmd_config_burst_value =
2657 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2659 cmdline_parse_inst_t cmd_config_burst = {
2660 .f = cmd_config_burst_parsed,
2662 .help_str = "port config all burst <value>",
2664 (void *)&cmd_config_burst_port,
2665 (void *)&cmd_config_burst_keyword,
2666 (void *)&cmd_config_burst_all,
2667 (void *)&cmd_config_burst_name,
2668 (void *)&cmd_config_burst_value,
2673 /* *** configure rx/tx queues *** */
2674 struct cmd_config_thresh {
2675 cmdline_fixed_string_t port;
2676 cmdline_fixed_string_t keyword;
2677 cmdline_fixed_string_t all;
2678 cmdline_fixed_string_t name;
2683 cmd_config_thresh_parsed(void *parsed_result,
2684 __attribute__((unused)) struct cmdline *cl,
2685 __attribute__((unused)) void *data)
2687 struct cmd_config_thresh *res = parsed_result;
2689 if (!all_ports_stopped()) {
2690 printf("Please stop all ports first\n");
2694 if (!strcmp(res->name, "txpt"))
2695 tx_pthresh = res->value;
2696 else if(!strcmp(res->name, "txht"))
2697 tx_hthresh = res->value;
2698 else if(!strcmp(res->name, "txwt"))
2699 tx_wthresh = res->value;
2700 else if(!strcmp(res->name, "rxpt"))
2701 rx_pthresh = res->value;
2702 else if(!strcmp(res->name, "rxht"))
2703 rx_hthresh = res->value;
2704 else if(!strcmp(res->name, "rxwt"))
2705 rx_wthresh = res->value;
2707 printf("Unknown parameter\n");
2713 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2716 cmdline_parse_token_string_t cmd_config_thresh_port =
2717 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2718 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2719 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2720 cmdline_parse_token_string_t cmd_config_thresh_all =
2721 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2722 cmdline_parse_token_string_t cmd_config_thresh_name =
2723 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2724 "txpt#txht#txwt#rxpt#rxht#rxwt");
2725 cmdline_parse_token_num_t cmd_config_thresh_value =
2726 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2728 cmdline_parse_inst_t cmd_config_thresh = {
2729 .f = cmd_config_thresh_parsed,
2731 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2733 (void *)&cmd_config_thresh_port,
2734 (void *)&cmd_config_thresh_keyword,
2735 (void *)&cmd_config_thresh_all,
2736 (void *)&cmd_config_thresh_name,
2737 (void *)&cmd_config_thresh_value,
2742 /* *** configure free/rs threshold *** */
2743 struct cmd_config_threshold {
2744 cmdline_fixed_string_t port;
2745 cmdline_fixed_string_t keyword;
2746 cmdline_fixed_string_t all;
2747 cmdline_fixed_string_t name;
2752 cmd_config_threshold_parsed(void *parsed_result,
2753 __attribute__((unused)) struct cmdline *cl,
2754 __attribute__((unused)) void *data)
2756 struct cmd_config_threshold *res = parsed_result;
2758 if (!all_ports_stopped()) {
2759 printf("Please stop all ports first\n");
2763 if (!strcmp(res->name, "txfreet"))
2764 tx_free_thresh = res->value;
2765 else if (!strcmp(res->name, "txrst"))
2766 tx_rs_thresh = res->value;
2767 else if (!strcmp(res->name, "rxfreet"))
2768 rx_free_thresh = res->value;
2770 printf("Unknown parameter\n");
2776 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2779 cmdline_parse_token_string_t cmd_config_threshold_port =
2780 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2781 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2782 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2784 cmdline_parse_token_string_t cmd_config_threshold_all =
2785 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2786 cmdline_parse_token_string_t cmd_config_threshold_name =
2787 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2788 "txfreet#txrst#rxfreet");
2789 cmdline_parse_token_num_t cmd_config_threshold_value =
2790 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2792 cmdline_parse_inst_t cmd_config_threshold = {
2793 .f = cmd_config_threshold_parsed,
2795 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2797 (void *)&cmd_config_threshold_port,
2798 (void *)&cmd_config_threshold_keyword,
2799 (void *)&cmd_config_threshold_all,
2800 (void *)&cmd_config_threshold_name,
2801 (void *)&cmd_config_threshold_value,
2807 struct cmd_stop_result {
2808 cmdline_fixed_string_t stop;
2811 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2812 __attribute__((unused)) struct cmdline *cl,
2813 __attribute__((unused)) void *data)
2815 stop_packet_forwarding();
2818 cmdline_parse_token_string_t cmd_stop_stop =
2819 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2821 cmdline_parse_inst_t cmd_stop = {
2822 .f = cmd_stop_parsed,
2824 .help_str = "stop: Stop packet forwarding",
2826 (void *)&cmd_stop_stop,
2831 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2834 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2835 unsigned int *parsed_items, int check_unique_values)
2837 unsigned int nb_item;
2845 * First parse all items in the list and store their value.
2850 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2852 if ((c >= '0') && (c <= '9')) {
2853 value = (unsigned int) (value * 10 + (c - '0'));
2858 printf("character %c is not a decimal digit\n", c);
2862 printf("No valid value before comma\n");
2865 if (nb_item < max_items) {
2866 parsed_items[nb_item] = value;
2872 if (nb_item >= max_items) {
2873 printf("Number of %s = %u > %u (maximum items)\n",
2874 item_name, nb_item + 1, max_items);
2877 parsed_items[nb_item++] = value;
2878 if (! check_unique_values)
2882 * Then, check that all values in the list are differents.
2883 * No optimization here...
2885 for (i = 0; i < nb_item; i++) {
2886 for (j = i + 1; j < nb_item; j++) {
2887 if (parsed_items[j] == parsed_items[i]) {
2888 printf("duplicated %s %u at index %u and %u\n",
2889 item_name, parsed_items[i], i, j);
2897 struct cmd_set_list_result {
2898 cmdline_fixed_string_t cmd_keyword;
2899 cmdline_fixed_string_t list_name;
2900 cmdline_fixed_string_t list_of_items;
2903 static void cmd_set_list_parsed(void *parsed_result,
2904 __attribute__((unused)) struct cmdline *cl,
2905 __attribute__((unused)) void *data)
2907 struct cmd_set_list_result *res;
2909 unsigned int lcorelist[RTE_MAX_LCORE];
2910 unsigned int portlist[RTE_MAX_ETHPORTS];
2912 unsigned int nb_item;
2914 if (test_done == 0) {
2915 printf("Please stop forwarding first\n");
2919 res = parsed_result;
2920 if (!strcmp(res->list_name, "corelist")) {
2921 nb_item = parse_item_list(res->list_of_items, "core",
2923 parsed_items.lcorelist, 1);
2925 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2930 if (!strcmp(res->list_name, "portlist")) {
2931 nb_item = parse_item_list(res->list_of_items, "port",
2933 parsed_items.portlist, 1);
2935 set_fwd_ports_list(parsed_items.portlist, nb_item);
2941 cmdline_parse_token_string_t cmd_set_list_keyword =
2942 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2944 cmdline_parse_token_string_t cmd_set_list_name =
2945 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2946 "corelist#portlist");
2947 cmdline_parse_token_string_t cmd_set_list_of_items =
2948 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2951 cmdline_parse_inst_t cmd_set_fwd_list = {
2952 .f = cmd_set_list_parsed,
2954 .help_str = "set corelist|portlist <list0[,list1]*>",
2956 (void *)&cmd_set_list_keyword,
2957 (void *)&cmd_set_list_name,
2958 (void *)&cmd_set_list_of_items,
2963 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2965 struct cmd_setmask_result {
2966 cmdline_fixed_string_t set;
2967 cmdline_fixed_string_t mask;
2971 static void cmd_set_mask_parsed(void *parsed_result,
2972 __attribute__((unused)) struct cmdline *cl,
2973 __attribute__((unused)) void *data)
2975 struct cmd_setmask_result *res = parsed_result;
2977 if (test_done == 0) {
2978 printf("Please stop forwarding first\n");
2981 if (!strcmp(res->mask, "coremask")) {
2982 set_fwd_lcores_mask(res->hexavalue);
2984 } else if (!strcmp(res->mask, "portmask")) {
2985 set_fwd_ports_mask(res->hexavalue);
2990 cmdline_parse_token_string_t cmd_setmask_set =
2991 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2992 cmdline_parse_token_string_t cmd_setmask_mask =
2993 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2994 "coremask#portmask");
2995 cmdline_parse_token_num_t cmd_setmask_value =
2996 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2998 cmdline_parse_inst_t cmd_set_fwd_mask = {
2999 .f = cmd_set_mask_parsed,
3001 .help_str = "set coremask|portmask <hexadecimal value>",
3003 (void *)&cmd_setmask_set,
3004 (void *)&cmd_setmask_mask,
3005 (void *)&cmd_setmask_value,
3011 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3013 struct cmd_set_result {
3014 cmdline_fixed_string_t set;
3015 cmdline_fixed_string_t what;
3019 static void cmd_set_parsed(void *parsed_result,
3020 __attribute__((unused)) struct cmdline *cl,
3021 __attribute__((unused)) void *data)
3023 struct cmd_set_result *res = parsed_result;
3024 if (!strcmp(res->what, "nbport")) {
3025 set_fwd_ports_number(res->value);
3027 } else if (!strcmp(res->what, "nbcore")) {
3028 set_fwd_lcores_number(res->value);
3030 } else if (!strcmp(res->what, "burst"))
3031 set_nb_pkt_per_burst(res->value);
3032 else if (!strcmp(res->what, "verbose"))
3033 set_verbose_level(res->value);
3036 cmdline_parse_token_string_t cmd_set_set =
3037 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3038 cmdline_parse_token_string_t cmd_set_what =
3039 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3040 "nbport#nbcore#burst#verbose");
3041 cmdline_parse_token_num_t cmd_set_value =
3042 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3044 cmdline_parse_inst_t cmd_set_numbers = {
3045 .f = cmd_set_parsed,
3047 .help_str = "set nbport|nbcore|burst|verbose <value>",
3049 (void *)&cmd_set_set,
3050 (void *)&cmd_set_what,
3051 (void *)&cmd_set_value,
3056 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3058 struct cmd_set_txpkts_result {
3059 cmdline_fixed_string_t cmd_keyword;
3060 cmdline_fixed_string_t txpkts;
3061 cmdline_fixed_string_t seg_lengths;
3065 cmd_set_txpkts_parsed(void *parsed_result,
3066 __attribute__((unused)) struct cmdline *cl,
3067 __attribute__((unused)) void *data)
3069 struct cmd_set_txpkts_result *res;
3070 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3071 unsigned int nb_segs;
3073 res = parsed_result;
3074 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3075 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3077 set_tx_pkt_segments(seg_lengths, nb_segs);
3080 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3081 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3082 cmd_keyword, "set");
3083 cmdline_parse_token_string_t cmd_set_txpkts_name =
3084 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3086 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3087 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3090 cmdline_parse_inst_t cmd_set_txpkts = {
3091 .f = cmd_set_txpkts_parsed,
3093 .help_str = "set txpkts <len0[,len1]*>",
3095 (void *)&cmd_set_txpkts_keyword,
3096 (void *)&cmd_set_txpkts_name,
3097 (void *)&cmd_set_txpkts_lengths,
3102 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3104 struct cmd_set_txsplit_result {
3105 cmdline_fixed_string_t cmd_keyword;
3106 cmdline_fixed_string_t txsplit;
3107 cmdline_fixed_string_t mode;
3111 cmd_set_txsplit_parsed(void *parsed_result,
3112 __attribute__((unused)) struct cmdline *cl,
3113 __attribute__((unused)) void *data)
3115 struct cmd_set_txsplit_result *res;
3117 res = parsed_result;
3118 set_tx_pkt_split(res->mode);
3121 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3122 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3123 cmd_keyword, "set");
3124 cmdline_parse_token_string_t cmd_set_txsplit_name =
3125 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3126 txsplit, "txsplit");
3127 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3128 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3131 cmdline_parse_inst_t cmd_set_txsplit = {
3132 .f = cmd_set_txsplit_parsed,
3134 .help_str = "set txsplit on|off|rand",
3136 (void *)&cmd_set_txsplit_keyword,
3137 (void *)&cmd_set_txsplit_name,
3138 (void *)&cmd_set_txsplit_mode,
3143 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3144 struct cmd_rx_vlan_filter_all_result {
3145 cmdline_fixed_string_t rx_vlan;
3146 cmdline_fixed_string_t what;
3147 cmdline_fixed_string_t all;
3152 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3153 __attribute__((unused)) struct cmdline *cl,
3154 __attribute__((unused)) void *data)
3156 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3158 if (!strcmp(res->what, "add"))
3159 rx_vlan_all_filter_set(res->port_id, 1);
3161 rx_vlan_all_filter_set(res->port_id, 0);
3164 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3165 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3166 rx_vlan, "rx_vlan");
3167 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3168 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3170 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3171 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3173 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3174 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3177 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3178 .f = cmd_rx_vlan_filter_all_parsed,
3180 .help_str = "rx_vlan add|rm all <port_id>: "
3181 "Add/Remove all identifiers to/from the set of VLAN "
3182 "identifiers filtered by a port",
3184 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3185 (void *)&cmd_rx_vlan_filter_all_what,
3186 (void *)&cmd_rx_vlan_filter_all_all,
3187 (void *)&cmd_rx_vlan_filter_all_portid,
3192 /* *** VLAN OFFLOAD SET ON A PORT *** */
3193 struct cmd_vlan_offload_result {
3194 cmdline_fixed_string_t vlan;
3195 cmdline_fixed_string_t set;
3196 cmdline_fixed_string_t vlan_type;
3197 cmdline_fixed_string_t what;
3198 cmdline_fixed_string_t on;
3199 cmdline_fixed_string_t port_id;
3203 cmd_vlan_offload_parsed(void *parsed_result,
3204 __attribute__((unused)) struct cmdline *cl,
3205 __attribute__((unused)) void *data)
3208 struct cmd_vlan_offload_result *res = parsed_result;
3211 portid_t port_id = 0;
3215 len = strnlen(str, STR_TOKEN_SIZE);
3217 /* Get port_id first */
3225 tmp = strtoul(str, NULL, 0);
3226 /* If port_id greater that what portid_t can represent, return */
3227 if(tmp >= RTE_MAX_ETHPORTS)
3229 port_id = (portid_t)tmp;
3231 if (!strcmp(res->on, "on"))
3236 if (!strcmp(res->what, "strip"))
3237 rx_vlan_strip_set(port_id, on);
3238 else if(!strcmp(res->what, "stripq")){
3239 uint16_t queue_id = 0;
3241 /* No queue_id, return */
3243 printf("must specify (port,queue_id)\n");
3246 tmp = strtoul(str + i + 1, NULL, 0);
3247 /* If queue_id greater that what 16-bits can represent, return */
3251 queue_id = (uint16_t)tmp;
3252 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3254 else if (!strcmp(res->what, "filter"))
3255 rx_vlan_filter_set(port_id, on);
3257 vlan_extend_set(port_id, on);
3262 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3263 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3265 cmdline_parse_token_string_t cmd_vlan_offload_set =
3266 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3268 cmdline_parse_token_string_t cmd_vlan_offload_what =
3269 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3270 what, "strip#filter#qinq#stripq");
3271 cmdline_parse_token_string_t cmd_vlan_offload_on =
3272 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3274 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3275 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3278 cmdline_parse_inst_t cmd_vlan_offload = {
3279 .f = cmd_vlan_offload_parsed,
3281 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3282 "<port_id[,queue_id]>: "
3283 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3285 (void *)&cmd_vlan_offload_vlan,
3286 (void *)&cmd_vlan_offload_set,
3287 (void *)&cmd_vlan_offload_what,
3288 (void *)&cmd_vlan_offload_on,
3289 (void *)&cmd_vlan_offload_portid,
3294 /* *** VLAN TPID SET ON A PORT *** */
3295 struct cmd_vlan_tpid_result {
3296 cmdline_fixed_string_t vlan;
3297 cmdline_fixed_string_t set;
3298 cmdline_fixed_string_t vlan_type;
3299 cmdline_fixed_string_t what;
3305 cmd_vlan_tpid_parsed(void *parsed_result,
3306 __attribute__((unused)) struct cmdline *cl,
3307 __attribute__((unused)) void *data)
3309 struct cmd_vlan_tpid_result *res = parsed_result;
3310 enum rte_vlan_type vlan_type;
3312 if (!strcmp(res->vlan_type, "inner"))
3313 vlan_type = ETH_VLAN_TYPE_INNER;
3314 else if (!strcmp(res->vlan_type, "outer"))
3315 vlan_type = ETH_VLAN_TYPE_OUTER;
3317 printf("Unknown vlan type\n");
3320 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3323 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3324 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3326 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3327 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3329 cmdline_parse_token_string_t cmd_vlan_type =
3330 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3331 vlan_type, "inner#outer");
3332 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3333 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3335 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3336 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3338 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3339 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3342 cmdline_parse_inst_t cmd_vlan_tpid = {
3343 .f = cmd_vlan_tpid_parsed,
3345 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3346 "Set the VLAN Ether type",
3348 (void *)&cmd_vlan_tpid_vlan,
3349 (void *)&cmd_vlan_tpid_set,
3350 (void *)&cmd_vlan_type,
3351 (void *)&cmd_vlan_tpid_what,
3352 (void *)&cmd_vlan_tpid_tpid,
3353 (void *)&cmd_vlan_tpid_portid,
3358 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3359 struct cmd_rx_vlan_filter_result {
3360 cmdline_fixed_string_t rx_vlan;
3361 cmdline_fixed_string_t what;
3367 cmd_rx_vlan_filter_parsed(void *parsed_result,
3368 __attribute__((unused)) struct cmdline *cl,
3369 __attribute__((unused)) void *data)
3371 struct cmd_rx_vlan_filter_result *res = parsed_result;
3373 if (!strcmp(res->what, "add"))
3374 rx_vft_set(res->port_id, res->vlan_id, 1);
3376 rx_vft_set(res->port_id, res->vlan_id, 0);
3379 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3380 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3381 rx_vlan, "rx_vlan");
3382 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3383 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3385 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3386 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3388 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3389 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3392 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3393 .f = cmd_rx_vlan_filter_parsed,
3395 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3396 "Add/Remove a VLAN identifier to/from the set of VLAN "
3397 "identifiers filtered by a port",
3399 (void *)&cmd_rx_vlan_filter_rx_vlan,
3400 (void *)&cmd_rx_vlan_filter_what,
3401 (void *)&cmd_rx_vlan_filter_vlanid,
3402 (void *)&cmd_rx_vlan_filter_portid,
3407 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3408 struct cmd_tx_vlan_set_result {
3409 cmdline_fixed_string_t tx_vlan;
3410 cmdline_fixed_string_t set;
3416 cmd_tx_vlan_set_parsed(void *parsed_result,
3417 __attribute__((unused)) struct cmdline *cl,
3418 __attribute__((unused)) void *data)
3420 struct cmd_tx_vlan_set_result *res = parsed_result;
3422 if (!port_is_stopped(res->port_id)) {
3423 printf("Please stop port %d first\n", res->port_id);
3427 tx_vlan_set(res->port_id, res->vlan_id);
3429 cmd_reconfig_device_queue(res->port_id, 1, 1);
3432 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3433 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3434 tx_vlan, "tx_vlan");
3435 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3436 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3438 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3439 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3441 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3442 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3445 cmdline_parse_inst_t cmd_tx_vlan_set = {
3446 .f = cmd_tx_vlan_set_parsed,
3448 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3449 "Enable hardware insertion of a single VLAN header "
3450 "with a given TAG Identifier in packets sent on a port",
3452 (void *)&cmd_tx_vlan_set_tx_vlan,
3453 (void *)&cmd_tx_vlan_set_set,
3454 (void *)&cmd_tx_vlan_set_portid,
3455 (void *)&cmd_tx_vlan_set_vlanid,
3460 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3461 struct cmd_tx_vlan_set_qinq_result {
3462 cmdline_fixed_string_t tx_vlan;
3463 cmdline_fixed_string_t set;
3466 uint16_t vlan_id_outer;
3470 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3471 __attribute__((unused)) struct cmdline *cl,
3472 __attribute__((unused)) void *data)
3474 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3476 if (!port_is_stopped(res->port_id)) {
3477 printf("Please stop port %d first\n", res->port_id);
3481 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3483 cmd_reconfig_device_queue(res->port_id, 1, 1);
3486 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3487 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3488 tx_vlan, "tx_vlan");
3489 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3490 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3492 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3493 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3495 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3496 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3498 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3499 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3500 vlan_id_outer, UINT16);
3502 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3503 .f = cmd_tx_vlan_set_qinq_parsed,
3505 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3506 "Enable hardware insertion of double VLAN header "
3507 "with given TAG Identifiers in packets sent on a port",
3509 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3510 (void *)&cmd_tx_vlan_set_qinq_set,
3511 (void *)&cmd_tx_vlan_set_qinq_portid,
3512 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3513 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3518 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3519 struct cmd_tx_vlan_set_pvid_result {
3520 cmdline_fixed_string_t tx_vlan;
3521 cmdline_fixed_string_t set;
3522 cmdline_fixed_string_t pvid;
3525 cmdline_fixed_string_t mode;
3529 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3530 __attribute__((unused)) struct cmdline *cl,
3531 __attribute__((unused)) void *data)
3533 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3535 if (strcmp(res->mode, "on") == 0)
3536 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3538 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3541 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3542 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3543 tx_vlan, "tx_vlan");
3544 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3545 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3547 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3548 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3550 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3551 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3553 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3554 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3556 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3557 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3560 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3561 .f = cmd_tx_vlan_set_pvid_parsed,
3563 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3565 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3566 (void *)&cmd_tx_vlan_set_pvid_set,
3567 (void *)&cmd_tx_vlan_set_pvid_pvid,
3568 (void *)&cmd_tx_vlan_set_pvid_port_id,
3569 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3570 (void *)&cmd_tx_vlan_set_pvid_mode,
3575 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3576 struct cmd_tx_vlan_reset_result {
3577 cmdline_fixed_string_t tx_vlan;
3578 cmdline_fixed_string_t reset;
3583 cmd_tx_vlan_reset_parsed(void *parsed_result,
3584 __attribute__((unused)) struct cmdline *cl,
3585 __attribute__((unused)) void *data)
3587 struct cmd_tx_vlan_reset_result *res = parsed_result;
3589 if (!port_is_stopped(res->port_id)) {
3590 printf("Please stop port %d first\n", res->port_id);
3594 tx_vlan_reset(res->port_id);
3596 cmd_reconfig_device_queue(res->port_id, 1, 1);
3599 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3600 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3601 tx_vlan, "tx_vlan");
3602 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3603 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3605 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3606 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3609 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3610 .f = cmd_tx_vlan_reset_parsed,
3612 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3613 "VLAN header in packets sent on a port",
3615 (void *)&cmd_tx_vlan_reset_tx_vlan,
3616 (void *)&cmd_tx_vlan_reset_reset,
3617 (void *)&cmd_tx_vlan_reset_portid,
3623 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3624 struct cmd_csum_result {
3625 cmdline_fixed_string_t csum;
3626 cmdline_fixed_string_t mode;
3627 cmdline_fixed_string_t proto;
3628 cmdline_fixed_string_t hwsw;
3633 csum_show(int port_id)
3635 struct rte_eth_dev_info dev_info;
3636 uint64_t tx_offloads;
3638 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3639 printf("Parse tunnel is %s\n",
3640 (ports[port_id].parse_tunnel) ? "on" : "off");
3641 printf("IP checksum offload is %s\n",
3642 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3643 printf("UDP checksum offload is %s\n",
3644 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3645 printf("TCP checksum offload is %s\n",
3646 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3647 printf("SCTP checksum offload is %s\n",
3648 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3649 printf("Outer-Ip checksum offload is %s\n",
3650 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3652 /* display warnings if configuration is not supported by the NIC */
3653 rte_eth_dev_info_get(port_id, &dev_info);
3654 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3655 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3656 printf("Warning: hardware IP checksum enabled but not "
3657 "supported by port %d\n", port_id);
3659 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3660 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3661 printf("Warning: hardware UDP checksum enabled but not "
3662 "supported by port %d\n", port_id);
3664 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3665 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3666 printf("Warning: hardware TCP checksum enabled but not "
3667 "supported by port %d\n", port_id);
3669 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3670 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3671 printf("Warning: hardware SCTP checksum enabled but not "
3672 "supported by port %d\n", port_id);
3674 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3675 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3676 printf("Warning: hardware outer IP checksum enabled but not "
3677 "supported by port %d\n", port_id);
3682 cmd_csum_parsed(void *parsed_result,
3683 __attribute__((unused)) struct cmdline *cl,
3684 __attribute__((unused)) void *data)
3686 struct cmd_csum_result *res = parsed_result;
3688 uint64_t csum_offloads = 0;
3689 struct rte_eth_dev_info dev_info;
3691 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3692 printf("invalid port %d\n", res->port_id);
3695 if (!port_is_stopped(res->port_id)) {
3696 printf("Please stop port %d first\n", res->port_id);
3700 rte_eth_dev_info_get(res->port_id, &dev_info);
3701 if (!strcmp(res->mode, "set")) {
3703 if (!strcmp(res->hwsw, "hw"))
3706 if (!strcmp(res->proto, "ip")) {
3707 if (dev_info.tx_offload_capa &
3708 DEV_TX_OFFLOAD_IPV4_CKSUM) {
3709 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3711 printf("IP checksum offload is not supported "
3712 "by port %u\n", res->port_id);
3714 } else if (!strcmp(res->proto, "udp")) {
3715 if (dev_info.tx_offload_capa &
3716 DEV_TX_OFFLOAD_UDP_CKSUM) {
3717 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3719 printf("UDP checksum offload is not supported "
3720 "by port %u\n", res->port_id);
3722 } else if (!strcmp(res->proto, "tcp")) {
3723 if (dev_info.tx_offload_capa &
3724 DEV_TX_OFFLOAD_TCP_CKSUM) {
3725 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3727 printf("TCP checksum offload is not supported "
3728 "by port %u\n", res->port_id);
3730 } else if (!strcmp(res->proto, "sctp")) {
3731 if (dev_info.tx_offload_capa &
3732 DEV_TX_OFFLOAD_SCTP_CKSUM) {
3733 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3735 printf("SCTP checksum offload is not supported "
3736 "by port %u\n", res->port_id);
3738 } else if (!strcmp(res->proto, "outer-ip")) {
3739 if (dev_info.tx_offload_capa &
3740 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) {
3742 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3744 printf("Outer IP checksum offload is not "
3745 "supported by port %u\n", res->port_id);
3750 ports[res->port_id].dev_conf.txmode.offloads |=
3753 ports[res->port_id].dev_conf.txmode.offloads &=
3757 csum_show(res->port_id);
3759 cmd_reconfig_device_queue(res->port_id, 1, 1);
3762 cmdline_parse_token_string_t cmd_csum_csum =
3763 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3765 cmdline_parse_token_string_t cmd_csum_mode =
3766 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3768 cmdline_parse_token_string_t cmd_csum_proto =
3769 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3770 proto, "ip#tcp#udp#sctp#outer-ip");
3771 cmdline_parse_token_string_t cmd_csum_hwsw =
3772 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3774 cmdline_parse_token_num_t cmd_csum_portid =
3775 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3778 cmdline_parse_inst_t cmd_csum_set = {
3779 .f = cmd_csum_parsed,
3781 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3782 "Enable/Disable hardware calculation of L3/L4 checksum when "
3783 "using csum forward engine",
3785 (void *)&cmd_csum_csum,
3786 (void *)&cmd_csum_mode,
3787 (void *)&cmd_csum_proto,
3788 (void *)&cmd_csum_hwsw,
3789 (void *)&cmd_csum_portid,
3794 cmdline_parse_token_string_t cmd_csum_mode_show =
3795 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3798 cmdline_parse_inst_t cmd_csum_show = {
3799 .f = cmd_csum_parsed,
3801 .help_str = "csum show <port_id>: Show checksum offload configuration",
3803 (void *)&cmd_csum_csum,
3804 (void *)&cmd_csum_mode_show,
3805 (void *)&cmd_csum_portid,
3810 /* Enable/disable tunnel parsing */
3811 struct cmd_csum_tunnel_result {
3812 cmdline_fixed_string_t csum;
3813 cmdline_fixed_string_t parse;
3814 cmdline_fixed_string_t onoff;
3819 cmd_csum_tunnel_parsed(void *parsed_result,
3820 __attribute__((unused)) struct cmdline *cl,
3821 __attribute__((unused)) void *data)
3823 struct cmd_csum_tunnel_result *res = parsed_result;
3825 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3828 if (!strcmp(res->onoff, "on"))
3829 ports[res->port_id].parse_tunnel = 1;
3831 ports[res->port_id].parse_tunnel = 0;
3833 csum_show(res->port_id);
3836 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3837 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3839 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3840 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3841 parse, "parse_tunnel");
3842 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3843 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3845 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3846 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3849 cmdline_parse_inst_t cmd_csum_tunnel = {
3850 .f = cmd_csum_tunnel_parsed,
3852 .help_str = "csum parse_tunnel on|off <port_id>: "
3853 "Enable/Disable parsing of tunnels for csum engine",
3855 (void *)&cmd_csum_tunnel_csum,
3856 (void *)&cmd_csum_tunnel_parse,
3857 (void *)&cmd_csum_tunnel_onoff,
3858 (void *)&cmd_csum_tunnel_portid,
3863 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3864 struct cmd_tso_set_result {
3865 cmdline_fixed_string_t tso;
3866 cmdline_fixed_string_t mode;
3872 cmd_tso_set_parsed(void *parsed_result,
3873 __attribute__((unused)) struct cmdline *cl,
3874 __attribute__((unused)) void *data)
3876 struct cmd_tso_set_result *res = parsed_result;
3877 struct rte_eth_dev_info dev_info;
3879 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3881 if (!port_is_stopped(res->port_id)) {
3882 printf("Please stop port %d first\n", res->port_id);
3886 if (!strcmp(res->mode, "set"))
3887 ports[res->port_id].tso_segsz = res->tso_segsz;
3889 rte_eth_dev_info_get(res->port_id, &dev_info);
3890 if ((ports[res->port_id].tso_segsz != 0) &&
3891 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3892 printf("Error: TSO is not supported by port %d\n",
3897 if (ports[res->port_id].tso_segsz == 0) {
3898 ports[res->port_id].dev_conf.txmode.offloads &=
3899 ~DEV_TX_OFFLOAD_TCP_TSO;
3900 printf("TSO for non-tunneled packets is disabled\n");
3902 ports[res->port_id].dev_conf.txmode.offloads |=
3903 DEV_TX_OFFLOAD_TCP_TSO;
3904 printf("TSO segment size for non-tunneled packets is %d\n",
3905 ports[res->port_id].tso_segsz);
3908 /* display warnings if configuration is not supported by the NIC */
3909 rte_eth_dev_info_get(res->port_id, &dev_info);
3910 if ((ports[res->port_id].tso_segsz != 0) &&
3911 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3912 printf("Warning: TSO enabled but not "
3913 "supported by port %d\n", res->port_id);
3916 cmd_reconfig_device_queue(res->port_id, 1, 1);
3919 cmdline_parse_token_string_t cmd_tso_set_tso =
3920 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3922 cmdline_parse_token_string_t cmd_tso_set_mode =
3923 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3925 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3926 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3928 cmdline_parse_token_num_t cmd_tso_set_portid =
3929 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3932 cmdline_parse_inst_t cmd_tso_set = {
3933 .f = cmd_tso_set_parsed,
3935 .help_str = "tso set <tso_segsz> <port_id>: "
3936 "Set TSO segment size of non-tunneled packets for csum engine "
3939 (void *)&cmd_tso_set_tso,
3940 (void *)&cmd_tso_set_mode,
3941 (void *)&cmd_tso_set_tso_segsz,
3942 (void *)&cmd_tso_set_portid,
3947 cmdline_parse_token_string_t cmd_tso_show_mode =
3948 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3952 cmdline_parse_inst_t cmd_tso_show = {
3953 .f = cmd_tso_set_parsed,
3955 .help_str = "tso show <port_id>: "
3956 "Show TSO segment size of non-tunneled packets for csum engine",
3958 (void *)&cmd_tso_set_tso,
3959 (void *)&cmd_tso_show_mode,
3960 (void *)&cmd_tso_set_portid,
3965 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3966 struct cmd_tunnel_tso_set_result {
3967 cmdline_fixed_string_t tso;
3968 cmdline_fixed_string_t mode;
3973 static struct rte_eth_dev_info
3974 check_tunnel_tso_nic_support(portid_t port_id)
3976 struct rte_eth_dev_info dev_info;
3978 rte_eth_dev_info_get(port_id, &dev_info);
3979 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3980 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
3981 "not enabled for port %d\n", port_id);
3982 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3983 printf("Warning: GRE TUNNEL TSO not supported therefore "
3984 "not enabled for port %d\n", port_id);
3985 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3986 printf("Warning: IPIP TUNNEL TSO not supported therefore "
3987 "not enabled for port %d\n", port_id);
3988 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3989 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
3990 "not enabled for port %d\n", port_id);
3995 cmd_tunnel_tso_set_parsed(void *parsed_result,
3996 __attribute__((unused)) struct cmdline *cl,
3997 __attribute__((unused)) void *data)
3999 struct cmd_tunnel_tso_set_result *res = parsed_result;
4000 struct rte_eth_dev_info dev_info;
4002 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4004 if (!port_is_stopped(res->port_id)) {
4005 printf("Please stop port %d first\n", res->port_id);
4009 if (!strcmp(res->mode, "set"))
4010 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4012 dev_info = check_tunnel_tso_nic_support(res->port_id);
4013 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4014 ports[res->port_id].dev_conf.txmode.offloads &=
4015 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4016 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4017 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4018 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4019 printf("TSO for tunneled packets is disabled\n");
4021 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4022 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4023 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4024 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4026 ports[res->port_id].dev_conf.txmode.offloads |=
4027 (tso_offloads & dev_info.tx_offload_capa);
4028 printf("TSO segment size for tunneled packets is %d\n",
4029 ports[res->port_id].tunnel_tso_segsz);
4031 /* Below conditions are needed to make it work:
4032 * (1) tunnel TSO is supported by the NIC;
4033 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4035 * (3) for tunneled pkts with outer L3 of IPv4,
4036 * "csum set outer-ip" must be set to hw, because after tso,
4037 * total_len of outer IP header is changed, and the checksum
4038 * of outer IP header calculated by sw should be wrong; that
4039 * is not necessary for IPv6 tunneled pkts because there's no
4040 * checksum in IP header anymore.
4043 if (!ports[res->port_id].parse_tunnel)
4044 printf("Warning: csum parse_tunnel must be set "
4045 "so that tunneled packets are recognized\n");
4046 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4047 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4048 printf("Warning: csum set outer-ip must be set to hw "
4049 "if outer L3 is IPv4; not necessary for IPv6\n");
4052 cmd_reconfig_device_queue(res->port_id, 1, 1);
4055 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4056 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4058 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4059 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4061 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4062 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4064 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4065 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4068 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4069 .f = cmd_tunnel_tso_set_parsed,
4071 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4072 "Set TSO segment size of tunneled packets for csum engine "
4075 (void *)&cmd_tunnel_tso_set_tso,
4076 (void *)&cmd_tunnel_tso_set_mode,
4077 (void *)&cmd_tunnel_tso_set_tso_segsz,
4078 (void *)&cmd_tunnel_tso_set_portid,
4083 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4084 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4088 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4089 .f = cmd_tunnel_tso_set_parsed,
4091 .help_str = "tunnel_tso show <port_id> "
4092 "Show TSO segment size of tunneled packets for csum engine",
4094 (void *)&cmd_tunnel_tso_set_tso,
4095 (void *)&cmd_tunnel_tso_show_mode,
4096 (void *)&cmd_tunnel_tso_set_portid,
4101 /* *** SET GRO FOR A PORT *** */
4102 struct cmd_gro_enable_result {
4103 cmdline_fixed_string_t cmd_set;
4104 cmdline_fixed_string_t cmd_port;
4105 cmdline_fixed_string_t cmd_keyword;
4106 cmdline_fixed_string_t cmd_onoff;
4111 cmd_gro_enable_parsed(void *parsed_result,
4112 __attribute__((unused)) struct cmdline *cl,
4113 __attribute__((unused)) void *data)
4115 struct cmd_gro_enable_result *res;
4117 res = parsed_result;
4118 if (!strcmp(res->cmd_keyword, "gro"))
4119 setup_gro(res->cmd_onoff, res->cmd_pid);
4122 cmdline_parse_token_string_t cmd_gro_enable_set =
4123 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4125 cmdline_parse_token_string_t cmd_gro_enable_port =
4126 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4127 cmd_keyword, "port");
4128 cmdline_parse_token_num_t cmd_gro_enable_pid =
4129 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4131 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4132 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4133 cmd_keyword, "gro");
4134 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4135 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4136 cmd_onoff, "on#off");
4138 cmdline_parse_inst_t cmd_gro_enable = {
4139 .f = cmd_gro_enable_parsed,
4141 .help_str = "set port <port_id> gro on|off",
4143 (void *)&cmd_gro_enable_set,
4144 (void *)&cmd_gro_enable_port,
4145 (void *)&cmd_gro_enable_pid,
4146 (void *)&cmd_gro_enable_keyword,
4147 (void *)&cmd_gro_enable_onoff,
4152 /* *** DISPLAY GRO CONFIGURATION *** */
4153 struct cmd_gro_show_result {
4154 cmdline_fixed_string_t cmd_show;
4155 cmdline_fixed_string_t cmd_port;
4156 cmdline_fixed_string_t cmd_keyword;
4161 cmd_gro_show_parsed(void *parsed_result,
4162 __attribute__((unused)) struct cmdline *cl,
4163 __attribute__((unused)) void *data)
4165 struct cmd_gro_show_result *res;
4167 res = parsed_result;
4168 if (!strcmp(res->cmd_keyword, "gro"))
4169 show_gro(res->cmd_pid);
4172 cmdline_parse_token_string_t cmd_gro_show_show =
4173 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4175 cmdline_parse_token_string_t cmd_gro_show_port =
4176 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4178 cmdline_parse_token_num_t cmd_gro_show_pid =
4179 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4181 cmdline_parse_token_string_t cmd_gro_show_keyword =
4182 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4183 cmd_keyword, "gro");
4185 cmdline_parse_inst_t cmd_gro_show = {
4186 .f = cmd_gro_show_parsed,
4188 .help_str = "show port <port_id> gro",
4190 (void *)&cmd_gro_show_show,
4191 (void *)&cmd_gro_show_port,
4192 (void *)&cmd_gro_show_pid,
4193 (void *)&cmd_gro_show_keyword,
4198 /* *** SET FLUSH CYCLES FOR GRO *** */
4199 struct cmd_gro_flush_result {
4200 cmdline_fixed_string_t cmd_set;
4201 cmdline_fixed_string_t cmd_keyword;
4202 cmdline_fixed_string_t cmd_flush;
4207 cmd_gro_flush_parsed(void *parsed_result,
4208 __attribute__((unused)) struct cmdline *cl,
4209 __attribute__((unused)) void *data)
4211 struct cmd_gro_flush_result *res;
4213 res = parsed_result;
4214 if ((!strcmp(res->cmd_keyword, "gro")) &&
4215 (!strcmp(res->cmd_flush, "flush")))
4216 setup_gro_flush_cycles(res->cmd_cycles);
4219 cmdline_parse_token_string_t cmd_gro_flush_set =
4220 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4222 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4223 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4224 cmd_keyword, "gro");
4225 cmdline_parse_token_string_t cmd_gro_flush_flush =
4226 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4227 cmd_flush, "flush");
4228 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4229 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4232 cmdline_parse_inst_t cmd_gro_flush = {
4233 .f = cmd_gro_flush_parsed,
4235 .help_str = "set gro flush <cycles>",
4237 (void *)&cmd_gro_flush_set,
4238 (void *)&cmd_gro_flush_keyword,
4239 (void *)&cmd_gro_flush_flush,
4240 (void *)&cmd_gro_flush_cycles,
4245 /* *** ENABLE/DISABLE GSO *** */
4246 struct cmd_gso_enable_result {
4247 cmdline_fixed_string_t cmd_set;
4248 cmdline_fixed_string_t cmd_port;
4249 cmdline_fixed_string_t cmd_keyword;
4250 cmdline_fixed_string_t cmd_mode;
4255 cmd_gso_enable_parsed(void *parsed_result,
4256 __attribute__((unused)) struct cmdline *cl,
4257 __attribute__((unused)) void *data)
4259 struct cmd_gso_enable_result *res;
4261 res = parsed_result;
4262 if (!strcmp(res->cmd_keyword, "gso"))
4263 setup_gso(res->cmd_mode, res->cmd_pid);
4266 cmdline_parse_token_string_t cmd_gso_enable_set =
4267 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4269 cmdline_parse_token_string_t cmd_gso_enable_port =
4270 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4272 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4273 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4274 cmd_keyword, "gso");
4275 cmdline_parse_token_string_t cmd_gso_enable_mode =
4276 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4277 cmd_mode, "on#off");
4278 cmdline_parse_token_num_t cmd_gso_enable_pid =
4279 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4282 cmdline_parse_inst_t cmd_gso_enable = {
4283 .f = cmd_gso_enable_parsed,
4285 .help_str = "set port <port_id> gso on|off",
4287 (void *)&cmd_gso_enable_set,
4288 (void *)&cmd_gso_enable_port,
4289 (void *)&cmd_gso_enable_pid,
4290 (void *)&cmd_gso_enable_keyword,
4291 (void *)&cmd_gso_enable_mode,
4296 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4297 struct cmd_gso_size_result {
4298 cmdline_fixed_string_t cmd_set;
4299 cmdline_fixed_string_t cmd_keyword;
4300 cmdline_fixed_string_t cmd_segsz;
4305 cmd_gso_size_parsed(void *parsed_result,
4306 __attribute__((unused)) struct cmdline *cl,
4307 __attribute__((unused)) void *data)
4309 struct cmd_gso_size_result *res = parsed_result;
4311 if (test_done == 0) {
4312 printf("Before setting GSO segsz, please first"
4313 " stop fowarding\n");
4317 if (!strcmp(res->cmd_keyword, "gso") &&
4318 !strcmp(res->cmd_segsz, "segsz")) {
4319 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4320 printf("gso_size should be larger than %zu."
4321 " Please input a legal value\n",
4322 RTE_GSO_SEG_SIZE_MIN);
4324 gso_max_segment_size = res->cmd_size;
4328 cmdline_parse_token_string_t cmd_gso_size_set =
4329 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4331 cmdline_parse_token_string_t cmd_gso_size_keyword =
4332 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4333 cmd_keyword, "gso");
4334 cmdline_parse_token_string_t cmd_gso_size_segsz =
4335 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4336 cmd_segsz, "segsz");
4337 cmdline_parse_token_num_t cmd_gso_size_size =
4338 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4341 cmdline_parse_inst_t cmd_gso_size = {
4342 .f = cmd_gso_size_parsed,
4344 .help_str = "set gso segsz <length>",
4346 (void *)&cmd_gso_size_set,
4347 (void *)&cmd_gso_size_keyword,
4348 (void *)&cmd_gso_size_segsz,
4349 (void *)&cmd_gso_size_size,
4354 /* *** SHOW GSO CONFIGURATION *** */
4355 struct cmd_gso_show_result {
4356 cmdline_fixed_string_t cmd_show;
4357 cmdline_fixed_string_t cmd_port;
4358 cmdline_fixed_string_t cmd_keyword;
4363 cmd_gso_show_parsed(void *parsed_result,
4364 __attribute__((unused)) struct cmdline *cl,
4365 __attribute__((unused)) void *data)
4367 struct cmd_gso_show_result *res = parsed_result;
4369 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4370 printf("invalid port id %u\n", res->cmd_pid);
4373 if (!strcmp(res->cmd_keyword, "gso")) {
4374 if (gso_ports[res->cmd_pid].enable) {
4375 printf("Max GSO'd packet size: %uB\n"
4376 "Supported GSO types: TCP/IPv4, "
4377 "VxLAN with inner TCP/IPv4 packet, "
4378 "GRE with inner TCP/IPv4 packet\n",
4379 gso_max_segment_size);
4381 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4385 cmdline_parse_token_string_t cmd_gso_show_show =
4386 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4388 cmdline_parse_token_string_t cmd_gso_show_port =
4389 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4391 cmdline_parse_token_string_t cmd_gso_show_keyword =
4392 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4393 cmd_keyword, "gso");
4394 cmdline_parse_token_num_t cmd_gso_show_pid =
4395 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4398 cmdline_parse_inst_t cmd_gso_show = {
4399 .f = cmd_gso_show_parsed,
4401 .help_str = "show port <port_id> gso",
4403 (void *)&cmd_gso_show_show,
4404 (void *)&cmd_gso_show_port,
4405 (void *)&cmd_gso_show_pid,
4406 (void *)&cmd_gso_show_keyword,
4411 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4412 struct cmd_set_flush_rx {
4413 cmdline_fixed_string_t set;
4414 cmdline_fixed_string_t flush_rx;
4415 cmdline_fixed_string_t mode;
4419 cmd_set_flush_rx_parsed(void *parsed_result,
4420 __attribute__((unused)) struct cmdline *cl,
4421 __attribute__((unused)) void *data)
4423 struct cmd_set_flush_rx *res = parsed_result;
4424 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4427 cmdline_parse_token_string_t cmd_setflushrx_set =
4428 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4430 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4431 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4432 flush_rx, "flush_rx");
4433 cmdline_parse_token_string_t cmd_setflushrx_mode =
4434 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4438 cmdline_parse_inst_t cmd_set_flush_rx = {
4439 .f = cmd_set_flush_rx_parsed,
4440 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4443 (void *)&cmd_setflushrx_set,
4444 (void *)&cmd_setflushrx_flush_rx,
4445 (void *)&cmd_setflushrx_mode,
4450 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4451 struct cmd_set_link_check {
4452 cmdline_fixed_string_t set;
4453 cmdline_fixed_string_t link_check;
4454 cmdline_fixed_string_t mode;
4458 cmd_set_link_check_parsed(void *parsed_result,
4459 __attribute__((unused)) struct cmdline *cl,
4460 __attribute__((unused)) void *data)
4462 struct cmd_set_link_check *res = parsed_result;
4463 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4466 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4467 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4469 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4470 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4471 link_check, "link_check");
4472 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4473 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4477 cmdline_parse_inst_t cmd_set_link_check = {
4478 .f = cmd_set_link_check_parsed,
4479 .help_str = "set link_check on|off: Enable/Disable link status check "
4480 "when starting/stopping a port",
4483 (void *)&cmd_setlinkcheck_set,
4484 (void *)&cmd_setlinkcheck_link_check,
4485 (void *)&cmd_setlinkcheck_mode,
4490 /* *** SET NIC BYPASS MODE *** */
4491 struct cmd_set_bypass_mode_result {
4492 cmdline_fixed_string_t set;
4493 cmdline_fixed_string_t bypass;
4494 cmdline_fixed_string_t mode;
4495 cmdline_fixed_string_t value;
4500 cmd_set_bypass_mode_parsed(void *parsed_result,
4501 __attribute__((unused)) struct cmdline *cl,
4502 __attribute__((unused)) void *data)
4504 struct cmd_set_bypass_mode_result *res = parsed_result;
4505 portid_t port_id = res->port_id;
4506 int32_t rc = -EINVAL;
4508 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4509 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4511 if (!strcmp(res->value, "bypass"))
4512 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4513 else if (!strcmp(res->value, "isolate"))
4514 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4516 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4518 /* Set the bypass mode for the relevant port. */
4519 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4522 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4525 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4526 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4528 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4529 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4531 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4532 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4534 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4535 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4536 value, "normal#bypass#isolate");
4537 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4538 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4541 cmdline_parse_inst_t cmd_set_bypass_mode = {
4542 .f = cmd_set_bypass_mode_parsed,
4543 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4544 "Set the NIC bypass mode for port_id",
4547 (void *)&cmd_setbypass_mode_set,
4548 (void *)&cmd_setbypass_mode_bypass,
4549 (void *)&cmd_setbypass_mode_mode,
4550 (void *)&cmd_setbypass_mode_value,
4551 (void *)&cmd_setbypass_mode_port,
4556 /* *** SET NIC BYPASS EVENT *** */
4557 struct cmd_set_bypass_event_result {
4558 cmdline_fixed_string_t set;
4559 cmdline_fixed_string_t bypass;
4560 cmdline_fixed_string_t event;
4561 cmdline_fixed_string_t event_value;
4562 cmdline_fixed_string_t mode;
4563 cmdline_fixed_string_t mode_value;
4568 cmd_set_bypass_event_parsed(void *parsed_result,
4569 __attribute__((unused)) struct cmdline *cl,
4570 __attribute__((unused)) void *data)
4572 int32_t rc = -EINVAL;
4573 struct cmd_set_bypass_event_result *res = parsed_result;
4574 portid_t port_id = res->port_id;
4576 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4577 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4578 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4580 if (!strcmp(res->event_value, "timeout"))
4581 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4582 else if (!strcmp(res->event_value, "os_on"))
4583 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4584 else if (!strcmp(res->event_value, "os_off"))
4585 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4586 else if (!strcmp(res->event_value, "power_on"))
4587 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4588 else if (!strcmp(res->event_value, "power_off"))
4589 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4591 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4593 if (!strcmp(res->mode_value, "bypass"))
4594 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4595 else if (!strcmp(res->mode_value, "isolate"))
4596 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4598 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4600 /* Set the watchdog timeout. */
4601 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4604 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4605 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4609 printf("Failed to set timeout value %u "
4610 "for port %d, errto code: %d.\n",
4611 bypass_timeout, port_id, rc);
4615 /* Set the bypass event to transition to bypass mode. */
4616 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4621 printf("\t Failed to set bypass event for port = %d.\n",
4625 cmdline_parse_token_string_t cmd_setbypass_event_set =
4626 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4628 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4629 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4631 cmdline_parse_token_string_t cmd_setbypass_event_event =
4632 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4634 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4635 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4636 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4637 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4638 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4640 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4641 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4642 mode_value, "normal#bypass#isolate");
4643 cmdline_parse_token_num_t cmd_setbypass_event_port =
4644 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4647 cmdline_parse_inst_t cmd_set_bypass_event = {
4648 .f = cmd_set_bypass_event_parsed,
4649 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4650 "power_off mode normal|bypass|isolate <port_id>: "
4651 "Set the NIC bypass event mode for port_id",
4654 (void *)&cmd_setbypass_event_set,
4655 (void *)&cmd_setbypass_event_bypass,
4656 (void *)&cmd_setbypass_event_event,
4657 (void *)&cmd_setbypass_event_event_value,
4658 (void *)&cmd_setbypass_event_mode,
4659 (void *)&cmd_setbypass_event_mode_value,
4660 (void *)&cmd_setbypass_event_port,
4666 /* *** SET NIC BYPASS TIMEOUT *** */
4667 struct cmd_set_bypass_timeout_result {
4668 cmdline_fixed_string_t set;
4669 cmdline_fixed_string_t bypass;
4670 cmdline_fixed_string_t timeout;
4671 cmdline_fixed_string_t value;
4675 cmd_set_bypass_timeout_parsed(void *parsed_result,
4676 __attribute__((unused)) struct cmdline *cl,
4677 __attribute__((unused)) void *data)
4679 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4681 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4682 if (!strcmp(res->value, "1.5"))
4683 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4684 else if (!strcmp(res->value, "2"))
4685 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4686 else if (!strcmp(res->value, "3"))
4687 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4688 else if (!strcmp(res->value, "4"))
4689 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4690 else if (!strcmp(res->value, "8"))
4691 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4692 else if (!strcmp(res->value, "16"))
4693 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4694 else if (!strcmp(res->value, "32"))
4695 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4697 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4701 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4702 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4704 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4705 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4707 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4708 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4709 timeout, "timeout");
4710 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4711 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4712 value, "0#1.5#2#3#4#8#16#32");
4714 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4715 .f = cmd_set_bypass_timeout_parsed,
4716 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4717 "Set the NIC bypass watchdog timeout in seconds",
4720 (void *)&cmd_setbypass_timeout_set,
4721 (void *)&cmd_setbypass_timeout_bypass,
4722 (void *)&cmd_setbypass_timeout_timeout,
4723 (void *)&cmd_setbypass_timeout_value,
4728 /* *** SHOW NIC BYPASS MODE *** */
4729 struct cmd_show_bypass_config_result {
4730 cmdline_fixed_string_t show;
4731 cmdline_fixed_string_t bypass;
4732 cmdline_fixed_string_t config;
4737 cmd_show_bypass_config_parsed(void *parsed_result,
4738 __attribute__((unused)) struct cmdline *cl,
4739 __attribute__((unused)) void *data)
4741 struct cmd_show_bypass_config_result *res = parsed_result;
4742 portid_t port_id = res->port_id;
4744 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4745 uint32_t event_mode;
4746 uint32_t bypass_mode;
4747 uint32_t timeout = bypass_timeout;
4750 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4751 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4752 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4753 {"UNKNOWN", "normal", "bypass", "isolate"};
4754 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4761 int num_events = (sizeof events) / (sizeof events[0]);
4763 /* Display the bypass mode.*/
4764 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4765 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4769 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4770 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4772 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4775 /* Display the bypass timeout.*/
4776 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4777 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4779 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4781 /* Display the bypass events and associated modes. */
4782 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4784 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4785 printf("\tFailed to get bypass mode for event = %s\n",
4788 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4789 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4791 printf("\tbypass event: %-16s = %s\n", events[i],
4797 printf("\tFailed to get bypass configuration for port = %d\n",
4801 cmdline_parse_token_string_t cmd_showbypass_config_show =
4802 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4804 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4805 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4807 cmdline_parse_token_string_t cmd_showbypass_config_config =
4808 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4810 cmdline_parse_token_num_t cmd_showbypass_config_port =
4811 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4814 cmdline_parse_inst_t cmd_show_bypass_config = {
4815 .f = cmd_show_bypass_config_parsed,
4816 .help_str = "show bypass config <port_id>: "
4817 "Show the NIC bypass config for port_id",
4820 (void *)&cmd_showbypass_config_show,
4821 (void *)&cmd_showbypass_config_bypass,
4822 (void *)&cmd_showbypass_config_config,
4823 (void *)&cmd_showbypass_config_port,
4828 #ifdef RTE_LIBRTE_PMD_BOND
4829 /* *** SET BONDING MODE *** */
4830 struct cmd_set_bonding_mode_result {
4831 cmdline_fixed_string_t set;
4832 cmdline_fixed_string_t bonding;
4833 cmdline_fixed_string_t mode;
4838 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4839 __attribute__((unused)) struct cmdline *cl,
4840 __attribute__((unused)) void *data)
4842 struct cmd_set_bonding_mode_result *res = parsed_result;
4843 portid_t port_id = res->port_id;
4845 /* Set the bonding mode for the relevant port. */
4846 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4847 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4850 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4851 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4853 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4854 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4855 bonding, "bonding");
4856 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4857 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4859 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4860 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4862 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4863 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4866 cmdline_parse_inst_t cmd_set_bonding_mode = {
4867 .f = cmd_set_bonding_mode_parsed,
4868 .help_str = "set bonding mode <mode_value> <port_id>: "
4869 "Set the bonding mode for port_id",
4872 (void *) &cmd_setbonding_mode_set,
4873 (void *) &cmd_setbonding_mode_bonding,
4874 (void *) &cmd_setbonding_mode_mode,
4875 (void *) &cmd_setbonding_mode_value,
4876 (void *) &cmd_setbonding_mode_port,
4881 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4882 struct cmd_set_bonding_lacp_dedicated_queues_result {
4883 cmdline_fixed_string_t set;
4884 cmdline_fixed_string_t bonding;
4885 cmdline_fixed_string_t lacp;
4886 cmdline_fixed_string_t dedicated_queues;
4888 cmdline_fixed_string_t mode;
4891 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4892 __attribute__((unused)) struct cmdline *cl,
4893 __attribute__((unused)) void *data)
4895 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4896 portid_t port_id = res->port_id;
4897 struct rte_port *port;
4899 port = &ports[port_id];
4901 /** Check if the port is not started **/
4902 if (port->port_status != RTE_PORT_STOPPED) {
4903 printf("Please stop port %d first\n", port_id);
4907 if (!strcmp(res->mode, "enable")) {
4908 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4909 printf("Dedicate queues for LACP control packets"
4912 printf("Enabling dedicate queues for LACP control "
4913 "packets on port %d failed\n", port_id);
4914 } else if (!strcmp(res->mode, "disable")) {
4915 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4916 printf("Dedicated queues for LACP control packets "
4919 printf("Disabling dedicated queues for LACP control "
4920 "traffic on port %d failed\n", port_id);
4924 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4925 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4927 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4928 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4929 bonding, "bonding");
4930 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4931 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4933 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4934 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4935 dedicated_queues, "dedicated_queues");
4936 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4937 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4939 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4940 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4941 mode, "enable#disable");
4943 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4944 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4945 .help_str = "set bonding lacp dedicated_queues <port_id> "
4947 "Enable/disable dedicated queues for LACP control traffic for port_id",
4950 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4951 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4952 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4953 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4954 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4955 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4960 /* *** SET BALANCE XMIT POLICY *** */
4961 struct cmd_set_bonding_balance_xmit_policy_result {
4962 cmdline_fixed_string_t set;
4963 cmdline_fixed_string_t bonding;
4964 cmdline_fixed_string_t balance_xmit_policy;
4966 cmdline_fixed_string_t policy;
4969 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4970 __attribute__((unused)) struct cmdline *cl,
4971 __attribute__((unused)) void *data)
4973 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4974 portid_t port_id = res->port_id;
4977 if (!strcmp(res->policy, "l2")) {
4978 policy = BALANCE_XMIT_POLICY_LAYER2;
4979 } else if (!strcmp(res->policy, "l23")) {
4980 policy = BALANCE_XMIT_POLICY_LAYER23;
4981 } else if (!strcmp(res->policy, "l34")) {
4982 policy = BALANCE_XMIT_POLICY_LAYER34;
4984 printf("\t Invalid xmit policy selection");
4988 /* Set the bonding mode for the relevant port. */
4989 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4990 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4995 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4996 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4998 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4999 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5000 bonding, "bonding");
5001 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5002 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5003 balance_xmit_policy, "balance_xmit_policy");
5004 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5005 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5007 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5008 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5009 policy, "l2#l23#l34");
5011 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5012 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5013 .help_str = "set bonding balance_xmit_policy <port_id> "
5015 "Set the bonding balance_xmit_policy for port_id",
5018 (void *)&cmd_setbonding_balance_xmit_policy_set,
5019 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5020 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5021 (void *)&cmd_setbonding_balance_xmit_policy_port,
5022 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5027 /* *** SHOW NIC BONDING CONFIGURATION *** */
5028 struct cmd_show_bonding_config_result {
5029 cmdline_fixed_string_t show;
5030 cmdline_fixed_string_t bonding;
5031 cmdline_fixed_string_t config;
5035 static void cmd_show_bonding_config_parsed(void *parsed_result,
5036 __attribute__((unused)) struct cmdline *cl,
5037 __attribute__((unused)) void *data)
5039 struct cmd_show_bonding_config_result *res = parsed_result;
5040 int bonding_mode, agg_mode;
5041 portid_t slaves[RTE_MAX_ETHPORTS];
5042 int num_slaves, num_active_slaves;
5045 portid_t port_id = res->port_id;
5047 /* Display the bonding mode.*/
5048 bonding_mode = rte_eth_bond_mode_get(port_id);
5049 if (bonding_mode < 0) {
5050 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5053 printf("\tBonding mode: %d\n", bonding_mode);
5055 if (bonding_mode == BONDING_MODE_BALANCE) {
5056 int balance_xmit_policy;
5058 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5059 if (balance_xmit_policy < 0) {
5060 printf("\tFailed to get balance xmit policy for port = %d\n",
5064 printf("\tBalance Xmit Policy: ");
5066 switch (balance_xmit_policy) {
5067 case BALANCE_XMIT_POLICY_LAYER2:
5068 printf("BALANCE_XMIT_POLICY_LAYER2");
5070 case BALANCE_XMIT_POLICY_LAYER23:
5071 printf("BALANCE_XMIT_POLICY_LAYER23");
5073 case BALANCE_XMIT_POLICY_LAYER34:
5074 printf("BALANCE_XMIT_POLICY_LAYER34");
5081 if (bonding_mode == BONDING_MODE_8023AD) {
5082 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5083 printf("\tIEEE802.3AD Aggregator Mode: ");
5086 printf("bandwidth");
5098 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5100 if (num_slaves < 0) {
5101 printf("\tFailed to get slave list for port = %d\n", port_id);
5104 if (num_slaves > 0) {
5105 printf("\tSlaves (%d): [", num_slaves);
5106 for (i = 0; i < num_slaves - 1; i++)
5107 printf("%d ", slaves[i]);
5109 printf("%d]\n", slaves[num_slaves - 1]);
5111 printf("\tSlaves: []\n");
5115 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5118 if (num_active_slaves < 0) {
5119 printf("\tFailed to get active slave list for port = %d\n", port_id);
5122 if (num_active_slaves > 0) {
5123 printf("\tActive Slaves (%d): [", num_active_slaves);
5124 for (i = 0; i < num_active_slaves - 1; i++)
5125 printf("%d ", slaves[i]);
5127 printf("%d]\n", slaves[num_active_slaves - 1]);
5130 printf("\tActive Slaves: []\n");
5134 primary_id = rte_eth_bond_primary_get(port_id);
5135 if (primary_id < 0) {
5136 printf("\tFailed to get primary slave for port = %d\n", port_id);
5139 printf("\tPrimary: [%d]\n", primary_id);
5143 cmdline_parse_token_string_t cmd_showbonding_config_show =
5144 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5146 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5147 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5148 bonding, "bonding");
5149 cmdline_parse_token_string_t cmd_showbonding_config_config =
5150 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5152 cmdline_parse_token_num_t cmd_showbonding_config_port =
5153 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5156 cmdline_parse_inst_t cmd_show_bonding_config = {
5157 .f = cmd_show_bonding_config_parsed,
5158 .help_str = "show bonding config <port_id>: "
5159 "Show the bonding config for port_id",
5162 (void *)&cmd_showbonding_config_show,
5163 (void *)&cmd_showbonding_config_bonding,
5164 (void *)&cmd_showbonding_config_config,
5165 (void *)&cmd_showbonding_config_port,
5170 /* *** SET BONDING PRIMARY *** */
5171 struct cmd_set_bonding_primary_result {
5172 cmdline_fixed_string_t set;
5173 cmdline_fixed_string_t bonding;
5174 cmdline_fixed_string_t primary;
5179 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5180 __attribute__((unused)) struct cmdline *cl,
5181 __attribute__((unused)) void *data)
5183 struct cmd_set_bonding_primary_result *res = parsed_result;
5184 portid_t master_port_id = res->port_id;
5185 portid_t slave_port_id = res->slave_id;
5187 /* Set the primary slave for a bonded device. */
5188 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5189 printf("\t Failed to set primary slave for port = %d.\n",
5196 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5197 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5199 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5200 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5201 bonding, "bonding");
5202 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5203 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5204 primary, "primary");
5205 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5206 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5208 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5209 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5212 cmdline_parse_inst_t cmd_set_bonding_primary = {
5213 .f = cmd_set_bonding_primary_parsed,
5214 .help_str = "set bonding primary <slave_id> <port_id>: "
5215 "Set the primary slave for port_id",
5218 (void *)&cmd_setbonding_primary_set,
5219 (void *)&cmd_setbonding_primary_bonding,
5220 (void *)&cmd_setbonding_primary_primary,
5221 (void *)&cmd_setbonding_primary_slave,
5222 (void *)&cmd_setbonding_primary_port,
5227 /* *** ADD SLAVE *** */
5228 struct cmd_add_bonding_slave_result {
5229 cmdline_fixed_string_t add;
5230 cmdline_fixed_string_t bonding;
5231 cmdline_fixed_string_t slave;
5236 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5237 __attribute__((unused)) struct cmdline *cl,
5238 __attribute__((unused)) void *data)
5240 struct cmd_add_bonding_slave_result *res = parsed_result;
5241 portid_t master_port_id = res->port_id;
5242 portid_t slave_port_id = res->slave_id;
5244 /* add the slave for a bonded device. */
5245 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5246 printf("\t Failed to add slave %d to master port = %d.\n",
5247 slave_port_id, master_port_id);
5251 set_port_slave_flag(slave_port_id);
5254 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5255 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5257 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5258 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5259 bonding, "bonding");
5260 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5261 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5263 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5264 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5266 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5267 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5270 cmdline_parse_inst_t cmd_add_bonding_slave = {
5271 .f = cmd_add_bonding_slave_parsed,
5272 .help_str = "add bonding slave <slave_id> <port_id>: "
5273 "Add a slave device to a bonded device",
5276 (void *)&cmd_addbonding_slave_add,
5277 (void *)&cmd_addbonding_slave_bonding,
5278 (void *)&cmd_addbonding_slave_slave,
5279 (void *)&cmd_addbonding_slave_slaveid,
5280 (void *)&cmd_addbonding_slave_port,
5285 /* *** REMOVE SLAVE *** */
5286 struct cmd_remove_bonding_slave_result {
5287 cmdline_fixed_string_t remove;
5288 cmdline_fixed_string_t bonding;
5289 cmdline_fixed_string_t slave;
5294 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5295 __attribute__((unused)) struct cmdline *cl,
5296 __attribute__((unused)) void *data)
5298 struct cmd_remove_bonding_slave_result *res = parsed_result;
5299 portid_t master_port_id = res->port_id;
5300 portid_t slave_port_id = res->slave_id;
5302 /* remove the slave from a bonded device. */
5303 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5304 printf("\t Failed to remove slave %d from master port = %d.\n",
5305 slave_port_id, master_port_id);
5309 clear_port_slave_flag(slave_port_id);
5312 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5313 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5315 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5316 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5317 bonding, "bonding");
5318 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5319 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5321 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5322 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5324 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5325 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5328 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5329 .f = cmd_remove_bonding_slave_parsed,
5330 .help_str = "remove bonding slave <slave_id> <port_id>: "
5331 "Remove a slave device from a bonded device",
5334 (void *)&cmd_removebonding_slave_remove,
5335 (void *)&cmd_removebonding_slave_bonding,
5336 (void *)&cmd_removebonding_slave_slave,
5337 (void *)&cmd_removebonding_slave_slaveid,
5338 (void *)&cmd_removebonding_slave_port,
5343 /* *** CREATE BONDED DEVICE *** */
5344 struct cmd_create_bonded_device_result {
5345 cmdline_fixed_string_t create;
5346 cmdline_fixed_string_t bonded;
5347 cmdline_fixed_string_t device;
5352 static int bond_dev_num = 0;
5354 static void cmd_create_bonded_device_parsed(void *parsed_result,
5355 __attribute__((unused)) struct cmdline *cl,
5356 __attribute__((unused)) void *data)
5358 struct cmd_create_bonded_device_result *res = parsed_result;
5359 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5362 if (test_done == 0) {
5363 printf("Please stop forwarding first\n");
5367 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5370 /* Create a new bonded device. */
5371 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5373 printf("\t Failed to create bonded device.\n");
5376 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5379 /* Update number of ports */
5380 nb_ports = rte_eth_dev_count();
5381 reconfig(port_id, res->socket);
5382 rte_eth_promiscuous_enable(port_id);
5387 cmdline_parse_token_string_t cmd_createbonded_device_create =
5388 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5390 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5391 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5393 cmdline_parse_token_string_t cmd_createbonded_device_device =
5394 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5396 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5397 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5399 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5400 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5403 cmdline_parse_inst_t cmd_create_bonded_device = {
5404 .f = cmd_create_bonded_device_parsed,
5405 .help_str = "create bonded device <mode> <socket>: "
5406 "Create a new bonded device with specific bonding mode and socket",
5409 (void *)&cmd_createbonded_device_create,
5410 (void *)&cmd_createbonded_device_bonded,
5411 (void *)&cmd_createbonded_device_device,
5412 (void *)&cmd_createbonded_device_mode,
5413 (void *)&cmd_createbonded_device_socket,
5418 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5419 struct cmd_set_bond_mac_addr_result {
5420 cmdline_fixed_string_t set;
5421 cmdline_fixed_string_t bonding;
5422 cmdline_fixed_string_t mac_addr;
5424 struct ether_addr address;
5427 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5428 __attribute__((unused)) struct cmdline *cl,
5429 __attribute__((unused)) void *data)
5431 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5434 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5437 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5439 /* check the return value and print it if is < 0 */
5441 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5444 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5445 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5446 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5447 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5449 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5450 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5452 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5453 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5455 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5456 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5458 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5459 .f = cmd_set_bond_mac_addr_parsed,
5461 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5463 (void *)&cmd_set_bond_mac_addr_set,
5464 (void *)&cmd_set_bond_mac_addr_bonding,
5465 (void *)&cmd_set_bond_mac_addr_mac,
5466 (void *)&cmd_set_bond_mac_addr_portnum,
5467 (void *)&cmd_set_bond_mac_addr_addr,
5473 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5474 struct cmd_set_bond_mon_period_result {
5475 cmdline_fixed_string_t set;
5476 cmdline_fixed_string_t bonding;
5477 cmdline_fixed_string_t mon_period;
5482 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5483 __attribute__((unused)) struct cmdline *cl,
5484 __attribute__((unused)) void *data)
5486 struct cmd_set_bond_mon_period_result *res = parsed_result;
5489 if (res->port_num >= nb_ports) {
5490 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5494 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5496 /* check the return value and print it if is < 0 */
5498 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5501 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5502 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5504 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5505 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5506 bonding, "bonding");
5507 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5508 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5509 mon_period, "mon_period");
5510 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5511 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5513 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5514 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5517 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5518 .f = cmd_set_bond_mon_period_parsed,
5520 .help_str = "set bonding mon_period <port_id> <period_ms>",
5522 (void *)&cmd_set_bond_mon_period_set,
5523 (void *)&cmd_set_bond_mon_period_bonding,
5524 (void *)&cmd_set_bond_mon_period_mon_period,
5525 (void *)&cmd_set_bond_mon_period_portnum,
5526 (void *)&cmd_set_bond_mon_period_period_ms,
5533 struct cmd_set_bonding_agg_mode_policy_result {
5534 cmdline_fixed_string_t set;
5535 cmdline_fixed_string_t bonding;
5536 cmdline_fixed_string_t agg_mode;
5538 cmdline_fixed_string_t policy;
5543 cmd_set_bonding_agg_mode(void *parsed_result,
5544 __attribute__((unused)) struct cmdline *cl,
5545 __attribute__((unused)) void *data)
5547 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5548 uint8_t policy = AGG_BANDWIDTH;
5550 if (res->port_num >= nb_ports) {
5551 printf("Port id %d must be less than %d\n",
5552 res->port_num, nb_ports);
5556 if (!strcmp(res->policy, "bandwidth"))
5557 policy = AGG_BANDWIDTH;
5558 else if (!strcmp(res->policy, "stable"))
5559 policy = AGG_STABLE;
5560 else if (!strcmp(res->policy, "count"))
5563 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5567 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5568 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5570 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5571 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5572 bonding, "bonding");
5574 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5575 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5576 agg_mode, "agg_mode");
5578 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5579 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5582 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5583 TOKEN_STRING_INITIALIZER(
5584 struct cmd_set_bonding_balance_xmit_policy_result,
5585 policy, "stable#bandwidth#count");
5587 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5588 .f = cmd_set_bonding_agg_mode,
5590 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5592 (void *)&cmd_set_bonding_agg_mode_set,
5593 (void *)&cmd_set_bonding_agg_mode_bonding,
5594 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5595 (void *)&cmd_set_bonding_agg_mode_portnum,
5596 (void *)&cmd_set_bonding_agg_mode_policy_string,
5602 #endif /* RTE_LIBRTE_PMD_BOND */
5604 /* *** SET FORWARDING MODE *** */
5605 struct cmd_set_fwd_mode_result {
5606 cmdline_fixed_string_t set;
5607 cmdline_fixed_string_t fwd;
5608 cmdline_fixed_string_t mode;
5611 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5612 __attribute__((unused)) struct cmdline *cl,
5613 __attribute__((unused)) void *data)
5615 struct cmd_set_fwd_mode_result *res = parsed_result;
5618 set_pkt_forwarding_mode(res->mode);
5621 cmdline_parse_token_string_t cmd_setfwd_set =
5622 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5623 cmdline_parse_token_string_t cmd_setfwd_fwd =
5624 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5625 cmdline_parse_token_string_t cmd_setfwd_mode =
5626 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5627 "" /* defined at init */);
5629 cmdline_parse_inst_t cmd_set_fwd_mode = {
5630 .f = cmd_set_fwd_mode_parsed,
5632 .help_str = NULL, /* defined at init */
5634 (void *)&cmd_setfwd_set,
5635 (void *)&cmd_setfwd_fwd,
5636 (void *)&cmd_setfwd_mode,
5641 static void cmd_set_fwd_mode_init(void)
5644 static char token[128];
5645 static char help[256];
5646 cmdline_parse_token_string_t *token_struct;
5648 modes = list_pkt_forwarding_modes();
5649 snprintf(help, sizeof(help), "set fwd %s: "
5650 "Set packet forwarding mode", modes);
5651 cmd_set_fwd_mode.help_str = help;
5653 /* string token separator is # */
5654 for (c = token; *modes != '\0'; modes++)
5659 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5660 token_struct->string_data.str = token;
5663 /* *** SET RETRY FORWARDING MODE *** */
5664 struct cmd_set_fwd_retry_mode_result {
5665 cmdline_fixed_string_t set;
5666 cmdline_fixed_string_t fwd;
5667 cmdline_fixed_string_t mode;
5668 cmdline_fixed_string_t retry;
5671 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5672 __attribute__((unused)) struct cmdline *cl,
5673 __attribute__((unused)) void *data)
5675 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5678 set_pkt_forwarding_mode(res->mode);
5681 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5682 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5684 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5685 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5687 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5688 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5690 "" /* defined at init */);
5691 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5692 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5695 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5696 .f = cmd_set_fwd_retry_mode_parsed,
5698 .help_str = NULL, /* defined at init */
5700 (void *)&cmd_setfwd_retry_set,
5701 (void *)&cmd_setfwd_retry_fwd,
5702 (void *)&cmd_setfwd_retry_mode,
5703 (void *)&cmd_setfwd_retry_retry,
5708 static void cmd_set_fwd_retry_mode_init(void)
5711 static char token[128];
5712 static char help[256];
5713 cmdline_parse_token_string_t *token_struct;
5715 modes = list_pkt_forwarding_retry_modes();
5716 snprintf(help, sizeof(help), "set fwd %s retry: "
5717 "Set packet forwarding mode with retry", modes);
5718 cmd_set_fwd_retry_mode.help_str = help;
5720 /* string token separator is # */
5721 for (c = token; *modes != '\0'; modes++)
5726 token_struct = (cmdline_parse_token_string_t *)
5727 cmd_set_fwd_retry_mode.tokens[2];
5728 token_struct->string_data.str = token;
5731 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5732 struct cmd_set_burst_tx_retry_result {
5733 cmdline_fixed_string_t set;
5734 cmdline_fixed_string_t burst;
5735 cmdline_fixed_string_t tx;
5736 cmdline_fixed_string_t delay;
5738 cmdline_fixed_string_t retry;
5742 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5743 __attribute__((unused)) struct cmdline *cl,
5744 __attribute__((unused)) void *data)
5746 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5748 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5749 && !strcmp(res->tx, "tx")) {
5750 if (!strcmp(res->delay, "delay"))
5751 burst_tx_delay_time = res->time;
5752 if (!strcmp(res->retry, "retry"))
5753 burst_tx_retry_num = res->retry_num;
5758 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5759 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5760 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5761 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5763 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5765 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5766 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5767 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5768 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5769 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5770 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5771 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5772 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5774 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5775 .f = cmd_set_burst_tx_retry_parsed,
5776 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5778 (void *)&cmd_set_burst_tx_retry_set,
5779 (void *)&cmd_set_burst_tx_retry_burst,
5780 (void *)&cmd_set_burst_tx_retry_tx,
5781 (void *)&cmd_set_burst_tx_retry_delay,
5782 (void *)&cmd_set_burst_tx_retry_time,
5783 (void *)&cmd_set_burst_tx_retry_retry,
5784 (void *)&cmd_set_burst_tx_retry_retry_num,
5789 /* *** SET PROMISC MODE *** */
5790 struct cmd_set_promisc_mode_result {
5791 cmdline_fixed_string_t set;
5792 cmdline_fixed_string_t promisc;
5793 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5794 uint16_t port_num; /* valid if "allports" argument == 0 */
5795 cmdline_fixed_string_t mode;
5798 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5799 __attribute__((unused)) struct cmdline *cl,
5802 struct cmd_set_promisc_mode_result *res = parsed_result;
5806 if (!strcmp(res->mode, "on"))
5813 RTE_ETH_FOREACH_DEV(i) {
5815 rte_eth_promiscuous_enable(i);
5817 rte_eth_promiscuous_disable(i);
5822 rte_eth_promiscuous_enable(res->port_num);
5824 rte_eth_promiscuous_disable(res->port_num);
5828 cmdline_parse_token_string_t cmd_setpromisc_set =
5829 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5830 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5831 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5833 cmdline_parse_token_string_t cmd_setpromisc_portall =
5834 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5836 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5837 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5839 cmdline_parse_token_string_t cmd_setpromisc_mode =
5840 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5843 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5844 .f = cmd_set_promisc_mode_parsed,
5846 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5848 (void *)&cmd_setpromisc_set,
5849 (void *)&cmd_setpromisc_promisc,
5850 (void *)&cmd_setpromisc_portall,
5851 (void *)&cmd_setpromisc_mode,
5856 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5857 .f = cmd_set_promisc_mode_parsed,
5859 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5861 (void *)&cmd_setpromisc_set,
5862 (void *)&cmd_setpromisc_promisc,
5863 (void *)&cmd_setpromisc_portnum,
5864 (void *)&cmd_setpromisc_mode,
5869 /* *** SET ALLMULTI MODE *** */
5870 struct cmd_set_allmulti_mode_result {
5871 cmdline_fixed_string_t set;
5872 cmdline_fixed_string_t allmulti;
5873 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5874 uint16_t port_num; /* valid if "allports" argument == 0 */
5875 cmdline_fixed_string_t mode;
5878 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5879 __attribute__((unused)) struct cmdline *cl,
5882 struct cmd_set_allmulti_mode_result *res = parsed_result;
5886 if (!strcmp(res->mode, "on"))
5893 RTE_ETH_FOREACH_DEV(i) {
5895 rte_eth_allmulticast_enable(i);
5897 rte_eth_allmulticast_disable(i);
5902 rte_eth_allmulticast_enable(res->port_num);
5904 rte_eth_allmulticast_disable(res->port_num);
5908 cmdline_parse_token_string_t cmd_setallmulti_set =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5910 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5911 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5913 cmdline_parse_token_string_t cmd_setallmulti_portall =
5914 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5916 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5917 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5919 cmdline_parse_token_string_t cmd_setallmulti_mode =
5920 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5923 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5924 .f = cmd_set_allmulti_mode_parsed,
5926 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5928 (void *)&cmd_setallmulti_set,
5929 (void *)&cmd_setallmulti_allmulti,
5930 (void *)&cmd_setallmulti_portall,
5931 (void *)&cmd_setallmulti_mode,
5936 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5937 .f = cmd_set_allmulti_mode_parsed,
5939 .help_str = "set allmulti <port_id> on|off: "
5940 "Set allmulti mode on port_id",
5942 (void *)&cmd_setallmulti_set,
5943 (void *)&cmd_setallmulti_allmulti,
5944 (void *)&cmd_setallmulti_portnum,
5945 (void *)&cmd_setallmulti_mode,
5950 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5951 struct cmd_link_flow_ctrl_set_result {
5952 cmdline_fixed_string_t set;
5953 cmdline_fixed_string_t flow_ctrl;
5954 cmdline_fixed_string_t rx;
5955 cmdline_fixed_string_t rx_lfc_mode;
5956 cmdline_fixed_string_t tx;
5957 cmdline_fixed_string_t tx_lfc_mode;
5958 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5959 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5960 cmdline_fixed_string_t autoneg_str;
5961 cmdline_fixed_string_t autoneg;
5962 cmdline_fixed_string_t hw_str;
5963 uint32_t high_water;
5964 cmdline_fixed_string_t lw_str;
5966 cmdline_fixed_string_t pt_str;
5967 uint16_t pause_time;
5968 cmdline_fixed_string_t xon_str;
5973 cmdline_parse_token_string_t cmd_lfc_set_set =
5974 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5976 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5977 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5978 flow_ctrl, "flow_ctrl");
5979 cmdline_parse_token_string_t cmd_lfc_set_rx =
5980 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5982 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5983 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5984 rx_lfc_mode, "on#off");
5985 cmdline_parse_token_string_t cmd_lfc_set_tx =
5986 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5988 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5989 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5990 tx_lfc_mode, "on#off");
5991 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5992 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5993 hw_str, "high_water");
5994 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5995 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5996 high_water, UINT32);
5997 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5998 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5999 lw_str, "low_water");
6000 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6001 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6003 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6004 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6005 pt_str, "pause_time");
6006 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6007 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6008 pause_time, UINT16);
6009 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6010 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6011 xon_str, "send_xon");
6012 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6013 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6015 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6016 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6017 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6018 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6019 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6020 mac_ctrl_frame_fwd_mode, "on#off");
6021 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6022 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6023 autoneg_str, "autoneg");
6024 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6025 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6027 cmdline_parse_token_num_t cmd_lfc_set_portid =
6028 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6031 /* forward declaration */
6033 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6036 cmdline_parse_inst_t cmd_link_flow_control_set = {
6037 .f = cmd_link_flow_ctrl_set_parsed,
6039 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6040 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6041 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6043 (void *)&cmd_lfc_set_set,
6044 (void *)&cmd_lfc_set_flow_ctrl,
6045 (void *)&cmd_lfc_set_rx,
6046 (void *)&cmd_lfc_set_rx_mode,
6047 (void *)&cmd_lfc_set_tx,
6048 (void *)&cmd_lfc_set_tx_mode,
6049 (void *)&cmd_lfc_set_high_water,
6050 (void *)&cmd_lfc_set_low_water,
6051 (void *)&cmd_lfc_set_pause_time,
6052 (void *)&cmd_lfc_set_send_xon,
6053 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6054 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6055 (void *)&cmd_lfc_set_autoneg_str,
6056 (void *)&cmd_lfc_set_autoneg,
6057 (void *)&cmd_lfc_set_portid,
6062 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6063 .f = cmd_link_flow_ctrl_set_parsed,
6064 .data = (void *)&cmd_link_flow_control_set_rx,
6065 .help_str = "set flow_ctrl rx on|off <port_id>: "
6066 "Change rx flow control parameter",
6068 (void *)&cmd_lfc_set_set,
6069 (void *)&cmd_lfc_set_flow_ctrl,
6070 (void *)&cmd_lfc_set_rx,
6071 (void *)&cmd_lfc_set_rx_mode,
6072 (void *)&cmd_lfc_set_portid,
6077 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6078 .f = cmd_link_flow_ctrl_set_parsed,
6079 .data = (void *)&cmd_link_flow_control_set_tx,
6080 .help_str = "set flow_ctrl tx on|off <port_id>: "
6081 "Change tx flow control parameter",
6083 (void *)&cmd_lfc_set_set,
6084 (void *)&cmd_lfc_set_flow_ctrl,
6085 (void *)&cmd_lfc_set_tx,
6086 (void *)&cmd_lfc_set_tx_mode,
6087 (void *)&cmd_lfc_set_portid,
6092 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6093 .f = cmd_link_flow_ctrl_set_parsed,
6094 .data = (void *)&cmd_link_flow_control_set_hw,
6095 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6096 "Change high water flow control parameter",
6098 (void *)&cmd_lfc_set_set,
6099 (void *)&cmd_lfc_set_flow_ctrl,
6100 (void *)&cmd_lfc_set_high_water_str,
6101 (void *)&cmd_lfc_set_high_water,
6102 (void *)&cmd_lfc_set_portid,
6107 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6108 .f = cmd_link_flow_ctrl_set_parsed,
6109 .data = (void *)&cmd_link_flow_control_set_lw,
6110 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6111 "Change low water flow control parameter",
6113 (void *)&cmd_lfc_set_set,
6114 (void *)&cmd_lfc_set_flow_ctrl,
6115 (void *)&cmd_lfc_set_low_water_str,
6116 (void *)&cmd_lfc_set_low_water,
6117 (void *)&cmd_lfc_set_portid,
6122 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6123 .f = cmd_link_flow_ctrl_set_parsed,
6124 .data = (void *)&cmd_link_flow_control_set_pt,
6125 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6126 "Change pause time flow control parameter",
6128 (void *)&cmd_lfc_set_set,
6129 (void *)&cmd_lfc_set_flow_ctrl,
6130 (void *)&cmd_lfc_set_pause_time_str,
6131 (void *)&cmd_lfc_set_pause_time,
6132 (void *)&cmd_lfc_set_portid,
6137 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6138 .f = cmd_link_flow_ctrl_set_parsed,
6139 .data = (void *)&cmd_link_flow_control_set_xon,
6140 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6141 "Change send_xon flow control parameter",
6143 (void *)&cmd_lfc_set_set,
6144 (void *)&cmd_lfc_set_flow_ctrl,
6145 (void *)&cmd_lfc_set_send_xon_str,
6146 (void *)&cmd_lfc_set_send_xon,
6147 (void *)&cmd_lfc_set_portid,
6152 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6153 .f = cmd_link_flow_ctrl_set_parsed,
6154 .data = (void *)&cmd_link_flow_control_set_macfwd,
6155 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6156 "Change mac ctrl fwd flow control parameter",
6158 (void *)&cmd_lfc_set_set,
6159 (void *)&cmd_lfc_set_flow_ctrl,
6160 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6161 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6162 (void *)&cmd_lfc_set_portid,
6167 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6168 .f = cmd_link_flow_ctrl_set_parsed,
6169 .data = (void *)&cmd_link_flow_control_set_autoneg,
6170 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6171 "Change autoneg flow control parameter",
6173 (void *)&cmd_lfc_set_set,
6174 (void *)&cmd_lfc_set_flow_ctrl,
6175 (void *)&cmd_lfc_set_autoneg_str,
6176 (void *)&cmd_lfc_set_autoneg,
6177 (void *)&cmd_lfc_set_portid,
6183 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6184 __attribute__((unused)) struct cmdline *cl,
6187 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6188 cmdline_parse_inst_t *cmd = data;
6189 struct rte_eth_fc_conf fc_conf;
6195 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6196 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6197 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6198 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6200 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6201 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6204 /* Partial command line, retrieve current configuration */
6206 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6208 printf("cannot get current flow ctrl parameters, return"
6209 "code = %d\n", ret);
6213 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6214 (fc_conf.mode == RTE_FC_FULL))
6216 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6217 (fc_conf.mode == RTE_FC_FULL))
6221 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6222 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6224 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6225 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6227 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6229 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6230 fc_conf.high_water = res->high_water;
6232 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6233 fc_conf.low_water = res->low_water;
6235 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6236 fc_conf.pause_time = res->pause_time;
6238 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6239 fc_conf.send_xon = res->send_xon;
6241 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6242 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6243 fc_conf.mac_ctrl_frame_fwd = 1;
6245 fc_conf.mac_ctrl_frame_fwd = 0;
6248 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6249 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6251 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6253 printf("bad flow contrl parameter, return code = %d \n", ret);
6256 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6257 struct cmd_priority_flow_ctrl_set_result {
6258 cmdline_fixed_string_t set;
6259 cmdline_fixed_string_t pfc_ctrl;
6260 cmdline_fixed_string_t rx;
6261 cmdline_fixed_string_t rx_pfc_mode;
6262 cmdline_fixed_string_t tx;
6263 cmdline_fixed_string_t tx_pfc_mode;
6264 uint32_t high_water;
6266 uint16_t pause_time;
6272 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6273 __attribute__((unused)) struct cmdline *cl,
6274 __attribute__((unused)) void *data)
6276 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6277 struct rte_eth_pfc_conf pfc_conf;
6278 int rx_fc_enable, tx_fc_enable;
6282 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6283 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6284 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6285 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6287 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6288 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6291 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6292 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6293 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6294 pfc_conf.fc.high_water = res->high_water;
6295 pfc_conf.fc.low_water = res->low_water;
6296 pfc_conf.fc.pause_time = res->pause_time;
6297 pfc_conf.priority = res->priority;
6299 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6301 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6304 cmdline_parse_token_string_t cmd_pfc_set_set =
6305 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6307 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6308 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6309 pfc_ctrl, "pfc_ctrl");
6310 cmdline_parse_token_string_t cmd_pfc_set_rx =
6311 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6313 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6314 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6315 rx_pfc_mode, "on#off");
6316 cmdline_parse_token_string_t cmd_pfc_set_tx =
6317 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6319 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6320 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6321 tx_pfc_mode, "on#off");
6322 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6323 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6324 high_water, UINT32);
6325 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6326 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6328 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6329 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6330 pause_time, UINT16);
6331 cmdline_parse_token_num_t cmd_pfc_set_priority =
6332 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6334 cmdline_parse_token_num_t cmd_pfc_set_portid =
6335 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6338 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6339 .f = cmd_priority_flow_ctrl_set_parsed,
6341 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6342 "<pause_time> <priority> <port_id>: "
6343 "Configure the Ethernet priority flow control",
6345 (void *)&cmd_pfc_set_set,
6346 (void *)&cmd_pfc_set_flow_ctrl,
6347 (void *)&cmd_pfc_set_rx,
6348 (void *)&cmd_pfc_set_rx_mode,
6349 (void *)&cmd_pfc_set_tx,
6350 (void *)&cmd_pfc_set_tx_mode,
6351 (void *)&cmd_pfc_set_high_water,
6352 (void *)&cmd_pfc_set_low_water,
6353 (void *)&cmd_pfc_set_pause_time,
6354 (void *)&cmd_pfc_set_priority,
6355 (void *)&cmd_pfc_set_portid,
6360 /* *** RESET CONFIGURATION *** */
6361 struct cmd_reset_result {
6362 cmdline_fixed_string_t reset;
6363 cmdline_fixed_string_t def;
6366 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6368 __attribute__((unused)) void *data)
6370 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6371 set_def_fwd_config();
6374 cmdline_parse_token_string_t cmd_reset_set =
6375 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6376 cmdline_parse_token_string_t cmd_reset_def =
6377 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6380 cmdline_parse_inst_t cmd_reset = {
6381 .f = cmd_reset_parsed,
6383 .help_str = "set default: Reset default forwarding configuration",
6385 (void *)&cmd_reset_set,
6386 (void *)&cmd_reset_def,
6391 /* *** START FORWARDING *** */
6392 struct cmd_start_result {
6393 cmdline_fixed_string_t start;
6396 cmdline_parse_token_string_t cmd_start_start =
6397 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6399 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6400 __attribute__((unused)) struct cmdline *cl,
6401 __attribute__((unused)) void *data)
6403 start_packet_forwarding(0);
6406 cmdline_parse_inst_t cmd_start = {
6407 .f = cmd_start_parsed,
6409 .help_str = "start: Start packet forwarding",
6411 (void *)&cmd_start_start,
6416 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6417 struct cmd_start_tx_first_result {
6418 cmdline_fixed_string_t start;
6419 cmdline_fixed_string_t tx_first;
6423 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6424 __attribute__((unused)) struct cmdline *cl,
6425 __attribute__((unused)) void *data)
6427 start_packet_forwarding(1);
6430 cmdline_parse_token_string_t cmd_start_tx_first_start =
6431 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6433 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6434 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6435 tx_first, "tx_first");
6437 cmdline_parse_inst_t cmd_start_tx_first = {
6438 .f = cmd_start_tx_first_parsed,
6440 .help_str = "start tx_first: Start packet forwarding, "
6441 "after sending 1 burst of packets",
6443 (void *)&cmd_start_tx_first_start,
6444 (void *)&cmd_start_tx_first_tx_first,
6449 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6450 struct cmd_start_tx_first_n_result {
6451 cmdline_fixed_string_t start;
6452 cmdline_fixed_string_t tx_first;
6457 cmd_start_tx_first_n_parsed(void *parsed_result,
6458 __attribute__((unused)) struct cmdline *cl,
6459 __attribute__((unused)) void *data)
6461 struct cmd_start_tx_first_n_result *res = parsed_result;
6463 start_packet_forwarding(res->tx_num);
6466 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6467 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6469 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6470 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6471 tx_first, "tx_first");
6472 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6473 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6476 cmdline_parse_inst_t cmd_start_tx_first_n = {
6477 .f = cmd_start_tx_first_n_parsed,
6479 .help_str = "start tx_first <num>: "
6480 "packet forwarding, after sending <num> bursts of packets",
6482 (void *)&cmd_start_tx_first_n_start,
6483 (void *)&cmd_start_tx_first_n_tx_first,
6484 (void *)&cmd_start_tx_first_n_tx_num,
6489 /* *** SET LINK UP *** */
6490 struct cmd_set_link_up_result {
6491 cmdline_fixed_string_t set;
6492 cmdline_fixed_string_t link_up;
6493 cmdline_fixed_string_t port;
6497 cmdline_parse_token_string_t cmd_set_link_up_set =
6498 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6499 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6500 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6502 cmdline_parse_token_string_t cmd_set_link_up_port =
6503 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6504 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6505 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6507 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6508 __attribute__((unused)) struct cmdline *cl,
6509 __attribute__((unused)) void *data)
6511 struct cmd_set_link_up_result *res = parsed_result;
6512 dev_set_link_up(res->port_id);
6515 cmdline_parse_inst_t cmd_set_link_up = {
6516 .f = cmd_set_link_up_parsed,
6518 .help_str = "set link-up port <port id>",
6520 (void *)&cmd_set_link_up_set,
6521 (void *)&cmd_set_link_up_link_up,
6522 (void *)&cmd_set_link_up_port,
6523 (void *)&cmd_set_link_up_port_id,
6528 /* *** SET LINK DOWN *** */
6529 struct cmd_set_link_down_result {
6530 cmdline_fixed_string_t set;
6531 cmdline_fixed_string_t link_down;
6532 cmdline_fixed_string_t port;
6536 cmdline_parse_token_string_t cmd_set_link_down_set =
6537 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6538 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6539 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6541 cmdline_parse_token_string_t cmd_set_link_down_port =
6542 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6543 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6544 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6546 static void cmd_set_link_down_parsed(
6547 __attribute__((unused)) void *parsed_result,
6548 __attribute__((unused)) struct cmdline *cl,
6549 __attribute__((unused)) void *data)
6551 struct cmd_set_link_down_result *res = parsed_result;
6552 dev_set_link_down(res->port_id);
6555 cmdline_parse_inst_t cmd_set_link_down = {
6556 .f = cmd_set_link_down_parsed,
6558 .help_str = "set link-down port <port id>",
6560 (void *)&cmd_set_link_down_set,
6561 (void *)&cmd_set_link_down_link_down,
6562 (void *)&cmd_set_link_down_port,
6563 (void *)&cmd_set_link_down_port_id,
6568 /* *** SHOW CFG *** */
6569 struct cmd_showcfg_result {
6570 cmdline_fixed_string_t show;
6571 cmdline_fixed_string_t cfg;
6572 cmdline_fixed_string_t what;
6575 static void cmd_showcfg_parsed(void *parsed_result,
6576 __attribute__((unused)) struct cmdline *cl,
6577 __attribute__((unused)) void *data)
6579 struct cmd_showcfg_result *res = parsed_result;
6580 if (!strcmp(res->what, "rxtx"))
6581 rxtx_config_display();
6582 else if (!strcmp(res->what, "cores"))
6583 fwd_lcores_config_display();
6584 else if (!strcmp(res->what, "fwd"))
6585 pkt_fwd_config_display(&cur_fwd_config);
6586 else if (!strcmp(res->what, "txpkts"))
6587 show_tx_pkt_segments();
6590 cmdline_parse_token_string_t cmd_showcfg_show =
6591 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6592 cmdline_parse_token_string_t cmd_showcfg_port =
6593 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6594 cmdline_parse_token_string_t cmd_showcfg_what =
6595 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6596 "rxtx#cores#fwd#txpkts");
6598 cmdline_parse_inst_t cmd_showcfg = {
6599 .f = cmd_showcfg_parsed,
6601 .help_str = "show config rxtx|cores|fwd|txpkts",
6603 (void *)&cmd_showcfg_show,
6604 (void *)&cmd_showcfg_port,
6605 (void *)&cmd_showcfg_what,
6610 /* *** SHOW ALL PORT INFO *** */
6611 struct cmd_showportall_result {
6612 cmdline_fixed_string_t show;
6613 cmdline_fixed_string_t port;
6614 cmdline_fixed_string_t what;
6615 cmdline_fixed_string_t all;
6618 static void cmd_showportall_parsed(void *parsed_result,
6619 __attribute__((unused)) struct cmdline *cl,
6620 __attribute__((unused)) void *data)
6624 struct cmd_showportall_result *res = parsed_result;
6625 if (!strcmp(res->show, "clear")) {
6626 if (!strcmp(res->what, "stats"))
6627 RTE_ETH_FOREACH_DEV(i)
6629 else if (!strcmp(res->what, "xstats"))
6630 RTE_ETH_FOREACH_DEV(i)
6631 nic_xstats_clear(i);
6632 } else if (!strcmp(res->what, "info"))
6633 RTE_ETH_FOREACH_DEV(i)
6634 port_infos_display(i);
6635 else if (!strcmp(res->what, "stats"))
6636 RTE_ETH_FOREACH_DEV(i)
6637 nic_stats_display(i);
6638 else if (!strcmp(res->what, "xstats"))
6639 RTE_ETH_FOREACH_DEV(i)
6640 nic_xstats_display(i);
6641 else if (!strcmp(res->what, "fdir"))
6642 RTE_ETH_FOREACH_DEV(i)
6644 else if (!strcmp(res->what, "stat_qmap"))
6645 RTE_ETH_FOREACH_DEV(i)
6646 nic_stats_mapping_display(i);
6647 else if (!strcmp(res->what, "dcb_tc"))
6648 RTE_ETH_FOREACH_DEV(i)
6649 port_dcb_info_display(i);
6650 else if (!strcmp(res->what, "cap"))
6651 RTE_ETH_FOREACH_DEV(i)
6652 port_offload_cap_display(i);
6655 cmdline_parse_token_string_t cmd_showportall_show =
6656 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6658 cmdline_parse_token_string_t cmd_showportall_port =
6659 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6660 cmdline_parse_token_string_t cmd_showportall_what =
6661 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6662 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6663 cmdline_parse_token_string_t cmd_showportall_all =
6664 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6665 cmdline_parse_inst_t cmd_showportall = {
6666 .f = cmd_showportall_parsed,
6668 .help_str = "show|clear port "
6669 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6671 (void *)&cmd_showportall_show,
6672 (void *)&cmd_showportall_port,
6673 (void *)&cmd_showportall_what,
6674 (void *)&cmd_showportall_all,
6679 /* *** SHOW PORT INFO *** */
6680 struct cmd_showport_result {
6681 cmdline_fixed_string_t show;
6682 cmdline_fixed_string_t port;
6683 cmdline_fixed_string_t what;
6687 static void cmd_showport_parsed(void *parsed_result,
6688 __attribute__((unused)) struct cmdline *cl,
6689 __attribute__((unused)) void *data)
6691 struct cmd_showport_result *res = parsed_result;
6692 if (!strcmp(res->show, "clear")) {
6693 if (!strcmp(res->what, "stats"))
6694 nic_stats_clear(res->portnum);
6695 else if (!strcmp(res->what, "xstats"))
6696 nic_xstats_clear(res->portnum);
6697 } else if (!strcmp(res->what, "info"))
6698 port_infos_display(res->portnum);
6699 else if (!strcmp(res->what, "stats"))
6700 nic_stats_display(res->portnum);
6701 else if (!strcmp(res->what, "xstats"))
6702 nic_xstats_display(res->portnum);
6703 else if (!strcmp(res->what, "fdir"))
6704 fdir_get_infos(res->portnum);
6705 else if (!strcmp(res->what, "stat_qmap"))
6706 nic_stats_mapping_display(res->portnum);
6707 else if (!strcmp(res->what, "dcb_tc"))
6708 port_dcb_info_display(res->portnum);
6709 else if (!strcmp(res->what, "cap"))
6710 port_offload_cap_display(res->portnum);
6713 cmdline_parse_token_string_t cmd_showport_show =
6714 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6716 cmdline_parse_token_string_t cmd_showport_port =
6717 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6718 cmdline_parse_token_string_t cmd_showport_what =
6719 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6720 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6721 cmdline_parse_token_num_t cmd_showport_portnum =
6722 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6724 cmdline_parse_inst_t cmd_showport = {
6725 .f = cmd_showport_parsed,
6727 .help_str = "show|clear port "
6728 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6731 (void *)&cmd_showport_show,
6732 (void *)&cmd_showport_port,
6733 (void *)&cmd_showport_what,
6734 (void *)&cmd_showport_portnum,
6739 /* *** SHOW QUEUE INFO *** */
6740 struct cmd_showqueue_result {
6741 cmdline_fixed_string_t show;
6742 cmdline_fixed_string_t type;
6743 cmdline_fixed_string_t what;
6749 cmd_showqueue_parsed(void *parsed_result,
6750 __attribute__((unused)) struct cmdline *cl,
6751 __attribute__((unused)) void *data)
6753 struct cmd_showqueue_result *res = parsed_result;
6755 if (!strcmp(res->type, "rxq"))
6756 rx_queue_infos_display(res->portnum, res->queuenum);
6757 else if (!strcmp(res->type, "txq"))
6758 tx_queue_infos_display(res->portnum, res->queuenum);
6761 cmdline_parse_token_string_t cmd_showqueue_show =
6762 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6763 cmdline_parse_token_string_t cmd_showqueue_type =
6764 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6765 cmdline_parse_token_string_t cmd_showqueue_what =
6766 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6767 cmdline_parse_token_num_t cmd_showqueue_portnum =
6768 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6769 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6770 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6772 cmdline_parse_inst_t cmd_showqueue = {
6773 .f = cmd_showqueue_parsed,
6775 .help_str = "show rxq|txq info <port_id> <queue_id>",
6777 (void *)&cmd_showqueue_show,
6778 (void *)&cmd_showqueue_type,
6779 (void *)&cmd_showqueue_what,
6780 (void *)&cmd_showqueue_portnum,
6781 (void *)&cmd_showqueue_queuenum,
6786 /* *** READ PORT REGISTER *** */
6787 struct cmd_read_reg_result {
6788 cmdline_fixed_string_t read;
6789 cmdline_fixed_string_t reg;
6795 cmd_read_reg_parsed(void *parsed_result,
6796 __attribute__((unused)) struct cmdline *cl,
6797 __attribute__((unused)) void *data)
6799 struct cmd_read_reg_result *res = parsed_result;
6800 port_reg_display(res->port_id, res->reg_off);
6803 cmdline_parse_token_string_t cmd_read_reg_read =
6804 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6805 cmdline_parse_token_string_t cmd_read_reg_reg =
6806 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6807 cmdline_parse_token_num_t cmd_read_reg_port_id =
6808 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6809 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6810 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6812 cmdline_parse_inst_t cmd_read_reg = {
6813 .f = cmd_read_reg_parsed,
6815 .help_str = "read reg <port_id> <reg_off>",
6817 (void *)&cmd_read_reg_read,
6818 (void *)&cmd_read_reg_reg,
6819 (void *)&cmd_read_reg_port_id,
6820 (void *)&cmd_read_reg_reg_off,
6825 /* *** READ PORT REGISTER BIT FIELD *** */
6826 struct cmd_read_reg_bit_field_result {
6827 cmdline_fixed_string_t read;
6828 cmdline_fixed_string_t regfield;
6836 cmd_read_reg_bit_field_parsed(void *parsed_result,
6837 __attribute__((unused)) struct cmdline *cl,
6838 __attribute__((unused)) void *data)
6840 struct cmd_read_reg_bit_field_result *res = parsed_result;
6841 port_reg_bit_field_display(res->port_id, res->reg_off,
6842 res->bit1_pos, res->bit2_pos);
6845 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6846 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6848 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6849 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6850 regfield, "regfield");
6851 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6852 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6854 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6855 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6857 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6858 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6860 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6861 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6864 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6865 .f = cmd_read_reg_bit_field_parsed,
6867 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6868 "Read register bit field between bit_x and bit_y included",
6870 (void *)&cmd_read_reg_bit_field_read,
6871 (void *)&cmd_read_reg_bit_field_regfield,
6872 (void *)&cmd_read_reg_bit_field_port_id,
6873 (void *)&cmd_read_reg_bit_field_reg_off,
6874 (void *)&cmd_read_reg_bit_field_bit1_pos,
6875 (void *)&cmd_read_reg_bit_field_bit2_pos,
6880 /* *** READ PORT REGISTER BIT *** */
6881 struct cmd_read_reg_bit_result {
6882 cmdline_fixed_string_t read;
6883 cmdline_fixed_string_t regbit;
6890 cmd_read_reg_bit_parsed(void *parsed_result,
6891 __attribute__((unused)) struct cmdline *cl,
6892 __attribute__((unused)) void *data)
6894 struct cmd_read_reg_bit_result *res = parsed_result;
6895 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6898 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6899 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6900 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6901 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6903 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6904 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6905 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6906 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6907 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6908 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6910 cmdline_parse_inst_t cmd_read_reg_bit = {
6911 .f = cmd_read_reg_bit_parsed,
6913 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6915 (void *)&cmd_read_reg_bit_read,
6916 (void *)&cmd_read_reg_bit_regbit,
6917 (void *)&cmd_read_reg_bit_port_id,
6918 (void *)&cmd_read_reg_bit_reg_off,
6919 (void *)&cmd_read_reg_bit_bit_pos,
6924 /* *** WRITE PORT REGISTER *** */
6925 struct cmd_write_reg_result {
6926 cmdline_fixed_string_t write;
6927 cmdline_fixed_string_t reg;
6934 cmd_write_reg_parsed(void *parsed_result,
6935 __attribute__((unused)) struct cmdline *cl,
6936 __attribute__((unused)) void *data)
6938 struct cmd_write_reg_result *res = parsed_result;
6939 port_reg_set(res->port_id, res->reg_off, res->value);
6942 cmdline_parse_token_string_t cmd_write_reg_write =
6943 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6944 cmdline_parse_token_string_t cmd_write_reg_reg =
6945 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6946 cmdline_parse_token_num_t cmd_write_reg_port_id =
6947 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6948 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6949 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6950 cmdline_parse_token_num_t cmd_write_reg_value =
6951 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6953 cmdline_parse_inst_t cmd_write_reg = {
6954 .f = cmd_write_reg_parsed,
6956 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6958 (void *)&cmd_write_reg_write,
6959 (void *)&cmd_write_reg_reg,
6960 (void *)&cmd_write_reg_port_id,
6961 (void *)&cmd_write_reg_reg_off,
6962 (void *)&cmd_write_reg_value,
6967 /* *** WRITE PORT REGISTER BIT FIELD *** */
6968 struct cmd_write_reg_bit_field_result {
6969 cmdline_fixed_string_t write;
6970 cmdline_fixed_string_t regfield;
6979 cmd_write_reg_bit_field_parsed(void *parsed_result,
6980 __attribute__((unused)) struct cmdline *cl,
6981 __attribute__((unused)) void *data)
6983 struct cmd_write_reg_bit_field_result *res = parsed_result;
6984 port_reg_bit_field_set(res->port_id, res->reg_off,
6985 res->bit1_pos, res->bit2_pos, res->value);
6988 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6989 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6991 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6992 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6993 regfield, "regfield");
6994 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6995 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6997 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6998 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7000 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7001 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7003 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7004 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7006 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7007 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7010 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7011 .f = cmd_write_reg_bit_field_parsed,
7013 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7015 "Set register bit field between bit_x and bit_y included",
7017 (void *)&cmd_write_reg_bit_field_write,
7018 (void *)&cmd_write_reg_bit_field_regfield,
7019 (void *)&cmd_write_reg_bit_field_port_id,
7020 (void *)&cmd_write_reg_bit_field_reg_off,
7021 (void *)&cmd_write_reg_bit_field_bit1_pos,
7022 (void *)&cmd_write_reg_bit_field_bit2_pos,
7023 (void *)&cmd_write_reg_bit_field_value,
7028 /* *** WRITE PORT REGISTER BIT *** */
7029 struct cmd_write_reg_bit_result {
7030 cmdline_fixed_string_t write;
7031 cmdline_fixed_string_t regbit;
7039 cmd_write_reg_bit_parsed(void *parsed_result,
7040 __attribute__((unused)) struct cmdline *cl,
7041 __attribute__((unused)) void *data)
7043 struct cmd_write_reg_bit_result *res = parsed_result;
7044 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7047 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7048 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7050 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7051 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7053 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7054 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7055 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7056 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7057 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7058 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7059 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7060 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7062 cmdline_parse_inst_t cmd_write_reg_bit = {
7063 .f = cmd_write_reg_bit_parsed,
7065 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7068 (void *)&cmd_write_reg_bit_write,
7069 (void *)&cmd_write_reg_bit_regbit,
7070 (void *)&cmd_write_reg_bit_port_id,
7071 (void *)&cmd_write_reg_bit_reg_off,
7072 (void *)&cmd_write_reg_bit_bit_pos,
7073 (void *)&cmd_write_reg_bit_value,
7078 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7079 struct cmd_read_rxd_txd_result {
7080 cmdline_fixed_string_t read;
7081 cmdline_fixed_string_t rxd_txd;
7088 cmd_read_rxd_txd_parsed(void *parsed_result,
7089 __attribute__((unused)) struct cmdline *cl,
7090 __attribute__((unused)) void *data)
7092 struct cmd_read_rxd_txd_result *res = parsed_result;
7094 if (!strcmp(res->rxd_txd, "rxd"))
7095 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7096 else if (!strcmp(res->rxd_txd, "txd"))
7097 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7100 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7101 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7102 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7103 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7105 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7106 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7107 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7108 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7109 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7110 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7112 cmdline_parse_inst_t cmd_read_rxd_txd = {
7113 .f = cmd_read_rxd_txd_parsed,
7115 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7117 (void *)&cmd_read_rxd_txd_read,
7118 (void *)&cmd_read_rxd_txd_rxd_txd,
7119 (void *)&cmd_read_rxd_txd_port_id,
7120 (void *)&cmd_read_rxd_txd_queue_id,
7121 (void *)&cmd_read_rxd_txd_desc_id,
7127 struct cmd_quit_result {
7128 cmdline_fixed_string_t quit;
7131 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7133 __attribute__((unused)) void *data)
7139 cmdline_parse_token_string_t cmd_quit_quit =
7140 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7142 cmdline_parse_inst_t cmd_quit = {
7143 .f = cmd_quit_parsed,
7145 .help_str = "quit: Exit application",
7147 (void *)&cmd_quit_quit,
7152 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7153 struct cmd_mac_addr_result {
7154 cmdline_fixed_string_t mac_addr_cmd;
7155 cmdline_fixed_string_t what;
7157 struct ether_addr address;
7160 static void cmd_mac_addr_parsed(void *parsed_result,
7161 __attribute__((unused)) struct cmdline *cl,
7162 __attribute__((unused)) void *data)
7164 struct cmd_mac_addr_result *res = parsed_result;
7167 if (strcmp(res->what, "add") == 0)
7168 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7169 else if (strcmp(res->what, "set") == 0)
7170 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7173 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7175 /* check the return value and print it if is < 0 */
7177 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7181 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7182 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7184 cmdline_parse_token_string_t cmd_mac_addr_what =
7185 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7187 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7188 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7190 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7191 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7193 cmdline_parse_inst_t cmd_mac_addr = {
7194 .f = cmd_mac_addr_parsed,
7196 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7197 "Add/Remove/Set MAC address on port_id",
7199 (void *)&cmd_mac_addr_cmd,
7200 (void *)&cmd_mac_addr_what,
7201 (void *)&cmd_mac_addr_portnum,
7202 (void *)&cmd_mac_addr_addr,
7207 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7208 struct cmd_eth_peer_result {
7209 cmdline_fixed_string_t set;
7210 cmdline_fixed_string_t eth_peer;
7212 cmdline_fixed_string_t peer_addr;
7215 static void cmd_set_eth_peer_parsed(void *parsed_result,
7216 __attribute__((unused)) struct cmdline *cl,
7217 __attribute__((unused)) void *data)
7219 struct cmd_eth_peer_result *res = parsed_result;
7221 if (test_done == 0) {
7222 printf("Please stop forwarding first\n");
7225 if (!strcmp(res->eth_peer, "eth-peer")) {
7226 set_fwd_eth_peer(res->port_id, res->peer_addr);
7230 cmdline_parse_token_string_t cmd_eth_peer_set =
7231 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7232 cmdline_parse_token_string_t cmd_eth_peer =
7233 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7234 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7235 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7236 cmdline_parse_token_string_t cmd_eth_peer_addr =
7237 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7239 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7240 .f = cmd_set_eth_peer_parsed,
7242 .help_str = "set eth-peer <port_id> <peer_mac>",
7244 (void *)&cmd_eth_peer_set,
7245 (void *)&cmd_eth_peer,
7246 (void *)&cmd_eth_peer_port_id,
7247 (void *)&cmd_eth_peer_addr,
7252 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7253 struct cmd_set_qmap_result {
7254 cmdline_fixed_string_t set;
7255 cmdline_fixed_string_t qmap;
7256 cmdline_fixed_string_t what;
7263 cmd_set_qmap_parsed(void *parsed_result,
7264 __attribute__((unused)) struct cmdline *cl,
7265 __attribute__((unused)) void *data)
7267 struct cmd_set_qmap_result *res = parsed_result;
7268 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7270 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7273 cmdline_parse_token_string_t cmd_setqmap_set =
7274 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7276 cmdline_parse_token_string_t cmd_setqmap_qmap =
7277 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7279 cmdline_parse_token_string_t cmd_setqmap_what =
7280 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7282 cmdline_parse_token_num_t cmd_setqmap_portid =
7283 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7285 cmdline_parse_token_num_t cmd_setqmap_queueid =
7286 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7288 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7289 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7292 cmdline_parse_inst_t cmd_set_qmap = {
7293 .f = cmd_set_qmap_parsed,
7295 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7296 "Set statistics mapping value on tx|rx queue_id of port_id",
7298 (void *)&cmd_setqmap_set,
7299 (void *)&cmd_setqmap_qmap,
7300 (void *)&cmd_setqmap_what,
7301 (void *)&cmd_setqmap_portid,
7302 (void *)&cmd_setqmap_queueid,
7303 (void *)&cmd_setqmap_mapvalue,
7308 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7309 struct cmd_set_xstats_hide_zero_result {
7310 cmdline_fixed_string_t keyword;
7311 cmdline_fixed_string_t name;
7312 cmdline_fixed_string_t on_off;
7316 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7317 __attribute__((unused)) struct cmdline *cl,
7318 __attribute__((unused)) void *data)
7320 struct cmd_set_xstats_hide_zero_result *res;
7321 uint16_t on_off = 0;
7323 res = parsed_result;
7324 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7325 set_xstats_hide_zero(on_off);
7328 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7329 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7331 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7332 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7333 name, "xstats-hide-zero");
7334 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7335 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7338 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7339 .f = cmd_set_xstats_hide_zero_parsed,
7341 .help_str = "set xstats-hide-zero on|off",
7343 (void *)&cmd_set_xstats_hide_zero_keyword,
7344 (void *)&cmd_set_xstats_hide_zero_name,
7345 (void *)&cmd_set_xstats_hide_zero_on_off,
7350 /* *** CONFIGURE UNICAST HASH TABLE *** */
7351 struct cmd_set_uc_hash_table {
7352 cmdline_fixed_string_t set;
7353 cmdline_fixed_string_t port;
7355 cmdline_fixed_string_t what;
7356 struct ether_addr address;
7357 cmdline_fixed_string_t mode;
7361 cmd_set_uc_hash_parsed(void *parsed_result,
7362 __attribute__((unused)) struct cmdline *cl,
7363 __attribute__((unused)) void *data)
7366 struct cmd_set_uc_hash_table *res = parsed_result;
7368 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7370 if (strcmp(res->what, "uta") == 0)
7371 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7372 &res->address,(uint8_t)is_on);
7374 printf("bad unicast hash table parameter, return code = %d \n", ret);
7378 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7379 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7381 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7382 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7384 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7385 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7387 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7388 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7390 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7391 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7393 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7394 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7397 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7398 .f = cmd_set_uc_hash_parsed,
7400 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7402 (void *)&cmd_set_uc_hash_set,
7403 (void *)&cmd_set_uc_hash_port,
7404 (void *)&cmd_set_uc_hash_portid,
7405 (void *)&cmd_set_uc_hash_what,
7406 (void *)&cmd_set_uc_hash_mac,
7407 (void *)&cmd_set_uc_hash_mode,
7412 struct cmd_set_uc_all_hash_table {
7413 cmdline_fixed_string_t set;
7414 cmdline_fixed_string_t port;
7416 cmdline_fixed_string_t what;
7417 cmdline_fixed_string_t value;
7418 cmdline_fixed_string_t mode;
7422 cmd_set_uc_all_hash_parsed(void *parsed_result,
7423 __attribute__((unused)) struct cmdline *cl,
7424 __attribute__((unused)) void *data)
7427 struct cmd_set_uc_all_hash_table *res = parsed_result;
7429 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7431 if ((strcmp(res->what, "uta") == 0) &&
7432 (strcmp(res->value, "all") == 0))
7433 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7435 printf("bad unicast hash table parameter,"
7436 "return code = %d \n", ret);
7439 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7440 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7442 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7443 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7445 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7446 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7448 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7449 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7451 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7452 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7454 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7455 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7458 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7459 .f = cmd_set_uc_all_hash_parsed,
7461 .help_str = "set port <port_id> uta all on|off",
7463 (void *)&cmd_set_uc_all_hash_set,
7464 (void *)&cmd_set_uc_all_hash_port,
7465 (void *)&cmd_set_uc_all_hash_portid,
7466 (void *)&cmd_set_uc_all_hash_what,
7467 (void *)&cmd_set_uc_all_hash_value,
7468 (void *)&cmd_set_uc_all_hash_mode,
7473 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7474 struct cmd_set_vf_macvlan_filter {
7475 cmdline_fixed_string_t set;
7476 cmdline_fixed_string_t port;
7478 cmdline_fixed_string_t vf;
7480 struct ether_addr address;
7481 cmdline_fixed_string_t filter_type;
7482 cmdline_fixed_string_t mode;
7486 cmd_set_vf_macvlan_parsed(void *parsed_result,
7487 __attribute__((unused)) struct cmdline *cl,
7488 __attribute__((unused)) void *data)
7491 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7492 struct rte_eth_mac_filter filter;
7494 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7496 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7498 /* set VF MAC filter */
7502 filter.dst_id = res->vf_id;
7504 if (!strcmp(res->filter_type, "exact-mac"))
7505 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7506 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7507 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7508 else if (!strcmp(res->filter_type, "hashmac"))
7509 filter.filter_type = RTE_MAC_HASH_MATCH;
7510 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7511 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7513 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7516 ret = rte_eth_dev_filter_ctrl(res->port_id,
7517 RTE_ETH_FILTER_MACVLAN,
7521 ret = rte_eth_dev_filter_ctrl(res->port_id,
7522 RTE_ETH_FILTER_MACVLAN,
7523 RTE_ETH_FILTER_DELETE,
7527 printf("bad set MAC hash parameter, return code = %d\n", ret);
7531 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7532 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7534 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7535 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7537 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7538 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7540 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7541 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7543 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7544 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7546 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7547 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7549 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7550 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7551 filter_type, "exact-mac#exact-mac-vlan"
7552 "#hashmac#hashmac-vlan");
7553 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7554 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7557 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7558 .f = cmd_set_vf_macvlan_parsed,
7560 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7561 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7562 "Exact match rule: exact match of MAC or MAC and VLAN; "
7563 "hash match rule: hash match of MAC and exact match of VLAN",
7565 (void *)&cmd_set_vf_macvlan_set,
7566 (void *)&cmd_set_vf_macvlan_port,
7567 (void *)&cmd_set_vf_macvlan_portid,
7568 (void *)&cmd_set_vf_macvlan_vf,
7569 (void *)&cmd_set_vf_macvlan_vf_id,
7570 (void *)&cmd_set_vf_macvlan_mac,
7571 (void *)&cmd_set_vf_macvlan_filter_type,
7572 (void *)&cmd_set_vf_macvlan_mode,
7577 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7578 struct cmd_set_vf_traffic {
7579 cmdline_fixed_string_t set;
7580 cmdline_fixed_string_t port;
7582 cmdline_fixed_string_t vf;
7584 cmdline_fixed_string_t what;
7585 cmdline_fixed_string_t mode;
7589 cmd_set_vf_traffic_parsed(void *parsed_result,
7590 __attribute__((unused)) struct cmdline *cl,
7591 __attribute__((unused)) void *data)
7593 struct cmd_set_vf_traffic *res = parsed_result;
7594 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7595 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7597 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7600 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7601 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7603 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7604 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7606 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7607 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7609 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7610 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7612 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7613 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7615 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7616 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7618 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7619 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7622 cmdline_parse_inst_t cmd_set_vf_traffic = {
7623 .f = cmd_set_vf_traffic_parsed,
7625 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7627 (void *)&cmd_setvf_traffic_set,
7628 (void *)&cmd_setvf_traffic_port,
7629 (void *)&cmd_setvf_traffic_portid,
7630 (void *)&cmd_setvf_traffic_vf,
7631 (void *)&cmd_setvf_traffic_vfid,
7632 (void *)&cmd_setvf_traffic_what,
7633 (void *)&cmd_setvf_traffic_mode,
7638 /* *** CONFIGURE VF RECEIVE MODE *** */
7639 struct cmd_set_vf_rxmode {
7640 cmdline_fixed_string_t set;
7641 cmdline_fixed_string_t port;
7643 cmdline_fixed_string_t vf;
7645 cmdline_fixed_string_t what;
7646 cmdline_fixed_string_t mode;
7647 cmdline_fixed_string_t on;
7651 cmd_set_vf_rxmode_parsed(void *parsed_result,
7652 __attribute__((unused)) struct cmdline *cl,
7653 __attribute__((unused)) void *data)
7656 uint16_t rx_mode = 0;
7657 struct cmd_set_vf_rxmode *res = parsed_result;
7659 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7660 if (!strcmp(res->what,"rxmode")) {
7661 if (!strcmp(res->mode, "AUPE"))
7662 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7663 else if (!strcmp(res->mode, "ROPE"))
7664 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7665 else if (!strcmp(res->mode, "BAM"))
7666 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7667 else if (!strncmp(res->mode, "MPE",3))
7668 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7671 RTE_SET_USED(is_on);
7673 #ifdef RTE_LIBRTE_IXGBE_PMD
7674 if (ret == -ENOTSUP)
7675 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7676 rx_mode, (uint8_t)is_on);
7678 #ifdef RTE_LIBRTE_BNXT_PMD
7679 if (ret == -ENOTSUP)
7680 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7681 rx_mode, (uint8_t)is_on);
7684 printf("bad VF receive mode parameter, return code = %d \n",
7688 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7689 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7691 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7692 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7694 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7695 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7697 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7698 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7700 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7701 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7703 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7704 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7706 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7707 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7708 mode, "AUPE#ROPE#BAM#MPE");
7709 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7710 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7713 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7714 .f = cmd_set_vf_rxmode_parsed,
7716 .help_str = "set port <port_id> vf <vf_id> rxmode "
7717 "AUPE|ROPE|BAM|MPE on|off",
7719 (void *)&cmd_set_vf_rxmode_set,
7720 (void *)&cmd_set_vf_rxmode_port,
7721 (void *)&cmd_set_vf_rxmode_portid,
7722 (void *)&cmd_set_vf_rxmode_vf,
7723 (void *)&cmd_set_vf_rxmode_vfid,
7724 (void *)&cmd_set_vf_rxmode_what,
7725 (void *)&cmd_set_vf_rxmode_mode,
7726 (void *)&cmd_set_vf_rxmode_on,
7731 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7732 struct cmd_vf_mac_addr_result {
7733 cmdline_fixed_string_t mac_addr_cmd;
7734 cmdline_fixed_string_t what;
7735 cmdline_fixed_string_t port;
7737 cmdline_fixed_string_t vf;
7739 struct ether_addr address;
7742 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7743 __attribute__((unused)) struct cmdline *cl,
7744 __attribute__((unused)) void *data)
7746 struct cmd_vf_mac_addr_result *res = parsed_result;
7749 if (strcmp(res->what, "add") != 0)
7752 #ifdef RTE_LIBRTE_I40E_PMD
7753 if (ret == -ENOTSUP)
7754 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7757 #ifdef RTE_LIBRTE_BNXT_PMD
7758 if (ret == -ENOTSUP)
7759 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7764 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7768 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7769 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7770 mac_addr_cmd,"mac_addr");
7771 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7772 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7774 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7775 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7777 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7778 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7780 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7781 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7783 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7784 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7786 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7787 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7790 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7791 .f = cmd_vf_mac_addr_parsed,
7793 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7794 "Add MAC address filtering for a VF on port_id",
7796 (void *)&cmd_vf_mac_addr_cmd,
7797 (void *)&cmd_vf_mac_addr_what,
7798 (void *)&cmd_vf_mac_addr_port,
7799 (void *)&cmd_vf_mac_addr_portnum,
7800 (void *)&cmd_vf_mac_addr_vf,
7801 (void *)&cmd_vf_mac_addr_vfnum,
7802 (void *)&cmd_vf_mac_addr_addr,
7807 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7808 struct cmd_vf_rx_vlan_filter {
7809 cmdline_fixed_string_t rx_vlan;
7810 cmdline_fixed_string_t what;
7812 cmdline_fixed_string_t port;
7814 cmdline_fixed_string_t vf;
7819 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7820 __attribute__((unused)) struct cmdline *cl,
7821 __attribute__((unused)) void *data)
7823 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7826 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7828 #ifdef RTE_LIBRTE_IXGBE_PMD
7829 if (ret == -ENOTSUP)
7830 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7831 res->vlan_id, res->vf_mask, is_add);
7833 #ifdef RTE_LIBRTE_I40E_PMD
7834 if (ret == -ENOTSUP)
7835 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7836 res->vlan_id, res->vf_mask, is_add);
7838 #ifdef RTE_LIBRTE_BNXT_PMD
7839 if (ret == -ENOTSUP)
7840 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7841 res->vlan_id, res->vf_mask, is_add);
7848 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7849 res->vlan_id, res->vf_mask);
7852 printf("invalid port_id %d\n", res->port_id);
7855 printf("function not implemented or supported\n");
7858 printf("programming error: (%s)\n", strerror(-ret));
7862 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7863 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7864 rx_vlan, "rx_vlan");
7865 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7866 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7868 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7869 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7871 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7872 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7874 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7875 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7877 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7878 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7880 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7881 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7884 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7885 .f = cmd_vf_rx_vlan_filter_parsed,
7887 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7888 "(vf_mask = hexadecimal VF mask)",
7890 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7891 (void *)&cmd_vf_rx_vlan_filter_what,
7892 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7893 (void *)&cmd_vf_rx_vlan_filter_port,
7894 (void *)&cmd_vf_rx_vlan_filter_portid,
7895 (void *)&cmd_vf_rx_vlan_filter_vf,
7896 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7901 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7902 struct cmd_queue_rate_limit_result {
7903 cmdline_fixed_string_t set;
7904 cmdline_fixed_string_t port;
7906 cmdline_fixed_string_t queue;
7908 cmdline_fixed_string_t rate;
7912 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7913 __attribute__((unused)) struct cmdline *cl,
7914 __attribute__((unused)) void *data)
7916 struct cmd_queue_rate_limit_result *res = parsed_result;
7919 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7920 && (strcmp(res->queue, "queue") == 0)
7921 && (strcmp(res->rate, "rate") == 0))
7922 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7925 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7929 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7930 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7932 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7933 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7935 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7936 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7938 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7939 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7941 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7942 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7944 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7945 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7947 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7948 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7951 cmdline_parse_inst_t cmd_queue_rate_limit = {
7952 .f = cmd_queue_rate_limit_parsed,
7954 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7955 "Set rate limit for a queue on port_id",
7957 (void *)&cmd_queue_rate_limit_set,
7958 (void *)&cmd_queue_rate_limit_port,
7959 (void *)&cmd_queue_rate_limit_portnum,
7960 (void *)&cmd_queue_rate_limit_queue,
7961 (void *)&cmd_queue_rate_limit_queuenum,
7962 (void *)&cmd_queue_rate_limit_rate,
7963 (void *)&cmd_queue_rate_limit_ratenum,
7968 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7969 struct cmd_vf_rate_limit_result {
7970 cmdline_fixed_string_t set;
7971 cmdline_fixed_string_t port;
7973 cmdline_fixed_string_t vf;
7975 cmdline_fixed_string_t rate;
7977 cmdline_fixed_string_t q_msk;
7981 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7982 __attribute__((unused)) struct cmdline *cl,
7983 __attribute__((unused)) void *data)
7985 struct cmd_vf_rate_limit_result *res = parsed_result;
7988 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7989 && (strcmp(res->vf, "vf") == 0)
7990 && (strcmp(res->rate, "rate") == 0)
7991 && (strcmp(res->q_msk, "queue_mask") == 0))
7992 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7993 res->rate_num, res->q_msk_val);
7995 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7999 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8000 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8002 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8003 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8005 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8006 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8008 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8009 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8011 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8012 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8014 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8015 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8017 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8018 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8020 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8021 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8022 q_msk, "queue_mask");
8023 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8024 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8027 cmdline_parse_inst_t cmd_vf_rate_limit = {
8028 .f = cmd_vf_rate_limit_parsed,
8030 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8031 "queue_mask <queue_mask_value>: "
8032 "Set rate limit for queues of VF on port_id",
8034 (void *)&cmd_vf_rate_limit_set,
8035 (void *)&cmd_vf_rate_limit_port,
8036 (void *)&cmd_vf_rate_limit_portnum,
8037 (void *)&cmd_vf_rate_limit_vf,
8038 (void *)&cmd_vf_rate_limit_vfnum,
8039 (void *)&cmd_vf_rate_limit_rate,
8040 (void *)&cmd_vf_rate_limit_ratenum,
8041 (void *)&cmd_vf_rate_limit_q_msk,
8042 (void *)&cmd_vf_rate_limit_q_msk_val,
8047 /* *** ADD TUNNEL FILTER OF A PORT *** */
8048 struct cmd_tunnel_filter_result {
8049 cmdline_fixed_string_t cmd;
8050 cmdline_fixed_string_t what;
8052 struct ether_addr outer_mac;
8053 struct ether_addr inner_mac;
8054 cmdline_ipaddr_t ip_value;
8055 uint16_t inner_vlan;
8056 cmdline_fixed_string_t tunnel_type;
8057 cmdline_fixed_string_t filter_type;
8063 cmd_tunnel_filter_parsed(void *parsed_result,
8064 __attribute__((unused)) struct cmdline *cl,
8065 __attribute__((unused)) void *data)
8067 struct cmd_tunnel_filter_result *res = parsed_result;
8068 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8071 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8073 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8074 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8075 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8077 if (res->ip_value.family == AF_INET) {
8078 tunnel_filter_conf.ip_addr.ipv4_addr =
8079 res->ip_value.addr.ipv4.s_addr;
8080 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8082 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8083 &(res->ip_value.addr.ipv6),
8084 sizeof(struct in6_addr));
8085 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8088 if (!strcmp(res->filter_type, "imac-ivlan"))
8089 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8090 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8091 tunnel_filter_conf.filter_type =
8092 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8093 else if (!strcmp(res->filter_type, "imac-tenid"))
8094 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8095 else if (!strcmp(res->filter_type, "imac"))
8096 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8097 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8098 tunnel_filter_conf.filter_type =
8099 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8100 else if (!strcmp(res->filter_type, "oip"))
8101 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8102 else if (!strcmp(res->filter_type, "iip"))
8103 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8105 printf("The filter type is not supported");
8109 if (!strcmp(res->tunnel_type, "vxlan"))
8110 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8111 else if (!strcmp(res->tunnel_type, "nvgre"))
8112 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8113 else if (!strcmp(res->tunnel_type, "ipingre"))
8114 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8116 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8120 tunnel_filter_conf.tenant_id = res->tenant_id;
8121 tunnel_filter_conf.queue_id = res->queue_num;
8122 if (!strcmp(res->what, "add"))
8123 ret = rte_eth_dev_filter_ctrl(res->port_id,
8124 RTE_ETH_FILTER_TUNNEL,
8126 &tunnel_filter_conf);
8128 ret = rte_eth_dev_filter_ctrl(res->port_id,
8129 RTE_ETH_FILTER_TUNNEL,
8130 RTE_ETH_FILTER_DELETE,
8131 &tunnel_filter_conf);
8133 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8137 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8138 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8139 cmd, "tunnel_filter");
8140 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8141 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8143 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8144 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8146 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8147 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8149 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8150 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8152 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8153 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8154 inner_vlan, UINT16);
8155 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8156 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8158 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8159 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8160 tunnel_type, "vxlan#nvgre#ipingre");
8162 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8163 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8164 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8165 "imac#omac-imac-tenid");
8166 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8167 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8169 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8170 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8173 cmdline_parse_inst_t cmd_tunnel_filter = {
8174 .f = cmd_tunnel_filter_parsed,
8176 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8177 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8178 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8179 "<queue_id>: Add/Rm tunnel filter of a port",
8181 (void *)&cmd_tunnel_filter_cmd,
8182 (void *)&cmd_tunnel_filter_what,
8183 (void *)&cmd_tunnel_filter_port_id,
8184 (void *)&cmd_tunnel_filter_outer_mac,
8185 (void *)&cmd_tunnel_filter_inner_mac,
8186 (void *)&cmd_tunnel_filter_ip_value,
8187 (void *)&cmd_tunnel_filter_innner_vlan,
8188 (void *)&cmd_tunnel_filter_tunnel_type,
8189 (void *)&cmd_tunnel_filter_filter_type,
8190 (void *)&cmd_tunnel_filter_tenant_id,
8191 (void *)&cmd_tunnel_filter_queue_num,
8196 /* *** CONFIGURE TUNNEL UDP PORT *** */
8197 struct cmd_tunnel_udp_config {
8198 cmdline_fixed_string_t cmd;
8199 cmdline_fixed_string_t what;
8205 cmd_tunnel_udp_config_parsed(void *parsed_result,
8206 __attribute__((unused)) struct cmdline *cl,
8207 __attribute__((unused)) void *data)
8209 struct cmd_tunnel_udp_config *res = parsed_result;
8210 struct rte_eth_udp_tunnel tunnel_udp;
8213 tunnel_udp.udp_port = res->udp_port;
8215 if (!strcmp(res->cmd, "rx_vxlan_port"))
8216 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8218 if (!strcmp(res->what, "add"))
8219 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8222 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8226 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8229 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8230 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8231 cmd, "rx_vxlan_port");
8232 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8233 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8235 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8236 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8238 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8239 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8242 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8243 .f = cmd_tunnel_udp_config_parsed,
8245 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8246 "Add/Remove a tunneling UDP port filter",
8248 (void *)&cmd_tunnel_udp_config_cmd,
8249 (void *)&cmd_tunnel_udp_config_what,
8250 (void *)&cmd_tunnel_udp_config_udp_port,
8251 (void *)&cmd_tunnel_udp_config_port_id,
8256 /* *** GLOBAL CONFIG *** */
8257 struct cmd_global_config_result {
8258 cmdline_fixed_string_t cmd;
8260 cmdline_fixed_string_t cfg_type;
8265 cmd_global_config_parsed(void *parsed_result,
8266 __attribute__((unused)) struct cmdline *cl,
8267 __attribute__((unused)) void *data)
8269 struct cmd_global_config_result *res = parsed_result;
8270 struct rte_eth_global_cfg conf;
8273 memset(&conf, 0, sizeof(conf));
8274 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8275 conf.cfg.gre_key_len = res->len;
8276 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8277 RTE_ETH_FILTER_SET, &conf);
8279 printf("Global config error\n");
8282 cmdline_parse_token_string_t cmd_global_config_cmd =
8283 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8285 cmdline_parse_token_num_t cmd_global_config_port_id =
8286 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8288 cmdline_parse_token_string_t cmd_global_config_type =
8289 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8290 cfg_type, "gre-key-len");
8291 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8292 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8295 cmdline_parse_inst_t cmd_global_config = {
8296 .f = cmd_global_config_parsed,
8297 .data = (void *)NULL,
8298 .help_str = "global_config <port_id> gre-key-len <key_len>",
8300 (void *)&cmd_global_config_cmd,
8301 (void *)&cmd_global_config_port_id,
8302 (void *)&cmd_global_config_type,
8303 (void *)&cmd_global_config_gre_key_len,
8308 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8309 struct cmd_set_mirror_mask_result {
8310 cmdline_fixed_string_t set;
8311 cmdline_fixed_string_t port;
8313 cmdline_fixed_string_t mirror;
8315 cmdline_fixed_string_t what;
8316 cmdline_fixed_string_t value;
8317 cmdline_fixed_string_t dstpool;
8319 cmdline_fixed_string_t on;
8322 cmdline_parse_token_string_t cmd_mirror_mask_set =
8323 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8325 cmdline_parse_token_string_t cmd_mirror_mask_port =
8326 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8328 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8329 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8331 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8332 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8333 mirror, "mirror-rule");
8334 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8335 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8337 cmdline_parse_token_string_t cmd_mirror_mask_what =
8338 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8339 what, "pool-mirror-up#pool-mirror-down"
8341 cmdline_parse_token_string_t cmd_mirror_mask_value =
8342 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8344 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8345 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8346 dstpool, "dst-pool");
8347 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8348 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8350 cmdline_parse_token_string_t cmd_mirror_mask_on =
8351 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8355 cmd_set_mirror_mask_parsed(void *parsed_result,
8356 __attribute__((unused)) struct cmdline *cl,
8357 __attribute__((unused)) void *data)
8360 struct cmd_set_mirror_mask_result *res = parsed_result;
8361 struct rte_eth_mirror_conf mr_conf;
8363 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8365 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8367 mr_conf.dst_pool = res->dstpool_id;
8369 if (!strcmp(res->what, "pool-mirror-up")) {
8370 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8371 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8372 } else if (!strcmp(res->what, "pool-mirror-down")) {
8373 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8374 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8375 } else if (!strcmp(res->what, "vlan-mirror")) {
8376 mr_conf.rule_type = ETH_MIRROR_VLAN;
8377 nb_item = parse_item_list(res->value, "vlan",
8378 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8382 for (i = 0; i < nb_item; i++) {
8383 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8384 printf("Invalid vlan_id: must be < 4096\n");
8388 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8389 mr_conf.vlan.vlan_mask |= 1ULL << i;
8393 if (!strcmp(res->on, "on"))
8394 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8397 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8400 printf("mirror rule add error: (%s)\n", strerror(-ret));
8403 cmdline_parse_inst_t cmd_set_mirror_mask = {
8404 .f = cmd_set_mirror_mask_parsed,
8406 .help_str = "set port <port_id> mirror-rule <rule_id> "
8407 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8408 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8410 (void *)&cmd_mirror_mask_set,
8411 (void *)&cmd_mirror_mask_port,
8412 (void *)&cmd_mirror_mask_portid,
8413 (void *)&cmd_mirror_mask_mirror,
8414 (void *)&cmd_mirror_mask_ruleid,
8415 (void *)&cmd_mirror_mask_what,
8416 (void *)&cmd_mirror_mask_value,
8417 (void *)&cmd_mirror_mask_dstpool,
8418 (void *)&cmd_mirror_mask_poolid,
8419 (void *)&cmd_mirror_mask_on,
8424 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8425 struct cmd_set_mirror_link_result {
8426 cmdline_fixed_string_t set;
8427 cmdline_fixed_string_t port;
8429 cmdline_fixed_string_t mirror;
8431 cmdline_fixed_string_t what;
8432 cmdline_fixed_string_t dstpool;
8434 cmdline_fixed_string_t on;
8437 cmdline_parse_token_string_t cmd_mirror_link_set =
8438 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8440 cmdline_parse_token_string_t cmd_mirror_link_port =
8441 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8443 cmdline_parse_token_num_t cmd_mirror_link_portid =
8444 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8446 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8447 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8448 mirror, "mirror-rule");
8449 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8450 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8452 cmdline_parse_token_string_t cmd_mirror_link_what =
8453 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8454 what, "uplink-mirror#downlink-mirror");
8455 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8456 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8457 dstpool, "dst-pool");
8458 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8459 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8461 cmdline_parse_token_string_t cmd_mirror_link_on =
8462 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8466 cmd_set_mirror_link_parsed(void *parsed_result,
8467 __attribute__((unused)) struct cmdline *cl,
8468 __attribute__((unused)) void *data)
8471 struct cmd_set_mirror_link_result *res = parsed_result;
8472 struct rte_eth_mirror_conf mr_conf;
8474 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8475 if (!strcmp(res->what, "uplink-mirror"))
8476 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8478 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8480 mr_conf.dst_pool = res->dstpool_id;
8482 if (!strcmp(res->on, "on"))
8483 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8486 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8489 /* check the return value and print it if is < 0 */
8491 printf("mirror rule add error: (%s)\n", strerror(-ret));
8495 cmdline_parse_inst_t cmd_set_mirror_link = {
8496 .f = cmd_set_mirror_link_parsed,
8498 .help_str = "set port <port_id> mirror-rule <rule_id> "
8499 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8501 (void *)&cmd_mirror_link_set,
8502 (void *)&cmd_mirror_link_port,
8503 (void *)&cmd_mirror_link_portid,
8504 (void *)&cmd_mirror_link_mirror,
8505 (void *)&cmd_mirror_link_ruleid,
8506 (void *)&cmd_mirror_link_what,
8507 (void *)&cmd_mirror_link_dstpool,
8508 (void *)&cmd_mirror_link_poolid,
8509 (void *)&cmd_mirror_link_on,
8514 /* *** RESET VM MIRROR RULE *** */
8515 struct cmd_rm_mirror_rule_result {
8516 cmdline_fixed_string_t reset;
8517 cmdline_fixed_string_t port;
8519 cmdline_fixed_string_t mirror;
8523 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8524 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8526 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8527 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8529 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8530 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8532 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8533 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8534 mirror, "mirror-rule");
8535 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8536 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8540 cmd_reset_mirror_rule_parsed(void *parsed_result,
8541 __attribute__((unused)) struct cmdline *cl,
8542 __attribute__((unused)) void *data)
8545 struct cmd_set_mirror_link_result *res = parsed_result;
8547 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8549 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8552 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8553 .f = cmd_reset_mirror_rule_parsed,
8555 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8557 (void *)&cmd_rm_mirror_rule_reset,
8558 (void *)&cmd_rm_mirror_rule_port,
8559 (void *)&cmd_rm_mirror_rule_portid,
8560 (void *)&cmd_rm_mirror_rule_mirror,
8561 (void *)&cmd_rm_mirror_rule_ruleid,
8566 /* ******************************************************************************** */
8568 struct cmd_dump_result {
8569 cmdline_fixed_string_t dump;
8573 dump_struct_sizes(void)
8575 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8576 DUMP_SIZE(struct rte_mbuf);
8577 DUMP_SIZE(struct rte_mempool);
8578 DUMP_SIZE(struct rte_ring);
8582 static void cmd_dump_parsed(void *parsed_result,
8583 __attribute__((unused)) struct cmdline *cl,
8584 __attribute__((unused)) void *data)
8586 struct cmd_dump_result *res = parsed_result;
8588 if (!strcmp(res->dump, "dump_physmem"))
8589 rte_dump_physmem_layout(stdout);
8590 else if (!strcmp(res->dump, "dump_memzone"))
8591 rte_memzone_dump(stdout);
8592 else if (!strcmp(res->dump, "dump_struct_sizes"))
8593 dump_struct_sizes();
8594 else if (!strcmp(res->dump, "dump_ring"))
8595 rte_ring_list_dump(stdout);
8596 else if (!strcmp(res->dump, "dump_mempool"))
8597 rte_mempool_list_dump(stdout);
8598 else if (!strcmp(res->dump, "dump_devargs"))
8599 rte_eal_devargs_dump(stdout);
8600 else if (!strcmp(res->dump, "dump_log_types"))
8601 rte_log_dump(stdout);
8604 cmdline_parse_token_string_t cmd_dump_dump =
8605 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8608 "dump_struct_sizes#"
8614 cmdline_parse_inst_t cmd_dump = {
8615 .f = cmd_dump_parsed, /* function to call */
8616 .data = NULL, /* 2nd arg of func */
8617 .help_str = "Dump status",
8618 .tokens = { /* token list, NULL terminated */
8619 (void *)&cmd_dump_dump,
8624 /* ******************************************************************************** */
8626 struct cmd_dump_one_result {
8627 cmdline_fixed_string_t dump;
8628 cmdline_fixed_string_t name;
8631 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8632 __attribute__((unused)) void *data)
8634 struct cmd_dump_one_result *res = parsed_result;
8636 if (!strcmp(res->dump, "dump_ring")) {
8638 r = rte_ring_lookup(res->name);
8640 cmdline_printf(cl, "Cannot find ring\n");
8643 rte_ring_dump(stdout, r);
8644 } else if (!strcmp(res->dump, "dump_mempool")) {
8645 struct rte_mempool *mp;
8646 mp = rte_mempool_lookup(res->name);
8648 cmdline_printf(cl, "Cannot find mempool\n");
8651 rte_mempool_dump(stdout, mp);
8655 cmdline_parse_token_string_t cmd_dump_one_dump =
8656 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8657 "dump_ring#dump_mempool");
8659 cmdline_parse_token_string_t cmd_dump_one_name =
8660 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8662 cmdline_parse_inst_t cmd_dump_one = {
8663 .f = cmd_dump_one_parsed, /* function to call */
8664 .data = NULL, /* 2nd arg of func */
8665 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8666 .tokens = { /* token list, NULL terminated */
8667 (void *)&cmd_dump_one_dump,
8668 (void *)&cmd_dump_one_name,
8673 /* *** Add/Del syn filter *** */
8674 struct cmd_syn_filter_result {
8675 cmdline_fixed_string_t filter;
8677 cmdline_fixed_string_t ops;
8678 cmdline_fixed_string_t priority;
8679 cmdline_fixed_string_t high;
8680 cmdline_fixed_string_t queue;
8685 cmd_syn_filter_parsed(void *parsed_result,
8686 __attribute__((unused)) struct cmdline *cl,
8687 __attribute__((unused)) void *data)
8689 struct cmd_syn_filter_result *res = parsed_result;
8690 struct rte_eth_syn_filter syn_filter;
8693 ret = rte_eth_dev_filter_supported(res->port_id,
8694 RTE_ETH_FILTER_SYN);
8696 printf("syn filter is not supported on port %u.\n",
8701 memset(&syn_filter, 0, sizeof(syn_filter));
8703 if (!strcmp(res->ops, "add")) {
8704 if (!strcmp(res->high, "high"))
8705 syn_filter.hig_pri = 1;
8707 syn_filter.hig_pri = 0;
8709 syn_filter.queue = res->queue_id;
8710 ret = rte_eth_dev_filter_ctrl(res->port_id,
8715 ret = rte_eth_dev_filter_ctrl(res->port_id,
8717 RTE_ETH_FILTER_DELETE,
8721 printf("syn filter programming error: (%s)\n",
8725 cmdline_parse_token_string_t cmd_syn_filter_filter =
8726 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8727 filter, "syn_filter");
8728 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8729 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8731 cmdline_parse_token_string_t cmd_syn_filter_ops =
8732 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8734 cmdline_parse_token_string_t cmd_syn_filter_priority =
8735 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8736 priority, "priority");
8737 cmdline_parse_token_string_t cmd_syn_filter_high =
8738 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8740 cmdline_parse_token_string_t cmd_syn_filter_queue =
8741 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8743 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8744 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8747 cmdline_parse_inst_t cmd_syn_filter = {
8748 .f = cmd_syn_filter_parsed,
8750 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8751 "<queue_id>: Add/Delete syn filter",
8753 (void *)&cmd_syn_filter_filter,
8754 (void *)&cmd_syn_filter_port_id,
8755 (void *)&cmd_syn_filter_ops,
8756 (void *)&cmd_syn_filter_priority,
8757 (void *)&cmd_syn_filter_high,
8758 (void *)&cmd_syn_filter_queue,
8759 (void *)&cmd_syn_filter_queue_id,
8764 /* *** queue region set *** */
8765 struct cmd_queue_region_result {
8766 cmdline_fixed_string_t set;
8767 cmdline_fixed_string_t port;
8769 cmdline_fixed_string_t cmd;
8770 cmdline_fixed_string_t region;
8772 cmdline_fixed_string_t queue_start_index;
8774 cmdline_fixed_string_t queue_num;
8775 uint8_t queue_num_value;
8779 cmd_queue_region_parsed(void *parsed_result,
8780 __attribute__((unused)) struct cmdline *cl,
8781 __attribute__((unused)) void *data)
8783 struct cmd_queue_region_result *res = parsed_result;
8785 #ifdef RTE_LIBRTE_I40E_PMD
8786 struct rte_pmd_i40e_queue_region_conf region_conf;
8787 enum rte_pmd_i40e_queue_region_op op_type;
8790 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8793 #ifdef RTE_LIBRTE_I40E_PMD
8794 memset(®ion_conf, 0, sizeof(region_conf));
8795 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8796 region_conf.region_id = res->region_id;
8797 region_conf.queue_num = res->queue_num_value;
8798 region_conf.queue_start_index = res->queue_id;
8800 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8801 op_type, ®ion_conf);
8808 printf("function not implemented or supported\n");
8811 printf("queue region config error: (%s)\n", strerror(-ret));
8815 cmdline_parse_token_string_t cmd_queue_region_set =
8816 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8818 cmdline_parse_token_string_t cmd_queue_region_port =
8819 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8820 cmdline_parse_token_num_t cmd_queue_region_port_id =
8821 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8823 cmdline_parse_token_string_t cmd_queue_region_cmd =
8824 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8825 cmd, "queue-region");
8826 cmdline_parse_token_string_t cmd_queue_region_id =
8827 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8828 region, "region_id");
8829 cmdline_parse_token_num_t cmd_queue_region_index =
8830 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8832 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8833 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8834 queue_start_index, "queue_start_index");
8835 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8836 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8838 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8839 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8840 queue_num, "queue_num");
8841 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8842 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8843 queue_num_value, UINT8);
8845 cmdline_parse_inst_t cmd_queue_region = {
8846 .f = cmd_queue_region_parsed,
8848 .help_str = "set port <port_id> queue-region region_id <value> "
8849 "queue_start_index <value> queue_num <value>: Set a queue region",
8851 (void *)&cmd_queue_region_set,
8852 (void *)&cmd_queue_region_port,
8853 (void *)&cmd_queue_region_port_id,
8854 (void *)&cmd_queue_region_cmd,
8855 (void *)&cmd_queue_region_id,
8856 (void *)&cmd_queue_region_index,
8857 (void *)&cmd_queue_region_queue_start_index,
8858 (void *)&cmd_queue_region_queue_id,
8859 (void *)&cmd_queue_region_queue_num,
8860 (void *)&cmd_queue_region_queue_num_value,
8865 /* *** queue region and flowtype set *** */
8866 struct cmd_region_flowtype_result {
8867 cmdline_fixed_string_t set;
8868 cmdline_fixed_string_t port;
8870 cmdline_fixed_string_t cmd;
8871 cmdline_fixed_string_t region;
8873 cmdline_fixed_string_t flowtype;
8874 uint8_t flowtype_id;
8878 cmd_region_flowtype_parsed(void *parsed_result,
8879 __attribute__((unused)) struct cmdline *cl,
8880 __attribute__((unused)) void *data)
8882 struct cmd_region_flowtype_result *res = parsed_result;
8884 #ifdef RTE_LIBRTE_I40E_PMD
8885 struct rte_pmd_i40e_queue_region_conf region_conf;
8886 enum rte_pmd_i40e_queue_region_op op_type;
8889 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8892 #ifdef RTE_LIBRTE_I40E_PMD
8893 memset(®ion_conf, 0, sizeof(region_conf));
8895 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8896 region_conf.region_id = res->region_id;
8897 region_conf.hw_flowtype = res->flowtype_id;
8899 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8900 op_type, ®ion_conf);
8907 printf("function not implemented or supported\n");
8910 printf("region flowtype config error: (%s)\n", strerror(-ret));
8914 cmdline_parse_token_string_t cmd_region_flowtype_set =
8915 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8917 cmdline_parse_token_string_t cmd_region_flowtype_port =
8918 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8920 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8921 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8923 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8924 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8925 cmd, "queue-region");
8926 cmdline_parse_token_string_t cmd_region_flowtype_index =
8927 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8928 region, "region_id");
8929 cmdline_parse_token_num_t cmd_region_flowtype_id =
8930 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8932 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8933 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8934 flowtype, "flowtype");
8935 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8936 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8937 flowtype_id, UINT8);
8938 cmdline_parse_inst_t cmd_region_flowtype = {
8939 .f = cmd_region_flowtype_parsed,
8941 .help_str = "set port <port_id> queue-region region_id <value> "
8942 "flowtype <value>: Set a flowtype region index",
8944 (void *)&cmd_region_flowtype_set,
8945 (void *)&cmd_region_flowtype_port,
8946 (void *)&cmd_region_flowtype_port_index,
8947 (void *)&cmd_region_flowtype_cmd,
8948 (void *)&cmd_region_flowtype_index,
8949 (void *)&cmd_region_flowtype_id,
8950 (void *)&cmd_region_flowtype_flow_index,
8951 (void *)&cmd_region_flowtype_flow_id,
8956 /* *** User Priority (UP) to queue region (region_id) set *** */
8957 struct cmd_user_priority_region_result {
8958 cmdline_fixed_string_t set;
8959 cmdline_fixed_string_t port;
8961 cmdline_fixed_string_t cmd;
8962 cmdline_fixed_string_t user_priority;
8963 uint8_t user_priority_id;
8964 cmdline_fixed_string_t region;
8969 cmd_user_priority_region_parsed(void *parsed_result,
8970 __attribute__((unused)) struct cmdline *cl,
8971 __attribute__((unused)) void *data)
8973 struct cmd_user_priority_region_result *res = parsed_result;
8975 #ifdef RTE_LIBRTE_I40E_PMD
8976 struct rte_pmd_i40e_queue_region_conf region_conf;
8977 enum rte_pmd_i40e_queue_region_op op_type;
8980 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8983 #ifdef RTE_LIBRTE_I40E_PMD
8984 memset(®ion_conf, 0, sizeof(region_conf));
8985 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8986 region_conf.user_priority = res->user_priority_id;
8987 region_conf.region_id = res->region_id;
8989 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8990 op_type, ®ion_conf);
8997 printf("function not implemented or supported\n");
9000 printf("user_priority region config error: (%s)\n",
9005 cmdline_parse_token_string_t cmd_user_priority_region_set =
9006 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9008 cmdline_parse_token_string_t cmd_user_priority_region_port =
9009 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9011 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9012 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9014 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9015 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9016 cmd, "queue-region");
9017 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9018 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9019 user_priority, "UP");
9020 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9021 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9022 user_priority_id, UINT8);
9023 cmdline_parse_token_string_t cmd_user_priority_region_region =
9024 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9025 region, "region_id");
9026 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9027 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9030 cmdline_parse_inst_t cmd_user_priority_region = {
9031 .f = cmd_user_priority_region_parsed,
9033 .help_str = "set port <port_id> queue-region UP <value> "
9034 "region_id <value>: Set the mapping of User Priority (UP) "
9035 "to queue region (region_id) ",
9037 (void *)&cmd_user_priority_region_set,
9038 (void *)&cmd_user_priority_region_port,
9039 (void *)&cmd_user_priority_region_port_index,
9040 (void *)&cmd_user_priority_region_cmd,
9041 (void *)&cmd_user_priority_region_UP,
9042 (void *)&cmd_user_priority_region_UP_id,
9043 (void *)&cmd_user_priority_region_region,
9044 (void *)&cmd_user_priority_region_region_id,
9049 /* *** flush all queue region related configuration *** */
9050 struct cmd_flush_queue_region_result {
9051 cmdline_fixed_string_t set;
9052 cmdline_fixed_string_t port;
9054 cmdline_fixed_string_t cmd;
9055 cmdline_fixed_string_t flush;
9056 cmdline_fixed_string_t what;
9060 cmd_flush_queue_region_parsed(void *parsed_result,
9061 __attribute__((unused)) struct cmdline *cl,
9062 __attribute__((unused)) void *data)
9064 struct cmd_flush_queue_region_result *res = parsed_result;
9066 #ifdef RTE_LIBRTE_I40E_PMD
9067 struct rte_pmd_i40e_queue_region_conf region_conf;
9068 enum rte_pmd_i40e_queue_region_op op_type;
9071 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9074 #ifdef RTE_LIBRTE_I40E_PMD
9075 memset(®ion_conf, 0, sizeof(region_conf));
9077 if (strcmp(res->what, "on") == 0)
9078 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9080 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9082 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9083 op_type, ®ion_conf);
9090 printf("function not implemented or supported\n");
9093 printf("queue region config flush error: (%s)\n",
9098 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9099 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9101 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9102 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9104 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9105 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9107 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9108 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9109 cmd, "queue-region");
9110 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9111 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9113 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9114 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9117 cmdline_parse_inst_t cmd_flush_queue_region = {
9118 .f = cmd_flush_queue_region_parsed,
9120 .help_str = "set port <port_id> queue-region flush on|off"
9121 ": flush all queue region related configuration",
9123 (void *)&cmd_flush_queue_region_set,
9124 (void *)&cmd_flush_queue_region_port,
9125 (void *)&cmd_flush_queue_region_port_index,
9126 (void *)&cmd_flush_queue_region_cmd,
9127 (void *)&cmd_flush_queue_region_flush,
9128 (void *)&cmd_flush_queue_region_what,
9133 /* *** get all queue region related configuration info *** */
9134 struct cmd_show_queue_region_info {
9135 cmdline_fixed_string_t show;
9136 cmdline_fixed_string_t port;
9138 cmdline_fixed_string_t cmd;
9142 cmd_show_queue_region_info_parsed(void *parsed_result,
9143 __attribute__((unused)) struct cmdline *cl,
9144 __attribute__((unused)) void *data)
9146 struct cmd_show_queue_region_info *res = parsed_result;
9148 #ifdef RTE_LIBRTE_I40E_PMD
9149 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9150 enum rte_pmd_i40e_queue_region_op op_type;
9153 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9156 #ifdef RTE_LIBRTE_I40E_PMD
9157 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9159 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9161 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9162 op_type, &rte_pmd_regions);
9164 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9171 printf("function not implemented or supported\n");
9174 printf("queue region config info show error: (%s)\n",
9179 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9180 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9182 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9183 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9185 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9186 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9188 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9189 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9190 cmd, "queue-region");
9192 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9193 .f = cmd_show_queue_region_info_parsed,
9195 .help_str = "show port <port_id> queue-region"
9196 ": show all queue region related configuration info",
9198 (void *)&cmd_show_queue_region_info_get,
9199 (void *)&cmd_show_queue_region_info_port,
9200 (void *)&cmd_show_queue_region_info_port_index,
9201 (void *)&cmd_show_queue_region_info_cmd,
9206 /* *** ADD/REMOVE A 2tuple FILTER *** */
9207 struct cmd_2tuple_filter_result {
9208 cmdline_fixed_string_t filter;
9210 cmdline_fixed_string_t ops;
9211 cmdline_fixed_string_t dst_port;
9212 uint16_t dst_port_value;
9213 cmdline_fixed_string_t protocol;
9214 uint8_t protocol_value;
9215 cmdline_fixed_string_t mask;
9217 cmdline_fixed_string_t tcp_flags;
9218 uint8_t tcp_flags_value;
9219 cmdline_fixed_string_t priority;
9220 uint8_t priority_value;
9221 cmdline_fixed_string_t queue;
9226 cmd_2tuple_filter_parsed(void *parsed_result,
9227 __attribute__((unused)) struct cmdline *cl,
9228 __attribute__((unused)) void *data)
9230 struct rte_eth_ntuple_filter filter;
9231 struct cmd_2tuple_filter_result *res = parsed_result;
9234 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9236 printf("ntuple filter is not supported on port %u.\n",
9241 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9243 filter.flags = RTE_2TUPLE_FLAGS;
9244 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9245 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9246 filter.proto = res->protocol_value;
9247 filter.priority = res->priority_value;
9248 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9249 printf("nonzero tcp_flags is only meaningful"
9250 " when protocol is TCP.\n");
9253 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9254 printf("invalid TCP flags.\n");
9258 if (res->tcp_flags_value != 0) {
9259 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9260 filter.tcp_flags = res->tcp_flags_value;
9263 /* need convert to big endian. */
9264 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9265 filter.queue = res->queue_id;
9267 if (!strcmp(res->ops, "add"))
9268 ret = rte_eth_dev_filter_ctrl(res->port_id,
9269 RTE_ETH_FILTER_NTUPLE,
9273 ret = rte_eth_dev_filter_ctrl(res->port_id,
9274 RTE_ETH_FILTER_NTUPLE,
9275 RTE_ETH_FILTER_DELETE,
9278 printf("2tuple filter programming error: (%s)\n",
9283 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9284 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9285 filter, "2tuple_filter");
9286 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9287 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9289 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9290 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9292 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9293 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9294 dst_port, "dst_port");
9295 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9296 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9297 dst_port_value, UINT16);
9298 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9299 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9300 protocol, "protocol");
9301 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9302 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9303 protocol_value, UINT8);
9304 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9305 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9307 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9308 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9310 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9311 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9312 tcp_flags, "tcp_flags");
9313 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9314 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9315 tcp_flags_value, UINT8);
9316 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9317 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9318 priority, "priority");
9319 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9320 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9321 priority_value, UINT8);
9322 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9323 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9325 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9326 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9329 cmdline_parse_inst_t cmd_2tuple_filter = {
9330 .f = cmd_2tuple_filter_parsed,
9332 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9333 "<value> mask <value> tcp_flags <value> priority <value> queue "
9334 "<queue_id>: Add a 2tuple filter",
9336 (void *)&cmd_2tuple_filter_filter,
9337 (void *)&cmd_2tuple_filter_port_id,
9338 (void *)&cmd_2tuple_filter_ops,
9339 (void *)&cmd_2tuple_filter_dst_port,
9340 (void *)&cmd_2tuple_filter_dst_port_value,
9341 (void *)&cmd_2tuple_filter_protocol,
9342 (void *)&cmd_2tuple_filter_protocol_value,
9343 (void *)&cmd_2tuple_filter_mask,
9344 (void *)&cmd_2tuple_filter_mask_value,
9345 (void *)&cmd_2tuple_filter_tcp_flags,
9346 (void *)&cmd_2tuple_filter_tcp_flags_value,
9347 (void *)&cmd_2tuple_filter_priority,
9348 (void *)&cmd_2tuple_filter_priority_value,
9349 (void *)&cmd_2tuple_filter_queue,
9350 (void *)&cmd_2tuple_filter_queue_id,
9355 /* *** ADD/REMOVE A 5tuple FILTER *** */
9356 struct cmd_5tuple_filter_result {
9357 cmdline_fixed_string_t filter;
9359 cmdline_fixed_string_t ops;
9360 cmdline_fixed_string_t dst_ip;
9361 cmdline_ipaddr_t dst_ip_value;
9362 cmdline_fixed_string_t src_ip;
9363 cmdline_ipaddr_t src_ip_value;
9364 cmdline_fixed_string_t dst_port;
9365 uint16_t dst_port_value;
9366 cmdline_fixed_string_t src_port;
9367 uint16_t src_port_value;
9368 cmdline_fixed_string_t protocol;
9369 uint8_t protocol_value;
9370 cmdline_fixed_string_t mask;
9372 cmdline_fixed_string_t tcp_flags;
9373 uint8_t tcp_flags_value;
9374 cmdline_fixed_string_t priority;
9375 uint8_t priority_value;
9376 cmdline_fixed_string_t queue;
9381 cmd_5tuple_filter_parsed(void *parsed_result,
9382 __attribute__((unused)) struct cmdline *cl,
9383 __attribute__((unused)) void *data)
9385 struct rte_eth_ntuple_filter filter;
9386 struct cmd_5tuple_filter_result *res = parsed_result;
9389 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9391 printf("ntuple filter is not supported on port %u.\n",
9396 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9398 filter.flags = RTE_5TUPLE_FLAGS;
9399 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9400 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9401 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9402 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9403 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9404 filter.proto = res->protocol_value;
9405 filter.priority = res->priority_value;
9406 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9407 printf("nonzero tcp_flags is only meaningful"
9408 " when protocol is TCP.\n");
9411 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9412 printf("invalid TCP flags.\n");
9416 if (res->tcp_flags_value != 0) {
9417 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9418 filter.tcp_flags = res->tcp_flags_value;
9421 if (res->dst_ip_value.family == AF_INET)
9422 /* no need to convert, already big endian. */
9423 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9425 if (filter.dst_ip_mask == 0) {
9426 printf("can not support ipv6 involved compare.\n");
9432 if (res->src_ip_value.family == AF_INET)
9433 /* no need to convert, already big endian. */
9434 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9436 if (filter.src_ip_mask == 0) {
9437 printf("can not support ipv6 involved compare.\n");
9442 /* need convert to big endian. */
9443 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9444 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9445 filter.queue = res->queue_id;
9447 if (!strcmp(res->ops, "add"))
9448 ret = rte_eth_dev_filter_ctrl(res->port_id,
9449 RTE_ETH_FILTER_NTUPLE,
9453 ret = rte_eth_dev_filter_ctrl(res->port_id,
9454 RTE_ETH_FILTER_NTUPLE,
9455 RTE_ETH_FILTER_DELETE,
9458 printf("5tuple filter programming error: (%s)\n",
9462 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9463 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9464 filter, "5tuple_filter");
9465 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9466 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9468 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9469 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9471 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9472 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9474 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9475 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9477 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9478 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9480 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9481 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9483 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9484 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9485 dst_port, "dst_port");
9486 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9487 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9488 dst_port_value, UINT16);
9489 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9490 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9491 src_port, "src_port");
9492 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9493 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9494 src_port_value, UINT16);
9495 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9496 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9497 protocol, "protocol");
9498 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9499 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9500 protocol_value, UINT8);
9501 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9502 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9504 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9505 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9507 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9508 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9509 tcp_flags, "tcp_flags");
9510 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9511 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9512 tcp_flags_value, UINT8);
9513 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9514 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9515 priority, "priority");
9516 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9517 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9518 priority_value, UINT8);
9519 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9520 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9522 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9523 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9526 cmdline_parse_inst_t cmd_5tuple_filter = {
9527 .f = cmd_5tuple_filter_parsed,
9529 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9530 "src_ip <value> dst_port <value> src_port <value> "
9531 "protocol <value> mask <value> tcp_flags <value> "
9532 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9534 (void *)&cmd_5tuple_filter_filter,
9535 (void *)&cmd_5tuple_filter_port_id,
9536 (void *)&cmd_5tuple_filter_ops,
9537 (void *)&cmd_5tuple_filter_dst_ip,
9538 (void *)&cmd_5tuple_filter_dst_ip_value,
9539 (void *)&cmd_5tuple_filter_src_ip,
9540 (void *)&cmd_5tuple_filter_src_ip_value,
9541 (void *)&cmd_5tuple_filter_dst_port,
9542 (void *)&cmd_5tuple_filter_dst_port_value,
9543 (void *)&cmd_5tuple_filter_src_port,
9544 (void *)&cmd_5tuple_filter_src_port_value,
9545 (void *)&cmd_5tuple_filter_protocol,
9546 (void *)&cmd_5tuple_filter_protocol_value,
9547 (void *)&cmd_5tuple_filter_mask,
9548 (void *)&cmd_5tuple_filter_mask_value,
9549 (void *)&cmd_5tuple_filter_tcp_flags,
9550 (void *)&cmd_5tuple_filter_tcp_flags_value,
9551 (void *)&cmd_5tuple_filter_priority,
9552 (void *)&cmd_5tuple_filter_priority_value,
9553 (void *)&cmd_5tuple_filter_queue,
9554 (void *)&cmd_5tuple_filter_queue_id,
9559 /* *** ADD/REMOVE A flex FILTER *** */
9560 struct cmd_flex_filter_result {
9561 cmdline_fixed_string_t filter;
9562 cmdline_fixed_string_t ops;
9564 cmdline_fixed_string_t len;
9566 cmdline_fixed_string_t bytes;
9567 cmdline_fixed_string_t bytes_value;
9568 cmdline_fixed_string_t mask;
9569 cmdline_fixed_string_t mask_value;
9570 cmdline_fixed_string_t priority;
9571 uint8_t priority_value;
9572 cmdline_fixed_string_t queue;
9576 static int xdigit2val(unsigned char c)
9581 else if (isupper(c))
9589 cmd_flex_filter_parsed(void *parsed_result,
9590 __attribute__((unused)) struct cmdline *cl,
9591 __attribute__((unused)) void *data)
9594 struct rte_eth_flex_filter filter;
9595 struct cmd_flex_filter_result *res = parsed_result;
9596 char *bytes_ptr, *mask_ptr;
9597 uint16_t len, i, j = 0;
9602 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9603 printf("the len exceed the max length 128\n");
9606 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9607 filter.len = res->len_value;
9608 filter.priority = res->priority_value;
9609 filter.queue = res->queue_id;
9610 bytes_ptr = res->bytes_value;
9611 mask_ptr = res->mask_value;
9613 /* translate bytes string to array. */
9614 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9615 (bytes_ptr[1] == 'X')))
9617 len = strnlen(bytes_ptr, res->len_value * 2);
9618 if (len == 0 || (len % 8 != 0)) {
9619 printf("please check len and bytes input\n");
9622 for (i = 0; i < len; i++) {
9624 if (isxdigit(c) == 0) {
9625 /* invalid characters. */
9626 printf("invalid input\n");
9629 val = xdigit2val(c);
9632 filter.bytes[j] = byte;
9633 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9640 /* translate mask string to uint8_t array. */
9641 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9642 (mask_ptr[1] == 'X')))
9644 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9646 printf("invalid input\n");
9651 for (i = 0; i < len; i++) {
9653 if (isxdigit(c) == 0) {
9654 /* invalid characters. */
9655 printf("invalid input\n");
9658 val = xdigit2val(c);
9661 filter.mask[j] = byte;
9662 printf("mask[%d]:%02x ", j, filter.mask[j]);
9670 if (!strcmp(res->ops, "add"))
9671 ret = rte_eth_dev_filter_ctrl(res->port_id,
9672 RTE_ETH_FILTER_FLEXIBLE,
9676 ret = rte_eth_dev_filter_ctrl(res->port_id,
9677 RTE_ETH_FILTER_FLEXIBLE,
9678 RTE_ETH_FILTER_DELETE,
9682 printf("flex filter setting error: (%s)\n", strerror(-ret));
9685 cmdline_parse_token_string_t cmd_flex_filter_filter =
9686 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9687 filter, "flex_filter");
9688 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9689 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9691 cmdline_parse_token_string_t cmd_flex_filter_ops =
9692 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9694 cmdline_parse_token_string_t cmd_flex_filter_len =
9695 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9697 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9698 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9700 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9701 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9703 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9704 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9706 cmdline_parse_token_string_t cmd_flex_filter_mask =
9707 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9709 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9710 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9712 cmdline_parse_token_string_t cmd_flex_filter_priority =
9713 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9714 priority, "priority");
9715 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9716 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9717 priority_value, UINT8);
9718 cmdline_parse_token_string_t cmd_flex_filter_queue =
9719 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9721 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9722 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9724 cmdline_parse_inst_t cmd_flex_filter = {
9725 .f = cmd_flex_filter_parsed,
9727 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9728 "<value> mask <value> priority <value> queue <queue_id>: "
9729 "Add/Del a flex filter",
9731 (void *)&cmd_flex_filter_filter,
9732 (void *)&cmd_flex_filter_port_id,
9733 (void *)&cmd_flex_filter_ops,
9734 (void *)&cmd_flex_filter_len,
9735 (void *)&cmd_flex_filter_len_value,
9736 (void *)&cmd_flex_filter_bytes,
9737 (void *)&cmd_flex_filter_bytes_value,
9738 (void *)&cmd_flex_filter_mask,
9739 (void *)&cmd_flex_filter_mask_value,
9740 (void *)&cmd_flex_filter_priority,
9741 (void *)&cmd_flex_filter_priority_value,
9742 (void *)&cmd_flex_filter_queue,
9743 (void *)&cmd_flex_filter_queue_id,
9748 /* *** Filters Control *** */
9750 /* *** deal with ethertype filter *** */
9751 struct cmd_ethertype_filter_result {
9752 cmdline_fixed_string_t filter;
9754 cmdline_fixed_string_t ops;
9755 cmdline_fixed_string_t mac;
9756 struct ether_addr mac_addr;
9757 cmdline_fixed_string_t ethertype;
9758 uint16_t ethertype_value;
9759 cmdline_fixed_string_t drop;
9760 cmdline_fixed_string_t queue;
9764 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9765 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9766 filter, "ethertype_filter");
9767 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9768 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9770 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9771 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9773 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9774 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9775 mac, "mac_addr#mac_ignr");
9776 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9777 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9779 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9780 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9781 ethertype, "ethertype");
9782 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9783 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9784 ethertype_value, UINT16);
9785 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9786 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9788 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9789 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9791 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9792 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9796 cmd_ethertype_filter_parsed(void *parsed_result,
9797 __attribute__((unused)) struct cmdline *cl,
9798 __attribute__((unused)) void *data)
9800 struct cmd_ethertype_filter_result *res = parsed_result;
9801 struct rte_eth_ethertype_filter filter;
9804 ret = rte_eth_dev_filter_supported(res->port_id,
9805 RTE_ETH_FILTER_ETHERTYPE);
9807 printf("ethertype filter is not supported on port %u.\n",
9812 memset(&filter, 0, sizeof(filter));
9813 if (!strcmp(res->mac, "mac_addr")) {
9814 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9815 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9816 sizeof(struct ether_addr));
9818 if (!strcmp(res->drop, "drop"))
9819 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9820 filter.ether_type = res->ethertype_value;
9821 filter.queue = res->queue_id;
9823 if (!strcmp(res->ops, "add"))
9824 ret = rte_eth_dev_filter_ctrl(res->port_id,
9825 RTE_ETH_FILTER_ETHERTYPE,
9829 ret = rte_eth_dev_filter_ctrl(res->port_id,
9830 RTE_ETH_FILTER_ETHERTYPE,
9831 RTE_ETH_FILTER_DELETE,
9834 printf("ethertype filter programming error: (%s)\n",
9838 cmdline_parse_inst_t cmd_ethertype_filter = {
9839 .f = cmd_ethertype_filter_parsed,
9841 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9842 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9843 "Add or delete an ethertype filter entry",
9845 (void *)&cmd_ethertype_filter_filter,
9846 (void *)&cmd_ethertype_filter_port_id,
9847 (void *)&cmd_ethertype_filter_ops,
9848 (void *)&cmd_ethertype_filter_mac,
9849 (void *)&cmd_ethertype_filter_mac_addr,
9850 (void *)&cmd_ethertype_filter_ethertype,
9851 (void *)&cmd_ethertype_filter_ethertype_value,
9852 (void *)&cmd_ethertype_filter_drop,
9853 (void *)&cmd_ethertype_filter_queue,
9854 (void *)&cmd_ethertype_filter_queue_id,
9859 /* *** deal with flow director filter *** */
9860 struct cmd_flow_director_result {
9861 cmdline_fixed_string_t flow_director_filter;
9863 cmdline_fixed_string_t mode;
9864 cmdline_fixed_string_t mode_value;
9865 cmdline_fixed_string_t ops;
9866 cmdline_fixed_string_t flow;
9867 cmdline_fixed_string_t flow_type;
9868 cmdline_fixed_string_t ether;
9869 uint16_t ether_type;
9870 cmdline_fixed_string_t src;
9871 cmdline_ipaddr_t ip_src;
9873 cmdline_fixed_string_t dst;
9874 cmdline_ipaddr_t ip_dst;
9876 cmdline_fixed_string_t verify_tag;
9877 uint32_t verify_tag_value;
9878 cmdline_ipaddr_t tos;
9880 cmdline_ipaddr_t proto;
9881 uint8_t proto_value;
9882 cmdline_ipaddr_t ttl;
9884 cmdline_fixed_string_t vlan;
9885 uint16_t vlan_value;
9886 cmdline_fixed_string_t flexbytes;
9887 cmdline_fixed_string_t flexbytes_value;
9888 cmdline_fixed_string_t pf_vf;
9889 cmdline_fixed_string_t drop;
9890 cmdline_fixed_string_t queue;
9892 cmdline_fixed_string_t fd_id;
9893 uint32_t fd_id_value;
9894 cmdline_fixed_string_t mac;
9895 struct ether_addr mac_addr;
9896 cmdline_fixed_string_t tunnel;
9897 cmdline_fixed_string_t tunnel_type;
9898 cmdline_fixed_string_t tunnel_id;
9899 uint32_t tunnel_id_value;
9900 cmdline_fixed_string_t packet;
9905 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9908 const char *p, *p0 = q_arg;
9910 unsigned long int_fld;
9911 char *str_fld[max_num];
9916 p = strchr(p0, '(');
9920 p0 = strchr(p, ')');
9925 if (size >= sizeof(s))
9928 snprintf(s, sizeof(s), "%.*s", size, p);
9929 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9930 if (ret < 0 || ret > max_num)
9932 for (i = 0; i < ret; i++) {
9934 int_fld = strtoul(str_fld[i], &end, 0);
9935 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9937 flexbytes[i] = (uint8_t)int_fld;
9943 str2flowtype(char *string)
9946 static const struct {
9949 } flowtype_str[] = {
9950 {"raw", RTE_ETH_FLOW_RAW},
9951 {"ipv4", RTE_ETH_FLOW_IPV4},
9952 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9953 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9954 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9955 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9956 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9957 {"ipv6", RTE_ETH_FLOW_IPV6},
9958 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9959 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9960 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9961 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9962 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9963 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9966 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9967 if (!strcmp(flowtype_str[i].str, string))
9968 return flowtype_str[i].type;
9971 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9972 return (uint16_t)atoi(string);
9974 return RTE_ETH_FLOW_UNKNOWN;
9977 static enum rte_eth_fdir_tunnel_type
9978 str2fdir_tunneltype(char *string)
9982 static const struct {
9984 enum rte_eth_fdir_tunnel_type type;
9985 } tunneltype_str[] = {
9986 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9987 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9990 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9991 if (!strcmp(tunneltype_str[i].str, string))
9992 return tunneltype_str[i].type;
9994 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9997 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9999 if ((ip_addr).family == AF_INET) \
10000 (ip) = (ip_addr).addr.ipv4.s_addr; \
10002 printf("invalid parameter.\n"); \
10007 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10009 if ((ip_addr).family == AF_INET6) \
10010 rte_memcpy(&(ip), \
10011 &((ip_addr).addr.ipv6), \
10012 sizeof(struct in6_addr)); \
10014 printf("invalid parameter.\n"); \
10020 cmd_flow_director_filter_parsed(void *parsed_result,
10021 __attribute__((unused)) struct cmdline *cl,
10022 __attribute__((unused)) void *data)
10024 struct cmd_flow_director_result *res = parsed_result;
10025 struct rte_eth_fdir_filter entry;
10026 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10028 unsigned long vf_id;
10031 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10033 printf("flow director is not supported on port %u.\n",
10037 memset(flexbytes, 0, sizeof(flexbytes));
10038 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10040 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10041 if (strcmp(res->mode_value, "MAC-VLAN")) {
10042 printf("Please set mode to MAC-VLAN.\n");
10045 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10046 if (strcmp(res->mode_value, "Tunnel")) {
10047 printf("Please set mode to Tunnel.\n");
10051 if (!strcmp(res->mode_value, "raw")) {
10052 #ifdef RTE_LIBRTE_I40E_PMD
10053 struct rte_pmd_i40e_flow_type_mapping
10054 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10055 struct rte_pmd_i40e_pkt_template_conf conf;
10056 uint16_t flow_type = str2flowtype(res->flow_type);
10057 uint16_t i, port = res->port_id;
10060 memset(&conf, 0, sizeof(conf));
10062 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10063 printf("Invalid flow type specified.\n");
10066 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10070 if (mapping[flow_type].pctype == 0ULL) {
10071 printf("Invalid flow type specified.\n");
10074 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10075 if (mapping[flow_type].pctype & (1ULL << i)) {
10076 conf.input.pctype = i;
10081 conf.input.packet = open_file(res->filepath,
10082 &conf.input.length);
10083 if (!conf.input.packet)
10085 if (!strcmp(res->drop, "drop"))
10086 conf.action.behavior =
10087 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10089 conf.action.behavior =
10090 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10091 conf.action.report_status =
10092 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10093 conf.action.rx_queue = res->queue_id;
10094 conf.soft_id = res->fd_id_value;
10095 add = strcmp(res->ops, "del") ? 1 : 0;
10096 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10100 printf("flow director config error: (%s)\n",
10102 close_file(conf.input.packet);
10105 } else if (strcmp(res->mode_value, "IP")) {
10106 printf("Please set mode to IP or raw.\n");
10109 entry.input.flow_type = str2flowtype(res->flow_type);
10112 ret = parse_flexbytes(res->flexbytes_value,
10114 RTE_ETH_FDIR_MAX_FLEXLEN);
10116 printf("error: Cannot parse flexbytes input.\n");
10120 switch (entry.input.flow_type) {
10121 case RTE_ETH_FLOW_FRAG_IPV4:
10122 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10123 entry.input.flow.ip4_flow.proto = res->proto_value;
10125 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10126 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10127 IPV4_ADDR_TO_UINT(res->ip_dst,
10128 entry.input.flow.ip4_flow.dst_ip);
10129 IPV4_ADDR_TO_UINT(res->ip_src,
10130 entry.input.flow.ip4_flow.src_ip);
10131 entry.input.flow.ip4_flow.tos = res->tos_value;
10132 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10133 /* need convert to big endian. */
10134 entry.input.flow.udp4_flow.dst_port =
10135 rte_cpu_to_be_16(res->port_dst);
10136 entry.input.flow.udp4_flow.src_port =
10137 rte_cpu_to_be_16(res->port_src);
10139 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10140 IPV4_ADDR_TO_UINT(res->ip_dst,
10141 entry.input.flow.sctp4_flow.ip.dst_ip);
10142 IPV4_ADDR_TO_UINT(res->ip_src,
10143 entry.input.flow.sctp4_flow.ip.src_ip);
10144 entry.input.flow.ip4_flow.tos = res->tos_value;
10145 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10146 /* need convert to big endian. */
10147 entry.input.flow.sctp4_flow.dst_port =
10148 rte_cpu_to_be_16(res->port_dst);
10149 entry.input.flow.sctp4_flow.src_port =
10150 rte_cpu_to_be_16(res->port_src);
10151 entry.input.flow.sctp4_flow.verify_tag =
10152 rte_cpu_to_be_32(res->verify_tag_value);
10154 case RTE_ETH_FLOW_FRAG_IPV6:
10155 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10156 entry.input.flow.ipv6_flow.proto = res->proto_value;
10158 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10159 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10160 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10161 entry.input.flow.ipv6_flow.dst_ip);
10162 IPV6_ADDR_TO_ARRAY(res->ip_src,
10163 entry.input.flow.ipv6_flow.src_ip);
10164 entry.input.flow.ipv6_flow.tc = res->tos_value;
10165 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10166 /* need convert to big endian. */
10167 entry.input.flow.udp6_flow.dst_port =
10168 rte_cpu_to_be_16(res->port_dst);
10169 entry.input.flow.udp6_flow.src_port =
10170 rte_cpu_to_be_16(res->port_src);
10172 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10173 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10174 entry.input.flow.sctp6_flow.ip.dst_ip);
10175 IPV6_ADDR_TO_ARRAY(res->ip_src,
10176 entry.input.flow.sctp6_flow.ip.src_ip);
10177 entry.input.flow.ipv6_flow.tc = res->tos_value;
10178 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10179 /* need convert to big endian. */
10180 entry.input.flow.sctp6_flow.dst_port =
10181 rte_cpu_to_be_16(res->port_dst);
10182 entry.input.flow.sctp6_flow.src_port =
10183 rte_cpu_to_be_16(res->port_src);
10184 entry.input.flow.sctp6_flow.verify_tag =
10185 rte_cpu_to_be_32(res->verify_tag_value);
10187 case RTE_ETH_FLOW_L2_PAYLOAD:
10188 entry.input.flow.l2_flow.ether_type =
10189 rte_cpu_to_be_16(res->ether_type);
10195 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10196 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10198 sizeof(struct ether_addr));
10200 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10201 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10203 sizeof(struct ether_addr));
10204 entry.input.flow.tunnel_flow.tunnel_type =
10205 str2fdir_tunneltype(res->tunnel_type);
10206 entry.input.flow.tunnel_flow.tunnel_id =
10207 rte_cpu_to_be_32(res->tunnel_id_value);
10210 rte_memcpy(entry.input.flow_ext.flexbytes,
10212 RTE_ETH_FDIR_MAX_FLEXLEN);
10214 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10216 entry.action.flex_off = 0; /*use 0 by default */
10217 if (!strcmp(res->drop, "drop"))
10218 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10220 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10222 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10223 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10224 if (!strcmp(res->pf_vf, "pf"))
10225 entry.input.flow_ext.is_vf = 0;
10226 else if (!strncmp(res->pf_vf, "vf", 2)) {
10227 struct rte_eth_dev_info dev_info;
10229 memset(&dev_info, 0, sizeof(dev_info));
10230 rte_eth_dev_info_get(res->port_id, &dev_info);
10232 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10233 if (errno != 0 || *end != '\0' ||
10234 vf_id >= dev_info.max_vfs) {
10235 printf("invalid parameter %s.\n", res->pf_vf);
10238 entry.input.flow_ext.is_vf = 1;
10239 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10241 printf("invalid parameter %s.\n", res->pf_vf);
10246 /* set to report FD ID by default */
10247 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10248 entry.action.rx_queue = res->queue_id;
10249 entry.soft_id = res->fd_id_value;
10250 if (!strcmp(res->ops, "add"))
10251 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10252 RTE_ETH_FILTER_ADD, &entry);
10253 else if (!strcmp(res->ops, "del"))
10254 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10255 RTE_ETH_FILTER_DELETE, &entry);
10257 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10258 RTE_ETH_FILTER_UPDATE, &entry);
10260 printf("flow director programming error: (%s)\n",
10264 cmdline_parse_token_string_t cmd_flow_director_filter =
10265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10266 flow_director_filter, "flow_director_filter");
10267 cmdline_parse_token_num_t cmd_flow_director_port_id =
10268 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10270 cmdline_parse_token_string_t cmd_flow_director_ops =
10271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10272 ops, "add#del#update");
10273 cmdline_parse_token_string_t cmd_flow_director_flow =
10274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10276 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10279 cmdline_parse_token_string_t cmd_flow_director_ether =
10280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10282 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10283 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10284 ether_type, UINT16);
10285 cmdline_parse_token_string_t cmd_flow_director_src =
10286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10288 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10289 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10291 cmdline_parse_token_num_t cmd_flow_director_port_src =
10292 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10294 cmdline_parse_token_string_t cmd_flow_director_dst =
10295 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10297 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10298 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10300 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10301 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10303 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10304 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10305 verify_tag, "verify_tag");
10306 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10307 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10308 verify_tag_value, UINT32);
10309 cmdline_parse_token_string_t cmd_flow_director_tos =
10310 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10312 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10313 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10315 cmdline_parse_token_string_t cmd_flow_director_proto =
10316 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10318 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10319 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10320 proto_value, UINT8);
10321 cmdline_parse_token_string_t cmd_flow_director_ttl =
10322 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10324 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10325 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10327 cmdline_parse_token_string_t cmd_flow_director_vlan =
10328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10330 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10331 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10332 vlan_value, UINT16);
10333 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10334 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10335 flexbytes, "flexbytes");
10336 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10337 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10338 flexbytes_value, NULL);
10339 cmdline_parse_token_string_t cmd_flow_director_drop =
10340 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10342 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10343 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10345 cmdline_parse_token_string_t cmd_flow_director_queue =
10346 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10348 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10349 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10351 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10352 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10354 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10355 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10356 fd_id_value, UINT32);
10358 cmdline_parse_token_string_t cmd_flow_director_mode =
10359 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10361 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10364 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10366 mode_value, "MAC-VLAN");
10367 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10368 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10369 mode_value, "Tunnel");
10370 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10371 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10372 mode_value, "raw");
10373 cmdline_parse_token_string_t cmd_flow_director_mac =
10374 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10376 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10377 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10379 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10380 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10382 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10383 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10384 tunnel_type, "NVGRE#VxLAN");
10385 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10386 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10387 tunnel_id, "tunnel-id");
10388 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10389 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10390 tunnel_id_value, UINT32);
10391 cmdline_parse_token_string_t cmd_flow_director_packet =
10392 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10394 cmdline_parse_token_string_t cmd_flow_director_filepath =
10395 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10398 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10399 .f = cmd_flow_director_filter_parsed,
10401 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10402 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10403 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10404 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10405 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10406 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10407 "fd_id <fd_id_value>: "
10408 "Add or delete an ip flow director entry on NIC",
10410 (void *)&cmd_flow_director_filter,
10411 (void *)&cmd_flow_director_port_id,
10412 (void *)&cmd_flow_director_mode,
10413 (void *)&cmd_flow_director_mode_ip,
10414 (void *)&cmd_flow_director_ops,
10415 (void *)&cmd_flow_director_flow,
10416 (void *)&cmd_flow_director_flow_type,
10417 (void *)&cmd_flow_director_src,
10418 (void *)&cmd_flow_director_ip_src,
10419 (void *)&cmd_flow_director_dst,
10420 (void *)&cmd_flow_director_ip_dst,
10421 (void *)&cmd_flow_director_tos,
10422 (void *)&cmd_flow_director_tos_value,
10423 (void *)&cmd_flow_director_proto,
10424 (void *)&cmd_flow_director_proto_value,
10425 (void *)&cmd_flow_director_ttl,
10426 (void *)&cmd_flow_director_ttl_value,
10427 (void *)&cmd_flow_director_vlan,
10428 (void *)&cmd_flow_director_vlan_value,
10429 (void *)&cmd_flow_director_flexbytes,
10430 (void *)&cmd_flow_director_flexbytes_value,
10431 (void *)&cmd_flow_director_drop,
10432 (void *)&cmd_flow_director_pf_vf,
10433 (void *)&cmd_flow_director_queue,
10434 (void *)&cmd_flow_director_queue_id,
10435 (void *)&cmd_flow_director_fd_id,
10436 (void *)&cmd_flow_director_fd_id_value,
10441 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10442 .f = cmd_flow_director_filter_parsed,
10444 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10445 "director entry on NIC",
10447 (void *)&cmd_flow_director_filter,
10448 (void *)&cmd_flow_director_port_id,
10449 (void *)&cmd_flow_director_mode,
10450 (void *)&cmd_flow_director_mode_ip,
10451 (void *)&cmd_flow_director_ops,
10452 (void *)&cmd_flow_director_flow,
10453 (void *)&cmd_flow_director_flow_type,
10454 (void *)&cmd_flow_director_src,
10455 (void *)&cmd_flow_director_ip_src,
10456 (void *)&cmd_flow_director_port_src,
10457 (void *)&cmd_flow_director_dst,
10458 (void *)&cmd_flow_director_ip_dst,
10459 (void *)&cmd_flow_director_port_dst,
10460 (void *)&cmd_flow_director_tos,
10461 (void *)&cmd_flow_director_tos_value,
10462 (void *)&cmd_flow_director_ttl,
10463 (void *)&cmd_flow_director_ttl_value,
10464 (void *)&cmd_flow_director_vlan,
10465 (void *)&cmd_flow_director_vlan_value,
10466 (void *)&cmd_flow_director_flexbytes,
10467 (void *)&cmd_flow_director_flexbytes_value,
10468 (void *)&cmd_flow_director_drop,
10469 (void *)&cmd_flow_director_pf_vf,
10470 (void *)&cmd_flow_director_queue,
10471 (void *)&cmd_flow_director_queue_id,
10472 (void *)&cmd_flow_director_fd_id,
10473 (void *)&cmd_flow_director_fd_id_value,
10478 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10479 .f = cmd_flow_director_filter_parsed,
10481 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10482 "director entry on NIC",
10484 (void *)&cmd_flow_director_filter,
10485 (void *)&cmd_flow_director_port_id,
10486 (void *)&cmd_flow_director_mode,
10487 (void *)&cmd_flow_director_mode_ip,
10488 (void *)&cmd_flow_director_ops,
10489 (void *)&cmd_flow_director_flow,
10490 (void *)&cmd_flow_director_flow_type,
10491 (void *)&cmd_flow_director_src,
10492 (void *)&cmd_flow_director_ip_src,
10493 (void *)&cmd_flow_director_port_dst,
10494 (void *)&cmd_flow_director_dst,
10495 (void *)&cmd_flow_director_ip_dst,
10496 (void *)&cmd_flow_director_port_dst,
10497 (void *)&cmd_flow_director_verify_tag,
10498 (void *)&cmd_flow_director_verify_tag_value,
10499 (void *)&cmd_flow_director_tos,
10500 (void *)&cmd_flow_director_tos_value,
10501 (void *)&cmd_flow_director_ttl,
10502 (void *)&cmd_flow_director_ttl_value,
10503 (void *)&cmd_flow_director_vlan,
10504 (void *)&cmd_flow_director_vlan_value,
10505 (void *)&cmd_flow_director_flexbytes,
10506 (void *)&cmd_flow_director_flexbytes_value,
10507 (void *)&cmd_flow_director_drop,
10508 (void *)&cmd_flow_director_pf_vf,
10509 (void *)&cmd_flow_director_queue,
10510 (void *)&cmd_flow_director_queue_id,
10511 (void *)&cmd_flow_director_fd_id,
10512 (void *)&cmd_flow_director_fd_id_value,
10517 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10518 .f = cmd_flow_director_filter_parsed,
10520 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10521 "director entry on NIC",
10523 (void *)&cmd_flow_director_filter,
10524 (void *)&cmd_flow_director_port_id,
10525 (void *)&cmd_flow_director_mode,
10526 (void *)&cmd_flow_director_mode_ip,
10527 (void *)&cmd_flow_director_ops,
10528 (void *)&cmd_flow_director_flow,
10529 (void *)&cmd_flow_director_flow_type,
10530 (void *)&cmd_flow_director_ether,
10531 (void *)&cmd_flow_director_ether_type,
10532 (void *)&cmd_flow_director_flexbytes,
10533 (void *)&cmd_flow_director_flexbytes_value,
10534 (void *)&cmd_flow_director_drop,
10535 (void *)&cmd_flow_director_pf_vf,
10536 (void *)&cmd_flow_director_queue,
10537 (void *)&cmd_flow_director_queue_id,
10538 (void *)&cmd_flow_director_fd_id,
10539 (void *)&cmd_flow_director_fd_id_value,
10544 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10545 .f = cmd_flow_director_filter_parsed,
10547 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10548 "director entry on NIC",
10550 (void *)&cmd_flow_director_filter,
10551 (void *)&cmd_flow_director_port_id,
10552 (void *)&cmd_flow_director_mode,
10553 (void *)&cmd_flow_director_mode_mac_vlan,
10554 (void *)&cmd_flow_director_ops,
10555 (void *)&cmd_flow_director_mac,
10556 (void *)&cmd_flow_director_mac_addr,
10557 (void *)&cmd_flow_director_vlan,
10558 (void *)&cmd_flow_director_vlan_value,
10559 (void *)&cmd_flow_director_flexbytes,
10560 (void *)&cmd_flow_director_flexbytes_value,
10561 (void *)&cmd_flow_director_drop,
10562 (void *)&cmd_flow_director_queue,
10563 (void *)&cmd_flow_director_queue_id,
10564 (void *)&cmd_flow_director_fd_id,
10565 (void *)&cmd_flow_director_fd_id_value,
10570 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10571 .f = cmd_flow_director_filter_parsed,
10573 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10574 "director entry on NIC",
10576 (void *)&cmd_flow_director_filter,
10577 (void *)&cmd_flow_director_port_id,
10578 (void *)&cmd_flow_director_mode,
10579 (void *)&cmd_flow_director_mode_tunnel,
10580 (void *)&cmd_flow_director_ops,
10581 (void *)&cmd_flow_director_mac,
10582 (void *)&cmd_flow_director_mac_addr,
10583 (void *)&cmd_flow_director_vlan,
10584 (void *)&cmd_flow_director_vlan_value,
10585 (void *)&cmd_flow_director_tunnel,
10586 (void *)&cmd_flow_director_tunnel_type,
10587 (void *)&cmd_flow_director_tunnel_id,
10588 (void *)&cmd_flow_director_tunnel_id_value,
10589 (void *)&cmd_flow_director_flexbytes,
10590 (void *)&cmd_flow_director_flexbytes_value,
10591 (void *)&cmd_flow_director_drop,
10592 (void *)&cmd_flow_director_queue,
10593 (void *)&cmd_flow_director_queue_id,
10594 (void *)&cmd_flow_director_fd_id,
10595 (void *)&cmd_flow_director_fd_id_value,
10600 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10601 .f = cmd_flow_director_filter_parsed,
10603 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10604 "director entry on NIC",
10606 (void *)&cmd_flow_director_filter,
10607 (void *)&cmd_flow_director_port_id,
10608 (void *)&cmd_flow_director_mode,
10609 (void *)&cmd_flow_director_mode_raw,
10610 (void *)&cmd_flow_director_ops,
10611 (void *)&cmd_flow_director_flow,
10612 (void *)&cmd_flow_director_flow_type,
10613 (void *)&cmd_flow_director_drop,
10614 (void *)&cmd_flow_director_queue,
10615 (void *)&cmd_flow_director_queue_id,
10616 (void *)&cmd_flow_director_fd_id,
10617 (void *)&cmd_flow_director_fd_id_value,
10618 (void *)&cmd_flow_director_packet,
10619 (void *)&cmd_flow_director_filepath,
10624 struct cmd_flush_flow_director_result {
10625 cmdline_fixed_string_t flush_flow_director;
10629 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10630 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10631 flush_flow_director, "flush_flow_director");
10632 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10633 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10637 cmd_flush_flow_director_parsed(void *parsed_result,
10638 __attribute__((unused)) struct cmdline *cl,
10639 __attribute__((unused)) void *data)
10641 struct cmd_flow_director_result *res = parsed_result;
10644 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10646 printf("flow director is not supported on port %u.\n",
10651 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10652 RTE_ETH_FILTER_FLUSH, NULL);
10654 printf("flow director table flushing error: (%s)\n",
10658 cmdline_parse_inst_t cmd_flush_flow_director = {
10659 .f = cmd_flush_flow_director_parsed,
10661 .help_str = "flush_flow_director <port_id>: "
10662 "Flush all flow director entries of a device on NIC",
10664 (void *)&cmd_flush_flow_director_flush,
10665 (void *)&cmd_flush_flow_director_port_id,
10670 /* *** deal with flow director mask *** */
10671 struct cmd_flow_director_mask_result {
10672 cmdline_fixed_string_t flow_director_mask;
10674 cmdline_fixed_string_t mode;
10675 cmdline_fixed_string_t mode_value;
10676 cmdline_fixed_string_t vlan;
10677 uint16_t vlan_mask;
10678 cmdline_fixed_string_t src_mask;
10679 cmdline_ipaddr_t ipv4_src;
10680 cmdline_ipaddr_t ipv6_src;
10682 cmdline_fixed_string_t dst_mask;
10683 cmdline_ipaddr_t ipv4_dst;
10684 cmdline_ipaddr_t ipv6_dst;
10686 cmdline_fixed_string_t mac;
10687 uint8_t mac_addr_byte_mask;
10688 cmdline_fixed_string_t tunnel_id;
10689 uint32_t tunnel_id_mask;
10690 cmdline_fixed_string_t tunnel_type;
10691 uint8_t tunnel_type_mask;
10695 cmd_flow_director_mask_parsed(void *parsed_result,
10696 __attribute__((unused)) struct cmdline *cl,
10697 __attribute__((unused)) void *data)
10699 struct cmd_flow_director_mask_result *res = parsed_result;
10700 struct rte_eth_fdir_masks *mask;
10701 struct rte_port *port;
10703 if (res->port_id > nb_ports) {
10704 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10708 port = &ports[res->port_id];
10709 /** Check if the port is not started **/
10710 if (port->port_status != RTE_PORT_STOPPED) {
10711 printf("Please stop port %d first\n", res->port_id);
10715 mask = &port->dev_conf.fdir_conf.mask;
10717 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10718 if (strcmp(res->mode_value, "MAC-VLAN")) {
10719 printf("Please set mode to MAC-VLAN.\n");
10723 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10724 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10725 if (strcmp(res->mode_value, "Tunnel")) {
10726 printf("Please set mode to Tunnel.\n");
10730 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10731 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10732 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10733 mask->tunnel_type_mask = res->tunnel_type_mask;
10735 if (strcmp(res->mode_value, "IP")) {
10736 printf("Please set mode to IP.\n");
10740 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10741 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10742 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10743 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10744 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10745 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10746 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10749 cmd_reconfig_device_queue(res->port_id, 1, 1);
10752 cmdline_parse_token_string_t cmd_flow_director_mask =
10753 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10754 flow_director_mask, "flow_director_mask");
10755 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10756 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10758 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10759 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10761 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10762 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10763 vlan_mask, UINT16);
10764 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10765 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10766 src_mask, "src_mask");
10767 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10768 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10770 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10771 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10773 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10774 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10776 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10777 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10778 dst_mask, "dst_mask");
10779 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10780 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10782 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10783 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10785 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10786 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10789 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10790 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10792 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10793 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10795 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10796 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10797 mode_value, "MAC-VLAN");
10798 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10799 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10800 mode_value, "Tunnel");
10801 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10802 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10804 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10805 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10806 mac_addr_byte_mask, UINT8);
10807 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10808 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10809 tunnel_type, "tunnel-type");
10810 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10811 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10812 tunnel_type_mask, UINT8);
10813 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10814 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10815 tunnel_id, "tunnel-id");
10816 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10817 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10818 tunnel_id_mask, UINT32);
10820 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10821 .f = cmd_flow_director_mask_parsed,
10823 .help_str = "flow_director_mask ... : "
10824 "Set IP mode flow director's mask on NIC",
10826 (void *)&cmd_flow_director_mask,
10827 (void *)&cmd_flow_director_mask_port_id,
10828 (void *)&cmd_flow_director_mask_mode,
10829 (void *)&cmd_flow_director_mask_mode_ip,
10830 (void *)&cmd_flow_director_mask_vlan,
10831 (void *)&cmd_flow_director_mask_vlan_value,
10832 (void *)&cmd_flow_director_mask_src,
10833 (void *)&cmd_flow_director_mask_ipv4_src,
10834 (void *)&cmd_flow_director_mask_ipv6_src,
10835 (void *)&cmd_flow_director_mask_port_src,
10836 (void *)&cmd_flow_director_mask_dst,
10837 (void *)&cmd_flow_director_mask_ipv4_dst,
10838 (void *)&cmd_flow_director_mask_ipv6_dst,
10839 (void *)&cmd_flow_director_mask_port_dst,
10844 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10845 .f = cmd_flow_director_mask_parsed,
10847 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10848 "flow director's mask on NIC",
10850 (void *)&cmd_flow_director_mask,
10851 (void *)&cmd_flow_director_mask_port_id,
10852 (void *)&cmd_flow_director_mask_mode,
10853 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10854 (void *)&cmd_flow_director_mask_vlan,
10855 (void *)&cmd_flow_director_mask_vlan_value,
10860 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10861 .f = cmd_flow_director_mask_parsed,
10863 .help_str = "flow_director_mask ... : Set tunnel mode "
10864 "flow director's mask on NIC",
10866 (void *)&cmd_flow_director_mask,
10867 (void *)&cmd_flow_director_mask_port_id,
10868 (void *)&cmd_flow_director_mask_mode,
10869 (void *)&cmd_flow_director_mask_mode_tunnel,
10870 (void *)&cmd_flow_director_mask_vlan,
10871 (void *)&cmd_flow_director_mask_vlan_value,
10872 (void *)&cmd_flow_director_mask_mac,
10873 (void *)&cmd_flow_director_mask_mac_value,
10874 (void *)&cmd_flow_director_mask_tunnel_type,
10875 (void *)&cmd_flow_director_mask_tunnel_type_value,
10876 (void *)&cmd_flow_director_mask_tunnel_id,
10877 (void *)&cmd_flow_director_mask_tunnel_id_value,
10882 /* *** deal with flow director mask on flexible payload *** */
10883 struct cmd_flow_director_flex_mask_result {
10884 cmdline_fixed_string_t flow_director_flexmask;
10886 cmdline_fixed_string_t flow;
10887 cmdline_fixed_string_t flow_type;
10888 cmdline_fixed_string_t mask;
10892 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10893 __attribute__((unused)) struct cmdline *cl,
10894 __attribute__((unused)) void *data)
10896 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10897 struct rte_eth_fdir_info fdir_info;
10898 struct rte_eth_fdir_flex_mask flex_mask;
10899 struct rte_port *port;
10900 uint32_t flow_type_mask;
10904 if (res->port_id > nb_ports) {
10905 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10909 port = &ports[res->port_id];
10910 /** Check if the port is not started **/
10911 if (port->port_status != RTE_PORT_STOPPED) {
10912 printf("Please stop port %d first\n", res->port_id);
10916 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10917 ret = parse_flexbytes(res->mask,
10919 RTE_ETH_FDIR_MAX_FLEXLEN);
10921 printf("error: Cannot parse mask input.\n");
10925 memset(&fdir_info, 0, sizeof(fdir_info));
10926 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10927 RTE_ETH_FILTER_INFO, &fdir_info);
10929 printf("Cannot get FDir filter info\n");
10933 if (!strcmp(res->flow_type, "none")) {
10934 /* means don't specify the flow type */
10935 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10936 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10937 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10938 0, sizeof(struct rte_eth_fdir_flex_mask));
10939 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10940 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10942 sizeof(struct rte_eth_fdir_flex_mask));
10943 cmd_reconfig_device_queue(res->port_id, 1, 1);
10946 flow_type_mask = fdir_info.flow_types_mask[0];
10947 if (!strcmp(res->flow_type, "all")) {
10948 if (!flow_type_mask) {
10949 printf("No flow type supported\n");
10952 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10953 if (flow_type_mask & (1 << i)) {
10954 flex_mask.flow_type = i;
10955 fdir_set_flex_mask(res->port_id, &flex_mask);
10958 cmd_reconfig_device_queue(res->port_id, 1, 1);
10961 flex_mask.flow_type = str2flowtype(res->flow_type);
10962 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10963 printf("Flow type %s not supported on port %d\n",
10964 res->flow_type, res->port_id);
10967 fdir_set_flex_mask(res->port_id, &flex_mask);
10968 cmd_reconfig_device_queue(res->port_id, 1, 1);
10971 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10972 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10973 flow_director_flexmask,
10974 "flow_director_flex_mask");
10975 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10976 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10978 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10979 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10981 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10982 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10983 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10984 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10985 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10986 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10989 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10990 .f = cmd_flow_director_flex_mask_parsed,
10992 .help_str = "flow_director_flex_mask ... : "
10993 "Set flow director's flex mask on NIC",
10995 (void *)&cmd_flow_director_flexmask,
10996 (void *)&cmd_flow_director_flexmask_port_id,
10997 (void *)&cmd_flow_director_flexmask_flow,
10998 (void *)&cmd_flow_director_flexmask_flow_type,
10999 (void *)&cmd_flow_director_flexmask_mask,
11004 /* *** deal with flow director flexible payload configuration *** */
11005 struct cmd_flow_director_flexpayload_result {
11006 cmdline_fixed_string_t flow_director_flexpayload;
11008 cmdline_fixed_string_t payload_layer;
11009 cmdline_fixed_string_t payload_cfg;
11013 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11016 const char *p, *p0 = q_arg;
11018 unsigned long int_fld;
11019 char *str_fld[max_num];
11024 p = strchr(p0, '(');
11028 p0 = strchr(p, ')');
11033 if (size >= sizeof(s))
11036 snprintf(s, sizeof(s), "%.*s", size, p);
11037 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11038 if (ret < 0 || ret > max_num)
11040 for (i = 0; i < ret; i++) {
11042 int_fld = strtoul(str_fld[i], &end, 0);
11043 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11045 offsets[i] = (uint16_t)int_fld;
11051 cmd_flow_director_flxpld_parsed(void *parsed_result,
11052 __attribute__((unused)) struct cmdline *cl,
11053 __attribute__((unused)) void *data)
11055 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11056 struct rte_eth_flex_payload_cfg flex_cfg;
11057 struct rte_port *port;
11060 if (res->port_id > nb_ports) {
11061 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
11065 port = &ports[res->port_id];
11066 /** Check if the port is not started **/
11067 if (port->port_status != RTE_PORT_STOPPED) {
11068 printf("Please stop port %d first\n", res->port_id);
11072 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11074 if (!strcmp(res->payload_layer, "raw"))
11075 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11076 else if (!strcmp(res->payload_layer, "l2"))
11077 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11078 else if (!strcmp(res->payload_layer, "l3"))
11079 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11080 else if (!strcmp(res->payload_layer, "l4"))
11081 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11083 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11084 RTE_ETH_FDIR_MAX_FLEXLEN);
11086 printf("error: Cannot parse flex payload input.\n");
11090 fdir_set_flex_payload(res->port_id, &flex_cfg);
11091 cmd_reconfig_device_queue(res->port_id, 1, 1);
11094 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11095 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11096 flow_director_flexpayload,
11097 "flow_director_flex_payload");
11098 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11099 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11101 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11102 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11103 payload_layer, "raw#l2#l3#l4");
11104 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11105 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11106 payload_cfg, NULL);
11108 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11109 .f = cmd_flow_director_flxpld_parsed,
11111 .help_str = "flow_director_flexpayload ... : "
11112 "Set flow director's flex payload on NIC",
11114 (void *)&cmd_flow_director_flexpayload,
11115 (void *)&cmd_flow_director_flexpayload_port_id,
11116 (void *)&cmd_flow_director_flexpayload_payload_layer,
11117 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11122 /* Generic flow interface command. */
11123 extern cmdline_parse_inst_t cmd_flow;
11125 /* *** Classification Filters Control *** */
11126 /* *** Get symmetric hash enable per port *** */
11127 struct cmd_get_sym_hash_ena_per_port_result {
11128 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11133 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11134 __rte_unused struct cmdline *cl,
11135 __rte_unused void *data)
11137 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11138 struct rte_eth_hash_filter_info info;
11141 if (rte_eth_dev_filter_supported(res->port_id,
11142 RTE_ETH_FILTER_HASH) < 0) {
11143 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11148 memset(&info, 0, sizeof(info));
11149 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11150 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11151 RTE_ETH_FILTER_GET, &info);
11154 printf("Cannot get symmetric hash enable per port "
11155 "on port %u\n", res->port_id);
11159 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11160 "enabled" : "disabled", res->port_id);
11163 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11164 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11165 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11166 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11167 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11170 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11171 .f = cmd_get_sym_hash_per_port_parsed,
11173 .help_str = "get_sym_hash_ena_per_port <port_id>",
11175 (void *)&cmd_get_sym_hash_ena_per_port_all,
11176 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11181 /* *** Set symmetric hash enable per port *** */
11182 struct cmd_set_sym_hash_ena_per_port_result {
11183 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11184 cmdline_fixed_string_t enable;
11189 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11190 __rte_unused struct cmdline *cl,
11191 __rte_unused void *data)
11193 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11194 struct rte_eth_hash_filter_info info;
11197 if (rte_eth_dev_filter_supported(res->port_id,
11198 RTE_ETH_FILTER_HASH) < 0) {
11199 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11204 memset(&info, 0, sizeof(info));
11205 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11206 if (!strcmp(res->enable, "enable"))
11207 info.info.enable = 1;
11208 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11209 RTE_ETH_FILTER_SET, &info);
11211 printf("Cannot set symmetric hash enable per port on "
11212 "port %u\n", res->port_id);
11215 printf("Symmetric hash has been set to %s on port %u\n",
11216 res->enable, res->port_id);
11219 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11220 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11221 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11222 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11223 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11225 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11226 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11227 enable, "enable#disable");
11229 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11230 .f = cmd_set_sym_hash_per_port_parsed,
11232 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11234 (void *)&cmd_set_sym_hash_ena_per_port_all,
11235 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11236 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11241 /* Get global config of hash function */
11242 struct cmd_get_hash_global_config_result {
11243 cmdline_fixed_string_t get_hash_global_config;
11248 flowtype_to_str(uint16_t ftype)
11254 } ftype_table[] = {
11255 {"ipv4", RTE_ETH_FLOW_IPV4},
11256 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11257 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11258 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11259 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11260 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11261 {"ipv6", RTE_ETH_FLOW_IPV6},
11262 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11263 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11264 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11265 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11266 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11267 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11268 {"port", RTE_ETH_FLOW_PORT},
11269 {"vxlan", RTE_ETH_FLOW_VXLAN},
11270 {"geneve", RTE_ETH_FLOW_GENEVE},
11271 {"nvgre", RTE_ETH_FLOW_NVGRE},
11274 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11275 if (ftype_table[i].ftype == ftype)
11276 return ftype_table[i].str;
11283 cmd_get_hash_global_config_parsed(void *parsed_result,
11284 __rte_unused struct cmdline *cl,
11285 __rte_unused void *data)
11287 struct cmd_get_hash_global_config_result *res = parsed_result;
11288 struct rte_eth_hash_filter_info info;
11289 uint32_t idx, offset;
11294 if (rte_eth_dev_filter_supported(res->port_id,
11295 RTE_ETH_FILTER_HASH) < 0) {
11296 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11301 memset(&info, 0, sizeof(info));
11302 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11303 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11304 RTE_ETH_FILTER_GET, &info);
11306 printf("Cannot get hash global configurations by port %d\n",
11311 switch (info.info.global_conf.hash_func) {
11312 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11313 printf("Hash function is Toeplitz\n");
11315 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11316 printf("Hash function is Simple XOR\n");
11319 printf("Unknown hash function\n");
11323 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11324 idx = i / UINT32_BIT;
11325 offset = i % UINT32_BIT;
11326 if (!(info.info.global_conf.valid_bit_mask[idx] &
11329 str = flowtype_to_str(i);
11332 printf("Symmetric hash is %s globally for flow type %s "
11334 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11335 (1UL << offset)) ? "enabled" : "disabled"), str,
11340 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11341 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11342 get_hash_global_config, "get_hash_global_config");
11343 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11344 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11347 cmdline_parse_inst_t cmd_get_hash_global_config = {
11348 .f = cmd_get_hash_global_config_parsed,
11350 .help_str = "get_hash_global_config <port_id>",
11352 (void *)&cmd_get_hash_global_config_all,
11353 (void *)&cmd_get_hash_global_config_port_id,
11358 /* Set global config of hash function */
11359 struct cmd_set_hash_global_config_result {
11360 cmdline_fixed_string_t set_hash_global_config;
11362 cmdline_fixed_string_t hash_func;
11363 cmdline_fixed_string_t flow_type;
11364 cmdline_fixed_string_t enable;
11368 cmd_set_hash_global_config_parsed(void *parsed_result,
11369 __rte_unused struct cmdline *cl,
11370 __rte_unused void *data)
11372 struct cmd_set_hash_global_config_result *res = parsed_result;
11373 struct rte_eth_hash_filter_info info;
11374 uint32_t ftype, idx, offset;
11377 if (rte_eth_dev_filter_supported(res->port_id,
11378 RTE_ETH_FILTER_HASH) < 0) {
11379 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11383 memset(&info, 0, sizeof(info));
11384 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11385 if (!strcmp(res->hash_func, "toeplitz"))
11386 info.info.global_conf.hash_func =
11387 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11388 else if (!strcmp(res->hash_func, "simple_xor"))
11389 info.info.global_conf.hash_func =
11390 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11391 else if (!strcmp(res->hash_func, "default"))
11392 info.info.global_conf.hash_func =
11393 RTE_ETH_HASH_FUNCTION_DEFAULT;
11395 ftype = str2flowtype(res->flow_type);
11396 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11397 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11398 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11399 if (!strcmp(res->enable, "enable"))
11400 info.info.global_conf.sym_hash_enable_mask[idx] |=
11402 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11403 RTE_ETH_FILTER_SET, &info);
11405 printf("Cannot set global hash configurations by port %d\n",
11408 printf("Global hash configurations have been set "
11409 "succcessfully by port %d\n", res->port_id);
11412 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11413 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11414 set_hash_global_config, "set_hash_global_config");
11415 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11416 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11418 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11419 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11420 hash_func, "toeplitz#simple_xor#default");
11421 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11422 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11424 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11425 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11426 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11427 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11428 enable, "enable#disable");
11430 cmdline_parse_inst_t cmd_set_hash_global_config = {
11431 .f = cmd_set_hash_global_config_parsed,
11433 .help_str = "set_hash_global_config <port_id> "
11434 "toeplitz|simple_xor|default "
11435 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11436 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11437 "l2_payload enable|disable",
11439 (void *)&cmd_set_hash_global_config_all,
11440 (void *)&cmd_set_hash_global_config_port_id,
11441 (void *)&cmd_set_hash_global_config_hash_func,
11442 (void *)&cmd_set_hash_global_config_flow_type,
11443 (void *)&cmd_set_hash_global_config_enable,
11448 /* Set hash input set */
11449 struct cmd_set_hash_input_set_result {
11450 cmdline_fixed_string_t set_hash_input_set;
11452 cmdline_fixed_string_t flow_type;
11453 cmdline_fixed_string_t inset_field;
11454 cmdline_fixed_string_t select;
11457 static enum rte_eth_input_set_field
11458 str2inset(char *string)
11462 static const struct {
11464 enum rte_eth_input_set_field inset;
11465 } inset_table[] = {
11466 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11467 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11468 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11469 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11470 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11471 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11472 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11473 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11474 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11475 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11476 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11477 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11478 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11479 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11480 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11481 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11482 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11483 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11484 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11485 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11486 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11487 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11488 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11489 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11490 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11491 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11492 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11493 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11494 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11495 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11496 {"none", RTE_ETH_INPUT_SET_NONE},
11499 for (i = 0; i < RTE_DIM(inset_table); i++) {
11500 if (!strcmp(string, inset_table[i].str))
11501 return inset_table[i].inset;
11504 return RTE_ETH_INPUT_SET_UNKNOWN;
11508 cmd_set_hash_input_set_parsed(void *parsed_result,
11509 __rte_unused struct cmdline *cl,
11510 __rte_unused void *data)
11512 struct cmd_set_hash_input_set_result *res = parsed_result;
11513 struct rte_eth_hash_filter_info info;
11515 memset(&info, 0, sizeof(info));
11516 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11517 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11518 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11519 info.info.input_set_conf.inset_size = 1;
11520 if (!strcmp(res->select, "select"))
11521 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11522 else if (!strcmp(res->select, "add"))
11523 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11524 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11525 RTE_ETH_FILTER_SET, &info);
11528 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11529 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11530 set_hash_input_set, "set_hash_input_set");
11531 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11532 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11534 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11535 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11537 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11538 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11540 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11541 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11542 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11543 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11544 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11546 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11547 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11548 select, "select#add");
11550 cmdline_parse_inst_t cmd_set_hash_input_set = {
11551 .f = cmd_set_hash_input_set_parsed,
11553 .help_str = "set_hash_input_set <port_id> "
11554 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11555 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11556 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11557 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11558 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11559 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11560 "fld-7th|fld-8th|none select|add",
11562 (void *)&cmd_set_hash_input_set_cmd,
11563 (void *)&cmd_set_hash_input_set_port_id,
11564 (void *)&cmd_set_hash_input_set_flow_type,
11565 (void *)&cmd_set_hash_input_set_field,
11566 (void *)&cmd_set_hash_input_set_select,
11571 /* Set flow director input set */
11572 struct cmd_set_fdir_input_set_result {
11573 cmdline_fixed_string_t set_fdir_input_set;
11575 cmdline_fixed_string_t flow_type;
11576 cmdline_fixed_string_t inset_field;
11577 cmdline_fixed_string_t select;
11581 cmd_set_fdir_input_set_parsed(void *parsed_result,
11582 __rte_unused struct cmdline *cl,
11583 __rte_unused void *data)
11585 struct cmd_set_fdir_input_set_result *res = parsed_result;
11586 struct rte_eth_fdir_filter_info info;
11588 memset(&info, 0, sizeof(info));
11589 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11590 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11591 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11592 info.info.input_set_conf.inset_size = 1;
11593 if (!strcmp(res->select, "select"))
11594 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11595 else if (!strcmp(res->select, "add"))
11596 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11597 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11598 RTE_ETH_FILTER_SET, &info);
11601 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11602 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11603 set_fdir_input_set, "set_fdir_input_set");
11604 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11605 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11607 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11608 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11610 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11611 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11612 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11613 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11615 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11616 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11617 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11618 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11619 "sctp-veri-tag#none");
11620 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11621 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11622 select, "select#add");
11624 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11625 .f = cmd_set_fdir_input_set_parsed,
11627 .help_str = "set_fdir_input_set <port_id> "
11628 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11629 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11630 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11631 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11632 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11633 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11634 "sctp-veri-tag|none select|add",
11636 (void *)&cmd_set_fdir_input_set_cmd,
11637 (void *)&cmd_set_fdir_input_set_port_id,
11638 (void *)&cmd_set_fdir_input_set_flow_type,
11639 (void *)&cmd_set_fdir_input_set_field,
11640 (void *)&cmd_set_fdir_input_set_select,
11645 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11646 struct cmd_mcast_addr_result {
11647 cmdline_fixed_string_t mcast_addr_cmd;
11648 cmdline_fixed_string_t what;
11650 struct ether_addr mc_addr;
11653 static void cmd_mcast_addr_parsed(void *parsed_result,
11654 __attribute__((unused)) struct cmdline *cl,
11655 __attribute__((unused)) void *data)
11657 struct cmd_mcast_addr_result *res = parsed_result;
11659 if (!is_multicast_ether_addr(&res->mc_addr)) {
11660 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11661 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11662 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11663 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11666 if (strcmp(res->what, "add") == 0)
11667 mcast_addr_add(res->port_num, &res->mc_addr);
11669 mcast_addr_remove(res->port_num, &res->mc_addr);
11672 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11673 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11674 mcast_addr_cmd, "mcast_addr");
11675 cmdline_parse_token_string_t cmd_mcast_addr_what =
11676 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11678 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11679 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11680 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11681 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11683 cmdline_parse_inst_t cmd_mcast_addr = {
11684 .f = cmd_mcast_addr_parsed,
11686 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11687 "Add/Remove multicast MAC address on port_id",
11689 (void *)&cmd_mcast_addr_cmd,
11690 (void *)&cmd_mcast_addr_what,
11691 (void *)&cmd_mcast_addr_portnum,
11692 (void *)&cmd_mcast_addr_addr,
11697 /* l2 tunnel config
11698 * only support E-tag now.
11701 /* Ether type config */
11702 struct cmd_config_l2_tunnel_eth_type_result {
11703 cmdline_fixed_string_t port;
11704 cmdline_fixed_string_t config;
11705 cmdline_fixed_string_t all;
11707 cmdline_fixed_string_t l2_tunnel;
11708 cmdline_fixed_string_t l2_tunnel_type;
11709 cmdline_fixed_string_t eth_type;
11710 uint16_t eth_type_val;
11713 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11714 TOKEN_STRING_INITIALIZER
11715 (struct cmd_config_l2_tunnel_eth_type_result,
11717 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11718 TOKEN_STRING_INITIALIZER
11719 (struct cmd_config_l2_tunnel_eth_type_result,
11721 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11722 TOKEN_STRING_INITIALIZER
11723 (struct cmd_config_l2_tunnel_eth_type_result,
11725 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11726 TOKEN_NUM_INITIALIZER
11727 (struct cmd_config_l2_tunnel_eth_type_result,
11729 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11730 TOKEN_STRING_INITIALIZER
11731 (struct cmd_config_l2_tunnel_eth_type_result,
11732 l2_tunnel, "l2-tunnel");
11733 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11734 TOKEN_STRING_INITIALIZER
11735 (struct cmd_config_l2_tunnel_eth_type_result,
11736 l2_tunnel_type, "E-tag");
11737 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11738 TOKEN_STRING_INITIALIZER
11739 (struct cmd_config_l2_tunnel_eth_type_result,
11740 eth_type, "ether-type");
11741 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11742 TOKEN_NUM_INITIALIZER
11743 (struct cmd_config_l2_tunnel_eth_type_result,
11744 eth_type_val, UINT16);
11746 static enum rte_eth_tunnel_type
11747 str2fdir_l2_tunnel_type(char *string)
11751 static const struct {
11753 enum rte_eth_tunnel_type type;
11754 } l2_tunnel_type_str[] = {
11755 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11758 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11759 if (!strcmp(l2_tunnel_type_str[i].str, string))
11760 return l2_tunnel_type_str[i].type;
11762 return RTE_TUNNEL_TYPE_NONE;
11765 /* ether type config for all ports */
11767 cmd_config_l2_tunnel_eth_type_all_parsed
11768 (void *parsed_result,
11769 __attribute__((unused)) struct cmdline *cl,
11770 __attribute__((unused)) void *data)
11772 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11773 struct rte_eth_l2_tunnel_conf entry;
11776 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11777 entry.ether_type = res->eth_type_val;
11779 RTE_ETH_FOREACH_DEV(pid) {
11780 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11784 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11785 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11787 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11789 (void *)&cmd_config_l2_tunnel_eth_type_port,
11790 (void *)&cmd_config_l2_tunnel_eth_type_config,
11791 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11792 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11793 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11794 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11795 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11800 /* ether type config for a specific port */
11802 cmd_config_l2_tunnel_eth_type_specific_parsed(
11803 void *parsed_result,
11804 __attribute__((unused)) struct cmdline *cl,
11805 __attribute__((unused)) void *data)
11807 struct cmd_config_l2_tunnel_eth_type_result *res =
11809 struct rte_eth_l2_tunnel_conf entry;
11811 if (port_id_is_invalid(res->id, ENABLED_WARN))
11814 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11815 entry.ether_type = res->eth_type_val;
11817 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11820 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11821 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11823 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11825 (void *)&cmd_config_l2_tunnel_eth_type_port,
11826 (void *)&cmd_config_l2_tunnel_eth_type_config,
11827 (void *)&cmd_config_l2_tunnel_eth_type_id,
11828 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11829 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11830 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11831 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11836 /* Enable/disable l2 tunnel */
11837 struct cmd_config_l2_tunnel_en_dis_result {
11838 cmdline_fixed_string_t port;
11839 cmdline_fixed_string_t config;
11840 cmdline_fixed_string_t all;
11842 cmdline_fixed_string_t l2_tunnel;
11843 cmdline_fixed_string_t l2_tunnel_type;
11844 cmdline_fixed_string_t en_dis;
11847 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11848 TOKEN_STRING_INITIALIZER
11849 (struct cmd_config_l2_tunnel_en_dis_result,
11851 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11852 TOKEN_STRING_INITIALIZER
11853 (struct cmd_config_l2_tunnel_en_dis_result,
11855 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11856 TOKEN_STRING_INITIALIZER
11857 (struct cmd_config_l2_tunnel_en_dis_result,
11859 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11860 TOKEN_NUM_INITIALIZER
11861 (struct cmd_config_l2_tunnel_en_dis_result,
11863 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11864 TOKEN_STRING_INITIALIZER
11865 (struct cmd_config_l2_tunnel_en_dis_result,
11866 l2_tunnel, "l2-tunnel");
11867 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11868 TOKEN_STRING_INITIALIZER
11869 (struct cmd_config_l2_tunnel_en_dis_result,
11870 l2_tunnel_type, "E-tag");
11871 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11872 TOKEN_STRING_INITIALIZER
11873 (struct cmd_config_l2_tunnel_en_dis_result,
11874 en_dis, "enable#disable");
11876 /* enable/disable l2 tunnel for all ports */
11878 cmd_config_l2_tunnel_en_dis_all_parsed(
11879 void *parsed_result,
11880 __attribute__((unused)) struct cmdline *cl,
11881 __attribute__((unused)) void *data)
11883 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11884 struct rte_eth_l2_tunnel_conf entry;
11888 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11890 if (!strcmp("enable", res->en_dis))
11895 RTE_ETH_FOREACH_DEV(pid) {
11896 rte_eth_dev_l2_tunnel_offload_set(pid,
11898 ETH_L2_TUNNEL_ENABLE_MASK,
11903 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11904 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11906 .help_str = "port config all l2-tunnel E-tag enable|disable",
11908 (void *)&cmd_config_l2_tunnel_en_dis_port,
11909 (void *)&cmd_config_l2_tunnel_en_dis_config,
11910 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11911 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11912 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11913 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11918 /* enable/disable l2 tunnel for a port */
11920 cmd_config_l2_tunnel_en_dis_specific_parsed(
11921 void *parsed_result,
11922 __attribute__((unused)) struct cmdline *cl,
11923 __attribute__((unused)) void *data)
11925 struct cmd_config_l2_tunnel_en_dis_result *res =
11927 struct rte_eth_l2_tunnel_conf entry;
11929 if (port_id_is_invalid(res->id, ENABLED_WARN))
11932 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11934 if (!strcmp("enable", res->en_dis))
11935 rte_eth_dev_l2_tunnel_offload_set(res->id,
11937 ETH_L2_TUNNEL_ENABLE_MASK,
11940 rte_eth_dev_l2_tunnel_offload_set(res->id,
11942 ETH_L2_TUNNEL_ENABLE_MASK,
11946 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11947 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11949 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11951 (void *)&cmd_config_l2_tunnel_en_dis_port,
11952 (void *)&cmd_config_l2_tunnel_en_dis_config,
11953 (void *)&cmd_config_l2_tunnel_en_dis_id,
11954 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11955 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11956 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11961 /* E-tag configuration */
11963 /* Common result structure for all E-tag configuration */
11964 struct cmd_config_e_tag_result {
11965 cmdline_fixed_string_t e_tag;
11966 cmdline_fixed_string_t set;
11967 cmdline_fixed_string_t insertion;
11968 cmdline_fixed_string_t stripping;
11969 cmdline_fixed_string_t forwarding;
11970 cmdline_fixed_string_t filter;
11971 cmdline_fixed_string_t add;
11972 cmdline_fixed_string_t del;
11973 cmdline_fixed_string_t on;
11974 cmdline_fixed_string_t off;
11975 cmdline_fixed_string_t on_off;
11976 cmdline_fixed_string_t port_tag_id;
11977 uint32_t port_tag_id_val;
11978 cmdline_fixed_string_t e_tag_id;
11979 uint16_t e_tag_id_val;
11980 cmdline_fixed_string_t dst_pool;
11981 uint8_t dst_pool_val;
11982 cmdline_fixed_string_t port;
11984 cmdline_fixed_string_t vf;
11988 /* Common CLI fields for all E-tag configuration */
11989 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11990 TOKEN_STRING_INITIALIZER
11991 (struct cmd_config_e_tag_result,
11993 cmdline_parse_token_string_t cmd_config_e_tag_set =
11994 TOKEN_STRING_INITIALIZER
11995 (struct cmd_config_e_tag_result,
11997 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11998 TOKEN_STRING_INITIALIZER
11999 (struct cmd_config_e_tag_result,
12000 insertion, "insertion");
12001 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12002 TOKEN_STRING_INITIALIZER
12003 (struct cmd_config_e_tag_result,
12004 stripping, "stripping");
12005 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12006 TOKEN_STRING_INITIALIZER
12007 (struct cmd_config_e_tag_result,
12008 forwarding, "forwarding");
12009 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12010 TOKEN_STRING_INITIALIZER
12011 (struct cmd_config_e_tag_result,
12013 cmdline_parse_token_string_t cmd_config_e_tag_add =
12014 TOKEN_STRING_INITIALIZER
12015 (struct cmd_config_e_tag_result,
12017 cmdline_parse_token_string_t cmd_config_e_tag_del =
12018 TOKEN_STRING_INITIALIZER
12019 (struct cmd_config_e_tag_result,
12021 cmdline_parse_token_string_t cmd_config_e_tag_on =
12022 TOKEN_STRING_INITIALIZER
12023 (struct cmd_config_e_tag_result,
12025 cmdline_parse_token_string_t cmd_config_e_tag_off =
12026 TOKEN_STRING_INITIALIZER
12027 (struct cmd_config_e_tag_result,
12029 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12030 TOKEN_STRING_INITIALIZER
12031 (struct cmd_config_e_tag_result,
12033 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12034 TOKEN_STRING_INITIALIZER
12035 (struct cmd_config_e_tag_result,
12036 port_tag_id, "port-tag-id");
12037 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12038 TOKEN_NUM_INITIALIZER
12039 (struct cmd_config_e_tag_result,
12040 port_tag_id_val, UINT32);
12041 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12042 TOKEN_STRING_INITIALIZER
12043 (struct cmd_config_e_tag_result,
12044 e_tag_id, "e-tag-id");
12045 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12046 TOKEN_NUM_INITIALIZER
12047 (struct cmd_config_e_tag_result,
12048 e_tag_id_val, UINT16);
12049 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12050 TOKEN_STRING_INITIALIZER
12051 (struct cmd_config_e_tag_result,
12052 dst_pool, "dst-pool");
12053 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12054 TOKEN_NUM_INITIALIZER
12055 (struct cmd_config_e_tag_result,
12056 dst_pool_val, UINT8);
12057 cmdline_parse_token_string_t cmd_config_e_tag_port =
12058 TOKEN_STRING_INITIALIZER
12059 (struct cmd_config_e_tag_result,
12061 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12062 TOKEN_NUM_INITIALIZER
12063 (struct cmd_config_e_tag_result,
12065 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12066 TOKEN_STRING_INITIALIZER
12067 (struct cmd_config_e_tag_result,
12069 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12070 TOKEN_NUM_INITIALIZER
12071 (struct cmd_config_e_tag_result,
12074 /* E-tag insertion configuration */
12076 cmd_config_e_tag_insertion_en_parsed(
12077 void *parsed_result,
12078 __attribute__((unused)) struct cmdline *cl,
12079 __attribute__((unused)) void *data)
12081 struct cmd_config_e_tag_result *res =
12083 struct rte_eth_l2_tunnel_conf entry;
12085 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12088 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12089 entry.tunnel_id = res->port_tag_id_val;
12090 entry.vf_id = res->vf_id;
12091 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12093 ETH_L2_TUNNEL_INSERTION_MASK,
12098 cmd_config_e_tag_insertion_dis_parsed(
12099 void *parsed_result,
12100 __attribute__((unused)) struct cmdline *cl,
12101 __attribute__((unused)) void *data)
12103 struct cmd_config_e_tag_result *res =
12105 struct rte_eth_l2_tunnel_conf entry;
12107 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12110 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12111 entry.vf_id = res->vf_id;
12113 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12115 ETH_L2_TUNNEL_INSERTION_MASK,
12119 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12120 .f = cmd_config_e_tag_insertion_en_parsed,
12122 .help_str = "E-tag ... : E-tag insertion enable",
12124 (void *)&cmd_config_e_tag_e_tag,
12125 (void *)&cmd_config_e_tag_set,
12126 (void *)&cmd_config_e_tag_insertion,
12127 (void *)&cmd_config_e_tag_on,
12128 (void *)&cmd_config_e_tag_port_tag_id,
12129 (void *)&cmd_config_e_tag_port_tag_id_val,
12130 (void *)&cmd_config_e_tag_port,
12131 (void *)&cmd_config_e_tag_port_id,
12132 (void *)&cmd_config_e_tag_vf,
12133 (void *)&cmd_config_e_tag_vf_id,
12138 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12139 .f = cmd_config_e_tag_insertion_dis_parsed,
12141 .help_str = "E-tag ... : E-tag insertion disable",
12143 (void *)&cmd_config_e_tag_e_tag,
12144 (void *)&cmd_config_e_tag_set,
12145 (void *)&cmd_config_e_tag_insertion,
12146 (void *)&cmd_config_e_tag_off,
12147 (void *)&cmd_config_e_tag_port,
12148 (void *)&cmd_config_e_tag_port_id,
12149 (void *)&cmd_config_e_tag_vf,
12150 (void *)&cmd_config_e_tag_vf_id,
12155 /* E-tag stripping configuration */
12157 cmd_config_e_tag_stripping_parsed(
12158 void *parsed_result,
12159 __attribute__((unused)) struct cmdline *cl,
12160 __attribute__((unused)) void *data)
12162 struct cmd_config_e_tag_result *res =
12164 struct rte_eth_l2_tunnel_conf entry;
12166 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12169 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12171 if (!strcmp(res->on_off, "on"))
12172 rte_eth_dev_l2_tunnel_offload_set
12175 ETH_L2_TUNNEL_STRIPPING_MASK,
12178 rte_eth_dev_l2_tunnel_offload_set
12181 ETH_L2_TUNNEL_STRIPPING_MASK,
12185 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12186 .f = cmd_config_e_tag_stripping_parsed,
12188 .help_str = "E-tag ... : E-tag stripping enable/disable",
12190 (void *)&cmd_config_e_tag_e_tag,
12191 (void *)&cmd_config_e_tag_set,
12192 (void *)&cmd_config_e_tag_stripping,
12193 (void *)&cmd_config_e_tag_on_off,
12194 (void *)&cmd_config_e_tag_port,
12195 (void *)&cmd_config_e_tag_port_id,
12200 /* E-tag forwarding configuration */
12202 cmd_config_e_tag_forwarding_parsed(
12203 void *parsed_result,
12204 __attribute__((unused)) struct cmdline *cl,
12205 __attribute__((unused)) void *data)
12207 struct cmd_config_e_tag_result *res = parsed_result;
12208 struct rte_eth_l2_tunnel_conf entry;
12210 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12213 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12215 if (!strcmp(res->on_off, "on"))
12216 rte_eth_dev_l2_tunnel_offload_set
12219 ETH_L2_TUNNEL_FORWARDING_MASK,
12222 rte_eth_dev_l2_tunnel_offload_set
12225 ETH_L2_TUNNEL_FORWARDING_MASK,
12229 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12230 .f = cmd_config_e_tag_forwarding_parsed,
12232 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12234 (void *)&cmd_config_e_tag_e_tag,
12235 (void *)&cmd_config_e_tag_set,
12236 (void *)&cmd_config_e_tag_forwarding,
12237 (void *)&cmd_config_e_tag_on_off,
12238 (void *)&cmd_config_e_tag_port,
12239 (void *)&cmd_config_e_tag_port_id,
12244 /* E-tag filter configuration */
12246 cmd_config_e_tag_filter_add_parsed(
12247 void *parsed_result,
12248 __attribute__((unused)) struct cmdline *cl,
12249 __attribute__((unused)) void *data)
12251 struct cmd_config_e_tag_result *res = parsed_result;
12252 struct rte_eth_l2_tunnel_conf entry;
12255 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12258 if (res->e_tag_id_val > 0x3fff) {
12259 printf("e-tag-id must be equal or less than 0x3fff.\n");
12263 ret = rte_eth_dev_filter_supported(res->port_id,
12264 RTE_ETH_FILTER_L2_TUNNEL);
12266 printf("E-tag filter is not supported on port %u.\n",
12271 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12272 entry.tunnel_id = res->e_tag_id_val;
12273 entry.pool = res->dst_pool_val;
12275 ret = rte_eth_dev_filter_ctrl(res->port_id,
12276 RTE_ETH_FILTER_L2_TUNNEL,
12277 RTE_ETH_FILTER_ADD,
12280 printf("E-tag filter programming error: (%s)\n",
12284 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12285 .f = cmd_config_e_tag_filter_add_parsed,
12287 .help_str = "E-tag ... : E-tag filter add",
12289 (void *)&cmd_config_e_tag_e_tag,
12290 (void *)&cmd_config_e_tag_set,
12291 (void *)&cmd_config_e_tag_filter,
12292 (void *)&cmd_config_e_tag_add,
12293 (void *)&cmd_config_e_tag_e_tag_id,
12294 (void *)&cmd_config_e_tag_e_tag_id_val,
12295 (void *)&cmd_config_e_tag_dst_pool,
12296 (void *)&cmd_config_e_tag_dst_pool_val,
12297 (void *)&cmd_config_e_tag_port,
12298 (void *)&cmd_config_e_tag_port_id,
12304 cmd_config_e_tag_filter_del_parsed(
12305 void *parsed_result,
12306 __attribute__((unused)) struct cmdline *cl,
12307 __attribute__((unused)) void *data)
12309 struct cmd_config_e_tag_result *res = parsed_result;
12310 struct rte_eth_l2_tunnel_conf entry;
12313 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12316 if (res->e_tag_id_val > 0x3fff) {
12317 printf("e-tag-id must be less than 0x3fff.\n");
12321 ret = rte_eth_dev_filter_supported(res->port_id,
12322 RTE_ETH_FILTER_L2_TUNNEL);
12324 printf("E-tag filter is not supported on port %u.\n",
12329 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12330 entry.tunnel_id = res->e_tag_id_val;
12332 ret = rte_eth_dev_filter_ctrl(res->port_id,
12333 RTE_ETH_FILTER_L2_TUNNEL,
12334 RTE_ETH_FILTER_DELETE,
12337 printf("E-tag filter programming error: (%s)\n",
12341 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12342 .f = cmd_config_e_tag_filter_del_parsed,
12344 .help_str = "E-tag ... : E-tag filter delete",
12346 (void *)&cmd_config_e_tag_e_tag,
12347 (void *)&cmd_config_e_tag_set,
12348 (void *)&cmd_config_e_tag_filter,
12349 (void *)&cmd_config_e_tag_del,
12350 (void *)&cmd_config_e_tag_e_tag_id,
12351 (void *)&cmd_config_e_tag_e_tag_id_val,
12352 (void *)&cmd_config_e_tag_port,
12353 (void *)&cmd_config_e_tag_port_id,
12358 /* vf vlan anti spoof configuration */
12360 /* Common result structure for vf vlan anti spoof */
12361 struct cmd_vf_vlan_anti_spoof_result {
12362 cmdline_fixed_string_t set;
12363 cmdline_fixed_string_t vf;
12364 cmdline_fixed_string_t vlan;
12365 cmdline_fixed_string_t antispoof;
12368 cmdline_fixed_string_t on_off;
12371 /* Common CLI fields for vf vlan anti spoof enable disable */
12372 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12373 TOKEN_STRING_INITIALIZER
12374 (struct cmd_vf_vlan_anti_spoof_result,
12376 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12377 TOKEN_STRING_INITIALIZER
12378 (struct cmd_vf_vlan_anti_spoof_result,
12380 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12381 TOKEN_STRING_INITIALIZER
12382 (struct cmd_vf_vlan_anti_spoof_result,
12384 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12385 TOKEN_STRING_INITIALIZER
12386 (struct cmd_vf_vlan_anti_spoof_result,
12387 antispoof, "antispoof");
12388 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12389 TOKEN_NUM_INITIALIZER
12390 (struct cmd_vf_vlan_anti_spoof_result,
12392 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12393 TOKEN_NUM_INITIALIZER
12394 (struct cmd_vf_vlan_anti_spoof_result,
12396 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12397 TOKEN_STRING_INITIALIZER
12398 (struct cmd_vf_vlan_anti_spoof_result,
12402 cmd_set_vf_vlan_anti_spoof_parsed(
12403 void *parsed_result,
12404 __attribute__((unused)) struct cmdline *cl,
12405 __attribute__((unused)) void *data)
12407 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12408 int ret = -ENOTSUP;
12410 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12412 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12415 #ifdef RTE_LIBRTE_IXGBE_PMD
12416 if (ret == -ENOTSUP)
12417 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12418 res->vf_id, is_on);
12420 #ifdef RTE_LIBRTE_I40E_PMD
12421 if (ret == -ENOTSUP)
12422 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12423 res->vf_id, is_on);
12425 #ifdef RTE_LIBRTE_BNXT_PMD
12426 if (ret == -ENOTSUP)
12427 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12428 res->vf_id, is_on);
12435 printf("invalid vf_id %d\n", res->vf_id);
12438 printf("invalid port_id %d\n", res->port_id);
12441 printf("function not implemented\n");
12444 printf("programming error: (%s)\n", strerror(-ret));
12448 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12449 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12451 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12453 (void *)&cmd_vf_vlan_anti_spoof_set,
12454 (void *)&cmd_vf_vlan_anti_spoof_vf,
12455 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12456 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12457 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12458 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12459 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12464 /* vf mac anti spoof configuration */
12466 /* Common result structure for vf mac anti spoof */
12467 struct cmd_vf_mac_anti_spoof_result {
12468 cmdline_fixed_string_t set;
12469 cmdline_fixed_string_t vf;
12470 cmdline_fixed_string_t mac;
12471 cmdline_fixed_string_t antispoof;
12474 cmdline_fixed_string_t on_off;
12477 /* Common CLI fields for vf mac anti spoof enable disable */
12478 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12479 TOKEN_STRING_INITIALIZER
12480 (struct cmd_vf_mac_anti_spoof_result,
12482 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12483 TOKEN_STRING_INITIALIZER
12484 (struct cmd_vf_mac_anti_spoof_result,
12486 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12487 TOKEN_STRING_INITIALIZER
12488 (struct cmd_vf_mac_anti_spoof_result,
12490 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12491 TOKEN_STRING_INITIALIZER
12492 (struct cmd_vf_mac_anti_spoof_result,
12493 antispoof, "antispoof");
12494 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12495 TOKEN_NUM_INITIALIZER
12496 (struct cmd_vf_mac_anti_spoof_result,
12498 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12499 TOKEN_NUM_INITIALIZER
12500 (struct cmd_vf_mac_anti_spoof_result,
12502 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12503 TOKEN_STRING_INITIALIZER
12504 (struct cmd_vf_mac_anti_spoof_result,
12508 cmd_set_vf_mac_anti_spoof_parsed(
12509 void *parsed_result,
12510 __attribute__((unused)) struct cmdline *cl,
12511 __attribute__((unused)) void *data)
12513 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12514 int ret = -ENOTSUP;
12516 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12518 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12521 #ifdef RTE_LIBRTE_IXGBE_PMD
12522 if (ret == -ENOTSUP)
12523 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12524 res->vf_id, is_on);
12526 #ifdef RTE_LIBRTE_I40E_PMD
12527 if (ret == -ENOTSUP)
12528 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12529 res->vf_id, is_on);
12531 #ifdef RTE_LIBRTE_BNXT_PMD
12532 if (ret == -ENOTSUP)
12533 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12534 res->vf_id, is_on);
12541 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12544 printf("invalid port_id %d\n", res->port_id);
12547 printf("function not implemented\n");
12550 printf("programming error: (%s)\n", strerror(-ret));
12554 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12555 .f = cmd_set_vf_mac_anti_spoof_parsed,
12557 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12559 (void *)&cmd_vf_mac_anti_spoof_set,
12560 (void *)&cmd_vf_mac_anti_spoof_vf,
12561 (void *)&cmd_vf_mac_anti_spoof_mac,
12562 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12563 (void *)&cmd_vf_mac_anti_spoof_port_id,
12564 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12565 (void *)&cmd_vf_mac_anti_spoof_on_off,
12570 /* vf vlan strip queue configuration */
12572 /* Common result structure for vf mac anti spoof */
12573 struct cmd_vf_vlan_stripq_result {
12574 cmdline_fixed_string_t set;
12575 cmdline_fixed_string_t vf;
12576 cmdline_fixed_string_t vlan;
12577 cmdline_fixed_string_t stripq;
12580 cmdline_fixed_string_t on_off;
12583 /* Common CLI fields for vf vlan strip enable disable */
12584 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12585 TOKEN_STRING_INITIALIZER
12586 (struct cmd_vf_vlan_stripq_result,
12588 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12589 TOKEN_STRING_INITIALIZER
12590 (struct cmd_vf_vlan_stripq_result,
12592 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12593 TOKEN_STRING_INITIALIZER
12594 (struct cmd_vf_vlan_stripq_result,
12596 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12597 TOKEN_STRING_INITIALIZER
12598 (struct cmd_vf_vlan_stripq_result,
12600 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12601 TOKEN_NUM_INITIALIZER
12602 (struct cmd_vf_vlan_stripq_result,
12604 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12605 TOKEN_NUM_INITIALIZER
12606 (struct cmd_vf_vlan_stripq_result,
12608 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12609 TOKEN_STRING_INITIALIZER
12610 (struct cmd_vf_vlan_stripq_result,
12614 cmd_set_vf_vlan_stripq_parsed(
12615 void *parsed_result,
12616 __attribute__((unused)) struct cmdline *cl,
12617 __attribute__((unused)) void *data)
12619 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12620 int ret = -ENOTSUP;
12622 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12624 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12627 #ifdef RTE_LIBRTE_IXGBE_PMD
12628 if (ret == -ENOTSUP)
12629 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12630 res->vf_id, is_on);
12632 #ifdef RTE_LIBRTE_I40E_PMD
12633 if (ret == -ENOTSUP)
12634 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12635 res->vf_id, is_on);
12637 #ifdef RTE_LIBRTE_BNXT_PMD
12638 if (ret == -ENOTSUP)
12639 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12640 res->vf_id, is_on);
12647 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12650 printf("invalid port_id %d\n", res->port_id);
12653 printf("function not implemented\n");
12656 printf("programming error: (%s)\n", strerror(-ret));
12660 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12661 .f = cmd_set_vf_vlan_stripq_parsed,
12663 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12665 (void *)&cmd_vf_vlan_stripq_set,
12666 (void *)&cmd_vf_vlan_stripq_vf,
12667 (void *)&cmd_vf_vlan_stripq_vlan,
12668 (void *)&cmd_vf_vlan_stripq_stripq,
12669 (void *)&cmd_vf_vlan_stripq_port_id,
12670 (void *)&cmd_vf_vlan_stripq_vf_id,
12671 (void *)&cmd_vf_vlan_stripq_on_off,
12676 /* vf vlan insert configuration */
12678 /* Common result structure for vf vlan insert */
12679 struct cmd_vf_vlan_insert_result {
12680 cmdline_fixed_string_t set;
12681 cmdline_fixed_string_t vf;
12682 cmdline_fixed_string_t vlan;
12683 cmdline_fixed_string_t insert;
12689 /* Common CLI fields for vf vlan insert enable disable */
12690 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12691 TOKEN_STRING_INITIALIZER
12692 (struct cmd_vf_vlan_insert_result,
12694 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12695 TOKEN_STRING_INITIALIZER
12696 (struct cmd_vf_vlan_insert_result,
12698 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12699 TOKEN_STRING_INITIALIZER
12700 (struct cmd_vf_vlan_insert_result,
12702 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12703 TOKEN_STRING_INITIALIZER
12704 (struct cmd_vf_vlan_insert_result,
12706 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12707 TOKEN_NUM_INITIALIZER
12708 (struct cmd_vf_vlan_insert_result,
12710 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12711 TOKEN_NUM_INITIALIZER
12712 (struct cmd_vf_vlan_insert_result,
12714 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12715 TOKEN_NUM_INITIALIZER
12716 (struct cmd_vf_vlan_insert_result,
12720 cmd_set_vf_vlan_insert_parsed(
12721 void *parsed_result,
12722 __attribute__((unused)) struct cmdline *cl,
12723 __attribute__((unused)) void *data)
12725 struct cmd_vf_vlan_insert_result *res = parsed_result;
12726 int ret = -ENOTSUP;
12728 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12731 #ifdef RTE_LIBRTE_IXGBE_PMD
12732 if (ret == -ENOTSUP)
12733 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12736 #ifdef RTE_LIBRTE_I40E_PMD
12737 if (ret == -ENOTSUP)
12738 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12741 #ifdef RTE_LIBRTE_BNXT_PMD
12742 if (ret == -ENOTSUP)
12743 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12751 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12754 printf("invalid port_id %d\n", res->port_id);
12757 printf("function not implemented\n");
12760 printf("programming error: (%s)\n", strerror(-ret));
12764 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12765 .f = cmd_set_vf_vlan_insert_parsed,
12767 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12769 (void *)&cmd_vf_vlan_insert_set,
12770 (void *)&cmd_vf_vlan_insert_vf,
12771 (void *)&cmd_vf_vlan_insert_vlan,
12772 (void *)&cmd_vf_vlan_insert_insert,
12773 (void *)&cmd_vf_vlan_insert_port_id,
12774 (void *)&cmd_vf_vlan_insert_vf_id,
12775 (void *)&cmd_vf_vlan_insert_vlan_id,
12780 /* tx loopback configuration */
12782 /* Common result structure for tx loopback */
12783 struct cmd_tx_loopback_result {
12784 cmdline_fixed_string_t set;
12785 cmdline_fixed_string_t tx;
12786 cmdline_fixed_string_t loopback;
12788 cmdline_fixed_string_t on_off;
12791 /* Common CLI fields for tx loopback enable disable */
12792 cmdline_parse_token_string_t cmd_tx_loopback_set =
12793 TOKEN_STRING_INITIALIZER
12794 (struct cmd_tx_loopback_result,
12796 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12797 TOKEN_STRING_INITIALIZER
12798 (struct cmd_tx_loopback_result,
12800 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12801 TOKEN_STRING_INITIALIZER
12802 (struct cmd_tx_loopback_result,
12803 loopback, "loopback");
12804 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12805 TOKEN_NUM_INITIALIZER
12806 (struct cmd_tx_loopback_result,
12808 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12809 TOKEN_STRING_INITIALIZER
12810 (struct cmd_tx_loopback_result,
12814 cmd_set_tx_loopback_parsed(
12815 void *parsed_result,
12816 __attribute__((unused)) struct cmdline *cl,
12817 __attribute__((unused)) void *data)
12819 struct cmd_tx_loopback_result *res = parsed_result;
12820 int ret = -ENOTSUP;
12822 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12824 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12827 #ifdef RTE_LIBRTE_IXGBE_PMD
12828 if (ret == -ENOTSUP)
12829 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12831 #ifdef RTE_LIBRTE_I40E_PMD
12832 if (ret == -ENOTSUP)
12833 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12835 #ifdef RTE_LIBRTE_BNXT_PMD
12836 if (ret == -ENOTSUP)
12837 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12839 #ifdef RTE_LIBRTE_DPAA_PMD
12840 if (ret == -ENOTSUP)
12841 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
12848 printf("invalid is_on %d\n", is_on);
12851 printf("invalid port_id %d\n", res->port_id);
12854 printf("function not implemented\n");
12857 printf("programming error: (%s)\n", strerror(-ret));
12861 cmdline_parse_inst_t cmd_set_tx_loopback = {
12862 .f = cmd_set_tx_loopback_parsed,
12864 .help_str = "set tx loopback <port_id> on|off",
12866 (void *)&cmd_tx_loopback_set,
12867 (void *)&cmd_tx_loopback_tx,
12868 (void *)&cmd_tx_loopback_loopback,
12869 (void *)&cmd_tx_loopback_port_id,
12870 (void *)&cmd_tx_loopback_on_off,
12875 /* all queues drop enable configuration */
12877 /* Common result structure for all queues drop enable */
12878 struct cmd_all_queues_drop_en_result {
12879 cmdline_fixed_string_t set;
12880 cmdline_fixed_string_t all;
12881 cmdline_fixed_string_t queues;
12882 cmdline_fixed_string_t drop;
12884 cmdline_fixed_string_t on_off;
12887 /* Common CLI fields for tx loopback enable disable */
12888 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12889 TOKEN_STRING_INITIALIZER
12890 (struct cmd_all_queues_drop_en_result,
12892 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12893 TOKEN_STRING_INITIALIZER
12894 (struct cmd_all_queues_drop_en_result,
12896 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12897 TOKEN_STRING_INITIALIZER
12898 (struct cmd_all_queues_drop_en_result,
12900 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12901 TOKEN_STRING_INITIALIZER
12902 (struct cmd_all_queues_drop_en_result,
12904 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12905 TOKEN_NUM_INITIALIZER
12906 (struct cmd_all_queues_drop_en_result,
12908 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12909 TOKEN_STRING_INITIALIZER
12910 (struct cmd_all_queues_drop_en_result,
12914 cmd_set_all_queues_drop_en_parsed(
12915 void *parsed_result,
12916 __attribute__((unused)) struct cmdline *cl,
12917 __attribute__((unused)) void *data)
12919 struct cmd_all_queues_drop_en_result *res = parsed_result;
12920 int ret = -ENOTSUP;
12921 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12923 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12926 #ifdef RTE_LIBRTE_IXGBE_PMD
12927 if (ret == -ENOTSUP)
12928 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12930 #ifdef RTE_LIBRTE_BNXT_PMD
12931 if (ret == -ENOTSUP)
12932 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12938 printf("invalid is_on %d\n", is_on);
12941 printf("invalid port_id %d\n", res->port_id);
12944 printf("function not implemented\n");
12947 printf("programming error: (%s)\n", strerror(-ret));
12951 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12952 .f = cmd_set_all_queues_drop_en_parsed,
12954 .help_str = "set all queues drop <port_id> on|off",
12956 (void *)&cmd_all_queues_drop_en_set,
12957 (void *)&cmd_all_queues_drop_en_all,
12958 (void *)&cmd_all_queues_drop_en_queues,
12959 (void *)&cmd_all_queues_drop_en_drop,
12960 (void *)&cmd_all_queues_drop_en_port_id,
12961 (void *)&cmd_all_queues_drop_en_on_off,
12966 /* vf split drop enable configuration */
12968 /* Common result structure for vf split drop enable */
12969 struct cmd_vf_split_drop_en_result {
12970 cmdline_fixed_string_t set;
12971 cmdline_fixed_string_t vf;
12972 cmdline_fixed_string_t split;
12973 cmdline_fixed_string_t drop;
12976 cmdline_fixed_string_t on_off;
12979 /* Common CLI fields for vf split drop enable disable */
12980 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12981 TOKEN_STRING_INITIALIZER
12982 (struct cmd_vf_split_drop_en_result,
12984 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12985 TOKEN_STRING_INITIALIZER
12986 (struct cmd_vf_split_drop_en_result,
12988 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12989 TOKEN_STRING_INITIALIZER
12990 (struct cmd_vf_split_drop_en_result,
12992 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12993 TOKEN_STRING_INITIALIZER
12994 (struct cmd_vf_split_drop_en_result,
12996 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12997 TOKEN_NUM_INITIALIZER
12998 (struct cmd_vf_split_drop_en_result,
13000 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13001 TOKEN_NUM_INITIALIZER
13002 (struct cmd_vf_split_drop_en_result,
13004 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13005 TOKEN_STRING_INITIALIZER
13006 (struct cmd_vf_split_drop_en_result,
13010 cmd_set_vf_split_drop_en_parsed(
13011 void *parsed_result,
13012 __attribute__((unused)) struct cmdline *cl,
13013 __attribute__((unused)) void *data)
13015 struct cmd_vf_split_drop_en_result *res = parsed_result;
13016 int ret = -ENOTSUP;
13017 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13019 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13022 #ifdef RTE_LIBRTE_IXGBE_PMD
13023 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13030 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13033 printf("invalid port_id %d\n", res->port_id);
13036 printf("not supported on port %d\n", res->port_id);
13039 printf("programming error: (%s)\n", strerror(-ret));
13043 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13044 .f = cmd_set_vf_split_drop_en_parsed,
13046 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13048 (void *)&cmd_vf_split_drop_en_set,
13049 (void *)&cmd_vf_split_drop_en_vf,
13050 (void *)&cmd_vf_split_drop_en_split,
13051 (void *)&cmd_vf_split_drop_en_drop,
13052 (void *)&cmd_vf_split_drop_en_port_id,
13053 (void *)&cmd_vf_split_drop_en_vf_id,
13054 (void *)&cmd_vf_split_drop_en_on_off,
13059 /* vf mac address configuration */
13061 /* Common result structure for vf mac address */
13062 struct cmd_set_vf_mac_addr_result {
13063 cmdline_fixed_string_t set;
13064 cmdline_fixed_string_t vf;
13065 cmdline_fixed_string_t mac;
13066 cmdline_fixed_string_t addr;
13069 struct ether_addr mac_addr;
13073 /* Common CLI fields for vf split drop enable disable */
13074 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13075 TOKEN_STRING_INITIALIZER
13076 (struct cmd_set_vf_mac_addr_result,
13078 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13079 TOKEN_STRING_INITIALIZER
13080 (struct cmd_set_vf_mac_addr_result,
13082 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13083 TOKEN_STRING_INITIALIZER
13084 (struct cmd_set_vf_mac_addr_result,
13086 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13087 TOKEN_STRING_INITIALIZER
13088 (struct cmd_set_vf_mac_addr_result,
13090 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13091 TOKEN_NUM_INITIALIZER
13092 (struct cmd_set_vf_mac_addr_result,
13094 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13095 TOKEN_NUM_INITIALIZER
13096 (struct cmd_set_vf_mac_addr_result,
13098 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13099 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13103 cmd_set_vf_mac_addr_parsed(
13104 void *parsed_result,
13105 __attribute__((unused)) struct cmdline *cl,
13106 __attribute__((unused)) void *data)
13108 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13109 int ret = -ENOTSUP;
13111 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13114 #ifdef RTE_LIBRTE_IXGBE_PMD
13115 if (ret == -ENOTSUP)
13116 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13119 #ifdef RTE_LIBRTE_I40E_PMD
13120 if (ret == -ENOTSUP)
13121 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13124 #ifdef RTE_LIBRTE_BNXT_PMD
13125 if (ret == -ENOTSUP)
13126 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13134 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13137 printf("invalid port_id %d\n", res->port_id);
13140 printf("function not implemented\n");
13143 printf("programming error: (%s)\n", strerror(-ret));
13147 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13148 .f = cmd_set_vf_mac_addr_parsed,
13150 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13152 (void *)&cmd_set_vf_mac_addr_set,
13153 (void *)&cmd_set_vf_mac_addr_vf,
13154 (void *)&cmd_set_vf_mac_addr_mac,
13155 (void *)&cmd_set_vf_mac_addr_addr,
13156 (void *)&cmd_set_vf_mac_addr_port_id,
13157 (void *)&cmd_set_vf_mac_addr_vf_id,
13158 (void *)&cmd_set_vf_mac_addr_mac_addr,
13163 /* MACsec configuration */
13165 /* Common result structure for MACsec offload enable */
13166 struct cmd_macsec_offload_on_result {
13167 cmdline_fixed_string_t set;
13168 cmdline_fixed_string_t macsec;
13169 cmdline_fixed_string_t offload;
13171 cmdline_fixed_string_t on;
13172 cmdline_fixed_string_t encrypt;
13173 cmdline_fixed_string_t en_on_off;
13174 cmdline_fixed_string_t replay_protect;
13175 cmdline_fixed_string_t rp_on_off;
13178 /* Common CLI fields for MACsec offload disable */
13179 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13180 TOKEN_STRING_INITIALIZER
13181 (struct cmd_macsec_offload_on_result,
13183 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13184 TOKEN_STRING_INITIALIZER
13185 (struct cmd_macsec_offload_on_result,
13187 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13188 TOKEN_STRING_INITIALIZER
13189 (struct cmd_macsec_offload_on_result,
13190 offload, "offload");
13191 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13192 TOKEN_NUM_INITIALIZER
13193 (struct cmd_macsec_offload_on_result,
13195 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13196 TOKEN_STRING_INITIALIZER
13197 (struct cmd_macsec_offload_on_result,
13199 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13200 TOKEN_STRING_INITIALIZER
13201 (struct cmd_macsec_offload_on_result,
13202 encrypt, "encrypt");
13203 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13204 TOKEN_STRING_INITIALIZER
13205 (struct cmd_macsec_offload_on_result,
13206 en_on_off, "on#off");
13207 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13208 TOKEN_STRING_INITIALIZER
13209 (struct cmd_macsec_offload_on_result,
13210 replay_protect, "replay-protect");
13211 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13212 TOKEN_STRING_INITIALIZER
13213 (struct cmd_macsec_offload_on_result,
13214 rp_on_off, "on#off");
13217 cmd_set_macsec_offload_on_parsed(
13218 void *parsed_result,
13219 __attribute__((unused)) struct cmdline *cl,
13220 __attribute__((unused)) void *data)
13222 struct cmd_macsec_offload_on_result *res = parsed_result;
13223 int ret = -ENOTSUP;
13224 portid_t port_id = res->port_id;
13225 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13226 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13227 struct rte_eth_dev_info dev_info;
13229 if (port_id_is_invalid(port_id, ENABLED_WARN))
13231 if (!port_is_stopped(port_id)) {
13232 printf("Please stop port %d first\n", port_id);
13236 rte_eth_dev_info_get(port_id, &dev_info);
13237 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13238 #ifdef RTE_LIBRTE_IXGBE_PMD
13239 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13247 ports[port_id].dev_conf.txmode.offloads |=
13248 DEV_TX_OFFLOAD_MACSEC_INSERT;
13249 cmd_reconfig_device_queue(port_id, 1, 1);
13252 printf("invalid port_id %d\n", port_id);
13255 printf("not supported on port %d\n", port_id);
13258 printf("programming error: (%s)\n", strerror(-ret));
13262 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13263 .f = cmd_set_macsec_offload_on_parsed,
13265 .help_str = "set macsec offload <port_id> on "
13266 "encrypt on|off replay-protect on|off",
13268 (void *)&cmd_macsec_offload_on_set,
13269 (void *)&cmd_macsec_offload_on_macsec,
13270 (void *)&cmd_macsec_offload_on_offload,
13271 (void *)&cmd_macsec_offload_on_port_id,
13272 (void *)&cmd_macsec_offload_on_on,
13273 (void *)&cmd_macsec_offload_on_encrypt,
13274 (void *)&cmd_macsec_offload_on_en_on_off,
13275 (void *)&cmd_macsec_offload_on_replay_protect,
13276 (void *)&cmd_macsec_offload_on_rp_on_off,
13281 /* Common result structure for MACsec offload disable */
13282 struct cmd_macsec_offload_off_result {
13283 cmdline_fixed_string_t set;
13284 cmdline_fixed_string_t macsec;
13285 cmdline_fixed_string_t offload;
13287 cmdline_fixed_string_t off;
13290 /* Common CLI fields for MACsec offload disable */
13291 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13292 TOKEN_STRING_INITIALIZER
13293 (struct cmd_macsec_offload_off_result,
13295 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13296 TOKEN_STRING_INITIALIZER
13297 (struct cmd_macsec_offload_off_result,
13299 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13300 TOKEN_STRING_INITIALIZER
13301 (struct cmd_macsec_offload_off_result,
13302 offload, "offload");
13303 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13304 TOKEN_NUM_INITIALIZER
13305 (struct cmd_macsec_offload_off_result,
13307 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13308 TOKEN_STRING_INITIALIZER
13309 (struct cmd_macsec_offload_off_result,
13313 cmd_set_macsec_offload_off_parsed(
13314 void *parsed_result,
13315 __attribute__((unused)) struct cmdline *cl,
13316 __attribute__((unused)) void *data)
13318 struct cmd_macsec_offload_off_result *res = parsed_result;
13319 int ret = -ENOTSUP;
13320 struct rte_eth_dev_info dev_info;
13321 portid_t port_id = res->port_id;
13323 if (port_id_is_invalid(port_id, ENABLED_WARN))
13325 if (!port_is_stopped(port_id)) {
13326 printf("Please stop port %d first\n", port_id);
13330 rte_eth_dev_info_get(port_id, &dev_info);
13331 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13332 #ifdef RTE_LIBRTE_IXGBE_PMD
13333 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13338 ports[port_id].dev_conf.txmode.offloads &=
13339 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13340 cmd_reconfig_device_queue(port_id, 1, 1);
13343 printf("invalid port_id %d\n", port_id);
13346 printf("not supported on port %d\n", port_id);
13349 printf("programming error: (%s)\n", strerror(-ret));
13353 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13354 .f = cmd_set_macsec_offload_off_parsed,
13356 .help_str = "set macsec offload <port_id> off",
13358 (void *)&cmd_macsec_offload_off_set,
13359 (void *)&cmd_macsec_offload_off_macsec,
13360 (void *)&cmd_macsec_offload_off_offload,
13361 (void *)&cmd_macsec_offload_off_port_id,
13362 (void *)&cmd_macsec_offload_off_off,
13367 /* Common result structure for MACsec secure connection configure */
13368 struct cmd_macsec_sc_result {
13369 cmdline_fixed_string_t set;
13370 cmdline_fixed_string_t macsec;
13371 cmdline_fixed_string_t sc;
13372 cmdline_fixed_string_t tx_rx;
13374 struct ether_addr mac;
13378 /* Common CLI fields for MACsec secure connection configure */
13379 cmdline_parse_token_string_t cmd_macsec_sc_set =
13380 TOKEN_STRING_INITIALIZER
13381 (struct cmd_macsec_sc_result,
13383 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13384 TOKEN_STRING_INITIALIZER
13385 (struct cmd_macsec_sc_result,
13387 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13388 TOKEN_STRING_INITIALIZER
13389 (struct cmd_macsec_sc_result,
13391 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13392 TOKEN_STRING_INITIALIZER
13393 (struct cmd_macsec_sc_result,
13395 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13396 TOKEN_NUM_INITIALIZER
13397 (struct cmd_macsec_sc_result,
13399 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13400 TOKEN_ETHERADDR_INITIALIZER
13401 (struct cmd_macsec_sc_result,
13403 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13404 TOKEN_NUM_INITIALIZER
13405 (struct cmd_macsec_sc_result,
13409 cmd_set_macsec_sc_parsed(
13410 void *parsed_result,
13411 __attribute__((unused)) struct cmdline *cl,
13412 __attribute__((unused)) void *data)
13414 struct cmd_macsec_sc_result *res = parsed_result;
13415 int ret = -ENOTSUP;
13416 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13418 #ifdef RTE_LIBRTE_IXGBE_PMD
13420 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13421 res->mac.addr_bytes) :
13422 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13423 res->mac.addr_bytes, res->pi);
13425 RTE_SET_USED(is_tx);
13431 printf("invalid port_id %d\n", res->port_id);
13434 printf("not supported on port %d\n", res->port_id);
13437 printf("programming error: (%s)\n", strerror(-ret));
13441 cmdline_parse_inst_t cmd_set_macsec_sc = {
13442 .f = cmd_set_macsec_sc_parsed,
13444 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13446 (void *)&cmd_macsec_sc_set,
13447 (void *)&cmd_macsec_sc_macsec,
13448 (void *)&cmd_macsec_sc_sc,
13449 (void *)&cmd_macsec_sc_tx_rx,
13450 (void *)&cmd_macsec_sc_port_id,
13451 (void *)&cmd_macsec_sc_mac,
13452 (void *)&cmd_macsec_sc_pi,
13457 /* Common result structure for MACsec secure connection configure */
13458 struct cmd_macsec_sa_result {
13459 cmdline_fixed_string_t set;
13460 cmdline_fixed_string_t macsec;
13461 cmdline_fixed_string_t sa;
13462 cmdline_fixed_string_t tx_rx;
13467 cmdline_fixed_string_t key;
13470 /* Common CLI fields for MACsec secure connection configure */
13471 cmdline_parse_token_string_t cmd_macsec_sa_set =
13472 TOKEN_STRING_INITIALIZER
13473 (struct cmd_macsec_sa_result,
13475 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13476 TOKEN_STRING_INITIALIZER
13477 (struct cmd_macsec_sa_result,
13479 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13480 TOKEN_STRING_INITIALIZER
13481 (struct cmd_macsec_sa_result,
13483 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13484 TOKEN_STRING_INITIALIZER
13485 (struct cmd_macsec_sa_result,
13487 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13488 TOKEN_NUM_INITIALIZER
13489 (struct cmd_macsec_sa_result,
13491 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13492 TOKEN_NUM_INITIALIZER
13493 (struct cmd_macsec_sa_result,
13495 cmdline_parse_token_num_t cmd_macsec_sa_an =
13496 TOKEN_NUM_INITIALIZER
13497 (struct cmd_macsec_sa_result,
13499 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13500 TOKEN_NUM_INITIALIZER
13501 (struct cmd_macsec_sa_result,
13503 cmdline_parse_token_string_t cmd_macsec_sa_key =
13504 TOKEN_STRING_INITIALIZER
13505 (struct cmd_macsec_sa_result,
13509 cmd_set_macsec_sa_parsed(
13510 void *parsed_result,
13511 __attribute__((unused)) struct cmdline *cl,
13512 __attribute__((unused)) void *data)
13514 struct cmd_macsec_sa_result *res = parsed_result;
13515 int ret = -ENOTSUP;
13516 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13517 uint8_t key[16] = { 0 };
13523 key_len = strlen(res->key) / 2;
13527 for (i = 0; i < key_len; i++) {
13528 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13531 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13534 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13537 #ifdef RTE_LIBRTE_IXGBE_PMD
13539 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13540 res->idx, res->an, res->pn, key) :
13541 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13542 res->idx, res->an, res->pn, key);
13544 RTE_SET_USED(is_tx);
13551 printf("invalid idx %d or an %d\n", res->idx, res->an);
13554 printf("invalid port_id %d\n", res->port_id);
13557 printf("not supported on port %d\n", res->port_id);
13560 printf("programming error: (%s)\n", strerror(-ret));
13564 cmdline_parse_inst_t cmd_set_macsec_sa = {
13565 .f = cmd_set_macsec_sa_parsed,
13567 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13569 (void *)&cmd_macsec_sa_set,
13570 (void *)&cmd_macsec_sa_macsec,
13571 (void *)&cmd_macsec_sa_sa,
13572 (void *)&cmd_macsec_sa_tx_rx,
13573 (void *)&cmd_macsec_sa_port_id,
13574 (void *)&cmd_macsec_sa_idx,
13575 (void *)&cmd_macsec_sa_an,
13576 (void *)&cmd_macsec_sa_pn,
13577 (void *)&cmd_macsec_sa_key,
13582 /* VF unicast promiscuous mode configuration */
13584 /* Common result structure for VF unicast promiscuous mode */
13585 struct cmd_vf_promisc_result {
13586 cmdline_fixed_string_t set;
13587 cmdline_fixed_string_t vf;
13588 cmdline_fixed_string_t promisc;
13591 cmdline_fixed_string_t on_off;
13594 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13595 cmdline_parse_token_string_t cmd_vf_promisc_set =
13596 TOKEN_STRING_INITIALIZER
13597 (struct cmd_vf_promisc_result,
13599 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13600 TOKEN_STRING_INITIALIZER
13601 (struct cmd_vf_promisc_result,
13603 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13604 TOKEN_STRING_INITIALIZER
13605 (struct cmd_vf_promisc_result,
13606 promisc, "promisc");
13607 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13608 TOKEN_NUM_INITIALIZER
13609 (struct cmd_vf_promisc_result,
13611 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13612 TOKEN_NUM_INITIALIZER
13613 (struct cmd_vf_promisc_result,
13615 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13616 TOKEN_STRING_INITIALIZER
13617 (struct cmd_vf_promisc_result,
13621 cmd_set_vf_promisc_parsed(
13622 void *parsed_result,
13623 __attribute__((unused)) struct cmdline *cl,
13624 __attribute__((unused)) void *data)
13626 struct cmd_vf_promisc_result *res = parsed_result;
13627 int ret = -ENOTSUP;
13629 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13631 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13634 #ifdef RTE_LIBRTE_I40E_PMD
13635 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13636 res->vf_id, is_on);
13643 printf("invalid vf_id %d\n", res->vf_id);
13646 printf("invalid port_id %d\n", res->port_id);
13649 printf("function not implemented\n");
13652 printf("programming error: (%s)\n", strerror(-ret));
13656 cmdline_parse_inst_t cmd_set_vf_promisc = {
13657 .f = cmd_set_vf_promisc_parsed,
13659 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13660 "Set unicast promiscuous mode for a VF from the PF",
13662 (void *)&cmd_vf_promisc_set,
13663 (void *)&cmd_vf_promisc_vf,
13664 (void *)&cmd_vf_promisc_promisc,
13665 (void *)&cmd_vf_promisc_port_id,
13666 (void *)&cmd_vf_promisc_vf_id,
13667 (void *)&cmd_vf_promisc_on_off,
13672 /* VF multicast promiscuous mode configuration */
13674 /* Common result structure for VF multicast promiscuous mode */
13675 struct cmd_vf_allmulti_result {
13676 cmdline_fixed_string_t set;
13677 cmdline_fixed_string_t vf;
13678 cmdline_fixed_string_t allmulti;
13681 cmdline_fixed_string_t on_off;
13684 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13685 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13686 TOKEN_STRING_INITIALIZER
13687 (struct cmd_vf_allmulti_result,
13689 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13690 TOKEN_STRING_INITIALIZER
13691 (struct cmd_vf_allmulti_result,
13693 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13694 TOKEN_STRING_INITIALIZER
13695 (struct cmd_vf_allmulti_result,
13696 allmulti, "allmulti");
13697 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13698 TOKEN_NUM_INITIALIZER
13699 (struct cmd_vf_allmulti_result,
13701 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13702 TOKEN_NUM_INITIALIZER
13703 (struct cmd_vf_allmulti_result,
13705 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13706 TOKEN_STRING_INITIALIZER
13707 (struct cmd_vf_allmulti_result,
13711 cmd_set_vf_allmulti_parsed(
13712 void *parsed_result,
13713 __attribute__((unused)) struct cmdline *cl,
13714 __attribute__((unused)) void *data)
13716 struct cmd_vf_allmulti_result *res = parsed_result;
13717 int ret = -ENOTSUP;
13719 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13721 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13724 #ifdef RTE_LIBRTE_I40E_PMD
13725 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13726 res->vf_id, is_on);
13733 printf("invalid vf_id %d\n", res->vf_id);
13736 printf("invalid port_id %d\n", res->port_id);
13739 printf("function not implemented\n");
13742 printf("programming error: (%s)\n", strerror(-ret));
13746 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13747 .f = cmd_set_vf_allmulti_parsed,
13749 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13750 "Set multicast promiscuous mode for a VF from the PF",
13752 (void *)&cmd_vf_allmulti_set,
13753 (void *)&cmd_vf_allmulti_vf,
13754 (void *)&cmd_vf_allmulti_allmulti,
13755 (void *)&cmd_vf_allmulti_port_id,
13756 (void *)&cmd_vf_allmulti_vf_id,
13757 (void *)&cmd_vf_allmulti_on_off,
13762 /* vf broadcast mode configuration */
13764 /* Common result structure for vf broadcast */
13765 struct cmd_set_vf_broadcast_result {
13766 cmdline_fixed_string_t set;
13767 cmdline_fixed_string_t vf;
13768 cmdline_fixed_string_t broadcast;
13771 cmdline_fixed_string_t on_off;
13774 /* Common CLI fields for vf broadcast enable disable */
13775 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13776 TOKEN_STRING_INITIALIZER
13777 (struct cmd_set_vf_broadcast_result,
13779 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13780 TOKEN_STRING_INITIALIZER
13781 (struct cmd_set_vf_broadcast_result,
13783 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13784 TOKEN_STRING_INITIALIZER
13785 (struct cmd_set_vf_broadcast_result,
13786 broadcast, "broadcast");
13787 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13788 TOKEN_NUM_INITIALIZER
13789 (struct cmd_set_vf_broadcast_result,
13791 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13792 TOKEN_NUM_INITIALIZER
13793 (struct cmd_set_vf_broadcast_result,
13795 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13796 TOKEN_STRING_INITIALIZER
13797 (struct cmd_set_vf_broadcast_result,
13801 cmd_set_vf_broadcast_parsed(
13802 void *parsed_result,
13803 __attribute__((unused)) struct cmdline *cl,
13804 __attribute__((unused)) void *data)
13806 struct cmd_set_vf_broadcast_result *res = parsed_result;
13807 int ret = -ENOTSUP;
13809 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13811 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13814 #ifdef RTE_LIBRTE_I40E_PMD
13815 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13816 res->vf_id, is_on);
13823 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13826 printf("invalid port_id %d\n", res->port_id);
13829 printf("function not implemented\n");
13832 printf("programming error: (%s)\n", strerror(-ret));
13836 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13837 .f = cmd_set_vf_broadcast_parsed,
13839 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13841 (void *)&cmd_set_vf_broadcast_set,
13842 (void *)&cmd_set_vf_broadcast_vf,
13843 (void *)&cmd_set_vf_broadcast_broadcast,
13844 (void *)&cmd_set_vf_broadcast_port_id,
13845 (void *)&cmd_set_vf_broadcast_vf_id,
13846 (void *)&cmd_set_vf_broadcast_on_off,
13851 /* vf vlan tag configuration */
13853 /* Common result structure for vf vlan tag */
13854 struct cmd_set_vf_vlan_tag_result {
13855 cmdline_fixed_string_t set;
13856 cmdline_fixed_string_t vf;
13857 cmdline_fixed_string_t vlan;
13858 cmdline_fixed_string_t tag;
13861 cmdline_fixed_string_t on_off;
13864 /* Common CLI fields for vf vlan tag enable disable */
13865 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13866 TOKEN_STRING_INITIALIZER
13867 (struct cmd_set_vf_vlan_tag_result,
13869 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13870 TOKEN_STRING_INITIALIZER
13871 (struct cmd_set_vf_vlan_tag_result,
13873 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13874 TOKEN_STRING_INITIALIZER
13875 (struct cmd_set_vf_vlan_tag_result,
13877 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13878 TOKEN_STRING_INITIALIZER
13879 (struct cmd_set_vf_vlan_tag_result,
13881 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13882 TOKEN_NUM_INITIALIZER
13883 (struct cmd_set_vf_vlan_tag_result,
13885 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13886 TOKEN_NUM_INITIALIZER
13887 (struct cmd_set_vf_vlan_tag_result,
13889 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13890 TOKEN_STRING_INITIALIZER
13891 (struct cmd_set_vf_vlan_tag_result,
13895 cmd_set_vf_vlan_tag_parsed(
13896 void *parsed_result,
13897 __attribute__((unused)) struct cmdline *cl,
13898 __attribute__((unused)) void *data)
13900 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13901 int ret = -ENOTSUP;
13903 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13905 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13908 #ifdef RTE_LIBRTE_I40E_PMD
13909 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13910 res->vf_id, is_on);
13917 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13920 printf("invalid port_id %d\n", res->port_id);
13923 printf("function not implemented\n");
13926 printf("programming error: (%s)\n", strerror(-ret));
13930 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13931 .f = cmd_set_vf_vlan_tag_parsed,
13933 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13935 (void *)&cmd_set_vf_vlan_tag_set,
13936 (void *)&cmd_set_vf_vlan_tag_vf,
13937 (void *)&cmd_set_vf_vlan_tag_vlan,
13938 (void *)&cmd_set_vf_vlan_tag_tag,
13939 (void *)&cmd_set_vf_vlan_tag_port_id,
13940 (void *)&cmd_set_vf_vlan_tag_vf_id,
13941 (void *)&cmd_set_vf_vlan_tag_on_off,
13946 /* Common definition of VF and TC TX bandwidth configuration */
13947 struct cmd_vf_tc_bw_result {
13948 cmdline_fixed_string_t set;
13949 cmdline_fixed_string_t vf;
13950 cmdline_fixed_string_t tc;
13951 cmdline_fixed_string_t tx;
13952 cmdline_fixed_string_t min_bw;
13953 cmdline_fixed_string_t max_bw;
13954 cmdline_fixed_string_t strict_link_prio;
13959 cmdline_fixed_string_t bw_list;
13963 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13964 TOKEN_STRING_INITIALIZER
13965 (struct cmd_vf_tc_bw_result,
13967 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13968 TOKEN_STRING_INITIALIZER
13969 (struct cmd_vf_tc_bw_result,
13971 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13972 TOKEN_STRING_INITIALIZER
13973 (struct cmd_vf_tc_bw_result,
13975 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13976 TOKEN_STRING_INITIALIZER
13977 (struct cmd_vf_tc_bw_result,
13979 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13980 TOKEN_STRING_INITIALIZER
13981 (struct cmd_vf_tc_bw_result,
13982 strict_link_prio, "strict-link-priority");
13983 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13984 TOKEN_STRING_INITIALIZER
13985 (struct cmd_vf_tc_bw_result,
13986 min_bw, "min-bandwidth");
13987 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13988 TOKEN_STRING_INITIALIZER
13989 (struct cmd_vf_tc_bw_result,
13990 max_bw, "max-bandwidth");
13991 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13992 TOKEN_NUM_INITIALIZER
13993 (struct cmd_vf_tc_bw_result,
13995 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13996 TOKEN_NUM_INITIALIZER
13997 (struct cmd_vf_tc_bw_result,
13999 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14000 TOKEN_NUM_INITIALIZER
14001 (struct cmd_vf_tc_bw_result,
14003 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14004 TOKEN_NUM_INITIALIZER
14005 (struct cmd_vf_tc_bw_result,
14007 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14008 TOKEN_STRING_INITIALIZER
14009 (struct cmd_vf_tc_bw_result,
14011 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14012 TOKEN_NUM_INITIALIZER
14013 (struct cmd_vf_tc_bw_result,
14016 /* VF max bandwidth setting */
14018 cmd_vf_max_bw_parsed(
14019 void *parsed_result,
14020 __attribute__((unused)) struct cmdline *cl,
14021 __attribute__((unused)) void *data)
14023 struct cmd_vf_tc_bw_result *res = parsed_result;
14024 int ret = -ENOTSUP;
14026 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14029 #ifdef RTE_LIBRTE_I40E_PMD
14030 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14031 res->vf_id, res->bw);
14038 printf("invalid vf_id %d or bandwidth %d\n",
14039 res->vf_id, res->bw);
14042 printf("invalid port_id %d\n", res->port_id);
14045 printf("function not implemented\n");
14048 printf("programming error: (%s)\n", strerror(-ret));
14052 cmdline_parse_inst_t cmd_vf_max_bw = {
14053 .f = cmd_vf_max_bw_parsed,
14055 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14057 (void *)&cmd_vf_tc_bw_set,
14058 (void *)&cmd_vf_tc_bw_vf,
14059 (void *)&cmd_vf_tc_bw_tx,
14060 (void *)&cmd_vf_tc_bw_max_bw,
14061 (void *)&cmd_vf_tc_bw_port_id,
14062 (void *)&cmd_vf_tc_bw_vf_id,
14063 (void *)&cmd_vf_tc_bw_bw,
14069 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14074 const char *p, *p0 = str;
14081 p = strchr(p0, '(');
14083 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14087 p0 = strchr(p, ')');
14089 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14093 if (size >= sizeof(s)) {
14094 printf("The string size exceeds the internal buffer size\n");
14097 snprintf(s, sizeof(s), "%.*s", size, p);
14098 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14100 printf("Failed to get the bandwidth list. ");
14104 for (i = 0; i < ret; i++)
14105 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14110 /* TC min bandwidth setting */
14112 cmd_vf_tc_min_bw_parsed(
14113 void *parsed_result,
14114 __attribute__((unused)) struct cmdline *cl,
14115 __attribute__((unused)) void *data)
14117 struct cmd_vf_tc_bw_result *res = parsed_result;
14120 int ret = -ENOTSUP;
14122 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14125 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14129 #ifdef RTE_LIBRTE_I40E_PMD
14130 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14138 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14141 printf("invalid port_id %d\n", res->port_id);
14144 printf("function not implemented\n");
14147 printf("programming error: (%s)\n", strerror(-ret));
14151 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14152 .f = cmd_vf_tc_min_bw_parsed,
14154 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14155 " <bw1, bw2, ...>",
14157 (void *)&cmd_vf_tc_bw_set,
14158 (void *)&cmd_vf_tc_bw_vf,
14159 (void *)&cmd_vf_tc_bw_tc,
14160 (void *)&cmd_vf_tc_bw_tx,
14161 (void *)&cmd_vf_tc_bw_min_bw,
14162 (void *)&cmd_vf_tc_bw_port_id,
14163 (void *)&cmd_vf_tc_bw_vf_id,
14164 (void *)&cmd_vf_tc_bw_bw_list,
14170 cmd_tc_min_bw_parsed(
14171 void *parsed_result,
14172 __attribute__((unused)) struct cmdline *cl,
14173 __attribute__((unused)) void *data)
14175 struct cmd_vf_tc_bw_result *res = parsed_result;
14176 struct rte_port *port;
14179 int ret = -ENOTSUP;
14181 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14184 port = &ports[res->port_id];
14185 /** Check if the port is not started **/
14186 if (port->port_status != RTE_PORT_STOPPED) {
14187 printf("Please stop port %d first\n", res->port_id);
14191 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14195 #ifdef RTE_LIBRTE_IXGBE_PMD
14196 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14203 printf("invalid bandwidth\n");
14206 printf("invalid port_id %d\n", res->port_id);
14209 printf("function not implemented\n");
14212 printf("programming error: (%s)\n", strerror(-ret));
14216 cmdline_parse_inst_t cmd_tc_min_bw = {
14217 .f = cmd_tc_min_bw_parsed,
14219 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14221 (void *)&cmd_vf_tc_bw_set,
14222 (void *)&cmd_vf_tc_bw_tc,
14223 (void *)&cmd_vf_tc_bw_tx,
14224 (void *)&cmd_vf_tc_bw_min_bw,
14225 (void *)&cmd_vf_tc_bw_port_id,
14226 (void *)&cmd_vf_tc_bw_bw_list,
14231 /* TC max bandwidth setting */
14233 cmd_vf_tc_max_bw_parsed(
14234 void *parsed_result,
14235 __attribute__((unused)) struct cmdline *cl,
14236 __attribute__((unused)) void *data)
14238 struct cmd_vf_tc_bw_result *res = parsed_result;
14239 int ret = -ENOTSUP;
14241 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14244 #ifdef RTE_LIBRTE_I40E_PMD
14245 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14246 res->tc_no, res->bw);
14253 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14254 res->vf_id, res->tc_no, res->bw);
14257 printf("invalid port_id %d\n", res->port_id);
14260 printf("function not implemented\n");
14263 printf("programming error: (%s)\n", strerror(-ret));
14267 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14268 .f = cmd_vf_tc_max_bw_parsed,
14270 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14273 (void *)&cmd_vf_tc_bw_set,
14274 (void *)&cmd_vf_tc_bw_vf,
14275 (void *)&cmd_vf_tc_bw_tc,
14276 (void *)&cmd_vf_tc_bw_tx,
14277 (void *)&cmd_vf_tc_bw_max_bw,
14278 (void *)&cmd_vf_tc_bw_port_id,
14279 (void *)&cmd_vf_tc_bw_vf_id,
14280 (void *)&cmd_vf_tc_bw_tc_no,
14281 (void *)&cmd_vf_tc_bw_bw,
14287 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14289 /* *** Set Port default Traffic Management Hierarchy *** */
14290 struct cmd_set_port_tm_hierarchy_default_result {
14291 cmdline_fixed_string_t set;
14292 cmdline_fixed_string_t port;
14293 cmdline_fixed_string_t tm;
14294 cmdline_fixed_string_t hierarchy;
14295 cmdline_fixed_string_t def;
14299 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14300 TOKEN_STRING_INITIALIZER(
14301 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14302 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14303 TOKEN_STRING_INITIALIZER(
14304 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14305 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14306 TOKEN_STRING_INITIALIZER(
14307 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14308 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14309 TOKEN_STRING_INITIALIZER(
14310 struct cmd_set_port_tm_hierarchy_default_result,
14311 hierarchy, "hierarchy");
14312 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14313 TOKEN_STRING_INITIALIZER(
14314 struct cmd_set_port_tm_hierarchy_default_result,
14316 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14317 TOKEN_NUM_INITIALIZER(
14318 struct cmd_set_port_tm_hierarchy_default_result,
14321 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14322 __attribute__((unused)) struct cmdline *cl,
14323 __attribute__((unused)) void *data)
14325 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14326 struct rte_port *p;
14327 portid_t port_id = res->port_id;
14329 if (port_id_is_invalid(port_id, ENABLED_WARN))
14332 p = &ports[port_id];
14335 if (p->softport.tm_flag == 0) {
14336 printf(" tm not enabled on port %u (error)\n", port_id);
14340 /* Forward mode: tm */
14341 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14342 printf(" tm mode not enabled(error)\n");
14346 /* Set the default tm hierarchy */
14347 p->softport.tm.default_hierarchy_enable = 1;
14350 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14351 .f = cmd_set_port_tm_hierarchy_default_parsed,
14353 .help_str = "set port tm hierarchy default <port_id>",
14355 (void *)&cmd_set_port_tm_hierarchy_default_set,
14356 (void *)&cmd_set_port_tm_hierarchy_default_port,
14357 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14358 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14359 (void *)&cmd_set_port_tm_hierarchy_default_default,
14360 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14366 /* Strict link priority scheduling mode setting */
14368 cmd_strict_link_prio_parsed(
14369 void *parsed_result,
14370 __attribute__((unused)) struct cmdline *cl,
14371 __attribute__((unused)) void *data)
14373 struct cmd_vf_tc_bw_result *res = parsed_result;
14374 int ret = -ENOTSUP;
14376 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14379 #ifdef RTE_LIBRTE_I40E_PMD
14380 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14387 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14390 printf("invalid port_id %d\n", res->port_id);
14393 printf("function not implemented\n");
14396 printf("programming error: (%s)\n", strerror(-ret));
14400 cmdline_parse_inst_t cmd_strict_link_prio = {
14401 .f = cmd_strict_link_prio_parsed,
14403 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14405 (void *)&cmd_vf_tc_bw_set,
14406 (void *)&cmd_vf_tc_bw_tx,
14407 (void *)&cmd_vf_tc_bw_strict_link_prio,
14408 (void *)&cmd_vf_tc_bw_port_id,
14409 (void *)&cmd_vf_tc_bw_tc_map,
14414 /* Load dynamic device personalization*/
14415 struct cmd_ddp_add_result {
14416 cmdline_fixed_string_t ddp;
14417 cmdline_fixed_string_t add;
14422 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14423 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14424 cmdline_parse_token_string_t cmd_ddp_add_add =
14425 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14426 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14427 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14428 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14429 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14432 cmd_ddp_add_parsed(
14433 void *parsed_result,
14434 __attribute__((unused)) struct cmdline *cl,
14435 __attribute__((unused)) void *data)
14437 struct cmd_ddp_add_result *res = parsed_result;
14443 int ret = -ENOTSUP;
14445 if (res->port_id > nb_ports) {
14446 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14450 if (!all_ports_stopped()) {
14451 printf("Please stop all ports first\n");
14455 filepath = strdup(res->filepath);
14456 if (filepath == NULL) {
14457 printf("Failed to allocate memory\n");
14460 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14462 buff = open_file(file_fld[0], &size);
14464 free((void *)filepath);
14468 #ifdef RTE_LIBRTE_I40E_PMD
14469 if (ret == -ENOTSUP)
14470 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14472 RTE_PMD_I40E_PKG_OP_WR_ADD);
14475 if (ret == -EEXIST)
14476 printf("Profile has already existed.\n");
14478 printf("Failed to load profile.\n");
14479 else if (file_num == 2)
14480 save_file(file_fld[1], buff, size);
14483 free((void *)filepath);
14486 cmdline_parse_inst_t cmd_ddp_add = {
14487 .f = cmd_ddp_add_parsed,
14489 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14491 (void *)&cmd_ddp_add_ddp,
14492 (void *)&cmd_ddp_add_add,
14493 (void *)&cmd_ddp_add_port_id,
14494 (void *)&cmd_ddp_add_filepath,
14499 /* Delete dynamic device personalization*/
14500 struct cmd_ddp_del_result {
14501 cmdline_fixed_string_t ddp;
14502 cmdline_fixed_string_t del;
14507 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14508 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14509 cmdline_parse_token_string_t cmd_ddp_del_del =
14510 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14511 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14512 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14513 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14514 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14517 cmd_ddp_del_parsed(
14518 void *parsed_result,
14519 __attribute__((unused)) struct cmdline *cl,
14520 __attribute__((unused)) void *data)
14522 struct cmd_ddp_del_result *res = parsed_result;
14525 int ret = -ENOTSUP;
14527 if (res->port_id > nb_ports) {
14528 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14532 if (!all_ports_stopped()) {
14533 printf("Please stop all ports first\n");
14537 buff = open_file(res->filepath, &size);
14541 #ifdef RTE_LIBRTE_I40E_PMD
14542 if (ret == -ENOTSUP)
14543 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14545 RTE_PMD_I40E_PKG_OP_WR_DEL);
14548 if (ret == -EACCES)
14549 printf("Profile does not exist.\n");
14551 printf("Failed to delete profile.\n");
14556 cmdline_parse_inst_t cmd_ddp_del = {
14557 .f = cmd_ddp_del_parsed,
14559 .help_str = "ddp del <port_id> <profile_path>",
14561 (void *)&cmd_ddp_del_ddp,
14562 (void *)&cmd_ddp_del_del,
14563 (void *)&cmd_ddp_del_port_id,
14564 (void *)&cmd_ddp_del_filepath,
14569 /* Get dynamic device personalization profile info */
14570 struct cmd_ddp_info_result {
14571 cmdline_fixed_string_t ddp;
14572 cmdline_fixed_string_t get;
14573 cmdline_fixed_string_t info;
14577 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14578 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14579 cmdline_parse_token_string_t cmd_ddp_info_get =
14580 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14581 cmdline_parse_token_string_t cmd_ddp_info_info =
14582 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14583 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14584 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14587 cmd_ddp_info_parsed(
14588 void *parsed_result,
14589 __attribute__((unused)) struct cmdline *cl,
14590 __attribute__((unused)) void *data)
14592 struct cmd_ddp_info_result *res = parsed_result;
14595 int ret = -ENOTSUP;
14596 #ifdef RTE_LIBRTE_I40E_PMD
14599 uint32_t buff_size = 0;
14600 struct rte_pmd_i40e_profile_info info;
14601 uint32_t dev_num = 0;
14602 struct rte_pmd_i40e_ddp_device_id *devs;
14603 uint32_t proto_num = 0;
14604 struct rte_pmd_i40e_proto_info *proto = NULL;
14605 uint32_t pctype_num = 0;
14606 struct rte_pmd_i40e_ptype_info *pctype;
14607 uint32_t ptype_num = 0;
14608 struct rte_pmd_i40e_ptype_info *ptype;
14613 pkg = open_file(res->filepath, &pkg_size);
14617 #ifdef RTE_LIBRTE_I40E_PMD
14618 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14619 (uint8_t *)&info, sizeof(info),
14620 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14622 printf("Global Track id: 0x%x\n", info.track_id);
14623 printf("Global Version: %d.%d.%d.%d\n",
14624 info.version.major,
14625 info.version.minor,
14626 info.version.update,
14627 info.version.draft);
14628 printf("Global Package name: %s\n\n", info.name);
14631 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14632 (uint8_t *)&info, sizeof(info),
14633 RTE_PMD_I40E_PKG_INFO_HEADER);
14635 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14636 printf("i40e Profile Version: %d.%d.%d.%d\n",
14637 info.version.major,
14638 info.version.minor,
14639 info.version.update,
14640 info.version.draft);
14641 printf("i40e Profile name: %s\n\n", info.name);
14644 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14645 (uint8_t *)&buff_size, sizeof(buff_size),
14646 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14647 if (!ret && buff_size) {
14648 buff = (uint8_t *)malloc(buff_size);
14650 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14652 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14654 printf("Package Notes:\n%s\n\n", buff);
14659 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14660 (uint8_t *)&dev_num, sizeof(dev_num),
14661 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14662 if (!ret && dev_num) {
14663 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14664 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14666 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14667 (uint8_t *)devs, buff_size,
14668 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14670 printf("List of supported devices:\n");
14671 for (i = 0; i < dev_num; i++) {
14672 printf(" %04X:%04X %04X:%04X\n",
14673 devs[i].vendor_dev_id >> 16,
14674 devs[i].vendor_dev_id & 0xFFFF,
14675 devs[i].sub_vendor_dev_id >> 16,
14676 devs[i].sub_vendor_dev_id & 0xFFFF);
14684 /* get information about protocols and packet types */
14685 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14686 (uint8_t *)&proto_num, sizeof(proto_num),
14687 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14688 if (ret || !proto_num)
14689 goto no_print_return;
14691 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14692 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14694 goto no_print_return;
14696 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14698 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14700 printf("List of used protocols:\n");
14701 for (i = 0; i < proto_num; i++)
14702 printf(" %2u: %s\n", proto[i].proto_id,
14706 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14707 (uint8_t *)&pctype_num, sizeof(pctype_num),
14708 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14709 if (ret || !pctype_num)
14710 goto no_print_pctypes;
14712 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14713 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14715 goto no_print_pctypes;
14717 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14719 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14722 goto no_print_pctypes;
14725 printf("List of defined packet classification types:\n");
14726 for (i = 0; i < pctype_num; i++) {
14727 printf(" %2u:", pctype[i].ptype_id);
14728 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14729 proto_id = pctype[i].protocols[j];
14730 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14731 for (n = 0; n < proto_num; n++) {
14732 if (proto[n].proto_id == proto_id) {
14733 printf(" %s", proto[n].name);
14746 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14748 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14749 if (ret || !ptype_num)
14750 goto no_print_return;
14752 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14753 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14755 goto no_print_return;
14757 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14759 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14762 goto no_print_return;
14764 printf("List of defined packet types:\n");
14765 for (i = 0; i < ptype_num; i++) {
14766 printf(" %2u:", ptype[i].ptype_id);
14767 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14768 proto_id = ptype[i].protocols[j];
14769 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14770 for (n = 0; n < proto_num; n++) {
14771 if (proto[n].proto_id == proto_id) {
14772 printf(" %s", proto[n].name);
14788 if (ret == -ENOTSUP)
14789 printf("Function not supported in PMD driver\n");
14793 cmdline_parse_inst_t cmd_ddp_get_info = {
14794 .f = cmd_ddp_info_parsed,
14796 .help_str = "ddp get info <profile_path>",
14798 (void *)&cmd_ddp_info_ddp,
14799 (void *)&cmd_ddp_info_get,
14800 (void *)&cmd_ddp_info_info,
14801 (void *)&cmd_ddp_info_filepath,
14806 /* Get dynamic device personalization profile info list*/
14807 #define PROFILE_INFO_SIZE 48
14808 #define MAX_PROFILE_NUM 16
14810 struct cmd_ddp_get_list_result {
14811 cmdline_fixed_string_t ddp;
14812 cmdline_fixed_string_t get;
14813 cmdline_fixed_string_t list;
14817 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14818 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14819 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14820 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14821 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14822 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14823 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14824 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14827 cmd_ddp_get_list_parsed(
14828 void *parsed_result,
14829 __attribute__((unused)) struct cmdline *cl,
14830 __attribute__((unused)) void *data)
14832 struct cmd_ddp_get_list_result *res = parsed_result;
14833 #ifdef RTE_LIBRTE_I40E_PMD
14834 struct rte_pmd_i40e_profile_list *p_list;
14835 struct rte_pmd_i40e_profile_info *p_info;
14840 int ret = -ENOTSUP;
14842 if (res->port_id > nb_ports) {
14843 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14847 #ifdef RTE_LIBRTE_I40E_PMD
14848 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14849 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14851 printf("%s: Failed to malloc buffer\n", __func__);
14853 if (ret == -ENOTSUP)
14854 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14855 (uint8_t *)p_list, size);
14858 p_num = p_list->p_count;
14859 printf("Profile number is: %d\n\n", p_num);
14861 for (i = 0; i < p_num; i++) {
14862 p_info = &p_list->p_info[i];
14863 printf("Profile %d:\n", i);
14864 printf("Track id: 0x%x\n", p_info->track_id);
14865 printf("Version: %d.%d.%d.%d\n",
14866 p_info->version.major,
14867 p_info->version.minor,
14868 p_info->version.update,
14869 p_info->version.draft);
14870 printf("Profile name: %s\n\n", p_info->name);
14878 printf("Failed to get ddp list\n");
14881 cmdline_parse_inst_t cmd_ddp_get_list = {
14882 .f = cmd_ddp_get_list_parsed,
14884 .help_str = "ddp get list <port_id>",
14886 (void *)&cmd_ddp_get_list_ddp,
14887 (void *)&cmd_ddp_get_list_get,
14888 (void *)&cmd_ddp_get_list_list,
14889 (void *)&cmd_ddp_get_list_port_id,
14894 /* Configure input set */
14895 struct cmd_cfg_input_set_result {
14896 cmdline_fixed_string_t port;
14897 cmdline_fixed_string_t cfg;
14899 cmdline_fixed_string_t pctype;
14901 cmdline_fixed_string_t inset_type;
14902 cmdline_fixed_string_t opt;
14903 cmdline_fixed_string_t field;
14908 cmd_cfg_input_set_parsed(
14909 void *parsed_result,
14910 __attribute__((unused)) struct cmdline *cl,
14911 __attribute__((unused)) void *data)
14913 struct cmd_cfg_input_set_result *res = parsed_result;
14914 #ifdef RTE_LIBRTE_I40E_PMD
14915 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14916 struct rte_pmd_i40e_inset inset;
14918 int ret = -ENOTSUP;
14920 if (res->port_id > nb_ports) {
14921 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14925 if (!all_ports_stopped()) {
14926 printf("Please stop all ports first\n");
14930 #ifdef RTE_LIBRTE_I40E_PMD
14931 if (!strcmp(res->inset_type, "hash_inset"))
14932 inset_type = INSET_HASH;
14933 else if (!strcmp(res->inset_type, "fdir_inset"))
14934 inset_type = INSET_FDIR;
14935 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14936 inset_type = INSET_FDIR_FLX;
14937 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14938 &inset, inset_type);
14940 printf("Failed to get input set.\n");
14944 if (!strcmp(res->opt, "get")) {
14945 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14948 printf("Field index %d is enabled.\n", res->field_idx);
14950 printf("Field index %d is disabled.\n", res->field_idx);
14952 } else if (!strcmp(res->opt, "set"))
14953 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14955 else if (!strcmp(res->opt, "clear"))
14956 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14959 printf("Failed to configure input set field.\n");
14963 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14964 &inset, inset_type);
14966 printf("Failed to set input set.\n");
14971 if (ret == -ENOTSUP)
14972 printf("Function not supported\n");
14975 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14976 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14978 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14979 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14981 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14982 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14984 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14985 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14987 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14988 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14990 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14991 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14993 "hash_inset#fdir_inset#fdir_flx_inset");
14994 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14995 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14996 opt, "get#set#clear");
14997 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14998 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15000 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15001 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15004 cmdline_parse_inst_t cmd_cfg_input_set = {
15005 .f = cmd_cfg_input_set_parsed,
15007 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15008 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15010 (void *)&cmd_cfg_input_set_port,
15011 (void *)&cmd_cfg_input_set_cfg,
15012 (void *)&cmd_cfg_input_set_port_id,
15013 (void *)&cmd_cfg_input_set_pctype,
15014 (void *)&cmd_cfg_input_set_pctype_id,
15015 (void *)&cmd_cfg_input_set_inset_type,
15016 (void *)&cmd_cfg_input_set_opt,
15017 (void *)&cmd_cfg_input_set_field,
15018 (void *)&cmd_cfg_input_set_field_idx,
15023 /* Clear input set */
15024 struct cmd_clear_input_set_result {
15025 cmdline_fixed_string_t port;
15026 cmdline_fixed_string_t cfg;
15028 cmdline_fixed_string_t pctype;
15030 cmdline_fixed_string_t inset_type;
15031 cmdline_fixed_string_t clear;
15032 cmdline_fixed_string_t all;
15036 cmd_clear_input_set_parsed(
15037 void *parsed_result,
15038 __attribute__((unused)) struct cmdline *cl,
15039 __attribute__((unused)) void *data)
15041 struct cmd_clear_input_set_result *res = parsed_result;
15042 #ifdef RTE_LIBRTE_I40E_PMD
15043 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15044 struct rte_pmd_i40e_inset inset;
15046 int ret = -ENOTSUP;
15048 if (res->port_id > nb_ports) {
15049 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
15053 if (!all_ports_stopped()) {
15054 printf("Please stop all ports first\n");
15058 #ifdef RTE_LIBRTE_I40E_PMD
15059 if (!strcmp(res->inset_type, "hash_inset"))
15060 inset_type = INSET_HASH;
15061 else if (!strcmp(res->inset_type, "fdir_inset"))
15062 inset_type = INSET_FDIR;
15063 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15064 inset_type = INSET_FDIR_FLX;
15066 memset(&inset, 0, sizeof(inset));
15068 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15069 &inset, inset_type);
15071 printf("Failed to clear input set.\n");
15077 if (ret == -ENOTSUP)
15078 printf("Function not supported\n");
15081 cmdline_parse_token_string_t cmd_clear_input_set_port =
15082 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15084 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15085 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15087 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15088 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15090 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15091 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15093 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15094 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15096 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15097 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15099 "hash_inset#fdir_inset#fdir_flx_inset");
15100 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15101 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15103 cmdline_parse_token_string_t cmd_clear_input_set_all =
15104 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15107 cmdline_parse_inst_t cmd_clear_input_set = {
15108 .f = cmd_clear_input_set_parsed,
15110 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15111 "fdir_inset|fdir_flx_inset clear all",
15113 (void *)&cmd_clear_input_set_port,
15114 (void *)&cmd_clear_input_set_cfg,
15115 (void *)&cmd_clear_input_set_port_id,
15116 (void *)&cmd_clear_input_set_pctype,
15117 (void *)&cmd_clear_input_set_pctype_id,
15118 (void *)&cmd_clear_input_set_inset_type,
15119 (void *)&cmd_clear_input_set_clear,
15120 (void *)&cmd_clear_input_set_all,
15125 /* show vf stats */
15127 /* Common result structure for show vf stats */
15128 struct cmd_show_vf_stats_result {
15129 cmdline_fixed_string_t show;
15130 cmdline_fixed_string_t vf;
15131 cmdline_fixed_string_t stats;
15136 /* Common CLI fields show vf stats*/
15137 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15138 TOKEN_STRING_INITIALIZER
15139 (struct cmd_show_vf_stats_result,
15141 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15142 TOKEN_STRING_INITIALIZER
15143 (struct cmd_show_vf_stats_result,
15145 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15146 TOKEN_STRING_INITIALIZER
15147 (struct cmd_show_vf_stats_result,
15149 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15150 TOKEN_NUM_INITIALIZER
15151 (struct cmd_show_vf_stats_result,
15153 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15154 TOKEN_NUM_INITIALIZER
15155 (struct cmd_show_vf_stats_result,
15159 cmd_show_vf_stats_parsed(
15160 void *parsed_result,
15161 __attribute__((unused)) struct cmdline *cl,
15162 __attribute__((unused)) void *data)
15164 struct cmd_show_vf_stats_result *res = parsed_result;
15165 struct rte_eth_stats stats;
15166 int ret = -ENOTSUP;
15167 static const char *nic_stats_border = "########################";
15169 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15172 memset(&stats, 0, sizeof(stats));
15174 #ifdef RTE_LIBRTE_I40E_PMD
15175 if (ret == -ENOTSUP)
15176 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15180 #ifdef RTE_LIBRTE_BNXT_PMD
15181 if (ret == -ENOTSUP)
15182 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15191 printf("invalid vf_id %d\n", res->vf_id);
15194 printf("invalid port_id %d\n", res->port_id);
15197 printf("function not implemented\n");
15200 printf("programming error: (%s)\n", strerror(-ret));
15203 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15204 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15206 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15208 stats.ipackets, stats.imissed, stats.ibytes);
15209 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15210 printf(" RX-nombuf: %-10"PRIu64"\n",
15212 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15214 stats.opackets, stats.oerrors, stats.obytes);
15216 printf(" %s############################%s\n",
15217 nic_stats_border, nic_stats_border);
15220 cmdline_parse_inst_t cmd_show_vf_stats = {
15221 .f = cmd_show_vf_stats_parsed,
15223 .help_str = "show vf stats <port_id> <vf_id>",
15225 (void *)&cmd_show_vf_stats_show,
15226 (void *)&cmd_show_vf_stats_vf,
15227 (void *)&cmd_show_vf_stats_stats,
15228 (void *)&cmd_show_vf_stats_port_id,
15229 (void *)&cmd_show_vf_stats_vf_id,
15234 /* clear vf stats */
15236 /* Common result structure for clear vf stats */
15237 struct cmd_clear_vf_stats_result {
15238 cmdline_fixed_string_t clear;
15239 cmdline_fixed_string_t vf;
15240 cmdline_fixed_string_t stats;
15245 /* Common CLI fields clear vf stats*/
15246 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15247 TOKEN_STRING_INITIALIZER
15248 (struct cmd_clear_vf_stats_result,
15250 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15251 TOKEN_STRING_INITIALIZER
15252 (struct cmd_clear_vf_stats_result,
15254 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15255 TOKEN_STRING_INITIALIZER
15256 (struct cmd_clear_vf_stats_result,
15258 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15259 TOKEN_NUM_INITIALIZER
15260 (struct cmd_clear_vf_stats_result,
15262 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15263 TOKEN_NUM_INITIALIZER
15264 (struct cmd_clear_vf_stats_result,
15268 cmd_clear_vf_stats_parsed(
15269 void *parsed_result,
15270 __attribute__((unused)) struct cmdline *cl,
15271 __attribute__((unused)) void *data)
15273 struct cmd_clear_vf_stats_result *res = parsed_result;
15274 int ret = -ENOTSUP;
15276 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15279 #ifdef RTE_LIBRTE_I40E_PMD
15280 if (ret == -ENOTSUP)
15281 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15284 #ifdef RTE_LIBRTE_BNXT_PMD
15285 if (ret == -ENOTSUP)
15286 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15294 printf("invalid vf_id %d\n", res->vf_id);
15297 printf("invalid port_id %d\n", res->port_id);
15300 printf("function not implemented\n");
15303 printf("programming error: (%s)\n", strerror(-ret));
15307 cmdline_parse_inst_t cmd_clear_vf_stats = {
15308 .f = cmd_clear_vf_stats_parsed,
15310 .help_str = "clear vf stats <port_id> <vf_id>",
15312 (void *)&cmd_clear_vf_stats_clear,
15313 (void *)&cmd_clear_vf_stats_vf,
15314 (void *)&cmd_clear_vf_stats_stats,
15315 (void *)&cmd_clear_vf_stats_port_id,
15316 (void *)&cmd_clear_vf_stats_vf_id,
15321 /* port config pctype mapping reset */
15323 /* Common result structure for port config pctype mapping reset */
15324 struct cmd_pctype_mapping_reset_result {
15325 cmdline_fixed_string_t port;
15326 cmdline_fixed_string_t config;
15328 cmdline_fixed_string_t pctype;
15329 cmdline_fixed_string_t mapping;
15330 cmdline_fixed_string_t reset;
15333 /* Common CLI fields for port config pctype mapping reset*/
15334 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15335 TOKEN_STRING_INITIALIZER
15336 (struct cmd_pctype_mapping_reset_result,
15338 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15339 TOKEN_STRING_INITIALIZER
15340 (struct cmd_pctype_mapping_reset_result,
15342 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15343 TOKEN_NUM_INITIALIZER
15344 (struct cmd_pctype_mapping_reset_result,
15346 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15347 TOKEN_STRING_INITIALIZER
15348 (struct cmd_pctype_mapping_reset_result,
15350 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15351 TOKEN_STRING_INITIALIZER
15352 (struct cmd_pctype_mapping_reset_result,
15353 mapping, "mapping");
15354 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15355 TOKEN_STRING_INITIALIZER
15356 (struct cmd_pctype_mapping_reset_result,
15360 cmd_pctype_mapping_reset_parsed(
15361 void *parsed_result,
15362 __attribute__((unused)) struct cmdline *cl,
15363 __attribute__((unused)) void *data)
15365 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15366 int ret = -ENOTSUP;
15368 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15371 #ifdef RTE_LIBRTE_I40E_PMD
15372 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15379 printf("invalid port_id %d\n", res->port_id);
15382 printf("function not implemented\n");
15385 printf("programming error: (%s)\n", strerror(-ret));
15389 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15390 .f = cmd_pctype_mapping_reset_parsed,
15392 .help_str = "port config <port_id> pctype mapping reset",
15394 (void *)&cmd_pctype_mapping_reset_port,
15395 (void *)&cmd_pctype_mapping_reset_config,
15396 (void *)&cmd_pctype_mapping_reset_port_id,
15397 (void *)&cmd_pctype_mapping_reset_pctype,
15398 (void *)&cmd_pctype_mapping_reset_mapping,
15399 (void *)&cmd_pctype_mapping_reset_reset,
15404 /* show port pctype mapping */
15406 /* Common result structure for show port pctype mapping */
15407 struct cmd_pctype_mapping_get_result {
15408 cmdline_fixed_string_t show;
15409 cmdline_fixed_string_t port;
15411 cmdline_fixed_string_t pctype;
15412 cmdline_fixed_string_t mapping;
15415 /* Common CLI fields for pctype mapping get */
15416 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15417 TOKEN_STRING_INITIALIZER
15418 (struct cmd_pctype_mapping_get_result,
15420 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15421 TOKEN_STRING_INITIALIZER
15422 (struct cmd_pctype_mapping_get_result,
15424 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15425 TOKEN_NUM_INITIALIZER
15426 (struct cmd_pctype_mapping_get_result,
15428 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15429 TOKEN_STRING_INITIALIZER
15430 (struct cmd_pctype_mapping_get_result,
15432 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15433 TOKEN_STRING_INITIALIZER
15434 (struct cmd_pctype_mapping_get_result,
15435 mapping, "mapping");
15438 cmd_pctype_mapping_get_parsed(
15439 void *parsed_result,
15440 __attribute__((unused)) struct cmdline *cl,
15441 __attribute__((unused)) void *data)
15443 struct cmd_pctype_mapping_get_result *res = parsed_result;
15444 int ret = -ENOTSUP;
15445 #ifdef RTE_LIBRTE_I40E_PMD
15446 struct rte_pmd_i40e_flow_type_mapping
15447 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15448 int i, j, first_pctype;
15451 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15454 #ifdef RTE_LIBRTE_I40E_PMD
15455 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15462 printf("invalid port_id %d\n", res->port_id);
15465 printf("function not implemented\n");
15468 printf("programming error: (%s)\n", strerror(-ret));
15472 #ifdef RTE_LIBRTE_I40E_PMD
15473 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15474 if (mapping[i].pctype != 0ULL) {
15477 printf("pctype: ");
15478 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15479 if (mapping[i].pctype & (1ULL << j)) {
15480 printf(first_pctype ?
15481 "%02d" : ",%02d", j);
15485 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15491 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15492 .f = cmd_pctype_mapping_get_parsed,
15494 .help_str = "show port <port_id> pctype mapping",
15496 (void *)&cmd_pctype_mapping_get_show,
15497 (void *)&cmd_pctype_mapping_get_port,
15498 (void *)&cmd_pctype_mapping_get_port_id,
15499 (void *)&cmd_pctype_mapping_get_pctype,
15500 (void *)&cmd_pctype_mapping_get_mapping,
15505 /* port config pctype mapping update */
15507 /* Common result structure for port config pctype mapping update */
15508 struct cmd_pctype_mapping_update_result {
15509 cmdline_fixed_string_t port;
15510 cmdline_fixed_string_t config;
15512 cmdline_fixed_string_t pctype;
15513 cmdline_fixed_string_t mapping;
15514 cmdline_fixed_string_t update;
15515 cmdline_fixed_string_t pctype_list;
15516 uint16_t flow_type;
15519 /* Common CLI fields for pctype mapping update*/
15520 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15521 TOKEN_STRING_INITIALIZER
15522 (struct cmd_pctype_mapping_update_result,
15524 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15525 TOKEN_STRING_INITIALIZER
15526 (struct cmd_pctype_mapping_update_result,
15528 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15529 TOKEN_NUM_INITIALIZER
15530 (struct cmd_pctype_mapping_update_result,
15532 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15533 TOKEN_STRING_INITIALIZER
15534 (struct cmd_pctype_mapping_update_result,
15536 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15537 TOKEN_STRING_INITIALIZER
15538 (struct cmd_pctype_mapping_update_result,
15539 mapping, "mapping");
15540 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15541 TOKEN_STRING_INITIALIZER
15542 (struct cmd_pctype_mapping_update_result,
15544 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15545 TOKEN_STRING_INITIALIZER
15546 (struct cmd_pctype_mapping_update_result,
15547 pctype_list, NULL);
15548 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15549 TOKEN_NUM_INITIALIZER
15550 (struct cmd_pctype_mapping_update_result,
15551 flow_type, UINT16);
15554 cmd_pctype_mapping_update_parsed(
15555 void *parsed_result,
15556 __attribute__((unused)) struct cmdline *cl,
15557 __attribute__((unused)) void *data)
15559 struct cmd_pctype_mapping_update_result *res = parsed_result;
15560 int ret = -ENOTSUP;
15561 #ifdef RTE_LIBRTE_I40E_PMD
15562 struct rte_pmd_i40e_flow_type_mapping mapping;
15564 unsigned int nb_item;
15565 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15568 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15571 #ifdef RTE_LIBRTE_I40E_PMD
15572 nb_item = parse_item_list(res->pctype_list, "pctypes",
15573 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15574 mapping.flow_type = res->flow_type;
15575 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15576 mapping.pctype |= (1ULL << pctype_list[i]);
15577 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15587 printf("invalid pctype or flow type\n");
15590 printf("invalid port_id %d\n", res->port_id);
15593 printf("function not implemented\n");
15596 printf("programming error: (%s)\n", strerror(-ret));
15600 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15601 .f = cmd_pctype_mapping_update_parsed,
15603 .help_str = "port config <port_id> pctype mapping update"
15604 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15606 (void *)&cmd_pctype_mapping_update_port,
15607 (void *)&cmd_pctype_mapping_update_config,
15608 (void *)&cmd_pctype_mapping_update_port_id,
15609 (void *)&cmd_pctype_mapping_update_pctype,
15610 (void *)&cmd_pctype_mapping_update_mapping,
15611 (void *)&cmd_pctype_mapping_update_update,
15612 (void *)&cmd_pctype_mapping_update_pc_type,
15613 (void *)&cmd_pctype_mapping_update_flow_type,
15618 /* ptype mapping get */
15620 /* Common result structure for ptype mapping get */
15621 struct cmd_ptype_mapping_get_result {
15622 cmdline_fixed_string_t ptype;
15623 cmdline_fixed_string_t mapping;
15624 cmdline_fixed_string_t get;
15626 uint8_t valid_only;
15629 /* Common CLI fields for ptype mapping get */
15630 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15631 TOKEN_STRING_INITIALIZER
15632 (struct cmd_ptype_mapping_get_result,
15634 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15635 TOKEN_STRING_INITIALIZER
15636 (struct cmd_ptype_mapping_get_result,
15637 mapping, "mapping");
15638 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15639 TOKEN_STRING_INITIALIZER
15640 (struct cmd_ptype_mapping_get_result,
15642 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15643 TOKEN_NUM_INITIALIZER
15644 (struct cmd_ptype_mapping_get_result,
15646 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15647 TOKEN_NUM_INITIALIZER
15648 (struct cmd_ptype_mapping_get_result,
15649 valid_only, UINT8);
15652 cmd_ptype_mapping_get_parsed(
15653 void *parsed_result,
15654 __attribute__((unused)) struct cmdline *cl,
15655 __attribute__((unused)) void *data)
15657 struct cmd_ptype_mapping_get_result *res = parsed_result;
15658 int ret = -ENOTSUP;
15659 #ifdef RTE_LIBRTE_I40E_PMD
15660 int max_ptype_num = 256;
15661 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15666 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15669 #ifdef RTE_LIBRTE_I40E_PMD
15670 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15681 printf("invalid port_id %d\n", res->port_id);
15684 printf("function not implemented\n");
15687 printf("programming error: (%s)\n", strerror(-ret));
15690 #ifdef RTE_LIBRTE_I40E_PMD
15692 for (i = 0; i < count; i++)
15693 printf("%3d\t0x%08x\n",
15694 mapping[i].hw_ptype, mapping[i].sw_ptype);
15699 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15700 .f = cmd_ptype_mapping_get_parsed,
15702 .help_str = "ptype mapping get <port_id> <valid_only>",
15704 (void *)&cmd_ptype_mapping_get_ptype,
15705 (void *)&cmd_ptype_mapping_get_mapping,
15706 (void *)&cmd_ptype_mapping_get_get,
15707 (void *)&cmd_ptype_mapping_get_port_id,
15708 (void *)&cmd_ptype_mapping_get_valid_only,
15713 /* ptype mapping replace */
15715 /* Common result structure for ptype mapping replace */
15716 struct cmd_ptype_mapping_replace_result {
15717 cmdline_fixed_string_t ptype;
15718 cmdline_fixed_string_t mapping;
15719 cmdline_fixed_string_t replace;
15726 /* Common CLI fields for ptype mapping replace */
15727 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15728 TOKEN_STRING_INITIALIZER
15729 (struct cmd_ptype_mapping_replace_result,
15731 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15732 TOKEN_STRING_INITIALIZER
15733 (struct cmd_ptype_mapping_replace_result,
15734 mapping, "mapping");
15735 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15736 TOKEN_STRING_INITIALIZER
15737 (struct cmd_ptype_mapping_replace_result,
15738 replace, "replace");
15739 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15740 TOKEN_NUM_INITIALIZER
15741 (struct cmd_ptype_mapping_replace_result,
15743 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15744 TOKEN_NUM_INITIALIZER
15745 (struct cmd_ptype_mapping_replace_result,
15747 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15748 TOKEN_NUM_INITIALIZER
15749 (struct cmd_ptype_mapping_replace_result,
15751 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15752 TOKEN_NUM_INITIALIZER
15753 (struct cmd_ptype_mapping_replace_result,
15757 cmd_ptype_mapping_replace_parsed(
15758 void *parsed_result,
15759 __attribute__((unused)) struct cmdline *cl,
15760 __attribute__((unused)) void *data)
15762 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15763 int ret = -ENOTSUP;
15765 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15768 #ifdef RTE_LIBRTE_I40E_PMD
15769 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15779 printf("invalid ptype 0x%8x or 0x%8x\n",
15780 res->target, res->pkt_type);
15783 printf("invalid port_id %d\n", res->port_id);
15786 printf("function not implemented\n");
15789 printf("programming error: (%s)\n", strerror(-ret));
15793 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15794 .f = cmd_ptype_mapping_replace_parsed,
15797 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15799 (void *)&cmd_ptype_mapping_replace_ptype,
15800 (void *)&cmd_ptype_mapping_replace_mapping,
15801 (void *)&cmd_ptype_mapping_replace_replace,
15802 (void *)&cmd_ptype_mapping_replace_port_id,
15803 (void *)&cmd_ptype_mapping_replace_target,
15804 (void *)&cmd_ptype_mapping_replace_mask,
15805 (void *)&cmd_ptype_mapping_replace_pkt_type,
15810 /* ptype mapping reset */
15812 /* Common result structure for ptype mapping reset */
15813 struct cmd_ptype_mapping_reset_result {
15814 cmdline_fixed_string_t ptype;
15815 cmdline_fixed_string_t mapping;
15816 cmdline_fixed_string_t reset;
15820 /* Common CLI fields for ptype mapping reset*/
15821 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15822 TOKEN_STRING_INITIALIZER
15823 (struct cmd_ptype_mapping_reset_result,
15825 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15826 TOKEN_STRING_INITIALIZER
15827 (struct cmd_ptype_mapping_reset_result,
15828 mapping, "mapping");
15829 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15830 TOKEN_STRING_INITIALIZER
15831 (struct cmd_ptype_mapping_reset_result,
15833 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15834 TOKEN_NUM_INITIALIZER
15835 (struct cmd_ptype_mapping_reset_result,
15839 cmd_ptype_mapping_reset_parsed(
15840 void *parsed_result,
15841 __attribute__((unused)) struct cmdline *cl,
15842 __attribute__((unused)) void *data)
15844 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15845 int ret = -ENOTSUP;
15847 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15850 #ifdef RTE_LIBRTE_I40E_PMD
15851 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15858 printf("invalid port_id %d\n", res->port_id);
15861 printf("function not implemented\n");
15864 printf("programming error: (%s)\n", strerror(-ret));
15868 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15869 .f = cmd_ptype_mapping_reset_parsed,
15871 .help_str = "ptype mapping reset <port_id>",
15873 (void *)&cmd_ptype_mapping_reset_ptype,
15874 (void *)&cmd_ptype_mapping_reset_mapping,
15875 (void *)&cmd_ptype_mapping_reset_reset,
15876 (void *)&cmd_ptype_mapping_reset_port_id,
15881 /* ptype mapping update */
15883 /* Common result structure for ptype mapping update */
15884 struct cmd_ptype_mapping_update_result {
15885 cmdline_fixed_string_t ptype;
15886 cmdline_fixed_string_t mapping;
15887 cmdline_fixed_string_t reset;
15893 /* Common CLI fields for ptype mapping update*/
15894 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15895 TOKEN_STRING_INITIALIZER
15896 (struct cmd_ptype_mapping_update_result,
15898 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15899 TOKEN_STRING_INITIALIZER
15900 (struct cmd_ptype_mapping_update_result,
15901 mapping, "mapping");
15902 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15903 TOKEN_STRING_INITIALIZER
15904 (struct cmd_ptype_mapping_update_result,
15906 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15907 TOKEN_NUM_INITIALIZER
15908 (struct cmd_ptype_mapping_update_result,
15910 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15911 TOKEN_NUM_INITIALIZER
15912 (struct cmd_ptype_mapping_update_result,
15914 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15915 TOKEN_NUM_INITIALIZER
15916 (struct cmd_ptype_mapping_update_result,
15920 cmd_ptype_mapping_update_parsed(
15921 void *parsed_result,
15922 __attribute__((unused)) struct cmdline *cl,
15923 __attribute__((unused)) void *data)
15925 struct cmd_ptype_mapping_update_result *res = parsed_result;
15926 int ret = -ENOTSUP;
15927 #ifdef RTE_LIBRTE_I40E_PMD
15928 struct rte_pmd_i40e_ptype_mapping mapping;
15930 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15933 #ifdef RTE_LIBRTE_I40E_PMD
15934 mapping.hw_ptype = res->hw_ptype;
15935 mapping.sw_ptype = res->sw_ptype;
15936 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15946 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15949 printf("invalid port_id %d\n", res->port_id);
15952 printf("function not implemented\n");
15955 printf("programming error: (%s)\n", strerror(-ret));
15959 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15960 .f = cmd_ptype_mapping_update_parsed,
15962 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15964 (void *)&cmd_ptype_mapping_update_ptype,
15965 (void *)&cmd_ptype_mapping_update_mapping,
15966 (void *)&cmd_ptype_mapping_update_update,
15967 (void *)&cmd_ptype_mapping_update_port_id,
15968 (void *)&cmd_ptype_mapping_update_hw_ptype,
15969 (void *)&cmd_ptype_mapping_update_sw_ptype,
15974 /* Common result structure for file commands */
15975 struct cmd_cmdfile_result {
15976 cmdline_fixed_string_t load;
15977 cmdline_fixed_string_t filename;
15980 /* Common CLI fields for file commands */
15981 cmdline_parse_token_string_t cmd_load_cmdfile =
15982 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15983 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15984 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15987 cmd_load_from_file_parsed(
15988 void *parsed_result,
15989 __attribute__((unused)) struct cmdline *cl,
15990 __attribute__((unused)) void *data)
15992 struct cmd_cmdfile_result *res = parsed_result;
15994 cmdline_read_from_file(res->filename);
15997 cmdline_parse_inst_t cmd_load_from_file = {
15998 .f = cmd_load_from_file_parsed,
16000 .help_str = "load <filename>",
16002 (void *)&cmd_load_cmdfile,
16003 (void *)&cmd_load_cmdfile_filename,
16008 /* ******************************************************************************** */
16010 /* list of instructions */
16011 cmdline_parse_ctx_t main_ctx[] = {
16012 (cmdline_parse_inst_t *)&cmd_help_brief,
16013 (cmdline_parse_inst_t *)&cmd_help_long,
16014 (cmdline_parse_inst_t *)&cmd_quit,
16015 (cmdline_parse_inst_t *)&cmd_load_from_file,
16016 (cmdline_parse_inst_t *)&cmd_showport,
16017 (cmdline_parse_inst_t *)&cmd_showqueue,
16018 (cmdline_parse_inst_t *)&cmd_showportall,
16019 (cmdline_parse_inst_t *)&cmd_showcfg,
16020 (cmdline_parse_inst_t *)&cmd_start,
16021 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16022 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16023 (cmdline_parse_inst_t *)&cmd_set_link_up,
16024 (cmdline_parse_inst_t *)&cmd_set_link_down,
16025 (cmdline_parse_inst_t *)&cmd_reset,
16026 (cmdline_parse_inst_t *)&cmd_set_numbers,
16027 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16028 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16029 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16030 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16031 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16032 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16033 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16034 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16035 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16036 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16037 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16038 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16039 (cmdline_parse_inst_t *)&cmd_set_link_check,
16040 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16041 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16042 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16043 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16044 #ifdef RTE_LIBRTE_PMD_BOND
16045 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16046 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16047 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16048 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16049 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16050 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16051 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16052 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16053 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16054 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16055 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16057 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16058 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16059 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16060 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16061 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16062 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16063 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16064 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16065 (cmdline_parse_inst_t *)&cmd_csum_set,
16066 (cmdline_parse_inst_t *)&cmd_csum_show,
16067 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16068 (cmdline_parse_inst_t *)&cmd_tso_set,
16069 (cmdline_parse_inst_t *)&cmd_tso_show,
16070 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16071 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16072 (cmdline_parse_inst_t *)&cmd_gro_enable,
16073 (cmdline_parse_inst_t *)&cmd_gro_flush,
16074 (cmdline_parse_inst_t *)&cmd_gro_show,
16075 (cmdline_parse_inst_t *)&cmd_gso_enable,
16076 (cmdline_parse_inst_t *)&cmd_gso_size,
16077 (cmdline_parse_inst_t *)&cmd_gso_show,
16078 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16079 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16080 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16081 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16082 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16083 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16084 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16085 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16086 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16087 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16088 (cmdline_parse_inst_t *)&cmd_config_dcb,
16089 (cmdline_parse_inst_t *)&cmd_read_reg,
16090 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16091 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16092 (cmdline_parse_inst_t *)&cmd_write_reg,
16093 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16094 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16095 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16096 (cmdline_parse_inst_t *)&cmd_stop,
16097 (cmdline_parse_inst_t *)&cmd_mac_addr,
16098 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16099 (cmdline_parse_inst_t *)&cmd_set_qmap,
16100 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16101 (cmdline_parse_inst_t *)&cmd_operate_port,
16102 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16103 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16104 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16105 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16106 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16107 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16108 (cmdline_parse_inst_t *)&cmd_config_mtu,
16109 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16110 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16111 (cmdline_parse_inst_t *)&cmd_config_rss,
16112 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16113 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16114 (cmdline_parse_inst_t *)&cmd_showport_reta,
16115 (cmdline_parse_inst_t *)&cmd_config_burst,
16116 (cmdline_parse_inst_t *)&cmd_config_thresh,
16117 (cmdline_parse_inst_t *)&cmd_config_threshold,
16118 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16119 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16120 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16121 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16122 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16123 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16124 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16125 (cmdline_parse_inst_t *)&cmd_global_config,
16126 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16127 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16128 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16129 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16130 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16131 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16132 (cmdline_parse_inst_t *)&cmd_dump,
16133 (cmdline_parse_inst_t *)&cmd_dump_one,
16134 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16135 (cmdline_parse_inst_t *)&cmd_syn_filter,
16136 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16137 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16138 (cmdline_parse_inst_t *)&cmd_flex_filter,
16139 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16140 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16141 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16142 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16143 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16144 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16145 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16146 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16147 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16148 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16149 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16150 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16151 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16152 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16153 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16154 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16155 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16156 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16157 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16158 (cmdline_parse_inst_t *)&cmd_flow,
16159 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16160 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16161 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16162 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16163 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16164 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16165 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16166 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16167 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16168 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16169 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16170 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16171 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16172 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16173 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16174 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16175 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16176 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16177 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16178 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16179 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16180 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16181 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16182 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16183 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16184 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16185 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16186 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16187 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16188 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16189 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16190 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16191 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16192 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16193 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16194 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16195 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16196 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16197 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16198 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16199 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16200 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16201 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16202 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16203 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16204 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16205 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16206 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16207 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16208 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16209 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16211 (cmdline_parse_inst_t *)&cmd_ddp_add,
16212 (cmdline_parse_inst_t *)&cmd_ddp_del,
16213 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16214 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16215 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16216 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16217 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16218 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16219 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16220 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16221 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16222 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16224 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16225 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16226 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16227 (cmdline_parse_inst_t *)&cmd_queue_region,
16228 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16229 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16230 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16231 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16232 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16233 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16234 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16235 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16236 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16237 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16238 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16239 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16240 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16241 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16242 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16243 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16244 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16245 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16246 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16247 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16248 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16252 /* read cmdline commands from file */
16254 cmdline_read_from_file(const char *filename)
16256 struct cmdline *cl;
16258 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16260 printf("Failed to create file based cmdline context: %s\n",
16265 cmdline_interact(cl);
16270 printf("Read CLI commands from %s\n", filename);
16273 /* prompt function, called from main on MASTER lcore */
16277 /* initialize non-constant commands */
16278 cmd_set_fwd_mode_init();
16279 cmd_set_fwd_retry_mode_init();
16281 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16282 if (testpmd_cl == NULL)
16284 cmdline_interact(testpmd_cl);
16285 cmdline_stdin_exit(testpmd_cl);
16291 if (testpmd_cl != NULL)
16292 cmdline_quit(testpmd_cl);
16296 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16298 if (id == (portid_t)RTE_PORT_ALL) {
16301 RTE_ETH_FOREACH_DEV(pid) {
16302 /* check if need_reconfig has been set to 1 */
16303 if (ports[pid].need_reconfig == 0)
16304 ports[pid].need_reconfig = dev;
16305 /* check if need_reconfig_queues has been set to 1 */
16306 if (ports[pid].need_reconfig_queues == 0)
16307 ports[pid].need_reconfig_queues = queue;
16309 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16310 /* check if need_reconfig has been set to 1 */
16311 if (ports[id].need_reconfig == 0)
16312 ports[id].need_reconfig = dev;
16313 /* check if need_reconfig_queues has been set to 1 */
16314 if (ports[id].need_reconfig_queues == 0)
16315 ports[id].need_reconfig_queues = queue;