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_IXGBE_PMD
93 #include <rte_pmd_ixgbe.h>
95 #ifdef RTE_LIBRTE_I40E_PMD
96 #include <rte_pmd_i40e.h>
98 #ifdef RTE_LIBRTE_BNXT_PMD
99 #include <rte_pmd_bnxt.h>
102 #include "cmdline_mtr.h"
103 #include "cmdline_tm.h"
105 static struct cmdline *testpmd_cl;
107 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
109 /* *** Help command with introduction. *** */
110 struct cmd_help_brief_result {
111 cmdline_fixed_string_t help;
114 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
116 __attribute__((unused)) void *data)
121 "Help is available for the following sections:\n\n"
122 " help control : Start and stop forwarding.\n"
123 " help display : Displaying port, stats and config "
125 " help config : Configuration information.\n"
126 " help ports : Configuring ports.\n"
127 " help registers : Reading and setting port registers.\n"
128 " help filters : Filters configuration help.\n"
129 " help all : All of the above sections.\n\n"
134 cmdline_parse_token_string_t cmd_help_brief_help =
135 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
137 cmdline_parse_inst_t cmd_help_brief = {
138 .f = cmd_help_brief_parsed,
140 .help_str = "help: Show help",
142 (void *)&cmd_help_brief_help,
147 /* *** Help command with help sections. *** */
148 struct cmd_help_long_result {
149 cmdline_fixed_string_t help;
150 cmdline_fixed_string_t section;
153 static void cmd_help_long_parsed(void *parsed_result,
155 __attribute__((unused)) void *data)
158 struct cmd_help_long_result *res = parsed_result;
160 if (!strcmp(res->section, "all"))
163 if (show_all || !strcmp(res->section, "control")) {
168 "Control forwarding:\n"
169 "-------------------\n\n"
172 " Start packet forwarding with current configuration.\n\n"
175 " Start packet forwarding with current config"
176 " after sending one burst of packets.\n\n"
179 " Stop packet forwarding, and display accumulated"
183 " Quit to prompt.\n\n"
187 if (show_all || !strcmp(res->section, "display")) {
195 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
196 " Display information for port_id, or all.\n\n"
198 "show port X rss reta (size) (mask0,mask1,...)\n"
199 " Display the rss redirection table entry indicated"
200 " by masks on port X. size is used to indicate the"
201 " hardware supported reta size\n\n"
203 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
204 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
205 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
206 " Display the RSS hash functions and RSS hash key"
209 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
210 " Clear information for port_id, or all.\n\n"
212 "show (rxq|txq) info (port_id) (queue_id)\n"
213 " Display information for configured RX/TX queue.\n\n"
215 "show config (rxtx|cores|fwd|txpkts)\n"
216 " Display the given configuration.\n\n"
218 "read rxd (port_id) (queue_id) (rxd_id)\n"
219 " Display an RX descriptor of a port RX queue.\n\n"
221 "read txd (port_id) (queue_id) (txd_id)\n"
222 " Display a TX descriptor of a port TX queue.\n\n"
224 "ddp get list (port_id)\n"
225 " Get ddp profile info list\n\n"
227 "ddp get info (profile_path)\n"
228 " Get ddp profile information.\n\n"
230 "show vf stats (port_id) (vf_id)\n"
231 " Display a VF's statistics.\n\n"
233 "clear vf stats (port_id) (vf_id)\n"
234 " Reset a VF's statistics.\n\n"
236 "show port (port_id) pctype mapping\n"
237 " Get flow ptype to pctype mapping on a port\n\n"
239 "show port meter stats (port_id) (meter_id) (clear)\n"
240 " Get meter stats on a port\n\n"
241 "show port tm cap (port_id)\n"
242 " Display the port TM capability.\n\n"
244 "show port tm level cap (port_id) (level_id)\n"
245 " Display the port TM hierarchical level capability.\n\n"
247 "show port tm node cap (port_id) (node_id)\n"
248 " Display the port TM node capability.\n\n"
250 "show port tm node type (port_id) (node_id)\n"
251 " Display the port TM node type.\n\n"
253 "show port tm node stats (port_id) (node_id) (clear)\n"
254 " Display the port TM node stats.\n\n"
259 if (show_all || !strcmp(res->section, "config")) {
265 "Configuration changes only become active when"
266 " forwarding is started/restarted.\n\n"
269 " Reset forwarding to the default configuration.\n\n"
271 "set verbose (level)\n"
272 " Set the debug verbosity level X.\n\n"
275 " Set number of ports.\n\n"
278 " Set number of cores.\n\n"
280 "set coremask (mask)\n"
281 " Set the forwarding cores hexadecimal mask.\n\n"
283 "set portmask (mask)\n"
284 " Set the forwarding ports hexadecimal mask.\n\n"
287 " Set number of packets per burst.\n\n"
289 "set burst tx delay (microseconds) retry (num)\n"
290 " Set the transmit delay time and number of retries,"
291 " effective when retry is enabled.\n\n"
293 "set txpkts (x[,y]*)\n"
294 " Set the length of each segment of TXONLY"
295 " and optionally CSUM packets.\n\n"
297 "set txsplit (off|on|rand)\n"
298 " Set the split policy for the TX packets."
299 " Right now only applicable for CSUM and TXONLY"
302 "set corelist (x[,y]*)\n"
303 " Set the list of forwarding cores.\n\n"
305 "set portlist (x[,y]*)\n"
306 " Set the list of forwarding ports.\n\n"
308 "set tx loopback (port_id) (on|off)\n"
309 " Enable or disable tx loopback.\n\n"
311 "set all queues drop (port_id) (on|off)\n"
312 " Set drop enable bit for all queues.\n\n"
314 "set vf split drop (port_id) (vf_id) (on|off)\n"
315 " Set split drop enable bit for a VF from the PF.\n\n"
317 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
318 " Set MAC antispoof for a VF from the PF.\n\n"
320 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
321 " Enable MACsec offload.\n\n"
323 "set macsec offload (port_id) off\n"
324 " Disable MACsec offload.\n\n"
326 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
327 " Configure MACsec secure connection (SC).\n\n"
329 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
330 " Configure MACsec secure association (SA).\n\n"
332 "set vf broadcast (port_id) (vf_id) (on|off)\n"
333 " Set VF broadcast for a VF from the PF.\n\n"
335 "vlan set strip (on|off) (port_id)\n"
336 " Set the VLAN strip on a port.\n\n"
338 "vlan set stripq (on|off) (port_id,queue_id)\n"
339 " Set the VLAN strip for a queue on a port.\n\n"
341 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
342 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
344 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
345 " Set VLAN insert for a VF from the PF.\n\n"
347 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
348 " Set VLAN antispoof for a VF from the PF.\n\n"
350 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
351 " Set VLAN tag for a VF from the PF.\n\n"
353 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
354 " Set a VF's max bandwidth(Mbps).\n\n"
356 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
357 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
359 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
360 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
362 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
363 " Set some TCs' strict link priority mode on a physical port.\n\n"
365 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
366 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
368 "vlan set filter (on|off) (port_id)\n"
369 " Set the VLAN filter on a port.\n\n"
371 "vlan set qinq (on|off) (port_id)\n"
372 " Set the VLAN QinQ (extended queue in queue)"
375 "vlan set (inner|outer) tpid (value) (port_id)\n"
376 " Set the VLAN TPID for Packet Filtering on"
379 "rx_vlan add (vlan_id|all) (port_id)\n"
380 " Add a vlan_id, or all identifiers, to the set"
381 " of VLAN identifiers filtered by port_id.\n\n"
383 "rx_vlan rm (vlan_id|all) (port_id)\n"
384 " Remove a vlan_id, or all identifiers, from the set"
385 " of VLAN identifiers filtered by port_id.\n\n"
387 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
388 " Add a vlan_id, to the set of VLAN identifiers"
389 "filtered for VF(s) from port_id.\n\n"
391 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
392 " Remove a vlan_id, to the set of VLAN identifiers"
393 "filtered for VF(s) from port_id.\n\n"
395 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
396 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
397 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
398 " add a tunnel filter of a port.\n\n"
400 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
401 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
402 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
403 " remove a tunnel filter of a port.\n\n"
405 "rx_vxlan_port add (udp_port) (port_id)\n"
406 " Add an UDP port for VXLAN packet filter on a port\n\n"
408 "rx_vxlan_port rm (udp_port) (port_id)\n"
409 " Remove an UDP port for VXLAN packet filter on a port\n\n"
411 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
412 " Set hardware insertion of VLAN IDs (single or double VLAN "
413 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
415 "tx_vlan set pvid port_id vlan_id (on|off)\n"
416 " Set port based TX VLAN insertion.\n\n"
418 "tx_vlan reset (port_id)\n"
419 " Disable hardware insertion of a VLAN header in"
420 " packets sent on a port.\n\n"
422 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
423 " Select hardware or software calculation of the"
424 " checksum when transmitting a packet using the"
425 " csum forward engine.\n"
426 " ip|udp|tcp|sctp always concern the inner layer.\n"
427 " outer-ip concerns the outer IP layer in"
428 " case the packet is recognized as a tunnel packet by"
429 " the forward engine (vxlan, gre and ipip are supported)\n"
430 " Please check the NIC datasheet for HW limits.\n\n"
432 "csum parse-tunnel (on|off) (tx_port_id)\n"
433 " If disabled, treat tunnel packets as non-tunneled"
434 " packets (treat inner headers as payload). The port\n"
435 " argument is the port used for TX in csum forward"
438 "csum show (port_id)\n"
439 " Display tx checksum offload configuration\n\n"
441 "tso set (segsize) (portid)\n"
442 " Enable TCP Segmentation Offload in csum forward"
444 " Please check the NIC datasheet for HW limits.\n\n"
447 " Display the status of TCP Segmentation Offload.\n\n"
449 "set port (port_id) gro on|off\n"
450 " Enable or disable Generic Receive Offload in"
451 " csum forwarding engine.\n\n"
453 "show port (port_id) gro\n"
454 " Display GRO configuration.\n\n"
456 "set gro flush (cycles)\n"
457 " Set the cycle to flush GROed packets from"
458 " reassembly tables.\n\n"
460 "set port (port_id) gso (on|off)"
461 " Enable or disable Generic Segmentation Offload in"
462 " csum forwarding engine.\n\n"
464 "set gso segsz (length)\n"
465 " Set max packet length for output GSO segments,"
466 " including packet header and payload.\n\n"
468 "show port (port_id) gso\n"
469 " Show GSO configuration.\n\n"
472 " Set packet forwarding mode.\n\n"
474 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
475 " Add a MAC address on port_id.\n\n"
477 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
478 " Remove a MAC address from port_id.\n\n"
480 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
481 " Set the default MAC address for port_id.\n\n"
483 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
484 " Add a MAC address for a VF on the port.\n\n"
486 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
487 " Set the MAC address for a VF from the PF.\n\n"
489 "set eth-peer (port_id) (peer_addr)\n"
490 " set the peer address for certain port.\n\n"
492 "set port (port_id) uta (mac_address|all) (on|off)\n"
493 " Add/Remove a or all unicast hash filter(s)"
496 "set promisc (port_id|all) (on|off)\n"
497 " Set the promiscuous mode on port_id, or all.\n\n"
499 "set allmulti (port_id|all) (on|off)\n"
500 " Set the allmulti mode on port_id, or all.\n\n"
502 "set vf promisc (port_id) (vf_id) (on|off)\n"
503 " Set unicast promiscuous mode for a VF from the PF.\n\n"
505 "set vf allmulti (port_id) (vf_id) (on|off)\n"
506 " Set multicast promiscuous mode for a VF from the PF.\n\n"
508 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
509 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
510 " (on|off) autoneg (on|off) (port_id)\n"
511 "set flow_ctrl rx (on|off) (portid)\n"
512 "set flow_ctrl tx (on|off) (portid)\n"
513 "set flow_ctrl high_water (high_water) (portid)\n"
514 "set flow_ctrl low_water (low_water) (portid)\n"
515 "set flow_ctrl pause_time (pause_time) (portid)\n"
516 "set flow_ctrl send_xon (send_xon) (portid)\n"
517 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
518 "set flow_ctrl autoneg (on|off) (port_id)\n"
519 " Set the link flow control parameter on a port.\n\n"
521 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
522 " (low_water) (pause_time) (priority) (port_id)\n"
523 " Set the priority flow control parameter on a"
526 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
527 " Set statistics mapping (qmapping 0..15) for RX/TX"
529 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
530 " on port 0 to mapping 5.\n\n"
532 "set xstats-hide-zero on|off\n"
533 " Set the option to hide the zero values"
534 " for xstats display.\n"
536 "set port (port_id) vf (vf_id) rx|tx on|off\n"
537 " Enable/Disable a VF receive/tranmit from a port\n\n"
539 "set port (port_id) vf (vf_id) (mac_addr)"
540 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
541 " Add/Remove unicast or multicast MAC addr filter"
544 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
546 " AUPE:accepts untagged VLAN;"
547 "ROPE:accept unicast hash\n\n"
548 " BAM:accepts broadcast packets;"
549 "MPE:accepts all multicast packets\n\n"
550 " Enable/Disable a VF receive mode of a port\n\n"
552 "set port (port_id) queue (queue_id) rate (rate_num)\n"
553 " Set rate limit for a queue of a port\n\n"
555 "set port (port_id) vf (vf_id) rate (rate_num) "
556 "queue_mask (queue_mask_value)\n"
557 " Set rate limit for queues in VF of a port\n\n"
559 "set port (port_id) mirror-rule (rule_id)"
560 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
561 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
562 " Set pool or vlan type mirror rule on a port.\n"
563 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
564 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
567 "set port (port_id) mirror-rule (rule_id)"
568 " (uplink-mirror|downlink-mirror) dst-pool"
569 " (pool_id) (on|off)\n"
570 " Set uplink or downlink type mirror rule on a port.\n"
571 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
572 " 0 on' enable mirror income traffic to pool 0.\n\n"
574 "reset port (port_id) mirror-rule (rule_id)\n"
575 " Reset a mirror rule.\n\n"
577 "set flush_rx (on|off)\n"
578 " Flush (default) or don't flush RX streams before"
579 " forwarding. Mainly used with PCAP drivers.\n\n"
581 "set bypass mode (normal|bypass|isolate) (port_id)\n"
582 " Set the bypass mode for the lowest port on bypass enabled"
585 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
586 "mode (normal|bypass|isolate) (port_id)\n"
587 " Set the event required to initiate specified bypass mode for"
588 " the lowest port on a bypass enabled NIC where:\n"
589 " timeout = enable bypass after watchdog timeout.\n"
590 " os_on = enable bypass when OS/board is powered on.\n"
591 " os_off = enable bypass when OS/board is powered off.\n"
592 " power_on = enable bypass when power supply is turned on.\n"
593 " power_off = enable bypass when power supply is turned off."
596 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
597 " Set the bypass watchdog timeout to 'n' seconds"
598 " where 0 = instant.\n\n"
600 "show bypass config (port_id)\n"
601 " Show the bypass configuration for a bypass enabled NIC"
602 " using the lowest port on the NIC.\n\n"
604 #ifdef RTE_LIBRTE_PMD_BOND
605 "create bonded device (mode) (socket)\n"
606 " Create a new bonded device with specific bonding mode and socket.\n\n"
608 "add bonding slave (slave_id) (port_id)\n"
609 " Add a slave device to a bonded device.\n\n"
611 "remove bonding slave (slave_id) (port_id)\n"
612 " Remove a slave device from a bonded device.\n\n"
614 "set bonding mode (value) (port_id)\n"
615 " Set the bonding mode on a bonded device.\n\n"
617 "set bonding primary (slave_id) (port_id)\n"
618 " Set the primary slave for a bonded device.\n\n"
620 "show bonding config (port_id)\n"
621 " Show the bonding config for port_id.\n\n"
623 "set bonding mac_addr (port_id) (address)\n"
624 " Set the MAC address of a bonded device.\n\n"
626 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
627 " Set Aggregation mode for IEEE802.3AD (mode 4)"
629 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
630 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
632 "set bonding mon_period (port_id) (value)\n"
633 " Set the bonding link status monitoring polling period in ms.\n\n"
635 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
636 " Enable/disable dedicated queues for LACP control traffic.\n\n"
639 "set link-up port (port_id)\n"
640 " Set link up for a port.\n\n"
642 "set link-down port (port_id)\n"
643 " Set link down for a port.\n\n"
645 "E-tag set insertion on port-tag-id (value)"
646 " port (port_id) vf (vf_id)\n"
647 " Enable E-tag insertion for a VF on a port\n\n"
649 "E-tag set insertion off port (port_id) vf (vf_id)\n"
650 " Disable E-tag insertion for a VF on a port\n\n"
652 "E-tag set stripping (on|off) port (port_id)\n"
653 " Enable/disable E-tag stripping on a port\n\n"
655 "E-tag set forwarding (on|off) port (port_id)\n"
656 " Enable/disable E-tag based forwarding"
659 "E-tag set filter add e-tag-id (value) dst-pool"
660 " (pool_id) port (port_id)\n"
661 " Add an E-tag forwarding filter on a port\n\n"
663 "E-tag set filter del e-tag-id (value) port (port_id)\n"
664 " Delete an E-tag forwarding filter on a port\n\n"
666 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
667 "set port tm hierarchy default (port_id)\n"
668 " Set default traffic Management hierarchy on a port\n\n"
671 "ddp add (port_id) (profile_path[,output_path])\n"
672 " Load a profile package on a port\n\n"
674 "ddp del (port_id) (profile_path)\n"
675 " Delete a profile package from a port\n\n"
677 "ptype mapping get (port_id) (valid_only)\n"
678 " Get ptype mapping on a port\n\n"
680 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
681 " Replace target with the pkt_type in ptype mapping\n\n"
683 "ptype mapping reset (port_id)\n"
684 " Reset ptype mapping on a port\n\n"
686 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
687 " Update a ptype mapping item on a port\n\n"
689 "set port (port_id) queue-region region_id (value) "
690 "queue_start_index (value) queue_num (value)\n"
691 " Set a queue region on a port\n\n"
693 "set port (port_id) queue-region region_id (value) "
695 " Set a flowtype region index on a port\n\n"
697 "set port (port_id) queue-region UP (value) region_id (value)\n"
698 " Set the mapping of User Priority to "
699 "queue region on a port\n\n"
701 "set port (port_id) queue-region flush (on|off)\n"
702 " flush all queue region related configuration\n\n"
704 "show port meter cap (port_id)\n"
705 " Show port meter capability information\n\n"
707 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
708 " meter profile add - srtcm rfc 2697\n\n"
710 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
711 " meter profile add - trtcm rfc 2698\n\n"
713 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
714 " meter profile add - trtcm rfc 4115\n\n"
716 "del port meter profile (port_id) (profile_id)\n"
717 " meter profile delete\n\n"
719 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
720 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
721 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
722 "(dscp_tbl_entry63)]\n"
725 "enable port meter (port_id) (mtr_id)\n"
728 "disable port meter (port_id) (mtr_id)\n"
731 "del port meter (port_id) (mtr_id)\n"
734 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
735 " meter update meter profile\n\n"
737 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
738 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
739 " update meter dscp table entries\n\n"
741 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
742 "(action0) [(action1) (action2)]\n"
743 " meter update policer action\n\n"
745 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
746 " meter update stats\n\n"
748 "show port (port_id) queue-region\n"
749 " show all queue region related configuration info\n\n"
751 "add port tm node shaper profile (port_id) (shaper_profile_id)"
752 " (tb_rate) (tb_size) (packet_length_adjust)\n"
753 " Add port tm node private shaper profile.\n\n"
755 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
756 " Delete port tm node private shaper profile.\n\n"
758 "add port tm node shared shaper (port_id) (shared_shaper_id)"
759 " (shaper_profile_id)\n"
760 " Add/update port tm node shared shaper.\n\n"
762 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
763 " Delete port tm node shared shaper.\n\n"
765 "set port tm node shaper profile (port_id) (node_id)"
766 " (shaper_profile_id)\n"
767 " Set port tm node shaper profile.\n\n"
769 "add port tm node wred profile (port_id) (wred_profile_id)"
770 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
771 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
772 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
773 " Add port tm node wred profile.\n\n"
775 "del port tm node wred profile (port_id) (wred_profile_id)\n"
776 " Delete port tm node wred profile.\n\n"
778 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
779 " (priority) (weight) (level_id) (shaper_profile_id)"
780 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
781 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
782 " Add port tm nonleaf node.\n\n"
784 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
785 " (priority) (weight) (level_id) (shaper_profile_id)"
786 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
787 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
788 " Add port tm leaf node.\n\n"
790 "del port tm node (port_id) (node_id)\n"
791 " Delete port tm node.\n\n"
793 "set port tm node parent (port_id) (node_id) (parent_node_id)"
794 " (priority) (weight)\n"
795 " Set port tm node parent.\n\n"
797 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
798 " Commit tm hierarchy.\n\n"
800 , list_pkt_forwarding_modes()
804 if (show_all || !strcmp(res->section, "ports")) {
810 "----------------\n\n"
812 "port start (port_id|all)\n"
813 " Start all ports or port_id.\n\n"
815 "port stop (port_id|all)\n"
816 " Stop all ports or port_id.\n\n"
818 "port close (port_id|all)\n"
819 " Close all ports or port_id.\n\n"
821 "port attach (ident)\n"
822 " Attach physical or virtual dev by pci address or virtual device name\n\n"
824 "port detach (port_id)\n"
825 " Detach physical or virtual dev by port_id\n\n"
827 "port config (port_id|all)"
828 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
829 " duplex (half|full|auto)\n"
830 " Set speed and duplex for all ports or port_id\n\n"
832 "port config all (rxq|txq|rxd|txd) (value)\n"
833 " Set number for rxq/txq/rxd/txd.\n\n"
835 "port config all max-pkt-len (value)\n"
836 " Set the max packet length.\n\n"
838 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
839 "hw-vlan-strip|hw-vlan-extend|drop-en)"
841 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
844 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
845 "geneve|nvgre|none|<flowtype_id>)\n"
846 " Set the RSS mode.\n\n"
848 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
849 " Set the RSS redirection table.\n\n"
851 "port config (port_id) dcb vt (on|off) (traffic_class)"
853 " Set the DCB mode.\n\n"
855 "port config all burst (value)\n"
856 " Set the number of packets per burst.\n\n"
858 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
860 " Set the ring prefetch/host/writeback threshold"
861 " for tx/rx queue.\n\n"
863 "port config all (txfreet|txrst|rxfreet) (value)\n"
864 " Set free threshold for rx/tx, or set"
865 " tx rs bit threshold.\n\n"
866 "port config mtu X value\n"
867 " Set the MTU of port X to a given value\n\n"
869 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
870 " Start/stop a rx/tx queue of port X. Only take effect"
871 " when port X is started\n\n"
873 "port config (port_id|all) l2-tunnel E-tag ether-type"
875 " Set the value of E-tag ether-type.\n\n"
877 "port config (port_id|all) l2-tunnel E-tag"
878 " (enable|disable)\n"
879 " Enable/disable the E-tag support.\n\n"
881 "port config (port_id) pctype mapping reset\n"
882 " Reset flow type to pctype mapping on a port\n\n"
884 "port config (port_id) pctype mapping update"
885 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
886 " Update a flow type to pctype mapping item on a port\n\n"
890 if (show_all || !strcmp(res->section, "registers")) {
898 "read reg (port_id) (address)\n"
899 " Display value of a port register.\n\n"
901 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
902 " Display a port register bit field.\n\n"
904 "read regbit (port_id) (address) (bit_x)\n"
905 " Display a single port register bit.\n\n"
907 "write reg (port_id) (address) (value)\n"
908 " Set value of a port register.\n\n"
910 "write regfield (port_id) (address) (bit_x) (bit_y)"
912 " Set bit field of a port register.\n\n"
914 "write regbit (port_id) (address) (bit_x) (value)\n"
915 " Set single bit value of a port register.\n\n"
918 if (show_all || !strcmp(res->section, "filters")) {
926 "ethertype_filter (port_id) (add|del)"
927 " (mac_addr|mac_ignr) (mac_address) ethertype"
928 " (ether_type) (drop|fwd) queue (queue_id)\n"
929 " Add/Del an ethertype filter.\n\n"
931 "2tuple_filter (port_id) (add|del)"
932 " dst_port (dst_port_value) protocol (protocol_value)"
933 " mask (mask_value) tcp_flags (tcp_flags_value)"
934 " priority (prio_value) queue (queue_id)\n"
935 " Add/Del a 2tuple filter.\n\n"
937 "5tuple_filter (port_id) (add|del)"
938 " dst_ip (dst_address) src_ip (src_address)"
939 " dst_port (dst_port_value) src_port (src_port_value)"
940 " protocol (protocol_value)"
941 " mask (mask_value) tcp_flags (tcp_flags_value)"
942 " priority (prio_value) queue (queue_id)\n"
943 " Add/Del a 5tuple filter.\n\n"
945 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
946 " Add/Del syn filter.\n\n"
948 "flex_filter (port_id) (add|del) len (len_value)"
949 " bytes (bytes_value) mask (mask_value)"
950 " priority (prio_value) queue (queue_id)\n"
951 " Add/Del a flex filter.\n\n"
953 "flow_director_filter (port_id) mode IP (add|del|update)"
954 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
955 " src (src_ip_address) dst (dst_ip_address)"
956 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
957 " vlan (vlan_value) flexbytes (flexbytes_value)"
958 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
959 " fd_id (fd_id_value)\n"
960 " Add/Del an IP type flow director filter.\n\n"
962 "flow_director_filter (port_id) mode IP (add|del|update)"
963 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
964 " src (src_ip_address) (src_port)"
965 " dst (dst_ip_address) (dst_port)"
966 " tos (tos_value) ttl (ttl_value)"
967 " vlan (vlan_value) flexbytes (flexbytes_value)"
968 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
969 " fd_id (fd_id_value)\n"
970 " Add/Del an UDP/TCP type flow director filter.\n\n"
972 "flow_director_filter (port_id) mode IP (add|del|update)"
973 " flow (ipv4-sctp|ipv6-sctp)"
974 " src (src_ip_address) (src_port)"
975 " dst (dst_ip_address) (dst_port)"
976 " tag (verification_tag) "
977 " tos (tos_value) ttl (ttl_value)"
979 " flexbytes (flexbytes_value) (drop|fwd)"
980 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
981 " Add/Del a SCTP type flow director filter.\n\n"
983 "flow_director_filter (port_id) mode IP (add|del|update)"
984 " flow l2_payload ether (ethertype)"
985 " flexbytes (flexbytes_value) (drop|fwd)"
986 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
987 " Add/Del a l2 payload type flow director filter.\n\n"
989 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
990 " mac (mac_address) vlan (vlan_value)"
991 " flexbytes (flexbytes_value) (drop|fwd)"
992 " queue (queue_id) fd_id (fd_id_value)\n"
993 " Add/Del a MAC-VLAN flow director filter.\n\n"
995 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
996 " mac (mac_address) vlan (vlan_value)"
997 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
998 " flexbytes (flexbytes_value) (drop|fwd)"
999 " queue (queue_id) fd_id (fd_id_value)\n"
1000 " Add/Del a Tunnel flow director filter.\n\n"
1002 "flow_director_filter (port_id) mode raw (add|del|update)"
1003 " flow (flow_id) (drop|fwd) queue (queue_id)"
1004 " fd_id (fd_id_value) packet (packet file name)\n"
1005 " Add/Del a raw type flow director filter.\n\n"
1007 "flush_flow_director (port_id)\n"
1008 " Flush all flow director entries of a device.\n\n"
1010 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1011 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1012 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1013 " Set flow director IP mask.\n\n"
1015 "flow_director_mask (port_id) mode MAC-VLAN"
1016 " vlan (vlan_value)\n"
1017 " Set flow director MAC-VLAN mask.\n\n"
1019 "flow_director_mask (port_id) mode Tunnel"
1020 " vlan (vlan_value) mac (mac_value)"
1021 " tunnel-type (tunnel_type_value)"
1022 " tunnel-id (tunnel_id_value)\n"
1023 " Set flow director Tunnel mask.\n\n"
1025 "flow_director_flex_mask (port_id)"
1026 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1027 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1029 " Configure mask of flex payload.\n\n"
1031 "flow_director_flex_payload (port_id)"
1032 " (raw|l2|l3|l4) (config)\n"
1033 " Configure flex payload selection.\n\n"
1035 "get_sym_hash_ena_per_port (port_id)\n"
1036 " get symmetric hash enable configuration per port.\n\n"
1038 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1039 " set symmetric hash enable configuration per port"
1040 " to enable or disable.\n\n"
1042 "get_hash_global_config (port_id)\n"
1043 " Get the global configurations of hash filters.\n\n"
1045 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1046 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1047 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1048 " (enable|disable)\n"
1049 " Set the global configurations of hash filters.\n\n"
1051 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1052 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1053 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1054 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1055 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1056 "ipv6-next-header|udp-src-port|udp-dst-port|"
1057 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1058 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1059 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1060 "fld-8th|none) (select|add)\n"
1061 " Set the input set for hash.\n\n"
1063 "set_fdir_input_set (port_id) "
1064 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1065 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1066 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1067 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1068 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1069 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1070 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1072 " Set the input set for FDir.\n\n"
1074 "flow validate {port_id}"
1075 " [group {group_id}] [priority {level}]"
1076 " [ingress] [egress]"
1077 " pattern {item} [/ {item} [...]] / end"
1078 " actions {action} [/ {action} [...]] / end\n"
1079 " Check whether a flow rule can be created.\n\n"
1081 "flow create {port_id}"
1082 " [group {group_id}] [priority {level}]"
1083 " [ingress] [egress]"
1084 " pattern {item} [/ {item} [...]] / end"
1085 " actions {action} [/ {action} [...]] / end\n"
1086 " Create a flow rule.\n\n"
1088 "flow destroy {port_id} rule {rule_id} [...]\n"
1089 " Destroy specific flow rules.\n\n"
1091 "flow flush {port_id}\n"
1092 " Destroy all flow rules.\n\n"
1094 "flow query {port_id} {rule_id} {action}\n"
1095 " Query an existing flow rule.\n\n"
1097 "flow list {port_id} [group {group_id}] [...]\n"
1098 " List existing flow rules sorted by priority,"
1099 " filtered by group identifiers.\n\n"
1101 "flow isolate {port_id} {boolean}\n"
1102 " Restrict ingress traffic to the defined"
1108 cmdline_parse_token_string_t cmd_help_long_help =
1109 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1111 cmdline_parse_token_string_t cmd_help_long_section =
1112 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1113 "all#control#display#config#"
1114 "ports#registers#filters");
1116 cmdline_parse_inst_t cmd_help_long = {
1117 .f = cmd_help_long_parsed,
1119 .help_str = "help all|control|display|config|ports|register|filters: "
1122 (void *)&cmd_help_long_help,
1123 (void *)&cmd_help_long_section,
1129 /* *** start/stop/close all ports *** */
1130 struct cmd_operate_port_result {
1131 cmdline_fixed_string_t keyword;
1132 cmdline_fixed_string_t name;
1133 cmdline_fixed_string_t value;
1136 static void cmd_operate_port_parsed(void *parsed_result,
1137 __attribute__((unused)) struct cmdline *cl,
1138 __attribute__((unused)) void *data)
1140 struct cmd_operate_port_result *res = parsed_result;
1142 if (!strcmp(res->name, "start"))
1143 start_port(RTE_PORT_ALL);
1144 else if (!strcmp(res->name, "stop"))
1145 stop_port(RTE_PORT_ALL);
1146 else if (!strcmp(res->name, "close"))
1147 close_port(RTE_PORT_ALL);
1148 else if (!strcmp(res->name, "reset"))
1149 reset_port(RTE_PORT_ALL);
1151 printf("Unknown parameter\n");
1154 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1155 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1157 cmdline_parse_token_string_t cmd_operate_port_all_port =
1158 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1159 "start#stop#close#reset");
1160 cmdline_parse_token_string_t cmd_operate_port_all_all =
1161 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1163 cmdline_parse_inst_t cmd_operate_port = {
1164 .f = cmd_operate_port_parsed,
1166 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1168 (void *)&cmd_operate_port_all_cmd,
1169 (void *)&cmd_operate_port_all_port,
1170 (void *)&cmd_operate_port_all_all,
1175 /* *** start/stop/close specific port *** */
1176 struct cmd_operate_specific_port_result {
1177 cmdline_fixed_string_t keyword;
1178 cmdline_fixed_string_t name;
1182 static void cmd_operate_specific_port_parsed(void *parsed_result,
1183 __attribute__((unused)) struct cmdline *cl,
1184 __attribute__((unused)) void *data)
1186 struct cmd_operate_specific_port_result *res = parsed_result;
1188 if (!strcmp(res->name, "start"))
1189 start_port(res->value);
1190 else if (!strcmp(res->name, "stop"))
1191 stop_port(res->value);
1192 else if (!strcmp(res->name, "close"))
1193 close_port(res->value);
1194 else if (!strcmp(res->name, "reset"))
1195 reset_port(res->value);
1197 printf("Unknown parameter\n");
1200 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1201 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1203 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1204 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1205 name, "start#stop#close#reset");
1206 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1207 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1210 cmdline_parse_inst_t cmd_operate_specific_port = {
1211 .f = cmd_operate_specific_port_parsed,
1213 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1215 (void *)&cmd_operate_specific_port_cmd,
1216 (void *)&cmd_operate_specific_port_port,
1217 (void *)&cmd_operate_specific_port_id,
1222 /* *** attach a specified port *** */
1223 struct cmd_operate_attach_port_result {
1224 cmdline_fixed_string_t port;
1225 cmdline_fixed_string_t keyword;
1226 cmdline_fixed_string_t identifier;
1229 static void cmd_operate_attach_port_parsed(void *parsed_result,
1230 __attribute__((unused)) struct cmdline *cl,
1231 __attribute__((unused)) void *data)
1233 struct cmd_operate_attach_port_result *res = parsed_result;
1235 if (!strcmp(res->keyword, "attach"))
1236 attach_port(res->identifier);
1238 printf("Unknown parameter\n");
1241 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1242 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1244 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1245 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1247 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1248 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1251 cmdline_parse_inst_t cmd_operate_attach_port = {
1252 .f = cmd_operate_attach_port_parsed,
1254 .help_str = "port attach <identifier>: "
1255 "(identifier: pci address or virtual dev name)",
1257 (void *)&cmd_operate_attach_port_port,
1258 (void *)&cmd_operate_attach_port_keyword,
1259 (void *)&cmd_operate_attach_port_identifier,
1264 /* *** detach a specified port *** */
1265 struct cmd_operate_detach_port_result {
1266 cmdline_fixed_string_t port;
1267 cmdline_fixed_string_t keyword;
1271 static void cmd_operate_detach_port_parsed(void *parsed_result,
1272 __attribute__((unused)) struct cmdline *cl,
1273 __attribute__((unused)) void *data)
1275 struct cmd_operate_detach_port_result *res = parsed_result;
1277 if (!strcmp(res->keyword, "detach"))
1278 detach_port(res->port_id);
1280 printf("Unknown parameter\n");
1283 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1284 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1286 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1287 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1289 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1290 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1293 cmdline_parse_inst_t cmd_operate_detach_port = {
1294 .f = cmd_operate_detach_port_parsed,
1296 .help_str = "port detach <port_id>",
1298 (void *)&cmd_operate_detach_port_port,
1299 (void *)&cmd_operate_detach_port_keyword,
1300 (void *)&cmd_operate_detach_port_port_id,
1305 /* *** configure speed for all ports *** */
1306 struct cmd_config_speed_all {
1307 cmdline_fixed_string_t port;
1308 cmdline_fixed_string_t keyword;
1309 cmdline_fixed_string_t all;
1310 cmdline_fixed_string_t item1;
1311 cmdline_fixed_string_t item2;
1312 cmdline_fixed_string_t value1;
1313 cmdline_fixed_string_t value2;
1317 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1322 if (!strcmp(duplexstr, "half")) {
1323 duplex = ETH_LINK_HALF_DUPLEX;
1324 } else if (!strcmp(duplexstr, "full")) {
1325 duplex = ETH_LINK_FULL_DUPLEX;
1326 } else if (!strcmp(duplexstr, "auto")) {
1327 duplex = ETH_LINK_FULL_DUPLEX;
1329 printf("Unknown duplex parameter\n");
1333 if (!strcmp(speedstr, "10")) {
1334 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1335 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1336 } else if (!strcmp(speedstr, "100")) {
1337 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1338 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1340 if (duplex != ETH_LINK_FULL_DUPLEX) {
1341 printf("Invalid speed/duplex parameters\n");
1344 if (!strcmp(speedstr, "1000")) {
1345 *speed = ETH_LINK_SPEED_1G;
1346 } else if (!strcmp(speedstr, "10000")) {
1347 *speed = ETH_LINK_SPEED_10G;
1348 } else if (!strcmp(speedstr, "25000")) {
1349 *speed = ETH_LINK_SPEED_25G;
1350 } else if (!strcmp(speedstr, "40000")) {
1351 *speed = ETH_LINK_SPEED_40G;
1352 } else if (!strcmp(speedstr, "50000")) {
1353 *speed = ETH_LINK_SPEED_50G;
1354 } else if (!strcmp(speedstr, "100000")) {
1355 *speed = ETH_LINK_SPEED_100G;
1356 } else if (!strcmp(speedstr, "auto")) {
1357 *speed = ETH_LINK_SPEED_AUTONEG;
1359 printf("Unknown speed parameter\n");
1368 cmd_config_speed_all_parsed(void *parsed_result,
1369 __attribute__((unused)) struct cmdline *cl,
1370 __attribute__((unused)) void *data)
1372 struct cmd_config_speed_all *res = parsed_result;
1373 uint32_t link_speed;
1376 if (!all_ports_stopped()) {
1377 printf("Please stop all ports first\n");
1381 if (parse_and_check_speed_duplex(res->value1, res->value2,
1385 RTE_ETH_FOREACH_DEV(pid) {
1386 ports[pid].dev_conf.link_speeds = link_speed;
1389 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1392 cmdline_parse_token_string_t cmd_config_speed_all_port =
1393 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1394 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1395 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1397 cmdline_parse_token_string_t cmd_config_speed_all_all =
1398 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1399 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1400 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1401 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1402 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1403 "10#100#1000#10000#25000#40000#50000#100000#auto");
1404 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1405 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1406 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1407 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1410 cmdline_parse_inst_t cmd_config_speed_all = {
1411 .f = cmd_config_speed_all_parsed,
1413 .help_str = "port config all speed "
1414 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1417 (void *)&cmd_config_speed_all_port,
1418 (void *)&cmd_config_speed_all_keyword,
1419 (void *)&cmd_config_speed_all_all,
1420 (void *)&cmd_config_speed_all_item1,
1421 (void *)&cmd_config_speed_all_value1,
1422 (void *)&cmd_config_speed_all_item2,
1423 (void *)&cmd_config_speed_all_value2,
1428 /* *** configure speed for specific port *** */
1429 struct cmd_config_speed_specific {
1430 cmdline_fixed_string_t port;
1431 cmdline_fixed_string_t keyword;
1433 cmdline_fixed_string_t item1;
1434 cmdline_fixed_string_t item2;
1435 cmdline_fixed_string_t value1;
1436 cmdline_fixed_string_t value2;
1440 cmd_config_speed_specific_parsed(void *parsed_result,
1441 __attribute__((unused)) struct cmdline *cl,
1442 __attribute__((unused)) void *data)
1444 struct cmd_config_speed_specific *res = parsed_result;
1445 uint32_t link_speed;
1447 if (!all_ports_stopped()) {
1448 printf("Please stop all ports first\n");
1452 if (port_id_is_invalid(res->id, ENABLED_WARN))
1455 if (parse_and_check_speed_duplex(res->value1, res->value2,
1459 ports[res->id].dev_conf.link_speeds = link_speed;
1461 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1465 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1468 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1471 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1472 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1473 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1474 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1476 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1477 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1478 "10#100#1000#10000#25000#40000#50000#100000#auto");
1479 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1480 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1482 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1483 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1486 cmdline_parse_inst_t cmd_config_speed_specific = {
1487 .f = cmd_config_speed_specific_parsed,
1489 .help_str = "port config <port_id> speed "
1490 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1493 (void *)&cmd_config_speed_specific_port,
1494 (void *)&cmd_config_speed_specific_keyword,
1495 (void *)&cmd_config_speed_specific_id,
1496 (void *)&cmd_config_speed_specific_item1,
1497 (void *)&cmd_config_speed_specific_value1,
1498 (void *)&cmd_config_speed_specific_item2,
1499 (void *)&cmd_config_speed_specific_value2,
1504 /* *** configure txq/rxq, txd/rxd *** */
1505 struct cmd_config_rx_tx {
1506 cmdline_fixed_string_t port;
1507 cmdline_fixed_string_t keyword;
1508 cmdline_fixed_string_t all;
1509 cmdline_fixed_string_t name;
1514 cmd_config_rx_tx_parsed(void *parsed_result,
1515 __attribute__((unused)) struct cmdline *cl,
1516 __attribute__((unused)) void *data)
1518 struct cmd_config_rx_tx *res = parsed_result;
1520 if (!all_ports_stopped()) {
1521 printf("Please stop all ports first\n");
1524 if (!strcmp(res->name, "rxq")) {
1525 if (!res->value && !nb_txq) {
1526 printf("Warning: Either rx or tx queues should be non zero\n");
1529 nb_rxq = res->value;
1531 else if (!strcmp(res->name, "txq")) {
1532 if (!res->value && !nb_rxq) {
1533 printf("Warning: Either rx or tx queues should be non zero\n");
1536 nb_txq = res->value;
1538 else if (!strcmp(res->name, "rxd")) {
1539 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1540 printf("rxd %d invalid - must be > 0 && <= %d\n",
1541 res->value, RTE_TEST_RX_DESC_MAX);
1544 nb_rxd = res->value;
1545 } else if (!strcmp(res->name, "txd")) {
1546 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1547 printf("txd %d invalid - must be > 0 && <= %d\n",
1548 res->value, RTE_TEST_TX_DESC_MAX);
1551 nb_txd = res->value;
1553 printf("Unknown parameter\n");
1561 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1564 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1565 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1566 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1567 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1568 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1569 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1570 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1571 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1573 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1574 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1576 cmdline_parse_inst_t cmd_config_rx_tx = {
1577 .f = cmd_config_rx_tx_parsed,
1579 .help_str = "port config all rxq|txq|rxd|txd <value>",
1581 (void *)&cmd_config_rx_tx_port,
1582 (void *)&cmd_config_rx_tx_keyword,
1583 (void *)&cmd_config_rx_tx_all,
1584 (void *)&cmd_config_rx_tx_name,
1585 (void *)&cmd_config_rx_tx_value,
1590 /* *** config max packet length *** */
1591 struct cmd_config_max_pkt_len_result {
1592 cmdline_fixed_string_t port;
1593 cmdline_fixed_string_t keyword;
1594 cmdline_fixed_string_t all;
1595 cmdline_fixed_string_t name;
1600 cmd_config_max_pkt_len_parsed(void *parsed_result,
1601 __attribute__((unused)) struct cmdline *cl,
1602 __attribute__((unused)) void *data)
1604 struct cmd_config_max_pkt_len_result *res = parsed_result;
1607 if (!all_ports_stopped()) {
1608 printf("Please stop all ports first\n");
1612 RTE_ETH_FOREACH_DEV(pid) {
1613 struct rte_port *port = &ports[pid];
1614 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1616 if (!strcmp(res->name, "max-pkt-len")) {
1617 if (res->value < ETHER_MIN_LEN) {
1618 printf("max-pkt-len can not be less than %d\n",
1622 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1625 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1626 if (res->value > ETHER_MAX_LEN)
1627 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1629 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1630 port->dev_conf.rxmode.offloads = rx_offloads;
1632 printf("Unknown parameter\n");
1639 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1642 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1643 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1645 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1646 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1648 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1649 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1651 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1652 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1654 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1655 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1658 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1659 .f = cmd_config_max_pkt_len_parsed,
1661 .help_str = "port config all max-pkt-len <value>",
1663 (void *)&cmd_config_max_pkt_len_port,
1664 (void *)&cmd_config_max_pkt_len_keyword,
1665 (void *)&cmd_config_max_pkt_len_all,
1666 (void *)&cmd_config_max_pkt_len_name,
1667 (void *)&cmd_config_max_pkt_len_value,
1672 /* *** configure port MTU *** */
1673 struct cmd_config_mtu_result {
1674 cmdline_fixed_string_t port;
1675 cmdline_fixed_string_t keyword;
1676 cmdline_fixed_string_t mtu;
1682 cmd_config_mtu_parsed(void *parsed_result,
1683 __attribute__((unused)) struct cmdline *cl,
1684 __attribute__((unused)) void *data)
1686 struct cmd_config_mtu_result *res = parsed_result;
1688 if (res->value < ETHER_MIN_LEN) {
1689 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1692 port_mtu_set(res->port_id, res->value);
1695 cmdline_parse_token_string_t cmd_config_mtu_port =
1696 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1698 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1699 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1701 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1702 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1704 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1705 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1706 cmdline_parse_token_num_t cmd_config_mtu_value =
1707 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1709 cmdline_parse_inst_t cmd_config_mtu = {
1710 .f = cmd_config_mtu_parsed,
1712 .help_str = "port config mtu <port_id> <value>",
1714 (void *)&cmd_config_mtu_port,
1715 (void *)&cmd_config_mtu_keyword,
1716 (void *)&cmd_config_mtu_mtu,
1717 (void *)&cmd_config_mtu_port_id,
1718 (void *)&cmd_config_mtu_value,
1723 /* *** configure rx mode *** */
1724 struct cmd_config_rx_mode_flag {
1725 cmdline_fixed_string_t port;
1726 cmdline_fixed_string_t keyword;
1727 cmdline_fixed_string_t all;
1728 cmdline_fixed_string_t name;
1729 cmdline_fixed_string_t value;
1733 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1734 __attribute__((unused)) struct cmdline *cl,
1735 __attribute__((unused)) void *data)
1737 struct cmd_config_rx_mode_flag *res = parsed_result;
1740 if (!all_ports_stopped()) {
1741 printf("Please stop all ports first\n");
1745 RTE_ETH_FOREACH_DEV(pid) {
1746 struct rte_port *port;
1747 uint64_t rx_offloads;
1750 rx_offloads = port->dev_conf.rxmode.offloads;
1751 if (!strcmp(res->name, "crc-strip")) {
1752 if (!strcmp(res->value, "on"))
1753 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1754 else if (!strcmp(res->value, "off"))
1755 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1757 printf("Unknown parameter\n");
1760 } else if (!strcmp(res->name, "scatter")) {
1761 if (!strcmp(res->value, "on")) {
1762 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1763 } else if (!strcmp(res->value, "off")) {
1764 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1766 printf("Unknown parameter\n");
1769 } else if (!strcmp(res->name, "rx-cksum")) {
1770 if (!strcmp(res->value, "on"))
1771 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1772 else if (!strcmp(res->value, "off"))
1773 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1775 printf("Unknown parameter\n");
1778 } else if (!strcmp(res->name, "rx-timestamp")) {
1779 if (!strcmp(res->value, "on"))
1780 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1781 else if (!strcmp(res->value, "off"))
1782 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1784 printf("Unknown parameter\n");
1787 } else if (!strcmp(res->name, "hw-vlan")) {
1788 if (!strcmp(res->value, "on")) {
1789 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1790 DEV_RX_OFFLOAD_VLAN_STRIP);
1791 } else if (!strcmp(res->value, "off")) {
1792 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1793 DEV_RX_OFFLOAD_VLAN_STRIP);
1795 printf("Unknown parameter\n");
1798 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1799 if (!strcmp(res->value, "on"))
1800 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1801 else if (!strcmp(res->value, "off"))
1802 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1804 printf("Unknown parameter\n");
1807 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1808 if (!strcmp(res->value, "on"))
1809 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1810 else if (!strcmp(res->value, "off"))
1811 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1813 printf("Unknown parameter\n");
1816 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1817 if (!strcmp(res->value, "on"))
1818 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1819 else if (!strcmp(res->value, "off"))
1820 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1822 printf("Unknown parameter\n");
1825 } else if (!strcmp(res->name, "drop-en")) {
1826 if (!strcmp(res->value, "on"))
1828 else if (!strcmp(res->value, "off"))
1831 printf("Unknown parameter\n");
1835 printf("Unknown parameter\n");
1838 port->dev_conf.rxmode.offloads = rx_offloads;
1843 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1846 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1848 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1849 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1851 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1852 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1853 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1854 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1855 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1856 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1857 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1858 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1861 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1862 .f = cmd_config_rx_mode_flag_parsed,
1864 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1865 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1867 (void *)&cmd_config_rx_mode_flag_port,
1868 (void *)&cmd_config_rx_mode_flag_keyword,
1869 (void *)&cmd_config_rx_mode_flag_all,
1870 (void *)&cmd_config_rx_mode_flag_name,
1871 (void *)&cmd_config_rx_mode_flag_value,
1876 /* *** configure rss *** */
1877 struct cmd_config_rss {
1878 cmdline_fixed_string_t port;
1879 cmdline_fixed_string_t keyword;
1880 cmdline_fixed_string_t all;
1881 cmdline_fixed_string_t name;
1882 cmdline_fixed_string_t value;
1886 cmd_config_rss_parsed(void *parsed_result,
1887 __attribute__((unused)) struct cmdline *cl,
1888 __attribute__((unused)) void *data)
1890 struct cmd_config_rss *res = parsed_result;
1891 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1895 if (!strcmp(res->value, "all"))
1896 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1897 ETH_RSS_UDP | ETH_RSS_SCTP |
1899 else if (!strcmp(res->value, "ip"))
1900 rss_conf.rss_hf = ETH_RSS_IP;
1901 else if (!strcmp(res->value, "udp"))
1902 rss_conf.rss_hf = ETH_RSS_UDP;
1903 else if (!strcmp(res->value, "tcp"))
1904 rss_conf.rss_hf = ETH_RSS_TCP;
1905 else if (!strcmp(res->value, "sctp"))
1906 rss_conf.rss_hf = ETH_RSS_SCTP;
1907 else if (!strcmp(res->value, "ether"))
1908 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1909 else if (!strcmp(res->value, "port"))
1910 rss_conf.rss_hf = ETH_RSS_PORT;
1911 else if (!strcmp(res->value, "vxlan"))
1912 rss_conf.rss_hf = ETH_RSS_VXLAN;
1913 else if (!strcmp(res->value, "geneve"))
1914 rss_conf.rss_hf = ETH_RSS_GENEVE;
1915 else if (!strcmp(res->value, "nvgre"))
1916 rss_conf.rss_hf = ETH_RSS_NVGRE;
1917 else if (!strcmp(res->value, "none"))
1918 rss_conf.rss_hf = 0;
1919 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1920 atoi(res->value) < 64)
1921 rss_conf.rss_hf = 1ULL << atoi(res->value);
1923 printf("Unknown parameter\n");
1926 rss_conf.rss_key = NULL;
1927 for (i = 0; i < rte_eth_dev_count(); i++) {
1928 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1930 printf("Configuration of RSS hash at ethernet port %d "
1931 "failed with error (%d): %s.\n",
1932 i, -diag, strerror(-diag));
1936 cmdline_parse_token_string_t cmd_config_rss_port =
1937 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1938 cmdline_parse_token_string_t cmd_config_rss_keyword =
1939 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1940 cmdline_parse_token_string_t cmd_config_rss_all =
1941 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1942 cmdline_parse_token_string_t cmd_config_rss_name =
1943 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1944 cmdline_parse_token_string_t cmd_config_rss_value =
1945 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1947 cmdline_parse_inst_t cmd_config_rss = {
1948 .f = cmd_config_rss_parsed,
1950 .help_str = "port config all rss "
1951 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1953 (void *)&cmd_config_rss_port,
1954 (void *)&cmd_config_rss_keyword,
1955 (void *)&cmd_config_rss_all,
1956 (void *)&cmd_config_rss_name,
1957 (void *)&cmd_config_rss_value,
1962 /* *** configure rss hash key *** */
1963 struct cmd_config_rss_hash_key {
1964 cmdline_fixed_string_t port;
1965 cmdline_fixed_string_t config;
1967 cmdline_fixed_string_t rss_hash_key;
1968 cmdline_fixed_string_t rss_type;
1969 cmdline_fixed_string_t key;
1973 hexa_digit_to_value(char hexa_digit)
1975 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1976 return (uint8_t) (hexa_digit - '0');
1977 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1978 return (uint8_t) ((hexa_digit - 'a') + 10);
1979 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1980 return (uint8_t) ((hexa_digit - 'A') + 10);
1981 /* Invalid hexa digit */
1986 parse_and_check_key_hexa_digit(char *key, int idx)
1990 hexa_v = hexa_digit_to_value(key[idx]);
1992 printf("invalid key: character %c at position %d is not a "
1993 "valid hexa digit\n", key[idx], idx);
1998 cmd_config_rss_hash_key_parsed(void *parsed_result,
1999 __attribute__((unused)) struct cmdline *cl,
2000 __attribute__((unused)) void *data)
2002 struct cmd_config_rss_hash_key *res = parsed_result;
2003 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2007 struct rte_eth_dev_info dev_info;
2008 uint8_t hash_key_size;
2011 memset(&dev_info, 0, sizeof(dev_info));
2012 rte_eth_dev_info_get(res->port_id, &dev_info);
2013 if (dev_info.hash_key_size > 0 &&
2014 dev_info.hash_key_size <= sizeof(hash_key))
2015 hash_key_size = dev_info.hash_key_size;
2017 printf("dev_info did not provide a valid hash key size\n");
2020 /* Check the length of the RSS hash key */
2021 key_len = strlen(res->key);
2022 if (key_len != (hash_key_size * 2)) {
2023 printf("key length: %d invalid - key must be a string of %d"
2024 " hexa-decimal numbers\n",
2025 (int) key_len, hash_key_size * 2);
2028 /* Translate RSS hash key into binary representation */
2029 for (i = 0; i < hash_key_size; i++) {
2030 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2033 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2036 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2038 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2042 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2043 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2044 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2045 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2047 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2048 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2049 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2050 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2051 rss_hash_key, "rss-hash-key");
2052 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2053 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2054 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2055 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2056 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2057 "ipv6-tcp-ex#ipv6-udp-ex");
2058 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2059 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2061 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2062 .f = cmd_config_rss_hash_key_parsed,
2064 .help_str = "port config <port_id> rss-hash-key "
2065 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2066 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2067 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2068 "<string of hex digits (variable length, NIC dependent)>",
2070 (void *)&cmd_config_rss_hash_key_port,
2071 (void *)&cmd_config_rss_hash_key_config,
2072 (void *)&cmd_config_rss_hash_key_port_id,
2073 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2074 (void *)&cmd_config_rss_hash_key_rss_type,
2075 (void *)&cmd_config_rss_hash_key_value,
2080 /* *** configure port rxq/txq start/stop *** */
2081 struct cmd_config_rxtx_queue {
2082 cmdline_fixed_string_t port;
2084 cmdline_fixed_string_t rxtxq;
2086 cmdline_fixed_string_t opname;
2090 cmd_config_rxtx_queue_parsed(void *parsed_result,
2091 __attribute__((unused)) struct cmdline *cl,
2092 __attribute__((unused)) void *data)
2094 struct cmd_config_rxtx_queue *res = parsed_result;
2099 if (test_done == 0) {
2100 printf("Please stop forwarding first\n");
2104 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2107 if (port_is_started(res->portid) != 1) {
2108 printf("Please start port %u first\n", res->portid);
2112 if (!strcmp(res->rxtxq, "rxq"))
2114 else if (!strcmp(res->rxtxq, "txq"))
2117 printf("Unknown parameter\n");
2121 if (isrx && rx_queue_id_is_invalid(res->qid))
2123 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2126 if (!strcmp(res->opname, "start"))
2128 else if (!strcmp(res->opname, "stop"))
2131 printf("Unknown parameter\n");
2135 if (isstart && isrx)
2136 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2137 else if (!isstart && isrx)
2138 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2139 else if (isstart && !isrx)
2140 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2142 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2144 if (ret == -ENOTSUP)
2145 printf("Function not supported in PMD driver\n");
2148 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2149 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2150 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2151 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2152 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2153 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2154 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2155 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2156 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2157 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2160 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2161 .f = cmd_config_rxtx_queue_parsed,
2163 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2165 (void *)&cmd_config_speed_all_port,
2166 (void *)&cmd_config_rxtx_queue_portid,
2167 (void *)&cmd_config_rxtx_queue_rxtxq,
2168 (void *)&cmd_config_rxtx_queue_qid,
2169 (void *)&cmd_config_rxtx_queue_opname,
2174 /* *** Configure RSS RETA *** */
2175 struct cmd_config_rss_reta {
2176 cmdline_fixed_string_t port;
2177 cmdline_fixed_string_t keyword;
2179 cmdline_fixed_string_t name;
2180 cmdline_fixed_string_t list_name;
2181 cmdline_fixed_string_t list_of_items;
2185 parse_reta_config(const char *str,
2186 struct rte_eth_rss_reta_entry64 *reta_conf,
2187 uint16_t nb_entries)
2191 uint16_t hash_index, idx, shift;
2194 const char *p, *p0 = str;
2201 unsigned long int_fld[_NUM_FLD];
2202 char *str_fld[_NUM_FLD];
2204 while ((p = strchr(p0,'(')) != NULL) {
2206 if((p0 = strchr(p,')')) == NULL)
2210 if(size >= sizeof(s))
2213 snprintf(s, sizeof(s), "%.*s", size, p);
2214 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2216 for (i = 0; i < _NUM_FLD; i++) {
2218 int_fld[i] = strtoul(str_fld[i], &end, 0);
2219 if (errno != 0 || end == str_fld[i] ||
2224 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2225 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2227 if (hash_index >= nb_entries) {
2228 printf("Invalid RETA hash index=%d\n", hash_index);
2232 idx = hash_index / RTE_RETA_GROUP_SIZE;
2233 shift = hash_index % RTE_RETA_GROUP_SIZE;
2234 reta_conf[idx].mask |= (1ULL << shift);
2235 reta_conf[idx].reta[shift] = nb_queue;
2242 cmd_set_rss_reta_parsed(void *parsed_result,
2243 __attribute__((unused)) struct cmdline *cl,
2244 __attribute__((unused)) void *data)
2247 struct rte_eth_dev_info dev_info;
2248 struct rte_eth_rss_reta_entry64 reta_conf[8];
2249 struct cmd_config_rss_reta *res = parsed_result;
2251 memset(&dev_info, 0, sizeof(dev_info));
2252 rte_eth_dev_info_get(res->port_id, &dev_info);
2253 if (dev_info.reta_size == 0) {
2254 printf("Redirection table size is 0 which is "
2255 "invalid for RSS\n");
2258 printf("The reta size of port %d is %u\n",
2259 res->port_id, dev_info.reta_size);
2260 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2261 printf("Currently do not support more than %u entries of "
2262 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2266 memset(reta_conf, 0, sizeof(reta_conf));
2267 if (!strcmp(res->list_name, "reta")) {
2268 if (parse_reta_config(res->list_of_items, reta_conf,
2269 dev_info.reta_size)) {
2270 printf("Invalid RSS Redirection Table "
2271 "config entered\n");
2274 ret = rte_eth_dev_rss_reta_update(res->port_id,
2275 reta_conf, dev_info.reta_size);
2277 printf("Bad redirection table parameter, "
2278 "return code = %d \n", ret);
2282 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2283 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2284 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2285 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2286 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2287 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2288 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2289 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2290 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2291 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2292 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2293 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2295 cmdline_parse_inst_t cmd_config_rss_reta = {
2296 .f = cmd_set_rss_reta_parsed,
2298 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2300 (void *)&cmd_config_rss_reta_port,
2301 (void *)&cmd_config_rss_reta_keyword,
2302 (void *)&cmd_config_rss_reta_port_id,
2303 (void *)&cmd_config_rss_reta_name,
2304 (void *)&cmd_config_rss_reta_list_name,
2305 (void *)&cmd_config_rss_reta_list_of_items,
2310 /* *** SHOW PORT RETA INFO *** */
2311 struct cmd_showport_reta {
2312 cmdline_fixed_string_t show;
2313 cmdline_fixed_string_t port;
2315 cmdline_fixed_string_t rss;
2316 cmdline_fixed_string_t reta;
2318 cmdline_fixed_string_t list_of_items;
2322 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2323 uint16_t nb_entries,
2327 const char *p, *p0 = str;
2332 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2333 RTE_RETA_GROUP_SIZE;
2336 p = strchr(p0, '(');
2340 p0 = strchr(p, ')');
2344 if (size >= sizeof(s)) {
2345 printf("The string size exceeds the internal buffer size\n");
2348 snprintf(s, sizeof(s), "%.*s", size, p);
2349 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2350 if (ret <= 0 || ret != num) {
2351 printf("The bits of masks do not match the number of "
2352 "reta entries: %u\n", num);
2355 for (i = 0; i < ret; i++)
2356 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2362 cmd_showport_reta_parsed(void *parsed_result,
2363 __attribute__((unused)) struct cmdline *cl,
2364 __attribute__((unused)) void *data)
2366 struct cmd_showport_reta *res = parsed_result;
2367 struct rte_eth_rss_reta_entry64 reta_conf[8];
2368 struct rte_eth_dev_info dev_info;
2369 uint16_t max_reta_size;
2371 memset(&dev_info, 0, sizeof(dev_info));
2372 rte_eth_dev_info_get(res->port_id, &dev_info);
2373 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2374 if (res->size == 0 || res->size > max_reta_size) {
2375 printf("Invalid redirection table size: %u (1-%u)\n",
2376 res->size, max_reta_size);
2380 memset(reta_conf, 0, sizeof(reta_conf));
2381 if (showport_parse_reta_config(reta_conf, res->size,
2382 res->list_of_items) < 0) {
2383 printf("Invalid string: %s for reta masks\n",
2384 res->list_of_items);
2387 port_rss_reta_info(res->port_id, reta_conf, res->size);
2390 cmdline_parse_token_string_t cmd_showport_reta_show =
2391 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2392 cmdline_parse_token_string_t cmd_showport_reta_port =
2393 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2394 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2395 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2396 cmdline_parse_token_string_t cmd_showport_reta_rss =
2397 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2398 cmdline_parse_token_string_t cmd_showport_reta_reta =
2399 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2400 cmdline_parse_token_num_t cmd_showport_reta_size =
2401 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2402 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2403 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2404 list_of_items, NULL);
2406 cmdline_parse_inst_t cmd_showport_reta = {
2407 .f = cmd_showport_reta_parsed,
2409 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2411 (void *)&cmd_showport_reta_show,
2412 (void *)&cmd_showport_reta_port,
2413 (void *)&cmd_showport_reta_port_id,
2414 (void *)&cmd_showport_reta_rss,
2415 (void *)&cmd_showport_reta_reta,
2416 (void *)&cmd_showport_reta_size,
2417 (void *)&cmd_showport_reta_list_of_items,
2422 /* *** Show RSS hash configuration *** */
2423 struct cmd_showport_rss_hash {
2424 cmdline_fixed_string_t show;
2425 cmdline_fixed_string_t port;
2427 cmdline_fixed_string_t rss_hash;
2428 cmdline_fixed_string_t rss_type;
2429 cmdline_fixed_string_t key; /* optional argument */
2432 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2433 __attribute__((unused)) struct cmdline *cl,
2436 struct cmd_showport_rss_hash *res = parsed_result;
2438 port_rss_hash_conf_show(res->port_id, res->rss_type,
2439 show_rss_key != NULL);
2442 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2443 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2444 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2445 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2446 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2447 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2448 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2449 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2451 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2452 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2453 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2454 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2455 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2456 "ipv6-tcp-ex#ipv6-udp-ex");
2457 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2458 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2460 cmdline_parse_inst_t cmd_showport_rss_hash = {
2461 .f = cmd_showport_rss_hash_parsed,
2463 .help_str = "show port <port_id> rss-hash "
2464 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2465 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2466 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2468 (void *)&cmd_showport_rss_hash_show,
2469 (void *)&cmd_showport_rss_hash_port,
2470 (void *)&cmd_showport_rss_hash_port_id,
2471 (void *)&cmd_showport_rss_hash_rss_hash,
2472 (void *)&cmd_showport_rss_hash_rss_hash_info,
2477 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2478 .f = cmd_showport_rss_hash_parsed,
2480 .help_str = "show port <port_id> rss-hash "
2481 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2482 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2483 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2485 (void *)&cmd_showport_rss_hash_show,
2486 (void *)&cmd_showport_rss_hash_port,
2487 (void *)&cmd_showport_rss_hash_port_id,
2488 (void *)&cmd_showport_rss_hash_rss_hash,
2489 (void *)&cmd_showport_rss_hash_rss_hash_info,
2490 (void *)&cmd_showport_rss_hash_rss_key,
2495 /* *** Configure DCB *** */
2496 struct cmd_config_dcb {
2497 cmdline_fixed_string_t port;
2498 cmdline_fixed_string_t config;
2500 cmdline_fixed_string_t dcb;
2501 cmdline_fixed_string_t vt;
2502 cmdline_fixed_string_t vt_en;
2504 cmdline_fixed_string_t pfc;
2505 cmdline_fixed_string_t pfc_en;
2509 cmd_config_dcb_parsed(void *parsed_result,
2510 __attribute__((unused)) struct cmdline *cl,
2511 __attribute__((unused)) void *data)
2513 struct cmd_config_dcb *res = parsed_result;
2514 portid_t port_id = res->port_id;
2515 struct rte_port *port;
2519 port = &ports[port_id];
2520 /** Check if the port is not started **/
2521 if (port->port_status != RTE_PORT_STOPPED) {
2522 printf("Please stop port %d first\n", port_id);
2526 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2527 printf("The invalid number of traffic class,"
2528 " only 4 or 8 allowed.\n");
2532 if (nb_fwd_lcores < res->num_tcs) {
2533 printf("nb_cores shouldn't be less than number of TCs.\n");
2536 if (!strncmp(res->pfc_en, "on", 2))
2541 /* DCB in VT mode */
2542 if (!strncmp(res->vt_en, "on", 2))
2543 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2544 (enum rte_eth_nb_tcs)res->num_tcs,
2547 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2548 (enum rte_eth_nb_tcs)res->num_tcs,
2553 printf("Cannot initialize network ports.\n");
2557 cmd_reconfig_device_queue(port_id, 1, 1);
2560 cmdline_parse_token_string_t cmd_config_dcb_port =
2561 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2562 cmdline_parse_token_string_t cmd_config_dcb_config =
2563 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2564 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2565 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2566 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2567 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2568 cmdline_parse_token_string_t cmd_config_dcb_vt =
2569 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2570 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2571 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2572 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2573 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2574 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2575 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2576 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2577 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2579 cmdline_parse_inst_t cmd_config_dcb = {
2580 .f = cmd_config_dcb_parsed,
2582 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2584 (void *)&cmd_config_dcb_port,
2585 (void *)&cmd_config_dcb_config,
2586 (void *)&cmd_config_dcb_port_id,
2587 (void *)&cmd_config_dcb_dcb,
2588 (void *)&cmd_config_dcb_vt,
2589 (void *)&cmd_config_dcb_vt_en,
2590 (void *)&cmd_config_dcb_num_tcs,
2591 (void *)&cmd_config_dcb_pfc,
2592 (void *)&cmd_config_dcb_pfc_en,
2597 /* *** configure number of packets per burst *** */
2598 struct cmd_config_burst {
2599 cmdline_fixed_string_t port;
2600 cmdline_fixed_string_t keyword;
2601 cmdline_fixed_string_t all;
2602 cmdline_fixed_string_t name;
2607 cmd_config_burst_parsed(void *parsed_result,
2608 __attribute__((unused)) struct cmdline *cl,
2609 __attribute__((unused)) void *data)
2611 struct cmd_config_burst *res = parsed_result;
2613 if (!all_ports_stopped()) {
2614 printf("Please stop all ports first\n");
2618 if (!strcmp(res->name, "burst")) {
2619 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2620 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2623 nb_pkt_per_burst = res->value;
2625 printf("Unknown parameter\n");
2631 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2634 cmdline_parse_token_string_t cmd_config_burst_port =
2635 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2636 cmdline_parse_token_string_t cmd_config_burst_keyword =
2637 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2638 cmdline_parse_token_string_t cmd_config_burst_all =
2639 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2640 cmdline_parse_token_string_t cmd_config_burst_name =
2641 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2642 cmdline_parse_token_num_t cmd_config_burst_value =
2643 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2645 cmdline_parse_inst_t cmd_config_burst = {
2646 .f = cmd_config_burst_parsed,
2648 .help_str = "port config all burst <value>",
2650 (void *)&cmd_config_burst_port,
2651 (void *)&cmd_config_burst_keyword,
2652 (void *)&cmd_config_burst_all,
2653 (void *)&cmd_config_burst_name,
2654 (void *)&cmd_config_burst_value,
2659 /* *** configure rx/tx queues *** */
2660 struct cmd_config_thresh {
2661 cmdline_fixed_string_t port;
2662 cmdline_fixed_string_t keyword;
2663 cmdline_fixed_string_t all;
2664 cmdline_fixed_string_t name;
2669 cmd_config_thresh_parsed(void *parsed_result,
2670 __attribute__((unused)) struct cmdline *cl,
2671 __attribute__((unused)) void *data)
2673 struct cmd_config_thresh *res = parsed_result;
2675 if (!all_ports_stopped()) {
2676 printf("Please stop all ports first\n");
2680 if (!strcmp(res->name, "txpt"))
2681 tx_pthresh = res->value;
2682 else if(!strcmp(res->name, "txht"))
2683 tx_hthresh = res->value;
2684 else if(!strcmp(res->name, "txwt"))
2685 tx_wthresh = res->value;
2686 else if(!strcmp(res->name, "rxpt"))
2687 rx_pthresh = res->value;
2688 else if(!strcmp(res->name, "rxht"))
2689 rx_hthresh = res->value;
2690 else if(!strcmp(res->name, "rxwt"))
2691 rx_wthresh = res->value;
2693 printf("Unknown parameter\n");
2699 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2702 cmdline_parse_token_string_t cmd_config_thresh_port =
2703 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2704 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2705 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2706 cmdline_parse_token_string_t cmd_config_thresh_all =
2707 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2708 cmdline_parse_token_string_t cmd_config_thresh_name =
2709 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2710 "txpt#txht#txwt#rxpt#rxht#rxwt");
2711 cmdline_parse_token_num_t cmd_config_thresh_value =
2712 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2714 cmdline_parse_inst_t cmd_config_thresh = {
2715 .f = cmd_config_thresh_parsed,
2717 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2719 (void *)&cmd_config_thresh_port,
2720 (void *)&cmd_config_thresh_keyword,
2721 (void *)&cmd_config_thresh_all,
2722 (void *)&cmd_config_thresh_name,
2723 (void *)&cmd_config_thresh_value,
2728 /* *** configure free/rs threshold *** */
2729 struct cmd_config_threshold {
2730 cmdline_fixed_string_t port;
2731 cmdline_fixed_string_t keyword;
2732 cmdline_fixed_string_t all;
2733 cmdline_fixed_string_t name;
2738 cmd_config_threshold_parsed(void *parsed_result,
2739 __attribute__((unused)) struct cmdline *cl,
2740 __attribute__((unused)) void *data)
2742 struct cmd_config_threshold *res = parsed_result;
2744 if (!all_ports_stopped()) {
2745 printf("Please stop all ports first\n");
2749 if (!strcmp(res->name, "txfreet"))
2750 tx_free_thresh = res->value;
2751 else if (!strcmp(res->name, "txrst"))
2752 tx_rs_thresh = res->value;
2753 else if (!strcmp(res->name, "rxfreet"))
2754 rx_free_thresh = res->value;
2756 printf("Unknown parameter\n");
2762 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2765 cmdline_parse_token_string_t cmd_config_threshold_port =
2766 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2767 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2768 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2770 cmdline_parse_token_string_t cmd_config_threshold_all =
2771 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2772 cmdline_parse_token_string_t cmd_config_threshold_name =
2773 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2774 "txfreet#txrst#rxfreet");
2775 cmdline_parse_token_num_t cmd_config_threshold_value =
2776 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2778 cmdline_parse_inst_t cmd_config_threshold = {
2779 .f = cmd_config_threshold_parsed,
2781 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2783 (void *)&cmd_config_threshold_port,
2784 (void *)&cmd_config_threshold_keyword,
2785 (void *)&cmd_config_threshold_all,
2786 (void *)&cmd_config_threshold_name,
2787 (void *)&cmd_config_threshold_value,
2793 struct cmd_stop_result {
2794 cmdline_fixed_string_t stop;
2797 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2798 __attribute__((unused)) struct cmdline *cl,
2799 __attribute__((unused)) void *data)
2801 stop_packet_forwarding();
2804 cmdline_parse_token_string_t cmd_stop_stop =
2805 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2807 cmdline_parse_inst_t cmd_stop = {
2808 .f = cmd_stop_parsed,
2810 .help_str = "stop: Stop packet forwarding",
2812 (void *)&cmd_stop_stop,
2817 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2820 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2821 unsigned int *parsed_items, int check_unique_values)
2823 unsigned int nb_item;
2831 * First parse all items in the list and store their value.
2836 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2838 if ((c >= '0') && (c <= '9')) {
2839 value = (unsigned int) (value * 10 + (c - '0'));
2844 printf("character %c is not a decimal digit\n", c);
2848 printf("No valid value before comma\n");
2851 if (nb_item < max_items) {
2852 parsed_items[nb_item] = value;
2858 if (nb_item >= max_items) {
2859 printf("Number of %s = %u > %u (maximum items)\n",
2860 item_name, nb_item + 1, max_items);
2863 parsed_items[nb_item++] = value;
2864 if (! check_unique_values)
2868 * Then, check that all values in the list are differents.
2869 * No optimization here...
2871 for (i = 0; i < nb_item; i++) {
2872 for (j = i + 1; j < nb_item; j++) {
2873 if (parsed_items[j] == parsed_items[i]) {
2874 printf("duplicated %s %u at index %u and %u\n",
2875 item_name, parsed_items[i], i, j);
2883 struct cmd_set_list_result {
2884 cmdline_fixed_string_t cmd_keyword;
2885 cmdline_fixed_string_t list_name;
2886 cmdline_fixed_string_t list_of_items;
2889 static void cmd_set_list_parsed(void *parsed_result,
2890 __attribute__((unused)) struct cmdline *cl,
2891 __attribute__((unused)) void *data)
2893 struct cmd_set_list_result *res;
2895 unsigned int lcorelist[RTE_MAX_LCORE];
2896 unsigned int portlist[RTE_MAX_ETHPORTS];
2898 unsigned int nb_item;
2900 if (test_done == 0) {
2901 printf("Please stop forwarding first\n");
2905 res = parsed_result;
2906 if (!strcmp(res->list_name, "corelist")) {
2907 nb_item = parse_item_list(res->list_of_items, "core",
2909 parsed_items.lcorelist, 1);
2911 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2916 if (!strcmp(res->list_name, "portlist")) {
2917 nb_item = parse_item_list(res->list_of_items, "port",
2919 parsed_items.portlist, 1);
2921 set_fwd_ports_list(parsed_items.portlist, nb_item);
2927 cmdline_parse_token_string_t cmd_set_list_keyword =
2928 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2930 cmdline_parse_token_string_t cmd_set_list_name =
2931 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2932 "corelist#portlist");
2933 cmdline_parse_token_string_t cmd_set_list_of_items =
2934 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2937 cmdline_parse_inst_t cmd_set_fwd_list = {
2938 .f = cmd_set_list_parsed,
2940 .help_str = "set corelist|portlist <list0[,list1]*>",
2942 (void *)&cmd_set_list_keyword,
2943 (void *)&cmd_set_list_name,
2944 (void *)&cmd_set_list_of_items,
2949 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2951 struct cmd_setmask_result {
2952 cmdline_fixed_string_t set;
2953 cmdline_fixed_string_t mask;
2957 static void cmd_set_mask_parsed(void *parsed_result,
2958 __attribute__((unused)) struct cmdline *cl,
2959 __attribute__((unused)) void *data)
2961 struct cmd_setmask_result *res = parsed_result;
2963 if (test_done == 0) {
2964 printf("Please stop forwarding first\n");
2967 if (!strcmp(res->mask, "coremask")) {
2968 set_fwd_lcores_mask(res->hexavalue);
2970 } else if (!strcmp(res->mask, "portmask")) {
2971 set_fwd_ports_mask(res->hexavalue);
2976 cmdline_parse_token_string_t cmd_setmask_set =
2977 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2978 cmdline_parse_token_string_t cmd_setmask_mask =
2979 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2980 "coremask#portmask");
2981 cmdline_parse_token_num_t cmd_setmask_value =
2982 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2984 cmdline_parse_inst_t cmd_set_fwd_mask = {
2985 .f = cmd_set_mask_parsed,
2987 .help_str = "set coremask|portmask <hexadecimal value>",
2989 (void *)&cmd_setmask_set,
2990 (void *)&cmd_setmask_mask,
2991 (void *)&cmd_setmask_value,
2997 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2999 struct cmd_set_result {
3000 cmdline_fixed_string_t set;
3001 cmdline_fixed_string_t what;
3005 static void cmd_set_parsed(void *parsed_result,
3006 __attribute__((unused)) struct cmdline *cl,
3007 __attribute__((unused)) void *data)
3009 struct cmd_set_result *res = parsed_result;
3010 if (!strcmp(res->what, "nbport")) {
3011 set_fwd_ports_number(res->value);
3013 } else if (!strcmp(res->what, "nbcore")) {
3014 set_fwd_lcores_number(res->value);
3016 } else if (!strcmp(res->what, "burst"))
3017 set_nb_pkt_per_burst(res->value);
3018 else if (!strcmp(res->what, "verbose"))
3019 set_verbose_level(res->value);
3022 cmdline_parse_token_string_t cmd_set_set =
3023 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3024 cmdline_parse_token_string_t cmd_set_what =
3025 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3026 "nbport#nbcore#burst#verbose");
3027 cmdline_parse_token_num_t cmd_set_value =
3028 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3030 cmdline_parse_inst_t cmd_set_numbers = {
3031 .f = cmd_set_parsed,
3033 .help_str = "set nbport|nbcore|burst|verbose <value>",
3035 (void *)&cmd_set_set,
3036 (void *)&cmd_set_what,
3037 (void *)&cmd_set_value,
3042 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3044 struct cmd_set_txpkts_result {
3045 cmdline_fixed_string_t cmd_keyword;
3046 cmdline_fixed_string_t txpkts;
3047 cmdline_fixed_string_t seg_lengths;
3051 cmd_set_txpkts_parsed(void *parsed_result,
3052 __attribute__((unused)) struct cmdline *cl,
3053 __attribute__((unused)) void *data)
3055 struct cmd_set_txpkts_result *res;
3056 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3057 unsigned int nb_segs;
3059 res = parsed_result;
3060 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3061 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3063 set_tx_pkt_segments(seg_lengths, nb_segs);
3066 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3067 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3068 cmd_keyword, "set");
3069 cmdline_parse_token_string_t cmd_set_txpkts_name =
3070 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3072 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3073 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3076 cmdline_parse_inst_t cmd_set_txpkts = {
3077 .f = cmd_set_txpkts_parsed,
3079 .help_str = "set txpkts <len0[,len1]*>",
3081 (void *)&cmd_set_txpkts_keyword,
3082 (void *)&cmd_set_txpkts_name,
3083 (void *)&cmd_set_txpkts_lengths,
3088 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3090 struct cmd_set_txsplit_result {
3091 cmdline_fixed_string_t cmd_keyword;
3092 cmdline_fixed_string_t txsplit;
3093 cmdline_fixed_string_t mode;
3097 cmd_set_txsplit_parsed(void *parsed_result,
3098 __attribute__((unused)) struct cmdline *cl,
3099 __attribute__((unused)) void *data)
3101 struct cmd_set_txsplit_result *res;
3103 res = parsed_result;
3104 set_tx_pkt_split(res->mode);
3107 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3108 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3109 cmd_keyword, "set");
3110 cmdline_parse_token_string_t cmd_set_txsplit_name =
3111 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3112 txsplit, "txsplit");
3113 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3114 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3117 cmdline_parse_inst_t cmd_set_txsplit = {
3118 .f = cmd_set_txsplit_parsed,
3120 .help_str = "set txsplit on|off|rand",
3122 (void *)&cmd_set_txsplit_keyword,
3123 (void *)&cmd_set_txsplit_name,
3124 (void *)&cmd_set_txsplit_mode,
3129 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3130 struct cmd_rx_vlan_filter_all_result {
3131 cmdline_fixed_string_t rx_vlan;
3132 cmdline_fixed_string_t what;
3133 cmdline_fixed_string_t all;
3138 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3139 __attribute__((unused)) struct cmdline *cl,
3140 __attribute__((unused)) void *data)
3142 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3144 if (!strcmp(res->what, "add"))
3145 rx_vlan_all_filter_set(res->port_id, 1);
3147 rx_vlan_all_filter_set(res->port_id, 0);
3150 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3151 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3152 rx_vlan, "rx_vlan");
3153 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3154 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3156 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3157 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3159 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3160 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3163 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3164 .f = cmd_rx_vlan_filter_all_parsed,
3166 .help_str = "rx_vlan add|rm all <port_id>: "
3167 "Add/Remove all identifiers to/from the set of VLAN "
3168 "identifiers filtered by a port",
3170 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3171 (void *)&cmd_rx_vlan_filter_all_what,
3172 (void *)&cmd_rx_vlan_filter_all_all,
3173 (void *)&cmd_rx_vlan_filter_all_portid,
3178 /* *** VLAN OFFLOAD SET ON A PORT *** */
3179 struct cmd_vlan_offload_result {
3180 cmdline_fixed_string_t vlan;
3181 cmdline_fixed_string_t set;
3182 cmdline_fixed_string_t vlan_type;
3183 cmdline_fixed_string_t what;
3184 cmdline_fixed_string_t on;
3185 cmdline_fixed_string_t port_id;
3189 cmd_vlan_offload_parsed(void *parsed_result,
3190 __attribute__((unused)) struct cmdline *cl,
3191 __attribute__((unused)) void *data)
3194 struct cmd_vlan_offload_result *res = parsed_result;
3197 portid_t port_id = 0;
3201 len = strnlen(str, STR_TOKEN_SIZE);
3203 /* Get port_id first */
3211 tmp = strtoul(str, NULL, 0);
3212 /* If port_id greater that what portid_t can represent, return */
3213 if(tmp >= RTE_MAX_ETHPORTS)
3215 port_id = (portid_t)tmp;
3217 if (!strcmp(res->on, "on"))
3222 if (!strcmp(res->what, "strip"))
3223 rx_vlan_strip_set(port_id, on);
3224 else if(!strcmp(res->what, "stripq")){
3225 uint16_t queue_id = 0;
3227 /* No queue_id, return */
3229 printf("must specify (port,queue_id)\n");
3232 tmp = strtoul(str + i + 1, NULL, 0);
3233 /* If queue_id greater that what 16-bits can represent, return */
3237 queue_id = (uint16_t)tmp;
3238 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3240 else if (!strcmp(res->what, "filter"))
3241 rx_vlan_filter_set(port_id, on);
3243 vlan_extend_set(port_id, on);
3248 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3249 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3251 cmdline_parse_token_string_t cmd_vlan_offload_set =
3252 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3254 cmdline_parse_token_string_t cmd_vlan_offload_what =
3255 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3256 what, "strip#filter#qinq#stripq");
3257 cmdline_parse_token_string_t cmd_vlan_offload_on =
3258 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3260 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3261 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3264 cmdline_parse_inst_t cmd_vlan_offload = {
3265 .f = cmd_vlan_offload_parsed,
3267 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3268 "<port_id[,queue_id]>: "
3269 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3271 (void *)&cmd_vlan_offload_vlan,
3272 (void *)&cmd_vlan_offload_set,
3273 (void *)&cmd_vlan_offload_what,
3274 (void *)&cmd_vlan_offload_on,
3275 (void *)&cmd_vlan_offload_portid,
3280 /* *** VLAN TPID SET ON A PORT *** */
3281 struct cmd_vlan_tpid_result {
3282 cmdline_fixed_string_t vlan;
3283 cmdline_fixed_string_t set;
3284 cmdline_fixed_string_t vlan_type;
3285 cmdline_fixed_string_t what;
3291 cmd_vlan_tpid_parsed(void *parsed_result,
3292 __attribute__((unused)) struct cmdline *cl,
3293 __attribute__((unused)) void *data)
3295 struct cmd_vlan_tpid_result *res = parsed_result;
3296 enum rte_vlan_type vlan_type;
3298 if (!strcmp(res->vlan_type, "inner"))
3299 vlan_type = ETH_VLAN_TYPE_INNER;
3300 else if (!strcmp(res->vlan_type, "outer"))
3301 vlan_type = ETH_VLAN_TYPE_OUTER;
3303 printf("Unknown vlan type\n");
3306 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3309 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3310 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3312 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3313 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3315 cmdline_parse_token_string_t cmd_vlan_type =
3316 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3317 vlan_type, "inner#outer");
3318 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3319 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3321 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3322 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3324 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3325 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3328 cmdline_parse_inst_t cmd_vlan_tpid = {
3329 .f = cmd_vlan_tpid_parsed,
3331 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3332 "Set the VLAN Ether type",
3334 (void *)&cmd_vlan_tpid_vlan,
3335 (void *)&cmd_vlan_tpid_set,
3336 (void *)&cmd_vlan_type,
3337 (void *)&cmd_vlan_tpid_what,
3338 (void *)&cmd_vlan_tpid_tpid,
3339 (void *)&cmd_vlan_tpid_portid,
3344 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3345 struct cmd_rx_vlan_filter_result {
3346 cmdline_fixed_string_t rx_vlan;
3347 cmdline_fixed_string_t what;
3353 cmd_rx_vlan_filter_parsed(void *parsed_result,
3354 __attribute__((unused)) struct cmdline *cl,
3355 __attribute__((unused)) void *data)
3357 struct cmd_rx_vlan_filter_result *res = parsed_result;
3359 if (!strcmp(res->what, "add"))
3360 rx_vft_set(res->port_id, res->vlan_id, 1);
3362 rx_vft_set(res->port_id, res->vlan_id, 0);
3365 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3366 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3367 rx_vlan, "rx_vlan");
3368 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3369 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3371 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3372 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3374 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3375 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3378 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3379 .f = cmd_rx_vlan_filter_parsed,
3381 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3382 "Add/Remove a VLAN identifier to/from the set of VLAN "
3383 "identifiers filtered by a port",
3385 (void *)&cmd_rx_vlan_filter_rx_vlan,
3386 (void *)&cmd_rx_vlan_filter_what,
3387 (void *)&cmd_rx_vlan_filter_vlanid,
3388 (void *)&cmd_rx_vlan_filter_portid,
3393 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3394 struct cmd_tx_vlan_set_result {
3395 cmdline_fixed_string_t tx_vlan;
3396 cmdline_fixed_string_t set;
3402 cmd_tx_vlan_set_parsed(void *parsed_result,
3403 __attribute__((unused)) struct cmdline *cl,
3404 __attribute__((unused)) void *data)
3406 struct cmd_tx_vlan_set_result *res = parsed_result;
3408 if (!port_is_stopped(res->port_id)) {
3409 printf("Please stop port %d first\n", res->port_id);
3413 tx_vlan_set(res->port_id, res->vlan_id);
3415 cmd_reconfig_device_queue(res->port_id, 1, 1);
3418 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3419 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3420 tx_vlan, "tx_vlan");
3421 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3422 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3424 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3425 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3427 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3428 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3431 cmdline_parse_inst_t cmd_tx_vlan_set = {
3432 .f = cmd_tx_vlan_set_parsed,
3434 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3435 "Enable hardware insertion of a single VLAN header "
3436 "with a given TAG Identifier in packets sent on a port",
3438 (void *)&cmd_tx_vlan_set_tx_vlan,
3439 (void *)&cmd_tx_vlan_set_set,
3440 (void *)&cmd_tx_vlan_set_portid,
3441 (void *)&cmd_tx_vlan_set_vlanid,
3446 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3447 struct cmd_tx_vlan_set_qinq_result {
3448 cmdline_fixed_string_t tx_vlan;
3449 cmdline_fixed_string_t set;
3452 uint16_t vlan_id_outer;
3456 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3457 __attribute__((unused)) struct cmdline *cl,
3458 __attribute__((unused)) void *data)
3460 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3462 if (!port_is_stopped(res->port_id)) {
3463 printf("Please stop port %d first\n", res->port_id);
3467 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3469 cmd_reconfig_device_queue(res->port_id, 1, 1);
3472 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3473 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3474 tx_vlan, "tx_vlan");
3475 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3476 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3478 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3479 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3481 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3482 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3484 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3485 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3486 vlan_id_outer, UINT16);
3488 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3489 .f = cmd_tx_vlan_set_qinq_parsed,
3491 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3492 "Enable hardware insertion of double VLAN header "
3493 "with given TAG Identifiers in packets sent on a port",
3495 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3496 (void *)&cmd_tx_vlan_set_qinq_set,
3497 (void *)&cmd_tx_vlan_set_qinq_portid,
3498 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3499 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3504 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3505 struct cmd_tx_vlan_set_pvid_result {
3506 cmdline_fixed_string_t tx_vlan;
3507 cmdline_fixed_string_t set;
3508 cmdline_fixed_string_t pvid;
3511 cmdline_fixed_string_t mode;
3515 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3516 __attribute__((unused)) struct cmdline *cl,
3517 __attribute__((unused)) void *data)
3519 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3521 if (strcmp(res->mode, "on") == 0)
3522 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3524 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3527 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3528 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3529 tx_vlan, "tx_vlan");
3530 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3531 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3533 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3534 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3536 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3537 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3539 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3540 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3542 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3543 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3546 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3547 .f = cmd_tx_vlan_set_pvid_parsed,
3549 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3551 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3552 (void *)&cmd_tx_vlan_set_pvid_set,
3553 (void *)&cmd_tx_vlan_set_pvid_pvid,
3554 (void *)&cmd_tx_vlan_set_pvid_port_id,
3555 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3556 (void *)&cmd_tx_vlan_set_pvid_mode,
3561 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3562 struct cmd_tx_vlan_reset_result {
3563 cmdline_fixed_string_t tx_vlan;
3564 cmdline_fixed_string_t reset;
3569 cmd_tx_vlan_reset_parsed(void *parsed_result,
3570 __attribute__((unused)) struct cmdline *cl,
3571 __attribute__((unused)) void *data)
3573 struct cmd_tx_vlan_reset_result *res = parsed_result;
3575 if (!port_is_stopped(res->port_id)) {
3576 printf("Please stop port %d first\n", res->port_id);
3580 tx_vlan_reset(res->port_id);
3582 cmd_reconfig_device_queue(res->port_id, 1, 1);
3585 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3586 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3587 tx_vlan, "tx_vlan");
3588 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3589 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3591 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3592 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3595 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3596 .f = cmd_tx_vlan_reset_parsed,
3598 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3599 "VLAN header in packets sent on a port",
3601 (void *)&cmd_tx_vlan_reset_tx_vlan,
3602 (void *)&cmd_tx_vlan_reset_reset,
3603 (void *)&cmd_tx_vlan_reset_portid,
3609 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3610 struct cmd_csum_result {
3611 cmdline_fixed_string_t csum;
3612 cmdline_fixed_string_t mode;
3613 cmdline_fixed_string_t proto;
3614 cmdline_fixed_string_t hwsw;
3619 csum_show(int port_id)
3621 struct rte_eth_dev_info dev_info;
3622 uint64_t tx_offloads;
3624 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3625 printf("Parse tunnel is %s\n",
3626 (ports[port_id].parse_tunnel) ? "on" : "off");
3627 printf("IP checksum offload is %s\n",
3628 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3629 printf("UDP checksum offload is %s\n",
3630 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3631 printf("TCP checksum offload is %s\n",
3632 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3633 printf("SCTP checksum offload is %s\n",
3634 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3635 printf("Outer-Ip checksum offload is %s\n",
3636 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3638 /* display warnings if configuration is not supported by the NIC */
3639 rte_eth_dev_info_get(port_id, &dev_info);
3640 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3641 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3642 printf("Warning: hardware IP checksum enabled but not "
3643 "supported by port %d\n", port_id);
3645 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3646 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3647 printf("Warning: hardware UDP checksum enabled but not "
3648 "supported by port %d\n", port_id);
3650 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3651 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3652 printf("Warning: hardware TCP checksum enabled but not "
3653 "supported by port %d\n", port_id);
3655 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3656 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3657 printf("Warning: hardware SCTP checksum enabled but not "
3658 "supported by port %d\n", port_id);
3660 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3661 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3662 printf("Warning: hardware outer IP checksum enabled but not "
3663 "supported by port %d\n", port_id);
3668 cmd_csum_parsed(void *parsed_result,
3669 __attribute__((unused)) struct cmdline *cl,
3670 __attribute__((unused)) void *data)
3672 struct cmd_csum_result *res = parsed_result;
3674 uint64_t csum_offloads = 0;
3675 struct rte_eth_dev_info dev_info;
3677 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3678 printf("invalid port %d\n", res->port_id);
3681 if (!port_is_stopped(res->port_id)) {
3682 printf("Please stop port %d first\n", res->port_id);
3686 rte_eth_dev_info_get(res->port_id, &dev_info);
3687 if (!strcmp(res->mode, "set")) {
3689 if (!strcmp(res->hwsw, "hw"))
3692 if (!strcmp(res->proto, "ip")) {
3693 if (dev_info.tx_offload_capa &
3694 DEV_TX_OFFLOAD_IPV4_CKSUM) {
3695 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3697 printf("IP checksum offload is not supported "
3698 "by port %u\n", res->port_id);
3700 } else if (!strcmp(res->proto, "udp")) {
3701 if (dev_info.tx_offload_capa &
3702 DEV_TX_OFFLOAD_UDP_CKSUM) {
3703 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3705 printf("UDP checksum offload is not supported "
3706 "by port %u\n", res->port_id);
3708 } else if (!strcmp(res->proto, "tcp")) {
3709 if (dev_info.tx_offload_capa &
3710 DEV_TX_OFFLOAD_TCP_CKSUM) {
3711 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3713 printf("TCP checksum offload is not supported "
3714 "by port %u\n", res->port_id);
3716 } else if (!strcmp(res->proto, "sctp")) {
3717 if (dev_info.tx_offload_capa &
3718 DEV_TX_OFFLOAD_SCTP_CKSUM) {
3719 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3721 printf("SCTP checksum offload is not supported "
3722 "by port %u\n", res->port_id);
3724 } else if (!strcmp(res->proto, "outer-ip")) {
3725 if (dev_info.tx_offload_capa &
3726 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) {
3728 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3730 printf("Outer IP checksum offload is not "
3731 "supported by port %u\n", res->port_id);
3736 ports[res->port_id].dev_conf.txmode.offloads |=
3739 ports[res->port_id].dev_conf.txmode.offloads &=
3743 csum_show(res->port_id);
3745 cmd_reconfig_device_queue(res->port_id, 1, 1);
3748 cmdline_parse_token_string_t cmd_csum_csum =
3749 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3751 cmdline_parse_token_string_t cmd_csum_mode =
3752 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3754 cmdline_parse_token_string_t cmd_csum_proto =
3755 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3756 proto, "ip#tcp#udp#sctp#outer-ip");
3757 cmdline_parse_token_string_t cmd_csum_hwsw =
3758 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3760 cmdline_parse_token_num_t cmd_csum_portid =
3761 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3764 cmdline_parse_inst_t cmd_csum_set = {
3765 .f = cmd_csum_parsed,
3767 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3768 "Enable/Disable hardware calculation of L3/L4 checksum when "
3769 "using csum forward engine",
3771 (void *)&cmd_csum_csum,
3772 (void *)&cmd_csum_mode,
3773 (void *)&cmd_csum_proto,
3774 (void *)&cmd_csum_hwsw,
3775 (void *)&cmd_csum_portid,
3780 cmdline_parse_token_string_t cmd_csum_mode_show =
3781 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3784 cmdline_parse_inst_t cmd_csum_show = {
3785 .f = cmd_csum_parsed,
3787 .help_str = "csum show <port_id>: Show checksum offload configuration",
3789 (void *)&cmd_csum_csum,
3790 (void *)&cmd_csum_mode_show,
3791 (void *)&cmd_csum_portid,
3796 /* Enable/disable tunnel parsing */
3797 struct cmd_csum_tunnel_result {
3798 cmdline_fixed_string_t csum;
3799 cmdline_fixed_string_t parse;
3800 cmdline_fixed_string_t onoff;
3805 cmd_csum_tunnel_parsed(void *parsed_result,
3806 __attribute__((unused)) struct cmdline *cl,
3807 __attribute__((unused)) void *data)
3809 struct cmd_csum_tunnel_result *res = parsed_result;
3811 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3814 if (!strcmp(res->onoff, "on"))
3815 ports[res->port_id].parse_tunnel = 1;
3817 ports[res->port_id].parse_tunnel = 0;
3819 csum_show(res->port_id);
3822 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3823 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3825 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3826 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3827 parse, "parse_tunnel");
3828 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3829 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3831 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3832 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3835 cmdline_parse_inst_t cmd_csum_tunnel = {
3836 .f = cmd_csum_tunnel_parsed,
3838 .help_str = "csum parse_tunnel on|off <port_id>: "
3839 "Enable/Disable parsing of tunnels for csum engine",
3841 (void *)&cmd_csum_tunnel_csum,
3842 (void *)&cmd_csum_tunnel_parse,
3843 (void *)&cmd_csum_tunnel_onoff,
3844 (void *)&cmd_csum_tunnel_portid,
3849 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3850 struct cmd_tso_set_result {
3851 cmdline_fixed_string_t tso;
3852 cmdline_fixed_string_t mode;
3858 cmd_tso_set_parsed(void *parsed_result,
3859 __attribute__((unused)) struct cmdline *cl,
3860 __attribute__((unused)) void *data)
3862 struct cmd_tso_set_result *res = parsed_result;
3863 struct rte_eth_dev_info dev_info;
3865 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3867 if (!port_is_stopped(res->port_id)) {
3868 printf("Please stop port %d first\n", res->port_id);
3872 if (!strcmp(res->mode, "set"))
3873 ports[res->port_id].tso_segsz = res->tso_segsz;
3875 rte_eth_dev_info_get(res->port_id, &dev_info);
3876 if ((ports[res->port_id].tso_segsz != 0) &&
3877 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3878 printf("Error: TSO is not supported by port %d\n",
3883 if (ports[res->port_id].tso_segsz == 0) {
3884 ports[res->port_id].dev_conf.txmode.offloads &=
3885 ~DEV_TX_OFFLOAD_TCP_TSO;
3886 printf("TSO for non-tunneled packets is disabled\n");
3888 ports[res->port_id].dev_conf.txmode.offloads |=
3889 DEV_TX_OFFLOAD_TCP_TSO;
3890 printf("TSO segment size for non-tunneled packets is %d\n",
3891 ports[res->port_id].tso_segsz);
3894 /* display warnings if configuration is not supported by the NIC */
3895 rte_eth_dev_info_get(res->port_id, &dev_info);
3896 if ((ports[res->port_id].tso_segsz != 0) &&
3897 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3898 printf("Warning: TSO enabled but not "
3899 "supported by port %d\n", res->port_id);
3902 cmd_reconfig_device_queue(res->port_id, 1, 1);
3905 cmdline_parse_token_string_t cmd_tso_set_tso =
3906 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3908 cmdline_parse_token_string_t cmd_tso_set_mode =
3909 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3911 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3912 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3914 cmdline_parse_token_num_t cmd_tso_set_portid =
3915 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3918 cmdline_parse_inst_t cmd_tso_set = {
3919 .f = cmd_tso_set_parsed,
3921 .help_str = "tso set <tso_segsz> <port_id>: "
3922 "Set TSO segment size of non-tunneled packets for csum engine "
3925 (void *)&cmd_tso_set_tso,
3926 (void *)&cmd_tso_set_mode,
3927 (void *)&cmd_tso_set_tso_segsz,
3928 (void *)&cmd_tso_set_portid,
3933 cmdline_parse_token_string_t cmd_tso_show_mode =
3934 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3938 cmdline_parse_inst_t cmd_tso_show = {
3939 .f = cmd_tso_set_parsed,
3941 .help_str = "tso show <port_id>: "
3942 "Show TSO segment size of non-tunneled packets for csum engine",
3944 (void *)&cmd_tso_set_tso,
3945 (void *)&cmd_tso_show_mode,
3946 (void *)&cmd_tso_set_portid,
3951 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3952 struct cmd_tunnel_tso_set_result {
3953 cmdline_fixed_string_t tso;
3954 cmdline_fixed_string_t mode;
3959 static struct rte_eth_dev_info
3960 check_tunnel_tso_nic_support(portid_t port_id)
3962 struct rte_eth_dev_info dev_info;
3964 rte_eth_dev_info_get(port_id, &dev_info);
3965 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3966 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
3967 "not enabled for port %d\n", port_id);
3968 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3969 printf("Warning: GRE TUNNEL TSO not supported therefore "
3970 "not enabled for port %d\n", port_id);
3971 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3972 printf("Warning: IPIP TUNNEL TSO not supported therefore "
3973 "not enabled for port %d\n", port_id);
3974 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3975 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
3976 "not enabled for port %d\n", port_id);
3981 cmd_tunnel_tso_set_parsed(void *parsed_result,
3982 __attribute__((unused)) struct cmdline *cl,
3983 __attribute__((unused)) void *data)
3985 struct cmd_tunnel_tso_set_result *res = parsed_result;
3986 struct rte_eth_dev_info dev_info;
3988 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3990 if (!port_is_stopped(res->port_id)) {
3991 printf("Please stop port %d first\n", res->port_id);
3995 if (!strcmp(res->mode, "set"))
3996 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3998 dev_info = check_tunnel_tso_nic_support(res->port_id);
3999 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4000 ports[res->port_id].dev_conf.txmode.offloads &=
4001 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4002 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4003 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4004 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4005 printf("TSO for tunneled packets is disabled\n");
4007 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4008 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4009 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4010 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4012 ports[res->port_id].dev_conf.txmode.offloads |=
4013 (tso_offloads & dev_info.tx_offload_capa);
4014 printf("TSO segment size for tunneled packets is %d\n",
4015 ports[res->port_id].tunnel_tso_segsz);
4017 /* Below conditions are needed to make it work:
4018 * (1) tunnel TSO is supported by the NIC;
4019 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4021 * (3) for tunneled pkts with outer L3 of IPv4,
4022 * "csum set outer-ip" must be set to hw, because after tso,
4023 * total_len of outer IP header is changed, and the checksum
4024 * of outer IP header calculated by sw should be wrong; that
4025 * is not necessary for IPv6 tunneled pkts because there's no
4026 * checksum in IP header anymore.
4029 if (!ports[res->port_id].parse_tunnel)
4030 printf("Warning: csum parse_tunnel must be set "
4031 "so that tunneled packets are recognized\n");
4032 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4033 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4034 printf("Warning: csum set outer-ip must be set to hw "
4035 "if outer L3 is IPv4; not necessary for IPv6\n");
4038 cmd_reconfig_device_queue(res->port_id, 1, 1);
4041 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4042 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4044 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4045 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4047 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4048 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4050 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4051 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4054 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4055 .f = cmd_tunnel_tso_set_parsed,
4057 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4058 "Set TSO segment size of tunneled packets for csum engine "
4061 (void *)&cmd_tunnel_tso_set_tso,
4062 (void *)&cmd_tunnel_tso_set_mode,
4063 (void *)&cmd_tunnel_tso_set_tso_segsz,
4064 (void *)&cmd_tunnel_tso_set_portid,
4069 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4070 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4074 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4075 .f = cmd_tunnel_tso_set_parsed,
4077 .help_str = "tunnel_tso show <port_id> "
4078 "Show TSO segment size of tunneled packets for csum engine",
4080 (void *)&cmd_tunnel_tso_set_tso,
4081 (void *)&cmd_tunnel_tso_show_mode,
4082 (void *)&cmd_tunnel_tso_set_portid,
4087 /* *** SET GRO FOR A PORT *** */
4088 struct cmd_gro_enable_result {
4089 cmdline_fixed_string_t cmd_set;
4090 cmdline_fixed_string_t cmd_port;
4091 cmdline_fixed_string_t cmd_keyword;
4092 cmdline_fixed_string_t cmd_onoff;
4097 cmd_gro_enable_parsed(void *parsed_result,
4098 __attribute__((unused)) struct cmdline *cl,
4099 __attribute__((unused)) void *data)
4101 struct cmd_gro_enable_result *res;
4103 res = parsed_result;
4104 if (!strcmp(res->cmd_keyword, "gro"))
4105 setup_gro(res->cmd_onoff, res->cmd_pid);
4108 cmdline_parse_token_string_t cmd_gro_enable_set =
4109 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4111 cmdline_parse_token_string_t cmd_gro_enable_port =
4112 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4113 cmd_keyword, "port");
4114 cmdline_parse_token_num_t cmd_gro_enable_pid =
4115 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4117 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4118 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4119 cmd_keyword, "gro");
4120 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4121 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4122 cmd_onoff, "on#off");
4124 cmdline_parse_inst_t cmd_gro_enable = {
4125 .f = cmd_gro_enable_parsed,
4127 .help_str = "set port <port_id> gro on|off",
4129 (void *)&cmd_gro_enable_set,
4130 (void *)&cmd_gro_enable_port,
4131 (void *)&cmd_gro_enable_pid,
4132 (void *)&cmd_gro_enable_keyword,
4133 (void *)&cmd_gro_enable_onoff,
4138 /* *** DISPLAY GRO CONFIGURATION *** */
4139 struct cmd_gro_show_result {
4140 cmdline_fixed_string_t cmd_show;
4141 cmdline_fixed_string_t cmd_port;
4142 cmdline_fixed_string_t cmd_keyword;
4147 cmd_gro_show_parsed(void *parsed_result,
4148 __attribute__((unused)) struct cmdline *cl,
4149 __attribute__((unused)) void *data)
4151 struct cmd_gro_show_result *res;
4153 res = parsed_result;
4154 if (!strcmp(res->cmd_keyword, "gro"))
4155 show_gro(res->cmd_pid);
4158 cmdline_parse_token_string_t cmd_gro_show_show =
4159 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4161 cmdline_parse_token_string_t cmd_gro_show_port =
4162 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4164 cmdline_parse_token_num_t cmd_gro_show_pid =
4165 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4167 cmdline_parse_token_string_t cmd_gro_show_keyword =
4168 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4169 cmd_keyword, "gro");
4171 cmdline_parse_inst_t cmd_gro_show = {
4172 .f = cmd_gro_show_parsed,
4174 .help_str = "show port <port_id> gro",
4176 (void *)&cmd_gro_show_show,
4177 (void *)&cmd_gro_show_port,
4178 (void *)&cmd_gro_show_pid,
4179 (void *)&cmd_gro_show_keyword,
4184 /* *** SET FLUSH CYCLES FOR GRO *** */
4185 struct cmd_gro_flush_result {
4186 cmdline_fixed_string_t cmd_set;
4187 cmdline_fixed_string_t cmd_keyword;
4188 cmdline_fixed_string_t cmd_flush;
4193 cmd_gro_flush_parsed(void *parsed_result,
4194 __attribute__((unused)) struct cmdline *cl,
4195 __attribute__((unused)) void *data)
4197 struct cmd_gro_flush_result *res;
4199 res = parsed_result;
4200 if ((!strcmp(res->cmd_keyword, "gro")) &&
4201 (!strcmp(res->cmd_flush, "flush")))
4202 setup_gro_flush_cycles(res->cmd_cycles);
4205 cmdline_parse_token_string_t cmd_gro_flush_set =
4206 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4208 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4209 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4210 cmd_keyword, "gro");
4211 cmdline_parse_token_string_t cmd_gro_flush_flush =
4212 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4213 cmd_flush, "flush");
4214 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4215 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4218 cmdline_parse_inst_t cmd_gro_flush = {
4219 .f = cmd_gro_flush_parsed,
4221 .help_str = "set gro flush <cycles>",
4223 (void *)&cmd_gro_flush_set,
4224 (void *)&cmd_gro_flush_keyword,
4225 (void *)&cmd_gro_flush_flush,
4226 (void *)&cmd_gro_flush_cycles,
4231 /* *** ENABLE/DISABLE GSO *** */
4232 struct cmd_gso_enable_result {
4233 cmdline_fixed_string_t cmd_set;
4234 cmdline_fixed_string_t cmd_port;
4235 cmdline_fixed_string_t cmd_keyword;
4236 cmdline_fixed_string_t cmd_mode;
4241 cmd_gso_enable_parsed(void *parsed_result,
4242 __attribute__((unused)) struct cmdline *cl,
4243 __attribute__((unused)) void *data)
4245 struct cmd_gso_enable_result *res;
4247 res = parsed_result;
4248 if (!strcmp(res->cmd_keyword, "gso"))
4249 setup_gso(res->cmd_mode, res->cmd_pid);
4252 cmdline_parse_token_string_t cmd_gso_enable_set =
4253 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4255 cmdline_parse_token_string_t cmd_gso_enable_port =
4256 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4258 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4259 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4260 cmd_keyword, "gso");
4261 cmdline_parse_token_string_t cmd_gso_enable_mode =
4262 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4263 cmd_mode, "on#off");
4264 cmdline_parse_token_num_t cmd_gso_enable_pid =
4265 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4268 cmdline_parse_inst_t cmd_gso_enable = {
4269 .f = cmd_gso_enable_parsed,
4271 .help_str = "set port <port_id> gso on|off",
4273 (void *)&cmd_gso_enable_set,
4274 (void *)&cmd_gso_enable_port,
4275 (void *)&cmd_gso_enable_pid,
4276 (void *)&cmd_gso_enable_keyword,
4277 (void *)&cmd_gso_enable_mode,
4282 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4283 struct cmd_gso_size_result {
4284 cmdline_fixed_string_t cmd_set;
4285 cmdline_fixed_string_t cmd_keyword;
4286 cmdline_fixed_string_t cmd_segsz;
4291 cmd_gso_size_parsed(void *parsed_result,
4292 __attribute__((unused)) struct cmdline *cl,
4293 __attribute__((unused)) void *data)
4295 struct cmd_gso_size_result *res = parsed_result;
4297 if (test_done == 0) {
4298 printf("Before setting GSO segsz, please first"
4299 " stop fowarding\n");
4303 if (!strcmp(res->cmd_keyword, "gso") &&
4304 !strcmp(res->cmd_segsz, "segsz")) {
4305 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4306 printf("gso_size should be larger than %zu."
4307 " Please input a legal value\n",
4308 RTE_GSO_SEG_SIZE_MIN);
4310 gso_max_segment_size = res->cmd_size;
4314 cmdline_parse_token_string_t cmd_gso_size_set =
4315 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4317 cmdline_parse_token_string_t cmd_gso_size_keyword =
4318 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4319 cmd_keyword, "gso");
4320 cmdline_parse_token_string_t cmd_gso_size_segsz =
4321 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4322 cmd_segsz, "segsz");
4323 cmdline_parse_token_num_t cmd_gso_size_size =
4324 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4327 cmdline_parse_inst_t cmd_gso_size = {
4328 .f = cmd_gso_size_parsed,
4330 .help_str = "set gso segsz <length>",
4332 (void *)&cmd_gso_size_set,
4333 (void *)&cmd_gso_size_keyword,
4334 (void *)&cmd_gso_size_segsz,
4335 (void *)&cmd_gso_size_size,
4340 /* *** SHOW GSO CONFIGURATION *** */
4341 struct cmd_gso_show_result {
4342 cmdline_fixed_string_t cmd_show;
4343 cmdline_fixed_string_t cmd_port;
4344 cmdline_fixed_string_t cmd_keyword;
4349 cmd_gso_show_parsed(void *parsed_result,
4350 __attribute__((unused)) struct cmdline *cl,
4351 __attribute__((unused)) void *data)
4353 struct cmd_gso_show_result *res = parsed_result;
4355 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4356 printf("invalid port id %u\n", res->cmd_pid);
4359 if (!strcmp(res->cmd_keyword, "gso")) {
4360 if (gso_ports[res->cmd_pid].enable) {
4361 printf("Max GSO'd packet size: %uB\n"
4362 "Supported GSO types: TCP/IPv4, "
4363 "VxLAN with inner TCP/IPv4 packet, "
4364 "GRE with inner TCP/IPv4 packet\n",
4365 gso_max_segment_size);
4367 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4371 cmdline_parse_token_string_t cmd_gso_show_show =
4372 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4374 cmdline_parse_token_string_t cmd_gso_show_port =
4375 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4377 cmdline_parse_token_string_t cmd_gso_show_keyword =
4378 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4379 cmd_keyword, "gso");
4380 cmdline_parse_token_num_t cmd_gso_show_pid =
4381 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4384 cmdline_parse_inst_t cmd_gso_show = {
4385 .f = cmd_gso_show_parsed,
4387 .help_str = "show port <port_id> gso",
4389 (void *)&cmd_gso_show_show,
4390 (void *)&cmd_gso_show_port,
4391 (void *)&cmd_gso_show_pid,
4392 (void *)&cmd_gso_show_keyword,
4397 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4398 struct cmd_set_flush_rx {
4399 cmdline_fixed_string_t set;
4400 cmdline_fixed_string_t flush_rx;
4401 cmdline_fixed_string_t mode;
4405 cmd_set_flush_rx_parsed(void *parsed_result,
4406 __attribute__((unused)) struct cmdline *cl,
4407 __attribute__((unused)) void *data)
4409 struct cmd_set_flush_rx *res = parsed_result;
4410 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4413 cmdline_parse_token_string_t cmd_setflushrx_set =
4414 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4416 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4417 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4418 flush_rx, "flush_rx");
4419 cmdline_parse_token_string_t cmd_setflushrx_mode =
4420 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4424 cmdline_parse_inst_t cmd_set_flush_rx = {
4425 .f = cmd_set_flush_rx_parsed,
4426 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4429 (void *)&cmd_setflushrx_set,
4430 (void *)&cmd_setflushrx_flush_rx,
4431 (void *)&cmd_setflushrx_mode,
4436 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4437 struct cmd_set_link_check {
4438 cmdline_fixed_string_t set;
4439 cmdline_fixed_string_t link_check;
4440 cmdline_fixed_string_t mode;
4444 cmd_set_link_check_parsed(void *parsed_result,
4445 __attribute__((unused)) struct cmdline *cl,
4446 __attribute__((unused)) void *data)
4448 struct cmd_set_link_check *res = parsed_result;
4449 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4452 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4453 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4455 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4456 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4457 link_check, "link_check");
4458 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4459 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4463 cmdline_parse_inst_t cmd_set_link_check = {
4464 .f = cmd_set_link_check_parsed,
4465 .help_str = "set link_check on|off: Enable/Disable link status check "
4466 "when starting/stopping a port",
4469 (void *)&cmd_setlinkcheck_set,
4470 (void *)&cmd_setlinkcheck_link_check,
4471 (void *)&cmd_setlinkcheck_mode,
4476 /* *** SET NIC BYPASS MODE *** */
4477 struct cmd_set_bypass_mode_result {
4478 cmdline_fixed_string_t set;
4479 cmdline_fixed_string_t bypass;
4480 cmdline_fixed_string_t mode;
4481 cmdline_fixed_string_t value;
4486 cmd_set_bypass_mode_parsed(void *parsed_result,
4487 __attribute__((unused)) struct cmdline *cl,
4488 __attribute__((unused)) void *data)
4490 struct cmd_set_bypass_mode_result *res = parsed_result;
4491 portid_t port_id = res->port_id;
4492 int32_t rc = -EINVAL;
4494 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4495 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4497 if (!strcmp(res->value, "bypass"))
4498 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4499 else if (!strcmp(res->value, "isolate"))
4500 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4502 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4504 /* Set the bypass mode for the relevant port. */
4505 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4508 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4511 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4512 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4514 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4515 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4517 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4518 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4520 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4521 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4522 value, "normal#bypass#isolate");
4523 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4524 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4527 cmdline_parse_inst_t cmd_set_bypass_mode = {
4528 .f = cmd_set_bypass_mode_parsed,
4529 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4530 "Set the NIC bypass mode for port_id",
4533 (void *)&cmd_setbypass_mode_set,
4534 (void *)&cmd_setbypass_mode_bypass,
4535 (void *)&cmd_setbypass_mode_mode,
4536 (void *)&cmd_setbypass_mode_value,
4537 (void *)&cmd_setbypass_mode_port,
4542 /* *** SET NIC BYPASS EVENT *** */
4543 struct cmd_set_bypass_event_result {
4544 cmdline_fixed_string_t set;
4545 cmdline_fixed_string_t bypass;
4546 cmdline_fixed_string_t event;
4547 cmdline_fixed_string_t event_value;
4548 cmdline_fixed_string_t mode;
4549 cmdline_fixed_string_t mode_value;
4554 cmd_set_bypass_event_parsed(void *parsed_result,
4555 __attribute__((unused)) struct cmdline *cl,
4556 __attribute__((unused)) void *data)
4558 int32_t rc = -EINVAL;
4559 struct cmd_set_bypass_event_result *res = parsed_result;
4560 portid_t port_id = res->port_id;
4562 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4563 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4564 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4566 if (!strcmp(res->event_value, "timeout"))
4567 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4568 else if (!strcmp(res->event_value, "os_on"))
4569 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4570 else if (!strcmp(res->event_value, "os_off"))
4571 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4572 else if (!strcmp(res->event_value, "power_on"))
4573 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4574 else if (!strcmp(res->event_value, "power_off"))
4575 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4577 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4579 if (!strcmp(res->mode_value, "bypass"))
4580 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4581 else if (!strcmp(res->mode_value, "isolate"))
4582 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4584 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4586 /* Set the watchdog timeout. */
4587 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4590 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4591 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4595 printf("Failed to set timeout value %u "
4596 "for port %d, errto code: %d.\n",
4597 bypass_timeout, port_id, rc);
4601 /* Set the bypass event to transition to bypass mode. */
4602 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4607 printf("\t Failed to set bypass event for port = %d.\n",
4611 cmdline_parse_token_string_t cmd_setbypass_event_set =
4612 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4614 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4615 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4617 cmdline_parse_token_string_t cmd_setbypass_event_event =
4618 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4620 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4621 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4622 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4623 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4624 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4626 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4627 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4628 mode_value, "normal#bypass#isolate");
4629 cmdline_parse_token_num_t cmd_setbypass_event_port =
4630 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4633 cmdline_parse_inst_t cmd_set_bypass_event = {
4634 .f = cmd_set_bypass_event_parsed,
4635 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4636 "power_off mode normal|bypass|isolate <port_id>: "
4637 "Set the NIC bypass event mode for port_id",
4640 (void *)&cmd_setbypass_event_set,
4641 (void *)&cmd_setbypass_event_bypass,
4642 (void *)&cmd_setbypass_event_event,
4643 (void *)&cmd_setbypass_event_event_value,
4644 (void *)&cmd_setbypass_event_mode,
4645 (void *)&cmd_setbypass_event_mode_value,
4646 (void *)&cmd_setbypass_event_port,
4652 /* *** SET NIC BYPASS TIMEOUT *** */
4653 struct cmd_set_bypass_timeout_result {
4654 cmdline_fixed_string_t set;
4655 cmdline_fixed_string_t bypass;
4656 cmdline_fixed_string_t timeout;
4657 cmdline_fixed_string_t value;
4661 cmd_set_bypass_timeout_parsed(void *parsed_result,
4662 __attribute__((unused)) struct cmdline *cl,
4663 __attribute__((unused)) void *data)
4665 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4667 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4668 if (!strcmp(res->value, "1.5"))
4669 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4670 else if (!strcmp(res->value, "2"))
4671 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4672 else if (!strcmp(res->value, "3"))
4673 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4674 else if (!strcmp(res->value, "4"))
4675 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4676 else if (!strcmp(res->value, "8"))
4677 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4678 else if (!strcmp(res->value, "16"))
4679 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4680 else if (!strcmp(res->value, "32"))
4681 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4683 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4687 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4688 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4690 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4691 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4693 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4694 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4695 timeout, "timeout");
4696 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4697 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4698 value, "0#1.5#2#3#4#8#16#32");
4700 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4701 .f = cmd_set_bypass_timeout_parsed,
4702 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4703 "Set the NIC bypass watchdog timeout in seconds",
4706 (void *)&cmd_setbypass_timeout_set,
4707 (void *)&cmd_setbypass_timeout_bypass,
4708 (void *)&cmd_setbypass_timeout_timeout,
4709 (void *)&cmd_setbypass_timeout_value,
4714 /* *** SHOW NIC BYPASS MODE *** */
4715 struct cmd_show_bypass_config_result {
4716 cmdline_fixed_string_t show;
4717 cmdline_fixed_string_t bypass;
4718 cmdline_fixed_string_t config;
4723 cmd_show_bypass_config_parsed(void *parsed_result,
4724 __attribute__((unused)) struct cmdline *cl,
4725 __attribute__((unused)) void *data)
4727 struct cmd_show_bypass_config_result *res = parsed_result;
4728 portid_t port_id = res->port_id;
4730 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4731 uint32_t event_mode;
4732 uint32_t bypass_mode;
4733 uint32_t timeout = bypass_timeout;
4736 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4737 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4738 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4739 {"UNKNOWN", "normal", "bypass", "isolate"};
4740 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4747 int num_events = (sizeof events) / (sizeof events[0]);
4749 /* Display the bypass mode.*/
4750 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4751 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4755 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4756 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4758 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4761 /* Display the bypass timeout.*/
4762 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4763 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4765 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4767 /* Display the bypass events and associated modes. */
4768 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4770 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4771 printf("\tFailed to get bypass mode for event = %s\n",
4774 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4775 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4777 printf("\tbypass event: %-16s = %s\n", events[i],
4783 printf("\tFailed to get bypass configuration for port = %d\n",
4787 cmdline_parse_token_string_t cmd_showbypass_config_show =
4788 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4790 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4791 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4793 cmdline_parse_token_string_t cmd_showbypass_config_config =
4794 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4796 cmdline_parse_token_num_t cmd_showbypass_config_port =
4797 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4800 cmdline_parse_inst_t cmd_show_bypass_config = {
4801 .f = cmd_show_bypass_config_parsed,
4802 .help_str = "show bypass config <port_id>: "
4803 "Show the NIC bypass config for port_id",
4806 (void *)&cmd_showbypass_config_show,
4807 (void *)&cmd_showbypass_config_bypass,
4808 (void *)&cmd_showbypass_config_config,
4809 (void *)&cmd_showbypass_config_port,
4814 #ifdef RTE_LIBRTE_PMD_BOND
4815 /* *** SET BONDING MODE *** */
4816 struct cmd_set_bonding_mode_result {
4817 cmdline_fixed_string_t set;
4818 cmdline_fixed_string_t bonding;
4819 cmdline_fixed_string_t mode;
4824 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4825 __attribute__((unused)) struct cmdline *cl,
4826 __attribute__((unused)) void *data)
4828 struct cmd_set_bonding_mode_result *res = parsed_result;
4829 portid_t port_id = res->port_id;
4831 /* Set the bonding mode for the relevant port. */
4832 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4833 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4836 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4837 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4839 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4840 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4841 bonding, "bonding");
4842 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4843 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4845 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4846 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4848 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4849 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4852 cmdline_parse_inst_t cmd_set_bonding_mode = {
4853 .f = cmd_set_bonding_mode_parsed,
4854 .help_str = "set bonding mode <mode_value> <port_id>: "
4855 "Set the bonding mode for port_id",
4858 (void *) &cmd_setbonding_mode_set,
4859 (void *) &cmd_setbonding_mode_bonding,
4860 (void *) &cmd_setbonding_mode_mode,
4861 (void *) &cmd_setbonding_mode_value,
4862 (void *) &cmd_setbonding_mode_port,
4867 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4868 struct cmd_set_bonding_lacp_dedicated_queues_result {
4869 cmdline_fixed_string_t set;
4870 cmdline_fixed_string_t bonding;
4871 cmdline_fixed_string_t lacp;
4872 cmdline_fixed_string_t dedicated_queues;
4874 cmdline_fixed_string_t mode;
4877 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4878 __attribute__((unused)) struct cmdline *cl,
4879 __attribute__((unused)) void *data)
4881 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4882 portid_t port_id = res->port_id;
4883 struct rte_port *port;
4885 port = &ports[port_id];
4887 /** Check if the port is not started **/
4888 if (port->port_status != RTE_PORT_STOPPED) {
4889 printf("Please stop port %d first\n", port_id);
4893 if (!strcmp(res->mode, "enable")) {
4894 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4895 printf("Dedicate queues for LACP control packets"
4898 printf("Enabling dedicate queues for LACP control "
4899 "packets on port %d failed\n", port_id);
4900 } else if (!strcmp(res->mode, "disable")) {
4901 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4902 printf("Dedicated queues for LACP control packets "
4905 printf("Disabling dedicated queues for LACP control "
4906 "traffic on port %d failed\n", port_id);
4910 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4911 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4913 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4914 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4915 bonding, "bonding");
4916 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4917 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4919 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4920 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4921 dedicated_queues, "dedicated_queues");
4922 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4923 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4925 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4926 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4927 mode, "enable#disable");
4929 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4930 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4931 .help_str = "set bonding lacp dedicated_queues <port_id> "
4933 "Enable/disable dedicated queues for LACP control traffic for port_id",
4936 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4937 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4938 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4939 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4940 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4941 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4946 /* *** SET BALANCE XMIT POLICY *** */
4947 struct cmd_set_bonding_balance_xmit_policy_result {
4948 cmdline_fixed_string_t set;
4949 cmdline_fixed_string_t bonding;
4950 cmdline_fixed_string_t balance_xmit_policy;
4952 cmdline_fixed_string_t policy;
4955 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4956 __attribute__((unused)) struct cmdline *cl,
4957 __attribute__((unused)) void *data)
4959 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4960 portid_t port_id = res->port_id;
4963 if (!strcmp(res->policy, "l2")) {
4964 policy = BALANCE_XMIT_POLICY_LAYER2;
4965 } else if (!strcmp(res->policy, "l23")) {
4966 policy = BALANCE_XMIT_POLICY_LAYER23;
4967 } else if (!strcmp(res->policy, "l34")) {
4968 policy = BALANCE_XMIT_POLICY_LAYER34;
4970 printf("\t Invalid xmit policy selection");
4974 /* Set the bonding mode for the relevant port. */
4975 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4976 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4981 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4982 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4984 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4985 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4986 bonding, "bonding");
4987 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4988 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4989 balance_xmit_policy, "balance_xmit_policy");
4990 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4991 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4993 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4994 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4995 policy, "l2#l23#l34");
4997 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4998 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4999 .help_str = "set bonding balance_xmit_policy <port_id> "
5001 "Set the bonding balance_xmit_policy for port_id",
5004 (void *)&cmd_setbonding_balance_xmit_policy_set,
5005 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5006 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5007 (void *)&cmd_setbonding_balance_xmit_policy_port,
5008 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5013 /* *** SHOW NIC BONDING CONFIGURATION *** */
5014 struct cmd_show_bonding_config_result {
5015 cmdline_fixed_string_t show;
5016 cmdline_fixed_string_t bonding;
5017 cmdline_fixed_string_t config;
5021 static void cmd_show_bonding_config_parsed(void *parsed_result,
5022 __attribute__((unused)) struct cmdline *cl,
5023 __attribute__((unused)) void *data)
5025 struct cmd_show_bonding_config_result *res = parsed_result;
5026 int bonding_mode, agg_mode;
5027 portid_t slaves[RTE_MAX_ETHPORTS];
5028 int num_slaves, num_active_slaves;
5031 portid_t port_id = res->port_id;
5033 /* Display the bonding mode.*/
5034 bonding_mode = rte_eth_bond_mode_get(port_id);
5035 if (bonding_mode < 0) {
5036 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5039 printf("\tBonding mode: %d\n", bonding_mode);
5041 if (bonding_mode == BONDING_MODE_BALANCE) {
5042 int balance_xmit_policy;
5044 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5045 if (balance_xmit_policy < 0) {
5046 printf("\tFailed to get balance xmit policy for port = %d\n",
5050 printf("\tBalance Xmit Policy: ");
5052 switch (balance_xmit_policy) {
5053 case BALANCE_XMIT_POLICY_LAYER2:
5054 printf("BALANCE_XMIT_POLICY_LAYER2");
5056 case BALANCE_XMIT_POLICY_LAYER23:
5057 printf("BALANCE_XMIT_POLICY_LAYER23");
5059 case BALANCE_XMIT_POLICY_LAYER34:
5060 printf("BALANCE_XMIT_POLICY_LAYER34");
5067 if (bonding_mode == BONDING_MODE_8023AD) {
5068 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5069 printf("\tIEEE802.3AD Aggregator Mode: ");
5072 printf("bandwidth");
5084 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5086 if (num_slaves < 0) {
5087 printf("\tFailed to get slave list for port = %d\n", port_id);
5090 if (num_slaves > 0) {
5091 printf("\tSlaves (%d): [", num_slaves);
5092 for (i = 0; i < num_slaves - 1; i++)
5093 printf("%d ", slaves[i]);
5095 printf("%d]\n", slaves[num_slaves - 1]);
5097 printf("\tSlaves: []\n");
5101 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5104 if (num_active_slaves < 0) {
5105 printf("\tFailed to get active slave list for port = %d\n", port_id);
5108 if (num_active_slaves > 0) {
5109 printf("\tActive Slaves (%d): [", num_active_slaves);
5110 for (i = 0; i < num_active_slaves - 1; i++)
5111 printf("%d ", slaves[i]);
5113 printf("%d]\n", slaves[num_active_slaves - 1]);
5116 printf("\tActive Slaves: []\n");
5120 primary_id = rte_eth_bond_primary_get(port_id);
5121 if (primary_id < 0) {
5122 printf("\tFailed to get primary slave for port = %d\n", port_id);
5125 printf("\tPrimary: [%d]\n", primary_id);
5129 cmdline_parse_token_string_t cmd_showbonding_config_show =
5130 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5132 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5133 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5134 bonding, "bonding");
5135 cmdline_parse_token_string_t cmd_showbonding_config_config =
5136 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5138 cmdline_parse_token_num_t cmd_showbonding_config_port =
5139 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5142 cmdline_parse_inst_t cmd_show_bonding_config = {
5143 .f = cmd_show_bonding_config_parsed,
5144 .help_str = "show bonding config <port_id>: "
5145 "Show the bonding config for port_id",
5148 (void *)&cmd_showbonding_config_show,
5149 (void *)&cmd_showbonding_config_bonding,
5150 (void *)&cmd_showbonding_config_config,
5151 (void *)&cmd_showbonding_config_port,
5156 /* *** SET BONDING PRIMARY *** */
5157 struct cmd_set_bonding_primary_result {
5158 cmdline_fixed_string_t set;
5159 cmdline_fixed_string_t bonding;
5160 cmdline_fixed_string_t primary;
5165 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5166 __attribute__((unused)) struct cmdline *cl,
5167 __attribute__((unused)) void *data)
5169 struct cmd_set_bonding_primary_result *res = parsed_result;
5170 portid_t master_port_id = res->port_id;
5171 portid_t slave_port_id = res->slave_id;
5173 /* Set the primary slave for a bonded device. */
5174 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5175 printf("\t Failed to set primary slave for port = %d.\n",
5182 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5183 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5185 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5186 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5187 bonding, "bonding");
5188 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5189 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5190 primary, "primary");
5191 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5192 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5194 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5195 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5198 cmdline_parse_inst_t cmd_set_bonding_primary = {
5199 .f = cmd_set_bonding_primary_parsed,
5200 .help_str = "set bonding primary <slave_id> <port_id>: "
5201 "Set the primary slave for port_id",
5204 (void *)&cmd_setbonding_primary_set,
5205 (void *)&cmd_setbonding_primary_bonding,
5206 (void *)&cmd_setbonding_primary_primary,
5207 (void *)&cmd_setbonding_primary_slave,
5208 (void *)&cmd_setbonding_primary_port,
5213 /* *** ADD SLAVE *** */
5214 struct cmd_add_bonding_slave_result {
5215 cmdline_fixed_string_t add;
5216 cmdline_fixed_string_t bonding;
5217 cmdline_fixed_string_t slave;
5222 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5223 __attribute__((unused)) struct cmdline *cl,
5224 __attribute__((unused)) void *data)
5226 struct cmd_add_bonding_slave_result *res = parsed_result;
5227 portid_t master_port_id = res->port_id;
5228 portid_t slave_port_id = res->slave_id;
5230 /* add the slave for a bonded device. */
5231 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5232 printf("\t Failed to add slave %d to master port = %d.\n",
5233 slave_port_id, master_port_id);
5237 set_port_slave_flag(slave_port_id);
5240 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5241 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5243 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5244 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5245 bonding, "bonding");
5246 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5247 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5249 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5250 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5252 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5253 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5256 cmdline_parse_inst_t cmd_add_bonding_slave = {
5257 .f = cmd_add_bonding_slave_parsed,
5258 .help_str = "add bonding slave <slave_id> <port_id>: "
5259 "Add a slave device to a bonded device",
5262 (void *)&cmd_addbonding_slave_add,
5263 (void *)&cmd_addbonding_slave_bonding,
5264 (void *)&cmd_addbonding_slave_slave,
5265 (void *)&cmd_addbonding_slave_slaveid,
5266 (void *)&cmd_addbonding_slave_port,
5271 /* *** REMOVE SLAVE *** */
5272 struct cmd_remove_bonding_slave_result {
5273 cmdline_fixed_string_t remove;
5274 cmdline_fixed_string_t bonding;
5275 cmdline_fixed_string_t slave;
5280 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5281 __attribute__((unused)) struct cmdline *cl,
5282 __attribute__((unused)) void *data)
5284 struct cmd_remove_bonding_slave_result *res = parsed_result;
5285 portid_t master_port_id = res->port_id;
5286 portid_t slave_port_id = res->slave_id;
5288 /* remove the slave from a bonded device. */
5289 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5290 printf("\t Failed to remove slave %d from master port = %d.\n",
5291 slave_port_id, master_port_id);
5295 clear_port_slave_flag(slave_port_id);
5298 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5299 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5301 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5302 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5303 bonding, "bonding");
5304 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5305 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5307 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5308 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5310 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5311 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5314 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5315 .f = cmd_remove_bonding_slave_parsed,
5316 .help_str = "remove bonding slave <slave_id> <port_id>: "
5317 "Remove a slave device from a bonded device",
5320 (void *)&cmd_removebonding_slave_remove,
5321 (void *)&cmd_removebonding_slave_bonding,
5322 (void *)&cmd_removebonding_slave_slave,
5323 (void *)&cmd_removebonding_slave_slaveid,
5324 (void *)&cmd_removebonding_slave_port,
5329 /* *** CREATE BONDED DEVICE *** */
5330 struct cmd_create_bonded_device_result {
5331 cmdline_fixed_string_t create;
5332 cmdline_fixed_string_t bonded;
5333 cmdline_fixed_string_t device;
5338 static int bond_dev_num = 0;
5340 static void cmd_create_bonded_device_parsed(void *parsed_result,
5341 __attribute__((unused)) struct cmdline *cl,
5342 __attribute__((unused)) void *data)
5344 struct cmd_create_bonded_device_result *res = parsed_result;
5345 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5348 if (test_done == 0) {
5349 printf("Please stop forwarding first\n");
5353 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5356 /* Create a new bonded device. */
5357 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5359 printf("\t Failed to create bonded device.\n");
5362 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5365 /* Update number of ports */
5366 nb_ports = rte_eth_dev_count();
5367 reconfig(port_id, res->socket);
5368 rte_eth_promiscuous_enable(port_id);
5373 cmdline_parse_token_string_t cmd_createbonded_device_create =
5374 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5376 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5377 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5379 cmdline_parse_token_string_t cmd_createbonded_device_device =
5380 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5382 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5383 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5385 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5386 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5389 cmdline_parse_inst_t cmd_create_bonded_device = {
5390 .f = cmd_create_bonded_device_parsed,
5391 .help_str = "create bonded device <mode> <socket>: "
5392 "Create a new bonded device with specific bonding mode and socket",
5395 (void *)&cmd_createbonded_device_create,
5396 (void *)&cmd_createbonded_device_bonded,
5397 (void *)&cmd_createbonded_device_device,
5398 (void *)&cmd_createbonded_device_mode,
5399 (void *)&cmd_createbonded_device_socket,
5404 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5405 struct cmd_set_bond_mac_addr_result {
5406 cmdline_fixed_string_t set;
5407 cmdline_fixed_string_t bonding;
5408 cmdline_fixed_string_t mac_addr;
5410 struct ether_addr address;
5413 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5414 __attribute__((unused)) struct cmdline *cl,
5415 __attribute__((unused)) void *data)
5417 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5420 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5423 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5425 /* check the return value and print it if is < 0 */
5427 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5430 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5431 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5432 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5433 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5435 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5436 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5438 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5439 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5441 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5442 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5444 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5445 .f = cmd_set_bond_mac_addr_parsed,
5447 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5449 (void *)&cmd_set_bond_mac_addr_set,
5450 (void *)&cmd_set_bond_mac_addr_bonding,
5451 (void *)&cmd_set_bond_mac_addr_mac,
5452 (void *)&cmd_set_bond_mac_addr_portnum,
5453 (void *)&cmd_set_bond_mac_addr_addr,
5459 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5460 struct cmd_set_bond_mon_period_result {
5461 cmdline_fixed_string_t set;
5462 cmdline_fixed_string_t bonding;
5463 cmdline_fixed_string_t mon_period;
5468 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5469 __attribute__((unused)) struct cmdline *cl,
5470 __attribute__((unused)) void *data)
5472 struct cmd_set_bond_mon_period_result *res = parsed_result;
5475 if (res->port_num >= nb_ports) {
5476 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5480 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5482 /* check the return value and print it if is < 0 */
5484 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5487 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5488 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5490 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5491 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5492 bonding, "bonding");
5493 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5494 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5495 mon_period, "mon_period");
5496 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5497 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5499 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5500 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5503 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5504 .f = cmd_set_bond_mon_period_parsed,
5506 .help_str = "set bonding mon_period <port_id> <period_ms>",
5508 (void *)&cmd_set_bond_mon_period_set,
5509 (void *)&cmd_set_bond_mon_period_bonding,
5510 (void *)&cmd_set_bond_mon_period_mon_period,
5511 (void *)&cmd_set_bond_mon_period_portnum,
5512 (void *)&cmd_set_bond_mon_period_period_ms,
5519 struct cmd_set_bonding_agg_mode_policy_result {
5520 cmdline_fixed_string_t set;
5521 cmdline_fixed_string_t bonding;
5522 cmdline_fixed_string_t agg_mode;
5524 cmdline_fixed_string_t policy;
5529 cmd_set_bonding_agg_mode(void *parsed_result,
5530 __attribute__((unused)) struct cmdline *cl,
5531 __attribute__((unused)) void *data)
5533 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5534 uint8_t policy = AGG_BANDWIDTH;
5536 if (res->port_num >= nb_ports) {
5537 printf("Port id %d must be less than %d\n",
5538 res->port_num, nb_ports);
5542 if (!strcmp(res->policy, "bandwidth"))
5543 policy = AGG_BANDWIDTH;
5544 else if (!strcmp(res->policy, "stable"))
5545 policy = AGG_STABLE;
5546 else if (!strcmp(res->policy, "count"))
5549 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5553 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5554 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5556 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5557 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5558 bonding, "bonding");
5560 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5561 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5562 agg_mode, "agg_mode");
5564 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5565 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5568 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5569 TOKEN_STRING_INITIALIZER(
5570 struct cmd_set_bonding_balance_xmit_policy_result,
5571 policy, "stable#bandwidth#count");
5573 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5574 .f = cmd_set_bonding_agg_mode,
5576 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5578 (void *)&cmd_set_bonding_agg_mode_set,
5579 (void *)&cmd_set_bonding_agg_mode_bonding,
5580 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5581 (void *)&cmd_set_bonding_agg_mode_portnum,
5582 (void *)&cmd_set_bonding_agg_mode_policy_string,
5588 #endif /* RTE_LIBRTE_PMD_BOND */
5590 /* *** SET FORWARDING MODE *** */
5591 struct cmd_set_fwd_mode_result {
5592 cmdline_fixed_string_t set;
5593 cmdline_fixed_string_t fwd;
5594 cmdline_fixed_string_t mode;
5597 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5598 __attribute__((unused)) struct cmdline *cl,
5599 __attribute__((unused)) void *data)
5601 struct cmd_set_fwd_mode_result *res = parsed_result;
5604 set_pkt_forwarding_mode(res->mode);
5607 cmdline_parse_token_string_t cmd_setfwd_set =
5608 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5609 cmdline_parse_token_string_t cmd_setfwd_fwd =
5610 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5611 cmdline_parse_token_string_t cmd_setfwd_mode =
5612 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5613 "" /* defined at init */);
5615 cmdline_parse_inst_t cmd_set_fwd_mode = {
5616 .f = cmd_set_fwd_mode_parsed,
5618 .help_str = NULL, /* defined at init */
5620 (void *)&cmd_setfwd_set,
5621 (void *)&cmd_setfwd_fwd,
5622 (void *)&cmd_setfwd_mode,
5627 static void cmd_set_fwd_mode_init(void)
5630 static char token[128];
5631 static char help[256];
5632 cmdline_parse_token_string_t *token_struct;
5634 modes = list_pkt_forwarding_modes();
5635 snprintf(help, sizeof(help), "set fwd %s: "
5636 "Set packet forwarding mode", modes);
5637 cmd_set_fwd_mode.help_str = help;
5639 /* string token separator is # */
5640 for (c = token; *modes != '\0'; modes++)
5645 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5646 token_struct->string_data.str = token;
5649 /* *** SET RETRY FORWARDING MODE *** */
5650 struct cmd_set_fwd_retry_mode_result {
5651 cmdline_fixed_string_t set;
5652 cmdline_fixed_string_t fwd;
5653 cmdline_fixed_string_t mode;
5654 cmdline_fixed_string_t retry;
5657 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5658 __attribute__((unused)) struct cmdline *cl,
5659 __attribute__((unused)) void *data)
5661 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5664 set_pkt_forwarding_mode(res->mode);
5667 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5668 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5670 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5671 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5673 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5674 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5676 "" /* defined at init */);
5677 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5678 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5681 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5682 .f = cmd_set_fwd_retry_mode_parsed,
5684 .help_str = NULL, /* defined at init */
5686 (void *)&cmd_setfwd_retry_set,
5687 (void *)&cmd_setfwd_retry_fwd,
5688 (void *)&cmd_setfwd_retry_mode,
5689 (void *)&cmd_setfwd_retry_retry,
5694 static void cmd_set_fwd_retry_mode_init(void)
5697 static char token[128];
5698 static char help[256];
5699 cmdline_parse_token_string_t *token_struct;
5701 modes = list_pkt_forwarding_retry_modes();
5702 snprintf(help, sizeof(help), "set fwd %s retry: "
5703 "Set packet forwarding mode with retry", modes);
5704 cmd_set_fwd_retry_mode.help_str = help;
5706 /* string token separator is # */
5707 for (c = token; *modes != '\0'; modes++)
5712 token_struct = (cmdline_parse_token_string_t *)
5713 cmd_set_fwd_retry_mode.tokens[2];
5714 token_struct->string_data.str = token;
5717 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5718 struct cmd_set_burst_tx_retry_result {
5719 cmdline_fixed_string_t set;
5720 cmdline_fixed_string_t burst;
5721 cmdline_fixed_string_t tx;
5722 cmdline_fixed_string_t delay;
5724 cmdline_fixed_string_t retry;
5728 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5729 __attribute__((unused)) struct cmdline *cl,
5730 __attribute__((unused)) void *data)
5732 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5734 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5735 && !strcmp(res->tx, "tx")) {
5736 if (!strcmp(res->delay, "delay"))
5737 burst_tx_delay_time = res->time;
5738 if (!strcmp(res->retry, "retry"))
5739 burst_tx_retry_num = res->retry_num;
5744 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5745 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5746 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5747 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5749 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5750 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5751 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5752 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5753 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5754 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5755 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5756 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5757 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5758 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5760 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5761 .f = cmd_set_burst_tx_retry_parsed,
5762 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5764 (void *)&cmd_set_burst_tx_retry_set,
5765 (void *)&cmd_set_burst_tx_retry_burst,
5766 (void *)&cmd_set_burst_tx_retry_tx,
5767 (void *)&cmd_set_burst_tx_retry_delay,
5768 (void *)&cmd_set_burst_tx_retry_time,
5769 (void *)&cmd_set_burst_tx_retry_retry,
5770 (void *)&cmd_set_burst_tx_retry_retry_num,
5775 /* *** SET PROMISC MODE *** */
5776 struct cmd_set_promisc_mode_result {
5777 cmdline_fixed_string_t set;
5778 cmdline_fixed_string_t promisc;
5779 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5780 uint16_t port_num; /* valid if "allports" argument == 0 */
5781 cmdline_fixed_string_t mode;
5784 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5785 __attribute__((unused)) struct cmdline *cl,
5788 struct cmd_set_promisc_mode_result *res = parsed_result;
5792 if (!strcmp(res->mode, "on"))
5799 RTE_ETH_FOREACH_DEV(i) {
5801 rte_eth_promiscuous_enable(i);
5803 rte_eth_promiscuous_disable(i);
5808 rte_eth_promiscuous_enable(res->port_num);
5810 rte_eth_promiscuous_disable(res->port_num);
5814 cmdline_parse_token_string_t cmd_setpromisc_set =
5815 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5816 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5817 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5819 cmdline_parse_token_string_t cmd_setpromisc_portall =
5820 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5822 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5823 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5825 cmdline_parse_token_string_t cmd_setpromisc_mode =
5826 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5829 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5830 .f = cmd_set_promisc_mode_parsed,
5832 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5834 (void *)&cmd_setpromisc_set,
5835 (void *)&cmd_setpromisc_promisc,
5836 (void *)&cmd_setpromisc_portall,
5837 (void *)&cmd_setpromisc_mode,
5842 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5843 .f = cmd_set_promisc_mode_parsed,
5845 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5847 (void *)&cmd_setpromisc_set,
5848 (void *)&cmd_setpromisc_promisc,
5849 (void *)&cmd_setpromisc_portnum,
5850 (void *)&cmd_setpromisc_mode,
5855 /* *** SET ALLMULTI MODE *** */
5856 struct cmd_set_allmulti_mode_result {
5857 cmdline_fixed_string_t set;
5858 cmdline_fixed_string_t allmulti;
5859 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5860 uint16_t port_num; /* valid if "allports" argument == 0 */
5861 cmdline_fixed_string_t mode;
5864 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5865 __attribute__((unused)) struct cmdline *cl,
5868 struct cmd_set_allmulti_mode_result *res = parsed_result;
5872 if (!strcmp(res->mode, "on"))
5879 RTE_ETH_FOREACH_DEV(i) {
5881 rte_eth_allmulticast_enable(i);
5883 rte_eth_allmulticast_disable(i);
5888 rte_eth_allmulticast_enable(res->port_num);
5890 rte_eth_allmulticast_disable(res->port_num);
5894 cmdline_parse_token_string_t cmd_setallmulti_set =
5895 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5896 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5897 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5899 cmdline_parse_token_string_t cmd_setallmulti_portall =
5900 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5902 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5903 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5905 cmdline_parse_token_string_t cmd_setallmulti_mode =
5906 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5909 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5910 .f = cmd_set_allmulti_mode_parsed,
5912 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5914 (void *)&cmd_setallmulti_set,
5915 (void *)&cmd_setallmulti_allmulti,
5916 (void *)&cmd_setallmulti_portall,
5917 (void *)&cmd_setallmulti_mode,
5922 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5923 .f = cmd_set_allmulti_mode_parsed,
5925 .help_str = "set allmulti <port_id> on|off: "
5926 "Set allmulti mode on port_id",
5928 (void *)&cmd_setallmulti_set,
5929 (void *)&cmd_setallmulti_allmulti,
5930 (void *)&cmd_setallmulti_portnum,
5931 (void *)&cmd_setallmulti_mode,
5936 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5937 struct cmd_link_flow_ctrl_set_result {
5938 cmdline_fixed_string_t set;
5939 cmdline_fixed_string_t flow_ctrl;
5940 cmdline_fixed_string_t rx;
5941 cmdline_fixed_string_t rx_lfc_mode;
5942 cmdline_fixed_string_t tx;
5943 cmdline_fixed_string_t tx_lfc_mode;
5944 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5945 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5946 cmdline_fixed_string_t autoneg_str;
5947 cmdline_fixed_string_t autoneg;
5948 cmdline_fixed_string_t hw_str;
5949 uint32_t high_water;
5950 cmdline_fixed_string_t lw_str;
5952 cmdline_fixed_string_t pt_str;
5953 uint16_t pause_time;
5954 cmdline_fixed_string_t xon_str;
5959 cmdline_parse_token_string_t cmd_lfc_set_set =
5960 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5962 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5963 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5964 flow_ctrl, "flow_ctrl");
5965 cmdline_parse_token_string_t cmd_lfc_set_rx =
5966 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5968 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5969 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5970 rx_lfc_mode, "on#off");
5971 cmdline_parse_token_string_t cmd_lfc_set_tx =
5972 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5974 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5975 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5976 tx_lfc_mode, "on#off");
5977 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5978 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5979 hw_str, "high_water");
5980 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5981 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5982 high_water, UINT32);
5983 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5984 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5985 lw_str, "low_water");
5986 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5987 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5989 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5990 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5991 pt_str, "pause_time");
5992 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5993 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5994 pause_time, UINT16);
5995 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5996 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5997 xon_str, "send_xon");
5998 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5999 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6001 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6002 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6003 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6004 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6005 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6006 mac_ctrl_frame_fwd_mode, "on#off");
6007 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6008 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6009 autoneg_str, "autoneg");
6010 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6011 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6013 cmdline_parse_token_num_t cmd_lfc_set_portid =
6014 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6017 /* forward declaration */
6019 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6022 cmdline_parse_inst_t cmd_link_flow_control_set = {
6023 .f = cmd_link_flow_ctrl_set_parsed,
6025 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6026 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6027 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6029 (void *)&cmd_lfc_set_set,
6030 (void *)&cmd_lfc_set_flow_ctrl,
6031 (void *)&cmd_lfc_set_rx,
6032 (void *)&cmd_lfc_set_rx_mode,
6033 (void *)&cmd_lfc_set_tx,
6034 (void *)&cmd_lfc_set_tx_mode,
6035 (void *)&cmd_lfc_set_high_water,
6036 (void *)&cmd_lfc_set_low_water,
6037 (void *)&cmd_lfc_set_pause_time,
6038 (void *)&cmd_lfc_set_send_xon,
6039 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6040 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6041 (void *)&cmd_lfc_set_autoneg_str,
6042 (void *)&cmd_lfc_set_autoneg,
6043 (void *)&cmd_lfc_set_portid,
6048 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6049 .f = cmd_link_flow_ctrl_set_parsed,
6050 .data = (void *)&cmd_link_flow_control_set_rx,
6051 .help_str = "set flow_ctrl rx on|off <port_id>: "
6052 "Change rx flow control parameter",
6054 (void *)&cmd_lfc_set_set,
6055 (void *)&cmd_lfc_set_flow_ctrl,
6056 (void *)&cmd_lfc_set_rx,
6057 (void *)&cmd_lfc_set_rx_mode,
6058 (void *)&cmd_lfc_set_portid,
6063 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6064 .f = cmd_link_flow_ctrl_set_parsed,
6065 .data = (void *)&cmd_link_flow_control_set_tx,
6066 .help_str = "set flow_ctrl tx on|off <port_id>: "
6067 "Change tx flow control parameter",
6069 (void *)&cmd_lfc_set_set,
6070 (void *)&cmd_lfc_set_flow_ctrl,
6071 (void *)&cmd_lfc_set_tx,
6072 (void *)&cmd_lfc_set_tx_mode,
6073 (void *)&cmd_lfc_set_portid,
6078 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6079 .f = cmd_link_flow_ctrl_set_parsed,
6080 .data = (void *)&cmd_link_flow_control_set_hw,
6081 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6082 "Change high water flow control parameter",
6084 (void *)&cmd_lfc_set_set,
6085 (void *)&cmd_lfc_set_flow_ctrl,
6086 (void *)&cmd_lfc_set_high_water_str,
6087 (void *)&cmd_lfc_set_high_water,
6088 (void *)&cmd_lfc_set_portid,
6093 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6094 .f = cmd_link_flow_ctrl_set_parsed,
6095 .data = (void *)&cmd_link_flow_control_set_lw,
6096 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6097 "Change low water flow control parameter",
6099 (void *)&cmd_lfc_set_set,
6100 (void *)&cmd_lfc_set_flow_ctrl,
6101 (void *)&cmd_lfc_set_low_water_str,
6102 (void *)&cmd_lfc_set_low_water,
6103 (void *)&cmd_lfc_set_portid,
6108 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6109 .f = cmd_link_flow_ctrl_set_parsed,
6110 .data = (void *)&cmd_link_flow_control_set_pt,
6111 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6112 "Change pause time flow control parameter",
6114 (void *)&cmd_lfc_set_set,
6115 (void *)&cmd_lfc_set_flow_ctrl,
6116 (void *)&cmd_lfc_set_pause_time_str,
6117 (void *)&cmd_lfc_set_pause_time,
6118 (void *)&cmd_lfc_set_portid,
6123 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6124 .f = cmd_link_flow_ctrl_set_parsed,
6125 .data = (void *)&cmd_link_flow_control_set_xon,
6126 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6127 "Change send_xon flow control parameter",
6129 (void *)&cmd_lfc_set_set,
6130 (void *)&cmd_lfc_set_flow_ctrl,
6131 (void *)&cmd_lfc_set_send_xon_str,
6132 (void *)&cmd_lfc_set_send_xon,
6133 (void *)&cmd_lfc_set_portid,
6138 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6139 .f = cmd_link_flow_ctrl_set_parsed,
6140 .data = (void *)&cmd_link_flow_control_set_macfwd,
6141 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6142 "Change mac ctrl fwd flow control parameter",
6144 (void *)&cmd_lfc_set_set,
6145 (void *)&cmd_lfc_set_flow_ctrl,
6146 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6147 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6148 (void *)&cmd_lfc_set_portid,
6153 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6154 .f = cmd_link_flow_ctrl_set_parsed,
6155 .data = (void *)&cmd_link_flow_control_set_autoneg,
6156 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6157 "Change autoneg flow control parameter",
6159 (void *)&cmd_lfc_set_set,
6160 (void *)&cmd_lfc_set_flow_ctrl,
6161 (void *)&cmd_lfc_set_autoneg_str,
6162 (void *)&cmd_lfc_set_autoneg,
6163 (void *)&cmd_lfc_set_portid,
6169 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6170 __attribute__((unused)) struct cmdline *cl,
6173 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6174 cmdline_parse_inst_t *cmd = data;
6175 struct rte_eth_fc_conf fc_conf;
6181 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6182 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6183 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6184 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6186 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6187 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6190 /* Partial command line, retrieve current configuration */
6192 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6194 printf("cannot get current flow ctrl parameters, return"
6195 "code = %d\n", ret);
6199 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6200 (fc_conf.mode == RTE_FC_FULL))
6202 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6203 (fc_conf.mode == RTE_FC_FULL))
6207 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6208 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6210 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6211 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6213 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6215 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6216 fc_conf.high_water = res->high_water;
6218 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6219 fc_conf.low_water = res->low_water;
6221 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6222 fc_conf.pause_time = res->pause_time;
6224 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6225 fc_conf.send_xon = res->send_xon;
6227 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6228 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6229 fc_conf.mac_ctrl_frame_fwd = 1;
6231 fc_conf.mac_ctrl_frame_fwd = 0;
6234 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6235 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6237 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6239 printf("bad flow contrl parameter, return code = %d \n", ret);
6242 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6243 struct cmd_priority_flow_ctrl_set_result {
6244 cmdline_fixed_string_t set;
6245 cmdline_fixed_string_t pfc_ctrl;
6246 cmdline_fixed_string_t rx;
6247 cmdline_fixed_string_t rx_pfc_mode;
6248 cmdline_fixed_string_t tx;
6249 cmdline_fixed_string_t tx_pfc_mode;
6250 uint32_t high_water;
6252 uint16_t pause_time;
6258 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6259 __attribute__((unused)) struct cmdline *cl,
6260 __attribute__((unused)) void *data)
6262 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6263 struct rte_eth_pfc_conf pfc_conf;
6264 int rx_fc_enable, tx_fc_enable;
6268 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6269 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6270 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6271 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6273 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6274 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6277 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6278 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6279 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6280 pfc_conf.fc.high_water = res->high_water;
6281 pfc_conf.fc.low_water = res->low_water;
6282 pfc_conf.fc.pause_time = res->pause_time;
6283 pfc_conf.priority = res->priority;
6285 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6287 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6290 cmdline_parse_token_string_t cmd_pfc_set_set =
6291 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6293 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6294 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6295 pfc_ctrl, "pfc_ctrl");
6296 cmdline_parse_token_string_t cmd_pfc_set_rx =
6297 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6299 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6300 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6301 rx_pfc_mode, "on#off");
6302 cmdline_parse_token_string_t cmd_pfc_set_tx =
6303 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6305 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6306 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6307 tx_pfc_mode, "on#off");
6308 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6309 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6310 high_water, UINT32);
6311 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6312 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6314 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6315 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6316 pause_time, UINT16);
6317 cmdline_parse_token_num_t cmd_pfc_set_priority =
6318 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6320 cmdline_parse_token_num_t cmd_pfc_set_portid =
6321 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6324 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6325 .f = cmd_priority_flow_ctrl_set_parsed,
6327 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6328 "<pause_time> <priority> <port_id>: "
6329 "Configure the Ethernet priority flow control",
6331 (void *)&cmd_pfc_set_set,
6332 (void *)&cmd_pfc_set_flow_ctrl,
6333 (void *)&cmd_pfc_set_rx,
6334 (void *)&cmd_pfc_set_rx_mode,
6335 (void *)&cmd_pfc_set_tx,
6336 (void *)&cmd_pfc_set_tx_mode,
6337 (void *)&cmd_pfc_set_high_water,
6338 (void *)&cmd_pfc_set_low_water,
6339 (void *)&cmd_pfc_set_pause_time,
6340 (void *)&cmd_pfc_set_priority,
6341 (void *)&cmd_pfc_set_portid,
6346 /* *** RESET CONFIGURATION *** */
6347 struct cmd_reset_result {
6348 cmdline_fixed_string_t reset;
6349 cmdline_fixed_string_t def;
6352 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6354 __attribute__((unused)) void *data)
6356 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6357 set_def_fwd_config();
6360 cmdline_parse_token_string_t cmd_reset_set =
6361 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6362 cmdline_parse_token_string_t cmd_reset_def =
6363 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6366 cmdline_parse_inst_t cmd_reset = {
6367 .f = cmd_reset_parsed,
6369 .help_str = "set default: Reset default forwarding configuration",
6371 (void *)&cmd_reset_set,
6372 (void *)&cmd_reset_def,
6377 /* *** START FORWARDING *** */
6378 struct cmd_start_result {
6379 cmdline_fixed_string_t start;
6382 cmdline_parse_token_string_t cmd_start_start =
6383 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6385 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6386 __attribute__((unused)) struct cmdline *cl,
6387 __attribute__((unused)) void *data)
6389 start_packet_forwarding(0);
6392 cmdline_parse_inst_t cmd_start = {
6393 .f = cmd_start_parsed,
6395 .help_str = "start: Start packet forwarding",
6397 (void *)&cmd_start_start,
6402 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6403 struct cmd_start_tx_first_result {
6404 cmdline_fixed_string_t start;
6405 cmdline_fixed_string_t tx_first;
6409 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6410 __attribute__((unused)) struct cmdline *cl,
6411 __attribute__((unused)) void *data)
6413 start_packet_forwarding(1);
6416 cmdline_parse_token_string_t cmd_start_tx_first_start =
6417 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6419 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6420 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6421 tx_first, "tx_first");
6423 cmdline_parse_inst_t cmd_start_tx_first = {
6424 .f = cmd_start_tx_first_parsed,
6426 .help_str = "start tx_first: Start packet forwarding, "
6427 "after sending 1 burst of packets",
6429 (void *)&cmd_start_tx_first_start,
6430 (void *)&cmd_start_tx_first_tx_first,
6435 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6436 struct cmd_start_tx_first_n_result {
6437 cmdline_fixed_string_t start;
6438 cmdline_fixed_string_t tx_first;
6443 cmd_start_tx_first_n_parsed(void *parsed_result,
6444 __attribute__((unused)) struct cmdline *cl,
6445 __attribute__((unused)) void *data)
6447 struct cmd_start_tx_first_n_result *res = parsed_result;
6449 start_packet_forwarding(res->tx_num);
6452 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6453 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6455 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6456 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6457 tx_first, "tx_first");
6458 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6459 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6462 cmdline_parse_inst_t cmd_start_tx_first_n = {
6463 .f = cmd_start_tx_first_n_parsed,
6465 .help_str = "start tx_first <num>: "
6466 "packet forwarding, after sending <num> bursts of packets",
6468 (void *)&cmd_start_tx_first_n_start,
6469 (void *)&cmd_start_tx_first_n_tx_first,
6470 (void *)&cmd_start_tx_first_n_tx_num,
6475 /* *** SET LINK UP *** */
6476 struct cmd_set_link_up_result {
6477 cmdline_fixed_string_t set;
6478 cmdline_fixed_string_t link_up;
6479 cmdline_fixed_string_t port;
6483 cmdline_parse_token_string_t cmd_set_link_up_set =
6484 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6485 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6486 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6488 cmdline_parse_token_string_t cmd_set_link_up_port =
6489 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6490 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6491 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6493 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6494 __attribute__((unused)) struct cmdline *cl,
6495 __attribute__((unused)) void *data)
6497 struct cmd_set_link_up_result *res = parsed_result;
6498 dev_set_link_up(res->port_id);
6501 cmdline_parse_inst_t cmd_set_link_up = {
6502 .f = cmd_set_link_up_parsed,
6504 .help_str = "set link-up port <port id>",
6506 (void *)&cmd_set_link_up_set,
6507 (void *)&cmd_set_link_up_link_up,
6508 (void *)&cmd_set_link_up_port,
6509 (void *)&cmd_set_link_up_port_id,
6514 /* *** SET LINK DOWN *** */
6515 struct cmd_set_link_down_result {
6516 cmdline_fixed_string_t set;
6517 cmdline_fixed_string_t link_down;
6518 cmdline_fixed_string_t port;
6522 cmdline_parse_token_string_t cmd_set_link_down_set =
6523 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6524 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6525 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6527 cmdline_parse_token_string_t cmd_set_link_down_port =
6528 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6529 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6530 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6532 static void cmd_set_link_down_parsed(
6533 __attribute__((unused)) void *parsed_result,
6534 __attribute__((unused)) struct cmdline *cl,
6535 __attribute__((unused)) void *data)
6537 struct cmd_set_link_down_result *res = parsed_result;
6538 dev_set_link_down(res->port_id);
6541 cmdline_parse_inst_t cmd_set_link_down = {
6542 .f = cmd_set_link_down_parsed,
6544 .help_str = "set link-down port <port id>",
6546 (void *)&cmd_set_link_down_set,
6547 (void *)&cmd_set_link_down_link_down,
6548 (void *)&cmd_set_link_down_port,
6549 (void *)&cmd_set_link_down_port_id,
6554 /* *** SHOW CFG *** */
6555 struct cmd_showcfg_result {
6556 cmdline_fixed_string_t show;
6557 cmdline_fixed_string_t cfg;
6558 cmdline_fixed_string_t what;
6561 static void cmd_showcfg_parsed(void *parsed_result,
6562 __attribute__((unused)) struct cmdline *cl,
6563 __attribute__((unused)) void *data)
6565 struct cmd_showcfg_result *res = parsed_result;
6566 if (!strcmp(res->what, "rxtx"))
6567 rxtx_config_display();
6568 else if (!strcmp(res->what, "cores"))
6569 fwd_lcores_config_display();
6570 else if (!strcmp(res->what, "fwd"))
6571 pkt_fwd_config_display(&cur_fwd_config);
6572 else if (!strcmp(res->what, "txpkts"))
6573 show_tx_pkt_segments();
6576 cmdline_parse_token_string_t cmd_showcfg_show =
6577 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6578 cmdline_parse_token_string_t cmd_showcfg_port =
6579 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6580 cmdline_parse_token_string_t cmd_showcfg_what =
6581 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6582 "rxtx#cores#fwd#txpkts");
6584 cmdline_parse_inst_t cmd_showcfg = {
6585 .f = cmd_showcfg_parsed,
6587 .help_str = "show config rxtx|cores|fwd|txpkts",
6589 (void *)&cmd_showcfg_show,
6590 (void *)&cmd_showcfg_port,
6591 (void *)&cmd_showcfg_what,
6596 /* *** SHOW ALL PORT INFO *** */
6597 struct cmd_showportall_result {
6598 cmdline_fixed_string_t show;
6599 cmdline_fixed_string_t port;
6600 cmdline_fixed_string_t what;
6601 cmdline_fixed_string_t all;
6604 static void cmd_showportall_parsed(void *parsed_result,
6605 __attribute__((unused)) struct cmdline *cl,
6606 __attribute__((unused)) void *data)
6610 struct cmd_showportall_result *res = parsed_result;
6611 if (!strcmp(res->show, "clear")) {
6612 if (!strcmp(res->what, "stats"))
6613 RTE_ETH_FOREACH_DEV(i)
6615 else if (!strcmp(res->what, "xstats"))
6616 RTE_ETH_FOREACH_DEV(i)
6617 nic_xstats_clear(i);
6618 } else if (!strcmp(res->what, "info"))
6619 RTE_ETH_FOREACH_DEV(i)
6620 port_infos_display(i);
6621 else if (!strcmp(res->what, "stats"))
6622 RTE_ETH_FOREACH_DEV(i)
6623 nic_stats_display(i);
6624 else if (!strcmp(res->what, "xstats"))
6625 RTE_ETH_FOREACH_DEV(i)
6626 nic_xstats_display(i);
6627 else if (!strcmp(res->what, "fdir"))
6628 RTE_ETH_FOREACH_DEV(i)
6630 else if (!strcmp(res->what, "stat_qmap"))
6631 RTE_ETH_FOREACH_DEV(i)
6632 nic_stats_mapping_display(i);
6633 else if (!strcmp(res->what, "dcb_tc"))
6634 RTE_ETH_FOREACH_DEV(i)
6635 port_dcb_info_display(i);
6636 else if (!strcmp(res->what, "cap"))
6637 RTE_ETH_FOREACH_DEV(i)
6638 port_offload_cap_display(i);
6641 cmdline_parse_token_string_t cmd_showportall_show =
6642 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6644 cmdline_parse_token_string_t cmd_showportall_port =
6645 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6646 cmdline_parse_token_string_t cmd_showportall_what =
6647 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6648 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6649 cmdline_parse_token_string_t cmd_showportall_all =
6650 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6651 cmdline_parse_inst_t cmd_showportall = {
6652 .f = cmd_showportall_parsed,
6654 .help_str = "show|clear port "
6655 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6657 (void *)&cmd_showportall_show,
6658 (void *)&cmd_showportall_port,
6659 (void *)&cmd_showportall_what,
6660 (void *)&cmd_showportall_all,
6665 /* *** SHOW PORT INFO *** */
6666 struct cmd_showport_result {
6667 cmdline_fixed_string_t show;
6668 cmdline_fixed_string_t port;
6669 cmdline_fixed_string_t what;
6673 static void cmd_showport_parsed(void *parsed_result,
6674 __attribute__((unused)) struct cmdline *cl,
6675 __attribute__((unused)) void *data)
6677 struct cmd_showport_result *res = parsed_result;
6678 if (!strcmp(res->show, "clear")) {
6679 if (!strcmp(res->what, "stats"))
6680 nic_stats_clear(res->portnum);
6681 else if (!strcmp(res->what, "xstats"))
6682 nic_xstats_clear(res->portnum);
6683 } else if (!strcmp(res->what, "info"))
6684 port_infos_display(res->portnum);
6685 else if (!strcmp(res->what, "stats"))
6686 nic_stats_display(res->portnum);
6687 else if (!strcmp(res->what, "xstats"))
6688 nic_xstats_display(res->portnum);
6689 else if (!strcmp(res->what, "fdir"))
6690 fdir_get_infos(res->portnum);
6691 else if (!strcmp(res->what, "stat_qmap"))
6692 nic_stats_mapping_display(res->portnum);
6693 else if (!strcmp(res->what, "dcb_tc"))
6694 port_dcb_info_display(res->portnum);
6695 else if (!strcmp(res->what, "cap"))
6696 port_offload_cap_display(res->portnum);
6699 cmdline_parse_token_string_t cmd_showport_show =
6700 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6702 cmdline_parse_token_string_t cmd_showport_port =
6703 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6704 cmdline_parse_token_string_t cmd_showport_what =
6705 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6706 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6707 cmdline_parse_token_num_t cmd_showport_portnum =
6708 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6710 cmdline_parse_inst_t cmd_showport = {
6711 .f = cmd_showport_parsed,
6713 .help_str = "show|clear port "
6714 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6717 (void *)&cmd_showport_show,
6718 (void *)&cmd_showport_port,
6719 (void *)&cmd_showport_what,
6720 (void *)&cmd_showport_portnum,
6725 /* *** SHOW QUEUE INFO *** */
6726 struct cmd_showqueue_result {
6727 cmdline_fixed_string_t show;
6728 cmdline_fixed_string_t type;
6729 cmdline_fixed_string_t what;
6735 cmd_showqueue_parsed(void *parsed_result,
6736 __attribute__((unused)) struct cmdline *cl,
6737 __attribute__((unused)) void *data)
6739 struct cmd_showqueue_result *res = parsed_result;
6741 if (!strcmp(res->type, "rxq"))
6742 rx_queue_infos_display(res->portnum, res->queuenum);
6743 else if (!strcmp(res->type, "txq"))
6744 tx_queue_infos_display(res->portnum, res->queuenum);
6747 cmdline_parse_token_string_t cmd_showqueue_show =
6748 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6749 cmdline_parse_token_string_t cmd_showqueue_type =
6750 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6751 cmdline_parse_token_string_t cmd_showqueue_what =
6752 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6753 cmdline_parse_token_num_t cmd_showqueue_portnum =
6754 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6755 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6756 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6758 cmdline_parse_inst_t cmd_showqueue = {
6759 .f = cmd_showqueue_parsed,
6761 .help_str = "show rxq|txq info <port_id> <queue_id>",
6763 (void *)&cmd_showqueue_show,
6764 (void *)&cmd_showqueue_type,
6765 (void *)&cmd_showqueue_what,
6766 (void *)&cmd_showqueue_portnum,
6767 (void *)&cmd_showqueue_queuenum,
6772 /* *** READ PORT REGISTER *** */
6773 struct cmd_read_reg_result {
6774 cmdline_fixed_string_t read;
6775 cmdline_fixed_string_t reg;
6781 cmd_read_reg_parsed(void *parsed_result,
6782 __attribute__((unused)) struct cmdline *cl,
6783 __attribute__((unused)) void *data)
6785 struct cmd_read_reg_result *res = parsed_result;
6786 port_reg_display(res->port_id, res->reg_off);
6789 cmdline_parse_token_string_t cmd_read_reg_read =
6790 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6791 cmdline_parse_token_string_t cmd_read_reg_reg =
6792 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6793 cmdline_parse_token_num_t cmd_read_reg_port_id =
6794 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6795 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6796 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6798 cmdline_parse_inst_t cmd_read_reg = {
6799 .f = cmd_read_reg_parsed,
6801 .help_str = "read reg <port_id> <reg_off>",
6803 (void *)&cmd_read_reg_read,
6804 (void *)&cmd_read_reg_reg,
6805 (void *)&cmd_read_reg_port_id,
6806 (void *)&cmd_read_reg_reg_off,
6811 /* *** READ PORT REGISTER BIT FIELD *** */
6812 struct cmd_read_reg_bit_field_result {
6813 cmdline_fixed_string_t read;
6814 cmdline_fixed_string_t regfield;
6822 cmd_read_reg_bit_field_parsed(void *parsed_result,
6823 __attribute__((unused)) struct cmdline *cl,
6824 __attribute__((unused)) void *data)
6826 struct cmd_read_reg_bit_field_result *res = parsed_result;
6827 port_reg_bit_field_display(res->port_id, res->reg_off,
6828 res->bit1_pos, res->bit2_pos);
6831 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6832 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6834 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6835 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6836 regfield, "regfield");
6837 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6838 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6840 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6841 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6843 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6844 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6846 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6847 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6850 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6851 .f = cmd_read_reg_bit_field_parsed,
6853 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6854 "Read register bit field between bit_x and bit_y included",
6856 (void *)&cmd_read_reg_bit_field_read,
6857 (void *)&cmd_read_reg_bit_field_regfield,
6858 (void *)&cmd_read_reg_bit_field_port_id,
6859 (void *)&cmd_read_reg_bit_field_reg_off,
6860 (void *)&cmd_read_reg_bit_field_bit1_pos,
6861 (void *)&cmd_read_reg_bit_field_bit2_pos,
6866 /* *** READ PORT REGISTER BIT *** */
6867 struct cmd_read_reg_bit_result {
6868 cmdline_fixed_string_t read;
6869 cmdline_fixed_string_t regbit;
6876 cmd_read_reg_bit_parsed(void *parsed_result,
6877 __attribute__((unused)) struct cmdline *cl,
6878 __attribute__((unused)) void *data)
6880 struct cmd_read_reg_bit_result *res = parsed_result;
6881 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6884 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6885 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6886 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6887 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6889 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6890 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6891 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6892 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6893 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6894 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6896 cmdline_parse_inst_t cmd_read_reg_bit = {
6897 .f = cmd_read_reg_bit_parsed,
6899 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6901 (void *)&cmd_read_reg_bit_read,
6902 (void *)&cmd_read_reg_bit_regbit,
6903 (void *)&cmd_read_reg_bit_port_id,
6904 (void *)&cmd_read_reg_bit_reg_off,
6905 (void *)&cmd_read_reg_bit_bit_pos,
6910 /* *** WRITE PORT REGISTER *** */
6911 struct cmd_write_reg_result {
6912 cmdline_fixed_string_t write;
6913 cmdline_fixed_string_t reg;
6920 cmd_write_reg_parsed(void *parsed_result,
6921 __attribute__((unused)) struct cmdline *cl,
6922 __attribute__((unused)) void *data)
6924 struct cmd_write_reg_result *res = parsed_result;
6925 port_reg_set(res->port_id, res->reg_off, res->value);
6928 cmdline_parse_token_string_t cmd_write_reg_write =
6929 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6930 cmdline_parse_token_string_t cmd_write_reg_reg =
6931 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6932 cmdline_parse_token_num_t cmd_write_reg_port_id =
6933 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6934 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6935 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6936 cmdline_parse_token_num_t cmd_write_reg_value =
6937 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6939 cmdline_parse_inst_t cmd_write_reg = {
6940 .f = cmd_write_reg_parsed,
6942 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6944 (void *)&cmd_write_reg_write,
6945 (void *)&cmd_write_reg_reg,
6946 (void *)&cmd_write_reg_port_id,
6947 (void *)&cmd_write_reg_reg_off,
6948 (void *)&cmd_write_reg_value,
6953 /* *** WRITE PORT REGISTER BIT FIELD *** */
6954 struct cmd_write_reg_bit_field_result {
6955 cmdline_fixed_string_t write;
6956 cmdline_fixed_string_t regfield;
6965 cmd_write_reg_bit_field_parsed(void *parsed_result,
6966 __attribute__((unused)) struct cmdline *cl,
6967 __attribute__((unused)) void *data)
6969 struct cmd_write_reg_bit_field_result *res = parsed_result;
6970 port_reg_bit_field_set(res->port_id, res->reg_off,
6971 res->bit1_pos, res->bit2_pos, res->value);
6974 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6975 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6977 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6978 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6979 regfield, "regfield");
6980 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6981 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6983 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6984 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6986 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6987 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6989 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6990 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6992 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6993 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6996 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6997 .f = cmd_write_reg_bit_field_parsed,
6999 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7001 "Set register bit field between bit_x and bit_y included",
7003 (void *)&cmd_write_reg_bit_field_write,
7004 (void *)&cmd_write_reg_bit_field_regfield,
7005 (void *)&cmd_write_reg_bit_field_port_id,
7006 (void *)&cmd_write_reg_bit_field_reg_off,
7007 (void *)&cmd_write_reg_bit_field_bit1_pos,
7008 (void *)&cmd_write_reg_bit_field_bit2_pos,
7009 (void *)&cmd_write_reg_bit_field_value,
7014 /* *** WRITE PORT REGISTER BIT *** */
7015 struct cmd_write_reg_bit_result {
7016 cmdline_fixed_string_t write;
7017 cmdline_fixed_string_t regbit;
7025 cmd_write_reg_bit_parsed(void *parsed_result,
7026 __attribute__((unused)) struct cmdline *cl,
7027 __attribute__((unused)) void *data)
7029 struct cmd_write_reg_bit_result *res = parsed_result;
7030 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7033 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7034 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7036 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7037 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7039 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7040 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7041 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7042 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7043 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7044 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7045 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7046 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7048 cmdline_parse_inst_t cmd_write_reg_bit = {
7049 .f = cmd_write_reg_bit_parsed,
7051 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7054 (void *)&cmd_write_reg_bit_write,
7055 (void *)&cmd_write_reg_bit_regbit,
7056 (void *)&cmd_write_reg_bit_port_id,
7057 (void *)&cmd_write_reg_bit_reg_off,
7058 (void *)&cmd_write_reg_bit_bit_pos,
7059 (void *)&cmd_write_reg_bit_value,
7064 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7065 struct cmd_read_rxd_txd_result {
7066 cmdline_fixed_string_t read;
7067 cmdline_fixed_string_t rxd_txd;
7074 cmd_read_rxd_txd_parsed(void *parsed_result,
7075 __attribute__((unused)) struct cmdline *cl,
7076 __attribute__((unused)) void *data)
7078 struct cmd_read_rxd_txd_result *res = parsed_result;
7080 if (!strcmp(res->rxd_txd, "rxd"))
7081 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7082 else if (!strcmp(res->rxd_txd, "txd"))
7083 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7086 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7087 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7088 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7089 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7091 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7092 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7093 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7094 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7095 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7096 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7098 cmdline_parse_inst_t cmd_read_rxd_txd = {
7099 .f = cmd_read_rxd_txd_parsed,
7101 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7103 (void *)&cmd_read_rxd_txd_read,
7104 (void *)&cmd_read_rxd_txd_rxd_txd,
7105 (void *)&cmd_read_rxd_txd_port_id,
7106 (void *)&cmd_read_rxd_txd_queue_id,
7107 (void *)&cmd_read_rxd_txd_desc_id,
7113 struct cmd_quit_result {
7114 cmdline_fixed_string_t quit;
7117 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7119 __attribute__((unused)) void *data)
7125 cmdline_parse_token_string_t cmd_quit_quit =
7126 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7128 cmdline_parse_inst_t cmd_quit = {
7129 .f = cmd_quit_parsed,
7131 .help_str = "quit: Exit application",
7133 (void *)&cmd_quit_quit,
7138 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7139 struct cmd_mac_addr_result {
7140 cmdline_fixed_string_t mac_addr_cmd;
7141 cmdline_fixed_string_t what;
7143 struct ether_addr address;
7146 static void cmd_mac_addr_parsed(void *parsed_result,
7147 __attribute__((unused)) struct cmdline *cl,
7148 __attribute__((unused)) void *data)
7150 struct cmd_mac_addr_result *res = parsed_result;
7153 if (strcmp(res->what, "add") == 0)
7154 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7155 else if (strcmp(res->what, "set") == 0)
7156 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7159 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7161 /* check the return value and print it if is < 0 */
7163 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7167 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7168 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7170 cmdline_parse_token_string_t cmd_mac_addr_what =
7171 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7173 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7174 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7176 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7177 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7179 cmdline_parse_inst_t cmd_mac_addr = {
7180 .f = cmd_mac_addr_parsed,
7182 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7183 "Add/Remove/Set MAC address on port_id",
7185 (void *)&cmd_mac_addr_cmd,
7186 (void *)&cmd_mac_addr_what,
7187 (void *)&cmd_mac_addr_portnum,
7188 (void *)&cmd_mac_addr_addr,
7193 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7194 struct cmd_eth_peer_result {
7195 cmdline_fixed_string_t set;
7196 cmdline_fixed_string_t eth_peer;
7198 cmdline_fixed_string_t peer_addr;
7201 static void cmd_set_eth_peer_parsed(void *parsed_result,
7202 __attribute__((unused)) struct cmdline *cl,
7203 __attribute__((unused)) void *data)
7205 struct cmd_eth_peer_result *res = parsed_result;
7207 if (test_done == 0) {
7208 printf("Please stop forwarding first\n");
7211 if (!strcmp(res->eth_peer, "eth-peer")) {
7212 set_fwd_eth_peer(res->port_id, res->peer_addr);
7216 cmdline_parse_token_string_t cmd_eth_peer_set =
7217 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7218 cmdline_parse_token_string_t cmd_eth_peer =
7219 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7220 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7221 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7222 cmdline_parse_token_string_t cmd_eth_peer_addr =
7223 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7225 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7226 .f = cmd_set_eth_peer_parsed,
7228 .help_str = "set eth-peer <port_id> <peer_mac>",
7230 (void *)&cmd_eth_peer_set,
7231 (void *)&cmd_eth_peer,
7232 (void *)&cmd_eth_peer_port_id,
7233 (void *)&cmd_eth_peer_addr,
7238 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7239 struct cmd_set_qmap_result {
7240 cmdline_fixed_string_t set;
7241 cmdline_fixed_string_t qmap;
7242 cmdline_fixed_string_t what;
7249 cmd_set_qmap_parsed(void *parsed_result,
7250 __attribute__((unused)) struct cmdline *cl,
7251 __attribute__((unused)) void *data)
7253 struct cmd_set_qmap_result *res = parsed_result;
7254 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7256 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7259 cmdline_parse_token_string_t cmd_setqmap_set =
7260 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7262 cmdline_parse_token_string_t cmd_setqmap_qmap =
7263 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7265 cmdline_parse_token_string_t cmd_setqmap_what =
7266 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7268 cmdline_parse_token_num_t cmd_setqmap_portid =
7269 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7271 cmdline_parse_token_num_t cmd_setqmap_queueid =
7272 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7274 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7275 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7278 cmdline_parse_inst_t cmd_set_qmap = {
7279 .f = cmd_set_qmap_parsed,
7281 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7282 "Set statistics mapping value on tx|rx queue_id of port_id",
7284 (void *)&cmd_setqmap_set,
7285 (void *)&cmd_setqmap_qmap,
7286 (void *)&cmd_setqmap_what,
7287 (void *)&cmd_setqmap_portid,
7288 (void *)&cmd_setqmap_queueid,
7289 (void *)&cmd_setqmap_mapvalue,
7294 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7295 struct cmd_set_xstats_hide_zero_result {
7296 cmdline_fixed_string_t keyword;
7297 cmdline_fixed_string_t name;
7298 cmdline_fixed_string_t on_off;
7302 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7303 __attribute__((unused)) struct cmdline *cl,
7304 __attribute__((unused)) void *data)
7306 struct cmd_set_xstats_hide_zero_result *res;
7307 uint16_t on_off = 0;
7309 res = parsed_result;
7310 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7311 set_xstats_hide_zero(on_off);
7314 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7315 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7317 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7318 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7319 name, "xstats-hide-zero");
7320 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7321 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7324 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7325 .f = cmd_set_xstats_hide_zero_parsed,
7327 .help_str = "set xstats-hide-zero on|off",
7329 (void *)&cmd_set_xstats_hide_zero_keyword,
7330 (void *)&cmd_set_xstats_hide_zero_name,
7331 (void *)&cmd_set_xstats_hide_zero_on_off,
7336 /* *** CONFIGURE UNICAST HASH TABLE *** */
7337 struct cmd_set_uc_hash_table {
7338 cmdline_fixed_string_t set;
7339 cmdline_fixed_string_t port;
7341 cmdline_fixed_string_t what;
7342 struct ether_addr address;
7343 cmdline_fixed_string_t mode;
7347 cmd_set_uc_hash_parsed(void *parsed_result,
7348 __attribute__((unused)) struct cmdline *cl,
7349 __attribute__((unused)) void *data)
7352 struct cmd_set_uc_hash_table *res = parsed_result;
7354 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7356 if (strcmp(res->what, "uta") == 0)
7357 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7358 &res->address,(uint8_t)is_on);
7360 printf("bad unicast hash table parameter, return code = %d \n", ret);
7364 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7365 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7367 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7368 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7370 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7371 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7373 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7374 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7376 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7377 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7379 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7380 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7383 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7384 .f = cmd_set_uc_hash_parsed,
7386 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7388 (void *)&cmd_set_uc_hash_set,
7389 (void *)&cmd_set_uc_hash_port,
7390 (void *)&cmd_set_uc_hash_portid,
7391 (void *)&cmd_set_uc_hash_what,
7392 (void *)&cmd_set_uc_hash_mac,
7393 (void *)&cmd_set_uc_hash_mode,
7398 struct cmd_set_uc_all_hash_table {
7399 cmdline_fixed_string_t set;
7400 cmdline_fixed_string_t port;
7402 cmdline_fixed_string_t what;
7403 cmdline_fixed_string_t value;
7404 cmdline_fixed_string_t mode;
7408 cmd_set_uc_all_hash_parsed(void *parsed_result,
7409 __attribute__((unused)) struct cmdline *cl,
7410 __attribute__((unused)) void *data)
7413 struct cmd_set_uc_all_hash_table *res = parsed_result;
7415 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7417 if ((strcmp(res->what, "uta") == 0) &&
7418 (strcmp(res->value, "all") == 0))
7419 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7421 printf("bad unicast hash table parameter,"
7422 "return code = %d \n", ret);
7425 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7426 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7428 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7429 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7431 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7432 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7434 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7435 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7437 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7438 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7440 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7441 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7444 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7445 .f = cmd_set_uc_all_hash_parsed,
7447 .help_str = "set port <port_id> uta all on|off",
7449 (void *)&cmd_set_uc_all_hash_set,
7450 (void *)&cmd_set_uc_all_hash_port,
7451 (void *)&cmd_set_uc_all_hash_portid,
7452 (void *)&cmd_set_uc_all_hash_what,
7453 (void *)&cmd_set_uc_all_hash_value,
7454 (void *)&cmd_set_uc_all_hash_mode,
7459 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7460 struct cmd_set_vf_macvlan_filter {
7461 cmdline_fixed_string_t set;
7462 cmdline_fixed_string_t port;
7464 cmdline_fixed_string_t vf;
7466 struct ether_addr address;
7467 cmdline_fixed_string_t filter_type;
7468 cmdline_fixed_string_t mode;
7472 cmd_set_vf_macvlan_parsed(void *parsed_result,
7473 __attribute__((unused)) struct cmdline *cl,
7474 __attribute__((unused)) void *data)
7477 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7478 struct rte_eth_mac_filter filter;
7480 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7482 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7484 /* set VF MAC filter */
7488 filter.dst_id = res->vf_id;
7490 if (!strcmp(res->filter_type, "exact-mac"))
7491 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7492 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7493 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7494 else if (!strcmp(res->filter_type, "hashmac"))
7495 filter.filter_type = RTE_MAC_HASH_MATCH;
7496 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7497 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7499 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7502 ret = rte_eth_dev_filter_ctrl(res->port_id,
7503 RTE_ETH_FILTER_MACVLAN,
7507 ret = rte_eth_dev_filter_ctrl(res->port_id,
7508 RTE_ETH_FILTER_MACVLAN,
7509 RTE_ETH_FILTER_DELETE,
7513 printf("bad set MAC hash parameter, return code = %d\n", ret);
7517 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7518 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7520 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7521 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7523 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7524 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7526 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7527 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7529 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7530 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7532 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7533 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7535 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7536 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7537 filter_type, "exact-mac#exact-mac-vlan"
7538 "#hashmac#hashmac-vlan");
7539 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7540 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7543 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7544 .f = cmd_set_vf_macvlan_parsed,
7546 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7547 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7548 "Exact match rule: exact match of MAC or MAC and VLAN; "
7549 "hash match rule: hash match of MAC and exact match of VLAN",
7551 (void *)&cmd_set_vf_macvlan_set,
7552 (void *)&cmd_set_vf_macvlan_port,
7553 (void *)&cmd_set_vf_macvlan_portid,
7554 (void *)&cmd_set_vf_macvlan_vf,
7555 (void *)&cmd_set_vf_macvlan_vf_id,
7556 (void *)&cmd_set_vf_macvlan_mac,
7557 (void *)&cmd_set_vf_macvlan_filter_type,
7558 (void *)&cmd_set_vf_macvlan_mode,
7563 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7564 struct cmd_set_vf_traffic {
7565 cmdline_fixed_string_t set;
7566 cmdline_fixed_string_t port;
7568 cmdline_fixed_string_t vf;
7570 cmdline_fixed_string_t what;
7571 cmdline_fixed_string_t mode;
7575 cmd_set_vf_traffic_parsed(void *parsed_result,
7576 __attribute__((unused)) struct cmdline *cl,
7577 __attribute__((unused)) void *data)
7579 struct cmd_set_vf_traffic *res = parsed_result;
7580 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7581 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7583 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7586 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7587 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7589 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7590 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7592 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7593 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7595 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7596 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7598 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7599 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7601 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7602 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7604 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7605 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7608 cmdline_parse_inst_t cmd_set_vf_traffic = {
7609 .f = cmd_set_vf_traffic_parsed,
7611 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7613 (void *)&cmd_setvf_traffic_set,
7614 (void *)&cmd_setvf_traffic_port,
7615 (void *)&cmd_setvf_traffic_portid,
7616 (void *)&cmd_setvf_traffic_vf,
7617 (void *)&cmd_setvf_traffic_vfid,
7618 (void *)&cmd_setvf_traffic_what,
7619 (void *)&cmd_setvf_traffic_mode,
7624 /* *** CONFIGURE VF RECEIVE MODE *** */
7625 struct cmd_set_vf_rxmode {
7626 cmdline_fixed_string_t set;
7627 cmdline_fixed_string_t port;
7629 cmdline_fixed_string_t vf;
7631 cmdline_fixed_string_t what;
7632 cmdline_fixed_string_t mode;
7633 cmdline_fixed_string_t on;
7637 cmd_set_vf_rxmode_parsed(void *parsed_result,
7638 __attribute__((unused)) struct cmdline *cl,
7639 __attribute__((unused)) void *data)
7642 uint16_t rx_mode = 0;
7643 struct cmd_set_vf_rxmode *res = parsed_result;
7645 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7646 if (!strcmp(res->what,"rxmode")) {
7647 if (!strcmp(res->mode, "AUPE"))
7648 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7649 else if (!strcmp(res->mode, "ROPE"))
7650 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7651 else if (!strcmp(res->mode, "BAM"))
7652 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7653 else if (!strncmp(res->mode, "MPE",3))
7654 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7657 RTE_SET_USED(is_on);
7659 #ifdef RTE_LIBRTE_IXGBE_PMD
7660 if (ret == -ENOTSUP)
7661 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7662 rx_mode, (uint8_t)is_on);
7664 #ifdef RTE_LIBRTE_BNXT_PMD
7665 if (ret == -ENOTSUP)
7666 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7667 rx_mode, (uint8_t)is_on);
7670 printf("bad VF receive mode parameter, return code = %d \n",
7674 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7675 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7677 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7678 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7680 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7681 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7683 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7684 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7686 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7687 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7689 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7690 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7692 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7693 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7694 mode, "AUPE#ROPE#BAM#MPE");
7695 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7696 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7699 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7700 .f = cmd_set_vf_rxmode_parsed,
7702 .help_str = "set port <port_id> vf <vf_id> rxmode "
7703 "AUPE|ROPE|BAM|MPE on|off",
7705 (void *)&cmd_set_vf_rxmode_set,
7706 (void *)&cmd_set_vf_rxmode_port,
7707 (void *)&cmd_set_vf_rxmode_portid,
7708 (void *)&cmd_set_vf_rxmode_vf,
7709 (void *)&cmd_set_vf_rxmode_vfid,
7710 (void *)&cmd_set_vf_rxmode_what,
7711 (void *)&cmd_set_vf_rxmode_mode,
7712 (void *)&cmd_set_vf_rxmode_on,
7717 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7718 struct cmd_vf_mac_addr_result {
7719 cmdline_fixed_string_t mac_addr_cmd;
7720 cmdline_fixed_string_t what;
7721 cmdline_fixed_string_t port;
7723 cmdline_fixed_string_t vf;
7725 struct ether_addr address;
7728 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7729 __attribute__((unused)) struct cmdline *cl,
7730 __attribute__((unused)) void *data)
7732 struct cmd_vf_mac_addr_result *res = parsed_result;
7735 if (strcmp(res->what, "add") != 0)
7738 #ifdef RTE_LIBRTE_I40E_PMD
7739 if (ret == -ENOTSUP)
7740 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7743 #ifdef RTE_LIBRTE_BNXT_PMD
7744 if (ret == -ENOTSUP)
7745 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7750 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7754 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7755 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7756 mac_addr_cmd,"mac_addr");
7757 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7758 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7760 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7761 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7763 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7764 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7766 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7767 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7769 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7770 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7772 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7773 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7776 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7777 .f = cmd_vf_mac_addr_parsed,
7779 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7780 "Add MAC address filtering for a VF on port_id",
7782 (void *)&cmd_vf_mac_addr_cmd,
7783 (void *)&cmd_vf_mac_addr_what,
7784 (void *)&cmd_vf_mac_addr_port,
7785 (void *)&cmd_vf_mac_addr_portnum,
7786 (void *)&cmd_vf_mac_addr_vf,
7787 (void *)&cmd_vf_mac_addr_vfnum,
7788 (void *)&cmd_vf_mac_addr_addr,
7793 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7794 struct cmd_vf_rx_vlan_filter {
7795 cmdline_fixed_string_t rx_vlan;
7796 cmdline_fixed_string_t what;
7798 cmdline_fixed_string_t port;
7800 cmdline_fixed_string_t vf;
7805 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7806 __attribute__((unused)) struct cmdline *cl,
7807 __attribute__((unused)) void *data)
7809 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7812 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7814 #ifdef RTE_LIBRTE_IXGBE_PMD
7815 if (ret == -ENOTSUP)
7816 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7817 res->vlan_id, res->vf_mask, is_add);
7819 #ifdef RTE_LIBRTE_I40E_PMD
7820 if (ret == -ENOTSUP)
7821 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7822 res->vlan_id, res->vf_mask, is_add);
7824 #ifdef RTE_LIBRTE_BNXT_PMD
7825 if (ret == -ENOTSUP)
7826 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7827 res->vlan_id, res->vf_mask, is_add);
7834 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7835 res->vlan_id, res->vf_mask);
7838 printf("invalid port_id %d\n", res->port_id);
7841 printf("function not implemented or supported\n");
7844 printf("programming error: (%s)\n", strerror(-ret));
7848 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7849 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7850 rx_vlan, "rx_vlan");
7851 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7852 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7854 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7855 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7857 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7858 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7860 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7861 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7863 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7864 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7866 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7867 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7870 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7871 .f = cmd_vf_rx_vlan_filter_parsed,
7873 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7874 "(vf_mask = hexadecimal VF mask)",
7876 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7877 (void *)&cmd_vf_rx_vlan_filter_what,
7878 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7879 (void *)&cmd_vf_rx_vlan_filter_port,
7880 (void *)&cmd_vf_rx_vlan_filter_portid,
7881 (void *)&cmd_vf_rx_vlan_filter_vf,
7882 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7887 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7888 struct cmd_queue_rate_limit_result {
7889 cmdline_fixed_string_t set;
7890 cmdline_fixed_string_t port;
7892 cmdline_fixed_string_t queue;
7894 cmdline_fixed_string_t rate;
7898 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7899 __attribute__((unused)) struct cmdline *cl,
7900 __attribute__((unused)) void *data)
7902 struct cmd_queue_rate_limit_result *res = parsed_result;
7905 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7906 && (strcmp(res->queue, "queue") == 0)
7907 && (strcmp(res->rate, "rate") == 0))
7908 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7911 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7915 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7916 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7918 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7919 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7921 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7922 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7924 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7925 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7927 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7928 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7930 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7931 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7933 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7934 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7937 cmdline_parse_inst_t cmd_queue_rate_limit = {
7938 .f = cmd_queue_rate_limit_parsed,
7940 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7941 "Set rate limit for a queue on port_id",
7943 (void *)&cmd_queue_rate_limit_set,
7944 (void *)&cmd_queue_rate_limit_port,
7945 (void *)&cmd_queue_rate_limit_portnum,
7946 (void *)&cmd_queue_rate_limit_queue,
7947 (void *)&cmd_queue_rate_limit_queuenum,
7948 (void *)&cmd_queue_rate_limit_rate,
7949 (void *)&cmd_queue_rate_limit_ratenum,
7954 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7955 struct cmd_vf_rate_limit_result {
7956 cmdline_fixed_string_t set;
7957 cmdline_fixed_string_t port;
7959 cmdline_fixed_string_t vf;
7961 cmdline_fixed_string_t rate;
7963 cmdline_fixed_string_t q_msk;
7967 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7968 __attribute__((unused)) struct cmdline *cl,
7969 __attribute__((unused)) void *data)
7971 struct cmd_vf_rate_limit_result *res = parsed_result;
7974 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7975 && (strcmp(res->vf, "vf") == 0)
7976 && (strcmp(res->rate, "rate") == 0)
7977 && (strcmp(res->q_msk, "queue_mask") == 0))
7978 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7979 res->rate_num, res->q_msk_val);
7981 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7985 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7986 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7988 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7989 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7991 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7992 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7994 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7995 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7997 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7998 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8000 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8001 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8003 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8004 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8006 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8007 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8008 q_msk, "queue_mask");
8009 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8010 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8013 cmdline_parse_inst_t cmd_vf_rate_limit = {
8014 .f = cmd_vf_rate_limit_parsed,
8016 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8017 "queue_mask <queue_mask_value>: "
8018 "Set rate limit for queues of VF on port_id",
8020 (void *)&cmd_vf_rate_limit_set,
8021 (void *)&cmd_vf_rate_limit_port,
8022 (void *)&cmd_vf_rate_limit_portnum,
8023 (void *)&cmd_vf_rate_limit_vf,
8024 (void *)&cmd_vf_rate_limit_vfnum,
8025 (void *)&cmd_vf_rate_limit_rate,
8026 (void *)&cmd_vf_rate_limit_ratenum,
8027 (void *)&cmd_vf_rate_limit_q_msk,
8028 (void *)&cmd_vf_rate_limit_q_msk_val,
8033 /* *** ADD TUNNEL FILTER OF A PORT *** */
8034 struct cmd_tunnel_filter_result {
8035 cmdline_fixed_string_t cmd;
8036 cmdline_fixed_string_t what;
8038 struct ether_addr outer_mac;
8039 struct ether_addr inner_mac;
8040 cmdline_ipaddr_t ip_value;
8041 uint16_t inner_vlan;
8042 cmdline_fixed_string_t tunnel_type;
8043 cmdline_fixed_string_t filter_type;
8049 cmd_tunnel_filter_parsed(void *parsed_result,
8050 __attribute__((unused)) struct cmdline *cl,
8051 __attribute__((unused)) void *data)
8053 struct cmd_tunnel_filter_result *res = parsed_result;
8054 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8057 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8059 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8060 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8061 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8063 if (res->ip_value.family == AF_INET) {
8064 tunnel_filter_conf.ip_addr.ipv4_addr =
8065 res->ip_value.addr.ipv4.s_addr;
8066 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8068 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8069 &(res->ip_value.addr.ipv6),
8070 sizeof(struct in6_addr));
8071 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8074 if (!strcmp(res->filter_type, "imac-ivlan"))
8075 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8076 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8077 tunnel_filter_conf.filter_type =
8078 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8079 else if (!strcmp(res->filter_type, "imac-tenid"))
8080 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8081 else if (!strcmp(res->filter_type, "imac"))
8082 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8083 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8084 tunnel_filter_conf.filter_type =
8085 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8086 else if (!strcmp(res->filter_type, "oip"))
8087 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8088 else if (!strcmp(res->filter_type, "iip"))
8089 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8091 printf("The filter type is not supported");
8095 if (!strcmp(res->tunnel_type, "vxlan"))
8096 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8097 else if (!strcmp(res->tunnel_type, "nvgre"))
8098 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8099 else if (!strcmp(res->tunnel_type, "ipingre"))
8100 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8102 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8106 tunnel_filter_conf.tenant_id = res->tenant_id;
8107 tunnel_filter_conf.queue_id = res->queue_num;
8108 if (!strcmp(res->what, "add"))
8109 ret = rte_eth_dev_filter_ctrl(res->port_id,
8110 RTE_ETH_FILTER_TUNNEL,
8112 &tunnel_filter_conf);
8114 ret = rte_eth_dev_filter_ctrl(res->port_id,
8115 RTE_ETH_FILTER_TUNNEL,
8116 RTE_ETH_FILTER_DELETE,
8117 &tunnel_filter_conf);
8119 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8123 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8124 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8125 cmd, "tunnel_filter");
8126 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8127 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8129 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8130 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8132 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8133 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8135 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8136 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8138 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8139 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8140 inner_vlan, UINT16);
8141 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8142 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8144 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8145 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8146 tunnel_type, "vxlan#nvgre#ipingre");
8148 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8149 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8150 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8151 "imac#omac-imac-tenid");
8152 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8153 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8155 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8156 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8159 cmdline_parse_inst_t cmd_tunnel_filter = {
8160 .f = cmd_tunnel_filter_parsed,
8162 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8163 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8164 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8165 "<queue_id>: Add/Rm tunnel filter of a port",
8167 (void *)&cmd_tunnel_filter_cmd,
8168 (void *)&cmd_tunnel_filter_what,
8169 (void *)&cmd_tunnel_filter_port_id,
8170 (void *)&cmd_tunnel_filter_outer_mac,
8171 (void *)&cmd_tunnel_filter_inner_mac,
8172 (void *)&cmd_tunnel_filter_ip_value,
8173 (void *)&cmd_tunnel_filter_innner_vlan,
8174 (void *)&cmd_tunnel_filter_tunnel_type,
8175 (void *)&cmd_tunnel_filter_filter_type,
8176 (void *)&cmd_tunnel_filter_tenant_id,
8177 (void *)&cmd_tunnel_filter_queue_num,
8182 /* *** CONFIGURE TUNNEL UDP PORT *** */
8183 struct cmd_tunnel_udp_config {
8184 cmdline_fixed_string_t cmd;
8185 cmdline_fixed_string_t what;
8191 cmd_tunnel_udp_config_parsed(void *parsed_result,
8192 __attribute__((unused)) struct cmdline *cl,
8193 __attribute__((unused)) void *data)
8195 struct cmd_tunnel_udp_config *res = parsed_result;
8196 struct rte_eth_udp_tunnel tunnel_udp;
8199 tunnel_udp.udp_port = res->udp_port;
8201 if (!strcmp(res->cmd, "rx_vxlan_port"))
8202 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8204 if (!strcmp(res->what, "add"))
8205 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8208 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8212 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8215 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8216 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8217 cmd, "rx_vxlan_port");
8218 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8219 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8221 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8222 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8224 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8225 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8228 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8229 .f = cmd_tunnel_udp_config_parsed,
8231 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8232 "Add/Remove a tunneling UDP port filter",
8234 (void *)&cmd_tunnel_udp_config_cmd,
8235 (void *)&cmd_tunnel_udp_config_what,
8236 (void *)&cmd_tunnel_udp_config_udp_port,
8237 (void *)&cmd_tunnel_udp_config_port_id,
8242 /* *** GLOBAL CONFIG *** */
8243 struct cmd_global_config_result {
8244 cmdline_fixed_string_t cmd;
8246 cmdline_fixed_string_t cfg_type;
8251 cmd_global_config_parsed(void *parsed_result,
8252 __attribute__((unused)) struct cmdline *cl,
8253 __attribute__((unused)) void *data)
8255 struct cmd_global_config_result *res = parsed_result;
8256 struct rte_eth_global_cfg conf;
8259 memset(&conf, 0, sizeof(conf));
8260 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8261 conf.cfg.gre_key_len = res->len;
8262 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8263 RTE_ETH_FILTER_SET, &conf);
8265 printf("Global config error\n");
8268 cmdline_parse_token_string_t cmd_global_config_cmd =
8269 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8271 cmdline_parse_token_num_t cmd_global_config_port_id =
8272 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8274 cmdline_parse_token_string_t cmd_global_config_type =
8275 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8276 cfg_type, "gre-key-len");
8277 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8278 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8281 cmdline_parse_inst_t cmd_global_config = {
8282 .f = cmd_global_config_parsed,
8283 .data = (void *)NULL,
8284 .help_str = "global_config <port_id> gre-key-len <key_len>",
8286 (void *)&cmd_global_config_cmd,
8287 (void *)&cmd_global_config_port_id,
8288 (void *)&cmd_global_config_type,
8289 (void *)&cmd_global_config_gre_key_len,
8294 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8295 struct cmd_set_mirror_mask_result {
8296 cmdline_fixed_string_t set;
8297 cmdline_fixed_string_t port;
8299 cmdline_fixed_string_t mirror;
8301 cmdline_fixed_string_t what;
8302 cmdline_fixed_string_t value;
8303 cmdline_fixed_string_t dstpool;
8305 cmdline_fixed_string_t on;
8308 cmdline_parse_token_string_t cmd_mirror_mask_set =
8309 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8311 cmdline_parse_token_string_t cmd_mirror_mask_port =
8312 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8314 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8315 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8317 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8318 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8319 mirror, "mirror-rule");
8320 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8321 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8323 cmdline_parse_token_string_t cmd_mirror_mask_what =
8324 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8325 what, "pool-mirror-up#pool-mirror-down"
8327 cmdline_parse_token_string_t cmd_mirror_mask_value =
8328 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8330 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8331 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8332 dstpool, "dst-pool");
8333 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8334 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8336 cmdline_parse_token_string_t cmd_mirror_mask_on =
8337 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8341 cmd_set_mirror_mask_parsed(void *parsed_result,
8342 __attribute__((unused)) struct cmdline *cl,
8343 __attribute__((unused)) void *data)
8346 struct cmd_set_mirror_mask_result *res = parsed_result;
8347 struct rte_eth_mirror_conf mr_conf;
8349 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8351 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8353 mr_conf.dst_pool = res->dstpool_id;
8355 if (!strcmp(res->what, "pool-mirror-up")) {
8356 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8357 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8358 } else if (!strcmp(res->what, "pool-mirror-down")) {
8359 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8360 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8361 } else if (!strcmp(res->what, "vlan-mirror")) {
8362 mr_conf.rule_type = ETH_MIRROR_VLAN;
8363 nb_item = parse_item_list(res->value, "vlan",
8364 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8368 for (i = 0; i < nb_item; i++) {
8369 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8370 printf("Invalid vlan_id: must be < 4096\n");
8374 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8375 mr_conf.vlan.vlan_mask |= 1ULL << i;
8379 if (!strcmp(res->on, "on"))
8380 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8383 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8386 printf("mirror rule add error: (%s)\n", strerror(-ret));
8389 cmdline_parse_inst_t cmd_set_mirror_mask = {
8390 .f = cmd_set_mirror_mask_parsed,
8392 .help_str = "set port <port_id> mirror-rule <rule_id> "
8393 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8394 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8396 (void *)&cmd_mirror_mask_set,
8397 (void *)&cmd_mirror_mask_port,
8398 (void *)&cmd_mirror_mask_portid,
8399 (void *)&cmd_mirror_mask_mirror,
8400 (void *)&cmd_mirror_mask_ruleid,
8401 (void *)&cmd_mirror_mask_what,
8402 (void *)&cmd_mirror_mask_value,
8403 (void *)&cmd_mirror_mask_dstpool,
8404 (void *)&cmd_mirror_mask_poolid,
8405 (void *)&cmd_mirror_mask_on,
8410 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8411 struct cmd_set_mirror_link_result {
8412 cmdline_fixed_string_t set;
8413 cmdline_fixed_string_t port;
8415 cmdline_fixed_string_t mirror;
8417 cmdline_fixed_string_t what;
8418 cmdline_fixed_string_t dstpool;
8420 cmdline_fixed_string_t on;
8423 cmdline_parse_token_string_t cmd_mirror_link_set =
8424 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8426 cmdline_parse_token_string_t cmd_mirror_link_port =
8427 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8429 cmdline_parse_token_num_t cmd_mirror_link_portid =
8430 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8432 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8433 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8434 mirror, "mirror-rule");
8435 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8436 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8438 cmdline_parse_token_string_t cmd_mirror_link_what =
8439 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8440 what, "uplink-mirror#downlink-mirror");
8441 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8442 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8443 dstpool, "dst-pool");
8444 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8445 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8447 cmdline_parse_token_string_t cmd_mirror_link_on =
8448 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8452 cmd_set_mirror_link_parsed(void *parsed_result,
8453 __attribute__((unused)) struct cmdline *cl,
8454 __attribute__((unused)) void *data)
8457 struct cmd_set_mirror_link_result *res = parsed_result;
8458 struct rte_eth_mirror_conf mr_conf;
8460 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8461 if (!strcmp(res->what, "uplink-mirror"))
8462 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8464 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8466 mr_conf.dst_pool = res->dstpool_id;
8468 if (!strcmp(res->on, "on"))
8469 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8472 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8475 /* check the return value and print it if is < 0 */
8477 printf("mirror rule add error: (%s)\n", strerror(-ret));
8481 cmdline_parse_inst_t cmd_set_mirror_link = {
8482 .f = cmd_set_mirror_link_parsed,
8484 .help_str = "set port <port_id> mirror-rule <rule_id> "
8485 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8487 (void *)&cmd_mirror_link_set,
8488 (void *)&cmd_mirror_link_port,
8489 (void *)&cmd_mirror_link_portid,
8490 (void *)&cmd_mirror_link_mirror,
8491 (void *)&cmd_mirror_link_ruleid,
8492 (void *)&cmd_mirror_link_what,
8493 (void *)&cmd_mirror_link_dstpool,
8494 (void *)&cmd_mirror_link_poolid,
8495 (void *)&cmd_mirror_link_on,
8500 /* *** RESET VM MIRROR RULE *** */
8501 struct cmd_rm_mirror_rule_result {
8502 cmdline_fixed_string_t reset;
8503 cmdline_fixed_string_t port;
8505 cmdline_fixed_string_t mirror;
8509 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8510 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8512 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8513 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8515 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8516 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8518 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8519 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8520 mirror, "mirror-rule");
8521 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8522 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8526 cmd_reset_mirror_rule_parsed(void *parsed_result,
8527 __attribute__((unused)) struct cmdline *cl,
8528 __attribute__((unused)) void *data)
8531 struct cmd_set_mirror_link_result *res = parsed_result;
8533 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8535 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8538 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8539 .f = cmd_reset_mirror_rule_parsed,
8541 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8543 (void *)&cmd_rm_mirror_rule_reset,
8544 (void *)&cmd_rm_mirror_rule_port,
8545 (void *)&cmd_rm_mirror_rule_portid,
8546 (void *)&cmd_rm_mirror_rule_mirror,
8547 (void *)&cmd_rm_mirror_rule_ruleid,
8552 /* ******************************************************************************** */
8554 struct cmd_dump_result {
8555 cmdline_fixed_string_t dump;
8559 dump_struct_sizes(void)
8561 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8562 DUMP_SIZE(struct rte_mbuf);
8563 DUMP_SIZE(struct rte_mempool);
8564 DUMP_SIZE(struct rte_ring);
8568 static void cmd_dump_parsed(void *parsed_result,
8569 __attribute__((unused)) struct cmdline *cl,
8570 __attribute__((unused)) void *data)
8572 struct cmd_dump_result *res = parsed_result;
8574 if (!strcmp(res->dump, "dump_physmem"))
8575 rte_dump_physmem_layout(stdout);
8576 else if (!strcmp(res->dump, "dump_memzone"))
8577 rte_memzone_dump(stdout);
8578 else if (!strcmp(res->dump, "dump_struct_sizes"))
8579 dump_struct_sizes();
8580 else if (!strcmp(res->dump, "dump_ring"))
8581 rte_ring_list_dump(stdout);
8582 else if (!strcmp(res->dump, "dump_mempool"))
8583 rte_mempool_list_dump(stdout);
8584 else if (!strcmp(res->dump, "dump_devargs"))
8585 rte_eal_devargs_dump(stdout);
8586 else if (!strcmp(res->dump, "dump_log_types"))
8587 rte_log_dump(stdout);
8590 cmdline_parse_token_string_t cmd_dump_dump =
8591 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8594 "dump_struct_sizes#"
8600 cmdline_parse_inst_t cmd_dump = {
8601 .f = cmd_dump_parsed, /* function to call */
8602 .data = NULL, /* 2nd arg of func */
8603 .help_str = "Dump status",
8604 .tokens = { /* token list, NULL terminated */
8605 (void *)&cmd_dump_dump,
8610 /* ******************************************************************************** */
8612 struct cmd_dump_one_result {
8613 cmdline_fixed_string_t dump;
8614 cmdline_fixed_string_t name;
8617 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8618 __attribute__((unused)) void *data)
8620 struct cmd_dump_one_result *res = parsed_result;
8622 if (!strcmp(res->dump, "dump_ring")) {
8624 r = rte_ring_lookup(res->name);
8626 cmdline_printf(cl, "Cannot find ring\n");
8629 rte_ring_dump(stdout, r);
8630 } else if (!strcmp(res->dump, "dump_mempool")) {
8631 struct rte_mempool *mp;
8632 mp = rte_mempool_lookup(res->name);
8634 cmdline_printf(cl, "Cannot find mempool\n");
8637 rte_mempool_dump(stdout, mp);
8641 cmdline_parse_token_string_t cmd_dump_one_dump =
8642 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8643 "dump_ring#dump_mempool");
8645 cmdline_parse_token_string_t cmd_dump_one_name =
8646 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8648 cmdline_parse_inst_t cmd_dump_one = {
8649 .f = cmd_dump_one_parsed, /* function to call */
8650 .data = NULL, /* 2nd arg of func */
8651 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8652 .tokens = { /* token list, NULL terminated */
8653 (void *)&cmd_dump_one_dump,
8654 (void *)&cmd_dump_one_name,
8659 /* *** Add/Del syn filter *** */
8660 struct cmd_syn_filter_result {
8661 cmdline_fixed_string_t filter;
8663 cmdline_fixed_string_t ops;
8664 cmdline_fixed_string_t priority;
8665 cmdline_fixed_string_t high;
8666 cmdline_fixed_string_t queue;
8671 cmd_syn_filter_parsed(void *parsed_result,
8672 __attribute__((unused)) struct cmdline *cl,
8673 __attribute__((unused)) void *data)
8675 struct cmd_syn_filter_result *res = parsed_result;
8676 struct rte_eth_syn_filter syn_filter;
8679 ret = rte_eth_dev_filter_supported(res->port_id,
8680 RTE_ETH_FILTER_SYN);
8682 printf("syn filter is not supported on port %u.\n",
8687 memset(&syn_filter, 0, sizeof(syn_filter));
8689 if (!strcmp(res->ops, "add")) {
8690 if (!strcmp(res->high, "high"))
8691 syn_filter.hig_pri = 1;
8693 syn_filter.hig_pri = 0;
8695 syn_filter.queue = res->queue_id;
8696 ret = rte_eth_dev_filter_ctrl(res->port_id,
8701 ret = rte_eth_dev_filter_ctrl(res->port_id,
8703 RTE_ETH_FILTER_DELETE,
8707 printf("syn filter programming error: (%s)\n",
8711 cmdline_parse_token_string_t cmd_syn_filter_filter =
8712 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8713 filter, "syn_filter");
8714 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8715 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8717 cmdline_parse_token_string_t cmd_syn_filter_ops =
8718 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8720 cmdline_parse_token_string_t cmd_syn_filter_priority =
8721 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8722 priority, "priority");
8723 cmdline_parse_token_string_t cmd_syn_filter_high =
8724 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8726 cmdline_parse_token_string_t cmd_syn_filter_queue =
8727 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8729 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8730 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8733 cmdline_parse_inst_t cmd_syn_filter = {
8734 .f = cmd_syn_filter_parsed,
8736 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8737 "<queue_id>: Add/Delete syn filter",
8739 (void *)&cmd_syn_filter_filter,
8740 (void *)&cmd_syn_filter_port_id,
8741 (void *)&cmd_syn_filter_ops,
8742 (void *)&cmd_syn_filter_priority,
8743 (void *)&cmd_syn_filter_high,
8744 (void *)&cmd_syn_filter_queue,
8745 (void *)&cmd_syn_filter_queue_id,
8750 /* *** queue region set *** */
8751 struct cmd_queue_region_result {
8752 cmdline_fixed_string_t set;
8753 cmdline_fixed_string_t port;
8755 cmdline_fixed_string_t cmd;
8756 cmdline_fixed_string_t region;
8758 cmdline_fixed_string_t queue_start_index;
8760 cmdline_fixed_string_t queue_num;
8761 uint8_t queue_num_value;
8765 cmd_queue_region_parsed(void *parsed_result,
8766 __attribute__((unused)) struct cmdline *cl,
8767 __attribute__((unused)) void *data)
8769 struct cmd_queue_region_result *res = parsed_result;
8771 #ifdef RTE_LIBRTE_I40E_PMD
8772 struct rte_pmd_i40e_queue_region_conf region_conf;
8773 enum rte_pmd_i40e_queue_region_op op_type;
8776 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8779 #ifdef RTE_LIBRTE_I40E_PMD
8780 memset(®ion_conf, 0, sizeof(region_conf));
8781 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8782 region_conf.region_id = res->region_id;
8783 region_conf.queue_num = res->queue_num_value;
8784 region_conf.queue_start_index = res->queue_id;
8786 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8787 op_type, ®ion_conf);
8794 printf("function not implemented or supported\n");
8797 printf("queue region config error: (%s)\n", strerror(-ret));
8801 cmdline_parse_token_string_t cmd_queue_region_set =
8802 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8804 cmdline_parse_token_string_t cmd_queue_region_port =
8805 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8806 cmdline_parse_token_num_t cmd_queue_region_port_id =
8807 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8809 cmdline_parse_token_string_t cmd_queue_region_cmd =
8810 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8811 cmd, "queue-region");
8812 cmdline_parse_token_string_t cmd_queue_region_id =
8813 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8814 region, "region_id");
8815 cmdline_parse_token_num_t cmd_queue_region_index =
8816 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8818 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8819 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8820 queue_start_index, "queue_start_index");
8821 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8822 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8824 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8825 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8826 queue_num, "queue_num");
8827 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8828 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8829 queue_num_value, UINT8);
8831 cmdline_parse_inst_t cmd_queue_region = {
8832 .f = cmd_queue_region_parsed,
8834 .help_str = "set port <port_id> queue-region region_id <value> "
8835 "queue_start_index <value> queue_num <value>: Set a queue region",
8837 (void *)&cmd_queue_region_set,
8838 (void *)&cmd_queue_region_port,
8839 (void *)&cmd_queue_region_port_id,
8840 (void *)&cmd_queue_region_cmd,
8841 (void *)&cmd_queue_region_id,
8842 (void *)&cmd_queue_region_index,
8843 (void *)&cmd_queue_region_queue_start_index,
8844 (void *)&cmd_queue_region_queue_id,
8845 (void *)&cmd_queue_region_queue_num,
8846 (void *)&cmd_queue_region_queue_num_value,
8851 /* *** queue region and flowtype set *** */
8852 struct cmd_region_flowtype_result {
8853 cmdline_fixed_string_t set;
8854 cmdline_fixed_string_t port;
8856 cmdline_fixed_string_t cmd;
8857 cmdline_fixed_string_t region;
8859 cmdline_fixed_string_t flowtype;
8860 uint8_t flowtype_id;
8864 cmd_region_flowtype_parsed(void *parsed_result,
8865 __attribute__((unused)) struct cmdline *cl,
8866 __attribute__((unused)) void *data)
8868 struct cmd_region_flowtype_result *res = parsed_result;
8870 #ifdef RTE_LIBRTE_I40E_PMD
8871 struct rte_pmd_i40e_queue_region_conf region_conf;
8872 enum rte_pmd_i40e_queue_region_op op_type;
8875 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8878 #ifdef RTE_LIBRTE_I40E_PMD
8879 memset(®ion_conf, 0, sizeof(region_conf));
8881 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8882 region_conf.region_id = res->region_id;
8883 region_conf.hw_flowtype = res->flowtype_id;
8885 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8886 op_type, ®ion_conf);
8893 printf("function not implemented or supported\n");
8896 printf("region flowtype config error: (%s)\n", strerror(-ret));
8900 cmdline_parse_token_string_t cmd_region_flowtype_set =
8901 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8903 cmdline_parse_token_string_t cmd_region_flowtype_port =
8904 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8906 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8907 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8909 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8910 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8911 cmd, "queue-region");
8912 cmdline_parse_token_string_t cmd_region_flowtype_index =
8913 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8914 region, "region_id");
8915 cmdline_parse_token_num_t cmd_region_flowtype_id =
8916 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8918 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8919 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8920 flowtype, "flowtype");
8921 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8922 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8923 flowtype_id, UINT8);
8924 cmdline_parse_inst_t cmd_region_flowtype = {
8925 .f = cmd_region_flowtype_parsed,
8927 .help_str = "set port <port_id> queue-region region_id <value> "
8928 "flowtype <value>: Set a flowtype region index",
8930 (void *)&cmd_region_flowtype_set,
8931 (void *)&cmd_region_flowtype_port,
8932 (void *)&cmd_region_flowtype_port_index,
8933 (void *)&cmd_region_flowtype_cmd,
8934 (void *)&cmd_region_flowtype_index,
8935 (void *)&cmd_region_flowtype_id,
8936 (void *)&cmd_region_flowtype_flow_index,
8937 (void *)&cmd_region_flowtype_flow_id,
8942 /* *** User Priority (UP) to queue region (region_id) set *** */
8943 struct cmd_user_priority_region_result {
8944 cmdline_fixed_string_t set;
8945 cmdline_fixed_string_t port;
8947 cmdline_fixed_string_t cmd;
8948 cmdline_fixed_string_t user_priority;
8949 uint8_t user_priority_id;
8950 cmdline_fixed_string_t region;
8955 cmd_user_priority_region_parsed(void *parsed_result,
8956 __attribute__((unused)) struct cmdline *cl,
8957 __attribute__((unused)) void *data)
8959 struct cmd_user_priority_region_result *res = parsed_result;
8961 #ifdef RTE_LIBRTE_I40E_PMD
8962 struct rte_pmd_i40e_queue_region_conf region_conf;
8963 enum rte_pmd_i40e_queue_region_op op_type;
8966 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8969 #ifdef RTE_LIBRTE_I40E_PMD
8970 memset(®ion_conf, 0, sizeof(region_conf));
8971 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8972 region_conf.user_priority = res->user_priority_id;
8973 region_conf.region_id = res->region_id;
8975 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8976 op_type, ®ion_conf);
8983 printf("function not implemented or supported\n");
8986 printf("user_priority region config error: (%s)\n",
8991 cmdline_parse_token_string_t cmd_user_priority_region_set =
8992 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8994 cmdline_parse_token_string_t cmd_user_priority_region_port =
8995 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8997 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8998 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9000 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9001 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9002 cmd, "queue-region");
9003 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9004 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9005 user_priority, "UP");
9006 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9007 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9008 user_priority_id, UINT8);
9009 cmdline_parse_token_string_t cmd_user_priority_region_region =
9010 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9011 region, "region_id");
9012 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9013 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9016 cmdline_parse_inst_t cmd_user_priority_region = {
9017 .f = cmd_user_priority_region_parsed,
9019 .help_str = "set port <port_id> queue-region UP <value> "
9020 "region_id <value>: Set the mapping of User Priority (UP) "
9021 "to queue region (region_id) ",
9023 (void *)&cmd_user_priority_region_set,
9024 (void *)&cmd_user_priority_region_port,
9025 (void *)&cmd_user_priority_region_port_index,
9026 (void *)&cmd_user_priority_region_cmd,
9027 (void *)&cmd_user_priority_region_UP,
9028 (void *)&cmd_user_priority_region_UP_id,
9029 (void *)&cmd_user_priority_region_region,
9030 (void *)&cmd_user_priority_region_region_id,
9035 /* *** flush all queue region related configuration *** */
9036 struct cmd_flush_queue_region_result {
9037 cmdline_fixed_string_t set;
9038 cmdline_fixed_string_t port;
9040 cmdline_fixed_string_t cmd;
9041 cmdline_fixed_string_t flush;
9042 cmdline_fixed_string_t what;
9046 cmd_flush_queue_region_parsed(void *parsed_result,
9047 __attribute__((unused)) struct cmdline *cl,
9048 __attribute__((unused)) void *data)
9050 struct cmd_flush_queue_region_result *res = parsed_result;
9052 #ifdef RTE_LIBRTE_I40E_PMD
9053 struct rte_pmd_i40e_queue_region_conf region_conf;
9054 enum rte_pmd_i40e_queue_region_op op_type;
9057 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9060 #ifdef RTE_LIBRTE_I40E_PMD
9061 memset(®ion_conf, 0, sizeof(region_conf));
9063 if (strcmp(res->what, "on") == 0)
9064 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9066 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9068 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9069 op_type, ®ion_conf);
9076 printf("function not implemented or supported\n");
9079 printf("queue region config flush error: (%s)\n",
9084 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9085 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9087 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9088 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9090 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9091 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9093 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9094 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9095 cmd, "queue-region");
9096 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9097 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9099 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9100 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9103 cmdline_parse_inst_t cmd_flush_queue_region = {
9104 .f = cmd_flush_queue_region_parsed,
9106 .help_str = "set port <port_id> queue-region flush on|off"
9107 ": flush all queue region related configuration",
9109 (void *)&cmd_flush_queue_region_set,
9110 (void *)&cmd_flush_queue_region_port,
9111 (void *)&cmd_flush_queue_region_port_index,
9112 (void *)&cmd_flush_queue_region_cmd,
9113 (void *)&cmd_flush_queue_region_flush,
9114 (void *)&cmd_flush_queue_region_what,
9119 /* *** get all queue region related configuration info *** */
9120 struct cmd_show_queue_region_info {
9121 cmdline_fixed_string_t show;
9122 cmdline_fixed_string_t port;
9124 cmdline_fixed_string_t cmd;
9128 cmd_show_queue_region_info_parsed(void *parsed_result,
9129 __attribute__((unused)) struct cmdline *cl,
9130 __attribute__((unused)) void *data)
9132 struct cmd_show_queue_region_info *res = parsed_result;
9134 #ifdef RTE_LIBRTE_I40E_PMD
9135 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9136 enum rte_pmd_i40e_queue_region_op op_type;
9139 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9142 #ifdef RTE_LIBRTE_I40E_PMD
9143 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9145 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9147 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9148 op_type, &rte_pmd_regions);
9150 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9157 printf("function not implemented or supported\n");
9160 printf("queue region config info show error: (%s)\n",
9165 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9166 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9168 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9169 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9171 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9172 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9174 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9175 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9176 cmd, "queue-region");
9178 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9179 .f = cmd_show_queue_region_info_parsed,
9181 .help_str = "show port <port_id> queue-region"
9182 ": show all queue region related configuration info",
9184 (void *)&cmd_show_queue_region_info_get,
9185 (void *)&cmd_show_queue_region_info_port,
9186 (void *)&cmd_show_queue_region_info_port_index,
9187 (void *)&cmd_show_queue_region_info_cmd,
9192 /* *** ADD/REMOVE A 2tuple FILTER *** */
9193 struct cmd_2tuple_filter_result {
9194 cmdline_fixed_string_t filter;
9196 cmdline_fixed_string_t ops;
9197 cmdline_fixed_string_t dst_port;
9198 uint16_t dst_port_value;
9199 cmdline_fixed_string_t protocol;
9200 uint8_t protocol_value;
9201 cmdline_fixed_string_t mask;
9203 cmdline_fixed_string_t tcp_flags;
9204 uint8_t tcp_flags_value;
9205 cmdline_fixed_string_t priority;
9206 uint8_t priority_value;
9207 cmdline_fixed_string_t queue;
9212 cmd_2tuple_filter_parsed(void *parsed_result,
9213 __attribute__((unused)) struct cmdline *cl,
9214 __attribute__((unused)) void *data)
9216 struct rte_eth_ntuple_filter filter;
9217 struct cmd_2tuple_filter_result *res = parsed_result;
9220 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9222 printf("ntuple filter is not supported on port %u.\n",
9227 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9229 filter.flags = RTE_2TUPLE_FLAGS;
9230 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9231 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9232 filter.proto = res->protocol_value;
9233 filter.priority = res->priority_value;
9234 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9235 printf("nonzero tcp_flags is only meaningful"
9236 " when protocol is TCP.\n");
9239 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9240 printf("invalid TCP flags.\n");
9244 if (res->tcp_flags_value != 0) {
9245 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9246 filter.tcp_flags = res->tcp_flags_value;
9249 /* need convert to big endian. */
9250 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9251 filter.queue = res->queue_id;
9253 if (!strcmp(res->ops, "add"))
9254 ret = rte_eth_dev_filter_ctrl(res->port_id,
9255 RTE_ETH_FILTER_NTUPLE,
9259 ret = rte_eth_dev_filter_ctrl(res->port_id,
9260 RTE_ETH_FILTER_NTUPLE,
9261 RTE_ETH_FILTER_DELETE,
9264 printf("2tuple filter programming error: (%s)\n",
9269 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9270 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9271 filter, "2tuple_filter");
9272 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9273 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9275 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9276 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9278 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9279 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9280 dst_port, "dst_port");
9281 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9282 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9283 dst_port_value, UINT16);
9284 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9285 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9286 protocol, "protocol");
9287 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9288 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9289 protocol_value, UINT8);
9290 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9291 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9293 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9294 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9296 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9297 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9298 tcp_flags, "tcp_flags");
9299 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9300 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9301 tcp_flags_value, UINT8);
9302 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9303 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9304 priority, "priority");
9305 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9306 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9307 priority_value, UINT8);
9308 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9309 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9311 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9312 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9315 cmdline_parse_inst_t cmd_2tuple_filter = {
9316 .f = cmd_2tuple_filter_parsed,
9318 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9319 "<value> mask <value> tcp_flags <value> priority <value> queue "
9320 "<queue_id>: Add a 2tuple filter",
9322 (void *)&cmd_2tuple_filter_filter,
9323 (void *)&cmd_2tuple_filter_port_id,
9324 (void *)&cmd_2tuple_filter_ops,
9325 (void *)&cmd_2tuple_filter_dst_port,
9326 (void *)&cmd_2tuple_filter_dst_port_value,
9327 (void *)&cmd_2tuple_filter_protocol,
9328 (void *)&cmd_2tuple_filter_protocol_value,
9329 (void *)&cmd_2tuple_filter_mask,
9330 (void *)&cmd_2tuple_filter_mask_value,
9331 (void *)&cmd_2tuple_filter_tcp_flags,
9332 (void *)&cmd_2tuple_filter_tcp_flags_value,
9333 (void *)&cmd_2tuple_filter_priority,
9334 (void *)&cmd_2tuple_filter_priority_value,
9335 (void *)&cmd_2tuple_filter_queue,
9336 (void *)&cmd_2tuple_filter_queue_id,
9341 /* *** ADD/REMOVE A 5tuple FILTER *** */
9342 struct cmd_5tuple_filter_result {
9343 cmdline_fixed_string_t filter;
9345 cmdline_fixed_string_t ops;
9346 cmdline_fixed_string_t dst_ip;
9347 cmdline_ipaddr_t dst_ip_value;
9348 cmdline_fixed_string_t src_ip;
9349 cmdline_ipaddr_t src_ip_value;
9350 cmdline_fixed_string_t dst_port;
9351 uint16_t dst_port_value;
9352 cmdline_fixed_string_t src_port;
9353 uint16_t src_port_value;
9354 cmdline_fixed_string_t protocol;
9355 uint8_t protocol_value;
9356 cmdline_fixed_string_t mask;
9358 cmdline_fixed_string_t tcp_flags;
9359 uint8_t tcp_flags_value;
9360 cmdline_fixed_string_t priority;
9361 uint8_t priority_value;
9362 cmdline_fixed_string_t queue;
9367 cmd_5tuple_filter_parsed(void *parsed_result,
9368 __attribute__((unused)) struct cmdline *cl,
9369 __attribute__((unused)) void *data)
9371 struct rte_eth_ntuple_filter filter;
9372 struct cmd_5tuple_filter_result *res = parsed_result;
9375 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9377 printf("ntuple filter is not supported on port %u.\n",
9382 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9384 filter.flags = RTE_5TUPLE_FLAGS;
9385 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9386 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9387 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9388 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9389 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9390 filter.proto = res->protocol_value;
9391 filter.priority = res->priority_value;
9392 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9393 printf("nonzero tcp_flags is only meaningful"
9394 " when protocol is TCP.\n");
9397 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9398 printf("invalid TCP flags.\n");
9402 if (res->tcp_flags_value != 0) {
9403 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9404 filter.tcp_flags = res->tcp_flags_value;
9407 if (res->dst_ip_value.family == AF_INET)
9408 /* no need to convert, already big endian. */
9409 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9411 if (filter.dst_ip_mask == 0) {
9412 printf("can not support ipv6 involved compare.\n");
9418 if (res->src_ip_value.family == AF_INET)
9419 /* no need to convert, already big endian. */
9420 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9422 if (filter.src_ip_mask == 0) {
9423 printf("can not support ipv6 involved compare.\n");
9428 /* need convert to big endian. */
9429 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9430 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9431 filter.queue = res->queue_id;
9433 if (!strcmp(res->ops, "add"))
9434 ret = rte_eth_dev_filter_ctrl(res->port_id,
9435 RTE_ETH_FILTER_NTUPLE,
9439 ret = rte_eth_dev_filter_ctrl(res->port_id,
9440 RTE_ETH_FILTER_NTUPLE,
9441 RTE_ETH_FILTER_DELETE,
9444 printf("5tuple filter programming error: (%s)\n",
9448 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9449 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9450 filter, "5tuple_filter");
9451 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9452 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9454 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9455 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9457 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9458 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9460 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9461 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9463 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9464 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9466 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9467 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9469 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9470 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9471 dst_port, "dst_port");
9472 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9473 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9474 dst_port_value, UINT16);
9475 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9476 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9477 src_port, "src_port");
9478 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9479 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9480 src_port_value, UINT16);
9481 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9482 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9483 protocol, "protocol");
9484 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9485 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9486 protocol_value, UINT8);
9487 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9488 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9490 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9491 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9493 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9494 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9495 tcp_flags, "tcp_flags");
9496 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9497 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9498 tcp_flags_value, UINT8);
9499 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9500 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9501 priority, "priority");
9502 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9503 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9504 priority_value, UINT8);
9505 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9506 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9508 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9509 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9512 cmdline_parse_inst_t cmd_5tuple_filter = {
9513 .f = cmd_5tuple_filter_parsed,
9515 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9516 "src_ip <value> dst_port <value> src_port <value> "
9517 "protocol <value> mask <value> tcp_flags <value> "
9518 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9520 (void *)&cmd_5tuple_filter_filter,
9521 (void *)&cmd_5tuple_filter_port_id,
9522 (void *)&cmd_5tuple_filter_ops,
9523 (void *)&cmd_5tuple_filter_dst_ip,
9524 (void *)&cmd_5tuple_filter_dst_ip_value,
9525 (void *)&cmd_5tuple_filter_src_ip,
9526 (void *)&cmd_5tuple_filter_src_ip_value,
9527 (void *)&cmd_5tuple_filter_dst_port,
9528 (void *)&cmd_5tuple_filter_dst_port_value,
9529 (void *)&cmd_5tuple_filter_src_port,
9530 (void *)&cmd_5tuple_filter_src_port_value,
9531 (void *)&cmd_5tuple_filter_protocol,
9532 (void *)&cmd_5tuple_filter_protocol_value,
9533 (void *)&cmd_5tuple_filter_mask,
9534 (void *)&cmd_5tuple_filter_mask_value,
9535 (void *)&cmd_5tuple_filter_tcp_flags,
9536 (void *)&cmd_5tuple_filter_tcp_flags_value,
9537 (void *)&cmd_5tuple_filter_priority,
9538 (void *)&cmd_5tuple_filter_priority_value,
9539 (void *)&cmd_5tuple_filter_queue,
9540 (void *)&cmd_5tuple_filter_queue_id,
9545 /* *** ADD/REMOVE A flex FILTER *** */
9546 struct cmd_flex_filter_result {
9547 cmdline_fixed_string_t filter;
9548 cmdline_fixed_string_t ops;
9550 cmdline_fixed_string_t len;
9552 cmdline_fixed_string_t bytes;
9553 cmdline_fixed_string_t bytes_value;
9554 cmdline_fixed_string_t mask;
9555 cmdline_fixed_string_t mask_value;
9556 cmdline_fixed_string_t priority;
9557 uint8_t priority_value;
9558 cmdline_fixed_string_t queue;
9562 static int xdigit2val(unsigned char c)
9567 else if (isupper(c))
9575 cmd_flex_filter_parsed(void *parsed_result,
9576 __attribute__((unused)) struct cmdline *cl,
9577 __attribute__((unused)) void *data)
9580 struct rte_eth_flex_filter filter;
9581 struct cmd_flex_filter_result *res = parsed_result;
9582 char *bytes_ptr, *mask_ptr;
9583 uint16_t len, i, j = 0;
9588 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9589 printf("the len exceed the max length 128\n");
9592 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9593 filter.len = res->len_value;
9594 filter.priority = res->priority_value;
9595 filter.queue = res->queue_id;
9596 bytes_ptr = res->bytes_value;
9597 mask_ptr = res->mask_value;
9599 /* translate bytes string to array. */
9600 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9601 (bytes_ptr[1] == 'X')))
9603 len = strnlen(bytes_ptr, res->len_value * 2);
9604 if (len == 0 || (len % 8 != 0)) {
9605 printf("please check len and bytes input\n");
9608 for (i = 0; i < len; i++) {
9610 if (isxdigit(c) == 0) {
9611 /* invalid characters. */
9612 printf("invalid input\n");
9615 val = xdigit2val(c);
9618 filter.bytes[j] = byte;
9619 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9626 /* translate mask string to uint8_t array. */
9627 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9628 (mask_ptr[1] == 'X')))
9630 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9632 printf("invalid input\n");
9637 for (i = 0; i < len; i++) {
9639 if (isxdigit(c) == 0) {
9640 /* invalid characters. */
9641 printf("invalid input\n");
9644 val = xdigit2val(c);
9647 filter.mask[j] = byte;
9648 printf("mask[%d]:%02x ", j, filter.mask[j]);
9656 if (!strcmp(res->ops, "add"))
9657 ret = rte_eth_dev_filter_ctrl(res->port_id,
9658 RTE_ETH_FILTER_FLEXIBLE,
9662 ret = rte_eth_dev_filter_ctrl(res->port_id,
9663 RTE_ETH_FILTER_FLEXIBLE,
9664 RTE_ETH_FILTER_DELETE,
9668 printf("flex filter setting error: (%s)\n", strerror(-ret));
9671 cmdline_parse_token_string_t cmd_flex_filter_filter =
9672 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9673 filter, "flex_filter");
9674 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9675 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9677 cmdline_parse_token_string_t cmd_flex_filter_ops =
9678 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9680 cmdline_parse_token_string_t cmd_flex_filter_len =
9681 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9683 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9684 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9686 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9687 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9689 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9690 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9692 cmdline_parse_token_string_t cmd_flex_filter_mask =
9693 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9695 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9696 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9698 cmdline_parse_token_string_t cmd_flex_filter_priority =
9699 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9700 priority, "priority");
9701 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9702 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9703 priority_value, UINT8);
9704 cmdline_parse_token_string_t cmd_flex_filter_queue =
9705 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9707 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9708 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9710 cmdline_parse_inst_t cmd_flex_filter = {
9711 .f = cmd_flex_filter_parsed,
9713 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9714 "<value> mask <value> priority <value> queue <queue_id>: "
9715 "Add/Del a flex filter",
9717 (void *)&cmd_flex_filter_filter,
9718 (void *)&cmd_flex_filter_port_id,
9719 (void *)&cmd_flex_filter_ops,
9720 (void *)&cmd_flex_filter_len,
9721 (void *)&cmd_flex_filter_len_value,
9722 (void *)&cmd_flex_filter_bytes,
9723 (void *)&cmd_flex_filter_bytes_value,
9724 (void *)&cmd_flex_filter_mask,
9725 (void *)&cmd_flex_filter_mask_value,
9726 (void *)&cmd_flex_filter_priority,
9727 (void *)&cmd_flex_filter_priority_value,
9728 (void *)&cmd_flex_filter_queue,
9729 (void *)&cmd_flex_filter_queue_id,
9734 /* *** Filters Control *** */
9736 /* *** deal with ethertype filter *** */
9737 struct cmd_ethertype_filter_result {
9738 cmdline_fixed_string_t filter;
9740 cmdline_fixed_string_t ops;
9741 cmdline_fixed_string_t mac;
9742 struct ether_addr mac_addr;
9743 cmdline_fixed_string_t ethertype;
9744 uint16_t ethertype_value;
9745 cmdline_fixed_string_t drop;
9746 cmdline_fixed_string_t queue;
9750 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9751 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9752 filter, "ethertype_filter");
9753 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9754 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9756 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9757 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9759 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9760 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9761 mac, "mac_addr#mac_ignr");
9762 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9763 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9765 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9766 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9767 ethertype, "ethertype");
9768 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9769 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9770 ethertype_value, UINT16);
9771 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9772 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9774 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9775 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9777 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9778 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9782 cmd_ethertype_filter_parsed(void *parsed_result,
9783 __attribute__((unused)) struct cmdline *cl,
9784 __attribute__((unused)) void *data)
9786 struct cmd_ethertype_filter_result *res = parsed_result;
9787 struct rte_eth_ethertype_filter filter;
9790 ret = rte_eth_dev_filter_supported(res->port_id,
9791 RTE_ETH_FILTER_ETHERTYPE);
9793 printf("ethertype filter is not supported on port %u.\n",
9798 memset(&filter, 0, sizeof(filter));
9799 if (!strcmp(res->mac, "mac_addr")) {
9800 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9801 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9802 sizeof(struct ether_addr));
9804 if (!strcmp(res->drop, "drop"))
9805 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9806 filter.ether_type = res->ethertype_value;
9807 filter.queue = res->queue_id;
9809 if (!strcmp(res->ops, "add"))
9810 ret = rte_eth_dev_filter_ctrl(res->port_id,
9811 RTE_ETH_FILTER_ETHERTYPE,
9815 ret = rte_eth_dev_filter_ctrl(res->port_id,
9816 RTE_ETH_FILTER_ETHERTYPE,
9817 RTE_ETH_FILTER_DELETE,
9820 printf("ethertype filter programming error: (%s)\n",
9824 cmdline_parse_inst_t cmd_ethertype_filter = {
9825 .f = cmd_ethertype_filter_parsed,
9827 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9828 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9829 "Add or delete an ethertype filter entry",
9831 (void *)&cmd_ethertype_filter_filter,
9832 (void *)&cmd_ethertype_filter_port_id,
9833 (void *)&cmd_ethertype_filter_ops,
9834 (void *)&cmd_ethertype_filter_mac,
9835 (void *)&cmd_ethertype_filter_mac_addr,
9836 (void *)&cmd_ethertype_filter_ethertype,
9837 (void *)&cmd_ethertype_filter_ethertype_value,
9838 (void *)&cmd_ethertype_filter_drop,
9839 (void *)&cmd_ethertype_filter_queue,
9840 (void *)&cmd_ethertype_filter_queue_id,
9845 /* *** deal with flow director filter *** */
9846 struct cmd_flow_director_result {
9847 cmdline_fixed_string_t flow_director_filter;
9849 cmdline_fixed_string_t mode;
9850 cmdline_fixed_string_t mode_value;
9851 cmdline_fixed_string_t ops;
9852 cmdline_fixed_string_t flow;
9853 cmdline_fixed_string_t flow_type;
9854 cmdline_fixed_string_t ether;
9855 uint16_t ether_type;
9856 cmdline_fixed_string_t src;
9857 cmdline_ipaddr_t ip_src;
9859 cmdline_fixed_string_t dst;
9860 cmdline_ipaddr_t ip_dst;
9862 cmdline_fixed_string_t verify_tag;
9863 uint32_t verify_tag_value;
9864 cmdline_ipaddr_t tos;
9866 cmdline_ipaddr_t proto;
9867 uint8_t proto_value;
9868 cmdline_ipaddr_t ttl;
9870 cmdline_fixed_string_t vlan;
9871 uint16_t vlan_value;
9872 cmdline_fixed_string_t flexbytes;
9873 cmdline_fixed_string_t flexbytes_value;
9874 cmdline_fixed_string_t pf_vf;
9875 cmdline_fixed_string_t drop;
9876 cmdline_fixed_string_t queue;
9878 cmdline_fixed_string_t fd_id;
9879 uint32_t fd_id_value;
9880 cmdline_fixed_string_t mac;
9881 struct ether_addr mac_addr;
9882 cmdline_fixed_string_t tunnel;
9883 cmdline_fixed_string_t tunnel_type;
9884 cmdline_fixed_string_t tunnel_id;
9885 uint32_t tunnel_id_value;
9886 cmdline_fixed_string_t packet;
9891 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9894 const char *p, *p0 = q_arg;
9896 unsigned long int_fld;
9897 char *str_fld[max_num];
9902 p = strchr(p0, '(');
9906 p0 = strchr(p, ')');
9911 if (size >= sizeof(s))
9914 snprintf(s, sizeof(s), "%.*s", size, p);
9915 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9916 if (ret < 0 || ret > max_num)
9918 for (i = 0; i < ret; i++) {
9920 int_fld = strtoul(str_fld[i], &end, 0);
9921 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9923 flexbytes[i] = (uint8_t)int_fld;
9929 str2flowtype(char *string)
9932 static const struct {
9935 } flowtype_str[] = {
9936 {"raw", RTE_ETH_FLOW_RAW},
9937 {"ipv4", RTE_ETH_FLOW_IPV4},
9938 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9939 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9940 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9941 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9942 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9943 {"ipv6", RTE_ETH_FLOW_IPV6},
9944 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9945 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9946 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9947 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9948 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9949 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9952 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9953 if (!strcmp(flowtype_str[i].str, string))
9954 return flowtype_str[i].type;
9957 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9958 return (uint16_t)atoi(string);
9960 return RTE_ETH_FLOW_UNKNOWN;
9963 static enum rte_eth_fdir_tunnel_type
9964 str2fdir_tunneltype(char *string)
9968 static const struct {
9970 enum rte_eth_fdir_tunnel_type type;
9971 } tunneltype_str[] = {
9972 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9973 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9976 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9977 if (!strcmp(tunneltype_str[i].str, string))
9978 return tunneltype_str[i].type;
9980 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9983 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9985 if ((ip_addr).family == AF_INET) \
9986 (ip) = (ip_addr).addr.ipv4.s_addr; \
9988 printf("invalid parameter.\n"); \
9993 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9995 if ((ip_addr).family == AF_INET6) \
9997 &((ip_addr).addr.ipv6), \
9998 sizeof(struct in6_addr)); \
10000 printf("invalid parameter.\n"); \
10006 cmd_flow_director_filter_parsed(void *parsed_result,
10007 __attribute__((unused)) struct cmdline *cl,
10008 __attribute__((unused)) void *data)
10010 struct cmd_flow_director_result *res = parsed_result;
10011 struct rte_eth_fdir_filter entry;
10012 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10014 unsigned long vf_id;
10017 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10019 printf("flow director is not supported on port %u.\n",
10023 memset(flexbytes, 0, sizeof(flexbytes));
10024 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10026 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10027 if (strcmp(res->mode_value, "MAC-VLAN")) {
10028 printf("Please set mode to MAC-VLAN.\n");
10031 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10032 if (strcmp(res->mode_value, "Tunnel")) {
10033 printf("Please set mode to Tunnel.\n");
10037 if (!strcmp(res->mode_value, "raw")) {
10038 #ifdef RTE_LIBRTE_I40E_PMD
10039 struct rte_pmd_i40e_flow_type_mapping
10040 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10041 struct rte_pmd_i40e_pkt_template_conf conf;
10042 uint16_t flow_type = str2flowtype(res->flow_type);
10043 uint16_t i, port = res->port_id;
10046 memset(&conf, 0, sizeof(conf));
10048 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10049 printf("Invalid flow type specified.\n");
10052 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10056 if (mapping[flow_type].pctype == 0ULL) {
10057 printf("Invalid flow type specified.\n");
10060 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10061 if (mapping[flow_type].pctype & (1ULL << i)) {
10062 conf.input.pctype = i;
10067 conf.input.packet = open_file(res->filepath,
10068 &conf.input.length);
10069 if (!conf.input.packet)
10071 if (!strcmp(res->drop, "drop"))
10072 conf.action.behavior =
10073 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10075 conf.action.behavior =
10076 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10077 conf.action.report_status =
10078 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10079 conf.action.rx_queue = res->queue_id;
10080 conf.soft_id = res->fd_id_value;
10081 add = strcmp(res->ops, "del") ? 1 : 0;
10082 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10086 printf("flow director config error: (%s)\n",
10088 close_file(conf.input.packet);
10091 } else if (strcmp(res->mode_value, "IP")) {
10092 printf("Please set mode to IP or raw.\n");
10095 entry.input.flow_type = str2flowtype(res->flow_type);
10098 ret = parse_flexbytes(res->flexbytes_value,
10100 RTE_ETH_FDIR_MAX_FLEXLEN);
10102 printf("error: Cannot parse flexbytes input.\n");
10106 switch (entry.input.flow_type) {
10107 case RTE_ETH_FLOW_FRAG_IPV4:
10108 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10109 entry.input.flow.ip4_flow.proto = res->proto_value;
10111 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10112 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10113 IPV4_ADDR_TO_UINT(res->ip_dst,
10114 entry.input.flow.ip4_flow.dst_ip);
10115 IPV4_ADDR_TO_UINT(res->ip_src,
10116 entry.input.flow.ip4_flow.src_ip);
10117 entry.input.flow.ip4_flow.tos = res->tos_value;
10118 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10119 /* need convert to big endian. */
10120 entry.input.flow.udp4_flow.dst_port =
10121 rte_cpu_to_be_16(res->port_dst);
10122 entry.input.flow.udp4_flow.src_port =
10123 rte_cpu_to_be_16(res->port_src);
10125 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10126 IPV4_ADDR_TO_UINT(res->ip_dst,
10127 entry.input.flow.sctp4_flow.ip.dst_ip);
10128 IPV4_ADDR_TO_UINT(res->ip_src,
10129 entry.input.flow.sctp4_flow.ip.src_ip);
10130 entry.input.flow.ip4_flow.tos = res->tos_value;
10131 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10132 /* need convert to big endian. */
10133 entry.input.flow.sctp4_flow.dst_port =
10134 rte_cpu_to_be_16(res->port_dst);
10135 entry.input.flow.sctp4_flow.src_port =
10136 rte_cpu_to_be_16(res->port_src);
10137 entry.input.flow.sctp4_flow.verify_tag =
10138 rte_cpu_to_be_32(res->verify_tag_value);
10140 case RTE_ETH_FLOW_FRAG_IPV6:
10141 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10142 entry.input.flow.ipv6_flow.proto = res->proto_value;
10144 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10145 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10146 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10147 entry.input.flow.ipv6_flow.dst_ip);
10148 IPV6_ADDR_TO_ARRAY(res->ip_src,
10149 entry.input.flow.ipv6_flow.src_ip);
10150 entry.input.flow.ipv6_flow.tc = res->tos_value;
10151 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10152 /* need convert to big endian. */
10153 entry.input.flow.udp6_flow.dst_port =
10154 rte_cpu_to_be_16(res->port_dst);
10155 entry.input.flow.udp6_flow.src_port =
10156 rte_cpu_to_be_16(res->port_src);
10158 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10159 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10160 entry.input.flow.sctp6_flow.ip.dst_ip);
10161 IPV6_ADDR_TO_ARRAY(res->ip_src,
10162 entry.input.flow.sctp6_flow.ip.src_ip);
10163 entry.input.flow.ipv6_flow.tc = res->tos_value;
10164 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10165 /* need convert to big endian. */
10166 entry.input.flow.sctp6_flow.dst_port =
10167 rte_cpu_to_be_16(res->port_dst);
10168 entry.input.flow.sctp6_flow.src_port =
10169 rte_cpu_to_be_16(res->port_src);
10170 entry.input.flow.sctp6_flow.verify_tag =
10171 rte_cpu_to_be_32(res->verify_tag_value);
10173 case RTE_ETH_FLOW_L2_PAYLOAD:
10174 entry.input.flow.l2_flow.ether_type =
10175 rte_cpu_to_be_16(res->ether_type);
10181 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10182 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10184 sizeof(struct ether_addr));
10186 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10187 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10189 sizeof(struct ether_addr));
10190 entry.input.flow.tunnel_flow.tunnel_type =
10191 str2fdir_tunneltype(res->tunnel_type);
10192 entry.input.flow.tunnel_flow.tunnel_id =
10193 rte_cpu_to_be_32(res->tunnel_id_value);
10196 rte_memcpy(entry.input.flow_ext.flexbytes,
10198 RTE_ETH_FDIR_MAX_FLEXLEN);
10200 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10202 entry.action.flex_off = 0; /*use 0 by default */
10203 if (!strcmp(res->drop, "drop"))
10204 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10206 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10208 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10209 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10210 if (!strcmp(res->pf_vf, "pf"))
10211 entry.input.flow_ext.is_vf = 0;
10212 else if (!strncmp(res->pf_vf, "vf", 2)) {
10213 struct rte_eth_dev_info dev_info;
10215 memset(&dev_info, 0, sizeof(dev_info));
10216 rte_eth_dev_info_get(res->port_id, &dev_info);
10218 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10219 if (errno != 0 || *end != '\0' ||
10220 vf_id >= dev_info.max_vfs) {
10221 printf("invalid parameter %s.\n", res->pf_vf);
10224 entry.input.flow_ext.is_vf = 1;
10225 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10227 printf("invalid parameter %s.\n", res->pf_vf);
10232 /* set to report FD ID by default */
10233 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10234 entry.action.rx_queue = res->queue_id;
10235 entry.soft_id = res->fd_id_value;
10236 if (!strcmp(res->ops, "add"))
10237 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10238 RTE_ETH_FILTER_ADD, &entry);
10239 else if (!strcmp(res->ops, "del"))
10240 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10241 RTE_ETH_FILTER_DELETE, &entry);
10243 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10244 RTE_ETH_FILTER_UPDATE, &entry);
10246 printf("flow director programming error: (%s)\n",
10250 cmdline_parse_token_string_t cmd_flow_director_filter =
10251 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10252 flow_director_filter, "flow_director_filter");
10253 cmdline_parse_token_num_t cmd_flow_director_port_id =
10254 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10256 cmdline_parse_token_string_t cmd_flow_director_ops =
10257 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10258 ops, "add#del#update");
10259 cmdline_parse_token_string_t cmd_flow_director_flow =
10260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10262 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10263 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10265 cmdline_parse_token_string_t cmd_flow_director_ether =
10266 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10268 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10269 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10270 ether_type, UINT16);
10271 cmdline_parse_token_string_t cmd_flow_director_src =
10272 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10274 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10275 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10277 cmdline_parse_token_num_t cmd_flow_director_port_src =
10278 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10280 cmdline_parse_token_string_t cmd_flow_director_dst =
10281 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10283 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10284 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10286 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10287 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10289 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10290 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10291 verify_tag, "verify_tag");
10292 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10293 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10294 verify_tag_value, UINT32);
10295 cmdline_parse_token_string_t cmd_flow_director_tos =
10296 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10298 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10299 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10301 cmdline_parse_token_string_t cmd_flow_director_proto =
10302 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10304 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10305 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10306 proto_value, UINT8);
10307 cmdline_parse_token_string_t cmd_flow_director_ttl =
10308 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10310 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10311 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10313 cmdline_parse_token_string_t cmd_flow_director_vlan =
10314 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10316 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10317 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10318 vlan_value, UINT16);
10319 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10320 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10321 flexbytes, "flexbytes");
10322 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10323 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10324 flexbytes_value, NULL);
10325 cmdline_parse_token_string_t cmd_flow_director_drop =
10326 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10328 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10329 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10331 cmdline_parse_token_string_t cmd_flow_director_queue =
10332 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10334 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10335 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10337 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10338 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10340 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10341 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10342 fd_id_value, UINT32);
10344 cmdline_parse_token_string_t cmd_flow_director_mode =
10345 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10347 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10350 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10352 mode_value, "MAC-VLAN");
10353 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10354 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10355 mode_value, "Tunnel");
10356 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10357 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10358 mode_value, "raw");
10359 cmdline_parse_token_string_t cmd_flow_director_mac =
10360 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10362 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10363 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10365 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10366 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10368 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10369 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10370 tunnel_type, "NVGRE#VxLAN");
10371 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10372 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10373 tunnel_id, "tunnel-id");
10374 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10375 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10376 tunnel_id_value, UINT32);
10377 cmdline_parse_token_string_t cmd_flow_director_packet =
10378 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10380 cmdline_parse_token_string_t cmd_flow_director_filepath =
10381 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10384 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10385 .f = cmd_flow_director_filter_parsed,
10387 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10388 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10389 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10390 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10391 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10392 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10393 "fd_id <fd_id_value>: "
10394 "Add or delete an ip flow director entry on NIC",
10396 (void *)&cmd_flow_director_filter,
10397 (void *)&cmd_flow_director_port_id,
10398 (void *)&cmd_flow_director_mode,
10399 (void *)&cmd_flow_director_mode_ip,
10400 (void *)&cmd_flow_director_ops,
10401 (void *)&cmd_flow_director_flow,
10402 (void *)&cmd_flow_director_flow_type,
10403 (void *)&cmd_flow_director_src,
10404 (void *)&cmd_flow_director_ip_src,
10405 (void *)&cmd_flow_director_dst,
10406 (void *)&cmd_flow_director_ip_dst,
10407 (void *)&cmd_flow_director_tos,
10408 (void *)&cmd_flow_director_tos_value,
10409 (void *)&cmd_flow_director_proto,
10410 (void *)&cmd_flow_director_proto_value,
10411 (void *)&cmd_flow_director_ttl,
10412 (void *)&cmd_flow_director_ttl_value,
10413 (void *)&cmd_flow_director_vlan,
10414 (void *)&cmd_flow_director_vlan_value,
10415 (void *)&cmd_flow_director_flexbytes,
10416 (void *)&cmd_flow_director_flexbytes_value,
10417 (void *)&cmd_flow_director_drop,
10418 (void *)&cmd_flow_director_pf_vf,
10419 (void *)&cmd_flow_director_queue,
10420 (void *)&cmd_flow_director_queue_id,
10421 (void *)&cmd_flow_director_fd_id,
10422 (void *)&cmd_flow_director_fd_id_value,
10427 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10428 .f = cmd_flow_director_filter_parsed,
10430 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10431 "director entry on NIC",
10433 (void *)&cmd_flow_director_filter,
10434 (void *)&cmd_flow_director_port_id,
10435 (void *)&cmd_flow_director_mode,
10436 (void *)&cmd_flow_director_mode_ip,
10437 (void *)&cmd_flow_director_ops,
10438 (void *)&cmd_flow_director_flow,
10439 (void *)&cmd_flow_director_flow_type,
10440 (void *)&cmd_flow_director_src,
10441 (void *)&cmd_flow_director_ip_src,
10442 (void *)&cmd_flow_director_port_src,
10443 (void *)&cmd_flow_director_dst,
10444 (void *)&cmd_flow_director_ip_dst,
10445 (void *)&cmd_flow_director_port_dst,
10446 (void *)&cmd_flow_director_tos,
10447 (void *)&cmd_flow_director_tos_value,
10448 (void *)&cmd_flow_director_ttl,
10449 (void *)&cmd_flow_director_ttl_value,
10450 (void *)&cmd_flow_director_vlan,
10451 (void *)&cmd_flow_director_vlan_value,
10452 (void *)&cmd_flow_director_flexbytes,
10453 (void *)&cmd_flow_director_flexbytes_value,
10454 (void *)&cmd_flow_director_drop,
10455 (void *)&cmd_flow_director_pf_vf,
10456 (void *)&cmd_flow_director_queue,
10457 (void *)&cmd_flow_director_queue_id,
10458 (void *)&cmd_flow_director_fd_id,
10459 (void *)&cmd_flow_director_fd_id_value,
10464 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10465 .f = cmd_flow_director_filter_parsed,
10467 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10468 "director entry on NIC",
10470 (void *)&cmd_flow_director_filter,
10471 (void *)&cmd_flow_director_port_id,
10472 (void *)&cmd_flow_director_mode,
10473 (void *)&cmd_flow_director_mode_ip,
10474 (void *)&cmd_flow_director_ops,
10475 (void *)&cmd_flow_director_flow,
10476 (void *)&cmd_flow_director_flow_type,
10477 (void *)&cmd_flow_director_src,
10478 (void *)&cmd_flow_director_ip_src,
10479 (void *)&cmd_flow_director_port_dst,
10480 (void *)&cmd_flow_director_dst,
10481 (void *)&cmd_flow_director_ip_dst,
10482 (void *)&cmd_flow_director_port_dst,
10483 (void *)&cmd_flow_director_verify_tag,
10484 (void *)&cmd_flow_director_verify_tag_value,
10485 (void *)&cmd_flow_director_tos,
10486 (void *)&cmd_flow_director_tos_value,
10487 (void *)&cmd_flow_director_ttl,
10488 (void *)&cmd_flow_director_ttl_value,
10489 (void *)&cmd_flow_director_vlan,
10490 (void *)&cmd_flow_director_vlan_value,
10491 (void *)&cmd_flow_director_flexbytes,
10492 (void *)&cmd_flow_director_flexbytes_value,
10493 (void *)&cmd_flow_director_drop,
10494 (void *)&cmd_flow_director_pf_vf,
10495 (void *)&cmd_flow_director_queue,
10496 (void *)&cmd_flow_director_queue_id,
10497 (void *)&cmd_flow_director_fd_id,
10498 (void *)&cmd_flow_director_fd_id_value,
10503 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10504 .f = cmd_flow_director_filter_parsed,
10506 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10507 "director entry on NIC",
10509 (void *)&cmd_flow_director_filter,
10510 (void *)&cmd_flow_director_port_id,
10511 (void *)&cmd_flow_director_mode,
10512 (void *)&cmd_flow_director_mode_ip,
10513 (void *)&cmd_flow_director_ops,
10514 (void *)&cmd_flow_director_flow,
10515 (void *)&cmd_flow_director_flow_type,
10516 (void *)&cmd_flow_director_ether,
10517 (void *)&cmd_flow_director_ether_type,
10518 (void *)&cmd_flow_director_flexbytes,
10519 (void *)&cmd_flow_director_flexbytes_value,
10520 (void *)&cmd_flow_director_drop,
10521 (void *)&cmd_flow_director_pf_vf,
10522 (void *)&cmd_flow_director_queue,
10523 (void *)&cmd_flow_director_queue_id,
10524 (void *)&cmd_flow_director_fd_id,
10525 (void *)&cmd_flow_director_fd_id_value,
10530 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10531 .f = cmd_flow_director_filter_parsed,
10533 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10534 "director entry on NIC",
10536 (void *)&cmd_flow_director_filter,
10537 (void *)&cmd_flow_director_port_id,
10538 (void *)&cmd_flow_director_mode,
10539 (void *)&cmd_flow_director_mode_mac_vlan,
10540 (void *)&cmd_flow_director_ops,
10541 (void *)&cmd_flow_director_mac,
10542 (void *)&cmd_flow_director_mac_addr,
10543 (void *)&cmd_flow_director_vlan,
10544 (void *)&cmd_flow_director_vlan_value,
10545 (void *)&cmd_flow_director_flexbytes,
10546 (void *)&cmd_flow_director_flexbytes_value,
10547 (void *)&cmd_flow_director_drop,
10548 (void *)&cmd_flow_director_queue,
10549 (void *)&cmd_flow_director_queue_id,
10550 (void *)&cmd_flow_director_fd_id,
10551 (void *)&cmd_flow_director_fd_id_value,
10556 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10557 .f = cmd_flow_director_filter_parsed,
10559 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10560 "director entry on NIC",
10562 (void *)&cmd_flow_director_filter,
10563 (void *)&cmd_flow_director_port_id,
10564 (void *)&cmd_flow_director_mode,
10565 (void *)&cmd_flow_director_mode_tunnel,
10566 (void *)&cmd_flow_director_ops,
10567 (void *)&cmd_flow_director_mac,
10568 (void *)&cmd_flow_director_mac_addr,
10569 (void *)&cmd_flow_director_vlan,
10570 (void *)&cmd_flow_director_vlan_value,
10571 (void *)&cmd_flow_director_tunnel,
10572 (void *)&cmd_flow_director_tunnel_type,
10573 (void *)&cmd_flow_director_tunnel_id,
10574 (void *)&cmd_flow_director_tunnel_id_value,
10575 (void *)&cmd_flow_director_flexbytes,
10576 (void *)&cmd_flow_director_flexbytes_value,
10577 (void *)&cmd_flow_director_drop,
10578 (void *)&cmd_flow_director_queue,
10579 (void *)&cmd_flow_director_queue_id,
10580 (void *)&cmd_flow_director_fd_id,
10581 (void *)&cmd_flow_director_fd_id_value,
10586 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10587 .f = cmd_flow_director_filter_parsed,
10589 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10590 "director entry on NIC",
10592 (void *)&cmd_flow_director_filter,
10593 (void *)&cmd_flow_director_port_id,
10594 (void *)&cmd_flow_director_mode,
10595 (void *)&cmd_flow_director_mode_raw,
10596 (void *)&cmd_flow_director_ops,
10597 (void *)&cmd_flow_director_flow,
10598 (void *)&cmd_flow_director_flow_type,
10599 (void *)&cmd_flow_director_drop,
10600 (void *)&cmd_flow_director_queue,
10601 (void *)&cmd_flow_director_queue_id,
10602 (void *)&cmd_flow_director_fd_id,
10603 (void *)&cmd_flow_director_fd_id_value,
10604 (void *)&cmd_flow_director_packet,
10605 (void *)&cmd_flow_director_filepath,
10610 struct cmd_flush_flow_director_result {
10611 cmdline_fixed_string_t flush_flow_director;
10615 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10616 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10617 flush_flow_director, "flush_flow_director");
10618 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10619 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10623 cmd_flush_flow_director_parsed(void *parsed_result,
10624 __attribute__((unused)) struct cmdline *cl,
10625 __attribute__((unused)) void *data)
10627 struct cmd_flow_director_result *res = parsed_result;
10630 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10632 printf("flow director is not supported on port %u.\n",
10637 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10638 RTE_ETH_FILTER_FLUSH, NULL);
10640 printf("flow director table flushing error: (%s)\n",
10644 cmdline_parse_inst_t cmd_flush_flow_director = {
10645 .f = cmd_flush_flow_director_parsed,
10647 .help_str = "flush_flow_director <port_id>: "
10648 "Flush all flow director entries of a device on NIC",
10650 (void *)&cmd_flush_flow_director_flush,
10651 (void *)&cmd_flush_flow_director_port_id,
10656 /* *** deal with flow director mask *** */
10657 struct cmd_flow_director_mask_result {
10658 cmdline_fixed_string_t flow_director_mask;
10660 cmdline_fixed_string_t mode;
10661 cmdline_fixed_string_t mode_value;
10662 cmdline_fixed_string_t vlan;
10663 uint16_t vlan_mask;
10664 cmdline_fixed_string_t src_mask;
10665 cmdline_ipaddr_t ipv4_src;
10666 cmdline_ipaddr_t ipv6_src;
10668 cmdline_fixed_string_t dst_mask;
10669 cmdline_ipaddr_t ipv4_dst;
10670 cmdline_ipaddr_t ipv6_dst;
10672 cmdline_fixed_string_t mac;
10673 uint8_t mac_addr_byte_mask;
10674 cmdline_fixed_string_t tunnel_id;
10675 uint32_t tunnel_id_mask;
10676 cmdline_fixed_string_t tunnel_type;
10677 uint8_t tunnel_type_mask;
10681 cmd_flow_director_mask_parsed(void *parsed_result,
10682 __attribute__((unused)) struct cmdline *cl,
10683 __attribute__((unused)) void *data)
10685 struct cmd_flow_director_mask_result *res = parsed_result;
10686 struct rte_eth_fdir_masks *mask;
10687 struct rte_port *port;
10689 if (res->port_id > nb_ports) {
10690 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10694 port = &ports[res->port_id];
10695 /** Check if the port is not started **/
10696 if (port->port_status != RTE_PORT_STOPPED) {
10697 printf("Please stop port %d first\n", res->port_id);
10701 mask = &port->dev_conf.fdir_conf.mask;
10703 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10704 if (strcmp(res->mode_value, "MAC-VLAN")) {
10705 printf("Please set mode to MAC-VLAN.\n");
10709 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10710 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10711 if (strcmp(res->mode_value, "Tunnel")) {
10712 printf("Please set mode to Tunnel.\n");
10716 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10717 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10718 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10719 mask->tunnel_type_mask = res->tunnel_type_mask;
10721 if (strcmp(res->mode_value, "IP")) {
10722 printf("Please set mode to IP.\n");
10726 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10727 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10728 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10729 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10730 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10731 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10732 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10735 cmd_reconfig_device_queue(res->port_id, 1, 1);
10738 cmdline_parse_token_string_t cmd_flow_director_mask =
10739 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10740 flow_director_mask, "flow_director_mask");
10741 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10742 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10744 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10745 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10747 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10748 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10749 vlan_mask, UINT16);
10750 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10751 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10752 src_mask, "src_mask");
10753 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10754 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10756 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10757 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10759 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10760 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10762 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10763 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10764 dst_mask, "dst_mask");
10765 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10766 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10768 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10769 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10771 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10772 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10775 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10776 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10778 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10779 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10781 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10782 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10783 mode_value, "MAC-VLAN");
10784 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10785 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10786 mode_value, "Tunnel");
10787 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10788 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10790 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10791 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10792 mac_addr_byte_mask, UINT8);
10793 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10794 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10795 tunnel_type, "tunnel-type");
10796 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10797 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10798 tunnel_type_mask, UINT8);
10799 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10800 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10801 tunnel_id, "tunnel-id");
10802 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10803 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10804 tunnel_id_mask, UINT32);
10806 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10807 .f = cmd_flow_director_mask_parsed,
10809 .help_str = "flow_director_mask ... : "
10810 "Set IP mode flow director's mask on NIC",
10812 (void *)&cmd_flow_director_mask,
10813 (void *)&cmd_flow_director_mask_port_id,
10814 (void *)&cmd_flow_director_mask_mode,
10815 (void *)&cmd_flow_director_mask_mode_ip,
10816 (void *)&cmd_flow_director_mask_vlan,
10817 (void *)&cmd_flow_director_mask_vlan_value,
10818 (void *)&cmd_flow_director_mask_src,
10819 (void *)&cmd_flow_director_mask_ipv4_src,
10820 (void *)&cmd_flow_director_mask_ipv6_src,
10821 (void *)&cmd_flow_director_mask_port_src,
10822 (void *)&cmd_flow_director_mask_dst,
10823 (void *)&cmd_flow_director_mask_ipv4_dst,
10824 (void *)&cmd_flow_director_mask_ipv6_dst,
10825 (void *)&cmd_flow_director_mask_port_dst,
10830 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10831 .f = cmd_flow_director_mask_parsed,
10833 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10834 "flow director's mask on NIC",
10836 (void *)&cmd_flow_director_mask,
10837 (void *)&cmd_flow_director_mask_port_id,
10838 (void *)&cmd_flow_director_mask_mode,
10839 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10840 (void *)&cmd_flow_director_mask_vlan,
10841 (void *)&cmd_flow_director_mask_vlan_value,
10846 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10847 .f = cmd_flow_director_mask_parsed,
10849 .help_str = "flow_director_mask ... : Set tunnel mode "
10850 "flow director's mask on NIC",
10852 (void *)&cmd_flow_director_mask,
10853 (void *)&cmd_flow_director_mask_port_id,
10854 (void *)&cmd_flow_director_mask_mode,
10855 (void *)&cmd_flow_director_mask_mode_tunnel,
10856 (void *)&cmd_flow_director_mask_vlan,
10857 (void *)&cmd_flow_director_mask_vlan_value,
10858 (void *)&cmd_flow_director_mask_mac,
10859 (void *)&cmd_flow_director_mask_mac_value,
10860 (void *)&cmd_flow_director_mask_tunnel_type,
10861 (void *)&cmd_flow_director_mask_tunnel_type_value,
10862 (void *)&cmd_flow_director_mask_tunnel_id,
10863 (void *)&cmd_flow_director_mask_tunnel_id_value,
10868 /* *** deal with flow director mask on flexible payload *** */
10869 struct cmd_flow_director_flex_mask_result {
10870 cmdline_fixed_string_t flow_director_flexmask;
10872 cmdline_fixed_string_t flow;
10873 cmdline_fixed_string_t flow_type;
10874 cmdline_fixed_string_t mask;
10878 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10879 __attribute__((unused)) struct cmdline *cl,
10880 __attribute__((unused)) void *data)
10882 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10883 struct rte_eth_fdir_info fdir_info;
10884 struct rte_eth_fdir_flex_mask flex_mask;
10885 struct rte_port *port;
10886 uint32_t flow_type_mask;
10890 if (res->port_id > nb_ports) {
10891 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10895 port = &ports[res->port_id];
10896 /** Check if the port is not started **/
10897 if (port->port_status != RTE_PORT_STOPPED) {
10898 printf("Please stop port %d first\n", res->port_id);
10902 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10903 ret = parse_flexbytes(res->mask,
10905 RTE_ETH_FDIR_MAX_FLEXLEN);
10907 printf("error: Cannot parse mask input.\n");
10911 memset(&fdir_info, 0, sizeof(fdir_info));
10912 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10913 RTE_ETH_FILTER_INFO, &fdir_info);
10915 printf("Cannot get FDir filter info\n");
10919 if (!strcmp(res->flow_type, "none")) {
10920 /* means don't specify the flow type */
10921 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10922 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10923 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10924 0, sizeof(struct rte_eth_fdir_flex_mask));
10925 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10926 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10928 sizeof(struct rte_eth_fdir_flex_mask));
10929 cmd_reconfig_device_queue(res->port_id, 1, 1);
10932 flow_type_mask = fdir_info.flow_types_mask[0];
10933 if (!strcmp(res->flow_type, "all")) {
10934 if (!flow_type_mask) {
10935 printf("No flow type supported\n");
10938 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10939 if (flow_type_mask & (1 << i)) {
10940 flex_mask.flow_type = i;
10941 fdir_set_flex_mask(res->port_id, &flex_mask);
10944 cmd_reconfig_device_queue(res->port_id, 1, 1);
10947 flex_mask.flow_type = str2flowtype(res->flow_type);
10948 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10949 printf("Flow type %s not supported on port %d\n",
10950 res->flow_type, res->port_id);
10953 fdir_set_flex_mask(res->port_id, &flex_mask);
10954 cmd_reconfig_device_queue(res->port_id, 1, 1);
10957 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10958 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10959 flow_director_flexmask,
10960 "flow_director_flex_mask");
10961 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10962 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10964 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10967 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10968 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10969 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10970 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10971 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10972 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10975 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10976 .f = cmd_flow_director_flex_mask_parsed,
10978 .help_str = "flow_director_flex_mask ... : "
10979 "Set flow director's flex mask on NIC",
10981 (void *)&cmd_flow_director_flexmask,
10982 (void *)&cmd_flow_director_flexmask_port_id,
10983 (void *)&cmd_flow_director_flexmask_flow,
10984 (void *)&cmd_flow_director_flexmask_flow_type,
10985 (void *)&cmd_flow_director_flexmask_mask,
10990 /* *** deal with flow director flexible payload configuration *** */
10991 struct cmd_flow_director_flexpayload_result {
10992 cmdline_fixed_string_t flow_director_flexpayload;
10994 cmdline_fixed_string_t payload_layer;
10995 cmdline_fixed_string_t payload_cfg;
10999 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11002 const char *p, *p0 = q_arg;
11004 unsigned long int_fld;
11005 char *str_fld[max_num];
11010 p = strchr(p0, '(');
11014 p0 = strchr(p, ')');
11019 if (size >= sizeof(s))
11022 snprintf(s, sizeof(s), "%.*s", size, p);
11023 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11024 if (ret < 0 || ret > max_num)
11026 for (i = 0; i < ret; i++) {
11028 int_fld = strtoul(str_fld[i], &end, 0);
11029 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11031 offsets[i] = (uint16_t)int_fld;
11037 cmd_flow_director_flxpld_parsed(void *parsed_result,
11038 __attribute__((unused)) struct cmdline *cl,
11039 __attribute__((unused)) void *data)
11041 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11042 struct rte_eth_flex_payload_cfg flex_cfg;
11043 struct rte_port *port;
11046 if (res->port_id > nb_ports) {
11047 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
11051 port = &ports[res->port_id];
11052 /** Check if the port is not started **/
11053 if (port->port_status != RTE_PORT_STOPPED) {
11054 printf("Please stop port %d first\n", res->port_id);
11058 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11060 if (!strcmp(res->payload_layer, "raw"))
11061 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11062 else if (!strcmp(res->payload_layer, "l2"))
11063 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11064 else if (!strcmp(res->payload_layer, "l3"))
11065 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11066 else if (!strcmp(res->payload_layer, "l4"))
11067 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11069 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11070 RTE_ETH_FDIR_MAX_FLEXLEN);
11072 printf("error: Cannot parse flex payload input.\n");
11076 fdir_set_flex_payload(res->port_id, &flex_cfg);
11077 cmd_reconfig_device_queue(res->port_id, 1, 1);
11080 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11081 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11082 flow_director_flexpayload,
11083 "flow_director_flex_payload");
11084 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11085 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11087 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11088 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11089 payload_layer, "raw#l2#l3#l4");
11090 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11091 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11092 payload_cfg, NULL);
11094 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11095 .f = cmd_flow_director_flxpld_parsed,
11097 .help_str = "flow_director_flexpayload ... : "
11098 "Set flow director's flex payload on NIC",
11100 (void *)&cmd_flow_director_flexpayload,
11101 (void *)&cmd_flow_director_flexpayload_port_id,
11102 (void *)&cmd_flow_director_flexpayload_payload_layer,
11103 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11108 /* Generic flow interface command. */
11109 extern cmdline_parse_inst_t cmd_flow;
11111 /* *** Classification Filters Control *** */
11112 /* *** Get symmetric hash enable per port *** */
11113 struct cmd_get_sym_hash_ena_per_port_result {
11114 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11119 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11120 __rte_unused struct cmdline *cl,
11121 __rte_unused void *data)
11123 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11124 struct rte_eth_hash_filter_info info;
11127 if (rte_eth_dev_filter_supported(res->port_id,
11128 RTE_ETH_FILTER_HASH) < 0) {
11129 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11134 memset(&info, 0, sizeof(info));
11135 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11136 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11137 RTE_ETH_FILTER_GET, &info);
11140 printf("Cannot get symmetric hash enable per port "
11141 "on port %u\n", res->port_id);
11145 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11146 "enabled" : "disabled", res->port_id);
11149 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11150 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11151 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11152 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11153 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11156 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11157 .f = cmd_get_sym_hash_per_port_parsed,
11159 .help_str = "get_sym_hash_ena_per_port <port_id>",
11161 (void *)&cmd_get_sym_hash_ena_per_port_all,
11162 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11167 /* *** Set symmetric hash enable per port *** */
11168 struct cmd_set_sym_hash_ena_per_port_result {
11169 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11170 cmdline_fixed_string_t enable;
11175 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11176 __rte_unused struct cmdline *cl,
11177 __rte_unused void *data)
11179 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11180 struct rte_eth_hash_filter_info info;
11183 if (rte_eth_dev_filter_supported(res->port_id,
11184 RTE_ETH_FILTER_HASH) < 0) {
11185 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11190 memset(&info, 0, sizeof(info));
11191 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11192 if (!strcmp(res->enable, "enable"))
11193 info.info.enable = 1;
11194 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11195 RTE_ETH_FILTER_SET, &info);
11197 printf("Cannot set symmetric hash enable per port on "
11198 "port %u\n", res->port_id);
11201 printf("Symmetric hash has been set to %s on port %u\n",
11202 res->enable, res->port_id);
11205 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11206 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11207 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11208 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11209 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11211 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11212 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11213 enable, "enable#disable");
11215 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11216 .f = cmd_set_sym_hash_per_port_parsed,
11218 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11220 (void *)&cmd_set_sym_hash_ena_per_port_all,
11221 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11222 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11227 /* Get global config of hash function */
11228 struct cmd_get_hash_global_config_result {
11229 cmdline_fixed_string_t get_hash_global_config;
11234 flowtype_to_str(uint16_t ftype)
11240 } ftype_table[] = {
11241 {"ipv4", RTE_ETH_FLOW_IPV4},
11242 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11243 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11244 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11245 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11246 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11247 {"ipv6", RTE_ETH_FLOW_IPV6},
11248 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11249 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11250 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11251 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11252 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11253 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11254 {"port", RTE_ETH_FLOW_PORT},
11255 {"vxlan", RTE_ETH_FLOW_VXLAN},
11256 {"geneve", RTE_ETH_FLOW_GENEVE},
11257 {"nvgre", RTE_ETH_FLOW_NVGRE},
11260 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11261 if (ftype_table[i].ftype == ftype)
11262 return ftype_table[i].str;
11269 cmd_get_hash_global_config_parsed(void *parsed_result,
11270 __rte_unused struct cmdline *cl,
11271 __rte_unused void *data)
11273 struct cmd_get_hash_global_config_result *res = parsed_result;
11274 struct rte_eth_hash_filter_info info;
11275 uint32_t idx, offset;
11280 if (rte_eth_dev_filter_supported(res->port_id,
11281 RTE_ETH_FILTER_HASH) < 0) {
11282 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11287 memset(&info, 0, sizeof(info));
11288 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11289 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11290 RTE_ETH_FILTER_GET, &info);
11292 printf("Cannot get hash global configurations by port %d\n",
11297 switch (info.info.global_conf.hash_func) {
11298 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11299 printf("Hash function is Toeplitz\n");
11301 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11302 printf("Hash function is Simple XOR\n");
11305 printf("Unknown hash function\n");
11309 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11310 idx = i / UINT32_BIT;
11311 offset = i % UINT32_BIT;
11312 if (!(info.info.global_conf.valid_bit_mask[idx] &
11315 str = flowtype_to_str(i);
11318 printf("Symmetric hash is %s globally for flow type %s "
11320 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11321 (1UL << offset)) ? "enabled" : "disabled"), str,
11326 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11327 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11328 get_hash_global_config, "get_hash_global_config");
11329 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11330 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11333 cmdline_parse_inst_t cmd_get_hash_global_config = {
11334 .f = cmd_get_hash_global_config_parsed,
11336 .help_str = "get_hash_global_config <port_id>",
11338 (void *)&cmd_get_hash_global_config_all,
11339 (void *)&cmd_get_hash_global_config_port_id,
11344 /* Set global config of hash function */
11345 struct cmd_set_hash_global_config_result {
11346 cmdline_fixed_string_t set_hash_global_config;
11348 cmdline_fixed_string_t hash_func;
11349 cmdline_fixed_string_t flow_type;
11350 cmdline_fixed_string_t enable;
11354 cmd_set_hash_global_config_parsed(void *parsed_result,
11355 __rte_unused struct cmdline *cl,
11356 __rte_unused void *data)
11358 struct cmd_set_hash_global_config_result *res = parsed_result;
11359 struct rte_eth_hash_filter_info info;
11360 uint32_t ftype, idx, offset;
11363 if (rte_eth_dev_filter_supported(res->port_id,
11364 RTE_ETH_FILTER_HASH) < 0) {
11365 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11369 memset(&info, 0, sizeof(info));
11370 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11371 if (!strcmp(res->hash_func, "toeplitz"))
11372 info.info.global_conf.hash_func =
11373 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11374 else if (!strcmp(res->hash_func, "simple_xor"))
11375 info.info.global_conf.hash_func =
11376 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11377 else if (!strcmp(res->hash_func, "default"))
11378 info.info.global_conf.hash_func =
11379 RTE_ETH_HASH_FUNCTION_DEFAULT;
11381 ftype = str2flowtype(res->flow_type);
11382 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11383 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11384 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11385 if (!strcmp(res->enable, "enable"))
11386 info.info.global_conf.sym_hash_enable_mask[idx] |=
11388 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11389 RTE_ETH_FILTER_SET, &info);
11391 printf("Cannot set global hash configurations by port %d\n",
11394 printf("Global hash configurations have been set "
11395 "succcessfully by port %d\n", res->port_id);
11398 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11399 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11400 set_hash_global_config, "set_hash_global_config");
11401 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11402 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11404 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11405 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11406 hash_func, "toeplitz#simple_xor#default");
11407 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11408 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11410 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11411 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11412 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11413 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11414 enable, "enable#disable");
11416 cmdline_parse_inst_t cmd_set_hash_global_config = {
11417 .f = cmd_set_hash_global_config_parsed,
11419 .help_str = "set_hash_global_config <port_id> "
11420 "toeplitz|simple_xor|default "
11421 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11422 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11423 "l2_payload enable|disable",
11425 (void *)&cmd_set_hash_global_config_all,
11426 (void *)&cmd_set_hash_global_config_port_id,
11427 (void *)&cmd_set_hash_global_config_hash_func,
11428 (void *)&cmd_set_hash_global_config_flow_type,
11429 (void *)&cmd_set_hash_global_config_enable,
11434 /* Set hash input set */
11435 struct cmd_set_hash_input_set_result {
11436 cmdline_fixed_string_t set_hash_input_set;
11438 cmdline_fixed_string_t flow_type;
11439 cmdline_fixed_string_t inset_field;
11440 cmdline_fixed_string_t select;
11443 static enum rte_eth_input_set_field
11444 str2inset(char *string)
11448 static const struct {
11450 enum rte_eth_input_set_field inset;
11451 } inset_table[] = {
11452 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11453 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11454 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11455 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11456 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11457 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11458 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11459 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11460 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11461 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11462 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11463 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11464 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11465 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11466 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11467 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11468 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11469 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11470 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11471 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11472 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11473 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11474 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11475 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11476 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11477 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11478 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11479 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11480 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11481 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11482 {"none", RTE_ETH_INPUT_SET_NONE},
11485 for (i = 0; i < RTE_DIM(inset_table); i++) {
11486 if (!strcmp(string, inset_table[i].str))
11487 return inset_table[i].inset;
11490 return RTE_ETH_INPUT_SET_UNKNOWN;
11494 cmd_set_hash_input_set_parsed(void *parsed_result,
11495 __rte_unused struct cmdline *cl,
11496 __rte_unused void *data)
11498 struct cmd_set_hash_input_set_result *res = parsed_result;
11499 struct rte_eth_hash_filter_info info;
11501 memset(&info, 0, sizeof(info));
11502 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11503 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11504 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11505 info.info.input_set_conf.inset_size = 1;
11506 if (!strcmp(res->select, "select"))
11507 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11508 else if (!strcmp(res->select, "add"))
11509 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11510 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11511 RTE_ETH_FILTER_SET, &info);
11514 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11515 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11516 set_hash_input_set, "set_hash_input_set");
11517 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11518 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11520 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11521 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11523 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11524 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11526 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11527 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11528 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11529 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11530 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11532 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11533 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11534 select, "select#add");
11536 cmdline_parse_inst_t cmd_set_hash_input_set = {
11537 .f = cmd_set_hash_input_set_parsed,
11539 .help_str = "set_hash_input_set <port_id> "
11540 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11541 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11542 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11543 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11544 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11545 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11546 "fld-7th|fld-8th|none select|add",
11548 (void *)&cmd_set_hash_input_set_cmd,
11549 (void *)&cmd_set_hash_input_set_port_id,
11550 (void *)&cmd_set_hash_input_set_flow_type,
11551 (void *)&cmd_set_hash_input_set_field,
11552 (void *)&cmd_set_hash_input_set_select,
11557 /* Set flow director input set */
11558 struct cmd_set_fdir_input_set_result {
11559 cmdline_fixed_string_t set_fdir_input_set;
11561 cmdline_fixed_string_t flow_type;
11562 cmdline_fixed_string_t inset_field;
11563 cmdline_fixed_string_t select;
11567 cmd_set_fdir_input_set_parsed(void *parsed_result,
11568 __rte_unused struct cmdline *cl,
11569 __rte_unused void *data)
11571 struct cmd_set_fdir_input_set_result *res = parsed_result;
11572 struct rte_eth_fdir_filter_info info;
11574 memset(&info, 0, sizeof(info));
11575 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11576 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11577 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11578 info.info.input_set_conf.inset_size = 1;
11579 if (!strcmp(res->select, "select"))
11580 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11581 else if (!strcmp(res->select, "add"))
11582 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11583 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11584 RTE_ETH_FILTER_SET, &info);
11587 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11588 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11589 set_fdir_input_set, "set_fdir_input_set");
11590 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11591 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11593 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11594 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11596 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11597 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11598 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11599 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11601 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11602 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11603 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11604 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11605 "sctp-veri-tag#none");
11606 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11607 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11608 select, "select#add");
11610 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11611 .f = cmd_set_fdir_input_set_parsed,
11613 .help_str = "set_fdir_input_set <port_id> "
11614 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11615 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11616 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11617 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11618 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11619 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11620 "sctp-veri-tag|none select|add",
11622 (void *)&cmd_set_fdir_input_set_cmd,
11623 (void *)&cmd_set_fdir_input_set_port_id,
11624 (void *)&cmd_set_fdir_input_set_flow_type,
11625 (void *)&cmd_set_fdir_input_set_field,
11626 (void *)&cmd_set_fdir_input_set_select,
11631 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11632 struct cmd_mcast_addr_result {
11633 cmdline_fixed_string_t mcast_addr_cmd;
11634 cmdline_fixed_string_t what;
11636 struct ether_addr mc_addr;
11639 static void cmd_mcast_addr_parsed(void *parsed_result,
11640 __attribute__((unused)) struct cmdline *cl,
11641 __attribute__((unused)) void *data)
11643 struct cmd_mcast_addr_result *res = parsed_result;
11645 if (!is_multicast_ether_addr(&res->mc_addr)) {
11646 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11647 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11648 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11649 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11652 if (strcmp(res->what, "add") == 0)
11653 mcast_addr_add(res->port_num, &res->mc_addr);
11655 mcast_addr_remove(res->port_num, &res->mc_addr);
11658 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11659 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11660 mcast_addr_cmd, "mcast_addr");
11661 cmdline_parse_token_string_t cmd_mcast_addr_what =
11662 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11664 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11665 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11666 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11667 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11669 cmdline_parse_inst_t cmd_mcast_addr = {
11670 .f = cmd_mcast_addr_parsed,
11672 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11673 "Add/Remove multicast MAC address on port_id",
11675 (void *)&cmd_mcast_addr_cmd,
11676 (void *)&cmd_mcast_addr_what,
11677 (void *)&cmd_mcast_addr_portnum,
11678 (void *)&cmd_mcast_addr_addr,
11683 /* l2 tunnel config
11684 * only support E-tag now.
11687 /* Ether type config */
11688 struct cmd_config_l2_tunnel_eth_type_result {
11689 cmdline_fixed_string_t port;
11690 cmdline_fixed_string_t config;
11691 cmdline_fixed_string_t all;
11693 cmdline_fixed_string_t l2_tunnel;
11694 cmdline_fixed_string_t l2_tunnel_type;
11695 cmdline_fixed_string_t eth_type;
11696 uint16_t eth_type_val;
11699 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11700 TOKEN_STRING_INITIALIZER
11701 (struct cmd_config_l2_tunnel_eth_type_result,
11703 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11704 TOKEN_STRING_INITIALIZER
11705 (struct cmd_config_l2_tunnel_eth_type_result,
11707 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11708 TOKEN_STRING_INITIALIZER
11709 (struct cmd_config_l2_tunnel_eth_type_result,
11711 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11712 TOKEN_NUM_INITIALIZER
11713 (struct cmd_config_l2_tunnel_eth_type_result,
11715 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11716 TOKEN_STRING_INITIALIZER
11717 (struct cmd_config_l2_tunnel_eth_type_result,
11718 l2_tunnel, "l2-tunnel");
11719 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11720 TOKEN_STRING_INITIALIZER
11721 (struct cmd_config_l2_tunnel_eth_type_result,
11722 l2_tunnel_type, "E-tag");
11723 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11724 TOKEN_STRING_INITIALIZER
11725 (struct cmd_config_l2_tunnel_eth_type_result,
11726 eth_type, "ether-type");
11727 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11728 TOKEN_NUM_INITIALIZER
11729 (struct cmd_config_l2_tunnel_eth_type_result,
11730 eth_type_val, UINT16);
11732 static enum rte_eth_tunnel_type
11733 str2fdir_l2_tunnel_type(char *string)
11737 static const struct {
11739 enum rte_eth_tunnel_type type;
11740 } l2_tunnel_type_str[] = {
11741 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11744 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11745 if (!strcmp(l2_tunnel_type_str[i].str, string))
11746 return l2_tunnel_type_str[i].type;
11748 return RTE_TUNNEL_TYPE_NONE;
11751 /* ether type config for all ports */
11753 cmd_config_l2_tunnel_eth_type_all_parsed
11754 (void *parsed_result,
11755 __attribute__((unused)) struct cmdline *cl,
11756 __attribute__((unused)) void *data)
11758 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11759 struct rte_eth_l2_tunnel_conf entry;
11762 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11763 entry.ether_type = res->eth_type_val;
11765 RTE_ETH_FOREACH_DEV(pid) {
11766 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11770 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11771 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11773 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11775 (void *)&cmd_config_l2_tunnel_eth_type_port,
11776 (void *)&cmd_config_l2_tunnel_eth_type_config,
11777 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11778 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11779 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11780 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11781 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11786 /* ether type config for a specific port */
11788 cmd_config_l2_tunnel_eth_type_specific_parsed(
11789 void *parsed_result,
11790 __attribute__((unused)) struct cmdline *cl,
11791 __attribute__((unused)) void *data)
11793 struct cmd_config_l2_tunnel_eth_type_result *res =
11795 struct rte_eth_l2_tunnel_conf entry;
11797 if (port_id_is_invalid(res->id, ENABLED_WARN))
11800 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11801 entry.ether_type = res->eth_type_val;
11803 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11806 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11807 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11809 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11811 (void *)&cmd_config_l2_tunnel_eth_type_port,
11812 (void *)&cmd_config_l2_tunnel_eth_type_config,
11813 (void *)&cmd_config_l2_tunnel_eth_type_id,
11814 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11815 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11816 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11817 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11822 /* Enable/disable l2 tunnel */
11823 struct cmd_config_l2_tunnel_en_dis_result {
11824 cmdline_fixed_string_t port;
11825 cmdline_fixed_string_t config;
11826 cmdline_fixed_string_t all;
11828 cmdline_fixed_string_t l2_tunnel;
11829 cmdline_fixed_string_t l2_tunnel_type;
11830 cmdline_fixed_string_t en_dis;
11833 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11834 TOKEN_STRING_INITIALIZER
11835 (struct cmd_config_l2_tunnel_en_dis_result,
11837 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11838 TOKEN_STRING_INITIALIZER
11839 (struct cmd_config_l2_tunnel_en_dis_result,
11841 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11842 TOKEN_STRING_INITIALIZER
11843 (struct cmd_config_l2_tunnel_en_dis_result,
11845 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11846 TOKEN_NUM_INITIALIZER
11847 (struct cmd_config_l2_tunnel_en_dis_result,
11849 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11850 TOKEN_STRING_INITIALIZER
11851 (struct cmd_config_l2_tunnel_en_dis_result,
11852 l2_tunnel, "l2-tunnel");
11853 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11854 TOKEN_STRING_INITIALIZER
11855 (struct cmd_config_l2_tunnel_en_dis_result,
11856 l2_tunnel_type, "E-tag");
11857 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11858 TOKEN_STRING_INITIALIZER
11859 (struct cmd_config_l2_tunnel_en_dis_result,
11860 en_dis, "enable#disable");
11862 /* enable/disable l2 tunnel for all ports */
11864 cmd_config_l2_tunnel_en_dis_all_parsed(
11865 void *parsed_result,
11866 __attribute__((unused)) struct cmdline *cl,
11867 __attribute__((unused)) void *data)
11869 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11870 struct rte_eth_l2_tunnel_conf entry;
11874 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11876 if (!strcmp("enable", res->en_dis))
11881 RTE_ETH_FOREACH_DEV(pid) {
11882 rte_eth_dev_l2_tunnel_offload_set(pid,
11884 ETH_L2_TUNNEL_ENABLE_MASK,
11889 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11890 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11892 .help_str = "port config all l2-tunnel E-tag enable|disable",
11894 (void *)&cmd_config_l2_tunnel_en_dis_port,
11895 (void *)&cmd_config_l2_tunnel_en_dis_config,
11896 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11897 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11898 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11899 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11904 /* enable/disable l2 tunnel for a port */
11906 cmd_config_l2_tunnel_en_dis_specific_parsed(
11907 void *parsed_result,
11908 __attribute__((unused)) struct cmdline *cl,
11909 __attribute__((unused)) void *data)
11911 struct cmd_config_l2_tunnel_en_dis_result *res =
11913 struct rte_eth_l2_tunnel_conf entry;
11915 if (port_id_is_invalid(res->id, ENABLED_WARN))
11918 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11920 if (!strcmp("enable", res->en_dis))
11921 rte_eth_dev_l2_tunnel_offload_set(res->id,
11923 ETH_L2_TUNNEL_ENABLE_MASK,
11926 rte_eth_dev_l2_tunnel_offload_set(res->id,
11928 ETH_L2_TUNNEL_ENABLE_MASK,
11932 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11933 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11935 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11937 (void *)&cmd_config_l2_tunnel_en_dis_port,
11938 (void *)&cmd_config_l2_tunnel_en_dis_config,
11939 (void *)&cmd_config_l2_tunnel_en_dis_id,
11940 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11941 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11942 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11947 /* E-tag configuration */
11949 /* Common result structure for all E-tag configuration */
11950 struct cmd_config_e_tag_result {
11951 cmdline_fixed_string_t e_tag;
11952 cmdline_fixed_string_t set;
11953 cmdline_fixed_string_t insertion;
11954 cmdline_fixed_string_t stripping;
11955 cmdline_fixed_string_t forwarding;
11956 cmdline_fixed_string_t filter;
11957 cmdline_fixed_string_t add;
11958 cmdline_fixed_string_t del;
11959 cmdline_fixed_string_t on;
11960 cmdline_fixed_string_t off;
11961 cmdline_fixed_string_t on_off;
11962 cmdline_fixed_string_t port_tag_id;
11963 uint32_t port_tag_id_val;
11964 cmdline_fixed_string_t e_tag_id;
11965 uint16_t e_tag_id_val;
11966 cmdline_fixed_string_t dst_pool;
11967 uint8_t dst_pool_val;
11968 cmdline_fixed_string_t port;
11970 cmdline_fixed_string_t vf;
11974 /* Common CLI fields for all E-tag configuration */
11975 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11976 TOKEN_STRING_INITIALIZER
11977 (struct cmd_config_e_tag_result,
11979 cmdline_parse_token_string_t cmd_config_e_tag_set =
11980 TOKEN_STRING_INITIALIZER
11981 (struct cmd_config_e_tag_result,
11983 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11984 TOKEN_STRING_INITIALIZER
11985 (struct cmd_config_e_tag_result,
11986 insertion, "insertion");
11987 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11988 TOKEN_STRING_INITIALIZER
11989 (struct cmd_config_e_tag_result,
11990 stripping, "stripping");
11991 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11992 TOKEN_STRING_INITIALIZER
11993 (struct cmd_config_e_tag_result,
11994 forwarding, "forwarding");
11995 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11996 TOKEN_STRING_INITIALIZER
11997 (struct cmd_config_e_tag_result,
11999 cmdline_parse_token_string_t cmd_config_e_tag_add =
12000 TOKEN_STRING_INITIALIZER
12001 (struct cmd_config_e_tag_result,
12003 cmdline_parse_token_string_t cmd_config_e_tag_del =
12004 TOKEN_STRING_INITIALIZER
12005 (struct cmd_config_e_tag_result,
12007 cmdline_parse_token_string_t cmd_config_e_tag_on =
12008 TOKEN_STRING_INITIALIZER
12009 (struct cmd_config_e_tag_result,
12011 cmdline_parse_token_string_t cmd_config_e_tag_off =
12012 TOKEN_STRING_INITIALIZER
12013 (struct cmd_config_e_tag_result,
12015 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12016 TOKEN_STRING_INITIALIZER
12017 (struct cmd_config_e_tag_result,
12019 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12020 TOKEN_STRING_INITIALIZER
12021 (struct cmd_config_e_tag_result,
12022 port_tag_id, "port-tag-id");
12023 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12024 TOKEN_NUM_INITIALIZER
12025 (struct cmd_config_e_tag_result,
12026 port_tag_id_val, UINT32);
12027 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12028 TOKEN_STRING_INITIALIZER
12029 (struct cmd_config_e_tag_result,
12030 e_tag_id, "e-tag-id");
12031 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12032 TOKEN_NUM_INITIALIZER
12033 (struct cmd_config_e_tag_result,
12034 e_tag_id_val, UINT16);
12035 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12036 TOKEN_STRING_INITIALIZER
12037 (struct cmd_config_e_tag_result,
12038 dst_pool, "dst-pool");
12039 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12040 TOKEN_NUM_INITIALIZER
12041 (struct cmd_config_e_tag_result,
12042 dst_pool_val, UINT8);
12043 cmdline_parse_token_string_t cmd_config_e_tag_port =
12044 TOKEN_STRING_INITIALIZER
12045 (struct cmd_config_e_tag_result,
12047 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12048 TOKEN_NUM_INITIALIZER
12049 (struct cmd_config_e_tag_result,
12051 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12052 TOKEN_STRING_INITIALIZER
12053 (struct cmd_config_e_tag_result,
12055 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12056 TOKEN_NUM_INITIALIZER
12057 (struct cmd_config_e_tag_result,
12060 /* E-tag insertion configuration */
12062 cmd_config_e_tag_insertion_en_parsed(
12063 void *parsed_result,
12064 __attribute__((unused)) struct cmdline *cl,
12065 __attribute__((unused)) void *data)
12067 struct cmd_config_e_tag_result *res =
12069 struct rte_eth_l2_tunnel_conf entry;
12071 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12074 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12075 entry.tunnel_id = res->port_tag_id_val;
12076 entry.vf_id = res->vf_id;
12077 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12079 ETH_L2_TUNNEL_INSERTION_MASK,
12084 cmd_config_e_tag_insertion_dis_parsed(
12085 void *parsed_result,
12086 __attribute__((unused)) struct cmdline *cl,
12087 __attribute__((unused)) void *data)
12089 struct cmd_config_e_tag_result *res =
12091 struct rte_eth_l2_tunnel_conf entry;
12093 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12096 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12097 entry.vf_id = res->vf_id;
12099 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12101 ETH_L2_TUNNEL_INSERTION_MASK,
12105 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12106 .f = cmd_config_e_tag_insertion_en_parsed,
12108 .help_str = "E-tag ... : E-tag insertion enable",
12110 (void *)&cmd_config_e_tag_e_tag,
12111 (void *)&cmd_config_e_tag_set,
12112 (void *)&cmd_config_e_tag_insertion,
12113 (void *)&cmd_config_e_tag_on,
12114 (void *)&cmd_config_e_tag_port_tag_id,
12115 (void *)&cmd_config_e_tag_port_tag_id_val,
12116 (void *)&cmd_config_e_tag_port,
12117 (void *)&cmd_config_e_tag_port_id,
12118 (void *)&cmd_config_e_tag_vf,
12119 (void *)&cmd_config_e_tag_vf_id,
12124 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12125 .f = cmd_config_e_tag_insertion_dis_parsed,
12127 .help_str = "E-tag ... : E-tag insertion disable",
12129 (void *)&cmd_config_e_tag_e_tag,
12130 (void *)&cmd_config_e_tag_set,
12131 (void *)&cmd_config_e_tag_insertion,
12132 (void *)&cmd_config_e_tag_off,
12133 (void *)&cmd_config_e_tag_port,
12134 (void *)&cmd_config_e_tag_port_id,
12135 (void *)&cmd_config_e_tag_vf,
12136 (void *)&cmd_config_e_tag_vf_id,
12141 /* E-tag stripping configuration */
12143 cmd_config_e_tag_stripping_parsed(
12144 void *parsed_result,
12145 __attribute__((unused)) struct cmdline *cl,
12146 __attribute__((unused)) void *data)
12148 struct cmd_config_e_tag_result *res =
12150 struct rte_eth_l2_tunnel_conf entry;
12152 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12155 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12157 if (!strcmp(res->on_off, "on"))
12158 rte_eth_dev_l2_tunnel_offload_set
12161 ETH_L2_TUNNEL_STRIPPING_MASK,
12164 rte_eth_dev_l2_tunnel_offload_set
12167 ETH_L2_TUNNEL_STRIPPING_MASK,
12171 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12172 .f = cmd_config_e_tag_stripping_parsed,
12174 .help_str = "E-tag ... : E-tag stripping enable/disable",
12176 (void *)&cmd_config_e_tag_e_tag,
12177 (void *)&cmd_config_e_tag_set,
12178 (void *)&cmd_config_e_tag_stripping,
12179 (void *)&cmd_config_e_tag_on_off,
12180 (void *)&cmd_config_e_tag_port,
12181 (void *)&cmd_config_e_tag_port_id,
12186 /* E-tag forwarding configuration */
12188 cmd_config_e_tag_forwarding_parsed(
12189 void *parsed_result,
12190 __attribute__((unused)) struct cmdline *cl,
12191 __attribute__((unused)) void *data)
12193 struct cmd_config_e_tag_result *res = parsed_result;
12194 struct rte_eth_l2_tunnel_conf entry;
12196 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12199 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12201 if (!strcmp(res->on_off, "on"))
12202 rte_eth_dev_l2_tunnel_offload_set
12205 ETH_L2_TUNNEL_FORWARDING_MASK,
12208 rte_eth_dev_l2_tunnel_offload_set
12211 ETH_L2_TUNNEL_FORWARDING_MASK,
12215 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12216 .f = cmd_config_e_tag_forwarding_parsed,
12218 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12220 (void *)&cmd_config_e_tag_e_tag,
12221 (void *)&cmd_config_e_tag_set,
12222 (void *)&cmd_config_e_tag_forwarding,
12223 (void *)&cmd_config_e_tag_on_off,
12224 (void *)&cmd_config_e_tag_port,
12225 (void *)&cmd_config_e_tag_port_id,
12230 /* E-tag filter configuration */
12232 cmd_config_e_tag_filter_add_parsed(
12233 void *parsed_result,
12234 __attribute__((unused)) struct cmdline *cl,
12235 __attribute__((unused)) void *data)
12237 struct cmd_config_e_tag_result *res = parsed_result;
12238 struct rte_eth_l2_tunnel_conf entry;
12241 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12244 if (res->e_tag_id_val > 0x3fff) {
12245 printf("e-tag-id must be equal or less than 0x3fff.\n");
12249 ret = rte_eth_dev_filter_supported(res->port_id,
12250 RTE_ETH_FILTER_L2_TUNNEL);
12252 printf("E-tag filter is not supported on port %u.\n",
12257 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12258 entry.tunnel_id = res->e_tag_id_val;
12259 entry.pool = res->dst_pool_val;
12261 ret = rte_eth_dev_filter_ctrl(res->port_id,
12262 RTE_ETH_FILTER_L2_TUNNEL,
12263 RTE_ETH_FILTER_ADD,
12266 printf("E-tag filter programming error: (%s)\n",
12270 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12271 .f = cmd_config_e_tag_filter_add_parsed,
12273 .help_str = "E-tag ... : E-tag filter add",
12275 (void *)&cmd_config_e_tag_e_tag,
12276 (void *)&cmd_config_e_tag_set,
12277 (void *)&cmd_config_e_tag_filter,
12278 (void *)&cmd_config_e_tag_add,
12279 (void *)&cmd_config_e_tag_e_tag_id,
12280 (void *)&cmd_config_e_tag_e_tag_id_val,
12281 (void *)&cmd_config_e_tag_dst_pool,
12282 (void *)&cmd_config_e_tag_dst_pool_val,
12283 (void *)&cmd_config_e_tag_port,
12284 (void *)&cmd_config_e_tag_port_id,
12290 cmd_config_e_tag_filter_del_parsed(
12291 void *parsed_result,
12292 __attribute__((unused)) struct cmdline *cl,
12293 __attribute__((unused)) void *data)
12295 struct cmd_config_e_tag_result *res = parsed_result;
12296 struct rte_eth_l2_tunnel_conf entry;
12299 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12302 if (res->e_tag_id_val > 0x3fff) {
12303 printf("e-tag-id must be less than 0x3fff.\n");
12307 ret = rte_eth_dev_filter_supported(res->port_id,
12308 RTE_ETH_FILTER_L2_TUNNEL);
12310 printf("E-tag filter is not supported on port %u.\n",
12315 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12316 entry.tunnel_id = res->e_tag_id_val;
12318 ret = rte_eth_dev_filter_ctrl(res->port_id,
12319 RTE_ETH_FILTER_L2_TUNNEL,
12320 RTE_ETH_FILTER_DELETE,
12323 printf("E-tag filter programming error: (%s)\n",
12327 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12328 .f = cmd_config_e_tag_filter_del_parsed,
12330 .help_str = "E-tag ... : E-tag filter delete",
12332 (void *)&cmd_config_e_tag_e_tag,
12333 (void *)&cmd_config_e_tag_set,
12334 (void *)&cmd_config_e_tag_filter,
12335 (void *)&cmd_config_e_tag_del,
12336 (void *)&cmd_config_e_tag_e_tag_id,
12337 (void *)&cmd_config_e_tag_e_tag_id_val,
12338 (void *)&cmd_config_e_tag_port,
12339 (void *)&cmd_config_e_tag_port_id,
12344 /* vf vlan anti spoof configuration */
12346 /* Common result structure for vf vlan anti spoof */
12347 struct cmd_vf_vlan_anti_spoof_result {
12348 cmdline_fixed_string_t set;
12349 cmdline_fixed_string_t vf;
12350 cmdline_fixed_string_t vlan;
12351 cmdline_fixed_string_t antispoof;
12354 cmdline_fixed_string_t on_off;
12357 /* Common CLI fields for vf vlan anti spoof enable disable */
12358 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12359 TOKEN_STRING_INITIALIZER
12360 (struct cmd_vf_vlan_anti_spoof_result,
12362 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12363 TOKEN_STRING_INITIALIZER
12364 (struct cmd_vf_vlan_anti_spoof_result,
12366 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12367 TOKEN_STRING_INITIALIZER
12368 (struct cmd_vf_vlan_anti_spoof_result,
12370 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12371 TOKEN_STRING_INITIALIZER
12372 (struct cmd_vf_vlan_anti_spoof_result,
12373 antispoof, "antispoof");
12374 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12375 TOKEN_NUM_INITIALIZER
12376 (struct cmd_vf_vlan_anti_spoof_result,
12378 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12379 TOKEN_NUM_INITIALIZER
12380 (struct cmd_vf_vlan_anti_spoof_result,
12382 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12383 TOKEN_STRING_INITIALIZER
12384 (struct cmd_vf_vlan_anti_spoof_result,
12388 cmd_set_vf_vlan_anti_spoof_parsed(
12389 void *parsed_result,
12390 __attribute__((unused)) struct cmdline *cl,
12391 __attribute__((unused)) void *data)
12393 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12394 int ret = -ENOTSUP;
12396 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12398 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12401 #ifdef RTE_LIBRTE_IXGBE_PMD
12402 if (ret == -ENOTSUP)
12403 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12404 res->vf_id, is_on);
12406 #ifdef RTE_LIBRTE_I40E_PMD
12407 if (ret == -ENOTSUP)
12408 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12409 res->vf_id, is_on);
12411 #ifdef RTE_LIBRTE_BNXT_PMD
12412 if (ret == -ENOTSUP)
12413 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12414 res->vf_id, is_on);
12421 printf("invalid vf_id %d\n", res->vf_id);
12424 printf("invalid port_id %d\n", res->port_id);
12427 printf("function not implemented\n");
12430 printf("programming error: (%s)\n", strerror(-ret));
12434 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12435 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12437 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12439 (void *)&cmd_vf_vlan_anti_spoof_set,
12440 (void *)&cmd_vf_vlan_anti_spoof_vf,
12441 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12442 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12443 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12444 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12445 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12450 /* vf mac anti spoof configuration */
12452 /* Common result structure for vf mac anti spoof */
12453 struct cmd_vf_mac_anti_spoof_result {
12454 cmdline_fixed_string_t set;
12455 cmdline_fixed_string_t vf;
12456 cmdline_fixed_string_t mac;
12457 cmdline_fixed_string_t antispoof;
12460 cmdline_fixed_string_t on_off;
12463 /* Common CLI fields for vf mac anti spoof enable disable */
12464 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12465 TOKEN_STRING_INITIALIZER
12466 (struct cmd_vf_mac_anti_spoof_result,
12468 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12469 TOKEN_STRING_INITIALIZER
12470 (struct cmd_vf_mac_anti_spoof_result,
12472 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12473 TOKEN_STRING_INITIALIZER
12474 (struct cmd_vf_mac_anti_spoof_result,
12476 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12477 TOKEN_STRING_INITIALIZER
12478 (struct cmd_vf_mac_anti_spoof_result,
12479 antispoof, "antispoof");
12480 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12481 TOKEN_NUM_INITIALIZER
12482 (struct cmd_vf_mac_anti_spoof_result,
12484 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12485 TOKEN_NUM_INITIALIZER
12486 (struct cmd_vf_mac_anti_spoof_result,
12488 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12489 TOKEN_STRING_INITIALIZER
12490 (struct cmd_vf_mac_anti_spoof_result,
12494 cmd_set_vf_mac_anti_spoof_parsed(
12495 void *parsed_result,
12496 __attribute__((unused)) struct cmdline *cl,
12497 __attribute__((unused)) void *data)
12499 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12500 int ret = -ENOTSUP;
12502 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12504 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12507 #ifdef RTE_LIBRTE_IXGBE_PMD
12508 if (ret == -ENOTSUP)
12509 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12510 res->vf_id, is_on);
12512 #ifdef RTE_LIBRTE_I40E_PMD
12513 if (ret == -ENOTSUP)
12514 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12515 res->vf_id, is_on);
12517 #ifdef RTE_LIBRTE_BNXT_PMD
12518 if (ret == -ENOTSUP)
12519 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12520 res->vf_id, is_on);
12527 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12530 printf("invalid port_id %d\n", res->port_id);
12533 printf("function not implemented\n");
12536 printf("programming error: (%s)\n", strerror(-ret));
12540 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12541 .f = cmd_set_vf_mac_anti_spoof_parsed,
12543 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12545 (void *)&cmd_vf_mac_anti_spoof_set,
12546 (void *)&cmd_vf_mac_anti_spoof_vf,
12547 (void *)&cmd_vf_mac_anti_spoof_mac,
12548 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12549 (void *)&cmd_vf_mac_anti_spoof_port_id,
12550 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12551 (void *)&cmd_vf_mac_anti_spoof_on_off,
12556 /* vf vlan strip queue configuration */
12558 /* Common result structure for vf mac anti spoof */
12559 struct cmd_vf_vlan_stripq_result {
12560 cmdline_fixed_string_t set;
12561 cmdline_fixed_string_t vf;
12562 cmdline_fixed_string_t vlan;
12563 cmdline_fixed_string_t stripq;
12566 cmdline_fixed_string_t on_off;
12569 /* Common CLI fields for vf vlan strip enable disable */
12570 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12571 TOKEN_STRING_INITIALIZER
12572 (struct cmd_vf_vlan_stripq_result,
12574 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12575 TOKEN_STRING_INITIALIZER
12576 (struct cmd_vf_vlan_stripq_result,
12578 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12579 TOKEN_STRING_INITIALIZER
12580 (struct cmd_vf_vlan_stripq_result,
12582 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12583 TOKEN_STRING_INITIALIZER
12584 (struct cmd_vf_vlan_stripq_result,
12586 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12587 TOKEN_NUM_INITIALIZER
12588 (struct cmd_vf_vlan_stripq_result,
12590 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12591 TOKEN_NUM_INITIALIZER
12592 (struct cmd_vf_vlan_stripq_result,
12594 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12595 TOKEN_STRING_INITIALIZER
12596 (struct cmd_vf_vlan_stripq_result,
12600 cmd_set_vf_vlan_stripq_parsed(
12601 void *parsed_result,
12602 __attribute__((unused)) struct cmdline *cl,
12603 __attribute__((unused)) void *data)
12605 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12606 int ret = -ENOTSUP;
12608 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12610 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12613 #ifdef RTE_LIBRTE_IXGBE_PMD
12614 if (ret == -ENOTSUP)
12615 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12616 res->vf_id, is_on);
12618 #ifdef RTE_LIBRTE_I40E_PMD
12619 if (ret == -ENOTSUP)
12620 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12621 res->vf_id, is_on);
12623 #ifdef RTE_LIBRTE_BNXT_PMD
12624 if (ret == -ENOTSUP)
12625 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12626 res->vf_id, is_on);
12633 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12636 printf("invalid port_id %d\n", res->port_id);
12639 printf("function not implemented\n");
12642 printf("programming error: (%s)\n", strerror(-ret));
12646 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12647 .f = cmd_set_vf_vlan_stripq_parsed,
12649 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12651 (void *)&cmd_vf_vlan_stripq_set,
12652 (void *)&cmd_vf_vlan_stripq_vf,
12653 (void *)&cmd_vf_vlan_stripq_vlan,
12654 (void *)&cmd_vf_vlan_stripq_stripq,
12655 (void *)&cmd_vf_vlan_stripq_port_id,
12656 (void *)&cmd_vf_vlan_stripq_vf_id,
12657 (void *)&cmd_vf_vlan_stripq_on_off,
12662 /* vf vlan insert configuration */
12664 /* Common result structure for vf vlan insert */
12665 struct cmd_vf_vlan_insert_result {
12666 cmdline_fixed_string_t set;
12667 cmdline_fixed_string_t vf;
12668 cmdline_fixed_string_t vlan;
12669 cmdline_fixed_string_t insert;
12675 /* Common CLI fields for vf vlan insert enable disable */
12676 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12677 TOKEN_STRING_INITIALIZER
12678 (struct cmd_vf_vlan_insert_result,
12680 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12681 TOKEN_STRING_INITIALIZER
12682 (struct cmd_vf_vlan_insert_result,
12684 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12685 TOKEN_STRING_INITIALIZER
12686 (struct cmd_vf_vlan_insert_result,
12688 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12689 TOKEN_STRING_INITIALIZER
12690 (struct cmd_vf_vlan_insert_result,
12692 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12693 TOKEN_NUM_INITIALIZER
12694 (struct cmd_vf_vlan_insert_result,
12696 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12697 TOKEN_NUM_INITIALIZER
12698 (struct cmd_vf_vlan_insert_result,
12700 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12701 TOKEN_NUM_INITIALIZER
12702 (struct cmd_vf_vlan_insert_result,
12706 cmd_set_vf_vlan_insert_parsed(
12707 void *parsed_result,
12708 __attribute__((unused)) struct cmdline *cl,
12709 __attribute__((unused)) void *data)
12711 struct cmd_vf_vlan_insert_result *res = parsed_result;
12712 int ret = -ENOTSUP;
12714 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12717 #ifdef RTE_LIBRTE_IXGBE_PMD
12718 if (ret == -ENOTSUP)
12719 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12722 #ifdef RTE_LIBRTE_I40E_PMD
12723 if (ret == -ENOTSUP)
12724 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12727 #ifdef RTE_LIBRTE_BNXT_PMD
12728 if (ret == -ENOTSUP)
12729 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12737 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12740 printf("invalid port_id %d\n", res->port_id);
12743 printf("function not implemented\n");
12746 printf("programming error: (%s)\n", strerror(-ret));
12750 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12751 .f = cmd_set_vf_vlan_insert_parsed,
12753 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12755 (void *)&cmd_vf_vlan_insert_set,
12756 (void *)&cmd_vf_vlan_insert_vf,
12757 (void *)&cmd_vf_vlan_insert_vlan,
12758 (void *)&cmd_vf_vlan_insert_insert,
12759 (void *)&cmd_vf_vlan_insert_port_id,
12760 (void *)&cmd_vf_vlan_insert_vf_id,
12761 (void *)&cmd_vf_vlan_insert_vlan_id,
12766 /* tx loopback configuration */
12768 /* Common result structure for tx loopback */
12769 struct cmd_tx_loopback_result {
12770 cmdline_fixed_string_t set;
12771 cmdline_fixed_string_t tx;
12772 cmdline_fixed_string_t loopback;
12774 cmdline_fixed_string_t on_off;
12777 /* Common CLI fields for tx loopback enable disable */
12778 cmdline_parse_token_string_t cmd_tx_loopback_set =
12779 TOKEN_STRING_INITIALIZER
12780 (struct cmd_tx_loopback_result,
12782 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12783 TOKEN_STRING_INITIALIZER
12784 (struct cmd_tx_loopback_result,
12786 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12787 TOKEN_STRING_INITIALIZER
12788 (struct cmd_tx_loopback_result,
12789 loopback, "loopback");
12790 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12791 TOKEN_NUM_INITIALIZER
12792 (struct cmd_tx_loopback_result,
12794 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12795 TOKEN_STRING_INITIALIZER
12796 (struct cmd_tx_loopback_result,
12800 cmd_set_tx_loopback_parsed(
12801 void *parsed_result,
12802 __attribute__((unused)) struct cmdline *cl,
12803 __attribute__((unused)) void *data)
12805 struct cmd_tx_loopback_result *res = parsed_result;
12806 int ret = -ENOTSUP;
12808 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12810 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12813 #ifdef RTE_LIBRTE_IXGBE_PMD
12814 if (ret == -ENOTSUP)
12815 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12817 #ifdef RTE_LIBRTE_I40E_PMD
12818 if (ret == -ENOTSUP)
12819 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12821 #ifdef RTE_LIBRTE_BNXT_PMD
12822 if (ret == -ENOTSUP)
12823 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12830 printf("invalid is_on %d\n", is_on);
12833 printf("invalid port_id %d\n", res->port_id);
12836 printf("function not implemented\n");
12839 printf("programming error: (%s)\n", strerror(-ret));
12843 cmdline_parse_inst_t cmd_set_tx_loopback = {
12844 .f = cmd_set_tx_loopback_parsed,
12846 .help_str = "set tx loopback <port_id> on|off",
12848 (void *)&cmd_tx_loopback_set,
12849 (void *)&cmd_tx_loopback_tx,
12850 (void *)&cmd_tx_loopback_loopback,
12851 (void *)&cmd_tx_loopback_port_id,
12852 (void *)&cmd_tx_loopback_on_off,
12857 /* all queues drop enable configuration */
12859 /* Common result structure for all queues drop enable */
12860 struct cmd_all_queues_drop_en_result {
12861 cmdline_fixed_string_t set;
12862 cmdline_fixed_string_t all;
12863 cmdline_fixed_string_t queues;
12864 cmdline_fixed_string_t drop;
12866 cmdline_fixed_string_t on_off;
12869 /* Common CLI fields for tx loopback enable disable */
12870 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12871 TOKEN_STRING_INITIALIZER
12872 (struct cmd_all_queues_drop_en_result,
12874 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12875 TOKEN_STRING_INITIALIZER
12876 (struct cmd_all_queues_drop_en_result,
12878 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12879 TOKEN_STRING_INITIALIZER
12880 (struct cmd_all_queues_drop_en_result,
12882 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12883 TOKEN_STRING_INITIALIZER
12884 (struct cmd_all_queues_drop_en_result,
12886 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12887 TOKEN_NUM_INITIALIZER
12888 (struct cmd_all_queues_drop_en_result,
12890 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12891 TOKEN_STRING_INITIALIZER
12892 (struct cmd_all_queues_drop_en_result,
12896 cmd_set_all_queues_drop_en_parsed(
12897 void *parsed_result,
12898 __attribute__((unused)) struct cmdline *cl,
12899 __attribute__((unused)) void *data)
12901 struct cmd_all_queues_drop_en_result *res = parsed_result;
12902 int ret = -ENOTSUP;
12903 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12905 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12908 #ifdef RTE_LIBRTE_IXGBE_PMD
12909 if (ret == -ENOTSUP)
12910 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12912 #ifdef RTE_LIBRTE_BNXT_PMD
12913 if (ret == -ENOTSUP)
12914 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12920 printf("invalid is_on %d\n", is_on);
12923 printf("invalid port_id %d\n", res->port_id);
12926 printf("function not implemented\n");
12929 printf("programming error: (%s)\n", strerror(-ret));
12933 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12934 .f = cmd_set_all_queues_drop_en_parsed,
12936 .help_str = "set all queues drop <port_id> on|off",
12938 (void *)&cmd_all_queues_drop_en_set,
12939 (void *)&cmd_all_queues_drop_en_all,
12940 (void *)&cmd_all_queues_drop_en_queues,
12941 (void *)&cmd_all_queues_drop_en_drop,
12942 (void *)&cmd_all_queues_drop_en_port_id,
12943 (void *)&cmd_all_queues_drop_en_on_off,
12948 /* vf split drop enable configuration */
12950 /* Common result structure for vf split drop enable */
12951 struct cmd_vf_split_drop_en_result {
12952 cmdline_fixed_string_t set;
12953 cmdline_fixed_string_t vf;
12954 cmdline_fixed_string_t split;
12955 cmdline_fixed_string_t drop;
12958 cmdline_fixed_string_t on_off;
12961 /* Common CLI fields for vf split drop enable disable */
12962 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12963 TOKEN_STRING_INITIALIZER
12964 (struct cmd_vf_split_drop_en_result,
12966 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12967 TOKEN_STRING_INITIALIZER
12968 (struct cmd_vf_split_drop_en_result,
12970 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12971 TOKEN_STRING_INITIALIZER
12972 (struct cmd_vf_split_drop_en_result,
12974 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12975 TOKEN_STRING_INITIALIZER
12976 (struct cmd_vf_split_drop_en_result,
12978 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12979 TOKEN_NUM_INITIALIZER
12980 (struct cmd_vf_split_drop_en_result,
12982 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12983 TOKEN_NUM_INITIALIZER
12984 (struct cmd_vf_split_drop_en_result,
12986 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12987 TOKEN_STRING_INITIALIZER
12988 (struct cmd_vf_split_drop_en_result,
12992 cmd_set_vf_split_drop_en_parsed(
12993 void *parsed_result,
12994 __attribute__((unused)) struct cmdline *cl,
12995 __attribute__((unused)) void *data)
12997 struct cmd_vf_split_drop_en_result *res = parsed_result;
12998 int ret = -ENOTSUP;
12999 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13001 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13004 #ifdef RTE_LIBRTE_IXGBE_PMD
13005 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13012 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13015 printf("invalid port_id %d\n", res->port_id);
13018 printf("not supported on port %d\n", res->port_id);
13021 printf("programming error: (%s)\n", strerror(-ret));
13025 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13026 .f = cmd_set_vf_split_drop_en_parsed,
13028 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13030 (void *)&cmd_vf_split_drop_en_set,
13031 (void *)&cmd_vf_split_drop_en_vf,
13032 (void *)&cmd_vf_split_drop_en_split,
13033 (void *)&cmd_vf_split_drop_en_drop,
13034 (void *)&cmd_vf_split_drop_en_port_id,
13035 (void *)&cmd_vf_split_drop_en_vf_id,
13036 (void *)&cmd_vf_split_drop_en_on_off,
13041 /* vf mac address configuration */
13043 /* Common result structure for vf mac address */
13044 struct cmd_set_vf_mac_addr_result {
13045 cmdline_fixed_string_t set;
13046 cmdline_fixed_string_t vf;
13047 cmdline_fixed_string_t mac;
13048 cmdline_fixed_string_t addr;
13051 struct ether_addr mac_addr;
13055 /* Common CLI fields for vf split drop enable disable */
13056 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13057 TOKEN_STRING_INITIALIZER
13058 (struct cmd_set_vf_mac_addr_result,
13060 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13061 TOKEN_STRING_INITIALIZER
13062 (struct cmd_set_vf_mac_addr_result,
13064 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13065 TOKEN_STRING_INITIALIZER
13066 (struct cmd_set_vf_mac_addr_result,
13068 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13069 TOKEN_STRING_INITIALIZER
13070 (struct cmd_set_vf_mac_addr_result,
13072 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13073 TOKEN_NUM_INITIALIZER
13074 (struct cmd_set_vf_mac_addr_result,
13076 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13077 TOKEN_NUM_INITIALIZER
13078 (struct cmd_set_vf_mac_addr_result,
13080 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13081 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13085 cmd_set_vf_mac_addr_parsed(
13086 void *parsed_result,
13087 __attribute__((unused)) struct cmdline *cl,
13088 __attribute__((unused)) void *data)
13090 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13091 int ret = -ENOTSUP;
13093 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13096 #ifdef RTE_LIBRTE_IXGBE_PMD
13097 if (ret == -ENOTSUP)
13098 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13101 #ifdef RTE_LIBRTE_I40E_PMD
13102 if (ret == -ENOTSUP)
13103 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13106 #ifdef RTE_LIBRTE_BNXT_PMD
13107 if (ret == -ENOTSUP)
13108 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13116 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13119 printf("invalid port_id %d\n", res->port_id);
13122 printf("function not implemented\n");
13125 printf("programming error: (%s)\n", strerror(-ret));
13129 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13130 .f = cmd_set_vf_mac_addr_parsed,
13132 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13134 (void *)&cmd_set_vf_mac_addr_set,
13135 (void *)&cmd_set_vf_mac_addr_vf,
13136 (void *)&cmd_set_vf_mac_addr_mac,
13137 (void *)&cmd_set_vf_mac_addr_addr,
13138 (void *)&cmd_set_vf_mac_addr_port_id,
13139 (void *)&cmd_set_vf_mac_addr_vf_id,
13140 (void *)&cmd_set_vf_mac_addr_mac_addr,
13145 /* MACsec configuration */
13147 /* Common result structure for MACsec offload enable */
13148 struct cmd_macsec_offload_on_result {
13149 cmdline_fixed_string_t set;
13150 cmdline_fixed_string_t macsec;
13151 cmdline_fixed_string_t offload;
13153 cmdline_fixed_string_t on;
13154 cmdline_fixed_string_t encrypt;
13155 cmdline_fixed_string_t en_on_off;
13156 cmdline_fixed_string_t replay_protect;
13157 cmdline_fixed_string_t rp_on_off;
13160 /* Common CLI fields for MACsec offload disable */
13161 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13162 TOKEN_STRING_INITIALIZER
13163 (struct cmd_macsec_offload_on_result,
13165 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13166 TOKEN_STRING_INITIALIZER
13167 (struct cmd_macsec_offload_on_result,
13169 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13170 TOKEN_STRING_INITIALIZER
13171 (struct cmd_macsec_offload_on_result,
13172 offload, "offload");
13173 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13174 TOKEN_NUM_INITIALIZER
13175 (struct cmd_macsec_offload_on_result,
13177 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13178 TOKEN_STRING_INITIALIZER
13179 (struct cmd_macsec_offload_on_result,
13181 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13182 TOKEN_STRING_INITIALIZER
13183 (struct cmd_macsec_offload_on_result,
13184 encrypt, "encrypt");
13185 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13186 TOKEN_STRING_INITIALIZER
13187 (struct cmd_macsec_offload_on_result,
13188 en_on_off, "on#off");
13189 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13190 TOKEN_STRING_INITIALIZER
13191 (struct cmd_macsec_offload_on_result,
13192 replay_protect, "replay-protect");
13193 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13194 TOKEN_STRING_INITIALIZER
13195 (struct cmd_macsec_offload_on_result,
13196 rp_on_off, "on#off");
13199 cmd_set_macsec_offload_on_parsed(
13200 void *parsed_result,
13201 __attribute__((unused)) struct cmdline *cl,
13202 __attribute__((unused)) void *data)
13204 struct cmd_macsec_offload_on_result *res = parsed_result;
13205 int ret = -ENOTSUP;
13206 portid_t port_id = res->port_id;
13207 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13208 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13209 struct rte_eth_dev_info dev_info;
13211 if (port_id_is_invalid(port_id, ENABLED_WARN))
13213 if (!port_is_stopped(port_id)) {
13214 printf("Please stop port %d first\n", port_id);
13218 rte_eth_dev_info_get(port_id, &dev_info);
13219 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13220 #ifdef RTE_LIBRTE_IXGBE_PMD
13221 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13229 ports[port_id].dev_conf.txmode.offloads |=
13230 DEV_TX_OFFLOAD_MACSEC_INSERT;
13231 cmd_reconfig_device_queue(port_id, 1, 1);
13234 printf("invalid port_id %d\n", port_id);
13237 printf("not supported on port %d\n", port_id);
13240 printf("programming error: (%s)\n", strerror(-ret));
13244 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13245 .f = cmd_set_macsec_offload_on_parsed,
13247 .help_str = "set macsec offload <port_id> on "
13248 "encrypt on|off replay-protect on|off",
13250 (void *)&cmd_macsec_offload_on_set,
13251 (void *)&cmd_macsec_offload_on_macsec,
13252 (void *)&cmd_macsec_offload_on_offload,
13253 (void *)&cmd_macsec_offload_on_port_id,
13254 (void *)&cmd_macsec_offload_on_on,
13255 (void *)&cmd_macsec_offload_on_encrypt,
13256 (void *)&cmd_macsec_offload_on_en_on_off,
13257 (void *)&cmd_macsec_offload_on_replay_protect,
13258 (void *)&cmd_macsec_offload_on_rp_on_off,
13263 /* Common result structure for MACsec offload disable */
13264 struct cmd_macsec_offload_off_result {
13265 cmdline_fixed_string_t set;
13266 cmdline_fixed_string_t macsec;
13267 cmdline_fixed_string_t offload;
13269 cmdline_fixed_string_t off;
13272 /* Common CLI fields for MACsec offload disable */
13273 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13274 TOKEN_STRING_INITIALIZER
13275 (struct cmd_macsec_offload_off_result,
13277 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13278 TOKEN_STRING_INITIALIZER
13279 (struct cmd_macsec_offload_off_result,
13281 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13282 TOKEN_STRING_INITIALIZER
13283 (struct cmd_macsec_offload_off_result,
13284 offload, "offload");
13285 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13286 TOKEN_NUM_INITIALIZER
13287 (struct cmd_macsec_offload_off_result,
13289 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13290 TOKEN_STRING_INITIALIZER
13291 (struct cmd_macsec_offload_off_result,
13295 cmd_set_macsec_offload_off_parsed(
13296 void *parsed_result,
13297 __attribute__((unused)) struct cmdline *cl,
13298 __attribute__((unused)) void *data)
13300 struct cmd_macsec_offload_off_result *res = parsed_result;
13301 int ret = -ENOTSUP;
13302 struct rte_eth_dev_info dev_info;
13303 portid_t port_id = res->port_id;
13305 if (port_id_is_invalid(port_id, ENABLED_WARN))
13307 if (!port_is_stopped(port_id)) {
13308 printf("Please stop port %d first\n", port_id);
13312 rte_eth_dev_info_get(port_id, &dev_info);
13313 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13314 #ifdef RTE_LIBRTE_IXGBE_PMD
13315 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13320 ports[port_id].dev_conf.txmode.offloads &=
13321 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13322 cmd_reconfig_device_queue(port_id, 1, 1);
13325 printf("invalid port_id %d\n", port_id);
13328 printf("not supported on port %d\n", port_id);
13331 printf("programming error: (%s)\n", strerror(-ret));
13335 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13336 .f = cmd_set_macsec_offload_off_parsed,
13338 .help_str = "set macsec offload <port_id> off",
13340 (void *)&cmd_macsec_offload_off_set,
13341 (void *)&cmd_macsec_offload_off_macsec,
13342 (void *)&cmd_macsec_offload_off_offload,
13343 (void *)&cmd_macsec_offload_off_port_id,
13344 (void *)&cmd_macsec_offload_off_off,
13349 /* Common result structure for MACsec secure connection configure */
13350 struct cmd_macsec_sc_result {
13351 cmdline_fixed_string_t set;
13352 cmdline_fixed_string_t macsec;
13353 cmdline_fixed_string_t sc;
13354 cmdline_fixed_string_t tx_rx;
13356 struct ether_addr mac;
13360 /* Common CLI fields for MACsec secure connection configure */
13361 cmdline_parse_token_string_t cmd_macsec_sc_set =
13362 TOKEN_STRING_INITIALIZER
13363 (struct cmd_macsec_sc_result,
13365 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13366 TOKEN_STRING_INITIALIZER
13367 (struct cmd_macsec_sc_result,
13369 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13370 TOKEN_STRING_INITIALIZER
13371 (struct cmd_macsec_sc_result,
13373 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13374 TOKEN_STRING_INITIALIZER
13375 (struct cmd_macsec_sc_result,
13377 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13378 TOKEN_NUM_INITIALIZER
13379 (struct cmd_macsec_sc_result,
13381 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13382 TOKEN_ETHERADDR_INITIALIZER
13383 (struct cmd_macsec_sc_result,
13385 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13386 TOKEN_NUM_INITIALIZER
13387 (struct cmd_macsec_sc_result,
13391 cmd_set_macsec_sc_parsed(
13392 void *parsed_result,
13393 __attribute__((unused)) struct cmdline *cl,
13394 __attribute__((unused)) void *data)
13396 struct cmd_macsec_sc_result *res = parsed_result;
13397 int ret = -ENOTSUP;
13398 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13400 #ifdef RTE_LIBRTE_IXGBE_PMD
13402 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13403 res->mac.addr_bytes) :
13404 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13405 res->mac.addr_bytes, res->pi);
13407 RTE_SET_USED(is_tx);
13413 printf("invalid port_id %d\n", res->port_id);
13416 printf("not supported on port %d\n", res->port_id);
13419 printf("programming error: (%s)\n", strerror(-ret));
13423 cmdline_parse_inst_t cmd_set_macsec_sc = {
13424 .f = cmd_set_macsec_sc_parsed,
13426 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13428 (void *)&cmd_macsec_sc_set,
13429 (void *)&cmd_macsec_sc_macsec,
13430 (void *)&cmd_macsec_sc_sc,
13431 (void *)&cmd_macsec_sc_tx_rx,
13432 (void *)&cmd_macsec_sc_port_id,
13433 (void *)&cmd_macsec_sc_mac,
13434 (void *)&cmd_macsec_sc_pi,
13439 /* Common result structure for MACsec secure connection configure */
13440 struct cmd_macsec_sa_result {
13441 cmdline_fixed_string_t set;
13442 cmdline_fixed_string_t macsec;
13443 cmdline_fixed_string_t sa;
13444 cmdline_fixed_string_t tx_rx;
13449 cmdline_fixed_string_t key;
13452 /* Common CLI fields for MACsec secure connection configure */
13453 cmdline_parse_token_string_t cmd_macsec_sa_set =
13454 TOKEN_STRING_INITIALIZER
13455 (struct cmd_macsec_sa_result,
13457 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13458 TOKEN_STRING_INITIALIZER
13459 (struct cmd_macsec_sa_result,
13461 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13462 TOKEN_STRING_INITIALIZER
13463 (struct cmd_macsec_sa_result,
13465 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13466 TOKEN_STRING_INITIALIZER
13467 (struct cmd_macsec_sa_result,
13469 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13470 TOKEN_NUM_INITIALIZER
13471 (struct cmd_macsec_sa_result,
13473 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13474 TOKEN_NUM_INITIALIZER
13475 (struct cmd_macsec_sa_result,
13477 cmdline_parse_token_num_t cmd_macsec_sa_an =
13478 TOKEN_NUM_INITIALIZER
13479 (struct cmd_macsec_sa_result,
13481 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13482 TOKEN_NUM_INITIALIZER
13483 (struct cmd_macsec_sa_result,
13485 cmdline_parse_token_string_t cmd_macsec_sa_key =
13486 TOKEN_STRING_INITIALIZER
13487 (struct cmd_macsec_sa_result,
13491 cmd_set_macsec_sa_parsed(
13492 void *parsed_result,
13493 __attribute__((unused)) struct cmdline *cl,
13494 __attribute__((unused)) void *data)
13496 struct cmd_macsec_sa_result *res = parsed_result;
13497 int ret = -ENOTSUP;
13498 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13499 uint8_t key[16] = { 0 };
13505 key_len = strlen(res->key) / 2;
13509 for (i = 0; i < key_len; i++) {
13510 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13513 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13516 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13519 #ifdef RTE_LIBRTE_IXGBE_PMD
13521 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13522 res->idx, res->an, res->pn, key) :
13523 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13524 res->idx, res->an, res->pn, key);
13526 RTE_SET_USED(is_tx);
13533 printf("invalid idx %d or an %d\n", res->idx, res->an);
13536 printf("invalid port_id %d\n", res->port_id);
13539 printf("not supported on port %d\n", res->port_id);
13542 printf("programming error: (%s)\n", strerror(-ret));
13546 cmdline_parse_inst_t cmd_set_macsec_sa = {
13547 .f = cmd_set_macsec_sa_parsed,
13549 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13551 (void *)&cmd_macsec_sa_set,
13552 (void *)&cmd_macsec_sa_macsec,
13553 (void *)&cmd_macsec_sa_sa,
13554 (void *)&cmd_macsec_sa_tx_rx,
13555 (void *)&cmd_macsec_sa_port_id,
13556 (void *)&cmd_macsec_sa_idx,
13557 (void *)&cmd_macsec_sa_an,
13558 (void *)&cmd_macsec_sa_pn,
13559 (void *)&cmd_macsec_sa_key,
13564 /* VF unicast promiscuous mode configuration */
13566 /* Common result structure for VF unicast promiscuous mode */
13567 struct cmd_vf_promisc_result {
13568 cmdline_fixed_string_t set;
13569 cmdline_fixed_string_t vf;
13570 cmdline_fixed_string_t promisc;
13573 cmdline_fixed_string_t on_off;
13576 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13577 cmdline_parse_token_string_t cmd_vf_promisc_set =
13578 TOKEN_STRING_INITIALIZER
13579 (struct cmd_vf_promisc_result,
13581 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13582 TOKEN_STRING_INITIALIZER
13583 (struct cmd_vf_promisc_result,
13585 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13586 TOKEN_STRING_INITIALIZER
13587 (struct cmd_vf_promisc_result,
13588 promisc, "promisc");
13589 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13590 TOKEN_NUM_INITIALIZER
13591 (struct cmd_vf_promisc_result,
13593 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13594 TOKEN_NUM_INITIALIZER
13595 (struct cmd_vf_promisc_result,
13597 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13598 TOKEN_STRING_INITIALIZER
13599 (struct cmd_vf_promisc_result,
13603 cmd_set_vf_promisc_parsed(
13604 void *parsed_result,
13605 __attribute__((unused)) struct cmdline *cl,
13606 __attribute__((unused)) void *data)
13608 struct cmd_vf_promisc_result *res = parsed_result;
13609 int ret = -ENOTSUP;
13611 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13613 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13616 #ifdef RTE_LIBRTE_I40E_PMD
13617 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13618 res->vf_id, is_on);
13625 printf("invalid vf_id %d\n", res->vf_id);
13628 printf("invalid port_id %d\n", res->port_id);
13631 printf("function not implemented\n");
13634 printf("programming error: (%s)\n", strerror(-ret));
13638 cmdline_parse_inst_t cmd_set_vf_promisc = {
13639 .f = cmd_set_vf_promisc_parsed,
13641 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13642 "Set unicast promiscuous mode for a VF from the PF",
13644 (void *)&cmd_vf_promisc_set,
13645 (void *)&cmd_vf_promisc_vf,
13646 (void *)&cmd_vf_promisc_promisc,
13647 (void *)&cmd_vf_promisc_port_id,
13648 (void *)&cmd_vf_promisc_vf_id,
13649 (void *)&cmd_vf_promisc_on_off,
13654 /* VF multicast promiscuous mode configuration */
13656 /* Common result structure for VF multicast promiscuous mode */
13657 struct cmd_vf_allmulti_result {
13658 cmdline_fixed_string_t set;
13659 cmdline_fixed_string_t vf;
13660 cmdline_fixed_string_t allmulti;
13663 cmdline_fixed_string_t on_off;
13666 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13667 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13668 TOKEN_STRING_INITIALIZER
13669 (struct cmd_vf_allmulti_result,
13671 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13672 TOKEN_STRING_INITIALIZER
13673 (struct cmd_vf_allmulti_result,
13675 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13676 TOKEN_STRING_INITIALIZER
13677 (struct cmd_vf_allmulti_result,
13678 allmulti, "allmulti");
13679 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13680 TOKEN_NUM_INITIALIZER
13681 (struct cmd_vf_allmulti_result,
13683 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13684 TOKEN_NUM_INITIALIZER
13685 (struct cmd_vf_allmulti_result,
13687 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13688 TOKEN_STRING_INITIALIZER
13689 (struct cmd_vf_allmulti_result,
13693 cmd_set_vf_allmulti_parsed(
13694 void *parsed_result,
13695 __attribute__((unused)) struct cmdline *cl,
13696 __attribute__((unused)) void *data)
13698 struct cmd_vf_allmulti_result *res = parsed_result;
13699 int ret = -ENOTSUP;
13701 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13703 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13706 #ifdef RTE_LIBRTE_I40E_PMD
13707 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13708 res->vf_id, is_on);
13715 printf("invalid vf_id %d\n", res->vf_id);
13718 printf("invalid port_id %d\n", res->port_id);
13721 printf("function not implemented\n");
13724 printf("programming error: (%s)\n", strerror(-ret));
13728 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13729 .f = cmd_set_vf_allmulti_parsed,
13731 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13732 "Set multicast promiscuous mode for a VF from the PF",
13734 (void *)&cmd_vf_allmulti_set,
13735 (void *)&cmd_vf_allmulti_vf,
13736 (void *)&cmd_vf_allmulti_allmulti,
13737 (void *)&cmd_vf_allmulti_port_id,
13738 (void *)&cmd_vf_allmulti_vf_id,
13739 (void *)&cmd_vf_allmulti_on_off,
13744 /* vf broadcast mode configuration */
13746 /* Common result structure for vf broadcast */
13747 struct cmd_set_vf_broadcast_result {
13748 cmdline_fixed_string_t set;
13749 cmdline_fixed_string_t vf;
13750 cmdline_fixed_string_t broadcast;
13753 cmdline_fixed_string_t on_off;
13756 /* Common CLI fields for vf broadcast enable disable */
13757 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13758 TOKEN_STRING_INITIALIZER
13759 (struct cmd_set_vf_broadcast_result,
13761 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13762 TOKEN_STRING_INITIALIZER
13763 (struct cmd_set_vf_broadcast_result,
13765 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13766 TOKEN_STRING_INITIALIZER
13767 (struct cmd_set_vf_broadcast_result,
13768 broadcast, "broadcast");
13769 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13770 TOKEN_NUM_INITIALIZER
13771 (struct cmd_set_vf_broadcast_result,
13773 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13774 TOKEN_NUM_INITIALIZER
13775 (struct cmd_set_vf_broadcast_result,
13777 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13778 TOKEN_STRING_INITIALIZER
13779 (struct cmd_set_vf_broadcast_result,
13783 cmd_set_vf_broadcast_parsed(
13784 void *parsed_result,
13785 __attribute__((unused)) struct cmdline *cl,
13786 __attribute__((unused)) void *data)
13788 struct cmd_set_vf_broadcast_result *res = parsed_result;
13789 int ret = -ENOTSUP;
13791 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13793 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13796 #ifdef RTE_LIBRTE_I40E_PMD
13797 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13798 res->vf_id, is_on);
13805 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13808 printf("invalid port_id %d\n", res->port_id);
13811 printf("function not implemented\n");
13814 printf("programming error: (%s)\n", strerror(-ret));
13818 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13819 .f = cmd_set_vf_broadcast_parsed,
13821 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13823 (void *)&cmd_set_vf_broadcast_set,
13824 (void *)&cmd_set_vf_broadcast_vf,
13825 (void *)&cmd_set_vf_broadcast_broadcast,
13826 (void *)&cmd_set_vf_broadcast_port_id,
13827 (void *)&cmd_set_vf_broadcast_vf_id,
13828 (void *)&cmd_set_vf_broadcast_on_off,
13833 /* vf vlan tag configuration */
13835 /* Common result structure for vf vlan tag */
13836 struct cmd_set_vf_vlan_tag_result {
13837 cmdline_fixed_string_t set;
13838 cmdline_fixed_string_t vf;
13839 cmdline_fixed_string_t vlan;
13840 cmdline_fixed_string_t tag;
13843 cmdline_fixed_string_t on_off;
13846 /* Common CLI fields for vf vlan tag enable disable */
13847 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13848 TOKEN_STRING_INITIALIZER
13849 (struct cmd_set_vf_vlan_tag_result,
13851 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13852 TOKEN_STRING_INITIALIZER
13853 (struct cmd_set_vf_vlan_tag_result,
13855 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13856 TOKEN_STRING_INITIALIZER
13857 (struct cmd_set_vf_vlan_tag_result,
13859 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13860 TOKEN_STRING_INITIALIZER
13861 (struct cmd_set_vf_vlan_tag_result,
13863 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13864 TOKEN_NUM_INITIALIZER
13865 (struct cmd_set_vf_vlan_tag_result,
13867 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13868 TOKEN_NUM_INITIALIZER
13869 (struct cmd_set_vf_vlan_tag_result,
13871 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13872 TOKEN_STRING_INITIALIZER
13873 (struct cmd_set_vf_vlan_tag_result,
13877 cmd_set_vf_vlan_tag_parsed(
13878 void *parsed_result,
13879 __attribute__((unused)) struct cmdline *cl,
13880 __attribute__((unused)) void *data)
13882 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13883 int ret = -ENOTSUP;
13885 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13887 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13890 #ifdef RTE_LIBRTE_I40E_PMD
13891 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13892 res->vf_id, is_on);
13899 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13902 printf("invalid port_id %d\n", res->port_id);
13905 printf("function not implemented\n");
13908 printf("programming error: (%s)\n", strerror(-ret));
13912 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13913 .f = cmd_set_vf_vlan_tag_parsed,
13915 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13917 (void *)&cmd_set_vf_vlan_tag_set,
13918 (void *)&cmd_set_vf_vlan_tag_vf,
13919 (void *)&cmd_set_vf_vlan_tag_vlan,
13920 (void *)&cmd_set_vf_vlan_tag_tag,
13921 (void *)&cmd_set_vf_vlan_tag_port_id,
13922 (void *)&cmd_set_vf_vlan_tag_vf_id,
13923 (void *)&cmd_set_vf_vlan_tag_on_off,
13928 /* Common definition of VF and TC TX bandwidth configuration */
13929 struct cmd_vf_tc_bw_result {
13930 cmdline_fixed_string_t set;
13931 cmdline_fixed_string_t vf;
13932 cmdline_fixed_string_t tc;
13933 cmdline_fixed_string_t tx;
13934 cmdline_fixed_string_t min_bw;
13935 cmdline_fixed_string_t max_bw;
13936 cmdline_fixed_string_t strict_link_prio;
13941 cmdline_fixed_string_t bw_list;
13945 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13946 TOKEN_STRING_INITIALIZER
13947 (struct cmd_vf_tc_bw_result,
13949 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13950 TOKEN_STRING_INITIALIZER
13951 (struct cmd_vf_tc_bw_result,
13953 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13954 TOKEN_STRING_INITIALIZER
13955 (struct cmd_vf_tc_bw_result,
13957 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13958 TOKEN_STRING_INITIALIZER
13959 (struct cmd_vf_tc_bw_result,
13961 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13962 TOKEN_STRING_INITIALIZER
13963 (struct cmd_vf_tc_bw_result,
13964 strict_link_prio, "strict-link-priority");
13965 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13966 TOKEN_STRING_INITIALIZER
13967 (struct cmd_vf_tc_bw_result,
13968 min_bw, "min-bandwidth");
13969 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13970 TOKEN_STRING_INITIALIZER
13971 (struct cmd_vf_tc_bw_result,
13972 max_bw, "max-bandwidth");
13973 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13974 TOKEN_NUM_INITIALIZER
13975 (struct cmd_vf_tc_bw_result,
13977 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13978 TOKEN_NUM_INITIALIZER
13979 (struct cmd_vf_tc_bw_result,
13981 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13982 TOKEN_NUM_INITIALIZER
13983 (struct cmd_vf_tc_bw_result,
13985 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13986 TOKEN_NUM_INITIALIZER
13987 (struct cmd_vf_tc_bw_result,
13989 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13990 TOKEN_STRING_INITIALIZER
13991 (struct cmd_vf_tc_bw_result,
13993 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13994 TOKEN_NUM_INITIALIZER
13995 (struct cmd_vf_tc_bw_result,
13998 /* VF max bandwidth setting */
14000 cmd_vf_max_bw_parsed(
14001 void *parsed_result,
14002 __attribute__((unused)) struct cmdline *cl,
14003 __attribute__((unused)) void *data)
14005 struct cmd_vf_tc_bw_result *res = parsed_result;
14006 int ret = -ENOTSUP;
14008 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14011 #ifdef RTE_LIBRTE_I40E_PMD
14012 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14013 res->vf_id, res->bw);
14020 printf("invalid vf_id %d or bandwidth %d\n",
14021 res->vf_id, res->bw);
14024 printf("invalid port_id %d\n", res->port_id);
14027 printf("function not implemented\n");
14030 printf("programming error: (%s)\n", strerror(-ret));
14034 cmdline_parse_inst_t cmd_vf_max_bw = {
14035 .f = cmd_vf_max_bw_parsed,
14037 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14039 (void *)&cmd_vf_tc_bw_set,
14040 (void *)&cmd_vf_tc_bw_vf,
14041 (void *)&cmd_vf_tc_bw_tx,
14042 (void *)&cmd_vf_tc_bw_max_bw,
14043 (void *)&cmd_vf_tc_bw_port_id,
14044 (void *)&cmd_vf_tc_bw_vf_id,
14045 (void *)&cmd_vf_tc_bw_bw,
14051 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14056 const char *p, *p0 = str;
14063 p = strchr(p0, '(');
14065 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14069 p0 = strchr(p, ')');
14071 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14075 if (size >= sizeof(s)) {
14076 printf("The string size exceeds the internal buffer size\n");
14079 snprintf(s, sizeof(s), "%.*s", size, p);
14080 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14082 printf("Failed to get the bandwidth list. ");
14086 for (i = 0; i < ret; i++)
14087 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14092 /* TC min bandwidth setting */
14094 cmd_vf_tc_min_bw_parsed(
14095 void *parsed_result,
14096 __attribute__((unused)) struct cmdline *cl,
14097 __attribute__((unused)) void *data)
14099 struct cmd_vf_tc_bw_result *res = parsed_result;
14102 int ret = -ENOTSUP;
14104 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14107 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14111 #ifdef RTE_LIBRTE_I40E_PMD
14112 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14120 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14123 printf("invalid port_id %d\n", res->port_id);
14126 printf("function not implemented\n");
14129 printf("programming error: (%s)\n", strerror(-ret));
14133 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14134 .f = cmd_vf_tc_min_bw_parsed,
14136 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14137 " <bw1, bw2, ...>",
14139 (void *)&cmd_vf_tc_bw_set,
14140 (void *)&cmd_vf_tc_bw_vf,
14141 (void *)&cmd_vf_tc_bw_tc,
14142 (void *)&cmd_vf_tc_bw_tx,
14143 (void *)&cmd_vf_tc_bw_min_bw,
14144 (void *)&cmd_vf_tc_bw_port_id,
14145 (void *)&cmd_vf_tc_bw_vf_id,
14146 (void *)&cmd_vf_tc_bw_bw_list,
14152 cmd_tc_min_bw_parsed(
14153 void *parsed_result,
14154 __attribute__((unused)) struct cmdline *cl,
14155 __attribute__((unused)) void *data)
14157 struct cmd_vf_tc_bw_result *res = parsed_result;
14158 struct rte_port *port;
14161 int ret = -ENOTSUP;
14163 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14166 port = &ports[res->port_id];
14167 /** Check if the port is not started **/
14168 if (port->port_status != RTE_PORT_STOPPED) {
14169 printf("Please stop port %d first\n", res->port_id);
14173 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14177 #ifdef RTE_LIBRTE_IXGBE_PMD
14178 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14185 printf("invalid bandwidth\n");
14188 printf("invalid port_id %d\n", res->port_id);
14191 printf("function not implemented\n");
14194 printf("programming error: (%s)\n", strerror(-ret));
14198 cmdline_parse_inst_t cmd_tc_min_bw = {
14199 .f = cmd_tc_min_bw_parsed,
14201 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14203 (void *)&cmd_vf_tc_bw_set,
14204 (void *)&cmd_vf_tc_bw_tc,
14205 (void *)&cmd_vf_tc_bw_tx,
14206 (void *)&cmd_vf_tc_bw_min_bw,
14207 (void *)&cmd_vf_tc_bw_port_id,
14208 (void *)&cmd_vf_tc_bw_bw_list,
14213 /* TC max bandwidth setting */
14215 cmd_vf_tc_max_bw_parsed(
14216 void *parsed_result,
14217 __attribute__((unused)) struct cmdline *cl,
14218 __attribute__((unused)) void *data)
14220 struct cmd_vf_tc_bw_result *res = parsed_result;
14221 int ret = -ENOTSUP;
14223 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14226 #ifdef RTE_LIBRTE_I40E_PMD
14227 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14228 res->tc_no, res->bw);
14235 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14236 res->vf_id, res->tc_no, res->bw);
14239 printf("invalid port_id %d\n", res->port_id);
14242 printf("function not implemented\n");
14245 printf("programming error: (%s)\n", strerror(-ret));
14249 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14250 .f = cmd_vf_tc_max_bw_parsed,
14252 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14255 (void *)&cmd_vf_tc_bw_set,
14256 (void *)&cmd_vf_tc_bw_vf,
14257 (void *)&cmd_vf_tc_bw_tc,
14258 (void *)&cmd_vf_tc_bw_tx,
14259 (void *)&cmd_vf_tc_bw_max_bw,
14260 (void *)&cmd_vf_tc_bw_port_id,
14261 (void *)&cmd_vf_tc_bw_vf_id,
14262 (void *)&cmd_vf_tc_bw_tc_no,
14263 (void *)&cmd_vf_tc_bw_bw,
14269 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14271 /* *** Set Port default Traffic Management Hierarchy *** */
14272 struct cmd_set_port_tm_hierarchy_default_result {
14273 cmdline_fixed_string_t set;
14274 cmdline_fixed_string_t port;
14275 cmdline_fixed_string_t tm;
14276 cmdline_fixed_string_t hierarchy;
14277 cmdline_fixed_string_t def;
14281 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14282 TOKEN_STRING_INITIALIZER(
14283 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14284 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14285 TOKEN_STRING_INITIALIZER(
14286 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14287 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14288 TOKEN_STRING_INITIALIZER(
14289 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14290 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14291 TOKEN_STRING_INITIALIZER(
14292 struct cmd_set_port_tm_hierarchy_default_result,
14293 hierarchy, "hierarchy");
14294 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14295 TOKEN_STRING_INITIALIZER(
14296 struct cmd_set_port_tm_hierarchy_default_result,
14298 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14299 TOKEN_NUM_INITIALIZER(
14300 struct cmd_set_port_tm_hierarchy_default_result,
14303 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14304 __attribute__((unused)) struct cmdline *cl,
14305 __attribute__((unused)) void *data)
14307 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14308 struct rte_port *p;
14309 portid_t port_id = res->port_id;
14311 if (port_id_is_invalid(port_id, ENABLED_WARN))
14314 p = &ports[port_id];
14317 if (p->softport.tm_flag == 0) {
14318 printf(" tm not enabled on port %u (error)\n", port_id);
14322 /* Forward mode: tm */
14323 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14324 printf(" tm mode not enabled(error)\n");
14328 /* Set the default tm hierarchy */
14329 p->softport.tm.default_hierarchy_enable = 1;
14332 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14333 .f = cmd_set_port_tm_hierarchy_default_parsed,
14335 .help_str = "set port tm hierarchy default <port_id>",
14337 (void *)&cmd_set_port_tm_hierarchy_default_set,
14338 (void *)&cmd_set_port_tm_hierarchy_default_port,
14339 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14340 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14341 (void *)&cmd_set_port_tm_hierarchy_default_default,
14342 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14348 /* Strict link priority scheduling mode setting */
14350 cmd_strict_link_prio_parsed(
14351 void *parsed_result,
14352 __attribute__((unused)) struct cmdline *cl,
14353 __attribute__((unused)) void *data)
14355 struct cmd_vf_tc_bw_result *res = parsed_result;
14356 int ret = -ENOTSUP;
14358 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14361 #ifdef RTE_LIBRTE_I40E_PMD
14362 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14369 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14372 printf("invalid port_id %d\n", res->port_id);
14375 printf("function not implemented\n");
14378 printf("programming error: (%s)\n", strerror(-ret));
14382 cmdline_parse_inst_t cmd_strict_link_prio = {
14383 .f = cmd_strict_link_prio_parsed,
14385 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14387 (void *)&cmd_vf_tc_bw_set,
14388 (void *)&cmd_vf_tc_bw_tx,
14389 (void *)&cmd_vf_tc_bw_strict_link_prio,
14390 (void *)&cmd_vf_tc_bw_port_id,
14391 (void *)&cmd_vf_tc_bw_tc_map,
14396 /* Load dynamic device personalization*/
14397 struct cmd_ddp_add_result {
14398 cmdline_fixed_string_t ddp;
14399 cmdline_fixed_string_t add;
14404 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14405 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14406 cmdline_parse_token_string_t cmd_ddp_add_add =
14407 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14408 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14409 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14410 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14411 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14414 cmd_ddp_add_parsed(
14415 void *parsed_result,
14416 __attribute__((unused)) struct cmdline *cl,
14417 __attribute__((unused)) void *data)
14419 struct cmd_ddp_add_result *res = parsed_result;
14425 int ret = -ENOTSUP;
14427 if (res->port_id > nb_ports) {
14428 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14432 if (!all_ports_stopped()) {
14433 printf("Please stop all ports first\n");
14437 filepath = strdup(res->filepath);
14438 if (filepath == NULL) {
14439 printf("Failed to allocate memory\n");
14442 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14444 buff = open_file(file_fld[0], &size);
14446 free((void *)filepath);
14450 #ifdef RTE_LIBRTE_I40E_PMD
14451 if (ret == -ENOTSUP)
14452 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14454 RTE_PMD_I40E_PKG_OP_WR_ADD);
14457 if (ret == -EEXIST)
14458 printf("Profile has already existed.\n");
14460 printf("Failed to load profile.\n");
14461 else if (file_num == 2)
14462 save_file(file_fld[1], buff, size);
14465 free((void *)filepath);
14468 cmdline_parse_inst_t cmd_ddp_add = {
14469 .f = cmd_ddp_add_parsed,
14471 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14473 (void *)&cmd_ddp_add_ddp,
14474 (void *)&cmd_ddp_add_add,
14475 (void *)&cmd_ddp_add_port_id,
14476 (void *)&cmd_ddp_add_filepath,
14481 /* Delete dynamic device personalization*/
14482 struct cmd_ddp_del_result {
14483 cmdline_fixed_string_t ddp;
14484 cmdline_fixed_string_t del;
14489 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14490 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14491 cmdline_parse_token_string_t cmd_ddp_del_del =
14492 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14493 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14494 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14495 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14496 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14499 cmd_ddp_del_parsed(
14500 void *parsed_result,
14501 __attribute__((unused)) struct cmdline *cl,
14502 __attribute__((unused)) void *data)
14504 struct cmd_ddp_del_result *res = parsed_result;
14507 int ret = -ENOTSUP;
14509 if (res->port_id > nb_ports) {
14510 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14514 if (!all_ports_stopped()) {
14515 printf("Please stop all ports first\n");
14519 buff = open_file(res->filepath, &size);
14523 #ifdef RTE_LIBRTE_I40E_PMD
14524 if (ret == -ENOTSUP)
14525 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14527 RTE_PMD_I40E_PKG_OP_WR_DEL);
14530 if (ret == -EACCES)
14531 printf("Profile does not exist.\n");
14533 printf("Failed to delete profile.\n");
14538 cmdline_parse_inst_t cmd_ddp_del = {
14539 .f = cmd_ddp_del_parsed,
14541 .help_str = "ddp del <port_id> <profile_path>",
14543 (void *)&cmd_ddp_del_ddp,
14544 (void *)&cmd_ddp_del_del,
14545 (void *)&cmd_ddp_del_port_id,
14546 (void *)&cmd_ddp_del_filepath,
14551 /* Get dynamic device personalization profile info */
14552 struct cmd_ddp_info_result {
14553 cmdline_fixed_string_t ddp;
14554 cmdline_fixed_string_t get;
14555 cmdline_fixed_string_t info;
14559 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14560 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14561 cmdline_parse_token_string_t cmd_ddp_info_get =
14562 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14563 cmdline_parse_token_string_t cmd_ddp_info_info =
14564 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14565 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14566 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14569 cmd_ddp_info_parsed(
14570 void *parsed_result,
14571 __attribute__((unused)) struct cmdline *cl,
14572 __attribute__((unused)) void *data)
14574 struct cmd_ddp_info_result *res = parsed_result;
14577 int ret = -ENOTSUP;
14578 #ifdef RTE_LIBRTE_I40E_PMD
14581 uint32_t buff_size = 0;
14582 struct rte_pmd_i40e_profile_info info;
14583 uint32_t dev_num = 0;
14584 struct rte_pmd_i40e_ddp_device_id *devs;
14585 uint32_t proto_num = 0;
14586 struct rte_pmd_i40e_proto_info *proto = NULL;
14587 uint32_t pctype_num = 0;
14588 struct rte_pmd_i40e_ptype_info *pctype;
14589 uint32_t ptype_num = 0;
14590 struct rte_pmd_i40e_ptype_info *ptype;
14595 pkg = open_file(res->filepath, &pkg_size);
14599 #ifdef RTE_LIBRTE_I40E_PMD
14600 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14601 (uint8_t *)&info, sizeof(info),
14602 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14604 printf("Global Track id: 0x%x\n", info.track_id);
14605 printf("Global Version: %d.%d.%d.%d\n",
14606 info.version.major,
14607 info.version.minor,
14608 info.version.update,
14609 info.version.draft);
14610 printf("Global Package name: %s\n\n", info.name);
14613 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14614 (uint8_t *)&info, sizeof(info),
14615 RTE_PMD_I40E_PKG_INFO_HEADER);
14617 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14618 printf("i40e Profile Version: %d.%d.%d.%d\n",
14619 info.version.major,
14620 info.version.minor,
14621 info.version.update,
14622 info.version.draft);
14623 printf("i40e Profile name: %s\n\n", info.name);
14626 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14627 (uint8_t *)&buff_size, sizeof(buff_size),
14628 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14629 if (!ret && buff_size) {
14630 buff = (uint8_t *)malloc(buff_size);
14632 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14634 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14636 printf("Package Notes:\n%s\n\n", buff);
14641 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14642 (uint8_t *)&dev_num, sizeof(dev_num),
14643 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14644 if (!ret && dev_num) {
14645 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14646 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14648 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14649 (uint8_t *)devs, buff_size,
14650 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14652 printf("List of supported devices:\n");
14653 for (i = 0; i < dev_num; i++) {
14654 printf(" %04X:%04X %04X:%04X\n",
14655 devs[i].vendor_dev_id >> 16,
14656 devs[i].vendor_dev_id & 0xFFFF,
14657 devs[i].sub_vendor_dev_id >> 16,
14658 devs[i].sub_vendor_dev_id & 0xFFFF);
14666 /* get information about protocols and packet types */
14667 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14668 (uint8_t *)&proto_num, sizeof(proto_num),
14669 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14670 if (ret || !proto_num)
14671 goto no_print_return;
14673 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14674 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14676 goto no_print_return;
14678 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14680 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14682 printf("List of used protocols:\n");
14683 for (i = 0; i < proto_num; i++)
14684 printf(" %2u: %s\n", proto[i].proto_id,
14688 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14689 (uint8_t *)&pctype_num, sizeof(pctype_num),
14690 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14691 if (ret || !pctype_num)
14692 goto no_print_pctypes;
14694 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14695 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14697 goto no_print_pctypes;
14699 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14701 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14704 goto no_print_pctypes;
14707 printf("List of defined packet classification types:\n");
14708 for (i = 0; i < pctype_num; i++) {
14709 printf(" %2u:", pctype[i].ptype_id);
14710 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14711 proto_id = pctype[i].protocols[j];
14712 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14713 for (n = 0; n < proto_num; n++) {
14714 if (proto[n].proto_id == proto_id) {
14715 printf(" %s", proto[n].name);
14728 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14730 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14731 if (ret || !ptype_num)
14732 goto no_print_return;
14734 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14735 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14737 goto no_print_return;
14739 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14741 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14744 goto no_print_return;
14746 printf("List of defined packet types:\n");
14747 for (i = 0; i < ptype_num; i++) {
14748 printf(" %2u:", ptype[i].ptype_id);
14749 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14750 proto_id = ptype[i].protocols[j];
14751 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14752 for (n = 0; n < proto_num; n++) {
14753 if (proto[n].proto_id == proto_id) {
14754 printf(" %s", proto[n].name);
14770 if (ret == -ENOTSUP)
14771 printf("Function not supported in PMD driver\n");
14775 cmdline_parse_inst_t cmd_ddp_get_info = {
14776 .f = cmd_ddp_info_parsed,
14778 .help_str = "ddp get info <profile_path>",
14780 (void *)&cmd_ddp_info_ddp,
14781 (void *)&cmd_ddp_info_get,
14782 (void *)&cmd_ddp_info_info,
14783 (void *)&cmd_ddp_info_filepath,
14788 /* Get dynamic device personalization profile info list*/
14789 #define PROFILE_INFO_SIZE 48
14790 #define MAX_PROFILE_NUM 16
14792 struct cmd_ddp_get_list_result {
14793 cmdline_fixed_string_t ddp;
14794 cmdline_fixed_string_t get;
14795 cmdline_fixed_string_t list;
14799 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14800 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14801 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14802 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14803 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14804 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14805 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14806 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14809 cmd_ddp_get_list_parsed(
14810 void *parsed_result,
14811 __attribute__((unused)) struct cmdline *cl,
14812 __attribute__((unused)) void *data)
14814 struct cmd_ddp_get_list_result *res = parsed_result;
14815 #ifdef RTE_LIBRTE_I40E_PMD
14816 struct rte_pmd_i40e_profile_list *p_list;
14817 struct rte_pmd_i40e_profile_info *p_info;
14822 int ret = -ENOTSUP;
14824 if (res->port_id > nb_ports) {
14825 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14829 #ifdef RTE_LIBRTE_I40E_PMD
14830 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14831 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14833 printf("%s: Failed to malloc buffer\n", __func__);
14835 if (ret == -ENOTSUP)
14836 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14837 (uint8_t *)p_list, size);
14840 p_num = p_list->p_count;
14841 printf("Profile number is: %d\n\n", p_num);
14843 for (i = 0; i < p_num; i++) {
14844 p_info = &p_list->p_info[i];
14845 printf("Profile %d:\n", i);
14846 printf("Track id: 0x%x\n", p_info->track_id);
14847 printf("Version: %d.%d.%d.%d\n",
14848 p_info->version.major,
14849 p_info->version.minor,
14850 p_info->version.update,
14851 p_info->version.draft);
14852 printf("Profile name: %s\n\n", p_info->name);
14860 printf("Failed to get ddp list\n");
14863 cmdline_parse_inst_t cmd_ddp_get_list = {
14864 .f = cmd_ddp_get_list_parsed,
14866 .help_str = "ddp get list <port_id>",
14868 (void *)&cmd_ddp_get_list_ddp,
14869 (void *)&cmd_ddp_get_list_get,
14870 (void *)&cmd_ddp_get_list_list,
14871 (void *)&cmd_ddp_get_list_port_id,
14876 /* show vf stats */
14878 /* Common result structure for show vf stats */
14879 struct cmd_show_vf_stats_result {
14880 cmdline_fixed_string_t show;
14881 cmdline_fixed_string_t vf;
14882 cmdline_fixed_string_t stats;
14887 /* Common CLI fields show vf stats*/
14888 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14889 TOKEN_STRING_INITIALIZER
14890 (struct cmd_show_vf_stats_result,
14892 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14893 TOKEN_STRING_INITIALIZER
14894 (struct cmd_show_vf_stats_result,
14896 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14897 TOKEN_STRING_INITIALIZER
14898 (struct cmd_show_vf_stats_result,
14900 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14901 TOKEN_NUM_INITIALIZER
14902 (struct cmd_show_vf_stats_result,
14904 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14905 TOKEN_NUM_INITIALIZER
14906 (struct cmd_show_vf_stats_result,
14910 cmd_show_vf_stats_parsed(
14911 void *parsed_result,
14912 __attribute__((unused)) struct cmdline *cl,
14913 __attribute__((unused)) void *data)
14915 struct cmd_show_vf_stats_result *res = parsed_result;
14916 struct rte_eth_stats stats;
14917 int ret = -ENOTSUP;
14918 static const char *nic_stats_border = "########################";
14920 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14923 memset(&stats, 0, sizeof(stats));
14925 #ifdef RTE_LIBRTE_I40E_PMD
14926 if (ret == -ENOTSUP)
14927 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14931 #ifdef RTE_LIBRTE_BNXT_PMD
14932 if (ret == -ENOTSUP)
14933 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14942 printf("invalid vf_id %d\n", res->vf_id);
14945 printf("invalid port_id %d\n", res->port_id);
14948 printf("function not implemented\n");
14951 printf("programming error: (%s)\n", strerror(-ret));
14954 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14955 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14957 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14959 stats.ipackets, stats.imissed, stats.ibytes);
14960 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14961 printf(" RX-nombuf: %-10"PRIu64"\n",
14963 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14965 stats.opackets, stats.oerrors, stats.obytes);
14967 printf(" %s############################%s\n",
14968 nic_stats_border, nic_stats_border);
14971 cmdline_parse_inst_t cmd_show_vf_stats = {
14972 .f = cmd_show_vf_stats_parsed,
14974 .help_str = "show vf stats <port_id> <vf_id>",
14976 (void *)&cmd_show_vf_stats_show,
14977 (void *)&cmd_show_vf_stats_vf,
14978 (void *)&cmd_show_vf_stats_stats,
14979 (void *)&cmd_show_vf_stats_port_id,
14980 (void *)&cmd_show_vf_stats_vf_id,
14985 /* clear vf stats */
14987 /* Common result structure for clear vf stats */
14988 struct cmd_clear_vf_stats_result {
14989 cmdline_fixed_string_t clear;
14990 cmdline_fixed_string_t vf;
14991 cmdline_fixed_string_t stats;
14996 /* Common CLI fields clear vf stats*/
14997 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14998 TOKEN_STRING_INITIALIZER
14999 (struct cmd_clear_vf_stats_result,
15001 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15002 TOKEN_STRING_INITIALIZER
15003 (struct cmd_clear_vf_stats_result,
15005 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15006 TOKEN_STRING_INITIALIZER
15007 (struct cmd_clear_vf_stats_result,
15009 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15010 TOKEN_NUM_INITIALIZER
15011 (struct cmd_clear_vf_stats_result,
15013 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15014 TOKEN_NUM_INITIALIZER
15015 (struct cmd_clear_vf_stats_result,
15019 cmd_clear_vf_stats_parsed(
15020 void *parsed_result,
15021 __attribute__((unused)) struct cmdline *cl,
15022 __attribute__((unused)) void *data)
15024 struct cmd_clear_vf_stats_result *res = parsed_result;
15025 int ret = -ENOTSUP;
15027 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15030 #ifdef RTE_LIBRTE_I40E_PMD
15031 if (ret == -ENOTSUP)
15032 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15035 #ifdef RTE_LIBRTE_BNXT_PMD
15036 if (ret == -ENOTSUP)
15037 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15045 printf("invalid vf_id %d\n", res->vf_id);
15048 printf("invalid port_id %d\n", res->port_id);
15051 printf("function not implemented\n");
15054 printf("programming error: (%s)\n", strerror(-ret));
15058 cmdline_parse_inst_t cmd_clear_vf_stats = {
15059 .f = cmd_clear_vf_stats_parsed,
15061 .help_str = "clear vf stats <port_id> <vf_id>",
15063 (void *)&cmd_clear_vf_stats_clear,
15064 (void *)&cmd_clear_vf_stats_vf,
15065 (void *)&cmd_clear_vf_stats_stats,
15066 (void *)&cmd_clear_vf_stats_port_id,
15067 (void *)&cmd_clear_vf_stats_vf_id,
15072 /* port config pctype mapping reset */
15074 /* Common result structure for port config pctype mapping reset */
15075 struct cmd_pctype_mapping_reset_result {
15076 cmdline_fixed_string_t port;
15077 cmdline_fixed_string_t config;
15079 cmdline_fixed_string_t pctype;
15080 cmdline_fixed_string_t mapping;
15081 cmdline_fixed_string_t reset;
15084 /* Common CLI fields for port config pctype mapping reset*/
15085 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15086 TOKEN_STRING_INITIALIZER
15087 (struct cmd_pctype_mapping_reset_result,
15089 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15090 TOKEN_STRING_INITIALIZER
15091 (struct cmd_pctype_mapping_reset_result,
15093 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15094 TOKEN_NUM_INITIALIZER
15095 (struct cmd_pctype_mapping_reset_result,
15097 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15098 TOKEN_STRING_INITIALIZER
15099 (struct cmd_pctype_mapping_reset_result,
15101 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15102 TOKEN_STRING_INITIALIZER
15103 (struct cmd_pctype_mapping_reset_result,
15104 mapping, "mapping");
15105 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15106 TOKEN_STRING_INITIALIZER
15107 (struct cmd_pctype_mapping_reset_result,
15111 cmd_pctype_mapping_reset_parsed(
15112 void *parsed_result,
15113 __attribute__((unused)) struct cmdline *cl,
15114 __attribute__((unused)) void *data)
15116 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15117 int ret = -ENOTSUP;
15119 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15122 #ifdef RTE_LIBRTE_I40E_PMD
15123 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15130 printf("invalid port_id %d\n", res->port_id);
15133 printf("function not implemented\n");
15136 printf("programming error: (%s)\n", strerror(-ret));
15140 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15141 .f = cmd_pctype_mapping_reset_parsed,
15143 .help_str = "port config <port_id> pctype mapping reset",
15145 (void *)&cmd_pctype_mapping_reset_port,
15146 (void *)&cmd_pctype_mapping_reset_config,
15147 (void *)&cmd_pctype_mapping_reset_port_id,
15148 (void *)&cmd_pctype_mapping_reset_pctype,
15149 (void *)&cmd_pctype_mapping_reset_mapping,
15150 (void *)&cmd_pctype_mapping_reset_reset,
15155 /* show port pctype mapping */
15157 /* Common result structure for show port pctype mapping */
15158 struct cmd_pctype_mapping_get_result {
15159 cmdline_fixed_string_t show;
15160 cmdline_fixed_string_t port;
15162 cmdline_fixed_string_t pctype;
15163 cmdline_fixed_string_t mapping;
15166 /* Common CLI fields for pctype mapping get */
15167 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15168 TOKEN_STRING_INITIALIZER
15169 (struct cmd_pctype_mapping_get_result,
15171 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15172 TOKEN_STRING_INITIALIZER
15173 (struct cmd_pctype_mapping_get_result,
15175 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15176 TOKEN_NUM_INITIALIZER
15177 (struct cmd_pctype_mapping_get_result,
15179 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15180 TOKEN_STRING_INITIALIZER
15181 (struct cmd_pctype_mapping_get_result,
15183 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15184 TOKEN_STRING_INITIALIZER
15185 (struct cmd_pctype_mapping_get_result,
15186 mapping, "mapping");
15189 cmd_pctype_mapping_get_parsed(
15190 void *parsed_result,
15191 __attribute__((unused)) struct cmdline *cl,
15192 __attribute__((unused)) void *data)
15194 struct cmd_pctype_mapping_get_result *res = parsed_result;
15195 int ret = -ENOTSUP;
15196 #ifdef RTE_LIBRTE_I40E_PMD
15197 struct rte_pmd_i40e_flow_type_mapping
15198 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15199 int i, j, first_pctype;
15202 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15205 #ifdef RTE_LIBRTE_I40E_PMD
15206 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15213 printf("invalid port_id %d\n", res->port_id);
15216 printf("function not implemented\n");
15219 printf("programming error: (%s)\n", strerror(-ret));
15223 #ifdef RTE_LIBRTE_I40E_PMD
15224 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15225 if (mapping[i].pctype != 0ULL) {
15228 printf("pctype: ");
15229 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15230 if (mapping[i].pctype & (1ULL << j)) {
15231 printf(first_pctype ?
15232 "%02d" : ",%02d", j);
15236 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15242 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15243 .f = cmd_pctype_mapping_get_parsed,
15245 .help_str = "show port <port_id> pctype mapping",
15247 (void *)&cmd_pctype_mapping_get_show,
15248 (void *)&cmd_pctype_mapping_get_port,
15249 (void *)&cmd_pctype_mapping_get_port_id,
15250 (void *)&cmd_pctype_mapping_get_pctype,
15251 (void *)&cmd_pctype_mapping_get_mapping,
15256 /* port config pctype mapping update */
15258 /* Common result structure for port config pctype mapping update */
15259 struct cmd_pctype_mapping_update_result {
15260 cmdline_fixed_string_t port;
15261 cmdline_fixed_string_t config;
15263 cmdline_fixed_string_t pctype;
15264 cmdline_fixed_string_t mapping;
15265 cmdline_fixed_string_t update;
15266 cmdline_fixed_string_t pctype_list;
15267 uint16_t flow_type;
15270 /* Common CLI fields for pctype mapping update*/
15271 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15272 TOKEN_STRING_INITIALIZER
15273 (struct cmd_pctype_mapping_update_result,
15275 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15276 TOKEN_STRING_INITIALIZER
15277 (struct cmd_pctype_mapping_update_result,
15279 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15280 TOKEN_NUM_INITIALIZER
15281 (struct cmd_pctype_mapping_update_result,
15283 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15284 TOKEN_STRING_INITIALIZER
15285 (struct cmd_pctype_mapping_update_result,
15287 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15288 TOKEN_STRING_INITIALIZER
15289 (struct cmd_pctype_mapping_update_result,
15290 mapping, "mapping");
15291 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15292 TOKEN_STRING_INITIALIZER
15293 (struct cmd_pctype_mapping_update_result,
15295 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15296 TOKEN_STRING_INITIALIZER
15297 (struct cmd_pctype_mapping_update_result,
15298 pctype_list, NULL);
15299 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15300 TOKEN_NUM_INITIALIZER
15301 (struct cmd_pctype_mapping_update_result,
15302 flow_type, UINT16);
15305 cmd_pctype_mapping_update_parsed(
15306 void *parsed_result,
15307 __attribute__((unused)) struct cmdline *cl,
15308 __attribute__((unused)) void *data)
15310 struct cmd_pctype_mapping_update_result *res = parsed_result;
15311 int ret = -ENOTSUP;
15312 #ifdef RTE_LIBRTE_I40E_PMD
15313 struct rte_pmd_i40e_flow_type_mapping mapping;
15315 unsigned int nb_item;
15316 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15319 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15322 #ifdef RTE_LIBRTE_I40E_PMD
15323 nb_item = parse_item_list(res->pctype_list, "pctypes",
15324 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15325 mapping.flow_type = res->flow_type;
15326 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15327 mapping.pctype |= (1ULL << pctype_list[i]);
15328 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15338 printf("invalid pctype or flow type\n");
15341 printf("invalid port_id %d\n", res->port_id);
15344 printf("function not implemented\n");
15347 printf("programming error: (%s)\n", strerror(-ret));
15351 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15352 .f = cmd_pctype_mapping_update_parsed,
15354 .help_str = "port config <port_id> pctype mapping update"
15355 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15357 (void *)&cmd_pctype_mapping_update_port,
15358 (void *)&cmd_pctype_mapping_update_config,
15359 (void *)&cmd_pctype_mapping_update_port_id,
15360 (void *)&cmd_pctype_mapping_update_pctype,
15361 (void *)&cmd_pctype_mapping_update_mapping,
15362 (void *)&cmd_pctype_mapping_update_update,
15363 (void *)&cmd_pctype_mapping_update_pc_type,
15364 (void *)&cmd_pctype_mapping_update_flow_type,
15369 /* ptype mapping get */
15371 /* Common result structure for ptype mapping get */
15372 struct cmd_ptype_mapping_get_result {
15373 cmdline_fixed_string_t ptype;
15374 cmdline_fixed_string_t mapping;
15375 cmdline_fixed_string_t get;
15377 uint8_t valid_only;
15380 /* Common CLI fields for ptype mapping get */
15381 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15382 TOKEN_STRING_INITIALIZER
15383 (struct cmd_ptype_mapping_get_result,
15385 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15386 TOKEN_STRING_INITIALIZER
15387 (struct cmd_ptype_mapping_get_result,
15388 mapping, "mapping");
15389 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15390 TOKEN_STRING_INITIALIZER
15391 (struct cmd_ptype_mapping_get_result,
15393 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15394 TOKEN_NUM_INITIALIZER
15395 (struct cmd_ptype_mapping_get_result,
15397 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15398 TOKEN_NUM_INITIALIZER
15399 (struct cmd_ptype_mapping_get_result,
15400 valid_only, UINT8);
15403 cmd_ptype_mapping_get_parsed(
15404 void *parsed_result,
15405 __attribute__((unused)) struct cmdline *cl,
15406 __attribute__((unused)) void *data)
15408 struct cmd_ptype_mapping_get_result *res = parsed_result;
15409 int ret = -ENOTSUP;
15410 #ifdef RTE_LIBRTE_I40E_PMD
15411 int max_ptype_num = 256;
15412 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15417 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15420 #ifdef RTE_LIBRTE_I40E_PMD
15421 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15432 printf("invalid port_id %d\n", res->port_id);
15435 printf("function not implemented\n");
15438 printf("programming error: (%s)\n", strerror(-ret));
15441 #ifdef RTE_LIBRTE_I40E_PMD
15443 for (i = 0; i < count; i++)
15444 printf("%3d\t0x%08x\n",
15445 mapping[i].hw_ptype, mapping[i].sw_ptype);
15450 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15451 .f = cmd_ptype_mapping_get_parsed,
15453 .help_str = "ptype mapping get <port_id> <valid_only>",
15455 (void *)&cmd_ptype_mapping_get_ptype,
15456 (void *)&cmd_ptype_mapping_get_mapping,
15457 (void *)&cmd_ptype_mapping_get_get,
15458 (void *)&cmd_ptype_mapping_get_port_id,
15459 (void *)&cmd_ptype_mapping_get_valid_only,
15464 /* ptype mapping replace */
15466 /* Common result structure for ptype mapping replace */
15467 struct cmd_ptype_mapping_replace_result {
15468 cmdline_fixed_string_t ptype;
15469 cmdline_fixed_string_t mapping;
15470 cmdline_fixed_string_t replace;
15477 /* Common CLI fields for ptype mapping replace */
15478 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15479 TOKEN_STRING_INITIALIZER
15480 (struct cmd_ptype_mapping_replace_result,
15482 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15483 TOKEN_STRING_INITIALIZER
15484 (struct cmd_ptype_mapping_replace_result,
15485 mapping, "mapping");
15486 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15487 TOKEN_STRING_INITIALIZER
15488 (struct cmd_ptype_mapping_replace_result,
15489 replace, "replace");
15490 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15491 TOKEN_NUM_INITIALIZER
15492 (struct cmd_ptype_mapping_replace_result,
15494 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15495 TOKEN_NUM_INITIALIZER
15496 (struct cmd_ptype_mapping_replace_result,
15498 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15499 TOKEN_NUM_INITIALIZER
15500 (struct cmd_ptype_mapping_replace_result,
15502 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15503 TOKEN_NUM_INITIALIZER
15504 (struct cmd_ptype_mapping_replace_result,
15508 cmd_ptype_mapping_replace_parsed(
15509 void *parsed_result,
15510 __attribute__((unused)) struct cmdline *cl,
15511 __attribute__((unused)) void *data)
15513 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15514 int ret = -ENOTSUP;
15516 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15519 #ifdef RTE_LIBRTE_I40E_PMD
15520 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15530 printf("invalid ptype 0x%8x or 0x%8x\n",
15531 res->target, res->pkt_type);
15534 printf("invalid port_id %d\n", res->port_id);
15537 printf("function not implemented\n");
15540 printf("programming error: (%s)\n", strerror(-ret));
15544 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15545 .f = cmd_ptype_mapping_replace_parsed,
15548 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15550 (void *)&cmd_ptype_mapping_replace_ptype,
15551 (void *)&cmd_ptype_mapping_replace_mapping,
15552 (void *)&cmd_ptype_mapping_replace_replace,
15553 (void *)&cmd_ptype_mapping_replace_port_id,
15554 (void *)&cmd_ptype_mapping_replace_target,
15555 (void *)&cmd_ptype_mapping_replace_mask,
15556 (void *)&cmd_ptype_mapping_replace_pkt_type,
15561 /* ptype mapping reset */
15563 /* Common result structure for ptype mapping reset */
15564 struct cmd_ptype_mapping_reset_result {
15565 cmdline_fixed_string_t ptype;
15566 cmdline_fixed_string_t mapping;
15567 cmdline_fixed_string_t reset;
15571 /* Common CLI fields for ptype mapping reset*/
15572 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15573 TOKEN_STRING_INITIALIZER
15574 (struct cmd_ptype_mapping_reset_result,
15576 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15577 TOKEN_STRING_INITIALIZER
15578 (struct cmd_ptype_mapping_reset_result,
15579 mapping, "mapping");
15580 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15581 TOKEN_STRING_INITIALIZER
15582 (struct cmd_ptype_mapping_reset_result,
15584 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15585 TOKEN_NUM_INITIALIZER
15586 (struct cmd_ptype_mapping_reset_result,
15590 cmd_ptype_mapping_reset_parsed(
15591 void *parsed_result,
15592 __attribute__((unused)) struct cmdline *cl,
15593 __attribute__((unused)) void *data)
15595 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15596 int ret = -ENOTSUP;
15598 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15601 #ifdef RTE_LIBRTE_I40E_PMD
15602 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15609 printf("invalid port_id %d\n", res->port_id);
15612 printf("function not implemented\n");
15615 printf("programming error: (%s)\n", strerror(-ret));
15619 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15620 .f = cmd_ptype_mapping_reset_parsed,
15622 .help_str = "ptype mapping reset <port_id>",
15624 (void *)&cmd_ptype_mapping_reset_ptype,
15625 (void *)&cmd_ptype_mapping_reset_mapping,
15626 (void *)&cmd_ptype_mapping_reset_reset,
15627 (void *)&cmd_ptype_mapping_reset_port_id,
15632 /* ptype mapping update */
15634 /* Common result structure for ptype mapping update */
15635 struct cmd_ptype_mapping_update_result {
15636 cmdline_fixed_string_t ptype;
15637 cmdline_fixed_string_t mapping;
15638 cmdline_fixed_string_t reset;
15644 /* Common CLI fields for ptype mapping update*/
15645 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15646 TOKEN_STRING_INITIALIZER
15647 (struct cmd_ptype_mapping_update_result,
15649 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15650 TOKEN_STRING_INITIALIZER
15651 (struct cmd_ptype_mapping_update_result,
15652 mapping, "mapping");
15653 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15654 TOKEN_STRING_INITIALIZER
15655 (struct cmd_ptype_mapping_update_result,
15657 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15658 TOKEN_NUM_INITIALIZER
15659 (struct cmd_ptype_mapping_update_result,
15661 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15662 TOKEN_NUM_INITIALIZER
15663 (struct cmd_ptype_mapping_update_result,
15665 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15666 TOKEN_NUM_INITIALIZER
15667 (struct cmd_ptype_mapping_update_result,
15671 cmd_ptype_mapping_update_parsed(
15672 void *parsed_result,
15673 __attribute__((unused)) struct cmdline *cl,
15674 __attribute__((unused)) void *data)
15676 struct cmd_ptype_mapping_update_result *res = parsed_result;
15677 int ret = -ENOTSUP;
15678 #ifdef RTE_LIBRTE_I40E_PMD
15679 struct rte_pmd_i40e_ptype_mapping mapping;
15681 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15684 #ifdef RTE_LIBRTE_I40E_PMD
15685 mapping.hw_ptype = res->hw_ptype;
15686 mapping.sw_ptype = res->sw_ptype;
15687 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15697 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15700 printf("invalid port_id %d\n", res->port_id);
15703 printf("function not implemented\n");
15706 printf("programming error: (%s)\n", strerror(-ret));
15710 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15711 .f = cmd_ptype_mapping_update_parsed,
15713 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15715 (void *)&cmd_ptype_mapping_update_ptype,
15716 (void *)&cmd_ptype_mapping_update_mapping,
15717 (void *)&cmd_ptype_mapping_update_update,
15718 (void *)&cmd_ptype_mapping_update_port_id,
15719 (void *)&cmd_ptype_mapping_update_hw_ptype,
15720 (void *)&cmd_ptype_mapping_update_sw_ptype,
15725 /* Common result structure for file commands */
15726 struct cmd_cmdfile_result {
15727 cmdline_fixed_string_t load;
15728 cmdline_fixed_string_t filename;
15731 /* Common CLI fields for file commands */
15732 cmdline_parse_token_string_t cmd_load_cmdfile =
15733 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15734 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15735 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15738 cmd_load_from_file_parsed(
15739 void *parsed_result,
15740 __attribute__((unused)) struct cmdline *cl,
15741 __attribute__((unused)) void *data)
15743 struct cmd_cmdfile_result *res = parsed_result;
15745 cmdline_read_from_file(res->filename);
15748 cmdline_parse_inst_t cmd_load_from_file = {
15749 .f = cmd_load_from_file_parsed,
15751 .help_str = "load <filename>",
15753 (void *)&cmd_load_cmdfile,
15754 (void *)&cmd_load_cmdfile_filename,
15759 /* ******************************************************************************** */
15761 /* list of instructions */
15762 cmdline_parse_ctx_t main_ctx[] = {
15763 (cmdline_parse_inst_t *)&cmd_help_brief,
15764 (cmdline_parse_inst_t *)&cmd_help_long,
15765 (cmdline_parse_inst_t *)&cmd_quit,
15766 (cmdline_parse_inst_t *)&cmd_load_from_file,
15767 (cmdline_parse_inst_t *)&cmd_showport,
15768 (cmdline_parse_inst_t *)&cmd_showqueue,
15769 (cmdline_parse_inst_t *)&cmd_showportall,
15770 (cmdline_parse_inst_t *)&cmd_showcfg,
15771 (cmdline_parse_inst_t *)&cmd_start,
15772 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15773 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15774 (cmdline_parse_inst_t *)&cmd_set_link_up,
15775 (cmdline_parse_inst_t *)&cmd_set_link_down,
15776 (cmdline_parse_inst_t *)&cmd_reset,
15777 (cmdline_parse_inst_t *)&cmd_set_numbers,
15778 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15779 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15780 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15781 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15782 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15783 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15784 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15785 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15786 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15787 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15788 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15789 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15790 (cmdline_parse_inst_t *)&cmd_set_link_check,
15791 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15792 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15793 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15794 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15795 #ifdef RTE_LIBRTE_PMD_BOND
15796 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15797 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15798 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15799 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15800 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15801 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15802 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15803 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15804 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15805 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15806 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15808 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15809 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15810 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15811 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15812 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15813 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15814 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15815 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15816 (cmdline_parse_inst_t *)&cmd_csum_set,
15817 (cmdline_parse_inst_t *)&cmd_csum_show,
15818 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15819 (cmdline_parse_inst_t *)&cmd_tso_set,
15820 (cmdline_parse_inst_t *)&cmd_tso_show,
15821 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15822 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15823 (cmdline_parse_inst_t *)&cmd_gro_enable,
15824 (cmdline_parse_inst_t *)&cmd_gro_flush,
15825 (cmdline_parse_inst_t *)&cmd_gro_show,
15826 (cmdline_parse_inst_t *)&cmd_gso_enable,
15827 (cmdline_parse_inst_t *)&cmd_gso_size,
15828 (cmdline_parse_inst_t *)&cmd_gso_show,
15829 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15830 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15831 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15832 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15833 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15834 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15835 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15836 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15837 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15838 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15839 (cmdline_parse_inst_t *)&cmd_config_dcb,
15840 (cmdline_parse_inst_t *)&cmd_read_reg,
15841 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15842 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15843 (cmdline_parse_inst_t *)&cmd_write_reg,
15844 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15845 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15846 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15847 (cmdline_parse_inst_t *)&cmd_stop,
15848 (cmdline_parse_inst_t *)&cmd_mac_addr,
15849 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
15850 (cmdline_parse_inst_t *)&cmd_set_qmap,
15851 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
15852 (cmdline_parse_inst_t *)&cmd_operate_port,
15853 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15854 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15855 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15856 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15857 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15858 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15859 (cmdline_parse_inst_t *)&cmd_config_mtu,
15860 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15861 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15862 (cmdline_parse_inst_t *)&cmd_config_rss,
15863 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15864 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15865 (cmdline_parse_inst_t *)&cmd_showport_reta,
15866 (cmdline_parse_inst_t *)&cmd_config_burst,
15867 (cmdline_parse_inst_t *)&cmd_config_thresh,
15868 (cmdline_parse_inst_t *)&cmd_config_threshold,
15869 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15870 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15871 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15872 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15873 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15874 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15875 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15876 (cmdline_parse_inst_t *)&cmd_global_config,
15877 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15878 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15879 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15880 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15881 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15882 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15883 (cmdline_parse_inst_t *)&cmd_dump,
15884 (cmdline_parse_inst_t *)&cmd_dump_one,
15885 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15886 (cmdline_parse_inst_t *)&cmd_syn_filter,
15887 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15888 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15889 (cmdline_parse_inst_t *)&cmd_flex_filter,
15890 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15891 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15892 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15893 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15894 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15895 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15896 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
15897 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15898 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15899 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15900 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15901 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15902 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15903 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15904 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15905 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15906 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15907 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15908 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15909 (cmdline_parse_inst_t *)&cmd_flow,
15910 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
15911 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15912 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15913 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15914 (cmdline_parse_inst_t *)&cmd_create_port_meter,
15915 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
15916 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
15917 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15918 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15919 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
15920 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15921 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15922 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15923 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15924 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15925 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15926 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15927 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15928 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15929 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15930 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15931 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15932 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15933 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15934 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15935 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15936 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15937 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15938 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15939 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15940 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15941 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15942 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15943 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15944 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15945 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15946 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15947 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15948 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15949 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15950 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15951 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15952 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15953 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15954 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15955 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15956 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15957 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15958 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15959 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15960 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15962 (cmdline_parse_inst_t *)&cmd_ddp_add,
15963 (cmdline_parse_inst_t *)&cmd_ddp_del,
15964 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15965 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15966 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15967 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15968 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15969 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15970 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15971 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15973 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15974 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15975 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15976 (cmdline_parse_inst_t *)&cmd_queue_region,
15977 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15978 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15979 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15980 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15981 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15982 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15983 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15984 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15985 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15986 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15987 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15988 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15989 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15990 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15991 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15992 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
15993 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
15994 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
15995 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
15996 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
15997 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16001 /* read cmdline commands from file */
16003 cmdline_read_from_file(const char *filename)
16005 struct cmdline *cl;
16007 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16009 printf("Failed to create file based cmdline context: %s\n",
16014 cmdline_interact(cl);
16019 printf("Read CLI commands from %s\n", filename);
16022 /* prompt function, called from main on MASTER lcore */
16026 /* initialize non-constant commands */
16027 cmd_set_fwd_mode_init();
16028 cmd_set_fwd_retry_mode_init();
16030 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16031 if (testpmd_cl == NULL)
16033 cmdline_interact(testpmd_cl);
16034 cmdline_stdin_exit(testpmd_cl);
16040 if (testpmd_cl != NULL)
16041 cmdline_quit(testpmd_cl);
16045 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16047 if (id == (portid_t)RTE_PORT_ALL) {
16050 RTE_ETH_FOREACH_DEV(pid) {
16051 /* check if need_reconfig has been set to 1 */
16052 if (ports[pid].need_reconfig == 0)
16053 ports[pid].need_reconfig = dev;
16054 /* check if need_reconfig_queues has been set to 1 */
16055 if (ports[pid].need_reconfig_queues == 0)
16056 ports[pid].need_reconfig_queues = queue;
16058 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16059 /* check if need_reconfig has been set to 1 */
16060 if (ports[id].need_reconfig == 0)
16061 ports[id].need_reconfig = dev;
16062 /* check if need_reconfig_queues has been set to 1 */
16063 if (ports[id].need_reconfig_queues == 0)
16064 ports[id].need_reconfig_queues = queue;