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 if (check_nb_txq(res->value) != 0)
1552 nb_txq = res->value;
1554 else if (!strcmp(res->name, "rxd")) {
1555 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1556 printf("rxd %d invalid - must be > 0 && <= %d\n",
1557 res->value, RTE_TEST_RX_DESC_MAX);
1560 nb_rxd = res->value;
1561 } else if (!strcmp(res->name, "txd")) {
1562 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1563 printf("txd %d invalid - must be > 0 && <= %d\n",
1564 res->value, RTE_TEST_TX_DESC_MAX);
1567 nb_txd = res->value;
1569 printf("Unknown parameter\n");
1577 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1580 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1581 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1582 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1583 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1584 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1585 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1586 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1587 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1589 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1590 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1592 cmdline_parse_inst_t cmd_config_rx_tx = {
1593 .f = cmd_config_rx_tx_parsed,
1595 .help_str = "port config all rxq|txq|rxd|txd <value>",
1597 (void *)&cmd_config_rx_tx_port,
1598 (void *)&cmd_config_rx_tx_keyword,
1599 (void *)&cmd_config_rx_tx_all,
1600 (void *)&cmd_config_rx_tx_name,
1601 (void *)&cmd_config_rx_tx_value,
1606 /* *** config max packet length *** */
1607 struct cmd_config_max_pkt_len_result {
1608 cmdline_fixed_string_t port;
1609 cmdline_fixed_string_t keyword;
1610 cmdline_fixed_string_t all;
1611 cmdline_fixed_string_t name;
1616 cmd_config_max_pkt_len_parsed(void *parsed_result,
1617 __attribute__((unused)) struct cmdline *cl,
1618 __attribute__((unused)) void *data)
1620 struct cmd_config_max_pkt_len_result *res = parsed_result;
1623 if (!all_ports_stopped()) {
1624 printf("Please stop all ports first\n");
1628 RTE_ETH_FOREACH_DEV(pid) {
1629 struct rte_port *port = &ports[pid];
1630 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1632 if (!strcmp(res->name, "max-pkt-len")) {
1633 if (res->value < ETHER_MIN_LEN) {
1634 printf("max-pkt-len can not be less than %d\n",
1638 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1641 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1642 if (res->value > ETHER_MAX_LEN)
1643 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1645 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1646 port->dev_conf.rxmode.offloads = rx_offloads;
1648 printf("Unknown parameter\n");
1655 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1658 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1661 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1664 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1665 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1667 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1668 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1670 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1671 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1674 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1675 .f = cmd_config_max_pkt_len_parsed,
1677 .help_str = "port config all max-pkt-len <value>",
1679 (void *)&cmd_config_max_pkt_len_port,
1680 (void *)&cmd_config_max_pkt_len_keyword,
1681 (void *)&cmd_config_max_pkt_len_all,
1682 (void *)&cmd_config_max_pkt_len_name,
1683 (void *)&cmd_config_max_pkt_len_value,
1688 /* *** configure port MTU *** */
1689 struct cmd_config_mtu_result {
1690 cmdline_fixed_string_t port;
1691 cmdline_fixed_string_t keyword;
1692 cmdline_fixed_string_t mtu;
1698 cmd_config_mtu_parsed(void *parsed_result,
1699 __attribute__((unused)) struct cmdline *cl,
1700 __attribute__((unused)) void *data)
1702 struct cmd_config_mtu_result *res = parsed_result;
1704 if (res->value < ETHER_MIN_LEN) {
1705 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1708 port_mtu_set(res->port_id, res->value);
1711 cmdline_parse_token_string_t cmd_config_mtu_port =
1712 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1714 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1715 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1717 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1720 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1721 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1722 cmdline_parse_token_num_t cmd_config_mtu_value =
1723 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1725 cmdline_parse_inst_t cmd_config_mtu = {
1726 .f = cmd_config_mtu_parsed,
1728 .help_str = "port config mtu <port_id> <value>",
1730 (void *)&cmd_config_mtu_port,
1731 (void *)&cmd_config_mtu_keyword,
1732 (void *)&cmd_config_mtu_mtu,
1733 (void *)&cmd_config_mtu_port_id,
1734 (void *)&cmd_config_mtu_value,
1739 /* *** configure rx mode *** */
1740 struct cmd_config_rx_mode_flag {
1741 cmdline_fixed_string_t port;
1742 cmdline_fixed_string_t keyword;
1743 cmdline_fixed_string_t all;
1744 cmdline_fixed_string_t name;
1745 cmdline_fixed_string_t value;
1749 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1750 __attribute__((unused)) struct cmdline *cl,
1751 __attribute__((unused)) void *data)
1753 struct cmd_config_rx_mode_flag *res = parsed_result;
1756 if (!all_ports_stopped()) {
1757 printf("Please stop all ports first\n");
1761 RTE_ETH_FOREACH_DEV(pid) {
1762 struct rte_port *port;
1763 uint64_t rx_offloads;
1766 rx_offloads = port->dev_conf.rxmode.offloads;
1767 if (!strcmp(res->name, "crc-strip")) {
1768 if (!strcmp(res->value, "on"))
1769 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1770 else if (!strcmp(res->value, "off"))
1771 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1773 printf("Unknown parameter\n");
1776 } else if (!strcmp(res->name, "scatter")) {
1777 if (!strcmp(res->value, "on")) {
1778 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1779 } else if (!strcmp(res->value, "off")) {
1780 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1782 printf("Unknown parameter\n");
1785 } else if (!strcmp(res->name, "rx-cksum")) {
1786 if (!strcmp(res->value, "on"))
1787 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1788 else if (!strcmp(res->value, "off"))
1789 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1791 printf("Unknown parameter\n");
1794 } else if (!strcmp(res->name, "rx-timestamp")) {
1795 if (!strcmp(res->value, "on"))
1796 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1797 else if (!strcmp(res->value, "off"))
1798 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1800 printf("Unknown parameter\n");
1803 } else if (!strcmp(res->name, "hw-vlan")) {
1804 if (!strcmp(res->value, "on")) {
1805 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1806 DEV_RX_OFFLOAD_VLAN_STRIP);
1807 } else if (!strcmp(res->value, "off")) {
1808 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1809 DEV_RX_OFFLOAD_VLAN_STRIP);
1811 printf("Unknown parameter\n");
1814 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1815 if (!strcmp(res->value, "on"))
1816 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1817 else if (!strcmp(res->value, "off"))
1818 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1820 printf("Unknown parameter\n");
1823 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1824 if (!strcmp(res->value, "on"))
1825 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1826 else if (!strcmp(res->value, "off"))
1827 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1829 printf("Unknown parameter\n");
1832 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1833 if (!strcmp(res->value, "on"))
1834 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1835 else if (!strcmp(res->value, "off"))
1836 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1838 printf("Unknown parameter\n");
1841 } else if (!strcmp(res->name, "drop-en")) {
1842 if (!strcmp(res->value, "on"))
1844 else if (!strcmp(res->value, "off"))
1847 printf("Unknown parameter\n");
1851 printf("Unknown parameter\n");
1854 port->dev_conf.rxmode.offloads = rx_offloads;
1859 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1862 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1863 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1864 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1865 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1867 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1868 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1869 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1870 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1871 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1872 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1873 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1874 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1877 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1878 .f = cmd_config_rx_mode_flag_parsed,
1880 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1881 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1883 (void *)&cmd_config_rx_mode_flag_port,
1884 (void *)&cmd_config_rx_mode_flag_keyword,
1885 (void *)&cmd_config_rx_mode_flag_all,
1886 (void *)&cmd_config_rx_mode_flag_name,
1887 (void *)&cmd_config_rx_mode_flag_value,
1892 /* *** configure rss *** */
1893 struct cmd_config_rss {
1894 cmdline_fixed_string_t port;
1895 cmdline_fixed_string_t keyword;
1896 cmdline_fixed_string_t all;
1897 cmdline_fixed_string_t name;
1898 cmdline_fixed_string_t value;
1902 cmd_config_rss_parsed(void *parsed_result,
1903 __attribute__((unused)) struct cmdline *cl,
1904 __attribute__((unused)) void *data)
1906 struct cmd_config_rss *res = parsed_result;
1907 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1911 if (!strcmp(res->value, "all"))
1912 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1913 ETH_RSS_UDP | ETH_RSS_SCTP |
1915 else if (!strcmp(res->value, "ip"))
1916 rss_conf.rss_hf = ETH_RSS_IP;
1917 else if (!strcmp(res->value, "udp"))
1918 rss_conf.rss_hf = ETH_RSS_UDP;
1919 else if (!strcmp(res->value, "tcp"))
1920 rss_conf.rss_hf = ETH_RSS_TCP;
1921 else if (!strcmp(res->value, "sctp"))
1922 rss_conf.rss_hf = ETH_RSS_SCTP;
1923 else if (!strcmp(res->value, "ether"))
1924 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1925 else if (!strcmp(res->value, "port"))
1926 rss_conf.rss_hf = ETH_RSS_PORT;
1927 else if (!strcmp(res->value, "vxlan"))
1928 rss_conf.rss_hf = ETH_RSS_VXLAN;
1929 else if (!strcmp(res->value, "geneve"))
1930 rss_conf.rss_hf = ETH_RSS_GENEVE;
1931 else if (!strcmp(res->value, "nvgre"))
1932 rss_conf.rss_hf = ETH_RSS_NVGRE;
1933 else if (!strcmp(res->value, "none"))
1934 rss_conf.rss_hf = 0;
1935 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1936 atoi(res->value) < 64)
1937 rss_conf.rss_hf = 1ULL << atoi(res->value);
1939 printf("Unknown parameter\n");
1942 rss_conf.rss_key = NULL;
1943 for (i = 0; i < rte_eth_dev_count(); i++) {
1944 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1946 printf("Configuration of RSS hash at ethernet port %d "
1947 "failed with error (%d): %s.\n",
1948 i, -diag, strerror(-diag));
1952 cmdline_parse_token_string_t cmd_config_rss_port =
1953 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1954 cmdline_parse_token_string_t cmd_config_rss_keyword =
1955 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1956 cmdline_parse_token_string_t cmd_config_rss_all =
1957 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1958 cmdline_parse_token_string_t cmd_config_rss_name =
1959 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1960 cmdline_parse_token_string_t cmd_config_rss_value =
1961 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1963 cmdline_parse_inst_t cmd_config_rss = {
1964 .f = cmd_config_rss_parsed,
1966 .help_str = "port config all rss "
1967 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1969 (void *)&cmd_config_rss_port,
1970 (void *)&cmd_config_rss_keyword,
1971 (void *)&cmd_config_rss_all,
1972 (void *)&cmd_config_rss_name,
1973 (void *)&cmd_config_rss_value,
1978 /* *** configure rss hash key *** */
1979 struct cmd_config_rss_hash_key {
1980 cmdline_fixed_string_t port;
1981 cmdline_fixed_string_t config;
1983 cmdline_fixed_string_t rss_hash_key;
1984 cmdline_fixed_string_t rss_type;
1985 cmdline_fixed_string_t key;
1989 hexa_digit_to_value(char hexa_digit)
1991 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1992 return (uint8_t) (hexa_digit - '0');
1993 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1994 return (uint8_t) ((hexa_digit - 'a') + 10);
1995 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1996 return (uint8_t) ((hexa_digit - 'A') + 10);
1997 /* Invalid hexa digit */
2002 parse_and_check_key_hexa_digit(char *key, int idx)
2006 hexa_v = hexa_digit_to_value(key[idx]);
2008 printf("invalid key: character %c at position %d is not a "
2009 "valid hexa digit\n", key[idx], idx);
2014 cmd_config_rss_hash_key_parsed(void *parsed_result,
2015 __attribute__((unused)) struct cmdline *cl,
2016 __attribute__((unused)) void *data)
2018 struct cmd_config_rss_hash_key *res = parsed_result;
2019 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2023 struct rte_eth_dev_info dev_info;
2024 uint8_t hash_key_size;
2027 memset(&dev_info, 0, sizeof(dev_info));
2028 rte_eth_dev_info_get(res->port_id, &dev_info);
2029 if (dev_info.hash_key_size > 0 &&
2030 dev_info.hash_key_size <= sizeof(hash_key))
2031 hash_key_size = dev_info.hash_key_size;
2033 printf("dev_info did not provide a valid hash key size\n");
2036 /* Check the length of the RSS hash key */
2037 key_len = strlen(res->key);
2038 if (key_len != (hash_key_size * 2)) {
2039 printf("key length: %d invalid - key must be a string of %d"
2040 " hexa-decimal numbers\n",
2041 (int) key_len, hash_key_size * 2);
2044 /* Translate RSS hash key into binary representation */
2045 for (i = 0; i < hash_key_size; i++) {
2046 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2049 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2052 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2054 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2058 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2059 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2060 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2061 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2063 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2064 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2065 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2066 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2067 rss_hash_key, "rss-hash-key");
2068 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2069 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2070 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2071 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2072 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2073 "ipv6-tcp-ex#ipv6-udp-ex");
2074 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2075 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2077 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2078 .f = cmd_config_rss_hash_key_parsed,
2080 .help_str = "port config <port_id> rss-hash-key "
2081 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2082 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2083 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2084 "<string of hex digits (variable length, NIC dependent)>",
2086 (void *)&cmd_config_rss_hash_key_port,
2087 (void *)&cmd_config_rss_hash_key_config,
2088 (void *)&cmd_config_rss_hash_key_port_id,
2089 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2090 (void *)&cmd_config_rss_hash_key_rss_type,
2091 (void *)&cmd_config_rss_hash_key_value,
2096 /* *** configure port rxq/txq start/stop *** */
2097 struct cmd_config_rxtx_queue {
2098 cmdline_fixed_string_t port;
2100 cmdline_fixed_string_t rxtxq;
2102 cmdline_fixed_string_t opname;
2106 cmd_config_rxtx_queue_parsed(void *parsed_result,
2107 __attribute__((unused)) struct cmdline *cl,
2108 __attribute__((unused)) void *data)
2110 struct cmd_config_rxtx_queue *res = parsed_result;
2115 if (test_done == 0) {
2116 printf("Please stop forwarding first\n");
2120 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2123 if (port_is_started(res->portid) != 1) {
2124 printf("Please start port %u first\n", res->portid);
2128 if (!strcmp(res->rxtxq, "rxq"))
2130 else if (!strcmp(res->rxtxq, "txq"))
2133 printf("Unknown parameter\n");
2137 if (isrx && rx_queue_id_is_invalid(res->qid))
2139 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2142 if (!strcmp(res->opname, "start"))
2144 else if (!strcmp(res->opname, "stop"))
2147 printf("Unknown parameter\n");
2151 if (isstart && isrx)
2152 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2153 else if (!isstart && isrx)
2154 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2155 else if (isstart && !isrx)
2156 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2158 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2160 if (ret == -ENOTSUP)
2161 printf("Function not supported in PMD driver\n");
2164 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2165 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2166 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2167 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2168 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2169 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2170 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2171 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2172 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2173 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2176 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2177 .f = cmd_config_rxtx_queue_parsed,
2179 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2181 (void *)&cmd_config_speed_all_port,
2182 (void *)&cmd_config_rxtx_queue_portid,
2183 (void *)&cmd_config_rxtx_queue_rxtxq,
2184 (void *)&cmd_config_rxtx_queue_qid,
2185 (void *)&cmd_config_rxtx_queue_opname,
2190 /* *** Configure RSS RETA *** */
2191 struct cmd_config_rss_reta {
2192 cmdline_fixed_string_t port;
2193 cmdline_fixed_string_t keyword;
2195 cmdline_fixed_string_t name;
2196 cmdline_fixed_string_t list_name;
2197 cmdline_fixed_string_t list_of_items;
2201 parse_reta_config(const char *str,
2202 struct rte_eth_rss_reta_entry64 *reta_conf,
2203 uint16_t nb_entries)
2207 uint16_t hash_index, idx, shift;
2210 const char *p, *p0 = str;
2217 unsigned long int_fld[_NUM_FLD];
2218 char *str_fld[_NUM_FLD];
2220 while ((p = strchr(p0,'(')) != NULL) {
2222 if((p0 = strchr(p,')')) == NULL)
2226 if(size >= sizeof(s))
2229 snprintf(s, sizeof(s), "%.*s", size, p);
2230 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2232 for (i = 0; i < _NUM_FLD; i++) {
2234 int_fld[i] = strtoul(str_fld[i], &end, 0);
2235 if (errno != 0 || end == str_fld[i] ||
2240 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2241 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2243 if (hash_index >= nb_entries) {
2244 printf("Invalid RETA hash index=%d\n", hash_index);
2248 idx = hash_index / RTE_RETA_GROUP_SIZE;
2249 shift = hash_index % RTE_RETA_GROUP_SIZE;
2250 reta_conf[idx].mask |= (1ULL << shift);
2251 reta_conf[idx].reta[shift] = nb_queue;
2258 cmd_set_rss_reta_parsed(void *parsed_result,
2259 __attribute__((unused)) struct cmdline *cl,
2260 __attribute__((unused)) void *data)
2263 struct rte_eth_dev_info dev_info;
2264 struct rte_eth_rss_reta_entry64 reta_conf[8];
2265 struct cmd_config_rss_reta *res = parsed_result;
2267 memset(&dev_info, 0, sizeof(dev_info));
2268 rte_eth_dev_info_get(res->port_id, &dev_info);
2269 if (dev_info.reta_size == 0) {
2270 printf("Redirection table size is 0 which is "
2271 "invalid for RSS\n");
2274 printf("The reta size of port %d is %u\n",
2275 res->port_id, dev_info.reta_size);
2276 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2277 printf("Currently do not support more than %u entries of "
2278 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2282 memset(reta_conf, 0, sizeof(reta_conf));
2283 if (!strcmp(res->list_name, "reta")) {
2284 if (parse_reta_config(res->list_of_items, reta_conf,
2285 dev_info.reta_size)) {
2286 printf("Invalid RSS Redirection Table "
2287 "config entered\n");
2290 ret = rte_eth_dev_rss_reta_update(res->port_id,
2291 reta_conf, dev_info.reta_size);
2293 printf("Bad redirection table parameter, "
2294 "return code = %d \n", ret);
2298 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2299 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2300 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2301 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2302 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2303 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2304 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2305 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2306 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2307 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2308 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2309 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2311 cmdline_parse_inst_t cmd_config_rss_reta = {
2312 .f = cmd_set_rss_reta_parsed,
2314 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2316 (void *)&cmd_config_rss_reta_port,
2317 (void *)&cmd_config_rss_reta_keyword,
2318 (void *)&cmd_config_rss_reta_port_id,
2319 (void *)&cmd_config_rss_reta_name,
2320 (void *)&cmd_config_rss_reta_list_name,
2321 (void *)&cmd_config_rss_reta_list_of_items,
2326 /* *** SHOW PORT RETA INFO *** */
2327 struct cmd_showport_reta {
2328 cmdline_fixed_string_t show;
2329 cmdline_fixed_string_t port;
2331 cmdline_fixed_string_t rss;
2332 cmdline_fixed_string_t reta;
2334 cmdline_fixed_string_t list_of_items;
2338 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2339 uint16_t nb_entries,
2343 const char *p, *p0 = str;
2348 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2349 RTE_RETA_GROUP_SIZE;
2352 p = strchr(p0, '(');
2356 p0 = strchr(p, ')');
2360 if (size >= sizeof(s)) {
2361 printf("The string size exceeds the internal buffer size\n");
2364 snprintf(s, sizeof(s), "%.*s", size, p);
2365 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2366 if (ret <= 0 || ret != num) {
2367 printf("The bits of masks do not match the number of "
2368 "reta entries: %u\n", num);
2371 for (i = 0; i < ret; i++)
2372 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2378 cmd_showport_reta_parsed(void *parsed_result,
2379 __attribute__((unused)) struct cmdline *cl,
2380 __attribute__((unused)) void *data)
2382 struct cmd_showport_reta *res = parsed_result;
2383 struct rte_eth_rss_reta_entry64 reta_conf[8];
2384 struct rte_eth_dev_info dev_info;
2385 uint16_t max_reta_size;
2387 memset(&dev_info, 0, sizeof(dev_info));
2388 rte_eth_dev_info_get(res->port_id, &dev_info);
2389 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2390 if (res->size == 0 || res->size > max_reta_size) {
2391 printf("Invalid redirection table size: %u (1-%u)\n",
2392 res->size, max_reta_size);
2396 memset(reta_conf, 0, sizeof(reta_conf));
2397 if (showport_parse_reta_config(reta_conf, res->size,
2398 res->list_of_items) < 0) {
2399 printf("Invalid string: %s for reta masks\n",
2400 res->list_of_items);
2403 port_rss_reta_info(res->port_id, reta_conf, res->size);
2406 cmdline_parse_token_string_t cmd_showport_reta_show =
2407 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2408 cmdline_parse_token_string_t cmd_showport_reta_port =
2409 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2410 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2411 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2412 cmdline_parse_token_string_t cmd_showport_reta_rss =
2413 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2414 cmdline_parse_token_string_t cmd_showport_reta_reta =
2415 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2416 cmdline_parse_token_num_t cmd_showport_reta_size =
2417 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2418 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2419 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2420 list_of_items, NULL);
2422 cmdline_parse_inst_t cmd_showport_reta = {
2423 .f = cmd_showport_reta_parsed,
2425 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2427 (void *)&cmd_showport_reta_show,
2428 (void *)&cmd_showport_reta_port,
2429 (void *)&cmd_showport_reta_port_id,
2430 (void *)&cmd_showport_reta_rss,
2431 (void *)&cmd_showport_reta_reta,
2432 (void *)&cmd_showport_reta_size,
2433 (void *)&cmd_showport_reta_list_of_items,
2438 /* *** Show RSS hash configuration *** */
2439 struct cmd_showport_rss_hash {
2440 cmdline_fixed_string_t show;
2441 cmdline_fixed_string_t port;
2443 cmdline_fixed_string_t rss_hash;
2444 cmdline_fixed_string_t rss_type;
2445 cmdline_fixed_string_t key; /* optional argument */
2448 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2449 __attribute__((unused)) struct cmdline *cl,
2452 struct cmd_showport_rss_hash *res = parsed_result;
2454 port_rss_hash_conf_show(res->port_id, res->rss_type,
2455 show_rss_key != NULL);
2458 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2459 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2460 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2461 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2462 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2463 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2464 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2465 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2467 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2468 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2469 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2470 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2471 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2472 "ipv6-tcp-ex#ipv6-udp-ex");
2473 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2474 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2476 cmdline_parse_inst_t cmd_showport_rss_hash = {
2477 .f = cmd_showport_rss_hash_parsed,
2479 .help_str = "show port <port_id> rss-hash "
2480 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2481 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2482 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2484 (void *)&cmd_showport_rss_hash_show,
2485 (void *)&cmd_showport_rss_hash_port,
2486 (void *)&cmd_showport_rss_hash_port_id,
2487 (void *)&cmd_showport_rss_hash_rss_hash,
2488 (void *)&cmd_showport_rss_hash_rss_hash_info,
2493 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2494 .f = cmd_showport_rss_hash_parsed,
2496 .help_str = "show port <port_id> rss-hash "
2497 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2498 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2499 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2501 (void *)&cmd_showport_rss_hash_show,
2502 (void *)&cmd_showport_rss_hash_port,
2503 (void *)&cmd_showport_rss_hash_port_id,
2504 (void *)&cmd_showport_rss_hash_rss_hash,
2505 (void *)&cmd_showport_rss_hash_rss_hash_info,
2506 (void *)&cmd_showport_rss_hash_rss_key,
2511 /* *** Configure DCB *** */
2512 struct cmd_config_dcb {
2513 cmdline_fixed_string_t port;
2514 cmdline_fixed_string_t config;
2516 cmdline_fixed_string_t dcb;
2517 cmdline_fixed_string_t vt;
2518 cmdline_fixed_string_t vt_en;
2520 cmdline_fixed_string_t pfc;
2521 cmdline_fixed_string_t pfc_en;
2525 cmd_config_dcb_parsed(void *parsed_result,
2526 __attribute__((unused)) struct cmdline *cl,
2527 __attribute__((unused)) void *data)
2529 struct cmd_config_dcb *res = parsed_result;
2530 portid_t port_id = res->port_id;
2531 struct rte_port *port;
2535 port = &ports[port_id];
2536 /** Check if the port is not started **/
2537 if (port->port_status != RTE_PORT_STOPPED) {
2538 printf("Please stop port %d first\n", port_id);
2542 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2543 printf("The invalid number of traffic class,"
2544 " only 4 or 8 allowed.\n");
2548 if (nb_fwd_lcores < res->num_tcs) {
2549 printf("nb_cores shouldn't be less than number of TCs.\n");
2552 if (!strncmp(res->pfc_en, "on", 2))
2557 /* DCB in VT mode */
2558 if (!strncmp(res->vt_en, "on", 2))
2559 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2560 (enum rte_eth_nb_tcs)res->num_tcs,
2563 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2564 (enum rte_eth_nb_tcs)res->num_tcs,
2569 printf("Cannot initialize network ports.\n");
2573 cmd_reconfig_device_queue(port_id, 1, 1);
2576 cmdline_parse_token_string_t cmd_config_dcb_port =
2577 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2578 cmdline_parse_token_string_t cmd_config_dcb_config =
2579 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2580 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2581 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2582 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2583 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2584 cmdline_parse_token_string_t cmd_config_dcb_vt =
2585 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2586 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2587 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2588 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2589 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2590 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2591 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2592 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2593 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2595 cmdline_parse_inst_t cmd_config_dcb = {
2596 .f = cmd_config_dcb_parsed,
2598 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2600 (void *)&cmd_config_dcb_port,
2601 (void *)&cmd_config_dcb_config,
2602 (void *)&cmd_config_dcb_port_id,
2603 (void *)&cmd_config_dcb_dcb,
2604 (void *)&cmd_config_dcb_vt,
2605 (void *)&cmd_config_dcb_vt_en,
2606 (void *)&cmd_config_dcb_num_tcs,
2607 (void *)&cmd_config_dcb_pfc,
2608 (void *)&cmd_config_dcb_pfc_en,
2613 /* *** configure number of packets per burst *** */
2614 struct cmd_config_burst {
2615 cmdline_fixed_string_t port;
2616 cmdline_fixed_string_t keyword;
2617 cmdline_fixed_string_t all;
2618 cmdline_fixed_string_t name;
2623 cmd_config_burst_parsed(void *parsed_result,
2624 __attribute__((unused)) struct cmdline *cl,
2625 __attribute__((unused)) void *data)
2627 struct cmd_config_burst *res = parsed_result;
2629 if (!all_ports_stopped()) {
2630 printf("Please stop all ports first\n");
2634 if (!strcmp(res->name, "burst")) {
2635 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2636 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2639 nb_pkt_per_burst = res->value;
2641 printf("Unknown parameter\n");
2647 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2650 cmdline_parse_token_string_t cmd_config_burst_port =
2651 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2652 cmdline_parse_token_string_t cmd_config_burst_keyword =
2653 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2654 cmdline_parse_token_string_t cmd_config_burst_all =
2655 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2656 cmdline_parse_token_string_t cmd_config_burst_name =
2657 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2658 cmdline_parse_token_num_t cmd_config_burst_value =
2659 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2661 cmdline_parse_inst_t cmd_config_burst = {
2662 .f = cmd_config_burst_parsed,
2664 .help_str = "port config all burst <value>",
2666 (void *)&cmd_config_burst_port,
2667 (void *)&cmd_config_burst_keyword,
2668 (void *)&cmd_config_burst_all,
2669 (void *)&cmd_config_burst_name,
2670 (void *)&cmd_config_burst_value,
2675 /* *** configure rx/tx queues *** */
2676 struct cmd_config_thresh {
2677 cmdline_fixed_string_t port;
2678 cmdline_fixed_string_t keyword;
2679 cmdline_fixed_string_t all;
2680 cmdline_fixed_string_t name;
2685 cmd_config_thresh_parsed(void *parsed_result,
2686 __attribute__((unused)) struct cmdline *cl,
2687 __attribute__((unused)) void *data)
2689 struct cmd_config_thresh *res = parsed_result;
2691 if (!all_ports_stopped()) {
2692 printf("Please stop all ports first\n");
2696 if (!strcmp(res->name, "txpt"))
2697 tx_pthresh = res->value;
2698 else if(!strcmp(res->name, "txht"))
2699 tx_hthresh = res->value;
2700 else if(!strcmp(res->name, "txwt"))
2701 tx_wthresh = res->value;
2702 else if(!strcmp(res->name, "rxpt"))
2703 rx_pthresh = res->value;
2704 else if(!strcmp(res->name, "rxht"))
2705 rx_hthresh = res->value;
2706 else if(!strcmp(res->name, "rxwt"))
2707 rx_wthresh = res->value;
2709 printf("Unknown parameter\n");
2715 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2718 cmdline_parse_token_string_t cmd_config_thresh_port =
2719 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2720 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2721 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2722 cmdline_parse_token_string_t cmd_config_thresh_all =
2723 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2724 cmdline_parse_token_string_t cmd_config_thresh_name =
2725 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2726 "txpt#txht#txwt#rxpt#rxht#rxwt");
2727 cmdline_parse_token_num_t cmd_config_thresh_value =
2728 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2730 cmdline_parse_inst_t cmd_config_thresh = {
2731 .f = cmd_config_thresh_parsed,
2733 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2735 (void *)&cmd_config_thresh_port,
2736 (void *)&cmd_config_thresh_keyword,
2737 (void *)&cmd_config_thresh_all,
2738 (void *)&cmd_config_thresh_name,
2739 (void *)&cmd_config_thresh_value,
2744 /* *** configure free/rs threshold *** */
2745 struct cmd_config_threshold {
2746 cmdline_fixed_string_t port;
2747 cmdline_fixed_string_t keyword;
2748 cmdline_fixed_string_t all;
2749 cmdline_fixed_string_t name;
2754 cmd_config_threshold_parsed(void *parsed_result,
2755 __attribute__((unused)) struct cmdline *cl,
2756 __attribute__((unused)) void *data)
2758 struct cmd_config_threshold *res = parsed_result;
2760 if (!all_ports_stopped()) {
2761 printf("Please stop all ports first\n");
2765 if (!strcmp(res->name, "txfreet"))
2766 tx_free_thresh = res->value;
2767 else if (!strcmp(res->name, "txrst"))
2768 tx_rs_thresh = res->value;
2769 else if (!strcmp(res->name, "rxfreet"))
2770 rx_free_thresh = res->value;
2772 printf("Unknown parameter\n");
2778 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2781 cmdline_parse_token_string_t cmd_config_threshold_port =
2782 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2783 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2784 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2786 cmdline_parse_token_string_t cmd_config_threshold_all =
2787 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2788 cmdline_parse_token_string_t cmd_config_threshold_name =
2789 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2790 "txfreet#txrst#rxfreet");
2791 cmdline_parse_token_num_t cmd_config_threshold_value =
2792 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2794 cmdline_parse_inst_t cmd_config_threshold = {
2795 .f = cmd_config_threshold_parsed,
2797 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2799 (void *)&cmd_config_threshold_port,
2800 (void *)&cmd_config_threshold_keyword,
2801 (void *)&cmd_config_threshold_all,
2802 (void *)&cmd_config_threshold_name,
2803 (void *)&cmd_config_threshold_value,
2809 struct cmd_stop_result {
2810 cmdline_fixed_string_t stop;
2813 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2814 __attribute__((unused)) struct cmdline *cl,
2815 __attribute__((unused)) void *data)
2817 stop_packet_forwarding();
2820 cmdline_parse_token_string_t cmd_stop_stop =
2821 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2823 cmdline_parse_inst_t cmd_stop = {
2824 .f = cmd_stop_parsed,
2826 .help_str = "stop: Stop packet forwarding",
2828 (void *)&cmd_stop_stop,
2833 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2836 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2837 unsigned int *parsed_items, int check_unique_values)
2839 unsigned int nb_item;
2847 * First parse all items in the list and store their value.
2852 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2854 if ((c >= '0') && (c <= '9')) {
2855 value = (unsigned int) (value * 10 + (c - '0'));
2860 printf("character %c is not a decimal digit\n", c);
2864 printf("No valid value before comma\n");
2867 if (nb_item < max_items) {
2868 parsed_items[nb_item] = value;
2874 if (nb_item >= max_items) {
2875 printf("Number of %s = %u > %u (maximum items)\n",
2876 item_name, nb_item + 1, max_items);
2879 parsed_items[nb_item++] = value;
2880 if (! check_unique_values)
2884 * Then, check that all values in the list are differents.
2885 * No optimization here...
2887 for (i = 0; i < nb_item; i++) {
2888 for (j = i + 1; j < nb_item; j++) {
2889 if (parsed_items[j] == parsed_items[i]) {
2890 printf("duplicated %s %u at index %u and %u\n",
2891 item_name, parsed_items[i], i, j);
2899 struct cmd_set_list_result {
2900 cmdline_fixed_string_t cmd_keyword;
2901 cmdline_fixed_string_t list_name;
2902 cmdline_fixed_string_t list_of_items;
2905 static void cmd_set_list_parsed(void *parsed_result,
2906 __attribute__((unused)) struct cmdline *cl,
2907 __attribute__((unused)) void *data)
2909 struct cmd_set_list_result *res;
2911 unsigned int lcorelist[RTE_MAX_LCORE];
2912 unsigned int portlist[RTE_MAX_ETHPORTS];
2914 unsigned int nb_item;
2916 if (test_done == 0) {
2917 printf("Please stop forwarding first\n");
2921 res = parsed_result;
2922 if (!strcmp(res->list_name, "corelist")) {
2923 nb_item = parse_item_list(res->list_of_items, "core",
2925 parsed_items.lcorelist, 1);
2927 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2932 if (!strcmp(res->list_name, "portlist")) {
2933 nb_item = parse_item_list(res->list_of_items, "port",
2935 parsed_items.portlist, 1);
2937 set_fwd_ports_list(parsed_items.portlist, nb_item);
2943 cmdline_parse_token_string_t cmd_set_list_keyword =
2944 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2946 cmdline_parse_token_string_t cmd_set_list_name =
2947 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2948 "corelist#portlist");
2949 cmdline_parse_token_string_t cmd_set_list_of_items =
2950 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2953 cmdline_parse_inst_t cmd_set_fwd_list = {
2954 .f = cmd_set_list_parsed,
2956 .help_str = "set corelist|portlist <list0[,list1]*>",
2958 (void *)&cmd_set_list_keyword,
2959 (void *)&cmd_set_list_name,
2960 (void *)&cmd_set_list_of_items,
2965 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2967 struct cmd_setmask_result {
2968 cmdline_fixed_string_t set;
2969 cmdline_fixed_string_t mask;
2973 static void cmd_set_mask_parsed(void *parsed_result,
2974 __attribute__((unused)) struct cmdline *cl,
2975 __attribute__((unused)) void *data)
2977 struct cmd_setmask_result *res = parsed_result;
2979 if (test_done == 0) {
2980 printf("Please stop forwarding first\n");
2983 if (!strcmp(res->mask, "coremask")) {
2984 set_fwd_lcores_mask(res->hexavalue);
2986 } else if (!strcmp(res->mask, "portmask")) {
2987 set_fwd_ports_mask(res->hexavalue);
2992 cmdline_parse_token_string_t cmd_setmask_set =
2993 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2994 cmdline_parse_token_string_t cmd_setmask_mask =
2995 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2996 "coremask#portmask");
2997 cmdline_parse_token_num_t cmd_setmask_value =
2998 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3000 cmdline_parse_inst_t cmd_set_fwd_mask = {
3001 .f = cmd_set_mask_parsed,
3003 .help_str = "set coremask|portmask <hexadecimal value>",
3005 (void *)&cmd_setmask_set,
3006 (void *)&cmd_setmask_mask,
3007 (void *)&cmd_setmask_value,
3013 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3015 struct cmd_set_result {
3016 cmdline_fixed_string_t set;
3017 cmdline_fixed_string_t what;
3021 static void cmd_set_parsed(void *parsed_result,
3022 __attribute__((unused)) struct cmdline *cl,
3023 __attribute__((unused)) void *data)
3025 struct cmd_set_result *res = parsed_result;
3026 if (!strcmp(res->what, "nbport")) {
3027 set_fwd_ports_number(res->value);
3029 } else if (!strcmp(res->what, "nbcore")) {
3030 set_fwd_lcores_number(res->value);
3032 } else if (!strcmp(res->what, "burst"))
3033 set_nb_pkt_per_burst(res->value);
3034 else if (!strcmp(res->what, "verbose"))
3035 set_verbose_level(res->value);
3038 cmdline_parse_token_string_t cmd_set_set =
3039 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3040 cmdline_parse_token_string_t cmd_set_what =
3041 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3042 "nbport#nbcore#burst#verbose");
3043 cmdline_parse_token_num_t cmd_set_value =
3044 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3046 cmdline_parse_inst_t cmd_set_numbers = {
3047 .f = cmd_set_parsed,
3049 .help_str = "set nbport|nbcore|burst|verbose <value>",
3051 (void *)&cmd_set_set,
3052 (void *)&cmd_set_what,
3053 (void *)&cmd_set_value,
3058 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3060 struct cmd_set_txpkts_result {
3061 cmdline_fixed_string_t cmd_keyword;
3062 cmdline_fixed_string_t txpkts;
3063 cmdline_fixed_string_t seg_lengths;
3067 cmd_set_txpkts_parsed(void *parsed_result,
3068 __attribute__((unused)) struct cmdline *cl,
3069 __attribute__((unused)) void *data)
3071 struct cmd_set_txpkts_result *res;
3072 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3073 unsigned int nb_segs;
3075 res = parsed_result;
3076 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3077 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3079 set_tx_pkt_segments(seg_lengths, nb_segs);
3082 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3083 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3084 cmd_keyword, "set");
3085 cmdline_parse_token_string_t cmd_set_txpkts_name =
3086 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3088 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3089 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3092 cmdline_parse_inst_t cmd_set_txpkts = {
3093 .f = cmd_set_txpkts_parsed,
3095 .help_str = "set txpkts <len0[,len1]*>",
3097 (void *)&cmd_set_txpkts_keyword,
3098 (void *)&cmd_set_txpkts_name,
3099 (void *)&cmd_set_txpkts_lengths,
3104 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3106 struct cmd_set_txsplit_result {
3107 cmdline_fixed_string_t cmd_keyword;
3108 cmdline_fixed_string_t txsplit;
3109 cmdline_fixed_string_t mode;
3113 cmd_set_txsplit_parsed(void *parsed_result,
3114 __attribute__((unused)) struct cmdline *cl,
3115 __attribute__((unused)) void *data)
3117 struct cmd_set_txsplit_result *res;
3119 res = parsed_result;
3120 set_tx_pkt_split(res->mode);
3123 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3124 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3125 cmd_keyword, "set");
3126 cmdline_parse_token_string_t cmd_set_txsplit_name =
3127 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3128 txsplit, "txsplit");
3129 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3130 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3133 cmdline_parse_inst_t cmd_set_txsplit = {
3134 .f = cmd_set_txsplit_parsed,
3136 .help_str = "set txsplit on|off|rand",
3138 (void *)&cmd_set_txsplit_keyword,
3139 (void *)&cmd_set_txsplit_name,
3140 (void *)&cmd_set_txsplit_mode,
3145 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3146 struct cmd_rx_vlan_filter_all_result {
3147 cmdline_fixed_string_t rx_vlan;
3148 cmdline_fixed_string_t what;
3149 cmdline_fixed_string_t all;
3154 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3155 __attribute__((unused)) struct cmdline *cl,
3156 __attribute__((unused)) void *data)
3158 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3160 if (!strcmp(res->what, "add"))
3161 rx_vlan_all_filter_set(res->port_id, 1);
3163 rx_vlan_all_filter_set(res->port_id, 0);
3166 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3167 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3168 rx_vlan, "rx_vlan");
3169 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3170 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3172 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3173 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3175 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3176 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3179 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3180 .f = cmd_rx_vlan_filter_all_parsed,
3182 .help_str = "rx_vlan add|rm all <port_id>: "
3183 "Add/Remove all identifiers to/from the set of VLAN "
3184 "identifiers filtered by a port",
3186 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3187 (void *)&cmd_rx_vlan_filter_all_what,
3188 (void *)&cmd_rx_vlan_filter_all_all,
3189 (void *)&cmd_rx_vlan_filter_all_portid,
3194 /* *** VLAN OFFLOAD SET ON A PORT *** */
3195 struct cmd_vlan_offload_result {
3196 cmdline_fixed_string_t vlan;
3197 cmdline_fixed_string_t set;
3198 cmdline_fixed_string_t vlan_type;
3199 cmdline_fixed_string_t what;
3200 cmdline_fixed_string_t on;
3201 cmdline_fixed_string_t port_id;
3205 cmd_vlan_offload_parsed(void *parsed_result,
3206 __attribute__((unused)) struct cmdline *cl,
3207 __attribute__((unused)) void *data)
3210 struct cmd_vlan_offload_result *res = parsed_result;
3213 portid_t port_id = 0;
3217 len = strnlen(str, STR_TOKEN_SIZE);
3219 /* Get port_id first */
3227 tmp = strtoul(str, NULL, 0);
3228 /* If port_id greater that what portid_t can represent, return */
3229 if(tmp >= RTE_MAX_ETHPORTS)
3231 port_id = (portid_t)tmp;
3233 if (!strcmp(res->on, "on"))
3238 if (!strcmp(res->what, "strip"))
3239 rx_vlan_strip_set(port_id, on);
3240 else if(!strcmp(res->what, "stripq")){
3241 uint16_t queue_id = 0;
3243 /* No queue_id, return */
3245 printf("must specify (port,queue_id)\n");
3248 tmp = strtoul(str + i + 1, NULL, 0);
3249 /* If queue_id greater that what 16-bits can represent, return */
3253 queue_id = (uint16_t)tmp;
3254 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3256 else if (!strcmp(res->what, "filter"))
3257 rx_vlan_filter_set(port_id, on);
3259 vlan_extend_set(port_id, on);
3264 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3265 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3267 cmdline_parse_token_string_t cmd_vlan_offload_set =
3268 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3270 cmdline_parse_token_string_t cmd_vlan_offload_what =
3271 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3272 what, "strip#filter#qinq#stripq");
3273 cmdline_parse_token_string_t cmd_vlan_offload_on =
3274 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3276 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3277 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3280 cmdline_parse_inst_t cmd_vlan_offload = {
3281 .f = cmd_vlan_offload_parsed,
3283 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3284 "<port_id[,queue_id]>: "
3285 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3287 (void *)&cmd_vlan_offload_vlan,
3288 (void *)&cmd_vlan_offload_set,
3289 (void *)&cmd_vlan_offload_what,
3290 (void *)&cmd_vlan_offload_on,
3291 (void *)&cmd_vlan_offload_portid,
3296 /* *** VLAN TPID SET ON A PORT *** */
3297 struct cmd_vlan_tpid_result {
3298 cmdline_fixed_string_t vlan;
3299 cmdline_fixed_string_t set;
3300 cmdline_fixed_string_t vlan_type;
3301 cmdline_fixed_string_t what;
3307 cmd_vlan_tpid_parsed(void *parsed_result,
3308 __attribute__((unused)) struct cmdline *cl,
3309 __attribute__((unused)) void *data)
3311 struct cmd_vlan_tpid_result *res = parsed_result;
3312 enum rte_vlan_type vlan_type;
3314 if (!strcmp(res->vlan_type, "inner"))
3315 vlan_type = ETH_VLAN_TYPE_INNER;
3316 else if (!strcmp(res->vlan_type, "outer"))
3317 vlan_type = ETH_VLAN_TYPE_OUTER;
3319 printf("Unknown vlan type\n");
3322 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3325 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3326 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3328 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3329 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3331 cmdline_parse_token_string_t cmd_vlan_type =
3332 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3333 vlan_type, "inner#outer");
3334 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3335 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3337 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3338 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3340 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3341 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3344 cmdline_parse_inst_t cmd_vlan_tpid = {
3345 .f = cmd_vlan_tpid_parsed,
3347 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3348 "Set the VLAN Ether type",
3350 (void *)&cmd_vlan_tpid_vlan,
3351 (void *)&cmd_vlan_tpid_set,
3352 (void *)&cmd_vlan_type,
3353 (void *)&cmd_vlan_tpid_what,
3354 (void *)&cmd_vlan_tpid_tpid,
3355 (void *)&cmd_vlan_tpid_portid,
3360 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3361 struct cmd_rx_vlan_filter_result {
3362 cmdline_fixed_string_t rx_vlan;
3363 cmdline_fixed_string_t what;
3369 cmd_rx_vlan_filter_parsed(void *parsed_result,
3370 __attribute__((unused)) struct cmdline *cl,
3371 __attribute__((unused)) void *data)
3373 struct cmd_rx_vlan_filter_result *res = parsed_result;
3375 if (!strcmp(res->what, "add"))
3376 rx_vft_set(res->port_id, res->vlan_id, 1);
3378 rx_vft_set(res->port_id, res->vlan_id, 0);
3381 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3382 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3383 rx_vlan, "rx_vlan");
3384 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3385 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3387 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3388 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3390 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3391 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3394 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3395 .f = cmd_rx_vlan_filter_parsed,
3397 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3398 "Add/Remove a VLAN identifier to/from the set of VLAN "
3399 "identifiers filtered by a port",
3401 (void *)&cmd_rx_vlan_filter_rx_vlan,
3402 (void *)&cmd_rx_vlan_filter_what,
3403 (void *)&cmd_rx_vlan_filter_vlanid,
3404 (void *)&cmd_rx_vlan_filter_portid,
3409 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3410 struct cmd_tx_vlan_set_result {
3411 cmdline_fixed_string_t tx_vlan;
3412 cmdline_fixed_string_t set;
3418 cmd_tx_vlan_set_parsed(void *parsed_result,
3419 __attribute__((unused)) struct cmdline *cl,
3420 __attribute__((unused)) void *data)
3422 struct cmd_tx_vlan_set_result *res = parsed_result;
3424 if (!port_is_stopped(res->port_id)) {
3425 printf("Please stop port %d first\n", res->port_id);
3429 tx_vlan_set(res->port_id, res->vlan_id);
3431 cmd_reconfig_device_queue(res->port_id, 1, 1);
3434 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3435 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3436 tx_vlan, "tx_vlan");
3437 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3438 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3440 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3441 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3443 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3444 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3447 cmdline_parse_inst_t cmd_tx_vlan_set = {
3448 .f = cmd_tx_vlan_set_parsed,
3450 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3451 "Enable hardware insertion of a single VLAN header "
3452 "with a given TAG Identifier in packets sent on a port",
3454 (void *)&cmd_tx_vlan_set_tx_vlan,
3455 (void *)&cmd_tx_vlan_set_set,
3456 (void *)&cmd_tx_vlan_set_portid,
3457 (void *)&cmd_tx_vlan_set_vlanid,
3462 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3463 struct cmd_tx_vlan_set_qinq_result {
3464 cmdline_fixed_string_t tx_vlan;
3465 cmdline_fixed_string_t set;
3468 uint16_t vlan_id_outer;
3472 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3473 __attribute__((unused)) struct cmdline *cl,
3474 __attribute__((unused)) void *data)
3476 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3478 if (!port_is_stopped(res->port_id)) {
3479 printf("Please stop port %d first\n", res->port_id);
3483 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3485 cmd_reconfig_device_queue(res->port_id, 1, 1);
3488 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3489 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3490 tx_vlan, "tx_vlan");
3491 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3492 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3494 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3495 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3497 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3498 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3500 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3501 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3502 vlan_id_outer, UINT16);
3504 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3505 .f = cmd_tx_vlan_set_qinq_parsed,
3507 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3508 "Enable hardware insertion of double VLAN header "
3509 "with given TAG Identifiers in packets sent on a port",
3511 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3512 (void *)&cmd_tx_vlan_set_qinq_set,
3513 (void *)&cmd_tx_vlan_set_qinq_portid,
3514 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3515 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3520 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3521 struct cmd_tx_vlan_set_pvid_result {
3522 cmdline_fixed_string_t tx_vlan;
3523 cmdline_fixed_string_t set;
3524 cmdline_fixed_string_t pvid;
3527 cmdline_fixed_string_t mode;
3531 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3532 __attribute__((unused)) struct cmdline *cl,
3533 __attribute__((unused)) void *data)
3535 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3537 if (strcmp(res->mode, "on") == 0)
3538 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3540 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3543 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3544 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3545 tx_vlan, "tx_vlan");
3546 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3547 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3549 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3550 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3552 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3553 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3555 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3556 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3558 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3559 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3562 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3563 .f = cmd_tx_vlan_set_pvid_parsed,
3565 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3567 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3568 (void *)&cmd_tx_vlan_set_pvid_set,
3569 (void *)&cmd_tx_vlan_set_pvid_pvid,
3570 (void *)&cmd_tx_vlan_set_pvid_port_id,
3571 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3572 (void *)&cmd_tx_vlan_set_pvid_mode,
3577 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3578 struct cmd_tx_vlan_reset_result {
3579 cmdline_fixed_string_t tx_vlan;
3580 cmdline_fixed_string_t reset;
3585 cmd_tx_vlan_reset_parsed(void *parsed_result,
3586 __attribute__((unused)) struct cmdline *cl,
3587 __attribute__((unused)) void *data)
3589 struct cmd_tx_vlan_reset_result *res = parsed_result;
3591 if (!port_is_stopped(res->port_id)) {
3592 printf("Please stop port %d first\n", res->port_id);
3596 tx_vlan_reset(res->port_id);
3598 cmd_reconfig_device_queue(res->port_id, 1, 1);
3601 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3602 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3603 tx_vlan, "tx_vlan");
3604 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3605 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3607 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3608 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3611 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3612 .f = cmd_tx_vlan_reset_parsed,
3614 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3615 "VLAN header in packets sent on a port",
3617 (void *)&cmd_tx_vlan_reset_tx_vlan,
3618 (void *)&cmd_tx_vlan_reset_reset,
3619 (void *)&cmd_tx_vlan_reset_portid,
3625 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3626 struct cmd_csum_result {
3627 cmdline_fixed_string_t csum;
3628 cmdline_fixed_string_t mode;
3629 cmdline_fixed_string_t proto;
3630 cmdline_fixed_string_t hwsw;
3635 csum_show(int port_id)
3637 struct rte_eth_dev_info dev_info;
3638 uint64_t tx_offloads;
3640 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3641 printf("Parse tunnel is %s\n",
3642 (ports[port_id].parse_tunnel) ? "on" : "off");
3643 printf("IP checksum offload is %s\n",
3644 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3645 printf("UDP checksum offload is %s\n",
3646 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3647 printf("TCP checksum offload is %s\n",
3648 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3649 printf("SCTP checksum offload is %s\n",
3650 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3651 printf("Outer-Ip checksum offload is %s\n",
3652 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3654 /* display warnings if configuration is not supported by the NIC */
3655 rte_eth_dev_info_get(port_id, &dev_info);
3656 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3657 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3658 printf("Warning: hardware IP checksum enabled but not "
3659 "supported by port %d\n", port_id);
3661 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3662 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3663 printf("Warning: hardware UDP checksum enabled but not "
3664 "supported by port %d\n", port_id);
3666 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3667 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3668 printf("Warning: hardware TCP checksum enabled but not "
3669 "supported by port %d\n", port_id);
3671 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3672 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3673 printf("Warning: hardware SCTP checksum enabled but not "
3674 "supported by port %d\n", port_id);
3676 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3677 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3678 printf("Warning: hardware outer IP checksum enabled but not "
3679 "supported by port %d\n", port_id);
3684 cmd_csum_parsed(void *parsed_result,
3685 __attribute__((unused)) struct cmdline *cl,
3686 __attribute__((unused)) void *data)
3688 struct cmd_csum_result *res = parsed_result;
3690 uint64_t csum_offloads = 0;
3691 struct rte_eth_dev_info dev_info;
3693 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3694 printf("invalid port %d\n", res->port_id);
3697 if (!port_is_stopped(res->port_id)) {
3698 printf("Please stop port %d first\n", res->port_id);
3702 rte_eth_dev_info_get(res->port_id, &dev_info);
3703 if (!strcmp(res->mode, "set")) {
3705 if (!strcmp(res->hwsw, "hw"))
3708 if (!strcmp(res->proto, "ip")) {
3709 if (dev_info.tx_offload_capa &
3710 DEV_TX_OFFLOAD_IPV4_CKSUM) {
3711 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3713 printf("IP checksum offload is not supported "
3714 "by port %u\n", res->port_id);
3716 } else if (!strcmp(res->proto, "udp")) {
3717 if (dev_info.tx_offload_capa &
3718 DEV_TX_OFFLOAD_UDP_CKSUM) {
3719 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3721 printf("UDP checksum offload is not supported "
3722 "by port %u\n", res->port_id);
3724 } else if (!strcmp(res->proto, "tcp")) {
3725 if (dev_info.tx_offload_capa &
3726 DEV_TX_OFFLOAD_TCP_CKSUM) {
3727 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3729 printf("TCP checksum offload is not supported "
3730 "by port %u\n", res->port_id);
3732 } else if (!strcmp(res->proto, "sctp")) {
3733 if (dev_info.tx_offload_capa &
3734 DEV_TX_OFFLOAD_SCTP_CKSUM) {
3735 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3737 printf("SCTP checksum offload is not supported "
3738 "by port %u\n", res->port_id);
3740 } else if (!strcmp(res->proto, "outer-ip")) {
3741 if (dev_info.tx_offload_capa &
3742 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) {
3744 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3746 printf("Outer IP checksum offload is not "
3747 "supported by port %u\n", res->port_id);
3752 ports[res->port_id].dev_conf.txmode.offloads |=
3755 ports[res->port_id].dev_conf.txmode.offloads &=
3759 csum_show(res->port_id);
3761 cmd_reconfig_device_queue(res->port_id, 1, 1);
3764 cmdline_parse_token_string_t cmd_csum_csum =
3765 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3767 cmdline_parse_token_string_t cmd_csum_mode =
3768 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3770 cmdline_parse_token_string_t cmd_csum_proto =
3771 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3772 proto, "ip#tcp#udp#sctp#outer-ip");
3773 cmdline_parse_token_string_t cmd_csum_hwsw =
3774 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3776 cmdline_parse_token_num_t cmd_csum_portid =
3777 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3780 cmdline_parse_inst_t cmd_csum_set = {
3781 .f = cmd_csum_parsed,
3783 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3784 "Enable/Disable hardware calculation of L3/L4 checksum when "
3785 "using csum forward engine",
3787 (void *)&cmd_csum_csum,
3788 (void *)&cmd_csum_mode,
3789 (void *)&cmd_csum_proto,
3790 (void *)&cmd_csum_hwsw,
3791 (void *)&cmd_csum_portid,
3796 cmdline_parse_token_string_t cmd_csum_mode_show =
3797 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3800 cmdline_parse_inst_t cmd_csum_show = {
3801 .f = cmd_csum_parsed,
3803 .help_str = "csum show <port_id>: Show checksum offload configuration",
3805 (void *)&cmd_csum_csum,
3806 (void *)&cmd_csum_mode_show,
3807 (void *)&cmd_csum_portid,
3812 /* Enable/disable tunnel parsing */
3813 struct cmd_csum_tunnel_result {
3814 cmdline_fixed_string_t csum;
3815 cmdline_fixed_string_t parse;
3816 cmdline_fixed_string_t onoff;
3821 cmd_csum_tunnel_parsed(void *parsed_result,
3822 __attribute__((unused)) struct cmdline *cl,
3823 __attribute__((unused)) void *data)
3825 struct cmd_csum_tunnel_result *res = parsed_result;
3827 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3830 if (!strcmp(res->onoff, "on"))
3831 ports[res->port_id].parse_tunnel = 1;
3833 ports[res->port_id].parse_tunnel = 0;
3835 csum_show(res->port_id);
3838 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3839 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3841 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3842 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3843 parse, "parse_tunnel");
3844 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3845 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3847 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3848 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3851 cmdline_parse_inst_t cmd_csum_tunnel = {
3852 .f = cmd_csum_tunnel_parsed,
3854 .help_str = "csum parse_tunnel on|off <port_id>: "
3855 "Enable/Disable parsing of tunnels for csum engine",
3857 (void *)&cmd_csum_tunnel_csum,
3858 (void *)&cmd_csum_tunnel_parse,
3859 (void *)&cmd_csum_tunnel_onoff,
3860 (void *)&cmd_csum_tunnel_portid,
3865 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3866 struct cmd_tso_set_result {
3867 cmdline_fixed_string_t tso;
3868 cmdline_fixed_string_t mode;
3874 cmd_tso_set_parsed(void *parsed_result,
3875 __attribute__((unused)) struct cmdline *cl,
3876 __attribute__((unused)) void *data)
3878 struct cmd_tso_set_result *res = parsed_result;
3879 struct rte_eth_dev_info dev_info;
3881 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3883 if (!port_is_stopped(res->port_id)) {
3884 printf("Please stop port %d first\n", res->port_id);
3888 if (!strcmp(res->mode, "set"))
3889 ports[res->port_id].tso_segsz = res->tso_segsz;
3891 rte_eth_dev_info_get(res->port_id, &dev_info);
3892 if ((ports[res->port_id].tso_segsz != 0) &&
3893 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3894 printf("Error: TSO is not supported by port %d\n",
3899 if (ports[res->port_id].tso_segsz == 0) {
3900 ports[res->port_id].dev_conf.txmode.offloads &=
3901 ~DEV_TX_OFFLOAD_TCP_TSO;
3902 printf("TSO for non-tunneled packets is disabled\n");
3904 ports[res->port_id].dev_conf.txmode.offloads |=
3905 DEV_TX_OFFLOAD_TCP_TSO;
3906 printf("TSO segment size for non-tunneled packets is %d\n",
3907 ports[res->port_id].tso_segsz);
3910 /* display warnings if configuration is not supported by the NIC */
3911 rte_eth_dev_info_get(res->port_id, &dev_info);
3912 if ((ports[res->port_id].tso_segsz != 0) &&
3913 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3914 printf("Warning: TSO enabled but not "
3915 "supported by port %d\n", res->port_id);
3918 cmd_reconfig_device_queue(res->port_id, 1, 1);
3921 cmdline_parse_token_string_t cmd_tso_set_tso =
3922 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3924 cmdline_parse_token_string_t cmd_tso_set_mode =
3925 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3927 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3928 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3930 cmdline_parse_token_num_t cmd_tso_set_portid =
3931 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3934 cmdline_parse_inst_t cmd_tso_set = {
3935 .f = cmd_tso_set_parsed,
3937 .help_str = "tso set <tso_segsz> <port_id>: "
3938 "Set TSO segment size of non-tunneled packets for csum engine "
3941 (void *)&cmd_tso_set_tso,
3942 (void *)&cmd_tso_set_mode,
3943 (void *)&cmd_tso_set_tso_segsz,
3944 (void *)&cmd_tso_set_portid,
3949 cmdline_parse_token_string_t cmd_tso_show_mode =
3950 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3954 cmdline_parse_inst_t cmd_tso_show = {
3955 .f = cmd_tso_set_parsed,
3957 .help_str = "tso show <port_id>: "
3958 "Show TSO segment size of non-tunneled packets for csum engine",
3960 (void *)&cmd_tso_set_tso,
3961 (void *)&cmd_tso_show_mode,
3962 (void *)&cmd_tso_set_portid,
3967 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3968 struct cmd_tunnel_tso_set_result {
3969 cmdline_fixed_string_t tso;
3970 cmdline_fixed_string_t mode;
3975 static struct rte_eth_dev_info
3976 check_tunnel_tso_nic_support(portid_t port_id)
3978 struct rte_eth_dev_info dev_info;
3980 rte_eth_dev_info_get(port_id, &dev_info);
3981 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3982 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
3983 "not enabled for port %d\n", port_id);
3984 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3985 printf("Warning: GRE TUNNEL TSO not supported therefore "
3986 "not enabled for port %d\n", port_id);
3987 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3988 printf("Warning: IPIP TUNNEL TSO not supported therefore "
3989 "not enabled for port %d\n", port_id);
3990 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3991 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
3992 "not enabled for port %d\n", port_id);
3997 cmd_tunnel_tso_set_parsed(void *parsed_result,
3998 __attribute__((unused)) struct cmdline *cl,
3999 __attribute__((unused)) void *data)
4001 struct cmd_tunnel_tso_set_result *res = parsed_result;
4002 struct rte_eth_dev_info dev_info;
4004 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4006 if (!port_is_stopped(res->port_id)) {
4007 printf("Please stop port %d first\n", res->port_id);
4011 if (!strcmp(res->mode, "set"))
4012 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4014 dev_info = check_tunnel_tso_nic_support(res->port_id);
4015 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4016 ports[res->port_id].dev_conf.txmode.offloads &=
4017 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4018 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4019 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4020 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4021 printf("TSO for tunneled packets is disabled\n");
4023 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4024 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4025 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4026 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4028 ports[res->port_id].dev_conf.txmode.offloads |=
4029 (tso_offloads & dev_info.tx_offload_capa);
4030 printf("TSO segment size for tunneled packets is %d\n",
4031 ports[res->port_id].tunnel_tso_segsz);
4033 /* Below conditions are needed to make it work:
4034 * (1) tunnel TSO is supported by the NIC;
4035 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4037 * (3) for tunneled pkts with outer L3 of IPv4,
4038 * "csum set outer-ip" must be set to hw, because after tso,
4039 * total_len of outer IP header is changed, and the checksum
4040 * of outer IP header calculated by sw should be wrong; that
4041 * is not necessary for IPv6 tunneled pkts because there's no
4042 * checksum in IP header anymore.
4045 if (!ports[res->port_id].parse_tunnel)
4046 printf("Warning: csum parse_tunnel must be set "
4047 "so that tunneled packets are recognized\n");
4048 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4049 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4050 printf("Warning: csum set outer-ip must be set to hw "
4051 "if outer L3 is IPv4; not necessary for IPv6\n");
4054 cmd_reconfig_device_queue(res->port_id, 1, 1);
4057 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4058 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4060 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4061 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4063 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4064 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4066 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4067 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4070 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4071 .f = cmd_tunnel_tso_set_parsed,
4073 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4074 "Set TSO segment size of tunneled packets for csum engine "
4077 (void *)&cmd_tunnel_tso_set_tso,
4078 (void *)&cmd_tunnel_tso_set_mode,
4079 (void *)&cmd_tunnel_tso_set_tso_segsz,
4080 (void *)&cmd_tunnel_tso_set_portid,
4085 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4086 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4090 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4091 .f = cmd_tunnel_tso_set_parsed,
4093 .help_str = "tunnel_tso show <port_id> "
4094 "Show TSO segment size of tunneled packets for csum engine",
4096 (void *)&cmd_tunnel_tso_set_tso,
4097 (void *)&cmd_tunnel_tso_show_mode,
4098 (void *)&cmd_tunnel_tso_set_portid,
4103 /* *** SET GRO FOR A PORT *** */
4104 struct cmd_gro_enable_result {
4105 cmdline_fixed_string_t cmd_set;
4106 cmdline_fixed_string_t cmd_port;
4107 cmdline_fixed_string_t cmd_keyword;
4108 cmdline_fixed_string_t cmd_onoff;
4113 cmd_gro_enable_parsed(void *parsed_result,
4114 __attribute__((unused)) struct cmdline *cl,
4115 __attribute__((unused)) void *data)
4117 struct cmd_gro_enable_result *res;
4119 res = parsed_result;
4120 if (!strcmp(res->cmd_keyword, "gro"))
4121 setup_gro(res->cmd_onoff, res->cmd_pid);
4124 cmdline_parse_token_string_t cmd_gro_enable_set =
4125 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4127 cmdline_parse_token_string_t cmd_gro_enable_port =
4128 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4129 cmd_keyword, "port");
4130 cmdline_parse_token_num_t cmd_gro_enable_pid =
4131 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4133 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4134 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4135 cmd_keyword, "gro");
4136 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4137 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4138 cmd_onoff, "on#off");
4140 cmdline_parse_inst_t cmd_gro_enable = {
4141 .f = cmd_gro_enable_parsed,
4143 .help_str = "set port <port_id> gro on|off",
4145 (void *)&cmd_gro_enable_set,
4146 (void *)&cmd_gro_enable_port,
4147 (void *)&cmd_gro_enable_pid,
4148 (void *)&cmd_gro_enable_keyword,
4149 (void *)&cmd_gro_enable_onoff,
4154 /* *** DISPLAY GRO CONFIGURATION *** */
4155 struct cmd_gro_show_result {
4156 cmdline_fixed_string_t cmd_show;
4157 cmdline_fixed_string_t cmd_port;
4158 cmdline_fixed_string_t cmd_keyword;
4163 cmd_gro_show_parsed(void *parsed_result,
4164 __attribute__((unused)) struct cmdline *cl,
4165 __attribute__((unused)) void *data)
4167 struct cmd_gro_show_result *res;
4169 res = parsed_result;
4170 if (!strcmp(res->cmd_keyword, "gro"))
4171 show_gro(res->cmd_pid);
4174 cmdline_parse_token_string_t cmd_gro_show_show =
4175 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4177 cmdline_parse_token_string_t cmd_gro_show_port =
4178 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4180 cmdline_parse_token_num_t cmd_gro_show_pid =
4181 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4183 cmdline_parse_token_string_t cmd_gro_show_keyword =
4184 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4185 cmd_keyword, "gro");
4187 cmdline_parse_inst_t cmd_gro_show = {
4188 .f = cmd_gro_show_parsed,
4190 .help_str = "show port <port_id> gro",
4192 (void *)&cmd_gro_show_show,
4193 (void *)&cmd_gro_show_port,
4194 (void *)&cmd_gro_show_pid,
4195 (void *)&cmd_gro_show_keyword,
4200 /* *** SET FLUSH CYCLES FOR GRO *** */
4201 struct cmd_gro_flush_result {
4202 cmdline_fixed_string_t cmd_set;
4203 cmdline_fixed_string_t cmd_keyword;
4204 cmdline_fixed_string_t cmd_flush;
4209 cmd_gro_flush_parsed(void *parsed_result,
4210 __attribute__((unused)) struct cmdline *cl,
4211 __attribute__((unused)) void *data)
4213 struct cmd_gro_flush_result *res;
4215 res = parsed_result;
4216 if ((!strcmp(res->cmd_keyword, "gro")) &&
4217 (!strcmp(res->cmd_flush, "flush")))
4218 setup_gro_flush_cycles(res->cmd_cycles);
4221 cmdline_parse_token_string_t cmd_gro_flush_set =
4222 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4224 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4225 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4226 cmd_keyword, "gro");
4227 cmdline_parse_token_string_t cmd_gro_flush_flush =
4228 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4229 cmd_flush, "flush");
4230 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4231 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4234 cmdline_parse_inst_t cmd_gro_flush = {
4235 .f = cmd_gro_flush_parsed,
4237 .help_str = "set gro flush <cycles>",
4239 (void *)&cmd_gro_flush_set,
4240 (void *)&cmd_gro_flush_keyword,
4241 (void *)&cmd_gro_flush_flush,
4242 (void *)&cmd_gro_flush_cycles,
4247 /* *** ENABLE/DISABLE GSO *** */
4248 struct cmd_gso_enable_result {
4249 cmdline_fixed_string_t cmd_set;
4250 cmdline_fixed_string_t cmd_port;
4251 cmdline_fixed_string_t cmd_keyword;
4252 cmdline_fixed_string_t cmd_mode;
4257 cmd_gso_enable_parsed(void *parsed_result,
4258 __attribute__((unused)) struct cmdline *cl,
4259 __attribute__((unused)) void *data)
4261 struct cmd_gso_enable_result *res;
4263 res = parsed_result;
4264 if (!strcmp(res->cmd_keyword, "gso"))
4265 setup_gso(res->cmd_mode, res->cmd_pid);
4268 cmdline_parse_token_string_t cmd_gso_enable_set =
4269 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4271 cmdline_parse_token_string_t cmd_gso_enable_port =
4272 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4274 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4275 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4276 cmd_keyword, "gso");
4277 cmdline_parse_token_string_t cmd_gso_enable_mode =
4278 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4279 cmd_mode, "on#off");
4280 cmdline_parse_token_num_t cmd_gso_enable_pid =
4281 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4284 cmdline_parse_inst_t cmd_gso_enable = {
4285 .f = cmd_gso_enable_parsed,
4287 .help_str = "set port <port_id> gso on|off",
4289 (void *)&cmd_gso_enable_set,
4290 (void *)&cmd_gso_enable_port,
4291 (void *)&cmd_gso_enable_pid,
4292 (void *)&cmd_gso_enable_keyword,
4293 (void *)&cmd_gso_enable_mode,
4298 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4299 struct cmd_gso_size_result {
4300 cmdline_fixed_string_t cmd_set;
4301 cmdline_fixed_string_t cmd_keyword;
4302 cmdline_fixed_string_t cmd_segsz;
4307 cmd_gso_size_parsed(void *parsed_result,
4308 __attribute__((unused)) struct cmdline *cl,
4309 __attribute__((unused)) void *data)
4311 struct cmd_gso_size_result *res = parsed_result;
4313 if (test_done == 0) {
4314 printf("Before setting GSO segsz, please first"
4315 " stop fowarding\n");
4319 if (!strcmp(res->cmd_keyword, "gso") &&
4320 !strcmp(res->cmd_segsz, "segsz")) {
4321 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4322 printf("gso_size should be larger than %zu."
4323 " Please input a legal value\n",
4324 RTE_GSO_SEG_SIZE_MIN);
4326 gso_max_segment_size = res->cmd_size;
4330 cmdline_parse_token_string_t cmd_gso_size_set =
4331 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4333 cmdline_parse_token_string_t cmd_gso_size_keyword =
4334 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4335 cmd_keyword, "gso");
4336 cmdline_parse_token_string_t cmd_gso_size_segsz =
4337 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4338 cmd_segsz, "segsz");
4339 cmdline_parse_token_num_t cmd_gso_size_size =
4340 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4343 cmdline_parse_inst_t cmd_gso_size = {
4344 .f = cmd_gso_size_parsed,
4346 .help_str = "set gso segsz <length>",
4348 (void *)&cmd_gso_size_set,
4349 (void *)&cmd_gso_size_keyword,
4350 (void *)&cmd_gso_size_segsz,
4351 (void *)&cmd_gso_size_size,
4356 /* *** SHOW GSO CONFIGURATION *** */
4357 struct cmd_gso_show_result {
4358 cmdline_fixed_string_t cmd_show;
4359 cmdline_fixed_string_t cmd_port;
4360 cmdline_fixed_string_t cmd_keyword;
4365 cmd_gso_show_parsed(void *parsed_result,
4366 __attribute__((unused)) struct cmdline *cl,
4367 __attribute__((unused)) void *data)
4369 struct cmd_gso_show_result *res = parsed_result;
4371 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4372 printf("invalid port id %u\n", res->cmd_pid);
4375 if (!strcmp(res->cmd_keyword, "gso")) {
4376 if (gso_ports[res->cmd_pid].enable) {
4377 printf("Max GSO'd packet size: %uB\n"
4378 "Supported GSO types: TCP/IPv4, "
4379 "VxLAN with inner TCP/IPv4 packet, "
4380 "GRE with inner TCP/IPv4 packet\n",
4381 gso_max_segment_size);
4383 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4387 cmdline_parse_token_string_t cmd_gso_show_show =
4388 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4390 cmdline_parse_token_string_t cmd_gso_show_port =
4391 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4393 cmdline_parse_token_string_t cmd_gso_show_keyword =
4394 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4395 cmd_keyword, "gso");
4396 cmdline_parse_token_num_t cmd_gso_show_pid =
4397 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4400 cmdline_parse_inst_t cmd_gso_show = {
4401 .f = cmd_gso_show_parsed,
4403 .help_str = "show port <port_id> gso",
4405 (void *)&cmd_gso_show_show,
4406 (void *)&cmd_gso_show_port,
4407 (void *)&cmd_gso_show_pid,
4408 (void *)&cmd_gso_show_keyword,
4413 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4414 struct cmd_set_flush_rx {
4415 cmdline_fixed_string_t set;
4416 cmdline_fixed_string_t flush_rx;
4417 cmdline_fixed_string_t mode;
4421 cmd_set_flush_rx_parsed(void *parsed_result,
4422 __attribute__((unused)) struct cmdline *cl,
4423 __attribute__((unused)) void *data)
4425 struct cmd_set_flush_rx *res = parsed_result;
4426 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4429 cmdline_parse_token_string_t cmd_setflushrx_set =
4430 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4432 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4433 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4434 flush_rx, "flush_rx");
4435 cmdline_parse_token_string_t cmd_setflushrx_mode =
4436 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4440 cmdline_parse_inst_t cmd_set_flush_rx = {
4441 .f = cmd_set_flush_rx_parsed,
4442 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4445 (void *)&cmd_setflushrx_set,
4446 (void *)&cmd_setflushrx_flush_rx,
4447 (void *)&cmd_setflushrx_mode,
4452 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4453 struct cmd_set_link_check {
4454 cmdline_fixed_string_t set;
4455 cmdline_fixed_string_t link_check;
4456 cmdline_fixed_string_t mode;
4460 cmd_set_link_check_parsed(void *parsed_result,
4461 __attribute__((unused)) struct cmdline *cl,
4462 __attribute__((unused)) void *data)
4464 struct cmd_set_link_check *res = parsed_result;
4465 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4468 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4469 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4471 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4472 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4473 link_check, "link_check");
4474 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4475 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4479 cmdline_parse_inst_t cmd_set_link_check = {
4480 .f = cmd_set_link_check_parsed,
4481 .help_str = "set link_check on|off: Enable/Disable link status check "
4482 "when starting/stopping a port",
4485 (void *)&cmd_setlinkcheck_set,
4486 (void *)&cmd_setlinkcheck_link_check,
4487 (void *)&cmd_setlinkcheck_mode,
4492 /* *** SET NIC BYPASS MODE *** */
4493 struct cmd_set_bypass_mode_result {
4494 cmdline_fixed_string_t set;
4495 cmdline_fixed_string_t bypass;
4496 cmdline_fixed_string_t mode;
4497 cmdline_fixed_string_t value;
4502 cmd_set_bypass_mode_parsed(void *parsed_result,
4503 __attribute__((unused)) struct cmdline *cl,
4504 __attribute__((unused)) void *data)
4506 struct cmd_set_bypass_mode_result *res = parsed_result;
4507 portid_t port_id = res->port_id;
4508 int32_t rc = -EINVAL;
4510 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4511 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4513 if (!strcmp(res->value, "bypass"))
4514 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4515 else if (!strcmp(res->value, "isolate"))
4516 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4518 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4520 /* Set the bypass mode for the relevant port. */
4521 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4524 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4527 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4528 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4530 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4531 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4533 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4534 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4536 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4537 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4538 value, "normal#bypass#isolate");
4539 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4540 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4543 cmdline_parse_inst_t cmd_set_bypass_mode = {
4544 .f = cmd_set_bypass_mode_parsed,
4545 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4546 "Set the NIC bypass mode for port_id",
4549 (void *)&cmd_setbypass_mode_set,
4550 (void *)&cmd_setbypass_mode_bypass,
4551 (void *)&cmd_setbypass_mode_mode,
4552 (void *)&cmd_setbypass_mode_value,
4553 (void *)&cmd_setbypass_mode_port,
4558 /* *** SET NIC BYPASS EVENT *** */
4559 struct cmd_set_bypass_event_result {
4560 cmdline_fixed_string_t set;
4561 cmdline_fixed_string_t bypass;
4562 cmdline_fixed_string_t event;
4563 cmdline_fixed_string_t event_value;
4564 cmdline_fixed_string_t mode;
4565 cmdline_fixed_string_t mode_value;
4570 cmd_set_bypass_event_parsed(void *parsed_result,
4571 __attribute__((unused)) struct cmdline *cl,
4572 __attribute__((unused)) void *data)
4574 int32_t rc = -EINVAL;
4575 struct cmd_set_bypass_event_result *res = parsed_result;
4576 portid_t port_id = res->port_id;
4578 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4579 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4580 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4582 if (!strcmp(res->event_value, "timeout"))
4583 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4584 else if (!strcmp(res->event_value, "os_on"))
4585 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4586 else if (!strcmp(res->event_value, "os_off"))
4587 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4588 else if (!strcmp(res->event_value, "power_on"))
4589 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4590 else if (!strcmp(res->event_value, "power_off"))
4591 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4593 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4595 if (!strcmp(res->mode_value, "bypass"))
4596 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4597 else if (!strcmp(res->mode_value, "isolate"))
4598 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4600 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4602 /* Set the watchdog timeout. */
4603 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4606 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4607 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4611 printf("Failed to set timeout value %u "
4612 "for port %d, errto code: %d.\n",
4613 bypass_timeout, port_id, rc);
4617 /* Set the bypass event to transition to bypass mode. */
4618 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4623 printf("\t Failed to set bypass event for port = %d.\n",
4627 cmdline_parse_token_string_t cmd_setbypass_event_set =
4628 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4630 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4631 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4633 cmdline_parse_token_string_t cmd_setbypass_event_event =
4634 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4636 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4637 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4638 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4639 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4640 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4642 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4643 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4644 mode_value, "normal#bypass#isolate");
4645 cmdline_parse_token_num_t cmd_setbypass_event_port =
4646 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4649 cmdline_parse_inst_t cmd_set_bypass_event = {
4650 .f = cmd_set_bypass_event_parsed,
4651 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4652 "power_off mode normal|bypass|isolate <port_id>: "
4653 "Set the NIC bypass event mode for port_id",
4656 (void *)&cmd_setbypass_event_set,
4657 (void *)&cmd_setbypass_event_bypass,
4658 (void *)&cmd_setbypass_event_event,
4659 (void *)&cmd_setbypass_event_event_value,
4660 (void *)&cmd_setbypass_event_mode,
4661 (void *)&cmd_setbypass_event_mode_value,
4662 (void *)&cmd_setbypass_event_port,
4668 /* *** SET NIC BYPASS TIMEOUT *** */
4669 struct cmd_set_bypass_timeout_result {
4670 cmdline_fixed_string_t set;
4671 cmdline_fixed_string_t bypass;
4672 cmdline_fixed_string_t timeout;
4673 cmdline_fixed_string_t value;
4677 cmd_set_bypass_timeout_parsed(void *parsed_result,
4678 __attribute__((unused)) struct cmdline *cl,
4679 __attribute__((unused)) void *data)
4681 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4683 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4684 if (!strcmp(res->value, "1.5"))
4685 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4686 else if (!strcmp(res->value, "2"))
4687 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4688 else if (!strcmp(res->value, "3"))
4689 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4690 else if (!strcmp(res->value, "4"))
4691 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4692 else if (!strcmp(res->value, "8"))
4693 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4694 else if (!strcmp(res->value, "16"))
4695 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4696 else if (!strcmp(res->value, "32"))
4697 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4699 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4703 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4704 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4706 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4707 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4709 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4710 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4711 timeout, "timeout");
4712 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4713 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4714 value, "0#1.5#2#3#4#8#16#32");
4716 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4717 .f = cmd_set_bypass_timeout_parsed,
4718 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4719 "Set the NIC bypass watchdog timeout in seconds",
4722 (void *)&cmd_setbypass_timeout_set,
4723 (void *)&cmd_setbypass_timeout_bypass,
4724 (void *)&cmd_setbypass_timeout_timeout,
4725 (void *)&cmd_setbypass_timeout_value,
4730 /* *** SHOW NIC BYPASS MODE *** */
4731 struct cmd_show_bypass_config_result {
4732 cmdline_fixed_string_t show;
4733 cmdline_fixed_string_t bypass;
4734 cmdline_fixed_string_t config;
4739 cmd_show_bypass_config_parsed(void *parsed_result,
4740 __attribute__((unused)) struct cmdline *cl,
4741 __attribute__((unused)) void *data)
4743 struct cmd_show_bypass_config_result *res = parsed_result;
4744 portid_t port_id = res->port_id;
4746 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4747 uint32_t event_mode;
4748 uint32_t bypass_mode;
4749 uint32_t timeout = bypass_timeout;
4752 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4753 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4754 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4755 {"UNKNOWN", "normal", "bypass", "isolate"};
4756 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4763 int num_events = (sizeof events) / (sizeof events[0]);
4765 /* Display the bypass mode.*/
4766 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4767 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4771 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4772 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4774 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4777 /* Display the bypass timeout.*/
4778 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4779 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4781 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4783 /* Display the bypass events and associated modes. */
4784 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4786 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4787 printf("\tFailed to get bypass mode for event = %s\n",
4790 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4791 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4793 printf("\tbypass event: %-16s = %s\n", events[i],
4799 printf("\tFailed to get bypass configuration for port = %d\n",
4803 cmdline_parse_token_string_t cmd_showbypass_config_show =
4804 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4806 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4807 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4809 cmdline_parse_token_string_t cmd_showbypass_config_config =
4810 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4812 cmdline_parse_token_num_t cmd_showbypass_config_port =
4813 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4816 cmdline_parse_inst_t cmd_show_bypass_config = {
4817 .f = cmd_show_bypass_config_parsed,
4818 .help_str = "show bypass config <port_id>: "
4819 "Show the NIC bypass config for port_id",
4822 (void *)&cmd_showbypass_config_show,
4823 (void *)&cmd_showbypass_config_bypass,
4824 (void *)&cmd_showbypass_config_config,
4825 (void *)&cmd_showbypass_config_port,
4830 #ifdef RTE_LIBRTE_PMD_BOND
4831 /* *** SET BONDING MODE *** */
4832 struct cmd_set_bonding_mode_result {
4833 cmdline_fixed_string_t set;
4834 cmdline_fixed_string_t bonding;
4835 cmdline_fixed_string_t mode;
4840 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4841 __attribute__((unused)) struct cmdline *cl,
4842 __attribute__((unused)) void *data)
4844 struct cmd_set_bonding_mode_result *res = parsed_result;
4845 portid_t port_id = res->port_id;
4847 /* Set the bonding mode for the relevant port. */
4848 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4849 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4852 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4853 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4855 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4856 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4857 bonding, "bonding");
4858 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4859 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4861 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4862 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4864 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4865 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4868 cmdline_parse_inst_t cmd_set_bonding_mode = {
4869 .f = cmd_set_bonding_mode_parsed,
4870 .help_str = "set bonding mode <mode_value> <port_id>: "
4871 "Set the bonding mode for port_id",
4874 (void *) &cmd_setbonding_mode_set,
4875 (void *) &cmd_setbonding_mode_bonding,
4876 (void *) &cmd_setbonding_mode_mode,
4877 (void *) &cmd_setbonding_mode_value,
4878 (void *) &cmd_setbonding_mode_port,
4883 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4884 struct cmd_set_bonding_lacp_dedicated_queues_result {
4885 cmdline_fixed_string_t set;
4886 cmdline_fixed_string_t bonding;
4887 cmdline_fixed_string_t lacp;
4888 cmdline_fixed_string_t dedicated_queues;
4890 cmdline_fixed_string_t mode;
4893 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4894 __attribute__((unused)) struct cmdline *cl,
4895 __attribute__((unused)) void *data)
4897 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4898 portid_t port_id = res->port_id;
4899 struct rte_port *port;
4901 port = &ports[port_id];
4903 /** Check if the port is not started **/
4904 if (port->port_status != RTE_PORT_STOPPED) {
4905 printf("Please stop port %d first\n", port_id);
4909 if (!strcmp(res->mode, "enable")) {
4910 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4911 printf("Dedicate queues for LACP control packets"
4914 printf("Enabling dedicate queues for LACP control "
4915 "packets on port %d failed\n", port_id);
4916 } else if (!strcmp(res->mode, "disable")) {
4917 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4918 printf("Dedicated queues for LACP control packets "
4921 printf("Disabling dedicated queues for LACP control "
4922 "traffic on port %d failed\n", port_id);
4926 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4927 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4929 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4930 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4931 bonding, "bonding");
4932 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4933 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4935 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4936 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4937 dedicated_queues, "dedicated_queues");
4938 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4939 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4941 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4942 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4943 mode, "enable#disable");
4945 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4946 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4947 .help_str = "set bonding lacp dedicated_queues <port_id> "
4949 "Enable/disable dedicated queues for LACP control traffic for port_id",
4952 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4953 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4954 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4955 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4956 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4957 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4962 /* *** SET BALANCE XMIT POLICY *** */
4963 struct cmd_set_bonding_balance_xmit_policy_result {
4964 cmdline_fixed_string_t set;
4965 cmdline_fixed_string_t bonding;
4966 cmdline_fixed_string_t balance_xmit_policy;
4968 cmdline_fixed_string_t policy;
4971 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4972 __attribute__((unused)) struct cmdline *cl,
4973 __attribute__((unused)) void *data)
4975 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4976 portid_t port_id = res->port_id;
4979 if (!strcmp(res->policy, "l2")) {
4980 policy = BALANCE_XMIT_POLICY_LAYER2;
4981 } else if (!strcmp(res->policy, "l23")) {
4982 policy = BALANCE_XMIT_POLICY_LAYER23;
4983 } else if (!strcmp(res->policy, "l34")) {
4984 policy = BALANCE_XMIT_POLICY_LAYER34;
4986 printf("\t Invalid xmit policy selection");
4990 /* Set the bonding mode for the relevant port. */
4991 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4992 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4997 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4998 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5000 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5001 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5002 bonding, "bonding");
5003 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5004 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5005 balance_xmit_policy, "balance_xmit_policy");
5006 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5007 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5009 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5010 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5011 policy, "l2#l23#l34");
5013 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5014 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5015 .help_str = "set bonding balance_xmit_policy <port_id> "
5017 "Set the bonding balance_xmit_policy for port_id",
5020 (void *)&cmd_setbonding_balance_xmit_policy_set,
5021 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5022 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5023 (void *)&cmd_setbonding_balance_xmit_policy_port,
5024 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5029 /* *** SHOW NIC BONDING CONFIGURATION *** */
5030 struct cmd_show_bonding_config_result {
5031 cmdline_fixed_string_t show;
5032 cmdline_fixed_string_t bonding;
5033 cmdline_fixed_string_t config;
5037 static void cmd_show_bonding_config_parsed(void *parsed_result,
5038 __attribute__((unused)) struct cmdline *cl,
5039 __attribute__((unused)) void *data)
5041 struct cmd_show_bonding_config_result *res = parsed_result;
5042 int bonding_mode, agg_mode;
5043 portid_t slaves[RTE_MAX_ETHPORTS];
5044 int num_slaves, num_active_slaves;
5047 portid_t port_id = res->port_id;
5049 /* Display the bonding mode.*/
5050 bonding_mode = rte_eth_bond_mode_get(port_id);
5051 if (bonding_mode < 0) {
5052 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5055 printf("\tBonding mode: %d\n", bonding_mode);
5057 if (bonding_mode == BONDING_MODE_BALANCE) {
5058 int balance_xmit_policy;
5060 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5061 if (balance_xmit_policy < 0) {
5062 printf("\tFailed to get balance xmit policy for port = %d\n",
5066 printf("\tBalance Xmit Policy: ");
5068 switch (balance_xmit_policy) {
5069 case BALANCE_XMIT_POLICY_LAYER2:
5070 printf("BALANCE_XMIT_POLICY_LAYER2");
5072 case BALANCE_XMIT_POLICY_LAYER23:
5073 printf("BALANCE_XMIT_POLICY_LAYER23");
5075 case BALANCE_XMIT_POLICY_LAYER34:
5076 printf("BALANCE_XMIT_POLICY_LAYER34");
5083 if (bonding_mode == BONDING_MODE_8023AD) {
5084 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5085 printf("\tIEEE802.3AD Aggregator Mode: ");
5088 printf("bandwidth");
5100 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5102 if (num_slaves < 0) {
5103 printf("\tFailed to get slave list for port = %d\n", port_id);
5106 if (num_slaves > 0) {
5107 printf("\tSlaves (%d): [", num_slaves);
5108 for (i = 0; i < num_slaves - 1; i++)
5109 printf("%d ", slaves[i]);
5111 printf("%d]\n", slaves[num_slaves - 1]);
5113 printf("\tSlaves: []\n");
5117 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5120 if (num_active_slaves < 0) {
5121 printf("\tFailed to get active slave list for port = %d\n", port_id);
5124 if (num_active_slaves > 0) {
5125 printf("\tActive Slaves (%d): [", num_active_slaves);
5126 for (i = 0; i < num_active_slaves - 1; i++)
5127 printf("%d ", slaves[i]);
5129 printf("%d]\n", slaves[num_active_slaves - 1]);
5132 printf("\tActive Slaves: []\n");
5136 primary_id = rte_eth_bond_primary_get(port_id);
5137 if (primary_id < 0) {
5138 printf("\tFailed to get primary slave for port = %d\n", port_id);
5141 printf("\tPrimary: [%d]\n", primary_id);
5145 cmdline_parse_token_string_t cmd_showbonding_config_show =
5146 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5148 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5149 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5150 bonding, "bonding");
5151 cmdline_parse_token_string_t cmd_showbonding_config_config =
5152 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5154 cmdline_parse_token_num_t cmd_showbonding_config_port =
5155 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5158 cmdline_parse_inst_t cmd_show_bonding_config = {
5159 .f = cmd_show_bonding_config_parsed,
5160 .help_str = "show bonding config <port_id>: "
5161 "Show the bonding config for port_id",
5164 (void *)&cmd_showbonding_config_show,
5165 (void *)&cmd_showbonding_config_bonding,
5166 (void *)&cmd_showbonding_config_config,
5167 (void *)&cmd_showbonding_config_port,
5172 /* *** SET BONDING PRIMARY *** */
5173 struct cmd_set_bonding_primary_result {
5174 cmdline_fixed_string_t set;
5175 cmdline_fixed_string_t bonding;
5176 cmdline_fixed_string_t primary;
5181 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5182 __attribute__((unused)) struct cmdline *cl,
5183 __attribute__((unused)) void *data)
5185 struct cmd_set_bonding_primary_result *res = parsed_result;
5186 portid_t master_port_id = res->port_id;
5187 portid_t slave_port_id = res->slave_id;
5189 /* Set the primary slave for a bonded device. */
5190 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5191 printf("\t Failed to set primary slave for port = %d.\n",
5198 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5199 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5201 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5202 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5203 bonding, "bonding");
5204 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5205 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5206 primary, "primary");
5207 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5208 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5210 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5211 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5214 cmdline_parse_inst_t cmd_set_bonding_primary = {
5215 .f = cmd_set_bonding_primary_parsed,
5216 .help_str = "set bonding primary <slave_id> <port_id>: "
5217 "Set the primary slave for port_id",
5220 (void *)&cmd_setbonding_primary_set,
5221 (void *)&cmd_setbonding_primary_bonding,
5222 (void *)&cmd_setbonding_primary_primary,
5223 (void *)&cmd_setbonding_primary_slave,
5224 (void *)&cmd_setbonding_primary_port,
5229 /* *** ADD SLAVE *** */
5230 struct cmd_add_bonding_slave_result {
5231 cmdline_fixed_string_t add;
5232 cmdline_fixed_string_t bonding;
5233 cmdline_fixed_string_t slave;
5238 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5239 __attribute__((unused)) struct cmdline *cl,
5240 __attribute__((unused)) void *data)
5242 struct cmd_add_bonding_slave_result *res = parsed_result;
5243 portid_t master_port_id = res->port_id;
5244 portid_t slave_port_id = res->slave_id;
5246 /* add the slave for a bonded device. */
5247 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5248 printf("\t Failed to add slave %d to master port = %d.\n",
5249 slave_port_id, master_port_id);
5253 set_port_slave_flag(slave_port_id);
5256 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5257 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5259 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5260 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5261 bonding, "bonding");
5262 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5263 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5265 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5266 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5268 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5269 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5272 cmdline_parse_inst_t cmd_add_bonding_slave = {
5273 .f = cmd_add_bonding_slave_parsed,
5274 .help_str = "add bonding slave <slave_id> <port_id>: "
5275 "Add a slave device to a bonded device",
5278 (void *)&cmd_addbonding_slave_add,
5279 (void *)&cmd_addbonding_slave_bonding,
5280 (void *)&cmd_addbonding_slave_slave,
5281 (void *)&cmd_addbonding_slave_slaveid,
5282 (void *)&cmd_addbonding_slave_port,
5287 /* *** REMOVE SLAVE *** */
5288 struct cmd_remove_bonding_slave_result {
5289 cmdline_fixed_string_t remove;
5290 cmdline_fixed_string_t bonding;
5291 cmdline_fixed_string_t slave;
5296 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5297 __attribute__((unused)) struct cmdline *cl,
5298 __attribute__((unused)) void *data)
5300 struct cmd_remove_bonding_slave_result *res = parsed_result;
5301 portid_t master_port_id = res->port_id;
5302 portid_t slave_port_id = res->slave_id;
5304 /* remove the slave from a bonded device. */
5305 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5306 printf("\t Failed to remove slave %d from master port = %d.\n",
5307 slave_port_id, master_port_id);
5311 clear_port_slave_flag(slave_port_id);
5314 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5315 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5317 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5318 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5319 bonding, "bonding");
5320 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5321 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5323 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5324 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5326 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5327 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5330 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5331 .f = cmd_remove_bonding_slave_parsed,
5332 .help_str = "remove bonding slave <slave_id> <port_id>: "
5333 "Remove a slave device from a bonded device",
5336 (void *)&cmd_removebonding_slave_remove,
5337 (void *)&cmd_removebonding_slave_bonding,
5338 (void *)&cmd_removebonding_slave_slave,
5339 (void *)&cmd_removebonding_slave_slaveid,
5340 (void *)&cmd_removebonding_slave_port,
5345 /* *** CREATE BONDED DEVICE *** */
5346 struct cmd_create_bonded_device_result {
5347 cmdline_fixed_string_t create;
5348 cmdline_fixed_string_t bonded;
5349 cmdline_fixed_string_t device;
5354 static int bond_dev_num = 0;
5356 static void cmd_create_bonded_device_parsed(void *parsed_result,
5357 __attribute__((unused)) struct cmdline *cl,
5358 __attribute__((unused)) void *data)
5360 struct cmd_create_bonded_device_result *res = parsed_result;
5361 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5364 if (test_done == 0) {
5365 printf("Please stop forwarding first\n");
5369 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5372 /* Create a new bonded device. */
5373 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5375 printf("\t Failed to create bonded device.\n");
5378 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5381 /* Update number of ports */
5382 nb_ports = rte_eth_dev_count();
5383 reconfig(port_id, res->socket);
5384 rte_eth_promiscuous_enable(port_id);
5389 cmdline_parse_token_string_t cmd_createbonded_device_create =
5390 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5392 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5393 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5395 cmdline_parse_token_string_t cmd_createbonded_device_device =
5396 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5398 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5399 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5401 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5402 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5405 cmdline_parse_inst_t cmd_create_bonded_device = {
5406 .f = cmd_create_bonded_device_parsed,
5407 .help_str = "create bonded device <mode> <socket>: "
5408 "Create a new bonded device with specific bonding mode and socket",
5411 (void *)&cmd_createbonded_device_create,
5412 (void *)&cmd_createbonded_device_bonded,
5413 (void *)&cmd_createbonded_device_device,
5414 (void *)&cmd_createbonded_device_mode,
5415 (void *)&cmd_createbonded_device_socket,
5420 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5421 struct cmd_set_bond_mac_addr_result {
5422 cmdline_fixed_string_t set;
5423 cmdline_fixed_string_t bonding;
5424 cmdline_fixed_string_t mac_addr;
5426 struct ether_addr address;
5429 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5430 __attribute__((unused)) struct cmdline *cl,
5431 __attribute__((unused)) void *data)
5433 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5436 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5439 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5441 /* check the return value and print it if is < 0 */
5443 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5446 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5447 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5448 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5449 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5451 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5452 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5454 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5455 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5457 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5458 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5460 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5461 .f = cmd_set_bond_mac_addr_parsed,
5463 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5465 (void *)&cmd_set_bond_mac_addr_set,
5466 (void *)&cmd_set_bond_mac_addr_bonding,
5467 (void *)&cmd_set_bond_mac_addr_mac,
5468 (void *)&cmd_set_bond_mac_addr_portnum,
5469 (void *)&cmd_set_bond_mac_addr_addr,
5475 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5476 struct cmd_set_bond_mon_period_result {
5477 cmdline_fixed_string_t set;
5478 cmdline_fixed_string_t bonding;
5479 cmdline_fixed_string_t mon_period;
5484 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5485 __attribute__((unused)) struct cmdline *cl,
5486 __attribute__((unused)) void *data)
5488 struct cmd_set_bond_mon_period_result *res = parsed_result;
5491 if (res->port_num >= nb_ports) {
5492 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5496 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5498 /* check the return value and print it if is < 0 */
5500 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5503 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5504 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5506 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5507 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5508 bonding, "bonding");
5509 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5510 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5511 mon_period, "mon_period");
5512 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5513 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5515 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5516 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5519 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5520 .f = cmd_set_bond_mon_period_parsed,
5522 .help_str = "set bonding mon_period <port_id> <period_ms>",
5524 (void *)&cmd_set_bond_mon_period_set,
5525 (void *)&cmd_set_bond_mon_period_bonding,
5526 (void *)&cmd_set_bond_mon_period_mon_period,
5527 (void *)&cmd_set_bond_mon_period_portnum,
5528 (void *)&cmd_set_bond_mon_period_period_ms,
5535 struct cmd_set_bonding_agg_mode_policy_result {
5536 cmdline_fixed_string_t set;
5537 cmdline_fixed_string_t bonding;
5538 cmdline_fixed_string_t agg_mode;
5540 cmdline_fixed_string_t policy;
5545 cmd_set_bonding_agg_mode(void *parsed_result,
5546 __attribute__((unused)) struct cmdline *cl,
5547 __attribute__((unused)) void *data)
5549 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5550 uint8_t policy = AGG_BANDWIDTH;
5552 if (res->port_num >= nb_ports) {
5553 printf("Port id %d must be less than %d\n",
5554 res->port_num, nb_ports);
5558 if (!strcmp(res->policy, "bandwidth"))
5559 policy = AGG_BANDWIDTH;
5560 else if (!strcmp(res->policy, "stable"))
5561 policy = AGG_STABLE;
5562 else if (!strcmp(res->policy, "count"))
5565 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5569 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5570 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5572 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5573 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5574 bonding, "bonding");
5576 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5577 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5578 agg_mode, "agg_mode");
5580 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5581 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5584 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5585 TOKEN_STRING_INITIALIZER(
5586 struct cmd_set_bonding_balance_xmit_policy_result,
5587 policy, "stable#bandwidth#count");
5589 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5590 .f = cmd_set_bonding_agg_mode,
5592 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5594 (void *)&cmd_set_bonding_agg_mode_set,
5595 (void *)&cmd_set_bonding_agg_mode_bonding,
5596 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5597 (void *)&cmd_set_bonding_agg_mode_portnum,
5598 (void *)&cmd_set_bonding_agg_mode_policy_string,
5604 #endif /* RTE_LIBRTE_PMD_BOND */
5606 /* *** SET FORWARDING MODE *** */
5607 struct cmd_set_fwd_mode_result {
5608 cmdline_fixed_string_t set;
5609 cmdline_fixed_string_t fwd;
5610 cmdline_fixed_string_t mode;
5613 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5614 __attribute__((unused)) struct cmdline *cl,
5615 __attribute__((unused)) void *data)
5617 struct cmd_set_fwd_mode_result *res = parsed_result;
5620 set_pkt_forwarding_mode(res->mode);
5623 cmdline_parse_token_string_t cmd_setfwd_set =
5624 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5625 cmdline_parse_token_string_t cmd_setfwd_fwd =
5626 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5627 cmdline_parse_token_string_t cmd_setfwd_mode =
5628 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5629 "" /* defined at init */);
5631 cmdline_parse_inst_t cmd_set_fwd_mode = {
5632 .f = cmd_set_fwd_mode_parsed,
5634 .help_str = NULL, /* defined at init */
5636 (void *)&cmd_setfwd_set,
5637 (void *)&cmd_setfwd_fwd,
5638 (void *)&cmd_setfwd_mode,
5643 static void cmd_set_fwd_mode_init(void)
5646 static char token[128];
5647 static char help[256];
5648 cmdline_parse_token_string_t *token_struct;
5650 modes = list_pkt_forwarding_modes();
5651 snprintf(help, sizeof(help), "set fwd %s: "
5652 "Set packet forwarding mode", modes);
5653 cmd_set_fwd_mode.help_str = help;
5655 /* string token separator is # */
5656 for (c = token; *modes != '\0'; modes++)
5661 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5662 token_struct->string_data.str = token;
5665 /* *** SET RETRY FORWARDING MODE *** */
5666 struct cmd_set_fwd_retry_mode_result {
5667 cmdline_fixed_string_t set;
5668 cmdline_fixed_string_t fwd;
5669 cmdline_fixed_string_t mode;
5670 cmdline_fixed_string_t retry;
5673 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5674 __attribute__((unused)) struct cmdline *cl,
5675 __attribute__((unused)) void *data)
5677 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5680 set_pkt_forwarding_mode(res->mode);
5683 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5684 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5686 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5687 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5689 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5690 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5692 "" /* defined at init */);
5693 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5694 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5697 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5698 .f = cmd_set_fwd_retry_mode_parsed,
5700 .help_str = NULL, /* defined at init */
5702 (void *)&cmd_setfwd_retry_set,
5703 (void *)&cmd_setfwd_retry_fwd,
5704 (void *)&cmd_setfwd_retry_mode,
5705 (void *)&cmd_setfwd_retry_retry,
5710 static void cmd_set_fwd_retry_mode_init(void)
5713 static char token[128];
5714 static char help[256];
5715 cmdline_parse_token_string_t *token_struct;
5717 modes = list_pkt_forwarding_retry_modes();
5718 snprintf(help, sizeof(help), "set fwd %s retry: "
5719 "Set packet forwarding mode with retry", modes);
5720 cmd_set_fwd_retry_mode.help_str = help;
5722 /* string token separator is # */
5723 for (c = token; *modes != '\0'; modes++)
5728 token_struct = (cmdline_parse_token_string_t *)
5729 cmd_set_fwd_retry_mode.tokens[2];
5730 token_struct->string_data.str = token;
5733 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5734 struct cmd_set_burst_tx_retry_result {
5735 cmdline_fixed_string_t set;
5736 cmdline_fixed_string_t burst;
5737 cmdline_fixed_string_t tx;
5738 cmdline_fixed_string_t delay;
5740 cmdline_fixed_string_t retry;
5744 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5745 __attribute__((unused)) struct cmdline *cl,
5746 __attribute__((unused)) void *data)
5748 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5750 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5751 && !strcmp(res->tx, "tx")) {
5752 if (!strcmp(res->delay, "delay"))
5753 burst_tx_delay_time = res->time;
5754 if (!strcmp(res->retry, "retry"))
5755 burst_tx_retry_num = res->retry_num;
5760 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5761 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5762 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5763 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5765 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5766 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5767 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5768 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5769 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5770 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5771 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5772 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5773 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5774 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5776 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5777 .f = cmd_set_burst_tx_retry_parsed,
5778 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5780 (void *)&cmd_set_burst_tx_retry_set,
5781 (void *)&cmd_set_burst_tx_retry_burst,
5782 (void *)&cmd_set_burst_tx_retry_tx,
5783 (void *)&cmd_set_burst_tx_retry_delay,
5784 (void *)&cmd_set_burst_tx_retry_time,
5785 (void *)&cmd_set_burst_tx_retry_retry,
5786 (void *)&cmd_set_burst_tx_retry_retry_num,
5791 /* *** SET PROMISC MODE *** */
5792 struct cmd_set_promisc_mode_result {
5793 cmdline_fixed_string_t set;
5794 cmdline_fixed_string_t promisc;
5795 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5796 uint16_t port_num; /* valid if "allports" argument == 0 */
5797 cmdline_fixed_string_t mode;
5800 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5801 __attribute__((unused)) struct cmdline *cl,
5804 struct cmd_set_promisc_mode_result *res = parsed_result;
5808 if (!strcmp(res->mode, "on"))
5815 RTE_ETH_FOREACH_DEV(i) {
5817 rte_eth_promiscuous_enable(i);
5819 rte_eth_promiscuous_disable(i);
5824 rte_eth_promiscuous_enable(res->port_num);
5826 rte_eth_promiscuous_disable(res->port_num);
5830 cmdline_parse_token_string_t cmd_setpromisc_set =
5831 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5832 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5833 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5835 cmdline_parse_token_string_t cmd_setpromisc_portall =
5836 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5838 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5839 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5841 cmdline_parse_token_string_t cmd_setpromisc_mode =
5842 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5845 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5846 .f = cmd_set_promisc_mode_parsed,
5848 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5850 (void *)&cmd_setpromisc_set,
5851 (void *)&cmd_setpromisc_promisc,
5852 (void *)&cmd_setpromisc_portall,
5853 (void *)&cmd_setpromisc_mode,
5858 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5859 .f = cmd_set_promisc_mode_parsed,
5861 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5863 (void *)&cmd_setpromisc_set,
5864 (void *)&cmd_setpromisc_promisc,
5865 (void *)&cmd_setpromisc_portnum,
5866 (void *)&cmd_setpromisc_mode,
5871 /* *** SET ALLMULTI MODE *** */
5872 struct cmd_set_allmulti_mode_result {
5873 cmdline_fixed_string_t set;
5874 cmdline_fixed_string_t allmulti;
5875 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5876 uint16_t port_num; /* valid if "allports" argument == 0 */
5877 cmdline_fixed_string_t mode;
5880 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5881 __attribute__((unused)) struct cmdline *cl,
5884 struct cmd_set_allmulti_mode_result *res = parsed_result;
5888 if (!strcmp(res->mode, "on"))
5895 RTE_ETH_FOREACH_DEV(i) {
5897 rte_eth_allmulticast_enable(i);
5899 rte_eth_allmulticast_disable(i);
5904 rte_eth_allmulticast_enable(res->port_num);
5906 rte_eth_allmulticast_disable(res->port_num);
5910 cmdline_parse_token_string_t cmd_setallmulti_set =
5911 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5912 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5913 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5915 cmdline_parse_token_string_t cmd_setallmulti_portall =
5916 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5918 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5919 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5921 cmdline_parse_token_string_t cmd_setallmulti_mode =
5922 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5925 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5926 .f = cmd_set_allmulti_mode_parsed,
5928 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5930 (void *)&cmd_setallmulti_set,
5931 (void *)&cmd_setallmulti_allmulti,
5932 (void *)&cmd_setallmulti_portall,
5933 (void *)&cmd_setallmulti_mode,
5938 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5939 .f = cmd_set_allmulti_mode_parsed,
5941 .help_str = "set allmulti <port_id> on|off: "
5942 "Set allmulti mode on port_id",
5944 (void *)&cmd_setallmulti_set,
5945 (void *)&cmd_setallmulti_allmulti,
5946 (void *)&cmd_setallmulti_portnum,
5947 (void *)&cmd_setallmulti_mode,
5952 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5953 struct cmd_link_flow_ctrl_set_result {
5954 cmdline_fixed_string_t set;
5955 cmdline_fixed_string_t flow_ctrl;
5956 cmdline_fixed_string_t rx;
5957 cmdline_fixed_string_t rx_lfc_mode;
5958 cmdline_fixed_string_t tx;
5959 cmdline_fixed_string_t tx_lfc_mode;
5960 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5961 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5962 cmdline_fixed_string_t autoneg_str;
5963 cmdline_fixed_string_t autoneg;
5964 cmdline_fixed_string_t hw_str;
5965 uint32_t high_water;
5966 cmdline_fixed_string_t lw_str;
5968 cmdline_fixed_string_t pt_str;
5969 uint16_t pause_time;
5970 cmdline_fixed_string_t xon_str;
5975 cmdline_parse_token_string_t cmd_lfc_set_set =
5976 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5978 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5979 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5980 flow_ctrl, "flow_ctrl");
5981 cmdline_parse_token_string_t cmd_lfc_set_rx =
5982 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5984 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5985 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5986 rx_lfc_mode, "on#off");
5987 cmdline_parse_token_string_t cmd_lfc_set_tx =
5988 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5990 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5991 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5992 tx_lfc_mode, "on#off");
5993 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5994 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5995 hw_str, "high_water");
5996 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5997 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5998 high_water, UINT32);
5999 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6000 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6001 lw_str, "low_water");
6002 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6003 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6005 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6006 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6007 pt_str, "pause_time");
6008 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6009 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6010 pause_time, UINT16);
6011 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6012 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6013 xon_str, "send_xon");
6014 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6015 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6017 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6018 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6019 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6020 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6021 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6022 mac_ctrl_frame_fwd_mode, "on#off");
6023 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6024 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6025 autoneg_str, "autoneg");
6026 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6027 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6029 cmdline_parse_token_num_t cmd_lfc_set_portid =
6030 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6033 /* forward declaration */
6035 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6038 cmdline_parse_inst_t cmd_link_flow_control_set = {
6039 .f = cmd_link_flow_ctrl_set_parsed,
6041 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6042 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6043 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6045 (void *)&cmd_lfc_set_set,
6046 (void *)&cmd_lfc_set_flow_ctrl,
6047 (void *)&cmd_lfc_set_rx,
6048 (void *)&cmd_lfc_set_rx_mode,
6049 (void *)&cmd_lfc_set_tx,
6050 (void *)&cmd_lfc_set_tx_mode,
6051 (void *)&cmd_lfc_set_high_water,
6052 (void *)&cmd_lfc_set_low_water,
6053 (void *)&cmd_lfc_set_pause_time,
6054 (void *)&cmd_lfc_set_send_xon,
6055 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6056 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6057 (void *)&cmd_lfc_set_autoneg_str,
6058 (void *)&cmd_lfc_set_autoneg,
6059 (void *)&cmd_lfc_set_portid,
6064 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6065 .f = cmd_link_flow_ctrl_set_parsed,
6066 .data = (void *)&cmd_link_flow_control_set_rx,
6067 .help_str = "set flow_ctrl rx on|off <port_id>: "
6068 "Change rx flow control parameter",
6070 (void *)&cmd_lfc_set_set,
6071 (void *)&cmd_lfc_set_flow_ctrl,
6072 (void *)&cmd_lfc_set_rx,
6073 (void *)&cmd_lfc_set_rx_mode,
6074 (void *)&cmd_lfc_set_portid,
6079 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6080 .f = cmd_link_flow_ctrl_set_parsed,
6081 .data = (void *)&cmd_link_flow_control_set_tx,
6082 .help_str = "set flow_ctrl tx on|off <port_id>: "
6083 "Change tx flow control parameter",
6085 (void *)&cmd_lfc_set_set,
6086 (void *)&cmd_lfc_set_flow_ctrl,
6087 (void *)&cmd_lfc_set_tx,
6088 (void *)&cmd_lfc_set_tx_mode,
6089 (void *)&cmd_lfc_set_portid,
6094 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6095 .f = cmd_link_flow_ctrl_set_parsed,
6096 .data = (void *)&cmd_link_flow_control_set_hw,
6097 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6098 "Change high water flow control parameter",
6100 (void *)&cmd_lfc_set_set,
6101 (void *)&cmd_lfc_set_flow_ctrl,
6102 (void *)&cmd_lfc_set_high_water_str,
6103 (void *)&cmd_lfc_set_high_water,
6104 (void *)&cmd_lfc_set_portid,
6109 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6110 .f = cmd_link_flow_ctrl_set_parsed,
6111 .data = (void *)&cmd_link_flow_control_set_lw,
6112 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6113 "Change low water flow control parameter",
6115 (void *)&cmd_lfc_set_set,
6116 (void *)&cmd_lfc_set_flow_ctrl,
6117 (void *)&cmd_lfc_set_low_water_str,
6118 (void *)&cmd_lfc_set_low_water,
6119 (void *)&cmd_lfc_set_portid,
6124 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6125 .f = cmd_link_flow_ctrl_set_parsed,
6126 .data = (void *)&cmd_link_flow_control_set_pt,
6127 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6128 "Change pause time flow control parameter",
6130 (void *)&cmd_lfc_set_set,
6131 (void *)&cmd_lfc_set_flow_ctrl,
6132 (void *)&cmd_lfc_set_pause_time_str,
6133 (void *)&cmd_lfc_set_pause_time,
6134 (void *)&cmd_lfc_set_portid,
6139 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6140 .f = cmd_link_flow_ctrl_set_parsed,
6141 .data = (void *)&cmd_link_flow_control_set_xon,
6142 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6143 "Change send_xon flow control parameter",
6145 (void *)&cmd_lfc_set_set,
6146 (void *)&cmd_lfc_set_flow_ctrl,
6147 (void *)&cmd_lfc_set_send_xon_str,
6148 (void *)&cmd_lfc_set_send_xon,
6149 (void *)&cmd_lfc_set_portid,
6154 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6155 .f = cmd_link_flow_ctrl_set_parsed,
6156 .data = (void *)&cmd_link_flow_control_set_macfwd,
6157 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6158 "Change mac ctrl fwd flow control parameter",
6160 (void *)&cmd_lfc_set_set,
6161 (void *)&cmd_lfc_set_flow_ctrl,
6162 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6163 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6164 (void *)&cmd_lfc_set_portid,
6169 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6170 .f = cmd_link_flow_ctrl_set_parsed,
6171 .data = (void *)&cmd_link_flow_control_set_autoneg,
6172 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6173 "Change autoneg flow control parameter",
6175 (void *)&cmd_lfc_set_set,
6176 (void *)&cmd_lfc_set_flow_ctrl,
6177 (void *)&cmd_lfc_set_autoneg_str,
6178 (void *)&cmd_lfc_set_autoneg,
6179 (void *)&cmd_lfc_set_portid,
6185 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6186 __attribute__((unused)) struct cmdline *cl,
6189 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6190 cmdline_parse_inst_t *cmd = data;
6191 struct rte_eth_fc_conf fc_conf;
6197 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6198 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6199 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6200 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6202 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6203 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6206 /* Partial command line, retrieve current configuration */
6208 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6210 printf("cannot get current flow ctrl parameters, return"
6211 "code = %d\n", ret);
6215 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6216 (fc_conf.mode == RTE_FC_FULL))
6218 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6219 (fc_conf.mode == RTE_FC_FULL))
6223 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6224 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6226 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6227 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6229 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6231 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6232 fc_conf.high_water = res->high_water;
6234 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6235 fc_conf.low_water = res->low_water;
6237 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6238 fc_conf.pause_time = res->pause_time;
6240 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6241 fc_conf.send_xon = res->send_xon;
6243 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6244 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6245 fc_conf.mac_ctrl_frame_fwd = 1;
6247 fc_conf.mac_ctrl_frame_fwd = 0;
6250 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6251 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6253 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6255 printf("bad flow contrl parameter, return code = %d \n", ret);
6258 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6259 struct cmd_priority_flow_ctrl_set_result {
6260 cmdline_fixed_string_t set;
6261 cmdline_fixed_string_t pfc_ctrl;
6262 cmdline_fixed_string_t rx;
6263 cmdline_fixed_string_t rx_pfc_mode;
6264 cmdline_fixed_string_t tx;
6265 cmdline_fixed_string_t tx_pfc_mode;
6266 uint32_t high_water;
6268 uint16_t pause_time;
6274 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6275 __attribute__((unused)) struct cmdline *cl,
6276 __attribute__((unused)) void *data)
6278 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6279 struct rte_eth_pfc_conf pfc_conf;
6280 int rx_fc_enable, tx_fc_enable;
6284 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6285 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6286 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6287 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6289 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6290 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6293 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6294 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6295 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6296 pfc_conf.fc.high_water = res->high_water;
6297 pfc_conf.fc.low_water = res->low_water;
6298 pfc_conf.fc.pause_time = res->pause_time;
6299 pfc_conf.priority = res->priority;
6301 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6303 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6306 cmdline_parse_token_string_t cmd_pfc_set_set =
6307 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6309 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6310 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6311 pfc_ctrl, "pfc_ctrl");
6312 cmdline_parse_token_string_t cmd_pfc_set_rx =
6313 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6315 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6316 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6317 rx_pfc_mode, "on#off");
6318 cmdline_parse_token_string_t cmd_pfc_set_tx =
6319 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6321 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6322 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6323 tx_pfc_mode, "on#off");
6324 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6325 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6326 high_water, UINT32);
6327 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6328 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6330 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6331 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6332 pause_time, UINT16);
6333 cmdline_parse_token_num_t cmd_pfc_set_priority =
6334 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6336 cmdline_parse_token_num_t cmd_pfc_set_portid =
6337 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6340 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6341 .f = cmd_priority_flow_ctrl_set_parsed,
6343 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6344 "<pause_time> <priority> <port_id>: "
6345 "Configure the Ethernet priority flow control",
6347 (void *)&cmd_pfc_set_set,
6348 (void *)&cmd_pfc_set_flow_ctrl,
6349 (void *)&cmd_pfc_set_rx,
6350 (void *)&cmd_pfc_set_rx_mode,
6351 (void *)&cmd_pfc_set_tx,
6352 (void *)&cmd_pfc_set_tx_mode,
6353 (void *)&cmd_pfc_set_high_water,
6354 (void *)&cmd_pfc_set_low_water,
6355 (void *)&cmd_pfc_set_pause_time,
6356 (void *)&cmd_pfc_set_priority,
6357 (void *)&cmd_pfc_set_portid,
6362 /* *** RESET CONFIGURATION *** */
6363 struct cmd_reset_result {
6364 cmdline_fixed_string_t reset;
6365 cmdline_fixed_string_t def;
6368 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6370 __attribute__((unused)) void *data)
6372 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6373 set_def_fwd_config();
6376 cmdline_parse_token_string_t cmd_reset_set =
6377 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6378 cmdline_parse_token_string_t cmd_reset_def =
6379 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6382 cmdline_parse_inst_t cmd_reset = {
6383 .f = cmd_reset_parsed,
6385 .help_str = "set default: Reset default forwarding configuration",
6387 (void *)&cmd_reset_set,
6388 (void *)&cmd_reset_def,
6393 /* *** START FORWARDING *** */
6394 struct cmd_start_result {
6395 cmdline_fixed_string_t start;
6398 cmdline_parse_token_string_t cmd_start_start =
6399 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6401 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6402 __attribute__((unused)) struct cmdline *cl,
6403 __attribute__((unused)) void *data)
6405 start_packet_forwarding(0);
6408 cmdline_parse_inst_t cmd_start = {
6409 .f = cmd_start_parsed,
6411 .help_str = "start: Start packet forwarding",
6413 (void *)&cmd_start_start,
6418 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6419 struct cmd_start_tx_first_result {
6420 cmdline_fixed_string_t start;
6421 cmdline_fixed_string_t tx_first;
6425 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6426 __attribute__((unused)) struct cmdline *cl,
6427 __attribute__((unused)) void *data)
6429 start_packet_forwarding(1);
6432 cmdline_parse_token_string_t cmd_start_tx_first_start =
6433 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6435 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6436 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6437 tx_first, "tx_first");
6439 cmdline_parse_inst_t cmd_start_tx_first = {
6440 .f = cmd_start_tx_first_parsed,
6442 .help_str = "start tx_first: Start packet forwarding, "
6443 "after sending 1 burst of packets",
6445 (void *)&cmd_start_tx_first_start,
6446 (void *)&cmd_start_tx_first_tx_first,
6451 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6452 struct cmd_start_tx_first_n_result {
6453 cmdline_fixed_string_t start;
6454 cmdline_fixed_string_t tx_first;
6459 cmd_start_tx_first_n_parsed(void *parsed_result,
6460 __attribute__((unused)) struct cmdline *cl,
6461 __attribute__((unused)) void *data)
6463 struct cmd_start_tx_first_n_result *res = parsed_result;
6465 start_packet_forwarding(res->tx_num);
6468 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6469 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6471 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6472 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6473 tx_first, "tx_first");
6474 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6475 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6478 cmdline_parse_inst_t cmd_start_tx_first_n = {
6479 .f = cmd_start_tx_first_n_parsed,
6481 .help_str = "start tx_first <num>: "
6482 "packet forwarding, after sending <num> bursts of packets",
6484 (void *)&cmd_start_tx_first_n_start,
6485 (void *)&cmd_start_tx_first_n_tx_first,
6486 (void *)&cmd_start_tx_first_n_tx_num,
6491 /* *** SET LINK UP *** */
6492 struct cmd_set_link_up_result {
6493 cmdline_fixed_string_t set;
6494 cmdline_fixed_string_t link_up;
6495 cmdline_fixed_string_t port;
6499 cmdline_parse_token_string_t cmd_set_link_up_set =
6500 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6501 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6502 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6504 cmdline_parse_token_string_t cmd_set_link_up_port =
6505 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6506 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6507 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6509 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6510 __attribute__((unused)) struct cmdline *cl,
6511 __attribute__((unused)) void *data)
6513 struct cmd_set_link_up_result *res = parsed_result;
6514 dev_set_link_up(res->port_id);
6517 cmdline_parse_inst_t cmd_set_link_up = {
6518 .f = cmd_set_link_up_parsed,
6520 .help_str = "set link-up port <port id>",
6522 (void *)&cmd_set_link_up_set,
6523 (void *)&cmd_set_link_up_link_up,
6524 (void *)&cmd_set_link_up_port,
6525 (void *)&cmd_set_link_up_port_id,
6530 /* *** SET LINK DOWN *** */
6531 struct cmd_set_link_down_result {
6532 cmdline_fixed_string_t set;
6533 cmdline_fixed_string_t link_down;
6534 cmdline_fixed_string_t port;
6538 cmdline_parse_token_string_t cmd_set_link_down_set =
6539 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6540 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6541 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6543 cmdline_parse_token_string_t cmd_set_link_down_port =
6544 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6545 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6546 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6548 static void cmd_set_link_down_parsed(
6549 __attribute__((unused)) void *parsed_result,
6550 __attribute__((unused)) struct cmdline *cl,
6551 __attribute__((unused)) void *data)
6553 struct cmd_set_link_down_result *res = parsed_result;
6554 dev_set_link_down(res->port_id);
6557 cmdline_parse_inst_t cmd_set_link_down = {
6558 .f = cmd_set_link_down_parsed,
6560 .help_str = "set link-down port <port id>",
6562 (void *)&cmd_set_link_down_set,
6563 (void *)&cmd_set_link_down_link_down,
6564 (void *)&cmd_set_link_down_port,
6565 (void *)&cmd_set_link_down_port_id,
6570 /* *** SHOW CFG *** */
6571 struct cmd_showcfg_result {
6572 cmdline_fixed_string_t show;
6573 cmdline_fixed_string_t cfg;
6574 cmdline_fixed_string_t what;
6577 static void cmd_showcfg_parsed(void *parsed_result,
6578 __attribute__((unused)) struct cmdline *cl,
6579 __attribute__((unused)) void *data)
6581 struct cmd_showcfg_result *res = parsed_result;
6582 if (!strcmp(res->what, "rxtx"))
6583 rxtx_config_display();
6584 else if (!strcmp(res->what, "cores"))
6585 fwd_lcores_config_display();
6586 else if (!strcmp(res->what, "fwd"))
6587 pkt_fwd_config_display(&cur_fwd_config);
6588 else if (!strcmp(res->what, "txpkts"))
6589 show_tx_pkt_segments();
6592 cmdline_parse_token_string_t cmd_showcfg_show =
6593 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6594 cmdline_parse_token_string_t cmd_showcfg_port =
6595 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6596 cmdline_parse_token_string_t cmd_showcfg_what =
6597 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6598 "rxtx#cores#fwd#txpkts");
6600 cmdline_parse_inst_t cmd_showcfg = {
6601 .f = cmd_showcfg_parsed,
6603 .help_str = "show config rxtx|cores|fwd|txpkts",
6605 (void *)&cmd_showcfg_show,
6606 (void *)&cmd_showcfg_port,
6607 (void *)&cmd_showcfg_what,
6612 /* *** SHOW ALL PORT INFO *** */
6613 struct cmd_showportall_result {
6614 cmdline_fixed_string_t show;
6615 cmdline_fixed_string_t port;
6616 cmdline_fixed_string_t what;
6617 cmdline_fixed_string_t all;
6620 static void cmd_showportall_parsed(void *parsed_result,
6621 __attribute__((unused)) struct cmdline *cl,
6622 __attribute__((unused)) void *data)
6626 struct cmd_showportall_result *res = parsed_result;
6627 if (!strcmp(res->show, "clear")) {
6628 if (!strcmp(res->what, "stats"))
6629 RTE_ETH_FOREACH_DEV(i)
6631 else if (!strcmp(res->what, "xstats"))
6632 RTE_ETH_FOREACH_DEV(i)
6633 nic_xstats_clear(i);
6634 } else if (!strcmp(res->what, "info"))
6635 RTE_ETH_FOREACH_DEV(i)
6636 port_infos_display(i);
6637 else if (!strcmp(res->what, "stats"))
6638 RTE_ETH_FOREACH_DEV(i)
6639 nic_stats_display(i);
6640 else if (!strcmp(res->what, "xstats"))
6641 RTE_ETH_FOREACH_DEV(i)
6642 nic_xstats_display(i);
6643 else if (!strcmp(res->what, "fdir"))
6644 RTE_ETH_FOREACH_DEV(i)
6646 else if (!strcmp(res->what, "stat_qmap"))
6647 RTE_ETH_FOREACH_DEV(i)
6648 nic_stats_mapping_display(i);
6649 else if (!strcmp(res->what, "dcb_tc"))
6650 RTE_ETH_FOREACH_DEV(i)
6651 port_dcb_info_display(i);
6652 else if (!strcmp(res->what, "cap"))
6653 RTE_ETH_FOREACH_DEV(i)
6654 port_offload_cap_display(i);
6657 cmdline_parse_token_string_t cmd_showportall_show =
6658 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6660 cmdline_parse_token_string_t cmd_showportall_port =
6661 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6662 cmdline_parse_token_string_t cmd_showportall_what =
6663 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6664 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6665 cmdline_parse_token_string_t cmd_showportall_all =
6666 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6667 cmdline_parse_inst_t cmd_showportall = {
6668 .f = cmd_showportall_parsed,
6670 .help_str = "show|clear port "
6671 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6673 (void *)&cmd_showportall_show,
6674 (void *)&cmd_showportall_port,
6675 (void *)&cmd_showportall_what,
6676 (void *)&cmd_showportall_all,
6681 /* *** SHOW PORT INFO *** */
6682 struct cmd_showport_result {
6683 cmdline_fixed_string_t show;
6684 cmdline_fixed_string_t port;
6685 cmdline_fixed_string_t what;
6689 static void cmd_showport_parsed(void *parsed_result,
6690 __attribute__((unused)) struct cmdline *cl,
6691 __attribute__((unused)) void *data)
6693 struct cmd_showport_result *res = parsed_result;
6694 if (!strcmp(res->show, "clear")) {
6695 if (!strcmp(res->what, "stats"))
6696 nic_stats_clear(res->portnum);
6697 else if (!strcmp(res->what, "xstats"))
6698 nic_xstats_clear(res->portnum);
6699 } else if (!strcmp(res->what, "info"))
6700 port_infos_display(res->portnum);
6701 else if (!strcmp(res->what, "stats"))
6702 nic_stats_display(res->portnum);
6703 else if (!strcmp(res->what, "xstats"))
6704 nic_xstats_display(res->portnum);
6705 else if (!strcmp(res->what, "fdir"))
6706 fdir_get_infos(res->portnum);
6707 else if (!strcmp(res->what, "stat_qmap"))
6708 nic_stats_mapping_display(res->portnum);
6709 else if (!strcmp(res->what, "dcb_tc"))
6710 port_dcb_info_display(res->portnum);
6711 else if (!strcmp(res->what, "cap"))
6712 port_offload_cap_display(res->portnum);
6715 cmdline_parse_token_string_t cmd_showport_show =
6716 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6718 cmdline_parse_token_string_t cmd_showport_port =
6719 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6720 cmdline_parse_token_string_t cmd_showport_what =
6721 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6722 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6723 cmdline_parse_token_num_t cmd_showport_portnum =
6724 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6726 cmdline_parse_inst_t cmd_showport = {
6727 .f = cmd_showport_parsed,
6729 .help_str = "show|clear port "
6730 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6733 (void *)&cmd_showport_show,
6734 (void *)&cmd_showport_port,
6735 (void *)&cmd_showport_what,
6736 (void *)&cmd_showport_portnum,
6741 /* *** SHOW QUEUE INFO *** */
6742 struct cmd_showqueue_result {
6743 cmdline_fixed_string_t show;
6744 cmdline_fixed_string_t type;
6745 cmdline_fixed_string_t what;
6751 cmd_showqueue_parsed(void *parsed_result,
6752 __attribute__((unused)) struct cmdline *cl,
6753 __attribute__((unused)) void *data)
6755 struct cmd_showqueue_result *res = parsed_result;
6757 if (!strcmp(res->type, "rxq"))
6758 rx_queue_infos_display(res->portnum, res->queuenum);
6759 else if (!strcmp(res->type, "txq"))
6760 tx_queue_infos_display(res->portnum, res->queuenum);
6763 cmdline_parse_token_string_t cmd_showqueue_show =
6764 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6765 cmdline_parse_token_string_t cmd_showqueue_type =
6766 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6767 cmdline_parse_token_string_t cmd_showqueue_what =
6768 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6769 cmdline_parse_token_num_t cmd_showqueue_portnum =
6770 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6771 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6772 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6774 cmdline_parse_inst_t cmd_showqueue = {
6775 .f = cmd_showqueue_parsed,
6777 .help_str = "show rxq|txq info <port_id> <queue_id>",
6779 (void *)&cmd_showqueue_show,
6780 (void *)&cmd_showqueue_type,
6781 (void *)&cmd_showqueue_what,
6782 (void *)&cmd_showqueue_portnum,
6783 (void *)&cmd_showqueue_queuenum,
6788 /* *** READ PORT REGISTER *** */
6789 struct cmd_read_reg_result {
6790 cmdline_fixed_string_t read;
6791 cmdline_fixed_string_t reg;
6797 cmd_read_reg_parsed(void *parsed_result,
6798 __attribute__((unused)) struct cmdline *cl,
6799 __attribute__((unused)) void *data)
6801 struct cmd_read_reg_result *res = parsed_result;
6802 port_reg_display(res->port_id, res->reg_off);
6805 cmdline_parse_token_string_t cmd_read_reg_read =
6806 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6807 cmdline_parse_token_string_t cmd_read_reg_reg =
6808 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6809 cmdline_parse_token_num_t cmd_read_reg_port_id =
6810 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6811 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6812 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6814 cmdline_parse_inst_t cmd_read_reg = {
6815 .f = cmd_read_reg_parsed,
6817 .help_str = "read reg <port_id> <reg_off>",
6819 (void *)&cmd_read_reg_read,
6820 (void *)&cmd_read_reg_reg,
6821 (void *)&cmd_read_reg_port_id,
6822 (void *)&cmd_read_reg_reg_off,
6827 /* *** READ PORT REGISTER BIT FIELD *** */
6828 struct cmd_read_reg_bit_field_result {
6829 cmdline_fixed_string_t read;
6830 cmdline_fixed_string_t regfield;
6838 cmd_read_reg_bit_field_parsed(void *parsed_result,
6839 __attribute__((unused)) struct cmdline *cl,
6840 __attribute__((unused)) void *data)
6842 struct cmd_read_reg_bit_field_result *res = parsed_result;
6843 port_reg_bit_field_display(res->port_id, res->reg_off,
6844 res->bit1_pos, res->bit2_pos);
6847 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6848 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6850 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6851 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6852 regfield, "regfield");
6853 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6854 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6856 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6857 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6859 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6860 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6862 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6863 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6866 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6867 .f = cmd_read_reg_bit_field_parsed,
6869 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6870 "Read register bit field between bit_x and bit_y included",
6872 (void *)&cmd_read_reg_bit_field_read,
6873 (void *)&cmd_read_reg_bit_field_regfield,
6874 (void *)&cmd_read_reg_bit_field_port_id,
6875 (void *)&cmd_read_reg_bit_field_reg_off,
6876 (void *)&cmd_read_reg_bit_field_bit1_pos,
6877 (void *)&cmd_read_reg_bit_field_bit2_pos,
6882 /* *** READ PORT REGISTER BIT *** */
6883 struct cmd_read_reg_bit_result {
6884 cmdline_fixed_string_t read;
6885 cmdline_fixed_string_t regbit;
6892 cmd_read_reg_bit_parsed(void *parsed_result,
6893 __attribute__((unused)) struct cmdline *cl,
6894 __attribute__((unused)) void *data)
6896 struct cmd_read_reg_bit_result *res = parsed_result;
6897 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6900 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6901 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6902 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6903 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6905 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6906 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6907 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6908 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6909 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6910 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6912 cmdline_parse_inst_t cmd_read_reg_bit = {
6913 .f = cmd_read_reg_bit_parsed,
6915 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6917 (void *)&cmd_read_reg_bit_read,
6918 (void *)&cmd_read_reg_bit_regbit,
6919 (void *)&cmd_read_reg_bit_port_id,
6920 (void *)&cmd_read_reg_bit_reg_off,
6921 (void *)&cmd_read_reg_bit_bit_pos,
6926 /* *** WRITE PORT REGISTER *** */
6927 struct cmd_write_reg_result {
6928 cmdline_fixed_string_t write;
6929 cmdline_fixed_string_t reg;
6936 cmd_write_reg_parsed(void *parsed_result,
6937 __attribute__((unused)) struct cmdline *cl,
6938 __attribute__((unused)) void *data)
6940 struct cmd_write_reg_result *res = parsed_result;
6941 port_reg_set(res->port_id, res->reg_off, res->value);
6944 cmdline_parse_token_string_t cmd_write_reg_write =
6945 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6946 cmdline_parse_token_string_t cmd_write_reg_reg =
6947 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6948 cmdline_parse_token_num_t cmd_write_reg_port_id =
6949 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6950 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6951 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6952 cmdline_parse_token_num_t cmd_write_reg_value =
6953 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6955 cmdline_parse_inst_t cmd_write_reg = {
6956 .f = cmd_write_reg_parsed,
6958 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6960 (void *)&cmd_write_reg_write,
6961 (void *)&cmd_write_reg_reg,
6962 (void *)&cmd_write_reg_port_id,
6963 (void *)&cmd_write_reg_reg_off,
6964 (void *)&cmd_write_reg_value,
6969 /* *** WRITE PORT REGISTER BIT FIELD *** */
6970 struct cmd_write_reg_bit_field_result {
6971 cmdline_fixed_string_t write;
6972 cmdline_fixed_string_t regfield;
6981 cmd_write_reg_bit_field_parsed(void *parsed_result,
6982 __attribute__((unused)) struct cmdline *cl,
6983 __attribute__((unused)) void *data)
6985 struct cmd_write_reg_bit_field_result *res = parsed_result;
6986 port_reg_bit_field_set(res->port_id, res->reg_off,
6987 res->bit1_pos, res->bit2_pos, res->value);
6990 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6991 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6993 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6994 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6995 regfield, "regfield");
6996 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6997 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6999 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7000 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7002 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7003 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7005 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7006 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7008 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7009 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7012 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7013 .f = cmd_write_reg_bit_field_parsed,
7015 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7017 "Set register bit field between bit_x and bit_y included",
7019 (void *)&cmd_write_reg_bit_field_write,
7020 (void *)&cmd_write_reg_bit_field_regfield,
7021 (void *)&cmd_write_reg_bit_field_port_id,
7022 (void *)&cmd_write_reg_bit_field_reg_off,
7023 (void *)&cmd_write_reg_bit_field_bit1_pos,
7024 (void *)&cmd_write_reg_bit_field_bit2_pos,
7025 (void *)&cmd_write_reg_bit_field_value,
7030 /* *** WRITE PORT REGISTER BIT *** */
7031 struct cmd_write_reg_bit_result {
7032 cmdline_fixed_string_t write;
7033 cmdline_fixed_string_t regbit;
7041 cmd_write_reg_bit_parsed(void *parsed_result,
7042 __attribute__((unused)) struct cmdline *cl,
7043 __attribute__((unused)) void *data)
7045 struct cmd_write_reg_bit_result *res = parsed_result;
7046 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7049 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7050 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7052 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7053 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7055 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7056 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7057 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7058 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7059 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7060 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7061 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7062 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7064 cmdline_parse_inst_t cmd_write_reg_bit = {
7065 .f = cmd_write_reg_bit_parsed,
7067 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7070 (void *)&cmd_write_reg_bit_write,
7071 (void *)&cmd_write_reg_bit_regbit,
7072 (void *)&cmd_write_reg_bit_port_id,
7073 (void *)&cmd_write_reg_bit_reg_off,
7074 (void *)&cmd_write_reg_bit_bit_pos,
7075 (void *)&cmd_write_reg_bit_value,
7080 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7081 struct cmd_read_rxd_txd_result {
7082 cmdline_fixed_string_t read;
7083 cmdline_fixed_string_t rxd_txd;
7090 cmd_read_rxd_txd_parsed(void *parsed_result,
7091 __attribute__((unused)) struct cmdline *cl,
7092 __attribute__((unused)) void *data)
7094 struct cmd_read_rxd_txd_result *res = parsed_result;
7096 if (!strcmp(res->rxd_txd, "rxd"))
7097 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7098 else if (!strcmp(res->rxd_txd, "txd"))
7099 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7102 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7103 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7104 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7105 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7107 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7108 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7109 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7110 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7111 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7112 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7114 cmdline_parse_inst_t cmd_read_rxd_txd = {
7115 .f = cmd_read_rxd_txd_parsed,
7117 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7119 (void *)&cmd_read_rxd_txd_read,
7120 (void *)&cmd_read_rxd_txd_rxd_txd,
7121 (void *)&cmd_read_rxd_txd_port_id,
7122 (void *)&cmd_read_rxd_txd_queue_id,
7123 (void *)&cmd_read_rxd_txd_desc_id,
7129 struct cmd_quit_result {
7130 cmdline_fixed_string_t quit;
7133 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7135 __attribute__((unused)) void *data)
7141 cmdline_parse_token_string_t cmd_quit_quit =
7142 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7144 cmdline_parse_inst_t cmd_quit = {
7145 .f = cmd_quit_parsed,
7147 .help_str = "quit: Exit application",
7149 (void *)&cmd_quit_quit,
7154 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7155 struct cmd_mac_addr_result {
7156 cmdline_fixed_string_t mac_addr_cmd;
7157 cmdline_fixed_string_t what;
7159 struct ether_addr address;
7162 static void cmd_mac_addr_parsed(void *parsed_result,
7163 __attribute__((unused)) struct cmdline *cl,
7164 __attribute__((unused)) void *data)
7166 struct cmd_mac_addr_result *res = parsed_result;
7169 if (strcmp(res->what, "add") == 0)
7170 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7171 else if (strcmp(res->what, "set") == 0)
7172 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7175 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7177 /* check the return value and print it if is < 0 */
7179 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7183 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7184 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7186 cmdline_parse_token_string_t cmd_mac_addr_what =
7187 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7189 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7190 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7192 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7193 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7195 cmdline_parse_inst_t cmd_mac_addr = {
7196 .f = cmd_mac_addr_parsed,
7198 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7199 "Add/Remove/Set MAC address on port_id",
7201 (void *)&cmd_mac_addr_cmd,
7202 (void *)&cmd_mac_addr_what,
7203 (void *)&cmd_mac_addr_portnum,
7204 (void *)&cmd_mac_addr_addr,
7209 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7210 struct cmd_eth_peer_result {
7211 cmdline_fixed_string_t set;
7212 cmdline_fixed_string_t eth_peer;
7214 cmdline_fixed_string_t peer_addr;
7217 static void cmd_set_eth_peer_parsed(void *parsed_result,
7218 __attribute__((unused)) struct cmdline *cl,
7219 __attribute__((unused)) void *data)
7221 struct cmd_eth_peer_result *res = parsed_result;
7223 if (test_done == 0) {
7224 printf("Please stop forwarding first\n");
7227 if (!strcmp(res->eth_peer, "eth-peer")) {
7228 set_fwd_eth_peer(res->port_id, res->peer_addr);
7232 cmdline_parse_token_string_t cmd_eth_peer_set =
7233 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7234 cmdline_parse_token_string_t cmd_eth_peer =
7235 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7236 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7237 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7238 cmdline_parse_token_string_t cmd_eth_peer_addr =
7239 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7241 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7242 .f = cmd_set_eth_peer_parsed,
7244 .help_str = "set eth-peer <port_id> <peer_mac>",
7246 (void *)&cmd_eth_peer_set,
7247 (void *)&cmd_eth_peer,
7248 (void *)&cmd_eth_peer_port_id,
7249 (void *)&cmd_eth_peer_addr,
7254 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7255 struct cmd_set_qmap_result {
7256 cmdline_fixed_string_t set;
7257 cmdline_fixed_string_t qmap;
7258 cmdline_fixed_string_t what;
7265 cmd_set_qmap_parsed(void *parsed_result,
7266 __attribute__((unused)) struct cmdline *cl,
7267 __attribute__((unused)) void *data)
7269 struct cmd_set_qmap_result *res = parsed_result;
7270 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7272 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7275 cmdline_parse_token_string_t cmd_setqmap_set =
7276 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7278 cmdline_parse_token_string_t cmd_setqmap_qmap =
7279 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7281 cmdline_parse_token_string_t cmd_setqmap_what =
7282 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7284 cmdline_parse_token_num_t cmd_setqmap_portid =
7285 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7287 cmdline_parse_token_num_t cmd_setqmap_queueid =
7288 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7290 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7291 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7294 cmdline_parse_inst_t cmd_set_qmap = {
7295 .f = cmd_set_qmap_parsed,
7297 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7298 "Set statistics mapping value on tx|rx queue_id of port_id",
7300 (void *)&cmd_setqmap_set,
7301 (void *)&cmd_setqmap_qmap,
7302 (void *)&cmd_setqmap_what,
7303 (void *)&cmd_setqmap_portid,
7304 (void *)&cmd_setqmap_queueid,
7305 (void *)&cmd_setqmap_mapvalue,
7310 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7311 struct cmd_set_xstats_hide_zero_result {
7312 cmdline_fixed_string_t keyword;
7313 cmdline_fixed_string_t name;
7314 cmdline_fixed_string_t on_off;
7318 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7319 __attribute__((unused)) struct cmdline *cl,
7320 __attribute__((unused)) void *data)
7322 struct cmd_set_xstats_hide_zero_result *res;
7323 uint16_t on_off = 0;
7325 res = parsed_result;
7326 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7327 set_xstats_hide_zero(on_off);
7330 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7331 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7333 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7334 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7335 name, "xstats-hide-zero");
7336 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7337 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7340 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7341 .f = cmd_set_xstats_hide_zero_parsed,
7343 .help_str = "set xstats-hide-zero on|off",
7345 (void *)&cmd_set_xstats_hide_zero_keyword,
7346 (void *)&cmd_set_xstats_hide_zero_name,
7347 (void *)&cmd_set_xstats_hide_zero_on_off,
7352 /* *** CONFIGURE UNICAST HASH TABLE *** */
7353 struct cmd_set_uc_hash_table {
7354 cmdline_fixed_string_t set;
7355 cmdline_fixed_string_t port;
7357 cmdline_fixed_string_t what;
7358 struct ether_addr address;
7359 cmdline_fixed_string_t mode;
7363 cmd_set_uc_hash_parsed(void *parsed_result,
7364 __attribute__((unused)) struct cmdline *cl,
7365 __attribute__((unused)) void *data)
7368 struct cmd_set_uc_hash_table *res = parsed_result;
7370 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7372 if (strcmp(res->what, "uta") == 0)
7373 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7374 &res->address,(uint8_t)is_on);
7376 printf("bad unicast hash table parameter, return code = %d \n", ret);
7380 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7381 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7383 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7384 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7386 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7387 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7389 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7390 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7392 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7393 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7395 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7396 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7399 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7400 .f = cmd_set_uc_hash_parsed,
7402 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7404 (void *)&cmd_set_uc_hash_set,
7405 (void *)&cmd_set_uc_hash_port,
7406 (void *)&cmd_set_uc_hash_portid,
7407 (void *)&cmd_set_uc_hash_what,
7408 (void *)&cmd_set_uc_hash_mac,
7409 (void *)&cmd_set_uc_hash_mode,
7414 struct cmd_set_uc_all_hash_table {
7415 cmdline_fixed_string_t set;
7416 cmdline_fixed_string_t port;
7418 cmdline_fixed_string_t what;
7419 cmdline_fixed_string_t value;
7420 cmdline_fixed_string_t mode;
7424 cmd_set_uc_all_hash_parsed(void *parsed_result,
7425 __attribute__((unused)) struct cmdline *cl,
7426 __attribute__((unused)) void *data)
7429 struct cmd_set_uc_all_hash_table *res = parsed_result;
7431 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7433 if ((strcmp(res->what, "uta") == 0) &&
7434 (strcmp(res->value, "all") == 0))
7435 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7437 printf("bad unicast hash table parameter,"
7438 "return code = %d \n", ret);
7441 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7442 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7444 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7445 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7447 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7448 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7450 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7451 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7453 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7454 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7456 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7457 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7460 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7461 .f = cmd_set_uc_all_hash_parsed,
7463 .help_str = "set port <port_id> uta all on|off",
7465 (void *)&cmd_set_uc_all_hash_set,
7466 (void *)&cmd_set_uc_all_hash_port,
7467 (void *)&cmd_set_uc_all_hash_portid,
7468 (void *)&cmd_set_uc_all_hash_what,
7469 (void *)&cmd_set_uc_all_hash_value,
7470 (void *)&cmd_set_uc_all_hash_mode,
7475 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7476 struct cmd_set_vf_macvlan_filter {
7477 cmdline_fixed_string_t set;
7478 cmdline_fixed_string_t port;
7480 cmdline_fixed_string_t vf;
7482 struct ether_addr address;
7483 cmdline_fixed_string_t filter_type;
7484 cmdline_fixed_string_t mode;
7488 cmd_set_vf_macvlan_parsed(void *parsed_result,
7489 __attribute__((unused)) struct cmdline *cl,
7490 __attribute__((unused)) void *data)
7493 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7494 struct rte_eth_mac_filter filter;
7496 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7498 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7500 /* set VF MAC filter */
7504 filter.dst_id = res->vf_id;
7506 if (!strcmp(res->filter_type, "exact-mac"))
7507 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7508 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7509 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7510 else if (!strcmp(res->filter_type, "hashmac"))
7511 filter.filter_type = RTE_MAC_HASH_MATCH;
7512 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7513 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7515 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7518 ret = rte_eth_dev_filter_ctrl(res->port_id,
7519 RTE_ETH_FILTER_MACVLAN,
7523 ret = rte_eth_dev_filter_ctrl(res->port_id,
7524 RTE_ETH_FILTER_MACVLAN,
7525 RTE_ETH_FILTER_DELETE,
7529 printf("bad set MAC hash parameter, return code = %d\n", ret);
7533 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7534 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7536 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7537 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7539 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7540 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7542 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7543 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7545 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7546 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7548 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7549 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7551 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7552 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7553 filter_type, "exact-mac#exact-mac-vlan"
7554 "#hashmac#hashmac-vlan");
7555 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7556 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7559 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7560 .f = cmd_set_vf_macvlan_parsed,
7562 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7563 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7564 "Exact match rule: exact match of MAC or MAC and VLAN; "
7565 "hash match rule: hash match of MAC and exact match of VLAN",
7567 (void *)&cmd_set_vf_macvlan_set,
7568 (void *)&cmd_set_vf_macvlan_port,
7569 (void *)&cmd_set_vf_macvlan_portid,
7570 (void *)&cmd_set_vf_macvlan_vf,
7571 (void *)&cmd_set_vf_macvlan_vf_id,
7572 (void *)&cmd_set_vf_macvlan_mac,
7573 (void *)&cmd_set_vf_macvlan_filter_type,
7574 (void *)&cmd_set_vf_macvlan_mode,
7579 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7580 struct cmd_set_vf_traffic {
7581 cmdline_fixed_string_t set;
7582 cmdline_fixed_string_t port;
7584 cmdline_fixed_string_t vf;
7586 cmdline_fixed_string_t what;
7587 cmdline_fixed_string_t mode;
7591 cmd_set_vf_traffic_parsed(void *parsed_result,
7592 __attribute__((unused)) struct cmdline *cl,
7593 __attribute__((unused)) void *data)
7595 struct cmd_set_vf_traffic *res = parsed_result;
7596 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7597 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7599 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7602 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7603 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7605 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7606 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7608 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7609 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7611 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7612 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7614 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7615 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7617 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7618 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7620 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7621 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7624 cmdline_parse_inst_t cmd_set_vf_traffic = {
7625 .f = cmd_set_vf_traffic_parsed,
7627 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7629 (void *)&cmd_setvf_traffic_set,
7630 (void *)&cmd_setvf_traffic_port,
7631 (void *)&cmd_setvf_traffic_portid,
7632 (void *)&cmd_setvf_traffic_vf,
7633 (void *)&cmd_setvf_traffic_vfid,
7634 (void *)&cmd_setvf_traffic_what,
7635 (void *)&cmd_setvf_traffic_mode,
7640 /* *** CONFIGURE VF RECEIVE MODE *** */
7641 struct cmd_set_vf_rxmode {
7642 cmdline_fixed_string_t set;
7643 cmdline_fixed_string_t port;
7645 cmdline_fixed_string_t vf;
7647 cmdline_fixed_string_t what;
7648 cmdline_fixed_string_t mode;
7649 cmdline_fixed_string_t on;
7653 cmd_set_vf_rxmode_parsed(void *parsed_result,
7654 __attribute__((unused)) struct cmdline *cl,
7655 __attribute__((unused)) void *data)
7658 uint16_t rx_mode = 0;
7659 struct cmd_set_vf_rxmode *res = parsed_result;
7661 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7662 if (!strcmp(res->what,"rxmode")) {
7663 if (!strcmp(res->mode, "AUPE"))
7664 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7665 else if (!strcmp(res->mode, "ROPE"))
7666 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7667 else if (!strcmp(res->mode, "BAM"))
7668 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7669 else if (!strncmp(res->mode, "MPE",3))
7670 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7673 RTE_SET_USED(is_on);
7675 #ifdef RTE_LIBRTE_IXGBE_PMD
7676 if (ret == -ENOTSUP)
7677 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7678 rx_mode, (uint8_t)is_on);
7680 #ifdef RTE_LIBRTE_BNXT_PMD
7681 if (ret == -ENOTSUP)
7682 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7683 rx_mode, (uint8_t)is_on);
7686 printf("bad VF receive mode parameter, return code = %d \n",
7690 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7691 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7693 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7694 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7696 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7697 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7699 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7700 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7702 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7703 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7705 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7706 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7708 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7709 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7710 mode, "AUPE#ROPE#BAM#MPE");
7711 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7712 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7715 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7716 .f = cmd_set_vf_rxmode_parsed,
7718 .help_str = "set port <port_id> vf <vf_id> rxmode "
7719 "AUPE|ROPE|BAM|MPE on|off",
7721 (void *)&cmd_set_vf_rxmode_set,
7722 (void *)&cmd_set_vf_rxmode_port,
7723 (void *)&cmd_set_vf_rxmode_portid,
7724 (void *)&cmd_set_vf_rxmode_vf,
7725 (void *)&cmd_set_vf_rxmode_vfid,
7726 (void *)&cmd_set_vf_rxmode_what,
7727 (void *)&cmd_set_vf_rxmode_mode,
7728 (void *)&cmd_set_vf_rxmode_on,
7733 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7734 struct cmd_vf_mac_addr_result {
7735 cmdline_fixed_string_t mac_addr_cmd;
7736 cmdline_fixed_string_t what;
7737 cmdline_fixed_string_t port;
7739 cmdline_fixed_string_t vf;
7741 struct ether_addr address;
7744 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7745 __attribute__((unused)) struct cmdline *cl,
7746 __attribute__((unused)) void *data)
7748 struct cmd_vf_mac_addr_result *res = parsed_result;
7751 if (strcmp(res->what, "add") != 0)
7754 #ifdef RTE_LIBRTE_I40E_PMD
7755 if (ret == -ENOTSUP)
7756 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7759 #ifdef RTE_LIBRTE_BNXT_PMD
7760 if (ret == -ENOTSUP)
7761 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7766 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7770 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7771 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7772 mac_addr_cmd,"mac_addr");
7773 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7774 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7776 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7777 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7779 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7780 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7782 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7783 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7785 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7786 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7788 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7789 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7792 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7793 .f = cmd_vf_mac_addr_parsed,
7795 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7796 "Add MAC address filtering for a VF on port_id",
7798 (void *)&cmd_vf_mac_addr_cmd,
7799 (void *)&cmd_vf_mac_addr_what,
7800 (void *)&cmd_vf_mac_addr_port,
7801 (void *)&cmd_vf_mac_addr_portnum,
7802 (void *)&cmd_vf_mac_addr_vf,
7803 (void *)&cmd_vf_mac_addr_vfnum,
7804 (void *)&cmd_vf_mac_addr_addr,
7809 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7810 struct cmd_vf_rx_vlan_filter {
7811 cmdline_fixed_string_t rx_vlan;
7812 cmdline_fixed_string_t what;
7814 cmdline_fixed_string_t port;
7816 cmdline_fixed_string_t vf;
7821 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7822 __attribute__((unused)) struct cmdline *cl,
7823 __attribute__((unused)) void *data)
7825 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7828 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7830 #ifdef RTE_LIBRTE_IXGBE_PMD
7831 if (ret == -ENOTSUP)
7832 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7833 res->vlan_id, res->vf_mask, is_add);
7835 #ifdef RTE_LIBRTE_I40E_PMD
7836 if (ret == -ENOTSUP)
7837 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7838 res->vlan_id, res->vf_mask, is_add);
7840 #ifdef RTE_LIBRTE_BNXT_PMD
7841 if (ret == -ENOTSUP)
7842 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7843 res->vlan_id, res->vf_mask, is_add);
7850 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7851 res->vlan_id, res->vf_mask);
7854 printf("invalid port_id %d\n", res->port_id);
7857 printf("function not implemented or supported\n");
7860 printf("programming error: (%s)\n", strerror(-ret));
7864 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7865 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7866 rx_vlan, "rx_vlan");
7867 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7868 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7870 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7871 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7873 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7874 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7876 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7877 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7879 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7880 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7882 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7883 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7886 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7887 .f = cmd_vf_rx_vlan_filter_parsed,
7889 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7890 "(vf_mask = hexadecimal VF mask)",
7892 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7893 (void *)&cmd_vf_rx_vlan_filter_what,
7894 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7895 (void *)&cmd_vf_rx_vlan_filter_port,
7896 (void *)&cmd_vf_rx_vlan_filter_portid,
7897 (void *)&cmd_vf_rx_vlan_filter_vf,
7898 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7903 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7904 struct cmd_queue_rate_limit_result {
7905 cmdline_fixed_string_t set;
7906 cmdline_fixed_string_t port;
7908 cmdline_fixed_string_t queue;
7910 cmdline_fixed_string_t rate;
7914 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7915 __attribute__((unused)) struct cmdline *cl,
7916 __attribute__((unused)) void *data)
7918 struct cmd_queue_rate_limit_result *res = parsed_result;
7921 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7922 && (strcmp(res->queue, "queue") == 0)
7923 && (strcmp(res->rate, "rate") == 0))
7924 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7927 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7931 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7932 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7934 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7935 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7937 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7938 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7940 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7941 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7943 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7944 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7946 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7947 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7949 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7950 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7953 cmdline_parse_inst_t cmd_queue_rate_limit = {
7954 .f = cmd_queue_rate_limit_parsed,
7956 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7957 "Set rate limit for a queue on port_id",
7959 (void *)&cmd_queue_rate_limit_set,
7960 (void *)&cmd_queue_rate_limit_port,
7961 (void *)&cmd_queue_rate_limit_portnum,
7962 (void *)&cmd_queue_rate_limit_queue,
7963 (void *)&cmd_queue_rate_limit_queuenum,
7964 (void *)&cmd_queue_rate_limit_rate,
7965 (void *)&cmd_queue_rate_limit_ratenum,
7970 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7971 struct cmd_vf_rate_limit_result {
7972 cmdline_fixed_string_t set;
7973 cmdline_fixed_string_t port;
7975 cmdline_fixed_string_t vf;
7977 cmdline_fixed_string_t rate;
7979 cmdline_fixed_string_t q_msk;
7983 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7984 __attribute__((unused)) struct cmdline *cl,
7985 __attribute__((unused)) void *data)
7987 struct cmd_vf_rate_limit_result *res = parsed_result;
7990 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7991 && (strcmp(res->vf, "vf") == 0)
7992 && (strcmp(res->rate, "rate") == 0)
7993 && (strcmp(res->q_msk, "queue_mask") == 0))
7994 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7995 res->rate_num, res->q_msk_val);
7997 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8001 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8002 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8004 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8005 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8007 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8008 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8010 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8011 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8013 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8014 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8016 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8017 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8019 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8020 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8022 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8023 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8024 q_msk, "queue_mask");
8025 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8026 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8029 cmdline_parse_inst_t cmd_vf_rate_limit = {
8030 .f = cmd_vf_rate_limit_parsed,
8032 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8033 "queue_mask <queue_mask_value>: "
8034 "Set rate limit for queues of VF on port_id",
8036 (void *)&cmd_vf_rate_limit_set,
8037 (void *)&cmd_vf_rate_limit_port,
8038 (void *)&cmd_vf_rate_limit_portnum,
8039 (void *)&cmd_vf_rate_limit_vf,
8040 (void *)&cmd_vf_rate_limit_vfnum,
8041 (void *)&cmd_vf_rate_limit_rate,
8042 (void *)&cmd_vf_rate_limit_ratenum,
8043 (void *)&cmd_vf_rate_limit_q_msk,
8044 (void *)&cmd_vf_rate_limit_q_msk_val,
8049 /* *** ADD TUNNEL FILTER OF A PORT *** */
8050 struct cmd_tunnel_filter_result {
8051 cmdline_fixed_string_t cmd;
8052 cmdline_fixed_string_t what;
8054 struct ether_addr outer_mac;
8055 struct ether_addr inner_mac;
8056 cmdline_ipaddr_t ip_value;
8057 uint16_t inner_vlan;
8058 cmdline_fixed_string_t tunnel_type;
8059 cmdline_fixed_string_t filter_type;
8065 cmd_tunnel_filter_parsed(void *parsed_result,
8066 __attribute__((unused)) struct cmdline *cl,
8067 __attribute__((unused)) void *data)
8069 struct cmd_tunnel_filter_result *res = parsed_result;
8070 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8073 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8075 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8076 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8077 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8079 if (res->ip_value.family == AF_INET) {
8080 tunnel_filter_conf.ip_addr.ipv4_addr =
8081 res->ip_value.addr.ipv4.s_addr;
8082 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8084 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8085 &(res->ip_value.addr.ipv6),
8086 sizeof(struct in6_addr));
8087 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8090 if (!strcmp(res->filter_type, "imac-ivlan"))
8091 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8092 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8093 tunnel_filter_conf.filter_type =
8094 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8095 else if (!strcmp(res->filter_type, "imac-tenid"))
8096 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8097 else if (!strcmp(res->filter_type, "imac"))
8098 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8099 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8100 tunnel_filter_conf.filter_type =
8101 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8102 else if (!strcmp(res->filter_type, "oip"))
8103 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8104 else if (!strcmp(res->filter_type, "iip"))
8105 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8107 printf("The filter type is not supported");
8111 if (!strcmp(res->tunnel_type, "vxlan"))
8112 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8113 else if (!strcmp(res->tunnel_type, "nvgre"))
8114 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8115 else if (!strcmp(res->tunnel_type, "ipingre"))
8116 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8118 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8122 tunnel_filter_conf.tenant_id = res->tenant_id;
8123 tunnel_filter_conf.queue_id = res->queue_num;
8124 if (!strcmp(res->what, "add"))
8125 ret = rte_eth_dev_filter_ctrl(res->port_id,
8126 RTE_ETH_FILTER_TUNNEL,
8128 &tunnel_filter_conf);
8130 ret = rte_eth_dev_filter_ctrl(res->port_id,
8131 RTE_ETH_FILTER_TUNNEL,
8132 RTE_ETH_FILTER_DELETE,
8133 &tunnel_filter_conf);
8135 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8139 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8140 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8141 cmd, "tunnel_filter");
8142 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8143 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8145 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8146 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8148 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8149 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8151 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8152 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8154 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8155 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8156 inner_vlan, UINT16);
8157 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8158 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8160 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8161 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8162 tunnel_type, "vxlan#nvgre#ipingre");
8164 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8165 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8166 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8167 "imac#omac-imac-tenid");
8168 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8169 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8171 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8172 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8175 cmdline_parse_inst_t cmd_tunnel_filter = {
8176 .f = cmd_tunnel_filter_parsed,
8178 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8179 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8180 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8181 "<queue_id>: Add/Rm tunnel filter of a port",
8183 (void *)&cmd_tunnel_filter_cmd,
8184 (void *)&cmd_tunnel_filter_what,
8185 (void *)&cmd_tunnel_filter_port_id,
8186 (void *)&cmd_tunnel_filter_outer_mac,
8187 (void *)&cmd_tunnel_filter_inner_mac,
8188 (void *)&cmd_tunnel_filter_ip_value,
8189 (void *)&cmd_tunnel_filter_innner_vlan,
8190 (void *)&cmd_tunnel_filter_tunnel_type,
8191 (void *)&cmd_tunnel_filter_filter_type,
8192 (void *)&cmd_tunnel_filter_tenant_id,
8193 (void *)&cmd_tunnel_filter_queue_num,
8198 /* *** CONFIGURE TUNNEL UDP PORT *** */
8199 struct cmd_tunnel_udp_config {
8200 cmdline_fixed_string_t cmd;
8201 cmdline_fixed_string_t what;
8207 cmd_tunnel_udp_config_parsed(void *parsed_result,
8208 __attribute__((unused)) struct cmdline *cl,
8209 __attribute__((unused)) void *data)
8211 struct cmd_tunnel_udp_config *res = parsed_result;
8212 struct rte_eth_udp_tunnel tunnel_udp;
8215 tunnel_udp.udp_port = res->udp_port;
8217 if (!strcmp(res->cmd, "rx_vxlan_port"))
8218 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8220 if (!strcmp(res->what, "add"))
8221 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8224 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8228 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8231 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8232 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8233 cmd, "rx_vxlan_port");
8234 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8235 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8237 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8238 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8240 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8241 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8244 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8245 .f = cmd_tunnel_udp_config_parsed,
8247 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8248 "Add/Remove a tunneling UDP port filter",
8250 (void *)&cmd_tunnel_udp_config_cmd,
8251 (void *)&cmd_tunnel_udp_config_what,
8252 (void *)&cmd_tunnel_udp_config_udp_port,
8253 (void *)&cmd_tunnel_udp_config_port_id,
8258 /* *** GLOBAL CONFIG *** */
8259 struct cmd_global_config_result {
8260 cmdline_fixed_string_t cmd;
8262 cmdline_fixed_string_t cfg_type;
8267 cmd_global_config_parsed(void *parsed_result,
8268 __attribute__((unused)) struct cmdline *cl,
8269 __attribute__((unused)) void *data)
8271 struct cmd_global_config_result *res = parsed_result;
8272 struct rte_eth_global_cfg conf;
8275 memset(&conf, 0, sizeof(conf));
8276 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8277 conf.cfg.gre_key_len = res->len;
8278 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8279 RTE_ETH_FILTER_SET, &conf);
8281 printf("Global config error\n");
8284 cmdline_parse_token_string_t cmd_global_config_cmd =
8285 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8287 cmdline_parse_token_num_t cmd_global_config_port_id =
8288 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8290 cmdline_parse_token_string_t cmd_global_config_type =
8291 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8292 cfg_type, "gre-key-len");
8293 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8294 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8297 cmdline_parse_inst_t cmd_global_config = {
8298 .f = cmd_global_config_parsed,
8299 .data = (void *)NULL,
8300 .help_str = "global_config <port_id> gre-key-len <key_len>",
8302 (void *)&cmd_global_config_cmd,
8303 (void *)&cmd_global_config_port_id,
8304 (void *)&cmd_global_config_type,
8305 (void *)&cmd_global_config_gre_key_len,
8310 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8311 struct cmd_set_mirror_mask_result {
8312 cmdline_fixed_string_t set;
8313 cmdline_fixed_string_t port;
8315 cmdline_fixed_string_t mirror;
8317 cmdline_fixed_string_t what;
8318 cmdline_fixed_string_t value;
8319 cmdline_fixed_string_t dstpool;
8321 cmdline_fixed_string_t on;
8324 cmdline_parse_token_string_t cmd_mirror_mask_set =
8325 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8327 cmdline_parse_token_string_t cmd_mirror_mask_port =
8328 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8330 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8331 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8333 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8334 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8335 mirror, "mirror-rule");
8336 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8337 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8339 cmdline_parse_token_string_t cmd_mirror_mask_what =
8340 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8341 what, "pool-mirror-up#pool-mirror-down"
8343 cmdline_parse_token_string_t cmd_mirror_mask_value =
8344 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8346 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8347 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8348 dstpool, "dst-pool");
8349 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8350 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8352 cmdline_parse_token_string_t cmd_mirror_mask_on =
8353 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8357 cmd_set_mirror_mask_parsed(void *parsed_result,
8358 __attribute__((unused)) struct cmdline *cl,
8359 __attribute__((unused)) void *data)
8362 struct cmd_set_mirror_mask_result *res = parsed_result;
8363 struct rte_eth_mirror_conf mr_conf;
8365 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8367 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8369 mr_conf.dst_pool = res->dstpool_id;
8371 if (!strcmp(res->what, "pool-mirror-up")) {
8372 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8373 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8374 } else if (!strcmp(res->what, "pool-mirror-down")) {
8375 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8376 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8377 } else if (!strcmp(res->what, "vlan-mirror")) {
8378 mr_conf.rule_type = ETH_MIRROR_VLAN;
8379 nb_item = parse_item_list(res->value, "vlan",
8380 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8384 for (i = 0; i < nb_item; i++) {
8385 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8386 printf("Invalid vlan_id: must be < 4096\n");
8390 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8391 mr_conf.vlan.vlan_mask |= 1ULL << i;
8395 if (!strcmp(res->on, "on"))
8396 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8399 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8402 printf("mirror rule add error: (%s)\n", strerror(-ret));
8405 cmdline_parse_inst_t cmd_set_mirror_mask = {
8406 .f = cmd_set_mirror_mask_parsed,
8408 .help_str = "set port <port_id> mirror-rule <rule_id> "
8409 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8410 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8412 (void *)&cmd_mirror_mask_set,
8413 (void *)&cmd_mirror_mask_port,
8414 (void *)&cmd_mirror_mask_portid,
8415 (void *)&cmd_mirror_mask_mirror,
8416 (void *)&cmd_mirror_mask_ruleid,
8417 (void *)&cmd_mirror_mask_what,
8418 (void *)&cmd_mirror_mask_value,
8419 (void *)&cmd_mirror_mask_dstpool,
8420 (void *)&cmd_mirror_mask_poolid,
8421 (void *)&cmd_mirror_mask_on,
8426 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8427 struct cmd_set_mirror_link_result {
8428 cmdline_fixed_string_t set;
8429 cmdline_fixed_string_t port;
8431 cmdline_fixed_string_t mirror;
8433 cmdline_fixed_string_t what;
8434 cmdline_fixed_string_t dstpool;
8436 cmdline_fixed_string_t on;
8439 cmdline_parse_token_string_t cmd_mirror_link_set =
8440 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8442 cmdline_parse_token_string_t cmd_mirror_link_port =
8443 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8445 cmdline_parse_token_num_t cmd_mirror_link_portid =
8446 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8448 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8449 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8450 mirror, "mirror-rule");
8451 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8452 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8454 cmdline_parse_token_string_t cmd_mirror_link_what =
8455 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8456 what, "uplink-mirror#downlink-mirror");
8457 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8458 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8459 dstpool, "dst-pool");
8460 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8461 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8463 cmdline_parse_token_string_t cmd_mirror_link_on =
8464 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8468 cmd_set_mirror_link_parsed(void *parsed_result,
8469 __attribute__((unused)) struct cmdline *cl,
8470 __attribute__((unused)) void *data)
8473 struct cmd_set_mirror_link_result *res = parsed_result;
8474 struct rte_eth_mirror_conf mr_conf;
8476 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8477 if (!strcmp(res->what, "uplink-mirror"))
8478 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8480 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8482 mr_conf.dst_pool = res->dstpool_id;
8484 if (!strcmp(res->on, "on"))
8485 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8488 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8491 /* check the return value and print it if is < 0 */
8493 printf("mirror rule add error: (%s)\n", strerror(-ret));
8497 cmdline_parse_inst_t cmd_set_mirror_link = {
8498 .f = cmd_set_mirror_link_parsed,
8500 .help_str = "set port <port_id> mirror-rule <rule_id> "
8501 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8503 (void *)&cmd_mirror_link_set,
8504 (void *)&cmd_mirror_link_port,
8505 (void *)&cmd_mirror_link_portid,
8506 (void *)&cmd_mirror_link_mirror,
8507 (void *)&cmd_mirror_link_ruleid,
8508 (void *)&cmd_mirror_link_what,
8509 (void *)&cmd_mirror_link_dstpool,
8510 (void *)&cmd_mirror_link_poolid,
8511 (void *)&cmd_mirror_link_on,
8516 /* *** RESET VM MIRROR RULE *** */
8517 struct cmd_rm_mirror_rule_result {
8518 cmdline_fixed_string_t reset;
8519 cmdline_fixed_string_t port;
8521 cmdline_fixed_string_t mirror;
8525 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8526 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8528 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8529 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8531 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8532 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8534 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8535 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8536 mirror, "mirror-rule");
8537 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8538 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8542 cmd_reset_mirror_rule_parsed(void *parsed_result,
8543 __attribute__((unused)) struct cmdline *cl,
8544 __attribute__((unused)) void *data)
8547 struct cmd_set_mirror_link_result *res = parsed_result;
8549 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8551 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8554 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8555 .f = cmd_reset_mirror_rule_parsed,
8557 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8559 (void *)&cmd_rm_mirror_rule_reset,
8560 (void *)&cmd_rm_mirror_rule_port,
8561 (void *)&cmd_rm_mirror_rule_portid,
8562 (void *)&cmd_rm_mirror_rule_mirror,
8563 (void *)&cmd_rm_mirror_rule_ruleid,
8568 /* ******************************************************************************** */
8570 struct cmd_dump_result {
8571 cmdline_fixed_string_t dump;
8575 dump_struct_sizes(void)
8577 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8578 DUMP_SIZE(struct rte_mbuf);
8579 DUMP_SIZE(struct rte_mempool);
8580 DUMP_SIZE(struct rte_ring);
8584 static void cmd_dump_parsed(void *parsed_result,
8585 __attribute__((unused)) struct cmdline *cl,
8586 __attribute__((unused)) void *data)
8588 struct cmd_dump_result *res = parsed_result;
8590 if (!strcmp(res->dump, "dump_physmem"))
8591 rte_dump_physmem_layout(stdout);
8592 else if (!strcmp(res->dump, "dump_memzone"))
8593 rte_memzone_dump(stdout);
8594 else if (!strcmp(res->dump, "dump_struct_sizes"))
8595 dump_struct_sizes();
8596 else if (!strcmp(res->dump, "dump_ring"))
8597 rte_ring_list_dump(stdout);
8598 else if (!strcmp(res->dump, "dump_mempool"))
8599 rte_mempool_list_dump(stdout);
8600 else if (!strcmp(res->dump, "dump_devargs"))
8601 rte_eal_devargs_dump(stdout);
8602 else if (!strcmp(res->dump, "dump_log_types"))
8603 rte_log_dump(stdout);
8606 cmdline_parse_token_string_t cmd_dump_dump =
8607 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8610 "dump_struct_sizes#"
8616 cmdline_parse_inst_t cmd_dump = {
8617 .f = cmd_dump_parsed, /* function to call */
8618 .data = NULL, /* 2nd arg of func */
8619 .help_str = "Dump status",
8620 .tokens = { /* token list, NULL terminated */
8621 (void *)&cmd_dump_dump,
8626 /* ******************************************************************************** */
8628 struct cmd_dump_one_result {
8629 cmdline_fixed_string_t dump;
8630 cmdline_fixed_string_t name;
8633 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8634 __attribute__((unused)) void *data)
8636 struct cmd_dump_one_result *res = parsed_result;
8638 if (!strcmp(res->dump, "dump_ring")) {
8640 r = rte_ring_lookup(res->name);
8642 cmdline_printf(cl, "Cannot find ring\n");
8645 rte_ring_dump(stdout, r);
8646 } else if (!strcmp(res->dump, "dump_mempool")) {
8647 struct rte_mempool *mp;
8648 mp = rte_mempool_lookup(res->name);
8650 cmdline_printf(cl, "Cannot find mempool\n");
8653 rte_mempool_dump(stdout, mp);
8657 cmdline_parse_token_string_t cmd_dump_one_dump =
8658 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8659 "dump_ring#dump_mempool");
8661 cmdline_parse_token_string_t cmd_dump_one_name =
8662 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8664 cmdline_parse_inst_t cmd_dump_one = {
8665 .f = cmd_dump_one_parsed, /* function to call */
8666 .data = NULL, /* 2nd arg of func */
8667 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8668 .tokens = { /* token list, NULL terminated */
8669 (void *)&cmd_dump_one_dump,
8670 (void *)&cmd_dump_one_name,
8675 /* *** Add/Del syn filter *** */
8676 struct cmd_syn_filter_result {
8677 cmdline_fixed_string_t filter;
8679 cmdline_fixed_string_t ops;
8680 cmdline_fixed_string_t priority;
8681 cmdline_fixed_string_t high;
8682 cmdline_fixed_string_t queue;
8687 cmd_syn_filter_parsed(void *parsed_result,
8688 __attribute__((unused)) struct cmdline *cl,
8689 __attribute__((unused)) void *data)
8691 struct cmd_syn_filter_result *res = parsed_result;
8692 struct rte_eth_syn_filter syn_filter;
8695 ret = rte_eth_dev_filter_supported(res->port_id,
8696 RTE_ETH_FILTER_SYN);
8698 printf("syn filter is not supported on port %u.\n",
8703 memset(&syn_filter, 0, sizeof(syn_filter));
8705 if (!strcmp(res->ops, "add")) {
8706 if (!strcmp(res->high, "high"))
8707 syn_filter.hig_pri = 1;
8709 syn_filter.hig_pri = 0;
8711 syn_filter.queue = res->queue_id;
8712 ret = rte_eth_dev_filter_ctrl(res->port_id,
8717 ret = rte_eth_dev_filter_ctrl(res->port_id,
8719 RTE_ETH_FILTER_DELETE,
8723 printf("syn filter programming error: (%s)\n",
8727 cmdline_parse_token_string_t cmd_syn_filter_filter =
8728 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8729 filter, "syn_filter");
8730 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8731 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8733 cmdline_parse_token_string_t cmd_syn_filter_ops =
8734 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8736 cmdline_parse_token_string_t cmd_syn_filter_priority =
8737 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8738 priority, "priority");
8739 cmdline_parse_token_string_t cmd_syn_filter_high =
8740 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8742 cmdline_parse_token_string_t cmd_syn_filter_queue =
8743 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8745 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8746 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8749 cmdline_parse_inst_t cmd_syn_filter = {
8750 .f = cmd_syn_filter_parsed,
8752 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8753 "<queue_id>: Add/Delete syn filter",
8755 (void *)&cmd_syn_filter_filter,
8756 (void *)&cmd_syn_filter_port_id,
8757 (void *)&cmd_syn_filter_ops,
8758 (void *)&cmd_syn_filter_priority,
8759 (void *)&cmd_syn_filter_high,
8760 (void *)&cmd_syn_filter_queue,
8761 (void *)&cmd_syn_filter_queue_id,
8766 /* *** queue region set *** */
8767 struct cmd_queue_region_result {
8768 cmdline_fixed_string_t set;
8769 cmdline_fixed_string_t port;
8771 cmdline_fixed_string_t cmd;
8772 cmdline_fixed_string_t region;
8774 cmdline_fixed_string_t queue_start_index;
8776 cmdline_fixed_string_t queue_num;
8777 uint8_t queue_num_value;
8781 cmd_queue_region_parsed(void *parsed_result,
8782 __attribute__((unused)) struct cmdline *cl,
8783 __attribute__((unused)) void *data)
8785 struct cmd_queue_region_result *res = parsed_result;
8787 #ifdef RTE_LIBRTE_I40E_PMD
8788 struct rte_pmd_i40e_queue_region_conf region_conf;
8789 enum rte_pmd_i40e_queue_region_op op_type;
8792 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8795 #ifdef RTE_LIBRTE_I40E_PMD
8796 memset(®ion_conf, 0, sizeof(region_conf));
8797 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8798 region_conf.region_id = res->region_id;
8799 region_conf.queue_num = res->queue_num_value;
8800 region_conf.queue_start_index = res->queue_id;
8802 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8803 op_type, ®ion_conf);
8810 printf("function not implemented or supported\n");
8813 printf("queue region config error: (%s)\n", strerror(-ret));
8817 cmdline_parse_token_string_t cmd_queue_region_set =
8818 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8820 cmdline_parse_token_string_t cmd_queue_region_port =
8821 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8822 cmdline_parse_token_num_t cmd_queue_region_port_id =
8823 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8825 cmdline_parse_token_string_t cmd_queue_region_cmd =
8826 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8827 cmd, "queue-region");
8828 cmdline_parse_token_string_t cmd_queue_region_id =
8829 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8830 region, "region_id");
8831 cmdline_parse_token_num_t cmd_queue_region_index =
8832 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8834 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8835 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8836 queue_start_index, "queue_start_index");
8837 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8838 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8840 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8841 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8842 queue_num, "queue_num");
8843 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8844 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8845 queue_num_value, UINT8);
8847 cmdline_parse_inst_t cmd_queue_region = {
8848 .f = cmd_queue_region_parsed,
8850 .help_str = "set port <port_id> queue-region region_id <value> "
8851 "queue_start_index <value> queue_num <value>: Set a queue region",
8853 (void *)&cmd_queue_region_set,
8854 (void *)&cmd_queue_region_port,
8855 (void *)&cmd_queue_region_port_id,
8856 (void *)&cmd_queue_region_cmd,
8857 (void *)&cmd_queue_region_id,
8858 (void *)&cmd_queue_region_index,
8859 (void *)&cmd_queue_region_queue_start_index,
8860 (void *)&cmd_queue_region_queue_id,
8861 (void *)&cmd_queue_region_queue_num,
8862 (void *)&cmd_queue_region_queue_num_value,
8867 /* *** queue region and flowtype set *** */
8868 struct cmd_region_flowtype_result {
8869 cmdline_fixed_string_t set;
8870 cmdline_fixed_string_t port;
8872 cmdline_fixed_string_t cmd;
8873 cmdline_fixed_string_t region;
8875 cmdline_fixed_string_t flowtype;
8876 uint8_t flowtype_id;
8880 cmd_region_flowtype_parsed(void *parsed_result,
8881 __attribute__((unused)) struct cmdline *cl,
8882 __attribute__((unused)) void *data)
8884 struct cmd_region_flowtype_result *res = parsed_result;
8886 #ifdef RTE_LIBRTE_I40E_PMD
8887 struct rte_pmd_i40e_queue_region_conf region_conf;
8888 enum rte_pmd_i40e_queue_region_op op_type;
8891 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8894 #ifdef RTE_LIBRTE_I40E_PMD
8895 memset(®ion_conf, 0, sizeof(region_conf));
8897 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8898 region_conf.region_id = res->region_id;
8899 region_conf.hw_flowtype = res->flowtype_id;
8901 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8902 op_type, ®ion_conf);
8909 printf("function not implemented or supported\n");
8912 printf("region flowtype config error: (%s)\n", strerror(-ret));
8916 cmdline_parse_token_string_t cmd_region_flowtype_set =
8917 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8919 cmdline_parse_token_string_t cmd_region_flowtype_port =
8920 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8922 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8923 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8925 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8926 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8927 cmd, "queue-region");
8928 cmdline_parse_token_string_t cmd_region_flowtype_index =
8929 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8930 region, "region_id");
8931 cmdline_parse_token_num_t cmd_region_flowtype_id =
8932 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8934 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8935 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8936 flowtype, "flowtype");
8937 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8938 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8939 flowtype_id, UINT8);
8940 cmdline_parse_inst_t cmd_region_flowtype = {
8941 .f = cmd_region_flowtype_parsed,
8943 .help_str = "set port <port_id> queue-region region_id <value> "
8944 "flowtype <value>: Set a flowtype region index",
8946 (void *)&cmd_region_flowtype_set,
8947 (void *)&cmd_region_flowtype_port,
8948 (void *)&cmd_region_flowtype_port_index,
8949 (void *)&cmd_region_flowtype_cmd,
8950 (void *)&cmd_region_flowtype_index,
8951 (void *)&cmd_region_flowtype_id,
8952 (void *)&cmd_region_flowtype_flow_index,
8953 (void *)&cmd_region_flowtype_flow_id,
8958 /* *** User Priority (UP) to queue region (region_id) set *** */
8959 struct cmd_user_priority_region_result {
8960 cmdline_fixed_string_t set;
8961 cmdline_fixed_string_t port;
8963 cmdline_fixed_string_t cmd;
8964 cmdline_fixed_string_t user_priority;
8965 uint8_t user_priority_id;
8966 cmdline_fixed_string_t region;
8971 cmd_user_priority_region_parsed(void *parsed_result,
8972 __attribute__((unused)) struct cmdline *cl,
8973 __attribute__((unused)) void *data)
8975 struct cmd_user_priority_region_result *res = parsed_result;
8977 #ifdef RTE_LIBRTE_I40E_PMD
8978 struct rte_pmd_i40e_queue_region_conf region_conf;
8979 enum rte_pmd_i40e_queue_region_op op_type;
8982 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8985 #ifdef RTE_LIBRTE_I40E_PMD
8986 memset(®ion_conf, 0, sizeof(region_conf));
8987 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8988 region_conf.user_priority = res->user_priority_id;
8989 region_conf.region_id = res->region_id;
8991 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8992 op_type, ®ion_conf);
8999 printf("function not implemented or supported\n");
9002 printf("user_priority region config error: (%s)\n",
9007 cmdline_parse_token_string_t cmd_user_priority_region_set =
9008 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9010 cmdline_parse_token_string_t cmd_user_priority_region_port =
9011 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9013 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9014 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9016 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9017 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9018 cmd, "queue-region");
9019 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9020 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9021 user_priority, "UP");
9022 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9023 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9024 user_priority_id, UINT8);
9025 cmdline_parse_token_string_t cmd_user_priority_region_region =
9026 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9027 region, "region_id");
9028 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9029 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9032 cmdline_parse_inst_t cmd_user_priority_region = {
9033 .f = cmd_user_priority_region_parsed,
9035 .help_str = "set port <port_id> queue-region UP <value> "
9036 "region_id <value>: Set the mapping of User Priority (UP) "
9037 "to queue region (region_id) ",
9039 (void *)&cmd_user_priority_region_set,
9040 (void *)&cmd_user_priority_region_port,
9041 (void *)&cmd_user_priority_region_port_index,
9042 (void *)&cmd_user_priority_region_cmd,
9043 (void *)&cmd_user_priority_region_UP,
9044 (void *)&cmd_user_priority_region_UP_id,
9045 (void *)&cmd_user_priority_region_region,
9046 (void *)&cmd_user_priority_region_region_id,
9051 /* *** flush all queue region related configuration *** */
9052 struct cmd_flush_queue_region_result {
9053 cmdline_fixed_string_t set;
9054 cmdline_fixed_string_t port;
9056 cmdline_fixed_string_t cmd;
9057 cmdline_fixed_string_t flush;
9058 cmdline_fixed_string_t what;
9062 cmd_flush_queue_region_parsed(void *parsed_result,
9063 __attribute__((unused)) struct cmdline *cl,
9064 __attribute__((unused)) void *data)
9066 struct cmd_flush_queue_region_result *res = parsed_result;
9068 #ifdef RTE_LIBRTE_I40E_PMD
9069 struct rte_pmd_i40e_queue_region_conf region_conf;
9070 enum rte_pmd_i40e_queue_region_op op_type;
9073 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9076 #ifdef RTE_LIBRTE_I40E_PMD
9077 memset(®ion_conf, 0, sizeof(region_conf));
9079 if (strcmp(res->what, "on") == 0)
9080 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9082 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9084 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9085 op_type, ®ion_conf);
9092 printf("function not implemented or supported\n");
9095 printf("queue region config flush error: (%s)\n",
9100 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9101 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9103 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9104 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9106 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9107 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9109 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9110 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9111 cmd, "queue-region");
9112 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9113 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9115 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9116 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9119 cmdline_parse_inst_t cmd_flush_queue_region = {
9120 .f = cmd_flush_queue_region_parsed,
9122 .help_str = "set port <port_id> queue-region flush on|off"
9123 ": flush all queue region related configuration",
9125 (void *)&cmd_flush_queue_region_set,
9126 (void *)&cmd_flush_queue_region_port,
9127 (void *)&cmd_flush_queue_region_port_index,
9128 (void *)&cmd_flush_queue_region_cmd,
9129 (void *)&cmd_flush_queue_region_flush,
9130 (void *)&cmd_flush_queue_region_what,
9135 /* *** get all queue region related configuration info *** */
9136 struct cmd_show_queue_region_info {
9137 cmdline_fixed_string_t show;
9138 cmdline_fixed_string_t port;
9140 cmdline_fixed_string_t cmd;
9144 cmd_show_queue_region_info_parsed(void *parsed_result,
9145 __attribute__((unused)) struct cmdline *cl,
9146 __attribute__((unused)) void *data)
9148 struct cmd_show_queue_region_info *res = parsed_result;
9150 #ifdef RTE_LIBRTE_I40E_PMD
9151 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9152 enum rte_pmd_i40e_queue_region_op op_type;
9155 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9158 #ifdef RTE_LIBRTE_I40E_PMD
9159 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9161 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9163 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9164 op_type, &rte_pmd_regions);
9166 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9173 printf("function not implemented or supported\n");
9176 printf("queue region config info show error: (%s)\n",
9181 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9182 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9184 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9185 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9187 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9188 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9190 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9191 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9192 cmd, "queue-region");
9194 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9195 .f = cmd_show_queue_region_info_parsed,
9197 .help_str = "show port <port_id> queue-region"
9198 ": show all queue region related configuration info",
9200 (void *)&cmd_show_queue_region_info_get,
9201 (void *)&cmd_show_queue_region_info_port,
9202 (void *)&cmd_show_queue_region_info_port_index,
9203 (void *)&cmd_show_queue_region_info_cmd,
9208 /* *** ADD/REMOVE A 2tuple FILTER *** */
9209 struct cmd_2tuple_filter_result {
9210 cmdline_fixed_string_t filter;
9212 cmdline_fixed_string_t ops;
9213 cmdline_fixed_string_t dst_port;
9214 uint16_t dst_port_value;
9215 cmdline_fixed_string_t protocol;
9216 uint8_t protocol_value;
9217 cmdline_fixed_string_t mask;
9219 cmdline_fixed_string_t tcp_flags;
9220 uint8_t tcp_flags_value;
9221 cmdline_fixed_string_t priority;
9222 uint8_t priority_value;
9223 cmdline_fixed_string_t queue;
9228 cmd_2tuple_filter_parsed(void *parsed_result,
9229 __attribute__((unused)) struct cmdline *cl,
9230 __attribute__((unused)) void *data)
9232 struct rte_eth_ntuple_filter filter;
9233 struct cmd_2tuple_filter_result *res = parsed_result;
9236 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9238 printf("ntuple filter is not supported on port %u.\n",
9243 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9245 filter.flags = RTE_2TUPLE_FLAGS;
9246 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9247 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9248 filter.proto = res->protocol_value;
9249 filter.priority = res->priority_value;
9250 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9251 printf("nonzero tcp_flags is only meaningful"
9252 " when protocol is TCP.\n");
9255 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9256 printf("invalid TCP flags.\n");
9260 if (res->tcp_flags_value != 0) {
9261 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9262 filter.tcp_flags = res->tcp_flags_value;
9265 /* need convert to big endian. */
9266 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9267 filter.queue = res->queue_id;
9269 if (!strcmp(res->ops, "add"))
9270 ret = rte_eth_dev_filter_ctrl(res->port_id,
9271 RTE_ETH_FILTER_NTUPLE,
9275 ret = rte_eth_dev_filter_ctrl(res->port_id,
9276 RTE_ETH_FILTER_NTUPLE,
9277 RTE_ETH_FILTER_DELETE,
9280 printf("2tuple filter programming error: (%s)\n",
9285 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9286 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9287 filter, "2tuple_filter");
9288 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9289 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9291 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9292 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9294 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9295 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9296 dst_port, "dst_port");
9297 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9298 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9299 dst_port_value, UINT16);
9300 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9301 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9302 protocol, "protocol");
9303 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9304 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9305 protocol_value, UINT8);
9306 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9307 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9309 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9310 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9312 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9313 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9314 tcp_flags, "tcp_flags");
9315 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9316 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9317 tcp_flags_value, UINT8);
9318 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9319 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9320 priority, "priority");
9321 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9322 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9323 priority_value, UINT8);
9324 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9325 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9327 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9328 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9331 cmdline_parse_inst_t cmd_2tuple_filter = {
9332 .f = cmd_2tuple_filter_parsed,
9334 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9335 "<value> mask <value> tcp_flags <value> priority <value> queue "
9336 "<queue_id>: Add a 2tuple filter",
9338 (void *)&cmd_2tuple_filter_filter,
9339 (void *)&cmd_2tuple_filter_port_id,
9340 (void *)&cmd_2tuple_filter_ops,
9341 (void *)&cmd_2tuple_filter_dst_port,
9342 (void *)&cmd_2tuple_filter_dst_port_value,
9343 (void *)&cmd_2tuple_filter_protocol,
9344 (void *)&cmd_2tuple_filter_protocol_value,
9345 (void *)&cmd_2tuple_filter_mask,
9346 (void *)&cmd_2tuple_filter_mask_value,
9347 (void *)&cmd_2tuple_filter_tcp_flags,
9348 (void *)&cmd_2tuple_filter_tcp_flags_value,
9349 (void *)&cmd_2tuple_filter_priority,
9350 (void *)&cmd_2tuple_filter_priority_value,
9351 (void *)&cmd_2tuple_filter_queue,
9352 (void *)&cmd_2tuple_filter_queue_id,
9357 /* *** ADD/REMOVE A 5tuple FILTER *** */
9358 struct cmd_5tuple_filter_result {
9359 cmdline_fixed_string_t filter;
9361 cmdline_fixed_string_t ops;
9362 cmdline_fixed_string_t dst_ip;
9363 cmdline_ipaddr_t dst_ip_value;
9364 cmdline_fixed_string_t src_ip;
9365 cmdline_ipaddr_t src_ip_value;
9366 cmdline_fixed_string_t dst_port;
9367 uint16_t dst_port_value;
9368 cmdline_fixed_string_t src_port;
9369 uint16_t src_port_value;
9370 cmdline_fixed_string_t protocol;
9371 uint8_t protocol_value;
9372 cmdline_fixed_string_t mask;
9374 cmdline_fixed_string_t tcp_flags;
9375 uint8_t tcp_flags_value;
9376 cmdline_fixed_string_t priority;
9377 uint8_t priority_value;
9378 cmdline_fixed_string_t queue;
9383 cmd_5tuple_filter_parsed(void *parsed_result,
9384 __attribute__((unused)) struct cmdline *cl,
9385 __attribute__((unused)) void *data)
9387 struct rte_eth_ntuple_filter filter;
9388 struct cmd_5tuple_filter_result *res = parsed_result;
9391 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9393 printf("ntuple filter is not supported on port %u.\n",
9398 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9400 filter.flags = RTE_5TUPLE_FLAGS;
9401 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9402 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9403 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9404 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9405 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9406 filter.proto = res->protocol_value;
9407 filter.priority = res->priority_value;
9408 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9409 printf("nonzero tcp_flags is only meaningful"
9410 " when protocol is TCP.\n");
9413 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9414 printf("invalid TCP flags.\n");
9418 if (res->tcp_flags_value != 0) {
9419 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9420 filter.tcp_flags = res->tcp_flags_value;
9423 if (res->dst_ip_value.family == AF_INET)
9424 /* no need to convert, already big endian. */
9425 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9427 if (filter.dst_ip_mask == 0) {
9428 printf("can not support ipv6 involved compare.\n");
9434 if (res->src_ip_value.family == AF_INET)
9435 /* no need to convert, already big endian. */
9436 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9438 if (filter.src_ip_mask == 0) {
9439 printf("can not support ipv6 involved compare.\n");
9444 /* need convert to big endian. */
9445 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9446 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9447 filter.queue = res->queue_id;
9449 if (!strcmp(res->ops, "add"))
9450 ret = rte_eth_dev_filter_ctrl(res->port_id,
9451 RTE_ETH_FILTER_NTUPLE,
9455 ret = rte_eth_dev_filter_ctrl(res->port_id,
9456 RTE_ETH_FILTER_NTUPLE,
9457 RTE_ETH_FILTER_DELETE,
9460 printf("5tuple filter programming error: (%s)\n",
9464 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9465 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9466 filter, "5tuple_filter");
9467 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9468 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9470 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9471 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9473 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9474 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9476 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9477 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9479 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9480 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9482 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9483 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9485 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9486 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9487 dst_port, "dst_port");
9488 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9489 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9490 dst_port_value, UINT16);
9491 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9492 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9493 src_port, "src_port");
9494 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9495 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9496 src_port_value, UINT16);
9497 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9498 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9499 protocol, "protocol");
9500 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9501 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9502 protocol_value, UINT8);
9503 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9504 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9506 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9507 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9509 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9510 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9511 tcp_flags, "tcp_flags");
9512 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9513 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9514 tcp_flags_value, UINT8);
9515 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9516 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9517 priority, "priority");
9518 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9519 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9520 priority_value, UINT8);
9521 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9522 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9524 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9525 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9528 cmdline_parse_inst_t cmd_5tuple_filter = {
9529 .f = cmd_5tuple_filter_parsed,
9531 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9532 "src_ip <value> dst_port <value> src_port <value> "
9533 "protocol <value> mask <value> tcp_flags <value> "
9534 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9536 (void *)&cmd_5tuple_filter_filter,
9537 (void *)&cmd_5tuple_filter_port_id,
9538 (void *)&cmd_5tuple_filter_ops,
9539 (void *)&cmd_5tuple_filter_dst_ip,
9540 (void *)&cmd_5tuple_filter_dst_ip_value,
9541 (void *)&cmd_5tuple_filter_src_ip,
9542 (void *)&cmd_5tuple_filter_src_ip_value,
9543 (void *)&cmd_5tuple_filter_dst_port,
9544 (void *)&cmd_5tuple_filter_dst_port_value,
9545 (void *)&cmd_5tuple_filter_src_port,
9546 (void *)&cmd_5tuple_filter_src_port_value,
9547 (void *)&cmd_5tuple_filter_protocol,
9548 (void *)&cmd_5tuple_filter_protocol_value,
9549 (void *)&cmd_5tuple_filter_mask,
9550 (void *)&cmd_5tuple_filter_mask_value,
9551 (void *)&cmd_5tuple_filter_tcp_flags,
9552 (void *)&cmd_5tuple_filter_tcp_flags_value,
9553 (void *)&cmd_5tuple_filter_priority,
9554 (void *)&cmd_5tuple_filter_priority_value,
9555 (void *)&cmd_5tuple_filter_queue,
9556 (void *)&cmd_5tuple_filter_queue_id,
9561 /* *** ADD/REMOVE A flex FILTER *** */
9562 struct cmd_flex_filter_result {
9563 cmdline_fixed_string_t filter;
9564 cmdline_fixed_string_t ops;
9566 cmdline_fixed_string_t len;
9568 cmdline_fixed_string_t bytes;
9569 cmdline_fixed_string_t bytes_value;
9570 cmdline_fixed_string_t mask;
9571 cmdline_fixed_string_t mask_value;
9572 cmdline_fixed_string_t priority;
9573 uint8_t priority_value;
9574 cmdline_fixed_string_t queue;
9578 static int xdigit2val(unsigned char c)
9583 else if (isupper(c))
9591 cmd_flex_filter_parsed(void *parsed_result,
9592 __attribute__((unused)) struct cmdline *cl,
9593 __attribute__((unused)) void *data)
9596 struct rte_eth_flex_filter filter;
9597 struct cmd_flex_filter_result *res = parsed_result;
9598 char *bytes_ptr, *mask_ptr;
9599 uint16_t len, i, j = 0;
9604 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9605 printf("the len exceed the max length 128\n");
9608 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9609 filter.len = res->len_value;
9610 filter.priority = res->priority_value;
9611 filter.queue = res->queue_id;
9612 bytes_ptr = res->bytes_value;
9613 mask_ptr = res->mask_value;
9615 /* translate bytes string to array. */
9616 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9617 (bytes_ptr[1] == 'X')))
9619 len = strnlen(bytes_ptr, res->len_value * 2);
9620 if (len == 0 || (len % 8 != 0)) {
9621 printf("please check len and bytes input\n");
9624 for (i = 0; i < len; i++) {
9626 if (isxdigit(c) == 0) {
9627 /* invalid characters. */
9628 printf("invalid input\n");
9631 val = xdigit2val(c);
9634 filter.bytes[j] = byte;
9635 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9642 /* translate mask string to uint8_t array. */
9643 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9644 (mask_ptr[1] == 'X')))
9646 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9648 printf("invalid input\n");
9653 for (i = 0; i < len; i++) {
9655 if (isxdigit(c) == 0) {
9656 /* invalid characters. */
9657 printf("invalid input\n");
9660 val = xdigit2val(c);
9663 filter.mask[j] = byte;
9664 printf("mask[%d]:%02x ", j, filter.mask[j]);
9672 if (!strcmp(res->ops, "add"))
9673 ret = rte_eth_dev_filter_ctrl(res->port_id,
9674 RTE_ETH_FILTER_FLEXIBLE,
9678 ret = rte_eth_dev_filter_ctrl(res->port_id,
9679 RTE_ETH_FILTER_FLEXIBLE,
9680 RTE_ETH_FILTER_DELETE,
9684 printf("flex filter setting error: (%s)\n", strerror(-ret));
9687 cmdline_parse_token_string_t cmd_flex_filter_filter =
9688 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9689 filter, "flex_filter");
9690 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9691 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9693 cmdline_parse_token_string_t cmd_flex_filter_ops =
9694 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9696 cmdline_parse_token_string_t cmd_flex_filter_len =
9697 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9699 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9700 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9702 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9703 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9705 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9706 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9708 cmdline_parse_token_string_t cmd_flex_filter_mask =
9709 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9711 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9712 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9714 cmdline_parse_token_string_t cmd_flex_filter_priority =
9715 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9716 priority, "priority");
9717 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9718 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9719 priority_value, UINT8);
9720 cmdline_parse_token_string_t cmd_flex_filter_queue =
9721 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9723 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9724 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9726 cmdline_parse_inst_t cmd_flex_filter = {
9727 .f = cmd_flex_filter_parsed,
9729 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9730 "<value> mask <value> priority <value> queue <queue_id>: "
9731 "Add/Del a flex filter",
9733 (void *)&cmd_flex_filter_filter,
9734 (void *)&cmd_flex_filter_port_id,
9735 (void *)&cmd_flex_filter_ops,
9736 (void *)&cmd_flex_filter_len,
9737 (void *)&cmd_flex_filter_len_value,
9738 (void *)&cmd_flex_filter_bytes,
9739 (void *)&cmd_flex_filter_bytes_value,
9740 (void *)&cmd_flex_filter_mask,
9741 (void *)&cmd_flex_filter_mask_value,
9742 (void *)&cmd_flex_filter_priority,
9743 (void *)&cmd_flex_filter_priority_value,
9744 (void *)&cmd_flex_filter_queue,
9745 (void *)&cmd_flex_filter_queue_id,
9750 /* *** Filters Control *** */
9752 /* *** deal with ethertype filter *** */
9753 struct cmd_ethertype_filter_result {
9754 cmdline_fixed_string_t filter;
9756 cmdline_fixed_string_t ops;
9757 cmdline_fixed_string_t mac;
9758 struct ether_addr mac_addr;
9759 cmdline_fixed_string_t ethertype;
9760 uint16_t ethertype_value;
9761 cmdline_fixed_string_t drop;
9762 cmdline_fixed_string_t queue;
9766 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9767 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9768 filter, "ethertype_filter");
9769 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9770 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9772 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9773 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9775 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9776 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9777 mac, "mac_addr#mac_ignr");
9778 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9779 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9781 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9782 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9783 ethertype, "ethertype");
9784 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9785 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9786 ethertype_value, UINT16);
9787 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9788 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9790 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9791 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9793 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9794 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9798 cmd_ethertype_filter_parsed(void *parsed_result,
9799 __attribute__((unused)) struct cmdline *cl,
9800 __attribute__((unused)) void *data)
9802 struct cmd_ethertype_filter_result *res = parsed_result;
9803 struct rte_eth_ethertype_filter filter;
9806 ret = rte_eth_dev_filter_supported(res->port_id,
9807 RTE_ETH_FILTER_ETHERTYPE);
9809 printf("ethertype filter is not supported on port %u.\n",
9814 memset(&filter, 0, sizeof(filter));
9815 if (!strcmp(res->mac, "mac_addr")) {
9816 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9817 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9818 sizeof(struct ether_addr));
9820 if (!strcmp(res->drop, "drop"))
9821 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9822 filter.ether_type = res->ethertype_value;
9823 filter.queue = res->queue_id;
9825 if (!strcmp(res->ops, "add"))
9826 ret = rte_eth_dev_filter_ctrl(res->port_id,
9827 RTE_ETH_FILTER_ETHERTYPE,
9831 ret = rte_eth_dev_filter_ctrl(res->port_id,
9832 RTE_ETH_FILTER_ETHERTYPE,
9833 RTE_ETH_FILTER_DELETE,
9836 printf("ethertype filter programming error: (%s)\n",
9840 cmdline_parse_inst_t cmd_ethertype_filter = {
9841 .f = cmd_ethertype_filter_parsed,
9843 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9844 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9845 "Add or delete an ethertype filter entry",
9847 (void *)&cmd_ethertype_filter_filter,
9848 (void *)&cmd_ethertype_filter_port_id,
9849 (void *)&cmd_ethertype_filter_ops,
9850 (void *)&cmd_ethertype_filter_mac,
9851 (void *)&cmd_ethertype_filter_mac_addr,
9852 (void *)&cmd_ethertype_filter_ethertype,
9853 (void *)&cmd_ethertype_filter_ethertype_value,
9854 (void *)&cmd_ethertype_filter_drop,
9855 (void *)&cmd_ethertype_filter_queue,
9856 (void *)&cmd_ethertype_filter_queue_id,
9861 /* *** deal with flow director filter *** */
9862 struct cmd_flow_director_result {
9863 cmdline_fixed_string_t flow_director_filter;
9865 cmdline_fixed_string_t mode;
9866 cmdline_fixed_string_t mode_value;
9867 cmdline_fixed_string_t ops;
9868 cmdline_fixed_string_t flow;
9869 cmdline_fixed_string_t flow_type;
9870 cmdline_fixed_string_t ether;
9871 uint16_t ether_type;
9872 cmdline_fixed_string_t src;
9873 cmdline_ipaddr_t ip_src;
9875 cmdline_fixed_string_t dst;
9876 cmdline_ipaddr_t ip_dst;
9878 cmdline_fixed_string_t verify_tag;
9879 uint32_t verify_tag_value;
9880 cmdline_ipaddr_t tos;
9882 cmdline_ipaddr_t proto;
9883 uint8_t proto_value;
9884 cmdline_ipaddr_t ttl;
9886 cmdline_fixed_string_t vlan;
9887 uint16_t vlan_value;
9888 cmdline_fixed_string_t flexbytes;
9889 cmdline_fixed_string_t flexbytes_value;
9890 cmdline_fixed_string_t pf_vf;
9891 cmdline_fixed_string_t drop;
9892 cmdline_fixed_string_t queue;
9894 cmdline_fixed_string_t fd_id;
9895 uint32_t fd_id_value;
9896 cmdline_fixed_string_t mac;
9897 struct ether_addr mac_addr;
9898 cmdline_fixed_string_t tunnel;
9899 cmdline_fixed_string_t tunnel_type;
9900 cmdline_fixed_string_t tunnel_id;
9901 uint32_t tunnel_id_value;
9902 cmdline_fixed_string_t packet;
9907 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9910 const char *p, *p0 = q_arg;
9912 unsigned long int_fld;
9913 char *str_fld[max_num];
9918 p = strchr(p0, '(');
9922 p0 = strchr(p, ')');
9927 if (size >= sizeof(s))
9930 snprintf(s, sizeof(s), "%.*s", size, p);
9931 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9932 if (ret < 0 || ret > max_num)
9934 for (i = 0; i < ret; i++) {
9936 int_fld = strtoul(str_fld[i], &end, 0);
9937 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9939 flexbytes[i] = (uint8_t)int_fld;
9945 str2flowtype(char *string)
9948 static const struct {
9951 } flowtype_str[] = {
9952 {"raw", RTE_ETH_FLOW_RAW},
9953 {"ipv4", RTE_ETH_FLOW_IPV4},
9954 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9955 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9956 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9957 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9958 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9959 {"ipv6", RTE_ETH_FLOW_IPV6},
9960 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9961 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9962 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9963 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9964 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9965 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9968 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9969 if (!strcmp(flowtype_str[i].str, string))
9970 return flowtype_str[i].type;
9973 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9974 return (uint16_t)atoi(string);
9976 return RTE_ETH_FLOW_UNKNOWN;
9979 static enum rte_eth_fdir_tunnel_type
9980 str2fdir_tunneltype(char *string)
9984 static const struct {
9986 enum rte_eth_fdir_tunnel_type type;
9987 } tunneltype_str[] = {
9988 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9989 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9992 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9993 if (!strcmp(tunneltype_str[i].str, string))
9994 return tunneltype_str[i].type;
9996 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9999 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10001 if ((ip_addr).family == AF_INET) \
10002 (ip) = (ip_addr).addr.ipv4.s_addr; \
10004 printf("invalid parameter.\n"); \
10009 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10011 if ((ip_addr).family == AF_INET6) \
10012 rte_memcpy(&(ip), \
10013 &((ip_addr).addr.ipv6), \
10014 sizeof(struct in6_addr)); \
10016 printf("invalid parameter.\n"); \
10022 cmd_flow_director_filter_parsed(void *parsed_result,
10023 __attribute__((unused)) struct cmdline *cl,
10024 __attribute__((unused)) void *data)
10026 struct cmd_flow_director_result *res = parsed_result;
10027 struct rte_eth_fdir_filter entry;
10028 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10030 unsigned long vf_id;
10033 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10035 printf("flow director is not supported on port %u.\n",
10039 memset(flexbytes, 0, sizeof(flexbytes));
10040 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10042 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10043 if (strcmp(res->mode_value, "MAC-VLAN")) {
10044 printf("Please set mode to MAC-VLAN.\n");
10047 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10048 if (strcmp(res->mode_value, "Tunnel")) {
10049 printf("Please set mode to Tunnel.\n");
10053 if (!strcmp(res->mode_value, "raw")) {
10054 #ifdef RTE_LIBRTE_I40E_PMD
10055 struct rte_pmd_i40e_flow_type_mapping
10056 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10057 struct rte_pmd_i40e_pkt_template_conf conf;
10058 uint16_t flow_type = str2flowtype(res->flow_type);
10059 uint16_t i, port = res->port_id;
10062 memset(&conf, 0, sizeof(conf));
10064 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10065 printf("Invalid flow type specified.\n");
10068 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10072 if (mapping[flow_type].pctype == 0ULL) {
10073 printf("Invalid flow type specified.\n");
10076 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10077 if (mapping[flow_type].pctype & (1ULL << i)) {
10078 conf.input.pctype = i;
10083 conf.input.packet = open_file(res->filepath,
10084 &conf.input.length);
10085 if (!conf.input.packet)
10087 if (!strcmp(res->drop, "drop"))
10088 conf.action.behavior =
10089 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10091 conf.action.behavior =
10092 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10093 conf.action.report_status =
10094 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10095 conf.action.rx_queue = res->queue_id;
10096 conf.soft_id = res->fd_id_value;
10097 add = strcmp(res->ops, "del") ? 1 : 0;
10098 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10102 printf("flow director config error: (%s)\n",
10104 close_file(conf.input.packet);
10107 } else if (strcmp(res->mode_value, "IP")) {
10108 printf("Please set mode to IP or raw.\n");
10111 entry.input.flow_type = str2flowtype(res->flow_type);
10114 ret = parse_flexbytes(res->flexbytes_value,
10116 RTE_ETH_FDIR_MAX_FLEXLEN);
10118 printf("error: Cannot parse flexbytes input.\n");
10122 switch (entry.input.flow_type) {
10123 case RTE_ETH_FLOW_FRAG_IPV4:
10124 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10125 entry.input.flow.ip4_flow.proto = res->proto_value;
10127 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10128 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10129 IPV4_ADDR_TO_UINT(res->ip_dst,
10130 entry.input.flow.ip4_flow.dst_ip);
10131 IPV4_ADDR_TO_UINT(res->ip_src,
10132 entry.input.flow.ip4_flow.src_ip);
10133 entry.input.flow.ip4_flow.tos = res->tos_value;
10134 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10135 /* need convert to big endian. */
10136 entry.input.flow.udp4_flow.dst_port =
10137 rte_cpu_to_be_16(res->port_dst);
10138 entry.input.flow.udp4_flow.src_port =
10139 rte_cpu_to_be_16(res->port_src);
10141 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10142 IPV4_ADDR_TO_UINT(res->ip_dst,
10143 entry.input.flow.sctp4_flow.ip.dst_ip);
10144 IPV4_ADDR_TO_UINT(res->ip_src,
10145 entry.input.flow.sctp4_flow.ip.src_ip);
10146 entry.input.flow.ip4_flow.tos = res->tos_value;
10147 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10148 /* need convert to big endian. */
10149 entry.input.flow.sctp4_flow.dst_port =
10150 rte_cpu_to_be_16(res->port_dst);
10151 entry.input.flow.sctp4_flow.src_port =
10152 rte_cpu_to_be_16(res->port_src);
10153 entry.input.flow.sctp4_flow.verify_tag =
10154 rte_cpu_to_be_32(res->verify_tag_value);
10156 case RTE_ETH_FLOW_FRAG_IPV6:
10157 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10158 entry.input.flow.ipv6_flow.proto = res->proto_value;
10160 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10161 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10162 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10163 entry.input.flow.ipv6_flow.dst_ip);
10164 IPV6_ADDR_TO_ARRAY(res->ip_src,
10165 entry.input.flow.ipv6_flow.src_ip);
10166 entry.input.flow.ipv6_flow.tc = res->tos_value;
10167 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10168 /* need convert to big endian. */
10169 entry.input.flow.udp6_flow.dst_port =
10170 rte_cpu_to_be_16(res->port_dst);
10171 entry.input.flow.udp6_flow.src_port =
10172 rte_cpu_to_be_16(res->port_src);
10174 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10175 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10176 entry.input.flow.sctp6_flow.ip.dst_ip);
10177 IPV6_ADDR_TO_ARRAY(res->ip_src,
10178 entry.input.flow.sctp6_flow.ip.src_ip);
10179 entry.input.flow.ipv6_flow.tc = res->tos_value;
10180 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10181 /* need convert to big endian. */
10182 entry.input.flow.sctp6_flow.dst_port =
10183 rte_cpu_to_be_16(res->port_dst);
10184 entry.input.flow.sctp6_flow.src_port =
10185 rte_cpu_to_be_16(res->port_src);
10186 entry.input.flow.sctp6_flow.verify_tag =
10187 rte_cpu_to_be_32(res->verify_tag_value);
10189 case RTE_ETH_FLOW_L2_PAYLOAD:
10190 entry.input.flow.l2_flow.ether_type =
10191 rte_cpu_to_be_16(res->ether_type);
10197 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10198 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10200 sizeof(struct ether_addr));
10202 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10203 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10205 sizeof(struct ether_addr));
10206 entry.input.flow.tunnel_flow.tunnel_type =
10207 str2fdir_tunneltype(res->tunnel_type);
10208 entry.input.flow.tunnel_flow.tunnel_id =
10209 rte_cpu_to_be_32(res->tunnel_id_value);
10212 rte_memcpy(entry.input.flow_ext.flexbytes,
10214 RTE_ETH_FDIR_MAX_FLEXLEN);
10216 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10218 entry.action.flex_off = 0; /*use 0 by default */
10219 if (!strcmp(res->drop, "drop"))
10220 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10222 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10224 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10225 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10226 if (!strcmp(res->pf_vf, "pf"))
10227 entry.input.flow_ext.is_vf = 0;
10228 else if (!strncmp(res->pf_vf, "vf", 2)) {
10229 struct rte_eth_dev_info dev_info;
10231 memset(&dev_info, 0, sizeof(dev_info));
10232 rte_eth_dev_info_get(res->port_id, &dev_info);
10234 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10235 if (errno != 0 || *end != '\0' ||
10236 vf_id >= dev_info.max_vfs) {
10237 printf("invalid parameter %s.\n", res->pf_vf);
10240 entry.input.flow_ext.is_vf = 1;
10241 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10243 printf("invalid parameter %s.\n", res->pf_vf);
10248 /* set to report FD ID by default */
10249 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10250 entry.action.rx_queue = res->queue_id;
10251 entry.soft_id = res->fd_id_value;
10252 if (!strcmp(res->ops, "add"))
10253 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10254 RTE_ETH_FILTER_ADD, &entry);
10255 else if (!strcmp(res->ops, "del"))
10256 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10257 RTE_ETH_FILTER_DELETE, &entry);
10259 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10260 RTE_ETH_FILTER_UPDATE, &entry);
10262 printf("flow director programming error: (%s)\n",
10266 cmdline_parse_token_string_t cmd_flow_director_filter =
10267 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10268 flow_director_filter, "flow_director_filter");
10269 cmdline_parse_token_num_t cmd_flow_director_port_id =
10270 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10272 cmdline_parse_token_string_t cmd_flow_director_ops =
10273 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10274 ops, "add#del#update");
10275 cmdline_parse_token_string_t cmd_flow_director_flow =
10276 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10278 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10279 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10281 cmdline_parse_token_string_t cmd_flow_director_ether =
10282 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10284 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10285 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10286 ether_type, UINT16);
10287 cmdline_parse_token_string_t cmd_flow_director_src =
10288 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10290 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10291 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10293 cmdline_parse_token_num_t cmd_flow_director_port_src =
10294 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10296 cmdline_parse_token_string_t cmd_flow_director_dst =
10297 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10299 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10300 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10302 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10303 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10305 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10306 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10307 verify_tag, "verify_tag");
10308 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10309 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10310 verify_tag_value, UINT32);
10311 cmdline_parse_token_string_t cmd_flow_director_tos =
10312 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10314 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10315 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10317 cmdline_parse_token_string_t cmd_flow_director_proto =
10318 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10320 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10321 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10322 proto_value, UINT8);
10323 cmdline_parse_token_string_t cmd_flow_director_ttl =
10324 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10326 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10327 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10329 cmdline_parse_token_string_t cmd_flow_director_vlan =
10330 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10332 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10333 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10334 vlan_value, UINT16);
10335 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10336 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10337 flexbytes, "flexbytes");
10338 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10340 flexbytes_value, NULL);
10341 cmdline_parse_token_string_t cmd_flow_director_drop =
10342 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10344 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10345 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10347 cmdline_parse_token_string_t cmd_flow_director_queue =
10348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10350 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10351 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10353 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10354 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10356 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10357 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10358 fd_id_value, UINT32);
10360 cmdline_parse_token_string_t cmd_flow_director_mode =
10361 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10363 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10364 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10366 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10367 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10368 mode_value, "MAC-VLAN");
10369 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10370 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10371 mode_value, "Tunnel");
10372 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10373 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10374 mode_value, "raw");
10375 cmdline_parse_token_string_t cmd_flow_director_mac =
10376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10378 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10379 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10381 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10384 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10385 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10386 tunnel_type, "NVGRE#VxLAN");
10387 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10389 tunnel_id, "tunnel-id");
10390 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10391 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10392 tunnel_id_value, UINT32);
10393 cmdline_parse_token_string_t cmd_flow_director_packet =
10394 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10396 cmdline_parse_token_string_t cmd_flow_director_filepath =
10397 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10400 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10401 .f = cmd_flow_director_filter_parsed,
10403 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10404 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10405 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10406 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10407 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10408 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10409 "fd_id <fd_id_value>: "
10410 "Add or delete an ip flow director entry on NIC",
10412 (void *)&cmd_flow_director_filter,
10413 (void *)&cmd_flow_director_port_id,
10414 (void *)&cmd_flow_director_mode,
10415 (void *)&cmd_flow_director_mode_ip,
10416 (void *)&cmd_flow_director_ops,
10417 (void *)&cmd_flow_director_flow,
10418 (void *)&cmd_flow_director_flow_type,
10419 (void *)&cmd_flow_director_src,
10420 (void *)&cmd_flow_director_ip_src,
10421 (void *)&cmd_flow_director_dst,
10422 (void *)&cmd_flow_director_ip_dst,
10423 (void *)&cmd_flow_director_tos,
10424 (void *)&cmd_flow_director_tos_value,
10425 (void *)&cmd_flow_director_proto,
10426 (void *)&cmd_flow_director_proto_value,
10427 (void *)&cmd_flow_director_ttl,
10428 (void *)&cmd_flow_director_ttl_value,
10429 (void *)&cmd_flow_director_vlan,
10430 (void *)&cmd_flow_director_vlan_value,
10431 (void *)&cmd_flow_director_flexbytes,
10432 (void *)&cmd_flow_director_flexbytes_value,
10433 (void *)&cmd_flow_director_drop,
10434 (void *)&cmd_flow_director_pf_vf,
10435 (void *)&cmd_flow_director_queue,
10436 (void *)&cmd_flow_director_queue_id,
10437 (void *)&cmd_flow_director_fd_id,
10438 (void *)&cmd_flow_director_fd_id_value,
10443 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10444 .f = cmd_flow_director_filter_parsed,
10446 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10447 "director entry on NIC",
10449 (void *)&cmd_flow_director_filter,
10450 (void *)&cmd_flow_director_port_id,
10451 (void *)&cmd_flow_director_mode,
10452 (void *)&cmd_flow_director_mode_ip,
10453 (void *)&cmd_flow_director_ops,
10454 (void *)&cmd_flow_director_flow,
10455 (void *)&cmd_flow_director_flow_type,
10456 (void *)&cmd_flow_director_src,
10457 (void *)&cmd_flow_director_ip_src,
10458 (void *)&cmd_flow_director_port_src,
10459 (void *)&cmd_flow_director_dst,
10460 (void *)&cmd_flow_director_ip_dst,
10461 (void *)&cmd_flow_director_port_dst,
10462 (void *)&cmd_flow_director_tos,
10463 (void *)&cmd_flow_director_tos_value,
10464 (void *)&cmd_flow_director_ttl,
10465 (void *)&cmd_flow_director_ttl_value,
10466 (void *)&cmd_flow_director_vlan,
10467 (void *)&cmd_flow_director_vlan_value,
10468 (void *)&cmd_flow_director_flexbytes,
10469 (void *)&cmd_flow_director_flexbytes_value,
10470 (void *)&cmd_flow_director_drop,
10471 (void *)&cmd_flow_director_pf_vf,
10472 (void *)&cmd_flow_director_queue,
10473 (void *)&cmd_flow_director_queue_id,
10474 (void *)&cmd_flow_director_fd_id,
10475 (void *)&cmd_flow_director_fd_id_value,
10480 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10481 .f = cmd_flow_director_filter_parsed,
10483 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10484 "director entry on NIC",
10486 (void *)&cmd_flow_director_filter,
10487 (void *)&cmd_flow_director_port_id,
10488 (void *)&cmd_flow_director_mode,
10489 (void *)&cmd_flow_director_mode_ip,
10490 (void *)&cmd_flow_director_ops,
10491 (void *)&cmd_flow_director_flow,
10492 (void *)&cmd_flow_director_flow_type,
10493 (void *)&cmd_flow_director_src,
10494 (void *)&cmd_flow_director_ip_src,
10495 (void *)&cmd_flow_director_port_dst,
10496 (void *)&cmd_flow_director_dst,
10497 (void *)&cmd_flow_director_ip_dst,
10498 (void *)&cmd_flow_director_port_dst,
10499 (void *)&cmd_flow_director_verify_tag,
10500 (void *)&cmd_flow_director_verify_tag_value,
10501 (void *)&cmd_flow_director_tos,
10502 (void *)&cmd_flow_director_tos_value,
10503 (void *)&cmd_flow_director_ttl,
10504 (void *)&cmd_flow_director_ttl_value,
10505 (void *)&cmd_flow_director_vlan,
10506 (void *)&cmd_flow_director_vlan_value,
10507 (void *)&cmd_flow_director_flexbytes,
10508 (void *)&cmd_flow_director_flexbytes_value,
10509 (void *)&cmd_flow_director_drop,
10510 (void *)&cmd_flow_director_pf_vf,
10511 (void *)&cmd_flow_director_queue,
10512 (void *)&cmd_flow_director_queue_id,
10513 (void *)&cmd_flow_director_fd_id,
10514 (void *)&cmd_flow_director_fd_id_value,
10519 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10520 .f = cmd_flow_director_filter_parsed,
10522 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10523 "director entry on NIC",
10525 (void *)&cmd_flow_director_filter,
10526 (void *)&cmd_flow_director_port_id,
10527 (void *)&cmd_flow_director_mode,
10528 (void *)&cmd_flow_director_mode_ip,
10529 (void *)&cmd_flow_director_ops,
10530 (void *)&cmd_flow_director_flow,
10531 (void *)&cmd_flow_director_flow_type,
10532 (void *)&cmd_flow_director_ether,
10533 (void *)&cmd_flow_director_ether_type,
10534 (void *)&cmd_flow_director_flexbytes,
10535 (void *)&cmd_flow_director_flexbytes_value,
10536 (void *)&cmd_flow_director_drop,
10537 (void *)&cmd_flow_director_pf_vf,
10538 (void *)&cmd_flow_director_queue,
10539 (void *)&cmd_flow_director_queue_id,
10540 (void *)&cmd_flow_director_fd_id,
10541 (void *)&cmd_flow_director_fd_id_value,
10546 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10547 .f = cmd_flow_director_filter_parsed,
10549 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10550 "director entry on NIC",
10552 (void *)&cmd_flow_director_filter,
10553 (void *)&cmd_flow_director_port_id,
10554 (void *)&cmd_flow_director_mode,
10555 (void *)&cmd_flow_director_mode_mac_vlan,
10556 (void *)&cmd_flow_director_ops,
10557 (void *)&cmd_flow_director_mac,
10558 (void *)&cmd_flow_director_mac_addr,
10559 (void *)&cmd_flow_director_vlan,
10560 (void *)&cmd_flow_director_vlan_value,
10561 (void *)&cmd_flow_director_flexbytes,
10562 (void *)&cmd_flow_director_flexbytes_value,
10563 (void *)&cmd_flow_director_drop,
10564 (void *)&cmd_flow_director_queue,
10565 (void *)&cmd_flow_director_queue_id,
10566 (void *)&cmd_flow_director_fd_id,
10567 (void *)&cmd_flow_director_fd_id_value,
10572 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10573 .f = cmd_flow_director_filter_parsed,
10575 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10576 "director entry on NIC",
10578 (void *)&cmd_flow_director_filter,
10579 (void *)&cmd_flow_director_port_id,
10580 (void *)&cmd_flow_director_mode,
10581 (void *)&cmd_flow_director_mode_tunnel,
10582 (void *)&cmd_flow_director_ops,
10583 (void *)&cmd_flow_director_mac,
10584 (void *)&cmd_flow_director_mac_addr,
10585 (void *)&cmd_flow_director_vlan,
10586 (void *)&cmd_flow_director_vlan_value,
10587 (void *)&cmd_flow_director_tunnel,
10588 (void *)&cmd_flow_director_tunnel_type,
10589 (void *)&cmd_flow_director_tunnel_id,
10590 (void *)&cmd_flow_director_tunnel_id_value,
10591 (void *)&cmd_flow_director_flexbytes,
10592 (void *)&cmd_flow_director_flexbytes_value,
10593 (void *)&cmd_flow_director_drop,
10594 (void *)&cmd_flow_director_queue,
10595 (void *)&cmd_flow_director_queue_id,
10596 (void *)&cmd_flow_director_fd_id,
10597 (void *)&cmd_flow_director_fd_id_value,
10602 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10603 .f = cmd_flow_director_filter_parsed,
10605 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10606 "director entry on NIC",
10608 (void *)&cmd_flow_director_filter,
10609 (void *)&cmd_flow_director_port_id,
10610 (void *)&cmd_flow_director_mode,
10611 (void *)&cmd_flow_director_mode_raw,
10612 (void *)&cmd_flow_director_ops,
10613 (void *)&cmd_flow_director_flow,
10614 (void *)&cmd_flow_director_flow_type,
10615 (void *)&cmd_flow_director_drop,
10616 (void *)&cmd_flow_director_queue,
10617 (void *)&cmd_flow_director_queue_id,
10618 (void *)&cmd_flow_director_fd_id,
10619 (void *)&cmd_flow_director_fd_id_value,
10620 (void *)&cmd_flow_director_packet,
10621 (void *)&cmd_flow_director_filepath,
10626 struct cmd_flush_flow_director_result {
10627 cmdline_fixed_string_t flush_flow_director;
10631 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10632 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10633 flush_flow_director, "flush_flow_director");
10634 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10635 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10639 cmd_flush_flow_director_parsed(void *parsed_result,
10640 __attribute__((unused)) struct cmdline *cl,
10641 __attribute__((unused)) void *data)
10643 struct cmd_flow_director_result *res = parsed_result;
10646 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10648 printf("flow director is not supported on port %u.\n",
10653 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10654 RTE_ETH_FILTER_FLUSH, NULL);
10656 printf("flow director table flushing error: (%s)\n",
10660 cmdline_parse_inst_t cmd_flush_flow_director = {
10661 .f = cmd_flush_flow_director_parsed,
10663 .help_str = "flush_flow_director <port_id>: "
10664 "Flush all flow director entries of a device on NIC",
10666 (void *)&cmd_flush_flow_director_flush,
10667 (void *)&cmd_flush_flow_director_port_id,
10672 /* *** deal with flow director mask *** */
10673 struct cmd_flow_director_mask_result {
10674 cmdline_fixed_string_t flow_director_mask;
10676 cmdline_fixed_string_t mode;
10677 cmdline_fixed_string_t mode_value;
10678 cmdline_fixed_string_t vlan;
10679 uint16_t vlan_mask;
10680 cmdline_fixed_string_t src_mask;
10681 cmdline_ipaddr_t ipv4_src;
10682 cmdline_ipaddr_t ipv6_src;
10684 cmdline_fixed_string_t dst_mask;
10685 cmdline_ipaddr_t ipv4_dst;
10686 cmdline_ipaddr_t ipv6_dst;
10688 cmdline_fixed_string_t mac;
10689 uint8_t mac_addr_byte_mask;
10690 cmdline_fixed_string_t tunnel_id;
10691 uint32_t tunnel_id_mask;
10692 cmdline_fixed_string_t tunnel_type;
10693 uint8_t tunnel_type_mask;
10697 cmd_flow_director_mask_parsed(void *parsed_result,
10698 __attribute__((unused)) struct cmdline *cl,
10699 __attribute__((unused)) void *data)
10701 struct cmd_flow_director_mask_result *res = parsed_result;
10702 struct rte_eth_fdir_masks *mask;
10703 struct rte_port *port;
10705 if (res->port_id > nb_ports) {
10706 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10710 port = &ports[res->port_id];
10711 /** Check if the port is not started **/
10712 if (port->port_status != RTE_PORT_STOPPED) {
10713 printf("Please stop port %d first\n", res->port_id);
10717 mask = &port->dev_conf.fdir_conf.mask;
10719 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10720 if (strcmp(res->mode_value, "MAC-VLAN")) {
10721 printf("Please set mode to MAC-VLAN.\n");
10725 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10726 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10727 if (strcmp(res->mode_value, "Tunnel")) {
10728 printf("Please set mode to Tunnel.\n");
10732 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10733 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10734 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10735 mask->tunnel_type_mask = res->tunnel_type_mask;
10737 if (strcmp(res->mode_value, "IP")) {
10738 printf("Please set mode to IP.\n");
10742 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10743 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10744 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10745 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10746 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10747 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10748 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10751 cmd_reconfig_device_queue(res->port_id, 1, 1);
10754 cmdline_parse_token_string_t cmd_flow_director_mask =
10755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10756 flow_director_mask, "flow_director_mask");
10757 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10758 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10760 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10761 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10763 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10764 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10765 vlan_mask, UINT16);
10766 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10767 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10768 src_mask, "src_mask");
10769 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10770 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10772 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10773 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10775 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10776 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10778 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10779 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10780 dst_mask, "dst_mask");
10781 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10782 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10784 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10785 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10787 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10788 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10791 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10792 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10794 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10795 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10797 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10798 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10799 mode_value, "MAC-VLAN");
10800 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10801 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10802 mode_value, "Tunnel");
10803 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10804 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10806 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10807 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10808 mac_addr_byte_mask, UINT8);
10809 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10810 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10811 tunnel_type, "tunnel-type");
10812 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10813 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10814 tunnel_type_mask, UINT8);
10815 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10816 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10817 tunnel_id, "tunnel-id");
10818 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10819 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10820 tunnel_id_mask, UINT32);
10822 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10823 .f = cmd_flow_director_mask_parsed,
10825 .help_str = "flow_director_mask ... : "
10826 "Set IP mode flow director's mask on NIC",
10828 (void *)&cmd_flow_director_mask,
10829 (void *)&cmd_flow_director_mask_port_id,
10830 (void *)&cmd_flow_director_mask_mode,
10831 (void *)&cmd_flow_director_mask_mode_ip,
10832 (void *)&cmd_flow_director_mask_vlan,
10833 (void *)&cmd_flow_director_mask_vlan_value,
10834 (void *)&cmd_flow_director_mask_src,
10835 (void *)&cmd_flow_director_mask_ipv4_src,
10836 (void *)&cmd_flow_director_mask_ipv6_src,
10837 (void *)&cmd_flow_director_mask_port_src,
10838 (void *)&cmd_flow_director_mask_dst,
10839 (void *)&cmd_flow_director_mask_ipv4_dst,
10840 (void *)&cmd_flow_director_mask_ipv6_dst,
10841 (void *)&cmd_flow_director_mask_port_dst,
10846 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10847 .f = cmd_flow_director_mask_parsed,
10849 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10850 "flow director's mask on NIC",
10852 (void *)&cmd_flow_director_mask,
10853 (void *)&cmd_flow_director_mask_port_id,
10854 (void *)&cmd_flow_director_mask_mode,
10855 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10856 (void *)&cmd_flow_director_mask_vlan,
10857 (void *)&cmd_flow_director_mask_vlan_value,
10862 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10863 .f = cmd_flow_director_mask_parsed,
10865 .help_str = "flow_director_mask ... : Set tunnel mode "
10866 "flow director's mask on NIC",
10868 (void *)&cmd_flow_director_mask,
10869 (void *)&cmd_flow_director_mask_port_id,
10870 (void *)&cmd_flow_director_mask_mode,
10871 (void *)&cmd_flow_director_mask_mode_tunnel,
10872 (void *)&cmd_flow_director_mask_vlan,
10873 (void *)&cmd_flow_director_mask_vlan_value,
10874 (void *)&cmd_flow_director_mask_mac,
10875 (void *)&cmd_flow_director_mask_mac_value,
10876 (void *)&cmd_flow_director_mask_tunnel_type,
10877 (void *)&cmd_flow_director_mask_tunnel_type_value,
10878 (void *)&cmd_flow_director_mask_tunnel_id,
10879 (void *)&cmd_flow_director_mask_tunnel_id_value,
10884 /* *** deal with flow director mask on flexible payload *** */
10885 struct cmd_flow_director_flex_mask_result {
10886 cmdline_fixed_string_t flow_director_flexmask;
10888 cmdline_fixed_string_t flow;
10889 cmdline_fixed_string_t flow_type;
10890 cmdline_fixed_string_t mask;
10894 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10895 __attribute__((unused)) struct cmdline *cl,
10896 __attribute__((unused)) void *data)
10898 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10899 struct rte_eth_fdir_info fdir_info;
10900 struct rte_eth_fdir_flex_mask flex_mask;
10901 struct rte_port *port;
10902 uint32_t flow_type_mask;
10906 if (res->port_id > nb_ports) {
10907 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10911 port = &ports[res->port_id];
10912 /** Check if the port is not started **/
10913 if (port->port_status != RTE_PORT_STOPPED) {
10914 printf("Please stop port %d first\n", res->port_id);
10918 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10919 ret = parse_flexbytes(res->mask,
10921 RTE_ETH_FDIR_MAX_FLEXLEN);
10923 printf("error: Cannot parse mask input.\n");
10927 memset(&fdir_info, 0, sizeof(fdir_info));
10928 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10929 RTE_ETH_FILTER_INFO, &fdir_info);
10931 printf("Cannot get FDir filter info\n");
10935 if (!strcmp(res->flow_type, "none")) {
10936 /* means don't specify the flow type */
10937 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10938 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10939 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10940 0, sizeof(struct rte_eth_fdir_flex_mask));
10941 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10942 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10944 sizeof(struct rte_eth_fdir_flex_mask));
10945 cmd_reconfig_device_queue(res->port_id, 1, 1);
10948 flow_type_mask = fdir_info.flow_types_mask[0];
10949 if (!strcmp(res->flow_type, "all")) {
10950 if (!flow_type_mask) {
10951 printf("No flow type supported\n");
10954 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10955 if (flow_type_mask & (1 << i)) {
10956 flex_mask.flow_type = i;
10957 fdir_set_flex_mask(res->port_id, &flex_mask);
10960 cmd_reconfig_device_queue(res->port_id, 1, 1);
10963 flex_mask.flow_type = str2flowtype(res->flow_type);
10964 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10965 printf("Flow type %s not supported on port %d\n",
10966 res->flow_type, res->port_id);
10969 fdir_set_flex_mask(res->port_id, &flex_mask);
10970 cmd_reconfig_device_queue(res->port_id, 1, 1);
10973 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10974 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10975 flow_director_flexmask,
10976 "flow_director_flex_mask");
10977 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10978 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10980 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10981 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10983 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10984 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10985 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10986 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10987 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10988 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10991 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10992 .f = cmd_flow_director_flex_mask_parsed,
10994 .help_str = "flow_director_flex_mask ... : "
10995 "Set flow director's flex mask on NIC",
10997 (void *)&cmd_flow_director_flexmask,
10998 (void *)&cmd_flow_director_flexmask_port_id,
10999 (void *)&cmd_flow_director_flexmask_flow,
11000 (void *)&cmd_flow_director_flexmask_flow_type,
11001 (void *)&cmd_flow_director_flexmask_mask,
11006 /* *** deal with flow director flexible payload configuration *** */
11007 struct cmd_flow_director_flexpayload_result {
11008 cmdline_fixed_string_t flow_director_flexpayload;
11010 cmdline_fixed_string_t payload_layer;
11011 cmdline_fixed_string_t payload_cfg;
11015 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11018 const char *p, *p0 = q_arg;
11020 unsigned long int_fld;
11021 char *str_fld[max_num];
11026 p = strchr(p0, '(');
11030 p0 = strchr(p, ')');
11035 if (size >= sizeof(s))
11038 snprintf(s, sizeof(s), "%.*s", size, p);
11039 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11040 if (ret < 0 || ret > max_num)
11042 for (i = 0; i < ret; i++) {
11044 int_fld = strtoul(str_fld[i], &end, 0);
11045 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11047 offsets[i] = (uint16_t)int_fld;
11053 cmd_flow_director_flxpld_parsed(void *parsed_result,
11054 __attribute__((unused)) struct cmdline *cl,
11055 __attribute__((unused)) void *data)
11057 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11058 struct rte_eth_flex_payload_cfg flex_cfg;
11059 struct rte_port *port;
11062 if (res->port_id > nb_ports) {
11063 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
11067 port = &ports[res->port_id];
11068 /** Check if the port is not started **/
11069 if (port->port_status != RTE_PORT_STOPPED) {
11070 printf("Please stop port %d first\n", res->port_id);
11074 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11076 if (!strcmp(res->payload_layer, "raw"))
11077 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11078 else if (!strcmp(res->payload_layer, "l2"))
11079 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11080 else if (!strcmp(res->payload_layer, "l3"))
11081 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11082 else if (!strcmp(res->payload_layer, "l4"))
11083 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11085 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11086 RTE_ETH_FDIR_MAX_FLEXLEN);
11088 printf("error: Cannot parse flex payload input.\n");
11092 fdir_set_flex_payload(res->port_id, &flex_cfg);
11093 cmd_reconfig_device_queue(res->port_id, 1, 1);
11096 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11097 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11098 flow_director_flexpayload,
11099 "flow_director_flex_payload");
11100 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11101 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11103 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11104 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11105 payload_layer, "raw#l2#l3#l4");
11106 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11107 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11108 payload_cfg, NULL);
11110 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11111 .f = cmd_flow_director_flxpld_parsed,
11113 .help_str = "flow_director_flexpayload ... : "
11114 "Set flow director's flex payload on NIC",
11116 (void *)&cmd_flow_director_flexpayload,
11117 (void *)&cmd_flow_director_flexpayload_port_id,
11118 (void *)&cmd_flow_director_flexpayload_payload_layer,
11119 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11124 /* Generic flow interface command. */
11125 extern cmdline_parse_inst_t cmd_flow;
11127 /* *** Classification Filters Control *** */
11128 /* *** Get symmetric hash enable per port *** */
11129 struct cmd_get_sym_hash_ena_per_port_result {
11130 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11135 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11136 __rte_unused struct cmdline *cl,
11137 __rte_unused void *data)
11139 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11140 struct rte_eth_hash_filter_info info;
11143 if (rte_eth_dev_filter_supported(res->port_id,
11144 RTE_ETH_FILTER_HASH) < 0) {
11145 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11150 memset(&info, 0, sizeof(info));
11151 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11152 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11153 RTE_ETH_FILTER_GET, &info);
11156 printf("Cannot get symmetric hash enable per port "
11157 "on port %u\n", res->port_id);
11161 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11162 "enabled" : "disabled", res->port_id);
11165 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11166 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11167 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11168 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11169 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11172 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11173 .f = cmd_get_sym_hash_per_port_parsed,
11175 .help_str = "get_sym_hash_ena_per_port <port_id>",
11177 (void *)&cmd_get_sym_hash_ena_per_port_all,
11178 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11183 /* *** Set symmetric hash enable per port *** */
11184 struct cmd_set_sym_hash_ena_per_port_result {
11185 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11186 cmdline_fixed_string_t enable;
11191 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11192 __rte_unused struct cmdline *cl,
11193 __rte_unused void *data)
11195 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11196 struct rte_eth_hash_filter_info info;
11199 if (rte_eth_dev_filter_supported(res->port_id,
11200 RTE_ETH_FILTER_HASH) < 0) {
11201 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11206 memset(&info, 0, sizeof(info));
11207 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11208 if (!strcmp(res->enable, "enable"))
11209 info.info.enable = 1;
11210 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11211 RTE_ETH_FILTER_SET, &info);
11213 printf("Cannot set symmetric hash enable per port on "
11214 "port %u\n", res->port_id);
11217 printf("Symmetric hash has been set to %s on port %u\n",
11218 res->enable, res->port_id);
11221 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11222 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11223 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11224 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11225 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11227 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11228 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11229 enable, "enable#disable");
11231 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11232 .f = cmd_set_sym_hash_per_port_parsed,
11234 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11236 (void *)&cmd_set_sym_hash_ena_per_port_all,
11237 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11238 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11243 /* Get global config of hash function */
11244 struct cmd_get_hash_global_config_result {
11245 cmdline_fixed_string_t get_hash_global_config;
11250 flowtype_to_str(uint16_t ftype)
11256 } ftype_table[] = {
11257 {"ipv4", RTE_ETH_FLOW_IPV4},
11258 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11259 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11260 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11261 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11262 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11263 {"ipv6", RTE_ETH_FLOW_IPV6},
11264 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11265 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11266 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11267 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11268 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11269 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11270 {"port", RTE_ETH_FLOW_PORT},
11271 {"vxlan", RTE_ETH_FLOW_VXLAN},
11272 {"geneve", RTE_ETH_FLOW_GENEVE},
11273 {"nvgre", RTE_ETH_FLOW_NVGRE},
11276 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11277 if (ftype_table[i].ftype == ftype)
11278 return ftype_table[i].str;
11285 cmd_get_hash_global_config_parsed(void *parsed_result,
11286 __rte_unused struct cmdline *cl,
11287 __rte_unused void *data)
11289 struct cmd_get_hash_global_config_result *res = parsed_result;
11290 struct rte_eth_hash_filter_info info;
11291 uint32_t idx, offset;
11296 if (rte_eth_dev_filter_supported(res->port_id,
11297 RTE_ETH_FILTER_HASH) < 0) {
11298 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11303 memset(&info, 0, sizeof(info));
11304 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11305 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11306 RTE_ETH_FILTER_GET, &info);
11308 printf("Cannot get hash global configurations by port %d\n",
11313 switch (info.info.global_conf.hash_func) {
11314 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11315 printf("Hash function is Toeplitz\n");
11317 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11318 printf("Hash function is Simple XOR\n");
11321 printf("Unknown hash function\n");
11325 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11326 idx = i / UINT32_BIT;
11327 offset = i % UINT32_BIT;
11328 if (!(info.info.global_conf.valid_bit_mask[idx] &
11331 str = flowtype_to_str(i);
11334 printf("Symmetric hash is %s globally for flow type %s "
11336 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11337 (1UL << offset)) ? "enabled" : "disabled"), str,
11342 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11343 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11344 get_hash_global_config, "get_hash_global_config");
11345 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11346 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11349 cmdline_parse_inst_t cmd_get_hash_global_config = {
11350 .f = cmd_get_hash_global_config_parsed,
11352 .help_str = "get_hash_global_config <port_id>",
11354 (void *)&cmd_get_hash_global_config_all,
11355 (void *)&cmd_get_hash_global_config_port_id,
11360 /* Set global config of hash function */
11361 struct cmd_set_hash_global_config_result {
11362 cmdline_fixed_string_t set_hash_global_config;
11364 cmdline_fixed_string_t hash_func;
11365 cmdline_fixed_string_t flow_type;
11366 cmdline_fixed_string_t enable;
11370 cmd_set_hash_global_config_parsed(void *parsed_result,
11371 __rte_unused struct cmdline *cl,
11372 __rte_unused void *data)
11374 struct cmd_set_hash_global_config_result *res = parsed_result;
11375 struct rte_eth_hash_filter_info info;
11376 uint32_t ftype, idx, offset;
11379 if (rte_eth_dev_filter_supported(res->port_id,
11380 RTE_ETH_FILTER_HASH) < 0) {
11381 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11385 memset(&info, 0, sizeof(info));
11386 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11387 if (!strcmp(res->hash_func, "toeplitz"))
11388 info.info.global_conf.hash_func =
11389 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11390 else if (!strcmp(res->hash_func, "simple_xor"))
11391 info.info.global_conf.hash_func =
11392 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11393 else if (!strcmp(res->hash_func, "default"))
11394 info.info.global_conf.hash_func =
11395 RTE_ETH_HASH_FUNCTION_DEFAULT;
11397 ftype = str2flowtype(res->flow_type);
11398 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11399 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11400 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11401 if (!strcmp(res->enable, "enable"))
11402 info.info.global_conf.sym_hash_enable_mask[idx] |=
11404 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11405 RTE_ETH_FILTER_SET, &info);
11407 printf("Cannot set global hash configurations by port %d\n",
11410 printf("Global hash configurations have been set "
11411 "succcessfully by port %d\n", res->port_id);
11414 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11415 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11416 set_hash_global_config, "set_hash_global_config");
11417 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11418 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11420 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11421 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11422 hash_func, "toeplitz#simple_xor#default");
11423 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11424 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11426 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11427 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11428 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11429 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11430 enable, "enable#disable");
11432 cmdline_parse_inst_t cmd_set_hash_global_config = {
11433 .f = cmd_set_hash_global_config_parsed,
11435 .help_str = "set_hash_global_config <port_id> "
11436 "toeplitz|simple_xor|default "
11437 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11438 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11439 "l2_payload enable|disable",
11441 (void *)&cmd_set_hash_global_config_all,
11442 (void *)&cmd_set_hash_global_config_port_id,
11443 (void *)&cmd_set_hash_global_config_hash_func,
11444 (void *)&cmd_set_hash_global_config_flow_type,
11445 (void *)&cmd_set_hash_global_config_enable,
11450 /* Set hash input set */
11451 struct cmd_set_hash_input_set_result {
11452 cmdline_fixed_string_t set_hash_input_set;
11454 cmdline_fixed_string_t flow_type;
11455 cmdline_fixed_string_t inset_field;
11456 cmdline_fixed_string_t select;
11459 static enum rte_eth_input_set_field
11460 str2inset(char *string)
11464 static const struct {
11466 enum rte_eth_input_set_field inset;
11467 } inset_table[] = {
11468 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11469 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11470 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11471 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11472 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11473 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11474 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11475 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11476 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11477 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11478 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11479 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11480 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11481 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11482 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11483 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11484 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11485 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11486 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11487 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11488 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11489 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11490 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11491 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11492 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11493 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11494 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11495 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11496 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11497 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11498 {"none", RTE_ETH_INPUT_SET_NONE},
11501 for (i = 0; i < RTE_DIM(inset_table); i++) {
11502 if (!strcmp(string, inset_table[i].str))
11503 return inset_table[i].inset;
11506 return RTE_ETH_INPUT_SET_UNKNOWN;
11510 cmd_set_hash_input_set_parsed(void *parsed_result,
11511 __rte_unused struct cmdline *cl,
11512 __rte_unused void *data)
11514 struct cmd_set_hash_input_set_result *res = parsed_result;
11515 struct rte_eth_hash_filter_info info;
11517 memset(&info, 0, sizeof(info));
11518 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11519 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11520 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11521 info.info.input_set_conf.inset_size = 1;
11522 if (!strcmp(res->select, "select"))
11523 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11524 else if (!strcmp(res->select, "add"))
11525 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11526 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11527 RTE_ETH_FILTER_SET, &info);
11530 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11531 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11532 set_hash_input_set, "set_hash_input_set");
11533 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11534 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11536 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11537 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11539 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11540 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11542 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11543 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11544 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11545 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11546 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11548 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11549 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11550 select, "select#add");
11552 cmdline_parse_inst_t cmd_set_hash_input_set = {
11553 .f = cmd_set_hash_input_set_parsed,
11555 .help_str = "set_hash_input_set <port_id> "
11556 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11557 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11558 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11559 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11560 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11561 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11562 "fld-7th|fld-8th|none select|add",
11564 (void *)&cmd_set_hash_input_set_cmd,
11565 (void *)&cmd_set_hash_input_set_port_id,
11566 (void *)&cmd_set_hash_input_set_flow_type,
11567 (void *)&cmd_set_hash_input_set_field,
11568 (void *)&cmd_set_hash_input_set_select,
11573 /* Set flow director input set */
11574 struct cmd_set_fdir_input_set_result {
11575 cmdline_fixed_string_t set_fdir_input_set;
11577 cmdline_fixed_string_t flow_type;
11578 cmdline_fixed_string_t inset_field;
11579 cmdline_fixed_string_t select;
11583 cmd_set_fdir_input_set_parsed(void *parsed_result,
11584 __rte_unused struct cmdline *cl,
11585 __rte_unused void *data)
11587 struct cmd_set_fdir_input_set_result *res = parsed_result;
11588 struct rte_eth_fdir_filter_info info;
11590 memset(&info, 0, sizeof(info));
11591 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11592 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11593 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11594 info.info.input_set_conf.inset_size = 1;
11595 if (!strcmp(res->select, "select"))
11596 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11597 else if (!strcmp(res->select, "add"))
11598 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11599 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11600 RTE_ETH_FILTER_SET, &info);
11603 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11604 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11605 set_fdir_input_set, "set_fdir_input_set");
11606 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11607 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11609 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11610 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11612 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11613 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11614 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11615 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11617 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11618 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11619 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11620 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11621 "sctp-veri-tag#none");
11622 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11623 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11624 select, "select#add");
11626 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11627 .f = cmd_set_fdir_input_set_parsed,
11629 .help_str = "set_fdir_input_set <port_id> "
11630 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11631 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11632 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11633 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11634 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11635 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11636 "sctp-veri-tag|none select|add",
11638 (void *)&cmd_set_fdir_input_set_cmd,
11639 (void *)&cmd_set_fdir_input_set_port_id,
11640 (void *)&cmd_set_fdir_input_set_flow_type,
11641 (void *)&cmd_set_fdir_input_set_field,
11642 (void *)&cmd_set_fdir_input_set_select,
11647 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11648 struct cmd_mcast_addr_result {
11649 cmdline_fixed_string_t mcast_addr_cmd;
11650 cmdline_fixed_string_t what;
11652 struct ether_addr mc_addr;
11655 static void cmd_mcast_addr_parsed(void *parsed_result,
11656 __attribute__((unused)) struct cmdline *cl,
11657 __attribute__((unused)) void *data)
11659 struct cmd_mcast_addr_result *res = parsed_result;
11661 if (!is_multicast_ether_addr(&res->mc_addr)) {
11662 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11663 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11664 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11665 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11668 if (strcmp(res->what, "add") == 0)
11669 mcast_addr_add(res->port_num, &res->mc_addr);
11671 mcast_addr_remove(res->port_num, &res->mc_addr);
11674 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11675 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11676 mcast_addr_cmd, "mcast_addr");
11677 cmdline_parse_token_string_t cmd_mcast_addr_what =
11678 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11680 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11681 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11682 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11683 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11685 cmdline_parse_inst_t cmd_mcast_addr = {
11686 .f = cmd_mcast_addr_parsed,
11688 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11689 "Add/Remove multicast MAC address on port_id",
11691 (void *)&cmd_mcast_addr_cmd,
11692 (void *)&cmd_mcast_addr_what,
11693 (void *)&cmd_mcast_addr_portnum,
11694 (void *)&cmd_mcast_addr_addr,
11699 /* l2 tunnel config
11700 * only support E-tag now.
11703 /* Ether type config */
11704 struct cmd_config_l2_tunnel_eth_type_result {
11705 cmdline_fixed_string_t port;
11706 cmdline_fixed_string_t config;
11707 cmdline_fixed_string_t all;
11709 cmdline_fixed_string_t l2_tunnel;
11710 cmdline_fixed_string_t l2_tunnel_type;
11711 cmdline_fixed_string_t eth_type;
11712 uint16_t eth_type_val;
11715 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11716 TOKEN_STRING_INITIALIZER
11717 (struct cmd_config_l2_tunnel_eth_type_result,
11719 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11720 TOKEN_STRING_INITIALIZER
11721 (struct cmd_config_l2_tunnel_eth_type_result,
11723 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11724 TOKEN_STRING_INITIALIZER
11725 (struct cmd_config_l2_tunnel_eth_type_result,
11727 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11728 TOKEN_NUM_INITIALIZER
11729 (struct cmd_config_l2_tunnel_eth_type_result,
11731 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11732 TOKEN_STRING_INITIALIZER
11733 (struct cmd_config_l2_tunnel_eth_type_result,
11734 l2_tunnel, "l2-tunnel");
11735 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11736 TOKEN_STRING_INITIALIZER
11737 (struct cmd_config_l2_tunnel_eth_type_result,
11738 l2_tunnel_type, "E-tag");
11739 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11740 TOKEN_STRING_INITIALIZER
11741 (struct cmd_config_l2_tunnel_eth_type_result,
11742 eth_type, "ether-type");
11743 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11744 TOKEN_NUM_INITIALIZER
11745 (struct cmd_config_l2_tunnel_eth_type_result,
11746 eth_type_val, UINT16);
11748 static enum rte_eth_tunnel_type
11749 str2fdir_l2_tunnel_type(char *string)
11753 static const struct {
11755 enum rte_eth_tunnel_type type;
11756 } l2_tunnel_type_str[] = {
11757 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11760 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11761 if (!strcmp(l2_tunnel_type_str[i].str, string))
11762 return l2_tunnel_type_str[i].type;
11764 return RTE_TUNNEL_TYPE_NONE;
11767 /* ether type config for all ports */
11769 cmd_config_l2_tunnel_eth_type_all_parsed
11770 (void *parsed_result,
11771 __attribute__((unused)) struct cmdline *cl,
11772 __attribute__((unused)) void *data)
11774 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11775 struct rte_eth_l2_tunnel_conf entry;
11778 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11779 entry.ether_type = res->eth_type_val;
11781 RTE_ETH_FOREACH_DEV(pid) {
11782 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11786 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11787 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11789 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11791 (void *)&cmd_config_l2_tunnel_eth_type_port,
11792 (void *)&cmd_config_l2_tunnel_eth_type_config,
11793 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11794 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11795 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11796 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11797 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11802 /* ether type config for a specific port */
11804 cmd_config_l2_tunnel_eth_type_specific_parsed(
11805 void *parsed_result,
11806 __attribute__((unused)) struct cmdline *cl,
11807 __attribute__((unused)) void *data)
11809 struct cmd_config_l2_tunnel_eth_type_result *res =
11811 struct rte_eth_l2_tunnel_conf entry;
11813 if (port_id_is_invalid(res->id, ENABLED_WARN))
11816 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11817 entry.ether_type = res->eth_type_val;
11819 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11822 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11823 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11825 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11827 (void *)&cmd_config_l2_tunnel_eth_type_port,
11828 (void *)&cmd_config_l2_tunnel_eth_type_config,
11829 (void *)&cmd_config_l2_tunnel_eth_type_id,
11830 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11831 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11832 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11833 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11838 /* Enable/disable l2 tunnel */
11839 struct cmd_config_l2_tunnel_en_dis_result {
11840 cmdline_fixed_string_t port;
11841 cmdline_fixed_string_t config;
11842 cmdline_fixed_string_t all;
11844 cmdline_fixed_string_t l2_tunnel;
11845 cmdline_fixed_string_t l2_tunnel_type;
11846 cmdline_fixed_string_t en_dis;
11849 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11850 TOKEN_STRING_INITIALIZER
11851 (struct cmd_config_l2_tunnel_en_dis_result,
11853 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11854 TOKEN_STRING_INITIALIZER
11855 (struct cmd_config_l2_tunnel_en_dis_result,
11857 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11858 TOKEN_STRING_INITIALIZER
11859 (struct cmd_config_l2_tunnel_en_dis_result,
11861 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11862 TOKEN_NUM_INITIALIZER
11863 (struct cmd_config_l2_tunnel_en_dis_result,
11865 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11866 TOKEN_STRING_INITIALIZER
11867 (struct cmd_config_l2_tunnel_en_dis_result,
11868 l2_tunnel, "l2-tunnel");
11869 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11870 TOKEN_STRING_INITIALIZER
11871 (struct cmd_config_l2_tunnel_en_dis_result,
11872 l2_tunnel_type, "E-tag");
11873 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11874 TOKEN_STRING_INITIALIZER
11875 (struct cmd_config_l2_tunnel_en_dis_result,
11876 en_dis, "enable#disable");
11878 /* enable/disable l2 tunnel for all ports */
11880 cmd_config_l2_tunnel_en_dis_all_parsed(
11881 void *parsed_result,
11882 __attribute__((unused)) struct cmdline *cl,
11883 __attribute__((unused)) void *data)
11885 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11886 struct rte_eth_l2_tunnel_conf entry;
11890 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11892 if (!strcmp("enable", res->en_dis))
11897 RTE_ETH_FOREACH_DEV(pid) {
11898 rte_eth_dev_l2_tunnel_offload_set(pid,
11900 ETH_L2_TUNNEL_ENABLE_MASK,
11905 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11906 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11908 .help_str = "port config all l2-tunnel E-tag enable|disable",
11910 (void *)&cmd_config_l2_tunnel_en_dis_port,
11911 (void *)&cmd_config_l2_tunnel_en_dis_config,
11912 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11913 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11914 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11915 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11920 /* enable/disable l2 tunnel for a port */
11922 cmd_config_l2_tunnel_en_dis_specific_parsed(
11923 void *parsed_result,
11924 __attribute__((unused)) struct cmdline *cl,
11925 __attribute__((unused)) void *data)
11927 struct cmd_config_l2_tunnel_en_dis_result *res =
11929 struct rte_eth_l2_tunnel_conf entry;
11931 if (port_id_is_invalid(res->id, ENABLED_WARN))
11934 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11936 if (!strcmp("enable", res->en_dis))
11937 rte_eth_dev_l2_tunnel_offload_set(res->id,
11939 ETH_L2_TUNNEL_ENABLE_MASK,
11942 rte_eth_dev_l2_tunnel_offload_set(res->id,
11944 ETH_L2_TUNNEL_ENABLE_MASK,
11948 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11949 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11951 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11953 (void *)&cmd_config_l2_tunnel_en_dis_port,
11954 (void *)&cmd_config_l2_tunnel_en_dis_config,
11955 (void *)&cmd_config_l2_tunnel_en_dis_id,
11956 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11957 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11958 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11963 /* E-tag configuration */
11965 /* Common result structure for all E-tag configuration */
11966 struct cmd_config_e_tag_result {
11967 cmdline_fixed_string_t e_tag;
11968 cmdline_fixed_string_t set;
11969 cmdline_fixed_string_t insertion;
11970 cmdline_fixed_string_t stripping;
11971 cmdline_fixed_string_t forwarding;
11972 cmdline_fixed_string_t filter;
11973 cmdline_fixed_string_t add;
11974 cmdline_fixed_string_t del;
11975 cmdline_fixed_string_t on;
11976 cmdline_fixed_string_t off;
11977 cmdline_fixed_string_t on_off;
11978 cmdline_fixed_string_t port_tag_id;
11979 uint32_t port_tag_id_val;
11980 cmdline_fixed_string_t e_tag_id;
11981 uint16_t e_tag_id_val;
11982 cmdline_fixed_string_t dst_pool;
11983 uint8_t dst_pool_val;
11984 cmdline_fixed_string_t port;
11986 cmdline_fixed_string_t vf;
11990 /* Common CLI fields for all E-tag configuration */
11991 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11992 TOKEN_STRING_INITIALIZER
11993 (struct cmd_config_e_tag_result,
11995 cmdline_parse_token_string_t cmd_config_e_tag_set =
11996 TOKEN_STRING_INITIALIZER
11997 (struct cmd_config_e_tag_result,
11999 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12000 TOKEN_STRING_INITIALIZER
12001 (struct cmd_config_e_tag_result,
12002 insertion, "insertion");
12003 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12004 TOKEN_STRING_INITIALIZER
12005 (struct cmd_config_e_tag_result,
12006 stripping, "stripping");
12007 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12008 TOKEN_STRING_INITIALIZER
12009 (struct cmd_config_e_tag_result,
12010 forwarding, "forwarding");
12011 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12012 TOKEN_STRING_INITIALIZER
12013 (struct cmd_config_e_tag_result,
12015 cmdline_parse_token_string_t cmd_config_e_tag_add =
12016 TOKEN_STRING_INITIALIZER
12017 (struct cmd_config_e_tag_result,
12019 cmdline_parse_token_string_t cmd_config_e_tag_del =
12020 TOKEN_STRING_INITIALIZER
12021 (struct cmd_config_e_tag_result,
12023 cmdline_parse_token_string_t cmd_config_e_tag_on =
12024 TOKEN_STRING_INITIALIZER
12025 (struct cmd_config_e_tag_result,
12027 cmdline_parse_token_string_t cmd_config_e_tag_off =
12028 TOKEN_STRING_INITIALIZER
12029 (struct cmd_config_e_tag_result,
12031 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12032 TOKEN_STRING_INITIALIZER
12033 (struct cmd_config_e_tag_result,
12035 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12036 TOKEN_STRING_INITIALIZER
12037 (struct cmd_config_e_tag_result,
12038 port_tag_id, "port-tag-id");
12039 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12040 TOKEN_NUM_INITIALIZER
12041 (struct cmd_config_e_tag_result,
12042 port_tag_id_val, UINT32);
12043 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12044 TOKEN_STRING_INITIALIZER
12045 (struct cmd_config_e_tag_result,
12046 e_tag_id, "e-tag-id");
12047 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12048 TOKEN_NUM_INITIALIZER
12049 (struct cmd_config_e_tag_result,
12050 e_tag_id_val, UINT16);
12051 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12052 TOKEN_STRING_INITIALIZER
12053 (struct cmd_config_e_tag_result,
12054 dst_pool, "dst-pool");
12055 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12056 TOKEN_NUM_INITIALIZER
12057 (struct cmd_config_e_tag_result,
12058 dst_pool_val, UINT8);
12059 cmdline_parse_token_string_t cmd_config_e_tag_port =
12060 TOKEN_STRING_INITIALIZER
12061 (struct cmd_config_e_tag_result,
12063 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12064 TOKEN_NUM_INITIALIZER
12065 (struct cmd_config_e_tag_result,
12067 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12068 TOKEN_STRING_INITIALIZER
12069 (struct cmd_config_e_tag_result,
12071 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12072 TOKEN_NUM_INITIALIZER
12073 (struct cmd_config_e_tag_result,
12076 /* E-tag insertion configuration */
12078 cmd_config_e_tag_insertion_en_parsed(
12079 void *parsed_result,
12080 __attribute__((unused)) struct cmdline *cl,
12081 __attribute__((unused)) void *data)
12083 struct cmd_config_e_tag_result *res =
12085 struct rte_eth_l2_tunnel_conf entry;
12087 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12090 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12091 entry.tunnel_id = res->port_tag_id_val;
12092 entry.vf_id = res->vf_id;
12093 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12095 ETH_L2_TUNNEL_INSERTION_MASK,
12100 cmd_config_e_tag_insertion_dis_parsed(
12101 void *parsed_result,
12102 __attribute__((unused)) struct cmdline *cl,
12103 __attribute__((unused)) void *data)
12105 struct cmd_config_e_tag_result *res =
12107 struct rte_eth_l2_tunnel_conf entry;
12109 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12112 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12113 entry.vf_id = res->vf_id;
12115 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12117 ETH_L2_TUNNEL_INSERTION_MASK,
12121 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12122 .f = cmd_config_e_tag_insertion_en_parsed,
12124 .help_str = "E-tag ... : E-tag insertion enable",
12126 (void *)&cmd_config_e_tag_e_tag,
12127 (void *)&cmd_config_e_tag_set,
12128 (void *)&cmd_config_e_tag_insertion,
12129 (void *)&cmd_config_e_tag_on,
12130 (void *)&cmd_config_e_tag_port_tag_id,
12131 (void *)&cmd_config_e_tag_port_tag_id_val,
12132 (void *)&cmd_config_e_tag_port,
12133 (void *)&cmd_config_e_tag_port_id,
12134 (void *)&cmd_config_e_tag_vf,
12135 (void *)&cmd_config_e_tag_vf_id,
12140 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12141 .f = cmd_config_e_tag_insertion_dis_parsed,
12143 .help_str = "E-tag ... : E-tag insertion disable",
12145 (void *)&cmd_config_e_tag_e_tag,
12146 (void *)&cmd_config_e_tag_set,
12147 (void *)&cmd_config_e_tag_insertion,
12148 (void *)&cmd_config_e_tag_off,
12149 (void *)&cmd_config_e_tag_port,
12150 (void *)&cmd_config_e_tag_port_id,
12151 (void *)&cmd_config_e_tag_vf,
12152 (void *)&cmd_config_e_tag_vf_id,
12157 /* E-tag stripping configuration */
12159 cmd_config_e_tag_stripping_parsed(
12160 void *parsed_result,
12161 __attribute__((unused)) struct cmdline *cl,
12162 __attribute__((unused)) void *data)
12164 struct cmd_config_e_tag_result *res =
12166 struct rte_eth_l2_tunnel_conf entry;
12168 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12171 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12173 if (!strcmp(res->on_off, "on"))
12174 rte_eth_dev_l2_tunnel_offload_set
12177 ETH_L2_TUNNEL_STRIPPING_MASK,
12180 rte_eth_dev_l2_tunnel_offload_set
12183 ETH_L2_TUNNEL_STRIPPING_MASK,
12187 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12188 .f = cmd_config_e_tag_stripping_parsed,
12190 .help_str = "E-tag ... : E-tag stripping enable/disable",
12192 (void *)&cmd_config_e_tag_e_tag,
12193 (void *)&cmd_config_e_tag_set,
12194 (void *)&cmd_config_e_tag_stripping,
12195 (void *)&cmd_config_e_tag_on_off,
12196 (void *)&cmd_config_e_tag_port,
12197 (void *)&cmd_config_e_tag_port_id,
12202 /* E-tag forwarding configuration */
12204 cmd_config_e_tag_forwarding_parsed(
12205 void *parsed_result,
12206 __attribute__((unused)) struct cmdline *cl,
12207 __attribute__((unused)) void *data)
12209 struct cmd_config_e_tag_result *res = parsed_result;
12210 struct rte_eth_l2_tunnel_conf entry;
12212 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12215 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12217 if (!strcmp(res->on_off, "on"))
12218 rte_eth_dev_l2_tunnel_offload_set
12221 ETH_L2_TUNNEL_FORWARDING_MASK,
12224 rte_eth_dev_l2_tunnel_offload_set
12227 ETH_L2_TUNNEL_FORWARDING_MASK,
12231 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12232 .f = cmd_config_e_tag_forwarding_parsed,
12234 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12236 (void *)&cmd_config_e_tag_e_tag,
12237 (void *)&cmd_config_e_tag_set,
12238 (void *)&cmd_config_e_tag_forwarding,
12239 (void *)&cmd_config_e_tag_on_off,
12240 (void *)&cmd_config_e_tag_port,
12241 (void *)&cmd_config_e_tag_port_id,
12246 /* E-tag filter configuration */
12248 cmd_config_e_tag_filter_add_parsed(
12249 void *parsed_result,
12250 __attribute__((unused)) struct cmdline *cl,
12251 __attribute__((unused)) void *data)
12253 struct cmd_config_e_tag_result *res = parsed_result;
12254 struct rte_eth_l2_tunnel_conf entry;
12257 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12260 if (res->e_tag_id_val > 0x3fff) {
12261 printf("e-tag-id must be equal or less than 0x3fff.\n");
12265 ret = rte_eth_dev_filter_supported(res->port_id,
12266 RTE_ETH_FILTER_L2_TUNNEL);
12268 printf("E-tag filter is not supported on port %u.\n",
12273 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12274 entry.tunnel_id = res->e_tag_id_val;
12275 entry.pool = res->dst_pool_val;
12277 ret = rte_eth_dev_filter_ctrl(res->port_id,
12278 RTE_ETH_FILTER_L2_TUNNEL,
12279 RTE_ETH_FILTER_ADD,
12282 printf("E-tag filter programming error: (%s)\n",
12286 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12287 .f = cmd_config_e_tag_filter_add_parsed,
12289 .help_str = "E-tag ... : E-tag filter add",
12291 (void *)&cmd_config_e_tag_e_tag,
12292 (void *)&cmd_config_e_tag_set,
12293 (void *)&cmd_config_e_tag_filter,
12294 (void *)&cmd_config_e_tag_add,
12295 (void *)&cmd_config_e_tag_e_tag_id,
12296 (void *)&cmd_config_e_tag_e_tag_id_val,
12297 (void *)&cmd_config_e_tag_dst_pool,
12298 (void *)&cmd_config_e_tag_dst_pool_val,
12299 (void *)&cmd_config_e_tag_port,
12300 (void *)&cmd_config_e_tag_port_id,
12306 cmd_config_e_tag_filter_del_parsed(
12307 void *parsed_result,
12308 __attribute__((unused)) struct cmdline *cl,
12309 __attribute__((unused)) void *data)
12311 struct cmd_config_e_tag_result *res = parsed_result;
12312 struct rte_eth_l2_tunnel_conf entry;
12315 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12318 if (res->e_tag_id_val > 0x3fff) {
12319 printf("e-tag-id must be less than 0x3fff.\n");
12323 ret = rte_eth_dev_filter_supported(res->port_id,
12324 RTE_ETH_FILTER_L2_TUNNEL);
12326 printf("E-tag filter is not supported on port %u.\n",
12331 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12332 entry.tunnel_id = res->e_tag_id_val;
12334 ret = rte_eth_dev_filter_ctrl(res->port_id,
12335 RTE_ETH_FILTER_L2_TUNNEL,
12336 RTE_ETH_FILTER_DELETE,
12339 printf("E-tag filter programming error: (%s)\n",
12343 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12344 .f = cmd_config_e_tag_filter_del_parsed,
12346 .help_str = "E-tag ... : E-tag filter delete",
12348 (void *)&cmd_config_e_tag_e_tag,
12349 (void *)&cmd_config_e_tag_set,
12350 (void *)&cmd_config_e_tag_filter,
12351 (void *)&cmd_config_e_tag_del,
12352 (void *)&cmd_config_e_tag_e_tag_id,
12353 (void *)&cmd_config_e_tag_e_tag_id_val,
12354 (void *)&cmd_config_e_tag_port,
12355 (void *)&cmd_config_e_tag_port_id,
12360 /* vf vlan anti spoof configuration */
12362 /* Common result structure for vf vlan anti spoof */
12363 struct cmd_vf_vlan_anti_spoof_result {
12364 cmdline_fixed_string_t set;
12365 cmdline_fixed_string_t vf;
12366 cmdline_fixed_string_t vlan;
12367 cmdline_fixed_string_t antispoof;
12370 cmdline_fixed_string_t on_off;
12373 /* Common CLI fields for vf vlan anti spoof enable disable */
12374 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12375 TOKEN_STRING_INITIALIZER
12376 (struct cmd_vf_vlan_anti_spoof_result,
12378 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12379 TOKEN_STRING_INITIALIZER
12380 (struct cmd_vf_vlan_anti_spoof_result,
12382 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12383 TOKEN_STRING_INITIALIZER
12384 (struct cmd_vf_vlan_anti_spoof_result,
12386 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12387 TOKEN_STRING_INITIALIZER
12388 (struct cmd_vf_vlan_anti_spoof_result,
12389 antispoof, "antispoof");
12390 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12391 TOKEN_NUM_INITIALIZER
12392 (struct cmd_vf_vlan_anti_spoof_result,
12394 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12395 TOKEN_NUM_INITIALIZER
12396 (struct cmd_vf_vlan_anti_spoof_result,
12398 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12399 TOKEN_STRING_INITIALIZER
12400 (struct cmd_vf_vlan_anti_spoof_result,
12404 cmd_set_vf_vlan_anti_spoof_parsed(
12405 void *parsed_result,
12406 __attribute__((unused)) struct cmdline *cl,
12407 __attribute__((unused)) void *data)
12409 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12410 int ret = -ENOTSUP;
12412 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12414 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12417 #ifdef RTE_LIBRTE_IXGBE_PMD
12418 if (ret == -ENOTSUP)
12419 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12420 res->vf_id, is_on);
12422 #ifdef RTE_LIBRTE_I40E_PMD
12423 if (ret == -ENOTSUP)
12424 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12425 res->vf_id, is_on);
12427 #ifdef RTE_LIBRTE_BNXT_PMD
12428 if (ret == -ENOTSUP)
12429 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12430 res->vf_id, is_on);
12437 printf("invalid vf_id %d\n", res->vf_id);
12440 printf("invalid port_id %d\n", res->port_id);
12443 printf("function not implemented\n");
12446 printf("programming error: (%s)\n", strerror(-ret));
12450 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12451 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12453 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12455 (void *)&cmd_vf_vlan_anti_spoof_set,
12456 (void *)&cmd_vf_vlan_anti_spoof_vf,
12457 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12458 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12459 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12460 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12461 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12466 /* vf mac anti spoof configuration */
12468 /* Common result structure for vf mac anti spoof */
12469 struct cmd_vf_mac_anti_spoof_result {
12470 cmdline_fixed_string_t set;
12471 cmdline_fixed_string_t vf;
12472 cmdline_fixed_string_t mac;
12473 cmdline_fixed_string_t antispoof;
12476 cmdline_fixed_string_t on_off;
12479 /* Common CLI fields for vf mac anti spoof enable disable */
12480 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12481 TOKEN_STRING_INITIALIZER
12482 (struct cmd_vf_mac_anti_spoof_result,
12484 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12485 TOKEN_STRING_INITIALIZER
12486 (struct cmd_vf_mac_anti_spoof_result,
12488 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12489 TOKEN_STRING_INITIALIZER
12490 (struct cmd_vf_mac_anti_spoof_result,
12492 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12493 TOKEN_STRING_INITIALIZER
12494 (struct cmd_vf_mac_anti_spoof_result,
12495 antispoof, "antispoof");
12496 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12497 TOKEN_NUM_INITIALIZER
12498 (struct cmd_vf_mac_anti_spoof_result,
12500 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12501 TOKEN_NUM_INITIALIZER
12502 (struct cmd_vf_mac_anti_spoof_result,
12504 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12505 TOKEN_STRING_INITIALIZER
12506 (struct cmd_vf_mac_anti_spoof_result,
12510 cmd_set_vf_mac_anti_spoof_parsed(
12511 void *parsed_result,
12512 __attribute__((unused)) struct cmdline *cl,
12513 __attribute__((unused)) void *data)
12515 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12516 int ret = -ENOTSUP;
12518 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12520 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12523 #ifdef RTE_LIBRTE_IXGBE_PMD
12524 if (ret == -ENOTSUP)
12525 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12526 res->vf_id, is_on);
12528 #ifdef RTE_LIBRTE_I40E_PMD
12529 if (ret == -ENOTSUP)
12530 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12531 res->vf_id, is_on);
12533 #ifdef RTE_LIBRTE_BNXT_PMD
12534 if (ret == -ENOTSUP)
12535 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12536 res->vf_id, is_on);
12543 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12546 printf("invalid port_id %d\n", res->port_id);
12549 printf("function not implemented\n");
12552 printf("programming error: (%s)\n", strerror(-ret));
12556 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12557 .f = cmd_set_vf_mac_anti_spoof_parsed,
12559 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12561 (void *)&cmd_vf_mac_anti_spoof_set,
12562 (void *)&cmd_vf_mac_anti_spoof_vf,
12563 (void *)&cmd_vf_mac_anti_spoof_mac,
12564 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12565 (void *)&cmd_vf_mac_anti_spoof_port_id,
12566 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12567 (void *)&cmd_vf_mac_anti_spoof_on_off,
12572 /* vf vlan strip queue configuration */
12574 /* Common result structure for vf mac anti spoof */
12575 struct cmd_vf_vlan_stripq_result {
12576 cmdline_fixed_string_t set;
12577 cmdline_fixed_string_t vf;
12578 cmdline_fixed_string_t vlan;
12579 cmdline_fixed_string_t stripq;
12582 cmdline_fixed_string_t on_off;
12585 /* Common CLI fields for vf vlan strip enable disable */
12586 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12587 TOKEN_STRING_INITIALIZER
12588 (struct cmd_vf_vlan_stripq_result,
12590 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12591 TOKEN_STRING_INITIALIZER
12592 (struct cmd_vf_vlan_stripq_result,
12594 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12595 TOKEN_STRING_INITIALIZER
12596 (struct cmd_vf_vlan_stripq_result,
12598 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12599 TOKEN_STRING_INITIALIZER
12600 (struct cmd_vf_vlan_stripq_result,
12602 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12603 TOKEN_NUM_INITIALIZER
12604 (struct cmd_vf_vlan_stripq_result,
12606 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12607 TOKEN_NUM_INITIALIZER
12608 (struct cmd_vf_vlan_stripq_result,
12610 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12611 TOKEN_STRING_INITIALIZER
12612 (struct cmd_vf_vlan_stripq_result,
12616 cmd_set_vf_vlan_stripq_parsed(
12617 void *parsed_result,
12618 __attribute__((unused)) struct cmdline *cl,
12619 __attribute__((unused)) void *data)
12621 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12622 int ret = -ENOTSUP;
12624 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12626 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12629 #ifdef RTE_LIBRTE_IXGBE_PMD
12630 if (ret == -ENOTSUP)
12631 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12632 res->vf_id, is_on);
12634 #ifdef RTE_LIBRTE_I40E_PMD
12635 if (ret == -ENOTSUP)
12636 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12637 res->vf_id, is_on);
12639 #ifdef RTE_LIBRTE_BNXT_PMD
12640 if (ret == -ENOTSUP)
12641 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12642 res->vf_id, is_on);
12649 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12652 printf("invalid port_id %d\n", res->port_id);
12655 printf("function not implemented\n");
12658 printf("programming error: (%s)\n", strerror(-ret));
12662 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12663 .f = cmd_set_vf_vlan_stripq_parsed,
12665 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12667 (void *)&cmd_vf_vlan_stripq_set,
12668 (void *)&cmd_vf_vlan_stripq_vf,
12669 (void *)&cmd_vf_vlan_stripq_vlan,
12670 (void *)&cmd_vf_vlan_stripq_stripq,
12671 (void *)&cmd_vf_vlan_stripq_port_id,
12672 (void *)&cmd_vf_vlan_stripq_vf_id,
12673 (void *)&cmd_vf_vlan_stripq_on_off,
12678 /* vf vlan insert configuration */
12680 /* Common result structure for vf vlan insert */
12681 struct cmd_vf_vlan_insert_result {
12682 cmdline_fixed_string_t set;
12683 cmdline_fixed_string_t vf;
12684 cmdline_fixed_string_t vlan;
12685 cmdline_fixed_string_t insert;
12691 /* Common CLI fields for vf vlan insert enable disable */
12692 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12693 TOKEN_STRING_INITIALIZER
12694 (struct cmd_vf_vlan_insert_result,
12696 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12697 TOKEN_STRING_INITIALIZER
12698 (struct cmd_vf_vlan_insert_result,
12700 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12701 TOKEN_STRING_INITIALIZER
12702 (struct cmd_vf_vlan_insert_result,
12704 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12705 TOKEN_STRING_INITIALIZER
12706 (struct cmd_vf_vlan_insert_result,
12708 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12709 TOKEN_NUM_INITIALIZER
12710 (struct cmd_vf_vlan_insert_result,
12712 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12713 TOKEN_NUM_INITIALIZER
12714 (struct cmd_vf_vlan_insert_result,
12716 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12717 TOKEN_NUM_INITIALIZER
12718 (struct cmd_vf_vlan_insert_result,
12722 cmd_set_vf_vlan_insert_parsed(
12723 void *parsed_result,
12724 __attribute__((unused)) struct cmdline *cl,
12725 __attribute__((unused)) void *data)
12727 struct cmd_vf_vlan_insert_result *res = parsed_result;
12728 int ret = -ENOTSUP;
12730 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12733 #ifdef RTE_LIBRTE_IXGBE_PMD
12734 if (ret == -ENOTSUP)
12735 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12738 #ifdef RTE_LIBRTE_I40E_PMD
12739 if (ret == -ENOTSUP)
12740 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12743 #ifdef RTE_LIBRTE_BNXT_PMD
12744 if (ret == -ENOTSUP)
12745 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12753 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12756 printf("invalid port_id %d\n", res->port_id);
12759 printf("function not implemented\n");
12762 printf("programming error: (%s)\n", strerror(-ret));
12766 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12767 .f = cmd_set_vf_vlan_insert_parsed,
12769 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12771 (void *)&cmd_vf_vlan_insert_set,
12772 (void *)&cmd_vf_vlan_insert_vf,
12773 (void *)&cmd_vf_vlan_insert_vlan,
12774 (void *)&cmd_vf_vlan_insert_insert,
12775 (void *)&cmd_vf_vlan_insert_port_id,
12776 (void *)&cmd_vf_vlan_insert_vf_id,
12777 (void *)&cmd_vf_vlan_insert_vlan_id,
12782 /* tx loopback configuration */
12784 /* Common result structure for tx loopback */
12785 struct cmd_tx_loopback_result {
12786 cmdline_fixed_string_t set;
12787 cmdline_fixed_string_t tx;
12788 cmdline_fixed_string_t loopback;
12790 cmdline_fixed_string_t on_off;
12793 /* Common CLI fields for tx loopback enable disable */
12794 cmdline_parse_token_string_t cmd_tx_loopback_set =
12795 TOKEN_STRING_INITIALIZER
12796 (struct cmd_tx_loopback_result,
12798 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12799 TOKEN_STRING_INITIALIZER
12800 (struct cmd_tx_loopback_result,
12802 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12803 TOKEN_STRING_INITIALIZER
12804 (struct cmd_tx_loopback_result,
12805 loopback, "loopback");
12806 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12807 TOKEN_NUM_INITIALIZER
12808 (struct cmd_tx_loopback_result,
12810 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12811 TOKEN_STRING_INITIALIZER
12812 (struct cmd_tx_loopback_result,
12816 cmd_set_tx_loopback_parsed(
12817 void *parsed_result,
12818 __attribute__((unused)) struct cmdline *cl,
12819 __attribute__((unused)) void *data)
12821 struct cmd_tx_loopback_result *res = parsed_result;
12822 int ret = -ENOTSUP;
12824 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12826 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12829 #ifdef RTE_LIBRTE_IXGBE_PMD
12830 if (ret == -ENOTSUP)
12831 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12833 #ifdef RTE_LIBRTE_I40E_PMD
12834 if (ret == -ENOTSUP)
12835 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12837 #ifdef RTE_LIBRTE_BNXT_PMD
12838 if (ret == -ENOTSUP)
12839 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12841 #ifdef RTE_LIBRTE_DPAA_PMD
12842 if (ret == -ENOTSUP)
12843 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
12850 printf("invalid is_on %d\n", is_on);
12853 printf("invalid port_id %d\n", res->port_id);
12856 printf("function not implemented\n");
12859 printf("programming error: (%s)\n", strerror(-ret));
12863 cmdline_parse_inst_t cmd_set_tx_loopback = {
12864 .f = cmd_set_tx_loopback_parsed,
12866 .help_str = "set tx loopback <port_id> on|off",
12868 (void *)&cmd_tx_loopback_set,
12869 (void *)&cmd_tx_loopback_tx,
12870 (void *)&cmd_tx_loopback_loopback,
12871 (void *)&cmd_tx_loopback_port_id,
12872 (void *)&cmd_tx_loopback_on_off,
12877 /* all queues drop enable configuration */
12879 /* Common result structure for all queues drop enable */
12880 struct cmd_all_queues_drop_en_result {
12881 cmdline_fixed_string_t set;
12882 cmdline_fixed_string_t all;
12883 cmdline_fixed_string_t queues;
12884 cmdline_fixed_string_t drop;
12886 cmdline_fixed_string_t on_off;
12889 /* Common CLI fields for tx loopback enable disable */
12890 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12891 TOKEN_STRING_INITIALIZER
12892 (struct cmd_all_queues_drop_en_result,
12894 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12895 TOKEN_STRING_INITIALIZER
12896 (struct cmd_all_queues_drop_en_result,
12898 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12899 TOKEN_STRING_INITIALIZER
12900 (struct cmd_all_queues_drop_en_result,
12902 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12903 TOKEN_STRING_INITIALIZER
12904 (struct cmd_all_queues_drop_en_result,
12906 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12907 TOKEN_NUM_INITIALIZER
12908 (struct cmd_all_queues_drop_en_result,
12910 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12911 TOKEN_STRING_INITIALIZER
12912 (struct cmd_all_queues_drop_en_result,
12916 cmd_set_all_queues_drop_en_parsed(
12917 void *parsed_result,
12918 __attribute__((unused)) struct cmdline *cl,
12919 __attribute__((unused)) void *data)
12921 struct cmd_all_queues_drop_en_result *res = parsed_result;
12922 int ret = -ENOTSUP;
12923 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12925 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12928 #ifdef RTE_LIBRTE_IXGBE_PMD
12929 if (ret == -ENOTSUP)
12930 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12932 #ifdef RTE_LIBRTE_BNXT_PMD
12933 if (ret == -ENOTSUP)
12934 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12940 printf("invalid is_on %d\n", is_on);
12943 printf("invalid port_id %d\n", res->port_id);
12946 printf("function not implemented\n");
12949 printf("programming error: (%s)\n", strerror(-ret));
12953 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12954 .f = cmd_set_all_queues_drop_en_parsed,
12956 .help_str = "set all queues drop <port_id> on|off",
12958 (void *)&cmd_all_queues_drop_en_set,
12959 (void *)&cmd_all_queues_drop_en_all,
12960 (void *)&cmd_all_queues_drop_en_queues,
12961 (void *)&cmd_all_queues_drop_en_drop,
12962 (void *)&cmd_all_queues_drop_en_port_id,
12963 (void *)&cmd_all_queues_drop_en_on_off,
12968 /* vf split drop enable configuration */
12970 /* Common result structure for vf split drop enable */
12971 struct cmd_vf_split_drop_en_result {
12972 cmdline_fixed_string_t set;
12973 cmdline_fixed_string_t vf;
12974 cmdline_fixed_string_t split;
12975 cmdline_fixed_string_t drop;
12978 cmdline_fixed_string_t on_off;
12981 /* Common CLI fields for vf split drop enable disable */
12982 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12983 TOKEN_STRING_INITIALIZER
12984 (struct cmd_vf_split_drop_en_result,
12986 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12987 TOKEN_STRING_INITIALIZER
12988 (struct cmd_vf_split_drop_en_result,
12990 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12991 TOKEN_STRING_INITIALIZER
12992 (struct cmd_vf_split_drop_en_result,
12994 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12995 TOKEN_STRING_INITIALIZER
12996 (struct cmd_vf_split_drop_en_result,
12998 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12999 TOKEN_NUM_INITIALIZER
13000 (struct cmd_vf_split_drop_en_result,
13002 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13003 TOKEN_NUM_INITIALIZER
13004 (struct cmd_vf_split_drop_en_result,
13006 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13007 TOKEN_STRING_INITIALIZER
13008 (struct cmd_vf_split_drop_en_result,
13012 cmd_set_vf_split_drop_en_parsed(
13013 void *parsed_result,
13014 __attribute__((unused)) struct cmdline *cl,
13015 __attribute__((unused)) void *data)
13017 struct cmd_vf_split_drop_en_result *res = parsed_result;
13018 int ret = -ENOTSUP;
13019 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13021 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13024 #ifdef RTE_LIBRTE_IXGBE_PMD
13025 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13032 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13035 printf("invalid port_id %d\n", res->port_id);
13038 printf("not supported on port %d\n", res->port_id);
13041 printf("programming error: (%s)\n", strerror(-ret));
13045 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13046 .f = cmd_set_vf_split_drop_en_parsed,
13048 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13050 (void *)&cmd_vf_split_drop_en_set,
13051 (void *)&cmd_vf_split_drop_en_vf,
13052 (void *)&cmd_vf_split_drop_en_split,
13053 (void *)&cmd_vf_split_drop_en_drop,
13054 (void *)&cmd_vf_split_drop_en_port_id,
13055 (void *)&cmd_vf_split_drop_en_vf_id,
13056 (void *)&cmd_vf_split_drop_en_on_off,
13061 /* vf mac address configuration */
13063 /* Common result structure for vf mac address */
13064 struct cmd_set_vf_mac_addr_result {
13065 cmdline_fixed_string_t set;
13066 cmdline_fixed_string_t vf;
13067 cmdline_fixed_string_t mac;
13068 cmdline_fixed_string_t addr;
13071 struct ether_addr mac_addr;
13075 /* Common CLI fields for vf split drop enable disable */
13076 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13077 TOKEN_STRING_INITIALIZER
13078 (struct cmd_set_vf_mac_addr_result,
13080 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13081 TOKEN_STRING_INITIALIZER
13082 (struct cmd_set_vf_mac_addr_result,
13084 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13085 TOKEN_STRING_INITIALIZER
13086 (struct cmd_set_vf_mac_addr_result,
13088 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13089 TOKEN_STRING_INITIALIZER
13090 (struct cmd_set_vf_mac_addr_result,
13092 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13093 TOKEN_NUM_INITIALIZER
13094 (struct cmd_set_vf_mac_addr_result,
13096 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13097 TOKEN_NUM_INITIALIZER
13098 (struct cmd_set_vf_mac_addr_result,
13100 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13101 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13105 cmd_set_vf_mac_addr_parsed(
13106 void *parsed_result,
13107 __attribute__((unused)) struct cmdline *cl,
13108 __attribute__((unused)) void *data)
13110 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13111 int ret = -ENOTSUP;
13113 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13116 #ifdef RTE_LIBRTE_IXGBE_PMD
13117 if (ret == -ENOTSUP)
13118 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13121 #ifdef RTE_LIBRTE_I40E_PMD
13122 if (ret == -ENOTSUP)
13123 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13126 #ifdef RTE_LIBRTE_BNXT_PMD
13127 if (ret == -ENOTSUP)
13128 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13136 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13139 printf("invalid port_id %d\n", res->port_id);
13142 printf("function not implemented\n");
13145 printf("programming error: (%s)\n", strerror(-ret));
13149 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13150 .f = cmd_set_vf_mac_addr_parsed,
13152 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13154 (void *)&cmd_set_vf_mac_addr_set,
13155 (void *)&cmd_set_vf_mac_addr_vf,
13156 (void *)&cmd_set_vf_mac_addr_mac,
13157 (void *)&cmd_set_vf_mac_addr_addr,
13158 (void *)&cmd_set_vf_mac_addr_port_id,
13159 (void *)&cmd_set_vf_mac_addr_vf_id,
13160 (void *)&cmd_set_vf_mac_addr_mac_addr,
13165 /* MACsec configuration */
13167 /* Common result structure for MACsec offload enable */
13168 struct cmd_macsec_offload_on_result {
13169 cmdline_fixed_string_t set;
13170 cmdline_fixed_string_t macsec;
13171 cmdline_fixed_string_t offload;
13173 cmdline_fixed_string_t on;
13174 cmdline_fixed_string_t encrypt;
13175 cmdline_fixed_string_t en_on_off;
13176 cmdline_fixed_string_t replay_protect;
13177 cmdline_fixed_string_t rp_on_off;
13180 /* Common CLI fields for MACsec offload disable */
13181 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13182 TOKEN_STRING_INITIALIZER
13183 (struct cmd_macsec_offload_on_result,
13185 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13186 TOKEN_STRING_INITIALIZER
13187 (struct cmd_macsec_offload_on_result,
13189 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13190 TOKEN_STRING_INITIALIZER
13191 (struct cmd_macsec_offload_on_result,
13192 offload, "offload");
13193 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13194 TOKEN_NUM_INITIALIZER
13195 (struct cmd_macsec_offload_on_result,
13197 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13198 TOKEN_STRING_INITIALIZER
13199 (struct cmd_macsec_offload_on_result,
13201 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13202 TOKEN_STRING_INITIALIZER
13203 (struct cmd_macsec_offload_on_result,
13204 encrypt, "encrypt");
13205 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13206 TOKEN_STRING_INITIALIZER
13207 (struct cmd_macsec_offload_on_result,
13208 en_on_off, "on#off");
13209 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13210 TOKEN_STRING_INITIALIZER
13211 (struct cmd_macsec_offload_on_result,
13212 replay_protect, "replay-protect");
13213 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13214 TOKEN_STRING_INITIALIZER
13215 (struct cmd_macsec_offload_on_result,
13216 rp_on_off, "on#off");
13219 cmd_set_macsec_offload_on_parsed(
13220 void *parsed_result,
13221 __attribute__((unused)) struct cmdline *cl,
13222 __attribute__((unused)) void *data)
13224 struct cmd_macsec_offload_on_result *res = parsed_result;
13225 int ret = -ENOTSUP;
13226 portid_t port_id = res->port_id;
13227 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13228 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13229 struct rte_eth_dev_info dev_info;
13231 if (port_id_is_invalid(port_id, ENABLED_WARN))
13233 if (!port_is_stopped(port_id)) {
13234 printf("Please stop port %d first\n", port_id);
13238 rte_eth_dev_info_get(port_id, &dev_info);
13239 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13240 #ifdef RTE_LIBRTE_IXGBE_PMD
13241 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13249 ports[port_id].dev_conf.txmode.offloads |=
13250 DEV_TX_OFFLOAD_MACSEC_INSERT;
13251 cmd_reconfig_device_queue(port_id, 1, 1);
13254 printf("invalid port_id %d\n", port_id);
13257 printf("not supported on port %d\n", port_id);
13260 printf("programming error: (%s)\n", strerror(-ret));
13264 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13265 .f = cmd_set_macsec_offload_on_parsed,
13267 .help_str = "set macsec offload <port_id> on "
13268 "encrypt on|off replay-protect on|off",
13270 (void *)&cmd_macsec_offload_on_set,
13271 (void *)&cmd_macsec_offload_on_macsec,
13272 (void *)&cmd_macsec_offload_on_offload,
13273 (void *)&cmd_macsec_offload_on_port_id,
13274 (void *)&cmd_macsec_offload_on_on,
13275 (void *)&cmd_macsec_offload_on_encrypt,
13276 (void *)&cmd_macsec_offload_on_en_on_off,
13277 (void *)&cmd_macsec_offload_on_replay_protect,
13278 (void *)&cmd_macsec_offload_on_rp_on_off,
13283 /* Common result structure for MACsec offload disable */
13284 struct cmd_macsec_offload_off_result {
13285 cmdline_fixed_string_t set;
13286 cmdline_fixed_string_t macsec;
13287 cmdline_fixed_string_t offload;
13289 cmdline_fixed_string_t off;
13292 /* Common CLI fields for MACsec offload disable */
13293 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13294 TOKEN_STRING_INITIALIZER
13295 (struct cmd_macsec_offload_off_result,
13297 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13298 TOKEN_STRING_INITIALIZER
13299 (struct cmd_macsec_offload_off_result,
13301 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13302 TOKEN_STRING_INITIALIZER
13303 (struct cmd_macsec_offload_off_result,
13304 offload, "offload");
13305 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13306 TOKEN_NUM_INITIALIZER
13307 (struct cmd_macsec_offload_off_result,
13309 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13310 TOKEN_STRING_INITIALIZER
13311 (struct cmd_macsec_offload_off_result,
13315 cmd_set_macsec_offload_off_parsed(
13316 void *parsed_result,
13317 __attribute__((unused)) struct cmdline *cl,
13318 __attribute__((unused)) void *data)
13320 struct cmd_macsec_offload_off_result *res = parsed_result;
13321 int ret = -ENOTSUP;
13322 struct rte_eth_dev_info dev_info;
13323 portid_t port_id = res->port_id;
13325 if (port_id_is_invalid(port_id, ENABLED_WARN))
13327 if (!port_is_stopped(port_id)) {
13328 printf("Please stop port %d first\n", port_id);
13332 rte_eth_dev_info_get(port_id, &dev_info);
13333 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13334 #ifdef RTE_LIBRTE_IXGBE_PMD
13335 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13340 ports[port_id].dev_conf.txmode.offloads &=
13341 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13342 cmd_reconfig_device_queue(port_id, 1, 1);
13345 printf("invalid port_id %d\n", port_id);
13348 printf("not supported on port %d\n", port_id);
13351 printf("programming error: (%s)\n", strerror(-ret));
13355 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13356 .f = cmd_set_macsec_offload_off_parsed,
13358 .help_str = "set macsec offload <port_id> off",
13360 (void *)&cmd_macsec_offload_off_set,
13361 (void *)&cmd_macsec_offload_off_macsec,
13362 (void *)&cmd_macsec_offload_off_offload,
13363 (void *)&cmd_macsec_offload_off_port_id,
13364 (void *)&cmd_macsec_offload_off_off,
13369 /* Common result structure for MACsec secure connection configure */
13370 struct cmd_macsec_sc_result {
13371 cmdline_fixed_string_t set;
13372 cmdline_fixed_string_t macsec;
13373 cmdline_fixed_string_t sc;
13374 cmdline_fixed_string_t tx_rx;
13376 struct ether_addr mac;
13380 /* Common CLI fields for MACsec secure connection configure */
13381 cmdline_parse_token_string_t cmd_macsec_sc_set =
13382 TOKEN_STRING_INITIALIZER
13383 (struct cmd_macsec_sc_result,
13385 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13386 TOKEN_STRING_INITIALIZER
13387 (struct cmd_macsec_sc_result,
13389 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13390 TOKEN_STRING_INITIALIZER
13391 (struct cmd_macsec_sc_result,
13393 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13394 TOKEN_STRING_INITIALIZER
13395 (struct cmd_macsec_sc_result,
13397 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13398 TOKEN_NUM_INITIALIZER
13399 (struct cmd_macsec_sc_result,
13401 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13402 TOKEN_ETHERADDR_INITIALIZER
13403 (struct cmd_macsec_sc_result,
13405 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13406 TOKEN_NUM_INITIALIZER
13407 (struct cmd_macsec_sc_result,
13411 cmd_set_macsec_sc_parsed(
13412 void *parsed_result,
13413 __attribute__((unused)) struct cmdline *cl,
13414 __attribute__((unused)) void *data)
13416 struct cmd_macsec_sc_result *res = parsed_result;
13417 int ret = -ENOTSUP;
13418 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13420 #ifdef RTE_LIBRTE_IXGBE_PMD
13422 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13423 res->mac.addr_bytes) :
13424 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13425 res->mac.addr_bytes, res->pi);
13427 RTE_SET_USED(is_tx);
13433 printf("invalid port_id %d\n", res->port_id);
13436 printf("not supported on port %d\n", res->port_id);
13439 printf("programming error: (%s)\n", strerror(-ret));
13443 cmdline_parse_inst_t cmd_set_macsec_sc = {
13444 .f = cmd_set_macsec_sc_parsed,
13446 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13448 (void *)&cmd_macsec_sc_set,
13449 (void *)&cmd_macsec_sc_macsec,
13450 (void *)&cmd_macsec_sc_sc,
13451 (void *)&cmd_macsec_sc_tx_rx,
13452 (void *)&cmd_macsec_sc_port_id,
13453 (void *)&cmd_macsec_sc_mac,
13454 (void *)&cmd_macsec_sc_pi,
13459 /* Common result structure for MACsec secure connection configure */
13460 struct cmd_macsec_sa_result {
13461 cmdline_fixed_string_t set;
13462 cmdline_fixed_string_t macsec;
13463 cmdline_fixed_string_t sa;
13464 cmdline_fixed_string_t tx_rx;
13469 cmdline_fixed_string_t key;
13472 /* Common CLI fields for MACsec secure connection configure */
13473 cmdline_parse_token_string_t cmd_macsec_sa_set =
13474 TOKEN_STRING_INITIALIZER
13475 (struct cmd_macsec_sa_result,
13477 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13478 TOKEN_STRING_INITIALIZER
13479 (struct cmd_macsec_sa_result,
13481 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13482 TOKEN_STRING_INITIALIZER
13483 (struct cmd_macsec_sa_result,
13485 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13486 TOKEN_STRING_INITIALIZER
13487 (struct cmd_macsec_sa_result,
13489 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13490 TOKEN_NUM_INITIALIZER
13491 (struct cmd_macsec_sa_result,
13493 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13494 TOKEN_NUM_INITIALIZER
13495 (struct cmd_macsec_sa_result,
13497 cmdline_parse_token_num_t cmd_macsec_sa_an =
13498 TOKEN_NUM_INITIALIZER
13499 (struct cmd_macsec_sa_result,
13501 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13502 TOKEN_NUM_INITIALIZER
13503 (struct cmd_macsec_sa_result,
13505 cmdline_parse_token_string_t cmd_macsec_sa_key =
13506 TOKEN_STRING_INITIALIZER
13507 (struct cmd_macsec_sa_result,
13511 cmd_set_macsec_sa_parsed(
13512 void *parsed_result,
13513 __attribute__((unused)) struct cmdline *cl,
13514 __attribute__((unused)) void *data)
13516 struct cmd_macsec_sa_result *res = parsed_result;
13517 int ret = -ENOTSUP;
13518 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13519 uint8_t key[16] = { 0 };
13525 key_len = strlen(res->key) / 2;
13529 for (i = 0; i < key_len; i++) {
13530 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13533 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13536 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13539 #ifdef RTE_LIBRTE_IXGBE_PMD
13541 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13542 res->idx, res->an, res->pn, key) :
13543 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13544 res->idx, res->an, res->pn, key);
13546 RTE_SET_USED(is_tx);
13553 printf("invalid idx %d or an %d\n", res->idx, res->an);
13556 printf("invalid port_id %d\n", res->port_id);
13559 printf("not supported on port %d\n", res->port_id);
13562 printf("programming error: (%s)\n", strerror(-ret));
13566 cmdline_parse_inst_t cmd_set_macsec_sa = {
13567 .f = cmd_set_macsec_sa_parsed,
13569 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13571 (void *)&cmd_macsec_sa_set,
13572 (void *)&cmd_macsec_sa_macsec,
13573 (void *)&cmd_macsec_sa_sa,
13574 (void *)&cmd_macsec_sa_tx_rx,
13575 (void *)&cmd_macsec_sa_port_id,
13576 (void *)&cmd_macsec_sa_idx,
13577 (void *)&cmd_macsec_sa_an,
13578 (void *)&cmd_macsec_sa_pn,
13579 (void *)&cmd_macsec_sa_key,
13584 /* VF unicast promiscuous mode configuration */
13586 /* Common result structure for VF unicast promiscuous mode */
13587 struct cmd_vf_promisc_result {
13588 cmdline_fixed_string_t set;
13589 cmdline_fixed_string_t vf;
13590 cmdline_fixed_string_t promisc;
13593 cmdline_fixed_string_t on_off;
13596 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13597 cmdline_parse_token_string_t cmd_vf_promisc_set =
13598 TOKEN_STRING_INITIALIZER
13599 (struct cmd_vf_promisc_result,
13601 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13602 TOKEN_STRING_INITIALIZER
13603 (struct cmd_vf_promisc_result,
13605 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13606 TOKEN_STRING_INITIALIZER
13607 (struct cmd_vf_promisc_result,
13608 promisc, "promisc");
13609 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13610 TOKEN_NUM_INITIALIZER
13611 (struct cmd_vf_promisc_result,
13613 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13614 TOKEN_NUM_INITIALIZER
13615 (struct cmd_vf_promisc_result,
13617 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13618 TOKEN_STRING_INITIALIZER
13619 (struct cmd_vf_promisc_result,
13623 cmd_set_vf_promisc_parsed(
13624 void *parsed_result,
13625 __attribute__((unused)) struct cmdline *cl,
13626 __attribute__((unused)) void *data)
13628 struct cmd_vf_promisc_result *res = parsed_result;
13629 int ret = -ENOTSUP;
13631 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13633 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13636 #ifdef RTE_LIBRTE_I40E_PMD
13637 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13638 res->vf_id, is_on);
13645 printf("invalid vf_id %d\n", res->vf_id);
13648 printf("invalid port_id %d\n", res->port_id);
13651 printf("function not implemented\n");
13654 printf("programming error: (%s)\n", strerror(-ret));
13658 cmdline_parse_inst_t cmd_set_vf_promisc = {
13659 .f = cmd_set_vf_promisc_parsed,
13661 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13662 "Set unicast promiscuous mode for a VF from the PF",
13664 (void *)&cmd_vf_promisc_set,
13665 (void *)&cmd_vf_promisc_vf,
13666 (void *)&cmd_vf_promisc_promisc,
13667 (void *)&cmd_vf_promisc_port_id,
13668 (void *)&cmd_vf_promisc_vf_id,
13669 (void *)&cmd_vf_promisc_on_off,
13674 /* VF multicast promiscuous mode configuration */
13676 /* Common result structure for VF multicast promiscuous mode */
13677 struct cmd_vf_allmulti_result {
13678 cmdline_fixed_string_t set;
13679 cmdline_fixed_string_t vf;
13680 cmdline_fixed_string_t allmulti;
13683 cmdline_fixed_string_t on_off;
13686 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13687 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13688 TOKEN_STRING_INITIALIZER
13689 (struct cmd_vf_allmulti_result,
13691 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13692 TOKEN_STRING_INITIALIZER
13693 (struct cmd_vf_allmulti_result,
13695 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13696 TOKEN_STRING_INITIALIZER
13697 (struct cmd_vf_allmulti_result,
13698 allmulti, "allmulti");
13699 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13700 TOKEN_NUM_INITIALIZER
13701 (struct cmd_vf_allmulti_result,
13703 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13704 TOKEN_NUM_INITIALIZER
13705 (struct cmd_vf_allmulti_result,
13707 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13708 TOKEN_STRING_INITIALIZER
13709 (struct cmd_vf_allmulti_result,
13713 cmd_set_vf_allmulti_parsed(
13714 void *parsed_result,
13715 __attribute__((unused)) struct cmdline *cl,
13716 __attribute__((unused)) void *data)
13718 struct cmd_vf_allmulti_result *res = parsed_result;
13719 int ret = -ENOTSUP;
13721 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13723 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13726 #ifdef RTE_LIBRTE_I40E_PMD
13727 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13728 res->vf_id, is_on);
13735 printf("invalid vf_id %d\n", res->vf_id);
13738 printf("invalid port_id %d\n", res->port_id);
13741 printf("function not implemented\n");
13744 printf("programming error: (%s)\n", strerror(-ret));
13748 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13749 .f = cmd_set_vf_allmulti_parsed,
13751 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13752 "Set multicast promiscuous mode for a VF from the PF",
13754 (void *)&cmd_vf_allmulti_set,
13755 (void *)&cmd_vf_allmulti_vf,
13756 (void *)&cmd_vf_allmulti_allmulti,
13757 (void *)&cmd_vf_allmulti_port_id,
13758 (void *)&cmd_vf_allmulti_vf_id,
13759 (void *)&cmd_vf_allmulti_on_off,
13764 /* vf broadcast mode configuration */
13766 /* Common result structure for vf broadcast */
13767 struct cmd_set_vf_broadcast_result {
13768 cmdline_fixed_string_t set;
13769 cmdline_fixed_string_t vf;
13770 cmdline_fixed_string_t broadcast;
13773 cmdline_fixed_string_t on_off;
13776 /* Common CLI fields for vf broadcast enable disable */
13777 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13778 TOKEN_STRING_INITIALIZER
13779 (struct cmd_set_vf_broadcast_result,
13781 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13782 TOKEN_STRING_INITIALIZER
13783 (struct cmd_set_vf_broadcast_result,
13785 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13786 TOKEN_STRING_INITIALIZER
13787 (struct cmd_set_vf_broadcast_result,
13788 broadcast, "broadcast");
13789 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13790 TOKEN_NUM_INITIALIZER
13791 (struct cmd_set_vf_broadcast_result,
13793 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13794 TOKEN_NUM_INITIALIZER
13795 (struct cmd_set_vf_broadcast_result,
13797 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13798 TOKEN_STRING_INITIALIZER
13799 (struct cmd_set_vf_broadcast_result,
13803 cmd_set_vf_broadcast_parsed(
13804 void *parsed_result,
13805 __attribute__((unused)) struct cmdline *cl,
13806 __attribute__((unused)) void *data)
13808 struct cmd_set_vf_broadcast_result *res = parsed_result;
13809 int ret = -ENOTSUP;
13811 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13813 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13816 #ifdef RTE_LIBRTE_I40E_PMD
13817 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13818 res->vf_id, is_on);
13825 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13828 printf("invalid port_id %d\n", res->port_id);
13831 printf("function not implemented\n");
13834 printf("programming error: (%s)\n", strerror(-ret));
13838 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13839 .f = cmd_set_vf_broadcast_parsed,
13841 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13843 (void *)&cmd_set_vf_broadcast_set,
13844 (void *)&cmd_set_vf_broadcast_vf,
13845 (void *)&cmd_set_vf_broadcast_broadcast,
13846 (void *)&cmd_set_vf_broadcast_port_id,
13847 (void *)&cmd_set_vf_broadcast_vf_id,
13848 (void *)&cmd_set_vf_broadcast_on_off,
13853 /* vf vlan tag configuration */
13855 /* Common result structure for vf vlan tag */
13856 struct cmd_set_vf_vlan_tag_result {
13857 cmdline_fixed_string_t set;
13858 cmdline_fixed_string_t vf;
13859 cmdline_fixed_string_t vlan;
13860 cmdline_fixed_string_t tag;
13863 cmdline_fixed_string_t on_off;
13866 /* Common CLI fields for vf vlan tag enable disable */
13867 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13868 TOKEN_STRING_INITIALIZER
13869 (struct cmd_set_vf_vlan_tag_result,
13871 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13872 TOKEN_STRING_INITIALIZER
13873 (struct cmd_set_vf_vlan_tag_result,
13875 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13876 TOKEN_STRING_INITIALIZER
13877 (struct cmd_set_vf_vlan_tag_result,
13879 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13880 TOKEN_STRING_INITIALIZER
13881 (struct cmd_set_vf_vlan_tag_result,
13883 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13884 TOKEN_NUM_INITIALIZER
13885 (struct cmd_set_vf_vlan_tag_result,
13887 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13888 TOKEN_NUM_INITIALIZER
13889 (struct cmd_set_vf_vlan_tag_result,
13891 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13892 TOKEN_STRING_INITIALIZER
13893 (struct cmd_set_vf_vlan_tag_result,
13897 cmd_set_vf_vlan_tag_parsed(
13898 void *parsed_result,
13899 __attribute__((unused)) struct cmdline *cl,
13900 __attribute__((unused)) void *data)
13902 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13903 int ret = -ENOTSUP;
13905 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13907 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13910 #ifdef RTE_LIBRTE_I40E_PMD
13911 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13912 res->vf_id, is_on);
13919 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13922 printf("invalid port_id %d\n", res->port_id);
13925 printf("function not implemented\n");
13928 printf("programming error: (%s)\n", strerror(-ret));
13932 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13933 .f = cmd_set_vf_vlan_tag_parsed,
13935 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13937 (void *)&cmd_set_vf_vlan_tag_set,
13938 (void *)&cmd_set_vf_vlan_tag_vf,
13939 (void *)&cmd_set_vf_vlan_tag_vlan,
13940 (void *)&cmd_set_vf_vlan_tag_tag,
13941 (void *)&cmd_set_vf_vlan_tag_port_id,
13942 (void *)&cmd_set_vf_vlan_tag_vf_id,
13943 (void *)&cmd_set_vf_vlan_tag_on_off,
13948 /* Common definition of VF and TC TX bandwidth configuration */
13949 struct cmd_vf_tc_bw_result {
13950 cmdline_fixed_string_t set;
13951 cmdline_fixed_string_t vf;
13952 cmdline_fixed_string_t tc;
13953 cmdline_fixed_string_t tx;
13954 cmdline_fixed_string_t min_bw;
13955 cmdline_fixed_string_t max_bw;
13956 cmdline_fixed_string_t strict_link_prio;
13961 cmdline_fixed_string_t bw_list;
13965 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13966 TOKEN_STRING_INITIALIZER
13967 (struct cmd_vf_tc_bw_result,
13969 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13970 TOKEN_STRING_INITIALIZER
13971 (struct cmd_vf_tc_bw_result,
13973 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13974 TOKEN_STRING_INITIALIZER
13975 (struct cmd_vf_tc_bw_result,
13977 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13978 TOKEN_STRING_INITIALIZER
13979 (struct cmd_vf_tc_bw_result,
13981 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13982 TOKEN_STRING_INITIALIZER
13983 (struct cmd_vf_tc_bw_result,
13984 strict_link_prio, "strict-link-priority");
13985 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13986 TOKEN_STRING_INITIALIZER
13987 (struct cmd_vf_tc_bw_result,
13988 min_bw, "min-bandwidth");
13989 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13990 TOKEN_STRING_INITIALIZER
13991 (struct cmd_vf_tc_bw_result,
13992 max_bw, "max-bandwidth");
13993 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13994 TOKEN_NUM_INITIALIZER
13995 (struct cmd_vf_tc_bw_result,
13997 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13998 TOKEN_NUM_INITIALIZER
13999 (struct cmd_vf_tc_bw_result,
14001 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14002 TOKEN_NUM_INITIALIZER
14003 (struct cmd_vf_tc_bw_result,
14005 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14006 TOKEN_NUM_INITIALIZER
14007 (struct cmd_vf_tc_bw_result,
14009 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14010 TOKEN_STRING_INITIALIZER
14011 (struct cmd_vf_tc_bw_result,
14013 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14014 TOKEN_NUM_INITIALIZER
14015 (struct cmd_vf_tc_bw_result,
14018 /* VF max bandwidth setting */
14020 cmd_vf_max_bw_parsed(
14021 void *parsed_result,
14022 __attribute__((unused)) struct cmdline *cl,
14023 __attribute__((unused)) void *data)
14025 struct cmd_vf_tc_bw_result *res = parsed_result;
14026 int ret = -ENOTSUP;
14028 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14031 #ifdef RTE_LIBRTE_I40E_PMD
14032 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14033 res->vf_id, res->bw);
14040 printf("invalid vf_id %d or bandwidth %d\n",
14041 res->vf_id, res->bw);
14044 printf("invalid port_id %d\n", res->port_id);
14047 printf("function not implemented\n");
14050 printf("programming error: (%s)\n", strerror(-ret));
14054 cmdline_parse_inst_t cmd_vf_max_bw = {
14055 .f = cmd_vf_max_bw_parsed,
14057 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14059 (void *)&cmd_vf_tc_bw_set,
14060 (void *)&cmd_vf_tc_bw_vf,
14061 (void *)&cmd_vf_tc_bw_tx,
14062 (void *)&cmd_vf_tc_bw_max_bw,
14063 (void *)&cmd_vf_tc_bw_port_id,
14064 (void *)&cmd_vf_tc_bw_vf_id,
14065 (void *)&cmd_vf_tc_bw_bw,
14071 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14076 const char *p, *p0 = str;
14083 p = strchr(p0, '(');
14085 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14089 p0 = strchr(p, ')');
14091 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14095 if (size >= sizeof(s)) {
14096 printf("The string size exceeds the internal buffer size\n");
14099 snprintf(s, sizeof(s), "%.*s", size, p);
14100 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14102 printf("Failed to get the bandwidth list. ");
14106 for (i = 0; i < ret; i++)
14107 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14112 /* TC min bandwidth setting */
14114 cmd_vf_tc_min_bw_parsed(
14115 void *parsed_result,
14116 __attribute__((unused)) struct cmdline *cl,
14117 __attribute__((unused)) void *data)
14119 struct cmd_vf_tc_bw_result *res = parsed_result;
14122 int ret = -ENOTSUP;
14124 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14127 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14131 #ifdef RTE_LIBRTE_I40E_PMD
14132 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14140 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14143 printf("invalid port_id %d\n", res->port_id);
14146 printf("function not implemented\n");
14149 printf("programming error: (%s)\n", strerror(-ret));
14153 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14154 .f = cmd_vf_tc_min_bw_parsed,
14156 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14157 " <bw1, bw2, ...>",
14159 (void *)&cmd_vf_tc_bw_set,
14160 (void *)&cmd_vf_tc_bw_vf,
14161 (void *)&cmd_vf_tc_bw_tc,
14162 (void *)&cmd_vf_tc_bw_tx,
14163 (void *)&cmd_vf_tc_bw_min_bw,
14164 (void *)&cmd_vf_tc_bw_port_id,
14165 (void *)&cmd_vf_tc_bw_vf_id,
14166 (void *)&cmd_vf_tc_bw_bw_list,
14172 cmd_tc_min_bw_parsed(
14173 void *parsed_result,
14174 __attribute__((unused)) struct cmdline *cl,
14175 __attribute__((unused)) void *data)
14177 struct cmd_vf_tc_bw_result *res = parsed_result;
14178 struct rte_port *port;
14181 int ret = -ENOTSUP;
14183 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14186 port = &ports[res->port_id];
14187 /** Check if the port is not started **/
14188 if (port->port_status != RTE_PORT_STOPPED) {
14189 printf("Please stop port %d first\n", res->port_id);
14193 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14197 #ifdef RTE_LIBRTE_IXGBE_PMD
14198 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14205 printf("invalid bandwidth\n");
14208 printf("invalid port_id %d\n", res->port_id);
14211 printf("function not implemented\n");
14214 printf("programming error: (%s)\n", strerror(-ret));
14218 cmdline_parse_inst_t cmd_tc_min_bw = {
14219 .f = cmd_tc_min_bw_parsed,
14221 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14223 (void *)&cmd_vf_tc_bw_set,
14224 (void *)&cmd_vf_tc_bw_tc,
14225 (void *)&cmd_vf_tc_bw_tx,
14226 (void *)&cmd_vf_tc_bw_min_bw,
14227 (void *)&cmd_vf_tc_bw_port_id,
14228 (void *)&cmd_vf_tc_bw_bw_list,
14233 /* TC max bandwidth setting */
14235 cmd_vf_tc_max_bw_parsed(
14236 void *parsed_result,
14237 __attribute__((unused)) struct cmdline *cl,
14238 __attribute__((unused)) void *data)
14240 struct cmd_vf_tc_bw_result *res = parsed_result;
14241 int ret = -ENOTSUP;
14243 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14246 #ifdef RTE_LIBRTE_I40E_PMD
14247 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14248 res->tc_no, res->bw);
14255 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14256 res->vf_id, res->tc_no, res->bw);
14259 printf("invalid port_id %d\n", res->port_id);
14262 printf("function not implemented\n");
14265 printf("programming error: (%s)\n", strerror(-ret));
14269 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14270 .f = cmd_vf_tc_max_bw_parsed,
14272 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14275 (void *)&cmd_vf_tc_bw_set,
14276 (void *)&cmd_vf_tc_bw_vf,
14277 (void *)&cmd_vf_tc_bw_tc,
14278 (void *)&cmd_vf_tc_bw_tx,
14279 (void *)&cmd_vf_tc_bw_max_bw,
14280 (void *)&cmd_vf_tc_bw_port_id,
14281 (void *)&cmd_vf_tc_bw_vf_id,
14282 (void *)&cmd_vf_tc_bw_tc_no,
14283 (void *)&cmd_vf_tc_bw_bw,
14289 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14291 /* *** Set Port default Traffic Management Hierarchy *** */
14292 struct cmd_set_port_tm_hierarchy_default_result {
14293 cmdline_fixed_string_t set;
14294 cmdline_fixed_string_t port;
14295 cmdline_fixed_string_t tm;
14296 cmdline_fixed_string_t hierarchy;
14297 cmdline_fixed_string_t def;
14301 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14302 TOKEN_STRING_INITIALIZER(
14303 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14304 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14305 TOKEN_STRING_INITIALIZER(
14306 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14307 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14308 TOKEN_STRING_INITIALIZER(
14309 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14310 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14311 TOKEN_STRING_INITIALIZER(
14312 struct cmd_set_port_tm_hierarchy_default_result,
14313 hierarchy, "hierarchy");
14314 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14315 TOKEN_STRING_INITIALIZER(
14316 struct cmd_set_port_tm_hierarchy_default_result,
14318 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14319 TOKEN_NUM_INITIALIZER(
14320 struct cmd_set_port_tm_hierarchy_default_result,
14323 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14324 __attribute__((unused)) struct cmdline *cl,
14325 __attribute__((unused)) void *data)
14327 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14328 struct rte_port *p;
14329 portid_t port_id = res->port_id;
14331 if (port_id_is_invalid(port_id, ENABLED_WARN))
14334 p = &ports[port_id];
14337 if (p->softport.tm_flag == 0) {
14338 printf(" tm not enabled on port %u (error)\n", port_id);
14342 /* Forward mode: tm */
14343 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14344 printf(" tm mode not enabled(error)\n");
14348 /* Set the default tm hierarchy */
14349 p->softport.tm.default_hierarchy_enable = 1;
14352 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14353 .f = cmd_set_port_tm_hierarchy_default_parsed,
14355 .help_str = "set port tm hierarchy default <port_id>",
14357 (void *)&cmd_set_port_tm_hierarchy_default_set,
14358 (void *)&cmd_set_port_tm_hierarchy_default_port,
14359 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14360 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14361 (void *)&cmd_set_port_tm_hierarchy_default_default,
14362 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14368 /* Strict link priority scheduling mode setting */
14370 cmd_strict_link_prio_parsed(
14371 void *parsed_result,
14372 __attribute__((unused)) struct cmdline *cl,
14373 __attribute__((unused)) void *data)
14375 struct cmd_vf_tc_bw_result *res = parsed_result;
14376 int ret = -ENOTSUP;
14378 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14381 #ifdef RTE_LIBRTE_I40E_PMD
14382 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14389 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14392 printf("invalid port_id %d\n", res->port_id);
14395 printf("function not implemented\n");
14398 printf("programming error: (%s)\n", strerror(-ret));
14402 cmdline_parse_inst_t cmd_strict_link_prio = {
14403 .f = cmd_strict_link_prio_parsed,
14405 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14407 (void *)&cmd_vf_tc_bw_set,
14408 (void *)&cmd_vf_tc_bw_tx,
14409 (void *)&cmd_vf_tc_bw_strict_link_prio,
14410 (void *)&cmd_vf_tc_bw_port_id,
14411 (void *)&cmd_vf_tc_bw_tc_map,
14416 /* Load dynamic device personalization*/
14417 struct cmd_ddp_add_result {
14418 cmdline_fixed_string_t ddp;
14419 cmdline_fixed_string_t add;
14424 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14425 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14426 cmdline_parse_token_string_t cmd_ddp_add_add =
14427 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14428 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14429 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14430 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14431 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14434 cmd_ddp_add_parsed(
14435 void *parsed_result,
14436 __attribute__((unused)) struct cmdline *cl,
14437 __attribute__((unused)) void *data)
14439 struct cmd_ddp_add_result *res = parsed_result;
14445 int ret = -ENOTSUP;
14447 if (res->port_id > nb_ports) {
14448 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14452 if (!all_ports_stopped()) {
14453 printf("Please stop all ports first\n");
14457 filepath = strdup(res->filepath);
14458 if (filepath == NULL) {
14459 printf("Failed to allocate memory\n");
14462 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14464 buff = open_file(file_fld[0], &size);
14466 free((void *)filepath);
14470 #ifdef RTE_LIBRTE_I40E_PMD
14471 if (ret == -ENOTSUP)
14472 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14474 RTE_PMD_I40E_PKG_OP_WR_ADD);
14477 if (ret == -EEXIST)
14478 printf("Profile has already existed.\n");
14480 printf("Failed to load profile.\n");
14481 else if (file_num == 2)
14482 save_file(file_fld[1], buff, size);
14485 free((void *)filepath);
14488 cmdline_parse_inst_t cmd_ddp_add = {
14489 .f = cmd_ddp_add_parsed,
14491 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14493 (void *)&cmd_ddp_add_ddp,
14494 (void *)&cmd_ddp_add_add,
14495 (void *)&cmd_ddp_add_port_id,
14496 (void *)&cmd_ddp_add_filepath,
14501 /* Delete dynamic device personalization*/
14502 struct cmd_ddp_del_result {
14503 cmdline_fixed_string_t ddp;
14504 cmdline_fixed_string_t del;
14509 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14510 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14511 cmdline_parse_token_string_t cmd_ddp_del_del =
14512 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14513 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14514 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14515 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14516 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14519 cmd_ddp_del_parsed(
14520 void *parsed_result,
14521 __attribute__((unused)) struct cmdline *cl,
14522 __attribute__((unused)) void *data)
14524 struct cmd_ddp_del_result *res = parsed_result;
14527 int ret = -ENOTSUP;
14529 if (res->port_id > nb_ports) {
14530 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14534 if (!all_ports_stopped()) {
14535 printf("Please stop all ports first\n");
14539 buff = open_file(res->filepath, &size);
14543 #ifdef RTE_LIBRTE_I40E_PMD
14544 if (ret == -ENOTSUP)
14545 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14547 RTE_PMD_I40E_PKG_OP_WR_DEL);
14550 if (ret == -EACCES)
14551 printf("Profile does not exist.\n");
14553 printf("Failed to delete profile.\n");
14558 cmdline_parse_inst_t cmd_ddp_del = {
14559 .f = cmd_ddp_del_parsed,
14561 .help_str = "ddp del <port_id> <profile_path>",
14563 (void *)&cmd_ddp_del_ddp,
14564 (void *)&cmd_ddp_del_del,
14565 (void *)&cmd_ddp_del_port_id,
14566 (void *)&cmd_ddp_del_filepath,
14571 /* Get dynamic device personalization profile info */
14572 struct cmd_ddp_info_result {
14573 cmdline_fixed_string_t ddp;
14574 cmdline_fixed_string_t get;
14575 cmdline_fixed_string_t info;
14579 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14580 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14581 cmdline_parse_token_string_t cmd_ddp_info_get =
14582 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14583 cmdline_parse_token_string_t cmd_ddp_info_info =
14584 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14585 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14586 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14589 cmd_ddp_info_parsed(
14590 void *parsed_result,
14591 __attribute__((unused)) struct cmdline *cl,
14592 __attribute__((unused)) void *data)
14594 struct cmd_ddp_info_result *res = parsed_result;
14597 int ret = -ENOTSUP;
14598 #ifdef RTE_LIBRTE_I40E_PMD
14601 uint32_t buff_size = 0;
14602 struct rte_pmd_i40e_profile_info info;
14603 uint32_t dev_num = 0;
14604 struct rte_pmd_i40e_ddp_device_id *devs;
14605 uint32_t proto_num = 0;
14606 struct rte_pmd_i40e_proto_info *proto = NULL;
14607 uint32_t pctype_num = 0;
14608 struct rte_pmd_i40e_ptype_info *pctype;
14609 uint32_t ptype_num = 0;
14610 struct rte_pmd_i40e_ptype_info *ptype;
14615 pkg = open_file(res->filepath, &pkg_size);
14619 #ifdef RTE_LIBRTE_I40E_PMD
14620 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14621 (uint8_t *)&info, sizeof(info),
14622 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14624 printf("Global Track id: 0x%x\n", info.track_id);
14625 printf("Global Version: %d.%d.%d.%d\n",
14626 info.version.major,
14627 info.version.minor,
14628 info.version.update,
14629 info.version.draft);
14630 printf("Global Package name: %s\n\n", info.name);
14633 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14634 (uint8_t *)&info, sizeof(info),
14635 RTE_PMD_I40E_PKG_INFO_HEADER);
14637 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14638 printf("i40e Profile Version: %d.%d.%d.%d\n",
14639 info.version.major,
14640 info.version.minor,
14641 info.version.update,
14642 info.version.draft);
14643 printf("i40e Profile name: %s\n\n", info.name);
14646 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14647 (uint8_t *)&buff_size, sizeof(buff_size),
14648 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14649 if (!ret && buff_size) {
14650 buff = (uint8_t *)malloc(buff_size);
14652 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14654 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14656 printf("Package Notes:\n%s\n\n", buff);
14661 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14662 (uint8_t *)&dev_num, sizeof(dev_num),
14663 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14664 if (!ret && dev_num) {
14665 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14666 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14668 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14669 (uint8_t *)devs, buff_size,
14670 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14672 printf("List of supported devices:\n");
14673 for (i = 0; i < dev_num; i++) {
14674 printf(" %04X:%04X %04X:%04X\n",
14675 devs[i].vendor_dev_id >> 16,
14676 devs[i].vendor_dev_id & 0xFFFF,
14677 devs[i].sub_vendor_dev_id >> 16,
14678 devs[i].sub_vendor_dev_id & 0xFFFF);
14686 /* get information about protocols and packet types */
14687 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14688 (uint8_t *)&proto_num, sizeof(proto_num),
14689 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14690 if (ret || !proto_num)
14691 goto no_print_return;
14693 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14694 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14696 goto no_print_return;
14698 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14700 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14702 printf("List of used protocols:\n");
14703 for (i = 0; i < proto_num; i++)
14704 printf(" %2u: %s\n", proto[i].proto_id,
14708 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14709 (uint8_t *)&pctype_num, sizeof(pctype_num),
14710 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14711 if (ret || !pctype_num)
14712 goto no_print_pctypes;
14714 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14715 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14717 goto no_print_pctypes;
14719 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14721 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14724 goto no_print_pctypes;
14727 printf("List of defined packet classification types:\n");
14728 for (i = 0; i < pctype_num; i++) {
14729 printf(" %2u:", pctype[i].ptype_id);
14730 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14731 proto_id = pctype[i].protocols[j];
14732 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14733 for (n = 0; n < proto_num; n++) {
14734 if (proto[n].proto_id == proto_id) {
14735 printf(" %s", proto[n].name);
14748 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14750 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14751 if (ret || !ptype_num)
14752 goto no_print_return;
14754 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14755 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14757 goto no_print_return;
14759 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14761 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14764 goto no_print_return;
14766 printf("List of defined packet types:\n");
14767 for (i = 0; i < ptype_num; i++) {
14768 printf(" %2u:", ptype[i].ptype_id);
14769 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14770 proto_id = ptype[i].protocols[j];
14771 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14772 for (n = 0; n < proto_num; n++) {
14773 if (proto[n].proto_id == proto_id) {
14774 printf(" %s", proto[n].name);
14790 if (ret == -ENOTSUP)
14791 printf("Function not supported in PMD driver\n");
14795 cmdline_parse_inst_t cmd_ddp_get_info = {
14796 .f = cmd_ddp_info_parsed,
14798 .help_str = "ddp get info <profile_path>",
14800 (void *)&cmd_ddp_info_ddp,
14801 (void *)&cmd_ddp_info_get,
14802 (void *)&cmd_ddp_info_info,
14803 (void *)&cmd_ddp_info_filepath,
14808 /* Get dynamic device personalization profile info list*/
14809 #define PROFILE_INFO_SIZE 48
14810 #define MAX_PROFILE_NUM 16
14812 struct cmd_ddp_get_list_result {
14813 cmdline_fixed_string_t ddp;
14814 cmdline_fixed_string_t get;
14815 cmdline_fixed_string_t list;
14819 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14820 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14821 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14822 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14823 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14824 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14825 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14826 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14829 cmd_ddp_get_list_parsed(
14830 void *parsed_result,
14831 __attribute__((unused)) struct cmdline *cl,
14832 __attribute__((unused)) void *data)
14834 struct cmd_ddp_get_list_result *res = parsed_result;
14835 #ifdef RTE_LIBRTE_I40E_PMD
14836 struct rte_pmd_i40e_profile_list *p_list;
14837 struct rte_pmd_i40e_profile_info *p_info;
14842 int ret = -ENOTSUP;
14844 if (res->port_id > nb_ports) {
14845 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14849 #ifdef RTE_LIBRTE_I40E_PMD
14850 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14851 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14853 printf("%s: Failed to malloc buffer\n", __func__);
14855 if (ret == -ENOTSUP)
14856 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14857 (uint8_t *)p_list, size);
14860 p_num = p_list->p_count;
14861 printf("Profile number is: %d\n\n", p_num);
14863 for (i = 0; i < p_num; i++) {
14864 p_info = &p_list->p_info[i];
14865 printf("Profile %d:\n", i);
14866 printf("Track id: 0x%x\n", p_info->track_id);
14867 printf("Version: %d.%d.%d.%d\n",
14868 p_info->version.major,
14869 p_info->version.minor,
14870 p_info->version.update,
14871 p_info->version.draft);
14872 printf("Profile name: %s\n\n", p_info->name);
14880 printf("Failed to get ddp list\n");
14883 cmdline_parse_inst_t cmd_ddp_get_list = {
14884 .f = cmd_ddp_get_list_parsed,
14886 .help_str = "ddp get list <port_id>",
14888 (void *)&cmd_ddp_get_list_ddp,
14889 (void *)&cmd_ddp_get_list_get,
14890 (void *)&cmd_ddp_get_list_list,
14891 (void *)&cmd_ddp_get_list_port_id,
14896 /* Configure input set */
14897 struct cmd_cfg_input_set_result {
14898 cmdline_fixed_string_t port;
14899 cmdline_fixed_string_t cfg;
14901 cmdline_fixed_string_t pctype;
14903 cmdline_fixed_string_t inset_type;
14904 cmdline_fixed_string_t opt;
14905 cmdline_fixed_string_t field;
14910 cmd_cfg_input_set_parsed(
14911 void *parsed_result,
14912 __attribute__((unused)) struct cmdline *cl,
14913 __attribute__((unused)) void *data)
14915 struct cmd_cfg_input_set_result *res = parsed_result;
14916 #ifdef RTE_LIBRTE_I40E_PMD
14917 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14918 struct rte_pmd_i40e_inset inset;
14920 int ret = -ENOTSUP;
14922 if (res->port_id > nb_ports) {
14923 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14927 if (!all_ports_stopped()) {
14928 printf("Please stop all ports first\n");
14932 #ifdef RTE_LIBRTE_I40E_PMD
14933 if (!strcmp(res->inset_type, "hash_inset"))
14934 inset_type = INSET_HASH;
14935 else if (!strcmp(res->inset_type, "fdir_inset"))
14936 inset_type = INSET_FDIR;
14937 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14938 inset_type = INSET_FDIR_FLX;
14939 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14940 &inset, inset_type);
14942 printf("Failed to get input set.\n");
14946 if (!strcmp(res->opt, "get")) {
14947 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14950 printf("Field index %d is enabled.\n", res->field_idx);
14952 printf("Field index %d is disabled.\n", res->field_idx);
14954 } else if (!strcmp(res->opt, "set"))
14955 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14957 else if (!strcmp(res->opt, "clear"))
14958 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14961 printf("Failed to configure input set field.\n");
14965 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14966 &inset, inset_type);
14968 printf("Failed to set input set.\n");
14973 if (ret == -ENOTSUP)
14974 printf("Function not supported\n");
14977 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14978 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14980 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14981 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14983 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14984 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14986 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14987 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14989 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14990 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14992 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14993 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14995 "hash_inset#fdir_inset#fdir_flx_inset");
14996 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14997 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14998 opt, "get#set#clear");
14999 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15000 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15002 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15003 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15006 cmdline_parse_inst_t cmd_cfg_input_set = {
15007 .f = cmd_cfg_input_set_parsed,
15009 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15010 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15012 (void *)&cmd_cfg_input_set_port,
15013 (void *)&cmd_cfg_input_set_cfg,
15014 (void *)&cmd_cfg_input_set_port_id,
15015 (void *)&cmd_cfg_input_set_pctype,
15016 (void *)&cmd_cfg_input_set_pctype_id,
15017 (void *)&cmd_cfg_input_set_inset_type,
15018 (void *)&cmd_cfg_input_set_opt,
15019 (void *)&cmd_cfg_input_set_field,
15020 (void *)&cmd_cfg_input_set_field_idx,
15025 /* Clear input set */
15026 struct cmd_clear_input_set_result {
15027 cmdline_fixed_string_t port;
15028 cmdline_fixed_string_t cfg;
15030 cmdline_fixed_string_t pctype;
15032 cmdline_fixed_string_t inset_type;
15033 cmdline_fixed_string_t clear;
15034 cmdline_fixed_string_t all;
15038 cmd_clear_input_set_parsed(
15039 void *parsed_result,
15040 __attribute__((unused)) struct cmdline *cl,
15041 __attribute__((unused)) void *data)
15043 struct cmd_clear_input_set_result *res = parsed_result;
15044 #ifdef RTE_LIBRTE_I40E_PMD
15045 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15046 struct rte_pmd_i40e_inset inset;
15048 int ret = -ENOTSUP;
15050 if (res->port_id > nb_ports) {
15051 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
15055 if (!all_ports_stopped()) {
15056 printf("Please stop all ports first\n");
15060 #ifdef RTE_LIBRTE_I40E_PMD
15061 if (!strcmp(res->inset_type, "hash_inset"))
15062 inset_type = INSET_HASH;
15063 else if (!strcmp(res->inset_type, "fdir_inset"))
15064 inset_type = INSET_FDIR;
15065 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15066 inset_type = INSET_FDIR_FLX;
15068 memset(&inset, 0, sizeof(inset));
15070 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15071 &inset, inset_type);
15073 printf("Failed to clear input set.\n");
15079 if (ret == -ENOTSUP)
15080 printf("Function not supported\n");
15083 cmdline_parse_token_string_t cmd_clear_input_set_port =
15084 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15086 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15087 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15089 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15090 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15092 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15093 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15095 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15096 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15098 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15099 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15101 "hash_inset#fdir_inset#fdir_flx_inset");
15102 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15103 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15105 cmdline_parse_token_string_t cmd_clear_input_set_all =
15106 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15109 cmdline_parse_inst_t cmd_clear_input_set = {
15110 .f = cmd_clear_input_set_parsed,
15112 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15113 "fdir_inset|fdir_flx_inset clear all",
15115 (void *)&cmd_clear_input_set_port,
15116 (void *)&cmd_clear_input_set_cfg,
15117 (void *)&cmd_clear_input_set_port_id,
15118 (void *)&cmd_clear_input_set_pctype,
15119 (void *)&cmd_clear_input_set_pctype_id,
15120 (void *)&cmd_clear_input_set_inset_type,
15121 (void *)&cmd_clear_input_set_clear,
15122 (void *)&cmd_clear_input_set_all,
15127 /* show vf stats */
15129 /* Common result structure for show vf stats */
15130 struct cmd_show_vf_stats_result {
15131 cmdline_fixed_string_t show;
15132 cmdline_fixed_string_t vf;
15133 cmdline_fixed_string_t stats;
15138 /* Common CLI fields show vf stats*/
15139 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15140 TOKEN_STRING_INITIALIZER
15141 (struct cmd_show_vf_stats_result,
15143 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15144 TOKEN_STRING_INITIALIZER
15145 (struct cmd_show_vf_stats_result,
15147 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15148 TOKEN_STRING_INITIALIZER
15149 (struct cmd_show_vf_stats_result,
15151 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15152 TOKEN_NUM_INITIALIZER
15153 (struct cmd_show_vf_stats_result,
15155 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15156 TOKEN_NUM_INITIALIZER
15157 (struct cmd_show_vf_stats_result,
15161 cmd_show_vf_stats_parsed(
15162 void *parsed_result,
15163 __attribute__((unused)) struct cmdline *cl,
15164 __attribute__((unused)) void *data)
15166 struct cmd_show_vf_stats_result *res = parsed_result;
15167 struct rte_eth_stats stats;
15168 int ret = -ENOTSUP;
15169 static const char *nic_stats_border = "########################";
15171 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15174 memset(&stats, 0, sizeof(stats));
15176 #ifdef RTE_LIBRTE_I40E_PMD
15177 if (ret == -ENOTSUP)
15178 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15182 #ifdef RTE_LIBRTE_BNXT_PMD
15183 if (ret == -ENOTSUP)
15184 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15193 printf("invalid vf_id %d\n", res->vf_id);
15196 printf("invalid port_id %d\n", res->port_id);
15199 printf("function not implemented\n");
15202 printf("programming error: (%s)\n", strerror(-ret));
15205 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15206 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15208 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15210 stats.ipackets, stats.imissed, stats.ibytes);
15211 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15212 printf(" RX-nombuf: %-10"PRIu64"\n",
15214 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15216 stats.opackets, stats.oerrors, stats.obytes);
15218 printf(" %s############################%s\n",
15219 nic_stats_border, nic_stats_border);
15222 cmdline_parse_inst_t cmd_show_vf_stats = {
15223 .f = cmd_show_vf_stats_parsed,
15225 .help_str = "show vf stats <port_id> <vf_id>",
15227 (void *)&cmd_show_vf_stats_show,
15228 (void *)&cmd_show_vf_stats_vf,
15229 (void *)&cmd_show_vf_stats_stats,
15230 (void *)&cmd_show_vf_stats_port_id,
15231 (void *)&cmd_show_vf_stats_vf_id,
15236 /* clear vf stats */
15238 /* Common result structure for clear vf stats */
15239 struct cmd_clear_vf_stats_result {
15240 cmdline_fixed_string_t clear;
15241 cmdline_fixed_string_t vf;
15242 cmdline_fixed_string_t stats;
15247 /* Common CLI fields clear vf stats*/
15248 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15249 TOKEN_STRING_INITIALIZER
15250 (struct cmd_clear_vf_stats_result,
15252 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15253 TOKEN_STRING_INITIALIZER
15254 (struct cmd_clear_vf_stats_result,
15256 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15257 TOKEN_STRING_INITIALIZER
15258 (struct cmd_clear_vf_stats_result,
15260 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15261 TOKEN_NUM_INITIALIZER
15262 (struct cmd_clear_vf_stats_result,
15264 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15265 TOKEN_NUM_INITIALIZER
15266 (struct cmd_clear_vf_stats_result,
15270 cmd_clear_vf_stats_parsed(
15271 void *parsed_result,
15272 __attribute__((unused)) struct cmdline *cl,
15273 __attribute__((unused)) void *data)
15275 struct cmd_clear_vf_stats_result *res = parsed_result;
15276 int ret = -ENOTSUP;
15278 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15281 #ifdef RTE_LIBRTE_I40E_PMD
15282 if (ret == -ENOTSUP)
15283 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15286 #ifdef RTE_LIBRTE_BNXT_PMD
15287 if (ret == -ENOTSUP)
15288 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15296 printf("invalid vf_id %d\n", res->vf_id);
15299 printf("invalid port_id %d\n", res->port_id);
15302 printf("function not implemented\n");
15305 printf("programming error: (%s)\n", strerror(-ret));
15309 cmdline_parse_inst_t cmd_clear_vf_stats = {
15310 .f = cmd_clear_vf_stats_parsed,
15312 .help_str = "clear vf stats <port_id> <vf_id>",
15314 (void *)&cmd_clear_vf_stats_clear,
15315 (void *)&cmd_clear_vf_stats_vf,
15316 (void *)&cmd_clear_vf_stats_stats,
15317 (void *)&cmd_clear_vf_stats_port_id,
15318 (void *)&cmd_clear_vf_stats_vf_id,
15323 /* port config pctype mapping reset */
15325 /* Common result structure for port config pctype mapping reset */
15326 struct cmd_pctype_mapping_reset_result {
15327 cmdline_fixed_string_t port;
15328 cmdline_fixed_string_t config;
15330 cmdline_fixed_string_t pctype;
15331 cmdline_fixed_string_t mapping;
15332 cmdline_fixed_string_t reset;
15335 /* Common CLI fields for port config pctype mapping reset*/
15336 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15337 TOKEN_STRING_INITIALIZER
15338 (struct cmd_pctype_mapping_reset_result,
15340 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15341 TOKEN_STRING_INITIALIZER
15342 (struct cmd_pctype_mapping_reset_result,
15344 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15345 TOKEN_NUM_INITIALIZER
15346 (struct cmd_pctype_mapping_reset_result,
15348 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15349 TOKEN_STRING_INITIALIZER
15350 (struct cmd_pctype_mapping_reset_result,
15352 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15353 TOKEN_STRING_INITIALIZER
15354 (struct cmd_pctype_mapping_reset_result,
15355 mapping, "mapping");
15356 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15357 TOKEN_STRING_INITIALIZER
15358 (struct cmd_pctype_mapping_reset_result,
15362 cmd_pctype_mapping_reset_parsed(
15363 void *parsed_result,
15364 __attribute__((unused)) struct cmdline *cl,
15365 __attribute__((unused)) void *data)
15367 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15368 int ret = -ENOTSUP;
15370 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15373 #ifdef RTE_LIBRTE_I40E_PMD
15374 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15381 printf("invalid port_id %d\n", res->port_id);
15384 printf("function not implemented\n");
15387 printf("programming error: (%s)\n", strerror(-ret));
15391 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15392 .f = cmd_pctype_mapping_reset_parsed,
15394 .help_str = "port config <port_id> pctype mapping reset",
15396 (void *)&cmd_pctype_mapping_reset_port,
15397 (void *)&cmd_pctype_mapping_reset_config,
15398 (void *)&cmd_pctype_mapping_reset_port_id,
15399 (void *)&cmd_pctype_mapping_reset_pctype,
15400 (void *)&cmd_pctype_mapping_reset_mapping,
15401 (void *)&cmd_pctype_mapping_reset_reset,
15406 /* show port pctype mapping */
15408 /* Common result structure for show port pctype mapping */
15409 struct cmd_pctype_mapping_get_result {
15410 cmdline_fixed_string_t show;
15411 cmdline_fixed_string_t port;
15413 cmdline_fixed_string_t pctype;
15414 cmdline_fixed_string_t mapping;
15417 /* Common CLI fields for pctype mapping get */
15418 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15419 TOKEN_STRING_INITIALIZER
15420 (struct cmd_pctype_mapping_get_result,
15422 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15423 TOKEN_STRING_INITIALIZER
15424 (struct cmd_pctype_mapping_get_result,
15426 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15427 TOKEN_NUM_INITIALIZER
15428 (struct cmd_pctype_mapping_get_result,
15430 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15431 TOKEN_STRING_INITIALIZER
15432 (struct cmd_pctype_mapping_get_result,
15434 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15435 TOKEN_STRING_INITIALIZER
15436 (struct cmd_pctype_mapping_get_result,
15437 mapping, "mapping");
15440 cmd_pctype_mapping_get_parsed(
15441 void *parsed_result,
15442 __attribute__((unused)) struct cmdline *cl,
15443 __attribute__((unused)) void *data)
15445 struct cmd_pctype_mapping_get_result *res = parsed_result;
15446 int ret = -ENOTSUP;
15447 #ifdef RTE_LIBRTE_I40E_PMD
15448 struct rte_pmd_i40e_flow_type_mapping
15449 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15450 int i, j, first_pctype;
15453 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15456 #ifdef RTE_LIBRTE_I40E_PMD
15457 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15464 printf("invalid port_id %d\n", res->port_id);
15467 printf("function not implemented\n");
15470 printf("programming error: (%s)\n", strerror(-ret));
15474 #ifdef RTE_LIBRTE_I40E_PMD
15475 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15476 if (mapping[i].pctype != 0ULL) {
15479 printf("pctype: ");
15480 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15481 if (mapping[i].pctype & (1ULL << j)) {
15482 printf(first_pctype ?
15483 "%02d" : ",%02d", j);
15487 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15493 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15494 .f = cmd_pctype_mapping_get_parsed,
15496 .help_str = "show port <port_id> pctype mapping",
15498 (void *)&cmd_pctype_mapping_get_show,
15499 (void *)&cmd_pctype_mapping_get_port,
15500 (void *)&cmd_pctype_mapping_get_port_id,
15501 (void *)&cmd_pctype_mapping_get_pctype,
15502 (void *)&cmd_pctype_mapping_get_mapping,
15507 /* port config pctype mapping update */
15509 /* Common result structure for port config pctype mapping update */
15510 struct cmd_pctype_mapping_update_result {
15511 cmdline_fixed_string_t port;
15512 cmdline_fixed_string_t config;
15514 cmdline_fixed_string_t pctype;
15515 cmdline_fixed_string_t mapping;
15516 cmdline_fixed_string_t update;
15517 cmdline_fixed_string_t pctype_list;
15518 uint16_t flow_type;
15521 /* Common CLI fields for pctype mapping update*/
15522 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15523 TOKEN_STRING_INITIALIZER
15524 (struct cmd_pctype_mapping_update_result,
15526 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15527 TOKEN_STRING_INITIALIZER
15528 (struct cmd_pctype_mapping_update_result,
15530 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15531 TOKEN_NUM_INITIALIZER
15532 (struct cmd_pctype_mapping_update_result,
15534 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15535 TOKEN_STRING_INITIALIZER
15536 (struct cmd_pctype_mapping_update_result,
15538 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15539 TOKEN_STRING_INITIALIZER
15540 (struct cmd_pctype_mapping_update_result,
15541 mapping, "mapping");
15542 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15543 TOKEN_STRING_INITIALIZER
15544 (struct cmd_pctype_mapping_update_result,
15546 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15547 TOKEN_STRING_INITIALIZER
15548 (struct cmd_pctype_mapping_update_result,
15549 pctype_list, NULL);
15550 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15551 TOKEN_NUM_INITIALIZER
15552 (struct cmd_pctype_mapping_update_result,
15553 flow_type, UINT16);
15556 cmd_pctype_mapping_update_parsed(
15557 void *parsed_result,
15558 __attribute__((unused)) struct cmdline *cl,
15559 __attribute__((unused)) void *data)
15561 struct cmd_pctype_mapping_update_result *res = parsed_result;
15562 int ret = -ENOTSUP;
15563 #ifdef RTE_LIBRTE_I40E_PMD
15564 struct rte_pmd_i40e_flow_type_mapping mapping;
15566 unsigned int nb_item;
15567 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15570 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15573 #ifdef RTE_LIBRTE_I40E_PMD
15574 nb_item = parse_item_list(res->pctype_list, "pctypes",
15575 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15576 mapping.flow_type = res->flow_type;
15577 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15578 mapping.pctype |= (1ULL << pctype_list[i]);
15579 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15589 printf("invalid pctype or flow type\n");
15592 printf("invalid port_id %d\n", res->port_id);
15595 printf("function not implemented\n");
15598 printf("programming error: (%s)\n", strerror(-ret));
15602 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15603 .f = cmd_pctype_mapping_update_parsed,
15605 .help_str = "port config <port_id> pctype mapping update"
15606 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15608 (void *)&cmd_pctype_mapping_update_port,
15609 (void *)&cmd_pctype_mapping_update_config,
15610 (void *)&cmd_pctype_mapping_update_port_id,
15611 (void *)&cmd_pctype_mapping_update_pctype,
15612 (void *)&cmd_pctype_mapping_update_mapping,
15613 (void *)&cmd_pctype_mapping_update_update,
15614 (void *)&cmd_pctype_mapping_update_pc_type,
15615 (void *)&cmd_pctype_mapping_update_flow_type,
15620 /* ptype mapping get */
15622 /* Common result structure for ptype mapping get */
15623 struct cmd_ptype_mapping_get_result {
15624 cmdline_fixed_string_t ptype;
15625 cmdline_fixed_string_t mapping;
15626 cmdline_fixed_string_t get;
15628 uint8_t valid_only;
15631 /* Common CLI fields for ptype mapping get */
15632 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15633 TOKEN_STRING_INITIALIZER
15634 (struct cmd_ptype_mapping_get_result,
15636 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15637 TOKEN_STRING_INITIALIZER
15638 (struct cmd_ptype_mapping_get_result,
15639 mapping, "mapping");
15640 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15641 TOKEN_STRING_INITIALIZER
15642 (struct cmd_ptype_mapping_get_result,
15644 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15645 TOKEN_NUM_INITIALIZER
15646 (struct cmd_ptype_mapping_get_result,
15648 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15649 TOKEN_NUM_INITIALIZER
15650 (struct cmd_ptype_mapping_get_result,
15651 valid_only, UINT8);
15654 cmd_ptype_mapping_get_parsed(
15655 void *parsed_result,
15656 __attribute__((unused)) struct cmdline *cl,
15657 __attribute__((unused)) void *data)
15659 struct cmd_ptype_mapping_get_result *res = parsed_result;
15660 int ret = -ENOTSUP;
15661 #ifdef RTE_LIBRTE_I40E_PMD
15662 int max_ptype_num = 256;
15663 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15668 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15671 #ifdef RTE_LIBRTE_I40E_PMD
15672 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15683 printf("invalid port_id %d\n", res->port_id);
15686 printf("function not implemented\n");
15689 printf("programming error: (%s)\n", strerror(-ret));
15692 #ifdef RTE_LIBRTE_I40E_PMD
15694 for (i = 0; i < count; i++)
15695 printf("%3d\t0x%08x\n",
15696 mapping[i].hw_ptype, mapping[i].sw_ptype);
15701 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15702 .f = cmd_ptype_mapping_get_parsed,
15704 .help_str = "ptype mapping get <port_id> <valid_only>",
15706 (void *)&cmd_ptype_mapping_get_ptype,
15707 (void *)&cmd_ptype_mapping_get_mapping,
15708 (void *)&cmd_ptype_mapping_get_get,
15709 (void *)&cmd_ptype_mapping_get_port_id,
15710 (void *)&cmd_ptype_mapping_get_valid_only,
15715 /* ptype mapping replace */
15717 /* Common result structure for ptype mapping replace */
15718 struct cmd_ptype_mapping_replace_result {
15719 cmdline_fixed_string_t ptype;
15720 cmdline_fixed_string_t mapping;
15721 cmdline_fixed_string_t replace;
15728 /* Common CLI fields for ptype mapping replace */
15729 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15730 TOKEN_STRING_INITIALIZER
15731 (struct cmd_ptype_mapping_replace_result,
15733 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15734 TOKEN_STRING_INITIALIZER
15735 (struct cmd_ptype_mapping_replace_result,
15736 mapping, "mapping");
15737 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15738 TOKEN_STRING_INITIALIZER
15739 (struct cmd_ptype_mapping_replace_result,
15740 replace, "replace");
15741 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15742 TOKEN_NUM_INITIALIZER
15743 (struct cmd_ptype_mapping_replace_result,
15745 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15746 TOKEN_NUM_INITIALIZER
15747 (struct cmd_ptype_mapping_replace_result,
15749 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15750 TOKEN_NUM_INITIALIZER
15751 (struct cmd_ptype_mapping_replace_result,
15753 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15754 TOKEN_NUM_INITIALIZER
15755 (struct cmd_ptype_mapping_replace_result,
15759 cmd_ptype_mapping_replace_parsed(
15760 void *parsed_result,
15761 __attribute__((unused)) struct cmdline *cl,
15762 __attribute__((unused)) void *data)
15764 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15765 int ret = -ENOTSUP;
15767 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15770 #ifdef RTE_LIBRTE_I40E_PMD
15771 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15781 printf("invalid ptype 0x%8x or 0x%8x\n",
15782 res->target, res->pkt_type);
15785 printf("invalid port_id %d\n", res->port_id);
15788 printf("function not implemented\n");
15791 printf("programming error: (%s)\n", strerror(-ret));
15795 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15796 .f = cmd_ptype_mapping_replace_parsed,
15799 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15801 (void *)&cmd_ptype_mapping_replace_ptype,
15802 (void *)&cmd_ptype_mapping_replace_mapping,
15803 (void *)&cmd_ptype_mapping_replace_replace,
15804 (void *)&cmd_ptype_mapping_replace_port_id,
15805 (void *)&cmd_ptype_mapping_replace_target,
15806 (void *)&cmd_ptype_mapping_replace_mask,
15807 (void *)&cmd_ptype_mapping_replace_pkt_type,
15812 /* ptype mapping reset */
15814 /* Common result structure for ptype mapping reset */
15815 struct cmd_ptype_mapping_reset_result {
15816 cmdline_fixed_string_t ptype;
15817 cmdline_fixed_string_t mapping;
15818 cmdline_fixed_string_t reset;
15822 /* Common CLI fields for ptype mapping reset*/
15823 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15824 TOKEN_STRING_INITIALIZER
15825 (struct cmd_ptype_mapping_reset_result,
15827 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15828 TOKEN_STRING_INITIALIZER
15829 (struct cmd_ptype_mapping_reset_result,
15830 mapping, "mapping");
15831 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15832 TOKEN_STRING_INITIALIZER
15833 (struct cmd_ptype_mapping_reset_result,
15835 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15836 TOKEN_NUM_INITIALIZER
15837 (struct cmd_ptype_mapping_reset_result,
15841 cmd_ptype_mapping_reset_parsed(
15842 void *parsed_result,
15843 __attribute__((unused)) struct cmdline *cl,
15844 __attribute__((unused)) void *data)
15846 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15847 int ret = -ENOTSUP;
15849 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15852 #ifdef RTE_LIBRTE_I40E_PMD
15853 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15860 printf("invalid port_id %d\n", res->port_id);
15863 printf("function not implemented\n");
15866 printf("programming error: (%s)\n", strerror(-ret));
15870 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15871 .f = cmd_ptype_mapping_reset_parsed,
15873 .help_str = "ptype mapping reset <port_id>",
15875 (void *)&cmd_ptype_mapping_reset_ptype,
15876 (void *)&cmd_ptype_mapping_reset_mapping,
15877 (void *)&cmd_ptype_mapping_reset_reset,
15878 (void *)&cmd_ptype_mapping_reset_port_id,
15883 /* ptype mapping update */
15885 /* Common result structure for ptype mapping update */
15886 struct cmd_ptype_mapping_update_result {
15887 cmdline_fixed_string_t ptype;
15888 cmdline_fixed_string_t mapping;
15889 cmdline_fixed_string_t reset;
15895 /* Common CLI fields for ptype mapping update*/
15896 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15897 TOKEN_STRING_INITIALIZER
15898 (struct cmd_ptype_mapping_update_result,
15900 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15901 TOKEN_STRING_INITIALIZER
15902 (struct cmd_ptype_mapping_update_result,
15903 mapping, "mapping");
15904 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15905 TOKEN_STRING_INITIALIZER
15906 (struct cmd_ptype_mapping_update_result,
15908 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15909 TOKEN_NUM_INITIALIZER
15910 (struct cmd_ptype_mapping_update_result,
15912 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15913 TOKEN_NUM_INITIALIZER
15914 (struct cmd_ptype_mapping_update_result,
15916 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15917 TOKEN_NUM_INITIALIZER
15918 (struct cmd_ptype_mapping_update_result,
15922 cmd_ptype_mapping_update_parsed(
15923 void *parsed_result,
15924 __attribute__((unused)) struct cmdline *cl,
15925 __attribute__((unused)) void *data)
15927 struct cmd_ptype_mapping_update_result *res = parsed_result;
15928 int ret = -ENOTSUP;
15929 #ifdef RTE_LIBRTE_I40E_PMD
15930 struct rte_pmd_i40e_ptype_mapping mapping;
15932 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15935 #ifdef RTE_LIBRTE_I40E_PMD
15936 mapping.hw_ptype = res->hw_ptype;
15937 mapping.sw_ptype = res->sw_ptype;
15938 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15948 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15951 printf("invalid port_id %d\n", res->port_id);
15954 printf("function not implemented\n");
15957 printf("programming error: (%s)\n", strerror(-ret));
15961 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15962 .f = cmd_ptype_mapping_update_parsed,
15964 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15966 (void *)&cmd_ptype_mapping_update_ptype,
15967 (void *)&cmd_ptype_mapping_update_mapping,
15968 (void *)&cmd_ptype_mapping_update_update,
15969 (void *)&cmd_ptype_mapping_update_port_id,
15970 (void *)&cmd_ptype_mapping_update_hw_ptype,
15971 (void *)&cmd_ptype_mapping_update_sw_ptype,
15976 /* Common result structure for file commands */
15977 struct cmd_cmdfile_result {
15978 cmdline_fixed_string_t load;
15979 cmdline_fixed_string_t filename;
15982 /* Common CLI fields for file commands */
15983 cmdline_parse_token_string_t cmd_load_cmdfile =
15984 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15985 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15986 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15989 cmd_load_from_file_parsed(
15990 void *parsed_result,
15991 __attribute__((unused)) struct cmdline *cl,
15992 __attribute__((unused)) void *data)
15994 struct cmd_cmdfile_result *res = parsed_result;
15996 cmdline_read_from_file(res->filename);
15999 cmdline_parse_inst_t cmd_load_from_file = {
16000 .f = cmd_load_from_file_parsed,
16002 .help_str = "load <filename>",
16004 (void *)&cmd_load_cmdfile,
16005 (void *)&cmd_load_cmdfile_filename,
16010 /* ******************************************************************************** */
16012 /* list of instructions */
16013 cmdline_parse_ctx_t main_ctx[] = {
16014 (cmdline_parse_inst_t *)&cmd_help_brief,
16015 (cmdline_parse_inst_t *)&cmd_help_long,
16016 (cmdline_parse_inst_t *)&cmd_quit,
16017 (cmdline_parse_inst_t *)&cmd_load_from_file,
16018 (cmdline_parse_inst_t *)&cmd_showport,
16019 (cmdline_parse_inst_t *)&cmd_showqueue,
16020 (cmdline_parse_inst_t *)&cmd_showportall,
16021 (cmdline_parse_inst_t *)&cmd_showcfg,
16022 (cmdline_parse_inst_t *)&cmd_start,
16023 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16024 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16025 (cmdline_parse_inst_t *)&cmd_set_link_up,
16026 (cmdline_parse_inst_t *)&cmd_set_link_down,
16027 (cmdline_parse_inst_t *)&cmd_reset,
16028 (cmdline_parse_inst_t *)&cmd_set_numbers,
16029 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16030 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16031 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16032 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16033 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16034 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16035 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16036 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16037 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16038 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16039 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16040 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16041 (cmdline_parse_inst_t *)&cmd_set_link_check,
16042 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16043 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16044 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16045 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16046 #ifdef RTE_LIBRTE_PMD_BOND
16047 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16048 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16049 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16050 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16051 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16052 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16053 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16054 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16055 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16056 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16057 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16059 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16060 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16061 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16062 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16063 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16064 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16065 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16066 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16067 (cmdline_parse_inst_t *)&cmd_csum_set,
16068 (cmdline_parse_inst_t *)&cmd_csum_show,
16069 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16070 (cmdline_parse_inst_t *)&cmd_tso_set,
16071 (cmdline_parse_inst_t *)&cmd_tso_show,
16072 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16073 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16074 (cmdline_parse_inst_t *)&cmd_gro_enable,
16075 (cmdline_parse_inst_t *)&cmd_gro_flush,
16076 (cmdline_parse_inst_t *)&cmd_gro_show,
16077 (cmdline_parse_inst_t *)&cmd_gso_enable,
16078 (cmdline_parse_inst_t *)&cmd_gso_size,
16079 (cmdline_parse_inst_t *)&cmd_gso_show,
16080 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16081 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16082 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16083 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16084 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16085 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16086 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16087 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16088 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16089 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16090 (cmdline_parse_inst_t *)&cmd_config_dcb,
16091 (cmdline_parse_inst_t *)&cmd_read_reg,
16092 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16093 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16094 (cmdline_parse_inst_t *)&cmd_write_reg,
16095 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16096 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16097 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16098 (cmdline_parse_inst_t *)&cmd_stop,
16099 (cmdline_parse_inst_t *)&cmd_mac_addr,
16100 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16101 (cmdline_parse_inst_t *)&cmd_set_qmap,
16102 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16103 (cmdline_parse_inst_t *)&cmd_operate_port,
16104 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16105 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16106 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16107 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16108 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16109 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16110 (cmdline_parse_inst_t *)&cmd_config_mtu,
16111 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16112 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16113 (cmdline_parse_inst_t *)&cmd_config_rss,
16114 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16115 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16116 (cmdline_parse_inst_t *)&cmd_showport_reta,
16117 (cmdline_parse_inst_t *)&cmd_config_burst,
16118 (cmdline_parse_inst_t *)&cmd_config_thresh,
16119 (cmdline_parse_inst_t *)&cmd_config_threshold,
16120 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16121 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16122 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16123 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16124 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16125 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16126 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16127 (cmdline_parse_inst_t *)&cmd_global_config,
16128 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16129 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16130 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16131 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16132 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16133 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16134 (cmdline_parse_inst_t *)&cmd_dump,
16135 (cmdline_parse_inst_t *)&cmd_dump_one,
16136 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16137 (cmdline_parse_inst_t *)&cmd_syn_filter,
16138 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16139 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16140 (cmdline_parse_inst_t *)&cmd_flex_filter,
16141 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16142 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16143 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16144 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16145 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16146 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16147 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16148 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16149 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16150 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16151 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16152 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16153 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16154 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16155 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16156 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16157 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16158 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16159 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16160 (cmdline_parse_inst_t *)&cmd_flow,
16161 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16162 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16163 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16164 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16165 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16166 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16167 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16168 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16169 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16170 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16171 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16172 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16173 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16174 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16175 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16176 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16177 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16178 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16179 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16180 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16181 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16182 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16183 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16184 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16185 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16186 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16187 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16188 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16189 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16190 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16191 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16192 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16193 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16194 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16195 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16196 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16197 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16198 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16199 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16200 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16201 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16202 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16203 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16204 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16205 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16206 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16207 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16208 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16209 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16210 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16211 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16213 (cmdline_parse_inst_t *)&cmd_ddp_add,
16214 (cmdline_parse_inst_t *)&cmd_ddp_del,
16215 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16216 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16217 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16218 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16219 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16220 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16221 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16222 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16223 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16224 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16226 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16227 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16228 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16229 (cmdline_parse_inst_t *)&cmd_queue_region,
16230 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16231 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16232 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16233 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16234 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16235 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16236 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16237 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16238 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16239 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16240 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16241 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16242 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16243 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16244 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16245 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16246 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16247 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16248 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16249 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16250 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16254 /* read cmdline commands from file */
16256 cmdline_read_from_file(const char *filename)
16258 struct cmdline *cl;
16260 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16262 printf("Failed to create file based cmdline context: %s\n",
16267 cmdline_interact(cl);
16272 printf("Read CLI commands from %s\n", filename);
16275 /* prompt function, called from main on MASTER lcore */
16279 /* initialize non-constant commands */
16280 cmd_set_fwd_mode_init();
16281 cmd_set_fwd_retry_mode_init();
16283 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16284 if (testpmd_cl == NULL)
16286 cmdline_interact(testpmd_cl);
16287 cmdline_stdin_exit(testpmd_cl);
16293 if (testpmd_cl != NULL)
16294 cmdline_quit(testpmd_cl);
16298 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16300 if (id == (portid_t)RTE_PORT_ALL) {
16303 RTE_ETH_FOREACH_DEV(pid) {
16304 /* check if need_reconfig has been set to 1 */
16305 if (ports[pid].need_reconfig == 0)
16306 ports[pid].need_reconfig = dev;
16307 /* check if need_reconfig_queues has been set to 1 */
16308 if (ports[pid].need_reconfig_queues == 0)
16309 ports[pid].need_reconfig_queues = queue;
16311 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16312 /* check if need_reconfig has been set to 1 */
16313 if (ports[id].need_reconfig == 0)
16314 ports[id].need_reconfig = dev;
16315 /* check if need_reconfig_queues has been set to 1 */
16316 if (ports[id].need_reconfig_queues == 0)
16317 ports[id].need_reconfig_queues = queue;