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"
277 "set log global|(type) (level)\n"
278 " Set the log level.\n\n"
281 " Set number of ports.\n\n"
284 " Set number of cores.\n\n"
286 "set coremask (mask)\n"
287 " Set the forwarding cores hexadecimal mask.\n\n"
289 "set portmask (mask)\n"
290 " Set the forwarding ports hexadecimal mask.\n\n"
293 " Set number of packets per burst.\n\n"
295 "set burst tx delay (microseconds) retry (num)\n"
296 " Set the transmit delay time and number of retries,"
297 " effective when retry is enabled.\n\n"
299 "set txpkts (x[,y]*)\n"
300 " Set the length of each segment of TXONLY"
301 " and optionally CSUM packets.\n\n"
303 "set txsplit (off|on|rand)\n"
304 " Set the split policy for the TX packets."
305 " Right now only applicable for CSUM and TXONLY"
308 "set corelist (x[,y]*)\n"
309 " Set the list of forwarding cores.\n\n"
311 "set portlist (x[,y]*)\n"
312 " Set the list of forwarding ports.\n\n"
314 "set tx loopback (port_id) (on|off)\n"
315 " Enable or disable tx loopback.\n\n"
317 "set all queues drop (port_id) (on|off)\n"
318 " Set drop enable bit for all queues.\n\n"
320 "set vf split drop (port_id) (vf_id) (on|off)\n"
321 " Set split drop enable bit for a VF from the PF.\n\n"
323 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
324 " Set MAC antispoof for a VF from the PF.\n\n"
326 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
327 " Enable MACsec offload.\n\n"
329 "set macsec offload (port_id) off\n"
330 " Disable MACsec offload.\n\n"
332 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
333 " Configure MACsec secure connection (SC).\n\n"
335 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
336 " Configure MACsec secure association (SA).\n\n"
338 "set vf broadcast (port_id) (vf_id) (on|off)\n"
339 " Set VF broadcast for a VF from the PF.\n\n"
341 "vlan set strip (on|off) (port_id)\n"
342 " Set the VLAN strip on a port.\n\n"
344 "vlan set stripq (on|off) (port_id,queue_id)\n"
345 " Set the VLAN strip for a queue on a port.\n\n"
347 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
348 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
350 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
351 " Set VLAN insert for a VF from the PF.\n\n"
353 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
354 " Set VLAN antispoof for a VF from the PF.\n\n"
356 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
357 " Set VLAN tag for a VF from the PF.\n\n"
359 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
360 " Set a VF's max bandwidth(Mbps).\n\n"
362 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
363 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
365 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
366 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
368 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
369 " Set some TCs' strict link priority mode on a physical port.\n\n"
371 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
372 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
374 "vlan set filter (on|off) (port_id)\n"
375 " Set the VLAN filter on a port.\n\n"
377 "vlan set qinq (on|off) (port_id)\n"
378 " Set the VLAN QinQ (extended queue in queue)"
381 "vlan set (inner|outer) tpid (value) (port_id)\n"
382 " Set the VLAN TPID for Packet Filtering on"
385 "rx_vlan add (vlan_id|all) (port_id)\n"
386 " Add a vlan_id, or all identifiers, to the set"
387 " of VLAN identifiers filtered by port_id.\n\n"
389 "rx_vlan rm (vlan_id|all) (port_id)\n"
390 " Remove a vlan_id, or all identifiers, from the set"
391 " of VLAN identifiers filtered by port_id.\n\n"
393 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
394 " Add a vlan_id, to the set of VLAN identifiers"
395 "filtered for VF(s) from port_id.\n\n"
397 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
398 " Remove a vlan_id, to the set of VLAN identifiers"
399 "filtered for VF(s) from port_id.\n\n"
401 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
402 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
403 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
404 " add a tunnel filter of a port.\n\n"
406 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
407 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
408 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
409 " remove a tunnel filter of a port.\n\n"
411 "rx_vxlan_port add (udp_port) (port_id)\n"
412 " Add an UDP port for VXLAN packet filter on a port\n\n"
414 "rx_vxlan_port rm (udp_port) (port_id)\n"
415 " Remove an UDP port for VXLAN packet filter on a port\n\n"
417 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
418 " Set hardware insertion of VLAN IDs (single or double VLAN "
419 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
421 "tx_vlan set pvid port_id vlan_id (on|off)\n"
422 " Set port based TX VLAN insertion.\n\n"
424 "tx_vlan reset (port_id)\n"
425 " Disable hardware insertion of a VLAN header in"
426 " packets sent on a port.\n\n"
428 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
429 " Select hardware or software calculation of the"
430 " checksum when transmitting a packet using the"
431 " csum forward engine.\n"
432 " ip|udp|tcp|sctp always concern the inner layer.\n"
433 " outer-ip concerns the outer IP layer in"
434 " case the packet is recognized as a tunnel packet by"
435 " the forward engine (vxlan, gre and ipip are supported)\n"
436 " Please check the NIC datasheet for HW limits.\n\n"
438 "csum parse-tunnel (on|off) (tx_port_id)\n"
439 " If disabled, treat tunnel packets as non-tunneled"
440 " packets (treat inner headers as payload). The port\n"
441 " argument is the port used for TX in csum forward"
444 "csum show (port_id)\n"
445 " Display tx checksum offload configuration\n\n"
447 "tso set (segsize) (portid)\n"
448 " Enable TCP Segmentation Offload in csum forward"
450 " Please check the NIC datasheet for HW limits.\n\n"
453 " Display the status of TCP Segmentation Offload.\n\n"
455 "set port (port_id) gro on|off\n"
456 " Enable or disable Generic Receive Offload in"
457 " csum forwarding engine.\n\n"
459 "show port (port_id) gro\n"
460 " Display GRO configuration.\n\n"
462 "set gro flush (cycles)\n"
463 " Set the cycle to flush GROed packets from"
464 " reassembly tables.\n\n"
466 "set port (port_id) gso (on|off)"
467 " Enable or disable Generic Segmentation Offload in"
468 " csum forwarding engine.\n\n"
470 "set gso segsz (length)\n"
471 " Set max packet length for output GSO segments,"
472 " including packet header and payload.\n\n"
474 "show port (port_id) gso\n"
475 " Show GSO configuration.\n\n"
478 " Set packet forwarding mode.\n\n"
480 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
481 " Add a MAC address on port_id.\n\n"
483 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
484 " Remove a MAC address from port_id.\n\n"
486 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
487 " Set the default MAC address for port_id.\n\n"
489 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
490 " Add a MAC address for a VF on the port.\n\n"
492 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
493 " Set the MAC address for a VF from the PF.\n\n"
495 "set eth-peer (port_id) (peer_addr)\n"
496 " set the peer address for certain port.\n\n"
498 "set port (port_id) uta (mac_address|all) (on|off)\n"
499 " Add/Remove a or all unicast hash filter(s)"
502 "set promisc (port_id|all) (on|off)\n"
503 " Set the promiscuous mode on port_id, or all.\n\n"
505 "set allmulti (port_id|all) (on|off)\n"
506 " Set the allmulti mode on port_id, or all.\n\n"
508 "set vf promisc (port_id) (vf_id) (on|off)\n"
509 " Set unicast promiscuous mode for a VF from the PF.\n\n"
511 "set vf allmulti (port_id) (vf_id) (on|off)\n"
512 " Set multicast promiscuous mode for a VF from the PF.\n\n"
514 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
515 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
516 " (on|off) autoneg (on|off) (port_id)\n"
517 "set flow_ctrl rx (on|off) (portid)\n"
518 "set flow_ctrl tx (on|off) (portid)\n"
519 "set flow_ctrl high_water (high_water) (portid)\n"
520 "set flow_ctrl low_water (low_water) (portid)\n"
521 "set flow_ctrl pause_time (pause_time) (portid)\n"
522 "set flow_ctrl send_xon (send_xon) (portid)\n"
523 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
524 "set flow_ctrl autoneg (on|off) (port_id)\n"
525 " Set the link flow control parameter on a port.\n\n"
527 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
528 " (low_water) (pause_time) (priority) (port_id)\n"
529 " Set the priority flow control parameter on a"
532 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
533 " Set statistics mapping (qmapping 0..15) for RX/TX"
535 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
536 " on port 0 to mapping 5.\n\n"
538 "set xstats-hide-zero on|off\n"
539 " Set the option to hide the zero values"
540 " for xstats display.\n"
542 "set port (port_id) vf (vf_id) rx|tx on|off\n"
543 " Enable/Disable a VF receive/tranmit from a port\n\n"
545 "set port (port_id) vf (vf_id) (mac_addr)"
546 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
547 " Add/Remove unicast or multicast MAC addr filter"
550 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
552 " AUPE:accepts untagged VLAN;"
553 "ROPE:accept unicast hash\n\n"
554 " BAM:accepts broadcast packets;"
555 "MPE:accepts all multicast packets\n\n"
556 " Enable/Disable a VF receive mode of a port\n\n"
558 "set port (port_id) queue (queue_id) rate (rate_num)\n"
559 " Set rate limit for a queue of a port\n\n"
561 "set port (port_id) vf (vf_id) rate (rate_num) "
562 "queue_mask (queue_mask_value)\n"
563 " Set rate limit for queues in VF of a port\n\n"
565 "set port (port_id) mirror-rule (rule_id)"
566 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
567 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
568 " Set pool or vlan type mirror rule on a port.\n"
569 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
570 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
573 "set port (port_id) mirror-rule (rule_id)"
574 " (uplink-mirror|downlink-mirror) dst-pool"
575 " (pool_id) (on|off)\n"
576 " Set uplink or downlink type mirror rule on a port.\n"
577 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
578 " 0 on' enable mirror income traffic to pool 0.\n\n"
580 "reset port (port_id) mirror-rule (rule_id)\n"
581 " Reset a mirror rule.\n\n"
583 "set flush_rx (on|off)\n"
584 " Flush (default) or don't flush RX streams before"
585 " forwarding. Mainly used with PCAP drivers.\n\n"
587 "set bypass mode (normal|bypass|isolate) (port_id)\n"
588 " Set the bypass mode for the lowest port on bypass enabled"
591 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
592 "mode (normal|bypass|isolate) (port_id)\n"
593 " Set the event required to initiate specified bypass mode for"
594 " the lowest port on a bypass enabled NIC where:\n"
595 " timeout = enable bypass after watchdog timeout.\n"
596 " os_on = enable bypass when OS/board is powered on.\n"
597 " os_off = enable bypass when OS/board is powered off.\n"
598 " power_on = enable bypass when power supply is turned on.\n"
599 " power_off = enable bypass when power supply is turned off."
602 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
603 " Set the bypass watchdog timeout to 'n' seconds"
604 " where 0 = instant.\n\n"
606 "show bypass config (port_id)\n"
607 " Show the bypass configuration for a bypass enabled NIC"
608 " using the lowest port on the NIC.\n\n"
610 #ifdef RTE_LIBRTE_PMD_BOND
611 "create bonded device (mode) (socket)\n"
612 " Create a new bonded device with specific bonding mode and socket.\n\n"
614 "add bonding slave (slave_id) (port_id)\n"
615 " Add a slave device to a bonded device.\n\n"
617 "remove bonding slave (slave_id) (port_id)\n"
618 " Remove a slave device from a bonded device.\n\n"
620 "set bonding mode (value) (port_id)\n"
621 " Set the bonding mode on a bonded device.\n\n"
623 "set bonding primary (slave_id) (port_id)\n"
624 " Set the primary slave for a bonded device.\n\n"
626 "show bonding config (port_id)\n"
627 " Show the bonding config for port_id.\n\n"
629 "set bonding mac_addr (port_id) (address)\n"
630 " Set the MAC address of a bonded device.\n\n"
632 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
633 " Set Aggregation mode for IEEE802.3AD (mode 4)"
635 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
636 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
638 "set bonding mon_period (port_id) (value)\n"
639 " Set the bonding link status monitoring polling period in ms.\n\n"
641 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
642 " Enable/disable dedicated queues for LACP control traffic.\n\n"
645 "set link-up port (port_id)\n"
646 " Set link up for a port.\n\n"
648 "set link-down port (port_id)\n"
649 " Set link down for a port.\n\n"
651 "E-tag set insertion on port-tag-id (value)"
652 " port (port_id) vf (vf_id)\n"
653 " Enable E-tag insertion for a VF on a port\n\n"
655 "E-tag set insertion off port (port_id) vf (vf_id)\n"
656 " Disable E-tag insertion for a VF on a port\n\n"
658 "E-tag set stripping (on|off) port (port_id)\n"
659 " Enable/disable E-tag stripping on a port\n\n"
661 "E-tag set forwarding (on|off) port (port_id)\n"
662 " Enable/disable E-tag based forwarding"
665 "E-tag set filter add e-tag-id (value) dst-pool"
666 " (pool_id) port (port_id)\n"
667 " Add an E-tag forwarding filter on a port\n\n"
669 "E-tag set filter del e-tag-id (value) port (port_id)\n"
670 " Delete an E-tag forwarding filter on a port\n\n"
672 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
673 "set port tm hierarchy default (port_id)\n"
674 " Set default traffic Management hierarchy on a port\n\n"
677 "ddp add (port_id) (profile_path[,output_path])\n"
678 " Load a profile package on a port\n\n"
680 "ddp del (port_id) (profile_path)\n"
681 " Delete a profile package from a port\n\n"
683 "ptype mapping get (port_id) (valid_only)\n"
684 " Get ptype mapping on a port\n\n"
686 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
687 " Replace target with the pkt_type in ptype mapping\n\n"
689 "ptype mapping reset (port_id)\n"
690 " Reset ptype mapping on a port\n\n"
692 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
693 " Update a ptype mapping item on a port\n\n"
695 "set port (port_id) queue-region region_id (value) "
696 "queue_start_index (value) queue_num (value)\n"
697 " Set a queue region on a port\n\n"
699 "set port (port_id) queue-region region_id (value) "
701 " Set a flowtype region index on a port\n\n"
703 "set port (port_id) queue-region UP (value) region_id (value)\n"
704 " Set the mapping of User Priority to "
705 "queue region on a port\n\n"
707 "set port (port_id) queue-region flush (on|off)\n"
708 " flush all queue region related configuration\n\n"
710 "show port meter cap (port_id)\n"
711 " Show port meter capability information\n\n"
713 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
714 " meter profile add - srtcm rfc 2697\n\n"
716 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
717 " meter profile add - trtcm rfc 2698\n\n"
719 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
720 " meter profile add - trtcm rfc 4115\n\n"
722 "del port meter profile (port_id) (profile_id)\n"
723 " meter profile delete\n\n"
725 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
726 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
727 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
728 "(dscp_tbl_entry63)]\n"
731 "enable port meter (port_id) (mtr_id)\n"
734 "disable port meter (port_id) (mtr_id)\n"
737 "del port meter (port_id) (mtr_id)\n"
740 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
741 " meter update meter profile\n\n"
743 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
744 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
745 " update meter dscp table entries\n\n"
747 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
748 "(action0) [(action1) (action2)]\n"
749 " meter update policer action\n\n"
751 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
752 " meter update stats\n\n"
754 "show port (port_id) queue-region\n"
755 " show all queue region related configuration info\n\n"
757 "add port tm node shaper profile (port_id) (shaper_profile_id)"
758 " (tb_rate) (tb_size) (packet_length_adjust)\n"
759 " Add port tm node private shaper profile.\n\n"
761 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
762 " Delete port tm node private shaper profile.\n\n"
764 "add port tm node shared shaper (port_id) (shared_shaper_id)"
765 " (shaper_profile_id)\n"
766 " Add/update port tm node shared shaper.\n\n"
768 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
769 " Delete port tm node shared shaper.\n\n"
771 "set port tm node shaper profile (port_id) (node_id)"
772 " (shaper_profile_id)\n"
773 " Set port tm node shaper profile.\n\n"
775 "add port tm node wred profile (port_id) (wred_profile_id)"
776 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
777 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
778 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
779 " Add port tm node wred profile.\n\n"
781 "del port tm node wred profile (port_id) (wred_profile_id)\n"
782 " Delete port tm node wred profile.\n\n"
784 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
785 " (priority) (weight) (level_id) (shaper_profile_id)"
786 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
787 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
788 " Add port tm nonleaf node.\n\n"
790 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
791 " (priority) (weight) (level_id) (shaper_profile_id)"
792 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
793 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
794 " Add port tm leaf node.\n\n"
796 "del port tm node (port_id) (node_id)\n"
797 " Delete port tm node.\n\n"
799 "set port tm node parent (port_id) (node_id) (parent_node_id)"
800 " (priority) (weight)\n"
801 " Set port tm node parent.\n\n"
803 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
804 " Commit tm hierarchy.\n\n"
806 , list_pkt_forwarding_modes()
810 if (show_all || !strcmp(res->section, "ports")) {
816 "----------------\n\n"
818 "port start (port_id|all)\n"
819 " Start all ports or port_id.\n\n"
821 "port stop (port_id|all)\n"
822 " Stop all ports or port_id.\n\n"
824 "port close (port_id|all)\n"
825 " Close all ports or port_id.\n\n"
827 "port attach (ident)\n"
828 " Attach physical or virtual dev by pci address or virtual device name\n\n"
830 "port detach (port_id)\n"
831 " Detach physical or virtual dev by port_id\n\n"
833 "port config (port_id|all)"
834 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
835 " duplex (half|full|auto)\n"
836 " Set speed and duplex for all ports or port_id\n\n"
838 "port config all (rxq|txq|rxd|txd) (value)\n"
839 " Set number for rxq/txq/rxd/txd.\n\n"
841 "port config all max-pkt-len (value)\n"
842 " Set the max packet length.\n\n"
844 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
845 "hw-vlan-strip|hw-vlan-extend|drop-en)"
847 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
850 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
851 "geneve|nvgre|none|<flowtype_id>)\n"
852 " Set the RSS mode.\n\n"
854 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
855 " Set the RSS redirection table.\n\n"
857 "port config (port_id) dcb vt (on|off) (traffic_class)"
859 " Set the DCB mode.\n\n"
861 "port config all burst (value)\n"
862 " Set the number of packets per burst.\n\n"
864 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
866 " Set the ring prefetch/host/writeback threshold"
867 " for tx/rx queue.\n\n"
869 "port config all (txfreet|txrst|rxfreet) (value)\n"
870 " Set free threshold for rx/tx, or set"
871 " tx rs bit threshold.\n\n"
872 "port config mtu X value\n"
873 " Set the MTU of port X to a given value\n\n"
875 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
876 " Start/stop a rx/tx queue of port X. Only take effect"
877 " when port X is started\n\n"
879 "port config (port_id|all) l2-tunnel E-tag ether-type"
881 " Set the value of E-tag ether-type.\n\n"
883 "port config (port_id|all) l2-tunnel E-tag"
884 " (enable|disable)\n"
885 " Enable/disable the E-tag support.\n\n"
887 "port config (port_id) pctype mapping reset\n"
888 " Reset flow type to pctype mapping on a port\n\n"
890 "port config (port_id) pctype mapping update"
891 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
892 " Update a flow type to pctype mapping item on a port\n\n"
894 "port config (port_id) pctype (pctype_id) hash_inset|"
895 "fdir_inset|fdir_flx_inset get|set|clear field\n"
897 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
899 "port config (port_id) pctype (pctype_id) hash_inset|"
900 "fdir_inset|fdir_flx_inset clear all"
901 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
905 if (show_all || !strcmp(res->section, "registers")) {
913 "read reg (port_id) (address)\n"
914 " Display value of a port register.\n\n"
916 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
917 " Display a port register bit field.\n\n"
919 "read regbit (port_id) (address) (bit_x)\n"
920 " Display a single port register bit.\n\n"
922 "write reg (port_id) (address) (value)\n"
923 " Set value of a port register.\n\n"
925 "write regfield (port_id) (address) (bit_x) (bit_y)"
927 " Set bit field of a port register.\n\n"
929 "write regbit (port_id) (address) (bit_x) (value)\n"
930 " Set single bit value of a port register.\n\n"
933 if (show_all || !strcmp(res->section, "filters")) {
941 "ethertype_filter (port_id) (add|del)"
942 " (mac_addr|mac_ignr) (mac_address) ethertype"
943 " (ether_type) (drop|fwd) queue (queue_id)\n"
944 " Add/Del an ethertype filter.\n\n"
946 "2tuple_filter (port_id) (add|del)"
947 " dst_port (dst_port_value) protocol (protocol_value)"
948 " mask (mask_value) tcp_flags (tcp_flags_value)"
949 " priority (prio_value) queue (queue_id)\n"
950 " Add/Del a 2tuple filter.\n\n"
952 "5tuple_filter (port_id) (add|del)"
953 " dst_ip (dst_address) src_ip (src_address)"
954 " dst_port (dst_port_value) src_port (src_port_value)"
955 " protocol (protocol_value)"
956 " mask (mask_value) tcp_flags (tcp_flags_value)"
957 " priority (prio_value) queue (queue_id)\n"
958 " Add/Del a 5tuple filter.\n\n"
960 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
961 " Add/Del syn filter.\n\n"
963 "flex_filter (port_id) (add|del) len (len_value)"
964 " bytes (bytes_value) mask (mask_value)"
965 " priority (prio_value) queue (queue_id)\n"
966 " Add/Del a flex filter.\n\n"
968 "flow_director_filter (port_id) mode IP (add|del|update)"
969 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
970 " src (src_ip_address) dst (dst_ip_address)"
971 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
972 " vlan (vlan_value) flexbytes (flexbytes_value)"
973 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
974 " fd_id (fd_id_value)\n"
975 " Add/Del an IP type flow director filter.\n\n"
977 "flow_director_filter (port_id) mode IP (add|del|update)"
978 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
979 " src (src_ip_address) (src_port)"
980 " dst (dst_ip_address) (dst_port)"
981 " tos (tos_value) ttl (ttl_value)"
982 " vlan (vlan_value) flexbytes (flexbytes_value)"
983 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
984 " fd_id (fd_id_value)\n"
985 " Add/Del an UDP/TCP type flow director filter.\n\n"
987 "flow_director_filter (port_id) mode IP (add|del|update)"
988 " flow (ipv4-sctp|ipv6-sctp)"
989 " src (src_ip_address) (src_port)"
990 " dst (dst_ip_address) (dst_port)"
991 " tag (verification_tag) "
992 " tos (tos_value) ttl (ttl_value)"
994 " flexbytes (flexbytes_value) (drop|fwd)"
995 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
996 " Add/Del a SCTP type flow director filter.\n\n"
998 "flow_director_filter (port_id) mode IP (add|del|update)"
999 " flow l2_payload ether (ethertype)"
1000 " flexbytes (flexbytes_value) (drop|fwd)"
1001 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1002 " Add/Del a l2 payload type flow director filter.\n\n"
1004 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1005 " mac (mac_address) vlan (vlan_value)"
1006 " flexbytes (flexbytes_value) (drop|fwd)"
1007 " queue (queue_id) fd_id (fd_id_value)\n"
1008 " Add/Del a MAC-VLAN flow director filter.\n\n"
1010 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1011 " mac (mac_address) vlan (vlan_value)"
1012 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1013 " flexbytes (flexbytes_value) (drop|fwd)"
1014 " queue (queue_id) fd_id (fd_id_value)\n"
1015 " Add/Del a Tunnel flow director filter.\n\n"
1017 "flow_director_filter (port_id) mode raw (add|del|update)"
1018 " flow (flow_id) (drop|fwd) queue (queue_id)"
1019 " fd_id (fd_id_value) packet (packet file name)\n"
1020 " Add/Del a raw type flow director filter.\n\n"
1022 "flush_flow_director (port_id)\n"
1023 " Flush all flow director entries of a device.\n\n"
1025 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1026 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1027 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1028 " Set flow director IP mask.\n\n"
1030 "flow_director_mask (port_id) mode MAC-VLAN"
1031 " vlan (vlan_value)\n"
1032 " Set flow director MAC-VLAN mask.\n\n"
1034 "flow_director_mask (port_id) mode Tunnel"
1035 " vlan (vlan_value) mac (mac_value)"
1036 " tunnel-type (tunnel_type_value)"
1037 " tunnel-id (tunnel_id_value)\n"
1038 " Set flow director Tunnel mask.\n\n"
1040 "flow_director_flex_mask (port_id)"
1041 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1042 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1044 " Configure mask of flex payload.\n\n"
1046 "flow_director_flex_payload (port_id)"
1047 " (raw|l2|l3|l4) (config)\n"
1048 " Configure flex payload selection.\n\n"
1050 "get_sym_hash_ena_per_port (port_id)\n"
1051 " get symmetric hash enable configuration per port.\n\n"
1053 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1054 " set symmetric hash enable configuration per port"
1055 " to enable or disable.\n\n"
1057 "get_hash_global_config (port_id)\n"
1058 " Get the global configurations of hash filters.\n\n"
1060 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1061 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1062 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1063 " (enable|disable)\n"
1064 " Set the global configurations of hash filters.\n\n"
1066 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1067 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1068 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1069 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1070 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1071 "ipv6-next-header|udp-src-port|udp-dst-port|"
1072 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1073 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1074 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1075 "fld-8th|none) (select|add)\n"
1076 " Set the input set for hash.\n\n"
1078 "set_fdir_input_set (port_id) "
1079 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1080 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1081 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1082 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1083 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1084 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1085 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1087 " Set the input set for FDir.\n\n"
1089 "flow validate {port_id}"
1090 " [group {group_id}] [priority {level}]"
1091 " [ingress] [egress]"
1092 " pattern {item} [/ {item} [...]] / end"
1093 " actions {action} [/ {action} [...]] / end\n"
1094 " Check whether a flow rule can be created.\n\n"
1096 "flow create {port_id}"
1097 " [group {group_id}] [priority {level}]"
1098 " [ingress] [egress]"
1099 " pattern {item} [/ {item} [...]] / end"
1100 " actions {action} [/ {action} [...]] / end\n"
1101 " Create a flow rule.\n\n"
1103 "flow destroy {port_id} rule {rule_id} [...]\n"
1104 " Destroy specific flow rules.\n\n"
1106 "flow flush {port_id}\n"
1107 " Destroy all flow rules.\n\n"
1109 "flow query {port_id} {rule_id} {action}\n"
1110 " Query an existing flow rule.\n\n"
1112 "flow list {port_id} [group {group_id}] [...]\n"
1113 " List existing flow rules sorted by priority,"
1114 " filtered by group identifiers.\n\n"
1116 "flow isolate {port_id} {boolean}\n"
1117 " Restrict ingress traffic to the defined"
1123 cmdline_parse_token_string_t cmd_help_long_help =
1124 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1126 cmdline_parse_token_string_t cmd_help_long_section =
1127 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1128 "all#control#display#config#"
1129 "ports#registers#filters");
1131 cmdline_parse_inst_t cmd_help_long = {
1132 .f = cmd_help_long_parsed,
1134 .help_str = "help all|control|display|config|ports|register|filters: "
1137 (void *)&cmd_help_long_help,
1138 (void *)&cmd_help_long_section,
1144 /* *** start/stop/close all ports *** */
1145 struct cmd_operate_port_result {
1146 cmdline_fixed_string_t keyword;
1147 cmdline_fixed_string_t name;
1148 cmdline_fixed_string_t value;
1151 static void cmd_operate_port_parsed(void *parsed_result,
1152 __attribute__((unused)) struct cmdline *cl,
1153 __attribute__((unused)) void *data)
1155 struct cmd_operate_port_result *res = parsed_result;
1157 if (!strcmp(res->name, "start"))
1158 start_port(RTE_PORT_ALL);
1159 else if (!strcmp(res->name, "stop"))
1160 stop_port(RTE_PORT_ALL);
1161 else if (!strcmp(res->name, "close"))
1162 close_port(RTE_PORT_ALL);
1163 else if (!strcmp(res->name, "reset"))
1164 reset_port(RTE_PORT_ALL);
1166 printf("Unknown parameter\n");
1169 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1170 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1172 cmdline_parse_token_string_t cmd_operate_port_all_port =
1173 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1174 "start#stop#close#reset");
1175 cmdline_parse_token_string_t cmd_operate_port_all_all =
1176 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1178 cmdline_parse_inst_t cmd_operate_port = {
1179 .f = cmd_operate_port_parsed,
1181 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1183 (void *)&cmd_operate_port_all_cmd,
1184 (void *)&cmd_operate_port_all_port,
1185 (void *)&cmd_operate_port_all_all,
1190 /* *** start/stop/close specific port *** */
1191 struct cmd_operate_specific_port_result {
1192 cmdline_fixed_string_t keyword;
1193 cmdline_fixed_string_t name;
1197 static void cmd_operate_specific_port_parsed(void *parsed_result,
1198 __attribute__((unused)) struct cmdline *cl,
1199 __attribute__((unused)) void *data)
1201 struct cmd_operate_specific_port_result *res = parsed_result;
1203 if (!strcmp(res->name, "start"))
1204 start_port(res->value);
1205 else if (!strcmp(res->name, "stop"))
1206 stop_port(res->value);
1207 else if (!strcmp(res->name, "close"))
1208 close_port(res->value);
1209 else if (!strcmp(res->name, "reset"))
1210 reset_port(res->value);
1212 printf("Unknown parameter\n");
1215 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1216 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1218 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1219 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1220 name, "start#stop#close#reset");
1221 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1222 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1225 cmdline_parse_inst_t cmd_operate_specific_port = {
1226 .f = cmd_operate_specific_port_parsed,
1228 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1230 (void *)&cmd_operate_specific_port_cmd,
1231 (void *)&cmd_operate_specific_port_port,
1232 (void *)&cmd_operate_specific_port_id,
1237 /* *** attach a specified port *** */
1238 struct cmd_operate_attach_port_result {
1239 cmdline_fixed_string_t port;
1240 cmdline_fixed_string_t keyword;
1241 cmdline_fixed_string_t identifier;
1244 static void cmd_operate_attach_port_parsed(void *parsed_result,
1245 __attribute__((unused)) struct cmdline *cl,
1246 __attribute__((unused)) void *data)
1248 struct cmd_operate_attach_port_result *res = parsed_result;
1250 if (!strcmp(res->keyword, "attach"))
1251 attach_port(res->identifier);
1253 printf("Unknown parameter\n");
1256 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1257 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1259 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1260 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1262 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1263 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1266 cmdline_parse_inst_t cmd_operate_attach_port = {
1267 .f = cmd_operate_attach_port_parsed,
1269 .help_str = "port attach <identifier>: "
1270 "(identifier: pci address or virtual dev name)",
1272 (void *)&cmd_operate_attach_port_port,
1273 (void *)&cmd_operate_attach_port_keyword,
1274 (void *)&cmd_operate_attach_port_identifier,
1279 /* *** detach a specified port *** */
1280 struct cmd_operate_detach_port_result {
1281 cmdline_fixed_string_t port;
1282 cmdline_fixed_string_t keyword;
1286 static void cmd_operate_detach_port_parsed(void *parsed_result,
1287 __attribute__((unused)) struct cmdline *cl,
1288 __attribute__((unused)) void *data)
1290 struct cmd_operate_detach_port_result *res = parsed_result;
1292 if (!strcmp(res->keyword, "detach"))
1293 detach_port(res->port_id);
1295 printf("Unknown parameter\n");
1298 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1299 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1301 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1302 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1304 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1305 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1308 cmdline_parse_inst_t cmd_operate_detach_port = {
1309 .f = cmd_operate_detach_port_parsed,
1311 .help_str = "port detach <port_id>",
1313 (void *)&cmd_operate_detach_port_port,
1314 (void *)&cmd_operate_detach_port_keyword,
1315 (void *)&cmd_operate_detach_port_port_id,
1320 /* *** configure speed for all ports *** */
1321 struct cmd_config_speed_all {
1322 cmdline_fixed_string_t port;
1323 cmdline_fixed_string_t keyword;
1324 cmdline_fixed_string_t all;
1325 cmdline_fixed_string_t item1;
1326 cmdline_fixed_string_t item2;
1327 cmdline_fixed_string_t value1;
1328 cmdline_fixed_string_t value2;
1332 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1337 if (!strcmp(duplexstr, "half")) {
1338 duplex = ETH_LINK_HALF_DUPLEX;
1339 } else if (!strcmp(duplexstr, "full")) {
1340 duplex = ETH_LINK_FULL_DUPLEX;
1341 } else if (!strcmp(duplexstr, "auto")) {
1342 duplex = ETH_LINK_FULL_DUPLEX;
1344 printf("Unknown duplex parameter\n");
1348 if (!strcmp(speedstr, "10")) {
1349 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1350 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1351 } else if (!strcmp(speedstr, "100")) {
1352 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1353 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1355 if (duplex != ETH_LINK_FULL_DUPLEX) {
1356 printf("Invalid speed/duplex parameters\n");
1359 if (!strcmp(speedstr, "1000")) {
1360 *speed = ETH_LINK_SPEED_1G;
1361 } else if (!strcmp(speedstr, "10000")) {
1362 *speed = ETH_LINK_SPEED_10G;
1363 } else if (!strcmp(speedstr, "25000")) {
1364 *speed = ETH_LINK_SPEED_25G;
1365 } else if (!strcmp(speedstr, "40000")) {
1366 *speed = ETH_LINK_SPEED_40G;
1367 } else if (!strcmp(speedstr, "50000")) {
1368 *speed = ETH_LINK_SPEED_50G;
1369 } else if (!strcmp(speedstr, "100000")) {
1370 *speed = ETH_LINK_SPEED_100G;
1371 } else if (!strcmp(speedstr, "auto")) {
1372 *speed = ETH_LINK_SPEED_AUTONEG;
1374 printf("Unknown speed parameter\n");
1383 cmd_config_speed_all_parsed(void *parsed_result,
1384 __attribute__((unused)) struct cmdline *cl,
1385 __attribute__((unused)) void *data)
1387 struct cmd_config_speed_all *res = parsed_result;
1388 uint32_t link_speed;
1391 if (!all_ports_stopped()) {
1392 printf("Please stop all ports first\n");
1396 if (parse_and_check_speed_duplex(res->value1, res->value2,
1400 RTE_ETH_FOREACH_DEV(pid) {
1401 ports[pid].dev_conf.link_speeds = link_speed;
1404 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1407 cmdline_parse_token_string_t cmd_config_speed_all_port =
1408 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1409 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1410 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1412 cmdline_parse_token_string_t cmd_config_speed_all_all =
1413 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1414 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1415 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1416 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1417 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1418 "10#100#1000#10000#25000#40000#50000#100000#auto");
1419 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1420 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1421 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1422 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1425 cmdline_parse_inst_t cmd_config_speed_all = {
1426 .f = cmd_config_speed_all_parsed,
1428 .help_str = "port config all speed "
1429 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1432 (void *)&cmd_config_speed_all_port,
1433 (void *)&cmd_config_speed_all_keyword,
1434 (void *)&cmd_config_speed_all_all,
1435 (void *)&cmd_config_speed_all_item1,
1436 (void *)&cmd_config_speed_all_value1,
1437 (void *)&cmd_config_speed_all_item2,
1438 (void *)&cmd_config_speed_all_value2,
1443 /* *** configure speed for specific port *** */
1444 struct cmd_config_speed_specific {
1445 cmdline_fixed_string_t port;
1446 cmdline_fixed_string_t keyword;
1448 cmdline_fixed_string_t item1;
1449 cmdline_fixed_string_t item2;
1450 cmdline_fixed_string_t value1;
1451 cmdline_fixed_string_t value2;
1455 cmd_config_speed_specific_parsed(void *parsed_result,
1456 __attribute__((unused)) struct cmdline *cl,
1457 __attribute__((unused)) void *data)
1459 struct cmd_config_speed_specific *res = parsed_result;
1460 uint32_t link_speed;
1462 if (!all_ports_stopped()) {
1463 printf("Please stop all ports first\n");
1467 if (port_id_is_invalid(res->id, ENABLED_WARN))
1470 if (parse_and_check_speed_duplex(res->value1, res->value2,
1474 ports[res->id].dev_conf.link_speeds = link_speed;
1476 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1480 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1481 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1483 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1484 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1486 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1487 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1488 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1489 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1491 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1492 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1493 "10#100#1000#10000#25000#40000#50000#100000#auto");
1494 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1495 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1497 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1498 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1501 cmdline_parse_inst_t cmd_config_speed_specific = {
1502 .f = cmd_config_speed_specific_parsed,
1504 .help_str = "port config <port_id> speed "
1505 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1508 (void *)&cmd_config_speed_specific_port,
1509 (void *)&cmd_config_speed_specific_keyword,
1510 (void *)&cmd_config_speed_specific_id,
1511 (void *)&cmd_config_speed_specific_item1,
1512 (void *)&cmd_config_speed_specific_value1,
1513 (void *)&cmd_config_speed_specific_item2,
1514 (void *)&cmd_config_speed_specific_value2,
1519 /* *** configure txq/rxq, txd/rxd *** */
1520 struct cmd_config_rx_tx {
1521 cmdline_fixed_string_t port;
1522 cmdline_fixed_string_t keyword;
1523 cmdline_fixed_string_t all;
1524 cmdline_fixed_string_t name;
1529 cmd_config_rx_tx_parsed(void *parsed_result,
1530 __attribute__((unused)) struct cmdline *cl,
1531 __attribute__((unused)) void *data)
1533 struct cmd_config_rx_tx *res = parsed_result;
1535 if (!all_ports_stopped()) {
1536 printf("Please stop all ports first\n");
1539 if (!strcmp(res->name, "rxq")) {
1540 if (!res->value && !nb_txq) {
1541 printf("Warning: Either rx or tx queues should be non zero\n");
1544 if (check_nb_rxq(res->value) != 0)
1546 nb_rxq = res->value;
1548 else if (!strcmp(res->name, "txq")) {
1549 if (!res->value && !nb_rxq) {
1550 printf("Warning: Either rx or tx queues should be non zero\n");
1553 if (check_nb_txq(res->value) != 0)
1555 nb_txq = res->value;
1557 else if (!strcmp(res->name, "rxd")) {
1558 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1559 printf("rxd %d invalid - must be > 0 && <= %d\n",
1560 res->value, RTE_TEST_RX_DESC_MAX);
1563 nb_rxd = res->value;
1564 } else if (!strcmp(res->name, "txd")) {
1565 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1566 printf("txd %d invalid - must be > 0 && <= %d\n",
1567 res->value, RTE_TEST_TX_DESC_MAX);
1570 nb_txd = res->value;
1572 printf("Unknown parameter\n");
1580 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1583 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1584 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1585 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1586 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1587 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1588 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1589 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1590 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1592 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1593 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1595 cmdline_parse_inst_t cmd_config_rx_tx = {
1596 .f = cmd_config_rx_tx_parsed,
1598 .help_str = "port config all rxq|txq|rxd|txd <value>",
1600 (void *)&cmd_config_rx_tx_port,
1601 (void *)&cmd_config_rx_tx_keyword,
1602 (void *)&cmd_config_rx_tx_all,
1603 (void *)&cmd_config_rx_tx_name,
1604 (void *)&cmd_config_rx_tx_value,
1609 /* *** config max packet length *** */
1610 struct cmd_config_max_pkt_len_result {
1611 cmdline_fixed_string_t port;
1612 cmdline_fixed_string_t keyword;
1613 cmdline_fixed_string_t all;
1614 cmdline_fixed_string_t name;
1619 cmd_config_max_pkt_len_parsed(void *parsed_result,
1620 __attribute__((unused)) struct cmdline *cl,
1621 __attribute__((unused)) void *data)
1623 struct cmd_config_max_pkt_len_result *res = parsed_result;
1626 if (!all_ports_stopped()) {
1627 printf("Please stop all ports first\n");
1631 RTE_ETH_FOREACH_DEV(pid) {
1632 struct rte_port *port = &ports[pid];
1633 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1635 if (!strcmp(res->name, "max-pkt-len")) {
1636 if (res->value < ETHER_MIN_LEN) {
1637 printf("max-pkt-len can not be less than %d\n",
1641 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1644 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1645 if (res->value > ETHER_MAX_LEN)
1646 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1648 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1649 port->dev_conf.rxmode.offloads = rx_offloads;
1651 printf("Unknown parameter\n");
1658 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1661 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1664 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1665 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1667 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1668 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1670 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1671 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1673 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1674 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1677 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1678 .f = cmd_config_max_pkt_len_parsed,
1680 .help_str = "port config all max-pkt-len <value>",
1682 (void *)&cmd_config_max_pkt_len_port,
1683 (void *)&cmd_config_max_pkt_len_keyword,
1684 (void *)&cmd_config_max_pkt_len_all,
1685 (void *)&cmd_config_max_pkt_len_name,
1686 (void *)&cmd_config_max_pkt_len_value,
1691 /* *** configure port MTU *** */
1692 struct cmd_config_mtu_result {
1693 cmdline_fixed_string_t port;
1694 cmdline_fixed_string_t keyword;
1695 cmdline_fixed_string_t mtu;
1701 cmd_config_mtu_parsed(void *parsed_result,
1702 __attribute__((unused)) struct cmdline *cl,
1703 __attribute__((unused)) void *data)
1705 struct cmd_config_mtu_result *res = parsed_result;
1707 if (res->value < ETHER_MIN_LEN) {
1708 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1711 port_mtu_set(res->port_id, res->value);
1714 cmdline_parse_token_string_t cmd_config_mtu_port =
1715 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1717 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1720 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1721 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1723 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1724 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1725 cmdline_parse_token_num_t cmd_config_mtu_value =
1726 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1728 cmdline_parse_inst_t cmd_config_mtu = {
1729 .f = cmd_config_mtu_parsed,
1731 .help_str = "port config mtu <port_id> <value>",
1733 (void *)&cmd_config_mtu_port,
1734 (void *)&cmd_config_mtu_keyword,
1735 (void *)&cmd_config_mtu_mtu,
1736 (void *)&cmd_config_mtu_port_id,
1737 (void *)&cmd_config_mtu_value,
1742 /* *** configure rx mode *** */
1743 struct cmd_config_rx_mode_flag {
1744 cmdline_fixed_string_t port;
1745 cmdline_fixed_string_t keyword;
1746 cmdline_fixed_string_t all;
1747 cmdline_fixed_string_t name;
1748 cmdline_fixed_string_t value;
1752 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1753 __attribute__((unused)) struct cmdline *cl,
1754 __attribute__((unused)) void *data)
1756 struct cmd_config_rx_mode_flag *res = parsed_result;
1759 if (!all_ports_stopped()) {
1760 printf("Please stop all ports first\n");
1764 RTE_ETH_FOREACH_DEV(pid) {
1765 struct rte_port *port;
1766 uint64_t rx_offloads;
1769 rx_offloads = port->dev_conf.rxmode.offloads;
1770 if (!strcmp(res->name, "crc-strip")) {
1771 if (!strcmp(res->value, "on"))
1772 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1773 else if (!strcmp(res->value, "off"))
1774 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1776 printf("Unknown parameter\n");
1779 } else if (!strcmp(res->name, "scatter")) {
1780 if (!strcmp(res->value, "on")) {
1781 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1782 } else if (!strcmp(res->value, "off")) {
1783 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1785 printf("Unknown parameter\n");
1788 } else if (!strcmp(res->name, "rx-cksum")) {
1789 if (!strcmp(res->value, "on"))
1790 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1791 else if (!strcmp(res->value, "off"))
1792 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1794 printf("Unknown parameter\n");
1797 } else if (!strcmp(res->name, "rx-timestamp")) {
1798 if (!strcmp(res->value, "on"))
1799 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1800 else if (!strcmp(res->value, "off"))
1801 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1803 printf("Unknown parameter\n");
1806 } else if (!strcmp(res->name, "hw-vlan")) {
1807 if (!strcmp(res->value, "on")) {
1808 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1809 DEV_RX_OFFLOAD_VLAN_STRIP);
1810 } else if (!strcmp(res->value, "off")) {
1811 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1812 DEV_RX_OFFLOAD_VLAN_STRIP);
1814 printf("Unknown parameter\n");
1817 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1818 if (!strcmp(res->value, "on"))
1819 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1820 else if (!strcmp(res->value, "off"))
1821 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1823 printf("Unknown parameter\n");
1826 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1827 if (!strcmp(res->value, "on"))
1828 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1829 else if (!strcmp(res->value, "off"))
1830 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1832 printf("Unknown parameter\n");
1835 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1836 if (!strcmp(res->value, "on"))
1837 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1838 else if (!strcmp(res->value, "off"))
1839 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1841 printf("Unknown parameter\n");
1844 } else if (!strcmp(res->name, "drop-en")) {
1845 if (!strcmp(res->value, "on"))
1847 else if (!strcmp(res->value, "off"))
1850 printf("Unknown parameter\n");
1854 printf("Unknown parameter\n");
1857 port->dev_conf.rxmode.offloads = rx_offloads;
1862 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1865 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1866 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1867 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1868 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1870 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1871 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1872 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1873 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1874 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1875 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1876 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1877 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1880 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1881 .f = cmd_config_rx_mode_flag_parsed,
1883 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1884 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1886 (void *)&cmd_config_rx_mode_flag_port,
1887 (void *)&cmd_config_rx_mode_flag_keyword,
1888 (void *)&cmd_config_rx_mode_flag_all,
1889 (void *)&cmd_config_rx_mode_flag_name,
1890 (void *)&cmd_config_rx_mode_flag_value,
1895 /* *** configure rss *** */
1896 struct cmd_config_rss {
1897 cmdline_fixed_string_t port;
1898 cmdline_fixed_string_t keyword;
1899 cmdline_fixed_string_t all;
1900 cmdline_fixed_string_t name;
1901 cmdline_fixed_string_t value;
1905 cmd_config_rss_parsed(void *parsed_result,
1906 __attribute__((unused)) struct cmdline *cl,
1907 __attribute__((unused)) void *data)
1909 struct cmd_config_rss *res = parsed_result;
1910 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1914 if (!strcmp(res->value, "all"))
1915 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1916 ETH_RSS_UDP | ETH_RSS_SCTP |
1918 else if (!strcmp(res->value, "ip"))
1919 rss_conf.rss_hf = ETH_RSS_IP;
1920 else if (!strcmp(res->value, "udp"))
1921 rss_conf.rss_hf = ETH_RSS_UDP;
1922 else if (!strcmp(res->value, "tcp"))
1923 rss_conf.rss_hf = ETH_RSS_TCP;
1924 else if (!strcmp(res->value, "sctp"))
1925 rss_conf.rss_hf = ETH_RSS_SCTP;
1926 else if (!strcmp(res->value, "ether"))
1927 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1928 else if (!strcmp(res->value, "port"))
1929 rss_conf.rss_hf = ETH_RSS_PORT;
1930 else if (!strcmp(res->value, "vxlan"))
1931 rss_conf.rss_hf = ETH_RSS_VXLAN;
1932 else if (!strcmp(res->value, "geneve"))
1933 rss_conf.rss_hf = ETH_RSS_GENEVE;
1934 else if (!strcmp(res->value, "nvgre"))
1935 rss_conf.rss_hf = ETH_RSS_NVGRE;
1936 else if (!strcmp(res->value, "none"))
1937 rss_conf.rss_hf = 0;
1938 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1939 atoi(res->value) < 64)
1940 rss_conf.rss_hf = 1ULL << atoi(res->value);
1942 printf("Unknown parameter\n");
1945 rss_conf.rss_key = NULL;
1946 for (i = 0; i < rte_eth_dev_count(); i++) {
1947 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1949 printf("Configuration of RSS hash at ethernet port %d "
1950 "failed with error (%d): %s.\n",
1951 i, -diag, strerror(-diag));
1955 cmdline_parse_token_string_t cmd_config_rss_port =
1956 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1957 cmdline_parse_token_string_t cmd_config_rss_keyword =
1958 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1959 cmdline_parse_token_string_t cmd_config_rss_all =
1960 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1961 cmdline_parse_token_string_t cmd_config_rss_name =
1962 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1963 cmdline_parse_token_string_t cmd_config_rss_value =
1964 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1966 cmdline_parse_inst_t cmd_config_rss = {
1967 .f = cmd_config_rss_parsed,
1969 .help_str = "port config all rss "
1970 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1972 (void *)&cmd_config_rss_port,
1973 (void *)&cmd_config_rss_keyword,
1974 (void *)&cmd_config_rss_all,
1975 (void *)&cmd_config_rss_name,
1976 (void *)&cmd_config_rss_value,
1981 /* *** configure rss hash key *** */
1982 struct cmd_config_rss_hash_key {
1983 cmdline_fixed_string_t port;
1984 cmdline_fixed_string_t config;
1986 cmdline_fixed_string_t rss_hash_key;
1987 cmdline_fixed_string_t rss_type;
1988 cmdline_fixed_string_t key;
1992 hexa_digit_to_value(char hexa_digit)
1994 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1995 return (uint8_t) (hexa_digit - '0');
1996 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1997 return (uint8_t) ((hexa_digit - 'a') + 10);
1998 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1999 return (uint8_t) ((hexa_digit - 'A') + 10);
2000 /* Invalid hexa digit */
2005 parse_and_check_key_hexa_digit(char *key, int idx)
2009 hexa_v = hexa_digit_to_value(key[idx]);
2011 printf("invalid key: character %c at position %d is not a "
2012 "valid hexa digit\n", key[idx], idx);
2017 cmd_config_rss_hash_key_parsed(void *parsed_result,
2018 __attribute__((unused)) struct cmdline *cl,
2019 __attribute__((unused)) void *data)
2021 struct cmd_config_rss_hash_key *res = parsed_result;
2022 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2026 struct rte_eth_dev_info dev_info;
2027 uint8_t hash_key_size;
2030 memset(&dev_info, 0, sizeof(dev_info));
2031 rte_eth_dev_info_get(res->port_id, &dev_info);
2032 if (dev_info.hash_key_size > 0 &&
2033 dev_info.hash_key_size <= sizeof(hash_key))
2034 hash_key_size = dev_info.hash_key_size;
2036 printf("dev_info did not provide a valid hash key size\n");
2039 /* Check the length of the RSS hash key */
2040 key_len = strlen(res->key);
2041 if (key_len != (hash_key_size * 2)) {
2042 printf("key length: %d invalid - key must be a string of %d"
2043 " hexa-decimal numbers\n",
2044 (int) key_len, hash_key_size * 2);
2047 /* Translate RSS hash key into binary representation */
2048 for (i = 0; i < hash_key_size; i++) {
2049 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2052 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2055 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2057 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2061 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2062 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2063 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2066 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2067 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2068 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2069 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2070 rss_hash_key, "rss-hash-key");
2071 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2072 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2073 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2074 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2075 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2076 "ipv6-tcp-ex#ipv6-udp-ex");
2077 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2078 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2080 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2081 .f = cmd_config_rss_hash_key_parsed,
2083 .help_str = "port config <port_id> rss-hash-key "
2084 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2085 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2086 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2087 "<string of hex digits (variable length, NIC dependent)>",
2089 (void *)&cmd_config_rss_hash_key_port,
2090 (void *)&cmd_config_rss_hash_key_config,
2091 (void *)&cmd_config_rss_hash_key_port_id,
2092 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2093 (void *)&cmd_config_rss_hash_key_rss_type,
2094 (void *)&cmd_config_rss_hash_key_value,
2099 /* *** configure port rxq/txq start/stop *** */
2100 struct cmd_config_rxtx_queue {
2101 cmdline_fixed_string_t port;
2103 cmdline_fixed_string_t rxtxq;
2105 cmdline_fixed_string_t opname;
2109 cmd_config_rxtx_queue_parsed(void *parsed_result,
2110 __attribute__((unused)) struct cmdline *cl,
2111 __attribute__((unused)) void *data)
2113 struct cmd_config_rxtx_queue *res = parsed_result;
2118 if (test_done == 0) {
2119 printf("Please stop forwarding first\n");
2123 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2126 if (port_is_started(res->portid) != 1) {
2127 printf("Please start port %u first\n", res->portid);
2131 if (!strcmp(res->rxtxq, "rxq"))
2133 else if (!strcmp(res->rxtxq, "txq"))
2136 printf("Unknown parameter\n");
2140 if (isrx && rx_queue_id_is_invalid(res->qid))
2142 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2145 if (!strcmp(res->opname, "start"))
2147 else if (!strcmp(res->opname, "stop"))
2150 printf("Unknown parameter\n");
2154 if (isstart && isrx)
2155 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2156 else if (!isstart && isrx)
2157 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2158 else if (isstart && !isrx)
2159 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2161 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2163 if (ret == -ENOTSUP)
2164 printf("Function not supported in PMD driver\n");
2167 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2168 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2169 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2170 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2171 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2172 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2173 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2174 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2175 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2176 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2179 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2180 .f = cmd_config_rxtx_queue_parsed,
2182 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2184 (void *)&cmd_config_speed_all_port,
2185 (void *)&cmd_config_rxtx_queue_portid,
2186 (void *)&cmd_config_rxtx_queue_rxtxq,
2187 (void *)&cmd_config_rxtx_queue_qid,
2188 (void *)&cmd_config_rxtx_queue_opname,
2193 /* *** Configure RSS RETA *** */
2194 struct cmd_config_rss_reta {
2195 cmdline_fixed_string_t port;
2196 cmdline_fixed_string_t keyword;
2198 cmdline_fixed_string_t name;
2199 cmdline_fixed_string_t list_name;
2200 cmdline_fixed_string_t list_of_items;
2204 parse_reta_config(const char *str,
2205 struct rte_eth_rss_reta_entry64 *reta_conf,
2206 uint16_t nb_entries)
2210 uint16_t hash_index, idx, shift;
2213 const char *p, *p0 = str;
2220 unsigned long int_fld[_NUM_FLD];
2221 char *str_fld[_NUM_FLD];
2223 while ((p = strchr(p0,'(')) != NULL) {
2225 if((p0 = strchr(p,')')) == NULL)
2229 if(size >= sizeof(s))
2232 snprintf(s, sizeof(s), "%.*s", size, p);
2233 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2235 for (i = 0; i < _NUM_FLD; i++) {
2237 int_fld[i] = strtoul(str_fld[i], &end, 0);
2238 if (errno != 0 || end == str_fld[i] ||
2243 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2244 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2246 if (hash_index >= nb_entries) {
2247 printf("Invalid RETA hash index=%d\n", hash_index);
2251 idx = hash_index / RTE_RETA_GROUP_SIZE;
2252 shift = hash_index % RTE_RETA_GROUP_SIZE;
2253 reta_conf[idx].mask |= (1ULL << shift);
2254 reta_conf[idx].reta[shift] = nb_queue;
2261 cmd_set_rss_reta_parsed(void *parsed_result,
2262 __attribute__((unused)) struct cmdline *cl,
2263 __attribute__((unused)) void *data)
2266 struct rte_eth_dev_info dev_info;
2267 struct rte_eth_rss_reta_entry64 reta_conf[8];
2268 struct cmd_config_rss_reta *res = parsed_result;
2270 memset(&dev_info, 0, sizeof(dev_info));
2271 rte_eth_dev_info_get(res->port_id, &dev_info);
2272 if (dev_info.reta_size == 0) {
2273 printf("Redirection table size is 0 which is "
2274 "invalid for RSS\n");
2277 printf("The reta size of port %d is %u\n",
2278 res->port_id, dev_info.reta_size);
2279 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2280 printf("Currently do not support more than %u entries of "
2281 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2285 memset(reta_conf, 0, sizeof(reta_conf));
2286 if (!strcmp(res->list_name, "reta")) {
2287 if (parse_reta_config(res->list_of_items, reta_conf,
2288 dev_info.reta_size)) {
2289 printf("Invalid RSS Redirection Table "
2290 "config entered\n");
2293 ret = rte_eth_dev_rss_reta_update(res->port_id,
2294 reta_conf, dev_info.reta_size);
2296 printf("Bad redirection table parameter, "
2297 "return code = %d \n", ret);
2301 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2302 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2303 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2304 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2305 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2306 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2307 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2308 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2309 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2310 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2311 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2314 cmdline_parse_inst_t cmd_config_rss_reta = {
2315 .f = cmd_set_rss_reta_parsed,
2317 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2319 (void *)&cmd_config_rss_reta_port,
2320 (void *)&cmd_config_rss_reta_keyword,
2321 (void *)&cmd_config_rss_reta_port_id,
2322 (void *)&cmd_config_rss_reta_name,
2323 (void *)&cmd_config_rss_reta_list_name,
2324 (void *)&cmd_config_rss_reta_list_of_items,
2329 /* *** SHOW PORT RETA INFO *** */
2330 struct cmd_showport_reta {
2331 cmdline_fixed_string_t show;
2332 cmdline_fixed_string_t port;
2334 cmdline_fixed_string_t rss;
2335 cmdline_fixed_string_t reta;
2337 cmdline_fixed_string_t list_of_items;
2341 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2342 uint16_t nb_entries,
2346 const char *p, *p0 = str;
2351 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2352 RTE_RETA_GROUP_SIZE;
2355 p = strchr(p0, '(');
2359 p0 = strchr(p, ')');
2363 if (size >= sizeof(s)) {
2364 printf("The string size exceeds the internal buffer size\n");
2367 snprintf(s, sizeof(s), "%.*s", size, p);
2368 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2369 if (ret <= 0 || ret != num) {
2370 printf("The bits of masks do not match the number of "
2371 "reta entries: %u\n", num);
2374 for (i = 0; i < ret; i++)
2375 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2381 cmd_showport_reta_parsed(void *parsed_result,
2382 __attribute__((unused)) struct cmdline *cl,
2383 __attribute__((unused)) void *data)
2385 struct cmd_showport_reta *res = parsed_result;
2386 struct rte_eth_rss_reta_entry64 reta_conf[8];
2387 struct rte_eth_dev_info dev_info;
2388 uint16_t max_reta_size;
2390 memset(&dev_info, 0, sizeof(dev_info));
2391 rte_eth_dev_info_get(res->port_id, &dev_info);
2392 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2393 if (res->size == 0 || res->size > max_reta_size) {
2394 printf("Invalid redirection table size: %u (1-%u)\n",
2395 res->size, max_reta_size);
2399 memset(reta_conf, 0, sizeof(reta_conf));
2400 if (showport_parse_reta_config(reta_conf, res->size,
2401 res->list_of_items) < 0) {
2402 printf("Invalid string: %s for reta masks\n",
2403 res->list_of_items);
2406 port_rss_reta_info(res->port_id, reta_conf, res->size);
2409 cmdline_parse_token_string_t cmd_showport_reta_show =
2410 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2411 cmdline_parse_token_string_t cmd_showport_reta_port =
2412 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2413 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2414 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2415 cmdline_parse_token_string_t cmd_showport_reta_rss =
2416 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2417 cmdline_parse_token_string_t cmd_showport_reta_reta =
2418 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2419 cmdline_parse_token_num_t cmd_showport_reta_size =
2420 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2421 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2422 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2423 list_of_items, NULL);
2425 cmdline_parse_inst_t cmd_showport_reta = {
2426 .f = cmd_showport_reta_parsed,
2428 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2430 (void *)&cmd_showport_reta_show,
2431 (void *)&cmd_showport_reta_port,
2432 (void *)&cmd_showport_reta_port_id,
2433 (void *)&cmd_showport_reta_rss,
2434 (void *)&cmd_showport_reta_reta,
2435 (void *)&cmd_showport_reta_size,
2436 (void *)&cmd_showport_reta_list_of_items,
2441 /* *** Show RSS hash configuration *** */
2442 struct cmd_showport_rss_hash {
2443 cmdline_fixed_string_t show;
2444 cmdline_fixed_string_t port;
2446 cmdline_fixed_string_t rss_hash;
2447 cmdline_fixed_string_t rss_type;
2448 cmdline_fixed_string_t key; /* optional argument */
2451 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2452 __attribute__((unused)) struct cmdline *cl,
2455 struct cmd_showport_rss_hash *res = parsed_result;
2457 port_rss_hash_conf_show(res->port_id, res->rss_type,
2458 show_rss_key != NULL);
2461 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2462 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2463 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2464 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2465 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2466 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2467 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2468 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2470 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2471 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2472 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2473 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2474 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2475 "ipv6-tcp-ex#ipv6-udp-ex");
2476 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2477 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2479 cmdline_parse_inst_t cmd_showport_rss_hash = {
2480 .f = cmd_showport_rss_hash_parsed,
2482 .help_str = "show port <port_id> rss-hash "
2483 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2484 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2485 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2487 (void *)&cmd_showport_rss_hash_show,
2488 (void *)&cmd_showport_rss_hash_port,
2489 (void *)&cmd_showport_rss_hash_port_id,
2490 (void *)&cmd_showport_rss_hash_rss_hash,
2491 (void *)&cmd_showport_rss_hash_rss_hash_info,
2496 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2497 .f = cmd_showport_rss_hash_parsed,
2499 .help_str = "show port <port_id> rss-hash "
2500 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2501 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2502 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2504 (void *)&cmd_showport_rss_hash_show,
2505 (void *)&cmd_showport_rss_hash_port,
2506 (void *)&cmd_showport_rss_hash_port_id,
2507 (void *)&cmd_showport_rss_hash_rss_hash,
2508 (void *)&cmd_showport_rss_hash_rss_hash_info,
2509 (void *)&cmd_showport_rss_hash_rss_key,
2514 /* *** Configure DCB *** */
2515 struct cmd_config_dcb {
2516 cmdline_fixed_string_t port;
2517 cmdline_fixed_string_t config;
2519 cmdline_fixed_string_t dcb;
2520 cmdline_fixed_string_t vt;
2521 cmdline_fixed_string_t vt_en;
2523 cmdline_fixed_string_t pfc;
2524 cmdline_fixed_string_t pfc_en;
2528 cmd_config_dcb_parsed(void *parsed_result,
2529 __attribute__((unused)) struct cmdline *cl,
2530 __attribute__((unused)) void *data)
2532 struct cmd_config_dcb *res = parsed_result;
2533 portid_t port_id = res->port_id;
2534 struct rte_port *port;
2538 port = &ports[port_id];
2539 /** Check if the port is not started **/
2540 if (port->port_status != RTE_PORT_STOPPED) {
2541 printf("Please stop port %d first\n", port_id);
2545 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2546 printf("The invalid number of traffic class,"
2547 " only 4 or 8 allowed.\n");
2551 if (nb_fwd_lcores < res->num_tcs) {
2552 printf("nb_cores shouldn't be less than number of TCs.\n");
2555 if (!strncmp(res->pfc_en, "on", 2))
2560 /* DCB in VT mode */
2561 if (!strncmp(res->vt_en, "on", 2))
2562 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2563 (enum rte_eth_nb_tcs)res->num_tcs,
2566 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2567 (enum rte_eth_nb_tcs)res->num_tcs,
2572 printf("Cannot initialize network ports.\n");
2576 cmd_reconfig_device_queue(port_id, 1, 1);
2579 cmdline_parse_token_string_t cmd_config_dcb_port =
2580 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2581 cmdline_parse_token_string_t cmd_config_dcb_config =
2582 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2583 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2584 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2585 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2586 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2587 cmdline_parse_token_string_t cmd_config_dcb_vt =
2588 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2589 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2590 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2591 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2592 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2593 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2594 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2595 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2596 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2598 cmdline_parse_inst_t cmd_config_dcb = {
2599 .f = cmd_config_dcb_parsed,
2601 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2603 (void *)&cmd_config_dcb_port,
2604 (void *)&cmd_config_dcb_config,
2605 (void *)&cmd_config_dcb_port_id,
2606 (void *)&cmd_config_dcb_dcb,
2607 (void *)&cmd_config_dcb_vt,
2608 (void *)&cmd_config_dcb_vt_en,
2609 (void *)&cmd_config_dcb_num_tcs,
2610 (void *)&cmd_config_dcb_pfc,
2611 (void *)&cmd_config_dcb_pfc_en,
2616 /* *** configure number of packets per burst *** */
2617 struct cmd_config_burst {
2618 cmdline_fixed_string_t port;
2619 cmdline_fixed_string_t keyword;
2620 cmdline_fixed_string_t all;
2621 cmdline_fixed_string_t name;
2626 cmd_config_burst_parsed(void *parsed_result,
2627 __attribute__((unused)) struct cmdline *cl,
2628 __attribute__((unused)) void *data)
2630 struct cmd_config_burst *res = parsed_result;
2632 if (!all_ports_stopped()) {
2633 printf("Please stop all ports first\n");
2637 if (!strcmp(res->name, "burst")) {
2638 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2639 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2642 nb_pkt_per_burst = res->value;
2644 printf("Unknown parameter\n");
2650 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2653 cmdline_parse_token_string_t cmd_config_burst_port =
2654 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2655 cmdline_parse_token_string_t cmd_config_burst_keyword =
2656 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2657 cmdline_parse_token_string_t cmd_config_burst_all =
2658 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2659 cmdline_parse_token_string_t cmd_config_burst_name =
2660 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2661 cmdline_parse_token_num_t cmd_config_burst_value =
2662 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2664 cmdline_parse_inst_t cmd_config_burst = {
2665 .f = cmd_config_burst_parsed,
2667 .help_str = "port config all burst <value>",
2669 (void *)&cmd_config_burst_port,
2670 (void *)&cmd_config_burst_keyword,
2671 (void *)&cmd_config_burst_all,
2672 (void *)&cmd_config_burst_name,
2673 (void *)&cmd_config_burst_value,
2678 /* *** configure rx/tx queues *** */
2679 struct cmd_config_thresh {
2680 cmdline_fixed_string_t port;
2681 cmdline_fixed_string_t keyword;
2682 cmdline_fixed_string_t all;
2683 cmdline_fixed_string_t name;
2688 cmd_config_thresh_parsed(void *parsed_result,
2689 __attribute__((unused)) struct cmdline *cl,
2690 __attribute__((unused)) void *data)
2692 struct cmd_config_thresh *res = parsed_result;
2694 if (!all_ports_stopped()) {
2695 printf("Please stop all ports first\n");
2699 if (!strcmp(res->name, "txpt"))
2700 tx_pthresh = res->value;
2701 else if(!strcmp(res->name, "txht"))
2702 tx_hthresh = res->value;
2703 else if(!strcmp(res->name, "txwt"))
2704 tx_wthresh = res->value;
2705 else if(!strcmp(res->name, "rxpt"))
2706 rx_pthresh = res->value;
2707 else if(!strcmp(res->name, "rxht"))
2708 rx_hthresh = res->value;
2709 else if(!strcmp(res->name, "rxwt"))
2710 rx_wthresh = res->value;
2712 printf("Unknown parameter\n");
2718 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2721 cmdline_parse_token_string_t cmd_config_thresh_port =
2722 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2723 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2724 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2725 cmdline_parse_token_string_t cmd_config_thresh_all =
2726 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2727 cmdline_parse_token_string_t cmd_config_thresh_name =
2728 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2729 "txpt#txht#txwt#rxpt#rxht#rxwt");
2730 cmdline_parse_token_num_t cmd_config_thresh_value =
2731 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2733 cmdline_parse_inst_t cmd_config_thresh = {
2734 .f = cmd_config_thresh_parsed,
2736 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2738 (void *)&cmd_config_thresh_port,
2739 (void *)&cmd_config_thresh_keyword,
2740 (void *)&cmd_config_thresh_all,
2741 (void *)&cmd_config_thresh_name,
2742 (void *)&cmd_config_thresh_value,
2747 /* *** configure free/rs threshold *** */
2748 struct cmd_config_threshold {
2749 cmdline_fixed_string_t port;
2750 cmdline_fixed_string_t keyword;
2751 cmdline_fixed_string_t all;
2752 cmdline_fixed_string_t name;
2757 cmd_config_threshold_parsed(void *parsed_result,
2758 __attribute__((unused)) struct cmdline *cl,
2759 __attribute__((unused)) void *data)
2761 struct cmd_config_threshold *res = parsed_result;
2763 if (!all_ports_stopped()) {
2764 printf("Please stop all ports first\n");
2768 if (!strcmp(res->name, "txfreet"))
2769 tx_free_thresh = res->value;
2770 else if (!strcmp(res->name, "txrst"))
2771 tx_rs_thresh = res->value;
2772 else if (!strcmp(res->name, "rxfreet"))
2773 rx_free_thresh = res->value;
2775 printf("Unknown parameter\n");
2781 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2784 cmdline_parse_token_string_t cmd_config_threshold_port =
2785 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2786 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2787 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2789 cmdline_parse_token_string_t cmd_config_threshold_all =
2790 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2791 cmdline_parse_token_string_t cmd_config_threshold_name =
2792 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2793 "txfreet#txrst#rxfreet");
2794 cmdline_parse_token_num_t cmd_config_threshold_value =
2795 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2797 cmdline_parse_inst_t cmd_config_threshold = {
2798 .f = cmd_config_threshold_parsed,
2800 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2802 (void *)&cmd_config_threshold_port,
2803 (void *)&cmd_config_threshold_keyword,
2804 (void *)&cmd_config_threshold_all,
2805 (void *)&cmd_config_threshold_name,
2806 (void *)&cmd_config_threshold_value,
2812 struct cmd_stop_result {
2813 cmdline_fixed_string_t stop;
2816 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2817 __attribute__((unused)) struct cmdline *cl,
2818 __attribute__((unused)) void *data)
2820 stop_packet_forwarding();
2823 cmdline_parse_token_string_t cmd_stop_stop =
2824 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2826 cmdline_parse_inst_t cmd_stop = {
2827 .f = cmd_stop_parsed,
2829 .help_str = "stop: Stop packet forwarding",
2831 (void *)&cmd_stop_stop,
2836 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2839 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2840 unsigned int *parsed_items, int check_unique_values)
2842 unsigned int nb_item;
2850 * First parse all items in the list and store their value.
2855 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2857 if ((c >= '0') && (c <= '9')) {
2858 value = (unsigned int) (value * 10 + (c - '0'));
2863 printf("character %c is not a decimal digit\n", c);
2867 printf("No valid value before comma\n");
2870 if (nb_item < max_items) {
2871 parsed_items[nb_item] = value;
2877 if (nb_item >= max_items) {
2878 printf("Number of %s = %u > %u (maximum items)\n",
2879 item_name, nb_item + 1, max_items);
2882 parsed_items[nb_item++] = value;
2883 if (! check_unique_values)
2887 * Then, check that all values in the list are differents.
2888 * No optimization here...
2890 for (i = 0; i < nb_item; i++) {
2891 for (j = i + 1; j < nb_item; j++) {
2892 if (parsed_items[j] == parsed_items[i]) {
2893 printf("duplicated %s %u at index %u and %u\n",
2894 item_name, parsed_items[i], i, j);
2902 struct cmd_set_list_result {
2903 cmdline_fixed_string_t cmd_keyword;
2904 cmdline_fixed_string_t list_name;
2905 cmdline_fixed_string_t list_of_items;
2908 static void cmd_set_list_parsed(void *parsed_result,
2909 __attribute__((unused)) struct cmdline *cl,
2910 __attribute__((unused)) void *data)
2912 struct cmd_set_list_result *res;
2914 unsigned int lcorelist[RTE_MAX_LCORE];
2915 unsigned int portlist[RTE_MAX_ETHPORTS];
2917 unsigned int nb_item;
2919 if (test_done == 0) {
2920 printf("Please stop forwarding first\n");
2924 res = parsed_result;
2925 if (!strcmp(res->list_name, "corelist")) {
2926 nb_item = parse_item_list(res->list_of_items, "core",
2928 parsed_items.lcorelist, 1);
2930 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2935 if (!strcmp(res->list_name, "portlist")) {
2936 nb_item = parse_item_list(res->list_of_items, "port",
2938 parsed_items.portlist, 1);
2940 set_fwd_ports_list(parsed_items.portlist, nb_item);
2946 cmdline_parse_token_string_t cmd_set_list_keyword =
2947 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2949 cmdline_parse_token_string_t cmd_set_list_name =
2950 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2951 "corelist#portlist");
2952 cmdline_parse_token_string_t cmd_set_list_of_items =
2953 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2956 cmdline_parse_inst_t cmd_set_fwd_list = {
2957 .f = cmd_set_list_parsed,
2959 .help_str = "set corelist|portlist <list0[,list1]*>",
2961 (void *)&cmd_set_list_keyword,
2962 (void *)&cmd_set_list_name,
2963 (void *)&cmd_set_list_of_items,
2968 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2970 struct cmd_setmask_result {
2971 cmdline_fixed_string_t set;
2972 cmdline_fixed_string_t mask;
2976 static void cmd_set_mask_parsed(void *parsed_result,
2977 __attribute__((unused)) struct cmdline *cl,
2978 __attribute__((unused)) void *data)
2980 struct cmd_setmask_result *res = parsed_result;
2982 if (test_done == 0) {
2983 printf("Please stop forwarding first\n");
2986 if (!strcmp(res->mask, "coremask")) {
2987 set_fwd_lcores_mask(res->hexavalue);
2989 } else if (!strcmp(res->mask, "portmask")) {
2990 set_fwd_ports_mask(res->hexavalue);
2995 cmdline_parse_token_string_t cmd_setmask_set =
2996 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2997 cmdline_parse_token_string_t cmd_setmask_mask =
2998 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2999 "coremask#portmask");
3000 cmdline_parse_token_num_t cmd_setmask_value =
3001 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3003 cmdline_parse_inst_t cmd_set_fwd_mask = {
3004 .f = cmd_set_mask_parsed,
3006 .help_str = "set coremask|portmask <hexadecimal value>",
3008 (void *)&cmd_setmask_set,
3009 (void *)&cmd_setmask_mask,
3010 (void *)&cmd_setmask_value,
3016 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3018 struct cmd_set_result {
3019 cmdline_fixed_string_t set;
3020 cmdline_fixed_string_t what;
3024 static void cmd_set_parsed(void *parsed_result,
3025 __attribute__((unused)) struct cmdline *cl,
3026 __attribute__((unused)) void *data)
3028 struct cmd_set_result *res = parsed_result;
3029 if (!strcmp(res->what, "nbport")) {
3030 set_fwd_ports_number(res->value);
3032 } else if (!strcmp(res->what, "nbcore")) {
3033 set_fwd_lcores_number(res->value);
3035 } else if (!strcmp(res->what, "burst"))
3036 set_nb_pkt_per_burst(res->value);
3037 else if (!strcmp(res->what, "verbose"))
3038 set_verbose_level(res->value);
3041 cmdline_parse_token_string_t cmd_set_set =
3042 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3043 cmdline_parse_token_string_t cmd_set_what =
3044 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3045 "nbport#nbcore#burst#verbose");
3046 cmdline_parse_token_num_t cmd_set_value =
3047 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3049 cmdline_parse_inst_t cmd_set_numbers = {
3050 .f = cmd_set_parsed,
3052 .help_str = "set nbport|nbcore|burst|verbose <value>",
3054 (void *)&cmd_set_set,
3055 (void *)&cmd_set_what,
3056 (void *)&cmd_set_value,
3061 /* *** SET LOG LEVEL CONFIGURATION *** */
3063 struct cmd_set_log_result {
3064 cmdline_fixed_string_t set;
3065 cmdline_fixed_string_t log;
3066 cmdline_fixed_string_t type;
3071 cmd_set_log_parsed(void *parsed_result,
3072 __attribute__((unused)) struct cmdline *cl,
3073 __attribute__((unused)) void *data)
3075 struct cmd_set_log_result *res;
3078 res = parsed_result;
3079 if (!strcmp(res->type, "global"))
3080 rte_log_set_global_level(res->level);
3082 ret = rte_log_set_level_regexp(res->type, res->level);
3084 printf("Unable to set log level\n");
3088 cmdline_parse_token_string_t cmd_set_log_set =
3089 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3090 cmdline_parse_token_string_t cmd_set_log_log =
3091 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3092 cmdline_parse_token_string_t cmd_set_log_type =
3093 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3094 cmdline_parse_token_num_t cmd_set_log_level =
3095 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3097 cmdline_parse_inst_t cmd_set_log = {
3098 .f = cmd_set_log_parsed,
3100 .help_str = "set log global|<type> <level>",
3102 (void *)&cmd_set_log_set,
3103 (void *)&cmd_set_log_log,
3104 (void *)&cmd_set_log_type,
3105 (void *)&cmd_set_log_level,
3110 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3112 struct cmd_set_txpkts_result {
3113 cmdline_fixed_string_t cmd_keyword;
3114 cmdline_fixed_string_t txpkts;
3115 cmdline_fixed_string_t seg_lengths;
3119 cmd_set_txpkts_parsed(void *parsed_result,
3120 __attribute__((unused)) struct cmdline *cl,
3121 __attribute__((unused)) void *data)
3123 struct cmd_set_txpkts_result *res;
3124 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3125 unsigned int nb_segs;
3127 res = parsed_result;
3128 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3129 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3131 set_tx_pkt_segments(seg_lengths, nb_segs);
3134 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3135 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3136 cmd_keyword, "set");
3137 cmdline_parse_token_string_t cmd_set_txpkts_name =
3138 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3140 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3141 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3144 cmdline_parse_inst_t cmd_set_txpkts = {
3145 .f = cmd_set_txpkts_parsed,
3147 .help_str = "set txpkts <len0[,len1]*>",
3149 (void *)&cmd_set_txpkts_keyword,
3150 (void *)&cmd_set_txpkts_name,
3151 (void *)&cmd_set_txpkts_lengths,
3156 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3158 struct cmd_set_txsplit_result {
3159 cmdline_fixed_string_t cmd_keyword;
3160 cmdline_fixed_string_t txsplit;
3161 cmdline_fixed_string_t mode;
3165 cmd_set_txsplit_parsed(void *parsed_result,
3166 __attribute__((unused)) struct cmdline *cl,
3167 __attribute__((unused)) void *data)
3169 struct cmd_set_txsplit_result *res;
3171 res = parsed_result;
3172 set_tx_pkt_split(res->mode);
3175 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3176 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3177 cmd_keyword, "set");
3178 cmdline_parse_token_string_t cmd_set_txsplit_name =
3179 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3180 txsplit, "txsplit");
3181 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3182 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3185 cmdline_parse_inst_t cmd_set_txsplit = {
3186 .f = cmd_set_txsplit_parsed,
3188 .help_str = "set txsplit on|off|rand",
3190 (void *)&cmd_set_txsplit_keyword,
3191 (void *)&cmd_set_txsplit_name,
3192 (void *)&cmd_set_txsplit_mode,
3197 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3198 struct cmd_rx_vlan_filter_all_result {
3199 cmdline_fixed_string_t rx_vlan;
3200 cmdline_fixed_string_t what;
3201 cmdline_fixed_string_t all;
3206 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3207 __attribute__((unused)) struct cmdline *cl,
3208 __attribute__((unused)) void *data)
3210 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3212 if (!strcmp(res->what, "add"))
3213 rx_vlan_all_filter_set(res->port_id, 1);
3215 rx_vlan_all_filter_set(res->port_id, 0);
3218 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3219 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3220 rx_vlan, "rx_vlan");
3221 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3222 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3224 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3225 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3227 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3228 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3231 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3232 .f = cmd_rx_vlan_filter_all_parsed,
3234 .help_str = "rx_vlan add|rm all <port_id>: "
3235 "Add/Remove all identifiers to/from the set of VLAN "
3236 "identifiers filtered by a port",
3238 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3239 (void *)&cmd_rx_vlan_filter_all_what,
3240 (void *)&cmd_rx_vlan_filter_all_all,
3241 (void *)&cmd_rx_vlan_filter_all_portid,
3246 /* *** VLAN OFFLOAD SET ON A PORT *** */
3247 struct cmd_vlan_offload_result {
3248 cmdline_fixed_string_t vlan;
3249 cmdline_fixed_string_t set;
3250 cmdline_fixed_string_t vlan_type;
3251 cmdline_fixed_string_t what;
3252 cmdline_fixed_string_t on;
3253 cmdline_fixed_string_t port_id;
3257 cmd_vlan_offload_parsed(void *parsed_result,
3258 __attribute__((unused)) struct cmdline *cl,
3259 __attribute__((unused)) void *data)
3262 struct cmd_vlan_offload_result *res = parsed_result;
3265 portid_t port_id = 0;
3269 len = strnlen(str, STR_TOKEN_SIZE);
3271 /* Get port_id first */
3279 tmp = strtoul(str, NULL, 0);
3280 /* If port_id greater that what portid_t can represent, return */
3281 if(tmp >= RTE_MAX_ETHPORTS)
3283 port_id = (portid_t)tmp;
3285 if (!strcmp(res->on, "on"))
3290 if (!strcmp(res->what, "strip"))
3291 rx_vlan_strip_set(port_id, on);
3292 else if(!strcmp(res->what, "stripq")){
3293 uint16_t queue_id = 0;
3295 /* No queue_id, return */
3297 printf("must specify (port,queue_id)\n");
3300 tmp = strtoul(str + i + 1, NULL, 0);
3301 /* If queue_id greater that what 16-bits can represent, return */
3305 queue_id = (uint16_t)tmp;
3306 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3308 else if (!strcmp(res->what, "filter"))
3309 rx_vlan_filter_set(port_id, on);
3311 vlan_extend_set(port_id, on);
3316 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3317 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3319 cmdline_parse_token_string_t cmd_vlan_offload_set =
3320 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3322 cmdline_parse_token_string_t cmd_vlan_offload_what =
3323 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3324 what, "strip#filter#qinq#stripq");
3325 cmdline_parse_token_string_t cmd_vlan_offload_on =
3326 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3328 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3329 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3332 cmdline_parse_inst_t cmd_vlan_offload = {
3333 .f = cmd_vlan_offload_parsed,
3335 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3336 "<port_id[,queue_id]>: "
3337 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3339 (void *)&cmd_vlan_offload_vlan,
3340 (void *)&cmd_vlan_offload_set,
3341 (void *)&cmd_vlan_offload_what,
3342 (void *)&cmd_vlan_offload_on,
3343 (void *)&cmd_vlan_offload_portid,
3348 /* *** VLAN TPID SET ON A PORT *** */
3349 struct cmd_vlan_tpid_result {
3350 cmdline_fixed_string_t vlan;
3351 cmdline_fixed_string_t set;
3352 cmdline_fixed_string_t vlan_type;
3353 cmdline_fixed_string_t what;
3359 cmd_vlan_tpid_parsed(void *parsed_result,
3360 __attribute__((unused)) struct cmdline *cl,
3361 __attribute__((unused)) void *data)
3363 struct cmd_vlan_tpid_result *res = parsed_result;
3364 enum rte_vlan_type vlan_type;
3366 if (!strcmp(res->vlan_type, "inner"))
3367 vlan_type = ETH_VLAN_TYPE_INNER;
3368 else if (!strcmp(res->vlan_type, "outer"))
3369 vlan_type = ETH_VLAN_TYPE_OUTER;
3371 printf("Unknown vlan type\n");
3374 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3377 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3378 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3380 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3381 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3383 cmdline_parse_token_string_t cmd_vlan_type =
3384 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3385 vlan_type, "inner#outer");
3386 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3387 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3389 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3390 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3392 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3393 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3396 cmdline_parse_inst_t cmd_vlan_tpid = {
3397 .f = cmd_vlan_tpid_parsed,
3399 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3400 "Set the VLAN Ether type",
3402 (void *)&cmd_vlan_tpid_vlan,
3403 (void *)&cmd_vlan_tpid_set,
3404 (void *)&cmd_vlan_type,
3405 (void *)&cmd_vlan_tpid_what,
3406 (void *)&cmd_vlan_tpid_tpid,
3407 (void *)&cmd_vlan_tpid_portid,
3412 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3413 struct cmd_rx_vlan_filter_result {
3414 cmdline_fixed_string_t rx_vlan;
3415 cmdline_fixed_string_t what;
3421 cmd_rx_vlan_filter_parsed(void *parsed_result,
3422 __attribute__((unused)) struct cmdline *cl,
3423 __attribute__((unused)) void *data)
3425 struct cmd_rx_vlan_filter_result *res = parsed_result;
3427 if (!strcmp(res->what, "add"))
3428 rx_vft_set(res->port_id, res->vlan_id, 1);
3430 rx_vft_set(res->port_id, res->vlan_id, 0);
3433 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3434 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3435 rx_vlan, "rx_vlan");
3436 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3437 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3439 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3440 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3442 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3443 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3446 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3447 .f = cmd_rx_vlan_filter_parsed,
3449 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3450 "Add/Remove a VLAN identifier to/from the set of VLAN "
3451 "identifiers filtered by a port",
3453 (void *)&cmd_rx_vlan_filter_rx_vlan,
3454 (void *)&cmd_rx_vlan_filter_what,
3455 (void *)&cmd_rx_vlan_filter_vlanid,
3456 (void *)&cmd_rx_vlan_filter_portid,
3461 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3462 struct cmd_tx_vlan_set_result {
3463 cmdline_fixed_string_t tx_vlan;
3464 cmdline_fixed_string_t set;
3470 cmd_tx_vlan_set_parsed(void *parsed_result,
3471 __attribute__((unused)) struct cmdline *cl,
3472 __attribute__((unused)) void *data)
3474 struct cmd_tx_vlan_set_result *res = parsed_result;
3476 if (!port_is_stopped(res->port_id)) {
3477 printf("Please stop port %d first\n", res->port_id);
3481 tx_vlan_set(res->port_id, res->vlan_id);
3483 cmd_reconfig_device_queue(res->port_id, 1, 1);
3486 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3487 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3488 tx_vlan, "tx_vlan");
3489 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3490 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3492 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3493 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3495 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3496 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3499 cmdline_parse_inst_t cmd_tx_vlan_set = {
3500 .f = cmd_tx_vlan_set_parsed,
3502 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3503 "Enable hardware insertion of a single VLAN header "
3504 "with a given TAG Identifier in packets sent on a port",
3506 (void *)&cmd_tx_vlan_set_tx_vlan,
3507 (void *)&cmd_tx_vlan_set_set,
3508 (void *)&cmd_tx_vlan_set_portid,
3509 (void *)&cmd_tx_vlan_set_vlanid,
3514 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3515 struct cmd_tx_vlan_set_qinq_result {
3516 cmdline_fixed_string_t tx_vlan;
3517 cmdline_fixed_string_t set;
3520 uint16_t vlan_id_outer;
3524 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3525 __attribute__((unused)) struct cmdline *cl,
3526 __attribute__((unused)) void *data)
3528 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3530 if (!port_is_stopped(res->port_id)) {
3531 printf("Please stop port %d first\n", res->port_id);
3535 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3537 cmd_reconfig_device_queue(res->port_id, 1, 1);
3540 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3541 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3542 tx_vlan, "tx_vlan");
3543 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3544 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3546 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3547 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3549 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3550 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3552 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3553 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3554 vlan_id_outer, UINT16);
3556 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3557 .f = cmd_tx_vlan_set_qinq_parsed,
3559 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3560 "Enable hardware insertion of double VLAN header "
3561 "with given TAG Identifiers in packets sent on a port",
3563 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3564 (void *)&cmd_tx_vlan_set_qinq_set,
3565 (void *)&cmd_tx_vlan_set_qinq_portid,
3566 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3567 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3572 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3573 struct cmd_tx_vlan_set_pvid_result {
3574 cmdline_fixed_string_t tx_vlan;
3575 cmdline_fixed_string_t set;
3576 cmdline_fixed_string_t pvid;
3579 cmdline_fixed_string_t mode;
3583 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3584 __attribute__((unused)) struct cmdline *cl,
3585 __attribute__((unused)) void *data)
3587 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3589 if (strcmp(res->mode, "on") == 0)
3590 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3592 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3595 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3596 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3597 tx_vlan, "tx_vlan");
3598 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3599 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3601 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3602 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3604 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3605 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3607 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3608 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3610 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3611 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3614 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3615 .f = cmd_tx_vlan_set_pvid_parsed,
3617 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3619 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3620 (void *)&cmd_tx_vlan_set_pvid_set,
3621 (void *)&cmd_tx_vlan_set_pvid_pvid,
3622 (void *)&cmd_tx_vlan_set_pvid_port_id,
3623 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3624 (void *)&cmd_tx_vlan_set_pvid_mode,
3629 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3630 struct cmd_tx_vlan_reset_result {
3631 cmdline_fixed_string_t tx_vlan;
3632 cmdline_fixed_string_t reset;
3637 cmd_tx_vlan_reset_parsed(void *parsed_result,
3638 __attribute__((unused)) struct cmdline *cl,
3639 __attribute__((unused)) void *data)
3641 struct cmd_tx_vlan_reset_result *res = parsed_result;
3643 if (!port_is_stopped(res->port_id)) {
3644 printf("Please stop port %d first\n", res->port_id);
3648 tx_vlan_reset(res->port_id);
3650 cmd_reconfig_device_queue(res->port_id, 1, 1);
3653 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3654 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3655 tx_vlan, "tx_vlan");
3656 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3657 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3659 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3660 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3663 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3664 .f = cmd_tx_vlan_reset_parsed,
3666 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3667 "VLAN header in packets sent on a port",
3669 (void *)&cmd_tx_vlan_reset_tx_vlan,
3670 (void *)&cmd_tx_vlan_reset_reset,
3671 (void *)&cmd_tx_vlan_reset_portid,
3677 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3678 struct cmd_csum_result {
3679 cmdline_fixed_string_t csum;
3680 cmdline_fixed_string_t mode;
3681 cmdline_fixed_string_t proto;
3682 cmdline_fixed_string_t hwsw;
3687 csum_show(int port_id)
3689 struct rte_eth_dev_info dev_info;
3690 uint64_t tx_offloads;
3692 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3693 printf("Parse tunnel is %s\n",
3694 (ports[port_id].parse_tunnel) ? "on" : "off");
3695 printf("IP checksum offload is %s\n",
3696 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3697 printf("UDP checksum offload is %s\n",
3698 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3699 printf("TCP checksum offload is %s\n",
3700 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3701 printf("SCTP checksum offload is %s\n",
3702 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3703 printf("Outer-Ip checksum offload is %s\n",
3704 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3706 /* display warnings if configuration is not supported by the NIC */
3707 rte_eth_dev_info_get(port_id, &dev_info);
3708 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3709 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3710 printf("Warning: hardware IP checksum enabled but not "
3711 "supported by port %d\n", port_id);
3713 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3714 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3715 printf("Warning: hardware UDP checksum enabled but not "
3716 "supported by port %d\n", port_id);
3718 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3719 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3720 printf("Warning: hardware TCP checksum enabled but not "
3721 "supported by port %d\n", port_id);
3723 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3724 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3725 printf("Warning: hardware SCTP checksum enabled but not "
3726 "supported by port %d\n", port_id);
3728 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3729 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3730 printf("Warning: hardware outer IP checksum enabled but not "
3731 "supported by port %d\n", port_id);
3736 cmd_csum_parsed(void *parsed_result,
3737 __attribute__((unused)) struct cmdline *cl,
3738 __attribute__((unused)) void *data)
3740 struct cmd_csum_result *res = parsed_result;
3742 uint64_t csum_offloads = 0;
3743 struct rte_eth_dev_info dev_info;
3745 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3746 printf("invalid port %d\n", res->port_id);
3749 if (!port_is_stopped(res->port_id)) {
3750 printf("Please stop port %d first\n", res->port_id);
3754 rte_eth_dev_info_get(res->port_id, &dev_info);
3755 if (!strcmp(res->mode, "set")) {
3757 if (!strcmp(res->hwsw, "hw"))
3760 if (!strcmp(res->proto, "ip")) {
3761 if (hw == 0 || (dev_info.tx_offload_capa &
3762 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
3763 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3765 printf("IP checksum offload is not supported "
3766 "by port %u\n", res->port_id);
3768 } else if (!strcmp(res->proto, "udp")) {
3769 if (hw == 0 || (dev_info.tx_offload_capa &
3770 DEV_TX_OFFLOAD_UDP_CKSUM)) {
3771 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3773 printf("UDP checksum offload is not supported "
3774 "by port %u\n", res->port_id);
3776 } else if (!strcmp(res->proto, "tcp")) {
3777 if (hw == 0 || (dev_info.tx_offload_capa &
3778 DEV_TX_OFFLOAD_TCP_CKSUM)) {
3779 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3781 printf("TCP checksum offload is not supported "
3782 "by port %u\n", res->port_id);
3784 } else if (!strcmp(res->proto, "sctp")) {
3785 if (hw == 0 || (dev_info.tx_offload_capa &
3786 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
3787 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3789 printf("SCTP checksum offload is not supported "
3790 "by port %u\n", res->port_id);
3792 } else if (!strcmp(res->proto, "outer-ip")) {
3793 if (hw == 0 || (dev_info.tx_offload_capa &
3794 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
3796 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3798 printf("Outer IP checksum offload is not "
3799 "supported by port %u\n", res->port_id);
3804 ports[res->port_id].dev_conf.txmode.offloads |=
3807 ports[res->port_id].dev_conf.txmode.offloads &=
3811 csum_show(res->port_id);
3813 cmd_reconfig_device_queue(res->port_id, 1, 1);
3816 cmdline_parse_token_string_t cmd_csum_csum =
3817 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3819 cmdline_parse_token_string_t cmd_csum_mode =
3820 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3822 cmdline_parse_token_string_t cmd_csum_proto =
3823 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3824 proto, "ip#tcp#udp#sctp#outer-ip");
3825 cmdline_parse_token_string_t cmd_csum_hwsw =
3826 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3828 cmdline_parse_token_num_t cmd_csum_portid =
3829 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3832 cmdline_parse_inst_t cmd_csum_set = {
3833 .f = cmd_csum_parsed,
3835 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3836 "Enable/Disable hardware calculation of L3/L4 checksum when "
3837 "using csum forward engine",
3839 (void *)&cmd_csum_csum,
3840 (void *)&cmd_csum_mode,
3841 (void *)&cmd_csum_proto,
3842 (void *)&cmd_csum_hwsw,
3843 (void *)&cmd_csum_portid,
3848 cmdline_parse_token_string_t cmd_csum_mode_show =
3849 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3852 cmdline_parse_inst_t cmd_csum_show = {
3853 .f = cmd_csum_parsed,
3855 .help_str = "csum show <port_id>: Show checksum offload configuration",
3857 (void *)&cmd_csum_csum,
3858 (void *)&cmd_csum_mode_show,
3859 (void *)&cmd_csum_portid,
3864 /* Enable/disable tunnel parsing */
3865 struct cmd_csum_tunnel_result {
3866 cmdline_fixed_string_t csum;
3867 cmdline_fixed_string_t parse;
3868 cmdline_fixed_string_t onoff;
3873 cmd_csum_tunnel_parsed(void *parsed_result,
3874 __attribute__((unused)) struct cmdline *cl,
3875 __attribute__((unused)) void *data)
3877 struct cmd_csum_tunnel_result *res = parsed_result;
3879 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3882 if (!strcmp(res->onoff, "on"))
3883 ports[res->port_id].parse_tunnel = 1;
3885 ports[res->port_id].parse_tunnel = 0;
3887 csum_show(res->port_id);
3890 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3891 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3893 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3894 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3895 parse, "parse_tunnel");
3896 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3897 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3899 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3900 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3903 cmdline_parse_inst_t cmd_csum_tunnel = {
3904 .f = cmd_csum_tunnel_parsed,
3906 .help_str = "csum parse_tunnel on|off <port_id>: "
3907 "Enable/Disable parsing of tunnels for csum engine",
3909 (void *)&cmd_csum_tunnel_csum,
3910 (void *)&cmd_csum_tunnel_parse,
3911 (void *)&cmd_csum_tunnel_onoff,
3912 (void *)&cmd_csum_tunnel_portid,
3917 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3918 struct cmd_tso_set_result {
3919 cmdline_fixed_string_t tso;
3920 cmdline_fixed_string_t mode;
3926 cmd_tso_set_parsed(void *parsed_result,
3927 __attribute__((unused)) struct cmdline *cl,
3928 __attribute__((unused)) void *data)
3930 struct cmd_tso_set_result *res = parsed_result;
3931 struct rte_eth_dev_info dev_info;
3933 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3935 if (!port_is_stopped(res->port_id)) {
3936 printf("Please stop port %d first\n", res->port_id);
3940 if (!strcmp(res->mode, "set"))
3941 ports[res->port_id].tso_segsz = res->tso_segsz;
3943 rte_eth_dev_info_get(res->port_id, &dev_info);
3944 if ((ports[res->port_id].tso_segsz != 0) &&
3945 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3946 printf("Error: TSO is not supported by port %d\n",
3951 if (ports[res->port_id].tso_segsz == 0) {
3952 ports[res->port_id].dev_conf.txmode.offloads &=
3953 ~DEV_TX_OFFLOAD_TCP_TSO;
3954 printf("TSO for non-tunneled packets is disabled\n");
3956 ports[res->port_id].dev_conf.txmode.offloads |=
3957 DEV_TX_OFFLOAD_TCP_TSO;
3958 printf("TSO segment size for non-tunneled packets is %d\n",
3959 ports[res->port_id].tso_segsz);
3962 /* display warnings if configuration is not supported by the NIC */
3963 rte_eth_dev_info_get(res->port_id, &dev_info);
3964 if ((ports[res->port_id].tso_segsz != 0) &&
3965 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3966 printf("Warning: TSO enabled but not "
3967 "supported by port %d\n", res->port_id);
3970 cmd_reconfig_device_queue(res->port_id, 1, 1);
3973 cmdline_parse_token_string_t cmd_tso_set_tso =
3974 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3976 cmdline_parse_token_string_t cmd_tso_set_mode =
3977 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3979 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3980 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3982 cmdline_parse_token_num_t cmd_tso_set_portid =
3983 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3986 cmdline_parse_inst_t cmd_tso_set = {
3987 .f = cmd_tso_set_parsed,
3989 .help_str = "tso set <tso_segsz> <port_id>: "
3990 "Set TSO segment size of non-tunneled packets for csum engine "
3993 (void *)&cmd_tso_set_tso,
3994 (void *)&cmd_tso_set_mode,
3995 (void *)&cmd_tso_set_tso_segsz,
3996 (void *)&cmd_tso_set_portid,
4001 cmdline_parse_token_string_t cmd_tso_show_mode =
4002 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4006 cmdline_parse_inst_t cmd_tso_show = {
4007 .f = cmd_tso_set_parsed,
4009 .help_str = "tso show <port_id>: "
4010 "Show TSO segment size of non-tunneled packets for csum engine",
4012 (void *)&cmd_tso_set_tso,
4013 (void *)&cmd_tso_show_mode,
4014 (void *)&cmd_tso_set_portid,
4019 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4020 struct cmd_tunnel_tso_set_result {
4021 cmdline_fixed_string_t tso;
4022 cmdline_fixed_string_t mode;
4027 static struct rte_eth_dev_info
4028 check_tunnel_tso_nic_support(portid_t port_id)
4030 struct rte_eth_dev_info dev_info;
4032 rte_eth_dev_info_get(port_id, &dev_info);
4033 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4034 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4035 "not enabled for port %d\n", port_id);
4036 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4037 printf("Warning: GRE TUNNEL TSO not supported therefore "
4038 "not enabled for port %d\n", port_id);
4039 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4040 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4041 "not enabled for port %d\n", port_id);
4042 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4043 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4044 "not enabled for port %d\n", port_id);
4049 cmd_tunnel_tso_set_parsed(void *parsed_result,
4050 __attribute__((unused)) struct cmdline *cl,
4051 __attribute__((unused)) void *data)
4053 struct cmd_tunnel_tso_set_result *res = parsed_result;
4054 struct rte_eth_dev_info dev_info;
4056 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4058 if (!port_is_stopped(res->port_id)) {
4059 printf("Please stop port %d first\n", res->port_id);
4063 if (!strcmp(res->mode, "set"))
4064 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4066 dev_info = check_tunnel_tso_nic_support(res->port_id);
4067 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4068 ports[res->port_id].dev_conf.txmode.offloads &=
4069 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4070 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4071 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4072 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4073 printf("TSO for tunneled packets is disabled\n");
4075 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4076 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4077 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4078 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4080 ports[res->port_id].dev_conf.txmode.offloads |=
4081 (tso_offloads & dev_info.tx_offload_capa);
4082 printf("TSO segment size for tunneled packets is %d\n",
4083 ports[res->port_id].tunnel_tso_segsz);
4085 /* Below conditions are needed to make it work:
4086 * (1) tunnel TSO is supported by the NIC;
4087 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4089 * (3) for tunneled pkts with outer L3 of IPv4,
4090 * "csum set outer-ip" must be set to hw, because after tso,
4091 * total_len of outer IP header is changed, and the checksum
4092 * of outer IP header calculated by sw should be wrong; that
4093 * is not necessary for IPv6 tunneled pkts because there's no
4094 * checksum in IP header anymore.
4097 if (!ports[res->port_id].parse_tunnel)
4098 printf("Warning: csum parse_tunnel must be set "
4099 "so that tunneled packets are recognized\n");
4100 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4101 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4102 printf("Warning: csum set outer-ip must be set to hw "
4103 "if outer L3 is IPv4; not necessary for IPv6\n");
4106 cmd_reconfig_device_queue(res->port_id, 1, 1);
4109 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4110 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4112 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4113 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4115 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4116 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4118 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4119 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4122 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4123 .f = cmd_tunnel_tso_set_parsed,
4125 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4126 "Set TSO segment size of tunneled packets for csum engine "
4129 (void *)&cmd_tunnel_tso_set_tso,
4130 (void *)&cmd_tunnel_tso_set_mode,
4131 (void *)&cmd_tunnel_tso_set_tso_segsz,
4132 (void *)&cmd_tunnel_tso_set_portid,
4137 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4138 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4142 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4143 .f = cmd_tunnel_tso_set_parsed,
4145 .help_str = "tunnel_tso show <port_id> "
4146 "Show TSO segment size of tunneled packets for csum engine",
4148 (void *)&cmd_tunnel_tso_set_tso,
4149 (void *)&cmd_tunnel_tso_show_mode,
4150 (void *)&cmd_tunnel_tso_set_portid,
4155 /* *** SET GRO FOR A PORT *** */
4156 struct cmd_gro_enable_result {
4157 cmdline_fixed_string_t cmd_set;
4158 cmdline_fixed_string_t cmd_port;
4159 cmdline_fixed_string_t cmd_keyword;
4160 cmdline_fixed_string_t cmd_onoff;
4165 cmd_gro_enable_parsed(void *parsed_result,
4166 __attribute__((unused)) struct cmdline *cl,
4167 __attribute__((unused)) void *data)
4169 struct cmd_gro_enable_result *res;
4171 res = parsed_result;
4172 if (!strcmp(res->cmd_keyword, "gro"))
4173 setup_gro(res->cmd_onoff, res->cmd_pid);
4176 cmdline_parse_token_string_t cmd_gro_enable_set =
4177 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4179 cmdline_parse_token_string_t cmd_gro_enable_port =
4180 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4181 cmd_keyword, "port");
4182 cmdline_parse_token_num_t cmd_gro_enable_pid =
4183 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4185 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4186 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4187 cmd_keyword, "gro");
4188 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4189 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4190 cmd_onoff, "on#off");
4192 cmdline_parse_inst_t cmd_gro_enable = {
4193 .f = cmd_gro_enable_parsed,
4195 .help_str = "set port <port_id> gro on|off",
4197 (void *)&cmd_gro_enable_set,
4198 (void *)&cmd_gro_enable_port,
4199 (void *)&cmd_gro_enable_pid,
4200 (void *)&cmd_gro_enable_keyword,
4201 (void *)&cmd_gro_enable_onoff,
4206 /* *** DISPLAY GRO CONFIGURATION *** */
4207 struct cmd_gro_show_result {
4208 cmdline_fixed_string_t cmd_show;
4209 cmdline_fixed_string_t cmd_port;
4210 cmdline_fixed_string_t cmd_keyword;
4215 cmd_gro_show_parsed(void *parsed_result,
4216 __attribute__((unused)) struct cmdline *cl,
4217 __attribute__((unused)) void *data)
4219 struct cmd_gro_show_result *res;
4221 res = parsed_result;
4222 if (!strcmp(res->cmd_keyword, "gro"))
4223 show_gro(res->cmd_pid);
4226 cmdline_parse_token_string_t cmd_gro_show_show =
4227 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4229 cmdline_parse_token_string_t cmd_gro_show_port =
4230 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4232 cmdline_parse_token_num_t cmd_gro_show_pid =
4233 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4235 cmdline_parse_token_string_t cmd_gro_show_keyword =
4236 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4237 cmd_keyword, "gro");
4239 cmdline_parse_inst_t cmd_gro_show = {
4240 .f = cmd_gro_show_parsed,
4242 .help_str = "show port <port_id> gro",
4244 (void *)&cmd_gro_show_show,
4245 (void *)&cmd_gro_show_port,
4246 (void *)&cmd_gro_show_pid,
4247 (void *)&cmd_gro_show_keyword,
4252 /* *** SET FLUSH CYCLES FOR GRO *** */
4253 struct cmd_gro_flush_result {
4254 cmdline_fixed_string_t cmd_set;
4255 cmdline_fixed_string_t cmd_keyword;
4256 cmdline_fixed_string_t cmd_flush;
4261 cmd_gro_flush_parsed(void *parsed_result,
4262 __attribute__((unused)) struct cmdline *cl,
4263 __attribute__((unused)) void *data)
4265 struct cmd_gro_flush_result *res;
4267 res = parsed_result;
4268 if ((!strcmp(res->cmd_keyword, "gro")) &&
4269 (!strcmp(res->cmd_flush, "flush")))
4270 setup_gro_flush_cycles(res->cmd_cycles);
4273 cmdline_parse_token_string_t cmd_gro_flush_set =
4274 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4276 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4277 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4278 cmd_keyword, "gro");
4279 cmdline_parse_token_string_t cmd_gro_flush_flush =
4280 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4281 cmd_flush, "flush");
4282 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4283 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4286 cmdline_parse_inst_t cmd_gro_flush = {
4287 .f = cmd_gro_flush_parsed,
4289 .help_str = "set gro flush <cycles>",
4291 (void *)&cmd_gro_flush_set,
4292 (void *)&cmd_gro_flush_keyword,
4293 (void *)&cmd_gro_flush_flush,
4294 (void *)&cmd_gro_flush_cycles,
4299 /* *** ENABLE/DISABLE GSO *** */
4300 struct cmd_gso_enable_result {
4301 cmdline_fixed_string_t cmd_set;
4302 cmdline_fixed_string_t cmd_port;
4303 cmdline_fixed_string_t cmd_keyword;
4304 cmdline_fixed_string_t cmd_mode;
4309 cmd_gso_enable_parsed(void *parsed_result,
4310 __attribute__((unused)) struct cmdline *cl,
4311 __attribute__((unused)) void *data)
4313 struct cmd_gso_enable_result *res;
4315 res = parsed_result;
4316 if (!strcmp(res->cmd_keyword, "gso"))
4317 setup_gso(res->cmd_mode, res->cmd_pid);
4320 cmdline_parse_token_string_t cmd_gso_enable_set =
4321 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4323 cmdline_parse_token_string_t cmd_gso_enable_port =
4324 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4326 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4327 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4328 cmd_keyword, "gso");
4329 cmdline_parse_token_string_t cmd_gso_enable_mode =
4330 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4331 cmd_mode, "on#off");
4332 cmdline_parse_token_num_t cmd_gso_enable_pid =
4333 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4336 cmdline_parse_inst_t cmd_gso_enable = {
4337 .f = cmd_gso_enable_parsed,
4339 .help_str = "set port <port_id> gso on|off",
4341 (void *)&cmd_gso_enable_set,
4342 (void *)&cmd_gso_enable_port,
4343 (void *)&cmd_gso_enable_pid,
4344 (void *)&cmd_gso_enable_keyword,
4345 (void *)&cmd_gso_enable_mode,
4350 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4351 struct cmd_gso_size_result {
4352 cmdline_fixed_string_t cmd_set;
4353 cmdline_fixed_string_t cmd_keyword;
4354 cmdline_fixed_string_t cmd_segsz;
4359 cmd_gso_size_parsed(void *parsed_result,
4360 __attribute__((unused)) struct cmdline *cl,
4361 __attribute__((unused)) void *data)
4363 struct cmd_gso_size_result *res = parsed_result;
4365 if (test_done == 0) {
4366 printf("Before setting GSO segsz, please first"
4367 " stop fowarding\n");
4371 if (!strcmp(res->cmd_keyword, "gso") &&
4372 !strcmp(res->cmd_segsz, "segsz")) {
4373 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4374 printf("gso_size should be larger than %zu."
4375 " Please input a legal value\n",
4376 RTE_GSO_SEG_SIZE_MIN);
4378 gso_max_segment_size = res->cmd_size;
4382 cmdline_parse_token_string_t cmd_gso_size_set =
4383 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4385 cmdline_parse_token_string_t cmd_gso_size_keyword =
4386 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4387 cmd_keyword, "gso");
4388 cmdline_parse_token_string_t cmd_gso_size_segsz =
4389 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4390 cmd_segsz, "segsz");
4391 cmdline_parse_token_num_t cmd_gso_size_size =
4392 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4395 cmdline_parse_inst_t cmd_gso_size = {
4396 .f = cmd_gso_size_parsed,
4398 .help_str = "set gso segsz <length>",
4400 (void *)&cmd_gso_size_set,
4401 (void *)&cmd_gso_size_keyword,
4402 (void *)&cmd_gso_size_segsz,
4403 (void *)&cmd_gso_size_size,
4408 /* *** SHOW GSO CONFIGURATION *** */
4409 struct cmd_gso_show_result {
4410 cmdline_fixed_string_t cmd_show;
4411 cmdline_fixed_string_t cmd_port;
4412 cmdline_fixed_string_t cmd_keyword;
4417 cmd_gso_show_parsed(void *parsed_result,
4418 __attribute__((unused)) struct cmdline *cl,
4419 __attribute__((unused)) void *data)
4421 struct cmd_gso_show_result *res = parsed_result;
4423 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4424 printf("invalid port id %u\n", res->cmd_pid);
4427 if (!strcmp(res->cmd_keyword, "gso")) {
4428 if (gso_ports[res->cmd_pid].enable) {
4429 printf("Max GSO'd packet size: %uB\n"
4430 "Supported GSO types: TCP/IPv4, "
4431 "VxLAN with inner TCP/IPv4 packet, "
4432 "GRE with inner TCP/IPv4 packet\n",
4433 gso_max_segment_size);
4435 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4439 cmdline_parse_token_string_t cmd_gso_show_show =
4440 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4442 cmdline_parse_token_string_t cmd_gso_show_port =
4443 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4445 cmdline_parse_token_string_t cmd_gso_show_keyword =
4446 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4447 cmd_keyword, "gso");
4448 cmdline_parse_token_num_t cmd_gso_show_pid =
4449 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4452 cmdline_parse_inst_t cmd_gso_show = {
4453 .f = cmd_gso_show_parsed,
4455 .help_str = "show port <port_id> gso",
4457 (void *)&cmd_gso_show_show,
4458 (void *)&cmd_gso_show_port,
4459 (void *)&cmd_gso_show_pid,
4460 (void *)&cmd_gso_show_keyword,
4465 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4466 struct cmd_set_flush_rx {
4467 cmdline_fixed_string_t set;
4468 cmdline_fixed_string_t flush_rx;
4469 cmdline_fixed_string_t mode;
4473 cmd_set_flush_rx_parsed(void *parsed_result,
4474 __attribute__((unused)) struct cmdline *cl,
4475 __attribute__((unused)) void *data)
4477 struct cmd_set_flush_rx *res = parsed_result;
4478 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4481 cmdline_parse_token_string_t cmd_setflushrx_set =
4482 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4484 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4485 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4486 flush_rx, "flush_rx");
4487 cmdline_parse_token_string_t cmd_setflushrx_mode =
4488 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4492 cmdline_parse_inst_t cmd_set_flush_rx = {
4493 .f = cmd_set_flush_rx_parsed,
4494 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4497 (void *)&cmd_setflushrx_set,
4498 (void *)&cmd_setflushrx_flush_rx,
4499 (void *)&cmd_setflushrx_mode,
4504 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4505 struct cmd_set_link_check {
4506 cmdline_fixed_string_t set;
4507 cmdline_fixed_string_t link_check;
4508 cmdline_fixed_string_t mode;
4512 cmd_set_link_check_parsed(void *parsed_result,
4513 __attribute__((unused)) struct cmdline *cl,
4514 __attribute__((unused)) void *data)
4516 struct cmd_set_link_check *res = parsed_result;
4517 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4520 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4521 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4523 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4524 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4525 link_check, "link_check");
4526 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4527 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4531 cmdline_parse_inst_t cmd_set_link_check = {
4532 .f = cmd_set_link_check_parsed,
4533 .help_str = "set link_check on|off: Enable/Disable link status check "
4534 "when starting/stopping a port",
4537 (void *)&cmd_setlinkcheck_set,
4538 (void *)&cmd_setlinkcheck_link_check,
4539 (void *)&cmd_setlinkcheck_mode,
4544 /* *** SET NIC BYPASS MODE *** */
4545 struct cmd_set_bypass_mode_result {
4546 cmdline_fixed_string_t set;
4547 cmdline_fixed_string_t bypass;
4548 cmdline_fixed_string_t mode;
4549 cmdline_fixed_string_t value;
4554 cmd_set_bypass_mode_parsed(void *parsed_result,
4555 __attribute__((unused)) struct cmdline *cl,
4556 __attribute__((unused)) void *data)
4558 struct cmd_set_bypass_mode_result *res = parsed_result;
4559 portid_t port_id = res->port_id;
4560 int32_t rc = -EINVAL;
4562 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4563 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4565 if (!strcmp(res->value, "bypass"))
4566 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4567 else if (!strcmp(res->value, "isolate"))
4568 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4570 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4572 /* Set the bypass mode for the relevant port. */
4573 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4576 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4579 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4580 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4582 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4583 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4585 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4586 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4588 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4589 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4590 value, "normal#bypass#isolate");
4591 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4592 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4595 cmdline_parse_inst_t cmd_set_bypass_mode = {
4596 .f = cmd_set_bypass_mode_parsed,
4597 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4598 "Set the NIC bypass mode for port_id",
4601 (void *)&cmd_setbypass_mode_set,
4602 (void *)&cmd_setbypass_mode_bypass,
4603 (void *)&cmd_setbypass_mode_mode,
4604 (void *)&cmd_setbypass_mode_value,
4605 (void *)&cmd_setbypass_mode_port,
4610 /* *** SET NIC BYPASS EVENT *** */
4611 struct cmd_set_bypass_event_result {
4612 cmdline_fixed_string_t set;
4613 cmdline_fixed_string_t bypass;
4614 cmdline_fixed_string_t event;
4615 cmdline_fixed_string_t event_value;
4616 cmdline_fixed_string_t mode;
4617 cmdline_fixed_string_t mode_value;
4622 cmd_set_bypass_event_parsed(void *parsed_result,
4623 __attribute__((unused)) struct cmdline *cl,
4624 __attribute__((unused)) void *data)
4626 int32_t rc = -EINVAL;
4627 struct cmd_set_bypass_event_result *res = parsed_result;
4628 portid_t port_id = res->port_id;
4630 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4631 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4632 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4634 if (!strcmp(res->event_value, "timeout"))
4635 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4636 else if (!strcmp(res->event_value, "os_on"))
4637 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4638 else if (!strcmp(res->event_value, "os_off"))
4639 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4640 else if (!strcmp(res->event_value, "power_on"))
4641 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4642 else if (!strcmp(res->event_value, "power_off"))
4643 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4645 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4647 if (!strcmp(res->mode_value, "bypass"))
4648 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4649 else if (!strcmp(res->mode_value, "isolate"))
4650 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4652 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4654 /* Set the watchdog timeout. */
4655 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4658 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4659 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4663 printf("Failed to set timeout value %u "
4664 "for port %d, errto code: %d.\n",
4665 bypass_timeout, port_id, rc);
4669 /* Set the bypass event to transition to bypass mode. */
4670 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4675 printf("\t Failed to set bypass event for port = %d.\n",
4679 cmdline_parse_token_string_t cmd_setbypass_event_set =
4680 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4682 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4683 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4685 cmdline_parse_token_string_t cmd_setbypass_event_event =
4686 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4688 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4689 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4690 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4691 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4692 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4694 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4695 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4696 mode_value, "normal#bypass#isolate");
4697 cmdline_parse_token_num_t cmd_setbypass_event_port =
4698 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4701 cmdline_parse_inst_t cmd_set_bypass_event = {
4702 .f = cmd_set_bypass_event_parsed,
4703 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4704 "power_off mode normal|bypass|isolate <port_id>: "
4705 "Set the NIC bypass event mode for port_id",
4708 (void *)&cmd_setbypass_event_set,
4709 (void *)&cmd_setbypass_event_bypass,
4710 (void *)&cmd_setbypass_event_event,
4711 (void *)&cmd_setbypass_event_event_value,
4712 (void *)&cmd_setbypass_event_mode,
4713 (void *)&cmd_setbypass_event_mode_value,
4714 (void *)&cmd_setbypass_event_port,
4720 /* *** SET NIC BYPASS TIMEOUT *** */
4721 struct cmd_set_bypass_timeout_result {
4722 cmdline_fixed_string_t set;
4723 cmdline_fixed_string_t bypass;
4724 cmdline_fixed_string_t timeout;
4725 cmdline_fixed_string_t value;
4729 cmd_set_bypass_timeout_parsed(void *parsed_result,
4730 __attribute__((unused)) struct cmdline *cl,
4731 __attribute__((unused)) void *data)
4733 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4735 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4736 if (!strcmp(res->value, "1.5"))
4737 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4738 else if (!strcmp(res->value, "2"))
4739 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4740 else if (!strcmp(res->value, "3"))
4741 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4742 else if (!strcmp(res->value, "4"))
4743 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4744 else if (!strcmp(res->value, "8"))
4745 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4746 else if (!strcmp(res->value, "16"))
4747 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4748 else if (!strcmp(res->value, "32"))
4749 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4751 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4755 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4756 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4758 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4759 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4761 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4762 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4763 timeout, "timeout");
4764 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4765 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4766 value, "0#1.5#2#3#4#8#16#32");
4768 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4769 .f = cmd_set_bypass_timeout_parsed,
4770 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4771 "Set the NIC bypass watchdog timeout in seconds",
4774 (void *)&cmd_setbypass_timeout_set,
4775 (void *)&cmd_setbypass_timeout_bypass,
4776 (void *)&cmd_setbypass_timeout_timeout,
4777 (void *)&cmd_setbypass_timeout_value,
4782 /* *** SHOW NIC BYPASS MODE *** */
4783 struct cmd_show_bypass_config_result {
4784 cmdline_fixed_string_t show;
4785 cmdline_fixed_string_t bypass;
4786 cmdline_fixed_string_t config;
4791 cmd_show_bypass_config_parsed(void *parsed_result,
4792 __attribute__((unused)) struct cmdline *cl,
4793 __attribute__((unused)) void *data)
4795 struct cmd_show_bypass_config_result *res = parsed_result;
4796 portid_t port_id = res->port_id;
4798 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4799 uint32_t event_mode;
4800 uint32_t bypass_mode;
4801 uint32_t timeout = bypass_timeout;
4804 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4805 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4806 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4807 {"UNKNOWN", "normal", "bypass", "isolate"};
4808 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4815 int num_events = (sizeof events) / (sizeof events[0]);
4817 /* Display the bypass mode.*/
4818 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4819 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4823 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4824 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4826 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4829 /* Display the bypass timeout.*/
4830 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4831 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4833 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4835 /* Display the bypass events and associated modes. */
4836 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4838 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4839 printf("\tFailed to get bypass mode for event = %s\n",
4842 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4843 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4845 printf("\tbypass event: %-16s = %s\n", events[i],
4851 printf("\tFailed to get bypass configuration for port = %d\n",
4855 cmdline_parse_token_string_t cmd_showbypass_config_show =
4856 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4858 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4859 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4861 cmdline_parse_token_string_t cmd_showbypass_config_config =
4862 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4864 cmdline_parse_token_num_t cmd_showbypass_config_port =
4865 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4868 cmdline_parse_inst_t cmd_show_bypass_config = {
4869 .f = cmd_show_bypass_config_parsed,
4870 .help_str = "show bypass config <port_id>: "
4871 "Show the NIC bypass config for port_id",
4874 (void *)&cmd_showbypass_config_show,
4875 (void *)&cmd_showbypass_config_bypass,
4876 (void *)&cmd_showbypass_config_config,
4877 (void *)&cmd_showbypass_config_port,
4882 #ifdef RTE_LIBRTE_PMD_BOND
4883 /* *** SET BONDING MODE *** */
4884 struct cmd_set_bonding_mode_result {
4885 cmdline_fixed_string_t set;
4886 cmdline_fixed_string_t bonding;
4887 cmdline_fixed_string_t mode;
4892 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4893 __attribute__((unused)) struct cmdline *cl,
4894 __attribute__((unused)) void *data)
4896 struct cmd_set_bonding_mode_result *res = parsed_result;
4897 portid_t port_id = res->port_id;
4899 /* Set the bonding mode for the relevant port. */
4900 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4901 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4904 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4905 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4907 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4908 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4909 bonding, "bonding");
4910 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4911 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4913 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4914 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4916 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4917 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4920 cmdline_parse_inst_t cmd_set_bonding_mode = {
4921 .f = cmd_set_bonding_mode_parsed,
4922 .help_str = "set bonding mode <mode_value> <port_id>: "
4923 "Set the bonding mode for port_id",
4926 (void *) &cmd_setbonding_mode_set,
4927 (void *) &cmd_setbonding_mode_bonding,
4928 (void *) &cmd_setbonding_mode_mode,
4929 (void *) &cmd_setbonding_mode_value,
4930 (void *) &cmd_setbonding_mode_port,
4935 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4936 struct cmd_set_bonding_lacp_dedicated_queues_result {
4937 cmdline_fixed_string_t set;
4938 cmdline_fixed_string_t bonding;
4939 cmdline_fixed_string_t lacp;
4940 cmdline_fixed_string_t dedicated_queues;
4942 cmdline_fixed_string_t mode;
4945 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4946 __attribute__((unused)) struct cmdline *cl,
4947 __attribute__((unused)) void *data)
4949 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4950 portid_t port_id = res->port_id;
4951 struct rte_port *port;
4953 port = &ports[port_id];
4955 /** Check if the port is not started **/
4956 if (port->port_status != RTE_PORT_STOPPED) {
4957 printf("Please stop port %d first\n", port_id);
4961 if (!strcmp(res->mode, "enable")) {
4962 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4963 printf("Dedicate queues for LACP control packets"
4966 printf("Enabling dedicate queues for LACP control "
4967 "packets on port %d failed\n", port_id);
4968 } else if (!strcmp(res->mode, "disable")) {
4969 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4970 printf("Dedicated queues for LACP control packets "
4973 printf("Disabling dedicated queues for LACP control "
4974 "traffic on port %d failed\n", port_id);
4978 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4979 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4981 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4982 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4983 bonding, "bonding");
4984 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4985 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4987 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4988 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4989 dedicated_queues, "dedicated_queues");
4990 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4991 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4993 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4994 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4995 mode, "enable#disable");
4997 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4998 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4999 .help_str = "set bonding lacp dedicated_queues <port_id> "
5001 "Enable/disable dedicated queues for LACP control traffic for port_id",
5004 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5005 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5006 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5007 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5008 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5009 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5014 /* *** SET BALANCE XMIT POLICY *** */
5015 struct cmd_set_bonding_balance_xmit_policy_result {
5016 cmdline_fixed_string_t set;
5017 cmdline_fixed_string_t bonding;
5018 cmdline_fixed_string_t balance_xmit_policy;
5020 cmdline_fixed_string_t policy;
5023 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5024 __attribute__((unused)) struct cmdline *cl,
5025 __attribute__((unused)) void *data)
5027 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5028 portid_t port_id = res->port_id;
5031 if (!strcmp(res->policy, "l2")) {
5032 policy = BALANCE_XMIT_POLICY_LAYER2;
5033 } else if (!strcmp(res->policy, "l23")) {
5034 policy = BALANCE_XMIT_POLICY_LAYER23;
5035 } else if (!strcmp(res->policy, "l34")) {
5036 policy = BALANCE_XMIT_POLICY_LAYER34;
5038 printf("\t Invalid xmit policy selection");
5042 /* Set the bonding mode for the relevant port. */
5043 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5044 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5049 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5050 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5052 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5053 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5054 bonding, "bonding");
5055 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5056 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5057 balance_xmit_policy, "balance_xmit_policy");
5058 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5059 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5061 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5062 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5063 policy, "l2#l23#l34");
5065 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5066 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5067 .help_str = "set bonding balance_xmit_policy <port_id> "
5069 "Set the bonding balance_xmit_policy for port_id",
5072 (void *)&cmd_setbonding_balance_xmit_policy_set,
5073 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5074 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5075 (void *)&cmd_setbonding_balance_xmit_policy_port,
5076 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5081 /* *** SHOW NIC BONDING CONFIGURATION *** */
5082 struct cmd_show_bonding_config_result {
5083 cmdline_fixed_string_t show;
5084 cmdline_fixed_string_t bonding;
5085 cmdline_fixed_string_t config;
5089 static void cmd_show_bonding_config_parsed(void *parsed_result,
5090 __attribute__((unused)) struct cmdline *cl,
5091 __attribute__((unused)) void *data)
5093 struct cmd_show_bonding_config_result *res = parsed_result;
5094 int bonding_mode, agg_mode;
5095 portid_t slaves[RTE_MAX_ETHPORTS];
5096 int num_slaves, num_active_slaves;
5099 portid_t port_id = res->port_id;
5101 /* Display the bonding mode.*/
5102 bonding_mode = rte_eth_bond_mode_get(port_id);
5103 if (bonding_mode < 0) {
5104 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5107 printf("\tBonding mode: %d\n", bonding_mode);
5109 if (bonding_mode == BONDING_MODE_BALANCE) {
5110 int balance_xmit_policy;
5112 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5113 if (balance_xmit_policy < 0) {
5114 printf("\tFailed to get balance xmit policy for port = %d\n",
5118 printf("\tBalance Xmit Policy: ");
5120 switch (balance_xmit_policy) {
5121 case BALANCE_XMIT_POLICY_LAYER2:
5122 printf("BALANCE_XMIT_POLICY_LAYER2");
5124 case BALANCE_XMIT_POLICY_LAYER23:
5125 printf("BALANCE_XMIT_POLICY_LAYER23");
5127 case BALANCE_XMIT_POLICY_LAYER34:
5128 printf("BALANCE_XMIT_POLICY_LAYER34");
5135 if (bonding_mode == BONDING_MODE_8023AD) {
5136 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5137 printf("\tIEEE802.3AD Aggregator Mode: ");
5140 printf("bandwidth");
5152 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5154 if (num_slaves < 0) {
5155 printf("\tFailed to get slave list for port = %d\n", port_id);
5158 if (num_slaves > 0) {
5159 printf("\tSlaves (%d): [", num_slaves);
5160 for (i = 0; i < num_slaves - 1; i++)
5161 printf("%d ", slaves[i]);
5163 printf("%d]\n", slaves[num_slaves - 1]);
5165 printf("\tSlaves: []\n");
5169 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5172 if (num_active_slaves < 0) {
5173 printf("\tFailed to get active slave list for port = %d\n", port_id);
5176 if (num_active_slaves > 0) {
5177 printf("\tActive Slaves (%d): [", num_active_slaves);
5178 for (i = 0; i < num_active_slaves - 1; i++)
5179 printf("%d ", slaves[i]);
5181 printf("%d]\n", slaves[num_active_slaves - 1]);
5184 printf("\tActive Slaves: []\n");
5188 primary_id = rte_eth_bond_primary_get(port_id);
5189 if (primary_id < 0) {
5190 printf("\tFailed to get primary slave for port = %d\n", port_id);
5193 printf("\tPrimary: [%d]\n", primary_id);
5197 cmdline_parse_token_string_t cmd_showbonding_config_show =
5198 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5200 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5201 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5202 bonding, "bonding");
5203 cmdline_parse_token_string_t cmd_showbonding_config_config =
5204 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5206 cmdline_parse_token_num_t cmd_showbonding_config_port =
5207 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5210 cmdline_parse_inst_t cmd_show_bonding_config = {
5211 .f = cmd_show_bonding_config_parsed,
5212 .help_str = "show bonding config <port_id>: "
5213 "Show the bonding config for port_id",
5216 (void *)&cmd_showbonding_config_show,
5217 (void *)&cmd_showbonding_config_bonding,
5218 (void *)&cmd_showbonding_config_config,
5219 (void *)&cmd_showbonding_config_port,
5224 /* *** SET BONDING PRIMARY *** */
5225 struct cmd_set_bonding_primary_result {
5226 cmdline_fixed_string_t set;
5227 cmdline_fixed_string_t bonding;
5228 cmdline_fixed_string_t primary;
5233 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5234 __attribute__((unused)) struct cmdline *cl,
5235 __attribute__((unused)) void *data)
5237 struct cmd_set_bonding_primary_result *res = parsed_result;
5238 portid_t master_port_id = res->port_id;
5239 portid_t slave_port_id = res->slave_id;
5241 /* Set the primary slave for a bonded device. */
5242 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5243 printf("\t Failed to set primary slave for port = %d.\n",
5250 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5251 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5253 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5254 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5255 bonding, "bonding");
5256 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5257 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5258 primary, "primary");
5259 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5260 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5262 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5263 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5266 cmdline_parse_inst_t cmd_set_bonding_primary = {
5267 .f = cmd_set_bonding_primary_parsed,
5268 .help_str = "set bonding primary <slave_id> <port_id>: "
5269 "Set the primary slave for port_id",
5272 (void *)&cmd_setbonding_primary_set,
5273 (void *)&cmd_setbonding_primary_bonding,
5274 (void *)&cmd_setbonding_primary_primary,
5275 (void *)&cmd_setbonding_primary_slave,
5276 (void *)&cmd_setbonding_primary_port,
5281 /* *** ADD SLAVE *** */
5282 struct cmd_add_bonding_slave_result {
5283 cmdline_fixed_string_t add;
5284 cmdline_fixed_string_t bonding;
5285 cmdline_fixed_string_t slave;
5290 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5291 __attribute__((unused)) struct cmdline *cl,
5292 __attribute__((unused)) void *data)
5294 struct cmd_add_bonding_slave_result *res = parsed_result;
5295 portid_t master_port_id = res->port_id;
5296 portid_t slave_port_id = res->slave_id;
5298 /* add the slave for a bonded device. */
5299 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5300 printf("\t Failed to add slave %d to master port = %d.\n",
5301 slave_port_id, master_port_id);
5305 set_port_slave_flag(slave_port_id);
5308 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5309 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5311 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5312 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5313 bonding, "bonding");
5314 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5315 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5317 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5318 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5320 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5321 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5324 cmdline_parse_inst_t cmd_add_bonding_slave = {
5325 .f = cmd_add_bonding_slave_parsed,
5326 .help_str = "add bonding slave <slave_id> <port_id>: "
5327 "Add a slave device to a bonded device",
5330 (void *)&cmd_addbonding_slave_add,
5331 (void *)&cmd_addbonding_slave_bonding,
5332 (void *)&cmd_addbonding_slave_slave,
5333 (void *)&cmd_addbonding_slave_slaveid,
5334 (void *)&cmd_addbonding_slave_port,
5339 /* *** REMOVE SLAVE *** */
5340 struct cmd_remove_bonding_slave_result {
5341 cmdline_fixed_string_t remove;
5342 cmdline_fixed_string_t bonding;
5343 cmdline_fixed_string_t slave;
5348 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5349 __attribute__((unused)) struct cmdline *cl,
5350 __attribute__((unused)) void *data)
5352 struct cmd_remove_bonding_slave_result *res = parsed_result;
5353 portid_t master_port_id = res->port_id;
5354 portid_t slave_port_id = res->slave_id;
5356 /* remove the slave from a bonded device. */
5357 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5358 printf("\t Failed to remove slave %d from master port = %d.\n",
5359 slave_port_id, master_port_id);
5363 clear_port_slave_flag(slave_port_id);
5366 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5367 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5369 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5370 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5371 bonding, "bonding");
5372 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5373 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5375 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5376 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5378 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5379 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5382 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5383 .f = cmd_remove_bonding_slave_parsed,
5384 .help_str = "remove bonding slave <slave_id> <port_id>: "
5385 "Remove a slave device from a bonded device",
5388 (void *)&cmd_removebonding_slave_remove,
5389 (void *)&cmd_removebonding_slave_bonding,
5390 (void *)&cmd_removebonding_slave_slave,
5391 (void *)&cmd_removebonding_slave_slaveid,
5392 (void *)&cmd_removebonding_slave_port,
5397 /* *** CREATE BONDED DEVICE *** */
5398 struct cmd_create_bonded_device_result {
5399 cmdline_fixed_string_t create;
5400 cmdline_fixed_string_t bonded;
5401 cmdline_fixed_string_t device;
5406 static int bond_dev_num = 0;
5408 static void cmd_create_bonded_device_parsed(void *parsed_result,
5409 __attribute__((unused)) struct cmdline *cl,
5410 __attribute__((unused)) void *data)
5412 struct cmd_create_bonded_device_result *res = parsed_result;
5413 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5416 if (test_done == 0) {
5417 printf("Please stop forwarding first\n");
5421 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5424 /* Create a new bonded device. */
5425 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5427 printf("\t Failed to create bonded device.\n");
5430 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5433 /* Update number of ports */
5434 nb_ports = rte_eth_dev_count();
5435 reconfig(port_id, res->socket);
5436 rte_eth_promiscuous_enable(port_id);
5441 cmdline_parse_token_string_t cmd_createbonded_device_create =
5442 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5444 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5445 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5447 cmdline_parse_token_string_t cmd_createbonded_device_device =
5448 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5450 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5451 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5453 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5454 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5457 cmdline_parse_inst_t cmd_create_bonded_device = {
5458 .f = cmd_create_bonded_device_parsed,
5459 .help_str = "create bonded device <mode> <socket>: "
5460 "Create a new bonded device with specific bonding mode and socket",
5463 (void *)&cmd_createbonded_device_create,
5464 (void *)&cmd_createbonded_device_bonded,
5465 (void *)&cmd_createbonded_device_device,
5466 (void *)&cmd_createbonded_device_mode,
5467 (void *)&cmd_createbonded_device_socket,
5472 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5473 struct cmd_set_bond_mac_addr_result {
5474 cmdline_fixed_string_t set;
5475 cmdline_fixed_string_t bonding;
5476 cmdline_fixed_string_t mac_addr;
5478 struct ether_addr address;
5481 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5482 __attribute__((unused)) struct cmdline *cl,
5483 __attribute__((unused)) void *data)
5485 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5488 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5491 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5493 /* check the return value and print it if is < 0 */
5495 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5498 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5499 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5500 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5501 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5503 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5504 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5506 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5507 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5509 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5510 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5512 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5513 .f = cmd_set_bond_mac_addr_parsed,
5515 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5517 (void *)&cmd_set_bond_mac_addr_set,
5518 (void *)&cmd_set_bond_mac_addr_bonding,
5519 (void *)&cmd_set_bond_mac_addr_mac,
5520 (void *)&cmd_set_bond_mac_addr_portnum,
5521 (void *)&cmd_set_bond_mac_addr_addr,
5527 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5528 struct cmd_set_bond_mon_period_result {
5529 cmdline_fixed_string_t set;
5530 cmdline_fixed_string_t bonding;
5531 cmdline_fixed_string_t mon_period;
5536 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5537 __attribute__((unused)) struct cmdline *cl,
5538 __attribute__((unused)) void *data)
5540 struct cmd_set_bond_mon_period_result *res = parsed_result;
5543 if (res->port_num >= nb_ports) {
5544 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5548 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5550 /* check the return value and print it if is < 0 */
5552 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5555 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5556 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5558 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5559 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5560 bonding, "bonding");
5561 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5562 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5563 mon_period, "mon_period");
5564 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5565 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5567 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5568 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5571 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5572 .f = cmd_set_bond_mon_period_parsed,
5574 .help_str = "set bonding mon_period <port_id> <period_ms>",
5576 (void *)&cmd_set_bond_mon_period_set,
5577 (void *)&cmd_set_bond_mon_period_bonding,
5578 (void *)&cmd_set_bond_mon_period_mon_period,
5579 (void *)&cmd_set_bond_mon_period_portnum,
5580 (void *)&cmd_set_bond_mon_period_period_ms,
5587 struct cmd_set_bonding_agg_mode_policy_result {
5588 cmdline_fixed_string_t set;
5589 cmdline_fixed_string_t bonding;
5590 cmdline_fixed_string_t agg_mode;
5592 cmdline_fixed_string_t policy;
5597 cmd_set_bonding_agg_mode(void *parsed_result,
5598 __attribute__((unused)) struct cmdline *cl,
5599 __attribute__((unused)) void *data)
5601 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5602 uint8_t policy = AGG_BANDWIDTH;
5604 if (res->port_num >= nb_ports) {
5605 printf("Port id %d must be less than %d\n",
5606 res->port_num, nb_ports);
5610 if (!strcmp(res->policy, "bandwidth"))
5611 policy = AGG_BANDWIDTH;
5612 else if (!strcmp(res->policy, "stable"))
5613 policy = AGG_STABLE;
5614 else if (!strcmp(res->policy, "count"))
5617 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5621 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5622 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5624 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5625 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5626 bonding, "bonding");
5628 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5629 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5630 agg_mode, "agg_mode");
5632 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5633 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5636 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5637 TOKEN_STRING_INITIALIZER(
5638 struct cmd_set_bonding_balance_xmit_policy_result,
5639 policy, "stable#bandwidth#count");
5641 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5642 .f = cmd_set_bonding_agg_mode,
5644 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5646 (void *)&cmd_set_bonding_agg_mode_set,
5647 (void *)&cmd_set_bonding_agg_mode_bonding,
5648 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5649 (void *)&cmd_set_bonding_agg_mode_portnum,
5650 (void *)&cmd_set_bonding_agg_mode_policy_string,
5656 #endif /* RTE_LIBRTE_PMD_BOND */
5658 /* *** SET FORWARDING MODE *** */
5659 struct cmd_set_fwd_mode_result {
5660 cmdline_fixed_string_t set;
5661 cmdline_fixed_string_t fwd;
5662 cmdline_fixed_string_t mode;
5665 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5666 __attribute__((unused)) struct cmdline *cl,
5667 __attribute__((unused)) void *data)
5669 struct cmd_set_fwd_mode_result *res = parsed_result;
5672 set_pkt_forwarding_mode(res->mode);
5675 cmdline_parse_token_string_t cmd_setfwd_set =
5676 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5677 cmdline_parse_token_string_t cmd_setfwd_fwd =
5678 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5679 cmdline_parse_token_string_t cmd_setfwd_mode =
5680 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5681 "" /* defined at init */);
5683 cmdline_parse_inst_t cmd_set_fwd_mode = {
5684 .f = cmd_set_fwd_mode_parsed,
5686 .help_str = NULL, /* defined at init */
5688 (void *)&cmd_setfwd_set,
5689 (void *)&cmd_setfwd_fwd,
5690 (void *)&cmd_setfwd_mode,
5695 static void cmd_set_fwd_mode_init(void)
5698 static char token[128];
5699 static char help[256];
5700 cmdline_parse_token_string_t *token_struct;
5702 modes = list_pkt_forwarding_modes();
5703 snprintf(help, sizeof(help), "set fwd %s: "
5704 "Set packet forwarding mode", modes);
5705 cmd_set_fwd_mode.help_str = help;
5707 /* string token separator is # */
5708 for (c = token; *modes != '\0'; modes++)
5713 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5714 token_struct->string_data.str = token;
5717 /* *** SET RETRY FORWARDING MODE *** */
5718 struct cmd_set_fwd_retry_mode_result {
5719 cmdline_fixed_string_t set;
5720 cmdline_fixed_string_t fwd;
5721 cmdline_fixed_string_t mode;
5722 cmdline_fixed_string_t retry;
5725 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5726 __attribute__((unused)) struct cmdline *cl,
5727 __attribute__((unused)) void *data)
5729 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5732 set_pkt_forwarding_mode(res->mode);
5735 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5736 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5738 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5739 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5741 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5742 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5744 "" /* defined at init */);
5745 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5746 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5749 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5750 .f = cmd_set_fwd_retry_mode_parsed,
5752 .help_str = NULL, /* defined at init */
5754 (void *)&cmd_setfwd_retry_set,
5755 (void *)&cmd_setfwd_retry_fwd,
5756 (void *)&cmd_setfwd_retry_mode,
5757 (void *)&cmd_setfwd_retry_retry,
5762 static void cmd_set_fwd_retry_mode_init(void)
5765 static char token[128];
5766 static char help[256];
5767 cmdline_parse_token_string_t *token_struct;
5769 modes = list_pkt_forwarding_retry_modes();
5770 snprintf(help, sizeof(help), "set fwd %s retry: "
5771 "Set packet forwarding mode with retry", modes);
5772 cmd_set_fwd_retry_mode.help_str = help;
5774 /* string token separator is # */
5775 for (c = token; *modes != '\0'; modes++)
5780 token_struct = (cmdline_parse_token_string_t *)
5781 cmd_set_fwd_retry_mode.tokens[2];
5782 token_struct->string_data.str = token;
5785 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5786 struct cmd_set_burst_tx_retry_result {
5787 cmdline_fixed_string_t set;
5788 cmdline_fixed_string_t burst;
5789 cmdline_fixed_string_t tx;
5790 cmdline_fixed_string_t delay;
5792 cmdline_fixed_string_t retry;
5796 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5797 __attribute__((unused)) struct cmdline *cl,
5798 __attribute__((unused)) void *data)
5800 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5802 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5803 && !strcmp(res->tx, "tx")) {
5804 if (!strcmp(res->delay, "delay"))
5805 burst_tx_delay_time = res->time;
5806 if (!strcmp(res->retry, "retry"))
5807 burst_tx_retry_num = res->retry_num;
5812 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5813 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5814 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5815 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5817 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5818 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5819 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5820 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5821 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5822 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5823 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5824 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5825 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5826 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5828 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5829 .f = cmd_set_burst_tx_retry_parsed,
5830 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5832 (void *)&cmd_set_burst_tx_retry_set,
5833 (void *)&cmd_set_burst_tx_retry_burst,
5834 (void *)&cmd_set_burst_tx_retry_tx,
5835 (void *)&cmd_set_burst_tx_retry_delay,
5836 (void *)&cmd_set_burst_tx_retry_time,
5837 (void *)&cmd_set_burst_tx_retry_retry,
5838 (void *)&cmd_set_burst_tx_retry_retry_num,
5843 /* *** SET PROMISC MODE *** */
5844 struct cmd_set_promisc_mode_result {
5845 cmdline_fixed_string_t set;
5846 cmdline_fixed_string_t promisc;
5847 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5848 uint16_t port_num; /* valid if "allports" argument == 0 */
5849 cmdline_fixed_string_t mode;
5852 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5853 __attribute__((unused)) struct cmdline *cl,
5856 struct cmd_set_promisc_mode_result *res = parsed_result;
5860 if (!strcmp(res->mode, "on"))
5867 RTE_ETH_FOREACH_DEV(i) {
5869 rte_eth_promiscuous_enable(i);
5871 rte_eth_promiscuous_disable(i);
5876 rte_eth_promiscuous_enable(res->port_num);
5878 rte_eth_promiscuous_disable(res->port_num);
5882 cmdline_parse_token_string_t cmd_setpromisc_set =
5883 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5884 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5885 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5887 cmdline_parse_token_string_t cmd_setpromisc_portall =
5888 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5890 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5891 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5893 cmdline_parse_token_string_t cmd_setpromisc_mode =
5894 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5897 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5898 .f = cmd_set_promisc_mode_parsed,
5900 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5902 (void *)&cmd_setpromisc_set,
5903 (void *)&cmd_setpromisc_promisc,
5904 (void *)&cmd_setpromisc_portall,
5905 (void *)&cmd_setpromisc_mode,
5910 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5911 .f = cmd_set_promisc_mode_parsed,
5913 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5915 (void *)&cmd_setpromisc_set,
5916 (void *)&cmd_setpromisc_promisc,
5917 (void *)&cmd_setpromisc_portnum,
5918 (void *)&cmd_setpromisc_mode,
5923 /* *** SET ALLMULTI MODE *** */
5924 struct cmd_set_allmulti_mode_result {
5925 cmdline_fixed_string_t set;
5926 cmdline_fixed_string_t allmulti;
5927 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5928 uint16_t port_num; /* valid if "allports" argument == 0 */
5929 cmdline_fixed_string_t mode;
5932 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5933 __attribute__((unused)) struct cmdline *cl,
5936 struct cmd_set_allmulti_mode_result *res = parsed_result;
5940 if (!strcmp(res->mode, "on"))
5947 RTE_ETH_FOREACH_DEV(i) {
5949 rte_eth_allmulticast_enable(i);
5951 rte_eth_allmulticast_disable(i);
5956 rte_eth_allmulticast_enable(res->port_num);
5958 rte_eth_allmulticast_disable(res->port_num);
5962 cmdline_parse_token_string_t cmd_setallmulti_set =
5963 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5964 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5965 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5967 cmdline_parse_token_string_t cmd_setallmulti_portall =
5968 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5970 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5971 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5973 cmdline_parse_token_string_t cmd_setallmulti_mode =
5974 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5977 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5978 .f = cmd_set_allmulti_mode_parsed,
5980 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5982 (void *)&cmd_setallmulti_set,
5983 (void *)&cmd_setallmulti_allmulti,
5984 (void *)&cmd_setallmulti_portall,
5985 (void *)&cmd_setallmulti_mode,
5990 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5991 .f = cmd_set_allmulti_mode_parsed,
5993 .help_str = "set allmulti <port_id> on|off: "
5994 "Set allmulti mode on port_id",
5996 (void *)&cmd_setallmulti_set,
5997 (void *)&cmd_setallmulti_allmulti,
5998 (void *)&cmd_setallmulti_portnum,
5999 (void *)&cmd_setallmulti_mode,
6004 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6005 struct cmd_link_flow_ctrl_set_result {
6006 cmdline_fixed_string_t set;
6007 cmdline_fixed_string_t flow_ctrl;
6008 cmdline_fixed_string_t rx;
6009 cmdline_fixed_string_t rx_lfc_mode;
6010 cmdline_fixed_string_t tx;
6011 cmdline_fixed_string_t tx_lfc_mode;
6012 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6013 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6014 cmdline_fixed_string_t autoneg_str;
6015 cmdline_fixed_string_t autoneg;
6016 cmdline_fixed_string_t hw_str;
6017 uint32_t high_water;
6018 cmdline_fixed_string_t lw_str;
6020 cmdline_fixed_string_t pt_str;
6021 uint16_t pause_time;
6022 cmdline_fixed_string_t xon_str;
6027 cmdline_parse_token_string_t cmd_lfc_set_set =
6028 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6030 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6031 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6032 flow_ctrl, "flow_ctrl");
6033 cmdline_parse_token_string_t cmd_lfc_set_rx =
6034 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6036 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6037 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6038 rx_lfc_mode, "on#off");
6039 cmdline_parse_token_string_t cmd_lfc_set_tx =
6040 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6042 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6043 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6044 tx_lfc_mode, "on#off");
6045 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6046 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6047 hw_str, "high_water");
6048 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6049 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6050 high_water, UINT32);
6051 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6052 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6053 lw_str, "low_water");
6054 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6055 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6057 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6058 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6059 pt_str, "pause_time");
6060 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6061 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6062 pause_time, UINT16);
6063 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6064 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6065 xon_str, "send_xon");
6066 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6067 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6069 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6070 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6071 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6072 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6073 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6074 mac_ctrl_frame_fwd_mode, "on#off");
6075 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6076 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6077 autoneg_str, "autoneg");
6078 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6079 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6081 cmdline_parse_token_num_t cmd_lfc_set_portid =
6082 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6085 /* forward declaration */
6087 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6090 cmdline_parse_inst_t cmd_link_flow_control_set = {
6091 .f = cmd_link_flow_ctrl_set_parsed,
6093 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6094 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6095 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6097 (void *)&cmd_lfc_set_set,
6098 (void *)&cmd_lfc_set_flow_ctrl,
6099 (void *)&cmd_lfc_set_rx,
6100 (void *)&cmd_lfc_set_rx_mode,
6101 (void *)&cmd_lfc_set_tx,
6102 (void *)&cmd_lfc_set_tx_mode,
6103 (void *)&cmd_lfc_set_high_water,
6104 (void *)&cmd_lfc_set_low_water,
6105 (void *)&cmd_lfc_set_pause_time,
6106 (void *)&cmd_lfc_set_send_xon,
6107 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6108 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6109 (void *)&cmd_lfc_set_autoneg_str,
6110 (void *)&cmd_lfc_set_autoneg,
6111 (void *)&cmd_lfc_set_portid,
6116 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6117 .f = cmd_link_flow_ctrl_set_parsed,
6118 .data = (void *)&cmd_link_flow_control_set_rx,
6119 .help_str = "set flow_ctrl rx on|off <port_id>: "
6120 "Change rx flow control parameter",
6122 (void *)&cmd_lfc_set_set,
6123 (void *)&cmd_lfc_set_flow_ctrl,
6124 (void *)&cmd_lfc_set_rx,
6125 (void *)&cmd_lfc_set_rx_mode,
6126 (void *)&cmd_lfc_set_portid,
6131 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6132 .f = cmd_link_flow_ctrl_set_parsed,
6133 .data = (void *)&cmd_link_flow_control_set_tx,
6134 .help_str = "set flow_ctrl tx on|off <port_id>: "
6135 "Change tx flow control parameter",
6137 (void *)&cmd_lfc_set_set,
6138 (void *)&cmd_lfc_set_flow_ctrl,
6139 (void *)&cmd_lfc_set_tx,
6140 (void *)&cmd_lfc_set_tx_mode,
6141 (void *)&cmd_lfc_set_portid,
6146 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6147 .f = cmd_link_flow_ctrl_set_parsed,
6148 .data = (void *)&cmd_link_flow_control_set_hw,
6149 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6150 "Change high water flow control parameter",
6152 (void *)&cmd_lfc_set_set,
6153 (void *)&cmd_lfc_set_flow_ctrl,
6154 (void *)&cmd_lfc_set_high_water_str,
6155 (void *)&cmd_lfc_set_high_water,
6156 (void *)&cmd_lfc_set_portid,
6161 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6162 .f = cmd_link_flow_ctrl_set_parsed,
6163 .data = (void *)&cmd_link_flow_control_set_lw,
6164 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6165 "Change low water flow control parameter",
6167 (void *)&cmd_lfc_set_set,
6168 (void *)&cmd_lfc_set_flow_ctrl,
6169 (void *)&cmd_lfc_set_low_water_str,
6170 (void *)&cmd_lfc_set_low_water,
6171 (void *)&cmd_lfc_set_portid,
6176 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6177 .f = cmd_link_flow_ctrl_set_parsed,
6178 .data = (void *)&cmd_link_flow_control_set_pt,
6179 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6180 "Change pause time flow control parameter",
6182 (void *)&cmd_lfc_set_set,
6183 (void *)&cmd_lfc_set_flow_ctrl,
6184 (void *)&cmd_lfc_set_pause_time_str,
6185 (void *)&cmd_lfc_set_pause_time,
6186 (void *)&cmd_lfc_set_portid,
6191 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6192 .f = cmd_link_flow_ctrl_set_parsed,
6193 .data = (void *)&cmd_link_flow_control_set_xon,
6194 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6195 "Change send_xon flow control parameter",
6197 (void *)&cmd_lfc_set_set,
6198 (void *)&cmd_lfc_set_flow_ctrl,
6199 (void *)&cmd_lfc_set_send_xon_str,
6200 (void *)&cmd_lfc_set_send_xon,
6201 (void *)&cmd_lfc_set_portid,
6206 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6207 .f = cmd_link_flow_ctrl_set_parsed,
6208 .data = (void *)&cmd_link_flow_control_set_macfwd,
6209 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6210 "Change mac ctrl fwd flow control parameter",
6212 (void *)&cmd_lfc_set_set,
6213 (void *)&cmd_lfc_set_flow_ctrl,
6214 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6215 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6216 (void *)&cmd_lfc_set_portid,
6221 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6222 .f = cmd_link_flow_ctrl_set_parsed,
6223 .data = (void *)&cmd_link_flow_control_set_autoneg,
6224 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6225 "Change autoneg flow control parameter",
6227 (void *)&cmd_lfc_set_set,
6228 (void *)&cmd_lfc_set_flow_ctrl,
6229 (void *)&cmd_lfc_set_autoneg_str,
6230 (void *)&cmd_lfc_set_autoneg,
6231 (void *)&cmd_lfc_set_portid,
6237 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6238 __attribute__((unused)) struct cmdline *cl,
6241 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6242 cmdline_parse_inst_t *cmd = data;
6243 struct rte_eth_fc_conf fc_conf;
6249 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6250 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6251 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6252 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6254 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6255 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6258 /* Partial command line, retrieve current configuration */
6260 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6262 printf("cannot get current flow ctrl parameters, return"
6263 "code = %d\n", ret);
6267 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6268 (fc_conf.mode == RTE_FC_FULL))
6270 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6271 (fc_conf.mode == RTE_FC_FULL))
6275 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6276 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6278 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6279 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6281 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6283 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6284 fc_conf.high_water = res->high_water;
6286 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6287 fc_conf.low_water = res->low_water;
6289 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6290 fc_conf.pause_time = res->pause_time;
6292 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6293 fc_conf.send_xon = res->send_xon;
6295 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6296 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6297 fc_conf.mac_ctrl_frame_fwd = 1;
6299 fc_conf.mac_ctrl_frame_fwd = 0;
6302 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6303 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6305 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6307 printf("bad flow contrl parameter, return code = %d \n", ret);
6310 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6311 struct cmd_priority_flow_ctrl_set_result {
6312 cmdline_fixed_string_t set;
6313 cmdline_fixed_string_t pfc_ctrl;
6314 cmdline_fixed_string_t rx;
6315 cmdline_fixed_string_t rx_pfc_mode;
6316 cmdline_fixed_string_t tx;
6317 cmdline_fixed_string_t tx_pfc_mode;
6318 uint32_t high_water;
6320 uint16_t pause_time;
6326 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6327 __attribute__((unused)) struct cmdline *cl,
6328 __attribute__((unused)) void *data)
6330 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6331 struct rte_eth_pfc_conf pfc_conf;
6332 int rx_fc_enable, tx_fc_enable;
6336 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6337 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6338 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6339 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6341 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6342 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6345 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6346 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6347 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6348 pfc_conf.fc.high_water = res->high_water;
6349 pfc_conf.fc.low_water = res->low_water;
6350 pfc_conf.fc.pause_time = res->pause_time;
6351 pfc_conf.priority = res->priority;
6353 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6355 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6358 cmdline_parse_token_string_t cmd_pfc_set_set =
6359 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6361 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6362 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6363 pfc_ctrl, "pfc_ctrl");
6364 cmdline_parse_token_string_t cmd_pfc_set_rx =
6365 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6367 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6368 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6369 rx_pfc_mode, "on#off");
6370 cmdline_parse_token_string_t cmd_pfc_set_tx =
6371 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6373 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6374 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6375 tx_pfc_mode, "on#off");
6376 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6377 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6378 high_water, UINT32);
6379 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6380 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6382 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6383 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6384 pause_time, UINT16);
6385 cmdline_parse_token_num_t cmd_pfc_set_priority =
6386 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6388 cmdline_parse_token_num_t cmd_pfc_set_portid =
6389 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6392 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6393 .f = cmd_priority_flow_ctrl_set_parsed,
6395 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6396 "<pause_time> <priority> <port_id>: "
6397 "Configure the Ethernet priority flow control",
6399 (void *)&cmd_pfc_set_set,
6400 (void *)&cmd_pfc_set_flow_ctrl,
6401 (void *)&cmd_pfc_set_rx,
6402 (void *)&cmd_pfc_set_rx_mode,
6403 (void *)&cmd_pfc_set_tx,
6404 (void *)&cmd_pfc_set_tx_mode,
6405 (void *)&cmd_pfc_set_high_water,
6406 (void *)&cmd_pfc_set_low_water,
6407 (void *)&cmd_pfc_set_pause_time,
6408 (void *)&cmd_pfc_set_priority,
6409 (void *)&cmd_pfc_set_portid,
6414 /* *** RESET CONFIGURATION *** */
6415 struct cmd_reset_result {
6416 cmdline_fixed_string_t reset;
6417 cmdline_fixed_string_t def;
6420 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6422 __attribute__((unused)) void *data)
6424 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6425 set_def_fwd_config();
6428 cmdline_parse_token_string_t cmd_reset_set =
6429 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6430 cmdline_parse_token_string_t cmd_reset_def =
6431 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6434 cmdline_parse_inst_t cmd_reset = {
6435 .f = cmd_reset_parsed,
6437 .help_str = "set default: Reset default forwarding configuration",
6439 (void *)&cmd_reset_set,
6440 (void *)&cmd_reset_def,
6445 /* *** START FORWARDING *** */
6446 struct cmd_start_result {
6447 cmdline_fixed_string_t start;
6450 cmdline_parse_token_string_t cmd_start_start =
6451 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6453 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6454 __attribute__((unused)) struct cmdline *cl,
6455 __attribute__((unused)) void *data)
6457 start_packet_forwarding(0);
6460 cmdline_parse_inst_t cmd_start = {
6461 .f = cmd_start_parsed,
6463 .help_str = "start: Start packet forwarding",
6465 (void *)&cmd_start_start,
6470 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6471 struct cmd_start_tx_first_result {
6472 cmdline_fixed_string_t start;
6473 cmdline_fixed_string_t tx_first;
6477 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6478 __attribute__((unused)) struct cmdline *cl,
6479 __attribute__((unused)) void *data)
6481 start_packet_forwarding(1);
6484 cmdline_parse_token_string_t cmd_start_tx_first_start =
6485 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6487 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6488 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6489 tx_first, "tx_first");
6491 cmdline_parse_inst_t cmd_start_tx_first = {
6492 .f = cmd_start_tx_first_parsed,
6494 .help_str = "start tx_first: Start packet forwarding, "
6495 "after sending 1 burst of packets",
6497 (void *)&cmd_start_tx_first_start,
6498 (void *)&cmd_start_tx_first_tx_first,
6503 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6504 struct cmd_start_tx_first_n_result {
6505 cmdline_fixed_string_t start;
6506 cmdline_fixed_string_t tx_first;
6511 cmd_start_tx_first_n_parsed(void *parsed_result,
6512 __attribute__((unused)) struct cmdline *cl,
6513 __attribute__((unused)) void *data)
6515 struct cmd_start_tx_first_n_result *res = parsed_result;
6517 start_packet_forwarding(res->tx_num);
6520 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6521 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6523 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6524 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6525 tx_first, "tx_first");
6526 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6527 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6530 cmdline_parse_inst_t cmd_start_tx_first_n = {
6531 .f = cmd_start_tx_first_n_parsed,
6533 .help_str = "start tx_first <num>: "
6534 "packet forwarding, after sending <num> bursts of packets",
6536 (void *)&cmd_start_tx_first_n_start,
6537 (void *)&cmd_start_tx_first_n_tx_first,
6538 (void *)&cmd_start_tx_first_n_tx_num,
6543 /* *** SET LINK UP *** */
6544 struct cmd_set_link_up_result {
6545 cmdline_fixed_string_t set;
6546 cmdline_fixed_string_t link_up;
6547 cmdline_fixed_string_t port;
6551 cmdline_parse_token_string_t cmd_set_link_up_set =
6552 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6553 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6554 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6556 cmdline_parse_token_string_t cmd_set_link_up_port =
6557 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6558 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6559 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6561 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6562 __attribute__((unused)) struct cmdline *cl,
6563 __attribute__((unused)) void *data)
6565 struct cmd_set_link_up_result *res = parsed_result;
6566 dev_set_link_up(res->port_id);
6569 cmdline_parse_inst_t cmd_set_link_up = {
6570 .f = cmd_set_link_up_parsed,
6572 .help_str = "set link-up port <port id>",
6574 (void *)&cmd_set_link_up_set,
6575 (void *)&cmd_set_link_up_link_up,
6576 (void *)&cmd_set_link_up_port,
6577 (void *)&cmd_set_link_up_port_id,
6582 /* *** SET LINK DOWN *** */
6583 struct cmd_set_link_down_result {
6584 cmdline_fixed_string_t set;
6585 cmdline_fixed_string_t link_down;
6586 cmdline_fixed_string_t port;
6590 cmdline_parse_token_string_t cmd_set_link_down_set =
6591 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6592 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6593 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6595 cmdline_parse_token_string_t cmd_set_link_down_port =
6596 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6597 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6598 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6600 static void cmd_set_link_down_parsed(
6601 __attribute__((unused)) void *parsed_result,
6602 __attribute__((unused)) struct cmdline *cl,
6603 __attribute__((unused)) void *data)
6605 struct cmd_set_link_down_result *res = parsed_result;
6606 dev_set_link_down(res->port_id);
6609 cmdline_parse_inst_t cmd_set_link_down = {
6610 .f = cmd_set_link_down_parsed,
6612 .help_str = "set link-down port <port id>",
6614 (void *)&cmd_set_link_down_set,
6615 (void *)&cmd_set_link_down_link_down,
6616 (void *)&cmd_set_link_down_port,
6617 (void *)&cmd_set_link_down_port_id,
6622 /* *** SHOW CFG *** */
6623 struct cmd_showcfg_result {
6624 cmdline_fixed_string_t show;
6625 cmdline_fixed_string_t cfg;
6626 cmdline_fixed_string_t what;
6629 static void cmd_showcfg_parsed(void *parsed_result,
6630 __attribute__((unused)) struct cmdline *cl,
6631 __attribute__((unused)) void *data)
6633 struct cmd_showcfg_result *res = parsed_result;
6634 if (!strcmp(res->what, "rxtx"))
6635 rxtx_config_display();
6636 else if (!strcmp(res->what, "cores"))
6637 fwd_lcores_config_display();
6638 else if (!strcmp(res->what, "fwd"))
6639 pkt_fwd_config_display(&cur_fwd_config);
6640 else if (!strcmp(res->what, "txpkts"))
6641 show_tx_pkt_segments();
6644 cmdline_parse_token_string_t cmd_showcfg_show =
6645 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6646 cmdline_parse_token_string_t cmd_showcfg_port =
6647 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6648 cmdline_parse_token_string_t cmd_showcfg_what =
6649 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6650 "rxtx#cores#fwd#txpkts");
6652 cmdline_parse_inst_t cmd_showcfg = {
6653 .f = cmd_showcfg_parsed,
6655 .help_str = "show config rxtx|cores|fwd|txpkts",
6657 (void *)&cmd_showcfg_show,
6658 (void *)&cmd_showcfg_port,
6659 (void *)&cmd_showcfg_what,
6664 /* *** SHOW ALL PORT INFO *** */
6665 struct cmd_showportall_result {
6666 cmdline_fixed_string_t show;
6667 cmdline_fixed_string_t port;
6668 cmdline_fixed_string_t what;
6669 cmdline_fixed_string_t all;
6672 static void cmd_showportall_parsed(void *parsed_result,
6673 __attribute__((unused)) struct cmdline *cl,
6674 __attribute__((unused)) void *data)
6678 struct cmd_showportall_result *res = parsed_result;
6679 if (!strcmp(res->show, "clear")) {
6680 if (!strcmp(res->what, "stats"))
6681 RTE_ETH_FOREACH_DEV(i)
6683 else if (!strcmp(res->what, "xstats"))
6684 RTE_ETH_FOREACH_DEV(i)
6685 nic_xstats_clear(i);
6686 } else if (!strcmp(res->what, "info"))
6687 RTE_ETH_FOREACH_DEV(i)
6688 port_infos_display(i);
6689 else if (!strcmp(res->what, "stats"))
6690 RTE_ETH_FOREACH_DEV(i)
6691 nic_stats_display(i);
6692 else if (!strcmp(res->what, "xstats"))
6693 RTE_ETH_FOREACH_DEV(i)
6694 nic_xstats_display(i);
6695 else if (!strcmp(res->what, "fdir"))
6696 RTE_ETH_FOREACH_DEV(i)
6698 else if (!strcmp(res->what, "stat_qmap"))
6699 RTE_ETH_FOREACH_DEV(i)
6700 nic_stats_mapping_display(i);
6701 else if (!strcmp(res->what, "dcb_tc"))
6702 RTE_ETH_FOREACH_DEV(i)
6703 port_dcb_info_display(i);
6704 else if (!strcmp(res->what, "cap"))
6705 RTE_ETH_FOREACH_DEV(i)
6706 port_offload_cap_display(i);
6709 cmdline_parse_token_string_t cmd_showportall_show =
6710 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6712 cmdline_parse_token_string_t cmd_showportall_port =
6713 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6714 cmdline_parse_token_string_t cmd_showportall_what =
6715 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6716 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6717 cmdline_parse_token_string_t cmd_showportall_all =
6718 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6719 cmdline_parse_inst_t cmd_showportall = {
6720 .f = cmd_showportall_parsed,
6722 .help_str = "show|clear port "
6723 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6725 (void *)&cmd_showportall_show,
6726 (void *)&cmd_showportall_port,
6727 (void *)&cmd_showportall_what,
6728 (void *)&cmd_showportall_all,
6733 /* *** SHOW PORT INFO *** */
6734 struct cmd_showport_result {
6735 cmdline_fixed_string_t show;
6736 cmdline_fixed_string_t port;
6737 cmdline_fixed_string_t what;
6741 static void cmd_showport_parsed(void *parsed_result,
6742 __attribute__((unused)) struct cmdline *cl,
6743 __attribute__((unused)) void *data)
6745 struct cmd_showport_result *res = parsed_result;
6746 if (!strcmp(res->show, "clear")) {
6747 if (!strcmp(res->what, "stats"))
6748 nic_stats_clear(res->portnum);
6749 else if (!strcmp(res->what, "xstats"))
6750 nic_xstats_clear(res->portnum);
6751 } else if (!strcmp(res->what, "info"))
6752 port_infos_display(res->portnum);
6753 else if (!strcmp(res->what, "stats"))
6754 nic_stats_display(res->portnum);
6755 else if (!strcmp(res->what, "xstats"))
6756 nic_xstats_display(res->portnum);
6757 else if (!strcmp(res->what, "fdir"))
6758 fdir_get_infos(res->portnum);
6759 else if (!strcmp(res->what, "stat_qmap"))
6760 nic_stats_mapping_display(res->portnum);
6761 else if (!strcmp(res->what, "dcb_tc"))
6762 port_dcb_info_display(res->portnum);
6763 else if (!strcmp(res->what, "cap"))
6764 port_offload_cap_display(res->portnum);
6767 cmdline_parse_token_string_t cmd_showport_show =
6768 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6770 cmdline_parse_token_string_t cmd_showport_port =
6771 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6772 cmdline_parse_token_string_t cmd_showport_what =
6773 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6774 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6775 cmdline_parse_token_num_t cmd_showport_portnum =
6776 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6778 cmdline_parse_inst_t cmd_showport = {
6779 .f = cmd_showport_parsed,
6781 .help_str = "show|clear port "
6782 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6785 (void *)&cmd_showport_show,
6786 (void *)&cmd_showport_port,
6787 (void *)&cmd_showport_what,
6788 (void *)&cmd_showport_portnum,
6793 /* *** SHOW QUEUE INFO *** */
6794 struct cmd_showqueue_result {
6795 cmdline_fixed_string_t show;
6796 cmdline_fixed_string_t type;
6797 cmdline_fixed_string_t what;
6803 cmd_showqueue_parsed(void *parsed_result,
6804 __attribute__((unused)) struct cmdline *cl,
6805 __attribute__((unused)) void *data)
6807 struct cmd_showqueue_result *res = parsed_result;
6809 if (!strcmp(res->type, "rxq"))
6810 rx_queue_infos_display(res->portnum, res->queuenum);
6811 else if (!strcmp(res->type, "txq"))
6812 tx_queue_infos_display(res->portnum, res->queuenum);
6815 cmdline_parse_token_string_t cmd_showqueue_show =
6816 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6817 cmdline_parse_token_string_t cmd_showqueue_type =
6818 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6819 cmdline_parse_token_string_t cmd_showqueue_what =
6820 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6821 cmdline_parse_token_num_t cmd_showqueue_portnum =
6822 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6823 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6824 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6826 cmdline_parse_inst_t cmd_showqueue = {
6827 .f = cmd_showqueue_parsed,
6829 .help_str = "show rxq|txq info <port_id> <queue_id>",
6831 (void *)&cmd_showqueue_show,
6832 (void *)&cmd_showqueue_type,
6833 (void *)&cmd_showqueue_what,
6834 (void *)&cmd_showqueue_portnum,
6835 (void *)&cmd_showqueue_queuenum,
6840 /* *** READ PORT REGISTER *** */
6841 struct cmd_read_reg_result {
6842 cmdline_fixed_string_t read;
6843 cmdline_fixed_string_t reg;
6849 cmd_read_reg_parsed(void *parsed_result,
6850 __attribute__((unused)) struct cmdline *cl,
6851 __attribute__((unused)) void *data)
6853 struct cmd_read_reg_result *res = parsed_result;
6854 port_reg_display(res->port_id, res->reg_off);
6857 cmdline_parse_token_string_t cmd_read_reg_read =
6858 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6859 cmdline_parse_token_string_t cmd_read_reg_reg =
6860 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6861 cmdline_parse_token_num_t cmd_read_reg_port_id =
6862 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6863 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6864 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6866 cmdline_parse_inst_t cmd_read_reg = {
6867 .f = cmd_read_reg_parsed,
6869 .help_str = "read reg <port_id> <reg_off>",
6871 (void *)&cmd_read_reg_read,
6872 (void *)&cmd_read_reg_reg,
6873 (void *)&cmd_read_reg_port_id,
6874 (void *)&cmd_read_reg_reg_off,
6879 /* *** READ PORT REGISTER BIT FIELD *** */
6880 struct cmd_read_reg_bit_field_result {
6881 cmdline_fixed_string_t read;
6882 cmdline_fixed_string_t regfield;
6890 cmd_read_reg_bit_field_parsed(void *parsed_result,
6891 __attribute__((unused)) struct cmdline *cl,
6892 __attribute__((unused)) void *data)
6894 struct cmd_read_reg_bit_field_result *res = parsed_result;
6895 port_reg_bit_field_display(res->port_id, res->reg_off,
6896 res->bit1_pos, res->bit2_pos);
6899 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6900 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6902 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6903 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6904 regfield, "regfield");
6905 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6906 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6908 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6909 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6911 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6912 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6914 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6915 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6918 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6919 .f = cmd_read_reg_bit_field_parsed,
6921 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6922 "Read register bit field between bit_x and bit_y included",
6924 (void *)&cmd_read_reg_bit_field_read,
6925 (void *)&cmd_read_reg_bit_field_regfield,
6926 (void *)&cmd_read_reg_bit_field_port_id,
6927 (void *)&cmd_read_reg_bit_field_reg_off,
6928 (void *)&cmd_read_reg_bit_field_bit1_pos,
6929 (void *)&cmd_read_reg_bit_field_bit2_pos,
6934 /* *** READ PORT REGISTER BIT *** */
6935 struct cmd_read_reg_bit_result {
6936 cmdline_fixed_string_t read;
6937 cmdline_fixed_string_t regbit;
6944 cmd_read_reg_bit_parsed(void *parsed_result,
6945 __attribute__((unused)) struct cmdline *cl,
6946 __attribute__((unused)) void *data)
6948 struct cmd_read_reg_bit_result *res = parsed_result;
6949 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6952 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6953 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6954 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6955 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6957 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6958 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6959 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6960 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6961 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6962 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6964 cmdline_parse_inst_t cmd_read_reg_bit = {
6965 .f = cmd_read_reg_bit_parsed,
6967 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6969 (void *)&cmd_read_reg_bit_read,
6970 (void *)&cmd_read_reg_bit_regbit,
6971 (void *)&cmd_read_reg_bit_port_id,
6972 (void *)&cmd_read_reg_bit_reg_off,
6973 (void *)&cmd_read_reg_bit_bit_pos,
6978 /* *** WRITE PORT REGISTER *** */
6979 struct cmd_write_reg_result {
6980 cmdline_fixed_string_t write;
6981 cmdline_fixed_string_t reg;
6988 cmd_write_reg_parsed(void *parsed_result,
6989 __attribute__((unused)) struct cmdline *cl,
6990 __attribute__((unused)) void *data)
6992 struct cmd_write_reg_result *res = parsed_result;
6993 port_reg_set(res->port_id, res->reg_off, res->value);
6996 cmdline_parse_token_string_t cmd_write_reg_write =
6997 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6998 cmdline_parse_token_string_t cmd_write_reg_reg =
6999 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7000 cmdline_parse_token_num_t cmd_write_reg_port_id =
7001 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7002 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7003 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7004 cmdline_parse_token_num_t cmd_write_reg_value =
7005 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7007 cmdline_parse_inst_t cmd_write_reg = {
7008 .f = cmd_write_reg_parsed,
7010 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7012 (void *)&cmd_write_reg_write,
7013 (void *)&cmd_write_reg_reg,
7014 (void *)&cmd_write_reg_port_id,
7015 (void *)&cmd_write_reg_reg_off,
7016 (void *)&cmd_write_reg_value,
7021 /* *** WRITE PORT REGISTER BIT FIELD *** */
7022 struct cmd_write_reg_bit_field_result {
7023 cmdline_fixed_string_t write;
7024 cmdline_fixed_string_t regfield;
7033 cmd_write_reg_bit_field_parsed(void *parsed_result,
7034 __attribute__((unused)) struct cmdline *cl,
7035 __attribute__((unused)) void *data)
7037 struct cmd_write_reg_bit_field_result *res = parsed_result;
7038 port_reg_bit_field_set(res->port_id, res->reg_off,
7039 res->bit1_pos, res->bit2_pos, res->value);
7042 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7043 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7045 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7046 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7047 regfield, "regfield");
7048 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7049 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7051 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7052 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7054 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7055 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7057 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7058 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7060 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7061 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7064 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7065 .f = cmd_write_reg_bit_field_parsed,
7067 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7069 "Set register bit field between bit_x and bit_y included",
7071 (void *)&cmd_write_reg_bit_field_write,
7072 (void *)&cmd_write_reg_bit_field_regfield,
7073 (void *)&cmd_write_reg_bit_field_port_id,
7074 (void *)&cmd_write_reg_bit_field_reg_off,
7075 (void *)&cmd_write_reg_bit_field_bit1_pos,
7076 (void *)&cmd_write_reg_bit_field_bit2_pos,
7077 (void *)&cmd_write_reg_bit_field_value,
7082 /* *** WRITE PORT REGISTER BIT *** */
7083 struct cmd_write_reg_bit_result {
7084 cmdline_fixed_string_t write;
7085 cmdline_fixed_string_t regbit;
7093 cmd_write_reg_bit_parsed(void *parsed_result,
7094 __attribute__((unused)) struct cmdline *cl,
7095 __attribute__((unused)) void *data)
7097 struct cmd_write_reg_bit_result *res = parsed_result;
7098 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7101 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7102 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7104 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7105 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7107 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7108 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7109 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7110 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7111 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7112 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7113 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7114 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7116 cmdline_parse_inst_t cmd_write_reg_bit = {
7117 .f = cmd_write_reg_bit_parsed,
7119 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7122 (void *)&cmd_write_reg_bit_write,
7123 (void *)&cmd_write_reg_bit_regbit,
7124 (void *)&cmd_write_reg_bit_port_id,
7125 (void *)&cmd_write_reg_bit_reg_off,
7126 (void *)&cmd_write_reg_bit_bit_pos,
7127 (void *)&cmd_write_reg_bit_value,
7132 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7133 struct cmd_read_rxd_txd_result {
7134 cmdline_fixed_string_t read;
7135 cmdline_fixed_string_t rxd_txd;
7142 cmd_read_rxd_txd_parsed(void *parsed_result,
7143 __attribute__((unused)) struct cmdline *cl,
7144 __attribute__((unused)) void *data)
7146 struct cmd_read_rxd_txd_result *res = parsed_result;
7148 if (!strcmp(res->rxd_txd, "rxd"))
7149 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7150 else if (!strcmp(res->rxd_txd, "txd"))
7151 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7154 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7155 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7156 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7157 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7159 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7160 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7161 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7162 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7163 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7164 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7166 cmdline_parse_inst_t cmd_read_rxd_txd = {
7167 .f = cmd_read_rxd_txd_parsed,
7169 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7171 (void *)&cmd_read_rxd_txd_read,
7172 (void *)&cmd_read_rxd_txd_rxd_txd,
7173 (void *)&cmd_read_rxd_txd_port_id,
7174 (void *)&cmd_read_rxd_txd_queue_id,
7175 (void *)&cmd_read_rxd_txd_desc_id,
7181 struct cmd_quit_result {
7182 cmdline_fixed_string_t quit;
7185 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7187 __attribute__((unused)) void *data)
7193 cmdline_parse_token_string_t cmd_quit_quit =
7194 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7196 cmdline_parse_inst_t cmd_quit = {
7197 .f = cmd_quit_parsed,
7199 .help_str = "quit: Exit application",
7201 (void *)&cmd_quit_quit,
7206 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7207 struct cmd_mac_addr_result {
7208 cmdline_fixed_string_t mac_addr_cmd;
7209 cmdline_fixed_string_t what;
7211 struct ether_addr address;
7214 static void cmd_mac_addr_parsed(void *parsed_result,
7215 __attribute__((unused)) struct cmdline *cl,
7216 __attribute__((unused)) void *data)
7218 struct cmd_mac_addr_result *res = parsed_result;
7221 if (strcmp(res->what, "add") == 0)
7222 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7223 else if (strcmp(res->what, "set") == 0)
7224 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7227 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7229 /* check the return value and print it if is < 0 */
7231 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7235 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7236 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7238 cmdline_parse_token_string_t cmd_mac_addr_what =
7239 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7241 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7242 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7244 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7245 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7247 cmdline_parse_inst_t cmd_mac_addr = {
7248 .f = cmd_mac_addr_parsed,
7250 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7251 "Add/Remove/Set MAC address on port_id",
7253 (void *)&cmd_mac_addr_cmd,
7254 (void *)&cmd_mac_addr_what,
7255 (void *)&cmd_mac_addr_portnum,
7256 (void *)&cmd_mac_addr_addr,
7261 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7262 struct cmd_eth_peer_result {
7263 cmdline_fixed_string_t set;
7264 cmdline_fixed_string_t eth_peer;
7266 cmdline_fixed_string_t peer_addr;
7269 static void cmd_set_eth_peer_parsed(void *parsed_result,
7270 __attribute__((unused)) struct cmdline *cl,
7271 __attribute__((unused)) void *data)
7273 struct cmd_eth_peer_result *res = parsed_result;
7275 if (test_done == 0) {
7276 printf("Please stop forwarding first\n");
7279 if (!strcmp(res->eth_peer, "eth-peer")) {
7280 set_fwd_eth_peer(res->port_id, res->peer_addr);
7284 cmdline_parse_token_string_t cmd_eth_peer_set =
7285 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7286 cmdline_parse_token_string_t cmd_eth_peer =
7287 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7288 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7289 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7290 cmdline_parse_token_string_t cmd_eth_peer_addr =
7291 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7293 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7294 .f = cmd_set_eth_peer_parsed,
7296 .help_str = "set eth-peer <port_id> <peer_mac>",
7298 (void *)&cmd_eth_peer_set,
7299 (void *)&cmd_eth_peer,
7300 (void *)&cmd_eth_peer_port_id,
7301 (void *)&cmd_eth_peer_addr,
7306 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7307 struct cmd_set_qmap_result {
7308 cmdline_fixed_string_t set;
7309 cmdline_fixed_string_t qmap;
7310 cmdline_fixed_string_t what;
7317 cmd_set_qmap_parsed(void *parsed_result,
7318 __attribute__((unused)) struct cmdline *cl,
7319 __attribute__((unused)) void *data)
7321 struct cmd_set_qmap_result *res = parsed_result;
7322 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7324 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7327 cmdline_parse_token_string_t cmd_setqmap_set =
7328 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7330 cmdline_parse_token_string_t cmd_setqmap_qmap =
7331 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7333 cmdline_parse_token_string_t cmd_setqmap_what =
7334 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7336 cmdline_parse_token_num_t cmd_setqmap_portid =
7337 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7339 cmdline_parse_token_num_t cmd_setqmap_queueid =
7340 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7342 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7343 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7346 cmdline_parse_inst_t cmd_set_qmap = {
7347 .f = cmd_set_qmap_parsed,
7349 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7350 "Set statistics mapping value on tx|rx queue_id of port_id",
7352 (void *)&cmd_setqmap_set,
7353 (void *)&cmd_setqmap_qmap,
7354 (void *)&cmd_setqmap_what,
7355 (void *)&cmd_setqmap_portid,
7356 (void *)&cmd_setqmap_queueid,
7357 (void *)&cmd_setqmap_mapvalue,
7362 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7363 struct cmd_set_xstats_hide_zero_result {
7364 cmdline_fixed_string_t keyword;
7365 cmdline_fixed_string_t name;
7366 cmdline_fixed_string_t on_off;
7370 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7371 __attribute__((unused)) struct cmdline *cl,
7372 __attribute__((unused)) void *data)
7374 struct cmd_set_xstats_hide_zero_result *res;
7375 uint16_t on_off = 0;
7377 res = parsed_result;
7378 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7379 set_xstats_hide_zero(on_off);
7382 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7383 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7385 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7386 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7387 name, "xstats-hide-zero");
7388 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7389 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7392 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7393 .f = cmd_set_xstats_hide_zero_parsed,
7395 .help_str = "set xstats-hide-zero on|off",
7397 (void *)&cmd_set_xstats_hide_zero_keyword,
7398 (void *)&cmd_set_xstats_hide_zero_name,
7399 (void *)&cmd_set_xstats_hide_zero_on_off,
7404 /* *** CONFIGURE UNICAST HASH TABLE *** */
7405 struct cmd_set_uc_hash_table {
7406 cmdline_fixed_string_t set;
7407 cmdline_fixed_string_t port;
7409 cmdline_fixed_string_t what;
7410 struct ether_addr address;
7411 cmdline_fixed_string_t mode;
7415 cmd_set_uc_hash_parsed(void *parsed_result,
7416 __attribute__((unused)) struct cmdline *cl,
7417 __attribute__((unused)) void *data)
7420 struct cmd_set_uc_hash_table *res = parsed_result;
7422 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7424 if (strcmp(res->what, "uta") == 0)
7425 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7426 &res->address,(uint8_t)is_on);
7428 printf("bad unicast hash table parameter, return code = %d \n", ret);
7432 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7433 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7435 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7436 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7438 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7439 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7441 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7442 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7444 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7445 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7447 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7448 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7451 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7452 .f = cmd_set_uc_hash_parsed,
7454 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7456 (void *)&cmd_set_uc_hash_set,
7457 (void *)&cmd_set_uc_hash_port,
7458 (void *)&cmd_set_uc_hash_portid,
7459 (void *)&cmd_set_uc_hash_what,
7460 (void *)&cmd_set_uc_hash_mac,
7461 (void *)&cmd_set_uc_hash_mode,
7466 struct cmd_set_uc_all_hash_table {
7467 cmdline_fixed_string_t set;
7468 cmdline_fixed_string_t port;
7470 cmdline_fixed_string_t what;
7471 cmdline_fixed_string_t value;
7472 cmdline_fixed_string_t mode;
7476 cmd_set_uc_all_hash_parsed(void *parsed_result,
7477 __attribute__((unused)) struct cmdline *cl,
7478 __attribute__((unused)) void *data)
7481 struct cmd_set_uc_all_hash_table *res = parsed_result;
7483 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7485 if ((strcmp(res->what, "uta") == 0) &&
7486 (strcmp(res->value, "all") == 0))
7487 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7489 printf("bad unicast hash table parameter,"
7490 "return code = %d \n", ret);
7493 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7494 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7496 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7497 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7499 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7500 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7502 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7503 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7505 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7506 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7508 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7509 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7512 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7513 .f = cmd_set_uc_all_hash_parsed,
7515 .help_str = "set port <port_id> uta all on|off",
7517 (void *)&cmd_set_uc_all_hash_set,
7518 (void *)&cmd_set_uc_all_hash_port,
7519 (void *)&cmd_set_uc_all_hash_portid,
7520 (void *)&cmd_set_uc_all_hash_what,
7521 (void *)&cmd_set_uc_all_hash_value,
7522 (void *)&cmd_set_uc_all_hash_mode,
7527 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7528 struct cmd_set_vf_macvlan_filter {
7529 cmdline_fixed_string_t set;
7530 cmdline_fixed_string_t port;
7532 cmdline_fixed_string_t vf;
7534 struct ether_addr address;
7535 cmdline_fixed_string_t filter_type;
7536 cmdline_fixed_string_t mode;
7540 cmd_set_vf_macvlan_parsed(void *parsed_result,
7541 __attribute__((unused)) struct cmdline *cl,
7542 __attribute__((unused)) void *data)
7545 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7546 struct rte_eth_mac_filter filter;
7548 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7550 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7552 /* set VF MAC filter */
7556 filter.dst_id = res->vf_id;
7558 if (!strcmp(res->filter_type, "exact-mac"))
7559 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7560 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7561 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7562 else if (!strcmp(res->filter_type, "hashmac"))
7563 filter.filter_type = RTE_MAC_HASH_MATCH;
7564 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7565 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7567 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7570 ret = rte_eth_dev_filter_ctrl(res->port_id,
7571 RTE_ETH_FILTER_MACVLAN,
7575 ret = rte_eth_dev_filter_ctrl(res->port_id,
7576 RTE_ETH_FILTER_MACVLAN,
7577 RTE_ETH_FILTER_DELETE,
7581 printf("bad set MAC hash parameter, return code = %d\n", ret);
7585 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7586 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7588 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7589 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7591 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7592 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7594 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7595 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7597 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7598 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7600 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7601 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7603 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7604 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7605 filter_type, "exact-mac#exact-mac-vlan"
7606 "#hashmac#hashmac-vlan");
7607 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7608 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7611 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7612 .f = cmd_set_vf_macvlan_parsed,
7614 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7615 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7616 "Exact match rule: exact match of MAC or MAC and VLAN; "
7617 "hash match rule: hash match of MAC and exact match of VLAN",
7619 (void *)&cmd_set_vf_macvlan_set,
7620 (void *)&cmd_set_vf_macvlan_port,
7621 (void *)&cmd_set_vf_macvlan_portid,
7622 (void *)&cmd_set_vf_macvlan_vf,
7623 (void *)&cmd_set_vf_macvlan_vf_id,
7624 (void *)&cmd_set_vf_macvlan_mac,
7625 (void *)&cmd_set_vf_macvlan_filter_type,
7626 (void *)&cmd_set_vf_macvlan_mode,
7631 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7632 struct cmd_set_vf_traffic {
7633 cmdline_fixed_string_t set;
7634 cmdline_fixed_string_t port;
7636 cmdline_fixed_string_t vf;
7638 cmdline_fixed_string_t what;
7639 cmdline_fixed_string_t mode;
7643 cmd_set_vf_traffic_parsed(void *parsed_result,
7644 __attribute__((unused)) struct cmdline *cl,
7645 __attribute__((unused)) void *data)
7647 struct cmd_set_vf_traffic *res = parsed_result;
7648 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7649 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7651 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7654 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7655 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7657 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7658 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7660 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7661 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7663 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7664 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7666 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7667 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7669 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7670 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7672 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7673 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7676 cmdline_parse_inst_t cmd_set_vf_traffic = {
7677 .f = cmd_set_vf_traffic_parsed,
7679 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7681 (void *)&cmd_setvf_traffic_set,
7682 (void *)&cmd_setvf_traffic_port,
7683 (void *)&cmd_setvf_traffic_portid,
7684 (void *)&cmd_setvf_traffic_vf,
7685 (void *)&cmd_setvf_traffic_vfid,
7686 (void *)&cmd_setvf_traffic_what,
7687 (void *)&cmd_setvf_traffic_mode,
7692 /* *** CONFIGURE VF RECEIVE MODE *** */
7693 struct cmd_set_vf_rxmode {
7694 cmdline_fixed_string_t set;
7695 cmdline_fixed_string_t port;
7697 cmdline_fixed_string_t vf;
7699 cmdline_fixed_string_t what;
7700 cmdline_fixed_string_t mode;
7701 cmdline_fixed_string_t on;
7705 cmd_set_vf_rxmode_parsed(void *parsed_result,
7706 __attribute__((unused)) struct cmdline *cl,
7707 __attribute__((unused)) void *data)
7710 uint16_t rx_mode = 0;
7711 struct cmd_set_vf_rxmode *res = parsed_result;
7713 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7714 if (!strcmp(res->what,"rxmode")) {
7715 if (!strcmp(res->mode, "AUPE"))
7716 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7717 else if (!strcmp(res->mode, "ROPE"))
7718 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7719 else if (!strcmp(res->mode, "BAM"))
7720 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7721 else if (!strncmp(res->mode, "MPE",3))
7722 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7725 RTE_SET_USED(is_on);
7727 #ifdef RTE_LIBRTE_IXGBE_PMD
7728 if (ret == -ENOTSUP)
7729 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7730 rx_mode, (uint8_t)is_on);
7732 #ifdef RTE_LIBRTE_BNXT_PMD
7733 if (ret == -ENOTSUP)
7734 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7735 rx_mode, (uint8_t)is_on);
7738 printf("bad VF receive mode parameter, return code = %d \n",
7742 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7743 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7745 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7746 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7748 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7749 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7751 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7752 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7754 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7755 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7757 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7758 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7760 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7761 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7762 mode, "AUPE#ROPE#BAM#MPE");
7763 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7764 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7767 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7768 .f = cmd_set_vf_rxmode_parsed,
7770 .help_str = "set port <port_id> vf <vf_id> rxmode "
7771 "AUPE|ROPE|BAM|MPE on|off",
7773 (void *)&cmd_set_vf_rxmode_set,
7774 (void *)&cmd_set_vf_rxmode_port,
7775 (void *)&cmd_set_vf_rxmode_portid,
7776 (void *)&cmd_set_vf_rxmode_vf,
7777 (void *)&cmd_set_vf_rxmode_vfid,
7778 (void *)&cmd_set_vf_rxmode_what,
7779 (void *)&cmd_set_vf_rxmode_mode,
7780 (void *)&cmd_set_vf_rxmode_on,
7785 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7786 struct cmd_vf_mac_addr_result {
7787 cmdline_fixed_string_t mac_addr_cmd;
7788 cmdline_fixed_string_t what;
7789 cmdline_fixed_string_t port;
7791 cmdline_fixed_string_t vf;
7793 struct ether_addr address;
7796 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7797 __attribute__((unused)) struct cmdline *cl,
7798 __attribute__((unused)) void *data)
7800 struct cmd_vf_mac_addr_result *res = parsed_result;
7803 if (strcmp(res->what, "add") != 0)
7806 #ifdef RTE_LIBRTE_I40E_PMD
7807 if (ret == -ENOTSUP)
7808 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7811 #ifdef RTE_LIBRTE_BNXT_PMD
7812 if (ret == -ENOTSUP)
7813 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7818 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7822 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7823 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7824 mac_addr_cmd,"mac_addr");
7825 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7826 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7828 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7829 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7831 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7832 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7834 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7835 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7837 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7838 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7840 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7841 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7844 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7845 .f = cmd_vf_mac_addr_parsed,
7847 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7848 "Add MAC address filtering for a VF on port_id",
7850 (void *)&cmd_vf_mac_addr_cmd,
7851 (void *)&cmd_vf_mac_addr_what,
7852 (void *)&cmd_vf_mac_addr_port,
7853 (void *)&cmd_vf_mac_addr_portnum,
7854 (void *)&cmd_vf_mac_addr_vf,
7855 (void *)&cmd_vf_mac_addr_vfnum,
7856 (void *)&cmd_vf_mac_addr_addr,
7861 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7862 struct cmd_vf_rx_vlan_filter {
7863 cmdline_fixed_string_t rx_vlan;
7864 cmdline_fixed_string_t what;
7866 cmdline_fixed_string_t port;
7868 cmdline_fixed_string_t vf;
7873 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7874 __attribute__((unused)) struct cmdline *cl,
7875 __attribute__((unused)) void *data)
7877 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7880 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7882 #ifdef RTE_LIBRTE_IXGBE_PMD
7883 if (ret == -ENOTSUP)
7884 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7885 res->vlan_id, res->vf_mask, is_add);
7887 #ifdef RTE_LIBRTE_I40E_PMD
7888 if (ret == -ENOTSUP)
7889 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7890 res->vlan_id, res->vf_mask, is_add);
7892 #ifdef RTE_LIBRTE_BNXT_PMD
7893 if (ret == -ENOTSUP)
7894 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7895 res->vlan_id, res->vf_mask, is_add);
7902 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7903 res->vlan_id, res->vf_mask);
7906 printf("invalid port_id %d\n", res->port_id);
7909 printf("function not implemented or supported\n");
7912 printf("programming error: (%s)\n", strerror(-ret));
7916 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7917 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7918 rx_vlan, "rx_vlan");
7919 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7920 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7922 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7923 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7925 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7926 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7928 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7929 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7931 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7932 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7934 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7935 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7938 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7939 .f = cmd_vf_rx_vlan_filter_parsed,
7941 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7942 "(vf_mask = hexadecimal VF mask)",
7944 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7945 (void *)&cmd_vf_rx_vlan_filter_what,
7946 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7947 (void *)&cmd_vf_rx_vlan_filter_port,
7948 (void *)&cmd_vf_rx_vlan_filter_portid,
7949 (void *)&cmd_vf_rx_vlan_filter_vf,
7950 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7955 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7956 struct cmd_queue_rate_limit_result {
7957 cmdline_fixed_string_t set;
7958 cmdline_fixed_string_t port;
7960 cmdline_fixed_string_t queue;
7962 cmdline_fixed_string_t rate;
7966 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7967 __attribute__((unused)) struct cmdline *cl,
7968 __attribute__((unused)) void *data)
7970 struct cmd_queue_rate_limit_result *res = parsed_result;
7973 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7974 && (strcmp(res->queue, "queue") == 0)
7975 && (strcmp(res->rate, "rate") == 0))
7976 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7979 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7983 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7984 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7986 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7987 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7989 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7990 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7992 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7993 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7995 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7996 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7998 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7999 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8001 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8002 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8005 cmdline_parse_inst_t cmd_queue_rate_limit = {
8006 .f = cmd_queue_rate_limit_parsed,
8008 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8009 "Set rate limit for a queue on port_id",
8011 (void *)&cmd_queue_rate_limit_set,
8012 (void *)&cmd_queue_rate_limit_port,
8013 (void *)&cmd_queue_rate_limit_portnum,
8014 (void *)&cmd_queue_rate_limit_queue,
8015 (void *)&cmd_queue_rate_limit_queuenum,
8016 (void *)&cmd_queue_rate_limit_rate,
8017 (void *)&cmd_queue_rate_limit_ratenum,
8022 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8023 struct cmd_vf_rate_limit_result {
8024 cmdline_fixed_string_t set;
8025 cmdline_fixed_string_t port;
8027 cmdline_fixed_string_t vf;
8029 cmdline_fixed_string_t rate;
8031 cmdline_fixed_string_t q_msk;
8035 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8036 __attribute__((unused)) struct cmdline *cl,
8037 __attribute__((unused)) void *data)
8039 struct cmd_vf_rate_limit_result *res = parsed_result;
8042 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8043 && (strcmp(res->vf, "vf") == 0)
8044 && (strcmp(res->rate, "rate") == 0)
8045 && (strcmp(res->q_msk, "queue_mask") == 0))
8046 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8047 res->rate_num, res->q_msk_val);
8049 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8053 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8054 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8056 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8057 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8059 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8060 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8062 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8063 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8065 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8066 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8068 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8069 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8071 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8072 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8074 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8075 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8076 q_msk, "queue_mask");
8077 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8078 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8081 cmdline_parse_inst_t cmd_vf_rate_limit = {
8082 .f = cmd_vf_rate_limit_parsed,
8084 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8085 "queue_mask <queue_mask_value>: "
8086 "Set rate limit for queues of VF on port_id",
8088 (void *)&cmd_vf_rate_limit_set,
8089 (void *)&cmd_vf_rate_limit_port,
8090 (void *)&cmd_vf_rate_limit_portnum,
8091 (void *)&cmd_vf_rate_limit_vf,
8092 (void *)&cmd_vf_rate_limit_vfnum,
8093 (void *)&cmd_vf_rate_limit_rate,
8094 (void *)&cmd_vf_rate_limit_ratenum,
8095 (void *)&cmd_vf_rate_limit_q_msk,
8096 (void *)&cmd_vf_rate_limit_q_msk_val,
8101 /* *** ADD TUNNEL FILTER OF A PORT *** */
8102 struct cmd_tunnel_filter_result {
8103 cmdline_fixed_string_t cmd;
8104 cmdline_fixed_string_t what;
8106 struct ether_addr outer_mac;
8107 struct ether_addr inner_mac;
8108 cmdline_ipaddr_t ip_value;
8109 uint16_t inner_vlan;
8110 cmdline_fixed_string_t tunnel_type;
8111 cmdline_fixed_string_t filter_type;
8117 cmd_tunnel_filter_parsed(void *parsed_result,
8118 __attribute__((unused)) struct cmdline *cl,
8119 __attribute__((unused)) void *data)
8121 struct cmd_tunnel_filter_result *res = parsed_result;
8122 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8125 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8127 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8128 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8129 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8131 if (res->ip_value.family == AF_INET) {
8132 tunnel_filter_conf.ip_addr.ipv4_addr =
8133 res->ip_value.addr.ipv4.s_addr;
8134 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8136 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8137 &(res->ip_value.addr.ipv6),
8138 sizeof(struct in6_addr));
8139 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8142 if (!strcmp(res->filter_type, "imac-ivlan"))
8143 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8144 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8145 tunnel_filter_conf.filter_type =
8146 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8147 else if (!strcmp(res->filter_type, "imac-tenid"))
8148 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8149 else if (!strcmp(res->filter_type, "imac"))
8150 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8151 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8152 tunnel_filter_conf.filter_type =
8153 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8154 else if (!strcmp(res->filter_type, "oip"))
8155 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8156 else if (!strcmp(res->filter_type, "iip"))
8157 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8159 printf("The filter type is not supported");
8163 if (!strcmp(res->tunnel_type, "vxlan"))
8164 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8165 else if (!strcmp(res->tunnel_type, "nvgre"))
8166 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8167 else if (!strcmp(res->tunnel_type, "ipingre"))
8168 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8170 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8174 tunnel_filter_conf.tenant_id = res->tenant_id;
8175 tunnel_filter_conf.queue_id = res->queue_num;
8176 if (!strcmp(res->what, "add"))
8177 ret = rte_eth_dev_filter_ctrl(res->port_id,
8178 RTE_ETH_FILTER_TUNNEL,
8180 &tunnel_filter_conf);
8182 ret = rte_eth_dev_filter_ctrl(res->port_id,
8183 RTE_ETH_FILTER_TUNNEL,
8184 RTE_ETH_FILTER_DELETE,
8185 &tunnel_filter_conf);
8187 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8191 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8192 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8193 cmd, "tunnel_filter");
8194 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8195 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8197 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8198 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8200 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8201 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8203 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8204 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8206 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8207 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8208 inner_vlan, UINT16);
8209 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8210 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8212 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8213 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8214 tunnel_type, "vxlan#nvgre#ipingre");
8216 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8217 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8218 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8219 "imac#omac-imac-tenid");
8220 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8221 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8223 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8224 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8227 cmdline_parse_inst_t cmd_tunnel_filter = {
8228 .f = cmd_tunnel_filter_parsed,
8230 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8231 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8232 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8233 "<queue_id>: Add/Rm tunnel filter of a port",
8235 (void *)&cmd_tunnel_filter_cmd,
8236 (void *)&cmd_tunnel_filter_what,
8237 (void *)&cmd_tunnel_filter_port_id,
8238 (void *)&cmd_tunnel_filter_outer_mac,
8239 (void *)&cmd_tunnel_filter_inner_mac,
8240 (void *)&cmd_tunnel_filter_ip_value,
8241 (void *)&cmd_tunnel_filter_innner_vlan,
8242 (void *)&cmd_tunnel_filter_tunnel_type,
8243 (void *)&cmd_tunnel_filter_filter_type,
8244 (void *)&cmd_tunnel_filter_tenant_id,
8245 (void *)&cmd_tunnel_filter_queue_num,
8250 /* *** CONFIGURE TUNNEL UDP PORT *** */
8251 struct cmd_tunnel_udp_config {
8252 cmdline_fixed_string_t cmd;
8253 cmdline_fixed_string_t what;
8259 cmd_tunnel_udp_config_parsed(void *parsed_result,
8260 __attribute__((unused)) struct cmdline *cl,
8261 __attribute__((unused)) void *data)
8263 struct cmd_tunnel_udp_config *res = parsed_result;
8264 struct rte_eth_udp_tunnel tunnel_udp;
8267 tunnel_udp.udp_port = res->udp_port;
8269 if (!strcmp(res->cmd, "rx_vxlan_port"))
8270 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8272 if (!strcmp(res->what, "add"))
8273 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8276 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8280 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8283 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8284 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8285 cmd, "rx_vxlan_port");
8286 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8287 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8289 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8290 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8292 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8293 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8296 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8297 .f = cmd_tunnel_udp_config_parsed,
8299 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8300 "Add/Remove a tunneling UDP port filter",
8302 (void *)&cmd_tunnel_udp_config_cmd,
8303 (void *)&cmd_tunnel_udp_config_what,
8304 (void *)&cmd_tunnel_udp_config_udp_port,
8305 (void *)&cmd_tunnel_udp_config_port_id,
8310 /* *** GLOBAL CONFIG *** */
8311 struct cmd_global_config_result {
8312 cmdline_fixed_string_t cmd;
8314 cmdline_fixed_string_t cfg_type;
8319 cmd_global_config_parsed(void *parsed_result,
8320 __attribute__((unused)) struct cmdline *cl,
8321 __attribute__((unused)) void *data)
8323 struct cmd_global_config_result *res = parsed_result;
8324 struct rte_eth_global_cfg conf;
8327 memset(&conf, 0, sizeof(conf));
8328 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8329 conf.cfg.gre_key_len = res->len;
8330 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8331 RTE_ETH_FILTER_SET, &conf);
8333 printf("Global config error\n");
8336 cmdline_parse_token_string_t cmd_global_config_cmd =
8337 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8339 cmdline_parse_token_num_t cmd_global_config_port_id =
8340 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8342 cmdline_parse_token_string_t cmd_global_config_type =
8343 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8344 cfg_type, "gre-key-len");
8345 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8346 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8349 cmdline_parse_inst_t cmd_global_config = {
8350 .f = cmd_global_config_parsed,
8351 .data = (void *)NULL,
8352 .help_str = "global_config <port_id> gre-key-len <key_len>",
8354 (void *)&cmd_global_config_cmd,
8355 (void *)&cmd_global_config_port_id,
8356 (void *)&cmd_global_config_type,
8357 (void *)&cmd_global_config_gre_key_len,
8362 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8363 struct cmd_set_mirror_mask_result {
8364 cmdline_fixed_string_t set;
8365 cmdline_fixed_string_t port;
8367 cmdline_fixed_string_t mirror;
8369 cmdline_fixed_string_t what;
8370 cmdline_fixed_string_t value;
8371 cmdline_fixed_string_t dstpool;
8373 cmdline_fixed_string_t on;
8376 cmdline_parse_token_string_t cmd_mirror_mask_set =
8377 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8379 cmdline_parse_token_string_t cmd_mirror_mask_port =
8380 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8382 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8383 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8385 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8386 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8387 mirror, "mirror-rule");
8388 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8389 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8391 cmdline_parse_token_string_t cmd_mirror_mask_what =
8392 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8393 what, "pool-mirror-up#pool-mirror-down"
8395 cmdline_parse_token_string_t cmd_mirror_mask_value =
8396 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8398 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8399 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8400 dstpool, "dst-pool");
8401 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8402 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8404 cmdline_parse_token_string_t cmd_mirror_mask_on =
8405 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8409 cmd_set_mirror_mask_parsed(void *parsed_result,
8410 __attribute__((unused)) struct cmdline *cl,
8411 __attribute__((unused)) void *data)
8414 struct cmd_set_mirror_mask_result *res = parsed_result;
8415 struct rte_eth_mirror_conf mr_conf;
8417 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8419 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8421 mr_conf.dst_pool = res->dstpool_id;
8423 if (!strcmp(res->what, "pool-mirror-up")) {
8424 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8425 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8426 } else if (!strcmp(res->what, "pool-mirror-down")) {
8427 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8428 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8429 } else if (!strcmp(res->what, "vlan-mirror")) {
8430 mr_conf.rule_type = ETH_MIRROR_VLAN;
8431 nb_item = parse_item_list(res->value, "vlan",
8432 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8436 for (i = 0; i < nb_item; i++) {
8437 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8438 printf("Invalid vlan_id: must be < 4096\n");
8442 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8443 mr_conf.vlan.vlan_mask |= 1ULL << i;
8447 if (!strcmp(res->on, "on"))
8448 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8451 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8454 printf("mirror rule add error: (%s)\n", strerror(-ret));
8457 cmdline_parse_inst_t cmd_set_mirror_mask = {
8458 .f = cmd_set_mirror_mask_parsed,
8460 .help_str = "set port <port_id> mirror-rule <rule_id> "
8461 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8462 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8464 (void *)&cmd_mirror_mask_set,
8465 (void *)&cmd_mirror_mask_port,
8466 (void *)&cmd_mirror_mask_portid,
8467 (void *)&cmd_mirror_mask_mirror,
8468 (void *)&cmd_mirror_mask_ruleid,
8469 (void *)&cmd_mirror_mask_what,
8470 (void *)&cmd_mirror_mask_value,
8471 (void *)&cmd_mirror_mask_dstpool,
8472 (void *)&cmd_mirror_mask_poolid,
8473 (void *)&cmd_mirror_mask_on,
8478 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8479 struct cmd_set_mirror_link_result {
8480 cmdline_fixed_string_t set;
8481 cmdline_fixed_string_t port;
8483 cmdline_fixed_string_t mirror;
8485 cmdline_fixed_string_t what;
8486 cmdline_fixed_string_t dstpool;
8488 cmdline_fixed_string_t on;
8491 cmdline_parse_token_string_t cmd_mirror_link_set =
8492 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8494 cmdline_parse_token_string_t cmd_mirror_link_port =
8495 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8497 cmdline_parse_token_num_t cmd_mirror_link_portid =
8498 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8500 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8501 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8502 mirror, "mirror-rule");
8503 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8504 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8506 cmdline_parse_token_string_t cmd_mirror_link_what =
8507 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8508 what, "uplink-mirror#downlink-mirror");
8509 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8510 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8511 dstpool, "dst-pool");
8512 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8513 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8515 cmdline_parse_token_string_t cmd_mirror_link_on =
8516 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8520 cmd_set_mirror_link_parsed(void *parsed_result,
8521 __attribute__((unused)) struct cmdline *cl,
8522 __attribute__((unused)) void *data)
8525 struct cmd_set_mirror_link_result *res = parsed_result;
8526 struct rte_eth_mirror_conf mr_conf;
8528 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8529 if (!strcmp(res->what, "uplink-mirror"))
8530 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8532 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8534 mr_conf.dst_pool = res->dstpool_id;
8536 if (!strcmp(res->on, "on"))
8537 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8540 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8543 /* check the return value and print it if is < 0 */
8545 printf("mirror rule add error: (%s)\n", strerror(-ret));
8549 cmdline_parse_inst_t cmd_set_mirror_link = {
8550 .f = cmd_set_mirror_link_parsed,
8552 .help_str = "set port <port_id> mirror-rule <rule_id> "
8553 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8555 (void *)&cmd_mirror_link_set,
8556 (void *)&cmd_mirror_link_port,
8557 (void *)&cmd_mirror_link_portid,
8558 (void *)&cmd_mirror_link_mirror,
8559 (void *)&cmd_mirror_link_ruleid,
8560 (void *)&cmd_mirror_link_what,
8561 (void *)&cmd_mirror_link_dstpool,
8562 (void *)&cmd_mirror_link_poolid,
8563 (void *)&cmd_mirror_link_on,
8568 /* *** RESET VM MIRROR RULE *** */
8569 struct cmd_rm_mirror_rule_result {
8570 cmdline_fixed_string_t reset;
8571 cmdline_fixed_string_t port;
8573 cmdline_fixed_string_t mirror;
8577 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8578 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8580 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8581 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8583 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8584 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8586 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8587 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8588 mirror, "mirror-rule");
8589 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8590 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8594 cmd_reset_mirror_rule_parsed(void *parsed_result,
8595 __attribute__((unused)) struct cmdline *cl,
8596 __attribute__((unused)) void *data)
8599 struct cmd_set_mirror_link_result *res = parsed_result;
8601 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8603 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8606 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8607 .f = cmd_reset_mirror_rule_parsed,
8609 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8611 (void *)&cmd_rm_mirror_rule_reset,
8612 (void *)&cmd_rm_mirror_rule_port,
8613 (void *)&cmd_rm_mirror_rule_portid,
8614 (void *)&cmd_rm_mirror_rule_mirror,
8615 (void *)&cmd_rm_mirror_rule_ruleid,
8620 /* ******************************************************************************** */
8622 struct cmd_dump_result {
8623 cmdline_fixed_string_t dump;
8627 dump_struct_sizes(void)
8629 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8630 DUMP_SIZE(struct rte_mbuf);
8631 DUMP_SIZE(struct rte_mempool);
8632 DUMP_SIZE(struct rte_ring);
8636 static void cmd_dump_parsed(void *parsed_result,
8637 __attribute__((unused)) struct cmdline *cl,
8638 __attribute__((unused)) void *data)
8640 struct cmd_dump_result *res = parsed_result;
8642 if (!strcmp(res->dump, "dump_physmem"))
8643 rte_dump_physmem_layout(stdout);
8644 else if (!strcmp(res->dump, "dump_memzone"))
8645 rte_memzone_dump(stdout);
8646 else if (!strcmp(res->dump, "dump_struct_sizes"))
8647 dump_struct_sizes();
8648 else if (!strcmp(res->dump, "dump_ring"))
8649 rte_ring_list_dump(stdout);
8650 else if (!strcmp(res->dump, "dump_mempool"))
8651 rte_mempool_list_dump(stdout);
8652 else if (!strcmp(res->dump, "dump_devargs"))
8653 rte_eal_devargs_dump(stdout);
8654 else if (!strcmp(res->dump, "dump_log_types"))
8655 rte_log_dump(stdout);
8658 cmdline_parse_token_string_t cmd_dump_dump =
8659 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8662 "dump_struct_sizes#"
8668 cmdline_parse_inst_t cmd_dump = {
8669 .f = cmd_dump_parsed, /* function to call */
8670 .data = NULL, /* 2nd arg of func */
8671 .help_str = "Dump status",
8672 .tokens = { /* token list, NULL terminated */
8673 (void *)&cmd_dump_dump,
8678 /* ******************************************************************************** */
8680 struct cmd_dump_one_result {
8681 cmdline_fixed_string_t dump;
8682 cmdline_fixed_string_t name;
8685 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8686 __attribute__((unused)) void *data)
8688 struct cmd_dump_one_result *res = parsed_result;
8690 if (!strcmp(res->dump, "dump_ring")) {
8692 r = rte_ring_lookup(res->name);
8694 cmdline_printf(cl, "Cannot find ring\n");
8697 rte_ring_dump(stdout, r);
8698 } else if (!strcmp(res->dump, "dump_mempool")) {
8699 struct rte_mempool *mp;
8700 mp = rte_mempool_lookup(res->name);
8702 cmdline_printf(cl, "Cannot find mempool\n");
8705 rte_mempool_dump(stdout, mp);
8709 cmdline_parse_token_string_t cmd_dump_one_dump =
8710 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8711 "dump_ring#dump_mempool");
8713 cmdline_parse_token_string_t cmd_dump_one_name =
8714 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8716 cmdline_parse_inst_t cmd_dump_one = {
8717 .f = cmd_dump_one_parsed, /* function to call */
8718 .data = NULL, /* 2nd arg of func */
8719 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8720 .tokens = { /* token list, NULL terminated */
8721 (void *)&cmd_dump_one_dump,
8722 (void *)&cmd_dump_one_name,
8727 /* *** Add/Del syn filter *** */
8728 struct cmd_syn_filter_result {
8729 cmdline_fixed_string_t filter;
8731 cmdline_fixed_string_t ops;
8732 cmdline_fixed_string_t priority;
8733 cmdline_fixed_string_t high;
8734 cmdline_fixed_string_t queue;
8739 cmd_syn_filter_parsed(void *parsed_result,
8740 __attribute__((unused)) struct cmdline *cl,
8741 __attribute__((unused)) void *data)
8743 struct cmd_syn_filter_result *res = parsed_result;
8744 struct rte_eth_syn_filter syn_filter;
8747 ret = rte_eth_dev_filter_supported(res->port_id,
8748 RTE_ETH_FILTER_SYN);
8750 printf("syn filter is not supported on port %u.\n",
8755 memset(&syn_filter, 0, sizeof(syn_filter));
8757 if (!strcmp(res->ops, "add")) {
8758 if (!strcmp(res->high, "high"))
8759 syn_filter.hig_pri = 1;
8761 syn_filter.hig_pri = 0;
8763 syn_filter.queue = res->queue_id;
8764 ret = rte_eth_dev_filter_ctrl(res->port_id,
8769 ret = rte_eth_dev_filter_ctrl(res->port_id,
8771 RTE_ETH_FILTER_DELETE,
8775 printf("syn filter programming error: (%s)\n",
8779 cmdline_parse_token_string_t cmd_syn_filter_filter =
8780 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8781 filter, "syn_filter");
8782 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8783 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8785 cmdline_parse_token_string_t cmd_syn_filter_ops =
8786 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8788 cmdline_parse_token_string_t cmd_syn_filter_priority =
8789 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8790 priority, "priority");
8791 cmdline_parse_token_string_t cmd_syn_filter_high =
8792 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8794 cmdline_parse_token_string_t cmd_syn_filter_queue =
8795 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8797 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8798 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8801 cmdline_parse_inst_t cmd_syn_filter = {
8802 .f = cmd_syn_filter_parsed,
8804 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8805 "<queue_id>: Add/Delete syn filter",
8807 (void *)&cmd_syn_filter_filter,
8808 (void *)&cmd_syn_filter_port_id,
8809 (void *)&cmd_syn_filter_ops,
8810 (void *)&cmd_syn_filter_priority,
8811 (void *)&cmd_syn_filter_high,
8812 (void *)&cmd_syn_filter_queue,
8813 (void *)&cmd_syn_filter_queue_id,
8818 /* *** queue region set *** */
8819 struct cmd_queue_region_result {
8820 cmdline_fixed_string_t set;
8821 cmdline_fixed_string_t port;
8823 cmdline_fixed_string_t cmd;
8824 cmdline_fixed_string_t region;
8826 cmdline_fixed_string_t queue_start_index;
8828 cmdline_fixed_string_t queue_num;
8829 uint8_t queue_num_value;
8833 cmd_queue_region_parsed(void *parsed_result,
8834 __attribute__((unused)) struct cmdline *cl,
8835 __attribute__((unused)) void *data)
8837 struct cmd_queue_region_result *res = parsed_result;
8839 #ifdef RTE_LIBRTE_I40E_PMD
8840 struct rte_pmd_i40e_queue_region_conf region_conf;
8841 enum rte_pmd_i40e_queue_region_op op_type;
8844 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8847 #ifdef RTE_LIBRTE_I40E_PMD
8848 memset(®ion_conf, 0, sizeof(region_conf));
8849 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8850 region_conf.region_id = res->region_id;
8851 region_conf.queue_num = res->queue_num_value;
8852 region_conf.queue_start_index = res->queue_id;
8854 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8855 op_type, ®ion_conf);
8862 printf("function not implemented or supported\n");
8865 printf("queue region config error: (%s)\n", strerror(-ret));
8869 cmdline_parse_token_string_t cmd_queue_region_set =
8870 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8872 cmdline_parse_token_string_t cmd_queue_region_port =
8873 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8874 cmdline_parse_token_num_t cmd_queue_region_port_id =
8875 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8877 cmdline_parse_token_string_t cmd_queue_region_cmd =
8878 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8879 cmd, "queue-region");
8880 cmdline_parse_token_string_t cmd_queue_region_id =
8881 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8882 region, "region_id");
8883 cmdline_parse_token_num_t cmd_queue_region_index =
8884 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8886 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8887 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8888 queue_start_index, "queue_start_index");
8889 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8890 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8892 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8893 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8894 queue_num, "queue_num");
8895 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8896 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8897 queue_num_value, UINT8);
8899 cmdline_parse_inst_t cmd_queue_region = {
8900 .f = cmd_queue_region_parsed,
8902 .help_str = "set port <port_id> queue-region region_id <value> "
8903 "queue_start_index <value> queue_num <value>: Set a queue region",
8905 (void *)&cmd_queue_region_set,
8906 (void *)&cmd_queue_region_port,
8907 (void *)&cmd_queue_region_port_id,
8908 (void *)&cmd_queue_region_cmd,
8909 (void *)&cmd_queue_region_id,
8910 (void *)&cmd_queue_region_index,
8911 (void *)&cmd_queue_region_queue_start_index,
8912 (void *)&cmd_queue_region_queue_id,
8913 (void *)&cmd_queue_region_queue_num,
8914 (void *)&cmd_queue_region_queue_num_value,
8919 /* *** queue region and flowtype set *** */
8920 struct cmd_region_flowtype_result {
8921 cmdline_fixed_string_t set;
8922 cmdline_fixed_string_t port;
8924 cmdline_fixed_string_t cmd;
8925 cmdline_fixed_string_t region;
8927 cmdline_fixed_string_t flowtype;
8928 uint8_t flowtype_id;
8932 cmd_region_flowtype_parsed(void *parsed_result,
8933 __attribute__((unused)) struct cmdline *cl,
8934 __attribute__((unused)) void *data)
8936 struct cmd_region_flowtype_result *res = parsed_result;
8938 #ifdef RTE_LIBRTE_I40E_PMD
8939 struct rte_pmd_i40e_queue_region_conf region_conf;
8940 enum rte_pmd_i40e_queue_region_op op_type;
8943 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8946 #ifdef RTE_LIBRTE_I40E_PMD
8947 memset(®ion_conf, 0, sizeof(region_conf));
8949 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8950 region_conf.region_id = res->region_id;
8951 region_conf.hw_flowtype = res->flowtype_id;
8953 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8954 op_type, ®ion_conf);
8961 printf("function not implemented or supported\n");
8964 printf("region flowtype config error: (%s)\n", strerror(-ret));
8968 cmdline_parse_token_string_t cmd_region_flowtype_set =
8969 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8971 cmdline_parse_token_string_t cmd_region_flowtype_port =
8972 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8974 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8975 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8977 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8978 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8979 cmd, "queue-region");
8980 cmdline_parse_token_string_t cmd_region_flowtype_index =
8981 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8982 region, "region_id");
8983 cmdline_parse_token_num_t cmd_region_flowtype_id =
8984 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8986 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8987 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8988 flowtype, "flowtype");
8989 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8990 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8991 flowtype_id, UINT8);
8992 cmdline_parse_inst_t cmd_region_flowtype = {
8993 .f = cmd_region_flowtype_parsed,
8995 .help_str = "set port <port_id> queue-region region_id <value> "
8996 "flowtype <value>: Set a flowtype region index",
8998 (void *)&cmd_region_flowtype_set,
8999 (void *)&cmd_region_flowtype_port,
9000 (void *)&cmd_region_flowtype_port_index,
9001 (void *)&cmd_region_flowtype_cmd,
9002 (void *)&cmd_region_flowtype_index,
9003 (void *)&cmd_region_flowtype_id,
9004 (void *)&cmd_region_flowtype_flow_index,
9005 (void *)&cmd_region_flowtype_flow_id,
9010 /* *** User Priority (UP) to queue region (region_id) set *** */
9011 struct cmd_user_priority_region_result {
9012 cmdline_fixed_string_t set;
9013 cmdline_fixed_string_t port;
9015 cmdline_fixed_string_t cmd;
9016 cmdline_fixed_string_t user_priority;
9017 uint8_t user_priority_id;
9018 cmdline_fixed_string_t region;
9023 cmd_user_priority_region_parsed(void *parsed_result,
9024 __attribute__((unused)) struct cmdline *cl,
9025 __attribute__((unused)) void *data)
9027 struct cmd_user_priority_region_result *res = parsed_result;
9029 #ifdef RTE_LIBRTE_I40E_PMD
9030 struct rte_pmd_i40e_queue_region_conf region_conf;
9031 enum rte_pmd_i40e_queue_region_op op_type;
9034 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9037 #ifdef RTE_LIBRTE_I40E_PMD
9038 memset(®ion_conf, 0, sizeof(region_conf));
9039 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9040 region_conf.user_priority = res->user_priority_id;
9041 region_conf.region_id = res->region_id;
9043 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9044 op_type, ®ion_conf);
9051 printf("function not implemented or supported\n");
9054 printf("user_priority region config error: (%s)\n",
9059 cmdline_parse_token_string_t cmd_user_priority_region_set =
9060 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9062 cmdline_parse_token_string_t cmd_user_priority_region_port =
9063 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9065 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9066 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9068 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9069 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9070 cmd, "queue-region");
9071 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9072 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9073 user_priority, "UP");
9074 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9075 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9076 user_priority_id, UINT8);
9077 cmdline_parse_token_string_t cmd_user_priority_region_region =
9078 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9079 region, "region_id");
9080 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9081 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9084 cmdline_parse_inst_t cmd_user_priority_region = {
9085 .f = cmd_user_priority_region_parsed,
9087 .help_str = "set port <port_id> queue-region UP <value> "
9088 "region_id <value>: Set the mapping of User Priority (UP) "
9089 "to queue region (region_id) ",
9091 (void *)&cmd_user_priority_region_set,
9092 (void *)&cmd_user_priority_region_port,
9093 (void *)&cmd_user_priority_region_port_index,
9094 (void *)&cmd_user_priority_region_cmd,
9095 (void *)&cmd_user_priority_region_UP,
9096 (void *)&cmd_user_priority_region_UP_id,
9097 (void *)&cmd_user_priority_region_region,
9098 (void *)&cmd_user_priority_region_region_id,
9103 /* *** flush all queue region related configuration *** */
9104 struct cmd_flush_queue_region_result {
9105 cmdline_fixed_string_t set;
9106 cmdline_fixed_string_t port;
9108 cmdline_fixed_string_t cmd;
9109 cmdline_fixed_string_t flush;
9110 cmdline_fixed_string_t what;
9114 cmd_flush_queue_region_parsed(void *parsed_result,
9115 __attribute__((unused)) struct cmdline *cl,
9116 __attribute__((unused)) void *data)
9118 struct cmd_flush_queue_region_result *res = parsed_result;
9120 #ifdef RTE_LIBRTE_I40E_PMD
9121 struct rte_pmd_i40e_queue_region_conf region_conf;
9122 enum rte_pmd_i40e_queue_region_op op_type;
9125 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9128 #ifdef RTE_LIBRTE_I40E_PMD
9129 memset(®ion_conf, 0, sizeof(region_conf));
9131 if (strcmp(res->what, "on") == 0)
9132 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9134 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9136 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9137 op_type, ®ion_conf);
9144 printf("function not implemented or supported\n");
9147 printf("queue region config flush error: (%s)\n",
9152 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9153 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9155 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9156 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9158 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9159 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9161 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9162 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9163 cmd, "queue-region");
9164 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9165 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9167 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9168 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9171 cmdline_parse_inst_t cmd_flush_queue_region = {
9172 .f = cmd_flush_queue_region_parsed,
9174 .help_str = "set port <port_id> queue-region flush on|off"
9175 ": flush all queue region related configuration",
9177 (void *)&cmd_flush_queue_region_set,
9178 (void *)&cmd_flush_queue_region_port,
9179 (void *)&cmd_flush_queue_region_port_index,
9180 (void *)&cmd_flush_queue_region_cmd,
9181 (void *)&cmd_flush_queue_region_flush,
9182 (void *)&cmd_flush_queue_region_what,
9187 /* *** get all queue region related configuration info *** */
9188 struct cmd_show_queue_region_info {
9189 cmdline_fixed_string_t show;
9190 cmdline_fixed_string_t port;
9192 cmdline_fixed_string_t cmd;
9196 cmd_show_queue_region_info_parsed(void *parsed_result,
9197 __attribute__((unused)) struct cmdline *cl,
9198 __attribute__((unused)) void *data)
9200 struct cmd_show_queue_region_info *res = parsed_result;
9202 #ifdef RTE_LIBRTE_I40E_PMD
9203 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9204 enum rte_pmd_i40e_queue_region_op op_type;
9207 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9210 #ifdef RTE_LIBRTE_I40E_PMD
9211 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9213 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9215 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9216 op_type, &rte_pmd_regions);
9218 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9225 printf("function not implemented or supported\n");
9228 printf("queue region config info show error: (%s)\n",
9233 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9234 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9236 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9237 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9239 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9240 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9242 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9243 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9244 cmd, "queue-region");
9246 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9247 .f = cmd_show_queue_region_info_parsed,
9249 .help_str = "show port <port_id> queue-region"
9250 ": show all queue region related configuration info",
9252 (void *)&cmd_show_queue_region_info_get,
9253 (void *)&cmd_show_queue_region_info_port,
9254 (void *)&cmd_show_queue_region_info_port_index,
9255 (void *)&cmd_show_queue_region_info_cmd,
9260 /* *** ADD/REMOVE A 2tuple FILTER *** */
9261 struct cmd_2tuple_filter_result {
9262 cmdline_fixed_string_t filter;
9264 cmdline_fixed_string_t ops;
9265 cmdline_fixed_string_t dst_port;
9266 uint16_t dst_port_value;
9267 cmdline_fixed_string_t protocol;
9268 uint8_t protocol_value;
9269 cmdline_fixed_string_t mask;
9271 cmdline_fixed_string_t tcp_flags;
9272 uint8_t tcp_flags_value;
9273 cmdline_fixed_string_t priority;
9274 uint8_t priority_value;
9275 cmdline_fixed_string_t queue;
9280 cmd_2tuple_filter_parsed(void *parsed_result,
9281 __attribute__((unused)) struct cmdline *cl,
9282 __attribute__((unused)) void *data)
9284 struct rte_eth_ntuple_filter filter;
9285 struct cmd_2tuple_filter_result *res = parsed_result;
9288 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9290 printf("ntuple filter is not supported on port %u.\n",
9295 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9297 filter.flags = RTE_2TUPLE_FLAGS;
9298 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9299 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9300 filter.proto = res->protocol_value;
9301 filter.priority = res->priority_value;
9302 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9303 printf("nonzero tcp_flags is only meaningful"
9304 " when protocol is TCP.\n");
9307 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9308 printf("invalid TCP flags.\n");
9312 if (res->tcp_flags_value != 0) {
9313 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9314 filter.tcp_flags = res->tcp_flags_value;
9317 /* need convert to big endian. */
9318 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9319 filter.queue = res->queue_id;
9321 if (!strcmp(res->ops, "add"))
9322 ret = rte_eth_dev_filter_ctrl(res->port_id,
9323 RTE_ETH_FILTER_NTUPLE,
9327 ret = rte_eth_dev_filter_ctrl(res->port_id,
9328 RTE_ETH_FILTER_NTUPLE,
9329 RTE_ETH_FILTER_DELETE,
9332 printf("2tuple filter programming error: (%s)\n",
9337 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9338 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9339 filter, "2tuple_filter");
9340 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9341 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9343 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9344 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9346 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9347 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9348 dst_port, "dst_port");
9349 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9350 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9351 dst_port_value, UINT16);
9352 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9353 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9354 protocol, "protocol");
9355 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9356 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9357 protocol_value, UINT8);
9358 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9359 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9361 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9362 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9364 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9365 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9366 tcp_flags, "tcp_flags");
9367 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9368 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9369 tcp_flags_value, UINT8);
9370 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9371 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9372 priority, "priority");
9373 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9374 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9375 priority_value, UINT8);
9376 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9377 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9379 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9380 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9383 cmdline_parse_inst_t cmd_2tuple_filter = {
9384 .f = cmd_2tuple_filter_parsed,
9386 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9387 "<value> mask <value> tcp_flags <value> priority <value> queue "
9388 "<queue_id>: Add a 2tuple filter",
9390 (void *)&cmd_2tuple_filter_filter,
9391 (void *)&cmd_2tuple_filter_port_id,
9392 (void *)&cmd_2tuple_filter_ops,
9393 (void *)&cmd_2tuple_filter_dst_port,
9394 (void *)&cmd_2tuple_filter_dst_port_value,
9395 (void *)&cmd_2tuple_filter_protocol,
9396 (void *)&cmd_2tuple_filter_protocol_value,
9397 (void *)&cmd_2tuple_filter_mask,
9398 (void *)&cmd_2tuple_filter_mask_value,
9399 (void *)&cmd_2tuple_filter_tcp_flags,
9400 (void *)&cmd_2tuple_filter_tcp_flags_value,
9401 (void *)&cmd_2tuple_filter_priority,
9402 (void *)&cmd_2tuple_filter_priority_value,
9403 (void *)&cmd_2tuple_filter_queue,
9404 (void *)&cmd_2tuple_filter_queue_id,
9409 /* *** ADD/REMOVE A 5tuple FILTER *** */
9410 struct cmd_5tuple_filter_result {
9411 cmdline_fixed_string_t filter;
9413 cmdline_fixed_string_t ops;
9414 cmdline_fixed_string_t dst_ip;
9415 cmdline_ipaddr_t dst_ip_value;
9416 cmdline_fixed_string_t src_ip;
9417 cmdline_ipaddr_t src_ip_value;
9418 cmdline_fixed_string_t dst_port;
9419 uint16_t dst_port_value;
9420 cmdline_fixed_string_t src_port;
9421 uint16_t src_port_value;
9422 cmdline_fixed_string_t protocol;
9423 uint8_t protocol_value;
9424 cmdline_fixed_string_t mask;
9426 cmdline_fixed_string_t tcp_flags;
9427 uint8_t tcp_flags_value;
9428 cmdline_fixed_string_t priority;
9429 uint8_t priority_value;
9430 cmdline_fixed_string_t queue;
9435 cmd_5tuple_filter_parsed(void *parsed_result,
9436 __attribute__((unused)) struct cmdline *cl,
9437 __attribute__((unused)) void *data)
9439 struct rte_eth_ntuple_filter filter;
9440 struct cmd_5tuple_filter_result *res = parsed_result;
9443 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9445 printf("ntuple filter is not supported on port %u.\n",
9450 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9452 filter.flags = RTE_5TUPLE_FLAGS;
9453 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9454 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9455 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9456 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9457 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9458 filter.proto = res->protocol_value;
9459 filter.priority = res->priority_value;
9460 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9461 printf("nonzero tcp_flags is only meaningful"
9462 " when protocol is TCP.\n");
9465 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9466 printf("invalid TCP flags.\n");
9470 if (res->tcp_flags_value != 0) {
9471 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9472 filter.tcp_flags = res->tcp_flags_value;
9475 if (res->dst_ip_value.family == AF_INET)
9476 /* no need to convert, already big endian. */
9477 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9479 if (filter.dst_ip_mask == 0) {
9480 printf("can not support ipv6 involved compare.\n");
9486 if (res->src_ip_value.family == AF_INET)
9487 /* no need to convert, already big endian. */
9488 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9490 if (filter.src_ip_mask == 0) {
9491 printf("can not support ipv6 involved compare.\n");
9496 /* need convert to big endian. */
9497 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9498 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9499 filter.queue = res->queue_id;
9501 if (!strcmp(res->ops, "add"))
9502 ret = rte_eth_dev_filter_ctrl(res->port_id,
9503 RTE_ETH_FILTER_NTUPLE,
9507 ret = rte_eth_dev_filter_ctrl(res->port_id,
9508 RTE_ETH_FILTER_NTUPLE,
9509 RTE_ETH_FILTER_DELETE,
9512 printf("5tuple filter programming error: (%s)\n",
9516 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9517 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9518 filter, "5tuple_filter");
9519 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9520 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9522 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9523 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9525 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9526 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9528 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9529 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9531 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9532 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9534 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9535 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9537 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9538 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9539 dst_port, "dst_port");
9540 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9541 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9542 dst_port_value, UINT16);
9543 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9544 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9545 src_port, "src_port");
9546 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9547 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9548 src_port_value, UINT16);
9549 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9550 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9551 protocol, "protocol");
9552 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9553 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9554 protocol_value, UINT8);
9555 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9556 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9558 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9559 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9561 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9562 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9563 tcp_flags, "tcp_flags");
9564 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9565 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9566 tcp_flags_value, UINT8);
9567 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9568 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9569 priority, "priority");
9570 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9571 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9572 priority_value, UINT8);
9573 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9574 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9576 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9577 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9580 cmdline_parse_inst_t cmd_5tuple_filter = {
9581 .f = cmd_5tuple_filter_parsed,
9583 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9584 "src_ip <value> dst_port <value> src_port <value> "
9585 "protocol <value> mask <value> tcp_flags <value> "
9586 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9588 (void *)&cmd_5tuple_filter_filter,
9589 (void *)&cmd_5tuple_filter_port_id,
9590 (void *)&cmd_5tuple_filter_ops,
9591 (void *)&cmd_5tuple_filter_dst_ip,
9592 (void *)&cmd_5tuple_filter_dst_ip_value,
9593 (void *)&cmd_5tuple_filter_src_ip,
9594 (void *)&cmd_5tuple_filter_src_ip_value,
9595 (void *)&cmd_5tuple_filter_dst_port,
9596 (void *)&cmd_5tuple_filter_dst_port_value,
9597 (void *)&cmd_5tuple_filter_src_port,
9598 (void *)&cmd_5tuple_filter_src_port_value,
9599 (void *)&cmd_5tuple_filter_protocol,
9600 (void *)&cmd_5tuple_filter_protocol_value,
9601 (void *)&cmd_5tuple_filter_mask,
9602 (void *)&cmd_5tuple_filter_mask_value,
9603 (void *)&cmd_5tuple_filter_tcp_flags,
9604 (void *)&cmd_5tuple_filter_tcp_flags_value,
9605 (void *)&cmd_5tuple_filter_priority,
9606 (void *)&cmd_5tuple_filter_priority_value,
9607 (void *)&cmd_5tuple_filter_queue,
9608 (void *)&cmd_5tuple_filter_queue_id,
9613 /* *** ADD/REMOVE A flex FILTER *** */
9614 struct cmd_flex_filter_result {
9615 cmdline_fixed_string_t filter;
9616 cmdline_fixed_string_t ops;
9618 cmdline_fixed_string_t len;
9620 cmdline_fixed_string_t bytes;
9621 cmdline_fixed_string_t bytes_value;
9622 cmdline_fixed_string_t mask;
9623 cmdline_fixed_string_t mask_value;
9624 cmdline_fixed_string_t priority;
9625 uint8_t priority_value;
9626 cmdline_fixed_string_t queue;
9630 static int xdigit2val(unsigned char c)
9635 else if (isupper(c))
9643 cmd_flex_filter_parsed(void *parsed_result,
9644 __attribute__((unused)) struct cmdline *cl,
9645 __attribute__((unused)) void *data)
9648 struct rte_eth_flex_filter filter;
9649 struct cmd_flex_filter_result *res = parsed_result;
9650 char *bytes_ptr, *mask_ptr;
9651 uint16_t len, i, j = 0;
9656 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9657 printf("the len exceed the max length 128\n");
9660 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9661 filter.len = res->len_value;
9662 filter.priority = res->priority_value;
9663 filter.queue = res->queue_id;
9664 bytes_ptr = res->bytes_value;
9665 mask_ptr = res->mask_value;
9667 /* translate bytes string to array. */
9668 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9669 (bytes_ptr[1] == 'X')))
9671 len = strnlen(bytes_ptr, res->len_value * 2);
9672 if (len == 0 || (len % 8 != 0)) {
9673 printf("please check len and bytes input\n");
9676 for (i = 0; i < len; i++) {
9678 if (isxdigit(c) == 0) {
9679 /* invalid characters. */
9680 printf("invalid input\n");
9683 val = xdigit2val(c);
9686 filter.bytes[j] = byte;
9687 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9694 /* translate mask string to uint8_t array. */
9695 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9696 (mask_ptr[1] == 'X')))
9698 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9700 printf("invalid input\n");
9705 for (i = 0; i < len; i++) {
9707 if (isxdigit(c) == 0) {
9708 /* invalid characters. */
9709 printf("invalid input\n");
9712 val = xdigit2val(c);
9715 filter.mask[j] = byte;
9716 printf("mask[%d]:%02x ", j, filter.mask[j]);
9724 if (!strcmp(res->ops, "add"))
9725 ret = rte_eth_dev_filter_ctrl(res->port_id,
9726 RTE_ETH_FILTER_FLEXIBLE,
9730 ret = rte_eth_dev_filter_ctrl(res->port_id,
9731 RTE_ETH_FILTER_FLEXIBLE,
9732 RTE_ETH_FILTER_DELETE,
9736 printf("flex filter setting error: (%s)\n", strerror(-ret));
9739 cmdline_parse_token_string_t cmd_flex_filter_filter =
9740 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9741 filter, "flex_filter");
9742 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9743 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9745 cmdline_parse_token_string_t cmd_flex_filter_ops =
9746 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9748 cmdline_parse_token_string_t cmd_flex_filter_len =
9749 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9751 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9752 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9754 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9755 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9757 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9758 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9760 cmdline_parse_token_string_t cmd_flex_filter_mask =
9761 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9763 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9764 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9766 cmdline_parse_token_string_t cmd_flex_filter_priority =
9767 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9768 priority, "priority");
9769 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9770 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9771 priority_value, UINT8);
9772 cmdline_parse_token_string_t cmd_flex_filter_queue =
9773 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9775 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9776 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9778 cmdline_parse_inst_t cmd_flex_filter = {
9779 .f = cmd_flex_filter_parsed,
9781 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9782 "<value> mask <value> priority <value> queue <queue_id>: "
9783 "Add/Del a flex filter",
9785 (void *)&cmd_flex_filter_filter,
9786 (void *)&cmd_flex_filter_port_id,
9787 (void *)&cmd_flex_filter_ops,
9788 (void *)&cmd_flex_filter_len,
9789 (void *)&cmd_flex_filter_len_value,
9790 (void *)&cmd_flex_filter_bytes,
9791 (void *)&cmd_flex_filter_bytes_value,
9792 (void *)&cmd_flex_filter_mask,
9793 (void *)&cmd_flex_filter_mask_value,
9794 (void *)&cmd_flex_filter_priority,
9795 (void *)&cmd_flex_filter_priority_value,
9796 (void *)&cmd_flex_filter_queue,
9797 (void *)&cmd_flex_filter_queue_id,
9802 /* *** Filters Control *** */
9804 /* *** deal with ethertype filter *** */
9805 struct cmd_ethertype_filter_result {
9806 cmdline_fixed_string_t filter;
9808 cmdline_fixed_string_t ops;
9809 cmdline_fixed_string_t mac;
9810 struct ether_addr mac_addr;
9811 cmdline_fixed_string_t ethertype;
9812 uint16_t ethertype_value;
9813 cmdline_fixed_string_t drop;
9814 cmdline_fixed_string_t queue;
9818 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9819 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9820 filter, "ethertype_filter");
9821 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9822 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9824 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9825 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9827 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9828 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9829 mac, "mac_addr#mac_ignr");
9830 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9831 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9833 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9834 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9835 ethertype, "ethertype");
9836 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9837 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9838 ethertype_value, UINT16);
9839 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9840 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9842 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9843 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9845 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9846 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9850 cmd_ethertype_filter_parsed(void *parsed_result,
9851 __attribute__((unused)) struct cmdline *cl,
9852 __attribute__((unused)) void *data)
9854 struct cmd_ethertype_filter_result *res = parsed_result;
9855 struct rte_eth_ethertype_filter filter;
9858 ret = rte_eth_dev_filter_supported(res->port_id,
9859 RTE_ETH_FILTER_ETHERTYPE);
9861 printf("ethertype filter is not supported on port %u.\n",
9866 memset(&filter, 0, sizeof(filter));
9867 if (!strcmp(res->mac, "mac_addr")) {
9868 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9869 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9870 sizeof(struct ether_addr));
9872 if (!strcmp(res->drop, "drop"))
9873 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9874 filter.ether_type = res->ethertype_value;
9875 filter.queue = res->queue_id;
9877 if (!strcmp(res->ops, "add"))
9878 ret = rte_eth_dev_filter_ctrl(res->port_id,
9879 RTE_ETH_FILTER_ETHERTYPE,
9883 ret = rte_eth_dev_filter_ctrl(res->port_id,
9884 RTE_ETH_FILTER_ETHERTYPE,
9885 RTE_ETH_FILTER_DELETE,
9888 printf("ethertype filter programming error: (%s)\n",
9892 cmdline_parse_inst_t cmd_ethertype_filter = {
9893 .f = cmd_ethertype_filter_parsed,
9895 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9896 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9897 "Add or delete an ethertype filter entry",
9899 (void *)&cmd_ethertype_filter_filter,
9900 (void *)&cmd_ethertype_filter_port_id,
9901 (void *)&cmd_ethertype_filter_ops,
9902 (void *)&cmd_ethertype_filter_mac,
9903 (void *)&cmd_ethertype_filter_mac_addr,
9904 (void *)&cmd_ethertype_filter_ethertype,
9905 (void *)&cmd_ethertype_filter_ethertype_value,
9906 (void *)&cmd_ethertype_filter_drop,
9907 (void *)&cmd_ethertype_filter_queue,
9908 (void *)&cmd_ethertype_filter_queue_id,
9913 /* *** deal with flow director filter *** */
9914 struct cmd_flow_director_result {
9915 cmdline_fixed_string_t flow_director_filter;
9917 cmdline_fixed_string_t mode;
9918 cmdline_fixed_string_t mode_value;
9919 cmdline_fixed_string_t ops;
9920 cmdline_fixed_string_t flow;
9921 cmdline_fixed_string_t flow_type;
9922 cmdline_fixed_string_t ether;
9923 uint16_t ether_type;
9924 cmdline_fixed_string_t src;
9925 cmdline_ipaddr_t ip_src;
9927 cmdline_fixed_string_t dst;
9928 cmdline_ipaddr_t ip_dst;
9930 cmdline_fixed_string_t verify_tag;
9931 uint32_t verify_tag_value;
9932 cmdline_ipaddr_t tos;
9934 cmdline_ipaddr_t proto;
9935 uint8_t proto_value;
9936 cmdline_ipaddr_t ttl;
9938 cmdline_fixed_string_t vlan;
9939 uint16_t vlan_value;
9940 cmdline_fixed_string_t flexbytes;
9941 cmdline_fixed_string_t flexbytes_value;
9942 cmdline_fixed_string_t pf_vf;
9943 cmdline_fixed_string_t drop;
9944 cmdline_fixed_string_t queue;
9946 cmdline_fixed_string_t fd_id;
9947 uint32_t fd_id_value;
9948 cmdline_fixed_string_t mac;
9949 struct ether_addr mac_addr;
9950 cmdline_fixed_string_t tunnel;
9951 cmdline_fixed_string_t tunnel_type;
9952 cmdline_fixed_string_t tunnel_id;
9953 uint32_t tunnel_id_value;
9954 cmdline_fixed_string_t packet;
9959 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9962 const char *p, *p0 = q_arg;
9964 unsigned long int_fld;
9965 char *str_fld[max_num];
9970 p = strchr(p0, '(');
9974 p0 = strchr(p, ')');
9979 if (size >= sizeof(s))
9982 snprintf(s, sizeof(s), "%.*s", size, p);
9983 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9984 if (ret < 0 || ret > max_num)
9986 for (i = 0; i < ret; i++) {
9988 int_fld = strtoul(str_fld[i], &end, 0);
9989 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9991 flexbytes[i] = (uint8_t)int_fld;
9997 str2flowtype(char *string)
10000 static const struct {
10003 } flowtype_str[] = {
10004 {"raw", RTE_ETH_FLOW_RAW},
10005 {"ipv4", RTE_ETH_FLOW_IPV4},
10006 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10007 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10008 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10009 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10010 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10011 {"ipv6", RTE_ETH_FLOW_IPV6},
10012 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10013 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10014 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10015 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10016 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10017 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10020 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10021 if (!strcmp(flowtype_str[i].str, string))
10022 return flowtype_str[i].type;
10025 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10026 return (uint16_t)atoi(string);
10028 return RTE_ETH_FLOW_UNKNOWN;
10031 static enum rte_eth_fdir_tunnel_type
10032 str2fdir_tunneltype(char *string)
10036 static const struct {
10038 enum rte_eth_fdir_tunnel_type type;
10039 } tunneltype_str[] = {
10040 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10041 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10044 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10045 if (!strcmp(tunneltype_str[i].str, string))
10046 return tunneltype_str[i].type;
10048 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10051 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10053 if ((ip_addr).family == AF_INET) \
10054 (ip) = (ip_addr).addr.ipv4.s_addr; \
10056 printf("invalid parameter.\n"); \
10061 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10063 if ((ip_addr).family == AF_INET6) \
10064 rte_memcpy(&(ip), \
10065 &((ip_addr).addr.ipv6), \
10066 sizeof(struct in6_addr)); \
10068 printf("invalid parameter.\n"); \
10074 cmd_flow_director_filter_parsed(void *parsed_result,
10075 __attribute__((unused)) struct cmdline *cl,
10076 __attribute__((unused)) void *data)
10078 struct cmd_flow_director_result *res = parsed_result;
10079 struct rte_eth_fdir_filter entry;
10080 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10082 unsigned long vf_id;
10085 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10087 printf("flow director is not supported on port %u.\n",
10091 memset(flexbytes, 0, sizeof(flexbytes));
10092 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10094 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10095 if (strcmp(res->mode_value, "MAC-VLAN")) {
10096 printf("Please set mode to MAC-VLAN.\n");
10099 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10100 if (strcmp(res->mode_value, "Tunnel")) {
10101 printf("Please set mode to Tunnel.\n");
10105 if (!strcmp(res->mode_value, "raw")) {
10106 #ifdef RTE_LIBRTE_I40E_PMD
10107 struct rte_pmd_i40e_flow_type_mapping
10108 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10109 struct rte_pmd_i40e_pkt_template_conf conf;
10110 uint16_t flow_type = str2flowtype(res->flow_type);
10111 uint16_t i, port = res->port_id;
10114 memset(&conf, 0, sizeof(conf));
10116 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10117 printf("Invalid flow type specified.\n");
10120 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10124 if (mapping[flow_type].pctype == 0ULL) {
10125 printf("Invalid flow type specified.\n");
10128 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10129 if (mapping[flow_type].pctype & (1ULL << i)) {
10130 conf.input.pctype = i;
10135 conf.input.packet = open_file(res->filepath,
10136 &conf.input.length);
10137 if (!conf.input.packet)
10139 if (!strcmp(res->drop, "drop"))
10140 conf.action.behavior =
10141 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10143 conf.action.behavior =
10144 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10145 conf.action.report_status =
10146 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10147 conf.action.rx_queue = res->queue_id;
10148 conf.soft_id = res->fd_id_value;
10149 add = strcmp(res->ops, "del") ? 1 : 0;
10150 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10154 printf("flow director config error: (%s)\n",
10156 close_file(conf.input.packet);
10159 } else if (strcmp(res->mode_value, "IP")) {
10160 printf("Please set mode to IP or raw.\n");
10163 entry.input.flow_type = str2flowtype(res->flow_type);
10166 ret = parse_flexbytes(res->flexbytes_value,
10168 RTE_ETH_FDIR_MAX_FLEXLEN);
10170 printf("error: Cannot parse flexbytes input.\n");
10174 switch (entry.input.flow_type) {
10175 case RTE_ETH_FLOW_FRAG_IPV4:
10176 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10177 entry.input.flow.ip4_flow.proto = res->proto_value;
10179 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10180 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10181 IPV4_ADDR_TO_UINT(res->ip_dst,
10182 entry.input.flow.ip4_flow.dst_ip);
10183 IPV4_ADDR_TO_UINT(res->ip_src,
10184 entry.input.flow.ip4_flow.src_ip);
10185 entry.input.flow.ip4_flow.tos = res->tos_value;
10186 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10187 /* need convert to big endian. */
10188 entry.input.flow.udp4_flow.dst_port =
10189 rte_cpu_to_be_16(res->port_dst);
10190 entry.input.flow.udp4_flow.src_port =
10191 rte_cpu_to_be_16(res->port_src);
10193 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10194 IPV4_ADDR_TO_UINT(res->ip_dst,
10195 entry.input.flow.sctp4_flow.ip.dst_ip);
10196 IPV4_ADDR_TO_UINT(res->ip_src,
10197 entry.input.flow.sctp4_flow.ip.src_ip);
10198 entry.input.flow.ip4_flow.tos = res->tos_value;
10199 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10200 /* need convert to big endian. */
10201 entry.input.flow.sctp4_flow.dst_port =
10202 rte_cpu_to_be_16(res->port_dst);
10203 entry.input.flow.sctp4_flow.src_port =
10204 rte_cpu_to_be_16(res->port_src);
10205 entry.input.flow.sctp4_flow.verify_tag =
10206 rte_cpu_to_be_32(res->verify_tag_value);
10208 case RTE_ETH_FLOW_FRAG_IPV6:
10209 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10210 entry.input.flow.ipv6_flow.proto = res->proto_value;
10212 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10213 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10214 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10215 entry.input.flow.ipv6_flow.dst_ip);
10216 IPV6_ADDR_TO_ARRAY(res->ip_src,
10217 entry.input.flow.ipv6_flow.src_ip);
10218 entry.input.flow.ipv6_flow.tc = res->tos_value;
10219 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10220 /* need convert to big endian. */
10221 entry.input.flow.udp6_flow.dst_port =
10222 rte_cpu_to_be_16(res->port_dst);
10223 entry.input.flow.udp6_flow.src_port =
10224 rte_cpu_to_be_16(res->port_src);
10226 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10227 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10228 entry.input.flow.sctp6_flow.ip.dst_ip);
10229 IPV6_ADDR_TO_ARRAY(res->ip_src,
10230 entry.input.flow.sctp6_flow.ip.src_ip);
10231 entry.input.flow.ipv6_flow.tc = res->tos_value;
10232 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10233 /* need convert to big endian. */
10234 entry.input.flow.sctp6_flow.dst_port =
10235 rte_cpu_to_be_16(res->port_dst);
10236 entry.input.flow.sctp6_flow.src_port =
10237 rte_cpu_to_be_16(res->port_src);
10238 entry.input.flow.sctp6_flow.verify_tag =
10239 rte_cpu_to_be_32(res->verify_tag_value);
10241 case RTE_ETH_FLOW_L2_PAYLOAD:
10242 entry.input.flow.l2_flow.ether_type =
10243 rte_cpu_to_be_16(res->ether_type);
10249 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10250 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10252 sizeof(struct ether_addr));
10254 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10255 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10257 sizeof(struct ether_addr));
10258 entry.input.flow.tunnel_flow.tunnel_type =
10259 str2fdir_tunneltype(res->tunnel_type);
10260 entry.input.flow.tunnel_flow.tunnel_id =
10261 rte_cpu_to_be_32(res->tunnel_id_value);
10264 rte_memcpy(entry.input.flow_ext.flexbytes,
10266 RTE_ETH_FDIR_MAX_FLEXLEN);
10268 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10270 entry.action.flex_off = 0; /*use 0 by default */
10271 if (!strcmp(res->drop, "drop"))
10272 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10274 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10276 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10277 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10278 if (!strcmp(res->pf_vf, "pf"))
10279 entry.input.flow_ext.is_vf = 0;
10280 else if (!strncmp(res->pf_vf, "vf", 2)) {
10281 struct rte_eth_dev_info dev_info;
10283 memset(&dev_info, 0, sizeof(dev_info));
10284 rte_eth_dev_info_get(res->port_id, &dev_info);
10286 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10287 if (errno != 0 || *end != '\0' ||
10288 vf_id >= dev_info.max_vfs) {
10289 printf("invalid parameter %s.\n", res->pf_vf);
10292 entry.input.flow_ext.is_vf = 1;
10293 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10295 printf("invalid parameter %s.\n", res->pf_vf);
10300 /* set to report FD ID by default */
10301 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10302 entry.action.rx_queue = res->queue_id;
10303 entry.soft_id = res->fd_id_value;
10304 if (!strcmp(res->ops, "add"))
10305 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10306 RTE_ETH_FILTER_ADD, &entry);
10307 else if (!strcmp(res->ops, "del"))
10308 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10309 RTE_ETH_FILTER_DELETE, &entry);
10311 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10312 RTE_ETH_FILTER_UPDATE, &entry);
10314 printf("flow director programming error: (%s)\n",
10318 cmdline_parse_token_string_t cmd_flow_director_filter =
10319 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10320 flow_director_filter, "flow_director_filter");
10321 cmdline_parse_token_num_t cmd_flow_director_port_id =
10322 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10324 cmdline_parse_token_string_t cmd_flow_director_ops =
10325 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10326 ops, "add#del#update");
10327 cmdline_parse_token_string_t cmd_flow_director_flow =
10328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10330 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10331 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10333 cmdline_parse_token_string_t cmd_flow_director_ether =
10334 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10336 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10337 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10338 ether_type, UINT16);
10339 cmdline_parse_token_string_t cmd_flow_director_src =
10340 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10342 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10343 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10345 cmdline_parse_token_num_t cmd_flow_director_port_src =
10346 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10348 cmdline_parse_token_string_t cmd_flow_director_dst =
10349 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10351 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10352 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10354 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10355 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10357 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10358 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10359 verify_tag, "verify_tag");
10360 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10361 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10362 verify_tag_value, UINT32);
10363 cmdline_parse_token_string_t cmd_flow_director_tos =
10364 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10366 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10367 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10369 cmdline_parse_token_string_t cmd_flow_director_proto =
10370 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10372 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10373 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10374 proto_value, UINT8);
10375 cmdline_parse_token_string_t cmd_flow_director_ttl =
10376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10378 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10379 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10381 cmdline_parse_token_string_t cmd_flow_director_vlan =
10382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10384 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10385 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10386 vlan_value, UINT16);
10387 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10389 flexbytes, "flexbytes");
10390 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10391 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10392 flexbytes_value, NULL);
10393 cmdline_parse_token_string_t cmd_flow_director_drop =
10394 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10396 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10397 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10399 cmdline_parse_token_string_t cmd_flow_director_queue =
10400 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10402 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10403 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10405 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10406 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10408 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10409 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10410 fd_id_value, UINT32);
10412 cmdline_parse_token_string_t cmd_flow_director_mode =
10413 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10415 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10416 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10418 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10419 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10420 mode_value, "MAC-VLAN");
10421 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10422 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10423 mode_value, "Tunnel");
10424 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10425 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10426 mode_value, "raw");
10427 cmdline_parse_token_string_t cmd_flow_director_mac =
10428 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10430 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10431 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10433 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10434 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10436 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10437 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10438 tunnel_type, "NVGRE#VxLAN");
10439 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10440 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10441 tunnel_id, "tunnel-id");
10442 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10443 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10444 tunnel_id_value, UINT32);
10445 cmdline_parse_token_string_t cmd_flow_director_packet =
10446 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10448 cmdline_parse_token_string_t cmd_flow_director_filepath =
10449 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10452 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10453 .f = cmd_flow_director_filter_parsed,
10455 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10456 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10457 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10458 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10459 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10460 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10461 "fd_id <fd_id_value>: "
10462 "Add or delete an ip flow director entry on NIC",
10464 (void *)&cmd_flow_director_filter,
10465 (void *)&cmd_flow_director_port_id,
10466 (void *)&cmd_flow_director_mode,
10467 (void *)&cmd_flow_director_mode_ip,
10468 (void *)&cmd_flow_director_ops,
10469 (void *)&cmd_flow_director_flow,
10470 (void *)&cmd_flow_director_flow_type,
10471 (void *)&cmd_flow_director_src,
10472 (void *)&cmd_flow_director_ip_src,
10473 (void *)&cmd_flow_director_dst,
10474 (void *)&cmd_flow_director_ip_dst,
10475 (void *)&cmd_flow_director_tos,
10476 (void *)&cmd_flow_director_tos_value,
10477 (void *)&cmd_flow_director_proto,
10478 (void *)&cmd_flow_director_proto_value,
10479 (void *)&cmd_flow_director_ttl,
10480 (void *)&cmd_flow_director_ttl_value,
10481 (void *)&cmd_flow_director_vlan,
10482 (void *)&cmd_flow_director_vlan_value,
10483 (void *)&cmd_flow_director_flexbytes,
10484 (void *)&cmd_flow_director_flexbytes_value,
10485 (void *)&cmd_flow_director_drop,
10486 (void *)&cmd_flow_director_pf_vf,
10487 (void *)&cmd_flow_director_queue,
10488 (void *)&cmd_flow_director_queue_id,
10489 (void *)&cmd_flow_director_fd_id,
10490 (void *)&cmd_flow_director_fd_id_value,
10495 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10496 .f = cmd_flow_director_filter_parsed,
10498 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10499 "director entry on NIC",
10501 (void *)&cmd_flow_director_filter,
10502 (void *)&cmd_flow_director_port_id,
10503 (void *)&cmd_flow_director_mode,
10504 (void *)&cmd_flow_director_mode_ip,
10505 (void *)&cmd_flow_director_ops,
10506 (void *)&cmd_flow_director_flow,
10507 (void *)&cmd_flow_director_flow_type,
10508 (void *)&cmd_flow_director_src,
10509 (void *)&cmd_flow_director_ip_src,
10510 (void *)&cmd_flow_director_port_src,
10511 (void *)&cmd_flow_director_dst,
10512 (void *)&cmd_flow_director_ip_dst,
10513 (void *)&cmd_flow_director_port_dst,
10514 (void *)&cmd_flow_director_tos,
10515 (void *)&cmd_flow_director_tos_value,
10516 (void *)&cmd_flow_director_ttl,
10517 (void *)&cmd_flow_director_ttl_value,
10518 (void *)&cmd_flow_director_vlan,
10519 (void *)&cmd_flow_director_vlan_value,
10520 (void *)&cmd_flow_director_flexbytes,
10521 (void *)&cmd_flow_director_flexbytes_value,
10522 (void *)&cmd_flow_director_drop,
10523 (void *)&cmd_flow_director_pf_vf,
10524 (void *)&cmd_flow_director_queue,
10525 (void *)&cmd_flow_director_queue_id,
10526 (void *)&cmd_flow_director_fd_id,
10527 (void *)&cmd_flow_director_fd_id_value,
10532 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10533 .f = cmd_flow_director_filter_parsed,
10535 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10536 "director entry on NIC",
10538 (void *)&cmd_flow_director_filter,
10539 (void *)&cmd_flow_director_port_id,
10540 (void *)&cmd_flow_director_mode,
10541 (void *)&cmd_flow_director_mode_ip,
10542 (void *)&cmd_flow_director_ops,
10543 (void *)&cmd_flow_director_flow,
10544 (void *)&cmd_flow_director_flow_type,
10545 (void *)&cmd_flow_director_src,
10546 (void *)&cmd_flow_director_ip_src,
10547 (void *)&cmd_flow_director_port_dst,
10548 (void *)&cmd_flow_director_dst,
10549 (void *)&cmd_flow_director_ip_dst,
10550 (void *)&cmd_flow_director_port_dst,
10551 (void *)&cmd_flow_director_verify_tag,
10552 (void *)&cmd_flow_director_verify_tag_value,
10553 (void *)&cmd_flow_director_tos,
10554 (void *)&cmd_flow_director_tos_value,
10555 (void *)&cmd_flow_director_ttl,
10556 (void *)&cmd_flow_director_ttl_value,
10557 (void *)&cmd_flow_director_vlan,
10558 (void *)&cmd_flow_director_vlan_value,
10559 (void *)&cmd_flow_director_flexbytes,
10560 (void *)&cmd_flow_director_flexbytes_value,
10561 (void *)&cmd_flow_director_drop,
10562 (void *)&cmd_flow_director_pf_vf,
10563 (void *)&cmd_flow_director_queue,
10564 (void *)&cmd_flow_director_queue_id,
10565 (void *)&cmd_flow_director_fd_id,
10566 (void *)&cmd_flow_director_fd_id_value,
10571 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10572 .f = cmd_flow_director_filter_parsed,
10574 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10575 "director entry on NIC",
10577 (void *)&cmd_flow_director_filter,
10578 (void *)&cmd_flow_director_port_id,
10579 (void *)&cmd_flow_director_mode,
10580 (void *)&cmd_flow_director_mode_ip,
10581 (void *)&cmd_flow_director_ops,
10582 (void *)&cmd_flow_director_flow,
10583 (void *)&cmd_flow_director_flow_type,
10584 (void *)&cmd_flow_director_ether,
10585 (void *)&cmd_flow_director_ether_type,
10586 (void *)&cmd_flow_director_flexbytes,
10587 (void *)&cmd_flow_director_flexbytes_value,
10588 (void *)&cmd_flow_director_drop,
10589 (void *)&cmd_flow_director_pf_vf,
10590 (void *)&cmd_flow_director_queue,
10591 (void *)&cmd_flow_director_queue_id,
10592 (void *)&cmd_flow_director_fd_id,
10593 (void *)&cmd_flow_director_fd_id_value,
10598 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10599 .f = cmd_flow_director_filter_parsed,
10601 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10602 "director entry on NIC",
10604 (void *)&cmd_flow_director_filter,
10605 (void *)&cmd_flow_director_port_id,
10606 (void *)&cmd_flow_director_mode,
10607 (void *)&cmd_flow_director_mode_mac_vlan,
10608 (void *)&cmd_flow_director_ops,
10609 (void *)&cmd_flow_director_mac,
10610 (void *)&cmd_flow_director_mac_addr,
10611 (void *)&cmd_flow_director_vlan,
10612 (void *)&cmd_flow_director_vlan_value,
10613 (void *)&cmd_flow_director_flexbytes,
10614 (void *)&cmd_flow_director_flexbytes_value,
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,
10624 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10625 .f = cmd_flow_director_filter_parsed,
10627 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10628 "director entry on NIC",
10630 (void *)&cmd_flow_director_filter,
10631 (void *)&cmd_flow_director_port_id,
10632 (void *)&cmd_flow_director_mode,
10633 (void *)&cmd_flow_director_mode_tunnel,
10634 (void *)&cmd_flow_director_ops,
10635 (void *)&cmd_flow_director_mac,
10636 (void *)&cmd_flow_director_mac_addr,
10637 (void *)&cmd_flow_director_vlan,
10638 (void *)&cmd_flow_director_vlan_value,
10639 (void *)&cmd_flow_director_tunnel,
10640 (void *)&cmd_flow_director_tunnel_type,
10641 (void *)&cmd_flow_director_tunnel_id,
10642 (void *)&cmd_flow_director_tunnel_id_value,
10643 (void *)&cmd_flow_director_flexbytes,
10644 (void *)&cmd_flow_director_flexbytes_value,
10645 (void *)&cmd_flow_director_drop,
10646 (void *)&cmd_flow_director_queue,
10647 (void *)&cmd_flow_director_queue_id,
10648 (void *)&cmd_flow_director_fd_id,
10649 (void *)&cmd_flow_director_fd_id_value,
10654 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10655 .f = cmd_flow_director_filter_parsed,
10657 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10658 "director entry on NIC",
10660 (void *)&cmd_flow_director_filter,
10661 (void *)&cmd_flow_director_port_id,
10662 (void *)&cmd_flow_director_mode,
10663 (void *)&cmd_flow_director_mode_raw,
10664 (void *)&cmd_flow_director_ops,
10665 (void *)&cmd_flow_director_flow,
10666 (void *)&cmd_flow_director_flow_type,
10667 (void *)&cmd_flow_director_drop,
10668 (void *)&cmd_flow_director_queue,
10669 (void *)&cmd_flow_director_queue_id,
10670 (void *)&cmd_flow_director_fd_id,
10671 (void *)&cmd_flow_director_fd_id_value,
10672 (void *)&cmd_flow_director_packet,
10673 (void *)&cmd_flow_director_filepath,
10678 struct cmd_flush_flow_director_result {
10679 cmdline_fixed_string_t flush_flow_director;
10683 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10684 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10685 flush_flow_director, "flush_flow_director");
10686 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10687 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10691 cmd_flush_flow_director_parsed(void *parsed_result,
10692 __attribute__((unused)) struct cmdline *cl,
10693 __attribute__((unused)) void *data)
10695 struct cmd_flow_director_result *res = parsed_result;
10698 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10700 printf("flow director is not supported on port %u.\n",
10705 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10706 RTE_ETH_FILTER_FLUSH, NULL);
10708 printf("flow director table flushing error: (%s)\n",
10712 cmdline_parse_inst_t cmd_flush_flow_director = {
10713 .f = cmd_flush_flow_director_parsed,
10715 .help_str = "flush_flow_director <port_id>: "
10716 "Flush all flow director entries of a device on NIC",
10718 (void *)&cmd_flush_flow_director_flush,
10719 (void *)&cmd_flush_flow_director_port_id,
10724 /* *** deal with flow director mask *** */
10725 struct cmd_flow_director_mask_result {
10726 cmdline_fixed_string_t flow_director_mask;
10728 cmdline_fixed_string_t mode;
10729 cmdline_fixed_string_t mode_value;
10730 cmdline_fixed_string_t vlan;
10731 uint16_t vlan_mask;
10732 cmdline_fixed_string_t src_mask;
10733 cmdline_ipaddr_t ipv4_src;
10734 cmdline_ipaddr_t ipv6_src;
10736 cmdline_fixed_string_t dst_mask;
10737 cmdline_ipaddr_t ipv4_dst;
10738 cmdline_ipaddr_t ipv6_dst;
10740 cmdline_fixed_string_t mac;
10741 uint8_t mac_addr_byte_mask;
10742 cmdline_fixed_string_t tunnel_id;
10743 uint32_t tunnel_id_mask;
10744 cmdline_fixed_string_t tunnel_type;
10745 uint8_t tunnel_type_mask;
10749 cmd_flow_director_mask_parsed(void *parsed_result,
10750 __attribute__((unused)) struct cmdline *cl,
10751 __attribute__((unused)) void *data)
10753 struct cmd_flow_director_mask_result *res = parsed_result;
10754 struct rte_eth_fdir_masks *mask;
10755 struct rte_port *port;
10757 if (res->port_id > nb_ports) {
10758 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10762 port = &ports[res->port_id];
10763 /** Check if the port is not started **/
10764 if (port->port_status != RTE_PORT_STOPPED) {
10765 printf("Please stop port %d first\n", res->port_id);
10769 mask = &port->dev_conf.fdir_conf.mask;
10771 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10772 if (strcmp(res->mode_value, "MAC-VLAN")) {
10773 printf("Please set mode to MAC-VLAN.\n");
10777 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10778 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10779 if (strcmp(res->mode_value, "Tunnel")) {
10780 printf("Please set mode to Tunnel.\n");
10784 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10785 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10786 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10787 mask->tunnel_type_mask = res->tunnel_type_mask;
10789 if (strcmp(res->mode_value, "IP")) {
10790 printf("Please set mode to IP.\n");
10794 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10795 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10796 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10797 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10798 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10799 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10800 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10803 cmd_reconfig_device_queue(res->port_id, 1, 1);
10806 cmdline_parse_token_string_t cmd_flow_director_mask =
10807 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10808 flow_director_mask, "flow_director_mask");
10809 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10810 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10812 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10813 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10815 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10816 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10817 vlan_mask, UINT16);
10818 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10819 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10820 src_mask, "src_mask");
10821 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10822 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10824 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10825 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10827 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10828 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10830 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10831 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10832 dst_mask, "dst_mask");
10833 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10834 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10836 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10837 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10839 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10840 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10843 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10844 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10846 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10847 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10849 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10850 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10851 mode_value, "MAC-VLAN");
10852 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10853 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10854 mode_value, "Tunnel");
10855 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10856 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10858 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10859 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10860 mac_addr_byte_mask, UINT8);
10861 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10863 tunnel_type, "tunnel-type");
10864 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10865 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10866 tunnel_type_mask, UINT8);
10867 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10869 tunnel_id, "tunnel-id");
10870 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10871 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10872 tunnel_id_mask, UINT32);
10874 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10875 .f = cmd_flow_director_mask_parsed,
10877 .help_str = "flow_director_mask ... : "
10878 "Set IP mode flow director's mask on NIC",
10880 (void *)&cmd_flow_director_mask,
10881 (void *)&cmd_flow_director_mask_port_id,
10882 (void *)&cmd_flow_director_mask_mode,
10883 (void *)&cmd_flow_director_mask_mode_ip,
10884 (void *)&cmd_flow_director_mask_vlan,
10885 (void *)&cmd_flow_director_mask_vlan_value,
10886 (void *)&cmd_flow_director_mask_src,
10887 (void *)&cmd_flow_director_mask_ipv4_src,
10888 (void *)&cmd_flow_director_mask_ipv6_src,
10889 (void *)&cmd_flow_director_mask_port_src,
10890 (void *)&cmd_flow_director_mask_dst,
10891 (void *)&cmd_flow_director_mask_ipv4_dst,
10892 (void *)&cmd_flow_director_mask_ipv6_dst,
10893 (void *)&cmd_flow_director_mask_port_dst,
10898 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10899 .f = cmd_flow_director_mask_parsed,
10901 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10902 "flow director's mask on NIC",
10904 (void *)&cmd_flow_director_mask,
10905 (void *)&cmd_flow_director_mask_port_id,
10906 (void *)&cmd_flow_director_mask_mode,
10907 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10908 (void *)&cmd_flow_director_mask_vlan,
10909 (void *)&cmd_flow_director_mask_vlan_value,
10914 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10915 .f = cmd_flow_director_mask_parsed,
10917 .help_str = "flow_director_mask ... : Set tunnel mode "
10918 "flow director's mask on NIC",
10920 (void *)&cmd_flow_director_mask,
10921 (void *)&cmd_flow_director_mask_port_id,
10922 (void *)&cmd_flow_director_mask_mode,
10923 (void *)&cmd_flow_director_mask_mode_tunnel,
10924 (void *)&cmd_flow_director_mask_vlan,
10925 (void *)&cmd_flow_director_mask_vlan_value,
10926 (void *)&cmd_flow_director_mask_mac,
10927 (void *)&cmd_flow_director_mask_mac_value,
10928 (void *)&cmd_flow_director_mask_tunnel_type,
10929 (void *)&cmd_flow_director_mask_tunnel_type_value,
10930 (void *)&cmd_flow_director_mask_tunnel_id,
10931 (void *)&cmd_flow_director_mask_tunnel_id_value,
10936 /* *** deal with flow director mask on flexible payload *** */
10937 struct cmd_flow_director_flex_mask_result {
10938 cmdline_fixed_string_t flow_director_flexmask;
10940 cmdline_fixed_string_t flow;
10941 cmdline_fixed_string_t flow_type;
10942 cmdline_fixed_string_t mask;
10946 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10947 __attribute__((unused)) struct cmdline *cl,
10948 __attribute__((unused)) void *data)
10950 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10951 struct rte_eth_fdir_info fdir_info;
10952 struct rte_eth_fdir_flex_mask flex_mask;
10953 struct rte_port *port;
10954 uint64_t flow_type_mask;
10958 if (res->port_id > nb_ports) {
10959 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10963 port = &ports[res->port_id];
10964 /** Check if the port is not started **/
10965 if (port->port_status != RTE_PORT_STOPPED) {
10966 printf("Please stop port %d first\n", res->port_id);
10970 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10971 ret = parse_flexbytes(res->mask,
10973 RTE_ETH_FDIR_MAX_FLEXLEN);
10975 printf("error: Cannot parse mask input.\n");
10979 memset(&fdir_info, 0, sizeof(fdir_info));
10980 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10981 RTE_ETH_FILTER_INFO, &fdir_info);
10983 printf("Cannot get FDir filter info\n");
10987 if (!strcmp(res->flow_type, "none")) {
10988 /* means don't specify the flow type */
10989 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10990 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10991 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10992 0, sizeof(struct rte_eth_fdir_flex_mask));
10993 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10994 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10996 sizeof(struct rte_eth_fdir_flex_mask));
10997 cmd_reconfig_device_queue(res->port_id, 1, 1);
11000 flow_type_mask = fdir_info.flow_types_mask[0];
11001 if (!strcmp(res->flow_type, "all")) {
11002 if (!flow_type_mask) {
11003 printf("No flow type supported\n");
11006 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11007 if (flow_type_mask & (1ULL << i)) {
11008 flex_mask.flow_type = i;
11009 fdir_set_flex_mask(res->port_id, &flex_mask);
11012 cmd_reconfig_device_queue(res->port_id, 1, 1);
11015 flex_mask.flow_type = str2flowtype(res->flow_type);
11016 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11017 printf("Flow type %s not supported on port %d\n",
11018 res->flow_type, res->port_id);
11021 fdir_set_flex_mask(res->port_id, &flex_mask);
11022 cmd_reconfig_device_queue(res->port_id, 1, 1);
11025 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11026 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11027 flow_director_flexmask,
11028 "flow_director_flex_mask");
11029 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11030 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11032 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11033 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11035 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11036 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11037 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11038 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11039 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11040 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11043 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11044 .f = cmd_flow_director_flex_mask_parsed,
11046 .help_str = "flow_director_flex_mask ... : "
11047 "Set flow director's flex mask on NIC",
11049 (void *)&cmd_flow_director_flexmask,
11050 (void *)&cmd_flow_director_flexmask_port_id,
11051 (void *)&cmd_flow_director_flexmask_flow,
11052 (void *)&cmd_flow_director_flexmask_flow_type,
11053 (void *)&cmd_flow_director_flexmask_mask,
11058 /* *** deal with flow director flexible payload configuration *** */
11059 struct cmd_flow_director_flexpayload_result {
11060 cmdline_fixed_string_t flow_director_flexpayload;
11062 cmdline_fixed_string_t payload_layer;
11063 cmdline_fixed_string_t payload_cfg;
11067 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11070 const char *p, *p0 = q_arg;
11072 unsigned long int_fld;
11073 char *str_fld[max_num];
11078 p = strchr(p0, '(');
11082 p0 = strchr(p, ')');
11087 if (size >= sizeof(s))
11090 snprintf(s, sizeof(s), "%.*s", size, p);
11091 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11092 if (ret < 0 || ret > max_num)
11094 for (i = 0; i < ret; i++) {
11096 int_fld = strtoul(str_fld[i], &end, 0);
11097 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11099 offsets[i] = (uint16_t)int_fld;
11105 cmd_flow_director_flxpld_parsed(void *parsed_result,
11106 __attribute__((unused)) struct cmdline *cl,
11107 __attribute__((unused)) void *data)
11109 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11110 struct rte_eth_flex_payload_cfg flex_cfg;
11111 struct rte_port *port;
11114 if (res->port_id > nb_ports) {
11115 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
11119 port = &ports[res->port_id];
11120 /** Check if the port is not started **/
11121 if (port->port_status != RTE_PORT_STOPPED) {
11122 printf("Please stop port %d first\n", res->port_id);
11126 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11128 if (!strcmp(res->payload_layer, "raw"))
11129 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11130 else if (!strcmp(res->payload_layer, "l2"))
11131 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11132 else if (!strcmp(res->payload_layer, "l3"))
11133 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11134 else if (!strcmp(res->payload_layer, "l4"))
11135 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11137 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11138 RTE_ETH_FDIR_MAX_FLEXLEN);
11140 printf("error: Cannot parse flex payload input.\n");
11144 fdir_set_flex_payload(res->port_id, &flex_cfg);
11145 cmd_reconfig_device_queue(res->port_id, 1, 1);
11148 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11150 flow_director_flexpayload,
11151 "flow_director_flex_payload");
11152 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11153 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11155 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11156 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11157 payload_layer, "raw#l2#l3#l4");
11158 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11159 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11160 payload_cfg, NULL);
11162 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11163 .f = cmd_flow_director_flxpld_parsed,
11165 .help_str = "flow_director_flexpayload ... : "
11166 "Set flow director's flex payload on NIC",
11168 (void *)&cmd_flow_director_flexpayload,
11169 (void *)&cmd_flow_director_flexpayload_port_id,
11170 (void *)&cmd_flow_director_flexpayload_payload_layer,
11171 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11176 /* Generic flow interface command. */
11177 extern cmdline_parse_inst_t cmd_flow;
11179 /* *** Classification Filters Control *** */
11180 /* *** Get symmetric hash enable per port *** */
11181 struct cmd_get_sym_hash_ena_per_port_result {
11182 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11187 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11188 __rte_unused struct cmdline *cl,
11189 __rte_unused void *data)
11191 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11192 struct rte_eth_hash_filter_info info;
11195 if (rte_eth_dev_filter_supported(res->port_id,
11196 RTE_ETH_FILTER_HASH) < 0) {
11197 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11202 memset(&info, 0, sizeof(info));
11203 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11204 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11205 RTE_ETH_FILTER_GET, &info);
11208 printf("Cannot get symmetric hash enable per port "
11209 "on port %u\n", res->port_id);
11213 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11214 "enabled" : "disabled", res->port_id);
11217 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11218 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11219 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11220 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11221 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11224 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11225 .f = cmd_get_sym_hash_per_port_parsed,
11227 .help_str = "get_sym_hash_ena_per_port <port_id>",
11229 (void *)&cmd_get_sym_hash_ena_per_port_all,
11230 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11235 /* *** Set symmetric hash enable per port *** */
11236 struct cmd_set_sym_hash_ena_per_port_result {
11237 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11238 cmdline_fixed_string_t enable;
11243 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11244 __rte_unused struct cmdline *cl,
11245 __rte_unused void *data)
11247 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11248 struct rte_eth_hash_filter_info info;
11251 if (rte_eth_dev_filter_supported(res->port_id,
11252 RTE_ETH_FILTER_HASH) < 0) {
11253 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11258 memset(&info, 0, sizeof(info));
11259 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11260 if (!strcmp(res->enable, "enable"))
11261 info.info.enable = 1;
11262 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11263 RTE_ETH_FILTER_SET, &info);
11265 printf("Cannot set symmetric hash enable per port on "
11266 "port %u\n", res->port_id);
11269 printf("Symmetric hash has been set to %s on port %u\n",
11270 res->enable, res->port_id);
11273 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11274 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11275 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11276 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11277 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11279 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11280 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11281 enable, "enable#disable");
11283 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11284 .f = cmd_set_sym_hash_per_port_parsed,
11286 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11288 (void *)&cmd_set_sym_hash_ena_per_port_all,
11289 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11290 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11295 /* Get global config of hash function */
11296 struct cmd_get_hash_global_config_result {
11297 cmdline_fixed_string_t get_hash_global_config;
11302 flowtype_to_str(uint16_t ftype)
11308 } ftype_table[] = {
11309 {"ipv4", RTE_ETH_FLOW_IPV4},
11310 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11311 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11312 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11313 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11314 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11315 {"ipv6", RTE_ETH_FLOW_IPV6},
11316 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11317 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11318 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11319 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11320 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11321 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11322 {"port", RTE_ETH_FLOW_PORT},
11323 {"vxlan", RTE_ETH_FLOW_VXLAN},
11324 {"geneve", RTE_ETH_FLOW_GENEVE},
11325 {"nvgre", RTE_ETH_FLOW_NVGRE},
11328 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11329 if (ftype_table[i].ftype == ftype)
11330 return ftype_table[i].str;
11337 cmd_get_hash_global_config_parsed(void *parsed_result,
11338 __rte_unused struct cmdline *cl,
11339 __rte_unused void *data)
11341 struct cmd_get_hash_global_config_result *res = parsed_result;
11342 struct rte_eth_hash_filter_info info;
11343 uint32_t idx, offset;
11348 if (rte_eth_dev_filter_supported(res->port_id,
11349 RTE_ETH_FILTER_HASH) < 0) {
11350 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11355 memset(&info, 0, sizeof(info));
11356 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11357 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11358 RTE_ETH_FILTER_GET, &info);
11360 printf("Cannot get hash global configurations by port %d\n",
11365 switch (info.info.global_conf.hash_func) {
11366 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11367 printf("Hash function is Toeplitz\n");
11369 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11370 printf("Hash function is Simple XOR\n");
11373 printf("Unknown hash function\n");
11377 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11378 idx = i / UINT64_BIT;
11379 offset = i % UINT64_BIT;
11380 if (!(info.info.global_conf.valid_bit_mask[idx] &
11383 str = flowtype_to_str(i);
11386 printf("Symmetric hash is %s globally for flow type %s "
11388 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11389 (1ULL << offset)) ? "enabled" : "disabled"), str,
11394 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11395 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11396 get_hash_global_config, "get_hash_global_config");
11397 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11398 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11401 cmdline_parse_inst_t cmd_get_hash_global_config = {
11402 .f = cmd_get_hash_global_config_parsed,
11404 .help_str = "get_hash_global_config <port_id>",
11406 (void *)&cmd_get_hash_global_config_all,
11407 (void *)&cmd_get_hash_global_config_port_id,
11412 /* Set global config of hash function */
11413 struct cmd_set_hash_global_config_result {
11414 cmdline_fixed_string_t set_hash_global_config;
11416 cmdline_fixed_string_t hash_func;
11417 cmdline_fixed_string_t flow_type;
11418 cmdline_fixed_string_t enable;
11422 cmd_set_hash_global_config_parsed(void *parsed_result,
11423 __rte_unused struct cmdline *cl,
11424 __rte_unused void *data)
11426 struct cmd_set_hash_global_config_result *res = parsed_result;
11427 struct rte_eth_hash_filter_info info;
11428 uint32_t ftype, idx, offset;
11431 if (rte_eth_dev_filter_supported(res->port_id,
11432 RTE_ETH_FILTER_HASH) < 0) {
11433 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11437 memset(&info, 0, sizeof(info));
11438 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11439 if (!strcmp(res->hash_func, "toeplitz"))
11440 info.info.global_conf.hash_func =
11441 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11442 else if (!strcmp(res->hash_func, "simple_xor"))
11443 info.info.global_conf.hash_func =
11444 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11445 else if (!strcmp(res->hash_func, "default"))
11446 info.info.global_conf.hash_func =
11447 RTE_ETH_HASH_FUNCTION_DEFAULT;
11449 ftype = str2flowtype(res->flow_type);
11450 idx = ftype / UINT64_BIT;
11451 offset = ftype % UINT64_BIT;
11452 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11453 if (!strcmp(res->enable, "enable"))
11454 info.info.global_conf.sym_hash_enable_mask[idx] |=
11456 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11457 RTE_ETH_FILTER_SET, &info);
11459 printf("Cannot set global hash configurations by port %d\n",
11462 printf("Global hash configurations have been set "
11463 "succcessfully by port %d\n", res->port_id);
11466 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11467 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11468 set_hash_global_config, "set_hash_global_config");
11469 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11470 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11472 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11473 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11474 hash_func, "toeplitz#simple_xor#default");
11475 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11476 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11478 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11479 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11480 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11481 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11482 enable, "enable#disable");
11484 cmdline_parse_inst_t cmd_set_hash_global_config = {
11485 .f = cmd_set_hash_global_config_parsed,
11487 .help_str = "set_hash_global_config <port_id> "
11488 "toeplitz|simple_xor|default "
11489 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11490 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11491 "l2_payload enable|disable",
11493 (void *)&cmd_set_hash_global_config_all,
11494 (void *)&cmd_set_hash_global_config_port_id,
11495 (void *)&cmd_set_hash_global_config_hash_func,
11496 (void *)&cmd_set_hash_global_config_flow_type,
11497 (void *)&cmd_set_hash_global_config_enable,
11502 /* Set hash input set */
11503 struct cmd_set_hash_input_set_result {
11504 cmdline_fixed_string_t set_hash_input_set;
11506 cmdline_fixed_string_t flow_type;
11507 cmdline_fixed_string_t inset_field;
11508 cmdline_fixed_string_t select;
11511 static enum rte_eth_input_set_field
11512 str2inset(char *string)
11516 static const struct {
11518 enum rte_eth_input_set_field inset;
11519 } inset_table[] = {
11520 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11521 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11522 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11523 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11524 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11525 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11526 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11527 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11528 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11529 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11530 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11531 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11532 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11533 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11534 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11535 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11536 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11537 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11538 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11539 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11540 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11541 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11542 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11543 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11544 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11545 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11546 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11547 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11548 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11549 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11550 {"none", RTE_ETH_INPUT_SET_NONE},
11553 for (i = 0; i < RTE_DIM(inset_table); i++) {
11554 if (!strcmp(string, inset_table[i].str))
11555 return inset_table[i].inset;
11558 return RTE_ETH_INPUT_SET_UNKNOWN;
11562 cmd_set_hash_input_set_parsed(void *parsed_result,
11563 __rte_unused struct cmdline *cl,
11564 __rte_unused void *data)
11566 struct cmd_set_hash_input_set_result *res = parsed_result;
11567 struct rte_eth_hash_filter_info info;
11569 memset(&info, 0, sizeof(info));
11570 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11571 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11572 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11573 info.info.input_set_conf.inset_size = 1;
11574 if (!strcmp(res->select, "select"))
11575 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11576 else if (!strcmp(res->select, "add"))
11577 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11578 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11579 RTE_ETH_FILTER_SET, &info);
11582 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11583 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11584 set_hash_input_set, "set_hash_input_set");
11585 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11586 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11588 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11589 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11591 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11592 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11594 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11595 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11596 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11597 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11598 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11600 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11601 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11602 select, "select#add");
11604 cmdline_parse_inst_t cmd_set_hash_input_set = {
11605 .f = cmd_set_hash_input_set_parsed,
11607 .help_str = "set_hash_input_set <port_id> "
11608 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11609 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11610 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11611 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11612 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11613 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11614 "fld-7th|fld-8th|none select|add",
11616 (void *)&cmd_set_hash_input_set_cmd,
11617 (void *)&cmd_set_hash_input_set_port_id,
11618 (void *)&cmd_set_hash_input_set_flow_type,
11619 (void *)&cmd_set_hash_input_set_field,
11620 (void *)&cmd_set_hash_input_set_select,
11625 /* Set flow director input set */
11626 struct cmd_set_fdir_input_set_result {
11627 cmdline_fixed_string_t set_fdir_input_set;
11629 cmdline_fixed_string_t flow_type;
11630 cmdline_fixed_string_t inset_field;
11631 cmdline_fixed_string_t select;
11635 cmd_set_fdir_input_set_parsed(void *parsed_result,
11636 __rte_unused struct cmdline *cl,
11637 __rte_unused void *data)
11639 struct cmd_set_fdir_input_set_result *res = parsed_result;
11640 struct rte_eth_fdir_filter_info info;
11642 memset(&info, 0, sizeof(info));
11643 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11644 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11645 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11646 info.info.input_set_conf.inset_size = 1;
11647 if (!strcmp(res->select, "select"))
11648 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11649 else if (!strcmp(res->select, "add"))
11650 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11651 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11652 RTE_ETH_FILTER_SET, &info);
11655 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11656 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11657 set_fdir_input_set, "set_fdir_input_set");
11658 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11659 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11661 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11662 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11664 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11665 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11666 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11667 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11669 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11670 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11671 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11672 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11673 "sctp-veri-tag#none");
11674 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11675 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11676 select, "select#add");
11678 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11679 .f = cmd_set_fdir_input_set_parsed,
11681 .help_str = "set_fdir_input_set <port_id> "
11682 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11683 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11684 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11685 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11686 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11687 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11688 "sctp-veri-tag|none select|add",
11690 (void *)&cmd_set_fdir_input_set_cmd,
11691 (void *)&cmd_set_fdir_input_set_port_id,
11692 (void *)&cmd_set_fdir_input_set_flow_type,
11693 (void *)&cmd_set_fdir_input_set_field,
11694 (void *)&cmd_set_fdir_input_set_select,
11699 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11700 struct cmd_mcast_addr_result {
11701 cmdline_fixed_string_t mcast_addr_cmd;
11702 cmdline_fixed_string_t what;
11704 struct ether_addr mc_addr;
11707 static void cmd_mcast_addr_parsed(void *parsed_result,
11708 __attribute__((unused)) struct cmdline *cl,
11709 __attribute__((unused)) void *data)
11711 struct cmd_mcast_addr_result *res = parsed_result;
11713 if (!is_multicast_ether_addr(&res->mc_addr)) {
11714 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11715 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11716 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11717 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11720 if (strcmp(res->what, "add") == 0)
11721 mcast_addr_add(res->port_num, &res->mc_addr);
11723 mcast_addr_remove(res->port_num, &res->mc_addr);
11726 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11727 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11728 mcast_addr_cmd, "mcast_addr");
11729 cmdline_parse_token_string_t cmd_mcast_addr_what =
11730 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11732 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11733 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11734 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11735 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11737 cmdline_parse_inst_t cmd_mcast_addr = {
11738 .f = cmd_mcast_addr_parsed,
11740 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11741 "Add/Remove multicast MAC address on port_id",
11743 (void *)&cmd_mcast_addr_cmd,
11744 (void *)&cmd_mcast_addr_what,
11745 (void *)&cmd_mcast_addr_portnum,
11746 (void *)&cmd_mcast_addr_addr,
11751 /* l2 tunnel config
11752 * only support E-tag now.
11755 /* Ether type config */
11756 struct cmd_config_l2_tunnel_eth_type_result {
11757 cmdline_fixed_string_t port;
11758 cmdline_fixed_string_t config;
11759 cmdline_fixed_string_t all;
11761 cmdline_fixed_string_t l2_tunnel;
11762 cmdline_fixed_string_t l2_tunnel_type;
11763 cmdline_fixed_string_t eth_type;
11764 uint16_t eth_type_val;
11767 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11768 TOKEN_STRING_INITIALIZER
11769 (struct cmd_config_l2_tunnel_eth_type_result,
11771 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11772 TOKEN_STRING_INITIALIZER
11773 (struct cmd_config_l2_tunnel_eth_type_result,
11775 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11776 TOKEN_STRING_INITIALIZER
11777 (struct cmd_config_l2_tunnel_eth_type_result,
11779 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11780 TOKEN_NUM_INITIALIZER
11781 (struct cmd_config_l2_tunnel_eth_type_result,
11783 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11784 TOKEN_STRING_INITIALIZER
11785 (struct cmd_config_l2_tunnel_eth_type_result,
11786 l2_tunnel, "l2-tunnel");
11787 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11788 TOKEN_STRING_INITIALIZER
11789 (struct cmd_config_l2_tunnel_eth_type_result,
11790 l2_tunnel_type, "E-tag");
11791 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11792 TOKEN_STRING_INITIALIZER
11793 (struct cmd_config_l2_tunnel_eth_type_result,
11794 eth_type, "ether-type");
11795 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11796 TOKEN_NUM_INITIALIZER
11797 (struct cmd_config_l2_tunnel_eth_type_result,
11798 eth_type_val, UINT16);
11800 static enum rte_eth_tunnel_type
11801 str2fdir_l2_tunnel_type(char *string)
11805 static const struct {
11807 enum rte_eth_tunnel_type type;
11808 } l2_tunnel_type_str[] = {
11809 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11812 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11813 if (!strcmp(l2_tunnel_type_str[i].str, string))
11814 return l2_tunnel_type_str[i].type;
11816 return RTE_TUNNEL_TYPE_NONE;
11819 /* ether type config for all ports */
11821 cmd_config_l2_tunnel_eth_type_all_parsed
11822 (void *parsed_result,
11823 __attribute__((unused)) struct cmdline *cl,
11824 __attribute__((unused)) void *data)
11826 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11827 struct rte_eth_l2_tunnel_conf entry;
11830 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11831 entry.ether_type = res->eth_type_val;
11833 RTE_ETH_FOREACH_DEV(pid) {
11834 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11838 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11839 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11841 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11843 (void *)&cmd_config_l2_tunnel_eth_type_port,
11844 (void *)&cmd_config_l2_tunnel_eth_type_config,
11845 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11846 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11847 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11848 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11849 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11854 /* ether type config for a specific port */
11856 cmd_config_l2_tunnel_eth_type_specific_parsed(
11857 void *parsed_result,
11858 __attribute__((unused)) struct cmdline *cl,
11859 __attribute__((unused)) void *data)
11861 struct cmd_config_l2_tunnel_eth_type_result *res =
11863 struct rte_eth_l2_tunnel_conf entry;
11865 if (port_id_is_invalid(res->id, ENABLED_WARN))
11868 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11869 entry.ether_type = res->eth_type_val;
11871 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11874 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11875 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11877 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11879 (void *)&cmd_config_l2_tunnel_eth_type_port,
11880 (void *)&cmd_config_l2_tunnel_eth_type_config,
11881 (void *)&cmd_config_l2_tunnel_eth_type_id,
11882 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11883 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11884 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11885 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11890 /* Enable/disable l2 tunnel */
11891 struct cmd_config_l2_tunnel_en_dis_result {
11892 cmdline_fixed_string_t port;
11893 cmdline_fixed_string_t config;
11894 cmdline_fixed_string_t all;
11896 cmdline_fixed_string_t l2_tunnel;
11897 cmdline_fixed_string_t l2_tunnel_type;
11898 cmdline_fixed_string_t en_dis;
11901 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11902 TOKEN_STRING_INITIALIZER
11903 (struct cmd_config_l2_tunnel_en_dis_result,
11905 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11906 TOKEN_STRING_INITIALIZER
11907 (struct cmd_config_l2_tunnel_en_dis_result,
11909 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11910 TOKEN_STRING_INITIALIZER
11911 (struct cmd_config_l2_tunnel_en_dis_result,
11913 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11914 TOKEN_NUM_INITIALIZER
11915 (struct cmd_config_l2_tunnel_en_dis_result,
11917 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11918 TOKEN_STRING_INITIALIZER
11919 (struct cmd_config_l2_tunnel_en_dis_result,
11920 l2_tunnel, "l2-tunnel");
11921 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11922 TOKEN_STRING_INITIALIZER
11923 (struct cmd_config_l2_tunnel_en_dis_result,
11924 l2_tunnel_type, "E-tag");
11925 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11926 TOKEN_STRING_INITIALIZER
11927 (struct cmd_config_l2_tunnel_en_dis_result,
11928 en_dis, "enable#disable");
11930 /* enable/disable l2 tunnel for all ports */
11932 cmd_config_l2_tunnel_en_dis_all_parsed(
11933 void *parsed_result,
11934 __attribute__((unused)) struct cmdline *cl,
11935 __attribute__((unused)) void *data)
11937 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11938 struct rte_eth_l2_tunnel_conf entry;
11942 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11944 if (!strcmp("enable", res->en_dis))
11949 RTE_ETH_FOREACH_DEV(pid) {
11950 rte_eth_dev_l2_tunnel_offload_set(pid,
11952 ETH_L2_TUNNEL_ENABLE_MASK,
11957 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11958 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11960 .help_str = "port config all l2-tunnel E-tag enable|disable",
11962 (void *)&cmd_config_l2_tunnel_en_dis_port,
11963 (void *)&cmd_config_l2_tunnel_en_dis_config,
11964 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11965 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11966 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11967 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11972 /* enable/disable l2 tunnel for a port */
11974 cmd_config_l2_tunnel_en_dis_specific_parsed(
11975 void *parsed_result,
11976 __attribute__((unused)) struct cmdline *cl,
11977 __attribute__((unused)) void *data)
11979 struct cmd_config_l2_tunnel_en_dis_result *res =
11981 struct rte_eth_l2_tunnel_conf entry;
11983 if (port_id_is_invalid(res->id, ENABLED_WARN))
11986 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11988 if (!strcmp("enable", res->en_dis))
11989 rte_eth_dev_l2_tunnel_offload_set(res->id,
11991 ETH_L2_TUNNEL_ENABLE_MASK,
11994 rte_eth_dev_l2_tunnel_offload_set(res->id,
11996 ETH_L2_TUNNEL_ENABLE_MASK,
12000 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12001 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12003 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12005 (void *)&cmd_config_l2_tunnel_en_dis_port,
12006 (void *)&cmd_config_l2_tunnel_en_dis_config,
12007 (void *)&cmd_config_l2_tunnel_en_dis_id,
12008 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12009 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12010 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12015 /* E-tag configuration */
12017 /* Common result structure for all E-tag configuration */
12018 struct cmd_config_e_tag_result {
12019 cmdline_fixed_string_t e_tag;
12020 cmdline_fixed_string_t set;
12021 cmdline_fixed_string_t insertion;
12022 cmdline_fixed_string_t stripping;
12023 cmdline_fixed_string_t forwarding;
12024 cmdline_fixed_string_t filter;
12025 cmdline_fixed_string_t add;
12026 cmdline_fixed_string_t del;
12027 cmdline_fixed_string_t on;
12028 cmdline_fixed_string_t off;
12029 cmdline_fixed_string_t on_off;
12030 cmdline_fixed_string_t port_tag_id;
12031 uint32_t port_tag_id_val;
12032 cmdline_fixed_string_t e_tag_id;
12033 uint16_t e_tag_id_val;
12034 cmdline_fixed_string_t dst_pool;
12035 uint8_t dst_pool_val;
12036 cmdline_fixed_string_t port;
12038 cmdline_fixed_string_t vf;
12042 /* Common CLI fields for all E-tag configuration */
12043 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12044 TOKEN_STRING_INITIALIZER
12045 (struct cmd_config_e_tag_result,
12047 cmdline_parse_token_string_t cmd_config_e_tag_set =
12048 TOKEN_STRING_INITIALIZER
12049 (struct cmd_config_e_tag_result,
12051 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12052 TOKEN_STRING_INITIALIZER
12053 (struct cmd_config_e_tag_result,
12054 insertion, "insertion");
12055 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12056 TOKEN_STRING_INITIALIZER
12057 (struct cmd_config_e_tag_result,
12058 stripping, "stripping");
12059 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12060 TOKEN_STRING_INITIALIZER
12061 (struct cmd_config_e_tag_result,
12062 forwarding, "forwarding");
12063 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12064 TOKEN_STRING_INITIALIZER
12065 (struct cmd_config_e_tag_result,
12067 cmdline_parse_token_string_t cmd_config_e_tag_add =
12068 TOKEN_STRING_INITIALIZER
12069 (struct cmd_config_e_tag_result,
12071 cmdline_parse_token_string_t cmd_config_e_tag_del =
12072 TOKEN_STRING_INITIALIZER
12073 (struct cmd_config_e_tag_result,
12075 cmdline_parse_token_string_t cmd_config_e_tag_on =
12076 TOKEN_STRING_INITIALIZER
12077 (struct cmd_config_e_tag_result,
12079 cmdline_parse_token_string_t cmd_config_e_tag_off =
12080 TOKEN_STRING_INITIALIZER
12081 (struct cmd_config_e_tag_result,
12083 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12084 TOKEN_STRING_INITIALIZER
12085 (struct cmd_config_e_tag_result,
12087 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12088 TOKEN_STRING_INITIALIZER
12089 (struct cmd_config_e_tag_result,
12090 port_tag_id, "port-tag-id");
12091 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12092 TOKEN_NUM_INITIALIZER
12093 (struct cmd_config_e_tag_result,
12094 port_tag_id_val, UINT32);
12095 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12096 TOKEN_STRING_INITIALIZER
12097 (struct cmd_config_e_tag_result,
12098 e_tag_id, "e-tag-id");
12099 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12100 TOKEN_NUM_INITIALIZER
12101 (struct cmd_config_e_tag_result,
12102 e_tag_id_val, UINT16);
12103 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12104 TOKEN_STRING_INITIALIZER
12105 (struct cmd_config_e_tag_result,
12106 dst_pool, "dst-pool");
12107 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12108 TOKEN_NUM_INITIALIZER
12109 (struct cmd_config_e_tag_result,
12110 dst_pool_val, UINT8);
12111 cmdline_parse_token_string_t cmd_config_e_tag_port =
12112 TOKEN_STRING_INITIALIZER
12113 (struct cmd_config_e_tag_result,
12115 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12116 TOKEN_NUM_INITIALIZER
12117 (struct cmd_config_e_tag_result,
12119 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12120 TOKEN_STRING_INITIALIZER
12121 (struct cmd_config_e_tag_result,
12123 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12124 TOKEN_NUM_INITIALIZER
12125 (struct cmd_config_e_tag_result,
12128 /* E-tag insertion configuration */
12130 cmd_config_e_tag_insertion_en_parsed(
12131 void *parsed_result,
12132 __attribute__((unused)) struct cmdline *cl,
12133 __attribute__((unused)) void *data)
12135 struct cmd_config_e_tag_result *res =
12137 struct rte_eth_l2_tunnel_conf entry;
12139 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12142 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12143 entry.tunnel_id = res->port_tag_id_val;
12144 entry.vf_id = res->vf_id;
12145 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12147 ETH_L2_TUNNEL_INSERTION_MASK,
12152 cmd_config_e_tag_insertion_dis_parsed(
12153 void *parsed_result,
12154 __attribute__((unused)) struct cmdline *cl,
12155 __attribute__((unused)) void *data)
12157 struct cmd_config_e_tag_result *res =
12159 struct rte_eth_l2_tunnel_conf entry;
12161 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12164 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12165 entry.vf_id = res->vf_id;
12167 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12169 ETH_L2_TUNNEL_INSERTION_MASK,
12173 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12174 .f = cmd_config_e_tag_insertion_en_parsed,
12176 .help_str = "E-tag ... : E-tag insertion enable",
12178 (void *)&cmd_config_e_tag_e_tag,
12179 (void *)&cmd_config_e_tag_set,
12180 (void *)&cmd_config_e_tag_insertion,
12181 (void *)&cmd_config_e_tag_on,
12182 (void *)&cmd_config_e_tag_port_tag_id,
12183 (void *)&cmd_config_e_tag_port_tag_id_val,
12184 (void *)&cmd_config_e_tag_port,
12185 (void *)&cmd_config_e_tag_port_id,
12186 (void *)&cmd_config_e_tag_vf,
12187 (void *)&cmd_config_e_tag_vf_id,
12192 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12193 .f = cmd_config_e_tag_insertion_dis_parsed,
12195 .help_str = "E-tag ... : E-tag insertion disable",
12197 (void *)&cmd_config_e_tag_e_tag,
12198 (void *)&cmd_config_e_tag_set,
12199 (void *)&cmd_config_e_tag_insertion,
12200 (void *)&cmd_config_e_tag_off,
12201 (void *)&cmd_config_e_tag_port,
12202 (void *)&cmd_config_e_tag_port_id,
12203 (void *)&cmd_config_e_tag_vf,
12204 (void *)&cmd_config_e_tag_vf_id,
12209 /* E-tag stripping configuration */
12211 cmd_config_e_tag_stripping_parsed(
12212 void *parsed_result,
12213 __attribute__((unused)) struct cmdline *cl,
12214 __attribute__((unused)) void *data)
12216 struct cmd_config_e_tag_result *res =
12218 struct rte_eth_l2_tunnel_conf entry;
12220 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12223 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12225 if (!strcmp(res->on_off, "on"))
12226 rte_eth_dev_l2_tunnel_offload_set
12229 ETH_L2_TUNNEL_STRIPPING_MASK,
12232 rte_eth_dev_l2_tunnel_offload_set
12235 ETH_L2_TUNNEL_STRIPPING_MASK,
12239 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12240 .f = cmd_config_e_tag_stripping_parsed,
12242 .help_str = "E-tag ... : E-tag stripping enable/disable",
12244 (void *)&cmd_config_e_tag_e_tag,
12245 (void *)&cmd_config_e_tag_set,
12246 (void *)&cmd_config_e_tag_stripping,
12247 (void *)&cmd_config_e_tag_on_off,
12248 (void *)&cmd_config_e_tag_port,
12249 (void *)&cmd_config_e_tag_port_id,
12254 /* E-tag forwarding configuration */
12256 cmd_config_e_tag_forwarding_parsed(
12257 void *parsed_result,
12258 __attribute__((unused)) struct cmdline *cl,
12259 __attribute__((unused)) void *data)
12261 struct cmd_config_e_tag_result *res = parsed_result;
12262 struct rte_eth_l2_tunnel_conf entry;
12264 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12267 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12269 if (!strcmp(res->on_off, "on"))
12270 rte_eth_dev_l2_tunnel_offload_set
12273 ETH_L2_TUNNEL_FORWARDING_MASK,
12276 rte_eth_dev_l2_tunnel_offload_set
12279 ETH_L2_TUNNEL_FORWARDING_MASK,
12283 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12284 .f = cmd_config_e_tag_forwarding_parsed,
12286 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12288 (void *)&cmd_config_e_tag_e_tag,
12289 (void *)&cmd_config_e_tag_set,
12290 (void *)&cmd_config_e_tag_forwarding,
12291 (void *)&cmd_config_e_tag_on_off,
12292 (void *)&cmd_config_e_tag_port,
12293 (void *)&cmd_config_e_tag_port_id,
12298 /* E-tag filter configuration */
12300 cmd_config_e_tag_filter_add_parsed(
12301 void *parsed_result,
12302 __attribute__((unused)) struct cmdline *cl,
12303 __attribute__((unused)) void *data)
12305 struct cmd_config_e_tag_result *res = parsed_result;
12306 struct rte_eth_l2_tunnel_conf entry;
12309 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12312 if (res->e_tag_id_val > 0x3fff) {
12313 printf("e-tag-id must be equal or less than 0x3fff.\n");
12317 ret = rte_eth_dev_filter_supported(res->port_id,
12318 RTE_ETH_FILTER_L2_TUNNEL);
12320 printf("E-tag filter is not supported on port %u.\n",
12325 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12326 entry.tunnel_id = res->e_tag_id_val;
12327 entry.pool = res->dst_pool_val;
12329 ret = rte_eth_dev_filter_ctrl(res->port_id,
12330 RTE_ETH_FILTER_L2_TUNNEL,
12331 RTE_ETH_FILTER_ADD,
12334 printf("E-tag filter programming error: (%s)\n",
12338 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12339 .f = cmd_config_e_tag_filter_add_parsed,
12341 .help_str = "E-tag ... : E-tag filter add",
12343 (void *)&cmd_config_e_tag_e_tag,
12344 (void *)&cmd_config_e_tag_set,
12345 (void *)&cmd_config_e_tag_filter,
12346 (void *)&cmd_config_e_tag_add,
12347 (void *)&cmd_config_e_tag_e_tag_id,
12348 (void *)&cmd_config_e_tag_e_tag_id_val,
12349 (void *)&cmd_config_e_tag_dst_pool,
12350 (void *)&cmd_config_e_tag_dst_pool_val,
12351 (void *)&cmd_config_e_tag_port,
12352 (void *)&cmd_config_e_tag_port_id,
12358 cmd_config_e_tag_filter_del_parsed(
12359 void *parsed_result,
12360 __attribute__((unused)) struct cmdline *cl,
12361 __attribute__((unused)) void *data)
12363 struct cmd_config_e_tag_result *res = parsed_result;
12364 struct rte_eth_l2_tunnel_conf entry;
12367 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12370 if (res->e_tag_id_val > 0x3fff) {
12371 printf("e-tag-id must be less than 0x3fff.\n");
12375 ret = rte_eth_dev_filter_supported(res->port_id,
12376 RTE_ETH_FILTER_L2_TUNNEL);
12378 printf("E-tag filter is not supported on port %u.\n",
12383 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12384 entry.tunnel_id = res->e_tag_id_val;
12386 ret = rte_eth_dev_filter_ctrl(res->port_id,
12387 RTE_ETH_FILTER_L2_TUNNEL,
12388 RTE_ETH_FILTER_DELETE,
12391 printf("E-tag filter programming error: (%s)\n",
12395 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12396 .f = cmd_config_e_tag_filter_del_parsed,
12398 .help_str = "E-tag ... : E-tag filter delete",
12400 (void *)&cmd_config_e_tag_e_tag,
12401 (void *)&cmd_config_e_tag_set,
12402 (void *)&cmd_config_e_tag_filter,
12403 (void *)&cmd_config_e_tag_del,
12404 (void *)&cmd_config_e_tag_e_tag_id,
12405 (void *)&cmd_config_e_tag_e_tag_id_val,
12406 (void *)&cmd_config_e_tag_port,
12407 (void *)&cmd_config_e_tag_port_id,
12412 /* vf vlan anti spoof configuration */
12414 /* Common result structure for vf vlan anti spoof */
12415 struct cmd_vf_vlan_anti_spoof_result {
12416 cmdline_fixed_string_t set;
12417 cmdline_fixed_string_t vf;
12418 cmdline_fixed_string_t vlan;
12419 cmdline_fixed_string_t antispoof;
12422 cmdline_fixed_string_t on_off;
12425 /* Common CLI fields for vf vlan anti spoof enable disable */
12426 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12427 TOKEN_STRING_INITIALIZER
12428 (struct cmd_vf_vlan_anti_spoof_result,
12430 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12431 TOKEN_STRING_INITIALIZER
12432 (struct cmd_vf_vlan_anti_spoof_result,
12434 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12435 TOKEN_STRING_INITIALIZER
12436 (struct cmd_vf_vlan_anti_spoof_result,
12438 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12439 TOKEN_STRING_INITIALIZER
12440 (struct cmd_vf_vlan_anti_spoof_result,
12441 antispoof, "antispoof");
12442 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12443 TOKEN_NUM_INITIALIZER
12444 (struct cmd_vf_vlan_anti_spoof_result,
12446 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12447 TOKEN_NUM_INITIALIZER
12448 (struct cmd_vf_vlan_anti_spoof_result,
12450 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12451 TOKEN_STRING_INITIALIZER
12452 (struct cmd_vf_vlan_anti_spoof_result,
12456 cmd_set_vf_vlan_anti_spoof_parsed(
12457 void *parsed_result,
12458 __attribute__((unused)) struct cmdline *cl,
12459 __attribute__((unused)) void *data)
12461 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12462 int ret = -ENOTSUP;
12464 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12466 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12469 #ifdef RTE_LIBRTE_IXGBE_PMD
12470 if (ret == -ENOTSUP)
12471 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12472 res->vf_id, is_on);
12474 #ifdef RTE_LIBRTE_I40E_PMD
12475 if (ret == -ENOTSUP)
12476 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12477 res->vf_id, is_on);
12479 #ifdef RTE_LIBRTE_BNXT_PMD
12480 if (ret == -ENOTSUP)
12481 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12482 res->vf_id, is_on);
12489 printf("invalid vf_id %d\n", res->vf_id);
12492 printf("invalid port_id %d\n", res->port_id);
12495 printf("function not implemented\n");
12498 printf("programming error: (%s)\n", strerror(-ret));
12502 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12503 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12505 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12507 (void *)&cmd_vf_vlan_anti_spoof_set,
12508 (void *)&cmd_vf_vlan_anti_spoof_vf,
12509 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12510 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12511 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12512 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12513 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12518 /* vf mac anti spoof configuration */
12520 /* Common result structure for vf mac anti spoof */
12521 struct cmd_vf_mac_anti_spoof_result {
12522 cmdline_fixed_string_t set;
12523 cmdline_fixed_string_t vf;
12524 cmdline_fixed_string_t mac;
12525 cmdline_fixed_string_t antispoof;
12528 cmdline_fixed_string_t on_off;
12531 /* Common CLI fields for vf mac anti spoof enable disable */
12532 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12533 TOKEN_STRING_INITIALIZER
12534 (struct cmd_vf_mac_anti_spoof_result,
12536 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12537 TOKEN_STRING_INITIALIZER
12538 (struct cmd_vf_mac_anti_spoof_result,
12540 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12541 TOKEN_STRING_INITIALIZER
12542 (struct cmd_vf_mac_anti_spoof_result,
12544 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12545 TOKEN_STRING_INITIALIZER
12546 (struct cmd_vf_mac_anti_spoof_result,
12547 antispoof, "antispoof");
12548 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12549 TOKEN_NUM_INITIALIZER
12550 (struct cmd_vf_mac_anti_spoof_result,
12552 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12553 TOKEN_NUM_INITIALIZER
12554 (struct cmd_vf_mac_anti_spoof_result,
12556 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12557 TOKEN_STRING_INITIALIZER
12558 (struct cmd_vf_mac_anti_spoof_result,
12562 cmd_set_vf_mac_anti_spoof_parsed(
12563 void *parsed_result,
12564 __attribute__((unused)) struct cmdline *cl,
12565 __attribute__((unused)) void *data)
12567 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12568 int ret = -ENOTSUP;
12570 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12572 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12575 #ifdef RTE_LIBRTE_IXGBE_PMD
12576 if (ret == -ENOTSUP)
12577 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12578 res->vf_id, is_on);
12580 #ifdef RTE_LIBRTE_I40E_PMD
12581 if (ret == -ENOTSUP)
12582 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12583 res->vf_id, is_on);
12585 #ifdef RTE_LIBRTE_BNXT_PMD
12586 if (ret == -ENOTSUP)
12587 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12588 res->vf_id, is_on);
12595 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12598 printf("invalid port_id %d\n", res->port_id);
12601 printf("function not implemented\n");
12604 printf("programming error: (%s)\n", strerror(-ret));
12608 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12609 .f = cmd_set_vf_mac_anti_spoof_parsed,
12611 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12613 (void *)&cmd_vf_mac_anti_spoof_set,
12614 (void *)&cmd_vf_mac_anti_spoof_vf,
12615 (void *)&cmd_vf_mac_anti_spoof_mac,
12616 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12617 (void *)&cmd_vf_mac_anti_spoof_port_id,
12618 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12619 (void *)&cmd_vf_mac_anti_spoof_on_off,
12624 /* vf vlan strip queue configuration */
12626 /* Common result structure for vf mac anti spoof */
12627 struct cmd_vf_vlan_stripq_result {
12628 cmdline_fixed_string_t set;
12629 cmdline_fixed_string_t vf;
12630 cmdline_fixed_string_t vlan;
12631 cmdline_fixed_string_t stripq;
12634 cmdline_fixed_string_t on_off;
12637 /* Common CLI fields for vf vlan strip enable disable */
12638 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12639 TOKEN_STRING_INITIALIZER
12640 (struct cmd_vf_vlan_stripq_result,
12642 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12643 TOKEN_STRING_INITIALIZER
12644 (struct cmd_vf_vlan_stripq_result,
12646 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12647 TOKEN_STRING_INITIALIZER
12648 (struct cmd_vf_vlan_stripq_result,
12650 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12651 TOKEN_STRING_INITIALIZER
12652 (struct cmd_vf_vlan_stripq_result,
12654 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12655 TOKEN_NUM_INITIALIZER
12656 (struct cmd_vf_vlan_stripq_result,
12658 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12659 TOKEN_NUM_INITIALIZER
12660 (struct cmd_vf_vlan_stripq_result,
12662 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12663 TOKEN_STRING_INITIALIZER
12664 (struct cmd_vf_vlan_stripq_result,
12668 cmd_set_vf_vlan_stripq_parsed(
12669 void *parsed_result,
12670 __attribute__((unused)) struct cmdline *cl,
12671 __attribute__((unused)) void *data)
12673 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12674 int ret = -ENOTSUP;
12676 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12678 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12681 #ifdef RTE_LIBRTE_IXGBE_PMD
12682 if (ret == -ENOTSUP)
12683 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12684 res->vf_id, is_on);
12686 #ifdef RTE_LIBRTE_I40E_PMD
12687 if (ret == -ENOTSUP)
12688 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12689 res->vf_id, is_on);
12691 #ifdef RTE_LIBRTE_BNXT_PMD
12692 if (ret == -ENOTSUP)
12693 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12694 res->vf_id, is_on);
12701 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12704 printf("invalid port_id %d\n", res->port_id);
12707 printf("function not implemented\n");
12710 printf("programming error: (%s)\n", strerror(-ret));
12714 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12715 .f = cmd_set_vf_vlan_stripq_parsed,
12717 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12719 (void *)&cmd_vf_vlan_stripq_set,
12720 (void *)&cmd_vf_vlan_stripq_vf,
12721 (void *)&cmd_vf_vlan_stripq_vlan,
12722 (void *)&cmd_vf_vlan_stripq_stripq,
12723 (void *)&cmd_vf_vlan_stripq_port_id,
12724 (void *)&cmd_vf_vlan_stripq_vf_id,
12725 (void *)&cmd_vf_vlan_stripq_on_off,
12730 /* vf vlan insert configuration */
12732 /* Common result structure for vf vlan insert */
12733 struct cmd_vf_vlan_insert_result {
12734 cmdline_fixed_string_t set;
12735 cmdline_fixed_string_t vf;
12736 cmdline_fixed_string_t vlan;
12737 cmdline_fixed_string_t insert;
12743 /* Common CLI fields for vf vlan insert enable disable */
12744 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12745 TOKEN_STRING_INITIALIZER
12746 (struct cmd_vf_vlan_insert_result,
12748 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12749 TOKEN_STRING_INITIALIZER
12750 (struct cmd_vf_vlan_insert_result,
12752 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12753 TOKEN_STRING_INITIALIZER
12754 (struct cmd_vf_vlan_insert_result,
12756 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12757 TOKEN_STRING_INITIALIZER
12758 (struct cmd_vf_vlan_insert_result,
12760 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12761 TOKEN_NUM_INITIALIZER
12762 (struct cmd_vf_vlan_insert_result,
12764 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12765 TOKEN_NUM_INITIALIZER
12766 (struct cmd_vf_vlan_insert_result,
12768 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12769 TOKEN_NUM_INITIALIZER
12770 (struct cmd_vf_vlan_insert_result,
12774 cmd_set_vf_vlan_insert_parsed(
12775 void *parsed_result,
12776 __attribute__((unused)) struct cmdline *cl,
12777 __attribute__((unused)) void *data)
12779 struct cmd_vf_vlan_insert_result *res = parsed_result;
12780 int ret = -ENOTSUP;
12782 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12785 #ifdef RTE_LIBRTE_IXGBE_PMD
12786 if (ret == -ENOTSUP)
12787 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12790 #ifdef RTE_LIBRTE_I40E_PMD
12791 if (ret == -ENOTSUP)
12792 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12795 #ifdef RTE_LIBRTE_BNXT_PMD
12796 if (ret == -ENOTSUP)
12797 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12805 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12808 printf("invalid port_id %d\n", res->port_id);
12811 printf("function not implemented\n");
12814 printf("programming error: (%s)\n", strerror(-ret));
12818 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12819 .f = cmd_set_vf_vlan_insert_parsed,
12821 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12823 (void *)&cmd_vf_vlan_insert_set,
12824 (void *)&cmd_vf_vlan_insert_vf,
12825 (void *)&cmd_vf_vlan_insert_vlan,
12826 (void *)&cmd_vf_vlan_insert_insert,
12827 (void *)&cmd_vf_vlan_insert_port_id,
12828 (void *)&cmd_vf_vlan_insert_vf_id,
12829 (void *)&cmd_vf_vlan_insert_vlan_id,
12834 /* tx loopback configuration */
12836 /* Common result structure for tx loopback */
12837 struct cmd_tx_loopback_result {
12838 cmdline_fixed_string_t set;
12839 cmdline_fixed_string_t tx;
12840 cmdline_fixed_string_t loopback;
12842 cmdline_fixed_string_t on_off;
12845 /* Common CLI fields for tx loopback enable disable */
12846 cmdline_parse_token_string_t cmd_tx_loopback_set =
12847 TOKEN_STRING_INITIALIZER
12848 (struct cmd_tx_loopback_result,
12850 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12851 TOKEN_STRING_INITIALIZER
12852 (struct cmd_tx_loopback_result,
12854 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12855 TOKEN_STRING_INITIALIZER
12856 (struct cmd_tx_loopback_result,
12857 loopback, "loopback");
12858 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12859 TOKEN_NUM_INITIALIZER
12860 (struct cmd_tx_loopback_result,
12862 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12863 TOKEN_STRING_INITIALIZER
12864 (struct cmd_tx_loopback_result,
12868 cmd_set_tx_loopback_parsed(
12869 void *parsed_result,
12870 __attribute__((unused)) struct cmdline *cl,
12871 __attribute__((unused)) void *data)
12873 struct cmd_tx_loopback_result *res = parsed_result;
12874 int ret = -ENOTSUP;
12876 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12878 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12881 #ifdef RTE_LIBRTE_IXGBE_PMD
12882 if (ret == -ENOTSUP)
12883 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12885 #ifdef RTE_LIBRTE_I40E_PMD
12886 if (ret == -ENOTSUP)
12887 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12889 #ifdef RTE_LIBRTE_BNXT_PMD
12890 if (ret == -ENOTSUP)
12891 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12893 #ifdef RTE_LIBRTE_DPAA_PMD
12894 if (ret == -ENOTSUP)
12895 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
12902 printf("invalid is_on %d\n", is_on);
12905 printf("invalid port_id %d\n", res->port_id);
12908 printf("function not implemented\n");
12911 printf("programming error: (%s)\n", strerror(-ret));
12915 cmdline_parse_inst_t cmd_set_tx_loopback = {
12916 .f = cmd_set_tx_loopback_parsed,
12918 .help_str = "set tx loopback <port_id> on|off",
12920 (void *)&cmd_tx_loopback_set,
12921 (void *)&cmd_tx_loopback_tx,
12922 (void *)&cmd_tx_loopback_loopback,
12923 (void *)&cmd_tx_loopback_port_id,
12924 (void *)&cmd_tx_loopback_on_off,
12929 /* all queues drop enable configuration */
12931 /* Common result structure for all queues drop enable */
12932 struct cmd_all_queues_drop_en_result {
12933 cmdline_fixed_string_t set;
12934 cmdline_fixed_string_t all;
12935 cmdline_fixed_string_t queues;
12936 cmdline_fixed_string_t drop;
12938 cmdline_fixed_string_t on_off;
12941 /* Common CLI fields for tx loopback enable disable */
12942 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12943 TOKEN_STRING_INITIALIZER
12944 (struct cmd_all_queues_drop_en_result,
12946 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12947 TOKEN_STRING_INITIALIZER
12948 (struct cmd_all_queues_drop_en_result,
12950 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12951 TOKEN_STRING_INITIALIZER
12952 (struct cmd_all_queues_drop_en_result,
12954 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12955 TOKEN_STRING_INITIALIZER
12956 (struct cmd_all_queues_drop_en_result,
12958 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12959 TOKEN_NUM_INITIALIZER
12960 (struct cmd_all_queues_drop_en_result,
12962 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12963 TOKEN_STRING_INITIALIZER
12964 (struct cmd_all_queues_drop_en_result,
12968 cmd_set_all_queues_drop_en_parsed(
12969 void *parsed_result,
12970 __attribute__((unused)) struct cmdline *cl,
12971 __attribute__((unused)) void *data)
12973 struct cmd_all_queues_drop_en_result *res = parsed_result;
12974 int ret = -ENOTSUP;
12975 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12977 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12980 #ifdef RTE_LIBRTE_IXGBE_PMD
12981 if (ret == -ENOTSUP)
12982 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12984 #ifdef RTE_LIBRTE_BNXT_PMD
12985 if (ret == -ENOTSUP)
12986 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12992 printf("invalid is_on %d\n", is_on);
12995 printf("invalid port_id %d\n", res->port_id);
12998 printf("function not implemented\n");
13001 printf("programming error: (%s)\n", strerror(-ret));
13005 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13006 .f = cmd_set_all_queues_drop_en_parsed,
13008 .help_str = "set all queues drop <port_id> on|off",
13010 (void *)&cmd_all_queues_drop_en_set,
13011 (void *)&cmd_all_queues_drop_en_all,
13012 (void *)&cmd_all_queues_drop_en_queues,
13013 (void *)&cmd_all_queues_drop_en_drop,
13014 (void *)&cmd_all_queues_drop_en_port_id,
13015 (void *)&cmd_all_queues_drop_en_on_off,
13020 /* vf split drop enable configuration */
13022 /* Common result structure for vf split drop enable */
13023 struct cmd_vf_split_drop_en_result {
13024 cmdline_fixed_string_t set;
13025 cmdline_fixed_string_t vf;
13026 cmdline_fixed_string_t split;
13027 cmdline_fixed_string_t drop;
13030 cmdline_fixed_string_t on_off;
13033 /* Common CLI fields for vf split drop enable disable */
13034 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13035 TOKEN_STRING_INITIALIZER
13036 (struct cmd_vf_split_drop_en_result,
13038 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13039 TOKEN_STRING_INITIALIZER
13040 (struct cmd_vf_split_drop_en_result,
13042 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13043 TOKEN_STRING_INITIALIZER
13044 (struct cmd_vf_split_drop_en_result,
13046 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13047 TOKEN_STRING_INITIALIZER
13048 (struct cmd_vf_split_drop_en_result,
13050 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13051 TOKEN_NUM_INITIALIZER
13052 (struct cmd_vf_split_drop_en_result,
13054 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13055 TOKEN_NUM_INITIALIZER
13056 (struct cmd_vf_split_drop_en_result,
13058 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13059 TOKEN_STRING_INITIALIZER
13060 (struct cmd_vf_split_drop_en_result,
13064 cmd_set_vf_split_drop_en_parsed(
13065 void *parsed_result,
13066 __attribute__((unused)) struct cmdline *cl,
13067 __attribute__((unused)) void *data)
13069 struct cmd_vf_split_drop_en_result *res = parsed_result;
13070 int ret = -ENOTSUP;
13071 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13073 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13076 #ifdef RTE_LIBRTE_IXGBE_PMD
13077 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13084 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13087 printf("invalid port_id %d\n", res->port_id);
13090 printf("not supported on port %d\n", res->port_id);
13093 printf("programming error: (%s)\n", strerror(-ret));
13097 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13098 .f = cmd_set_vf_split_drop_en_parsed,
13100 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13102 (void *)&cmd_vf_split_drop_en_set,
13103 (void *)&cmd_vf_split_drop_en_vf,
13104 (void *)&cmd_vf_split_drop_en_split,
13105 (void *)&cmd_vf_split_drop_en_drop,
13106 (void *)&cmd_vf_split_drop_en_port_id,
13107 (void *)&cmd_vf_split_drop_en_vf_id,
13108 (void *)&cmd_vf_split_drop_en_on_off,
13113 /* vf mac address configuration */
13115 /* Common result structure for vf mac address */
13116 struct cmd_set_vf_mac_addr_result {
13117 cmdline_fixed_string_t set;
13118 cmdline_fixed_string_t vf;
13119 cmdline_fixed_string_t mac;
13120 cmdline_fixed_string_t addr;
13123 struct ether_addr mac_addr;
13127 /* Common CLI fields for vf split drop enable disable */
13128 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13129 TOKEN_STRING_INITIALIZER
13130 (struct cmd_set_vf_mac_addr_result,
13132 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13133 TOKEN_STRING_INITIALIZER
13134 (struct cmd_set_vf_mac_addr_result,
13136 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13137 TOKEN_STRING_INITIALIZER
13138 (struct cmd_set_vf_mac_addr_result,
13140 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13141 TOKEN_STRING_INITIALIZER
13142 (struct cmd_set_vf_mac_addr_result,
13144 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13145 TOKEN_NUM_INITIALIZER
13146 (struct cmd_set_vf_mac_addr_result,
13148 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13149 TOKEN_NUM_INITIALIZER
13150 (struct cmd_set_vf_mac_addr_result,
13152 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13153 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13157 cmd_set_vf_mac_addr_parsed(
13158 void *parsed_result,
13159 __attribute__((unused)) struct cmdline *cl,
13160 __attribute__((unused)) void *data)
13162 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13163 int ret = -ENOTSUP;
13165 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13168 #ifdef RTE_LIBRTE_IXGBE_PMD
13169 if (ret == -ENOTSUP)
13170 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13173 #ifdef RTE_LIBRTE_I40E_PMD
13174 if (ret == -ENOTSUP)
13175 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13178 #ifdef RTE_LIBRTE_BNXT_PMD
13179 if (ret == -ENOTSUP)
13180 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13188 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13191 printf("invalid port_id %d\n", res->port_id);
13194 printf("function not implemented\n");
13197 printf("programming error: (%s)\n", strerror(-ret));
13201 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13202 .f = cmd_set_vf_mac_addr_parsed,
13204 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13206 (void *)&cmd_set_vf_mac_addr_set,
13207 (void *)&cmd_set_vf_mac_addr_vf,
13208 (void *)&cmd_set_vf_mac_addr_mac,
13209 (void *)&cmd_set_vf_mac_addr_addr,
13210 (void *)&cmd_set_vf_mac_addr_port_id,
13211 (void *)&cmd_set_vf_mac_addr_vf_id,
13212 (void *)&cmd_set_vf_mac_addr_mac_addr,
13217 /* MACsec configuration */
13219 /* Common result structure for MACsec offload enable */
13220 struct cmd_macsec_offload_on_result {
13221 cmdline_fixed_string_t set;
13222 cmdline_fixed_string_t macsec;
13223 cmdline_fixed_string_t offload;
13225 cmdline_fixed_string_t on;
13226 cmdline_fixed_string_t encrypt;
13227 cmdline_fixed_string_t en_on_off;
13228 cmdline_fixed_string_t replay_protect;
13229 cmdline_fixed_string_t rp_on_off;
13232 /* Common CLI fields for MACsec offload disable */
13233 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13234 TOKEN_STRING_INITIALIZER
13235 (struct cmd_macsec_offload_on_result,
13237 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13238 TOKEN_STRING_INITIALIZER
13239 (struct cmd_macsec_offload_on_result,
13241 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13242 TOKEN_STRING_INITIALIZER
13243 (struct cmd_macsec_offload_on_result,
13244 offload, "offload");
13245 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13246 TOKEN_NUM_INITIALIZER
13247 (struct cmd_macsec_offload_on_result,
13249 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13250 TOKEN_STRING_INITIALIZER
13251 (struct cmd_macsec_offload_on_result,
13253 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13254 TOKEN_STRING_INITIALIZER
13255 (struct cmd_macsec_offload_on_result,
13256 encrypt, "encrypt");
13257 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13258 TOKEN_STRING_INITIALIZER
13259 (struct cmd_macsec_offload_on_result,
13260 en_on_off, "on#off");
13261 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13262 TOKEN_STRING_INITIALIZER
13263 (struct cmd_macsec_offload_on_result,
13264 replay_protect, "replay-protect");
13265 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13266 TOKEN_STRING_INITIALIZER
13267 (struct cmd_macsec_offload_on_result,
13268 rp_on_off, "on#off");
13271 cmd_set_macsec_offload_on_parsed(
13272 void *parsed_result,
13273 __attribute__((unused)) struct cmdline *cl,
13274 __attribute__((unused)) void *data)
13276 struct cmd_macsec_offload_on_result *res = parsed_result;
13277 int ret = -ENOTSUP;
13278 portid_t port_id = res->port_id;
13279 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13280 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13281 struct rte_eth_dev_info dev_info;
13283 if (port_id_is_invalid(port_id, ENABLED_WARN))
13285 if (!port_is_stopped(port_id)) {
13286 printf("Please stop port %d first\n", port_id);
13290 rte_eth_dev_info_get(port_id, &dev_info);
13291 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13292 #ifdef RTE_LIBRTE_IXGBE_PMD
13293 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13301 ports[port_id].dev_conf.txmode.offloads |=
13302 DEV_TX_OFFLOAD_MACSEC_INSERT;
13303 cmd_reconfig_device_queue(port_id, 1, 1);
13306 printf("invalid port_id %d\n", port_id);
13309 printf("not supported on port %d\n", port_id);
13312 printf("programming error: (%s)\n", strerror(-ret));
13316 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13317 .f = cmd_set_macsec_offload_on_parsed,
13319 .help_str = "set macsec offload <port_id> on "
13320 "encrypt on|off replay-protect on|off",
13322 (void *)&cmd_macsec_offload_on_set,
13323 (void *)&cmd_macsec_offload_on_macsec,
13324 (void *)&cmd_macsec_offload_on_offload,
13325 (void *)&cmd_macsec_offload_on_port_id,
13326 (void *)&cmd_macsec_offload_on_on,
13327 (void *)&cmd_macsec_offload_on_encrypt,
13328 (void *)&cmd_macsec_offload_on_en_on_off,
13329 (void *)&cmd_macsec_offload_on_replay_protect,
13330 (void *)&cmd_macsec_offload_on_rp_on_off,
13335 /* Common result structure for MACsec offload disable */
13336 struct cmd_macsec_offload_off_result {
13337 cmdline_fixed_string_t set;
13338 cmdline_fixed_string_t macsec;
13339 cmdline_fixed_string_t offload;
13341 cmdline_fixed_string_t off;
13344 /* Common CLI fields for MACsec offload disable */
13345 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13346 TOKEN_STRING_INITIALIZER
13347 (struct cmd_macsec_offload_off_result,
13349 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13350 TOKEN_STRING_INITIALIZER
13351 (struct cmd_macsec_offload_off_result,
13353 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13354 TOKEN_STRING_INITIALIZER
13355 (struct cmd_macsec_offload_off_result,
13356 offload, "offload");
13357 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13358 TOKEN_NUM_INITIALIZER
13359 (struct cmd_macsec_offload_off_result,
13361 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13362 TOKEN_STRING_INITIALIZER
13363 (struct cmd_macsec_offload_off_result,
13367 cmd_set_macsec_offload_off_parsed(
13368 void *parsed_result,
13369 __attribute__((unused)) struct cmdline *cl,
13370 __attribute__((unused)) void *data)
13372 struct cmd_macsec_offload_off_result *res = parsed_result;
13373 int ret = -ENOTSUP;
13374 struct rte_eth_dev_info dev_info;
13375 portid_t port_id = res->port_id;
13377 if (port_id_is_invalid(port_id, ENABLED_WARN))
13379 if (!port_is_stopped(port_id)) {
13380 printf("Please stop port %d first\n", port_id);
13384 rte_eth_dev_info_get(port_id, &dev_info);
13385 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13386 #ifdef RTE_LIBRTE_IXGBE_PMD
13387 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13392 ports[port_id].dev_conf.txmode.offloads &=
13393 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13394 cmd_reconfig_device_queue(port_id, 1, 1);
13397 printf("invalid port_id %d\n", port_id);
13400 printf("not supported on port %d\n", port_id);
13403 printf("programming error: (%s)\n", strerror(-ret));
13407 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13408 .f = cmd_set_macsec_offload_off_parsed,
13410 .help_str = "set macsec offload <port_id> off",
13412 (void *)&cmd_macsec_offload_off_set,
13413 (void *)&cmd_macsec_offload_off_macsec,
13414 (void *)&cmd_macsec_offload_off_offload,
13415 (void *)&cmd_macsec_offload_off_port_id,
13416 (void *)&cmd_macsec_offload_off_off,
13421 /* Common result structure for MACsec secure connection configure */
13422 struct cmd_macsec_sc_result {
13423 cmdline_fixed_string_t set;
13424 cmdline_fixed_string_t macsec;
13425 cmdline_fixed_string_t sc;
13426 cmdline_fixed_string_t tx_rx;
13428 struct ether_addr mac;
13432 /* Common CLI fields for MACsec secure connection configure */
13433 cmdline_parse_token_string_t cmd_macsec_sc_set =
13434 TOKEN_STRING_INITIALIZER
13435 (struct cmd_macsec_sc_result,
13437 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13438 TOKEN_STRING_INITIALIZER
13439 (struct cmd_macsec_sc_result,
13441 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13442 TOKEN_STRING_INITIALIZER
13443 (struct cmd_macsec_sc_result,
13445 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13446 TOKEN_STRING_INITIALIZER
13447 (struct cmd_macsec_sc_result,
13449 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13450 TOKEN_NUM_INITIALIZER
13451 (struct cmd_macsec_sc_result,
13453 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13454 TOKEN_ETHERADDR_INITIALIZER
13455 (struct cmd_macsec_sc_result,
13457 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13458 TOKEN_NUM_INITIALIZER
13459 (struct cmd_macsec_sc_result,
13463 cmd_set_macsec_sc_parsed(
13464 void *parsed_result,
13465 __attribute__((unused)) struct cmdline *cl,
13466 __attribute__((unused)) void *data)
13468 struct cmd_macsec_sc_result *res = parsed_result;
13469 int ret = -ENOTSUP;
13470 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13472 #ifdef RTE_LIBRTE_IXGBE_PMD
13474 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13475 res->mac.addr_bytes) :
13476 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13477 res->mac.addr_bytes, res->pi);
13479 RTE_SET_USED(is_tx);
13485 printf("invalid port_id %d\n", res->port_id);
13488 printf("not supported on port %d\n", res->port_id);
13491 printf("programming error: (%s)\n", strerror(-ret));
13495 cmdline_parse_inst_t cmd_set_macsec_sc = {
13496 .f = cmd_set_macsec_sc_parsed,
13498 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13500 (void *)&cmd_macsec_sc_set,
13501 (void *)&cmd_macsec_sc_macsec,
13502 (void *)&cmd_macsec_sc_sc,
13503 (void *)&cmd_macsec_sc_tx_rx,
13504 (void *)&cmd_macsec_sc_port_id,
13505 (void *)&cmd_macsec_sc_mac,
13506 (void *)&cmd_macsec_sc_pi,
13511 /* Common result structure for MACsec secure connection configure */
13512 struct cmd_macsec_sa_result {
13513 cmdline_fixed_string_t set;
13514 cmdline_fixed_string_t macsec;
13515 cmdline_fixed_string_t sa;
13516 cmdline_fixed_string_t tx_rx;
13521 cmdline_fixed_string_t key;
13524 /* Common CLI fields for MACsec secure connection configure */
13525 cmdline_parse_token_string_t cmd_macsec_sa_set =
13526 TOKEN_STRING_INITIALIZER
13527 (struct cmd_macsec_sa_result,
13529 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13530 TOKEN_STRING_INITIALIZER
13531 (struct cmd_macsec_sa_result,
13533 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13534 TOKEN_STRING_INITIALIZER
13535 (struct cmd_macsec_sa_result,
13537 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13538 TOKEN_STRING_INITIALIZER
13539 (struct cmd_macsec_sa_result,
13541 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13542 TOKEN_NUM_INITIALIZER
13543 (struct cmd_macsec_sa_result,
13545 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13546 TOKEN_NUM_INITIALIZER
13547 (struct cmd_macsec_sa_result,
13549 cmdline_parse_token_num_t cmd_macsec_sa_an =
13550 TOKEN_NUM_INITIALIZER
13551 (struct cmd_macsec_sa_result,
13553 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13554 TOKEN_NUM_INITIALIZER
13555 (struct cmd_macsec_sa_result,
13557 cmdline_parse_token_string_t cmd_macsec_sa_key =
13558 TOKEN_STRING_INITIALIZER
13559 (struct cmd_macsec_sa_result,
13563 cmd_set_macsec_sa_parsed(
13564 void *parsed_result,
13565 __attribute__((unused)) struct cmdline *cl,
13566 __attribute__((unused)) void *data)
13568 struct cmd_macsec_sa_result *res = parsed_result;
13569 int ret = -ENOTSUP;
13570 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13571 uint8_t key[16] = { 0 };
13577 key_len = strlen(res->key) / 2;
13581 for (i = 0; i < key_len; i++) {
13582 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13585 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13588 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13591 #ifdef RTE_LIBRTE_IXGBE_PMD
13593 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13594 res->idx, res->an, res->pn, key) :
13595 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13596 res->idx, res->an, res->pn, key);
13598 RTE_SET_USED(is_tx);
13605 printf("invalid idx %d or an %d\n", res->idx, res->an);
13608 printf("invalid port_id %d\n", res->port_id);
13611 printf("not supported on port %d\n", res->port_id);
13614 printf("programming error: (%s)\n", strerror(-ret));
13618 cmdline_parse_inst_t cmd_set_macsec_sa = {
13619 .f = cmd_set_macsec_sa_parsed,
13621 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13623 (void *)&cmd_macsec_sa_set,
13624 (void *)&cmd_macsec_sa_macsec,
13625 (void *)&cmd_macsec_sa_sa,
13626 (void *)&cmd_macsec_sa_tx_rx,
13627 (void *)&cmd_macsec_sa_port_id,
13628 (void *)&cmd_macsec_sa_idx,
13629 (void *)&cmd_macsec_sa_an,
13630 (void *)&cmd_macsec_sa_pn,
13631 (void *)&cmd_macsec_sa_key,
13636 /* VF unicast promiscuous mode configuration */
13638 /* Common result structure for VF unicast promiscuous mode */
13639 struct cmd_vf_promisc_result {
13640 cmdline_fixed_string_t set;
13641 cmdline_fixed_string_t vf;
13642 cmdline_fixed_string_t promisc;
13645 cmdline_fixed_string_t on_off;
13648 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13649 cmdline_parse_token_string_t cmd_vf_promisc_set =
13650 TOKEN_STRING_INITIALIZER
13651 (struct cmd_vf_promisc_result,
13653 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13654 TOKEN_STRING_INITIALIZER
13655 (struct cmd_vf_promisc_result,
13657 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13658 TOKEN_STRING_INITIALIZER
13659 (struct cmd_vf_promisc_result,
13660 promisc, "promisc");
13661 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13662 TOKEN_NUM_INITIALIZER
13663 (struct cmd_vf_promisc_result,
13665 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13666 TOKEN_NUM_INITIALIZER
13667 (struct cmd_vf_promisc_result,
13669 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13670 TOKEN_STRING_INITIALIZER
13671 (struct cmd_vf_promisc_result,
13675 cmd_set_vf_promisc_parsed(
13676 void *parsed_result,
13677 __attribute__((unused)) struct cmdline *cl,
13678 __attribute__((unused)) void *data)
13680 struct cmd_vf_promisc_result *res = parsed_result;
13681 int ret = -ENOTSUP;
13683 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13685 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13688 #ifdef RTE_LIBRTE_I40E_PMD
13689 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13690 res->vf_id, is_on);
13697 printf("invalid vf_id %d\n", res->vf_id);
13700 printf("invalid port_id %d\n", res->port_id);
13703 printf("function not implemented\n");
13706 printf("programming error: (%s)\n", strerror(-ret));
13710 cmdline_parse_inst_t cmd_set_vf_promisc = {
13711 .f = cmd_set_vf_promisc_parsed,
13713 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13714 "Set unicast promiscuous mode for a VF from the PF",
13716 (void *)&cmd_vf_promisc_set,
13717 (void *)&cmd_vf_promisc_vf,
13718 (void *)&cmd_vf_promisc_promisc,
13719 (void *)&cmd_vf_promisc_port_id,
13720 (void *)&cmd_vf_promisc_vf_id,
13721 (void *)&cmd_vf_promisc_on_off,
13726 /* VF multicast promiscuous mode configuration */
13728 /* Common result structure for VF multicast promiscuous mode */
13729 struct cmd_vf_allmulti_result {
13730 cmdline_fixed_string_t set;
13731 cmdline_fixed_string_t vf;
13732 cmdline_fixed_string_t allmulti;
13735 cmdline_fixed_string_t on_off;
13738 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13739 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13740 TOKEN_STRING_INITIALIZER
13741 (struct cmd_vf_allmulti_result,
13743 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13744 TOKEN_STRING_INITIALIZER
13745 (struct cmd_vf_allmulti_result,
13747 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13748 TOKEN_STRING_INITIALIZER
13749 (struct cmd_vf_allmulti_result,
13750 allmulti, "allmulti");
13751 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13752 TOKEN_NUM_INITIALIZER
13753 (struct cmd_vf_allmulti_result,
13755 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13756 TOKEN_NUM_INITIALIZER
13757 (struct cmd_vf_allmulti_result,
13759 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13760 TOKEN_STRING_INITIALIZER
13761 (struct cmd_vf_allmulti_result,
13765 cmd_set_vf_allmulti_parsed(
13766 void *parsed_result,
13767 __attribute__((unused)) struct cmdline *cl,
13768 __attribute__((unused)) void *data)
13770 struct cmd_vf_allmulti_result *res = parsed_result;
13771 int ret = -ENOTSUP;
13773 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13775 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13778 #ifdef RTE_LIBRTE_I40E_PMD
13779 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13780 res->vf_id, is_on);
13787 printf("invalid vf_id %d\n", res->vf_id);
13790 printf("invalid port_id %d\n", res->port_id);
13793 printf("function not implemented\n");
13796 printf("programming error: (%s)\n", strerror(-ret));
13800 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13801 .f = cmd_set_vf_allmulti_parsed,
13803 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13804 "Set multicast promiscuous mode for a VF from the PF",
13806 (void *)&cmd_vf_allmulti_set,
13807 (void *)&cmd_vf_allmulti_vf,
13808 (void *)&cmd_vf_allmulti_allmulti,
13809 (void *)&cmd_vf_allmulti_port_id,
13810 (void *)&cmd_vf_allmulti_vf_id,
13811 (void *)&cmd_vf_allmulti_on_off,
13816 /* vf broadcast mode configuration */
13818 /* Common result structure for vf broadcast */
13819 struct cmd_set_vf_broadcast_result {
13820 cmdline_fixed_string_t set;
13821 cmdline_fixed_string_t vf;
13822 cmdline_fixed_string_t broadcast;
13825 cmdline_fixed_string_t on_off;
13828 /* Common CLI fields for vf broadcast enable disable */
13829 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13830 TOKEN_STRING_INITIALIZER
13831 (struct cmd_set_vf_broadcast_result,
13833 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13834 TOKEN_STRING_INITIALIZER
13835 (struct cmd_set_vf_broadcast_result,
13837 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13838 TOKEN_STRING_INITIALIZER
13839 (struct cmd_set_vf_broadcast_result,
13840 broadcast, "broadcast");
13841 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13842 TOKEN_NUM_INITIALIZER
13843 (struct cmd_set_vf_broadcast_result,
13845 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13846 TOKEN_NUM_INITIALIZER
13847 (struct cmd_set_vf_broadcast_result,
13849 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13850 TOKEN_STRING_INITIALIZER
13851 (struct cmd_set_vf_broadcast_result,
13855 cmd_set_vf_broadcast_parsed(
13856 void *parsed_result,
13857 __attribute__((unused)) struct cmdline *cl,
13858 __attribute__((unused)) void *data)
13860 struct cmd_set_vf_broadcast_result *res = parsed_result;
13861 int ret = -ENOTSUP;
13863 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13865 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13868 #ifdef RTE_LIBRTE_I40E_PMD
13869 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13870 res->vf_id, is_on);
13877 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13880 printf("invalid port_id %d\n", res->port_id);
13883 printf("function not implemented\n");
13886 printf("programming error: (%s)\n", strerror(-ret));
13890 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13891 .f = cmd_set_vf_broadcast_parsed,
13893 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13895 (void *)&cmd_set_vf_broadcast_set,
13896 (void *)&cmd_set_vf_broadcast_vf,
13897 (void *)&cmd_set_vf_broadcast_broadcast,
13898 (void *)&cmd_set_vf_broadcast_port_id,
13899 (void *)&cmd_set_vf_broadcast_vf_id,
13900 (void *)&cmd_set_vf_broadcast_on_off,
13905 /* vf vlan tag configuration */
13907 /* Common result structure for vf vlan tag */
13908 struct cmd_set_vf_vlan_tag_result {
13909 cmdline_fixed_string_t set;
13910 cmdline_fixed_string_t vf;
13911 cmdline_fixed_string_t vlan;
13912 cmdline_fixed_string_t tag;
13915 cmdline_fixed_string_t on_off;
13918 /* Common CLI fields for vf vlan tag enable disable */
13919 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13920 TOKEN_STRING_INITIALIZER
13921 (struct cmd_set_vf_vlan_tag_result,
13923 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13924 TOKEN_STRING_INITIALIZER
13925 (struct cmd_set_vf_vlan_tag_result,
13927 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13928 TOKEN_STRING_INITIALIZER
13929 (struct cmd_set_vf_vlan_tag_result,
13931 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13932 TOKEN_STRING_INITIALIZER
13933 (struct cmd_set_vf_vlan_tag_result,
13935 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13936 TOKEN_NUM_INITIALIZER
13937 (struct cmd_set_vf_vlan_tag_result,
13939 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13940 TOKEN_NUM_INITIALIZER
13941 (struct cmd_set_vf_vlan_tag_result,
13943 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13944 TOKEN_STRING_INITIALIZER
13945 (struct cmd_set_vf_vlan_tag_result,
13949 cmd_set_vf_vlan_tag_parsed(
13950 void *parsed_result,
13951 __attribute__((unused)) struct cmdline *cl,
13952 __attribute__((unused)) void *data)
13954 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13955 int ret = -ENOTSUP;
13957 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13959 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13962 #ifdef RTE_LIBRTE_I40E_PMD
13963 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13964 res->vf_id, is_on);
13971 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13974 printf("invalid port_id %d\n", res->port_id);
13977 printf("function not implemented\n");
13980 printf("programming error: (%s)\n", strerror(-ret));
13984 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13985 .f = cmd_set_vf_vlan_tag_parsed,
13987 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13989 (void *)&cmd_set_vf_vlan_tag_set,
13990 (void *)&cmd_set_vf_vlan_tag_vf,
13991 (void *)&cmd_set_vf_vlan_tag_vlan,
13992 (void *)&cmd_set_vf_vlan_tag_tag,
13993 (void *)&cmd_set_vf_vlan_tag_port_id,
13994 (void *)&cmd_set_vf_vlan_tag_vf_id,
13995 (void *)&cmd_set_vf_vlan_tag_on_off,
14000 /* Common definition of VF and TC TX bandwidth configuration */
14001 struct cmd_vf_tc_bw_result {
14002 cmdline_fixed_string_t set;
14003 cmdline_fixed_string_t vf;
14004 cmdline_fixed_string_t tc;
14005 cmdline_fixed_string_t tx;
14006 cmdline_fixed_string_t min_bw;
14007 cmdline_fixed_string_t max_bw;
14008 cmdline_fixed_string_t strict_link_prio;
14013 cmdline_fixed_string_t bw_list;
14017 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14018 TOKEN_STRING_INITIALIZER
14019 (struct cmd_vf_tc_bw_result,
14021 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14022 TOKEN_STRING_INITIALIZER
14023 (struct cmd_vf_tc_bw_result,
14025 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14026 TOKEN_STRING_INITIALIZER
14027 (struct cmd_vf_tc_bw_result,
14029 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14030 TOKEN_STRING_INITIALIZER
14031 (struct cmd_vf_tc_bw_result,
14033 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14034 TOKEN_STRING_INITIALIZER
14035 (struct cmd_vf_tc_bw_result,
14036 strict_link_prio, "strict-link-priority");
14037 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14038 TOKEN_STRING_INITIALIZER
14039 (struct cmd_vf_tc_bw_result,
14040 min_bw, "min-bandwidth");
14041 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14042 TOKEN_STRING_INITIALIZER
14043 (struct cmd_vf_tc_bw_result,
14044 max_bw, "max-bandwidth");
14045 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14046 TOKEN_NUM_INITIALIZER
14047 (struct cmd_vf_tc_bw_result,
14049 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14050 TOKEN_NUM_INITIALIZER
14051 (struct cmd_vf_tc_bw_result,
14053 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14054 TOKEN_NUM_INITIALIZER
14055 (struct cmd_vf_tc_bw_result,
14057 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14058 TOKEN_NUM_INITIALIZER
14059 (struct cmd_vf_tc_bw_result,
14061 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14062 TOKEN_STRING_INITIALIZER
14063 (struct cmd_vf_tc_bw_result,
14065 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14066 TOKEN_NUM_INITIALIZER
14067 (struct cmd_vf_tc_bw_result,
14070 /* VF max bandwidth setting */
14072 cmd_vf_max_bw_parsed(
14073 void *parsed_result,
14074 __attribute__((unused)) struct cmdline *cl,
14075 __attribute__((unused)) void *data)
14077 struct cmd_vf_tc_bw_result *res = parsed_result;
14078 int ret = -ENOTSUP;
14080 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14083 #ifdef RTE_LIBRTE_I40E_PMD
14084 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14085 res->vf_id, res->bw);
14092 printf("invalid vf_id %d or bandwidth %d\n",
14093 res->vf_id, res->bw);
14096 printf("invalid port_id %d\n", res->port_id);
14099 printf("function not implemented\n");
14102 printf("programming error: (%s)\n", strerror(-ret));
14106 cmdline_parse_inst_t cmd_vf_max_bw = {
14107 .f = cmd_vf_max_bw_parsed,
14109 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14111 (void *)&cmd_vf_tc_bw_set,
14112 (void *)&cmd_vf_tc_bw_vf,
14113 (void *)&cmd_vf_tc_bw_tx,
14114 (void *)&cmd_vf_tc_bw_max_bw,
14115 (void *)&cmd_vf_tc_bw_port_id,
14116 (void *)&cmd_vf_tc_bw_vf_id,
14117 (void *)&cmd_vf_tc_bw_bw,
14123 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14128 const char *p, *p0 = str;
14135 p = strchr(p0, '(');
14137 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14141 p0 = strchr(p, ')');
14143 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14147 if (size >= sizeof(s)) {
14148 printf("The string size exceeds the internal buffer size\n");
14151 snprintf(s, sizeof(s), "%.*s", size, p);
14152 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14154 printf("Failed to get the bandwidth list. ");
14158 for (i = 0; i < ret; i++)
14159 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14164 /* TC min bandwidth setting */
14166 cmd_vf_tc_min_bw_parsed(
14167 void *parsed_result,
14168 __attribute__((unused)) struct cmdline *cl,
14169 __attribute__((unused)) void *data)
14171 struct cmd_vf_tc_bw_result *res = parsed_result;
14174 int ret = -ENOTSUP;
14176 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14179 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14183 #ifdef RTE_LIBRTE_I40E_PMD
14184 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14192 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14195 printf("invalid port_id %d\n", res->port_id);
14198 printf("function not implemented\n");
14201 printf("programming error: (%s)\n", strerror(-ret));
14205 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14206 .f = cmd_vf_tc_min_bw_parsed,
14208 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14209 " <bw1, bw2, ...>",
14211 (void *)&cmd_vf_tc_bw_set,
14212 (void *)&cmd_vf_tc_bw_vf,
14213 (void *)&cmd_vf_tc_bw_tc,
14214 (void *)&cmd_vf_tc_bw_tx,
14215 (void *)&cmd_vf_tc_bw_min_bw,
14216 (void *)&cmd_vf_tc_bw_port_id,
14217 (void *)&cmd_vf_tc_bw_vf_id,
14218 (void *)&cmd_vf_tc_bw_bw_list,
14224 cmd_tc_min_bw_parsed(
14225 void *parsed_result,
14226 __attribute__((unused)) struct cmdline *cl,
14227 __attribute__((unused)) void *data)
14229 struct cmd_vf_tc_bw_result *res = parsed_result;
14230 struct rte_port *port;
14233 int ret = -ENOTSUP;
14235 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14238 port = &ports[res->port_id];
14239 /** Check if the port is not started **/
14240 if (port->port_status != RTE_PORT_STOPPED) {
14241 printf("Please stop port %d first\n", res->port_id);
14245 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14249 #ifdef RTE_LIBRTE_IXGBE_PMD
14250 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14257 printf("invalid bandwidth\n");
14260 printf("invalid port_id %d\n", res->port_id);
14263 printf("function not implemented\n");
14266 printf("programming error: (%s)\n", strerror(-ret));
14270 cmdline_parse_inst_t cmd_tc_min_bw = {
14271 .f = cmd_tc_min_bw_parsed,
14273 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14275 (void *)&cmd_vf_tc_bw_set,
14276 (void *)&cmd_vf_tc_bw_tc,
14277 (void *)&cmd_vf_tc_bw_tx,
14278 (void *)&cmd_vf_tc_bw_min_bw,
14279 (void *)&cmd_vf_tc_bw_port_id,
14280 (void *)&cmd_vf_tc_bw_bw_list,
14285 /* TC max bandwidth setting */
14287 cmd_vf_tc_max_bw_parsed(
14288 void *parsed_result,
14289 __attribute__((unused)) struct cmdline *cl,
14290 __attribute__((unused)) void *data)
14292 struct cmd_vf_tc_bw_result *res = parsed_result;
14293 int ret = -ENOTSUP;
14295 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14298 #ifdef RTE_LIBRTE_I40E_PMD
14299 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14300 res->tc_no, res->bw);
14307 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14308 res->vf_id, res->tc_no, res->bw);
14311 printf("invalid port_id %d\n", res->port_id);
14314 printf("function not implemented\n");
14317 printf("programming error: (%s)\n", strerror(-ret));
14321 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14322 .f = cmd_vf_tc_max_bw_parsed,
14324 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14327 (void *)&cmd_vf_tc_bw_set,
14328 (void *)&cmd_vf_tc_bw_vf,
14329 (void *)&cmd_vf_tc_bw_tc,
14330 (void *)&cmd_vf_tc_bw_tx,
14331 (void *)&cmd_vf_tc_bw_max_bw,
14332 (void *)&cmd_vf_tc_bw_port_id,
14333 (void *)&cmd_vf_tc_bw_vf_id,
14334 (void *)&cmd_vf_tc_bw_tc_no,
14335 (void *)&cmd_vf_tc_bw_bw,
14341 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14343 /* *** Set Port default Traffic Management Hierarchy *** */
14344 struct cmd_set_port_tm_hierarchy_default_result {
14345 cmdline_fixed_string_t set;
14346 cmdline_fixed_string_t port;
14347 cmdline_fixed_string_t tm;
14348 cmdline_fixed_string_t hierarchy;
14349 cmdline_fixed_string_t def;
14353 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14354 TOKEN_STRING_INITIALIZER(
14355 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14356 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14357 TOKEN_STRING_INITIALIZER(
14358 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14359 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14360 TOKEN_STRING_INITIALIZER(
14361 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14362 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14363 TOKEN_STRING_INITIALIZER(
14364 struct cmd_set_port_tm_hierarchy_default_result,
14365 hierarchy, "hierarchy");
14366 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14367 TOKEN_STRING_INITIALIZER(
14368 struct cmd_set_port_tm_hierarchy_default_result,
14370 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14371 TOKEN_NUM_INITIALIZER(
14372 struct cmd_set_port_tm_hierarchy_default_result,
14375 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14376 __attribute__((unused)) struct cmdline *cl,
14377 __attribute__((unused)) void *data)
14379 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14380 struct rte_port *p;
14381 portid_t port_id = res->port_id;
14383 if (port_id_is_invalid(port_id, ENABLED_WARN))
14386 p = &ports[port_id];
14389 if (p->softport.tm_flag == 0) {
14390 printf(" tm not enabled on port %u (error)\n", port_id);
14394 /* Forward mode: tm */
14395 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14396 printf(" tm mode not enabled(error)\n");
14400 /* Set the default tm hierarchy */
14401 p->softport.tm.default_hierarchy_enable = 1;
14404 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14405 .f = cmd_set_port_tm_hierarchy_default_parsed,
14407 .help_str = "set port tm hierarchy default <port_id>",
14409 (void *)&cmd_set_port_tm_hierarchy_default_set,
14410 (void *)&cmd_set_port_tm_hierarchy_default_port,
14411 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14412 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14413 (void *)&cmd_set_port_tm_hierarchy_default_default,
14414 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14420 /* Strict link priority scheduling mode setting */
14422 cmd_strict_link_prio_parsed(
14423 void *parsed_result,
14424 __attribute__((unused)) struct cmdline *cl,
14425 __attribute__((unused)) void *data)
14427 struct cmd_vf_tc_bw_result *res = parsed_result;
14428 int ret = -ENOTSUP;
14430 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14433 #ifdef RTE_LIBRTE_I40E_PMD
14434 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14441 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14444 printf("invalid port_id %d\n", res->port_id);
14447 printf("function not implemented\n");
14450 printf("programming error: (%s)\n", strerror(-ret));
14454 cmdline_parse_inst_t cmd_strict_link_prio = {
14455 .f = cmd_strict_link_prio_parsed,
14457 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14459 (void *)&cmd_vf_tc_bw_set,
14460 (void *)&cmd_vf_tc_bw_tx,
14461 (void *)&cmd_vf_tc_bw_strict_link_prio,
14462 (void *)&cmd_vf_tc_bw_port_id,
14463 (void *)&cmd_vf_tc_bw_tc_map,
14468 /* Load dynamic device personalization*/
14469 struct cmd_ddp_add_result {
14470 cmdline_fixed_string_t ddp;
14471 cmdline_fixed_string_t add;
14476 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14477 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14478 cmdline_parse_token_string_t cmd_ddp_add_add =
14479 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14480 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14481 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14482 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14483 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14486 cmd_ddp_add_parsed(
14487 void *parsed_result,
14488 __attribute__((unused)) struct cmdline *cl,
14489 __attribute__((unused)) void *data)
14491 struct cmd_ddp_add_result *res = parsed_result;
14497 int ret = -ENOTSUP;
14499 if (res->port_id > nb_ports) {
14500 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14504 if (!all_ports_stopped()) {
14505 printf("Please stop all ports first\n");
14509 filepath = strdup(res->filepath);
14510 if (filepath == NULL) {
14511 printf("Failed to allocate memory\n");
14514 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14516 buff = open_file(file_fld[0], &size);
14518 free((void *)filepath);
14522 #ifdef RTE_LIBRTE_I40E_PMD
14523 if (ret == -ENOTSUP)
14524 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14526 RTE_PMD_I40E_PKG_OP_WR_ADD);
14529 if (ret == -EEXIST)
14530 printf("Profile has already existed.\n");
14532 printf("Failed to load profile.\n");
14533 else if (file_num == 2)
14534 save_file(file_fld[1], buff, size);
14537 free((void *)filepath);
14540 cmdline_parse_inst_t cmd_ddp_add = {
14541 .f = cmd_ddp_add_parsed,
14543 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14545 (void *)&cmd_ddp_add_ddp,
14546 (void *)&cmd_ddp_add_add,
14547 (void *)&cmd_ddp_add_port_id,
14548 (void *)&cmd_ddp_add_filepath,
14553 /* Delete dynamic device personalization*/
14554 struct cmd_ddp_del_result {
14555 cmdline_fixed_string_t ddp;
14556 cmdline_fixed_string_t del;
14561 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14562 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14563 cmdline_parse_token_string_t cmd_ddp_del_del =
14564 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14565 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14566 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14567 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14568 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14571 cmd_ddp_del_parsed(
14572 void *parsed_result,
14573 __attribute__((unused)) struct cmdline *cl,
14574 __attribute__((unused)) void *data)
14576 struct cmd_ddp_del_result *res = parsed_result;
14579 int ret = -ENOTSUP;
14581 if (res->port_id > nb_ports) {
14582 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14586 if (!all_ports_stopped()) {
14587 printf("Please stop all ports first\n");
14591 buff = open_file(res->filepath, &size);
14595 #ifdef RTE_LIBRTE_I40E_PMD
14596 if (ret == -ENOTSUP)
14597 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14599 RTE_PMD_I40E_PKG_OP_WR_DEL);
14602 if (ret == -EACCES)
14603 printf("Profile does not exist.\n");
14605 printf("Failed to delete profile.\n");
14610 cmdline_parse_inst_t cmd_ddp_del = {
14611 .f = cmd_ddp_del_parsed,
14613 .help_str = "ddp del <port_id> <profile_path>",
14615 (void *)&cmd_ddp_del_ddp,
14616 (void *)&cmd_ddp_del_del,
14617 (void *)&cmd_ddp_del_port_id,
14618 (void *)&cmd_ddp_del_filepath,
14623 /* Get dynamic device personalization profile info */
14624 struct cmd_ddp_info_result {
14625 cmdline_fixed_string_t ddp;
14626 cmdline_fixed_string_t get;
14627 cmdline_fixed_string_t info;
14631 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14632 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14633 cmdline_parse_token_string_t cmd_ddp_info_get =
14634 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14635 cmdline_parse_token_string_t cmd_ddp_info_info =
14636 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14637 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14638 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14641 cmd_ddp_info_parsed(
14642 void *parsed_result,
14643 __attribute__((unused)) struct cmdline *cl,
14644 __attribute__((unused)) void *data)
14646 struct cmd_ddp_info_result *res = parsed_result;
14649 int ret = -ENOTSUP;
14650 #ifdef RTE_LIBRTE_I40E_PMD
14653 uint32_t buff_size = 0;
14654 struct rte_pmd_i40e_profile_info info;
14655 uint32_t dev_num = 0;
14656 struct rte_pmd_i40e_ddp_device_id *devs;
14657 uint32_t proto_num = 0;
14658 struct rte_pmd_i40e_proto_info *proto = NULL;
14659 uint32_t pctype_num = 0;
14660 struct rte_pmd_i40e_ptype_info *pctype;
14661 uint32_t ptype_num = 0;
14662 struct rte_pmd_i40e_ptype_info *ptype;
14667 pkg = open_file(res->filepath, &pkg_size);
14671 #ifdef RTE_LIBRTE_I40E_PMD
14672 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14673 (uint8_t *)&info, sizeof(info),
14674 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14676 printf("Global Track id: 0x%x\n", info.track_id);
14677 printf("Global Version: %d.%d.%d.%d\n",
14678 info.version.major,
14679 info.version.minor,
14680 info.version.update,
14681 info.version.draft);
14682 printf("Global Package name: %s\n\n", info.name);
14685 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14686 (uint8_t *)&info, sizeof(info),
14687 RTE_PMD_I40E_PKG_INFO_HEADER);
14689 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14690 printf("i40e Profile Version: %d.%d.%d.%d\n",
14691 info.version.major,
14692 info.version.minor,
14693 info.version.update,
14694 info.version.draft);
14695 printf("i40e Profile name: %s\n\n", info.name);
14698 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14699 (uint8_t *)&buff_size, sizeof(buff_size),
14700 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14701 if (!ret && buff_size) {
14702 buff = (uint8_t *)malloc(buff_size);
14704 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14706 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14708 printf("Package Notes:\n%s\n\n", buff);
14713 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14714 (uint8_t *)&dev_num, sizeof(dev_num),
14715 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14716 if (!ret && dev_num) {
14717 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14718 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14720 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14721 (uint8_t *)devs, buff_size,
14722 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14724 printf("List of supported devices:\n");
14725 for (i = 0; i < dev_num; i++) {
14726 printf(" %04X:%04X %04X:%04X\n",
14727 devs[i].vendor_dev_id >> 16,
14728 devs[i].vendor_dev_id & 0xFFFF,
14729 devs[i].sub_vendor_dev_id >> 16,
14730 devs[i].sub_vendor_dev_id & 0xFFFF);
14738 /* get information about protocols and packet types */
14739 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14740 (uint8_t *)&proto_num, sizeof(proto_num),
14741 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14742 if (ret || !proto_num)
14743 goto no_print_return;
14745 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14746 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14748 goto no_print_return;
14750 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14752 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14754 printf("List of used protocols:\n");
14755 for (i = 0; i < proto_num; i++)
14756 printf(" %2u: %s\n", proto[i].proto_id,
14760 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14761 (uint8_t *)&pctype_num, sizeof(pctype_num),
14762 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14763 if (ret || !pctype_num)
14764 goto no_print_pctypes;
14766 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14767 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14769 goto no_print_pctypes;
14771 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14773 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14776 goto no_print_pctypes;
14779 printf("List of defined packet classification types:\n");
14780 for (i = 0; i < pctype_num; i++) {
14781 printf(" %2u:", pctype[i].ptype_id);
14782 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14783 proto_id = pctype[i].protocols[j];
14784 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14785 for (n = 0; n < proto_num; n++) {
14786 if (proto[n].proto_id == proto_id) {
14787 printf(" %s", proto[n].name);
14800 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14802 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14803 if (ret || !ptype_num)
14804 goto no_print_return;
14806 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14807 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14809 goto no_print_return;
14811 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14813 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14816 goto no_print_return;
14818 printf("List of defined packet types:\n");
14819 for (i = 0; i < ptype_num; i++) {
14820 printf(" %2u:", ptype[i].ptype_id);
14821 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14822 proto_id = ptype[i].protocols[j];
14823 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14824 for (n = 0; n < proto_num; n++) {
14825 if (proto[n].proto_id == proto_id) {
14826 printf(" %s", proto[n].name);
14842 if (ret == -ENOTSUP)
14843 printf("Function not supported in PMD driver\n");
14847 cmdline_parse_inst_t cmd_ddp_get_info = {
14848 .f = cmd_ddp_info_parsed,
14850 .help_str = "ddp get info <profile_path>",
14852 (void *)&cmd_ddp_info_ddp,
14853 (void *)&cmd_ddp_info_get,
14854 (void *)&cmd_ddp_info_info,
14855 (void *)&cmd_ddp_info_filepath,
14860 /* Get dynamic device personalization profile info list*/
14861 #define PROFILE_INFO_SIZE 48
14862 #define MAX_PROFILE_NUM 16
14864 struct cmd_ddp_get_list_result {
14865 cmdline_fixed_string_t ddp;
14866 cmdline_fixed_string_t get;
14867 cmdline_fixed_string_t list;
14871 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14872 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14873 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14874 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14875 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14876 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14877 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14878 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14881 cmd_ddp_get_list_parsed(
14882 void *parsed_result,
14883 __attribute__((unused)) struct cmdline *cl,
14884 __attribute__((unused)) void *data)
14886 struct cmd_ddp_get_list_result *res = parsed_result;
14887 #ifdef RTE_LIBRTE_I40E_PMD
14888 struct rte_pmd_i40e_profile_list *p_list;
14889 struct rte_pmd_i40e_profile_info *p_info;
14894 int ret = -ENOTSUP;
14896 if (res->port_id > nb_ports) {
14897 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14901 #ifdef RTE_LIBRTE_I40E_PMD
14902 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14903 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14905 printf("%s: Failed to malloc buffer\n", __func__);
14907 if (ret == -ENOTSUP)
14908 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14909 (uint8_t *)p_list, size);
14912 p_num = p_list->p_count;
14913 printf("Profile number is: %d\n\n", p_num);
14915 for (i = 0; i < p_num; i++) {
14916 p_info = &p_list->p_info[i];
14917 printf("Profile %d:\n", i);
14918 printf("Track id: 0x%x\n", p_info->track_id);
14919 printf("Version: %d.%d.%d.%d\n",
14920 p_info->version.major,
14921 p_info->version.minor,
14922 p_info->version.update,
14923 p_info->version.draft);
14924 printf("Profile name: %s\n\n", p_info->name);
14932 printf("Failed to get ddp list\n");
14935 cmdline_parse_inst_t cmd_ddp_get_list = {
14936 .f = cmd_ddp_get_list_parsed,
14938 .help_str = "ddp get list <port_id>",
14940 (void *)&cmd_ddp_get_list_ddp,
14941 (void *)&cmd_ddp_get_list_get,
14942 (void *)&cmd_ddp_get_list_list,
14943 (void *)&cmd_ddp_get_list_port_id,
14948 /* Configure input set */
14949 struct cmd_cfg_input_set_result {
14950 cmdline_fixed_string_t port;
14951 cmdline_fixed_string_t cfg;
14953 cmdline_fixed_string_t pctype;
14955 cmdline_fixed_string_t inset_type;
14956 cmdline_fixed_string_t opt;
14957 cmdline_fixed_string_t field;
14962 cmd_cfg_input_set_parsed(
14963 void *parsed_result,
14964 __attribute__((unused)) struct cmdline *cl,
14965 __attribute__((unused)) void *data)
14967 struct cmd_cfg_input_set_result *res = parsed_result;
14968 #ifdef RTE_LIBRTE_I40E_PMD
14969 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14970 struct rte_pmd_i40e_inset inset;
14972 int ret = -ENOTSUP;
14974 if (res->port_id > nb_ports) {
14975 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14979 if (!all_ports_stopped()) {
14980 printf("Please stop all ports first\n");
14984 #ifdef RTE_LIBRTE_I40E_PMD
14985 if (!strcmp(res->inset_type, "hash_inset"))
14986 inset_type = INSET_HASH;
14987 else if (!strcmp(res->inset_type, "fdir_inset"))
14988 inset_type = INSET_FDIR;
14989 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14990 inset_type = INSET_FDIR_FLX;
14991 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14992 &inset, inset_type);
14994 printf("Failed to get input set.\n");
14998 if (!strcmp(res->opt, "get")) {
14999 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15002 printf("Field index %d is enabled.\n", res->field_idx);
15004 printf("Field index %d is disabled.\n", res->field_idx);
15006 } else if (!strcmp(res->opt, "set"))
15007 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15009 else if (!strcmp(res->opt, "clear"))
15010 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15013 printf("Failed to configure input set field.\n");
15017 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15018 &inset, inset_type);
15020 printf("Failed to set input set.\n");
15025 if (ret == -ENOTSUP)
15026 printf("Function not supported\n");
15029 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15030 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15032 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15033 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15035 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15036 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15038 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15039 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15041 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15042 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15044 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15045 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15047 "hash_inset#fdir_inset#fdir_flx_inset");
15048 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15049 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15050 opt, "get#set#clear");
15051 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15052 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15054 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15055 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15058 cmdline_parse_inst_t cmd_cfg_input_set = {
15059 .f = cmd_cfg_input_set_parsed,
15061 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15062 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15064 (void *)&cmd_cfg_input_set_port,
15065 (void *)&cmd_cfg_input_set_cfg,
15066 (void *)&cmd_cfg_input_set_port_id,
15067 (void *)&cmd_cfg_input_set_pctype,
15068 (void *)&cmd_cfg_input_set_pctype_id,
15069 (void *)&cmd_cfg_input_set_inset_type,
15070 (void *)&cmd_cfg_input_set_opt,
15071 (void *)&cmd_cfg_input_set_field,
15072 (void *)&cmd_cfg_input_set_field_idx,
15077 /* Clear input set */
15078 struct cmd_clear_input_set_result {
15079 cmdline_fixed_string_t port;
15080 cmdline_fixed_string_t cfg;
15082 cmdline_fixed_string_t pctype;
15084 cmdline_fixed_string_t inset_type;
15085 cmdline_fixed_string_t clear;
15086 cmdline_fixed_string_t all;
15090 cmd_clear_input_set_parsed(
15091 void *parsed_result,
15092 __attribute__((unused)) struct cmdline *cl,
15093 __attribute__((unused)) void *data)
15095 struct cmd_clear_input_set_result *res = parsed_result;
15096 #ifdef RTE_LIBRTE_I40E_PMD
15097 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15098 struct rte_pmd_i40e_inset inset;
15100 int ret = -ENOTSUP;
15102 if (res->port_id > nb_ports) {
15103 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
15107 if (!all_ports_stopped()) {
15108 printf("Please stop all ports first\n");
15112 #ifdef RTE_LIBRTE_I40E_PMD
15113 if (!strcmp(res->inset_type, "hash_inset"))
15114 inset_type = INSET_HASH;
15115 else if (!strcmp(res->inset_type, "fdir_inset"))
15116 inset_type = INSET_FDIR;
15117 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15118 inset_type = INSET_FDIR_FLX;
15120 memset(&inset, 0, sizeof(inset));
15122 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15123 &inset, inset_type);
15125 printf("Failed to clear input set.\n");
15131 if (ret == -ENOTSUP)
15132 printf("Function not supported\n");
15135 cmdline_parse_token_string_t cmd_clear_input_set_port =
15136 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15138 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15139 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15141 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15142 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15144 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15145 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15147 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15148 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15150 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15151 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15153 "hash_inset#fdir_inset#fdir_flx_inset");
15154 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15155 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15157 cmdline_parse_token_string_t cmd_clear_input_set_all =
15158 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15161 cmdline_parse_inst_t cmd_clear_input_set = {
15162 .f = cmd_clear_input_set_parsed,
15164 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15165 "fdir_inset|fdir_flx_inset clear all",
15167 (void *)&cmd_clear_input_set_port,
15168 (void *)&cmd_clear_input_set_cfg,
15169 (void *)&cmd_clear_input_set_port_id,
15170 (void *)&cmd_clear_input_set_pctype,
15171 (void *)&cmd_clear_input_set_pctype_id,
15172 (void *)&cmd_clear_input_set_inset_type,
15173 (void *)&cmd_clear_input_set_clear,
15174 (void *)&cmd_clear_input_set_all,
15179 /* show vf stats */
15181 /* Common result structure for show vf stats */
15182 struct cmd_show_vf_stats_result {
15183 cmdline_fixed_string_t show;
15184 cmdline_fixed_string_t vf;
15185 cmdline_fixed_string_t stats;
15190 /* Common CLI fields show vf stats*/
15191 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15192 TOKEN_STRING_INITIALIZER
15193 (struct cmd_show_vf_stats_result,
15195 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15196 TOKEN_STRING_INITIALIZER
15197 (struct cmd_show_vf_stats_result,
15199 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15200 TOKEN_STRING_INITIALIZER
15201 (struct cmd_show_vf_stats_result,
15203 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15204 TOKEN_NUM_INITIALIZER
15205 (struct cmd_show_vf_stats_result,
15207 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15208 TOKEN_NUM_INITIALIZER
15209 (struct cmd_show_vf_stats_result,
15213 cmd_show_vf_stats_parsed(
15214 void *parsed_result,
15215 __attribute__((unused)) struct cmdline *cl,
15216 __attribute__((unused)) void *data)
15218 struct cmd_show_vf_stats_result *res = parsed_result;
15219 struct rte_eth_stats stats;
15220 int ret = -ENOTSUP;
15221 static const char *nic_stats_border = "########################";
15223 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15226 memset(&stats, 0, sizeof(stats));
15228 #ifdef RTE_LIBRTE_I40E_PMD
15229 if (ret == -ENOTSUP)
15230 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15234 #ifdef RTE_LIBRTE_BNXT_PMD
15235 if (ret == -ENOTSUP)
15236 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15245 printf("invalid vf_id %d\n", res->vf_id);
15248 printf("invalid port_id %d\n", res->port_id);
15251 printf("function not implemented\n");
15254 printf("programming error: (%s)\n", strerror(-ret));
15257 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15258 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15260 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15262 stats.ipackets, stats.imissed, stats.ibytes);
15263 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15264 printf(" RX-nombuf: %-10"PRIu64"\n",
15266 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15268 stats.opackets, stats.oerrors, stats.obytes);
15270 printf(" %s############################%s\n",
15271 nic_stats_border, nic_stats_border);
15274 cmdline_parse_inst_t cmd_show_vf_stats = {
15275 .f = cmd_show_vf_stats_parsed,
15277 .help_str = "show vf stats <port_id> <vf_id>",
15279 (void *)&cmd_show_vf_stats_show,
15280 (void *)&cmd_show_vf_stats_vf,
15281 (void *)&cmd_show_vf_stats_stats,
15282 (void *)&cmd_show_vf_stats_port_id,
15283 (void *)&cmd_show_vf_stats_vf_id,
15288 /* clear vf stats */
15290 /* Common result structure for clear vf stats */
15291 struct cmd_clear_vf_stats_result {
15292 cmdline_fixed_string_t clear;
15293 cmdline_fixed_string_t vf;
15294 cmdline_fixed_string_t stats;
15299 /* Common CLI fields clear vf stats*/
15300 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15301 TOKEN_STRING_INITIALIZER
15302 (struct cmd_clear_vf_stats_result,
15304 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15305 TOKEN_STRING_INITIALIZER
15306 (struct cmd_clear_vf_stats_result,
15308 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15309 TOKEN_STRING_INITIALIZER
15310 (struct cmd_clear_vf_stats_result,
15312 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15313 TOKEN_NUM_INITIALIZER
15314 (struct cmd_clear_vf_stats_result,
15316 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15317 TOKEN_NUM_INITIALIZER
15318 (struct cmd_clear_vf_stats_result,
15322 cmd_clear_vf_stats_parsed(
15323 void *parsed_result,
15324 __attribute__((unused)) struct cmdline *cl,
15325 __attribute__((unused)) void *data)
15327 struct cmd_clear_vf_stats_result *res = parsed_result;
15328 int ret = -ENOTSUP;
15330 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15333 #ifdef RTE_LIBRTE_I40E_PMD
15334 if (ret == -ENOTSUP)
15335 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15338 #ifdef RTE_LIBRTE_BNXT_PMD
15339 if (ret == -ENOTSUP)
15340 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15348 printf("invalid vf_id %d\n", res->vf_id);
15351 printf("invalid port_id %d\n", res->port_id);
15354 printf("function not implemented\n");
15357 printf("programming error: (%s)\n", strerror(-ret));
15361 cmdline_parse_inst_t cmd_clear_vf_stats = {
15362 .f = cmd_clear_vf_stats_parsed,
15364 .help_str = "clear vf stats <port_id> <vf_id>",
15366 (void *)&cmd_clear_vf_stats_clear,
15367 (void *)&cmd_clear_vf_stats_vf,
15368 (void *)&cmd_clear_vf_stats_stats,
15369 (void *)&cmd_clear_vf_stats_port_id,
15370 (void *)&cmd_clear_vf_stats_vf_id,
15375 /* port config pctype mapping reset */
15377 /* Common result structure for port config pctype mapping reset */
15378 struct cmd_pctype_mapping_reset_result {
15379 cmdline_fixed_string_t port;
15380 cmdline_fixed_string_t config;
15382 cmdline_fixed_string_t pctype;
15383 cmdline_fixed_string_t mapping;
15384 cmdline_fixed_string_t reset;
15387 /* Common CLI fields for port config pctype mapping reset*/
15388 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15389 TOKEN_STRING_INITIALIZER
15390 (struct cmd_pctype_mapping_reset_result,
15392 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15393 TOKEN_STRING_INITIALIZER
15394 (struct cmd_pctype_mapping_reset_result,
15396 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15397 TOKEN_NUM_INITIALIZER
15398 (struct cmd_pctype_mapping_reset_result,
15400 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15401 TOKEN_STRING_INITIALIZER
15402 (struct cmd_pctype_mapping_reset_result,
15404 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15405 TOKEN_STRING_INITIALIZER
15406 (struct cmd_pctype_mapping_reset_result,
15407 mapping, "mapping");
15408 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15409 TOKEN_STRING_INITIALIZER
15410 (struct cmd_pctype_mapping_reset_result,
15414 cmd_pctype_mapping_reset_parsed(
15415 void *parsed_result,
15416 __attribute__((unused)) struct cmdline *cl,
15417 __attribute__((unused)) void *data)
15419 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15420 int ret = -ENOTSUP;
15422 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15425 #ifdef RTE_LIBRTE_I40E_PMD
15426 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15433 printf("invalid port_id %d\n", res->port_id);
15436 printf("function not implemented\n");
15439 printf("programming error: (%s)\n", strerror(-ret));
15443 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15444 .f = cmd_pctype_mapping_reset_parsed,
15446 .help_str = "port config <port_id> pctype mapping reset",
15448 (void *)&cmd_pctype_mapping_reset_port,
15449 (void *)&cmd_pctype_mapping_reset_config,
15450 (void *)&cmd_pctype_mapping_reset_port_id,
15451 (void *)&cmd_pctype_mapping_reset_pctype,
15452 (void *)&cmd_pctype_mapping_reset_mapping,
15453 (void *)&cmd_pctype_mapping_reset_reset,
15458 /* show port pctype mapping */
15460 /* Common result structure for show port pctype mapping */
15461 struct cmd_pctype_mapping_get_result {
15462 cmdline_fixed_string_t show;
15463 cmdline_fixed_string_t port;
15465 cmdline_fixed_string_t pctype;
15466 cmdline_fixed_string_t mapping;
15469 /* Common CLI fields for pctype mapping get */
15470 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15471 TOKEN_STRING_INITIALIZER
15472 (struct cmd_pctype_mapping_get_result,
15474 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15475 TOKEN_STRING_INITIALIZER
15476 (struct cmd_pctype_mapping_get_result,
15478 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15479 TOKEN_NUM_INITIALIZER
15480 (struct cmd_pctype_mapping_get_result,
15482 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15483 TOKEN_STRING_INITIALIZER
15484 (struct cmd_pctype_mapping_get_result,
15486 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15487 TOKEN_STRING_INITIALIZER
15488 (struct cmd_pctype_mapping_get_result,
15489 mapping, "mapping");
15492 cmd_pctype_mapping_get_parsed(
15493 void *parsed_result,
15494 __attribute__((unused)) struct cmdline *cl,
15495 __attribute__((unused)) void *data)
15497 struct cmd_pctype_mapping_get_result *res = parsed_result;
15498 int ret = -ENOTSUP;
15499 #ifdef RTE_LIBRTE_I40E_PMD
15500 struct rte_pmd_i40e_flow_type_mapping
15501 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15502 int i, j, first_pctype;
15505 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15508 #ifdef RTE_LIBRTE_I40E_PMD
15509 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15516 printf("invalid port_id %d\n", res->port_id);
15519 printf("function not implemented\n");
15522 printf("programming error: (%s)\n", strerror(-ret));
15526 #ifdef RTE_LIBRTE_I40E_PMD
15527 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15528 if (mapping[i].pctype != 0ULL) {
15531 printf("pctype: ");
15532 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15533 if (mapping[i].pctype & (1ULL << j)) {
15534 printf(first_pctype ?
15535 "%02d" : ",%02d", j);
15539 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15545 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15546 .f = cmd_pctype_mapping_get_parsed,
15548 .help_str = "show port <port_id> pctype mapping",
15550 (void *)&cmd_pctype_mapping_get_show,
15551 (void *)&cmd_pctype_mapping_get_port,
15552 (void *)&cmd_pctype_mapping_get_port_id,
15553 (void *)&cmd_pctype_mapping_get_pctype,
15554 (void *)&cmd_pctype_mapping_get_mapping,
15559 /* port config pctype mapping update */
15561 /* Common result structure for port config pctype mapping update */
15562 struct cmd_pctype_mapping_update_result {
15563 cmdline_fixed_string_t port;
15564 cmdline_fixed_string_t config;
15566 cmdline_fixed_string_t pctype;
15567 cmdline_fixed_string_t mapping;
15568 cmdline_fixed_string_t update;
15569 cmdline_fixed_string_t pctype_list;
15570 uint16_t flow_type;
15573 /* Common CLI fields for pctype mapping update*/
15574 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15575 TOKEN_STRING_INITIALIZER
15576 (struct cmd_pctype_mapping_update_result,
15578 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15579 TOKEN_STRING_INITIALIZER
15580 (struct cmd_pctype_mapping_update_result,
15582 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15583 TOKEN_NUM_INITIALIZER
15584 (struct cmd_pctype_mapping_update_result,
15586 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15587 TOKEN_STRING_INITIALIZER
15588 (struct cmd_pctype_mapping_update_result,
15590 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15591 TOKEN_STRING_INITIALIZER
15592 (struct cmd_pctype_mapping_update_result,
15593 mapping, "mapping");
15594 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15595 TOKEN_STRING_INITIALIZER
15596 (struct cmd_pctype_mapping_update_result,
15598 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15599 TOKEN_STRING_INITIALIZER
15600 (struct cmd_pctype_mapping_update_result,
15601 pctype_list, NULL);
15602 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15603 TOKEN_NUM_INITIALIZER
15604 (struct cmd_pctype_mapping_update_result,
15605 flow_type, UINT16);
15608 cmd_pctype_mapping_update_parsed(
15609 void *parsed_result,
15610 __attribute__((unused)) struct cmdline *cl,
15611 __attribute__((unused)) void *data)
15613 struct cmd_pctype_mapping_update_result *res = parsed_result;
15614 int ret = -ENOTSUP;
15615 #ifdef RTE_LIBRTE_I40E_PMD
15616 struct rte_pmd_i40e_flow_type_mapping mapping;
15618 unsigned int nb_item;
15619 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15622 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15625 #ifdef RTE_LIBRTE_I40E_PMD
15626 nb_item = parse_item_list(res->pctype_list, "pctypes",
15627 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15628 mapping.flow_type = res->flow_type;
15629 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15630 mapping.pctype |= (1ULL << pctype_list[i]);
15631 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15641 printf("invalid pctype or flow type\n");
15644 printf("invalid port_id %d\n", res->port_id);
15647 printf("function not implemented\n");
15650 printf("programming error: (%s)\n", strerror(-ret));
15654 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15655 .f = cmd_pctype_mapping_update_parsed,
15657 .help_str = "port config <port_id> pctype mapping update"
15658 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15660 (void *)&cmd_pctype_mapping_update_port,
15661 (void *)&cmd_pctype_mapping_update_config,
15662 (void *)&cmd_pctype_mapping_update_port_id,
15663 (void *)&cmd_pctype_mapping_update_pctype,
15664 (void *)&cmd_pctype_mapping_update_mapping,
15665 (void *)&cmd_pctype_mapping_update_update,
15666 (void *)&cmd_pctype_mapping_update_pc_type,
15667 (void *)&cmd_pctype_mapping_update_flow_type,
15672 /* ptype mapping get */
15674 /* Common result structure for ptype mapping get */
15675 struct cmd_ptype_mapping_get_result {
15676 cmdline_fixed_string_t ptype;
15677 cmdline_fixed_string_t mapping;
15678 cmdline_fixed_string_t get;
15680 uint8_t valid_only;
15683 /* Common CLI fields for ptype mapping get */
15684 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15685 TOKEN_STRING_INITIALIZER
15686 (struct cmd_ptype_mapping_get_result,
15688 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15689 TOKEN_STRING_INITIALIZER
15690 (struct cmd_ptype_mapping_get_result,
15691 mapping, "mapping");
15692 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15693 TOKEN_STRING_INITIALIZER
15694 (struct cmd_ptype_mapping_get_result,
15696 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15697 TOKEN_NUM_INITIALIZER
15698 (struct cmd_ptype_mapping_get_result,
15700 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15701 TOKEN_NUM_INITIALIZER
15702 (struct cmd_ptype_mapping_get_result,
15703 valid_only, UINT8);
15706 cmd_ptype_mapping_get_parsed(
15707 void *parsed_result,
15708 __attribute__((unused)) struct cmdline *cl,
15709 __attribute__((unused)) void *data)
15711 struct cmd_ptype_mapping_get_result *res = parsed_result;
15712 int ret = -ENOTSUP;
15713 #ifdef RTE_LIBRTE_I40E_PMD
15714 int max_ptype_num = 256;
15715 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15720 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15723 #ifdef RTE_LIBRTE_I40E_PMD
15724 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15735 printf("invalid port_id %d\n", res->port_id);
15738 printf("function not implemented\n");
15741 printf("programming error: (%s)\n", strerror(-ret));
15744 #ifdef RTE_LIBRTE_I40E_PMD
15746 for (i = 0; i < count; i++)
15747 printf("%3d\t0x%08x\n",
15748 mapping[i].hw_ptype, mapping[i].sw_ptype);
15753 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15754 .f = cmd_ptype_mapping_get_parsed,
15756 .help_str = "ptype mapping get <port_id> <valid_only>",
15758 (void *)&cmd_ptype_mapping_get_ptype,
15759 (void *)&cmd_ptype_mapping_get_mapping,
15760 (void *)&cmd_ptype_mapping_get_get,
15761 (void *)&cmd_ptype_mapping_get_port_id,
15762 (void *)&cmd_ptype_mapping_get_valid_only,
15767 /* ptype mapping replace */
15769 /* Common result structure for ptype mapping replace */
15770 struct cmd_ptype_mapping_replace_result {
15771 cmdline_fixed_string_t ptype;
15772 cmdline_fixed_string_t mapping;
15773 cmdline_fixed_string_t replace;
15780 /* Common CLI fields for ptype mapping replace */
15781 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15782 TOKEN_STRING_INITIALIZER
15783 (struct cmd_ptype_mapping_replace_result,
15785 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15786 TOKEN_STRING_INITIALIZER
15787 (struct cmd_ptype_mapping_replace_result,
15788 mapping, "mapping");
15789 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15790 TOKEN_STRING_INITIALIZER
15791 (struct cmd_ptype_mapping_replace_result,
15792 replace, "replace");
15793 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15794 TOKEN_NUM_INITIALIZER
15795 (struct cmd_ptype_mapping_replace_result,
15797 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15798 TOKEN_NUM_INITIALIZER
15799 (struct cmd_ptype_mapping_replace_result,
15801 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15802 TOKEN_NUM_INITIALIZER
15803 (struct cmd_ptype_mapping_replace_result,
15805 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15806 TOKEN_NUM_INITIALIZER
15807 (struct cmd_ptype_mapping_replace_result,
15811 cmd_ptype_mapping_replace_parsed(
15812 void *parsed_result,
15813 __attribute__((unused)) struct cmdline *cl,
15814 __attribute__((unused)) void *data)
15816 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15817 int ret = -ENOTSUP;
15819 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15822 #ifdef RTE_LIBRTE_I40E_PMD
15823 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15833 printf("invalid ptype 0x%8x or 0x%8x\n",
15834 res->target, res->pkt_type);
15837 printf("invalid port_id %d\n", res->port_id);
15840 printf("function not implemented\n");
15843 printf("programming error: (%s)\n", strerror(-ret));
15847 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15848 .f = cmd_ptype_mapping_replace_parsed,
15851 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15853 (void *)&cmd_ptype_mapping_replace_ptype,
15854 (void *)&cmd_ptype_mapping_replace_mapping,
15855 (void *)&cmd_ptype_mapping_replace_replace,
15856 (void *)&cmd_ptype_mapping_replace_port_id,
15857 (void *)&cmd_ptype_mapping_replace_target,
15858 (void *)&cmd_ptype_mapping_replace_mask,
15859 (void *)&cmd_ptype_mapping_replace_pkt_type,
15864 /* ptype mapping reset */
15866 /* Common result structure for ptype mapping reset */
15867 struct cmd_ptype_mapping_reset_result {
15868 cmdline_fixed_string_t ptype;
15869 cmdline_fixed_string_t mapping;
15870 cmdline_fixed_string_t reset;
15874 /* Common CLI fields for ptype mapping reset*/
15875 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15876 TOKEN_STRING_INITIALIZER
15877 (struct cmd_ptype_mapping_reset_result,
15879 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15880 TOKEN_STRING_INITIALIZER
15881 (struct cmd_ptype_mapping_reset_result,
15882 mapping, "mapping");
15883 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15884 TOKEN_STRING_INITIALIZER
15885 (struct cmd_ptype_mapping_reset_result,
15887 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15888 TOKEN_NUM_INITIALIZER
15889 (struct cmd_ptype_mapping_reset_result,
15893 cmd_ptype_mapping_reset_parsed(
15894 void *parsed_result,
15895 __attribute__((unused)) struct cmdline *cl,
15896 __attribute__((unused)) void *data)
15898 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15899 int ret = -ENOTSUP;
15901 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15904 #ifdef RTE_LIBRTE_I40E_PMD
15905 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15912 printf("invalid port_id %d\n", res->port_id);
15915 printf("function not implemented\n");
15918 printf("programming error: (%s)\n", strerror(-ret));
15922 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15923 .f = cmd_ptype_mapping_reset_parsed,
15925 .help_str = "ptype mapping reset <port_id>",
15927 (void *)&cmd_ptype_mapping_reset_ptype,
15928 (void *)&cmd_ptype_mapping_reset_mapping,
15929 (void *)&cmd_ptype_mapping_reset_reset,
15930 (void *)&cmd_ptype_mapping_reset_port_id,
15935 /* ptype mapping update */
15937 /* Common result structure for ptype mapping update */
15938 struct cmd_ptype_mapping_update_result {
15939 cmdline_fixed_string_t ptype;
15940 cmdline_fixed_string_t mapping;
15941 cmdline_fixed_string_t reset;
15947 /* Common CLI fields for ptype mapping update*/
15948 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15949 TOKEN_STRING_INITIALIZER
15950 (struct cmd_ptype_mapping_update_result,
15952 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15953 TOKEN_STRING_INITIALIZER
15954 (struct cmd_ptype_mapping_update_result,
15955 mapping, "mapping");
15956 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15957 TOKEN_STRING_INITIALIZER
15958 (struct cmd_ptype_mapping_update_result,
15960 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15961 TOKEN_NUM_INITIALIZER
15962 (struct cmd_ptype_mapping_update_result,
15964 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15965 TOKEN_NUM_INITIALIZER
15966 (struct cmd_ptype_mapping_update_result,
15968 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15969 TOKEN_NUM_INITIALIZER
15970 (struct cmd_ptype_mapping_update_result,
15974 cmd_ptype_mapping_update_parsed(
15975 void *parsed_result,
15976 __attribute__((unused)) struct cmdline *cl,
15977 __attribute__((unused)) void *data)
15979 struct cmd_ptype_mapping_update_result *res = parsed_result;
15980 int ret = -ENOTSUP;
15981 #ifdef RTE_LIBRTE_I40E_PMD
15982 struct rte_pmd_i40e_ptype_mapping mapping;
15984 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15987 #ifdef RTE_LIBRTE_I40E_PMD
15988 mapping.hw_ptype = res->hw_ptype;
15989 mapping.sw_ptype = res->sw_ptype;
15990 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16000 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16003 printf("invalid port_id %d\n", res->port_id);
16006 printf("function not implemented\n");
16009 printf("programming error: (%s)\n", strerror(-ret));
16013 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16014 .f = cmd_ptype_mapping_update_parsed,
16016 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16018 (void *)&cmd_ptype_mapping_update_ptype,
16019 (void *)&cmd_ptype_mapping_update_mapping,
16020 (void *)&cmd_ptype_mapping_update_update,
16021 (void *)&cmd_ptype_mapping_update_port_id,
16022 (void *)&cmd_ptype_mapping_update_hw_ptype,
16023 (void *)&cmd_ptype_mapping_update_sw_ptype,
16028 /* Common result structure for file commands */
16029 struct cmd_cmdfile_result {
16030 cmdline_fixed_string_t load;
16031 cmdline_fixed_string_t filename;
16034 /* Common CLI fields for file commands */
16035 cmdline_parse_token_string_t cmd_load_cmdfile =
16036 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16037 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16038 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16041 cmd_load_from_file_parsed(
16042 void *parsed_result,
16043 __attribute__((unused)) struct cmdline *cl,
16044 __attribute__((unused)) void *data)
16046 struct cmd_cmdfile_result *res = parsed_result;
16048 cmdline_read_from_file(res->filename);
16051 cmdline_parse_inst_t cmd_load_from_file = {
16052 .f = cmd_load_from_file_parsed,
16054 .help_str = "load <filename>",
16056 (void *)&cmd_load_cmdfile,
16057 (void *)&cmd_load_cmdfile_filename,
16062 /* ******************************************************************************** */
16064 /* list of instructions */
16065 cmdline_parse_ctx_t main_ctx[] = {
16066 (cmdline_parse_inst_t *)&cmd_help_brief,
16067 (cmdline_parse_inst_t *)&cmd_help_long,
16068 (cmdline_parse_inst_t *)&cmd_quit,
16069 (cmdline_parse_inst_t *)&cmd_load_from_file,
16070 (cmdline_parse_inst_t *)&cmd_showport,
16071 (cmdline_parse_inst_t *)&cmd_showqueue,
16072 (cmdline_parse_inst_t *)&cmd_showportall,
16073 (cmdline_parse_inst_t *)&cmd_showcfg,
16074 (cmdline_parse_inst_t *)&cmd_start,
16075 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16076 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16077 (cmdline_parse_inst_t *)&cmd_set_link_up,
16078 (cmdline_parse_inst_t *)&cmd_set_link_down,
16079 (cmdline_parse_inst_t *)&cmd_reset,
16080 (cmdline_parse_inst_t *)&cmd_set_numbers,
16081 (cmdline_parse_inst_t *)&cmd_set_log,
16082 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16083 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16084 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16085 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16086 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16087 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16088 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16089 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16090 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16091 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16092 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16093 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16094 (cmdline_parse_inst_t *)&cmd_set_link_check,
16095 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16096 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16097 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16098 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16099 #ifdef RTE_LIBRTE_PMD_BOND
16100 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16101 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16102 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16103 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16104 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16105 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16106 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16107 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16108 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16109 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16110 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16112 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16113 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16114 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16115 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16116 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16117 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16118 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16119 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16120 (cmdline_parse_inst_t *)&cmd_csum_set,
16121 (cmdline_parse_inst_t *)&cmd_csum_show,
16122 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16123 (cmdline_parse_inst_t *)&cmd_tso_set,
16124 (cmdline_parse_inst_t *)&cmd_tso_show,
16125 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16126 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16127 (cmdline_parse_inst_t *)&cmd_gro_enable,
16128 (cmdline_parse_inst_t *)&cmd_gro_flush,
16129 (cmdline_parse_inst_t *)&cmd_gro_show,
16130 (cmdline_parse_inst_t *)&cmd_gso_enable,
16131 (cmdline_parse_inst_t *)&cmd_gso_size,
16132 (cmdline_parse_inst_t *)&cmd_gso_show,
16133 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16134 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16135 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16136 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16137 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16138 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16139 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16140 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16141 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16142 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16143 (cmdline_parse_inst_t *)&cmd_config_dcb,
16144 (cmdline_parse_inst_t *)&cmd_read_reg,
16145 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16146 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16147 (cmdline_parse_inst_t *)&cmd_write_reg,
16148 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16149 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16150 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16151 (cmdline_parse_inst_t *)&cmd_stop,
16152 (cmdline_parse_inst_t *)&cmd_mac_addr,
16153 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16154 (cmdline_parse_inst_t *)&cmd_set_qmap,
16155 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16156 (cmdline_parse_inst_t *)&cmd_operate_port,
16157 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16158 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16159 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16160 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16161 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16162 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16163 (cmdline_parse_inst_t *)&cmd_config_mtu,
16164 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16165 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16166 (cmdline_parse_inst_t *)&cmd_config_rss,
16167 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16168 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16169 (cmdline_parse_inst_t *)&cmd_showport_reta,
16170 (cmdline_parse_inst_t *)&cmd_config_burst,
16171 (cmdline_parse_inst_t *)&cmd_config_thresh,
16172 (cmdline_parse_inst_t *)&cmd_config_threshold,
16173 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16174 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16175 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16176 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16177 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16178 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
16179 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16180 (cmdline_parse_inst_t *)&cmd_global_config,
16181 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16182 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16183 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16184 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16185 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16186 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16187 (cmdline_parse_inst_t *)&cmd_dump,
16188 (cmdline_parse_inst_t *)&cmd_dump_one,
16189 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
16190 (cmdline_parse_inst_t *)&cmd_syn_filter,
16191 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
16192 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
16193 (cmdline_parse_inst_t *)&cmd_flex_filter,
16194 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16195 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16196 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16197 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16198 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16199 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16200 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16201 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
16202 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16203 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16204 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16205 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16206 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16207 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16208 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16209 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16210 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16211 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16212 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16213 (cmdline_parse_inst_t *)&cmd_flow,
16214 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16215 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16216 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16217 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16218 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16219 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16220 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16221 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16222 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16223 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16224 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16225 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16226 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16227 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16228 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16229 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16230 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16231 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16232 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16233 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16234 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16235 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16236 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16237 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16238 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16239 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16240 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16241 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16242 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16243 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16244 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16245 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16246 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16247 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16248 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16249 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16250 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16251 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16252 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16253 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16254 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16255 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16256 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16257 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16258 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16259 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16260 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16261 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16262 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16263 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16264 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16266 (cmdline_parse_inst_t *)&cmd_ddp_add,
16267 (cmdline_parse_inst_t *)&cmd_ddp_del,
16268 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16269 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16270 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16271 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16272 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16273 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16274 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16275 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16276 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16277 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16279 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16280 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16281 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16282 (cmdline_parse_inst_t *)&cmd_queue_region,
16283 (cmdline_parse_inst_t *)&cmd_region_flowtype,
16284 (cmdline_parse_inst_t *)&cmd_user_priority_region,
16285 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
16286 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16287 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16288 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16289 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16290 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16291 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16292 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16293 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16294 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16295 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16296 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16297 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16298 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16299 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16300 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16301 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16302 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16303 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16307 /* read cmdline commands from file */
16309 cmdline_read_from_file(const char *filename)
16311 struct cmdline *cl;
16313 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16315 printf("Failed to create file based cmdline context: %s\n",
16320 cmdline_interact(cl);
16325 printf("Read CLI commands from %s\n", filename);
16328 /* prompt function, called from main on MASTER lcore */
16332 /* initialize non-constant commands */
16333 cmd_set_fwd_mode_init();
16334 cmd_set_fwd_retry_mode_init();
16336 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16337 if (testpmd_cl == NULL)
16339 cmdline_interact(testpmd_cl);
16340 cmdline_stdin_exit(testpmd_cl);
16346 if (testpmd_cl != NULL)
16347 cmdline_quit(testpmd_cl);
16351 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16353 if (id == (portid_t)RTE_PORT_ALL) {
16356 RTE_ETH_FOREACH_DEV(pid) {
16357 /* check if need_reconfig has been set to 1 */
16358 if (ports[pid].need_reconfig == 0)
16359 ports[pid].need_reconfig = dev;
16360 /* check if need_reconfig_queues has been set to 1 */
16361 if (ports[pid].need_reconfig_queues == 0)
16362 ports[pid].need_reconfig_queues = queue;
16364 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16365 /* check if need_reconfig has been set to 1 */
16366 if (ports[id].need_reconfig == 0)
16367 ports[id].need_reconfig = dev;
16368 /* check if need_reconfig_queues has been set to 1 */
16369 if (ports[id].need_reconfig_queues == 0)
16370 ports[id].need_reconfig_queues = queue;