4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 #include <net/socket.h>
47 #include <sys/socket.h>
50 #include <netinet/in.h>
52 #include <sys/queue.h>
54 #include <rte_common.h>
55 #include <rte_byteorder.h>
57 #include <rte_debug.h>
58 #include <rte_cycles.h>
59 #include <rte_memory.h>
60 #include <rte_memzone.h>
61 #include <rte_malloc.h>
62 #include <rte_launch.h>
64 #include <rte_per_lcore.h>
65 #include <rte_lcore.h>
66 #include <rte_atomic.h>
67 #include <rte_branch_prediction.h>
69 #include <rte_mempool.h>
70 #include <rte_interrupts.h>
72 #include <rte_ether.h>
73 #include <rte_ethdev.h>
74 #include <rte_string_fns.h>
75 #include <rte_devargs.h>
76 #include <rte_eth_ctrl.h>
80 #include <cmdline_rdline.h>
81 #include <cmdline_parse.h>
82 #include <cmdline_parse_num.h>
83 #include <cmdline_parse_string.h>
84 #include <cmdline_parse_ipaddr.h>
85 #include <cmdline_parse_etheraddr.h>
86 #include <cmdline_socket.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
90 #include <rte_eth_bond_8023ad.h>
92 #ifdef RTE_LIBRTE_DPAA_PMD
93 #include <rte_pmd_dpaa.h>
95 #ifdef RTE_LIBRTE_IXGBE_PMD
96 #include <rte_pmd_ixgbe.h>
98 #ifdef RTE_LIBRTE_I40E_PMD
99 #include <rte_pmd_i40e.h>
101 #ifdef RTE_LIBRTE_BNXT_PMD
102 #include <rte_pmd_bnxt.h>
105 #include "cmdline_mtr.h"
106 #include "cmdline_tm.h"
108 static struct cmdline *testpmd_cl;
110 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
112 /* *** Help command with introduction. *** */
113 struct cmd_help_brief_result {
114 cmdline_fixed_string_t help;
117 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
119 __attribute__((unused)) void *data)
124 "Help is available for the following sections:\n\n"
125 " help control : Start and stop forwarding.\n"
126 " help display : Displaying port, stats and config "
128 " help config : Configuration information.\n"
129 " help ports : Configuring ports.\n"
130 " help registers : Reading and setting port registers.\n"
131 " help filters : Filters configuration help.\n"
132 " help all : All of the above sections.\n\n"
137 cmdline_parse_token_string_t cmd_help_brief_help =
138 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
140 cmdline_parse_inst_t cmd_help_brief = {
141 .f = cmd_help_brief_parsed,
143 .help_str = "help: Show help",
145 (void *)&cmd_help_brief_help,
150 /* *** Help command with help sections. *** */
151 struct cmd_help_long_result {
152 cmdline_fixed_string_t help;
153 cmdline_fixed_string_t section;
156 static void cmd_help_long_parsed(void *parsed_result,
158 __attribute__((unused)) void *data)
161 struct cmd_help_long_result *res = parsed_result;
163 if (!strcmp(res->section, "all"))
166 if (show_all || !strcmp(res->section, "control")) {
171 "Control forwarding:\n"
172 "-------------------\n\n"
175 " Start packet forwarding with current configuration.\n\n"
178 " Start packet forwarding with current config"
179 " after sending one burst of packets.\n\n"
182 " Stop packet forwarding, and display accumulated"
186 " Quit to prompt.\n\n"
190 if (show_all || !strcmp(res->section, "display")) {
198 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
199 " Display information for port_id, or all.\n\n"
201 "show port X rss reta (size) (mask0,mask1,...)\n"
202 " Display the rss redirection table entry indicated"
203 " by masks on port X. size is used to indicate the"
204 " hardware supported reta size\n\n"
206 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
207 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
208 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
209 " Display the RSS hash functions and RSS hash key"
212 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
213 " Clear information for port_id, or all.\n\n"
215 "show (rxq|txq) info (port_id) (queue_id)\n"
216 " Display information for configured RX/TX queue.\n\n"
218 "show config (rxtx|cores|fwd|txpkts)\n"
219 " Display the given configuration.\n\n"
221 "read rxd (port_id) (queue_id) (rxd_id)\n"
222 " Display an RX descriptor of a port RX queue.\n\n"
224 "read txd (port_id) (queue_id) (txd_id)\n"
225 " Display a TX descriptor of a port TX queue.\n\n"
227 "ddp get list (port_id)\n"
228 " Get ddp profile info list\n\n"
230 "ddp get info (profile_path)\n"
231 " Get ddp profile information.\n\n"
233 "show vf stats (port_id) (vf_id)\n"
234 " Display a VF's statistics.\n\n"
236 "clear vf stats (port_id) (vf_id)\n"
237 " Reset a VF's statistics.\n\n"
239 "show port (port_id) pctype mapping\n"
240 " Get flow ptype to pctype mapping on a port\n\n"
242 "show port meter stats (port_id) (meter_id) (clear)\n"
243 " Get meter stats on a port\n\n"
244 "show port tm cap (port_id)\n"
245 " Display the port TM capability.\n\n"
247 "show port tm level cap (port_id) (level_id)\n"
248 " Display the port TM hierarchical level capability.\n\n"
250 "show port tm node cap (port_id) (node_id)\n"
251 " Display the port TM node capability.\n\n"
253 "show port tm node type (port_id) (node_id)\n"
254 " Display the port TM node type.\n\n"
256 "show port tm node stats (port_id) (node_id) (clear)\n"
257 " Display the port TM node stats.\n\n"
262 if (show_all || !strcmp(res->section, "config")) {
268 "Configuration changes only become active when"
269 " forwarding is started/restarted.\n\n"
272 " Reset forwarding to the default configuration.\n\n"
274 "set verbose (level)\n"
275 " Set the debug verbosity level X.\n\n"
278 " Set number of ports.\n\n"
281 " Set number of cores.\n\n"
283 "set coremask (mask)\n"
284 " Set the forwarding cores hexadecimal mask.\n\n"
286 "set portmask (mask)\n"
287 " Set the forwarding ports hexadecimal mask.\n\n"
290 " Set number of packets per burst.\n\n"
292 "set burst tx delay (microseconds) retry (num)\n"
293 " Set the transmit delay time and number of retries,"
294 " effective when retry is enabled.\n\n"
296 "set txpkts (x[,y]*)\n"
297 " Set the length of each segment of TXONLY"
298 " and optionally CSUM packets.\n\n"
300 "set txsplit (off|on|rand)\n"
301 " Set the split policy for the TX packets."
302 " Right now only applicable for CSUM and TXONLY"
305 "set corelist (x[,y]*)\n"
306 " Set the list of forwarding cores.\n\n"
308 "set portlist (x[,y]*)\n"
309 " Set the list of forwarding ports.\n\n"
311 "set tx loopback (port_id) (on|off)\n"
312 " Enable or disable tx loopback.\n\n"
314 "set all queues drop (port_id) (on|off)\n"
315 " Set drop enable bit for all queues.\n\n"
317 "set vf split drop (port_id) (vf_id) (on|off)\n"
318 " Set split drop enable bit for a VF from the PF.\n\n"
320 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
321 " Set MAC antispoof for a VF from the PF.\n\n"
323 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
324 " Enable MACsec offload.\n\n"
326 "set macsec offload (port_id) off\n"
327 " Disable MACsec offload.\n\n"
329 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
330 " Configure MACsec secure connection (SC).\n\n"
332 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
333 " Configure MACsec secure association (SA).\n\n"
335 "set vf broadcast (port_id) (vf_id) (on|off)\n"
336 " Set VF broadcast for a VF from the PF.\n\n"
338 "vlan set strip (on|off) (port_id)\n"
339 " Set the VLAN strip on a port.\n\n"
341 "vlan set stripq (on|off) (port_id,queue_id)\n"
342 " Set the VLAN strip for a queue on a port.\n\n"
344 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
345 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
347 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
348 " Set VLAN insert for a VF from the PF.\n\n"
350 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
351 " Set VLAN antispoof for a VF from the PF.\n\n"
353 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
354 " Set VLAN tag for a VF from the PF.\n\n"
356 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
357 " Set a VF's max bandwidth(Mbps).\n\n"
359 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
360 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
362 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
363 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
365 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
366 " Set some TCs' strict link priority mode on a physical port.\n\n"
368 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
369 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
371 "vlan set filter (on|off) (port_id)\n"
372 " Set the VLAN filter on a port.\n\n"
374 "vlan set qinq (on|off) (port_id)\n"
375 " Set the VLAN QinQ (extended queue in queue)"
378 "vlan set (inner|outer) tpid (value) (port_id)\n"
379 " Set the VLAN TPID for Packet Filtering on"
382 "rx_vlan add (vlan_id|all) (port_id)\n"
383 " Add a vlan_id, or all identifiers, to the set"
384 " of VLAN identifiers filtered by port_id.\n\n"
386 "rx_vlan rm (vlan_id|all) (port_id)\n"
387 " Remove a vlan_id, or all identifiers, from the set"
388 " of VLAN identifiers filtered by port_id.\n\n"
390 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
391 " Add a vlan_id, to the set of VLAN identifiers"
392 "filtered for VF(s) from port_id.\n\n"
394 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
395 " Remove a vlan_id, to the set of VLAN identifiers"
396 "filtered for VF(s) from port_id.\n\n"
398 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
399 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
400 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
401 " add a tunnel filter of a port.\n\n"
403 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
404 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
405 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
406 " remove a tunnel filter of a port.\n\n"
408 "rx_vxlan_port add (udp_port) (port_id)\n"
409 " Add an UDP port for VXLAN packet filter on a port\n\n"
411 "rx_vxlan_port rm (udp_port) (port_id)\n"
412 " Remove an UDP port for VXLAN packet filter on a port\n\n"
414 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
415 " Set hardware insertion of VLAN IDs (single or double VLAN "
416 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
418 "tx_vlan set pvid port_id vlan_id (on|off)\n"
419 " Set port based TX VLAN insertion.\n\n"
421 "tx_vlan reset (port_id)\n"
422 " Disable hardware insertion of a VLAN header in"
423 " packets sent on a port.\n\n"
425 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
426 " Select hardware or software calculation of the"
427 " checksum when transmitting a packet using the"
428 " csum forward engine.\n"
429 " ip|udp|tcp|sctp always concern the inner layer.\n"
430 " outer-ip concerns the outer IP layer in"
431 " case the packet is recognized as a tunnel packet by"
432 " the forward engine (vxlan, gre and ipip are supported)\n"
433 " Please check the NIC datasheet for HW limits.\n\n"
435 "csum parse-tunnel (on|off) (tx_port_id)\n"
436 " If disabled, treat tunnel packets as non-tunneled"
437 " packets (treat inner headers as payload). The port\n"
438 " argument is the port used for TX in csum forward"
441 "csum show (port_id)\n"
442 " Display tx checksum offload configuration\n\n"
444 "tso set (segsize) (portid)\n"
445 " Enable TCP Segmentation Offload in csum forward"
447 " Please check the NIC datasheet for HW limits.\n\n"
450 " Display the status of TCP Segmentation Offload.\n\n"
452 "set port (port_id) gro on|off\n"
453 " Enable or disable Generic Receive Offload in"
454 " csum forwarding engine.\n\n"
456 "show port (port_id) gro\n"
457 " Display GRO configuration.\n\n"
459 "set gro flush (cycles)\n"
460 " Set the cycle to flush GROed packets from"
461 " reassembly tables.\n\n"
463 "set port (port_id) gso (on|off)"
464 " Enable or disable Generic Segmentation Offload in"
465 " csum forwarding engine.\n\n"
467 "set gso segsz (length)\n"
468 " Set max packet length for output GSO segments,"
469 " including packet header and payload.\n\n"
471 "show port (port_id) gso\n"
472 " Show GSO configuration.\n\n"
475 " Set packet forwarding mode.\n\n"
477 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
478 " Add a MAC address on port_id.\n\n"
480 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
481 " Remove a MAC address from port_id.\n\n"
483 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
484 " Set the default MAC address for port_id.\n\n"
486 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
487 " Add a MAC address for a VF on the port.\n\n"
489 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
490 " Set the MAC address for a VF from the PF.\n\n"
492 "set eth-peer (port_id) (peer_addr)\n"
493 " set the peer address for certain port.\n\n"
495 "set port (port_id) uta (mac_address|all) (on|off)\n"
496 " Add/Remove a or all unicast hash filter(s)"
499 "set promisc (port_id|all) (on|off)\n"
500 " Set the promiscuous mode on port_id, or all.\n\n"
502 "set allmulti (port_id|all) (on|off)\n"
503 " Set the allmulti mode on port_id, or all.\n\n"
505 "set vf promisc (port_id) (vf_id) (on|off)\n"
506 " Set unicast promiscuous mode for a VF from the PF.\n\n"
508 "set vf allmulti (port_id) (vf_id) (on|off)\n"
509 " Set multicast promiscuous mode for a VF from the PF.\n\n"
511 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
512 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
513 " (on|off) autoneg (on|off) (port_id)\n"
514 "set flow_ctrl rx (on|off) (portid)\n"
515 "set flow_ctrl tx (on|off) (portid)\n"
516 "set flow_ctrl high_water (high_water) (portid)\n"
517 "set flow_ctrl low_water (low_water) (portid)\n"
518 "set flow_ctrl pause_time (pause_time) (portid)\n"
519 "set flow_ctrl send_xon (send_xon) (portid)\n"
520 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
521 "set flow_ctrl autoneg (on|off) (port_id)\n"
522 " Set the link flow control parameter on a port.\n\n"
524 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
525 " (low_water) (pause_time) (priority) (port_id)\n"
526 " Set the priority flow control parameter on a"
529 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
530 " Set statistics mapping (qmapping 0..15) for RX/TX"
532 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
533 " on port 0 to mapping 5.\n\n"
535 "set xstats-hide-zero on|off\n"
536 " Set the option to hide the zero values"
537 " for xstats display.\n"
539 "set port (port_id) vf (vf_id) rx|tx on|off\n"
540 " Enable/Disable a VF receive/tranmit from a port\n\n"
542 "set port (port_id) vf (vf_id) (mac_addr)"
543 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
544 " Add/Remove unicast or multicast MAC addr filter"
547 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
549 " AUPE:accepts untagged VLAN;"
550 "ROPE:accept unicast hash\n\n"
551 " BAM:accepts broadcast packets;"
552 "MPE:accepts all multicast packets\n\n"
553 " Enable/Disable a VF receive mode of a port\n\n"
555 "set port (port_id) queue (queue_id) rate (rate_num)\n"
556 " Set rate limit for a queue of a port\n\n"
558 "set port (port_id) vf (vf_id) rate (rate_num) "
559 "queue_mask (queue_mask_value)\n"
560 " Set rate limit for queues in VF of a port\n\n"
562 "set port (port_id) mirror-rule (rule_id)"
563 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
564 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
565 " Set pool or vlan type mirror rule on a port.\n"
566 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
567 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
570 "set port (port_id) mirror-rule (rule_id)"
571 " (uplink-mirror|downlink-mirror) dst-pool"
572 " (pool_id) (on|off)\n"
573 " Set uplink or downlink type mirror rule on a port.\n"
574 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
575 " 0 on' enable mirror income traffic to pool 0.\n\n"
577 "reset port (port_id) mirror-rule (rule_id)\n"
578 " Reset a mirror rule.\n\n"
580 "set flush_rx (on|off)\n"
581 " Flush (default) or don't flush RX streams before"
582 " forwarding. Mainly used with PCAP drivers.\n\n"
584 "set bypass mode (normal|bypass|isolate) (port_id)\n"
585 " Set the bypass mode for the lowest port on bypass enabled"
588 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
589 "mode (normal|bypass|isolate) (port_id)\n"
590 " Set the event required to initiate specified bypass mode for"
591 " the lowest port on a bypass enabled NIC where:\n"
592 " timeout = enable bypass after watchdog timeout.\n"
593 " os_on = enable bypass when OS/board is powered on.\n"
594 " os_off = enable bypass when OS/board is powered off.\n"
595 " power_on = enable bypass when power supply is turned on.\n"
596 " power_off = enable bypass when power supply is turned off."
599 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
600 " Set the bypass watchdog timeout to 'n' seconds"
601 " where 0 = instant.\n\n"
603 "show bypass config (port_id)\n"
604 " Show the bypass configuration for a bypass enabled NIC"
605 " using the lowest port on the NIC.\n\n"
607 #ifdef RTE_LIBRTE_PMD_BOND
608 "create bonded device (mode) (socket)\n"
609 " Create a new bonded device with specific bonding mode and socket.\n\n"
611 "add bonding slave (slave_id) (port_id)\n"
612 " Add a slave device to a bonded device.\n\n"
614 "remove bonding slave (slave_id) (port_id)\n"
615 " Remove a slave device from a bonded device.\n\n"
617 "set bonding mode (value) (port_id)\n"
618 " Set the bonding mode on a bonded device.\n\n"
620 "set bonding primary (slave_id) (port_id)\n"
621 " Set the primary slave for a bonded device.\n\n"
623 "show bonding config (port_id)\n"
624 " Show the bonding config for port_id.\n\n"
626 "set bonding mac_addr (port_id) (address)\n"
627 " Set the MAC address of a bonded device.\n\n"
629 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
630 " Set Aggregation mode for IEEE802.3AD (mode 4)"
632 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
633 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
635 "set bonding mon_period (port_id) (value)\n"
636 " Set the bonding link status monitoring polling period in ms.\n\n"
638 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
639 " Enable/disable dedicated queues for LACP control traffic.\n\n"
642 "set link-up port (port_id)\n"
643 " Set link up for a port.\n\n"
645 "set link-down port (port_id)\n"
646 " Set link down for a port.\n\n"
648 "E-tag set insertion on port-tag-id (value)"
649 " port (port_id) vf (vf_id)\n"
650 " Enable E-tag insertion for a VF on a port\n\n"
652 "E-tag set insertion off port (port_id) vf (vf_id)\n"
653 " Disable E-tag insertion for a VF on a port\n\n"
655 "E-tag set stripping (on|off) port (port_id)\n"
656 " Enable/disable E-tag stripping on a port\n\n"
658 "E-tag set forwarding (on|off) port (port_id)\n"
659 " Enable/disable E-tag based forwarding"
662 "E-tag set filter add e-tag-id (value) dst-pool"
663 " (pool_id) port (port_id)\n"
664 " Add an E-tag forwarding filter on a port\n\n"
666 "E-tag set filter del e-tag-id (value) port (port_id)\n"
667 " Delete an E-tag forwarding filter on a port\n\n"
669 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
670 "set port tm hierarchy default (port_id)\n"
671 " Set default traffic Management hierarchy on a port\n\n"
674 "ddp add (port_id) (profile_path[,output_path])\n"
675 " Load a profile package on a port\n\n"
677 "ddp del (port_id) (profile_path)\n"
678 " Delete a profile package from a port\n\n"
680 "ptype mapping get (port_id) (valid_only)\n"
681 " Get ptype mapping on a port\n\n"
683 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
684 " Replace target with the pkt_type in ptype mapping\n\n"
686 "ptype mapping reset (port_id)\n"
687 " Reset ptype mapping on a port\n\n"
689 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
690 " Update a ptype mapping item on a port\n\n"
692 "set port (port_id) queue-region region_id (value) "
693 "queue_start_index (value) queue_num (value)\n"
694 " Set a queue region on a port\n\n"
696 "set port (port_id) queue-region region_id (value) "
698 " Set a flowtype region index on a port\n\n"
700 "set port (port_id) queue-region UP (value) region_id (value)\n"
701 " Set the mapping of User Priority to "
702 "queue region on a port\n\n"
704 "set port (port_id) queue-region flush (on|off)\n"
705 " flush all queue region related configuration\n\n"
707 "show port meter cap (port_id)\n"
708 " Show port meter capability information\n\n"
710 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
711 " meter profile add - srtcm rfc 2697\n\n"
713 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
714 " meter profile add - trtcm rfc 2698\n\n"
716 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
717 " meter profile add - trtcm rfc 4115\n\n"
719 "del port meter profile (port_id) (profile_id)\n"
720 " meter profile delete\n\n"
722 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
723 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
724 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
725 "(dscp_tbl_entry63)]\n"
728 "enable port meter (port_id) (mtr_id)\n"
731 "disable port meter (port_id) (mtr_id)\n"
734 "del port meter (port_id) (mtr_id)\n"
737 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
738 " meter update meter profile\n\n"
740 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
741 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
742 " update meter dscp table entries\n\n"
744 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
745 "(action0) [(action1) (action2)]\n"
746 " meter update policer action\n\n"
748 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
749 " meter update stats\n\n"
751 "show port (port_id) queue-region\n"
752 " show all queue region related configuration info\n\n"
754 "add port tm node shaper profile (port_id) (shaper_profile_id)"
755 " (tb_rate) (tb_size) (packet_length_adjust)\n"
756 " Add port tm node private shaper profile.\n\n"
758 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
759 " Delete port tm node private shaper profile.\n\n"
761 "add port tm node shared shaper (port_id) (shared_shaper_id)"
762 " (shaper_profile_id)\n"
763 " Add/update port tm node shared shaper.\n\n"
765 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
766 " Delete port tm node shared shaper.\n\n"
768 "set port tm node shaper profile (port_id) (node_id)"
769 " (shaper_profile_id)\n"
770 " Set port tm node shaper profile.\n\n"
772 "add port tm node wred profile (port_id) (wred_profile_id)"
773 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
774 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
775 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
776 " Add port tm node wred profile.\n\n"
778 "del port tm node wred profile (port_id) (wred_profile_id)\n"
779 " Delete port tm node wred profile.\n\n"
781 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
782 " (priority) (weight) (level_id) (shaper_profile_id)"
783 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
784 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
785 " Add port tm nonleaf node.\n\n"
787 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
788 " (priority) (weight) (level_id) (shaper_profile_id)"
789 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
790 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
791 " Add port tm leaf node.\n\n"
793 "del port tm node (port_id) (node_id)\n"
794 " Delete port tm node.\n\n"
796 "set port tm node parent (port_id) (node_id) (parent_node_id)"
797 " (priority) (weight)\n"
798 " Set port tm node parent.\n\n"
800 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
801 " Commit tm hierarchy.\n\n"
803 , list_pkt_forwarding_modes()
807 if (show_all || !strcmp(res->section, "ports")) {
813 "----------------\n\n"
815 "port start (port_id|all)\n"
816 " Start all ports or port_id.\n\n"
818 "port stop (port_id|all)\n"
819 " Stop all ports or port_id.\n\n"
821 "port close (port_id|all)\n"
822 " Close all ports or port_id.\n\n"
824 "port attach (ident)\n"
825 " Attach physical or virtual dev by pci address or virtual device name\n\n"
827 "port detach (port_id)\n"
828 " Detach physical or virtual dev by port_id\n\n"
830 "port config (port_id|all)"
831 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
832 " duplex (half|full|auto)\n"
833 " Set speed and duplex for all ports or port_id\n\n"
835 "port config all (rxq|txq|rxd|txd) (value)\n"
836 " Set number for rxq/txq/rxd/txd.\n\n"
838 "port config all max-pkt-len (value)\n"
839 " Set the max packet length.\n\n"
841 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
842 "hw-vlan-strip|hw-vlan-extend|drop-en)"
844 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
847 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
848 "geneve|nvgre|none|<flowtype_id>)\n"
849 " Set the RSS mode.\n\n"
851 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
852 " Set the RSS redirection table.\n\n"
854 "port config (port_id) dcb vt (on|off) (traffic_class)"
856 " Set the DCB mode.\n\n"
858 "port config all burst (value)\n"
859 " Set the number of packets per burst.\n\n"
861 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
863 " Set the ring prefetch/host/writeback threshold"
864 " for tx/rx queue.\n\n"
866 "port config all (txfreet|txrst|rxfreet) (value)\n"
867 " Set free threshold for rx/tx, or set"
868 " tx rs bit threshold.\n\n"
869 "port config mtu X value\n"
870 " Set the MTU of port X to a given value\n\n"
872 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
873 " Start/stop a rx/tx queue of port X. Only take effect"
874 " when port X is started\n\n"
876 "port config (port_id|all) l2-tunnel E-tag ether-type"
878 " Set the value of E-tag ether-type.\n\n"
880 "port config (port_id|all) l2-tunnel E-tag"
881 " (enable|disable)\n"
882 " Enable/disable the E-tag support.\n\n"
884 "port config (port_id) pctype mapping reset\n"
885 " Reset flow type to pctype mapping on a port\n\n"
887 "port config (port_id) pctype mapping update"
888 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
889 " Update a flow type to pctype mapping item on a port\n\n"
893 if (show_all || !strcmp(res->section, "registers")) {
901 "read reg (port_id) (address)\n"
902 " Display value of a port register.\n\n"
904 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
905 " Display a port register bit field.\n\n"
907 "read regbit (port_id) (address) (bit_x)\n"
908 " Display a single port register bit.\n\n"
910 "write reg (port_id) (address) (value)\n"
911 " Set value of a port register.\n\n"
913 "write regfield (port_id) (address) (bit_x) (bit_y)"
915 " Set bit field of a port register.\n\n"
917 "write regbit (port_id) (address) (bit_x) (value)\n"
918 " Set single bit value of a port register.\n\n"
921 if (show_all || !strcmp(res->section, "filters")) {
929 "ethertype_filter (port_id) (add|del)"
930 " (mac_addr|mac_ignr) (mac_address) ethertype"
931 " (ether_type) (drop|fwd) queue (queue_id)\n"
932 " Add/Del an ethertype filter.\n\n"
934 "2tuple_filter (port_id) (add|del)"
935 " dst_port (dst_port_value) protocol (protocol_value)"
936 " mask (mask_value) tcp_flags (tcp_flags_value)"
937 " priority (prio_value) queue (queue_id)\n"
938 " Add/Del a 2tuple filter.\n\n"
940 "5tuple_filter (port_id) (add|del)"
941 " dst_ip (dst_address) src_ip (src_address)"
942 " dst_port (dst_port_value) src_port (src_port_value)"
943 " protocol (protocol_value)"
944 " mask (mask_value) tcp_flags (tcp_flags_value)"
945 " priority (prio_value) queue (queue_id)\n"
946 " Add/Del a 5tuple filter.\n\n"
948 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
949 " Add/Del syn filter.\n\n"
951 "flex_filter (port_id) (add|del) len (len_value)"
952 " bytes (bytes_value) mask (mask_value)"
953 " priority (prio_value) queue (queue_id)\n"
954 " Add/Del a flex filter.\n\n"
956 "flow_director_filter (port_id) mode IP (add|del|update)"
957 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
958 " src (src_ip_address) dst (dst_ip_address)"
959 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
960 " vlan (vlan_value) flexbytes (flexbytes_value)"
961 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
962 " fd_id (fd_id_value)\n"
963 " Add/Del an IP type flow director filter.\n\n"
965 "flow_director_filter (port_id) mode IP (add|del|update)"
966 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
967 " src (src_ip_address) (src_port)"
968 " dst (dst_ip_address) (dst_port)"
969 " tos (tos_value) ttl (ttl_value)"
970 " vlan (vlan_value) flexbytes (flexbytes_value)"
971 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
972 " fd_id (fd_id_value)\n"
973 " Add/Del an UDP/TCP type flow director filter.\n\n"
975 "flow_director_filter (port_id) mode IP (add|del|update)"
976 " flow (ipv4-sctp|ipv6-sctp)"
977 " src (src_ip_address) (src_port)"
978 " dst (dst_ip_address) (dst_port)"
979 " tag (verification_tag) "
980 " tos (tos_value) ttl (ttl_value)"
982 " flexbytes (flexbytes_value) (drop|fwd)"
983 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
984 " Add/Del a SCTP type flow director filter.\n\n"
986 "flow_director_filter (port_id) mode IP (add|del|update)"
987 " flow l2_payload ether (ethertype)"
988 " flexbytes (flexbytes_value) (drop|fwd)"
989 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
990 " Add/Del a l2 payload type flow director filter.\n\n"
992 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
993 " mac (mac_address) vlan (vlan_value)"
994 " flexbytes (flexbytes_value) (drop|fwd)"
995 " queue (queue_id) fd_id (fd_id_value)\n"
996 " Add/Del a MAC-VLAN flow director filter.\n\n"
998 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
999 " mac (mac_address) vlan (vlan_value)"
1000 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1001 " flexbytes (flexbytes_value) (drop|fwd)"
1002 " queue (queue_id) fd_id (fd_id_value)\n"
1003 " Add/Del a Tunnel flow director filter.\n\n"
1005 "flow_director_filter (port_id) mode raw (add|del|update)"
1006 " flow (flow_id) (drop|fwd) queue (queue_id)"
1007 " fd_id (fd_id_value) packet (packet file name)\n"
1008 " Add/Del a raw type flow director filter.\n\n"
1010 "flush_flow_director (port_id)\n"
1011 " Flush all flow director entries of a device.\n\n"
1013 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1014 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1015 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1016 " Set flow director IP mask.\n\n"
1018 "flow_director_mask (port_id) mode MAC-VLAN"
1019 " vlan (vlan_value)\n"
1020 " Set flow director MAC-VLAN mask.\n\n"
1022 "flow_director_mask (port_id) mode Tunnel"
1023 " vlan (vlan_value) mac (mac_value)"
1024 " tunnel-type (tunnel_type_value)"
1025 " tunnel-id (tunnel_id_value)\n"
1026 " Set flow director Tunnel mask.\n\n"
1028 "flow_director_flex_mask (port_id)"
1029 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1030 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1032 " Configure mask of flex payload.\n\n"
1034 "flow_director_flex_payload (port_id)"
1035 " (raw|l2|l3|l4) (config)\n"
1036 " Configure flex payload selection.\n\n"
1038 "get_sym_hash_ena_per_port (port_id)\n"
1039 " get symmetric hash enable configuration per port.\n\n"
1041 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1042 " set symmetric hash enable configuration per port"
1043 " to enable or disable.\n\n"
1045 "get_hash_global_config (port_id)\n"
1046 " Get the global configurations of hash filters.\n\n"
1048 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1049 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1050 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1051 " (enable|disable)\n"
1052 " Set the global configurations of hash filters.\n\n"
1054 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1055 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1056 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1057 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1058 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1059 "ipv6-next-header|udp-src-port|udp-dst-port|"
1060 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1061 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1062 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1063 "fld-8th|none) (select|add)\n"
1064 " Set the input set for hash.\n\n"
1066 "set_fdir_input_set (port_id) "
1067 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1068 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1069 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1070 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1071 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1072 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1073 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1075 " Set the input set for FDir.\n\n"
1077 "flow validate {port_id}"
1078 " [group {group_id}] [priority {level}]"
1079 " [ingress] [egress]"
1080 " pattern {item} [/ {item} [...]] / end"
1081 " actions {action} [/ {action} [...]] / end\n"
1082 " Check whether a flow rule can be created.\n\n"
1084 "flow create {port_id}"
1085 " [group {group_id}] [priority {level}]"
1086 " [ingress] [egress]"
1087 " pattern {item} [/ {item} [...]] / end"
1088 " actions {action} [/ {action} [...]] / end\n"
1089 " Create a flow rule.\n\n"
1091 "flow destroy {port_id} rule {rule_id} [...]\n"
1092 " Destroy specific flow rules.\n\n"
1094 "flow flush {port_id}\n"
1095 " Destroy all flow rules.\n\n"
1097 "flow query {port_id} {rule_id} {action}\n"
1098 " Query an existing flow rule.\n\n"
1100 "flow list {port_id} [group {group_id}] [...]\n"
1101 " List existing flow rules sorted by priority,"
1102 " filtered by group identifiers.\n\n"
1104 "flow isolate {port_id} {boolean}\n"
1105 " Restrict ingress traffic to the defined"
1111 cmdline_parse_token_string_t cmd_help_long_help =
1112 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1114 cmdline_parse_token_string_t cmd_help_long_section =
1115 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1116 "all#control#display#config#"
1117 "ports#registers#filters");
1119 cmdline_parse_inst_t cmd_help_long = {
1120 .f = cmd_help_long_parsed,
1122 .help_str = "help all|control|display|config|ports|register|filters: "
1125 (void *)&cmd_help_long_help,
1126 (void *)&cmd_help_long_section,
1132 /* *** start/stop/close all ports *** */
1133 struct cmd_operate_port_result {
1134 cmdline_fixed_string_t keyword;
1135 cmdline_fixed_string_t name;
1136 cmdline_fixed_string_t value;
1139 static void cmd_operate_port_parsed(void *parsed_result,
1140 __attribute__((unused)) struct cmdline *cl,
1141 __attribute__((unused)) void *data)
1143 struct cmd_operate_port_result *res = parsed_result;
1145 if (!strcmp(res->name, "start"))
1146 start_port(RTE_PORT_ALL);
1147 else if (!strcmp(res->name, "stop"))
1148 stop_port(RTE_PORT_ALL);
1149 else if (!strcmp(res->name, "close"))
1150 close_port(RTE_PORT_ALL);
1151 else if (!strcmp(res->name, "reset"))
1152 reset_port(RTE_PORT_ALL);
1154 printf("Unknown parameter\n");
1157 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1158 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1160 cmdline_parse_token_string_t cmd_operate_port_all_port =
1161 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1162 "start#stop#close#reset");
1163 cmdline_parse_token_string_t cmd_operate_port_all_all =
1164 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1166 cmdline_parse_inst_t cmd_operate_port = {
1167 .f = cmd_operate_port_parsed,
1169 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1171 (void *)&cmd_operate_port_all_cmd,
1172 (void *)&cmd_operate_port_all_port,
1173 (void *)&cmd_operate_port_all_all,
1178 /* *** start/stop/close specific port *** */
1179 struct cmd_operate_specific_port_result {
1180 cmdline_fixed_string_t keyword;
1181 cmdline_fixed_string_t name;
1185 static void cmd_operate_specific_port_parsed(void *parsed_result,
1186 __attribute__((unused)) struct cmdline *cl,
1187 __attribute__((unused)) void *data)
1189 struct cmd_operate_specific_port_result *res = parsed_result;
1191 if (!strcmp(res->name, "start"))
1192 start_port(res->value);
1193 else if (!strcmp(res->name, "stop"))
1194 stop_port(res->value);
1195 else if (!strcmp(res->name, "close"))
1196 close_port(res->value);
1197 else if (!strcmp(res->name, "reset"))
1198 reset_port(res->value);
1200 printf("Unknown parameter\n");
1203 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1204 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1206 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1207 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1208 name, "start#stop#close#reset");
1209 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1210 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1213 cmdline_parse_inst_t cmd_operate_specific_port = {
1214 .f = cmd_operate_specific_port_parsed,
1216 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1218 (void *)&cmd_operate_specific_port_cmd,
1219 (void *)&cmd_operate_specific_port_port,
1220 (void *)&cmd_operate_specific_port_id,
1225 /* *** attach a specified port *** */
1226 struct cmd_operate_attach_port_result {
1227 cmdline_fixed_string_t port;
1228 cmdline_fixed_string_t keyword;
1229 cmdline_fixed_string_t identifier;
1232 static void cmd_operate_attach_port_parsed(void *parsed_result,
1233 __attribute__((unused)) struct cmdline *cl,
1234 __attribute__((unused)) void *data)
1236 struct cmd_operate_attach_port_result *res = parsed_result;
1238 if (!strcmp(res->keyword, "attach"))
1239 attach_port(res->identifier);
1241 printf("Unknown parameter\n");
1244 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1245 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1247 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1248 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1250 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1251 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1254 cmdline_parse_inst_t cmd_operate_attach_port = {
1255 .f = cmd_operate_attach_port_parsed,
1257 .help_str = "port attach <identifier>: "
1258 "(identifier: pci address or virtual dev name)",
1260 (void *)&cmd_operate_attach_port_port,
1261 (void *)&cmd_operate_attach_port_keyword,
1262 (void *)&cmd_operate_attach_port_identifier,
1267 /* *** detach a specified port *** */
1268 struct cmd_operate_detach_port_result {
1269 cmdline_fixed_string_t port;
1270 cmdline_fixed_string_t keyword;
1274 static void cmd_operate_detach_port_parsed(void *parsed_result,
1275 __attribute__((unused)) struct cmdline *cl,
1276 __attribute__((unused)) void *data)
1278 struct cmd_operate_detach_port_result *res = parsed_result;
1280 if (!strcmp(res->keyword, "detach"))
1281 detach_port(res->port_id);
1283 printf("Unknown parameter\n");
1286 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1287 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1289 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1290 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1292 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1293 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1296 cmdline_parse_inst_t cmd_operate_detach_port = {
1297 .f = cmd_operate_detach_port_parsed,
1299 .help_str = "port detach <port_id>",
1301 (void *)&cmd_operate_detach_port_port,
1302 (void *)&cmd_operate_detach_port_keyword,
1303 (void *)&cmd_operate_detach_port_port_id,
1308 /* *** configure speed for all ports *** */
1309 struct cmd_config_speed_all {
1310 cmdline_fixed_string_t port;
1311 cmdline_fixed_string_t keyword;
1312 cmdline_fixed_string_t all;
1313 cmdline_fixed_string_t item1;
1314 cmdline_fixed_string_t item2;
1315 cmdline_fixed_string_t value1;
1316 cmdline_fixed_string_t value2;
1320 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1325 if (!strcmp(duplexstr, "half")) {
1326 duplex = ETH_LINK_HALF_DUPLEX;
1327 } else if (!strcmp(duplexstr, "full")) {
1328 duplex = ETH_LINK_FULL_DUPLEX;
1329 } else if (!strcmp(duplexstr, "auto")) {
1330 duplex = ETH_LINK_FULL_DUPLEX;
1332 printf("Unknown duplex parameter\n");
1336 if (!strcmp(speedstr, "10")) {
1337 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1338 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1339 } else if (!strcmp(speedstr, "100")) {
1340 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1341 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1343 if (duplex != ETH_LINK_FULL_DUPLEX) {
1344 printf("Invalid speed/duplex parameters\n");
1347 if (!strcmp(speedstr, "1000")) {
1348 *speed = ETH_LINK_SPEED_1G;
1349 } else if (!strcmp(speedstr, "10000")) {
1350 *speed = ETH_LINK_SPEED_10G;
1351 } else if (!strcmp(speedstr, "25000")) {
1352 *speed = ETH_LINK_SPEED_25G;
1353 } else if (!strcmp(speedstr, "40000")) {
1354 *speed = ETH_LINK_SPEED_40G;
1355 } else if (!strcmp(speedstr, "50000")) {
1356 *speed = ETH_LINK_SPEED_50G;
1357 } else if (!strcmp(speedstr, "100000")) {
1358 *speed = ETH_LINK_SPEED_100G;
1359 } else if (!strcmp(speedstr, "auto")) {
1360 *speed = ETH_LINK_SPEED_AUTONEG;
1362 printf("Unknown speed parameter\n");
1371 cmd_config_speed_all_parsed(void *parsed_result,
1372 __attribute__((unused)) struct cmdline *cl,
1373 __attribute__((unused)) void *data)
1375 struct cmd_config_speed_all *res = parsed_result;
1376 uint32_t link_speed;
1379 if (!all_ports_stopped()) {
1380 printf("Please stop all ports first\n");
1384 if (parse_and_check_speed_duplex(res->value1, res->value2,
1388 RTE_ETH_FOREACH_DEV(pid) {
1389 ports[pid].dev_conf.link_speeds = link_speed;
1392 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1395 cmdline_parse_token_string_t cmd_config_speed_all_port =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1397 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1398 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1400 cmdline_parse_token_string_t cmd_config_speed_all_all =
1401 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1402 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1403 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1404 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1405 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1406 "10#100#1000#10000#25000#40000#50000#100000#auto");
1407 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1408 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1409 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1410 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1413 cmdline_parse_inst_t cmd_config_speed_all = {
1414 .f = cmd_config_speed_all_parsed,
1416 .help_str = "port config all speed "
1417 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1420 (void *)&cmd_config_speed_all_port,
1421 (void *)&cmd_config_speed_all_keyword,
1422 (void *)&cmd_config_speed_all_all,
1423 (void *)&cmd_config_speed_all_item1,
1424 (void *)&cmd_config_speed_all_value1,
1425 (void *)&cmd_config_speed_all_item2,
1426 (void *)&cmd_config_speed_all_value2,
1431 /* *** configure speed for specific port *** */
1432 struct cmd_config_speed_specific {
1433 cmdline_fixed_string_t port;
1434 cmdline_fixed_string_t keyword;
1436 cmdline_fixed_string_t item1;
1437 cmdline_fixed_string_t item2;
1438 cmdline_fixed_string_t value1;
1439 cmdline_fixed_string_t value2;
1443 cmd_config_speed_specific_parsed(void *parsed_result,
1444 __attribute__((unused)) struct cmdline *cl,
1445 __attribute__((unused)) void *data)
1447 struct cmd_config_speed_specific *res = parsed_result;
1448 uint32_t link_speed;
1450 if (!all_ports_stopped()) {
1451 printf("Please stop all ports first\n");
1455 if (port_id_is_invalid(res->id, ENABLED_WARN))
1458 if (parse_and_check_speed_duplex(res->value1, res->value2,
1462 ports[res->id].dev_conf.link_speeds = link_speed;
1464 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1468 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1471 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1474 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1475 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1476 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1477 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1479 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1480 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1481 "10#100#1000#10000#25000#40000#50000#100000#auto");
1482 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1483 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1485 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1486 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1489 cmdline_parse_inst_t cmd_config_speed_specific = {
1490 .f = cmd_config_speed_specific_parsed,
1492 .help_str = "port config <port_id> speed "
1493 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1496 (void *)&cmd_config_speed_specific_port,
1497 (void *)&cmd_config_speed_specific_keyword,
1498 (void *)&cmd_config_speed_specific_id,
1499 (void *)&cmd_config_speed_specific_item1,
1500 (void *)&cmd_config_speed_specific_value1,
1501 (void *)&cmd_config_speed_specific_item2,
1502 (void *)&cmd_config_speed_specific_value2,
1507 /* *** configure txq/rxq, txd/rxd *** */
1508 struct cmd_config_rx_tx {
1509 cmdline_fixed_string_t port;
1510 cmdline_fixed_string_t keyword;
1511 cmdline_fixed_string_t all;
1512 cmdline_fixed_string_t name;
1517 cmd_config_rx_tx_parsed(void *parsed_result,
1518 __attribute__((unused)) struct cmdline *cl,
1519 __attribute__((unused)) void *data)
1521 struct cmd_config_rx_tx *res = parsed_result;
1523 if (!all_ports_stopped()) {
1524 printf("Please stop all ports first\n");
1527 if (!strcmp(res->name, "rxq")) {
1528 if (!res->value && !nb_txq) {
1529 printf("Warning: Either rx or tx queues should be non zero\n");
1532 nb_rxq = res->value;
1534 else if (!strcmp(res->name, "txq")) {
1535 if (!res->value && !nb_rxq) {
1536 printf("Warning: Either rx or tx queues should be non zero\n");
1539 nb_txq = res->value;
1541 else if (!strcmp(res->name, "rxd")) {
1542 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1543 printf("rxd %d invalid - must be > 0 && <= %d\n",
1544 res->value, RTE_TEST_RX_DESC_MAX);
1547 nb_rxd = res->value;
1548 } else if (!strcmp(res->name, "txd")) {
1549 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1550 printf("txd %d invalid - must be > 0 && <= %d\n",
1551 res->value, RTE_TEST_TX_DESC_MAX);
1554 nb_txd = res->value;
1556 printf("Unknown parameter\n");
1564 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1567 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1568 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1569 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1571 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1572 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1573 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1574 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1576 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1577 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1579 cmdline_parse_inst_t cmd_config_rx_tx = {
1580 .f = cmd_config_rx_tx_parsed,
1582 .help_str = "port config all rxq|txq|rxd|txd <value>",
1584 (void *)&cmd_config_rx_tx_port,
1585 (void *)&cmd_config_rx_tx_keyword,
1586 (void *)&cmd_config_rx_tx_all,
1587 (void *)&cmd_config_rx_tx_name,
1588 (void *)&cmd_config_rx_tx_value,
1593 /* *** config max packet length *** */
1594 struct cmd_config_max_pkt_len_result {
1595 cmdline_fixed_string_t port;
1596 cmdline_fixed_string_t keyword;
1597 cmdline_fixed_string_t all;
1598 cmdline_fixed_string_t name;
1603 cmd_config_max_pkt_len_parsed(void *parsed_result,
1604 __attribute__((unused)) struct cmdline *cl,
1605 __attribute__((unused)) void *data)
1607 struct cmd_config_max_pkt_len_result *res = parsed_result;
1610 if (!all_ports_stopped()) {
1611 printf("Please stop all ports first\n");
1615 RTE_ETH_FOREACH_DEV(pid) {
1616 struct rte_port *port = &ports[pid];
1617 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1619 if (!strcmp(res->name, "max-pkt-len")) {
1620 if (res->value < ETHER_MIN_LEN) {
1621 printf("max-pkt-len can not be less than %d\n",
1625 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1628 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1629 if (res->value > ETHER_MAX_LEN)
1630 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1632 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1633 port->dev_conf.rxmode.offloads = rx_offloads;
1635 printf("Unknown parameter\n");
1642 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1645 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1646 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1648 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1649 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1651 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1652 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1654 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1655 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1657 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1658 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1661 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1662 .f = cmd_config_max_pkt_len_parsed,
1664 .help_str = "port config all max-pkt-len <value>",
1666 (void *)&cmd_config_max_pkt_len_port,
1667 (void *)&cmd_config_max_pkt_len_keyword,
1668 (void *)&cmd_config_max_pkt_len_all,
1669 (void *)&cmd_config_max_pkt_len_name,
1670 (void *)&cmd_config_max_pkt_len_value,
1675 /* *** configure port MTU *** */
1676 struct cmd_config_mtu_result {
1677 cmdline_fixed_string_t port;
1678 cmdline_fixed_string_t keyword;
1679 cmdline_fixed_string_t mtu;
1685 cmd_config_mtu_parsed(void *parsed_result,
1686 __attribute__((unused)) struct cmdline *cl,
1687 __attribute__((unused)) void *data)
1689 struct cmd_config_mtu_result *res = parsed_result;
1691 if (res->value < ETHER_MIN_LEN) {
1692 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1695 port_mtu_set(res->port_id, res->value);
1698 cmdline_parse_token_string_t cmd_config_mtu_port =
1699 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1701 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1702 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1704 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1705 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1707 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1708 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1709 cmdline_parse_token_num_t cmd_config_mtu_value =
1710 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1712 cmdline_parse_inst_t cmd_config_mtu = {
1713 .f = cmd_config_mtu_parsed,
1715 .help_str = "port config mtu <port_id> <value>",
1717 (void *)&cmd_config_mtu_port,
1718 (void *)&cmd_config_mtu_keyword,
1719 (void *)&cmd_config_mtu_mtu,
1720 (void *)&cmd_config_mtu_port_id,
1721 (void *)&cmd_config_mtu_value,
1726 /* *** configure rx mode *** */
1727 struct cmd_config_rx_mode_flag {
1728 cmdline_fixed_string_t port;
1729 cmdline_fixed_string_t keyword;
1730 cmdline_fixed_string_t all;
1731 cmdline_fixed_string_t name;
1732 cmdline_fixed_string_t value;
1736 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1737 __attribute__((unused)) struct cmdline *cl,
1738 __attribute__((unused)) void *data)
1740 struct cmd_config_rx_mode_flag *res = parsed_result;
1743 if (!all_ports_stopped()) {
1744 printf("Please stop all ports first\n");
1748 RTE_ETH_FOREACH_DEV(pid) {
1749 struct rte_port *port;
1750 uint64_t rx_offloads;
1753 rx_offloads = port->dev_conf.rxmode.offloads;
1754 if (!strcmp(res->name, "crc-strip")) {
1755 if (!strcmp(res->value, "on"))
1756 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1757 else if (!strcmp(res->value, "off"))
1758 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1760 printf("Unknown parameter\n");
1763 } else if (!strcmp(res->name, "scatter")) {
1764 if (!strcmp(res->value, "on")) {
1765 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1766 } else if (!strcmp(res->value, "off")) {
1767 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1769 printf("Unknown parameter\n");
1772 } else if (!strcmp(res->name, "rx-cksum")) {
1773 if (!strcmp(res->value, "on"))
1774 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1775 else if (!strcmp(res->value, "off"))
1776 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1778 printf("Unknown parameter\n");
1781 } else if (!strcmp(res->name, "rx-timestamp")) {
1782 if (!strcmp(res->value, "on"))
1783 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1784 else if (!strcmp(res->value, "off"))
1785 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1787 printf("Unknown parameter\n");
1790 } else if (!strcmp(res->name, "hw-vlan")) {
1791 if (!strcmp(res->value, "on")) {
1792 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1793 DEV_RX_OFFLOAD_VLAN_STRIP);
1794 } else if (!strcmp(res->value, "off")) {
1795 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1796 DEV_RX_OFFLOAD_VLAN_STRIP);
1798 printf("Unknown parameter\n");
1801 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1802 if (!strcmp(res->value, "on"))
1803 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1804 else if (!strcmp(res->value, "off"))
1805 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1807 printf("Unknown parameter\n");
1810 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1811 if (!strcmp(res->value, "on"))
1812 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1813 else if (!strcmp(res->value, "off"))
1814 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1816 printf("Unknown parameter\n");
1819 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1820 if (!strcmp(res->value, "on"))
1821 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1822 else if (!strcmp(res->value, "off"))
1823 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1825 printf("Unknown parameter\n");
1828 } else if (!strcmp(res->name, "drop-en")) {
1829 if (!strcmp(res->value, "on"))
1831 else if (!strcmp(res->value, "off"))
1834 printf("Unknown parameter\n");
1838 printf("Unknown parameter\n");
1841 port->dev_conf.rxmode.offloads = rx_offloads;
1846 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1849 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1850 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1851 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1852 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1854 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1856 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1857 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1858 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1859 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1860 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1861 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1864 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1865 .f = cmd_config_rx_mode_flag_parsed,
1867 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1868 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1870 (void *)&cmd_config_rx_mode_flag_port,
1871 (void *)&cmd_config_rx_mode_flag_keyword,
1872 (void *)&cmd_config_rx_mode_flag_all,
1873 (void *)&cmd_config_rx_mode_flag_name,
1874 (void *)&cmd_config_rx_mode_flag_value,
1879 /* *** configure rss *** */
1880 struct cmd_config_rss {
1881 cmdline_fixed_string_t port;
1882 cmdline_fixed_string_t keyword;
1883 cmdline_fixed_string_t all;
1884 cmdline_fixed_string_t name;
1885 cmdline_fixed_string_t value;
1889 cmd_config_rss_parsed(void *parsed_result,
1890 __attribute__((unused)) struct cmdline *cl,
1891 __attribute__((unused)) void *data)
1893 struct cmd_config_rss *res = parsed_result;
1894 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1898 if (!strcmp(res->value, "all"))
1899 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1900 ETH_RSS_UDP | ETH_RSS_SCTP |
1902 else if (!strcmp(res->value, "ip"))
1903 rss_conf.rss_hf = ETH_RSS_IP;
1904 else if (!strcmp(res->value, "udp"))
1905 rss_conf.rss_hf = ETH_RSS_UDP;
1906 else if (!strcmp(res->value, "tcp"))
1907 rss_conf.rss_hf = ETH_RSS_TCP;
1908 else if (!strcmp(res->value, "sctp"))
1909 rss_conf.rss_hf = ETH_RSS_SCTP;
1910 else if (!strcmp(res->value, "ether"))
1911 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1912 else if (!strcmp(res->value, "port"))
1913 rss_conf.rss_hf = ETH_RSS_PORT;
1914 else if (!strcmp(res->value, "vxlan"))
1915 rss_conf.rss_hf = ETH_RSS_VXLAN;
1916 else if (!strcmp(res->value, "geneve"))
1917 rss_conf.rss_hf = ETH_RSS_GENEVE;
1918 else if (!strcmp(res->value, "nvgre"))
1919 rss_conf.rss_hf = ETH_RSS_NVGRE;
1920 else if (!strcmp(res->value, "none"))
1921 rss_conf.rss_hf = 0;
1922 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1923 atoi(res->value) < 64)
1924 rss_conf.rss_hf = 1ULL << atoi(res->value);
1926 printf("Unknown parameter\n");
1929 rss_conf.rss_key = NULL;
1930 for (i = 0; i < rte_eth_dev_count(); i++) {
1931 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1933 printf("Configuration of RSS hash at ethernet port %d "
1934 "failed with error (%d): %s.\n",
1935 i, -diag, strerror(-diag));
1939 cmdline_parse_token_string_t cmd_config_rss_port =
1940 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1941 cmdline_parse_token_string_t cmd_config_rss_keyword =
1942 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1943 cmdline_parse_token_string_t cmd_config_rss_all =
1944 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1945 cmdline_parse_token_string_t cmd_config_rss_name =
1946 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1947 cmdline_parse_token_string_t cmd_config_rss_value =
1948 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1950 cmdline_parse_inst_t cmd_config_rss = {
1951 .f = cmd_config_rss_parsed,
1953 .help_str = "port config all rss "
1954 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1956 (void *)&cmd_config_rss_port,
1957 (void *)&cmd_config_rss_keyword,
1958 (void *)&cmd_config_rss_all,
1959 (void *)&cmd_config_rss_name,
1960 (void *)&cmd_config_rss_value,
1965 /* *** configure rss hash key *** */
1966 struct cmd_config_rss_hash_key {
1967 cmdline_fixed_string_t port;
1968 cmdline_fixed_string_t config;
1970 cmdline_fixed_string_t rss_hash_key;
1971 cmdline_fixed_string_t rss_type;
1972 cmdline_fixed_string_t key;
1976 hexa_digit_to_value(char hexa_digit)
1978 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1979 return (uint8_t) (hexa_digit - '0');
1980 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1981 return (uint8_t) ((hexa_digit - 'a') + 10);
1982 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1983 return (uint8_t) ((hexa_digit - 'A') + 10);
1984 /* Invalid hexa digit */
1989 parse_and_check_key_hexa_digit(char *key, int idx)
1993 hexa_v = hexa_digit_to_value(key[idx]);
1995 printf("invalid key: character %c at position %d is not a "
1996 "valid hexa digit\n", key[idx], idx);
2001 cmd_config_rss_hash_key_parsed(void *parsed_result,
2002 __attribute__((unused)) struct cmdline *cl,
2003 __attribute__((unused)) void *data)
2005 struct cmd_config_rss_hash_key *res = parsed_result;
2006 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2010 struct rte_eth_dev_info dev_info;
2011 uint8_t hash_key_size;
2014 memset(&dev_info, 0, sizeof(dev_info));
2015 rte_eth_dev_info_get(res->port_id, &dev_info);
2016 if (dev_info.hash_key_size > 0 &&
2017 dev_info.hash_key_size <= sizeof(hash_key))
2018 hash_key_size = dev_info.hash_key_size;
2020 printf("dev_info did not provide a valid hash key size\n");
2023 /* Check the length of the RSS hash key */
2024 key_len = strlen(res->key);
2025 if (key_len != (hash_key_size * 2)) {
2026 printf("key length: %d invalid - key must be a string of %d"
2027 " hexa-decimal numbers\n",
2028 (int) key_len, hash_key_size * 2);
2031 /* Translate RSS hash key into binary representation */
2032 for (i = 0; i < hash_key_size; i++) {
2033 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2036 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2039 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2041 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2045 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2046 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2047 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2048 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2050 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2051 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2052 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2053 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2054 rss_hash_key, "rss-hash-key");
2055 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2056 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2057 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2058 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2059 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2060 "ipv6-tcp-ex#ipv6-udp-ex");
2061 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2062 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2064 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2065 .f = cmd_config_rss_hash_key_parsed,
2067 .help_str = "port config <port_id> rss-hash-key "
2068 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2069 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2070 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2071 "<string of hex digits (variable length, NIC dependent)>",
2073 (void *)&cmd_config_rss_hash_key_port,
2074 (void *)&cmd_config_rss_hash_key_config,
2075 (void *)&cmd_config_rss_hash_key_port_id,
2076 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2077 (void *)&cmd_config_rss_hash_key_rss_type,
2078 (void *)&cmd_config_rss_hash_key_value,
2083 /* *** configure port rxq/txq start/stop *** */
2084 struct cmd_config_rxtx_queue {
2085 cmdline_fixed_string_t port;
2087 cmdline_fixed_string_t rxtxq;
2089 cmdline_fixed_string_t opname;
2093 cmd_config_rxtx_queue_parsed(void *parsed_result,
2094 __attribute__((unused)) struct cmdline *cl,
2095 __attribute__((unused)) void *data)
2097 struct cmd_config_rxtx_queue *res = parsed_result;
2102 if (test_done == 0) {
2103 printf("Please stop forwarding first\n");
2107 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2110 if (port_is_started(res->portid) != 1) {
2111 printf("Please start port %u first\n", res->portid);
2115 if (!strcmp(res->rxtxq, "rxq"))
2117 else if (!strcmp(res->rxtxq, "txq"))
2120 printf("Unknown parameter\n");
2124 if (isrx && rx_queue_id_is_invalid(res->qid))
2126 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2129 if (!strcmp(res->opname, "start"))
2131 else if (!strcmp(res->opname, "stop"))
2134 printf("Unknown parameter\n");
2138 if (isstart && isrx)
2139 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2140 else if (!isstart && isrx)
2141 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2142 else if (isstart && !isrx)
2143 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2145 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2147 if (ret == -ENOTSUP)
2148 printf("Function not supported in PMD driver\n");
2151 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2152 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2153 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2154 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2155 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2156 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2157 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2158 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2159 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2160 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2163 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2164 .f = cmd_config_rxtx_queue_parsed,
2166 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2168 (void *)&cmd_config_speed_all_port,
2169 (void *)&cmd_config_rxtx_queue_portid,
2170 (void *)&cmd_config_rxtx_queue_rxtxq,
2171 (void *)&cmd_config_rxtx_queue_qid,
2172 (void *)&cmd_config_rxtx_queue_opname,
2177 /* *** Configure RSS RETA *** */
2178 struct cmd_config_rss_reta {
2179 cmdline_fixed_string_t port;
2180 cmdline_fixed_string_t keyword;
2182 cmdline_fixed_string_t name;
2183 cmdline_fixed_string_t list_name;
2184 cmdline_fixed_string_t list_of_items;
2188 parse_reta_config(const char *str,
2189 struct rte_eth_rss_reta_entry64 *reta_conf,
2190 uint16_t nb_entries)
2194 uint16_t hash_index, idx, shift;
2197 const char *p, *p0 = str;
2204 unsigned long int_fld[_NUM_FLD];
2205 char *str_fld[_NUM_FLD];
2207 while ((p = strchr(p0,'(')) != NULL) {
2209 if((p0 = strchr(p,')')) == NULL)
2213 if(size >= sizeof(s))
2216 snprintf(s, sizeof(s), "%.*s", size, p);
2217 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2219 for (i = 0; i < _NUM_FLD; i++) {
2221 int_fld[i] = strtoul(str_fld[i], &end, 0);
2222 if (errno != 0 || end == str_fld[i] ||
2227 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2228 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2230 if (hash_index >= nb_entries) {
2231 printf("Invalid RETA hash index=%d\n", hash_index);
2235 idx = hash_index / RTE_RETA_GROUP_SIZE;
2236 shift = hash_index % RTE_RETA_GROUP_SIZE;
2237 reta_conf[idx].mask |= (1ULL << shift);
2238 reta_conf[idx].reta[shift] = nb_queue;
2245 cmd_set_rss_reta_parsed(void *parsed_result,
2246 __attribute__((unused)) struct cmdline *cl,
2247 __attribute__((unused)) void *data)
2250 struct rte_eth_dev_info dev_info;
2251 struct rte_eth_rss_reta_entry64 reta_conf[8];
2252 struct cmd_config_rss_reta *res = parsed_result;
2254 memset(&dev_info, 0, sizeof(dev_info));
2255 rte_eth_dev_info_get(res->port_id, &dev_info);
2256 if (dev_info.reta_size == 0) {
2257 printf("Redirection table size is 0 which is "
2258 "invalid for RSS\n");
2261 printf("The reta size of port %d is %u\n",
2262 res->port_id, dev_info.reta_size);
2263 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2264 printf("Currently do not support more than %u entries of "
2265 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2269 memset(reta_conf, 0, sizeof(reta_conf));
2270 if (!strcmp(res->list_name, "reta")) {
2271 if (parse_reta_config(res->list_of_items, reta_conf,
2272 dev_info.reta_size)) {
2273 printf("Invalid RSS Redirection Table "
2274 "config entered\n");
2277 ret = rte_eth_dev_rss_reta_update(res->port_id,
2278 reta_conf, dev_info.reta_size);
2280 printf("Bad redirection table parameter, "
2281 "return code = %d \n", ret);
2285 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2286 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2287 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2288 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2289 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2290 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2291 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2292 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2293 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2294 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2295 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2296 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2298 cmdline_parse_inst_t cmd_config_rss_reta = {
2299 .f = cmd_set_rss_reta_parsed,
2301 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2303 (void *)&cmd_config_rss_reta_port,
2304 (void *)&cmd_config_rss_reta_keyword,
2305 (void *)&cmd_config_rss_reta_port_id,
2306 (void *)&cmd_config_rss_reta_name,
2307 (void *)&cmd_config_rss_reta_list_name,
2308 (void *)&cmd_config_rss_reta_list_of_items,
2313 /* *** SHOW PORT RETA INFO *** */
2314 struct cmd_showport_reta {
2315 cmdline_fixed_string_t show;
2316 cmdline_fixed_string_t port;
2318 cmdline_fixed_string_t rss;
2319 cmdline_fixed_string_t reta;
2321 cmdline_fixed_string_t list_of_items;
2325 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2326 uint16_t nb_entries,
2330 const char *p, *p0 = str;
2335 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2336 RTE_RETA_GROUP_SIZE;
2339 p = strchr(p0, '(');
2343 p0 = strchr(p, ')');
2347 if (size >= sizeof(s)) {
2348 printf("The string size exceeds the internal buffer size\n");
2351 snprintf(s, sizeof(s), "%.*s", size, p);
2352 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2353 if (ret <= 0 || ret != num) {
2354 printf("The bits of masks do not match the number of "
2355 "reta entries: %u\n", num);
2358 for (i = 0; i < ret; i++)
2359 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2365 cmd_showport_reta_parsed(void *parsed_result,
2366 __attribute__((unused)) struct cmdline *cl,
2367 __attribute__((unused)) void *data)
2369 struct cmd_showport_reta *res = parsed_result;
2370 struct rte_eth_rss_reta_entry64 reta_conf[8];
2371 struct rte_eth_dev_info dev_info;
2372 uint16_t max_reta_size;
2374 memset(&dev_info, 0, sizeof(dev_info));
2375 rte_eth_dev_info_get(res->port_id, &dev_info);
2376 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2377 if (res->size == 0 || res->size > max_reta_size) {
2378 printf("Invalid redirection table size: %u (1-%u)\n",
2379 res->size, max_reta_size);
2383 memset(reta_conf, 0, sizeof(reta_conf));
2384 if (showport_parse_reta_config(reta_conf, res->size,
2385 res->list_of_items) < 0) {
2386 printf("Invalid string: %s for reta masks\n",
2387 res->list_of_items);
2390 port_rss_reta_info(res->port_id, reta_conf, res->size);
2393 cmdline_parse_token_string_t cmd_showport_reta_show =
2394 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2395 cmdline_parse_token_string_t cmd_showport_reta_port =
2396 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2397 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2398 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2399 cmdline_parse_token_string_t cmd_showport_reta_rss =
2400 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2401 cmdline_parse_token_string_t cmd_showport_reta_reta =
2402 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2403 cmdline_parse_token_num_t cmd_showport_reta_size =
2404 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2405 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2406 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2407 list_of_items, NULL);
2409 cmdline_parse_inst_t cmd_showport_reta = {
2410 .f = cmd_showport_reta_parsed,
2412 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2414 (void *)&cmd_showport_reta_show,
2415 (void *)&cmd_showport_reta_port,
2416 (void *)&cmd_showport_reta_port_id,
2417 (void *)&cmd_showport_reta_rss,
2418 (void *)&cmd_showport_reta_reta,
2419 (void *)&cmd_showport_reta_size,
2420 (void *)&cmd_showport_reta_list_of_items,
2425 /* *** Show RSS hash configuration *** */
2426 struct cmd_showport_rss_hash {
2427 cmdline_fixed_string_t show;
2428 cmdline_fixed_string_t port;
2430 cmdline_fixed_string_t rss_hash;
2431 cmdline_fixed_string_t rss_type;
2432 cmdline_fixed_string_t key; /* optional argument */
2435 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2436 __attribute__((unused)) struct cmdline *cl,
2439 struct cmd_showport_rss_hash *res = parsed_result;
2441 port_rss_hash_conf_show(res->port_id, res->rss_type,
2442 show_rss_key != NULL);
2445 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2446 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2447 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2448 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2449 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2450 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2451 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2452 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2454 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2455 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2456 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2457 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2458 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2459 "ipv6-tcp-ex#ipv6-udp-ex");
2460 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2461 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2463 cmdline_parse_inst_t cmd_showport_rss_hash = {
2464 .f = cmd_showport_rss_hash_parsed,
2466 .help_str = "show port <port_id> rss-hash "
2467 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2468 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2469 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2471 (void *)&cmd_showport_rss_hash_show,
2472 (void *)&cmd_showport_rss_hash_port,
2473 (void *)&cmd_showport_rss_hash_port_id,
2474 (void *)&cmd_showport_rss_hash_rss_hash,
2475 (void *)&cmd_showport_rss_hash_rss_hash_info,
2480 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2481 .f = cmd_showport_rss_hash_parsed,
2483 .help_str = "show port <port_id> rss-hash "
2484 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2485 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2486 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2488 (void *)&cmd_showport_rss_hash_show,
2489 (void *)&cmd_showport_rss_hash_port,
2490 (void *)&cmd_showport_rss_hash_port_id,
2491 (void *)&cmd_showport_rss_hash_rss_hash,
2492 (void *)&cmd_showport_rss_hash_rss_hash_info,
2493 (void *)&cmd_showport_rss_hash_rss_key,
2498 /* *** Configure DCB *** */
2499 struct cmd_config_dcb {
2500 cmdline_fixed_string_t port;
2501 cmdline_fixed_string_t config;
2503 cmdline_fixed_string_t dcb;
2504 cmdline_fixed_string_t vt;
2505 cmdline_fixed_string_t vt_en;
2507 cmdline_fixed_string_t pfc;
2508 cmdline_fixed_string_t pfc_en;
2512 cmd_config_dcb_parsed(void *parsed_result,
2513 __attribute__((unused)) struct cmdline *cl,
2514 __attribute__((unused)) void *data)
2516 struct cmd_config_dcb *res = parsed_result;
2517 portid_t port_id = res->port_id;
2518 struct rte_port *port;
2522 port = &ports[port_id];
2523 /** Check if the port is not started **/
2524 if (port->port_status != RTE_PORT_STOPPED) {
2525 printf("Please stop port %d first\n", port_id);
2529 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2530 printf("The invalid number of traffic class,"
2531 " only 4 or 8 allowed.\n");
2535 if (nb_fwd_lcores < res->num_tcs) {
2536 printf("nb_cores shouldn't be less than number of TCs.\n");
2539 if (!strncmp(res->pfc_en, "on", 2))
2544 /* DCB in VT mode */
2545 if (!strncmp(res->vt_en, "on", 2))
2546 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2547 (enum rte_eth_nb_tcs)res->num_tcs,
2550 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2551 (enum rte_eth_nb_tcs)res->num_tcs,
2556 printf("Cannot initialize network ports.\n");
2560 cmd_reconfig_device_queue(port_id, 1, 1);
2563 cmdline_parse_token_string_t cmd_config_dcb_port =
2564 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2565 cmdline_parse_token_string_t cmd_config_dcb_config =
2566 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2567 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2568 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2569 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2570 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2571 cmdline_parse_token_string_t cmd_config_dcb_vt =
2572 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2573 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2574 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2575 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2576 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2577 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2578 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2579 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2580 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2582 cmdline_parse_inst_t cmd_config_dcb = {
2583 .f = cmd_config_dcb_parsed,
2585 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2587 (void *)&cmd_config_dcb_port,
2588 (void *)&cmd_config_dcb_config,
2589 (void *)&cmd_config_dcb_port_id,
2590 (void *)&cmd_config_dcb_dcb,
2591 (void *)&cmd_config_dcb_vt,
2592 (void *)&cmd_config_dcb_vt_en,
2593 (void *)&cmd_config_dcb_num_tcs,
2594 (void *)&cmd_config_dcb_pfc,
2595 (void *)&cmd_config_dcb_pfc_en,
2600 /* *** configure number of packets per burst *** */
2601 struct cmd_config_burst {
2602 cmdline_fixed_string_t port;
2603 cmdline_fixed_string_t keyword;
2604 cmdline_fixed_string_t all;
2605 cmdline_fixed_string_t name;
2610 cmd_config_burst_parsed(void *parsed_result,
2611 __attribute__((unused)) struct cmdline *cl,
2612 __attribute__((unused)) void *data)
2614 struct cmd_config_burst *res = parsed_result;
2616 if (!all_ports_stopped()) {
2617 printf("Please stop all ports first\n");
2621 if (!strcmp(res->name, "burst")) {
2622 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2623 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2626 nb_pkt_per_burst = res->value;
2628 printf("Unknown parameter\n");
2634 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2637 cmdline_parse_token_string_t cmd_config_burst_port =
2638 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2639 cmdline_parse_token_string_t cmd_config_burst_keyword =
2640 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2641 cmdline_parse_token_string_t cmd_config_burst_all =
2642 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2643 cmdline_parse_token_string_t cmd_config_burst_name =
2644 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2645 cmdline_parse_token_num_t cmd_config_burst_value =
2646 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2648 cmdline_parse_inst_t cmd_config_burst = {
2649 .f = cmd_config_burst_parsed,
2651 .help_str = "port config all burst <value>",
2653 (void *)&cmd_config_burst_port,
2654 (void *)&cmd_config_burst_keyword,
2655 (void *)&cmd_config_burst_all,
2656 (void *)&cmd_config_burst_name,
2657 (void *)&cmd_config_burst_value,
2662 /* *** configure rx/tx queues *** */
2663 struct cmd_config_thresh {
2664 cmdline_fixed_string_t port;
2665 cmdline_fixed_string_t keyword;
2666 cmdline_fixed_string_t all;
2667 cmdline_fixed_string_t name;
2672 cmd_config_thresh_parsed(void *parsed_result,
2673 __attribute__((unused)) struct cmdline *cl,
2674 __attribute__((unused)) void *data)
2676 struct cmd_config_thresh *res = parsed_result;
2678 if (!all_ports_stopped()) {
2679 printf("Please stop all ports first\n");
2683 if (!strcmp(res->name, "txpt"))
2684 tx_pthresh = res->value;
2685 else if(!strcmp(res->name, "txht"))
2686 tx_hthresh = res->value;
2687 else if(!strcmp(res->name, "txwt"))
2688 tx_wthresh = res->value;
2689 else if(!strcmp(res->name, "rxpt"))
2690 rx_pthresh = res->value;
2691 else if(!strcmp(res->name, "rxht"))
2692 rx_hthresh = res->value;
2693 else if(!strcmp(res->name, "rxwt"))
2694 rx_wthresh = res->value;
2696 printf("Unknown parameter\n");
2702 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2705 cmdline_parse_token_string_t cmd_config_thresh_port =
2706 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2707 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2708 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2709 cmdline_parse_token_string_t cmd_config_thresh_all =
2710 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2711 cmdline_parse_token_string_t cmd_config_thresh_name =
2712 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2713 "txpt#txht#txwt#rxpt#rxht#rxwt");
2714 cmdline_parse_token_num_t cmd_config_thresh_value =
2715 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2717 cmdline_parse_inst_t cmd_config_thresh = {
2718 .f = cmd_config_thresh_parsed,
2720 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2722 (void *)&cmd_config_thresh_port,
2723 (void *)&cmd_config_thresh_keyword,
2724 (void *)&cmd_config_thresh_all,
2725 (void *)&cmd_config_thresh_name,
2726 (void *)&cmd_config_thresh_value,
2731 /* *** configure free/rs threshold *** */
2732 struct cmd_config_threshold {
2733 cmdline_fixed_string_t port;
2734 cmdline_fixed_string_t keyword;
2735 cmdline_fixed_string_t all;
2736 cmdline_fixed_string_t name;
2741 cmd_config_threshold_parsed(void *parsed_result,
2742 __attribute__((unused)) struct cmdline *cl,
2743 __attribute__((unused)) void *data)
2745 struct cmd_config_threshold *res = parsed_result;
2747 if (!all_ports_stopped()) {
2748 printf("Please stop all ports first\n");
2752 if (!strcmp(res->name, "txfreet"))
2753 tx_free_thresh = res->value;
2754 else if (!strcmp(res->name, "txrst"))
2755 tx_rs_thresh = res->value;
2756 else if (!strcmp(res->name, "rxfreet"))
2757 rx_free_thresh = res->value;
2759 printf("Unknown parameter\n");
2765 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2768 cmdline_parse_token_string_t cmd_config_threshold_port =
2769 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2770 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2771 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2773 cmdline_parse_token_string_t cmd_config_threshold_all =
2774 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2775 cmdline_parse_token_string_t cmd_config_threshold_name =
2776 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2777 "txfreet#txrst#rxfreet");
2778 cmdline_parse_token_num_t cmd_config_threshold_value =
2779 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2781 cmdline_parse_inst_t cmd_config_threshold = {
2782 .f = cmd_config_threshold_parsed,
2784 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2786 (void *)&cmd_config_threshold_port,
2787 (void *)&cmd_config_threshold_keyword,
2788 (void *)&cmd_config_threshold_all,
2789 (void *)&cmd_config_threshold_name,
2790 (void *)&cmd_config_threshold_value,
2796 struct cmd_stop_result {
2797 cmdline_fixed_string_t stop;
2800 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2801 __attribute__((unused)) struct cmdline *cl,
2802 __attribute__((unused)) void *data)
2804 stop_packet_forwarding();
2807 cmdline_parse_token_string_t cmd_stop_stop =
2808 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2810 cmdline_parse_inst_t cmd_stop = {
2811 .f = cmd_stop_parsed,
2813 .help_str = "stop: Stop packet forwarding",
2815 (void *)&cmd_stop_stop,
2820 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2823 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2824 unsigned int *parsed_items, int check_unique_values)
2826 unsigned int nb_item;
2834 * First parse all items in the list and store their value.
2839 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2841 if ((c >= '0') && (c <= '9')) {
2842 value = (unsigned int) (value * 10 + (c - '0'));
2847 printf("character %c is not a decimal digit\n", c);
2851 printf("No valid value before comma\n");
2854 if (nb_item < max_items) {
2855 parsed_items[nb_item] = value;
2861 if (nb_item >= max_items) {
2862 printf("Number of %s = %u > %u (maximum items)\n",
2863 item_name, nb_item + 1, max_items);
2866 parsed_items[nb_item++] = value;
2867 if (! check_unique_values)
2871 * Then, check that all values in the list are differents.
2872 * No optimization here...
2874 for (i = 0; i < nb_item; i++) {
2875 for (j = i + 1; j < nb_item; j++) {
2876 if (parsed_items[j] == parsed_items[i]) {
2877 printf("duplicated %s %u at index %u and %u\n",
2878 item_name, parsed_items[i], i, j);
2886 struct cmd_set_list_result {
2887 cmdline_fixed_string_t cmd_keyword;
2888 cmdline_fixed_string_t list_name;
2889 cmdline_fixed_string_t list_of_items;
2892 static void cmd_set_list_parsed(void *parsed_result,
2893 __attribute__((unused)) struct cmdline *cl,
2894 __attribute__((unused)) void *data)
2896 struct cmd_set_list_result *res;
2898 unsigned int lcorelist[RTE_MAX_LCORE];
2899 unsigned int portlist[RTE_MAX_ETHPORTS];
2901 unsigned int nb_item;
2903 if (test_done == 0) {
2904 printf("Please stop forwarding first\n");
2908 res = parsed_result;
2909 if (!strcmp(res->list_name, "corelist")) {
2910 nb_item = parse_item_list(res->list_of_items, "core",
2912 parsed_items.lcorelist, 1);
2914 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2919 if (!strcmp(res->list_name, "portlist")) {
2920 nb_item = parse_item_list(res->list_of_items, "port",
2922 parsed_items.portlist, 1);
2924 set_fwd_ports_list(parsed_items.portlist, nb_item);
2930 cmdline_parse_token_string_t cmd_set_list_keyword =
2931 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2933 cmdline_parse_token_string_t cmd_set_list_name =
2934 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2935 "corelist#portlist");
2936 cmdline_parse_token_string_t cmd_set_list_of_items =
2937 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2940 cmdline_parse_inst_t cmd_set_fwd_list = {
2941 .f = cmd_set_list_parsed,
2943 .help_str = "set corelist|portlist <list0[,list1]*>",
2945 (void *)&cmd_set_list_keyword,
2946 (void *)&cmd_set_list_name,
2947 (void *)&cmd_set_list_of_items,
2952 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2954 struct cmd_setmask_result {
2955 cmdline_fixed_string_t set;
2956 cmdline_fixed_string_t mask;
2960 static void cmd_set_mask_parsed(void *parsed_result,
2961 __attribute__((unused)) struct cmdline *cl,
2962 __attribute__((unused)) void *data)
2964 struct cmd_setmask_result *res = parsed_result;
2966 if (test_done == 0) {
2967 printf("Please stop forwarding first\n");
2970 if (!strcmp(res->mask, "coremask")) {
2971 set_fwd_lcores_mask(res->hexavalue);
2973 } else if (!strcmp(res->mask, "portmask")) {
2974 set_fwd_ports_mask(res->hexavalue);
2979 cmdline_parse_token_string_t cmd_setmask_set =
2980 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2981 cmdline_parse_token_string_t cmd_setmask_mask =
2982 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2983 "coremask#portmask");
2984 cmdline_parse_token_num_t cmd_setmask_value =
2985 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2987 cmdline_parse_inst_t cmd_set_fwd_mask = {
2988 .f = cmd_set_mask_parsed,
2990 .help_str = "set coremask|portmask <hexadecimal value>",
2992 (void *)&cmd_setmask_set,
2993 (void *)&cmd_setmask_mask,
2994 (void *)&cmd_setmask_value,
3000 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3002 struct cmd_set_result {
3003 cmdline_fixed_string_t set;
3004 cmdline_fixed_string_t what;
3008 static void cmd_set_parsed(void *parsed_result,
3009 __attribute__((unused)) struct cmdline *cl,
3010 __attribute__((unused)) void *data)
3012 struct cmd_set_result *res = parsed_result;
3013 if (!strcmp(res->what, "nbport")) {
3014 set_fwd_ports_number(res->value);
3016 } else if (!strcmp(res->what, "nbcore")) {
3017 set_fwd_lcores_number(res->value);
3019 } else if (!strcmp(res->what, "burst"))
3020 set_nb_pkt_per_burst(res->value);
3021 else if (!strcmp(res->what, "verbose"))
3022 set_verbose_level(res->value);
3025 cmdline_parse_token_string_t cmd_set_set =
3026 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3027 cmdline_parse_token_string_t cmd_set_what =
3028 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3029 "nbport#nbcore#burst#verbose");
3030 cmdline_parse_token_num_t cmd_set_value =
3031 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3033 cmdline_parse_inst_t cmd_set_numbers = {
3034 .f = cmd_set_parsed,
3036 .help_str = "set nbport|nbcore|burst|verbose <value>",
3038 (void *)&cmd_set_set,
3039 (void *)&cmd_set_what,
3040 (void *)&cmd_set_value,
3045 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3047 struct cmd_set_txpkts_result {
3048 cmdline_fixed_string_t cmd_keyword;
3049 cmdline_fixed_string_t txpkts;
3050 cmdline_fixed_string_t seg_lengths;
3054 cmd_set_txpkts_parsed(void *parsed_result,
3055 __attribute__((unused)) struct cmdline *cl,
3056 __attribute__((unused)) void *data)
3058 struct cmd_set_txpkts_result *res;
3059 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3060 unsigned int nb_segs;
3062 res = parsed_result;
3063 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3064 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3066 set_tx_pkt_segments(seg_lengths, nb_segs);
3069 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3070 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3071 cmd_keyword, "set");
3072 cmdline_parse_token_string_t cmd_set_txpkts_name =
3073 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3075 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3076 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3079 cmdline_parse_inst_t cmd_set_txpkts = {
3080 .f = cmd_set_txpkts_parsed,
3082 .help_str = "set txpkts <len0[,len1]*>",
3084 (void *)&cmd_set_txpkts_keyword,
3085 (void *)&cmd_set_txpkts_name,
3086 (void *)&cmd_set_txpkts_lengths,
3091 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3093 struct cmd_set_txsplit_result {
3094 cmdline_fixed_string_t cmd_keyword;
3095 cmdline_fixed_string_t txsplit;
3096 cmdline_fixed_string_t mode;
3100 cmd_set_txsplit_parsed(void *parsed_result,
3101 __attribute__((unused)) struct cmdline *cl,
3102 __attribute__((unused)) void *data)
3104 struct cmd_set_txsplit_result *res;
3106 res = parsed_result;
3107 set_tx_pkt_split(res->mode);
3110 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3111 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3112 cmd_keyword, "set");
3113 cmdline_parse_token_string_t cmd_set_txsplit_name =
3114 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3115 txsplit, "txsplit");
3116 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3117 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3120 cmdline_parse_inst_t cmd_set_txsplit = {
3121 .f = cmd_set_txsplit_parsed,
3123 .help_str = "set txsplit on|off|rand",
3125 (void *)&cmd_set_txsplit_keyword,
3126 (void *)&cmd_set_txsplit_name,
3127 (void *)&cmd_set_txsplit_mode,
3132 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3133 struct cmd_rx_vlan_filter_all_result {
3134 cmdline_fixed_string_t rx_vlan;
3135 cmdline_fixed_string_t what;
3136 cmdline_fixed_string_t all;
3141 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3142 __attribute__((unused)) struct cmdline *cl,
3143 __attribute__((unused)) void *data)
3145 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3147 if (!strcmp(res->what, "add"))
3148 rx_vlan_all_filter_set(res->port_id, 1);
3150 rx_vlan_all_filter_set(res->port_id, 0);
3153 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3154 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3155 rx_vlan, "rx_vlan");
3156 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3157 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3159 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3160 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3162 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3163 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3166 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3167 .f = cmd_rx_vlan_filter_all_parsed,
3169 .help_str = "rx_vlan add|rm all <port_id>: "
3170 "Add/Remove all identifiers to/from the set of VLAN "
3171 "identifiers filtered by a port",
3173 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3174 (void *)&cmd_rx_vlan_filter_all_what,
3175 (void *)&cmd_rx_vlan_filter_all_all,
3176 (void *)&cmd_rx_vlan_filter_all_portid,
3181 /* *** VLAN OFFLOAD SET ON A PORT *** */
3182 struct cmd_vlan_offload_result {
3183 cmdline_fixed_string_t vlan;
3184 cmdline_fixed_string_t set;
3185 cmdline_fixed_string_t vlan_type;
3186 cmdline_fixed_string_t what;
3187 cmdline_fixed_string_t on;
3188 cmdline_fixed_string_t port_id;
3192 cmd_vlan_offload_parsed(void *parsed_result,
3193 __attribute__((unused)) struct cmdline *cl,
3194 __attribute__((unused)) void *data)
3197 struct cmd_vlan_offload_result *res = parsed_result;
3200 portid_t port_id = 0;
3204 len = strnlen(str, STR_TOKEN_SIZE);
3206 /* Get port_id first */
3214 tmp = strtoul(str, NULL, 0);
3215 /* If port_id greater that what portid_t can represent, return */
3216 if(tmp >= RTE_MAX_ETHPORTS)
3218 port_id = (portid_t)tmp;
3220 if (!strcmp(res->on, "on"))
3225 if (!strcmp(res->what, "strip"))
3226 rx_vlan_strip_set(port_id, on);
3227 else if(!strcmp(res->what, "stripq")){
3228 uint16_t queue_id = 0;
3230 /* No queue_id, return */
3232 printf("must specify (port,queue_id)\n");
3235 tmp = strtoul(str + i + 1, NULL, 0);
3236 /* If queue_id greater that what 16-bits can represent, return */
3240 queue_id = (uint16_t)tmp;
3241 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3243 else if (!strcmp(res->what, "filter"))
3244 rx_vlan_filter_set(port_id, on);
3246 vlan_extend_set(port_id, on);
3251 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3252 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3254 cmdline_parse_token_string_t cmd_vlan_offload_set =
3255 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3257 cmdline_parse_token_string_t cmd_vlan_offload_what =
3258 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3259 what, "strip#filter#qinq#stripq");
3260 cmdline_parse_token_string_t cmd_vlan_offload_on =
3261 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3263 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3264 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3267 cmdline_parse_inst_t cmd_vlan_offload = {
3268 .f = cmd_vlan_offload_parsed,
3270 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3271 "<port_id[,queue_id]>: "
3272 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3274 (void *)&cmd_vlan_offload_vlan,
3275 (void *)&cmd_vlan_offload_set,
3276 (void *)&cmd_vlan_offload_what,
3277 (void *)&cmd_vlan_offload_on,
3278 (void *)&cmd_vlan_offload_portid,
3283 /* *** VLAN TPID SET ON A PORT *** */
3284 struct cmd_vlan_tpid_result {
3285 cmdline_fixed_string_t vlan;
3286 cmdline_fixed_string_t set;
3287 cmdline_fixed_string_t vlan_type;
3288 cmdline_fixed_string_t what;
3294 cmd_vlan_tpid_parsed(void *parsed_result,
3295 __attribute__((unused)) struct cmdline *cl,
3296 __attribute__((unused)) void *data)
3298 struct cmd_vlan_tpid_result *res = parsed_result;
3299 enum rte_vlan_type vlan_type;
3301 if (!strcmp(res->vlan_type, "inner"))
3302 vlan_type = ETH_VLAN_TYPE_INNER;
3303 else if (!strcmp(res->vlan_type, "outer"))
3304 vlan_type = ETH_VLAN_TYPE_OUTER;
3306 printf("Unknown vlan type\n");
3309 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3312 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3313 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3315 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3316 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3318 cmdline_parse_token_string_t cmd_vlan_type =
3319 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3320 vlan_type, "inner#outer");
3321 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3322 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3324 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3325 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3327 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3328 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3331 cmdline_parse_inst_t cmd_vlan_tpid = {
3332 .f = cmd_vlan_tpid_parsed,
3334 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3335 "Set the VLAN Ether type",
3337 (void *)&cmd_vlan_tpid_vlan,
3338 (void *)&cmd_vlan_tpid_set,
3339 (void *)&cmd_vlan_type,
3340 (void *)&cmd_vlan_tpid_what,
3341 (void *)&cmd_vlan_tpid_tpid,
3342 (void *)&cmd_vlan_tpid_portid,
3347 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3348 struct cmd_rx_vlan_filter_result {
3349 cmdline_fixed_string_t rx_vlan;
3350 cmdline_fixed_string_t what;
3356 cmd_rx_vlan_filter_parsed(void *parsed_result,
3357 __attribute__((unused)) struct cmdline *cl,
3358 __attribute__((unused)) void *data)
3360 struct cmd_rx_vlan_filter_result *res = parsed_result;
3362 if (!strcmp(res->what, "add"))
3363 rx_vft_set(res->port_id, res->vlan_id, 1);
3365 rx_vft_set(res->port_id, res->vlan_id, 0);
3368 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3369 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3370 rx_vlan, "rx_vlan");
3371 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3372 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3374 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3375 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3377 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3378 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3381 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3382 .f = cmd_rx_vlan_filter_parsed,
3384 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3385 "Add/Remove a VLAN identifier to/from the set of VLAN "
3386 "identifiers filtered by a port",
3388 (void *)&cmd_rx_vlan_filter_rx_vlan,
3389 (void *)&cmd_rx_vlan_filter_what,
3390 (void *)&cmd_rx_vlan_filter_vlanid,
3391 (void *)&cmd_rx_vlan_filter_portid,
3396 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3397 struct cmd_tx_vlan_set_result {
3398 cmdline_fixed_string_t tx_vlan;
3399 cmdline_fixed_string_t set;
3405 cmd_tx_vlan_set_parsed(void *parsed_result,
3406 __attribute__((unused)) struct cmdline *cl,
3407 __attribute__((unused)) void *data)
3409 struct cmd_tx_vlan_set_result *res = parsed_result;
3411 if (!port_is_stopped(res->port_id)) {
3412 printf("Please stop port %d first\n", res->port_id);
3416 tx_vlan_set(res->port_id, res->vlan_id);
3418 cmd_reconfig_device_queue(res->port_id, 1, 1);
3421 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3422 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3423 tx_vlan, "tx_vlan");
3424 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3425 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3427 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3428 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3430 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3431 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3434 cmdline_parse_inst_t cmd_tx_vlan_set = {
3435 .f = cmd_tx_vlan_set_parsed,
3437 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3438 "Enable hardware insertion of a single VLAN header "
3439 "with a given TAG Identifier in packets sent on a port",
3441 (void *)&cmd_tx_vlan_set_tx_vlan,
3442 (void *)&cmd_tx_vlan_set_set,
3443 (void *)&cmd_tx_vlan_set_portid,
3444 (void *)&cmd_tx_vlan_set_vlanid,
3449 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3450 struct cmd_tx_vlan_set_qinq_result {
3451 cmdline_fixed_string_t tx_vlan;
3452 cmdline_fixed_string_t set;
3455 uint16_t vlan_id_outer;
3459 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3460 __attribute__((unused)) struct cmdline *cl,
3461 __attribute__((unused)) void *data)
3463 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3465 if (!port_is_stopped(res->port_id)) {
3466 printf("Please stop port %d first\n", res->port_id);
3470 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3472 cmd_reconfig_device_queue(res->port_id, 1, 1);
3475 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3476 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3477 tx_vlan, "tx_vlan");
3478 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3479 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3481 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3482 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3484 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3485 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3487 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3488 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3489 vlan_id_outer, UINT16);
3491 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3492 .f = cmd_tx_vlan_set_qinq_parsed,
3494 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3495 "Enable hardware insertion of double VLAN header "
3496 "with given TAG Identifiers in packets sent on a port",
3498 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3499 (void *)&cmd_tx_vlan_set_qinq_set,
3500 (void *)&cmd_tx_vlan_set_qinq_portid,
3501 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3502 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3507 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3508 struct cmd_tx_vlan_set_pvid_result {
3509 cmdline_fixed_string_t tx_vlan;
3510 cmdline_fixed_string_t set;
3511 cmdline_fixed_string_t pvid;
3514 cmdline_fixed_string_t mode;
3518 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3519 __attribute__((unused)) struct cmdline *cl,
3520 __attribute__((unused)) void *data)
3522 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3524 if (strcmp(res->mode, "on") == 0)
3525 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3527 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3530 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3531 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3532 tx_vlan, "tx_vlan");
3533 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3534 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3536 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3537 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3539 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3540 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3542 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3543 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3545 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3546 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3549 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3550 .f = cmd_tx_vlan_set_pvid_parsed,
3552 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3554 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3555 (void *)&cmd_tx_vlan_set_pvid_set,
3556 (void *)&cmd_tx_vlan_set_pvid_pvid,
3557 (void *)&cmd_tx_vlan_set_pvid_port_id,
3558 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3559 (void *)&cmd_tx_vlan_set_pvid_mode,
3564 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3565 struct cmd_tx_vlan_reset_result {
3566 cmdline_fixed_string_t tx_vlan;
3567 cmdline_fixed_string_t reset;
3572 cmd_tx_vlan_reset_parsed(void *parsed_result,
3573 __attribute__((unused)) struct cmdline *cl,
3574 __attribute__((unused)) void *data)
3576 struct cmd_tx_vlan_reset_result *res = parsed_result;
3578 if (!port_is_stopped(res->port_id)) {
3579 printf("Please stop port %d first\n", res->port_id);
3583 tx_vlan_reset(res->port_id);
3585 cmd_reconfig_device_queue(res->port_id, 1, 1);
3588 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3589 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3590 tx_vlan, "tx_vlan");
3591 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3592 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3594 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3595 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3598 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3599 .f = cmd_tx_vlan_reset_parsed,
3601 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3602 "VLAN header in packets sent on a port",
3604 (void *)&cmd_tx_vlan_reset_tx_vlan,
3605 (void *)&cmd_tx_vlan_reset_reset,
3606 (void *)&cmd_tx_vlan_reset_portid,
3612 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3613 struct cmd_csum_result {
3614 cmdline_fixed_string_t csum;
3615 cmdline_fixed_string_t mode;
3616 cmdline_fixed_string_t proto;
3617 cmdline_fixed_string_t hwsw;
3622 csum_show(int port_id)
3624 struct rte_eth_dev_info dev_info;
3625 uint64_t tx_offloads;
3627 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3628 printf("Parse tunnel is %s\n",
3629 (ports[port_id].parse_tunnel) ? "on" : "off");
3630 printf("IP checksum offload is %s\n",
3631 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3632 printf("UDP checksum offload is %s\n",
3633 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3634 printf("TCP checksum offload is %s\n",
3635 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3636 printf("SCTP checksum offload is %s\n",
3637 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3638 printf("Outer-Ip checksum offload is %s\n",
3639 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3641 /* display warnings if configuration is not supported by the NIC */
3642 rte_eth_dev_info_get(port_id, &dev_info);
3643 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3644 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3645 printf("Warning: hardware IP checksum enabled but not "
3646 "supported by port %d\n", port_id);
3648 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3649 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3650 printf("Warning: hardware UDP checksum enabled but not "
3651 "supported by port %d\n", port_id);
3653 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3654 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3655 printf("Warning: hardware TCP checksum enabled but not "
3656 "supported by port %d\n", port_id);
3658 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3659 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3660 printf("Warning: hardware SCTP checksum enabled but not "
3661 "supported by port %d\n", port_id);
3663 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3664 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3665 printf("Warning: hardware outer IP checksum enabled but not "
3666 "supported by port %d\n", port_id);
3671 cmd_csum_parsed(void *parsed_result,
3672 __attribute__((unused)) struct cmdline *cl,
3673 __attribute__((unused)) void *data)
3675 struct cmd_csum_result *res = parsed_result;
3677 uint64_t csum_offloads = 0;
3678 struct rte_eth_dev_info dev_info;
3680 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3681 printf("invalid port %d\n", res->port_id);
3684 if (!port_is_stopped(res->port_id)) {
3685 printf("Please stop port %d first\n", res->port_id);
3689 rte_eth_dev_info_get(res->port_id, &dev_info);
3690 if (!strcmp(res->mode, "set")) {
3692 if (!strcmp(res->hwsw, "hw"))
3695 if (!strcmp(res->proto, "ip")) {
3696 if (dev_info.tx_offload_capa &
3697 DEV_TX_OFFLOAD_IPV4_CKSUM) {
3698 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3700 printf("IP checksum offload is not supported "
3701 "by port %u\n", res->port_id);
3703 } else if (!strcmp(res->proto, "udp")) {
3704 if (dev_info.tx_offload_capa &
3705 DEV_TX_OFFLOAD_UDP_CKSUM) {
3706 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3708 printf("UDP checksum offload is not supported "
3709 "by port %u\n", res->port_id);
3711 } else if (!strcmp(res->proto, "tcp")) {
3712 if (dev_info.tx_offload_capa &
3713 DEV_TX_OFFLOAD_TCP_CKSUM) {
3714 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3716 printf("TCP checksum offload is not supported "
3717 "by port %u\n", res->port_id);
3719 } else if (!strcmp(res->proto, "sctp")) {
3720 if (dev_info.tx_offload_capa &
3721 DEV_TX_OFFLOAD_SCTP_CKSUM) {
3722 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3724 printf("SCTP checksum offload is not supported "
3725 "by port %u\n", res->port_id);
3727 } else if (!strcmp(res->proto, "outer-ip")) {
3728 if (dev_info.tx_offload_capa &
3729 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) {
3731 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3733 printf("Outer IP checksum offload is not "
3734 "supported by port %u\n", res->port_id);
3739 ports[res->port_id].dev_conf.txmode.offloads |=
3742 ports[res->port_id].dev_conf.txmode.offloads &=
3746 csum_show(res->port_id);
3748 cmd_reconfig_device_queue(res->port_id, 1, 1);
3751 cmdline_parse_token_string_t cmd_csum_csum =
3752 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3754 cmdline_parse_token_string_t cmd_csum_mode =
3755 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3757 cmdline_parse_token_string_t cmd_csum_proto =
3758 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3759 proto, "ip#tcp#udp#sctp#outer-ip");
3760 cmdline_parse_token_string_t cmd_csum_hwsw =
3761 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3763 cmdline_parse_token_num_t cmd_csum_portid =
3764 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3767 cmdline_parse_inst_t cmd_csum_set = {
3768 .f = cmd_csum_parsed,
3770 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3771 "Enable/Disable hardware calculation of L3/L4 checksum when "
3772 "using csum forward engine",
3774 (void *)&cmd_csum_csum,
3775 (void *)&cmd_csum_mode,
3776 (void *)&cmd_csum_proto,
3777 (void *)&cmd_csum_hwsw,
3778 (void *)&cmd_csum_portid,
3783 cmdline_parse_token_string_t cmd_csum_mode_show =
3784 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3787 cmdline_parse_inst_t cmd_csum_show = {
3788 .f = cmd_csum_parsed,
3790 .help_str = "csum show <port_id>: Show checksum offload configuration",
3792 (void *)&cmd_csum_csum,
3793 (void *)&cmd_csum_mode_show,
3794 (void *)&cmd_csum_portid,
3799 /* Enable/disable tunnel parsing */
3800 struct cmd_csum_tunnel_result {
3801 cmdline_fixed_string_t csum;
3802 cmdline_fixed_string_t parse;
3803 cmdline_fixed_string_t onoff;
3808 cmd_csum_tunnel_parsed(void *parsed_result,
3809 __attribute__((unused)) struct cmdline *cl,
3810 __attribute__((unused)) void *data)
3812 struct cmd_csum_tunnel_result *res = parsed_result;
3814 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3817 if (!strcmp(res->onoff, "on"))
3818 ports[res->port_id].parse_tunnel = 1;
3820 ports[res->port_id].parse_tunnel = 0;
3822 csum_show(res->port_id);
3825 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3826 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3828 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3829 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3830 parse, "parse_tunnel");
3831 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3832 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3834 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3835 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3838 cmdline_parse_inst_t cmd_csum_tunnel = {
3839 .f = cmd_csum_tunnel_parsed,
3841 .help_str = "csum parse_tunnel on|off <port_id>: "
3842 "Enable/Disable parsing of tunnels for csum engine",
3844 (void *)&cmd_csum_tunnel_csum,
3845 (void *)&cmd_csum_tunnel_parse,
3846 (void *)&cmd_csum_tunnel_onoff,
3847 (void *)&cmd_csum_tunnel_portid,
3852 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3853 struct cmd_tso_set_result {
3854 cmdline_fixed_string_t tso;
3855 cmdline_fixed_string_t mode;
3861 cmd_tso_set_parsed(void *parsed_result,
3862 __attribute__((unused)) struct cmdline *cl,
3863 __attribute__((unused)) void *data)
3865 struct cmd_tso_set_result *res = parsed_result;
3866 struct rte_eth_dev_info dev_info;
3868 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3870 if (!port_is_stopped(res->port_id)) {
3871 printf("Please stop port %d first\n", res->port_id);
3875 if (!strcmp(res->mode, "set"))
3876 ports[res->port_id].tso_segsz = res->tso_segsz;
3878 rte_eth_dev_info_get(res->port_id, &dev_info);
3879 if ((ports[res->port_id].tso_segsz != 0) &&
3880 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3881 printf("Error: TSO is not supported by port %d\n",
3886 if (ports[res->port_id].tso_segsz == 0) {
3887 ports[res->port_id].dev_conf.txmode.offloads &=
3888 ~DEV_TX_OFFLOAD_TCP_TSO;
3889 printf("TSO for non-tunneled packets is disabled\n");
3891 ports[res->port_id].dev_conf.txmode.offloads |=
3892 DEV_TX_OFFLOAD_TCP_TSO;
3893 printf("TSO segment size for non-tunneled packets is %d\n",
3894 ports[res->port_id].tso_segsz);
3897 /* display warnings if configuration is not supported by the NIC */
3898 rte_eth_dev_info_get(res->port_id, &dev_info);
3899 if ((ports[res->port_id].tso_segsz != 0) &&
3900 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3901 printf("Warning: TSO enabled but not "
3902 "supported by port %d\n", res->port_id);
3905 cmd_reconfig_device_queue(res->port_id, 1, 1);
3908 cmdline_parse_token_string_t cmd_tso_set_tso =
3909 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3911 cmdline_parse_token_string_t cmd_tso_set_mode =
3912 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3914 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3915 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3917 cmdline_parse_token_num_t cmd_tso_set_portid =
3918 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3921 cmdline_parse_inst_t cmd_tso_set = {
3922 .f = cmd_tso_set_parsed,
3924 .help_str = "tso set <tso_segsz> <port_id>: "
3925 "Set TSO segment size of non-tunneled packets for csum engine "
3928 (void *)&cmd_tso_set_tso,
3929 (void *)&cmd_tso_set_mode,
3930 (void *)&cmd_tso_set_tso_segsz,
3931 (void *)&cmd_tso_set_portid,
3936 cmdline_parse_token_string_t cmd_tso_show_mode =
3937 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3941 cmdline_parse_inst_t cmd_tso_show = {
3942 .f = cmd_tso_set_parsed,
3944 .help_str = "tso show <port_id>: "
3945 "Show TSO segment size of non-tunneled packets for csum engine",
3947 (void *)&cmd_tso_set_tso,
3948 (void *)&cmd_tso_show_mode,
3949 (void *)&cmd_tso_set_portid,
3954 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3955 struct cmd_tunnel_tso_set_result {
3956 cmdline_fixed_string_t tso;
3957 cmdline_fixed_string_t mode;
3962 static struct rte_eth_dev_info
3963 check_tunnel_tso_nic_support(portid_t port_id)
3965 struct rte_eth_dev_info dev_info;
3967 rte_eth_dev_info_get(port_id, &dev_info);
3968 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3969 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
3970 "not enabled for port %d\n", port_id);
3971 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3972 printf("Warning: GRE TUNNEL TSO not supported therefore "
3973 "not enabled for port %d\n", port_id);
3974 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3975 printf("Warning: IPIP TUNNEL TSO not supported therefore "
3976 "not enabled for port %d\n", port_id);
3977 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3978 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
3979 "not enabled for port %d\n", port_id);
3984 cmd_tunnel_tso_set_parsed(void *parsed_result,
3985 __attribute__((unused)) struct cmdline *cl,
3986 __attribute__((unused)) void *data)
3988 struct cmd_tunnel_tso_set_result *res = parsed_result;
3989 struct rte_eth_dev_info dev_info;
3991 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3993 if (!port_is_stopped(res->port_id)) {
3994 printf("Please stop port %d first\n", res->port_id);
3998 if (!strcmp(res->mode, "set"))
3999 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4001 dev_info = check_tunnel_tso_nic_support(res->port_id);
4002 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4003 ports[res->port_id].dev_conf.txmode.offloads &=
4004 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4005 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4006 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4007 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4008 printf("TSO for tunneled packets is disabled\n");
4010 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4011 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4012 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4013 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4015 ports[res->port_id].dev_conf.txmode.offloads |=
4016 (tso_offloads & dev_info.tx_offload_capa);
4017 printf("TSO segment size for tunneled packets is %d\n",
4018 ports[res->port_id].tunnel_tso_segsz);
4020 /* Below conditions are needed to make it work:
4021 * (1) tunnel TSO is supported by the NIC;
4022 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4024 * (3) for tunneled pkts with outer L3 of IPv4,
4025 * "csum set outer-ip" must be set to hw, because after tso,
4026 * total_len of outer IP header is changed, and the checksum
4027 * of outer IP header calculated by sw should be wrong; that
4028 * is not necessary for IPv6 tunneled pkts because there's no
4029 * checksum in IP header anymore.
4032 if (!ports[res->port_id].parse_tunnel)
4033 printf("Warning: csum parse_tunnel must be set "
4034 "so that tunneled packets are recognized\n");
4035 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4036 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4037 printf("Warning: csum set outer-ip must be set to hw "
4038 "if outer L3 is IPv4; not necessary for IPv6\n");
4041 cmd_reconfig_device_queue(res->port_id, 1, 1);
4044 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4045 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4047 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4048 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4050 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4051 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4053 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4054 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4057 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4058 .f = cmd_tunnel_tso_set_parsed,
4060 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4061 "Set TSO segment size of tunneled packets for csum engine "
4064 (void *)&cmd_tunnel_tso_set_tso,
4065 (void *)&cmd_tunnel_tso_set_mode,
4066 (void *)&cmd_tunnel_tso_set_tso_segsz,
4067 (void *)&cmd_tunnel_tso_set_portid,
4072 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4073 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4077 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4078 .f = cmd_tunnel_tso_set_parsed,
4080 .help_str = "tunnel_tso show <port_id> "
4081 "Show TSO segment size of tunneled packets for csum engine",
4083 (void *)&cmd_tunnel_tso_set_tso,
4084 (void *)&cmd_tunnel_tso_show_mode,
4085 (void *)&cmd_tunnel_tso_set_portid,
4090 /* *** SET GRO FOR A PORT *** */
4091 struct cmd_gro_enable_result {
4092 cmdline_fixed_string_t cmd_set;
4093 cmdline_fixed_string_t cmd_port;
4094 cmdline_fixed_string_t cmd_keyword;
4095 cmdline_fixed_string_t cmd_onoff;
4100 cmd_gro_enable_parsed(void *parsed_result,
4101 __attribute__((unused)) struct cmdline *cl,
4102 __attribute__((unused)) void *data)
4104 struct cmd_gro_enable_result *res;
4106 res = parsed_result;
4107 if (!strcmp(res->cmd_keyword, "gro"))
4108 setup_gro(res->cmd_onoff, res->cmd_pid);
4111 cmdline_parse_token_string_t cmd_gro_enable_set =
4112 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4114 cmdline_parse_token_string_t cmd_gro_enable_port =
4115 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4116 cmd_keyword, "port");
4117 cmdline_parse_token_num_t cmd_gro_enable_pid =
4118 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4120 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4121 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4122 cmd_keyword, "gro");
4123 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4124 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4125 cmd_onoff, "on#off");
4127 cmdline_parse_inst_t cmd_gro_enable = {
4128 .f = cmd_gro_enable_parsed,
4130 .help_str = "set port <port_id> gro on|off",
4132 (void *)&cmd_gro_enable_set,
4133 (void *)&cmd_gro_enable_port,
4134 (void *)&cmd_gro_enable_pid,
4135 (void *)&cmd_gro_enable_keyword,
4136 (void *)&cmd_gro_enable_onoff,
4141 /* *** DISPLAY GRO CONFIGURATION *** */
4142 struct cmd_gro_show_result {
4143 cmdline_fixed_string_t cmd_show;
4144 cmdline_fixed_string_t cmd_port;
4145 cmdline_fixed_string_t cmd_keyword;
4150 cmd_gro_show_parsed(void *parsed_result,
4151 __attribute__((unused)) struct cmdline *cl,
4152 __attribute__((unused)) void *data)
4154 struct cmd_gro_show_result *res;
4156 res = parsed_result;
4157 if (!strcmp(res->cmd_keyword, "gro"))
4158 show_gro(res->cmd_pid);
4161 cmdline_parse_token_string_t cmd_gro_show_show =
4162 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4164 cmdline_parse_token_string_t cmd_gro_show_port =
4165 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4167 cmdline_parse_token_num_t cmd_gro_show_pid =
4168 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4170 cmdline_parse_token_string_t cmd_gro_show_keyword =
4171 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4172 cmd_keyword, "gro");
4174 cmdline_parse_inst_t cmd_gro_show = {
4175 .f = cmd_gro_show_parsed,
4177 .help_str = "show port <port_id> gro",
4179 (void *)&cmd_gro_show_show,
4180 (void *)&cmd_gro_show_port,
4181 (void *)&cmd_gro_show_pid,
4182 (void *)&cmd_gro_show_keyword,
4187 /* *** SET FLUSH CYCLES FOR GRO *** */
4188 struct cmd_gro_flush_result {
4189 cmdline_fixed_string_t cmd_set;
4190 cmdline_fixed_string_t cmd_keyword;
4191 cmdline_fixed_string_t cmd_flush;
4196 cmd_gro_flush_parsed(void *parsed_result,
4197 __attribute__((unused)) struct cmdline *cl,
4198 __attribute__((unused)) void *data)
4200 struct cmd_gro_flush_result *res;
4202 res = parsed_result;
4203 if ((!strcmp(res->cmd_keyword, "gro")) &&
4204 (!strcmp(res->cmd_flush, "flush")))
4205 setup_gro_flush_cycles(res->cmd_cycles);
4208 cmdline_parse_token_string_t cmd_gro_flush_set =
4209 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4211 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4212 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4213 cmd_keyword, "gro");
4214 cmdline_parse_token_string_t cmd_gro_flush_flush =
4215 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4216 cmd_flush, "flush");
4217 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4218 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4221 cmdline_parse_inst_t cmd_gro_flush = {
4222 .f = cmd_gro_flush_parsed,
4224 .help_str = "set gro flush <cycles>",
4226 (void *)&cmd_gro_flush_set,
4227 (void *)&cmd_gro_flush_keyword,
4228 (void *)&cmd_gro_flush_flush,
4229 (void *)&cmd_gro_flush_cycles,
4234 /* *** ENABLE/DISABLE GSO *** */
4235 struct cmd_gso_enable_result {
4236 cmdline_fixed_string_t cmd_set;
4237 cmdline_fixed_string_t cmd_port;
4238 cmdline_fixed_string_t cmd_keyword;
4239 cmdline_fixed_string_t cmd_mode;
4244 cmd_gso_enable_parsed(void *parsed_result,
4245 __attribute__((unused)) struct cmdline *cl,
4246 __attribute__((unused)) void *data)
4248 struct cmd_gso_enable_result *res;
4250 res = parsed_result;
4251 if (!strcmp(res->cmd_keyword, "gso"))
4252 setup_gso(res->cmd_mode, res->cmd_pid);
4255 cmdline_parse_token_string_t cmd_gso_enable_set =
4256 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4258 cmdline_parse_token_string_t cmd_gso_enable_port =
4259 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4261 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4262 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4263 cmd_keyword, "gso");
4264 cmdline_parse_token_string_t cmd_gso_enable_mode =
4265 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4266 cmd_mode, "on#off");
4267 cmdline_parse_token_num_t cmd_gso_enable_pid =
4268 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4271 cmdline_parse_inst_t cmd_gso_enable = {
4272 .f = cmd_gso_enable_parsed,
4274 .help_str = "set port <port_id> gso on|off",
4276 (void *)&cmd_gso_enable_set,
4277 (void *)&cmd_gso_enable_port,
4278 (void *)&cmd_gso_enable_pid,
4279 (void *)&cmd_gso_enable_keyword,
4280 (void *)&cmd_gso_enable_mode,
4285 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4286 struct cmd_gso_size_result {
4287 cmdline_fixed_string_t cmd_set;
4288 cmdline_fixed_string_t cmd_keyword;
4289 cmdline_fixed_string_t cmd_segsz;
4294 cmd_gso_size_parsed(void *parsed_result,
4295 __attribute__((unused)) struct cmdline *cl,
4296 __attribute__((unused)) void *data)
4298 struct cmd_gso_size_result *res = parsed_result;
4300 if (test_done == 0) {
4301 printf("Before setting GSO segsz, please first"
4302 " stop fowarding\n");
4306 if (!strcmp(res->cmd_keyword, "gso") &&
4307 !strcmp(res->cmd_segsz, "segsz")) {
4308 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4309 printf("gso_size should be larger than %zu."
4310 " Please input a legal value\n",
4311 RTE_GSO_SEG_SIZE_MIN);
4313 gso_max_segment_size = res->cmd_size;
4317 cmdline_parse_token_string_t cmd_gso_size_set =
4318 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4320 cmdline_parse_token_string_t cmd_gso_size_keyword =
4321 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4322 cmd_keyword, "gso");
4323 cmdline_parse_token_string_t cmd_gso_size_segsz =
4324 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4325 cmd_segsz, "segsz");
4326 cmdline_parse_token_num_t cmd_gso_size_size =
4327 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4330 cmdline_parse_inst_t cmd_gso_size = {
4331 .f = cmd_gso_size_parsed,
4333 .help_str = "set gso segsz <length>",
4335 (void *)&cmd_gso_size_set,
4336 (void *)&cmd_gso_size_keyword,
4337 (void *)&cmd_gso_size_segsz,
4338 (void *)&cmd_gso_size_size,
4343 /* *** SHOW GSO CONFIGURATION *** */
4344 struct cmd_gso_show_result {
4345 cmdline_fixed_string_t cmd_show;
4346 cmdline_fixed_string_t cmd_port;
4347 cmdline_fixed_string_t cmd_keyword;
4352 cmd_gso_show_parsed(void *parsed_result,
4353 __attribute__((unused)) struct cmdline *cl,
4354 __attribute__((unused)) void *data)
4356 struct cmd_gso_show_result *res = parsed_result;
4358 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4359 printf("invalid port id %u\n", res->cmd_pid);
4362 if (!strcmp(res->cmd_keyword, "gso")) {
4363 if (gso_ports[res->cmd_pid].enable) {
4364 printf("Max GSO'd packet size: %uB\n"
4365 "Supported GSO types: TCP/IPv4, "
4366 "VxLAN with inner TCP/IPv4 packet, "
4367 "GRE with inner TCP/IPv4 packet\n",
4368 gso_max_segment_size);
4370 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4374 cmdline_parse_token_string_t cmd_gso_show_show =
4375 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4377 cmdline_parse_token_string_t cmd_gso_show_port =
4378 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4380 cmdline_parse_token_string_t cmd_gso_show_keyword =
4381 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4382 cmd_keyword, "gso");
4383 cmdline_parse_token_num_t cmd_gso_show_pid =
4384 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4387 cmdline_parse_inst_t cmd_gso_show = {
4388 .f = cmd_gso_show_parsed,
4390 .help_str = "show port <port_id> gso",
4392 (void *)&cmd_gso_show_show,
4393 (void *)&cmd_gso_show_port,
4394 (void *)&cmd_gso_show_pid,
4395 (void *)&cmd_gso_show_keyword,
4400 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4401 struct cmd_set_flush_rx {
4402 cmdline_fixed_string_t set;
4403 cmdline_fixed_string_t flush_rx;
4404 cmdline_fixed_string_t mode;
4408 cmd_set_flush_rx_parsed(void *parsed_result,
4409 __attribute__((unused)) struct cmdline *cl,
4410 __attribute__((unused)) void *data)
4412 struct cmd_set_flush_rx *res = parsed_result;
4413 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4416 cmdline_parse_token_string_t cmd_setflushrx_set =
4417 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4419 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4420 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4421 flush_rx, "flush_rx");
4422 cmdline_parse_token_string_t cmd_setflushrx_mode =
4423 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4427 cmdline_parse_inst_t cmd_set_flush_rx = {
4428 .f = cmd_set_flush_rx_parsed,
4429 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4432 (void *)&cmd_setflushrx_set,
4433 (void *)&cmd_setflushrx_flush_rx,
4434 (void *)&cmd_setflushrx_mode,
4439 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4440 struct cmd_set_link_check {
4441 cmdline_fixed_string_t set;
4442 cmdline_fixed_string_t link_check;
4443 cmdline_fixed_string_t mode;
4447 cmd_set_link_check_parsed(void *parsed_result,
4448 __attribute__((unused)) struct cmdline *cl,
4449 __attribute__((unused)) void *data)
4451 struct cmd_set_link_check *res = parsed_result;
4452 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4455 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4456 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4458 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4459 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4460 link_check, "link_check");
4461 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4462 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4466 cmdline_parse_inst_t cmd_set_link_check = {
4467 .f = cmd_set_link_check_parsed,
4468 .help_str = "set link_check on|off: Enable/Disable link status check "
4469 "when starting/stopping a port",
4472 (void *)&cmd_setlinkcheck_set,
4473 (void *)&cmd_setlinkcheck_link_check,
4474 (void *)&cmd_setlinkcheck_mode,
4479 /* *** SET NIC BYPASS MODE *** */
4480 struct cmd_set_bypass_mode_result {
4481 cmdline_fixed_string_t set;
4482 cmdline_fixed_string_t bypass;
4483 cmdline_fixed_string_t mode;
4484 cmdline_fixed_string_t value;
4489 cmd_set_bypass_mode_parsed(void *parsed_result,
4490 __attribute__((unused)) struct cmdline *cl,
4491 __attribute__((unused)) void *data)
4493 struct cmd_set_bypass_mode_result *res = parsed_result;
4494 portid_t port_id = res->port_id;
4495 int32_t rc = -EINVAL;
4497 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4498 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4500 if (!strcmp(res->value, "bypass"))
4501 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4502 else if (!strcmp(res->value, "isolate"))
4503 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4505 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4507 /* Set the bypass mode for the relevant port. */
4508 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4511 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4514 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4515 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4517 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4518 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4520 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4521 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4523 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4524 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4525 value, "normal#bypass#isolate");
4526 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4527 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4530 cmdline_parse_inst_t cmd_set_bypass_mode = {
4531 .f = cmd_set_bypass_mode_parsed,
4532 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4533 "Set the NIC bypass mode for port_id",
4536 (void *)&cmd_setbypass_mode_set,
4537 (void *)&cmd_setbypass_mode_bypass,
4538 (void *)&cmd_setbypass_mode_mode,
4539 (void *)&cmd_setbypass_mode_value,
4540 (void *)&cmd_setbypass_mode_port,
4545 /* *** SET NIC BYPASS EVENT *** */
4546 struct cmd_set_bypass_event_result {
4547 cmdline_fixed_string_t set;
4548 cmdline_fixed_string_t bypass;
4549 cmdline_fixed_string_t event;
4550 cmdline_fixed_string_t event_value;
4551 cmdline_fixed_string_t mode;
4552 cmdline_fixed_string_t mode_value;
4557 cmd_set_bypass_event_parsed(void *parsed_result,
4558 __attribute__((unused)) struct cmdline *cl,
4559 __attribute__((unused)) void *data)
4561 int32_t rc = -EINVAL;
4562 struct cmd_set_bypass_event_result *res = parsed_result;
4563 portid_t port_id = res->port_id;
4565 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4566 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4567 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4569 if (!strcmp(res->event_value, "timeout"))
4570 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4571 else if (!strcmp(res->event_value, "os_on"))
4572 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4573 else if (!strcmp(res->event_value, "os_off"))
4574 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4575 else if (!strcmp(res->event_value, "power_on"))
4576 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4577 else if (!strcmp(res->event_value, "power_off"))
4578 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4580 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4582 if (!strcmp(res->mode_value, "bypass"))
4583 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4584 else if (!strcmp(res->mode_value, "isolate"))
4585 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4587 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4589 /* Set the watchdog timeout. */
4590 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4593 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4594 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4598 printf("Failed to set timeout value %u "
4599 "for port %d, errto code: %d.\n",
4600 bypass_timeout, port_id, rc);
4604 /* Set the bypass event to transition to bypass mode. */
4605 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4610 printf("\t Failed to set bypass event for port = %d.\n",
4614 cmdline_parse_token_string_t cmd_setbypass_event_set =
4615 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4617 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4618 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4620 cmdline_parse_token_string_t cmd_setbypass_event_event =
4621 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4623 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4624 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4625 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4626 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4627 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4629 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4630 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4631 mode_value, "normal#bypass#isolate");
4632 cmdline_parse_token_num_t cmd_setbypass_event_port =
4633 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4636 cmdline_parse_inst_t cmd_set_bypass_event = {
4637 .f = cmd_set_bypass_event_parsed,
4638 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4639 "power_off mode normal|bypass|isolate <port_id>: "
4640 "Set the NIC bypass event mode for port_id",
4643 (void *)&cmd_setbypass_event_set,
4644 (void *)&cmd_setbypass_event_bypass,
4645 (void *)&cmd_setbypass_event_event,
4646 (void *)&cmd_setbypass_event_event_value,
4647 (void *)&cmd_setbypass_event_mode,
4648 (void *)&cmd_setbypass_event_mode_value,
4649 (void *)&cmd_setbypass_event_port,
4655 /* *** SET NIC BYPASS TIMEOUT *** */
4656 struct cmd_set_bypass_timeout_result {
4657 cmdline_fixed_string_t set;
4658 cmdline_fixed_string_t bypass;
4659 cmdline_fixed_string_t timeout;
4660 cmdline_fixed_string_t value;
4664 cmd_set_bypass_timeout_parsed(void *parsed_result,
4665 __attribute__((unused)) struct cmdline *cl,
4666 __attribute__((unused)) void *data)
4668 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4670 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4671 if (!strcmp(res->value, "1.5"))
4672 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4673 else if (!strcmp(res->value, "2"))
4674 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4675 else if (!strcmp(res->value, "3"))
4676 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4677 else if (!strcmp(res->value, "4"))
4678 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4679 else if (!strcmp(res->value, "8"))
4680 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4681 else if (!strcmp(res->value, "16"))
4682 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4683 else if (!strcmp(res->value, "32"))
4684 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4686 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4690 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4691 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4693 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4694 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4696 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4697 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4698 timeout, "timeout");
4699 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4700 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4701 value, "0#1.5#2#3#4#8#16#32");
4703 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4704 .f = cmd_set_bypass_timeout_parsed,
4705 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4706 "Set the NIC bypass watchdog timeout in seconds",
4709 (void *)&cmd_setbypass_timeout_set,
4710 (void *)&cmd_setbypass_timeout_bypass,
4711 (void *)&cmd_setbypass_timeout_timeout,
4712 (void *)&cmd_setbypass_timeout_value,
4717 /* *** SHOW NIC BYPASS MODE *** */
4718 struct cmd_show_bypass_config_result {
4719 cmdline_fixed_string_t show;
4720 cmdline_fixed_string_t bypass;
4721 cmdline_fixed_string_t config;
4726 cmd_show_bypass_config_parsed(void *parsed_result,
4727 __attribute__((unused)) struct cmdline *cl,
4728 __attribute__((unused)) void *data)
4730 struct cmd_show_bypass_config_result *res = parsed_result;
4731 portid_t port_id = res->port_id;
4733 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4734 uint32_t event_mode;
4735 uint32_t bypass_mode;
4736 uint32_t timeout = bypass_timeout;
4739 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4740 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4741 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4742 {"UNKNOWN", "normal", "bypass", "isolate"};
4743 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4750 int num_events = (sizeof events) / (sizeof events[0]);
4752 /* Display the bypass mode.*/
4753 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4754 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4758 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4759 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4761 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4764 /* Display the bypass timeout.*/
4765 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4766 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4768 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4770 /* Display the bypass events and associated modes. */
4771 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4773 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4774 printf("\tFailed to get bypass mode for event = %s\n",
4777 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4778 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4780 printf("\tbypass event: %-16s = %s\n", events[i],
4786 printf("\tFailed to get bypass configuration for port = %d\n",
4790 cmdline_parse_token_string_t cmd_showbypass_config_show =
4791 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4793 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4794 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4796 cmdline_parse_token_string_t cmd_showbypass_config_config =
4797 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4799 cmdline_parse_token_num_t cmd_showbypass_config_port =
4800 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4803 cmdline_parse_inst_t cmd_show_bypass_config = {
4804 .f = cmd_show_bypass_config_parsed,
4805 .help_str = "show bypass config <port_id>: "
4806 "Show the NIC bypass config for port_id",
4809 (void *)&cmd_showbypass_config_show,
4810 (void *)&cmd_showbypass_config_bypass,
4811 (void *)&cmd_showbypass_config_config,
4812 (void *)&cmd_showbypass_config_port,
4817 #ifdef RTE_LIBRTE_PMD_BOND
4818 /* *** SET BONDING MODE *** */
4819 struct cmd_set_bonding_mode_result {
4820 cmdline_fixed_string_t set;
4821 cmdline_fixed_string_t bonding;
4822 cmdline_fixed_string_t mode;
4827 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4828 __attribute__((unused)) struct cmdline *cl,
4829 __attribute__((unused)) void *data)
4831 struct cmd_set_bonding_mode_result *res = parsed_result;
4832 portid_t port_id = res->port_id;
4834 /* Set the bonding mode for the relevant port. */
4835 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4836 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4839 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4840 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4842 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4843 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4844 bonding, "bonding");
4845 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4846 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4848 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4849 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4851 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4852 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4855 cmdline_parse_inst_t cmd_set_bonding_mode = {
4856 .f = cmd_set_bonding_mode_parsed,
4857 .help_str = "set bonding mode <mode_value> <port_id>: "
4858 "Set the bonding mode for port_id",
4861 (void *) &cmd_setbonding_mode_set,
4862 (void *) &cmd_setbonding_mode_bonding,
4863 (void *) &cmd_setbonding_mode_mode,
4864 (void *) &cmd_setbonding_mode_value,
4865 (void *) &cmd_setbonding_mode_port,
4870 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4871 struct cmd_set_bonding_lacp_dedicated_queues_result {
4872 cmdline_fixed_string_t set;
4873 cmdline_fixed_string_t bonding;
4874 cmdline_fixed_string_t lacp;
4875 cmdline_fixed_string_t dedicated_queues;
4877 cmdline_fixed_string_t mode;
4880 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4881 __attribute__((unused)) struct cmdline *cl,
4882 __attribute__((unused)) void *data)
4884 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4885 portid_t port_id = res->port_id;
4886 struct rte_port *port;
4888 port = &ports[port_id];
4890 /** Check if the port is not started **/
4891 if (port->port_status != RTE_PORT_STOPPED) {
4892 printf("Please stop port %d first\n", port_id);
4896 if (!strcmp(res->mode, "enable")) {
4897 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4898 printf("Dedicate queues for LACP control packets"
4901 printf("Enabling dedicate queues for LACP control "
4902 "packets on port %d failed\n", port_id);
4903 } else if (!strcmp(res->mode, "disable")) {
4904 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4905 printf("Dedicated queues for LACP control packets "
4908 printf("Disabling dedicated queues for LACP control "
4909 "traffic on port %d failed\n", port_id);
4913 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4914 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4916 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4917 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4918 bonding, "bonding");
4919 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4920 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4922 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4923 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4924 dedicated_queues, "dedicated_queues");
4925 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4926 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4928 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4929 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4930 mode, "enable#disable");
4932 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4933 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4934 .help_str = "set bonding lacp dedicated_queues <port_id> "
4936 "Enable/disable dedicated queues for LACP control traffic for port_id",
4939 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4940 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4941 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4942 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4943 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4944 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4949 /* *** SET BALANCE XMIT POLICY *** */
4950 struct cmd_set_bonding_balance_xmit_policy_result {
4951 cmdline_fixed_string_t set;
4952 cmdline_fixed_string_t bonding;
4953 cmdline_fixed_string_t balance_xmit_policy;
4955 cmdline_fixed_string_t policy;
4958 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4959 __attribute__((unused)) struct cmdline *cl,
4960 __attribute__((unused)) void *data)
4962 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4963 portid_t port_id = res->port_id;
4966 if (!strcmp(res->policy, "l2")) {
4967 policy = BALANCE_XMIT_POLICY_LAYER2;
4968 } else if (!strcmp(res->policy, "l23")) {
4969 policy = BALANCE_XMIT_POLICY_LAYER23;
4970 } else if (!strcmp(res->policy, "l34")) {
4971 policy = BALANCE_XMIT_POLICY_LAYER34;
4973 printf("\t Invalid xmit policy selection");
4977 /* Set the bonding mode for the relevant port. */
4978 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4979 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4984 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4985 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4987 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4988 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4989 bonding, "bonding");
4990 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4991 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4992 balance_xmit_policy, "balance_xmit_policy");
4993 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4994 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4996 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4997 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4998 policy, "l2#l23#l34");
5000 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5001 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5002 .help_str = "set bonding balance_xmit_policy <port_id> "
5004 "Set the bonding balance_xmit_policy for port_id",
5007 (void *)&cmd_setbonding_balance_xmit_policy_set,
5008 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5009 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5010 (void *)&cmd_setbonding_balance_xmit_policy_port,
5011 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5016 /* *** SHOW NIC BONDING CONFIGURATION *** */
5017 struct cmd_show_bonding_config_result {
5018 cmdline_fixed_string_t show;
5019 cmdline_fixed_string_t bonding;
5020 cmdline_fixed_string_t config;
5024 static void cmd_show_bonding_config_parsed(void *parsed_result,
5025 __attribute__((unused)) struct cmdline *cl,
5026 __attribute__((unused)) void *data)
5028 struct cmd_show_bonding_config_result *res = parsed_result;
5029 int bonding_mode, agg_mode;
5030 portid_t slaves[RTE_MAX_ETHPORTS];
5031 int num_slaves, num_active_slaves;
5034 portid_t port_id = res->port_id;
5036 /* Display the bonding mode.*/
5037 bonding_mode = rte_eth_bond_mode_get(port_id);
5038 if (bonding_mode < 0) {
5039 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5042 printf("\tBonding mode: %d\n", bonding_mode);
5044 if (bonding_mode == BONDING_MODE_BALANCE) {
5045 int balance_xmit_policy;
5047 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5048 if (balance_xmit_policy < 0) {
5049 printf("\tFailed to get balance xmit policy for port = %d\n",
5053 printf("\tBalance Xmit Policy: ");
5055 switch (balance_xmit_policy) {
5056 case BALANCE_XMIT_POLICY_LAYER2:
5057 printf("BALANCE_XMIT_POLICY_LAYER2");
5059 case BALANCE_XMIT_POLICY_LAYER23:
5060 printf("BALANCE_XMIT_POLICY_LAYER23");
5062 case BALANCE_XMIT_POLICY_LAYER34:
5063 printf("BALANCE_XMIT_POLICY_LAYER34");
5070 if (bonding_mode == BONDING_MODE_8023AD) {
5071 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5072 printf("\tIEEE802.3AD Aggregator Mode: ");
5075 printf("bandwidth");
5087 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5089 if (num_slaves < 0) {
5090 printf("\tFailed to get slave list for port = %d\n", port_id);
5093 if (num_slaves > 0) {
5094 printf("\tSlaves (%d): [", num_slaves);
5095 for (i = 0; i < num_slaves - 1; i++)
5096 printf("%d ", slaves[i]);
5098 printf("%d]\n", slaves[num_slaves - 1]);
5100 printf("\tSlaves: []\n");
5104 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5107 if (num_active_slaves < 0) {
5108 printf("\tFailed to get active slave list for port = %d\n", port_id);
5111 if (num_active_slaves > 0) {
5112 printf("\tActive Slaves (%d): [", num_active_slaves);
5113 for (i = 0; i < num_active_slaves - 1; i++)
5114 printf("%d ", slaves[i]);
5116 printf("%d]\n", slaves[num_active_slaves - 1]);
5119 printf("\tActive Slaves: []\n");
5123 primary_id = rte_eth_bond_primary_get(port_id);
5124 if (primary_id < 0) {
5125 printf("\tFailed to get primary slave for port = %d\n", port_id);
5128 printf("\tPrimary: [%d]\n", primary_id);
5132 cmdline_parse_token_string_t cmd_showbonding_config_show =
5133 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5135 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5136 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5137 bonding, "bonding");
5138 cmdline_parse_token_string_t cmd_showbonding_config_config =
5139 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5141 cmdline_parse_token_num_t cmd_showbonding_config_port =
5142 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5145 cmdline_parse_inst_t cmd_show_bonding_config = {
5146 .f = cmd_show_bonding_config_parsed,
5147 .help_str = "show bonding config <port_id>: "
5148 "Show the bonding config for port_id",
5151 (void *)&cmd_showbonding_config_show,
5152 (void *)&cmd_showbonding_config_bonding,
5153 (void *)&cmd_showbonding_config_config,
5154 (void *)&cmd_showbonding_config_port,
5159 /* *** SET BONDING PRIMARY *** */
5160 struct cmd_set_bonding_primary_result {
5161 cmdline_fixed_string_t set;
5162 cmdline_fixed_string_t bonding;
5163 cmdline_fixed_string_t primary;
5168 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5169 __attribute__((unused)) struct cmdline *cl,
5170 __attribute__((unused)) void *data)
5172 struct cmd_set_bonding_primary_result *res = parsed_result;
5173 portid_t master_port_id = res->port_id;
5174 portid_t slave_port_id = res->slave_id;
5176 /* Set the primary slave for a bonded device. */
5177 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5178 printf("\t Failed to set primary slave for port = %d.\n",
5185 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5186 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5188 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5189 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5190 bonding, "bonding");
5191 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5192 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5193 primary, "primary");
5194 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5195 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5197 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5198 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5201 cmdline_parse_inst_t cmd_set_bonding_primary = {
5202 .f = cmd_set_bonding_primary_parsed,
5203 .help_str = "set bonding primary <slave_id> <port_id>: "
5204 "Set the primary slave for port_id",
5207 (void *)&cmd_setbonding_primary_set,
5208 (void *)&cmd_setbonding_primary_bonding,
5209 (void *)&cmd_setbonding_primary_primary,
5210 (void *)&cmd_setbonding_primary_slave,
5211 (void *)&cmd_setbonding_primary_port,
5216 /* *** ADD SLAVE *** */
5217 struct cmd_add_bonding_slave_result {
5218 cmdline_fixed_string_t add;
5219 cmdline_fixed_string_t bonding;
5220 cmdline_fixed_string_t slave;
5225 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5226 __attribute__((unused)) struct cmdline *cl,
5227 __attribute__((unused)) void *data)
5229 struct cmd_add_bonding_slave_result *res = parsed_result;
5230 portid_t master_port_id = res->port_id;
5231 portid_t slave_port_id = res->slave_id;
5233 /* add the slave for a bonded device. */
5234 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5235 printf("\t Failed to add slave %d to master port = %d.\n",
5236 slave_port_id, master_port_id);
5240 set_port_slave_flag(slave_port_id);
5243 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5244 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5246 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5247 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5248 bonding, "bonding");
5249 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5250 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5252 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5253 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5255 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5256 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5259 cmdline_parse_inst_t cmd_add_bonding_slave = {
5260 .f = cmd_add_bonding_slave_parsed,
5261 .help_str = "add bonding slave <slave_id> <port_id>: "
5262 "Add a slave device to a bonded device",
5265 (void *)&cmd_addbonding_slave_add,
5266 (void *)&cmd_addbonding_slave_bonding,
5267 (void *)&cmd_addbonding_slave_slave,
5268 (void *)&cmd_addbonding_slave_slaveid,
5269 (void *)&cmd_addbonding_slave_port,
5274 /* *** REMOVE SLAVE *** */
5275 struct cmd_remove_bonding_slave_result {
5276 cmdline_fixed_string_t remove;
5277 cmdline_fixed_string_t bonding;
5278 cmdline_fixed_string_t slave;
5283 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5284 __attribute__((unused)) struct cmdline *cl,
5285 __attribute__((unused)) void *data)
5287 struct cmd_remove_bonding_slave_result *res = parsed_result;
5288 portid_t master_port_id = res->port_id;
5289 portid_t slave_port_id = res->slave_id;
5291 /* remove the slave from a bonded device. */
5292 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5293 printf("\t Failed to remove slave %d from master port = %d.\n",
5294 slave_port_id, master_port_id);
5298 clear_port_slave_flag(slave_port_id);
5301 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5302 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5304 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5305 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5306 bonding, "bonding");
5307 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5308 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5310 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5311 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5313 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5314 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5317 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5318 .f = cmd_remove_bonding_slave_parsed,
5319 .help_str = "remove bonding slave <slave_id> <port_id>: "
5320 "Remove a slave device from a bonded device",
5323 (void *)&cmd_removebonding_slave_remove,
5324 (void *)&cmd_removebonding_slave_bonding,
5325 (void *)&cmd_removebonding_slave_slave,
5326 (void *)&cmd_removebonding_slave_slaveid,
5327 (void *)&cmd_removebonding_slave_port,
5332 /* *** CREATE BONDED DEVICE *** */
5333 struct cmd_create_bonded_device_result {
5334 cmdline_fixed_string_t create;
5335 cmdline_fixed_string_t bonded;
5336 cmdline_fixed_string_t device;
5341 static int bond_dev_num = 0;
5343 static void cmd_create_bonded_device_parsed(void *parsed_result,
5344 __attribute__((unused)) struct cmdline *cl,
5345 __attribute__((unused)) void *data)
5347 struct cmd_create_bonded_device_result *res = parsed_result;
5348 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5351 if (test_done == 0) {
5352 printf("Please stop forwarding first\n");
5356 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5359 /* Create a new bonded device. */
5360 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5362 printf("\t Failed to create bonded device.\n");
5365 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5368 /* Update number of ports */
5369 nb_ports = rte_eth_dev_count();
5370 reconfig(port_id, res->socket);
5371 rte_eth_promiscuous_enable(port_id);
5376 cmdline_parse_token_string_t cmd_createbonded_device_create =
5377 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5379 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5380 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5382 cmdline_parse_token_string_t cmd_createbonded_device_device =
5383 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5385 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5386 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5388 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5389 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5392 cmdline_parse_inst_t cmd_create_bonded_device = {
5393 .f = cmd_create_bonded_device_parsed,
5394 .help_str = "create bonded device <mode> <socket>: "
5395 "Create a new bonded device with specific bonding mode and socket",
5398 (void *)&cmd_createbonded_device_create,
5399 (void *)&cmd_createbonded_device_bonded,
5400 (void *)&cmd_createbonded_device_device,
5401 (void *)&cmd_createbonded_device_mode,
5402 (void *)&cmd_createbonded_device_socket,
5407 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5408 struct cmd_set_bond_mac_addr_result {
5409 cmdline_fixed_string_t set;
5410 cmdline_fixed_string_t bonding;
5411 cmdline_fixed_string_t mac_addr;
5413 struct ether_addr address;
5416 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5417 __attribute__((unused)) struct cmdline *cl,
5418 __attribute__((unused)) void *data)
5420 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5423 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5426 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5428 /* check the return value and print it if is < 0 */
5430 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5433 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5434 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5435 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5436 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5438 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5439 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5441 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5442 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5444 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5445 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5447 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5448 .f = cmd_set_bond_mac_addr_parsed,
5450 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5452 (void *)&cmd_set_bond_mac_addr_set,
5453 (void *)&cmd_set_bond_mac_addr_bonding,
5454 (void *)&cmd_set_bond_mac_addr_mac,
5455 (void *)&cmd_set_bond_mac_addr_portnum,
5456 (void *)&cmd_set_bond_mac_addr_addr,
5462 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5463 struct cmd_set_bond_mon_period_result {
5464 cmdline_fixed_string_t set;
5465 cmdline_fixed_string_t bonding;
5466 cmdline_fixed_string_t mon_period;
5471 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5472 __attribute__((unused)) struct cmdline *cl,
5473 __attribute__((unused)) void *data)
5475 struct cmd_set_bond_mon_period_result *res = parsed_result;
5478 if (res->port_num >= nb_ports) {
5479 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5483 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5485 /* check the return value and print it if is < 0 */
5487 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5490 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5491 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5493 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5494 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5495 bonding, "bonding");
5496 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5497 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5498 mon_period, "mon_period");
5499 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5500 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5502 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5503 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5506 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5507 .f = cmd_set_bond_mon_period_parsed,
5509 .help_str = "set bonding mon_period <port_id> <period_ms>",
5511 (void *)&cmd_set_bond_mon_period_set,
5512 (void *)&cmd_set_bond_mon_period_bonding,
5513 (void *)&cmd_set_bond_mon_period_mon_period,
5514 (void *)&cmd_set_bond_mon_period_portnum,
5515 (void *)&cmd_set_bond_mon_period_period_ms,
5522 struct cmd_set_bonding_agg_mode_policy_result {
5523 cmdline_fixed_string_t set;
5524 cmdline_fixed_string_t bonding;
5525 cmdline_fixed_string_t agg_mode;
5527 cmdline_fixed_string_t policy;
5532 cmd_set_bonding_agg_mode(void *parsed_result,
5533 __attribute__((unused)) struct cmdline *cl,
5534 __attribute__((unused)) void *data)
5536 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5537 uint8_t policy = AGG_BANDWIDTH;
5539 if (res->port_num >= nb_ports) {
5540 printf("Port id %d must be less than %d\n",
5541 res->port_num, nb_ports);
5545 if (!strcmp(res->policy, "bandwidth"))
5546 policy = AGG_BANDWIDTH;
5547 else if (!strcmp(res->policy, "stable"))
5548 policy = AGG_STABLE;
5549 else if (!strcmp(res->policy, "count"))
5552 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5556 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5557 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5559 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5560 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5561 bonding, "bonding");
5563 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5564 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5565 agg_mode, "agg_mode");
5567 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5568 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5571 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5572 TOKEN_STRING_INITIALIZER(
5573 struct cmd_set_bonding_balance_xmit_policy_result,
5574 policy, "stable#bandwidth#count");
5576 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5577 .f = cmd_set_bonding_agg_mode,
5579 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5581 (void *)&cmd_set_bonding_agg_mode_set,
5582 (void *)&cmd_set_bonding_agg_mode_bonding,
5583 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5584 (void *)&cmd_set_bonding_agg_mode_portnum,
5585 (void *)&cmd_set_bonding_agg_mode_policy_string,
5591 #endif /* RTE_LIBRTE_PMD_BOND */
5593 /* *** SET FORWARDING MODE *** */
5594 struct cmd_set_fwd_mode_result {
5595 cmdline_fixed_string_t set;
5596 cmdline_fixed_string_t fwd;
5597 cmdline_fixed_string_t mode;
5600 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5601 __attribute__((unused)) struct cmdline *cl,
5602 __attribute__((unused)) void *data)
5604 struct cmd_set_fwd_mode_result *res = parsed_result;
5607 set_pkt_forwarding_mode(res->mode);
5610 cmdline_parse_token_string_t cmd_setfwd_set =
5611 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5612 cmdline_parse_token_string_t cmd_setfwd_fwd =
5613 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5614 cmdline_parse_token_string_t cmd_setfwd_mode =
5615 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5616 "" /* defined at init */);
5618 cmdline_parse_inst_t cmd_set_fwd_mode = {
5619 .f = cmd_set_fwd_mode_parsed,
5621 .help_str = NULL, /* defined at init */
5623 (void *)&cmd_setfwd_set,
5624 (void *)&cmd_setfwd_fwd,
5625 (void *)&cmd_setfwd_mode,
5630 static void cmd_set_fwd_mode_init(void)
5633 static char token[128];
5634 static char help[256];
5635 cmdline_parse_token_string_t *token_struct;
5637 modes = list_pkt_forwarding_modes();
5638 snprintf(help, sizeof(help), "set fwd %s: "
5639 "Set packet forwarding mode", modes);
5640 cmd_set_fwd_mode.help_str = help;
5642 /* string token separator is # */
5643 for (c = token; *modes != '\0'; modes++)
5648 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5649 token_struct->string_data.str = token;
5652 /* *** SET RETRY FORWARDING MODE *** */
5653 struct cmd_set_fwd_retry_mode_result {
5654 cmdline_fixed_string_t set;
5655 cmdline_fixed_string_t fwd;
5656 cmdline_fixed_string_t mode;
5657 cmdline_fixed_string_t retry;
5660 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5661 __attribute__((unused)) struct cmdline *cl,
5662 __attribute__((unused)) void *data)
5664 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5667 set_pkt_forwarding_mode(res->mode);
5670 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5671 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5673 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5674 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5676 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5677 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5679 "" /* defined at init */);
5680 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5681 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5684 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5685 .f = cmd_set_fwd_retry_mode_parsed,
5687 .help_str = NULL, /* defined at init */
5689 (void *)&cmd_setfwd_retry_set,
5690 (void *)&cmd_setfwd_retry_fwd,
5691 (void *)&cmd_setfwd_retry_mode,
5692 (void *)&cmd_setfwd_retry_retry,
5697 static void cmd_set_fwd_retry_mode_init(void)
5700 static char token[128];
5701 static char help[256];
5702 cmdline_parse_token_string_t *token_struct;
5704 modes = list_pkt_forwarding_retry_modes();
5705 snprintf(help, sizeof(help), "set fwd %s retry: "
5706 "Set packet forwarding mode with retry", modes);
5707 cmd_set_fwd_retry_mode.help_str = help;
5709 /* string token separator is # */
5710 for (c = token; *modes != '\0'; modes++)
5715 token_struct = (cmdline_parse_token_string_t *)
5716 cmd_set_fwd_retry_mode.tokens[2];
5717 token_struct->string_data.str = token;
5720 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5721 struct cmd_set_burst_tx_retry_result {
5722 cmdline_fixed_string_t set;
5723 cmdline_fixed_string_t burst;
5724 cmdline_fixed_string_t tx;
5725 cmdline_fixed_string_t delay;
5727 cmdline_fixed_string_t retry;
5731 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5732 __attribute__((unused)) struct cmdline *cl,
5733 __attribute__((unused)) void *data)
5735 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5737 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5738 && !strcmp(res->tx, "tx")) {
5739 if (!strcmp(res->delay, "delay"))
5740 burst_tx_delay_time = res->time;
5741 if (!strcmp(res->retry, "retry"))
5742 burst_tx_retry_num = res->retry_num;
5747 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5748 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5749 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5750 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5752 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5753 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5754 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5755 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5756 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5757 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5758 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5759 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5760 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5761 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5763 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5764 .f = cmd_set_burst_tx_retry_parsed,
5765 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5767 (void *)&cmd_set_burst_tx_retry_set,
5768 (void *)&cmd_set_burst_tx_retry_burst,
5769 (void *)&cmd_set_burst_tx_retry_tx,
5770 (void *)&cmd_set_burst_tx_retry_delay,
5771 (void *)&cmd_set_burst_tx_retry_time,
5772 (void *)&cmd_set_burst_tx_retry_retry,
5773 (void *)&cmd_set_burst_tx_retry_retry_num,
5778 /* *** SET PROMISC MODE *** */
5779 struct cmd_set_promisc_mode_result {
5780 cmdline_fixed_string_t set;
5781 cmdline_fixed_string_t promisc;
5782 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5783 uint16_t port_num; /* valid if "allports" argument == 0 */
5784 cmdline_fixed_string_t mode;
5787 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5788 __attribute__((unused)) struct cmdline *cl,
5791 struct cmd_set_promisc_mode_result *res = parsed_result;
5795 if (!strcmp(res->mode, "on"))
5802 RTE_ETH_FOREACH_DEV(i) {
5804 rte_eth_promiscuous_enable(i);
5806 rte_eth_promiscuous_disable(i);
5811 rte_eth_promiscuous_enable(res->port_num);
5813 rte_eth_promiscuous_disable(res->port_num);
5817 cmdline_parse_token_string_t cmd_setpromisc_set =
5818 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5819 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5820 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5822 cmdline_parse_token_string_t cmd_setpromisc_portall =
5823 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5825 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5826 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5828 cmdline_parse_token_string_t cmd_setpromisc_mode =
5829 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5832 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5833 .f = cmd_set_promisc_mode_parsed,
5835 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5837 (void *)&cmd_setpromisc_set,
5838 (void *)&cmd_setpromisc_promisc,
5839 (void *)&cmd_setpromisc_portall,
5840 (void *)&cmd_setpromisc_mode,
5845 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5846 .f = cmd_set_promisc_mode_parsed,
5848 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5850 (void *)&cmd_setpromisc_set,
5851 (void *)&cmd_setpromisc_promisc,
5852 (void *)&cmd_setpromisc_portnum,
5853 (void *)&cmd_setpromisc_mode,
5858 /* *** SET ALLMULTI MODE *** */
5859 struct cmd_set_allmulti_mode_result {
5860 cmdline_fixed_string_t set;
5861 cmdline_fixed_string_t allmulti;
5862 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5863 uint16_t port_num; /* valid if "allports" argument == 0 */
5864 cmdline_fixed_string_t mode;
5867 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5868 __attribute__((unused)) struct cmdline *cl,
5871 struct cmd_set_allmulti_mode_result *res = parsed_result;
5875 if (!strcmp(res->mode, "on"))
5882 RTE_ETH_FOREACH_DEV(i) {
5884 rte_eth_allmulticast_enable(i);
5886 rte_eth_allmulticast_disable(i);
5891 rte_eth_allmulticast_enable(res->port_num);
5893 rte_eth_allmulticast_disable(res->port_num);
5897 cmdline_parse_token_string_t cmd_setallmulti_set =
5898 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5899 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5900 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5902 cmdline_parse_token_string_t cmd_setallmulti_portall =
5903 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5905 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5906 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5908 cmdline_parse_token_string_t cmd_setallmulti_mode =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5912 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5913 .f = cmd_set_allmulti_mode_parsed,
5915 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5917 (void *)&cmd_setallmulti_set,
5918 (void *)&cmd_setallmulti_allmulti,
5919 (void *)&cmd_setallmulti_portall,
5920 (void *)&cmd_setallmulti_mode,
5925 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5926 .f = cmd_set_allmulti_mode_parsed,
5928 .help_str = "set allmulti <port_id> on|off: "
5929 "Set allmulti mode on port_id",
5931 (void *)&cmd_setallmulti_set,
5932 (void *)&cmd_setallmulti_allmulti,
5933 (void *)&cmd_setallmulti_portnum,
5934 (void *)&cmd_setallmulti_mode,
5939 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5940 struct cmd_link_flow_ctrl_set_result {
5941 cmdline_fixed_string_t set;
5942 cmdline_fixed_string_t flow_ctrl;
5943 cmdline_fixed_string_t rx;
5944 cmdline_fixed_string_t rx_lfc_mode;
5945 cmdline_fixed_string_t tx;
5946 cmdline_fixed_string_t tx_lfc_mode;
5947 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5948 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5949 cmdline_fixed_string_t autoneg_str;
5950 cmdline_fixed_string_t autoneg;
5951 cmdline_fixed_string_t hw_str;
5952 uint32_t high_water;
5953 cmdline_fixed_string_t lw_str;
5955 cmdline_fixed_string_t pt_str;
5956 uint16_t pause_time;
5957 cmdline_fixed_string_t xon_str;
5962 cmdline_parse_token_string_t cmd_lfc_set_set =
5963 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5965 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5966 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5967 flow_ctrl, "flow_ctrl");
5968 cmdline_parse_token_string_t cmd_lfc_set_rx =
5969 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5971 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5972 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5973 rx_lfc_mode, "on#off");
5974 cmdline_parse_token_string_t cmd_lfc_set_tx =
5975 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5977 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5978 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5979 tx_lfc_mode, "on#off");
5980 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5981 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5982 hw_str, "high_water");
5983 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5984 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5985 high_water, UINT32);
5986 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5987 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5988 lw_str, "low_water");
5989 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5990 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5992 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5993 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5994 pt_str, "pause_time");
5995 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5996 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5997 pause_time, UINT16);
5998 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5999 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6000 xon_str, "send_xon");
6001 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6002 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6004 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6005 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6006 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6007 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6008 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6009 mac_ctrl_frame_fwd_mode, "on#off");
6010 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6011 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6012 autoneg_str, "autoneg");
6013 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6014 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6016 cmdline_parse_token_num_t cmd_lfc_set_portid =
6017 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6020 /* forward declaration */
6022 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6025 cmdline_parse_inst_t cmd_link_flow_control_set = {
6026 .f = cmd_link_flow_ctrl_set_parsed,
6028 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6029 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6030 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6032 (void *)&cmd_lfc_set_set,
6033 (void *)&cmd_lfc_set_flow_ctrl,
6034 (void *)&cmd_lfc_set_rx,
6035 (void *)&cmd_lfc_set_rx_mode,
6036 (void *)&cmd_lfc_set_tx,
6037 (void *)&cmd_lfc_set_tx_mode,
6038 (void *)&cmd_lfc_set_high_water,
6039 (void *)&cmd_lfc_set_low_water,
6040 (void *)&cmd_lfc_set_pause_time,
6041 (void *)&cmd_lfc_set_send_xon,
6042 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6043 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6044 (void *)&cmd_lfc_set_autoneg_str,
6045 (void *)&cmd_lfc_set_autoneg,
6046 (void *)&cmd_lfc_set_portid,
6051 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6052 .f = cmd_link_flow_ctrl_set_parsed,
6053 .data = (void *)&cmd_link_flow_control_set_rx,
6054 .help_str = "set flow_ctrl rx on|off <port_id>: "
6055 "Change rx flow control parameter",
6057 (void *)&cmd_lfc_set_set,
6058 (void *)&cmd_lfc_set_flow_ctrl,
6059 (void *)&cmd_lfc_set_rx,
6060 (void *)&cmd_lfc_set_rx_mode,
6061 (void *)&cmd_lfc_set_portid,
6066 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6067 .f = cmd_link_flow_ctrl_set_parsed,
6068 .data = (void *)&cmd_link_flow_control_set_tx,
6069 .help_str = "set flow_ctrl tx on|off <port_id>: "
6070 "Change tx flow control parameter",
6072 (void *)&cmd_lfc_set_set,
6073 (void *)&cmd_lfc_set_flow_ctrl,
6074 (void *)&cmd_lfc_set_tx,
6075 (void *)&cmd_lfc_set_tx_mode,
6076 (void *)&cmd_lfc_set_portid,
6081 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6082 .f = cmd_link_flow_ctrl_set_parsed,
6083 .data = (void *)&cmd_link_flow_control_set_hw,
6084 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6085 "Change high water flow control parameter",
6087 (void *)&cmd_lfc_set_set,
6088 (void *)&cmd_lfc_set_flow_ctrl,
6089 (void *)&cmd_lfc_set_high_water_str,
6090 (void *)&cmd_lfc_set_high_water,
6091 (void *)&cmd_lfc_set_portid,
6096 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6097 .f = cmd_link_flow_ctrl_set_parsed,
6098 .data = (void *)&cmd_link_flow_control_set_lw,
6099 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6100 "Change low water flow control parameter",
6102 (void *)&cmd_lfc_set_set,
6103 (void *)&cmd_lfc_set_flow_ctrl,
6104 (void *)&cmd_lfc_set_low_water_str,
6105 (void *)&cmd_lfc_set_low_water,
6106 (void *)&cmd_lfc_set_portid,
6111 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6112 .f = cmd_link_flow_ctrl_set_parsed,
6113 .data = (void *)&cmd_link_flow_control_set_pt,
6114 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6115 "Change pause time flow control parameter",
6117 (void *)&cmd_lfc_set_set,
6118 (void *)&cmd_lfc_set_flow_ctrl,
6119 (void *)&cmd_lfc_set_pause_time_str,
6120 (void *)&cmd_lfc_set_pause_time,
6121 (void *)&cmd_lfc_set_portid,
6126 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6127 .f = cmd_link_flow_ctrl_set_parsed,
6128 .data = (void *)&cmd_link_flow_control_set_xon,
6129 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6130 "Change send_xon flow control parameter",
6132 (void *)&cmd_lfc_set_set,
6133 (void *)&cmd_lfc_set_flow_ctrl,
6134 (void *)&cmd_lfc_set_send_xon_str,
6135 (void *)&cmd_lfc_set_send_xon,
6136 (void *)&cmd_lfc_set_portid,
6141 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6142 .f = cmd_link_flow_ctrl_set_parsed,
6143 .data = (void *)&cmd_link_flow_control_set_macfwd,
6144 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6145 "Change mac ctrl fwd flow control parameter",
6147 (void *)&cmd_lfc_set_set,
6148 (void *)&cmd_lfc_set_flow_ctrl,
6149 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6150 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6151 (void *)&cmd_lfc_set_portid,
6156 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6157 .f = cmd_link_flow_ctrl_set_parsed,
6158 .data = (void *)&cmd_link_flow_control_set_autoneg,
6159 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6160 "Change autoneg flow control parameter",
6162 (void *)&cmd_lfc_set_set,
6163 (void *)&cmd_lfc_set_flow_ctrl,
6164 (void *)&cmd_lfc_set_autoneg_str,
6165 (void *)&cmd_lfc_set_autoneg,
6166 (void *)&cmd_lfc_set_portid,
6172 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6173 __attribute__((unused)) struct cmdline *cl,
6176 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6177 cmdline_parse_inst_t *cmd = data;
6178 struct rte_eth_fc_conf fc_conf;
6184 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6185 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6186 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6187 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6189 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6190 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6193 /* Partial command line, retrieve current configuration */
6195 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6197 printf("cannot get current flow ctrl parameters, return"
6198 "code = %d\n", ret);
6202 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6203 (fc_conf.mode == RTE_FC_FULL))
6205 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6206 (fc_conf.mode == RTE_FC_FULL))
6210 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6211 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6213 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6214 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6216 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6218 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6219 fc_conf.high_water = res->high_water;
6221 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6222 fc_conf.low_water = res->low_water;
6224 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6225 fc_conf.pause_time = res->pause_time;
6227 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6228 fc_conf.send_xon = res->send_xon;
6230 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6231 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6232 fc_conf.mac_ctrl_frame_fwd = 1;
6234 fc_conf.mac_ctrl_frame_fwd = 0;
6237 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6238 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6240 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6242 printf("bad flow contrl parameter, return code = %d \n", ret);
6245 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6246 struct cmd_priority_flow_ctrl_set_result {
6247 cmdline_fixed_string_t set;
6248 cmdline_fixed_string_t pfc_ctrl;
6249 cmdline_fixed_string_t rx;
6250 cmdline_fixed_string_t rx_pfc_mode;
6251 cmdline_fixed_string_t tx;
6252 cmdline_fixed_string_t tx_pfc_mode;
6253 uint32_t high_water;
6255 uint16_t pause_time;
6261 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6262 __attribute__((unused)) struct cmdline *cl,
6263 __attribute__((unused)) void *data)
6265 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6266 struct rte_eth_pfc_conf pfc_conf;
6267 int rx_fc_enable, tx_fc_enable;
6271 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6272 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6273 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6274 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6276 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6277 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6280 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6281 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6282 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6283 pfc_conf.fc.high_water = res->high_water;
6284 pfc_conf.fc.low_water = res->low_water;
6285 pfc_conf.fc.pause_time = res->pause_time;
6286 pfc_conf.priority = res->priority;
6288 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6290 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6293 cmdline_parse_token_string_t cmd_pfc_set_set =
6294 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6296 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6297 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6298 pfc_ctrl, "pfc_ctrl");
6299 cmdline_parse_token_string_t cmd_pfc_set_rx =
6300 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6302 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6303 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6304 rx_pfc_mode, "on#off");
6305 cmdline_parse_token_string_t cmd_pfc_set_tx =
6306 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6308 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6309 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6310 tx_pfc_mode, "on#off");
6311 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6312 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6313 high_water, UINT32);
6314 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6315 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6317 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6318 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6319 pause_time, UINT16);
6320 cmdline_parse_token_num_t cmd_pfc_set_priority =
6321 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6323 cmdline_parse_token_num_t cmd_pfc_set_portid =
6324 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6327 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6328 .f = cmd_priority_flow_ctrl_set_parsed,
6330 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6331 "<pause_time> <priority> <port_id>: "
6332 "Configure the Ethernet priority flow control",
6334 (void *)&cmd_pfc_set_set,
6335 (void *)&cmd_pfc_set_flow_ctrl,
6336 (void *)&cmd_pfc_set_rx,
6337 (void *)&cmd_pfc_set_rx_mode,
6338 (void *)&cmd_pfc_set_tx,
6339 (void *)&cmd_pfc_set_tx_mode,
6340 (void *)&cmd_pfc_set_high_water,
6341 (void *)&cmd_pfc_set_low_water,
6342 (void *)&cmd_pfc_set_pause_time,
6343 (void *)&cmd_pfc_set_priority,
6344 (void *)&cmd_pfc_set_portid,
6349 /* *** RESET CONFIGURATION *** */
6350 struct cmd_reset_result {
6351 cmdline_fixed_string_t reset;
6352 cmdline_fixed_string_t def;
6355 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6357 __attribute__((unused)) void *data)
6359 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6360 set_def_fwd_config();
6363 cmdline_parse_token_string_t cmd_reset_set =
6364 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6365 cmdline_parse_token_string_t cmd_reset_def =
6366 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6369 cmdline_parse_inst_t cmd_reset = {
6370 .f = cmd_reset_parsed,
6372 .help_str = "set default: Reset default forwarding configuration",
6374 (void *)&cmd_reset_set,
6375 (void *)&cmd_reset_def,
6380 /* *** START FORWARDING *** */
6381 struct cmd_start_result {
6382 cmdline_fixed_string_t start;
6385 cmdline_parse_token_string_t cmd_start_start =
6386 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6388 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6389 __attribute__((unused)) struct cmdline *cl,
6390 __attribute__((unused)) void *data)
6392 start_packet_forwarding(0);
6395 cmdline_parse_inst_t cmd_start = {
6396 .f = cmd_start_parsed,
6398 .help_str = "start: Start packet forwarding",
6400 (void *)&cmd_start_start,
6405 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6406 struct cmd_start_tx_first_result {
6407 cmdline_fixed_string_t start;
6408 cmdline_fixed_string_t tx_first;
6412 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6413 __attribute__((unused)) struct cmdline *cl,
6414 __attribute__((unused)) void *data)
6416 start_packet_forwarding(1);
6419 cmdline_parse_token_string_t cmd_start_tx_first_start =
6420 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6422 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6423 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6424 tx_first, "tx_first");
6426 cmdline_parse_inst_t cmd_start_tx_first = {
6427 .f = cmd_start_tx_first_parsed,
6429 .help_str = "start tx_first: Start packet forwarding, "
6430 "after sending 1 burst of packets",
6432 (void *)&cmd_start_tx_first_start,
6433 (void *)&cmd_start_tx_first_tx_first,
6438 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6439 struct cmd_start_tx_first_n_result {
6440 cmdline_fixed_string_t start;
6441 cmdline_fixed_string_t tx_first;
6446 cmd_start_tx_first_n_parsed(void *parsed_result,
6447 __attribute__((unused)) struct cmdline *cl,
6448 __attribute__((unused)) void *data)
6450 struct cmd_start_tx_first_n_result *res = parsed_result;
6452 start_packet_forwarding(res->tx_num);
6455 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6456 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6458 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6459 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6460 tx_first, "tx_first");
6461 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6462 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6465 cmdline_parse_inst_t cmd_start_tx_first_n = {
6466 .f = cmd_start_tx_first_n_parsed,
6468 .help_str = "start tx_first <num>: "
6469 "packet forwarding, after sending <num> bursts of packets",
6471 (void *)&cmd_start_tx_first_n_start,
6472 (void *)&cmd_start_tx_first_n_tx_first,
6473 (void *)&cmd_start_tx_first_n_tx_num,
6478 /* *** SET LINK UP *** */
6479 struct cmd_set_link_up_result {
6480 cmdline_fixed_string_t set;
6481 cmdline_fixed_string_t link_up;
6482 cmdline_fixed_string_t port;
6486 cmdline_parse_token_string_t cmd_set_link_up_set =
6487 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6488 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6489 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6491 cmdline_parse_token_string_t cmd_set_link_up_port =
6492 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6493 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6494 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6496 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6497 __attribute__((unused)) struct cmdline *cl,
6498 __attribute__((unused)) void *data)
6500 struct cmd_set_link_up_result *res = parsed_result;
6501 dev_set_link_up(res->port_id);
6504 cmdline_parse_inst_t cmd_set_link_up = {
6505 .f = cmd_set_link_up_parsed,
6507 .help_str = "set link-up port <port id>",
6509 (void *)&cmd_set_link_up_set,
6510 (void *)&cmd_set_link_up_link_up,
6511 (void *)&cmd_set_link_up_port,
6512 (void *)&cmd_set_link_up_port_id,
6517 /* *** SET LINK DOWN *** */
6518 struct cmd_set_link_down_result {
6519 cmdline_fixed_string_t set;
6520 cmdline_fixed_string_t link_down;
6521 cmdline_fixed_string_t port;
6525 cmdline_parse_token_string_t cmd_set_link_down_set =
6526 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6527 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6528 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6530 cmdline_parse_token_string_t cmd_set_link_down_port =
6531 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6532 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6533 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6535 static void cmd_set_link_down_parsed(
6536 __attribute__((unused)) void *parsed_result,
6537 __attribute__((unused)) struct cmdline *cl,
6538 __attribute__((unused)) void *data)
6540 struct cmd_set_link_down_result *res = parsed_result;
6541 dev_set_link_down(res->port_id);
6544 cmdline_parse_inst_t cmd_set_link_down = {
6545 .f = cmd_set_link_down_parsed,
6547 .help_str = "set link-down port <port id>",
6549 (void *)&cmd_set_link_down_set,
6550 (void *)&cmd_set_link_down_link_down,
6551 (void *)&cmd_set_link_down_port,
6552 (void *)&cmd_set_link_down_port_id,
6557 /* *** SHOW CFG *** */
6558 struct cmd_showcfg_result {
6559 cmdline_fixed_string_t show;
6560 cmdline_fixed_string_t cfg;
6561 cmdline_fixed_string_t what;
6564 static void cmd_showcfg_parsed(void *parsed_result,
6565 __attribute__((unused)) struct cmdline *cl,
6566 __attribute__((unused)) void *data)
6568 struct cmd_showcfg_result *res = parsed_result;
6569 if (!strcmp(res->what, "rxtx"))
6570 rxtx_config_display();
6571 else if (!strcmp(res->what, "cores"))
6572 fwd_lcores_config_display();
6573 else if (!strcmp(res->what, "fwd"))
6574 pkt_fwd_config_display(&cur_fwd_config);
6575 else if (!strcmp(res->what, "txpkts"))
6576 show_tx_pkt_segments();
6579 cmdline_parse_token_string_t cmd_showcfg_show =
6580 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6581 cmdline_parse_token_string_t cmd_showcfg_port =
6582 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6583 cmdline_parse_token_string_t cmd_showcfg_what =
6584 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6585 "rxtx#cores#fwd#txpkts");
6587 cmdline_parse_inst_t cmd_showcfg = {
6588 .f = cmd_showcfg_parsed,
6590 .help_str = "show config rxtx|cores|fwd|txpkts",
6592 (void *)&cmd_showcfg_show,
6593 (void *)&cmd_showcfg_port,
6594 (void *)&cmd_showcfg_what,
6599 /* *** SHOW ALL PORT INFO *** */
6600 struct cmd_showportall_result {
6601 cmdline_fixed_string_t show;
6602 cmdline_fixed_string_t port;
6603 cmdline_fixed_string_t what;
6604 cmdline_fixed_string_t all;
6607 static void cmd_showportall_parsed(void *parsed_result,
6608 __attribute__((unused)) struct cmdline *cl,
6609 __attribute__((unused)) void *data)
6613 struct cmd_showportall_result *res = parsed_result;
6614 if (!strcmp(res->show, "clear")) {
6615 if (!strcmp(res->what, "stats"))
6616 RTE_ETH_FOREACH_DEV(i)
6618 else if (!strcmp(res->what, "xstats"))
6619 RTE_ETH_FOREACH_DEV(i)
6620 nic_xstats_clear(i);
6621 } else if (!strcmp(res->what, "info"))
6622 RTE_ETH_FOREACH_DEV(i)
6623 port_infos_display(i);
6624 else if (!strcmp(res->what, "stats"))
6625 RTE_ETH_FOREACH_DEV(i)
6626 nic_stats_display(i);
6627 else if (!strcmp(res->what, "xstats"))
6628 RTE_ETH_FOREACH_DEV(i)
6629 nic_xstats_display(i);
6630 else if (!strcmp(res->what, "fdir"))
6631 RTE_ETH_FOREACH_DEV(i)
6633 else if (!strcmp(res->what, "stat_qmap"))
6634 RTE_ETH_FOREACH_DEV(i)
6635 nic_stats_mapping_display(i);
6636 else if (!strcmp(res->what, "dcb_tc"))
6637 RTE_ETH_FOREACH_DEV(i)
6638 port_dcb_info_display(i);
6639 else if (!strcmp(res->what, "cap"))
6640 RTE_ETH_FOREACH_DEV(i)
6641 port_offload_cap_display(i);
6644 cmdline_parse_token_string_t cmd_showportall_show =
6645 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6647 cmdline_parse_token_string_t cmd_showportall_port =
6648 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6649 cmdline_parse_token_string_t cmd_showportall_what =
6650 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6651 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6652 cmdline_parse_token_string_t cmd_showportall_all =
6653 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6654 cmdline_parse_inst_t cmd_showportall = {
6655 .f = cmd_showportall_parsed,
6657 .help_str = "show|clear port "
6658 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6660 (void *)&cmd_showportall_show,
6661 (void *)&cmd_showportall_port,
6662 (void *)&cmd_showportall_what,
6663 (void *)&cmd_showportall_all,
6668 /* *** SHOW PORT INFO *** */
6669 struct cmd_showport_result {
6670 cmdline_fixed_string_t show;
6671 cmdline_fixed_string_t port;
6672 cmdline_fixed_string_t what;
6676 static void cmd_showport_parsed(void *parsed_result,
6677 __attribute__((unused)) struct cmdline *cl,
6678 __attribute__((unused)) void *data)
6680 struct cmd_showport_result *res = parsed_result;
6681 if (!strcmp(res->show, "clear")) {
6682 if (!strcmp(res->what, "stats"))
6683 nic_stats_clear(res->portnum);
6684 else if (!strcmp(res->what, "xstats"))
6685 nic_xstats_clear(res->portnum);
6686 } else if (!strcmp(res->what, "info"))
6687 port_infos_display(res->portnum);
6688 else if (!strcmp(res->what, "stats"))
6689 nic_stats_display(res->portnum);
6690 else if (!strcmp(res->what, "xstats"))
6691 nic_xstats_display(res->portnum);
6692 else if (!strcmp(res->what, "fdir"))
6693 fdir_get_infos(res->portnum);
6694 else if (!strcmp(res->what, "stat_qmap"))
6695 nic_stats_mapping_display(res->portnum);
6696 else if (!strcmp(res->what, "dcb_tc"))
6697 port_dcb_info_display(res->portnum);
6698 else if (!strcmp(res->what, "cap"))
6699 port_offload_cap_display(res->portnum);
6702 cmdline_parse_token_string_t cmd_showport_show =
6703 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6705 cmdline_parse_token_string_t cmd_showport_port =
6706 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6707 cmdline_parse_token_string_t cmd_showport_what =
6708 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6709 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6710 cmdline_parse_token_num_t cmd_showport_portnum =
6711 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6713 cmdline_parse_inst_t cmd_showport = {
6714 .f = cmd_showport_parsed,
6716 .help_str = "show|clear port "
6717 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6720 (void *)&cmd_showport_show,
6721 (void *)&cmd_showport_port,
6722 (void *)&cmd_showport_what,
6723 (void *)&cmd_showport_portnum,
6728 /* *** SHOW QUEUE INFO *** */
6729 struct cmd_showqueue_result {
6730 cmdline_fixed_string_t show;
6731 cmdline_fixed_string_t type;
6732 cmdline_fixed_string_t what;
6738 cmd_showqueue_parsed(void *parsed_result,
6739 __attribute__((unused)) struct cmdline *cl,
6740 __attribute__((unused)) void *data)
6742 struct cmd_showqueue_result *res = parsed_result;
6744 if (!strcmp(res->type, "rxq"))
6745 rx_queue_infos_display(res->portnum, res->queuenum);
6746 else if (!strcmp(res->type, "txq"))
6747 tx_queue_infos_display(res->portnum, res->queuenum);
6750 cmdline_parse_token_string_t cmd_showqueue_show =
6751 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6752 cmdline_parse_token_string_t cmd_showqueue_type =
6753 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6754 cmdline_parse_token_string_t cmd_showqueue_what =
6755 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6756 cmdline_parse_token_num_t cmd_showqueue_portnum =
6757 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6758 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6759 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6761 cmdline_parse_inst_t cmd_showqueue = {
6762 .f = cmd_showqueue_parsed,
6764 .help_str = "show rxq|txq info <port_id> <queue_id>",
6766 (void *)&cmd_showqueue_show,
6767 (void *)&cmd_showqueue_type,
6768 (void *)&cmd_showqueue_what,
6769 (void *)&cmd_showqueue_portnum,
6770 (void *)&cmd_showqueue_queuenum,
6775 /* *** READ PORT REGISTER *** */
6776 struct cmd_read_reg_result {
6777 cmdline_fixed_string_t read;
6778 cmdline_fixed_string_t reg;
6784 cmd_read_reg_parsed(void *parsed_result,
6785 __attribute__((unused)) struct cmdline *cl,
6786 __attribute__((unused)) void *data)
6788 struct cmd_read_reg_result *res = parsed_result;
6789 port_reg_display(res->port_id, res->reg_off);
6792 cmdline_parse_token_string_t cmd_read_reg_read =
6793 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6794 cmdline_parse_token_string_t cmd_read_reg_reg =
6795 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6796 cmdline_parse_token_num_t cmd_read_reg_port_id =
6797 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6798 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6799 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6801 cmdline_parse_inst_t cmd_read_reg = {
6802 .f = cmd_read_reg_parsed,
6804 .help_str = "read reg <port_id> <reg_off>",
6806 (void *)&cmd_read_reg_read,
6807 (void *)&cmd_read_reg_reg,
6808 (void *)&cmd_read_reg_port_id,
6809 (void *)&cmd_read_reg_reg_off,
6814 /* *** READ PORT REGISTER BIT FIELD *** */
6815 struct cmd_read_reg_bit_field_result {
6816 cmdline_fixed_string_t read;
6817 cmdline_fixed_string_t regfield;
6825 cmd_read_reg_bit_field_parsed(void *parsed_result,
6826 __attribute__((unused)) struct cmdline *cl,
6827 __attribute__((unused)) void *data)
6829 struct cmd_read_reg_bit_field_result *res = parsed_result;
6830 port_reg_bit_field_display(res->port_id, res->reg_off,
6831 res->bit1_pos, res->bit2_pos);
6834 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6835 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6837 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6838 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6839 regfield, "regfield");
6840 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6841 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6843 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6844 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6846 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6847 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6849 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6850 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6853 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6854 .f = cmd_read_reg_bit_field_parsed,
6856 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6857 "Read register bit field between bit_x and bit_y included",
6859 (void *)&cmd_read_reg_bit_field_read,
6860 (void *)&cmd_read_reg_bit_field_regfield,
6861 (void *)&cmd_read_reg_bit_field_port_id,
6862 (void *)&cmd_read_reg_bit_field_reg_off,
6863 (void *)&cmd_read_reg_bit_field_bit1_pos,
6864 (void *)&cmd_read_reg_bit_field_bit2_pos,
6869 /* *** READ PORT REGISTER BIT *** */
6870 struct cmd_read_reg_bit_result {
6871 cmdline_fixed_string_t read;
6872 cmdline_fixed_string_t regbit;
6879 cmd_read_reg_bit_parsed(void *parsed_result,
6880 __attribute__((unused)) struct cmdline *cl,
6881 __attribute__((unused)) void *data)
6883 struct cmd_read_reg_bit_result *res = parsed_result;
6884 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6887 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6888 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6889 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6890 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6892 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6893 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6894 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6895 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6896 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6897 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6899 cmdline_parse_inst_t cmd_read_reg_bit = {
6900 .f = cmd_read_reg_bit_parsed,
6902 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6904 (void *)&cmd_read_reg_bit_read,
6905 (void *)&cmd_read_reg_bit_regbit,
6906 (void *)&cmd_read_reg_bit_port_id,
6907 (void *)&cmd_read_reg_bit_reg_off,
6908 (void *)&cmd_read_reg_bit_bit_pos,
6913 /* *** WRITE PORT REGISTER *** */
6914 struct cmd_write_reg_result {
6915 cmdline_fixed_string_t write;
6916 cmdline_fixed_string_t reg;
6923 cmd_write_reg_parsed(void *parsed_result,
6924 __attribute__((unused)) struct cmdline *cl,
6925 __attribute__((unused)) void *data)
6927 struct cmd_write_reg_result *res = parsed_result;
6928 port_reg_set(res->port_id, res->reg_off, res->value);
6931 cmdline_parse_token_string_t cmd_write_reg_write =
6932 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6933 cmdline_parse_token_string_t cmd_write_reg_reg =
6934 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6935 cmdline_parse_token_num_t cmd_write_reg_port_id =
6936 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6937 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6938 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6939 cmdline_parse_token_num_t cmd_write_reg_value =
6940 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6942 cmdline_parse_inst_t cmd_write_reg = {
6943 .f = cmd_write_reg_parsed,
6945 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6947 (void *)&cmd_write_reg_write,
6948 (void *)&cmd_write_reg_reg,
6949 (void *)&cmd_write_reg_port_id,
6950 (void *)&cmd_write_reg_reg_off,
6951 (void *)&cmd_write_reg_value,
6956 /* *** WRITE PORT REGISTER BIT FIELD *** */
6957 struct cmd_write_reg_bit_field_result {
6958 cmdline_fixed_string_t write;
6959 cmdline_fixed_string_t regfield;
6968 cmd_write_reg_bit_field_parsed(void *parsed_result,
6969 __attribute__((unused)) struct cmdline *cl,
6970 __attribute__((unused)) void *data)
6972 struct cmd_write_reg_bit_field_result *res = parsed_result;
6973 port_reg_bit_field_set(res->port_id, res->reg_off,
6974 res->bit1_pos, res->bit2_pos, res->value);
6977 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6978 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6980 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6981 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6982 regfield, "regfield");
6983 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6984 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6986 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6987 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6989 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6990 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6992 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6993 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6995 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6996 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6999 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7000 .f = cmd_write_reg_bit_field_parsed,
7002 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7004 "Set register bit field between bit_x and bit_y included",
7006 (void *)&cmd_write_reg_bit_field_write,
7007 (void *)&cmd_write_reg_bit_field_regfield,
7008 (void *)&cmd_write_reg_bit_field_port_id,
7009 (void *)&cmd_write_reg_bit_field_reg_off,
7010 (void *)&cmd_write_reg_bit_field_bit1_pos,
7011 (void *)&cmd_write_reg_bit_field_bit2_pos,
7012 (void *)&cmd_write_reg_bit_field_value,
7017 /* *** WRITE PORT REGISTER BIT *** */
7018 struct cmd_write_reg_bit_result {
7019 cmdline_fixed_string_t write;
7020 cmdline_fixed_string_t regbit;
7028 cmd_write_reg_bit_parsed(void *parsed_result,
7029 __attribute__((unused)) struct cmdline *cl,
7030 __attribute__((unused)) void *data)
7032 struct cmd_write_reg_bit_result *res = parsed_result;
7033 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7036 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7037 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7039 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7040 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7042 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7043 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7044 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7045 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7046 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7047 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7048 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7049 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7051 cmdline_parse_inst_t cmd_write_reg_bit = {
7052 .f = cmd_write_reg_bit_parsed,
7054 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7057 (void *)&cmd_write_reg_bit_write,
7058 (void *)&cmd_write_reg_bit_regbit,
7059 (void *)&cmd_write_reg_bit_port_id,
7060 (void *)&cmd_write_reg_bit_reg_off,
7061 (void *)&cmd_write_reg_bit_bit_pos,
7062 (void *)&cmd_write_reg_bit_value,
7067 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7068 struct cmd_read_rxd_txd_result {
7069 cmdline_fixed_string_t read;
7070 cmdline_fixed_string_t rxd_txd;
7077 cmd_read_rxd_txd_parsed(void *parsed_result,
7078 __attribute__((unused)) struct cmdline *cl,
7079 __attribute__((unused)) void *data)
7081 struct cmd_read_rxd_txd_result *res = parsed_result;
7083 if (!strcmp(res->rxd_txd, "rxd"))
7084 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7085 else if (!strcmp(res->rxd_txd, "txd"))
7086 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7089 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7090 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7091 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7092 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7094 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7095 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7096 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7097 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7098 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7099 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7101 cmdline_parse_inst_t cmd_read_rxd_txd = {
7102 .f = cmd_read_rxd_txd_parsed,
7104 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7106 (void *)&cmd_read_rxd_txd_read,
7107 (void *)&cmd_read_rxd_txd_rxd_txd,
7108 (void *)&cmd_read_rxd_txd_port_id,
7109 (void *)&cmd_read_rxd_txd_queue_id,
7110 (void *)&cmd_read_rxd_txd_desc_id,
7116 struct cmd_quit_result {
7117 cmdline_fixed_string_t quit;
7120 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7122 __attribute__((unused)) void *data)
7128 cmdline_parse_token_string_t cmd_quit_quit =
7129 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7131 cmdline_parse_inst_t cmd_quit = {
7132 .f = cmd_quit_parsed,
7134 .help_str = "quit: Exit application",
7136 (void *)&cmd_quit_quit,
7141 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7142 struct cmd_mac_addr_result {
7143 cmdline_fixed_string_t mac_addr_cmd;
7144 cmdline_fixed_string_t what;
7146 struct ether_addr address;
7149 static void cmd_mac_addr_parsed(void *parsed_result,
7150 __attribute__((unused)) struct cmdline *cl,
7151 __attribute__((unused)) void *data)
7153 struct cmd_mac_addr_result *res = parsed_result;
7156 if (strcmp(res->what, "add") == 0)
7157 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7158 else if (strcmp(res->what, "set") == 0)
7159 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7162 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7164 /* check the return value and print it if is < 0 */
7166 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7170 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7171 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7173 cmdline_parse_token_string_t cmd_mac_addr_what =
7174 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7176 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7177 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7179 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7180 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7182 cmdline_parse_inst_t cmd_mac_addr = {
7183 .f = cmd_mac_addr_parsed,
7185 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7186 "Add/Remove/Set MAC address on port_id",
7188 (void *)&cmd_mac_addr_cmd,
7189 (void *)&cmd_mac_addr_what,
7190 (void *)&cmd_mac_addr_portnum,
7191 (void *)&cmd_mac_addr_addr,
7196 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7197 struct cmd_eth_peer_result {
7198 cmdline_fixed_string_t set;
7199 cmdline_fixed_string_t eth_peer;
7201 cmdline_fixed_string_t peer_addr;
7204 static void cmd_set_eth_peer_parsed(void *parsed_result,
7205 __attribute__((unused)) struct cmdline *cl,
7206 __attribute__((unused)) void *data)
7208 struct cmd_eth_peer_result *res = parsed_result;
7210 if (test_done == 0) {
7211 printf("Please stop forwarding first\n");
7214 if (!strcmp(res->eth_peer, "eth-peer")) {
7215 set_fwd_eth_peer(res->port_id, res->peer_addr);
7219 cmdline_parse_token_string_t cmd_eth_peer_set =
7220 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7221 cmdline_parse_token_string_t cmd_eth_peer =
7222 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7223 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7224 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7225 cmdline_parse_token_string_t cmd_eth_peer_addr =
7226 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7228 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7229 .f = cmd_set_eth_peer_parsed,
7231 .help_str = "set eth-peer <port_id> <peer_mac>",
7233 (void *)&cmd_eth_peer_set,
7234 (void *)&cmd_eth_peer,
7235 (void *)&cmd_eth_peer_port_id,
7236 (void *)&cmd_eth_peer_addr,
7241 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7242 struct cmd_set_qmap_result {
7243 cmdline_fixed_string_t set;
7244 cmdline_fixed_string_t qmap;
7245 cmdline_fixed_string_t what;
7252 cmd_set_qmap_parsed(void *parsed_result,
7253 __attribute__((unused)) struct cmdline *cl,
7254 __attribute__((unused)) void *data)
7256 struct cmd_set_qmap_result *res = parsed_result;
7257 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7259 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7262 cmdline_parse_token_string_t cmd_setqmap_set =
7263 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7265 cmdline_parse_token_string_t cmd_setqmap_qmap =
7266 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7268 cmdline_parse_token_string_t cmd_setqmap_what =
7269 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7271 cmdline_parse_token_num_t cmd_setqmap_portid =
7272 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7274 cmdline_parse_token_num_t cmd_setqmap_queueid =
7275 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7277 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7278 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7281 cmdline_parse_inst_t cmd_set_qmap = {
7282 .f = cmd_set_qmap_parsed,
7284 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7285 "Set statistics mapping value on tx|rx queue_id of port_id",
7287 (void *)&cmd_setqmap_set,
7288 (void *)&cmd_setqmap_qmap,
7289 (void *)&cmd_setqmap_what,
7290 (void *)&cmd_setqmap_portid,
7291 (void *)&cmd_setqmap_queueid,
7292 (void *)&cmd_setqmap_mapvalue,
7297 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7298 struct cmd_set_xstats_hide_zero_result {
7299 cmdline_fixed_string_t keyword;
7300 cmdline_fixed_string_t name;
7301 cmdline_fixed_string_t on_off;
7305 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7306 __attribute__((unused)) struct cmdline *cl,
7307 __attribute__((unused)) void *data)
7309 struct cmd_set_xstats_hide_zero_result *res;
7310 uint16_t on_off = 0;
7312 res = parsed_result;
7313 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7314 set_xstats_hide_zero(on_off);
7317 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7318 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7320 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7321 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7322 name, "xstats-hide-zero");
7323 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7324 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7327 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7328 .f = cmd_set_xstats_hide_zero_parsed,
7330 .help_str = "set xstats-hide-zero on|off",
7332 (void *)&cmd_set_xstats_hide_zero_keyword,
7333 (void *)&cmd_set_xstats_hide_zero_name,
7334 (void *)&cmd_set_xstats_hide_zero_on_off,
7339 /* *** CONFIGURE UNICAST HASH TABLE *** */
7340 struct cmd_set_uc_hash_table {
7341 cmdline_fixed_string_t set;
7342 cmdline_fixed_string_t port;
7344 cmdline_fixed_string_t what;
7345 struct ether_addr address;
7346 cmdline_fixed_string_t mode;
7350 cmd_set_uc_hash_parsed(void *parsed_result,
7351 __attribute__((unused)) struct cmdline *cl,
7352 __attribute__((unused)) void *data)
7355 struct cmd_set_uc_hash_table *res = parsed_result;
7357 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7359 if (strcmp(res->what, "uta") == 0)
7360 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7361 &res->address,(uint8_t)is_on);
7363 printf("bad unicast hash table parameter, return code = %d \n", ret);
7367 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7368 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7370 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7371 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7373 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7374 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7376 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7377 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7379 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7380 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7382 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7383 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7386 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7387 .f = cmd_set_uc_hash_parsed,
7389 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7391 (void *)&cmd_set_uc_hash_set,
7392 (void *)&cmd_set_uc_hash_port,
7393 (void *)&cmd_set_uc_hash_portid,
7394 (void *)&cmd_set_uc_hash_what,
7395 (void *)&cmd_set_uc_hash_mac,
7396 (void *)&cmd_set_uc_hash_mode,
7401 struct cmd_set_uc_all_hash_table {
7402 cmdline_fixed_string_t set;
7403 cmdline_fixed_string_t port;
7405 cmdline_fixed_string_t what;
7406 cmdline_fixed_string_t value;
7407 cmdline_fixed_string_t mode;
7411 cmd_set_uc_all_hash_parsed(void *parsed_result,
7412 __attribute__((unused)) struct cmdline *cl,
7413 __attribute__((unused)) void *data)
7416 struct cmd_set_uc_all_hash_table *res = parsed_result;
7418 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7420 if ((strcmp(res->what, "uta") == 0) &&
7421 (strcmp(res->value, "all") == 0))
7422 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7424 printf("bad unicast hash table parameter,"
7425 "return code = %d \n", ret);
7428 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7429 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7431 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7432 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7434 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7435 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7437 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7438 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7440 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7441 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7443 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7444 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7447 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7448 .f = cmd_set_uc_all_hash_parsed,
7450 .help_str = "set port <port_id> uta all on|off",
7452 (void *)&cmd_set_uc_all_hash_set,
7453 (void *)&cmd_set_uc_all_hash_port,
7454 (void *)&cmd_set_uc_all_hash_portid,
7455 (void *)&cmd_set_uc_all_hash_what,
7456 (void *)&cmd_set_uc_all_hash_value,
7457 (void *)&cmd_set_uc_all_hash_mode,
7462 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7463 struct cmd_set_vf_macvlan_filter {
7464 cmdline_fixed_string_t set;
7465 cmdline_fixed_string_t port;
7467 cmdline_fixed_string_t vf;
7469 struct ether_addr address;
7470 cmdline_fixed_string_t filter_type;
7471 cmdline_fixed_string_t mode;
7475 cmd_set_vf_macvlan_parsed(void *parsed_result,
7476 __attribute__((unused)) struct cmdline *cl,
7477 __attribute__((unused)) void *data)
7480 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7481 struct rte_eth_mac_filter filter;
7483 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7485 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7487 /* set VF MAC filter */
7491 filter.dst_id = res->vf_id;
7493 if (!strcmp(res->filter_type, "exact-mac"))
7494 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7495 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7496 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7497 else if (!strcmp(res->filter_type, "hashmac"))
7498 filter.filter_type = RTE_MAC_HASH_MATCH;
7499 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7500 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7502 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7505 ret = rte_eth_dev_filter_ctrl(res->port_id,
7506 RTE_ETH_FILTER_MACVLAN,
7510 ret = rte_eth_dev_filter_ctrl(res->port_id,
7511 RTE_ETH_FILTER_MACVLAN,
7512 RTE_ETH_FILTER_DELETE,
7516 printf("bad set MAC hash parameter, return code = %d\n", ret);
7520 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7521 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7523 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7524 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7526 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7527 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7529 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7530 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7532 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7533 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7535 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7536 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7538 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7539 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7540 filter_type, "exact-mac#exact-mac-vlan"
7541 "#hashmac#hashmac-vlan");
7542 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7543 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7546 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7547 .f = cmd_set_vf_macvlan_parsed,
7549 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7550 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7551 "Exact match rule: exact match of MAC or MAC and VLAN; "
7552 "hash match rule: hash match of MAC and exact match of VLAN",
7554 (void *)&cmd_set_vf_macvlan_set,
7555 (void *)&cmd_set_vf_macvlan_port,
7556 (void *)&cmd_set_vf_macvlan_portid,
7557 (void *)&cmd_set_vf_macvlan_vf,
7558 (void *)&cmd_set_vf_macvlan_vf_id,
7559 (void *)&cmd_set_vf_macvlan_mac,
7560 (void *)&cmd_set_vf_macvlan_filter_type,
7561 (void *)&cmd_set_vf_macvlan_mode,
7566 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7567 struct cmd_set_vf_traffic {
7568 cmdline_fixed_string_t set;
7569 cmdline_fixed_string_t port;
7571 cmdline_fixed_string_t vf;
7573 cmdline_fixed_string_t what;
7574 cmdline_fixed_string_t mode;
7578 cmd_set_vf_traffic_parsed(void *parsed_result,
7579 __attribute__((unused)) struct cmdline *cl,
7580 __attribute__((unused)) void *data)
7582 struct cmd_set_vf_traffic *res = parsed_result;
7583 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7584 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7586 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7589 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7590 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7592 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7593 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7595 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7596 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7598 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7599 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7601 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7602 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7604 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7605 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7607 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7608 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7611 cmdline_parse_inst_t cmd_set_vf_traffic = {
7612 .f = cmd_set_vf_traffic_parsed,
7614 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7616 (void *)&cmd_setvf_traffic_set,
7617 (void *)&cmd_setvf_traffic_port,
7618 (void *)&cmd_setvf_traffic_portid,
7619 (void *)&cmd_setvf_traffic_vf,
7620 (void *)&cmd_setvf_traffic_vfid,
7621 (void *)&cmd_setvf_traffic_what,
7622 (void *)&cmd_setvf_traffic_mode,
7627 /* *** CONFIGURE VF RECEIVE MODE *** */
7628 struct cmd_set_vf_rxmode {
7629 cmdline_fixed_string_t set;
7630 cmdline_fixed_string_t port;
7632 cmdline_fixed_string_t vf;
7634 cmdline_fixed_string_t what;
7635 cmdline_fixed_string_t mode;
7636 cmdline_fixed_string_t on;
7640 cmd_set_vf_rxmode_parsed(void *parsed_result,
7641 __attribute__((unused)) struct cmdline *cl,
7642 __attribute__((unused)) void *data)
7645 uint16_t rx_mode = 0;
7646 struct cmd_set_vf_rxmode *res = parsed_result;
7648 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7649 if (!strcmp(res->what,"rxmode")) {
7650 if (!strcmp(res->mode, "AUPE"))
7651 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7652 else if (!strcmp(res->mode, "ROPE"))
7653 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7654 else if (!strcmp(res->mode, "BAM"))
7655 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7656 else if (!strncmp(res->mode, "MPE",3))
7657 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7660 RTE_SET_USED(is_on);
7662 #ifdef RTE_LIBRTE_IXGBE_PMD
7663 if (ret == -ENOTSUP)
7664 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7665 rx_mode, (uint8_t)is_on);
7667 #ifdef RTE_LIBRTE_BNXT_PMD
7668 if (ret == -ENOTSUP)
7669 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7670 rx_mode, (uint8_t)is_on);
7673 printf("bad VF receive mode parameter, return code = %d \n",
7677 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7678 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7680 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7681 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7683 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7684 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7686 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7687 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7689 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7690 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7692 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7693 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7695 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7696 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7697 mode, "AUPE#ROPE#BAM#MPE");
7698 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7699 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7702 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7703 .f = cmd_set_vf_rxmode_parsed,
7705 .help_str = "set port <port_id> vf <vf_id> rxmode "
7706 "AUPE|ROPE|BAM|MPE on|off",
7708 (void *)&cmd_set_vf_rxmode_set,
7709 (void *)&cmd_set_vf_rxmode_port,
7710 (void *)&cmd_set_vf_rxmode_portid,
7711 (void *)&cmd_set_vf_rxmode_vf,
7712 (void *)&cmd_set_vf_rxmode_vfid,
7713 (void *)&cmd_set_vf_rxmode_what,
7714 (void *)&cmd_set_vf_rxmode_mode,
7715 (void *)&cmd_set_vf_rxmode_on,
7720 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7721 struct cmd_vf_mac_addr_result {
7722 cmdline_fixed_string_t mac_addr_cmd;
7723 cmdline_fixed_string_t what;
7724 cmdline_fixed_string_t port;
7726 cmdline_fixed_string_t vf;
7728 struct ether_addr address;
7731 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7732 __attribute__((unused)) struct cmdline *cl,
7733 __attribute__((unused)) void *data)
7735 struct cmd_vf_mac_addr_result *res = parsed_result;
7738 if (strcmp(res->what, "add") != 0)
7741 #ifdef RTE_LIBRTE_I40E_PMD
7742 if (ret == -ENOTSUP)
7743 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7746 #ifdef RTE_LIBRTE_BNXT_PMD
7747 if (ret == -ENOTSUP)
7748 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7753 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7757 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7758 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7759 mac_addr_cmd,"mac_addr");
7760 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7761 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7763 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7764 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7766 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7767 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7769 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7770 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7772 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7773 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7775 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7776 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7779 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7780 .f = cmd_vf_mac_addr_parsed,
7782 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7783 "Add MAC address filtering for a VF on port_id",
7785 (void *)&cmd_vf_mac_addr_cmd,
7786 (void *)&cmd_vf_mac_addr_what,
7787 (void *)&cmd_vf_mac_addr_port,
7788 (void *)&cmd_vf_mac_addr_portnum,
7789 (void *)&cmd_vf_mac_addr_vf,
7790 (void *)&cmd_vf_mac_addr_vfnum,
7791 (void *)&cmd_vf_mac_addr_addr,
7796 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7797 struct cmd_vf_rx_vlan_filter {
7798 cmdline_fixed_string_t rx_vlan;
7799 cmdline_fixed_string_t what;
7801 cmdline_fixed_string_t port;
7803 cmdline_fixed_string_t vf;
7808 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7809 __attribute__((unused)) struct cmdline *cl,
7810 __attribute__((unused)) void *data)
7812 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7815 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7817 #ifdef RTE_LIBRTE_IXGBE_PMD
7818 if (ret == -ENOTSUP)
7819 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7820 res->vlan_id, res->vf_mask, is_add);
7822 #ifdef RTE_LIBRTE_I40E_PMD
7823 if (ret == -ENOTSUP)
7824 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7825 res->vlan_id, res->vf_mask, is_add);
7827 #ifdef RTE_LIBRTE_BNXT_PMD
7828 if (ret == -ENOTSUP)
7829 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7830 res->vlan_id, res->vf_mask, is_add);
7837 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7838 res->vlan_id, res->vf_mask);
7841 printf("invalid port_id %d\n", res->port_id);
7844 printf("function not implemented or supported\n");
7847 printf("programming error: (%s)\n", strerror(-ret));
7851 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7852 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7853 rx_vlan, "rx_vlan");
7854 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7855 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7857 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7858 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7860 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7861 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7863 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7864 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7866 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7867 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7869 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7870 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7873 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7874 .f = cmd_vf_rx_vlan_filter_parsed,
7876 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7877 "(vf_mask = hexadecimal VF mask)",
7879 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7880 (void *)&cmd_vf_rx_vlan_filter_what,
7881 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7882 (void *)&cmd_vf_rx_vlan_filter_port,
7883 (void *)&cmd_vf_rx_vlan_filter_portid,
7884 (void *)&cmd_vf_rx_vlan_filter_vf,
7885 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7890 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7891 struct cmd_queue_rate_limit_result {
7892 cmdline_fixed_string_t set;
7893 cmdline_fixed_string_t port;
7895 cmdline_fixed_string_t queue;
7897 cmdline_fixed_string_t rate;
7901 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7902 __attribute__((unused)) struct cmdline *cl,
7903 __attribute__((unused)) void *data)
7905 struct cmd_queue_rate_limit_result *res = parsed_result;
7908 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7909 && (strcmp(res->queue, "queue") == 0)
7910 && (strcmp(res->rate, "rate") == 0))
7911 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7914 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7918 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7919 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7921 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7922 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7924 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7925 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7927 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7928 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7930 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7931 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7933 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7934 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7936 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7937 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7940 cmdline_parse_inst_t cmd_queue_rate_limit = {
7941 .f = cmd_queue_rate_limit_parsed,
7943 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7944 "Set rate limit for a queue on port_id",
7946 (void *)&cmd_queue_rate_limit_set,
7947 (void *)&cmd_queue_rate_limit_port,
7948 (void *)&cmd_queue_rate_limit_portnum,
7949 (void *)&cmd_queue_rate_limit_queue,
7950 (void *)&cmd_queue_rate_limit_queuenum,
7951 (void *)&cmd_queue_rate_limit_rate,
7952 (void *)&cmd_queue_rate_limit_ratenum,
7957 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7958 struct cmd_vf_rate_limit_result {
7959 cmdline_fixed_string_t set;
7960 cmdline_fixed_string_t port;
7962 cmdline_fixed_string_t vf;
7964 cmdline_fixed_string_t rate;
7966 cmdline_fixed_string_t q_msk;
7970 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7971 __attribute__((unused)) struct cmdline *cl,
7972 __attribute__((unused)) void *data)
7974 struct cmd_vf_rate_limit_result *res = parsed_result;
7977 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7978 && (strcmp(res->vf, "vf") == 0)
7979 && (strcmp(res->rate, "rate") == 0)
7980 && (strcmp(res->q_msk, "queue_mask") == 0))
7981 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7982 res->rate_num, res->q_msk_val);
7984 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7988 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7989 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7991 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7992 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7994 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7995 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7997 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7998 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8000 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8001 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8003 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8004 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8006 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8007 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8009 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8010 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8011 q_msk, "queue_mask");
8012 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8013 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8016 cmdline_parse_inst_t cmd_vf_rate_limit = {
8017 .f = cmd_vf_rate_limit_parsed,
8019 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8020 "queue_mask <queue_mask_value>: "
8021 "Set rate limit for queues of VF on port_id",
8023 (void *)&cmd_vf_rate_limit_set,
8024 (void *)&cmd_vf_rate_limit_port,
8025 (void *)&cmd_vf_rate_limit_portnum,
8026 (void *)&cmd_vf_rate_limit_vf,
8027 (void *)&cmd_vf_rate_limit_vfnum,
8028 (void *)&cmd_vf_rate_limit_rate,
8029 (void *)&cmd_vf_rate_limit_ratenum,
8030 (void *)&cmd_vf_rate_limit_q_msk,
8031 (void *)&cmd_vf_rate_limit_q_msk_val,
8036 /* *** ADD TUNNEL FILTER OF A PORT *** */
8037 struct cmd_tunnel_filter_result {
8038 cmdline_fixed_string_t cmd;
8039 cmdline_fixed_string_t what;
8041 struct ether_addr outer_mac;
8042 struct ether_addr inner_mac;
8043 cmdline_ipaddr_t ip_value;
8044 uint16_t inner_vlan;
8045 cmdline_fixed_string_t tunnel_type;
8046 cmdline_fixed_string_t filter_type;
8052 cmd_tunnel_filter_parsed(void *parsed_result,
8053 __attribute__((unused)) struct cmdline *cl,
8054 __attribute__((unused)) void *data)
8056 struct cmd_tunnel_filter_result *res = parsed_result;
8057 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8060 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8062 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8063 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8064 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8066 if (res->ip_value.family == AF_INET) {
8067 tunnel_filter_conf.ip_addr.ipv4_addr =
8068 res->ip_value.addr.ipv4.s_addr;
8069 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8071 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8072 &(res->ip_value.addr.ipv6),
8073 sizeof(struct in6_addr));
8074 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8077 if (!strcmp(res->filter_type, "imac-ivlan"))
8078 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8079 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8080 tunnel_filter_conf.filter_type =
8081 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8082 else if (!strcmp(res->filter_type, "imac-tenid"))
8083 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8084 else if (!strcmp(res->filter_type, "imac"))
8085 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8086 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8087 tunnel_filter_conf.filter_type =
8088 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8089 else if (!strcmp(res->filter_type, "oip"))
8090 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8091 else if (!strcmp(res->filter_type, "iip"))
8092 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8094 printf("The filter type is not supported");
8098 if (!strcmp(res->tunnel_type, "vxlan"))
8099 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8100 else if (!strcmp(res->tunnel_type, "nvgre"))
8101 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8102 else if (!strcmp(res->tunnel_type, "ipingre"))
8103 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8105 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8109 tunnel_filter_conf.tenant_id = res->tenant_id;
8110 tunnel_filter_conf.queue_id = res->queue_num;
8111 if (!strcmp(res->what, "add"))
8112 ret = rte_eth_dev_filter_ctrl(res->port_id,
8113 RTE_ETH_FILTER_TUNNEL,
8115 &tunnel_filter_conf);
8117 ret = rte_eth_dev_filter_ctrl(res->port_id,
8118 RTE_ETH_FILTER_TUNNEL,
8119 RTE_ETH_FILTER_DELETE,
8120 &tunnel_filter_conf);
8122 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8126 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8127 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8128 cmd, "tunnel_filter");
8129 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8130 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8132 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8133 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8135 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8136 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8138 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8139 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8141 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8142 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8143 inner_vlan, UINT16);
8144 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8145 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8147 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8148 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8149 tunnel_type, "vxlan#nvgre#ipingre");
8151 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8152 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8153 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8154 "imac#omac-imac-tenid");
8155 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8156 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8158 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8159 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8162 cmdline_parse_inst_t cmd_tunnel_filter = {
8163 .f = cmd_tunnel_filter_parsed,
8165 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8166 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8167 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8168 "<queue_id>: Add/Rm tunnel filter of a port",
8170 (void *)&cmd_tunnel_filter_cmd,
8171 (void *)&cmd_tunnel_filter_what,
8172 (void *)&cmd_tunnel_filter_port_id,
8173 (void *)&cmd_tunnel_filter_outer_mac,
8174 (void *)&cmd_tunnel_filter_inner_mac,
8175 (void *)&cmd_tunnel_filter_ip_value,
8176 (void *)&cmd_tunnel_filter_innner_vlan,
8177 (void *)&cmd_tunnel_filter_tunnel_type,
8178 (void *)&cmd_tunnel_filter_filter_type,
8179 (void *)&cmd_tunnel_filter_tenant_id,
8180 (void *)&cmd_tunnel_filter_queue_num,
8185 /* *** CONFIGURE TUNNEL UDP PORT *** */
8186 struct cmd_tunnel_udp_config {
8187 cmdline_fixed_string_t cmd;
8188 cmdline_fixed_string_t what;
8194 cmd_tunnel_udp_config_parsed(void *parsed_result,
8195 __attribute__((unused)) struct cmdline *cl,
8196 __attribute__((unused)) void *data)
8198 struct cmd_tunnel_udp_config *res = parsed_result;
8199 struct rte_eth_udp_tunnel tunnel_udp;
8202 tunnel_udp.udp_port = res->udp_port;
8204 if (!strcmp(res->cmd, "rx_vxlan_port"))
8205 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8207 if (!strcmp(res->what, "add"))
8208 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8211 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8215 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8218 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8219 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8220 cmd, "rx_vxlan_port");
8221 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8222 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8224 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8225 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8227 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8228 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8231 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8232 .f = cmd_tunnel_udp_config_parsed,
8234 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8235 "Add/Remove a tunneling UDP port filter",
8237 (void *)&cmd_tunnel_udp_config_cmd,
8238 (void *)&cmd_tunnel_udp_config_what,
8239 (void *)&cmd_tunnel_udp_config_udp_port,
8240 (void *)&cmd_tunnel_udp_config_port_id,
8245 /* *** GLOBAL CONFIG *** */
8246 struct cmd_global_config_result {
8247 cmdline_fixed_string_t cmd;
8249 cmdline_fixed_string_t cfg_type;
8254 cmd_global_config_parsed(void *parsed_result,
8255 __attribute__((unused)) struct cmdline *cl,
8256 __attribute__((unused)) void *data)
8258 struct cmd_global_config_result *res = parsed_result;
8259 struct rte_eth_global_cfg conf;
8262 memset(&conf, 0, sizeof(conf));
8263 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8264 conf.cfg.gre_key_len = res->len;
8265 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8266 RTE_ETH_FILTER_SET, &conf);
8268 printf("Global config error\n");
8271 cmdline_parse_token_string_t cmd_global_config_cmd =
8272 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8274 cmdline_parse_token_num_t cmd_global_config_port_id =
8275 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8277 cmdline_parse_token_string_t cmd_global_config_type =
8278 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8279 cfg_type, "gre-key-len");
8280 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8281 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8284 cmdline_parse_inst_t cmd_global_config = {
8285 .f = cmd_global_config_parsed,
8286 .data = (void *)NULL,
8287 .help_str = "global_config <port_id> gre-key-len <key_len>",
8289 (void *)&cmd_global_config_cmd,
8290 (void *)&cmd_global_config_port_id,
8291 (void *)&cmd_global_config_type,
8292 (void *)&cmd_global_config_gre_key_len,
8297 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8298 struct cmd_set_mirror_mask_result {
8299 cmdline_fixed_string_t set;
8300 cmdline_fixed_string_t port;
8302 cmdline_fixed_string_t mirror;
8304 cmdline_fixed_string_t what;
8305 cmdline_fixed_string_t value;
8306 cmdline_fixed_string_t dstpool;
8308 cmdline_fixed_string_t on;
8311 cmdline_parse_token_string_t cmd_mirror_mask_set =
8312 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8314 cmdline_parse_token_string_t cmd_mirror_mask_port =
8315 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8317 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8318 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8320 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8321 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8322 mirror, "mirror-rule");
8323 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8324 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8326 cmdline_parse_token_string_t cmd_mirror_mask_what =
8327 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8328 what, "pool-mirror-up#pool-mirror-down"
8330 cmdline_parse_token_string_t cmd_mirror_mask_value =
8331 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8333 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8334 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8335 dstpool, "dst-pool");
8336 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8337 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8339 cmdline_parse_token_string_t cmd_mirror_mask_on =
8340 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8344 cmd_set_mirror_mask_parsed(void *parsed_result,
8345 __attribute__((unused)) struct cmdline *cl,
8346 __attribute__((unused)) void *data)
8349 struct cmd_set_mirror_mask_result *res = parsed_result;
8350 struct rte_eth_mirror_conf mr_conf;
8352 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8354 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8356 mr_conf.dst_pool = res->dstpool_id;
8358 if (!strcmp(res->what, "pool-mirror-up")) {
8359 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8360 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8361 } else if (!strcmp(res->what, "pool-mirror-down")) {
8362 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8363 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8364 } else if (!strcmp(res->what, "vlan-mirror")) {
8365 mr_conf.rule_type = ETH_MIRROR_VLAN;
8366 nb_item = parse_item_list(res->value, "vlan",
8367 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8371 for (i = 0; i < nb_item; i++) {
8372 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8373 printf("Invalid vlan_id: must be < 4096\n");
8377 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8378 mr_conf.vlan.vlan_mask |= 1ULL << i;
8382 if (!strcmp(res->on, "on"))
8383 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8386 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8389 printf("mirror rule add error: (%s)\n", strerror(-ret));
8392 cmdline_parse_inst_t cmd_set_mirror_mask = {
8393 .f = cmd_set_mirror_mask_parsed,
8395 .help_str = "set port <port_id> mirror-rule <rule_id> "
8396 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8397 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8399 (void *)&cmd_mirror_mask_set,
8400 (void *)&cmd_mirror_mask_port,
8401 (void *)&cmd_mirror_mask_portid,
8402 (void *)&cmd_mirror_mask_mirror,
8403 (void *)&cmd_mirror_mask_ruleid,
8404 (void *)&cmd_mirror_mask_what,
8405 (void *)&cmd_mirror_mask_value,
8406 (void *)&cmd_mirror_mask_dstpool,
8407 (void *)&cmd_mirror_mask_poolid,
8408 (void *)&cmd_mirror_mask_on,
8413 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8414 struct cmd_set_mirror_link_result {
8415 cmdline_fixed_string_t set;
8416 cmdline_fixed_string_t port;
8418 cmdline_fixed_string_t mirror;
8420 cmdline_fixed_string_t what;
8421 cmdline_fixed_string_t dstpool;
8423 cmdline_fixed_string_t on;
8426 cmdline_parse_token_string_t cmd_mirror_link_set =
8427 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8429 cmdline_parse_token_string_t cmd_mirror_link_port =
8430 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8432 cmdline_parse_token_num_t cmd_mirror_link_portid =
8433 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8435 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8436 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8437 mirror, "mirror-rule");
8438 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8439 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8441 cmdline_parse_token_string_t cmd_mirror_link_what =
8442 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8443 what, "uplink-mirror#downlink-mirror");
8444 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8445 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8446 dstpool, "dst-pool");
8447 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8448 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8450 cmdline_parse_token_string_t cmd_mirror_link_on =
8451 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8455 cmd_set_mirror_link_parsed(void *parsed_result,
8456 __attribute__((unused)) struct cmdline *cl,
8457 __attribute__((unused)) void *data)
8460 struct cmd_set_mirror_link_result *res = parsed_result;
8461 struct rte_eth_mirror_conf mr_conf;
8463 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8464 if (!strcmp(res->what, "uplink-mirror"))
8465 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8467 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8469 mr_conf.dst_pool = res->dstpool_id;
8471 if (!strcmp(res->on, "on"))
8472 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8475 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8478 /* check the return value and print it if is < 0 */
8480 printf("mirror rule add error: (%s)\n", strerror(-ret));
8484 cmdline_parse_inst_t cmd_set_mirror_link = {
8485 .f = cmd_set_mirror_link_parsed,
8487 .help_str = "set port <port_id> mirror-rule <rule_id> "
8488 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8490 (void *)&cmd_mirror_link_set,
8491 (void *)&cmd_mirror_link_port,
8492 (void *)&cmd_mirror_link_portid,
8493 (void *)&cmd_mirror_link_mirror,
8494 (void *)&cmd_mirror_link_ruleid,
8495 (void *)&cmd_mirror_link_what,
8496 (void *)&cmd_mirror_link_dstpool,
8497 (void *)&cmd_mirror_link_poolid,
8498 (void *)&cmd_mirror_link_on,
8503 /* *** RESET VM MIRROR RULE *** */
8504 struct cmd_rm_mirror_rule_result {
8505 cmdline_fixed_string_t reset;
8506 cmdline_fixed_string_t port;
8508 cmdline_fixed_string_t mirror;
8512 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8513 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8515 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8516 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8518 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8519 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8521 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8522 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8523 mirror, "mirror-rule");
8524 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8525 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8529 cmd_reset_mirror_rule_parsed(void *parsed_result,
8530 __attribute__((unused)) struct cmdline *cl,
8531 __attribute__((unused)) void *data)
8534 struct cmd_set_mirror_link_result *res = parsed_result;
8536 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8538 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8541 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8542 .f = cmd_reset_mirror_rule_parsed,
8544 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8546 (void *)&cmd_rm_mirror_rule_reset,
8547 (void *)&cmd_rm_mirror_rule_port,
8548 (void *)&cmd_rm_mirror_rule_portid,
8549 (void *)&cmd_rm_mirror_rule_mirror,
8550 (void *)&cmd_rm_mirror_rule_ruleid,
8555 /* ******************************************************************************** */
8557 struct cmd_dump_result {
8558 cmdline_fixed_string_t dump;
8562 dump_struct_sizes(void)
8564 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8565 DUMP_SIZE(struct rte_mbuf);
8566 DUMP_SIZE(struct rte_mempool);
8567 DUMP_SIZE(struct rte_ring);
8571 static void cmd_dump_parsed(void *parsed_result,
8572 __attribute__((unused)) struct cmdline *cl,
8573 __attribute__((unused)) void *data)
8575 struct cmd_dump_result *res = parsed_result;
8577 if (!strcmp(res->dump, "dump_physmem"))
8578 rte_dump_physmem_layout(stdout);
8579 else if (!strcmp(res->dump, "dump_memzone"))
8580 rte_memzone_dump(stdout);
8581 else if (!strcmp(res->dump, "dump_struct_sizes"))
8582 dump_struct_sizes();
8583 else if (!strcmp(res->dump, "dump_ring"))
8584 rte_ring_list_dump(stdout);
8585 else if (!strcmp(res->dump, "dump_mempool"))
8586 rte_mempool_list_dump(stdout);
8587 else if (!strcmp(res->dump, "dump_devargs"))
8588 rte_eal_devargs_dump(stdout);
8589 else if (!strcmp(res->dump, "dump_log_types"))
8590 rte_log_dump(stdout);
8593 cmdline_parse_token_string_t cmd_dump_dump =
8594 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8597 "dump_struct_sizes#"
8603 cmdline_parse_inst_t cmd_dump = {
8604 .f = cmd_dump_parsed, /* function to call */
8605 .data = NULL, /* 2nd arg of func */
8606 .help_str = "Dump status",
8607 .tokens = { /* token list, NULL terminated */
8608 (void *)&cmd_dump_dump,
8613 /* ******************************************************************************** */
8615 struct cmd_dump_one_result {
8616 cmdline_fixed_string_t dump;
8617 cmdline_fixed_string_t name;
8620 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8621 __attribute__((unused)) void *data)
8623 struct cmd_dump_one_result *res = parsed_result;
8625 if (!strcmp(res->dump, "dump_ring")) {
8627 r = rte_ring_lookup(res->name);
8629 cmdline_printf(cl, "Cannot find ring\n");
8632 rte_ring_dump(stdout, r);
8633 } else if (!strcmp(res->dump, "dump_mempool")) {
8634 struct rte_mempool *mp;
8635 mp = rte_mempool_lookup(res->name);
8637 cmdline_printf(cl, "Cannot find mempool\n");
8640 rte_mempool_dump(stdout, mp);
8644 cmdline_parse_token_string_t cmd_dump_one_dump =
8645 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8646 "dump_ring#dump_mempool");
8648 cmdline_parse_token_string_t cmd_dump_one_name =
8649 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8651 cmdline_parse_inst_t cmd_dump_one = {
8652 .f = cmd_dump_one_parsed, /* function to call */
8653 .data = NULL, /* 2nd arg of func */
8654 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8655 .tokens = { /* token list, NULL terminated */
8656 (void *)&cmd_dump_one_dump,
8657 (void *)&cmd_dump_one_name,
8662 /* *** Add/Del syn filter *** */
8663 struct cmd_syn_filter_result {
8664 cmdline_fixed_string_t filter;
8666 cmdline_fixed_string_t ops;
8667 cmdline_fixed_string_t priority;
8668 cmdline_fixed_string_t high;
8669 cmdline_fixed_string_t queue;
8674 cmd_syn_filter_parsed(void *parsed_result,
8675 __attribute__((unused)) struct cmdline *cl,
8676 __attribute__((unused)) void *data)
8678 struct cmd_syn_filter_result *res = parsed_result;
8679 struct rte_eth_syn_filter syn_filter;
8682 ret = rte_eth_dev_filter_supported(res->port_id,
8683 RTE_ETH_FILTER_SYN);
8685 printf("syn filter is not supported on port %u.\n",
8690 memset(&syn_filter, 0, sizeof(syn_filter));
8692 if (!strcmp(res->ops, "add")) {
8693 if (!strcmp(res->high, "high"))
8694 syn_filter.hig_pri = 1;
8696 syn_filter.hig_pri = 0;
8698 syn_filter.queue = res->queue_id;
8699 ret = rte_eth_dev_filter_ctrl(res->port_id,
8704 ret = rte_eth_dev_filter_ctrl(res->port_id,
8706 RTE_ETH_FILTER_DELETE,
8710 printf("syn filter programming error: (%s)\n",
8714 cmdline_parse_token_string_t cmd_syn_filter_filter =
8715 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8716 filter, "syn_filter");
8717 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8718 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8720 cmdline_parse_token_string_t cmd_syn_filter_ops =
8721 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8723 cmdline_parse_token_string_t cmd_syn_filter_priority =
8724 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8725 priority, "priority");
8726 cmdline_parse_token_string_t cmd_syn_filter_high =
8727 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8729 cmdline_parse_token_string_t cmd_syn_filter_queue =
8730 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8732 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8733 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8736 cmdline_parse_inst_t cmd_syn_filter = {
8737 .f = cmd_syn_filter_parsed,
8739 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8740 "<queue_id>: Add/Delete syn filter",
8742 (void *)&cmd_syn_filter_filter,
8743 (void *)&cmd_syn_filter_port_id,
8744 (void *)&cmd_syn_filter_ops,
8745 (void *)&cmd_syn_filter_priority,
8746 (void *)&cmd_syn_filter_high,
8747 (void *)&cmd_syn_filter_queue,
8748 (void *)&cmd_syn_filter_queue_id,
8753 /* *** queue region set *** */
8754 struct cmd_queue_region_result {
8755 cmdline_fixed_string_t set;
8756 cmdline_fixed_string_t port;
8758 cmdline_fixed_string_t cmd;
8759 cmdline_fixed_string_t region;
8761 cmdline_fixed_string_t queue_start_index;
8763 cmdline_fixed_string_t queue_num;
8764 uint8_t queue_num_value;
8768 cmd_queue_region_parsed(void *parsed_result,
8769 __attribute__((unused)) struct cmdline *cl,
8770 __attribute__((unused)) void *data)
8772 struct cmd_queue_region_result *res = parsed_result;
8774 #ifdef RTE_LIBRTE_I40E_PMD
8775 struct rte_pmd_i40e_queue_region_conf region_conf;
8776 enum rte_pmd_i40e_queue_region_op op_type;
8779 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8782 #ifdef RTE_LIBRTE_I40E_PMD
8783 memset(®ion_conf, 0, sizeof(region_conf));
8784 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8785 region_conf.region_id = res->region_id;
8786 region_conf.queue_num = res->queue_num_value;
8787 region_conf.queue_start_index = res->queue_id;
8789 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8790 op_type, ®ion_conf);
8797 printf("function not implemented or supported\n");
8800 printf("queue region config error: (%s)\n", strerror(-ret));
8804 cmdline_parse_token_string_t cmd_queue_region_set =
8805 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8807 cmdline_parse_token_string_t cmd_queue_region_port =
8808 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8809 cmdline_parse_token_num_t cmd_queue_region_port_id =
8810 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8812 cmdline_parse_token_string_t cmd_queue_region_cmd =
8813 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8814 cmd, "queue-region");
8815 cmdline_parse_token_string_t cmd_queue_region_id =
8816 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8817 region, "region_id");
8818 cmdline_parse_token_num_t cmd_queue_region_index =
8819 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8821 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8822 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8823 queue_start_index, "queue_start_index");
8824 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8825 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8827 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8828 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8829 queue_num, "queue_num");
8830 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8831 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8832 queue_num_value, UINT8);
8834 cmdline_parse_inst_t cmd_queue_region = {
8835 .f = cmd_queue_region_parsed,
8837 .help_str = "set port <port_id> queue-region region_id <value> "
8838 "queue_start_index <value> queue_num <value>: Set a queue region",
8840 (void *)&cmd_queue_region_set,
8841 (void *)&cmd_queue_region_port,
8842 (void *)&cmd_queue_region_port_id,
8843 (void *)&cmd_queue_region_cmd,
8844 (void *)&cmd_queue_region_id,
8845 (void *)&cmd_queue_region_index,
8846 (void *)&cmd_queue_region_queue_start_index,
8847 (void *)&cmd_queue_region_queue_id,
8848 (void *)&cmd_queue_region_queue_num,
8849 (void *)&cmd_queue_region_queue_num_value,
8854 /* *** queue region and flowtype set *** */
8855 struct cmd_region_flowtype_result {
8856 cmdline_fixed_string_t set;
8857 cmdline_fixed_string_t port;
8859 cmdline_fixed_string_t cmd;
8860 cmdline_fixed_string_t region;
8862 cmdline_fixed_string_t flowtype;
8863 uint8_t flowtype_id;
8867 cmd_region_flowtype_parsed(void *parsed_result,
8868 __attribute__((unused)) struct cmdline *cl,
8869 __attribute__((unused)) void *data)
8871 struct cmd_region_flowtype_result *res = parsed_result;
8873 #ifdef RTE_LIBRTE_I40E_PMD
8874 struct rte_pmd_i40e_queue_region_conf region_conf;
8875 enum rte_pmd_i40e_queue_region_op op_type;
8878 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8881 #ifdef RTE_LIBRTE_I40E_PMD
8882 memset(®ion_conf, 0, sizeof(region_conf));
8884 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8885 region_conf.region_id = res->region_id;
8886 region_conf.hw_flowtype = res->flowtype_id;
8888 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8889 op_type, ®ion_conf);
8896 printf("function not implemented or supported\n");
8899 printf("region flowtype config error: (%s)\n", strerror(-ret));
8903 cmdline_parse_token_string_t cmd_region_flowtype_set =
8904 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8906 cmdline_parse_token_string_t cmd_region_flowtype_port =
8907 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8909 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8910 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8912 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8913 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8914 cmd, "queue-region");
8915 cmdline_parse_token_string_t cmd_region_flowtype_index =
8916 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8917 region, "region_id");
8918 cmdline_parse_token_num_t cmd_region_flowtype_id =
8919 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8921 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8922 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8923 flowtype, "flowtype");
8924 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8925 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8926 flowtype_id, UINT8);
8927 cmdline_parse_inst_t cmd_region_flowtype = {
8928 .f = cmd_region_flowtype_parsed,
8930 .help_str = "set port <port_id> queue-region region_id <value> "
8931 "flowtype <value>: Set a flowtype region index",
8933 (void *)&cmd_region_flowtype_set,
8934 (void *)&cmd_region_flowtype_port,
8935 (void *)&cmd_region_flowtype_port_index,
8936 (void *)&cmd_region_flowtype_cmd,
8937 (void *)&cmd_region_flowtype_index,
8938 (void *)&cmd_region_flowtype_id,
8939 (void *)&cmd_region_flowtype_flow_index,
8940 (void *)&cmd_region_flowtype_flow_id,
8945 /* *** User Priority (UP) to queue region (region_id) set *** */
8946 struct cmd_user_priority_region_result {
8947 cmdline_fixed_string_t set;
8948 cmdline_fixed_string_t port;
8950 cmdline_fixed_string_t cmd;
8951 cmdline_fixed_string_t user_priority;
8952 uint8_t user_priority_id;
8953 cmdline_fixed_string_t region;
8958 cmd_user_priority_region_parsed(void *parsed_result,
8959 __attribute__((unused)) struct cmdline *cl,
8960 __attribute__((unused)) void *data)
8962 struct cmd_user_priority_region_result *res = parsed_result;
8964 #ifdef RTE_LIBRTE_I40E_PMD
8965 struct rte_pmd_i40e_queue_region_conf region_conf;
8966 enum rte_pmd_i40e_queue_region_op op_type;
8969 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8972 #ifdef RTE_LIBRTE_I40E_PMD
8973 memset(®ion_conf, 0, sizeof(region_conf));
8974 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8975 region_conf.user_priority = res->user_priority_id;
8976 region_conf.region_id = res->region_id;
8978 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8979 op_type, ®ion_conf);
8986 printf("function not implemented or supported\n");
8989 printf("user_priority region config error: (%s)\n",
8994 cmdline_parse_token_string_t cmd_user_priority_region_set =
8995 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8997 cmdline_parse_token_string_t cmd_user_priority_region_port =
8998 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9000 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9001 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9003 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9004 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9005 cmd, "queue-region");
9006 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9007 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9008 user_priority, "UP");
9009 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9010 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9011 user_priority_id, UINT8);
9012 cmdline_parse_token_string_t cmd_user_priority_region_region =
9013 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9014 region, "region_id");
9015 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9016 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9019 cmdline_parse_inst_t cmd_user_priority_region = {
9020 .f = cmd_user_priority_region_parsed,
9022 .help_str = "set port <port_id> queue-region UP <value> "
9023 "region_id <value>: Set the mapping of User Priority (UP) "
9024 "to queue region (region_id) ",
9026 (void *)&cmd_user_priority_region_set,
9027 (void *)&cmd_user_priority_region_port,
9028 (void *)&cmd_user_priority_region_port_index,
9029 (void *)&cmd_user_priority_region_cmd,
9030 (void *)&cmd_user_priority_region_UP,
9031 (void *)&cmd_user_priority_region_UP_id,
9032 (void *)&cmd_user_priority_region_region,
9033 (void *)&cmd_user_priority_region_region_id,
9038 /* *** flush all queue region related configuration *** */
9039 struct cmd_flush_queue_region_result {
9040 cmdline_fixed_string_t set;
9041 cmdline_fixed_string_t port;
9043 cmdline_fixed_string_t cmd;
9044 cmdline_fixed_string_t flush;
9045 cmdline_fixed_string_t what;
9049 cmd_flush_queue_region_parsed(void *parsed_result,
9050 __attribute__((unused)) struct cmdline *cl,
9051 __attribute__((unused)) void *data)
9053 struct cmd_flush_queue_region_result *res = parsed_result;
9055 #ifdef RTE_LIBRTE_I40E_PMD
9056 struct rte_pmd_i40e_queue_region_conf region_conf;
9057 enum rte_pmd_i40e_queue_region_op op_type;
9060 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9063 #ifdef RTE_LIBRTE_I40E_PMD
9064 memset(®ion_conf, 0, sizeof(region_conf));
9066 if (strcmp(res->what, "on") == 0)
9067 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9069 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9071 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9072 op_type, ®ion_conf);
9079 printf("function not implemented or supported\n");
9082 printf("queue region config flush error: (%s)\n",
9087 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9088 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9090 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9091 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9093 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9094 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9096 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9097 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9098 cmd, "queue-region");
9099 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9100 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9102 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9103 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9106 cmdline_parse_inst_t cmd_flush_queue_region = {
9107 .f = cmd_flush_queue_region_parsed,
9109 .help_str = "set port <port_id> queue-region flush on|off"
9110 ": flush all queue region related configuration",
9112 (void *)&cmd_flush_queue_region_set,
9113 (void *)&cmd_flush_queue_region_port,
9114 (void *)&cmd_flush_queue_region_port_index,
9115 (void *)&cmd_flush_queue_region_cmd,
9116 (void *)&cmd_flush_queue_region_flush,
9117 (void *)&cmd_flush_queue_region_what,
9122 /* *** get all queue region related configuration info *** */
9123 struct cmd_show_queue_region_info {
9124 cmdline_fixed_string_t show;
9125 cmdline_fixed_string_t port;
9127 cmdline_fixed_string_t cmd;
9131 cmd_show_queue_region_info_parsed(void *parsed_result,
9132 __attribute__((unused)) struct cmdline *cl,
9133 __attribute__((unused)) void *data)
9135 struct cmd_show_queue_region_info *res = parsed_result;
9137 #ifdef RTE_LIBRTE_I40E_PMD
9138 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9139 enum rte_pmd_i40e_queue_region_op op_type;
9142 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9145 #ifdef RTE_LIBRTE_I40E_PMD
9146 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9148 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9150 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9151 op_type, &rte_pmd_regions);
9153 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9160 printf("function not implemented or supported\n");
9163 printf("queue region config info show error: (%s)\n",
9168 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9169 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9171 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9172 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9174 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9175 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9177 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9178 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9179 cmd, "queue-region");
9181 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9182 .f = cmd_show_queue_region_info_parsed,
9184 .help_str = "show port <port_id> queue-region"
9185 ": show all queue region related configuration info",
9187 (void *)&cmd_show_queue_region_info_get,
9188 (void *)&cmd_show_queue_region_info_port,
9189 (void *)&cmd_show_queue_region_info_port_index,
9190 (void *)&cmd_show_queue_region_info_cmd,
9195 /* *** ADD/REMOVE A 2tuple FILTER *** */
9196 struct cmd_2tuple_filter_result {
9197 cmdline_fixed_string_t filter;
9199 cmdline_fixed_string_t ops;
9200 cmdline_fixed_string_t dst_port;
9201 uint16_t dst_port_value;
9202 cmdline_fixed_string_t protocol;
9203 uint8_t protocol_value;
9204 cmdline_fixed_string_t mask;
9206 cmdline_fixed_string_t tcp_flags;
9207 uint8_t tcp_flags_value;
9208 cmdline_fixed_string_t priority;
9209 uint8_t priority_value;
9210 cmdline_fixed_string_t queue;
9215 cmd_2tuple_filter_parsed(void *parsed_result,
9216 __attribute__((unused)) struct cmdline *cl,
9217 __attribute__((unused)) void *data)
9219 struct rte_eth_ntuple_filter filter;
9220 struct cmd_2tuple_filter_result *res = parsed_result;
9223 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9225 printf("ntuple filter is not supported on port %u.\n",
9230 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9232 filter.flags = RTE_2TUPLE_FLAGS;
9233 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9234 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9235 filter.proto = res->protocol_value;
9236 filter.priority = res->priority_value;
9237 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9238 printf("nonzero tcp_flags is only meaningful"
9239 " when protocol is TCP.\n");
9242 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9243 printf("invalid TCP flags.\n");
9247 if (res->tcp_flags_value != 0) {
9248 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9249 filter.tcp_flags = res->tcp_flags_value;
9252 /* need convert to big endian. */
9253 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9254 filter.queue = res->queue_id;
9256 if (!strcmp(res->ops, "add"))
9257 ret = rte_eth_dev_filter_ctrl(res->port_id,
9258 RTE_ETH_FILTER_NTUPLE,
9262 ret = rte_eth_dev_filter_ctrl(res->port_id,
9263 RTE_ETH_FILTER_NTUPLE,
9264 RTE_ETH_FILTER_DELETE,
9267 printf("2tuple filter programming error: (%s)\n",
9272 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9273 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9274 filter, "2tuple_filter");
9275 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9276 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9278 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9279 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9281 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9282 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9283 dst_port, "dst_port");
9284 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9285 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9286 dst_port_value, UINT16);
9287 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9288 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9289 protocol, "protocol");
9290 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9291 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9292 protocol_value, UINT8);
9293 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9294 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9296 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9297 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9299 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9300 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9301 tcp_flags, "tcp_flags");
9302 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9303 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9304 tcp_flags_value, UINT8);
9305 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9306 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9307 priority, "priority");
9308 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9309 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9310 priority_value, UINT8);
9311 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9312 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9314 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9315 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9318 cmdline_parse_inst_t cmd_2tuple_filter = {
9319 .f = cmd_2tuple_filter_parsed,
9321 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9322 "<value> mask <value> tcp_flags <value> priority <value> queue "
9323 "<queue_id>: Add a 2tuple filter",
9325 (void *)&cmd_2tuple_filter_filter,
9326 (void *)&cmd_2tuple_filter_port_id,
9327 (void *)&cmd_2tuple_filter_ops,
9328 (void *)&cmd_2tuple_filter_dst_port,
9329 (void *)&cmd_2tuple_filter_dst_port_value,
9330 (void *)&cmd_2tuple_filter_protocol,
9331 (void *)&cmd_2tuple_filter_protocol_value,
9332 (void *)&cmd_2tuple_filter_mask,
9333 (void *)&cmd_2tuple_filter_mask_value,
9334 (void *)&cmd_2tuple_filter_tcp_flags,
9335 (void *)&cmd_2tuple_filter_tcp_flags_value,
9336 (void *)&cmd_2tuple_filter_priority,
9337 (void *)&cmd_2tuple_filter_priority_value,
9338 (void *)&cmd_2tuple_filter_queue,
9339 (void *)&cmd_2tuple_filter_queue_id,
9344 /* *** ADD/REMOVE A 5tuple FILTER *** */
9345 struct cmd_5tuple_filter_result {
9346 cmdline_fixed_string_t filter;
9348 cmdline_fixed_string_t ops;
9349 cmdline_fixed_string_t dst_ip;
9350 cmdline_ipaddr_t dst_ip_value;
9351 cmdline_fixed_string_t src_ip;
9352 cmdline_ipaddr_t src_ip_value;
9353 cmdline_fixed_string_t dst_port;
9354 uint16_t dst_port_value;
9355 cmdline_fixed_string_t src_port;
9356 uint16_t src_port_value;
9357 cmdline_fixed_string_t protocol;
9358 uint8_t protocol_value;
9359 cmdline_fixed_string_t mask;
9361 cmdline_fixed_string_t tcp_flags;
9362 uint8_t tcp_flags_value;
9363 cmdline_fixed_string_t priority;
9364 uint8_t priority_value;
9365 cmdline_fixed_string_t queue;
9370 cmd_5tuple_filter_parsed(void *parsed_result,
9371 __attribute__((unused)) struct cmdline *cl,
9372 __attribute__((unused)) void *data)
9374 struct rte_eth_ntuple_filter filter;
9375 struct cmd_5tuple_filter_result *res = parsed_result;
9378 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9380 printf("ntuple filter is not supported on port %u.\n",
9385 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9387 filter.flags = RTE_5TUPLE_FLAGS;
9388 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9389 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9390 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9391 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9392 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9393 filter.proto = res->protocol_value;
9394 filter.priority = res->priority_value;
9395 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9396 printf("nonzero tcp_flags is only meaningful"
9397 " when protocol is TCP.\n");
9400 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9401 printf("invalid TCP flags.\n");
9405 if (res->tcp_flags_value != 0) {
9406 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9407 filter.tcp_flags = res->tcp_flags_value;
9410 if (res->dst_ip_value.family == AF_INET)
9411 /* no need to convert, already big endian. */
9412 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9414 if (filter.dst_ip_mask == 0) {
9415 printf("can not support ipv6 involved compare.\n");
9421 if (res->src_ip_value.family == AF_INET)
9422 /* no need to convert, already big endian. */
9423 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9425 if (filter.src_ip_mask == 0) {
9426 printf("can not support ipv6 involved compare.\n");
9431 /* need convert to big endian. */
9432 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9433 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9434 filter.queue = res->queue_id;
9436 if (!strcmp(res->ops, "add"))
9437 ret = rte_eth_dev_filter_ctrl(res->port_id,
9438 RTE_ETH_FILTER_NTUPLE,
9442 ret = rte_eth_dev_filter_ctrl(res->port_id,
9443 RTE_ETH_FILTER_NTUPLE,
9444 RTE_ETH_FILTER_DELETE,
9447 printf("5tuple filter programming error: (%s)\n",
9451 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9452 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9453 filter, "5tuple_filter");
9454 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9455 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9457 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9458 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9460 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9461 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9463 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9464 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9466 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9467 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9469 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9470 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9472 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9473 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9474 dst_port, "dst_port");
9475 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9476 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9477 dst_port_value, UINT16);
9478 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9479 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9480 src_port, "src_port");
9481 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9482 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9483 src_port_value, UINT16);
9484 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9485 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9486 protocol, "protocol");
9487 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9488 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9489 protocol_value, UINT8);
9490 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9491 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9493 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9494 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9496 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9497 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9498 tcp_flags, "tcp_flags");
9499 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9500 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9501 tcp_flags_value, UINT8);
9502 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9503 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9504 priority, "priority");
9505 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9506 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9507 priority_value, UINT8);
9508 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9509 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9511 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9512 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9515 cmdline_parse_inst_t cmd_5tuple_filter = {
9516 .f = cmd_5tuple_filter_parsed,
9518 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9519 "src_ip <value> dst_port <value> src_port <value> "
9520 "protocol <value> mask <value> tcp_flags <value> "
9521 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9523 (void *)&cmd_5tuple_filter_filter,
9524 (void *)&cmd_5tuple_filter_port_id,
9525 (void *)&cmd_5tuple_filter_ops,
9526 (void *)&cmd_5tuple_filter_dst_ip,
9527 (void *)&cmd_5tuple_filter_dst_ip_value,
9528 (void *)&cmd_5tuple_filter_src_ip,
9529 (void *)&cmd_5tuple_filter_src_ip_value,
9530 (void *)&cmd_5tuple_filter_dst_port,
9531 (void *)&cmd_5tuple_filter_dst_port_value,
9532 (void *)&cmd_5tuple_filter_src_port,
9533 (void *)&cmd_5tuple_filter_src_port_value,
9534 (void *)&cmd_5tuple_filter_protocol,
9535 (void *)&cmd_5tuple_filter_protocol_value,
9536 (void *)&cmd_5tuple_filter_mask,
9537 (void *)&cmd_5tuple_filter_mask_value,
9538 (void *)&cmd_5tuple_filter_tcp_flags,
9539 (void *)&cmd_5tuple_filter_tcp_flags_value,
9540 (void *)&cmd_5tuple_filter_priority,
9541 (void *)&cmd_5tuple_filter_priority_value,
9542 (void *)&cmd_5tuple_filter_queue,
9543 (void *)&cmd_5tuple_filter_queue_id,
9548 /* *** ADD/REMOVE A flex FILTER *** */
9549 struct cmd_flex_filter_result {
9550 cmdline_fixed_string_t filter;
9551 cmdline_fixed_string_t ops;
9553 cmdline_fixed_string_t len;
9555 cmdline_fixed_string_t bytes;
9556 cmdline_fixed_string_t bytes_value;
9557 cmdline_fixed_string_t mask;
9558 cmdline_fixed_string_t mask_value;
9559 cmdline_fixed_string_t priority;
9560 uint8_t priority_value;
9561 cmdline_fixed_string_t queue;
9565 static int xdigit2val(unsigned char c)
9570 else if (isupper(c))
9578 cmd_flex_filter_parsed(void *parsed_result,
9579 __attribute__((unused)) struct cmdline *cl,
9580 __attribute__((unused)) void *data)
9583 struct rte_eth_flex_filter filter;
9584 struct cmd_flex_filter_result *res = parsed_result;
9585 char *bytes_ptr, *mask_ptr;
9586 uint16_t len, i, j = 0;
9591 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9592 printf("the len exceed the max length 128\n");
9595 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9596 filter.len = res->len_value;
9597 filter.priority = res->priority_value;
9598 filter.queue = res->queue_id;
9599 bytes_ptr = res->bytes_value;
9600 mask_ptr = res->mask_value;
9602 /* translate bytes string to array. */
9603 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9604 (bytes_ptr[1] == 'X')))
9606 len = strnlen(bytes_ptr, res->len_value * 2);
9607 if (len == 0 || (len % 8 != 0)) {
9608 printf("please check len and bytes input\n");
9611 for (i = 0; i < len; i++) {
9613 if (isxdigit(c) == 0) {
9614 /* invalid characters. */
9615 printf("invalid input\n");
9618 val = xdigit2val(c);
9621 filter.bytes[j] = byte;
9622 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9629 /* translate mask string to uint8_t array. */
9630 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9631 (mask_ptr[1] == 'X')))
9633 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9635 printf("invalid input\n");
9640 for (i = 0; i < len; i++) {
9642 if (isxdigit(c) == 0) {
9643 /* invalid characters. */
9644 printf("invalid input\n");
9647 val = xdigit2val(c);
9650 filter.mask[j] = byte;
9651 printf("mask[%d]:%02x ", j, filter.mask[j]);
9659 if (!strcmp(res->ops, "add"))
9660 ret = rte_eth_dev_filter_ctrl(res->port_id,
9661 RTE_ETH_FILTER_FLEXIBLE,
9665 ret = rte_eth_dev_filter_ctrl(res->port_id,
9666 RTE_ETH_FILTER_FLEXIBLE,
9667 RTE_ETH_FILTER_DELETE,
9671 printf("flex filter setting error: (%s)\n", strerror(-ret));
9674 cmdline_parse_token_string_t cmd_flex_filter_filter =
9675 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9676 filter, "flex_filter");
9677 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9678 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9680 cmdline_parse_token_string_t cmd_flex_filter_ops =
9681 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9683 cmdline_parse_token_string_t cmd_flex_filter_len =
9684 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9686 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9687 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9689 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9690 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9692 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9693 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9695 cmdline_parse_token_string_t cmd_flex_filter_mask =
9696 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9698 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9699 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9701 cmdline_parse_token_string_t cmd_flex_filter_priority =
9702 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9703 priority, "priority");
9704 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9705 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9706 priority_value, UINT8);
9707 cmdline_parse_token_string_t cmd_flex_filter_queue =
9708 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9710 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9711 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9713 cmdline_parse_inst_t cmd_flex_filter = {
9714 .f = cmd_flex_filter_parsed,
9716 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9717 "<value> mask <value> priority <value> queue <queue_id>: "
9718 "Add/Del a flex filter",
9720 (void *)&cmd_flex_filter_filter,
9721 (void *)&cmd_flex_filter_port_id,
9722 (void *)&cmd_flex_filter_ops,
9723 (void *)&cmd_flex_filter_len,
9724 (void *)&cmd_flex_filter_len_value,
9725 (void *)&cmd_flex_filter_bytes,
9726 (void *)&cmd_flex_filter_bytes_value,
9727 (void *)&cmd_flex_filter_mask,
9728 (void *)&cmd_flex_filter_mask_value,
9729 (void *)&cmd_flex_filter_priority,
9730 (void *)&cmd_flex_filter_priority_value,
9731 (void *)&cmd_flex_filter_queue,
9732 (void *)&cmd_flex_filter_queue_id,
9737 /* *** Filters Control *** */
9739 /* *** deal with ethertype filter *** */
9740 struct cmd_ethertype_filter_result {
9741 cmdline_fixed_string_t filter;
9743 cmdline_fixed_string_t ops;
9744 cmdline_fixed_string_t mac;
9745 struct ether_addr mac_addr;
9746 cmdline_fixed_string_t ethertype;
9747 uint16_t ethertype_value;
9748 cmdline_fixed_string_t drop;
9749 cmdline_fixed_string_t queue;
9753 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9754 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9755 filter, "ethertype_filter");
9756 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9757 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9759 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9760 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9762 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9763 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9764 mac, "mac_addr#mac_ignr");
9765 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9766 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9768 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9769 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9770 ethertype, "ethertype");
9771 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9772 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9773 ethertype_value, UINT16);
9774 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9775 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9777 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9778 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9780 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9781 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9785 cmd_ethertype_filter_parsed(void *parsed_result,
9786 __attribute__((unused)) struct cmdline *cl,
9787 __attribute__((unused)) void *data)
9789 struct cmd_ethertype_filter_result *res = parsed_result;
9790 struct rte_eth_ethertype_filter filter;
9793 ret = rte_eth_dev_filter_supported(res->port_id,
9794 RTE_ETH_FILTER_ETHERTYPE);
9796 printf("ethertype filter is not supported on port %u.\n",
9801 memset(&filter, 0, sizeof(filter));
9802 if (!strcmp(res->mac, "mac_addr")) {
9803 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9804 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9805 sizeof(struct ether_addr));
9807 if (!strcmp(res->drop, "drop"))
9808 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9809 filter.ether_type = res->ethertype_value;
9810 filter.queue = res->queue_id;
9812 if (!strcmp(res->ops, "add"))
9813 ret = rte_eth_dev_filter_ctrl(res->port_id,
9814 RTE_ETH_FILTER_ETHERTYPE,
9818 ret = rte_eth_dev_filter_ctrl(res->port_id,
9819 RTE_ETH_FILTER_ETHERTYPE,
9820 RTE_ETH_FILTER_DELETE,
9823 printf("ethertype filter programming error: (%s)\n",
9827 cmdline_parse_inst_t cmd_ethertype_filter = {
9828 .f = cmd_ethertype_filter_parsed,
9830 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9831 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9832 "Add or delete an ethertype filter entry",
9834 (void *)&cmd_ethertype_filter_filter,
9835 (void *)&cmd_ethertype_filter_port_id,
9836 (void *)&cmd_ethertype_filter_ops,
9837 (void *)&cmd_ethertype_filter_mac,
9838 (void *)&cmd_ethertype_filter_mac_addr,
9839 (void *)&cmd_ethertype_filter_ethertype,
9840 (void *)&cmd_ethertype_filter_ethertype_value,
9841 (void *)&cmd_ethertype_filter_drop,
9842 (void *)&cmd_ethertype_filter_queue,
9843 (void *)&cmd_ethertype_filter_queue_id,
9848 /* *** deal with flow director filter *** */
9849 struct cmd_flow_director_result {
9850 cmdline_fixed_string_t flow_director_filter;
9852 cmdline_fixed_string_t mode;
9853 cmdline_fixed_string_t mode_value;
9854 cmdline_fixed_string_t ops;
9855 cmdline_fixed_string_t flow;
9856 cmdline_fixed_string_t flow_type;
9857 cmdline_fixed_string_t ether;
9858 uint16_t ether_type;
9859 cmdline_fixed_string_t src;
9860 cmdline_ipaddr_t ip_src;
9862 cmdline_fixed_string_t dst;
9863 cmdline_ipaddr_t ip_dst;
9865 cmdline_fixed_string_t verify_tag;
9866 uint32_t verify_tag_value;
9867 cmdline_ipaddr_t tos;
9869 cmdline_ipaddr_t proto;
9870 uint8_t proto_value;
9871 cmdline_ipaddr_t ttl;
9873 cmdline_fixed_string_t vlan;
9874 uint16_t vlan_value;
9875 cmdline_fixed_string_t flexbytes;
9876 cmdline_fixed_string_t flexbytes_value;
9877 cmdline_fixed_string_t pf_vf;
9878 cmdline_fixed_string_t drop;
9879 cmdline_fixed_string_t queue;
9881 cmdline_fixed_string_t fd_id;
9882 uint32_t fd_id_value;
9883 cmdline_fixed_string_t mac;
9884 struct ether_addr mac_addr;
9885 cmdline_fixed_string_t tunnel;
9886 cmdline_fixed_string_t tunnel_type;
9887 cmdline_fixed_string_t tunnel_id;
9888 uint32_t tunnel_id_value;
9889 cmdline_fixed_string_t packet;
9894 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9897 const char *p, *p0 = q_arg;
9899 unsigned long int_fld;
9900 char *str_fld[max_num];
9905 p = strchr(p0, '(');
9909 p0 = strchr(p, ')');
9914 if (size >= sizeof(s))
9917 snprintf(s, sizeof(s), "%.*s", size, p);
9918 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9919 if (ret < 0 || ret > max_num)
9921 for (i = 0; i < ret; i++) {
9923 int_fld = strtoul(str_fld[i], &end, 0);
9924 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9926 flexbytes[i] = (uint8_t)int_fld;
9932 str2flowtype(char *string)
9935 static const struct {
9938 } flowtype_str[] = {
9939 {"raw", RTE_ETH_FLOW_RAW},
9940 {"ipv4", RTE_ETH_FLOW_IPV4},
9941 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9942 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9943 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9944 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9945 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9946 {"ipv6", RTE_ETH_FLOW_IPV6},
9947 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9948 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9949 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9950 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9951 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9952 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9955 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9956 if (!strcmp(flowtype_str[i].str, string))
9957 return flowtype_str[i].type;
9960 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9961 return (uint16_t)atoi(string);
9963 return RTE_ETH_FLOW_UNKNOWN;
9966 static enum rte_eth_fdir_tunnel_type
9967 str2fdir_tunneltype(char *string)
9971 static const struct {
9973 enum rte_eth_fdir_tunnel_type type;
9974 } tunneltype_str[] = {
9975 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9976 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9979 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9980 if (!strcmp(tunneltype_str[i].str, string))
9981 return tunneltype_str[i].type;
9983 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9986 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9988 if ((ip_addr).family == AF_INET) \
9989 (ip) = (ip_addr).addr.ipv4.s_addr; \
9991 printf("invalid parameter.\n"); \
9996 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9998 if ((ip_addr).family == AF_INET6) \
10000 &((ip_addr).addr.ipv6), \
10001 sizeof(struct in6_addr)); \
10003 printf("invalid parameter.\n"); \
10009 cmd_flow_director_filter_parsed(void *parsed_result,
10010 __attribute__((unused)) struct cmdline *cl,
10011 __attribute__((unused)) void *data)
10013 struct cmd_flow_director_result *res = parsed_result;
10014 struct rte_eth_fdir_filter entry;
10015 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10017 unsigned long vf_id;
10020 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10022 printf("flow director is not supported on port %u.\n",
10026 memset(flexbytes, 0, sizeof(flexbytes));
10027 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10029 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10030 if (strcmp(res->mode_value, "MAC-VLAN")) {
10031 printf("Please set mode to MAC-VLAN.\n");
10034 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10035 if (strcmp(res->mode_value, "Tunnel")) {
10036 printf("Please set mode to Tunnel.\n");
10040 if (!strcmp(res->mode_value, "raw")) {
10041 #ifdef RTE_LIBRTE_I40E_PMD
10042 struct rte_pmd_i40e_flow_type_mapping
10043 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10044 struct rte_pmd_i40e_pkt_template_conf conf;
10045 uint16_t flow_type = str2flowtype(res->flow_type);
10046 uint16_t i, port = res->port_id;
10049 memset(&conf, 0, sizeof(conf));
10051 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10052 printf("Invalid flow type specified.\n");
10055 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10059 if (mapping[flow_type].pctype == 0ULL) {
10060 printf("Invalid flow type specified.\n");
10063 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10064 if (mapping[flow_type].pctype & (1ULL << i)) {
10065 conf.input.pctype = i;
10070 conf.input.packet = open_file(res->filepath,
10071 &conf.input.length);
10072 if (!conf.input.packet)
10074 if (!strcmp(res->drop, "drop"))
10075 conf.action.behavior =
10076 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10078 conf.action.behavior =
10079 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10080 conf.action.report_status =
10081 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10082 conf.action.rx_queue = res->queue_id;
10083 conf.soft_id = res->fd_id_value;
10084 add = strcmp(res->ops, "del") ? 1 : 0;
10085 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10089 printf("flow director config error: (%s)\n",
10091 close_file(conf.input.packet);
10094 } else if (strcmp(res->mode_value, "IP")) {
10095 printf("Please set mode to IP or raw.\n");
10098 entry.input.flow_type = str2flowtype(res->flow_type);
10101 ret = parse_flexbytes(res->flexbytes_value,
10103 RTE_ETH_FDIR_MAX_FLEXLEN);
10105 printf("error: Cannot parse flexbytes input.\n");
10109 switch (entry.input.flow_type) {
10110 case RTE_ETH_FLOW_FRAG_IPV4:
10111 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10112 entry.input.flow.ip4_flow.proto = res->proto_value;
10114 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10115 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10116 IPV4_ADDR_TO_UINT(res->ip_dst,
10117 entry.input.flow.ip4_flow.dst_ip);
10118 IPV4_ADDR_TO_UINT(res->ip_src,
10119 entry.input.flow.ip4_flow.src_ip);
10120 entry.input.flow.ip4_flow.tos = res->tos_value;
10121 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10122 /* need convert to big endian. */
10123 entry.input.flow.udp4_flow.dst_port =
10124 rte_cpu_to_be_16(res->port_dst);
10125 entry.input.flow.udp4_flow.src_port =
10126 rte_cpu_to_be_16(res->port_src);
10128 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10129 IPV4_ADDR_TO_UINT(res->ip_dst,
10130 entry.input.flow.sctp4_flow.ip.dst_ip);
10131 IPV4_ADDR_TO_UINT(res->ip_src,
10132 entry.input.flow.sctp4_flow.ip.src_ip);
10133 entry.input.flow.ip4_flow.tos = res->tos_value;
10134 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10135 /* need convert to big endian. */
10136 entry.input.flow.sctp4_flow.dst_port =
10137 rte_cpu_to_be_16(res->port_dst);
10138 entry.input.flow.sctp4_flow.src_port =
10139 rte_cpu_to_be_16(res->port_src);
10140 entry.input.flow.sctp4_flow.verify_tag =
10141 rte_cpu_to_be_32(res->verify_tag_value);
10143 case RTE_ETH_FLOW_FRAG_IPV6:
10144 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10145 entry.input.flow.ipv6_flow.proto = res->proto_value;
10147 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10148 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10149 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10150 entry.input.flow.ipv6_flow.dst_ip);
10151 IPV6_ADDR_TO_ARRAY(res->ip_src,
10152 entry.input.flow.ipv6_flow.src_ip);
10153 entry.input.flow.ipv6_flow.tc = res->tos_value;
10154 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10155 /* need convert to big endian. */
10156 entry.input.flow.udp6_flow.dst_port =
10157 rte_cpu_to_be_16(res->port_dst);
10158 entry.input.flow.udp6_flow.src_port =
10159 rte_cpu_to_be_16(res->port_src);
10161 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10162 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10163 entry.input.flow.sctp6_flow.ip.dst_ip);
10164 IPV6_ADDR_TO_ARRAY(res->ip_src,
10165 entry.input.flow.sctp6_flow.ip.src_ip);
10166 entry.input.flow.ipv6_flow.tc = res->tos_value;
10167 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10168 /* need convert to big endian. */
10169 entry.input.flow.sctp6_flow.dst_port =
10170 rte_cpu_to_be_16(res->port_dst);
10171 entry.input.flow.sctp6_flow.src_port =
10172 rte_cpu_to_be_16(res->port_src);
10173 entry.input.flow.sctp6_flow.verify_tag =
10174 rte_cpu_to_be_32(res->verify_tag_value);
10176 case RTE_ETH_FLOW_L2_PAYLOAD:
10177 entry.input.flow.l2_flow.ether_type =
10178 rte_cpu_to_be_16(res->ether_type);
10184 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10185 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10187 sizeof(struct ether_addr));
10189 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10190 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10192 sizeof(struct ether_addr));
10193 entry.input.flow.tunnel_flow.tunnel_type =
10194 str2fdir_tunneltype(res->tunnel_type);
10195 entry.input.flow.tunnel_flow.tunnel_id =
10196 rte_cpu_to_be_32(res->tunnel_id_value);
10199 rte_memcpy(entry.input.flow_ext.flexbytes,
10201 RTE_ETH_FDIR_MAX_FLEXLEN);
10203 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10205 entry.action.flex_off = 0; /*use 0 by default */
10206 if (!strcmp(res->drop, "drop"))
10207 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10209 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10211 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10212 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10213 if (!strcmp(res->pf_vf, "pf"))
10214 entry.input.flow_ext.is_vf = 0;
10215 else if (!strncmp(res->pf_vf, "vf", 2)) {
10216 struct rte_eth_dev_info dev_info;
10218 memset(&dev_info, 0, sizeof(dev_info));
10219 rte_eth_dev_info_get(res->port_id, &dev_info);
10221 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10222 if (errno != 0 || *end != '\0' ||
10223 vf_id >= dev_info.max_vfs) {
10224 printf("invalid parameter %s.\n", res->pf_vf);
10227 entry.input.flow_ext.is_vf = 1;
10228 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10230 printf("invalid parameter %s.\n", res->pf_vf);
10235 /* set to report FD ID by default */
10236 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10237 entry.action.rx_queue = res->queue_id;
10238 entry.soft_id = res->fd_id_value;
10239 if (!strcmp(res->ops, "add"))
10240 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10241 RTE_ETH_FILTER_ADD, &entry);
10242 else if (!strcmp(res->ops, "del"))
10243 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10244 RTE_ETH_FILTER_DELETE, &entry);
10246 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10247 RTE_ETH_FILTER_UPDATE, &entry);
10249 printf("flow director programming error: (%s)\n",
10253 cmdline_parse_token_string_t cmd_flow_director_filter =
10254 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10255 flow_director_filter, "flow_director_filter");
10256 cmdline_parse_token_num_t cmd_flow_director_port_id =
10257 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10259 cmdline_parse_token_string_t cmd_flow_director_ops =
10260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10261 ops, "add#del#update");
10262 cmdline_parse_token_string_t cmd_flow_director_flow =
10263 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10265 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10266 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10268 cmdline_parse_token_string_t cmd_flow_director_ether =
10269 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10271 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10272 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10273 ether_type, UINT16);
10274 cmdline_parse_token_string_t cmd_flow_director_src =
10275 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10277 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10278 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10280 cmdline_parse_token_num_t cmd_flow_director_port_src =
10281 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10283 cmdline_parse_token_string_t cmd_flow_director_dst =
10284 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10286 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10287 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10289 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10290 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10292 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10293 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10294 verify_tag, "verify_tag");
10295 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10296 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10297 verify_tag_value, UINT32);
10298 cmdline_parse_token_string_t cmd_flow_director_tos =
10299 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10301 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10302 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10304 cmdline_parse_token_string_t cmd_flow_director_proto =
10305 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10307 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10308 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10309 proto_value, UINT8);
10310 cmdline_parse_token_string_t cmd_flow_director_ttl =
10311 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10313 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10314 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10316 cmdline_parse_token_string_t cmd_flow_director_vlan =
10317 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10319 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10320 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10321 vlan_value, UINT16);
10322 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10323 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10324 flexbytes, "flexbytes");
10325 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10326 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10327 flexbytes_value, NULL);
10328 cmdline_parse_token_string_t cmd_flow_director_drop =
10329 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10331 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10332 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10334 cmdline_parse_token_string_t cmd_flow_director_queue =
10335 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10337 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10338 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10340 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10341 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10343 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10344 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10345 fd_id_value, UINT32);
10347 cmdline_parse_token_string_t cmd_flow_director_mode =
10348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10350 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10353 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10354 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10355 mode_value, "MAC-VLAN");
10356 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10357 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10358 mode_value, "Tunnel");
10359 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10360 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10361 mode_value, "raw");
10362 cmdline_parse_token_string_t cmd_flow_director_mac =
10363 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10365 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10366 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10368 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10369 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10371 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10372 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10373 tunnel_type, "NVGRE#VxLAN");
10374 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10375 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10376 tunnel_id, "tunnel-id");
10377 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10378 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10379 tunnel_id_value, UINT32);
10380 cmdline_parse_token_string_t cmd_flow_director_packet =
10381 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10383 cmdline_parse_token_string_t cmd_flow_director_filepath =
10384 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10387 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10388 .f = cmd_flow_director_filter_parsed,
10390 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10391 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10392 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10393 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10394 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10395 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10396 "fd_id <fd_id_value>: "
10397 "Add or delete an ip flow director entry on NIC",
10399 (void *)&cmd_flow_director_filter,
10400 (void *)&cmd_flow_director_port_id,
10401 (void *)&cmd_flow_director_mode,
10402 (void *)&cmd_flow_director_mode_ip,
10403 (void *)&cmd_flow_director_ops,
10404 (void *)&cmd_flow_director_flow,
10405 (void *)&cmd_flow_director_flow_type,
10406 (void *)&cmd_flow_director_src,
10407 (void *)&cmd_flow_director_ip_src,
10408 (void *)&cmd_flow_director_dst,
10409 (void *)&cmd_flow_director_ip_dst,
10410 (void *)&cmd_flow_director_tos,
10411 (void *)&cmd_flow_director_tos_value,
10412 (void *)&cmd_flow_director_proto,
10413 (void *)&cmd_flow_director_proto_value,
10414 (void *)&cmd_flow_director_ttl,
10415 (void *)&cmd_flow_director_ttl_value,
10416 (void *)&cmd_flow_director_vlan,
10417 (void *)&cmd_flow_director_vlan_value,
10418 (void *)&cmd_flow_director_flexbytes,
10419 (void *)&cmd_flow_director_flexbytes_value,
10420 (void *)&cmd_flow_director_drop,
10421 (void *)&cmd_flow_director_pf_vf,
10422 (void *)&cmd_flow_director_queue,
10423 (void *)&cmd_flow_director_queue_id,
10424 (void *)&cmd_flow_director_fd_id,
10425 (void *)&cmd_flow_director_fd_id_value,
10430 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10431 .f = cmd_flow_director_filter_parsed,
10433 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10434 "director entry on NIC",
10436 (void *)&cmd_flow_director_filter,
10437 (void *)&cmd_flow_director_port_id,
10438 (void *)&cmd_flow_director_mode,
10439 (void *)&cmd_flow_director_mode_ip,
10440 (void *)&cmd_flow_director_ops,
10441 (void *)&cmd_flow_director_flow,
10442 (void *)&cmd_flow_director_flow_type,
10443 (void *)&cmd_flow_director_src,
10444 (void *)&cmd_flow_director_ip_src,
10445 (void *)&cmd_flow_director_port_src,
10446 (void *)&cmd_flow_director_dst,
10447 (void *)&cmd_flow_director_ip_dst,
10448 (void *)&cmd_flow_director_port_dst,
10449 (void *)&cmd_flow_director_tos,
10450 (void *)&cmd_flow_director_tos_value,
10451 (void *)&cmd_flow_director_ttl,
10452 (void *)&cmd_flow_director_ttl_value,
10453 (void *)&cmd_flow_director_vlan,
10454 (void *)&cmd_flow_director_vlan_value,
10455 (void *)&cmd_flow_director_flexbytes,
10456 (void *)&cmd_flow_director_flexbytes_value,
10457 (void *)&cmd_flow_director_drop,
10458 (void *)&cmd_flow_director_pf_vf,
10459 (void *)&cmd_flow_director_queue,
10460 (void *)&cmd_flow_director_queue_id,
10461 (void *)&cmd_flow_director_fd_id,
10462 (void *)&cmd_flow_director_fd_id_value,
10467 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10468 .f = cmd_flow_director_filter_parsed,
10470 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10471 "director entry on NIC",
10473 (void *)&cmd_flow_director_filter,
10474 (void *)&cmd_flow_director_port_id,
10475 (void *)&cmd_flow_director_mode,
10476 (void *)&cmd_flow_director_mode_ip,
10477 (void *)&cmd_flow_director_ops,
10478 (void *)&cmd_flow_director_flow,
10479 (void *)&cmd_flow_director_flow_type,
10480 (void *)&cmd_flow_director_src,
10481 (void *)&cmd_flow_director_ip_src,
10482 (void *)&cmd_flow_director_port_dst,
10483 (void *)&cmd_flow_director_dst,
10484 (void *)&cmd_flow_director_ip_dst,
10485 (void *)&cmd_flow_director_port_dst,
10486 (void *)&cmd_flow_director_verify_tag,
10487 (void *)&cmd_flow_director_verify_tag_value,
10488 (void *)&cmd_flow_director_tos,
10489 (void *)&cmd_flow_director_tos_value,
10490 (void *)&cmd_flow_director_ttl,
10491 (void *)&cmd_flow_director_ttl_value,
10492 (void *)&cmd_flow_director_vlan,
10493 (void *)&cmd_flow_director_vlan_value,
10494 (void *)&cmd_flow_director_flexbytes,
10495 (void *)&cmd_flow_director_flexbytes_value,
10496 (void *)&cmd_flow_director_drop,
10497 (void *)&cmd_flow_director_pf_vf,
10498 (void *)&cmd_flow_director_queue,
10499 (void *)&cmd_flow_director_queue_id,
10500 (void *)&cmd_flow_director_fd_id,
10501 (void *)&cmd_flow_director_fd_id_value,
10506 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10507 .f = cmd_flow_director_filter_parsed,
10509 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10510 "director entry on NIC",
10512 (void *)&cmd_flow_director_filter,
10513 (void *)&cmd_flow_director_port_id,
10514 (void *)&cmd_flow_director_mode,
10515 (void *)&cmd_flow_director_mode_ip,
10516 (void *)&cmd_flow_director_ops,
10517 (void *)&cmd_flow_director_flow,
10518 (void *)&cmd_flow_director_flow_type,
10519 (void *)&cmd_flow_director_ether,
10520 (void *)&cmd_flow_director_ether_type,
10521 (void *)&cmd_flow_director_flexbytes,
10522 (void *)&cmd_flow_director_flexbytes_value,
10523 (void *)&cmd_flow_director_drop,
10524 (void *)&cmd_flow_director_pf_vf,
10525 (void *)&cmd_flow_director_queue,
10526 (void *)&cmd_flow_director_queue_id,
10527 (void *)&cmd_flow_director_fd_id,
10528 (void *)&cmd_flow_director_fd_id_value,
10533 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10534 .f = cmd_flow_director_filter_parsed,
10536 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10537 "director entry on NIC",
10539 (void *)&cmd_flow_director_filter,
10540 (void *)&cmd_flow_director_port_id,
10541 (void *)&cmd_flow_director_mode,
10542 (void *)&cmd_flow_director_mode_mac_vlan,
10543 (void *)&cmd_flow_director_ops,
10544 (void *)&cmd_flow_director_mac,
10545 (void *)&cmd_flow_director_mac_addr,
10546 (void *)&cmd_flow_director_vlan,
10547 (void *)&cmd_flow_director_vlan_value,
10548 (void *)&cmd_flow_director_flexbytes,
10549 (void *)&cmd_flow_director_flexbytes_value,
10550 (void *)&cmd_flow_director_drop,
10551 (void *)&cmd_flow_director_queue,
10552 (void *)&cmd_flow_director_queue_id,
10553 (void *)&cmd_flow_director_fd_id,
10554 (void *)&cmd_flow_director_fd_id_value,
10559 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10560 .f = cmd_flow_director_filter_parsed,
10562 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10563 "director entry on NIC",
10565 (void *)&cmd_flow_director_filter,
10566 (void *)&cmd_flow_director_port_id,
10567 (void *)&cmd_flow_director_mode,
10568 (void *)&cmd_flow_director_mode_tunnel,
10569 (void *)&cmd_flow_director_ops,
10570 (void *)&cmd_flow_director_mac,
10571 (void *)&cmd_flow_director_mac_addr,
10572 (void *)&cmd_flow_director_vlan,
10573 (void *)&cmd_flow_director_vlan_value,
10574 (void *)&cmd_flow_director_tunnel,
10575 (void *)&cmd_flow_director_tunnel_type,
10576 (void *)&cmd_flow_director_tunnel_id,
10577 (void *)&cmd_flow_director_tunnel_id_value,
10578 (void *)&cmd_flow_director_flexbytes,
10579 (void *)&cmd_flow_director_flexbytes_value,
10580 (void *)&cmd_flow_director_drop,
10581 (void *)&cmd_flow_director_queue,
10582 (void *)&cmd_flow_director_queue_id,
10583 (void *)&cmd_flow_director_fd_id,
10584 (void *)&cmd_flow_director_fd_id_value,
10589 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10590 .f = cmd_flow_director_filter_parsed,
10592 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10593 "director entry on NIC",
10595 (void *)&cmd_flow_director_filter,
10596 (void *)&cmd_flow_director_port_id,
10597 (void *)&cmd_flow_director_mode,
10598 (void *)&cmd_flow_director_mode_raw,
10599 (void *)&cmd_flow_director_ops,
10600 (void *)&cmd_flow_director_flow,
10601 (void *)&cmd_flow_director_flow_type,
10602 (void *)&cmd_flow_director_drop,
10603 (void *)&cmd_flow_director_queue,
10604 (void *)&cmd_flow_director_queue_id,
10605 (void *)&cmd_flow_director_fd_id,
10606 (void *)&cmd_flow_director_fd_id_value,
10607 (void *)&cmd_flow_director_packet,
10608 (void *)&cmd_flow_director_filepath,
10613 struct cmd_flush_flow_director_result {
10614 cmdline_fixed_string_t flush_flow_director;
10618 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10619 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10620 flush_flow_director, "flush_flow_director");
10621 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10622 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10626 cmd_flush_flow_director_parsed(void *parsed_result,
10627 __attribute__((unused)) struct cmdline *cl,
10628 __attribute__((unused)) void *data)
10630 struct cmd_flow_director_result *res = parsed_result;
10633 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10635 printf("flow director is not supported on port %u.\n",
10640 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10641 RTE_ETH_FILTER_FLUSH, NULL);
10643 printf("flow director table flushing error: (%s)\n",
10647 cmdline_parse_inst_t cmd_flush_flow_director = {
10648 .f = cmd_flush_flow_director_parsed,
10650 .help_str = "flush_flow_director <port_id>: "
10651 "Flush all flow director entries of a device on NIC",
10653 (void *)&cmd_flush_flow_director_flush,
10654 (void *)&cmd_flush_flow_director_port_id,
10659 /* *** deal with flow director mask *** */
10660 struct cmd_flow_director_mask_result {
10661 cmdline_fixed_string_t flow_director_mask;
10663 cmdline_fixed_string_t mode;
10664 cmdline_fixed_string_t mode_value;
10665 cmdline_fixed_string_t vlan;
10666 uint16_t vlan_mask;
10667 cmdline_fixed_string_t src_mask;
10668 cmdline_ipaddr_t ipv4_src;
10669 cmdline_ipaddr_t ipv6_src;
10671 cmdline_fixed_string_t dst_mask;
10672 cmdline_ipaddr_t ipv4_dst;
10673 cmdline_ipaddr_t ipv6_dst;
10675 cmdline_fixed_string_t mac;
10676 uint8_t mac_addr_byte_mask;
10677 cmdline_fixed_string_t tunnel_id;
10678 uint32_t tunnel_id_mask;
10679 cmdline_fixed_string_t tunnel_type;
10680 uint8_t tunnel_type_mask;
10684 cmd_flow_director_mask_parsed(void *parsed_result,
10685 __attribute__((unused)) struct cmdline *cl,
10686 __attribute__((unused)) void *data)
10688 struct cmd_flow_director_mask_result *res = parsed_result;
10689 struct rte_eth_fdir_masks *mask;
10690 struct rte_port *port;
10692 if (res->port_id > nb_ports) {
10693 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10697 port = &ports[res->port_id];
10698 /** Check if the port is not started **/
10699 if (port->port_status != RTE_PORT_STOPPED) {
10700 printf("Please stop port %d first\n", res->port_id);
10704 mask = &port->dev_conf.fdir_conf.mask;
10706 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10707 if (strcmp(res->mode_value, "MAC-VLAN")) {
10708 printf("Please set mode to MAC-VLAN.\n");
10712 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10713 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10714 if (strcmp(res->mode_value, "Tunnel")) {
10715 printf("Please set mode to Tunnel.\n");
10719 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10720 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10721 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10722 mask->tunnel_type_mask = res->tunnel_type_mask;
10724 if (strcmp(res->mode_value, "IP")) {
10725 printf("Please set mode to IP.\n");
10729 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10730 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10731 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10732 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10733 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10734 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10735 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10738 cmd_reconfig_device_queue(res->port_id, 1, 1);
10741 cmdline_parse_token_string_t cmd_flow_director_mask =
10742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10743 flow_director_mask, "flow_director_mask");
10744 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10745 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10747 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10748 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10750 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10751 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10752 vlan_mask, UINT16);
10753 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10755 src_mask, "src_mask");
10756 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10757 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10759 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10760 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10762 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10763 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10765 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10767 dst_mask, "dst_mask");
10768 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10769 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10771 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10772 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10774 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10775 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10778 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10779 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10781 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10782 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10784 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10785 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10786 mode_value, "MAC-VLAN");
10787 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10788 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10789 mode_value, "Tunnel");
10790 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10791 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10793 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10794 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10795 mac_addr_byte_mask, UINT8);
10796 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10797 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10798 tunnel_type, "tunnel-type");
10799 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10800 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10801 tunnel_type_mask, UINT8);
10802 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10803 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10804 tunnel_id, "tunnel-id");
10805 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10806 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10807 tunnel_id_mask, UINT32);
10809 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10810 .f = cmd_flow_director_mask_parsed,
10812 .help_str = "flow_director_mask ... : "
10813 "Set IP mode flow director's mask on NIC",
10815 (void *)&cmd_flow_director_mask,
10816 (void *)&cmd_flow_director_mask_port_id,
10817 (void *)&cmd_flow_director_mask_mode,
10818 (void *)&cmd_flow_director_mask_mode_ip,
10819 (void *)&cmd_flow_director_mask_vlan,
10820 (void *)&cmd_flow_director_mask_vlan_value,
10821 (void *)&cmd_flow_director_mask_src,
10822 (void *)&cmd_flow_director_mask_ipv4_src,
10823 (void *)&cmd_flow_director_mask_ipv6_src,
10824 (void *)&cmd_flow_director_mask_port_src,
10825 (void *)&cmd_flow_director_mask_dst,
10826 (void *)&cmd_flow_director_mask_ipv4_dst,
10827 (void *)&cmd_flow_director_mask_ipv6_dst,
10828 (void *)&cmd_flow_director_mask_port_dst,
10833 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10834 .f = cmd_flow_director_mask_parsed,
10836 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10837 "flow director's mask on NIC",
10839 (void *)&cmd_flow_director_mask,
10840 (void *)&cmd_flow_director_mask_port_id,
10841 (void *)&cmd_flow_director_mask_mode,
10842 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10843 (void *)&cmd_flow_director_mask_vlan,
10844 (void *)&cmd_flow_director_mask_vlan_value,
10849 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10850 .f = cmd_flow_director_mask_parsed,
10852 .help_str = "flow_director_mask ... : Set tunnel mode "
10853 "flow director's mask on NIC",
10855 (void *)&cmd_flow_director_mask,
10856 (void *)&cmd_flow_director_mask_port_id,
10857 (void *)&cmd_flow_director_mask_mode,
10858 (void *)&cmd_flow_director_mask_mode_tunnel,
10859 (void *)&cmd_flow_director_mask_vlan,
10860 (void *)&cmd_flow_director_mask_vlan_value,
10861 (void *)&cmd_flow_director_mask_mac,
10862 (void *)&cmd_flow_director_mask_mac_value,
10863 (void *)&cmd_flow_director_mask_tunnel_type,
10864 (void *)&cmd_flow_director_mask_tunnel_type_value,
10865 (void *)&cmd_flow_director_mask_tunnel_id,
10866 (void *)&cmd_flow_director_mask_tunnel_id_value,
10871 /* *** deal with flow director mask on flexible payload *** */
10872 struct cmd_flow_director_flex_mask_result {
10873 cmdline_fixed_string_t flow_director_flexmask;
10875 cmdline_fixed_string_t flow;
10876 cmdline_fixed_string_t flow_type;
10877 cmdline_fixed_string_t mask;
10881 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10882 __attribute__((unused)) struct cmdline *cl,
10883 __attribute__((unused)) void *data)
10885 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10886 struct rte_eth_fdir_info fdir_info;
10887 struct rte_eth_fdir_flex_mask flex_mask;
10888 struct rte_port *port;
10889 uint32_t flow_type_mask;
10893 if (res->port_id > nb_ports) {
10894 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10898 port = &ports[res->port_id];
10899 /** Check if the port is not started **/
10900 if (port->port_status != RTE_PORT_STOPPED) {
10901 printf("Please stop port %d first\n", res->port_id);
10905 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10906 ret = parse_flexbytes(res->mask,
10908 RTE_ETH_FDIR_MAX_FLEXLEN);
10910 printf("error: Cannot parse mask input.\n");
10914 memset(&fdir_info, 0, sizeof(fdir_info));
10915 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10916 RTE_ETH_FILTER_INFO, &fdir_info);
10918 printf("Cannot get FDir filter info\n");
10922 if (!strcmp(res->flow_type, "none")) {
10923 /* means don't specify the flow type */
10924 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10925 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10926 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10927 0, sizeof(struct rte_eth_fdir_flex_mask));
10928 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10929 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10931 sizeof(struct rte_eth_fdir_flex_mask));
10932 cmd_reconfig_device_queue(res->port_id, 1, 1);
10935 flow_type_mask = fdir_info.flow_types_mask[0];
10936 if (!strcmp(res->flow_type, "all")) {
10937 if (!flow_type_mask) {
10938 printf("No flow type supported\n");
10941 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10942 if (flow_type_mask & (1 << i)) {
10943 flex_mask.flow_type = i;
10944 fdir_set_flex_mask(res->port_id, &flex_mask);
10947 cmd_reconfig_device_queue(res->port_id, 1, 1);
10950 flex_mask.flow_type = str2flowtype(res->flow_type);
10951 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10952 printf("Flow type %s not supported on port %d\n",
10953 res->flow_type, res->port_id);
10956 fdir_set_flex_mask(res->port_id, &flex_mask);
10957 cmd_reconfig_device_queue(res->port_id, 1, 1);
10960 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10961 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10962 flow_director_flexmask,
10963 "flow_director_flex_mask");
10964 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10965 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10967 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10968 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10970 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10972 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10973 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10974 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10975 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10978 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10979 .f = cmd_flow_director_flex_mask_parsed,
10981 .help_str = "flow_director_flex_mask ... : "
10982 "Set flow director's flex mask on NIC",
10984 (void *)&cmd_flow_director_flexmask,
10985 (void *)&cmd_flow_director_flexmask_port_id,
10986 (void *)&cmd_flow_director_flexmask_flow,
10987 (void *)&cmd_flow_director_flexmask_flow_type,
10988 (void *)&cmd_flow_director_flexmask_mask,
10993 /* *** deal with flow director flexible payload configuration *** */
10994 struct cmd_flow_director_flexpayload_result {
10995 cmdline_fixed_string_t flow_director_flexpayload;
10997 cmdline_fixed_string_t payload_layer;
10998 cmdline_fixed_string_t payload_cfg;
11002 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11005 const char *p, *p0 = q_arg;
11007 unsigned long int_fld;
11008 char *str_fld[max_num];
11013 p = strchr(p0, '(');
11017 p0 = strchr(p, ')');
11022 if (size >= sizeof(s))
11025 snprintf(s, sizeof(s), "%.*s", size, p);
11026 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11027 if (ret < 0 || ret > max_num)
11029 for (i = 0; i < ret; i++) {
11031 int_fld = strtoul(str_fld[i], &end, 0);
11032 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11034 offsets[i] = (uint16_t)int_fld;
11040 cmd_flow_director_flxpld_parsed(void *parsed_result,
11041 __attribute__((unused)) struct cmdline *cl,
11042 __attribute__((unused)) void *data)
11044 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11045 struct rte_eth_flex_payload_cfg flex_cfg;
11046 struct rte_port *port;
11049 if (res->port_id > nb_ports) {
11050 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
11054 port = &ports[res->port_id];
11055 /** Check if the port is not started **/
11056 if (port->port_status != RTE_PORT_STOPPED) {
11057 printf("Please stop port %d first\n", res->port_id);
11061 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11063 if (!strcmp(res->payload_layer, "raw"))
11064 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11065 else if (!strcmp(res->payload_layer, "l2"))
11066 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11067 else if (!strcmp(res->payload_layer, "l3"))
11068 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11069 else if (!strcmp(res->payload_layer, "l4"))
11070 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11072 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11073 RTE_ETH_FDIR_MAX_FLEXLEN);
11075 printf("error: Cannot parse flex payload input.\n");
11079 fdir_set_flex_payload(res->port_id, &flex_cfg);
11080 cmd_reconfig_device_queue(res->port_id, 1, 1);
11083 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11084 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11085 flow_director_flexpayload,
11086 "flow_director_flex_payload");
11087 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11088 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11090 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11091 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11092 payload_layer, "raw#l2#l3#l4");
11093 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11094 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11095 payload_cfg, NULL);
11097 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11098 .f = cmd_flow_director_flxpld_parsed,
11100 .help_str = "flow_director_flexpayload ... : "
11101 "Set flow director's flex payload on NIC",
11103 (void *)&cmd_flow_director_flexpayload,
11104 (void *)&cmd_flow_director_flexpayload_port_id,
11105 (void *)&cmd_flow_director_flexpayload_payload_layer,
11106 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11111 /* Generic flow interface command. */
11112 extern cmdline_parse_inst_t cmd_flow;
11114 /* *** Classification Filters Control *** */
11115 /* *** Get symmetric hash enable per port *** */
11116 struct cmd_get_sym_hash_ena_per_port_result {
11117 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11122 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11123 __rte_unused struct cmdline *cl,
11124 __rte_unused void *data)
11126 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11127 struct rte_eth_hash_filter_info info;
11130 if (rte_eth_dev_filter_supported(res->port_id,
11131 RTE_ETH_FILTER_HASH) < 0) {
11132 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11137 memset(&info, 0, sizeof(info));
11138 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11139 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11140 RTE_ETH_FILTER_GET, &info);
11143 printf("Cannot get symmetric hash enable per port "
11144 "on port %u\n", res->port_id);
11148 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11149 "enabled" : "disabled", res->port_id);
11152 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11153 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11154 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11155 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11156 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11159 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11160 .f = cmd_get_sym_hash_per_port_parsed,
11162 .help_str = "get_sym_hash_ena_per_port <port_id>",
11164 (void *)&cmd_get_sym_hash_ena_per_port_all,
11165 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11170 /* *** Set symmetric hash enable per port *** */
11171 struct cmd_set_sym_hash_ena_per_port_result {
11172 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11173 cmdline_fixed_string_t enable;
11178 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11179 __rte_unused struct cmdline *cl,
11180 __rte_unused void *data)
11182 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11183 struct rte_eth_hash_filter_info info;
11186 if (rte_eth_dev_filter_supported(res->port_id,
11187 RTE_ETH_FILTER_HASH) < 0) {
11188 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11193 memset(&info, 0, sizeof(info));
11194 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11195 if (!strcmp(res->enable, "enable"))
11196 info.info.enable = 1;
11197 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11198 RTE_ETH_FILTER_SET, &info);
11200 printf("Cannot set symmetric hash enable per port on "
11201 "port %u\n", res->port_id);
11204 printf("Symmetric hash has been set to %s on port %u\n",
11205 res->enable, res->port_id);
11208 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11209 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11210 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11211 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11212 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11214 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11215 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11216 enable, "enable#disable");
11218 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11219 .f = cmd_set_sym_hash_per_port_parsed,
11221 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11223 (void *)&cmd_set_sym_hash_ena_per_port_all,
11224 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11225 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11230 /* Get global config of hash function */
11231 struct cmd_get_hash_global_config_result {
11232 cmdline_fixed_string_t get_hash_global_config;
11237 flowtype_to_str(uint16_t ftype)
11243 } ftype_table[] = {
11244 {"ipv4", RTE_ETH_FLOW_IPV4},
11245 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11246 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11247 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11248 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11249 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11250 {"ipv6", RTE_ETH_FLOW_IPV6},
11251 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11252 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11253 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11254 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11255 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11256 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11257 {"port", RTE_ETH_FLOW_PORT},
11258 {"vxlan", RTE_ETH_FLOW_VXLAN},
11259 {"geneve", RTE_ETH_FLOW_GENEVE},
11260 {"nvgre", RTE_ETH_FLOW_NVGRE},
11263 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11264 if (ftype_table[i].ftype == ftype)
11265 return ftype_table[i].str;
11272 cmd_get_hash_global_config_parsed(void *parsed_result,
11273 __rte_unused struct cmdline *cl,
11274 __rte_unused void *data)
11276 struct cmd_get_hash_global_config_result *res = parsed_result;
11277 struct rte_eth_hash_filter_info info;
11278 uint32_t idx, offset;
11283 if (rte_eth_dev_filter_supported(res->port_id,
11284 RTE_ETH_FILTER_HASH) < 0) {
11285 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11290 memset(&info, 0, sizeof(info));
11291 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11292 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11293 RTE_ETH_FILTER_GET, &info);
11295 printf("Cannot get hash global configurations by port %d\n",
11300 switch (info.info.global_conf.hash_func) {
11301 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11302 printf("Hash function is Toeplitz\n");
11304 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11305 printf("Hash function is Simple XOR\n");
11308 printf("Unknown hash function\n");
11312 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11313 idx = i / UINT32_BIT;
11314 offset = i % UINT32_BIT;
11315 if (!(info.info.global_conf.valid_bit_mask[idx] &
11318 str = flowtype_to_str(i);
11321 printf("Symmetric hash is %s globally for flow type %s "
11323 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11324 (1UL << offset)) ? "enabled" : "disabled"), str,
11329 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11330 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11331 get_hash_global_config, "get_hash_global_config");
11332 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11333 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11336 cmdline_parse_inst_t cmd_get_hash_global_config = {
11337 .f = cmd_get_hash_global_config_parsed,
11339 .help_str = "get_hash_global_config <port_id>",
11341 (void *)&cmd_get_hash_global_config_all,
11342 (void *)&cmd_get_hash_global_config_port_id,
11347 /* Set global config of hash function */
11348 struct cmd_set_hash_global_config_result {
11349 cmdline_fixed_string_t set_hash_global_config;
11351 cmdline_fixed_string_t hash_func;
11352 cmdline_fixed_string_t flow_type;
11353 cmdline_fixed_string_t enable;
11357 cmd_set_hash_global_config_parsed(void *parsed_result,
11358 __rte_unused struct cmdline *cl,
11359 __rte_unused void *data)
11361 struct cmd_set_hash_global_config_result *res = parsed_result;
11362 struct rte_eth_hash_filter_info info;
11363 uint32_t ftype, idx, offset;
11366 if (rte_eth_dev_filter_supported(res->port_id,
11367 RTE_ETH_FILTER_HASH) < 0) {
11368 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11372 memset(&info, 0, sizeof(info));
11373 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11374 if (!strcmp(res->hash_func, "toeplitz"))
11375 info.info.global_conf.hash_func =
11376 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11377 else if (!strcmp(res->hash_func, "simple_xor"))
11378 info.info.global_conf.hash_func =
11379 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11380 else if (!strcmp(res->hash_func, "default"))
11381 info.info.global_conf.hash_func =
11382 RTE_ETH_HASH_FUNCTION_DEFAULT;
11384 ftype = str2flowtype(res->flow_type);
11385 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11386 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11387 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11388 if (!strcmp(res->enable, "enable"))
11389 info.info.global_conf.sym_hash_enable_mask[idx] |=
11391 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11392 RTE_ETH_FILTER_SET, &info);
11394 printf("Cannot set global hash configurations by port %d\n",
11397 printf("Global hash configurations have been set "
11398 "succcessfully by port %d\n", res->port_id);
11401 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11402 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11403 set_hash_global_config, "set_hash_global_config");
11404 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11405 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11407 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11408 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11409 hash_func, "toeplitz#simple_xor#default");
11410 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11411 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11413 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11414 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11415 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11416 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11417 enable, "enable#disable");
11419 cmdline_parse_inst_t cmd_set_hash_global_config = {
11420 .f = cmd_set_hash_global_config_parsed,
11422 .help_str = "set_hash_global_config <port_id> "
11423 "toeplitz|simple_xor|default "
11424 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11425 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11426 "l2_payload enable|disable",
11428 (void *)&cmd_set_hash_global_config_all,
11429 (void *)&cmd_set_hash_global_config_port_id,
11430 (void *)&cmd_set_hash_global_config_hash_func,
11431 (void *)&cmd_set_hash_global_config_flow_type,
11432 (void *)&cmd_set_hash_global_config_enable,
11437 /* Set hash input set */
11438 struct cmd_set_hash_input_set_result {
11439 cmdline_fixed_string_t set_hash_input_set;
11441 cmdline_fixed_string_t flow_type;
11442 cmdline_fixed_string_t inset_field;
11443 cmdline_fixed_string_t select;
11446 static enum rte_eth_input_set_field
11447 str2inset(char *string)
11451 static const struct {
11453 enum rte_eth_input_set_field inset;
11454 } inset_table[] = {
11455 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11456 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11457 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11458 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11459 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11460 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11461 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11462 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11463 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11464 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11465 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11466 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11467 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11468 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11469 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11470 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11471 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11472 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11473 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11474 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11475 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11476 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11477 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11478 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11479 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11480 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11481 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11482 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11483 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11484 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11485 {"none", RTE_ETH_INPUT_SET_NONE},
11488 for (i = 0; i < RTE_DIM(inset_table); i++) {
11489 if (!strcmp(string, inset_table[i].str))
11490 return inset_table[i].inset;
11493 return RTE_ETH_INPUT_SET_UNKNOWN;
11497 cmd_set_hash_input_set_parsed(void *parsed_result,
11498 __rte_unused struct cmdline *cl,
11499 __rte_unused void *data)
11501 struct cmd_set_hash_input_set_result *res = parsed_result;
11502 struct rte_eth_hash_filter_info info;
11504 memset(&info, 0, sizeof(info));
11505 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11506 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11507 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11508 info.info.input_set_conf.inset_size = 1;
11509 if (!strcmp(res->select, "select"))
11510 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11511 else if (!strcmp(res->select, "add"))
11512 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11513 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11514 RTE_ETH_FILTER_SET, &info);
11517 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11518 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11519 set_hash_input_set, "set_hash_input_set");
11520 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11521 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11523 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11524 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11526 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11527 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11529 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11530 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11531 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11532 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11533 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11535 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11536 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11537 select, "select#add");
11539 cmdline_parse_inst_t cmd_set_hash_input_set = {
11540 .f = cmd_set_hash_input_set_parsed,
11542 .help_str = "set_hash_input_set <port_id> "
11543 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11544 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11545 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11546 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11547 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11548 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11549 "fld-7th|fld-8th|none select|add",
11551 (void *)&cmd_set_hash_input_set_cmd,
11552 (void *)&cmd_set_hash_input_set_port_id,
11553 (void *)&cmd_set_hash_input_set_flow_type,
11554 (void *)&cmd_set_hash_input_set_field,
11555 (void *)&cmd_set_hash_input_set_select,
11560 /* Set flow director input set */
11561 struct cmd_set_fdir_input_set_result {
11562 cmdline_fixed_string_t set_fdir_input_set;
11564 cmdline_fixed_string_t flow_type;
11565 cmdline_fixed_string_t inset_field;
11566 cmdline_fixed_string_t select;
11570 cmd_set_fdir_input_set_parsed(void *parsed_result,
11571 __rte_unused struct cmdline *cl,
11572 __rte_unused void *data)
11574 struct cmd_set_fdir_input_set_result *res = parsed_result;
11575 struct rte_eth_fdir_filter_info info;
11577 memset(&info, 0, sizeof(info));
11578 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11579 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11580 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11581 info.info.input_set_conf.inset_size = 1;
11582 if (!strcmp(res->select, "select"))
11583 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11584 else if (!strcmp(res->select, "add"))
11585 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11586 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11587 RTE_ETH_FILTER_SET, &info);
11590 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11591 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11592 set_fdir_input_set, "set_fdir_input_set");
11593 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11594 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11596 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11597 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11599 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11600 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11601 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11602 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11604 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11605 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11606 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11607 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11608 "sctp-veri-tag#none");
11609 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11610 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11611 select, "select#add");
11613 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11614 .f = cmd_set_fdir_input_set_parsed,
11616 .help_str = "set_fdir_input_set <port_id> "
11617 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11618 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11619 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11620 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11621 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11622 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11623 "sctp-veri-tag|none select|add",
11625 (void *)&cmd_set_fdir_input_set_cmd,
11626 (void *)&cmd_set_fdir_input_set_port_id,
11627 (void *)&cmd_set_fdir_input_set_flow_type,
11628 (void *)&cmd_set_fdir_input_set_field,
11629 (void *)&cmd_set_fdir_input_set_select,
11634 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11635 struct cmd_mcast_addr_result {
11636 cmdline_fixed_string_t mcast_addr_cmd;
11637 cmdline_fixed_string_t what;
11639 struct ether_addr mc_addr;
11642 static void cmd_mcast_addr_parsed(void *parsed_result,
11643 __attribute__((unused)) struct cmdline *cl,
11644 __attribute__((unused)) void *data)
11646 struct cmd_mcast_addr_result *res = parsed_result;
11648 if (!is_multicast_ether_addr(&res->mc_addr)) {
11649 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11650 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11651 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11652 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11655 if (strcmp(res->what, "add") == 0)
11656 mcast_addr_add(res->port_num, &res->mc_addr);
11658 mcast_addr_remove(res->port_num, &res->mc_addr);
11661 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11662 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11663 mcast_addr_cmd, "mcast_addr");
11664 cmdline_parse_token_string_t cmd_mcast_addr_what =
11665 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11667 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11668 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11669 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11670 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11672 cmdline_parse_inst_t cmd_mcast_addr = {
11673 .f = cmd_mcast_addr_parsed,
11675 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11676 "Add/Remove multicast MAC address on port_id",
11678 (void *)&cmd_mcast_addr_cmd,
11679 (void *)&cmd_mcast_addr_what,
11680 (void *)&cmd_mcast_addr_portnum,
11681 (void *)&cmd_mcast_addr_addr,
11686 /* l2 tunnel config
11687 * only support E-tag now.
11690 /* Ether type config */
11691 struct cmd_config_l2_tunnel_eth_type_result {
11692 cmdline_fixed_string_t port;
11693 cmdline_fixed_string_t config;
11694 cmdline_fixed_string_t all;
11696 cmdline_fixed_string_t l2_tunnel;
11697 cmdline_fixed_string_t l2_tunnel_type;
11698 cmdline_fixed_string_t eth_type;
11699 uint16_t eth_type_val;
11702 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11703 TOKEN_STRING_INITIALIZER
11704 (struct cmd_config_l2_tunnel_eth_type_result,
11706 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11707 TOKEN_STRING_INITIALIZER
11708 (struct cmd_config_l2_tunnel_eth_type_result,
11710 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11711 TOKEN_STRING_INITIALIZER
11712 (struct cmd_config_l2_tunnel_eth_type_result,
11714 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11715 TOKEN_NUM_INITIALIZER
11716 (struct cmd_config_l2_tunnel_eth_type_result,
11718 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11719 TOKEN_STRING_INITIALIZER
11720 (struct cmd_config_l2_tunnel_eth_type_result,
11721 l2_tunnel, "l2-tunnel");
11722 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11723 TOKEN_STRING_INITIALIZER
11724 (struct cmd_config_l2_tunnel_eth_type_result,
11725 l2_tunnel_type, "E-tag");
11726 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11727 TOKEN_STRING_INITIALIZER
11728 (struct cmd_config_l2_tunnel_eth_type_result,
11729 eth_type, "ether-type");
11730 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11731 TOKEN_NUM_INITIALIZER
11732 (struct cmd_config_l2_tunnel_eth_type_result,
11733 eth_type_val, UINT16);
11735 static enum rte_eth_tunnel_type
11736 str2fdir_l2_tunnel_type(char *string)
11740 static const struct {
11742 enum rte_eth_tunnel_type type;
11743 } l2_tunnel_type_str[] = {
11744 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11747 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11748 if (!strcmp(l2_tunnel_type_str[i].str, string))
11749 return l2_tunnel_type_str[i].type;
11751 return RTE_TUNNEL_TYPE_NONE;
11754 /* ether type config for all ports */
11756 cmd_config_l2_tunnel_eth_type_all_parsed
11757 (void *parsed_result,
11758 __attribute__((unused)) struct cmdline *cl,
11759 __attribute__((unused)) void *data)
11761 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11762 struct rte_eth_l2_tunnel_conf entry;
11765 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11766 entry.ether_type = res->eth_type_val;
11768 RTE_ETH_FOREACH_DEV(pid) {
11769 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11773 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11774 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11776 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11778 (void *)&cmd_config_l2_tunnel_eth_type_port,
11779 (void *)&cmd_config_l2_tunnel_eth_type_config,
11780 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11781 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11782 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11783 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11784 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11789 /* ether type config for a specific port */
11791 cmd_config_l2_tunnel_eth_type_specific_parsed(
11792 void *parsed_result,
11793 __attribute__((unused)) struct cmdline *cl,
11794 __attribute__((unused)) void *data)
11796 struct cmd_config_l2_tunnel_eth_type_result *res =
11798 struct rte_eth_l2_tunnel_conf entry;
11800 if (port_id_is_invalid(res->id, ENABLED_WARN))
11803 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11804 entry.ether_type = res->eth_type_val;
11806 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11809 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11810 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11812 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11814 (void *)&cmd_config_l2_tunnel_eth_type_port,
11815 (void *)&cmd_config_l2_tunnel_eth_type_config,
11816 (void *)&cmd_config_l2_tunnel_eth_type_id,
11817 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11818 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11819 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11820 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11825 /* Enable/disable l2 tunnel */
11826 struct cmd_config_l2_tunnel_en_dis_result {
11827 cmdline_fixed_string_t port;
11828 cmdline_fixed_string_t config;
11829 cmdline_fixed_string_t all;
11831 cmdline_fixed_string_t l2_tunnel;
11832 cmdline_fixed_string_t l2_tunnel_type;
11833 cmdline_fixed_string_t en_dis;
11836 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11837 TOKEN_STRING_INITIALIZER
11838 (struct cmd_config_l2_tunnel_en_dis_result,
11840 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11841 TOKEN_STRING_INITIALIZER
11842 (struct cmd_config_l2_tunnel_en_dis_result,
11844 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11845 TOKEN_STRING_INITIALIZER
11846 (struct cmd_config_l2_tunnel_en_dis_result,
11848 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11849 TOKEN_NUM_INITIALIZER
11850 (struct cmd_config_l2_tunnel_en_dis_result,
11852 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11853 TOKEN_STRING_INITIALIZER
11854 (struct cmd_config_l2_tunnel_en_dis_result,
11855 l2_tunnel, "l2-tunnel");
11856 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11857 TOKEN_STRING_INITIALIZER
11858 (struct cmd_config_l2_tunnel_en_dis_result,
11859 l2_tunnel_type, "E-tag");
11860 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11861 TOKEN_STRING_INITIALIZER
11862 (struct cmd_config_l2_tunnel_en_dis_result,
11863 en_dis, "enable#disable");
11865 /* enable/disable l2 tunnel for all ports */
11867 cmd_config_l2_tunnel_en_dis_all_parsed(
11868 void *parsed_result,
11869 __attribute__((unused)) struct cmdline *cl,
11870 __attribute__((unused)) void *data)
11872 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11873 struct rte_eth_l2_tunnel_conf entry;
11877 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11879 if (!strcmp("enable", res->en_dis))
11884 RTE_ETH_FOREACH_DEV(pid) {
11885 rte_eth_dev_l2_tunnel_offload_set(pid,
11887 ETH_L2_TUNNEL_ENABLE_MASK,
11892 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11893 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11895 .help_str = "port config all l2-tunnel E-tag enable|disable",
11897 (void *)&cmd_config_l2_tunnel_en_dis_port,
11898 (void *)&cmd_config_l2_tunnel_en_dis_config,
11899 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11900 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11901 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11902 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11907 /* enable/disable l2 tunnel for a port */
11909 cmd_config_l2_tunnel_en_dis_specific_parsed(
11910 void *parsed_result,
11911 __attribute__((unused)) struct cmdline *cl,
11912 __attribute__((unused)) void *data)
11914 struct cmd_config_l2_tunnel_en_dis_result *res =
11916 struct rte_eth_l2_tunnel_conf entry;
11918 if (port_id_is_invalid(res->id, ENABLED_WARN))
11921 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11923 if (!strcmp("enable", res->en_dis))
11924 rte_eth_dev_l2_tunnel_offload_set(res->id,
11926 ETH_L2_TUNNEL_ENABLE_MASK,
11929 rte_eth_dev_l2_tunnel_offload_set(res->id,
11931 ETH_L2_TUNNEL_ENABLE_MASK,
11935 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11936 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11938 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11940 (void *)&cmd_config_l2_tunnel_en_dis_port,
11941 (void *)&cmd_config_l2_tunnel_en_dis_config,
11942 (void *)&cmd_config_l2_tunnel_en_dis_id,
11943 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11944 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11945 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11950 /* E-tag configuration */
11952 /* Common result structure for all E-tag configuration */
11953 struct cmd_config_e_tag_result {
11954 cmdline_fixed_string_t e_tag;
11955 cmdline_fixed_string_t set;
11956 cmdline_fixed_string_t insertion;
11957 cmdline_fixed_string_t stripping;
11958 cmdline_fixed_string_t forwarding;
11959 cmdline_fixed_string_t filter;
11960 cmdline_fixed_string_t add;
11961 cmdline_fixed_string_t del;
11962 cmdline_fixed_string_t on;
11963 cmdline_fixed_string_t off;
11964 cmdline_fixed_string_t on_off;
11965 cmdline_fixed_string_t port_tag_id;
11966 uint32_t port_tag_id_val;
11967 cmdline_fixed_string_t e_tag_id;
11968 uint16_t e_tag_id_val;
11969 cmdline_fixed_string_t dst_pool;
11970 uint8_t dst_pool_val;
11971 cmdline_fixed_string_t port;
11973 cmdline_fixed_string_t vf;
11977 /* Common CLI fields for all E-tag configuration */
11978 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11979 TOKEN_STRING_INITIALIZER
11980 (struct cmd_config_e_tag_result,
11982 cmdline_parse_token_string_t cmd_config_e_tag_set =
11983 TOKEN_STRING_INITIALIZER
11984 (struct cmd_config_e_tag_result,
11986 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11987 TOKEN_STRING_INITIALIZER
11988 (struct cmd_config_e_tag_result,
11989 insertion, "insertion");
11990 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11991 TOKEN_STRING_INITIALIZER
11992 (struct cmd_config_e_tag_result,
11993 stripping, "stripping");
11994 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11995 TOKEN_STRING_INITIALIZER
11996 (struct cmd_config_e_tag_result,
11997 forwarding, "forwarding");
11998 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11999 TOKEN_STRING_INITIALIZER
12000 (struct cmd_config_e_tag_result,
12002 cmdline_parse_token_string_t cmd_config_e_tag_add =
12003 TOKEN_STRING_INITIALIZER
12004 (struct cmd_config_e_tag_result,
12006 cmdline_parse_token_string_t cmd_config_e_tag_del =
12007 TOKEN_STRING_INITIALIZER
12008 (struct cmd_config_e_tag_result,
12010 cmdline_parse_token_string_t cmd_config_e_tag_on =
12011 TOKEN_STRING_INITIALIZER
12012 (struct cmd_config_e_tag_result,
12014 cmdline_parse_token_string_t cmd_config_e_tag_off =
12015 TOKEN_STRING_INITIALIZER
12016 (struct cmd_config_e_tag_result,
12018 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12019 TOKEN_STRING_INITIALIZER
12020 (struct cmd_config_e_tag_result,
12022 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12023 TOKEN_STRING_INITIALIZER
12024 (struct cmd_config_e_tag_result,
12025 port_tag_id, "port-tag-id");
12026 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12027 TOKEN_NUM_INITIALIZER
12028 (struct cmd_config_e_tag_result,
12029 port_tag_id_val, UINT32);
12030 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12031 TOKEN_STRING_INITIALIZER
12032 (struct cmd_config_e_tag_result,
12033 e_tag_id, "e-tag-id");
12034 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12035 TOKEN_NUM_INITIALIZER
12036 (struct cmd_config_e_tag_result,
12037 e_tag_id_val, UINT16);
12038 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12039 TOKEN_STRING_INITIALIZER
12040 (struct cmd_config_e_tag_result,
12041 dst_pool, "dst-pool");
12042 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12043 TOKEN_NUM_INITIALIZER
12044 (struct cmd_config_e_tag_result,
12045 dst_pool_val, UINT8);
12046 cmdline_parse_token_string_t cmd_config_e_tag_port =
12047 TOKEN_STRING_INITIALIZER
12048 (struct cmd_config_e_tag_result,
12050 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12051 TOKEN_NUM_INITIALIZER
12052 (struct cmd_config_e_tag_result,
12054 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12055 TOKEN_STRING_INITIALIZER
12056 (struct cmd_config_e_tag_result,
12058 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12059 TOKEN_NUM_INITIALIZER
12060 (struct cmd_config_e_tag_result,
12063 /* E-tag insertion configuration */
12065 cmd_config_e_tag_insertion_en_parsed(
12066 void *parsed_result,
12067 __attribute__((unused)) struct cmdline *cl,
12068 __attribute__((unused)) void *data)
12070 struct cmd_config_e_tag_result *res =
12072 struct rte_eth_l2_tunnel_conf entry;
12074 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12077 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12078 entry.tunnel_id = res->port_tag_id_val;
12079 entry.vf_id = res->vf_id;
12080 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12082 ETH_L2_TUNNEL_INSERTION_MASK,
12087 cmd_config_e_tag_insertion_dis_parsed(
12088 void *parsed_result,
12089 __attribute__((unused)) struct cmdline *cl,
12090 __attribute__((unused)) void *data)
12092 struct cmd_config_e_tag_result *res =
12094 struct rte_eth_l2_tunnel_conf entry;
12096 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12099 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12100 entry.vf_id = res->vf_id;
12102 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12104 ETH_L2_TUNNEL_INSERTION_MASK,
12108 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12109 .f = cmd_config_e_tag_insertion_en_parsed,
12111 .help_str = "E-tag ... : E-tag insertion enable",
12113 (void *)&cmd_config_e_tag_e_tag,
12114 (void *)&cmd_config_e_tag_set,
12115 (void *)&cmd_config_e_tag_insertion,
12116 (void *)&cmd_config_e_tag_on,
12117 (void *)&cmd_config_e_tag_port_tag_id,
12118 (void *)&cmd_config_e_tag_port_tag_id_val,
12119 (void *)&cmd_config_e_tag_port,
12120 (void *)&cmd_config_e_tag_port_id,
12121 (void *)&cmd_config_e_tag_vf,
12122 (void *)&cmd_config_e_tag_vf_id,
12127 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12128 .f = cmd_config_e_tag_insertion_dis_parsed,
12130 .help_str = "E-tag ... : E-tag insertion disable",
12132 (void *)&cmd_config_e_tag_e_tag,
12133 (void *)&cmd_config_e_tag_set,
12134 (void *)&cmd_config_e_tag_insertion,
12135 (void *)&cmd_config_e_tag_off,
12136 (void *)&cmd_config_e_tag_port,
12137 (void *)&cmd_config_e_tag_port_id,
12138 (void *)&cmd_config_e_tag_vf,
12139 (void *)&cmd_config_e_tag_vf_id,
12144 /* E-tag stripping configuration */
12146 cmd_config_e_tag_stripping_parsed(
12147 void *parsed_result,
12148 __attribute__((unused)) struct cmdline *cl,
12149 __attribute__((unused)) void *data)
12151 struct cmd_config_e_tag_result *res =
12153 struct rte_eth_l2_tunnel_conf entry;
12155 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12158 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12160 if (!strcmp(res->on_off, "on"))
12161 rte_eth_dev_l2_tunnel_offload_set
12164 ETH_L2_TUNNEL_STRIPPING_MASK,
12167 rte_eth_dev_l2_tunnel_offload_set
12170 ETH_L2_TUNNEL_STRIPPING_MASK,
12174 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12175 .f = cmd_config_e_tag_stripping_parsed,
12177 .help_str = "E-tag ... : E-tag stripping enable/disable",
12179 (void *)&cmd_config_e_tag_e_tag,
12180 (void *)&cmd_config_e_tag_set,
12181 (void *)&cmd_config_e_tag_stripping,
12182 (void *)&cmd_config_e_tag_on_off,
12183 (void *)&cmd_config_e_tag_port,
12184 (void *)&cmd_config_e_tag_port_id,
12189 /* E-tag forwarding configuration */
12191 cmd_config_e_tag_forwarding_parsed(
12192 void *parsed_result,
12193 __attribute__((unused)) struct cmdline *cl,
12194 __attribute__((unused)) void *data)
12196 struct cmd_config_e_tag_result *res = parsed_result;
12197 struct rte_eth_l2_tunnel_conf entry;
12199 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12202 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12204 if (!strcmp(res->on_off, "on"))
12205 rte_eth_dev_l2_tunnel_offload_set
12208 ETH_L2_TUNNEL_FORWARDING_MASK,
12211 rte_eth_dev_l2_tunnel_offload_set
12214 ETH_L2_TUNNEL_FORWARDING_MASK,
12218 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12219 .f = cmd_config_e_tag_forwarding_parsed,
12221 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12223 (void *)&cmd_config_e_tag_e_tag,
12224 (void *)&cmd_config_e_tag_set,
12225 (void *)&cmd_config_e_tag_forwarding,
12226 (void *)&cmd_config_e_tag_on_off,
12227 (void *)&cmd_config_e_tag_port,
12228 (void *)&cmd_config_e_tag_port_id,
12233 /* E-tag filter configuration */
12235 cmd_config_e_tag_filter_add_parsed(
12236 void *parsed_result,
12237 __attribute__((unused)) struct cmdline *cl,
12238 __attribute__((unused)) void *data)
12240 struct cmd_config_e_tag_result *res = parsed_result;
12241 struct rte_eth_l2_tunnel_conf entry;
12244 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12247 if (res->e_tag_id_val > 0x3fff) {
12248 printf("e-tag-id must be equal or less than 0x3fff.\n");
12252 ret = rte_eth_dev_filter_supported(res->port_id,
12253 RTE_ETH_FILTER_L2_TUNNEL);
12255 printf("E-tag filter is not supported on port %u.\n",
12260 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12261 entry.tunnel_id = res->e_tag_id_val;
12262 entry.pool = res->dst_pool_val;
12264 ret = rte_eth_dev_filter_ctrl(res->port_id,
12265 RTE_ETH_FILTER_L2_TUNNEL,
12266 RTE_ETH_FILTER_ADD,
12269 printf("E-tag filter programming error: (%s)\n",
12273 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12274 .f = cmd_config_e_tag_filter_add_parsed,
12276 .help_str = "E-tag ... : E-tag filter add",
12278 (void *)&cmd_config_e_tag_e_tag,
12279 (void *)&cmd_config_e_tag_set,
12280 (void *)&cmd_config_e_tag_filter,
12281 (void *)&cmd_config_e_tag_add,
12282 (void *)&cmd_config_e_tag_e_tag_id,
12283 (void *)&cmd_config_e_tag_e_tag_id_val,
12284 (void *)&cmd_config_e_tag_dst_pool,
12285 (void *)&cmd_config_e_tag_dst_pool_val,
12286 (void *)&cmd_config_e_tag_port,
12287 (void *)&cmd_config_e_tag_port_id,
12293 cmd_config_e_tag_filter_del_parsed(
12294 void *parsed_result,
12295 __attribute__((unused)) struct cmdline *cl,
12296 __attribute__((unused)) void *data)
12298 struct cmd_config_e_tag_result *res = parsed_result;
12299 struct rte_eth_l2_tunnel_conf entry;
12302 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12305 if (res->e_tag_id_val > 0x3fff) {
12306 printf("e-tag-id must be less than 0x3fff.\n");
12310 ret = rte_eth_dev_filter_supported(res->port_id,
12311 RTE_ETH_FILTER_L2_TUNNEL);
12313 printf("E-tag filter is not supported on port %u.\n",
12318 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12319 entry.tunnel_id = res->e_tag_id_val;
12321 ret = rte_eth_dev_filter_ctrl(res->port_id,
12322 RTE_ETH_FILTER_L2_TUNNEL,
12323 RTE_ETH_FILTER_DELETE,
12326 printf("E-tag filter programming error: (%s)\n",
12330 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12331 .f = cmd_config_e_tag_filter_del_parsed,
12333 .help_str = "E-tag ... : E-tag filter delete",
12335 (void *)&cmd_config_e_tag_e_tag,
12336 (void *)&cmd_config_e_tag_set,
12337 (void *)&cmd_config_e_tag_filter,
12338 (void *)&cmd_config_e_tag_del,
12339 (void *)&cmd_config_e_tag_e_tag_id,
12340 (void *)&cmd_config_e_tag_e_tag_id_val,
12341 (void *)&cmd_config_e_tag_port,
12342 (void *)&cmd_config_e_tag_port_id,
12347 /* vf vlan anti spoof configuration */
12349 /* Common result structure for vf vlan anti spoof */
12350 struct cmd_vf_vlan_anti_spoof_result {
12351 cmdline_fixed_string_t set;
12352 cmdline_fixed_string_t vf;
12353 cmdline_fixed_string_t vlan;
12354 cmdline_fixed_string_t antispoof;
12357 cmdline_fixed_string_t on_off;
12360 /* Common CLI fields for vf vlan anti spoof enable disable */
12361 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12362 TOKEN_STRING_INITIALIZER
12363 (struct cmd_vf_vlan_anti_spoof_result,
12365 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12366 TOKEN_STRING_INITIALIZER
12367 (struct cmd_vf_vlan_anti_spoof_result,
12369 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12370 TOKEN_STRING_INITIALIZER
12371 (struct cmd_vf_vlan_anti_spoof_result,
12373 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12374 TOKEN_STRING_INITIALIZER
12375 (struct cmd_vf_vlan_anti_spoof_result,
12376 antispoof, "antispoof");
12377 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12378 TOKEN_NUM_INITIALIZER
12379 (struct cmd_vf_vlan_anti_spoof_result,
12381 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12382 TOKEN_NUM_INITIALIZER
12383 (struct cmd_vf_vlan_anti_spoof_result,
12385 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12386 TOKEN_STRING_INITIALIZER
12387 (struct cmd_vf_vlan_anti_spoof_result,
12391 cmd_set_vf_vlan_anti_spoof_parsed(
12392 void *parsed_result,
12393 __attribute__((unused)) struct cmdline *cl,
12394 __attribute__((unused)) void *data)
12396 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12397 int ret = -ENOTSUP;
12399 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12401 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12404 #ifdef RTE_LIBRTE_IXGBE_PMD
12405 if (ret == -ENOTSUP)
12406 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12407 res->vf_id, is_on);
12409 #ifdef RTE_LIBRTE_I40E_PMD
12410 if (ret == -ENOTSUP)
12411 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12412 res->vf_id, is_on);
12414 #ifdef RTE_LIBRTE_BNXT_PMD
12415 if (ret == -ENOTSUP)
12416 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12417 res->vf_id, is_on);
12424 printf("invalid vf_id %d\n", res->vf_id);
12427 printf("invalid port_id %d\n", res->port_id);
12430 printf("function not implemented\n");
12433 printf("programming error: (%s)\n", strerror(-ret));
12437 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12438 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12440 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12442 (void *)&cmd_vf_vlan_anti_spoof_set,
12443 (void *)&cmd_vf_vlan_anti_spoof_vf,
12444 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12445 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12446 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12447 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12448 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12453 /* vf mac anti spoof configuration */
12455 /* Common result structure for vf mac anti spoof */
12456 struct cmd_vf_mac_anti_spoof_result {
12457 cmdline_fixed_string_t set;
12458 cmdline_fixed_string_t vf;
12459 cmdline_fixed_string_t mac;
12460 cmdline_fixed_string_t antispoof;
12463 cmdline_fixed_string_t on_off;
12466 /* Common CLI fields for vf mac anti spoof enable disable */
12467 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12468 TOKEN_STRING_INITIALIZER
12469 (struct cmd_vf_mac_anti_spoof_result,
12471 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12472 TOKEN_STRING_INITIALIZER
12473 (struct cmd_vf_mac_anti_spoof_result,
12475 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12476 TOKEN_STRING_INITIALIZER
12477 (struct cmd_vf_mac_anti_spoof_result,
12479 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12480 TOKEN_STRING_INITIALIZER
12481 (struct cmd_vf_mac_anti_spoof_result,
12482 antispoof, "antispoof");
12483 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12484 TOKEN_NUM_INITIALIZER
12485 (struct cmd_vf_mac_anti_spoof_result,
12487 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12488 TOKEN_NUM_INITIALIZER
12489 (struct cmd_vf_mac_anti_spoof_result,
12491 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12492 TOKEN_STRING_INITIALIZER
12493 (struct cmd_vf_mac_anti_spoof_result,
12497 cmd_set_vf_mac_anti_spoof_parsed(
12498 void *parsed_result,
12499 __attribute__((unused)) struct cmdline *cl,
12500 __attribute__((unused)) void *data)
12502 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12503 int ret = -ENOTSUP;
12505 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12507 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12510 #ifdef RTE_LIBRTE_IXGBE_PMD
12511 if (ret == -ENOTSUP)
12512 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12513 res->vf_id, is_on);
12515 #ifdef RTE_LIBRTE_I40E_PMD
12516 if (ret == -ENOTSUP)
12517 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12518 res->vf_id, is_on);
12520 #ifdef RTE_LIBRTE_BNXT_PMD
12521 if (ret == -ENOTSUP)
12522 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12523 res->vf_id, is_on);
12530 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12533 printf("invalid port_id %d\n", res->port_id);
12536 printf("function not implemented\n");
12539 printf("programming error: (%s)\n", strerror(-ret));
12543 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12544 .f = cmd_set_vf_mac_anti_spoof_parsed,
12546 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12548 (void *)&cmd_vf_mac_anti_spoof_set,
12549 (void *)&cmd_vf_mac_anti_spoof_vf,
12550 (void *)&cmd_vf_mac_anti_spoof_mac,
12551 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12552 (void *)&cmd_vf_mac_anti_spoof_port_id,
12553 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12554 (void *)&cmd_vf_mac_anti_spoof_on_off,
12559 /* vf vlan strip queue configuration */
12561 /* Common result structure for vf mac anti spoof */
12562 struct cmd_vf_vlan_stripq_result {
12563 cmdline_fixed_string_t set;
12564 cmdline_fixed_string_t vf;
12565 cmdline_fixed_string_t vlan;
12566 cmdline_fixed_string_t stripq;
12569 cmdline_fixed_string_t on_off;
12572 /* Common CLI fields for vf vlan strip enable disable */
12573 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12574 TOKEN_STRING_INITIALIZER
12575 (struct cmd_vf_vlan_stripq_result,
12577 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12578 TOKEN_STRING_INITIALIZER
12579 (struct cmd_vf_vlan_stripq_result,
12581 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12582 TOKEN_STRING_INITIALIZER
12583 (struct cmd_vf_vlan_stripq_result,
12585 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12586 TOKEN_STRING_INITIALIZER
12587 (struct cmd_vf_vlan_stripq_result,
12589 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12590 TOKEN_NUM_INITIALIZER
12591 (struct cmd_vf_vlan_stripq_result,
12593 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12594 TOKEN_NUM_INITIALIZER
12595 (struct cmd_vf_vlan_stripq_result,
12597 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12598 TOKEN_STRING_INITIALIZER
12599 (struct cmd_vf_vlan_stripq_result,
12603 cmd_set_vf_vlan_stripq_parsed(
12604 void *parsed_result,
12605 __attribute__((unused)) struct cmdline *cl,
12606 __attribute__((unused)) void *data)
12608 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12609 int ret = -ENOTSUP;
12611 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12613 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12616 #ifdef RTE_LIBRTE_IXGBE_PMD
12617 if (ret == -ENOTSUP)
12618 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12619 res->vf_id, is_on);
12621 #ifdef RTE_LIBRTE_I40E_PMD
12622 if (ret == -ENOTSUP)
12623 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12624 res->vf_id, is_on);
12626 #ifdef RTE_LIBRTE_BNXT_PMD
12627 if (ret == -ENOTSUP)
12628 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12629 res->vf_id, is_on);
12636 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12639 printf("invalid port_id %d\n", res->port_id);
12642 printf("function not implemented\n");
12645 printf("programming error: (%s)\n", strerror(-ret));
12649 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12650 .f = cmd_set_vf_vlan_stripq_parsed,
12652 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12654 (void *)&cmd_vf_vlan_stripq_set,
12655 (void *)&cmd_vf_vlan_stripq_vf,
12656 (void *)&cmd_vf_vlan_stripq_vlan,
12657 (void *)&cmd_vf_vlan_stripq_stripq,
12658 (void *)&cmd_vf_vlan_stripq_port_id,
12659 (void *)&cmd_vf_vlan_stripq_vf_id,
12660 (void *)&cmd_vf_vlan_stripq_on_off,
12665 /* vf vlan insert configuration */
12667 /* Common result structure for vf vlan insert */
12668 struct cmd_vf_vlan_insert_result {
12669 cmdline_fixed_string_t set;
12670 cmdline_fixed_string_t vf;
12671 cmdline_fixed_string_t vlan;
12672 cmdline_fixed_string_t insert;
12678 /* Common CLI fields for vf vlan insert enable disable */
12679 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12680 TOKEN_STRING_INITIALIZER
12681 (struct cmd_vf_vlan_insert_result,
12683 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12684 TOKEN_STRING_INITIALIZER
12685 (struct cmd_vf_vlan_insert_result,
12687 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12688 TOKEN_STRING_INITIALIZER
12689 (struct cmd_vf_vlan_insert_result,
12691 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12692 TOKEN_STRING_INITIALIZER
12693 (struct cmd_vf_vlan_insert_result,
12695 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12696 TOKEN_NUM_INITIALIZER
12697 (struct cmd_vf_vlan_insert_result,
12699 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12700 TOKEN_NUM_INITIALIZER
12701 (struct cmd_vf_vlan_insert_result,
12703 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12704 TOKEN_NUM_INITIALIZER
12705 (struct cmd_vf_vlan_insert_result,
12709 cmd_set_vf_vlan_insert_parsed(
12710 void *parsed_result,
12711 __attribute__((unused)) struct cmdline *cl,
12712 __attribute__((unused)) void *data)
12714 struct cmd_vf_vlan_insert_result *res = parsed_result;
12715 int ret = -ENOTSUP;
12717 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12720 #ifdef RTE_LIBRTE_IXGBE_PMD
12721 if (ret == -ENOTSUP)
12722 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12725 #ifdef RTE_LIBRTE_I40E_PMD
12726 if (ret == -ENOTSUP)
12727 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12730 #ifdef RTE_LIBRTE_BNXT_PMD
12731 if (ret == -ENOTSUP)
12732 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12740 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12743 printf("invalid port_id %d\n", res->port_id);
12746 printf("function not implemented\n");
12749 printf("programming error: (%s)\n", strerror(-ret));
12753 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12754 .f = cmd_set_vf_vlan_insert_parsed,
12756 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12758 (void *)&cmd_vf_vlan_insert_set,
12759 (void *)&cmd_vf_vlan_insert_vf,
12760 (void *)&cmd_vf_vlan_insert_vlan,
12761 (void *)&cmd_vf_vlan_insert_insert,
12762 (void *)&cmd_vf_vlan_insert_port_id,
12763 (void *)&cmd_vf_vlan_insert_vf_id,
12764 (void *)&cmd_vf_vlan_insert_vlan_id,
12769 /* tx loopback configuration */
12771 /* Common result structure for tx loopback */
12772 struct cmd_tx_loopback_result {
12773 cmdline_fixed_string_t set;
12774 cmdline_fixed_string_t tx;
12775 cmdline_fixed_string_t loopback;
12777 cmdline_fixed_string_t on_off;
12780 /* Common CLI fields for tx loopback enable disable */
12781 cmdline_parse_token_string_t cmd_tx_loopback_set =
12782 TOKEN_STRING_INITIALIZER
12783 (struct cmd_tx_loopback_result,
12785 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12786 TOKEN_STRING_INITIALIZER
12787 (struct cmd_tx_loopback_result,
12789 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12790 TOKEN_STRING_INITIALIZER
12791 (struct cmd_tx_loopback_result,
12792 loopback, "loopback");
12793 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12794 TOKEN_NUM_INITIALIZER
12795 (struct cmd_tx_loopback_result,
12797 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12798 TOKEN_STRING_INITIALIZER
12799 (struct cmd_tx_loopback_result,
12803 cmd_set_tx_loopback_parsed(
12804 void *parsed_result,
12805 __attribute__((unused)) struct cmdline *cl,
12806 __attribute__((unused)) void *data)
12808 struct cmd_tx_loopback_result *res = parsed_result;
12809 int ret = -ENOTSUP;
12811 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12813 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12816 #ifdef RTE_LIBRTE_IXGBE_PMD
12817 if (ret == -ENOTSUP)
12818 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12820 #ifdef RTE_LIBRTE_I40E_PMD
12821 if (ret == -ENOTSUP)
12822 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12824 #ifdef RTE_LIBRTE_BNXT_PMD
12825 if (ret == -ENOTSUP)
12826 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12828 #ifdef RTE_LIBRTE_DPAA_PMD
12829 if (ret == -ENOTSUP)
12830 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
12837 printf("invalid is_on %d\n", is_on);
12840 printf("invalid port_id %d\n", res->port_id);
12843 printf("function not implemented\n");
12846 printf("programming error: (%s)\n", strerror(-ret));
12850 cmdline_parse_inst_t cmd_set_tx_loopback = {
12851 .f = cmd_set_tx_loopback_parsed,
12853 .help_str = "set tx loopback <port_id> on|off",
12855 (void *)&cmd_tx_loopback_set,
12856 (void *)&cmd_tx_loopback_tx,
12857 (void *)&cmd_tx_loopback_loopback,
12858 (void *)&cmd_tx_loopback_port_id,
12859 (void *)&cmd_tx_loopback_on_off,
12864 /* all queues drop enable configuration */
12866 /* Common result structure for all queues drop enable */
12867 struct cmd_all_queues_drop_en_result {
12868 cmdline_fixed_string_t set;
12869 cmdline_fixed_string_t all;
12870 cmdline_fixed_string_t queues;
12871 cmdline_fixed_string_t drop;
12873 cmdline_fixed_string_t on_off;
12876 /* Common CLI fields for tx loopback enable disable */
12877 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12878 TOKEN_STRING_INITIALIZER
12879 (struct cmd_all_queues_drop_en_result,
12881 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12882 TOKEN_STRING_INITIALIZER
12883 (struct cmd_all_queues_drop_en_result,
12885 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12886 TOKEN_STRING_INITIALIZER
12887 (struct cmd_all_queues_drop_en_result,
12889 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12890 TOKEN_STRING_INITIALIZER
12891 (struct cmd_all_queues_drop_en_result,
12893 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12894 TOKEN_NUM_INITIALIZER
12895 (struct cmd_all_queues_drop_en_result,
12897 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12898 TOKEN_STRING_INITIALIZER
12899 (struct cmd_all_queues_drop_en_result,
12903 cmd_set_all_queues_drop_en_parsed(
12904 void *parsed_result,
12905 __attribute__((unused)) struct cmdline *cl,
12906 __attribute__((unused)) void *data)
12908 struct cmd_all_queues_drop_en_result *res = parsed_result;
12909 int ret = -ENOTSUP;
12910 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12912 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12915 #ifdef RTE_LIBRTE_IXGBE_PMD
12916 if (ret == -ENOTSUP)
12917 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12919 #ifdef RTE_LIBRTE_BNXT_PMD
12920 if (ret == -ENOTSUP)
12921 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12927 printf("invalid is_on %d\n", is_on);
12930 printf("invalid port_id %d\n", res->port_id);
12933 printf("function not implemented\n");
12936 printf("programming error: (%s)\n", strerror(-ret));
12940 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12941 .f = cmd_set_all_queues_drop_en_parsed,
12943 .help_str = "set all queues drop <port_id> on|off",
12945 (void *)&cmd_all_queues_drop_en_set,
12946 (void *)&cmd_all_queues_drop_en_all,
12947 (void *)&cmd_all_queues_drop_en_queues,
12948 (void *)&cmd_all_queues_drop_en_drop,
12949 (void *)&cmd_all_queues_drop_en_port_id,
12950 (void *)&cmd_all_queues_drop_en_on_off,
12955 /* vf split drop enable configuration */
12957 /* Common result structure for vf split drop enable */
12958 struct cmd_vf_split_drop_en_result {
12959 cmdline_fixed_string_t set;
12960 cmdline_fixed_string_t vf;
12961 cmdline_fixed_string_t split;
12962 cmdline_fixed_string_t drop;
12965 cmdline_fixed_string_t on_off;
12968 /* Common CLI fields for vf split drop enable disable */
12969 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12970 TOKEN_STRING_INITIALIZER
12971 (struct cmd_vf_split_drop_en_result,
12973 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12974 TOKEN_STRING_INITIALIZER
12975 (struct cmd_vf_split_drop_en_result,
12977 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12978 TOKEN_STRING_INITIALIZER
12979 (struct cmd_vf_split_drop_en_result,
12981 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12982 TOKEN_STRING_INITIALIZER
12983 (struct cmd_vf_split_drop_en_result,
12985 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12986 TOKEN_NUM_INITIALIZER
12987 (struct cmd_vf_split_drop_en_result,
12989 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12990 TOKEN_NUM_INITIALIZER
12991 (struct cmd_vf_split_drop_en_result,
12993 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12994 TOKEN_STRING_INITIALIZER
12995 (struct cmd_vf_split_drop_en_result,
12999 cmd_set_vf_split_drop_en_parsed(
13000 void *parsed_result,
13001 __attribute__((unused)) struct cmdline *cl,
13002 __attribute__((unused)) void *data)
13004 struct cmd_vf_split_drop_en_result *res = parsed_result;
13005 int ret = -ENOTSUP;
13006 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13008 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13011 #ifdef RTE_LIBRTE_IXGBE_PMD
13012 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13019 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13022 printf("invalid port_id %d\n", res->port_id);
13025 printf("not supported on port %d\n", res->port_id);
13028 printf("programming error: (%s)\n", strerror(-ret));
13032 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13033 .f = cmd_set_vf_split_drop_en_parsed,
13035 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13037 (void *)&cmd_vf_split_drop_en_set,
13038 (void *)&cmd_vf_split_drop_en_vf,
13039 (void *)&cmd_vf_split_drop_en_split,
13040 (void *)&cmd_vf_split_drop_en_drop,
13041 (void *)&cmd_vf_split_drop_en_port_id,
13042 (void *)&cmd_vf_split_drop_en_vf_id,
13043 (void *)&cmd_vf_split_drop_en_on_off,
13048 /* vf mac address configuration */
13050 /* Common result structure for vf mac address */
13051 struct cmd_set_vf_mac_addr_result {
13052 cmdline_fixed_string_t set;
13053 cmdline_fixed_string_t vf;
13054 cmdline_fixed_string_t mac;
13055 cmdline_fixed_string_t addr;
13058 struct ether_addr mac_addr;
13062 /* Common CLI fields for vf split drop enable disable */
13063 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13064 TOKEN_STRING_INITIALIZER
13065 (struct cmd_set_vf_mac_addr_result,
13067 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13068 TOKEN_STRING_INITIALIZER
13069 (struct cmd_set_vf_mac_addr_result,
13071 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13072 TOKEN_STRING_INITIALIZER
13073 (struct cmd_set_vf_mac_addr_result,
13075 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13076 TOKEN_STRING_INITIALIZER
13077 (struct cmd_set_vf_mac_addr_result,
13079 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13080 TOKEN_NUM_INITIALIZER
13081 (struct cmd_set_vf_mac_addr_result,
13083 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13084 TOKEN_NUM_INITIALIZER
13085 (struct cmd_set_vf_mac_addr_result,
13087 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13088 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13092 cmd_set_vf_mac_addr_parsed(
13093 void *parsed_result,
13094 __attribute__((unused)) struct cmdline *cl,
13095 __attribute__((unused)) void *data)
13097 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13098 int ret = -ENOTSUP;
13100 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13103 #ifdef RTE_LIBRTE_IXGBE_PMD
13104 if (ret == -ENOTSUP)
13105 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13108 #ifdef RTE_LIBRTE_I40E_PMD
13109 if (ret == -ENOTSUP)
13110 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13113 #ifdef RTE_LIBRTE_BNXT_PMD
13114 if (ret == -ENOTSUP)
13115 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13123 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13126 printf("invalid port_id %d\n", res->port_id);
13129 printf("function not implemented\n");
13132 printf("programming error: (%s)\n", strerror(-ret));
13136 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13137 .f = cmd_set_vf_mac_addr_parsed,
13139 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13141 (void *)&cmd_set_vf_mac_addr_set,
13142 (void *)&cmd_set_vf_mac_addr_vf,
13143 (void *)&cmd_set_vf_mac_addr_mac,
13144 (void *)&cmd_set_vf_mac_addr_addr,
13145 (void *)&cmd_set_vf_mac_addr_port_id,
13146 (void *)&cmd_set_vf_mac_addr_vf_id,
13147 (void *)&cmd_set_vf_mac_addr_mac_addr,
13152 /* MACsec configuration */
13154 /* Common result structure for MACsec offload enable */
13155 struct cmd_macsec_offload_on_result {
13156 cmdline_fixed_string_t set;
13157 cmdline_fixed_string_t macsec;
13158 cmdline_fixed_string_t offload;
13160 cmdline_fixed_string_t on;
13161 cmdline_fixed_string_t encrypt;
13162 cmdline_fixed_string_t en_on_off;
13163 cmdline_fixed_string_t replay_protect;
13164 cmdline_fixed_string_t rp_on_off;
13167 /* Common CLI fields for MACsec offload disable */
13168 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13169 TOKEN_STRING_INITIALIZER
13170 (struct cmd_macsec_offload_on_result,
13172 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13173 TOKEN_STRING_INITIALIZER
13174 (struct cmd_macsec_offload_on_result,
13176 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13177 TOKEN_STRING_INITIALIZER
13178 (struct cmd_macsec_offload_on_result,
13179 offload, "offload");
13180 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13181 TOKEN_NUM_INITIALIZER
13182 (struct cmd_macsec_offload_on_result,
13184 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13185 TOKEN_STRING_INITIALIZER
13186 (struct cmd_macsec_offload_on_result,
13188 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13189 TOKEN_STRING_INITIALIZER
13190 (struct cmd_macsec_offload_on_result,
13191 encrypt, "encrypt");
13192 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13193 TOKEN_STRING_INITIALIZER
13194 (struct cmd_macsec_offload_on_result,
13195 en_on_off, "on#off");
13196 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13197 TOKEN_STRING_INITIALIZER
13198 (struct cmd_macsec_offload_on_result,
13199 replay_protect, "replay-protect");
13200 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13201 TOKEN_STRING_INITIALIZER
13202 (struct cmd_macsec_offload_on_result,
13203 rp_on_off, "on#off");
13206 cmd_set_macsec_offload_on_parsed(
13207 void *parsed_result,
13208 __attribute__((unused)) struct cmdline *cl,
13209 __attribute__((unused)) void *data)
13211 struct cmd_macsec_offload_on_result *res = parsed_result;
13212 int ret = -ENOTSUP;
13213 portid_t port_id = res->port_id;
13214 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13215 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13216 struct rte_eth_dev_info dev_info;
13218 if (port_id_is_invalid(port_id, ENABLED_WARN))
13220 if (!port_is_stopped(port_id)) {
13221 printf("Please stop port %d first\n", port_id);
13225 rte_eth_dev_info_get(port_id, &dev_info);
13226 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13227 #ifdef RTE_LIBRTE_IXGBE_PMD
13228 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13236 ports[port_id].dev_conf.txmode.offloads |=
13237 DEV_TX_OFFLOAD_MACSEC_INSERT;
13238 cmd_reconfig_device_queue(port_id, 1, 1);
13241 printf("invalid port_id %d\n", port_id);
13244 printf("not supported on port %d\n", port_id);
13247 printf("programming error: (%s)\n", strerror(-ret));
13251 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13252 .f = cmd_set_macsec_offload_on_parsed,
13254 .help_str = "set macsec offload <port_id> on "
13255 "encrypt on|off replay-protect on|off",
13257 (void *)&cmd_macsec_offload_on_set,
13258 (void *)&cmd_macsec_offload_on_macsec,
13259 (void *)&cmd_macsec_offload_on_offload,
13260 (void *)&cmd_macsec_offload_on_port_id,
13261 (void *)&cmd_macsec_offload_on_on,
13262 (void *)&cmd_macsec_offload_on_encrypt,
13263 (void *)&cmd_macsec_offload_on_en_on_off,
13264 (void *)&cmd_macsec_offload_on_replay_protect,
13265 (void *)&cmd_macsec_offload_on_rp_on_off,
13270 /* Common result structure for MACsec offload disable */
13271 struct cmd_macsec_offload_off_result {
13272 cmdline_fixed_string_t set;
13273 cmdline_fixed_string_t macsec;
13274 cmdline_fixed_string_t offload;
13276 cmdline_fixed_string_t off;
13279 /* Common CLI fields for MACsec offload disable */
13280 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13281 TOKEN_STRING_INITIALIZER
13282 (struct cmd_macsec_offload_off_result,
13284 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13285 TOKEN_STRING_INITIALIZER
13286 (struct cmd_macsec_offload_off_result,
13288 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13289 TOKEN_STRING_INITIALIZER
13290 (struct cmd_macsec_offload_off_result,
13291 offload, "offload");
13292 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13293 TOKEN_NUM_INITIALIZER
13294 (struct cmd_macsec_offload_off_result,
13296 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13297 TOKEN_STRING_INITIALIZER
13298 (struct cmd_macsec_offload_off_result,
13302 cmd_set_macsec_offload_off_parsed(
13303 void *parsed_result,
13304 __attribute__((unused)) struct cmdline *cl,
13305 __attribute__((unused)) void *data)
13307 struct cmd_macsec_offload_off_result *res = parsed_result;
13308 int ret = -ENOTSUP;
13309 struct rte_eth_dev_info dev_info;
13310 portid_t port_id = res->port_id;
13312 if (port_id_is_invalid(port_id, ENABLED_WARN))
13314 if (!port_is_stopped(port_id)) {
13315 printf("Please stop port %d first\n", port_id);
13319 rte_eth_dev_info_get(port_id, &dev_info);
13320 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13321 #ifdef RTE_LIBRTE_IXGBE_PMD
13322 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13327 ports[port_id].dev_conf.txmode.offloads &=
13328 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13329 cmd_reconfig_device_queue(port_id, 1, 1);
13332 printf("invalid port_id %d\n", port_id);
13335 printf("not supported on port %d\n", port_id);
13338 printf("programming error: (%s)\n", strerror(-ret));
13342 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13343 .f = cmd_set_macsec_offload_off_parsed,
13345 .help_str = "set macsec offload <port_id> off",
13347 (void *)&cmd_macsec_offload_off_set,
13348 (void *)&cmd_macsec_offload_off_macsec,
13349 (void *)&cmd_macsec_offload_off_offload,
13350 (void *)&cmd_macsec_offload_off_port_id,
13351 (void *)&cmd_macsec_offload_off_off,
13356 /* Common result structure for MACsec secure connection configure */
13357 struct cmd_macsec_sc_result {
13358 cmdline_fixed_string_t set;
13359 cmdline_fixed_string_t macsec;
13360 cmdline_fixed_string_t sc;
13361 cmdline_fixed_string_t tx_rx;
13363 struct ether_addr mac;
13367 /* Common CLI fields for MACsec secure connection configure */
13368 cmdline_parse_token_string_t cmd_macsec_sc_set =
13369 TOKEN_STRING_INITIALIZER
13370 (struct cmd_macsec_sc_result,
13372 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13373 TOKEN_STRING_INITIALIZER
13374 (struct cmd_macsec_sc_result,
13376 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13377 TOKEN_STRING_INITIALIZER
13378 (struct cmd_macsec_sc_result,
13380 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13381 TOKEN_STRING_INITIALIZER
13382 (struct cmd_macsec_sc_result,
13384 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13385 TOKEN_NUM_INITIALIZER
13386 (struct cmd_macsec_sc_result,
13388 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13389 TOKEN_ETHERADDR_INITIALIZER
13390 (struct cmd_macsec_sc_result,
13392 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13393 TOKEN_NUM_INITIALIZER
13394 (struct cmd_macsec_sc_result,
13398 cmd_set_macsec_sc_parsed(
13399 void *parsed_result,
13400 __attribute__((unused)) struct cmdline *cl,
13401 __attribute__((unused)) void *data)
13403 struct cmd_macsec_sc_result *res = parsed_result;
13404 int ret = -ENOTSUP;
13405 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13407 #ifdef RTE_LIBRTE_IXGBE_PMD
13409 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13410 res->mac.addr_bytes) :
13411 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13412 res->mac.addr_bytes, res->pi);
13414 RTE_SET_USED(is_tx);
13420 printf("invalid port_id %d\n", res->port_id);
13423 printf("not supported on port %d\n", res->port_id);
13426 printf("programming error: (%s)\n", strerror(-ret));
13430 cmdline_parse_inst_t cmd_set_macsec_sc = {
13431 .f = cmd_set_macsec_sc_parsed,
13433 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13435 (void *)&cmd_macsec_sc_set,
13436 (void *)&cmd_macsec_sc_macsec,
13437 (void *)&cmd_macsec_sc_sc,
13438 (void *)&cmd_macsec_sc_tx_rx,
13439 (void *)&cmd_macsec_sc_port_id,
13440 (void *)&cmd_macsec_sc_mac,
13441 (void *)&cmd_macsec_sc_pi,
13446 /* Common result structure for MACsec secure connection configure */
13447 struct cmd_macsec_sa_result {
13448 cmdline_fixed_string_t set;
13449 cmdline_fixed_string_t macsec;
13450 cmdline_fixed_string_t sa;
13451 cmdline_fixed_string_t tx_rx;
13456 cmdline_fixed_string_t key;
13459 /* Common CLI fields for MACsec secure connection configure */
13460 cmdline_parse_token_string_t cmd_macsec_sa_set =
13461 TOKEN_STRING_INITIALIZER
13462 (struct cmd_macsec_sa_result,
13464 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13465 TOKEN_STRING_INITIALIZER
13466 (struct cmd_macsec_sa_result,
13468 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13469 TOKEN_STRING_INITIALIZER
13470 (struct cmd_macsec_sa_result,
13472 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13473 TOKEN_STRING_INITIALIZER
13474 (struct cmd_macsec_sa_result,
13476 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13477 TOKEN_NUM_INITIALIZER
13478 (struct cmd_macsec_sa_result,
13480 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13481 TOKEN_NUM_INITIALIZER
13482 (struct cmd_macsec_sa_result,
13484 cmdline_parse_token_num_t cmd_macsec_sa_an =
13485 TOKEN_NUM_INITIALIZER
13486 (struct cmd_macsec_sa_result,
13488 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13489 TOKEN_NUM_INITIALIZER
13490 (struct cmd_macsec_sa_result,
13492 cmdline_parse_token_string_t cmd_macsec_sa_key =
13493 TOKEN_STRING_INITIALIZER
13494 (struct cmd_macsec_sa_result,
13498 cmd_set_macsec_sa_parsed(
13499 void *parsed_result,
13500 __attribute__((unused)) struct cmdline *cl,
13501 __attribute__((unused)) void *data)
13503 struct cmd_macsec_sa_result *res = parsed_result;
13504 int ret = -ENOTSUP;
13505 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13506 uint8_t key[16] = { 0 };
13512 key_len = strlen(res->key) / 2;
13516 for (i = 0; i < key_len; i++) {
13517 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13520 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13523 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13526 #ifdef RTE_LIBRTE_IXGBE_PMD
13528 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13529 res->idx, res->an, res->pn, key) :
13530 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13531 res->idx, res->an, res->pn, key);
13533 RTE_SET_USED(is_tx);
13540 printf("invalid idx %d or an %d\n", res->idx, res->an);
13543 printf("invalid port_id %d\n", res->port_id);
13546 printf("not supported on port %d\n", res->port_id);
13549 printf("programming error: (%s)\n", strerror(-ret));
13553 cmdline_parse_inst_t cmd_set_macsec_sa = {
13554 .f = cmd_set_macsec_sa_parsed,
13556 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13558 (void *)&cmd_macsec_sa_set,
13559 (void *)&cmd_macsec_sa_macsec,
13560 (void *)&cmd_macsec_sa_sa,
13561 (void *)&cmd_macsec_sa_tx_rx,
13562 (void *)&cmd_macsec_sa_port_id,
13563 (void *)&cmd_macsec_sa_idx,
13564 (void *)&cmd_macsec_sa_an,
13565 (void *)&cmd_macsec_sa_pn,
13566 (void *)&cmd_macsec_sa_key,
13571 /* VF unicast promiscuous mode configuration */
13573 /* Common result structure for VF unicast promiscuous mode */
13574 struct cmd_vf_promisc_result {
13575 cmdline_fixed_string_t set;
13576 cmdline_fixed_string_t vf;
13577 cmdline_fixed_string_t promisc;
13580 cmdline_fixed_string_t on_off;
13583 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13584 cmdline_parse_token_string_t cmd_vf_promisc_set =
13585 TOKEN_STRING_INITIALIZER
13586 (struct cmd_vf_promisc_result,
13588 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13589 TOKEN_STRING_INITIALIZER
13590 (struct cmd_vf_promisc_result,
13592 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13593 TOKEN_STRING_INITIALIZER
13594 (struct cmd_vf_promisc_result,
13595 promisc, "promisc");
13596 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13597 TOKEN_NUM_INITIALIZER
13598 (struct cmd_vf_promisc_result,
13600 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13601 TOKEN_NUM_INITIALIZER
13602 (struct cmd_vf_promisc_result,
13604 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13605 TOKEN_STRING_INITIALIZER
13606 (struct cmd_vf_promisc_result,
13610 cmd_set_vf_promisc_parsed(
13611 void *parsed_result,
13612 __attribute__((unused)) struct cmdline *cl,
13613 __attribute__((unused)) void *data)
13615 struct cmd_vf_promisc_result *res = parsed_result;
13616 int ret = -ENOTSUP;
13618 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13620 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13623 #ifdef RTE_LIBRTE_I40E_PMD
13624 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13625 res->vf_id, is_on);
13632 printf("invalid vf_id %d\n", res->vf_id);
13635 printf("invalid port_id %d\n", res->port_id);
13638 printf("function not implemented\n");
13641 printf("programming error: (%s)\n", strerror(-ret));
13645 cmdline_parse_inst_t cmd_set_vf_promisc = {
13646 .f = cmd_set_vf_promisc_parsed,
13648 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13649 "Set unicast promiscuous mode for a VF from the PF",
13651 (void *)&cmd_vf_promisc_set,
13652 (void *)&cmd_vf_promisc_vf,
13653 (void *)&cmd_vf_promisc_promisc,
13654 (void *)&cmd_vf_promisc_port_id,
13655 (void *)&cmd_vf_promisc_vf_id,
13656 (void *)&cmd_vf_promisc_on_off,
13661 /* VF multicast promiscuous mode configuration */
13663 /* Common result structure for VF multicast promiscuous mode */
13664 struct cmd_vf_allmulti_result {
13665 cmdline_fixed_string_t set;
13666 cmdline_fixed_string_t vf;
13667 cmdline_fixed_string_t allmulti;
13670 cmdline_fixed_string_t on_off;
13673 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13674 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13675 TOKEN_STRING_INITIALIZER
13676 (struct cmd_vf_allmulti_result,
13678 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13679 TOKEN_STRING_INITIALIZER
13680 (struct cmd_vf_allmulti_result,
13682 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13683 TOKEN_STRING_INITIALIZER
13684 (struct cmd_vf_allmulti_result,
13685 allmulti, "allmulti");
13686 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13687 TOKEN_NUM_INITIALIZER
13688 (struct cmd_vf_allmulti_result,
13690 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13691 TOKEN_NUM_INITIALIZER
13692 (struct cmd_vf_allmulti_result,
13694 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13695 TOKEN_STRING_INITIALIZER
13696 (struct cmd_vf_allmulti_result,
13700 cmd_set_vf_allmulti_parsed(
13701 void *parsed_result,
13702 __attribute__((unused)) struct cmdline *cl,
13703 __attribute__((unused)) void *data)
13705 struct cmd_vf_allmulti_result *res = parsed_result;
13706 int ret = -ENOTSUP;
13708 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13710 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13713 #ifdef RTE_LIBRTE_I40E_PMD
13714 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13715 res->vf_id, is_on);
13722 printf("invalid vf_id %d\n", res->vf_id);
13725 printf("invalid port_id %d\n", res->port_id);
13728 printf("function not implemented\n");
13731 printf("programming error: (%s)\n", strerror(-ret));
13735 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13736 .f = cmd_set_vf_allmulti_parsed,
13738 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13739 "Set multicast promiscuous mode for a VF from the PF",
13741 (void *)&cmd_vf_allmulti_set,
13742 (void *)&cmd_vf_allmulti_vf,
13743 (void *)&cmd_vf_allmulti_allmulti,
13744 (void *)&cmd_vf_allmulti_port_id,
13745 (void *)&cmd_vf_allmulti_vf_id,
13746 (void *)&cmd_vf_allmulti_on_off,
13751 /* vf broadcast mode configuration */
13753 /* Common result structure for vf broadcast */
13754 struct cmd_set_vf_broadcast_result {
13755 cmdline_fixed_string_t set;
13756 cmdline_fixed_string_t vf;
13757 cmdline_fixed_string_t broadcast;
13760 cmdline_fixed_string_t on_off;
13763 /* Common CLI fields for vf broadcast enable disable */
13764 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13765 TOKEN_STRING_INITIALIZER
13766 (struct cmd_set_vf_broadcast_result,
13768 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13769 TOKEN_STRING_INITIALIZER
13770 (struct cmd_set_vf_broadcast_result,
13772 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13773 TOKEN_STRING_INITIALIZER
13774 (struct cmd_set_vf_broadcast_result,
13775 broadcast, "broadcast");
13776 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13777 TOKEN_NUM_INITIALIZER
13778 (struct cmd_set_vf_broadcast_result,
13780 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13781 TOKEN_NUM_INITIALIZER
13782 (struct cmd_set_vf_broadcast_result,
13784 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13785 TOKEN_STRING_INITIALIZER
13786 (struct cmd_set_vf_broadcast_result,
13790 cmd_set_vf_broadcast_parsed(
13791 void *parsed_result,
13792 __attribute__((unused)) struct cmdline *cl,
13793 __attribute__((unused)) void *data)
13795 struct cmd_set_vf_broadcast_result *res = parsed_result;
13796 int ret = -ENOTSUP;
13798 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13800 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13803 #ifdef RTE_LIBRTE_I40E_PMD
13804 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13805 res->vf_id, is_on);
13812 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13815 printf("invalid port_id %d\n", res->port_id);
13818 printf("function not implemented\n");
13821 printf("programming error: (%s)\n", strerror(-ret));
13825 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13826 .f = cmd_set_vf_broadcast_parsed,
13828 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13830 (void *)&cmd_set_vf_broadcast_set,
13831 (void *)&cmd_set_vf_broadcast_vf,
13832 (void *)&cmd_set_vf_broadcast_broadcast,
13833 (void *)&cmd_set_vf_broadcast_port_id,
13834 (void *)&cmd_set_vf_broadcast_vf_id,
13835 (void *)&cmd_set_vf_broadcast_on_off,
13840 /* vf vlan tag configuration */
13842 /* Common result structure for vf vlan tag */
13843 struct cmd_set_vf_vlan_tag_result {
13844 cmdline_fixed_string_t set;
13845 cmdline_fixed_string_t vf;
13846 cmdline_fixed_string_t vlan;
13847 cmdline_fixed_string_t tag;
13850 cmdline_fixed_string_t on_off;
13853 /* Common CLI fields for vf vlan tag enable disable */
13854 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13855 TOKEN_STRING_INITIALIZER
13856 (struct cmd_set_vf_vlan_tag_result,
13858 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13859 TOKEN_STRING_INITIALIZER
13860 (struct cmd_set_vf_vlan_tag_result,
13862 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13863 TOKEN_STRING_INITIALIZER
13864 (struct cmd_set_vf_vlan_tag_result,
13866 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13867 TOKEN_STRING_INITIALIZER
13868 (struct cmd_set_vf_vlan_tag_result,
13870 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13871 TOKEN_NUM_INITIALIZER
13872 (struct cmd_set_vf_vlan_tag_result,
13874 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13875 TOKEN_NUM_INITIALIZER
13876 (struct cmd_set_vf_vlan_tag_result,
13878 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13879 TOKEN_STRING_INITIALIZER
13880 (struct cmd_set_vf_vlan_tag_result,
13884 cmd_set_vf_vlan_tag_parsed(
13885 void *parsed_result,
13886 __attribute__((unused)) struct cmdline *cl,
13887 __attribute__((unused)) void *data)
13889 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13890 int ret = -ENOTSUP;
13892 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13894 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13897 #ifdef RTE_LIBRTE_I40E_PMD
13898 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13899 res->vf_id, is_on);
13906 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13909 printf("invalid port_id %d\n", res->port_id);
13912 printf("function not implemented\n");
13915 printf("programming error: (%s)\n", strerror(-ret));
13919 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13920 .f = cmd_set_vf_vlan_tag_parsed,
13922 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13924 (void *)&cmd_set_vf_vlan_tag_set,
13925 (void *)&cmd_set_vf_vlan_tag_vf,
13926 (void *)&cmd_set_vf_vlan_tag_vlan,
13927 (void *)&cmd_set_vf_vlan_tag_tag,
13928 (void *)&cmd_set_vf_vlan_tag_port_id,
13929 (void *)&cmd_set_vf_vlan_tag_vf_id,
13930 (void *)&cmd_set_vf_vlan_tag_on_off,
13935 /* Common definition of VF and TC TX bandwidth configuration */
13936 struct cmd_vf_tc_bw_result {
13937 cmdline_fixed_string_t set;
13938 cmdline_fixed_string_t vf;
13939 cmdline_fixed_string_t tc;
13940 cmdline_fixed_string_t tx;
13941 cmdline_fixed_string_t min_bw;
13942 cmdline_fixed_string_t max_bw;
13943 cmdline_fixed_string_t strict_link_prio;
13948 cmdline_fixed_string_t bw_list;
13952 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13953 TOKEN_STRING_INITIALIZER
13954 (struct cmd_vf_tc_bw_result,
13956 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13957 TOKEN_STRING_INITIALIZER
13958 (struct cmd_vf_tc_bw_result,
13960 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13961 TOKEN_STRING_INITIALIZER
13962 (struct cmd_vf_tc_bw_result,
13964 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13965 TOKEN_STRING_INITIALIZER
13966 (struct cmd_vf_tc_bw_result,
13968 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13969 TOKEN_STRING_INITIALIZER
13970 (struct cmd_vf_tc_bw_result,
13971 strict_link_prio, "strict-link-priority");
13972 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13973 TOKEN_STRING_INITIALIZER
13974 (struct cmd_vf_tc_bw_result,
13975 min_bw, "min-bandwidth");
13976 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13977 TOKEN_STRING_INITIALIZER
13978 (struct cmd_vf_tc_bw_result,
13979 max_bw, "max-bandwidth");
13980 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13981 TOKEN_NUM_INITIALIZER
13982 (struct cmd_vf_tc_bw_result,
13984 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13985 TOKEN_NUM_INITIALIZER
13986 (struct cmd_vf_tc_bw_result,
13988 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13989 TOKEN_NUM_INITIALIZER
13990 (struct cmd_vf_tc_bw_result,
13992 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13993 TOKEN_NUM_INITIALIZER
13994 (struct cmd_vf_tc_bw_result,
13996 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13997 TOKEN_STRING_INITIALIZER
13998 (struct cmd_vf_tc_bw_result,
14000 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14001 TOKEN_NUM_INITIALIZER
14002 (struct cmd_vf_tc_bw_result,
14005 /* VF max bandwidth setting */
14007 cmd_vf_max_bw_parsed(
14008 void *parsed_result,
14009 __attribute__((unused)) struct cmdline *cl,
14010 __attribute__((unused)) void *data)
14012 struct cmd_vf_tc_bw_result *res = parsed_result;
14013 int ret = -ENOTSUP;
14015 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14018 #ifdef RTE_LIBRTE_I40E_PMD
14019 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14020 res->vf_id, res->bw);
14027 printf("invalid vf_id %d or bandwidth %d\n",
14028 res->vf_id, res->bw);
14031 printf("invalid port_id %d\n", res->port_id);
14034 printf("function not implemented\n");
14037 printf("programming error: (%s)\n", strerror(-ret));
14041 cmdline_parse_inst_t cmd_vf_max_bw = {
14042 .f = cmd_vf_max_bw_parsed,
14044 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14046 (void *)&cmd_vf_tc_bw_set,
14047 (void *)&cmd_vf_tc_bw_vf,
14048 (void *)&cmd_vf_tc_bw_tx,
14049 (void *)&cmd_vf_tc_bw_max_bw,
14050 (void *)&cmd_vf_tc_bw_port_id,
14051 (void *)&cmd_vf_tc_bw_vf_id,
14052 (void *)&cmd_vf_tc_bw_bw,
14058 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14063 const char *p, *p0 = str;
14070 p = strchr(p0, '(');
14072 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14076 p0 = strchr(p, ')');
14078 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14082 if (size >= sizeof(s)) {
14083 printf("The string size exceeds the internal buffer size\n");
14086 snprintf(s, sizeof(s), "%.*s", size, p);
14087 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14089 printf("Failed to get the bandwidth list. ");
14093 for (i = 0; i < ret; i++)
14094 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14099 /* TC min bandwidth setting */
14101 cmd_vf_tc_min_bw_parsed(
14102 void *parsed_result,
14103 __attribute__((unused)) struct cmdline *cl,
14104 __attribute__((unused)) void *data)
14106 struct cmd_vf_tc_bw_result *res = parsed_result;
14109 int ret = -ENOTSUP;
14111 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14114 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14118 #ifdef RTE_LIBRTE_I40E_PMD
14119 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14127 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14130 printf("invalid port_id %d\n", res->port_id);
14133 printf("function not implemented\n");
14136 printf("programming error: (%s)\n", strerror(-ret));
14140 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14141 .f = cmd_vf_tc_min_bw_parsed,
14143 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14144 " <bw1, bw2, ...>",
14146 (void *)&cmd_vf_tc_bw_set,
14147 (void *)&cmd_vf_tc_bw_vf,
14148 (void *)&cmd_vf_tc_bw_tc,
14149 (void *)&cmd_vf_tc_bw_tx,
14150 (void *)&cmd_vf_tc_bw_min_bw,
14151 (void *)&cmd_vf_tc_bw_port_id,
14152 (void *)&cmd_vf_tc_bw_vf_id,
14153 (void *)&cmd_vf_tc_bw_bw_list,
14159 cmd_tc_min_bw_parsed(
14160 void *parsed_result,
14161 __attribute__((unused)) struct cmdline *cl,
14162 __attribute__((unused)) void *data)
14164 struct cmd_vf_tc_bw_result *res = parsed_result;
14165 struct rte_port *port;
14168 int ret = -ENOTSUP;
14170 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14173 port = &ports[res->port_id];
14174 /** Check if the port is not started **/
14175 if (port->port_status != RTE_PORT_STOPPED) {
14176 printf("Please stop port %d first\n", res->port_id);
14180 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14184 #ifdef RTE_LIBRTE_IXGBE_PMD
14185 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14192 printf("invalid bandwidth\n");
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_tc_min_bw = {
14206 .f = cmd_tc_min_bw_parsed,
14208 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14210 (void *)&cmd_vf_tc_bw_set,
14211 (void *)&cmd_vf_tc_bw_tc,
14212 (void *)&cmd_vf_tc_bw_tx,
14213 (void *)&cmd_vf_tc_bw_min_bw,
14214 (void *)&cmd_vf_tc_bw_port_id,
14215 (void *)&cmd_vf_tc_bw_bw_list,
14220 /* TC max bandwidth setting */
14222 cmd_vf_tc_max_bw_parsed(
14223 void *parsed_result,
14224 __attribute__((unused)) struct cmdline *cl,
14225 __attribute__((unused)) void *data)
14227 struct cmd_vf_tc_bw_result *res = parsed_result;
14228 int ret = -ENOTSUP;
14230 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14233 #ifdef RTE_LIBRTE_I40E_PMD
14234 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14235 res->tc_no, res->bw);
14242 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14243 res->vf_id, res->tc_no, res->bw);
14246 printf("invalid port_id %d\n", res->port_id);
14249 printf("function not implemented\n");
14252 printf("programming error: (%s)\n", strerror(-ret));
14256 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14257 .f = cmd_vf_tc_max_bw_parsed,
14259 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14262 (void *)&cmd_vf_tc_bw_set,
14263 (void *)&cmd_vf_tc_bw_vf,
14264 (void *)&cmd_vf_tc_bw_tc,
14265 (void *)&cmd_vf_tc_bw_tx,
14266 (void *)&cmd_vf_tc_bw_max_bw,
14267 (void *)&cmd_vf_tc_bw_port_id,
14268 (void *)&cmd_vf_tc_bw_vf_id,
14269 (void *)&cmd_vf_tc_bw_tc_no,
14270 (void *)&cmd_vf_tc_bw_bw,
14276 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14278 /* *** Set Port default Traffic Management Hierarchy *** */
14279 struct cmd_set_port_tm_hierarchy_default_result {
14280 cmdline_fixed_string_t set;
14281 cmdline_fixed_string_t port;
14282 cmdline_fixed_string_t tm;
14283 cmdline_fixed_string_t hierarchy;
14284 cmdline_fixed_string_t def;
14288 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14289 TOKEN_STRING_INITIALIZER(
14290 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14291 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14292 TOKEN_STRING_INITIALIZER(
14293 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14294 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14295 TOKEN_STRING_INITIALIZER(
14296 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14297 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14298 TOKEN_STRING_INITIALIZER(
14299 struct cmd_set_port_tm_hierarchy_default_result,
14300 hierarchy, "hierarchy");
14301 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14302 TOKEN_STRING_INITIALIZER(
14303 struct cmd_set_port_tm_hierarchy_default_result,
14305 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14306 TOKEN_NUM_INITIALIZER(
14307 struct cmd_set_port_tm_hierarchy_default_result,
14310 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14311 __attribute__((unused)) struct cmdline *cl,
14312 __attribute__((unused)) void *data)
14314 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14315 struct rte_port *p;
14316 portid_t port_id = res->port_id;
14318 if (port_id_is_invalid(port_id, ENABLED_WARN))
14321 p = &ports[port_id];
14324 if (p->softport.tm_flag == 0) {
14325 printf(" tm not enabled on port %u (error)\n", port_id);
14329 /* Forward mode: tm */
14330 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14331 printf(" tm mode not enabled(error)\n");
14335 /* Set the default tm hierarchy */
14336 p->softport.tm.default_hierarchy_enable = 1;
14339 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14340 .f = cmd_set_port_tm_hierarchy_default_parsed,
14342 .help_str = "set port tm hierarchy default <port_id>",
14344 (void *)&cmd_set_port_tm_hierarchy_default_set,
14345 (void *)&cmd_set_port_tm_hierarchy_default_port,
14346 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14347 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14348 (void *)&cmd_set_port_tm_hierarchy_default_default,
14349 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14355 /* Strict link priority scheduling mode setting */
14357 cmd_strict_link_prio_parsed(
14358 void *parsed_result,
14359 __attribute__((unused)) struct cmdline *cl,
14360 __attribute__((unused)) void *data)
14362 struct cmd_vf_tc_bw_result *res = parsed_result;
14363 int ret = -ENOTSUP;
14365 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14368 #ifdef RTE_LIBRTE_I40E_PMD
14369 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14376 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14379 printf("invalid port_id %d\n", res->port_id);
14382 printf("function not implemented\n");
14385 printf("programming error: (%s)\n", strerror(-ret));
14389 cmdline_parse_inst_t cmd_strict_link_prio = {
14390 .f = cmd_strict_link_prio_parsed,
14392 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14394 (void *)&cmd_vf_tc_bw_set,
14395 (void *)&cmd_vf_tc_bw_tx,
14396 (void *)&cmd_vf_tc_bw_strict_link_prio,
14397 (void *)&cmd_vf_tc_bw_port_id,
14398 (void *)&cmd_vf_tc_bw_tc_map,
14403 /* Load dynamic device personalization*/
14404 struct cmd_ddp_add_result {
14405 cmdline_fixed_string_t ddp;
14406 cmdline_fixed_string_t add;
14411 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14412 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14413 cmdline_parse_token_string_t cmd_ddp_add_add =
14414 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14415 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14416 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14417 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14418 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14421 cmd_ddp_add_parsed(
14422 void *parsed_result,
14423 __attribute__((unused)) struct cmdline *cl,
14424 __attribute__((unused)) void *data)
14426 struct cmd_ddp_add_result *res = parsed_result;
14432 int ret = -ENOTSUP;
14434 if (res->port_id > nb_ports) {
14435 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14439 if (!all_ports_stopped()) {
14440 printf("Please stop all ports first\n");
14444 filepath = strdup(res->filepath);
14445 if (filepath == NULL) {
14446 printf("Failed to allocate memory\n");
14449 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14451 buff = open_file(file_fld[0], &size);
14453 free((void *)filepath);
14457 #ifdef RTE_LIBRTE_I40E_PMD
14458 if (ret == -ENOTSUP)
14459 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14461 RTE_PMD_I40E_PKG_OP_WR_ADD);
14464 if (ret == -EEXIST)
14465 printf("Profile has already existed.\n");
14467 printf("Failed to load profile.\n");
14468 else if (file_num == 2)
14469 save_file(file_fld[1], buff, size);
14472 free((void *)filepath);
14475 cmdline_parse_inst_t cmd_ddp_add = {
14476 .f = cmd_ddp_add_parsed,
14478 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14480 (void *)&cmd_ddp_add_ddp,
14481 (void *)&cmd_ddp_add_add,
14482 (void *)&cmd_ddp_add_port_id,
14483 (void *)&cmd_ddp_add_filepath,
14488 /* Delete dynamic device personalization*/
14489 struct cmd_ddp_del_result {
14490 cmdline_fixed_string_t ddp;
14491 cmdline_fixed_string_t del;
14496 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14497 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14498 cmdline_parse_token_string_t cmd_ddp_del_del =
14499 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14500 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14501 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14502 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14503 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14506 cmd_ddp_del_parsed(
14507 void *parsed_result,
14508 __attribute__((unused)) struct cmdline *cl,
14509 __attribute__((unused)) void *data)
14511 struct cmd_ddp_del_result *res = parsed_result;
14514 int ret = -ENOTSUP;
14516 if (res->port_id > nb_ports) {
14517 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14521 if (!all_ports_stopped()) {
14522 printf("Please stop all ports first\n");
14526 buff = open_file(res->filepath, &size);
14530 #ifdef RTE_LIBRTE_I40E_PMD
14531 if (ret == -ENOTSUP)
14532 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14534 RTE_PMD_I40E_PKG_OP_WR_DEL);
14537 if (ret == -EACCES)
14538 printf("Profile does not exist.\n");
14540 printf("Failed to delete profile.\n");
14545 cmdline_parse_inst_t cmd_ddp_del = {
14546 .f = cmd_ddp_del_parsed,
14548 .help_str = "ddp del <port_id> <profile_path>",
14550 (void *)&cmd_ddp_del_ddp,
14551 (void *)&cmd_ddp_del_del,
14552 (void *)&cmd_ddp_del_port_id,
14553 (void *)&cmd_ddp_del_filepath,
14558 /* Get dynamic device personalization profile info */
14559 struct cmd_ddp_info_result {
14560 cmdline_fixed_string_t ddp;
14561 cmdline_fixed_string_t get;
14562 cmdline_fixed_string_t info;
14566 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14567 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14568 cmdline_parse_token_string_t cmd_ddp_info_get =
14569 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14570 cmdline_parse_token_string_t cmd_ddp_info_info =
14571 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14572 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14573 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14576 cmd_ddp_info_parsed(
14577 void *parsed_result,
14578 __attribute__((unused)) struct cmdline *cl,
14579 __attribute__((unused)) void *data)
14581 struct cmd_ddp_info_result *res = parsed_result;
14584 int ret = -ENOTSUP;
14585 #ifdef RTE_LIBRTE_I40E_PMD
14588 uint32_t buff_size = 0;
14589 struct rte_pmd_i40e_profile_info info;
14590 uint32_t dev_num = 0;
14591 struct rte_pmd_i40e_ddp_device_id *devs;
14592 uint32_t proto_num = 0;
14593 struct rte_pmd_i40e_proto_info *proto = NULL;
14594 uint32_t pctype_num = 0;
14595 struct rte_pmd_i40e_ptype_info *pctype;
14596 uint32_t ptype_num = 0;
14597 struct rte_pmd_i40e_ptype_info *ptype;
14602 pkg = open_file(res->filepath, &pkg_size);
14606 #ifdef RTE_LIBRTE_I40E_PMD
14607 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14608 (uint8_t *)&info, sizeof(info),
14609 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14611 printf("Global Track id: 0x%x\n", info.track_id);
14612 printf("Global Version: %d.%d.%d.%d\n",
14613 info.version.major,
14614 info.version.minor,
14615 info.version.update,
14616 info.version.draft);
14617 printf("Global Package name: %s\n\n", info.name);
14620 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14621 (uint8_t *)&info, sizeof(info),
14622 RTE_PMD_I40E_PKG_INFO_HEADER);
14624 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14625 printf("i40e Profile Version: %d.%d.%d.%d\n",
14626 info.version.major,
14627 info.version.minor,
14628 info.version.update,
14629 info.version.draft);
14630 printf("i40e Profile name: %s\n\n", info.name);
14633 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14634 (uint8_t *)&buff_size, sizeof(buff_size),
14635 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14636 if (!ret && buff_size) {
14637 buff = (uint8_t *)malloc(buff_size);
14639 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14641 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14643 printf("Package Notes:\n%s\n\n", buff);
14648 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14649 (uint8_t *)&dev_num, sizeof(dev_num),
14650 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14651 if (!ret && dev_num) {
14652 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14653 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14655 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14656 (uint8_t *)devs, buff_size,
14657 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14659 printf("List of supported devices:\n");
14660 for (i = 0; i < dev_num; i++) {
14661 printf(" %04X:%04X %04X:%04X\n",
14662 devs[i].vendor_dev_id >> 16,
14663 devs[i].vendor_dev_id & 0xFFFF,
14664 devs[i].sub_vendor_dev_id >> 16,
14665 devs[i].sub_vendor_dev_id & 0xFFFF);
14673 /* get information about protocols and packet types */
14674 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14675 (uint8_t *)&proto_num, sizeof(proto_num),
14676 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14677 if (ret || !proto_num)
14678 goto no_print_return;
14680 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14681 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14683 goto no_print_return;
14685 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14687 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14689 printf("List of used protocols:\n");
14690 for (i = 0; i < proto_num; i++)
14691 printf(" %2u: %s\n", proto[i].proto_id,
14695 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14696 (uint8_t *)&pctype_num, sizeof(pctype_num),
14697 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14698 if (ret || !pctype_num)
14699 goto no_print_pctypes;
14701 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14702 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14704 goto no_print_pctypes;
14706 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14708 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14711 goto no_print_pctypes;
14714 printf("List of defined packet classification types:\n");
14715 for (i = 0; i < pctype_num; i++) {
14716 printf(" %2u:", pctype[i].ptype_id);
14717 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14718 proto_id = pctype[i].protocols[j];
14719 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14720 for (n = 0; n < proto_num; n++) {
14721 if (proto[n].proto_id == proto_id) {
14722 printf(" %s", proto[n].name);
14735 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14737 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14738 if (ret || !ptype_num)
14739 goto no_print_return;
14741 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14742 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14744 goto no_print_return;
14746 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14748 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14751 goto no_print_return;
14753 printf("List of defined packet types:\n");
14754 for (i = 0; i < ptype_num; i++) {
14755 printf(" %2u:", ptype[i].ptype_id);
14756 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14757 proto_id = ptype[i].protocols[j];
14758 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14759 for (n = 0; n < proto_num; n++) {
14760 if (proto[n].proto_id == proto_id) {
14761 printf(" %s", proto[n].name);
14777 if (ret == -ENOTSUP)
14778 printf("Function not supported in PMD driver\n");
14782 cmdline_parse_inst_t cmd_ddp_get_info = {
14783 .f = cmd_ddp_info_parsed,
14785 .help_str = "ddp get info <profile_path>",
14787 (void *)&cmd_ddp_info_ddp,
14788 (void *)&cmd_ddp_info_get,
14789 (void *)&cmd_ddp_info_info,
14790 (void *)&cmd_ddp_info_filepath,
14795 /* Get dynamic device personalization profile info list*/
14796 #define PROFILE_INFO_SIZE 48
14797 #define MAX_PROFILE_NUM 16
14799 struct cmd_ddp_get_list_result {
14800 cmdline_fixed_string_t ddp;
14801 cmdline_fixed_string_t get;
14802 cmdline_fixed_string_t list;
14806 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14807 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14808 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14809 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14810 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14811 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14812 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14813 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14816 cmd_ddp_get_list_parsed(
14817 void *parsed_result,
14818 __attribute__((unused)) struct cmdline *cl,
14819 __attribute__((unused)) void *data)
14821 struct cmd_ddp_get_list_result *res = parsed_result;
14822 #ifdef RTE_LIBRTE_I40E_PMD
14823 struct rte_pmd_i40e_profile_list *p_list;
14824 struct rte_pmd_i40e_profile_info *p_info;
14829 int ret = -ENOTSUP;
14831 if (res->port_id > nb_ports) {
14832 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14836 #ifdef RTE_LIBRTE_I40E_PMD
14837 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14838 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14840 printf("%s: Failed to malloc buffer\n", __func__);
14842 if (ret == -ENOTSUP)
14843 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14844 (uint8_t *)p_list, size);
14847 p_num = p_list->p_count;
14848 printf("Profile number is: %d\n\n", p_num);
14850 for (i = 0; i < p_num; i++) {
14851 p_info = &p_list->p_info[i];
14852 printf("Profile %d:\n", i);
14853 printf("Track id: 0x%x\n", p_info->track_id);
14854 printf("Version: %d.%d.%d.%d\n",
14855 p_info->version.major,
14856 p_info->version.minor,
14857 p_info->version.update,
14858 p_info->version.draft);
14859 printf("Profile name: %s\n\n", p_info->name);
14867 printf("Failed to get ddp list\n");
14870 cmdline_parse_inst_t cmd_ddp_get_list = {
14871 .f = cmd_ddp_get_list_parsed,
14873 .help_str = "ddp get list <port_id>",
14875 (void *)&cmd_ddp_get_list_ddp,
14876 (void *)&cmd_ddp_get_list_get,
14877 (void *)&cmd_ddp_get_list_list,
14878 (void *)&cmd_ddp_get_list_port_id,
14883 /* show vf stats */
14885 /* Common result structure for show vf stats */
14886 struct cmd_show_vf_stats_result {
14887 cmdline_fixed_string_t show;
14888 cmdline_fixed_string_t vf;
14889 cmdline_fixed_string_t stats;
14894 /* Common CLI fields show vf stats*/
14895 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14896 TOKEN_STRING_INITIALIZER
14897 (struct cmd_show_vf_stats_result,
14899 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14900 TOKEN_STRING_INITIALIZER
14901 (struct cmd_show_vf_stats_result,
14903 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14904 TOKEN_STRING_INITIALIZER
14905 (struct cmd_show_vf_stats_result,
14907 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14908 TOKEN_NUM_INITIALIZER
14909 (struct cmd_show_vf_stats_result,
14911 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14912 TOKEN_NUM_INITIALIZER
14913 (struct cmd_show_vf_stats_result,
14917 cmd_show_vf_stats_parsed(
14918 void *parsed_result,
14919 __attribute__((unused)) struct cmdline *cl,
14920 __attribute__((unused)) void *data)
14922 struct cmd_show_vf_stats_result *res = parsed_result;
14923 struct rte_eth_stats stats;
14924 int ret = -ENOTSUP;
14925 static const char *nic_stats_border = "########################";
14927 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14930 memset(&stats, 0, sizeof(stats));
14932 #ifdef RTE_LIBRTE_I40E_PMD
14933 if (ret == -ENOTSUP)
14934 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14938 #ifdef RTE_LIBRTE_BNXT_PMD
14939 if (ret == -ENOTSUP)
14940 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14949 printf("invalid vf_id %d\n", res->vf_id);
14952 printf("invalid port_id %d\n", res->port_id);
14955 printf("function not implemented\n");
14958 printf("programming error: (%s)\n", strerror(-ret));
14961 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14962 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14964 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14966 stats.ipackets, stats.imissed, stats.ibytes);
14967 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14968 printf(" RX-nombuf: %-10"PRIu64"\n",
14970 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14972 stats.opackets, stats.oerrors, stats.obytes);
14974 printf(" %s############################%s\n",
14975 nic_stats_border, nic_stats_border);
14978 cmdline_parse_inst_t cmd_show_vf_stats = {
14979 .f = cmd_show_vf_stats_parsed,
14981 .help_str = "show vf stats <port_id> <vf_id>",
14983 (void *)&cmd_show_vf_stats_show,
14984 (void *)&cmd_show_vf_stats_vf,
14985 (void *)&cmd_show_vf_stats_stats,
14986 (void *)&cmd_show_vf_stats_port_id,
14987 (void *)&cmd_show_vf_stats_vf_id,
14992 /* clear vf stats */
14994 /* Common result structure for clear vf stats */
14995 struct cmd_clear_vf_stats_result {
14996 cmdline_fixed_string_t clear;
14997 cmdline_fixed_string_t vf;
14998 cmdline_fixed_string_t stats;
15003 /* Common CLI fields clear vf stats*/
15004 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15005 TOKEN_STRING_INITIALIZER
15006 (struct cmd_clear_vf_stats_result,
15008 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15009 TOKEN_STRING_INITIALIZER
15010 (struct cmd_clear_vf_stats_result,
15012 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15013 TOKEN_STRING_INITIALIZER
15014 (struct cmd_clear_vf_stats_result,
15016 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15017 TOKEN_NUM_INITIALIZER
15018 (struct cmd_clear_vf_stats_result,
15020 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15021 TOKEN_NUM_INITIALIZER
15022 (struct cmd_clear_vf_stats_result,
15026 cmd_clear_vf_stats_parsed(
15027 void *parsed_result,
15028 __attribute__((unused)) struct cmdline *cl,
15029 __attribute__((unused)) void *data)
15031 struct cmd_clear_vf_stats_result *res = parsed_result;
15032 int ret = -ENOTSUP;
15034 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15037 #ifdef RTE_LIBRTE_I40E_PMD
15038 if (ret == -ENOTSUP)
15039 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15042 #ifdef RTE_LIBRTE_BNXT_PMD
15043 if (ret == -ENOTSUP)
15044 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15052 printf("invalid vf_id %d\n", res->vf_id);
15055 printf("invalid port_id %d\n", res->port_id);
15058 printf("function not implemented\n");
15061 printf("programming error: (%s)\n", strerror(-ret));
15065 cmdline_parse_inst_t cmd_clear_vf_stats = {
15066 .f = cmd_clear_vf_stats_parsed,
15068 .help_str = "clear vf stats <port_id> <vf_id>",
15070 (void *)&cmd_clear_vf_stats_clear,
15071 (void *)&cmd_clear_vf_stats_vf,
15072 (void *)&cmd_clear_vf_stats_stats,
15073 (void *)&cmd_clear_vf_stats_port_id,
15074 (void *)&cmd_clear_vf_stats_vf_id,
15079 /* port config pctype mapping reset */
15081 /* Common result structure for port config pctype mapping reset */
15082 struct cmd_pctype_mapping_reset_result {
15083 cmdline_fixed_string_t port;
15084 cmdline_fixed_string_t config;
15086 cmdline_fixed_string_t pctype;
15087 cmdline_fixed_string_t mapping;
15088 cmdline_fixed_string_t reset;
15091 /* Common CLI fields for port config pctype mapping reset*/
15092 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15093 TOKEN_STRING_INITIALIZER
15094 (struct cmd_pctype_mapping_reset_result,
15096 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15097 TOKEN_STRING_INITIALIZER
15098 (struct cmd_pctype_mapping_reset_result,
15100 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15101 TOKEN_NUM_INITIALIZER
15102 (struct cmd_pctype_mapping_reset_result,
15104 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15105 TOKEN_STRING_INITIALIZER
15106 (struct cmd_pctype_mapping_reset_result,
15108 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15109 TOKEN_STRING_INITIALIZER
15110 (struct cmd_pctype_mapping_reset_result,
15111 mapping, "mapping");
15112 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15113 TOKEN_STRING_INITIALIZER
15114 (struct cmd_pctype_mapping_reset_result,
15118 cmd_pctype_mapping_reset_parsed(
15119 void *parsed_result,
15120 __attribute__((unused)) struct cmdline *cl,
15121 __attribute__((unused)) void *data)
15123 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15124 int ret = -ENOTSUP;
15126 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15129 #ifdef RTE_LIBRTE_I40E_PMD
15130 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15137 printf("invalid port_id %d\n", res->port_id);
15140 printf("function not implemented\n");
15143 printf("programming error: (%s)\n", strerror(-ret));
15147 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15148 .f = cmd_pctype_mapping_reset_parsed,
15150 .help_str = "port config <port_id> pctype mapping reset",
15152 (void *)&cmd_pctype_mapping_reset_port,
15153 (void *)&cmd_pctype_mapping_reset_config,
15154 (void *)&cmd_pctype_mapping_reset_port_id,
15155 (void *)&cmd_pctype_mapping_reset_pctype,
15156 (void *)&cmd_pctype_mapping_reset_mapping,
15157 (void *)&cmd_pctype_mapping_reset_reset,
15162 /* show port pctype mapping */
15164 /* Common result structure for show port pctype mapping */
15165 struct cmd_pctype_mapping_get_result {
15166 cmdline_fixed_string_t show;
15167 cmdline_fixed_string_t port;
15169 cmdline_fixed_string_t pctype;
15170 cmdline_fixed_string_t mapping;
15173 /* Common CLI fields for pctype mapping get */
15174 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15175 TOKEN_STRING_INITIALIZER
15176 (struct cmd_pctype_mapping_get_result,
15178 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15179 TOKEN_STRING_INITIALIZER
15180 (struct cmd_pctype_mapping_get_result,
15182 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15183 TOKEN_NUM_INITIALIZER
15184 (struct cmd_pctype_mapping_get_result,
15186 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15187 TOKEN_STRING_INITIALIZER
15188 (struct cmd_pctype_mapping_get_result,
15190 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15191 TOKEN_STRING_INITIALIZER
15192 (struct cmd_pctype_mapping_get_result,
15193 mapping, "mapping");
15196 cmd_pctype_mapping_get_parsed(
15197 void *parsed_result,
15198 __attribute__((unused)) struct cmdline *cl,
15199 __attribute__((unused)) void *data)
15201 struct cmd_pctype_mapping_get_result *res = parsed_result;
15202 int ret = -ENOTSUP;
15203 #ifdef RTE_LIBRTE_I40E_PMD
15204 struct rte_pmd_i40e_flow_type_mapping
15205 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15206 int i, j, first_pctype;
15209 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15212 #ifdef RTE_LIBRTE_I40E_PMD
15213 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15220 printf("invalid port_id %d\n", res->port_id);
15223 printf("function not implemented\n");
15226 printf("programming error: (%s)\n", strerror(-ret));
15230 #ifdef RTE_LIBRTE_I40E_PMD
15231 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15232 if (mapping[i].pctype != 0ULL) {
15235 printf("pctype: ");
15236 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15237 if (mapping[i].pctype & (1ULL << j)) {
15238 printf(first_pctype ?
15239 "%02d" : ",%02d", j);
15243 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15249 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15250 .f = cmd_pctype_mapping_get_parsed,
15252 .help_str = "show port <port_id> pctype mapping",
15254 (void *)&cmd_pctype_mapping_get_show,
15255 (void *)&cmd_pctype_mapping_get_port,
15256 (void *)&cmd_pctype_mapping_get_port_id,
15257 (void *)&cmd_pctype_mapping_get_pctype,
15258 (void *)&cmd_pctype_mapping_get_mapping,
15263 /* port config pctype mapping update */
15265 /* Common result structure for port config pctype mapping update */
15266 struct cmd_pctype_mapping_update_result {
15267 cmdline_fixed_string_t port;
15268 cmdline_fixed_string_t config;
15270 cmdline_fixed_string_t pctype;
15271 cmdline_fixed_string_t mapping;
15272 cmdline_fixed_string_t update;
15273 cmdline_fixed_string_t pctype_list;
15274 uint16_t flow_type;
15277 /* Common CLI fields for pctype mapping update*/
15278 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15279 TOKEN_STRING_INITIALIZER
15280 (struct cmd_pctype_mapping_update_result,
15282 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15283 TOKEN_STRING_INITIALIZER
15284 (struct cmd_pctype_mapping_update_result,
15286 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15287 TOKEN_NUM_INITIALIZER
15288 (struct cmd_pctype_mapping_update_result,
15290 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15291 TOKEN_STRING_INITIALIZER
15292 (struct cmd_pctype_mapping_update_result,
15294 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15295 TOKEN_STRING_INITIALIZER
15296 (struct cmd_pctype_mapping_update_result,
15297 mapping, "mapping");
15298 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15299 TOKEN_STRING_INITIALIZER
15300 (struct cmd_pctype_mapping_update_result,
15302 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15303 TOKEN_STRING_INITIALIZER
15304 (struct cmd_pctype_mapping_update_result,
15305 pctype_list, NULL);
15306 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15307 TOKEN_NUM_INITIALIZER
15308 (struct cmd_pctype_mapping_update_result,
15309 flow_type, UINT16);
15312 cmd_pctype_mapping_update_parsed(
15313 void *parsed_result,
15314 __attribute__((unused)) struct cmdline *cl,
15315 __attribute__((unused)) void *data)
15317 struct cmd_pctype_mapping_update_result *res = parsed_result;
15318 int ret = -ENOTSUP;
15319 #ifdef RTE_LIBRTE_I40E_PMD
15320 struct rte_pmd_i40e_flow_type_mapping mapping;
15322 unsigned int nb_item;
15323 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15326 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15329 #ifdef RTE_LIBRTE_I40E_PMD
15330 nb_item = parse_item_list(res->pctype_list, "pctypes",
15331 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15332 mapping.flow_type = res->flow_type;
15333 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15334 mapping.pctype |= (1ULL << pctype_list[i]);
15335 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15345 printf("invalid pctype or flow type\n");
15348 printf("invalid port_id %d\n", res->port_id);
15351 printf("function not implemented\n");
15354 printf("programming error: (%s)\n", strerror(-ret));
15358 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15359 .f = cmd_pctype_mapping_update_parsed,
15361 .help_str = "port config <port_id> pctype mapping update"
15362 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15364 (void *)&cmd_pctype_mapping_update_port,
15365 (void *)&cmd_pctype_mapping_update_config,
15366 (void *)&cmd_pctype_mapping_update_port_id,
15367 (void *)&cmd_pctype_mapping_update_pctype,
15368 (void *)&cmd_pctype_mapping_update_mapping,
15369 (void *)&cmd_pctype_mapping_update_update,
15370 (void *)&cmd_pctype_mapping_update_pc_type,
15371 (void *)&cmd_pctype_mapping_update_flow_type,
15376 /* ptype mapping get */
15378 /* Common result structure for ptype mapping get */
15379 struct cmd_ptype_mapping_get_result {
15380 cmdline_fixed_string_t ptype;
15381 cmdline_fixed_string_t mapping;
15382 cmdline_fixed_string_t get;
15384 uint8_t valid_only;
15387 /* Common CLI fields for ptype mapping get */
15388 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15389 TOKEN_STRING_INITIALIZER
15390 (struct cmd_ptype_mapping_get_result,
15392 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15393 TOKEN_STRING_INITIALIZER
15394 (struct cmd_ptype_mapping_get_result,
15395 mapping, "mapping");
15396 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15397 TOKEN_STRING_INITIALIZER
15398 (struct cmd_ptype_mapping_get_result,
15400 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15401 TOKEN_NUM_INITIALIZER
15402 (struct cmd_ptype_mapping_get_result,
15404 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15405 TOKEN_NUM_INITIALIZER
15406 (struct cmd_ptype_mapping_get_result,
15407 valid_only, UINT8);
15410 cmd_ptype_mapping_get_parsed(
15411 void *parsed_result,
15412 __attribute__((unused)) struct cmdline *cl,
15413 __attribute__((unused)) void *data)
15415 struct cmd_ptype_mapping_get_result *res = parsed_result;
15416 int ret = -ENOTSUP;
15417 #ifdef RTE_LIBRTE_I40E_PMD
15418 int max_ptype_num = 256;
15419 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15424 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15427 #ifdef RTE_LIBRTE_I40E_PMD
15428 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15439 printf("invalid port_id %d\n", res->port_id);
15442 printf("function not implemented\n");
15445 printf("programming error: (%s)\n", strerror(-ret));
15448 #ifdef RTE_LIBRTE_I40E_PMD
15450 for (i = 0; i < count; i++)
15451 printf("%3d\t0x%08x\n",
15452 mapping[i].hw_ptype, mapping[i].sw_ptype);
15457 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15458 .f = cmd_ptype_mapping_get_parsed,
15460 .help_str = "ptype mapping get <port_id> <valid_only>",
15462 (void *)&cmd_ptype_mapping_get_ptype,
15463 (void *)&cmd_ptype_mapping_get_mapping,
15464 (void *)&cmd_ptype_mapping_get_get,
15465 (void *)&cmd_ptype_mapping_get_port_id,
15466 (void *)&cmd_ptype_mapping_get_valid_only,
15471 /* ptype mapping replace */
15473 /* Common result structure for ptype mapping replace */
15474 struct cmd_ptype_mapping_replace_result {
15475 cmdline_fixed_string_t ptype;
15476 cmdline_fixed_string_t mapping;
15477 cmdline_fixed_string_t replace;
15484 /* Common CLI fields for ptype mapping replace */
15485 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15486 TOKEN_STRING_INITIALIZER
15487 (struct cmd_ptype_mapping_replace_result,
15489 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15490 TOKEN_STRING_INITIALIZER
15491 (struct cmd_ptype_mapping_replace_result,
15492 mapping, "mapping");
15493 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15494 TOKEN_STRING_INITIALIZER
15495 (struct cmd_ptype_mapping_replace_result,
15496 replace, "replace");
15497 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15498 TOKEN_NUM_INITIALIZER
15499 (struct cmd_ptype_mapping_replace_result,
15501 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15502 TOKEN_NUM_INITIALIZER
15503 (struct cmd_ptype_mapping_replace_result,
15505 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15506 TOKEN_NUM_INITIALIZER
15507 (struct cmd_ptype_mapping_replace_result,
15509 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15510 TOKEN_NUM_INITIALIZER
15511 (struct cmd_ptype_mapping_replace_result,
15515 cmd_ptype_mapping_replace_parsed(
15516 void *parsed_result,
15517 __attribute__((unused)) struct cmdline *cl,
15518 __attribute__((unused)) void *data)
15520 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15521 int ret = -ENOTSUP;
15523 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15526 #ifdef RTE_LIBRTE_I40E_PMD
15527 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15537 printf("invalid ptype 0x%8x or 0x%8x\n",
15538 res->target, res->pkt_type);
15541 printf("invalid port_id %d\n", res->port_id);
15544 printf("function not implemented\n");
15547 printf("programming error: (%s)\n", strerror(-ret));
15551 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15552 .f = cmd_ptype_mapping_replace_parsed,
15555 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15557 (void *)&cmd_ptype_mapping_replace_ptype,
15558 (void *)&cmd_ptype_mapping_replace_mapping,
15559 (void *)&cmd_ptype_mapping_replace_replace,
15560 (void *)&cmd_ptype_mapping_replace_port_id,
15561 (void *)&cmd_ptype_mapping_replace_target,
15562 (void *)&cmd_ptype_mapping_replace_mask,
15563 (void *)&cmd_ptype_mapping_replace_pkt_type,
15568 /* ptype mapping reset */
15570 /* Common result structure for ptype mapping reset */
15571 struct cmd_ptype_mapping_reset_result {
15572 cmdline_fixed_string_t ptype;
15573 cmdline_fixed_string_t mapping;
15574 cmdline_fixed_string_t reset;
15578 /* Common CLI fields for ptype mapping reset*/
15579 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15580 TOKEN_STRING_INITIALIZER
15581 (struct cmd_ptype_mapping_reset_result,
15583 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15584 TOKEN_STRING_INITIALIZER
15585 (struct cmd_ptype_mapping_reset_result,
15586 mapping, "mapping");
15587 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15588 TOKEN_STRING_INITIALIZER
15589 (struct cmd_ptype_mapping_reset_result,
15591 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15592 TOKEN_NUM_INITIALIZER
15593 (struct cmd_ptype_mapping_reset_result,
15597 cmd_ptype_mapping_reset_parsed(
15598 void *parsed_result,
15599 __attribute__((unused)) struct cmdline *cl,
15600 __attribute__((unused)) void *data)
15602 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15603 int ret = -ENOTSUP;
15605 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15608 #ifdef RTE_LIBRTE_I40E_PMD
15609 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15616 printf("invalid port_id %d\n", res->port_id);
15619 printf("function not implemented\n");
15622 printf("programming error: (%s)\n", strerror(-ret));
15626 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15627 .f = cmd_ptype_mapping_reset_parsed,
15629 .help_str = "ptype mapping reset <port_id>",
15631 (void *)&cmd_ptype_mapping_reset_ptype,
15632 (void *)&cmd_ptype_mapping_reset_mapping,
15633 (void *)&cmd_ptype_mapping_reset_reset,
15634 (void *)&cmd_ptype_mapping_reset_port_id,
15639 /* ptype mapping update */
15641 /* Common result structure for ptype mapping update */
15642 struct cmd_ptype_mapping_update_result {
15643 cmdline_fixed_string_t ptype;
15644 cmdline_fixed_string_t mapping;
15645 cmdline_fixed_string_t reset;
15651 /* Common CLI fields for ptype mapping update*/
15652 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15653 TOKEN_STRING_INITIALIZER
15654 (struct cmd_ptype_mapping_update_result,
15656 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15657 TOKEN_STRING_INITIALIZER
15658 (struct cmd_ptype_mapping_update_result,
15659 mapping, "mapping");
15660 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15661 TOKEN_STRING_INITIALIZER
15662 (struct cmd_ptype_mapping_update_result,
15664 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15665 TOKEN_NUM_INITIALIZER
15666 (struct cmd_ptype_mapping_update_result,
15668 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15669 TOKEN_NUM_INITIALIZER
15670 (struct cmd_ptype_mapping_update_result,
15672 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15673 TOKEN_NUM_INITIALIZER
15674 (struct cmd_ptype_mapping_update_result,
15678 cmd_ptype_mapping_update_parsed(
15679 void *parsed_result,
15680 __attribute__((unused)) struct cmdline *cl,
15681 __attribute__((unused)) void *data)
15683 struct cmd_ptype_mapping_update_result *res = parsed_result;
15684 int ret = -ENOTSUP;
15685 #ifdef RTE_LIBRTE_I40E_PMD
15686 struct rte_pmd_i40e_ptype_mapping mapping;
15688 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15691 #ifdef RTE_LIBRTE_I40E_PMD
15692 mapping.hw_ptype = res->hw_ptype;
15693 mapping.sw_ptype = res->sw_ptype;
15694 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15704 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15707 printf("invalid port_id %d\n", res->port_id);
15710 printf("function not implemented\n");
15713 printf("programming error: (%s)\n", strerror(-ret));
15717 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15718 .f = cmd_ptype_mapping_update_parsed,
15720 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15722 (void *)&cmd_ptype_mapping_update_ptype,
15723 (void *)&cmd_ptype_mapping_update_mapping,
15724 (void *)&cmd_ptype_mapping_update_update,
15725 (void *)&cmd_ptype_mapping_update_port_id,
15726 (void *)&cmd_ptype_mapping_update_hw_ptype,
15727 (void *)&cmd_ptype_mapping_update_sw_ptype,
15732 /* Common result structure for file commands */
15733 struct cmd_cmdfile_result {
15734 cmdline_fixed_string_t load;
15735 cmdline_fixed_string_t filename;
15738 /* Common CLI fields for file commands */
15739 cmdline_parse_token_string_t cmd_load_cmdfile =
15740 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15741 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15742 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15745 cmd_load_from_file_parsed(
15746 void *parsed_result,
15747 __attribute__((unused)) struct cmdline *cl,
15748 __attribute__((unused)) void *data)
15750 struct cmd_cmdfile_result *res = parsed_result;
15752 cmdline_read_from_file(res->filename);
15755 cmdline_parse_inst_t cmd_load_from_file = {
15756 .f = cmd_load_from_file_parsed,
15758 .help_str = "load <filename>",
15760 (void *)&cmd_load_cmdfile,
15761 (void *)&cmd_load_cmdfile_filename,
15766 /* ******************************************************************************** */
15768 /* list of instructions */
15769 cmdline_parse_ctx_t main_ctx[] = {
15770 (cmdline_parse_inst_t *)&cmd_help_brief,
15771 (cmdline_parse_inst_t *)&cmd_help_long,
15772 (cmdline_parse_inst_t *)&cmd_quit,
15773 (cmdline_parse_inst_t *)&cmd_load_from_file,
15774 (cmdline_parse_inst_t *)&cmd_showport,
15775 (cmdline_parse_inst_t *)&cmd_showqueue,
15776 (cmdline_parse_inst_t *)&cmd_showportall,
15777 (cmdline_parse_inst_t *)&cmd_showcfg,
15778 (cmdline_parse_inst_t *)&cmd_start,
15779 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15780 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15781 (cmdline_parse_inst_t *)&cmd_set_link_up,
15782 (cmdline_parse_inst_t *)&cmd_set_link_down,
15783 (cmdline_parse_inst_t *)&cmd_reset,
15784 (cmdline_parse_inst_t *)&cmd_set_numbers,
15785 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15786 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15787 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15788 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15789 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15790 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15791 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15792 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15793 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15794 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15795 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15796 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15797 (cmdline_parse_inst_t *)&cmd_set_link_check,
15798 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15799 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15800 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15801 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15802 #ifdef RTE_LIBRTE_PMD_BOND
15803 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15804 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15805 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15806 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15807 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15808 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15809 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15810 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15811 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15812 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15813 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15815 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15816 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15817 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15818 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15819 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15820 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15821 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15822 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15823 (cmdline_parse_inst_t *)&cmd_csum_set,
15824 (cmdline_parse_inst_t *)&cmd_csum_show,
15825 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15826 (cmdline_parse_inst_t *)&cmd_tso_set,
15827 (cmdline_parse_inst_t *)&cmd_tso_show,
15828 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15829 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15830 (cmdline_parse_inst_t *)&cmd_gro_enable,
15831 (cmdline_parse_inst_t *)&cmd_gro_flush,
15832 (cmdline_parse_inst_t *)&cmd_gro_show,
15833 (cmdline_parse_inst_t *)&cmd_gso_enable,
15834 (cmdline_parse_inst_t *)&cmd_gso_size,
15835 (cmdline_parse_inst_t *)&cmd_gso_show,
15836 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15837 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15838 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15839 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15840 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15841 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15842 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15843 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15844 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15845 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15846 (cmdline_parse_inst_t *)&cmd_config_dcb,
15847 (cmdline_parse_inst_t *)&cmd_read_reg,
15848 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15849 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15850 (cmdline_parse_inst_t *)&cmd_write_reg,
15851 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15852 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15853 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15854 (cmdline_parse_inst_t *)&cmd_stop,
15855 (cmdline_parse_inst_t *)&cmd_mac_addr,
15856 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
15857 (cmdline_parse_inst_t *)&cmd_set_qmap,
15858 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
15859 (cmdline_parse_inst_t *)&cmd_operate_port,
15860 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15861 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15862 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15863 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15864 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15865 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15866 (cmdline_parse_inst_t *)&cmd_config_mtu,
15867 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15868 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15869 (cmdline_parse_inst_t *)&cmd_config_rss,
15870 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15871 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15872 (cmdline_parse_inst_t *)&cmd_showport_reta,
15873 (cmdline_parse_inst_t *)&cmd_config_burst,
15874 (cmdline_parse_inst_t *)&cmd_config_thresh,
15875 (cmdline_parse_inst_t *)&cmd_config_threshold,
15876 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15877 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15878 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15879 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15880 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15881 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15882 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15883 (cmdline_parse_inst_t *)&cmd_global_config,
15884 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15885 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15886 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15887 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15888 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15889 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15890 (cmdline_parse_inst_t *)&cmd_dump,
15891 (cmdline_parse_inst_t *)&cmd_dump_one,
15892 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15893 (cmdline_parse_inst_t *)&cmd_syn_filter,
15894 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15895 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15896 (cmdline_parse_inst_t *)&cmd_flex_filter,
15897 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15898 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15899 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15900 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15901 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15902 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15903 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
15904 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15905 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15906 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15907 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15908 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15909 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15910 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15911 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15912 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15913 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15914 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15915 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15916 (cmdline_parse_inst_t *)&cmd_flow,
15917 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
15918 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15919 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15920 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15921 (cmdline_parse_inst_t *)&cmd_create_port_meter,
15922 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
15923 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
15924 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15925 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15926 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
15927 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15928 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15929 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15930 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15931 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15932 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15933 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15934 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15935 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15936 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15937 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15938 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15939 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15940 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15941 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15942 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15943 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15944 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15945 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15946 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15947 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15948 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15949 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15950 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15951 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15952 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15953 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15954 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15955 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15956 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15957 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15958 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15959 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15960 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15961 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15962 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15963 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15964 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15965 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15966 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15967 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15969 (cmdline_parse_inst_t *)&cmd_ddp_add,
15970 (cmdline_parse_inst_t *)&cmd_ddp_del,
15971 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15972 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15973 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15974 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15975 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15976 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15977 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15978 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15980 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15981 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15982 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15983 (cmdline_parse_inst_t *)&cmd_queue_region,
15984 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15985 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15986 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15987 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15988 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15989 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15990 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15991 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15992 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15993 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15994 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15995 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15996 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15997 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15998 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15999 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16000 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16001 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16002 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16003 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16004 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16008 /* read cmdline commands from file */
16010 cmdline_read_from_file(const char *filename)
16012 struct cmdline *cl;
16014 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16016 printf("Failed to create file based cmdline context: %s\n",
16021 cmdline_interact(cl);
16026 printf("Read CLI commands from %s\n", filename);
16029 /* prompt function, called from main on MASTER lcore */
16033 /* initialize non-constant commands */
16034 cmd_set_fwd_mode_init();
16035 cmd_set_fwd_retry_mode_init();
16037 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16038 if (testpmd_cl == NULL)
16040 cmdline_interact(testpmd_cl);
16041 cmdline_stdin_exit(testpmd_cl);
16047 if (testpmd_cl != NULL)
16048 cmdline_quit(testpmd_cl);
16052 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16054 if (id == (portid_t)RTE_PORT_ALL) {
16057 RTE_ETH_FOREACH_DEV(pid) {
16058 /* check if need_reconfig has been set to 1 */
16059 if (ports[pid].need_reconfig == 0)
16060 ports[pid].need_reconfig = dev;
16061 /* check if need_reconfig_queues has been set to 1 */
16062 if (ports[pid].need_reconfig_queues == 0)
16063 ports[pid].need_reconfig_queues = queue;
16065 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16066 /* check if need_reconfig has been set to 1 */
16067 if (ports[id].need_reconfig == 0)
16068 ports[id].need_reconfig = dev;
16069 /* check if need_reconfig_queues has been set to 1 */
16070 if (ports[id].need_reconfig_queues == 0)
16071 ports[id].need_reconfig_queues = queue;