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 "flush_flow_director (port_id)\n"
1003 " Flush all flow director entries of a device.\n\n"
1005 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1006 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1007 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1008 " Set flow director IP mask.\n\n"
1010 "flow_director_mask (port_id) mode MAC-VLAN"
1011 " vlan (vlan_value)\n"
1012 " Set flow director MAC-VLAN mask.\n\n"
1014 "flow_director_mask (port_id) mode Tunnel"
1015 " vlan (vlan_value) mac (mac_value)"
1016 " tunnel-type (tunnel_type_value)"
1017 " tunnel-id (tunnel_id_value)\n"
1018 " Set flow director Tunnel mask.\n\n"
1020 "flow_director_flex_mask (port_id)"
1021 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1022 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1024 " Configure mask of flex payload.\n\n"
1026 "flow_director_flex_payload (port_id)"
1027 " (raw|l2|l3|l4) (config)\n"
1028 " Configure flex payload selection.\n\n"
1030 "get_sym_hash_ena_per_port (port_id)\n"
1031 " get symmetric hash enable configuration per port.\n\n"
1033 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1034 " set symmetric hash enable configuration per port"
1035 " to enable or disable.\n\n"
1037 "get_hash_global_config (port_id)\n"
1038 " Get the global configurations of hash filters.\n\n"
1040 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1041 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1042 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1043 " (enable|disable)\n"
1044 " Set the global configurations of hash filters.\n\n"
1046 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1047 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1048 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1049 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1050 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1051 "ipv6-next-header|udp-src-port|udp-dst-port|"
1052 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1053 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1054 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1055 "fld-8th|none) (select|add)\n"
1056 " Set the input set for hash.\n\n"
1058 "set_fdir_input_set (port_id) "
1059 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1060 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1061 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1062 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1063 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1064 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1065 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1067 " Set the input set for FDir.\n\n"
1069 "flow validate {port_id}"
1070 " [group {group_id}] [priority {level}]"
1071 " [ingress] [egress]"
1072 " pattern {item} [/ {item} [...]] / end"
1073 " actions {action} [/ {action} [...]] / end\n"
1074 " Check whether a flow rule can be created.\n\n"
1076 "flow create {port_id}"
1077 " [group {group_id}] [priority {level}]"
1078 " [ingress] [egress]"
1079 " pattern {item} [/ {item} [...]] / end"
1080 " actions {action} [/ {action} [...]] / end\n"
1081 " Create a flow rule.\n\n"
1083 "flow destroy {port_id} rule {rule_id} [...]\n"
1084 " Destroy specific flow rules.\n\n"
1086 "flow flush {port_id}\n"
1087 " Destroy all flow rules.\n\n"
1089 "flow query {port_id} {rule_id} {action}\n"
1090 " Query an existing flow rule.\n\n"
1092 "flow list {port_id} [group {group_id}] [...]\n"
1093 " List existing flow rules sorted by priority,"
1094 " filtered by group identifiers.\n\n"
1096 "flow isolate {port_id} {boolean}\n"
1097 " Restrict ingress traffic to the defined"
1103 cmdline_parse_token_string_t cmd_help_long_help =
1104 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1106 cmdline_parse_token_string_t cmd_help_long_section =
1107 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1108 "all#control#display#config#"
1109 "ports#registers#filters");
1111 cmdline_parse_inst_t cmd_help_long = {
1112 .f = cmd_help_long_parsed,
1114 .help_str = "help all|control|display|config|ports|register|filters: "
1117 (void *)&cmd_help_long_help,
1118 (void *)&cmd_help_long_section,
1124 /* *** start/stop/close all ports *** */
1125 struct cmd_operate_port_result {
1126 cmdline_fixed_string_t keyword;
1127 cmdline_fixed_string_t name;
1128 cmdline_fixed_string_t value;
1131 static void cmd_operate_port_parsed(void *parsed_result,
1132 __attribute__((unused)) struct cmdline *cl,
1133 __attribute__((unused)) void *data)
1135 struct cmd_operate_port_result *res = parsed_result;
1137 if (!strcmp(res->name, "start"))
1138 start_port(RTE_PORT_ALL);
1139 else if (!strcmp(res->name, "stop"))
1140 stop_port(RTE_PORT_ALL);
1141 else if (!strcmp(res->name, "close"))
1142 close_port(RTE_PORT_ALL);
1143 else if (!strcmp(res->name, "reset"))
1144 reset_port(RTE_PORT_ALL);
1146 printf("Unknown parameter\n");
1149 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1150 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1152 cmdline_parse_token_string_t cmd_operate_port_all_port =
1153 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1154 "start#stop#close#reset");
1155 cmdline_parse_token_string_t cmd_operate_port_all_all =
1156 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1158 cmdline_parse_inst_t cmd_operate_port = {
1159 .f = cmd_operate_port_parsed,
1161 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1163 (void *)&cmd_operate_port_all_cmd,
1164 (void *)&cmd_operate_port_all_port,
1165 (void *)&cmd_operate_port_all_all,
1170 /* *** start/stop/close specific port *** */
1171 struct cmd_operate_specific_port_result {
1172 cmdline_fixed_string_t keyword;
1173 cmdline_fixed_string_t name;
1177 static void cmd_operate_specific_port_parsed(void *parsed_result,
1178 __attribute__((unused)) struct cmdline *cl,
1179 __attribute__((unused)) void *data)
1181 struct cmd_operate_specific_port_result *res = parsed_result;
1183 if (!strcmp(res->name, "start"))
1184 start_port(res->value);
1185 else if (!strcmp(res->name, "stop"))
1186 stop_port(res->value);
1187 else if (!strcmp(res->name, "close"))
1188 close_port(res->value);
1189 else if (!strcmp(res->name, "reset"))
1190 reset_port(res->value);
1192 printf("Unknown parameter\n");
1195 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1196 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1198 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1199 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1200 name, "start#stop#close#reset");
1201 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1202 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1205 cmdline_parse_inst_t cmd_operate_specific_port = {
1206 .f = cmd_operate_specific_port_parsed,
1208 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1210 (void *)&cmd_operate_specific_port_cmd,
1211 (void *)&cmd_operate_specific_port_port,
1212 (void *)&cmd_operate_specific_port_id,
1217 /* *** attach a specified port *** */
1218 struct cmd_operate_attach_port_result {
1219 cmdline_fixed_string_t port;
1220 cmdline_fixed_string_t keyword;
1221 cmdline_fixed_string_t identifier;
1224 static void cmd_operate_attach_port_parsed(void *parsed_result,
1225 __attribute__((unused)) struct cmdline *cl,
1226 __attribute__((unused)) void *data)
1228 struct cmd_operate_attach_port_result *res = parsed_result;
1230 if (!strcmp(res->keyword, "attach"))
1231 attach_port(res->identifier);
1233 printf("Unknown parameter\n");
1236 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1237 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1239 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1240 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1242 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1243 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1246 cmdline_parse_inst_t cmd_operate_attach_port = {
1247 .f = cmd_operate_attach_port_parsed,
1249 .help_str = "port attach <identifier>: "
1250 "(identifier: pci address or virtual dev name)",
1252 (void *)&cmd_operate_attach_port_port,
1253 (void *)&cmd_operate_attach_port_keyword,
1254 (void *)&cmd_operate_attach_port_identifier,
1259 /* *** detach a specified port *** */
1260 struct cmd_operate_detach_port_result {
1261 cmdline_fixed_string_t port;
1262 cmdline_fixed_string_t keyword;
1266 static void cmd_operate_detach_port_parsed(void *parsed_result,
1267 __attribute__((unused)) struct cmdline *cl,
1268 __attribute__((unused)) void *data)
1270 struct cmd_operate_detach_port_result *res = parsed_result;
1272 if (!strcmp(res->keyword, "detach"))
1273 detach_port(res->port_id);
1275 printf("Unknown parameter\n");
1278 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1279 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1281 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1282 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1284 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1285 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1288 cmdline_parse_inst_t cmd_operate_detach_port = {
1289 .f = cmd_operate_detach_port_parsed,
1291 .help_str = "port detach <port_id>",
1293 (void *)&cmd_operate_detach_port_port,
1294 (void *)&cmd_operate_detach_port_keyword,
1295 (void *)&cmd_operate_detach_port_port_id,
1300 /* *** configure speed for all ports *** */
1301 struct cmd_config_speed_all {
1302 cmdline_fixed_string_t port;
1303 cmdline_fixed_string_t keyword;
1304 cmdline_fixed_string_t all;
1305 cmdline_fixed_string_t item1;
1306 cmdline_fixed_string_t item2;
1307 cmdline_fixed_string_t value1;
1308 cmdline_fixed_string_t value2;
1312 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1317 if (!strcmp(duplexstr, "half")) {
1318 duplex = ETH_LINK_HALF_DUPLEX;
1319 } else if (!strcmp(duplexstr, "full")) {
1320 duplex = ETH_LINK_FULL_DUPLEX;
1321 } else if (!strcmp(duplexstr, "auto")) {
1322 duplex = ETH_LINK_FULL_DUPLEX;
1324 printf("Unknown duplex parameter\n");
1328 if (!strcmp(speedstr, "10")) {
1329 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1330 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1331 } else if (!strcmp(speedstr, "100")) {
1332 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1333 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1335 if (duplex != ETH_LINK_FULL_DUPLEX) {
1336 printf("Invalid speed/duplex parameters\n");
1339 if (!strcmp(speedstr, "1000")) {
1340 *speed = ETH_LINK_SPEED_1G;
1341 } else if (!strcmp(speedstr, "10000")) {
1342 *speed = ETH_LINK_SPEED_10G;
1343 } else if (!strcmp(speedstr, "25000")) {
1344 *speed = ETH_LINK_SPEED_25G;
1345 } else if (!strcmp(speedstr, "40000")) {
1346 *speed = ETH_LINK_SPEED_40G;
1347 } else if (!strcmp(speedstr, "50000")) {
1348 *speed = ETH_LINK_SPEED_50G;
1349 } else if (!strcmp(speedstr, "100000")) {
1350 *speed = ETH_LINK_SPEED_100G;
1351 } else if (!strcmp(speedstr, "auto")) {
1352 *speed = ETH_LINK_SPEED_AUTONEG;
1354 printf("Unknown speed parameter\n");
1363 cmd_config_speed_all_parsed(void *parsed_result,
1364 __attribute__((unused)) struct cmdline *cl,
1365 __attribute__((unused)) void *data)
1367 struct cmd_config_speed_all *res = parsed_result;
1368 uint32_t link_speed;
1371 if (!all_ports_stopped()) {
1372 printf("Please stop all ports first\n");
1376 if (parse_and_check_speed_duplex(res->value1, res->value2,
1380 RTE_ETH_FOREACH_DEV(pid) {
1381 ports[pid].dev_conf.link_speeds = link_speed;
1384 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1387 cmdline_parse_token_string_t cmd_config_speed_all_port =
1388 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1389 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1390 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1392 cmdline_parse_token_string_t cmd_config_speed_all_all =
1393 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1394 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1395 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1396 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1397 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1398 "10#100#1000#10000#25000#40000#50000#100000#auto");
1399 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1400 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1401 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1402 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1405 cmdline_parse_inst_t cmd_config_speed_all = {
1406 .f = cmd_config_speed_all_parsed,
1408 .help_str = "port config all speed "
1409 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1412 (void *)&cmd_config_speed_all_port,
1413 (void *)&cmd_config_speed_all_keyword,
1414 (void *)&cmd_config_speed_all_all,
1415 (void *)&cmd_config_speed_all_item1,
1416 (void *)&cmd_config_speed_all_value1,
1417 (void *)&cmd_config_speed_all_item2,
1418 (void *)&cmd_config_speed_all_value2,
1423 /* *** configure speed for specific port *** */
1424 struct cmd_config_speed_specific {
1425 cmdline_fixed_string_t port;
1426 cmdline_fixed_string_t keyword;
1428 cmdline_fixed_string_t item1;
1429 cmdline_fixed_string_t item2;
1430 cmdline_fixed_string_t value1;
1431 cmdline_fixed_string_t value2;
1435 cmd_config_speed_specific_parsed(void *parsed_result,
1436 __attribute__((unused)) struct cmdline *cl,
1437 __attribute__((unused)) void *data)
1439 struct cmd_config_speed_specific *res = parsed_result;
1440 uint32_t link_speed;
1442 if (!all_ports_stopped()) {
1443 printf("Please stop all ports first\n");
1447 if (port_id_is_invalid(res->id, ENABLED_WARN))
1450 if (parse_and_check_speed_duplex(res->value1, res->value2,
1454 ports[res->id].dev_conf.link_speeds = link_speed;
1456 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1460 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1461 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1463 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1464 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1466 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1467 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1468 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1471 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1473 "10#100#1000#10000#25000#40000#50000#100000#auto");
1474 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1475 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1477 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1478 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1481 cmdline_parse_inst_t cmd_config_speed_specific = {
1482 .f = cmd_config_speed_specific_parsed,
1484 .help_str = "port config <port_id> speed "
1485 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1488 (void *)&cmd_config_speed_specific_port,
1489 (void *)&cmd_config_speed_specific_keyword,
1490 (void *)&cmd_config_speed_specific_id,
1491 (void *)&cmd_config_speed_specific_item1,
1492 (void *)&cmd_config_speed_specific_value1,
1493 (void *)&cmd_config_speed_specific_item2,
1494 (void *)&cmd_config_speed_specific_value2,
1499 /* *** configure txq/rxq, txd/rxd *** */
1500 struct cmd_config_rx_tx {
1501 cmdline_fixed_string_t port;
1502 cmdline_fixed_string_t keyword;
1503 cmdline_fixed_string_t all;
1504 cmdline_fixed_string_t name;
1509 cmd_config_rx_tx_parsed(void *parsed_result,
1510 __attribute__((unused)) struct cmdline *cl,
1511 __attribute__((unused)) void *data)
1513 struct cmd_config_rx_tx *res = parsed_result;
1515 if (!all_ports_stopped()) {
1516 printf("Please stop all ports first\n");
1519 if (!strcmp(res->name, "rxq")) {
1520 if (!res->value && !nb_txq) {
1521 printf("Warning: Either rx or tx queues should be non zero\n");
1524 nb_rxq = res->value;
1526 else if (!strcmp(res->name, "txq")) {
1527 if (!res->value && !nb_rxq) {
1528 printf("Warning: Either rx or tx queues should be non zero\n");
1531 nb_txq = res->value;
1533 else if (!strcmp(res->name, "rxd")) {
1534 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1535 printf("rxd %d invalid - must be > 0 && <= %d\n",
1536 res->value, RTE_TEST_RX_DESC_MAX);
1539 nb_rxd = res->value;
1540 } else if (!strcmp(res->name, "txd")) {
1541 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1542 printf("txd %d invalid - must be > 0 && <= %d\n",
1543 res->value, RTE_TEST_TX_DESC_MAX);
1546 nb_txd = res->value;
1548 printf("Unknown parameter\n");
1556 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1559 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1560 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1561 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1563 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1564 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1565 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1566 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1568 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1569 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1571 cmdline_parse_inst_t cmd_config_rx_tx = {
1572 .f = cmd_config_rx_tx_parsed,
1574 .help_str = "port config all rxq|txq|rxd|txd <value>",
1576 (void *)&cmd_config_rx_tx_port,
1577 (void *)&cmd_config_rx_tx_keyword,
1578 (void *)&cmd_config_rx_tx_all,
1579 (void *)&cmd_config_rx_tx_name,
1580 (void *)&cmd_config_rx_tx_value,
1585 /* *** config max packet length *** */
1586 struct cmd_config_max_pkt_len_result {
1587 cmdline_fixed_string_t port;
1588 cmdline_fixed_string_t keyword;
1589 cmdline_fixed_string_t all;
1590 cmdline_fixed_string_t name;
1595 cmd_config_max_pkt_len_parsed(void *parsed_result,
1596 __attribute__((unused)) struct cmdline *cl,
1597 __attribute__((unused)) void *data)
1599 struct cmd_config_max_pkt_len_result *res = parsed_result;
1602 if (!all_ports_stopped()) {
1603 printf("Please stop all ports first\n");
1607 RTE_ETH_FOREACH_DEV(pid) {
1608 struct rte_port *port = &ports[pid];
1609 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1611 if (!strcmp(res->name, "max-pkt-len")) {
1612 if (res->value < ETHER_MIN_LEN) {
1613 printf("max-pkt-len can not be less than %d\n",
1617 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1620 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1621 if (res->value > ETHER_MAX_LEN)
1622 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1624 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1625 port->dev_conf.rxmode.offloads = rx_offloads;
1627 printf("Unknown parameter\n");
1634 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1637 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1638 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1640 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1641 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1643 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1644 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1646 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1647 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1649 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1650 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1653 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1654 .f = cmd_config_max_pkt_len_parsed,
1656 .help_str = "port config all max-pkt-len <value>",
1658 (void *)&cmd_config_max_pkt_len_port,
1659 (void *)&cmd_config_max_pkt_len_keyword,
1660 (void *)&cmd_config_max_pkt_len_all,
1661 (void *)&cmd_config_max_pkt_len_name,
1662 (void *)&cmd_config_max_pkt_len_value,
1667 /* *** configure port MTU *** */
1668 struct cmd_config_mtu_result {
1669 cmdline_fixed_string_t port;
1670 cmdline_fixed_string_t keyword;
1671 cmdline_fixed_string_t mtu;
1677 cmd_config_mtu_parsed(void *parsed_result,
1678 __attribute__((unused)) struct cmdline *cl,
1679 __attribute__((unused)) void *data)
1681 struct cmd_config_mtu_result *res = parsed_result;
1683 if (res->value < ETHER_MIN_LEN) {
1684 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1687 port_mtu_set(res->port_id, res->value);
1690 cmdline_parse_token_string_t cmd_config_mtu_port =
1691 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1693 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1694 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1696 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1697 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1699 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1700 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1701 cmdline_parse_token_num_t cmd_config_mtu_value =
1702 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1704 cmdline_parse_inst_t cmd_config_mtu = {
1705 .f = cmd_config_mtu_parsed,
1707 .help_str = "port config mtu <port_id> <value>",
1709 (void *)&cmd_config_mtu_port,
1710 (void *)&cmd_config_mtu_keyword,
1711 (void *)&cmd_config_mtu_mtu,
1712 (void *)&cmd_config_mtu_port_id,
1713 (void *)&cmd_config_mtu_value,
1718 /* *** configure rx mode *** */
1719 struct cmd_config_rx_mode_flag {
1720 cmdline_fixed_string_t port;
1721 cmdline_fixed_string_t keyword;
1722 cmdline_fixed_string_t all;
1723 cmdline_fixed_string_t name;
1724 cmdline_fixed_string_t value;
1728 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1729 __attribute__((unused)) struct cmdline *cl,
1730 __attribute__((unused)) void *data)
1732 struct cmd_config_rx_mode_flag *res = parsed_result;
1735 if (!all_ports_stopped()) {
1736 printf("Please stop all ports first\n");
1740 RTE_ETH_FOREACH_DEV(pid) {
1741 struct rte_port *port;
1742 uint64_t rx_offloads;
1745 rx_offloads = port->dev_conf.rxmode.offloads;
1746 if (!strcmp(res->name, "crc-strip")) {
1747 if (!strcmp(res->value, "on"))
1748 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1749 else if (!strcmp(res->value, "off"))
1750 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1752 printf("Unknown parameter\n");
1755 } else if (!strcmp(res->name, "scatter")) {
1756 if (!strcmp(res->value, "on")) {
1757 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1758 } else if (!strcmp(res->value, "off")) {
1759 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1761 printf("Unknown parameter\n");
1764 } else if (!strcmp(res->name, "rx-cksum")) {
1765 if (!strcmp(res->value, "on"))
1766 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1767 else if (!strcmp(res->value, "off"))
1768 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1770 printf("Unknown parameter\n");
1773 } else if (!strcmp(res->name, "rx-timestamp")) {
1774 if (!strcmp(res->value, "on"))
1775 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1776 else if (!strcmp(res->value, "off"))
1777 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1779 printf("Unknown parameter\n");
1782 } else if (!strcmp(res->name, "hw-vlan")) {
1783 if (!strcmp(res->value, "on")) {
1784 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1785 DEV_RX_OFFLOAD_VLAN_STRIP);
1786 } else if (!strcmp(res->value, "off")) {
1787 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1788 DEV_RX_OFFLOAD_VLAN_STRIP);
1790 printf("Unknown parameter\n");
1793 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1794 if (!strcmp(res->value, "on"))
1795 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1796 else if (!strcmp(res->value, "off"))
1797 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1799 printf("Unknown parameter\n");
1802 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1803 if (!strcmp(res->value, "on"))
1804 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1805 else if (!strcmp(res->value, "off"))
1806 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1808 printf("Unknown parameter\n");
1811 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1812 if (!strcmp(res->value, "on"))
1813 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1814 else if (!strcmp(res->value, "off"))
1815 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1817 printf("Unknown parameter\n");
1820 } else if (!strcmp(res->name, "drop-en")) {
1821 if (!strcmp(res->value, "on"))
1823 else if (!strcmp(res->value, "off"))
1826 printf("Unknown parameter\n");
1830 printf("Unknown parameter\n");
1833 port->dev_conf.rxmode.offloads = rx_offloads;
1838 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1841 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1842 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1843 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1844 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1846 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1848 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1849 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1850 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1851 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1852 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1853 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1856 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1857 .f = cmd_config_rx_mode_flag_parsed,
1859 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1860 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1862 (void *)&cmd_config_rx_mode_flag_port,
1863 (void *)&cmd_config_rx_mode_flag_keyword,
1864 (void *)&cmd_config_rx_mode_flag_all,
1865 (void *)&cmd_config_rx_mode_flag_name,
1866 (void *)&cmd_config_rx_mode_flag_value,
1871 /* *** configure rss *** */
1872 struct cmd_config_rss {
1873 cmdline_fixed_string_t port;
1874 cmdline_fixed_string_t keyword;
1875 cmdline_fixed_string_t all;
1876 cmdline_fixed_string_t name;
1877 cmdline_fixed_string_t value;
1881 cmd_config_rss_parsed(void *parsed_result,
1882 __attribute__((unused)) struct cmdline *cl,
1883 __attribute__((unused)) void *data)
1885 struct cmd_config_rss *res = parsed_result;
1886 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1890 if (!strcmp(res->value, "all"))
1891 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1892 ETH_RSS_UDP | ETH_RSS_SCTP |
1894 else if (!strcmp(res->value, "ip"))
1895 rss_conf.rss_hf = ETH_RSS_IP;
1896 else if (!strcmp(res->value, "udp"))
1897 rss_conf.rss_hf = ETH_RSS_UDP;
1898 else if (!strcmp(res->value, "tcp"))
1899 rss_conf.rss_hf = ETH_RSS_TCP;
1900 else if (!strcmp(res->value, "sctp"))
1901 rss_conf.rss_hf = ETH_RSS_SCTP;
1902 else if (!strcmp(res->value, "ether"))
1903 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1904 else if (!strcmp(res->value, "port"))
1905 rss_conf.rss_hf = ETH_RSS_PORT;
1906 else if (!strcmp(res->value, "vxlan"))
1907 rss_conf.rss_hf = ETH_RSS_VXLAN;
1908 else if (!strcmp(res->value, "geneve"))
1909 rss_conf.rss_hf = ETH_RSS_GENEVE;
1910 else if (!strcmp(res->value, "nvgre"))
1911 rss_conf.rss_hf = ETH_RSS_NVGRE;
1912 else if (!strcmp(res->value, "none"))
1913 rss_conf.rss_hf = 0;
1914 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1915 atoi(res->value) < 64)
1916 rss_conf.rss_hf = 1ULL << atoi(res->value);
1918 printf("Unknown parameter\n");
1921 rss_conf.rss_key = NULL;
1922 for (i = 0; i < rte_eth_dev_count(); i++) {
1923 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1925 printf("Configuration of RSS hash at ethernet port %d "
1926 "failed with error (%d): %s.\n",
1927 i, -diag, strerror(-diag));
1931 cmdline_parse_token_string_t cmd_config_rss_port =
1932 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1933 cmdline_parse_token_string_t cmd_config_rss_keyword =
1934 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1935 cmdline_parse_token_string_t cmd_config_rss_all =
1936 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1937 cmdline_parse_token_string_t cmd_config_rss_name =
1938 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1939 cmdline_parse_token_string_t cmd_config_rss_value =
1940 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1942 cmdline_parse_inst_t cmd_config_rss = {
1943 .f = cmd_config_rss_parsed,
1945 .help_str = "port config all rss "
1946 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1948 (void *)&cmd_config_rss_port,
1949 (void *)&cmd_config_rss_keyword,
1950 (void *)&cmd_config_rss_all,
1951 (void *)&cmd_config_rss_name,
1952 (void *)&cmd_config_rss_value,
1957 /* *** configure rss hash key *** */
1958 struct cmd_config_rss_hash_key {
1959 cmdline_fixed_string_t port;
1960 cmdline_fixed_string_t config;
1962 cmdline_fixed_string_t rss_hash_key;
1963 cmdline_fixed_string_t rss_type;
1964 cmdline_fixed_string_t key;
1968 hexa_digit_to_value(char hexa_digit)
1970 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1971 return (uint8_t) (hexa_digit - '0');
1972 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1973 return (uint8_t) ((hexa_digit - 'a') + 10);
1974 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1975 return (uint8_t) ((hexa_digit - 'A') + 10);
1976 /* Invalid hexa digit */
1981 parse_and_check_key_hexa_digit(char *key, int idx)
1985 hexa_v = hexa_digit_to_value(key[idx]);
1987 printf("invalid key: character %c at position %d is not a "
1988 "valid hexa digit\n", key[idx], idx);
1993 cmd_config_rss_hash_key_parsed(void *parsed_result,
1994 __attribute__((unused)) struct cmdline *cl,
1995 __attribute__((unused)) void *data)
1997 struct cmd_config_rss_hash_key *res = parsed_result;
1998 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2002 struct rte_eth_dev_info dev_info;
2003 uint8_t hash_key_size;
2006 memset(&dev_info, 0, sizeof(dev_info));
2007 rte_eth_dev_info_get(res->port_id, &dev_info);
2008 if (dev_info.hash_key_size > 0 &&
2009 dev_info.hash_key_size <= sizeof(hash_key))
2010 hash_key_size = dev_info.hash_key_size;
2012 printf("dev_info did not provide a valid hash key size\n");
2015 /* Check the length of the RSS hash key */
2016 key_len = strlen(res->key);
2017 if (key_len != (hash_key_size * 2)) {
2018 printf("key length: %d invalid - key must be a string of %d"
2019 " hexa-decimal numbers\n",
2020 (int) key_len, hash_key_size * 2);
2023 /* Translate RSS hash key into binary representation */
2024 for (i = 0; i < hash_key_size; i++) {
2025 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2028 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2031 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2033 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2037 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2038 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2039 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2040 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2042 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2043 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2044 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2045 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2046 rss_hash_key, "rss-hash-key");
2047 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2048 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2049 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2050 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2051 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2052 "ipv6-tcp-ex#ipv6-udp-ex");
2053 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2054 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2056 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2057 .f = cmd_config_rss_hash_key_parsed,
2059 .help_str = "port config <port_id> rss-hash-key "
2060 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2061 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2062 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2063 "<string of hex digits (variable length, NIC dependent)>",
2065 (void *)&cmd_config_rss_hash_key_port,
2066 (void *)&cmd_config_rss_hash_key_config,
2067 (void *)&cmd_config_rss_hash_key_port_id,
2068 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2069 (void *)&cmd_config_rss_hash_key_rss_type,
2070 (void *)&cmd_config_rss_hash_key_value,
2075 /* *** configure port rxq/txq start/stop *** */
2076 struct cmd_config_rxtx_queue {
2077 cmdline_fixed_string_t port;
2079 cmdline_fixed_string_t rxtxq;
2081 cmdline_fixed_string_t opname;
2085 cmd_config_rxtx_queue_parsed(void *parsed_result,
2086 __attribute__((unused)) struct cmdline *cl,
2087 __attribute__((unused)) void *data)
2089 struct cmd_config_rxtx_queue *res = parsed_result;
2094 if (test_done == 0) {
2095 printf("Please stop forwarding first\n");
2099 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2102 if (port_is_started(res->portid) != 1) {
2103 printf("Please start port %u first\n", res->portid);
2107 if (!strcmp(res->rxtxq, "rxq"))
2109 else if (!strcmp(res->rxtxq, "txq"))
2112 printf("Unknown parameter\n");
2116 if (isrx && rx_queue_id_is_invalid(res->qid))
2118 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2121 if (!strcmp(res->opname, "start"))
2123 else if (!strcmp(res->opname, "stop"))
2126 printf("Unknown parameter\n");
2130 if (isstart && isrx)
2131 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2132 else if (!isstart && isrx)
2133 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2134 else if (isstart && !isrx)
2135 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2137 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2139 if (ret == -ENOTSUP)
2140 printf("Function not supported in PMD driver\n");
2143 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2144 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2145 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2146 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2147 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2148 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2149 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2150 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2151 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2152 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2155 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2156 .f = cmd_config_rxtx_queue_parsed,
2158 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2160 (void *)&cmd_config_speed_all_port,
2161 (void *)&cmd_config_rxtx_queue_portid,
2162 (void *)&cmd_config_rxtx_queue_rxtxq,
2163 (void *)&cmd_config_rxtx_queue_qid,
2164 (void *)&cmd_config_rxtx_queue_opname,
2169 /* *** Configure RSS RETA *** */
2170 struct cmd_config_rss_reta {
2171 cmdline_fixed_string_t port;
2172 cmdline_fixed_string_t keyword;
2174 cmdline_fixed_string_t name;
2175 cmdline_fixed_string_t list_name;
2176 cmdline_fixed_string_t list_of_items;
2180 parse_reta_config(const char *str,
2181 struct rte_eth_rss_reta_entry64 *reta_conf,
2182 uint16_t nb_entries)
2186 uint16_t hash_index, idx, shift;
2189 const char *p, *p0 = str;
2196 unsigned long int_fld[_NUM_FLD];
2197 char *str_fld[_NUM_FLD];
2199 while ((p = strchr(p0,'(')) != NULL) {
2201 if((p0 = strchr(p,')')) == NULL)
2205 if(size >= sizeof(s))
2208 snprintf(s, sizeof(s), "%.*s", size, p);
2209 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2211 for (i = 0; i < _NUM_FLD; i++) {
2213 int_fld[i] = strtoul(str_fld[i], &end, 0);
2214 if (errno != 0 || end == str_fld[i] ||
2219 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2220 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2222 if (hash_index >= nb_entries) {
2223 printf("Invalid RETA hash index=%d\n", hash_index);
2227 idx = hash_index / RTE_RETA_GROUP_SIZE;
2228 shift = hash_index % RTE_RETA_GROUP_SIZE;
2229 reta_conf[idx].mask |= (1ULL << shift);
2230 reta_conf[idx].reta[shift] = nb_queue;
2237 cmd_set_rss_reta_parsed(void *parsed_result,
2238 __attribute__((unused)) struct cmdline *cl,
2239 __attribute__((unused)) void *data)
2242 struct rte_eth_dev_info dev_info;
2243 struct rte_eth_rss_reta_entry64 reta_conf[8];
2244 struct cmd_config_rss_reta *res = parsed_result;
2246 memset(&dev_info, 0, sizeof(dev_info));
2247 rte_eth_dev_info_get(res->port_id, &dev_info);
2248 if (dev_info.reta_size == 0) {
2249 printf("Redirection table size is 0 which is "
2250 "invalid for RSS\n");
2253 printf("The reta size of port %d is %u\n",
2254 res->port_id, dev_info.reta_size);
2255 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2256 printf("Currently do not support more than %u entries of "
2257 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2261 memset(reta_conf, 0, sizeof(reta_conf));
2262 if (!strcmp(res->list_name, "reta")) {
2263 if (parse_reta_config(res->list_of_items, reta_conf,
2264 dev_info.reta_size)) {
2265 printf("Invalid RSS Redirection Table "
2266 "config entered\n");
2269 ret = rte_eth_dev_rss_reta_update(res->port_id,
2270 reta_conf, dev_info.reta_size);
2272 printf("Bad redirection table parameter, "
2273 "return code = %d \n", ret);
2277 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2278 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2279 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2280 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2281 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2282 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2283 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2284 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2285 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2286 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2287 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2288 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2290 cmdline_parse_inst_t cmd_config_rss_reta = {
2291 .f = cmd_set_rss_reta_parsed,
2293 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2295 (void *)&cmd_config_rss_reta_port,
2296 (void *)&cmd_config_rss_reta_keyword,
2297 (void *)&cmd_config_rss_reta_port_id,
2298 (void *)&cmd_config_rss_reta_name,
2299 (void *)&cmd_config_rss_reta_list_name,
2300 (void *)&cmd_config_rss_reta_list_of_items,
2305 /* *** SHOW PORT RETA INFO *** */
2306 struct cmd_showport_reta {
2307 cmdline_fixed_string_t show;
2308 cmdline_fixed_string_t port;
2310 cmdline_fixed_string_t rss;
2311 cmdline_fixed_string_t reta;
2313 cmdline_fixed_string_t list_of_items;
2317 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2318 uint16_t nb_entries,
2322 const char *p, *p0 = str;
2327 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2328 RTE_RETA_GROUP_SIZE;
2331 p = strchr(p0, '(');
2335 p0 = strchr(p, ')');
2339 if (size >= sizeof(s)) {
2340 printf("The string size exceeds the internal buffer size\n");
2343 snprintf(s, sizeof(s), "%.*s", size, p);
2344 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2345 if (ret <= 0 || ret != num) {
2346 printf("The bits of masks do not match the number of "
2347 "reta entries: %u\n", num);
2350 for (i = 0; i < ret; i++)
2351 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2357 cmd_showport_reta_parsed(void *parsed_result,
2358 __attribute__((unused)) struct cmdline *cl,
2359 __attribute__((unused)) void *data)
2361 struct cmd_showport_reta *res = parsed_result;
2362 struct rte_eth_rss_reta_entry64 reta_conf[8];
2363 struct rte_eth_dev_info dev_info;
2364 uint16_t max_reta_size;
2366 memset(&dev_info, 0, sizeof(dev_info));
2367 rte_eth_dev_info_get(res->port_id, &dev_info);
2368 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2369 if (res->size == 0 || res->size > max_reta_size) {
2370 printf("Invalid redirection table size: %u (1-%u)\n",
2371 res->size, max_reta_size);
2375 memset(reta_conf, 0, sizeof(reta_conf));
2376 if (showport_parse_reta_config(reta_conf, res->size,
2377 res->list_of_items) < 0) {
2378 printf("Invalid string: %s for reta masks\n",
2379 res->list_of_items);
2382 port_rss_reta_info(res->port_id, reta_conf, res->size);
2385 cmdline_parse_token_string_t cmd_showport_reta_show =
2386 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2387 cmdline_parse_token_string_t cmd_showport_reta_port =
2388 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2389 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2390 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2391 cmdline_parse_token_string_t cmd_showport_reta_rss =
2392 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2393 cmdline_parse_token_string_t cmd_showport_reta_reta =
2394 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2395 cmdline_parse_token_num_t cmd_showport_reta_size =
2396 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2397 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2398 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2399 list_of_items, NULL);
2401 cmdline_parse_inst_t cmd_showport_reta = {
2402 .f = cmd_showport_reta_parsed,
2404 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2406 (void *)&cmd_showport_reta_show,
2407 (void *)&cmd_showport_reta_port,
2408 (void *)&cmd_showport_reta_port_id,
2409 (void *)&cmd_showport_reta_rss,
2410 (void *)&cmd_showport_reta_reta,
2411 (void *)&cmd_showport_reta_size,
2412 (void *)&cmd_showport_reta_list_of_items,
2417 /* *** Show RSS hash configuration *** */
2418 struct cmd_showport_rss_hash {
2419 cmdline_fixed_string_t show;
2420 cmdline_fixed_string_t port;
2422 cmdline_fixed_string_t rss_hash;
2423 cmdline_fixed_string_t rss_type;
2424 cmdline_fixed_string_t key; /* optional argument */
2427 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2428 __attribute__((unused)) struct cmdline *cl,
2431 struct cmd_showport_rss_hash *res = parsed_result;
2433 port_rss_hash_conf_show(res->port_id, res->rss_type,
2434 show_rss_key != NULL);
2437 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2438 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2439 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2440 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2441 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2442 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2443 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2444 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2446 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2447 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2448 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2449 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2450 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2451 "ipv6-tcp-ex#ipv6-udp-ex");
2452 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2453 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2455 cmdline_parse_inst_t cmd_showport_rss_hash = {
2456 .f = cmd_showport_rss_hash_parsed,
2458 .help_str = "show port <port_id> rss-hash "
2459 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2460 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2461 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2463 (void *)&cmd_showport_rss_hash_show,
2464 (void *)&cmd_showport_rss_hash_port,
2465 (void *)&cmd_showport_rss_hash_port_id,
2466 (void *)&cmd_showport_rss_hash_rss_hash,
2467 (void *)&cmd_showport_rss_hash_rss_hash_info,
2472 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2473 .f = cmd_showport_rss_hash_parsed,
2475 .help_str = "show port <port_id> rss-hash "
2476 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2477 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2478 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2480 (void *)&cmd_showport_rss_hash_show,
2481 (void *)&cmd_showport_rss_hash_port,
2482 (void *)&cmd_showport_rss_hash_port_id,
2483 (void *)&cmd_showport_rss_hash_rss_hash,
2484 (void *)&cmd_showport_rss_hash_rss_hash_info,
2485 (void *)&cmd_showport_rss_hash_rss_key,
2490 /* *** Configure DCB *** */
2491 struct cmd_config_dcb {
2492 cmdline_fixed_string_t port;
2493 cmdline_fixed_string_t config;
2495 cmdline_fixed_string_t dcb;
2496 cmdline_fixed_string_t vt;
2497 cmdline_fixed_string_t vt_en;
2499 cmdline_fixed_string_t pfc;
2500 cmdline_fixed_string_t pfc_en;
2504 cmd_config_dcb_parsed(void *parsed_result,
2505 __attribute__((unused)) struct cmdline *cl,
2506 __attribute__((unused)) void *data)
2508 struct cmd_config_dcb *res = parsed_result;
2509 portid_t port_id = res->port_id;
2510 struct rte_port *port;
2514 port = &ports[port_id];
2515 /** Check if the port is not started **/
2516 if (port->port_status != RTE_PORT_STOPPED) {
2517 printf("Please stop port %d first\n", port_id);
2521 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2522 printf("The invalid number of traffic class,"
2523 " only 4 or 8 allowed.\n");
2527 if (nb_fwd_lcores < res->num_tcs) {
2528 printf("nb_cores shouldn't be less than number of TCs.\n");
2531 if (!strncmp(res->pfc_en, "on", 2))
2536 /* DCB in VT mode */
2537 if (!strncmp(res->vt_en, "on", 2))
2538 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2539 (enum rte_eth_nb_tcs)res->num_tcs,
2542 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2543 (enum rte_eth_nb_tcs)res->num_tcs,
2548 printf("Cannot initialize network ports.\n");
2552 cmd_reconfig_device_queue(port_id, 1, 1);
2555 cmdline_parse_token_string_t cmd_config_dcb_port =
2556 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2557 cmdline_parse_token_string_t cmd_config_dcb_config =
2558 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2559 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2560 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2561 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2562 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2563 cmdline_parse_token_string_t cmd_config_dcb_vt =
2564 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2565 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2566 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2567 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2568 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2569 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2570 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2571 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2572 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2574 cmdline_parse_inst_t cmd_config_dcb = {
2575 .f = cmd_config_dcb_parsed,
2577 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2579 (void *)&cmd_config_dcb_port,
2580 (void *)&cmd_config_dcb_config,
2581 (void *)&cmd_config_dcb_port_id,
2582 (void *)&cmd_config_dcb_dcb,
2583 (void *)&cmd_config_dcb_vt,
2584 (void *)&cmd_config_dcb_vt_en,
2585 (void *)&cmd_config_dcb_num_tcs,
2586 (void *)&cmd_config_dcb_pfc,
2587 (void *)&cmd_config_dcb_pfc_en,
2592 /* *** configure number of packets per burst *** */
2593 struct cmd_config_burst {
2594 cmdline_fixed_string_t port;
2595 cmdline_fixed_string_t keyword;
2596 cmdline_fixed_string_t all;
2597 cmdline_fixed_string_t name;
2602 cmd_config_burst_parsed(void *parsed_result,
2603 __attribute__((unused)) struct cmdline *cl,
2604 __attribute__((unused)) void *data)
2606 struct cmd_config_burst *res = parsed_result;
2608 if (!all_ports_stopped()) {
2609 printf("Please stop all ports first\n");
2613 if (!strcmp(res->name, "burst")) {
2614 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2615 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2618 nb_pkt_per_burst = res->value;
2620 printf("Unknown parameter\n");
2626 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2629 cmdline_parse_token_string_t cmd_config_burst_port =
2630 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2631 cmdline_parse_token_string_t cmd_config_burst_keyword =
2632 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2633 cmdline_parse_token_string_t cmd_config_burst_all =
2634 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2635 cmdline_parse_token_string_t cmd_config_burst_name =
2636 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2637 cmdline_parse_token_num_t cmd_config_burst_value =
2638 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2640 cmdline_parse_inst_t cmd_config_burst = {
2641 .f = cmd_config_burst_parsed,
2643 .help_str = "port config all burst <value>",
2645 (void *)&cmd_config_burst_port,
2646 (void *)&cmd_config_burst_keyword,
2647 (void *)&cmd_config_burst_all,
2648 (void *)&cmd_config_burst_name,
2649 (void *)&cmd_config_burst_value,
2654 /* *** configure rx/tx queues *** */
2655 struct cmd_config_thresh {
2656 cmdline_fixed_string_t port;
2657 cmdline_fixed_string_t keyword;
2658 cmdline_fixed_string_t all;
2659 cmdline_fixed_string_t name;
2664 cmd_config_thresh_parsed(void *parsed_result,
2665 __attribute__((unused)) struct cmdline *cl,
2666 __attribute__((unused)) void *data)
2668 struct cmd_config_thresh *res = parsed_result;
2670 if (!all_ports_stopped()) {
2671 printf("Please stop all ports first\n");
2675 if (!strcmp(res->name, "txpt"))
2676 tx_pthresh = res->value;
2677 else if(!strcmp(res->name, "txht"))
2678 tx_hthresh = res->value;
2679 else if(!strcmp(res->name, "txwt"))
2680 tx_wthresh = res->value;
2681 else if(!strcmp(res->name, "rxpt"))
2682 rx_pthresh = res->value;
2683 else if(!strcmp(res->name, "rxht"))
2684 rx_hthresh = res->value;
2685 else if(!strcmp(res->name, "rxwt"))
2686 rx_wthresh = res->value;
2688 printf("Unknown parameter\n");
2694 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2697 cmdline_parse_token_string_t cmd_config_thresh_port =
2698 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2699 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2700 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2701 cmdline_parse_token_string_t cmd_config_thresh_all =
2702 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2703 cmdline_parse_token_string_t cmd_config_thresh_name =
2704 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2705 "txpt#txht#txwt#rxpt#rxht#rxwt");
2706 cmdline_parse_token_num_t cmd_config_thresh_value =
2707 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2709 cmdline_parse_inst_t cmd_config_thresh = {
2710 .f = cmd_config_thresh_parsed,
2712 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2714 (void *)&cmd_config_thresh_port,
2715 (void *)&cmd_config_thresh_keyword,
2716 (void *)&cmd_config_thresh_all,
2717 (void *)&cmd_config_thresh_name,
2718 (void *)&cmd_config_thresh_value,
2723 /* *** configure free/rs threshold *** */
2724 struct cmd_config_threshold {
2725 cmdline_fixed_string_t port;
2726 cmdline_fixed_string_t keyword;
2727 cmdline_fixed_string_t all;
2728 cmdline_fixed_string_t name;
2733 cmd_config_threshold_parsed(void *parsed_result,
2734 __attribute__((unused)) struct cmdline *cl,
2735 __attribute__((unused)) void *data)
2737 struct cmd_config_threshold *res = parsed_result;
2739 if (!all_ports_stopped()) {
2740 printf("Please stop all ports first\n");
2744 if (!strcmp(res->name, "txfreet"))
2745 tx_free_thresh = res->value;
2746 else if (!strcmp(res->name, "txrst"))
2747 tx_rs_thresh = res->value;
2748 else if (!strcmp(res->name, "rxfreet"))
2749 rx_free_thresh = res->value;
2751 printf("Unknown parameter\n");
2757 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2760 cmdline_parse_token_string_t cmd_config_threshold_port =
2761 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2762 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2763 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2765 cmdline_parse_token_string_t cmd_config_threshold_all =
2766 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2767 cmdline_parse_token_string_t cmd_config_threshold_name =
2768 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2769 "txfreet#txrst#rxfreet");
2770 cmdline_parse_token_num_t cmd_config_threshold_value =
2771 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2773 cmdline_parse_inst_t cmd_config_threshold = {
2774 .f = cmd_config_threshold_parsed,
2776 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2778 (void *)&cmd_config_threshold_port,
2779 (void *)&cmd_config_threshold_keyword,
2780 (void *)&cmd_config_threshold_all,
2781 (void *)&cmd_config_threshold_name,
2782 (void *)&cmd_config_threshold_value,
2788 struct cmd_stop_result {
2789 cmdline_fixed_string_t stop;
2792 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2793 __attribute__((unused)) struct cmdline *cl,
2794 __attribute__((unused)) void *data)
2796 stop_packet_forwarding();
2799 cmdline_parse_token_string_t cmd_stop_stop =
2800 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2802 cmdline_parse_inst_t cmd_stop = {
2803 .f = cmd_stop_parsed,
2805 .help_str = "stop: Stop packet forwarding",
2807 (void *)&cmd_stop_stop,
2812 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2815 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2816 unsigned int *parsed_items, int check_unique_values)
2818 unsigned int nb_item;
2826 * First parse all items in the list and store their value.
2831 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2833 if ((c >= '0') && (c <= '9')) {
2834 value = (unsigned int) (value * 10 + (c - '0'));
2839 printf("character %c is not a decimal digit\n", c);
2843 printf("No valid value before comma\n");
2846 if (nb_item < max_items) {
2847 parsed_items[nb_item] = value;
2853 if (nb_item >= max_items) {
2854 printf("Number of %s = %u > %u (maximum items)\n",
2855 item_name, nb_item + 1, max_items);
2858 parsed_items[nb_item++] = value;
2859 if (! check_unique_values)
2863 * Then, check that all values in the list are differents.
2864 * No optimization here...
2866 for (i = 0; i < nb_item; i++) {
2867 for (j = i + 1; j < nb_item; j++) {
2868 if (parsed_items[j] == parsed_items[i]) {
2869 printf("duplicated %s %u at index %u and %u\n",
2870 item_name, parsed_items[i], i, j);
2878 struct cmd_set_list_result {
2879 cmdline_fixed_string_t cmd_keyword;
2880 cmdline_fixed_string_t list_name;
2881 cmdline_fixed_string_t list_of_items;
2884 static void cmd_set_list_parsed(void *parsed_result,
2885 __attribute__((unused)) struct cmdline *cl,
2886 __attribute__((unused)) void *data)
2888 struct cmd_set_list_result *res;
2890 unsigned int lcorelist[RTE_MAX_LCORE];
2891 unsigned int portlist[RTE_MAX_ETHPORTS];
2893 unsigned int nb_item;
2895 if (test_done == 0) {
2896 printf("Please stop forwarding first\n");
2900 res = parsed_result;
2901 if (!strcmp(res->list_name, "corelist")) {
2902 nb_item = parse_item_list(res->list_of_items, "core",
2904 parsed_items.lcorelist, 1);
2906 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2911 if (!strcmp(res->list_name, "portlist")) {
2912 nb_item = parse_item_list(res->list_of_items, "port",
2914 parsed_items.portlist, 1);
2916 set_fwd_ports_list(parsed_items.portlist, nb_item);
2922 cmdline_parse_token_string_t cmd_set_list_keyword =
2923 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2925 cmdline_parse_token_string_t cmd_set_list_name =
2926 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2927 "corelist#portlist");
2928 cmdline_parse_token_string_t cmd_set_list_of_items =
2929 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2932 cmdline_parse_inst_t cmd_set_fwd_list = {
2933 .f = cmd_set_list_parsed,
2935 .help_str = "set corelist|portlist <list0[,list1]*>",
2937 (void *)&cmd_set_list_keyword,
2938 (void *)&cmd_set_list_name,
2939 (void *)&cmd_set_list_of_items,
2944 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2946 struct cmd_setmask_result {
2947 cmdline_fixed_string_t set;
2948 cmdline_fixed_string_t mask;
2952 static void cmd_set_mask_parsed(void *parsed_result,
2953 __attribute__((unused)) struct cmdline *cl,
2954 __attribute__((unused)) void *data)
2956 struct cmd_setmask_result *res = parsed_result;
2958 if (test_done == 0) {
2959 printf("Please stop forwarding first\n");
2962 if (!strcmp(res->mask, "coremask")) {
2963 set_fwd_lcores_mask(res->hexavalue);
2965 } else if (!strcmp(res->mask, "portmask")) {
2966 set_fwd_ports_mask(res->hexavalue);
2971 cmdline_parse_token_string_t cmd_setmask_set =
2972 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2973 cmdline_parse_token_string_t cmd_setmask_mask =
2974 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2975 "coremask#portmask");
2976 cmdline_parse_token_num_t cmd_setmask_value =
2977 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2979 cmdline_parse_inst_t cmd_set_fwd_mask = {
2980 .f = cmd_set_mask_parsed,
2982 .help_str = "set coremask|portmask <hexadecimal value>",
2984 (void *)&cmd_setmask_set,
2985 (void *)&cmd_setmask_mask,
2986 (void *)&cmd_setmask_value,
2992 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2994 struct cmd_set_result {
2995 cmdline_fixed_string_t set;
2996 cmdline_fixed_string_t what;
3000 static void cmd_set_parsed(void *parsed_result,
3001 __attribute__((unused)) struct cmdline *cl,
3002 __attribute__((unused)) void *data)
3004 struct cmd_set_result *res = parsed_result;
3005 if (!strcmp(res->what, "nbport")) {
3006 set_fwd_ports_number(res->value);
3008 } else if (!strcmp(res->what, "nbcore")) {
3009 set_fwd_lcores_number(res->value);
3011 } else if (!strcmp(res->what, "burst"))
3012 set_nb_pkt_per_burst(res->value);
3013 else if (!strcmp(res->what, "verbose"))
3014 set_verbose_level(res->value);
3017 cmdline_parse_token_string_t cmd_set_set =
3018 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3019 cmdline_parse_token_string_t cmd_set_what =
3020 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3021 "nbport#nbcore#burst#verbose");
3022 cmdline_parse_token_num_t cmd_set_value =
3023 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3025 cmdline_parse_inst_t cmd_set_numbers = {
3026 .f = cmd_set_parsed,
3028 .help_str = "set nbport|nbcore|burst|verbose <value>",
3030 (void *)&cmd_set_set,
3031 (void *)&cmd_set_what,
3032 (void *)&cmd_set_value,
3037 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3039 struct cmd_set_txpkts_result {
3040 cmdline_fixed_string_t cmd_keyword;
3041 cmdline_fixed_string_t txpkts;
3042 cmdline_fixed_string_t seg_lengths;
3046 cmd_set_txpkts_parsed(void *parsed_result,
3047 __attribute__((unused)) struct cmdline *cl,
3048 __attribute__((unused)) void *data)
3050 struct cmd_set_txpkts_result *res;
3051 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3052 unsigned int nb_segs;
3054 res = parsed_result;
3055 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3056 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3058 set_tx_pkt_segments(seg_lengths, nb_segs);
3061 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3062 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3063 cmd_keyword, "set");
3064 cmdline_parse_token_string_t cmd_set_txpkts_name =
3065 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3067 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3068 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3071 cmdline_parse_inst_t cmd_set_txpkts = {
3072 .f = cmd_set_txpkts_parsed,
3074 .help_str = "set txpkts <len0[,len1]*>",
3076 (void *)&cmd_set_txpkts_keyword,
3077 (void *)&cmd_set_txpkts_name,
3078 (void *)&cmd_set_txpkts_lengths,
3083 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3085 struct cmd_set_txsplit_result {
3086 cmdline_fixed_string_t cmd_keyword;
3087 cmdline_fixed_string_t txsplit;
3088 cmdline_fixed_string_t mode;
3092 cmd_set_txsplit_parsed(void *parsed_result,
3093 __attribute__((unused)) struct cmdline *cl,
3094 __attribute__((unused)) void *data)
3096 struct cmd_set_txsplit_result *res;
3098 res = parsed_result;
3099 set_tx_pkt_split(res->mode);
3102 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3103 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3104 cmd_keyword, "set");
3105 cmdline_parse_token_string_t cmd_set_txsplit_name =
3106 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3107 txsplit, "txsplit");
3108 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3109 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3112 cmdline_parse_inst_t cmd_set_txsplit = {
3113 .f = cmd_set_txsplit_parsed,
3115 .help_str = "set txsplit on|off|rand",
3117 (void *)&cmd_set_txsplit_keyword,
3118 (void *)&cmd_set_txsplit_name,
3119 (void *)&cmd_set_txsplit_mode,
3124 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3125 struct cmd_rx_vlan_filter_all_result {
3126 cmdline_fixed_string_t rx_vlan;
3127 cmdline_fixed_string_t what;
3128 cmdline_fixed_string_t all;
3133 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3134 __attribute__((unused)) struct cmdline *cl,
3135 __attribute__((unused)) void *data)
3137 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3139 if (!strcmp(res->what, "add"))
3140 rx_vlan_all_filter_set(res->port_id, 1);
3142 rx_vlan_all_filter_set(res->port_id, 0);
3145 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3146 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3147 rx_vlan, "rx_vlan");
3148 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3149 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3151 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3152 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3154 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3155 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3158 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3159 .f = cmd_rx_vlan_filter_all_parsed,
3161 .help_str = "rx_vlan add|rm all <port_id>: "
3162 "Add/Remove all identifiers to/from the set of VLAN "
3163 "identifiers filtered by a port",
3165 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3166 (void *)&cmd_rx_vlan_filter_all_what,
3167 (void *)&cmd_rx_vlan_filter_all_all,
3168 (void *)&cmd_rx_vlan_filter_all_portid,
3173 /* *** VLAN OFFLOAD SET ON A PORT *** */
3174 struct cmd_vlan_offload_result {
3175 cmdline_fixed_string_t vlan;
3176 cmdline_fixed_string_t set;
3177 cmdline_fixed_string_t vlan_type;
3178 cmdline_fixed_string_t what;
3179 cmdline_fixed_string_t on;
3180 cmdline_fixed_string_t port_id;
3184 cmd_vlan_offload_parsed(void *parsed_result,
3185 __attribute__((unused)) struct cmdline *cl,
3186 __attribute__((unused)) void *data)
3189 struct cmd_vlan_offload_result *res = parsed_result;
3192 portid_t port_id = 0;
3196 len = strnlen(str, STR_TOKEN_SIZE);
3198 /* Get port_id first */
3206 tmp = strtoul(str, NULL, 0);
3207 /* If port_id greater that what portid_t can represent, return */
3208 if(tmp >= RTE_MAX_ETHPORTS)
3210 port_id = (portid_t)tmp;
3212 if (!strcmp(res->on, "on"))
3217 if (!strcmp(res->what, "strip"))
3218 rx_vlan_strip_set(port_id, on);
3219 else if(!strcmp(res->what, "stripq")){
3220 uint16_t queue_id = 0;
3222 /* No queue_id, return */
3224 printf("must specify (port,queue_id)\n");
3227 tmp = strtoul(str + i + 1, NULL, 0);
3228 /* If queue_id greater that what 16-bits can represent, return */
3232 queue_id = (uint16_t)tmp;
3233 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3235 else if (!strcmp(res->what, "filter"))
3236 rx_vlan_filter_set(port_id, on);
3238 vlan_extend_set(port_id, on);
3243 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3244 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3246 cmdline_parse_token_string_t cmd_vlan_offload_set =
3247 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3249 cmdline_parse_token_string_t cmd_vlan_offload_what =
3250 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3251 what, "strip#filter#qinq#stripq");
3252 cmdline_parse_token_string_t cmd_vlan_offload_on =
3253 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3255 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3256 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3259 cmdline_parse_inst_t cmd_vlan_offload = {
3260 .f = cmd_vlan_offload_parsed,
3262 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3263 "<port_id[,queue_id]>: "
3264 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3266 (void *)&cmd_vlan_offload_vlan,
3267 (void *)&cmd_vlan_offload_set,
3268 (void *)&cmd_vlan_offload_what,
3269 (void *)&cmd_vlan_offload_on,
3270 (void *)&cmd_vlan_offload_portid,
3275 /* *** VLAN TPID SET ON A PORT *** */
3276 struct cmd_vlan_tpid_result {
3277 cmdline_fixed_string_t vlan;
3278 cmdline_fixed_string_t set;
3279 cmdline_fixed_string_t vlan_type;
3280 cmdline_fixed_string_t what;
3286 cmd_vlan_tpid_parsed(void *parsed_result,
3287 __attribute__((unused)) struct cmdline *cl,
3288 __attribute__((unused)) void *data)
3290 struct cmd_vlan_tpid_result *res = parsed_result;
3291 enum rte_vlan_type vlan_type;
3293 if (!strcmp(res->vlan_type, "inner"))
3294 vlan_type = ETH_VLAN_TYPE_INNER;
3295 else if (!strcmp(res->vlan_type, "outer"))
3296 vlan_type = ETH_VLAN_TYPE_OUTER;
3298 printf("Unknown vlan type\n");
3301 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3304 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3305 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3307 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3308 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3310 cmdline_parse_token_string_t cmd_vlan_type =
3311 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3312 vlan_type, "inner#outer");
3313 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3314 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3316 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3317 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3319 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3320 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3323 cmdline_parse_inst_t cmd_vlan_tpid = {
3324 .f = cmd_vlan_tpid_parsed,
3326 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3327 "Set the VLAN Ether type",
3329 (void *)&cmd_vlan_tpid_vlan,
3330 (void *)&cmd_vlan_tpid_set,
3331 (void *)&cmd_vlan_type,
3332 (void *)&cmd_vlan_tpid_what,
3333 (void *)&cmd_vlan_tpid_tpid,
3334 (void *)&cmd_vlan_tpid_portid,
3339 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3340 struct cmd_rx_vlan_filter_result {
3341 cmdline_fixed_string_t rx_vlan;
3342 cmdline_fixed_string_t what;
3348 cmd_rx_vlan_filter_parsed(void *parsed_result,
3349 __attribute__((unused)) struct cmdline *cl,
3350 __attribute__((unused)) void *data)
3352 struct cmd_rx_vlan_filter_result *res = parsed_result;
3354 if (!strcmp(res->what, "add"))
3355 rx_vft_set(res->port_id, res->vlan_id, 1);
3357 rx_vft_set(res->port_id, res->vlan_id, 0);
3360 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3361 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3362 rx_vlan, "rx_vlan");
3363 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3364 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3366 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3367 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3369 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3370 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3373 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3374 .f = cmd_rx_vlan_filter_parsed,
3376 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3377 "Add/Remove a VLAN identifier to/from the set of VLAN "
3378 "identifiers filtered by a port",
3380 (void *)&cmd_rx_vlan_filter_rx_vlan,
3381 (void *)&cmd_rx_vlan_filter_what,
3382 (void *)&cmd_rx_vlan_filter_vlanid,
3383 (void *)&cmd_rx_vlan_filter_portid,
3388 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3389 struct cmd_tx_vlan_set_result {
3390 cmdline_fixed_string_t tx_vlan;
3391 cmdline_fixed_string_t set;
3397 cmd_tx_vlan_set_parsed(void *parsed_result,
3398 __attribute__((unused)) struct cmdline *cl,
3399 __attribute__((unused)) void *data)
3401 struct cmd_tx_vlan_set_result *res = parsed_result;
3403 if (!port_is_stopped(res->port_id)) {
3404 printf("Please stop port %d first\n", res->port_id);
3408 tx_vlan_set(res->port_id, res->vlan_id);
3410 cmd_reconfig_device_queue(res->port_id, 1, 1);
3413 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3414 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3415 tx_vlan, "tx_vlan");
3416 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3417 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3419 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3420 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3422 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3423 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3426 cmdline_parse_inst_t cmd_tx_vlan_set = {
3427 .f = cmd_tx_vlan_set_parsed,
3429 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3430 "Enable hardware insertion of a single VLAN header "
3431 "with a given TAG Identifier in packets sent on a port",
3433 (void *)&cmd_tx_vlan_set_tx_vlan,
3434 (void *)&cmd_tx_vlan_set_set,
3435 (void *)&cmd_tx_vlan_set_portid,
3436 (void *)&cmd_tx_vlan_set_vlanid,
3441 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3442 struct cmd_tx_vlan_set_qinq_result {
3443 cmdline_fixed_string_t tx_vlan;
3444 cmdline_fixed_string_t set;
3447 uint16_t vlan_id_outer;
3451 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3452 __attribute__((unused)) struct cmdline *cl,
3453 __attribute__((unused)) void *data)
3455 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3457 if (!port_is_stopped(res->port_id)) {
3458 printf("Please stop port %d first\n", res->port_id);
3462 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3464 cmd_reconfig_device_queue(res->port_id, 1, 1);
3467 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3468 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3469 tx_vlan, "tx_vlan");
3470 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3471 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3473 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3474 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3476 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3477 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3479 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3480 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3481 vlan_id_outer, UINT16);
3483 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3484 .f = cmd_tx_vlan_set_qinq_parsed,
3486 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3487 "Enable hardware insertion of double VLAN header "
3488 "with given TAG Identifiers in packets sent on a port",
3490 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3491 (void *)&cmd_tx_vlan_set_qinq_set,
3492 (void *)&cmd_tx_vlan_set_qinq_portid,
3493 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3494 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3499 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3500 struct cmd_tx_vlan_set_pvid_result {
3501 cmdline_fixed_string_t tx_vlan;
3502 cmdline_fixed_string_t set;
3503 cmdline_fixed_string_t pvid;
3506 cmdline_fixed_string_t mode;
3510 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3511 __attribute__((unused)) struct cmdline *cl,
3512 __attribute__((unused)) void *data)
3514 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3516 if (strcmp(res->mode, "on") == 0)
3517 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3519 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3522 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3523 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3524 tx_vlan, "tx_vlan");
3525 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3526 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3528 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3529 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3531 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3532 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3534 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3535 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3537 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3538 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3541 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3542 .f = cmd_tx_vlan_set_pvid_parsed,
3544 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3546 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3547 (void *)&cmd_tx_vlan_set_pvid_set,
3548 (void *)&cmd_tx_vlan_set_pvid_pvid,
3549 (void *)&cmd_tx_vlan_set_pvid_port_id,
3550 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3551 (void *)&cmd_tx_vlan_set_pvid_mode,
3556 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3557 struct cmd_tx_vlan_reset_result {
3558 cmdline_fixed_string_t tx_vlan;
3559 cmdline_fixed_string_t reset;
3564 cmd_tx_vlan_reset_parsed(void *parsed_result,
3565 __attribute__((unused)) struct cmdline *cl,
3566 __attribute__((unused)) void *data)
3568 struct cmd_tx_vlan_reset_result *res = parsed_result;
3570 if (!port_is_stopped(res->port_id)) {
3571 printf("Please stop port %d first\n", res->port_id);
3575 tx_vlan_reset(res->port_id);
3577 cmd_reconfig_device_queue(res->port_id, 1, 1);
3580 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3581 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3582 tx_vlan, "tx_vlan");
3583 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3584 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3586 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3587 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3590 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3591 .f = cmd_tx_vlan_reset_parsed,
3593 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3594 "VLAN header in packets sent on a port",
3596 (void *)&cmd_tx_vlan_reset_tx_vlan,
3597 (void *)&cmd_tx_vlan_reset_reset,
3598 (void *)&cmd_tx_vlan_reset_portid,
3604 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3605 struct cmd_csum_result {
3606 cmdline_fixed_string_t csum;
3607 cmdline_fixed_string_t mode;
3608 cmdline_fixed_string_t proto;
3609 cmdline_fixed_string_t hwsw;
3614 csum_show(int port_id)
3616 struct rte_eth_dev_info dev_info;
3617 uint64_t tx_offloads;
3619 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3620 printf("Parse tunnel is %s\n",
3621 (ports[port_id].parse_tunnel) ? "on" : "off");
3622 printf("IP checksum offload is %s\n",
3623 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3624 printf("UDP checksum offload is %s\n",
3625 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3626 printf("TCP checksum offload is %s\n",
3627 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3628 printf("SCTP checksum offload is %s\n",
3629 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3630 printf("Outer-Ip checksum offload is %s\n",
3631 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3633 /* display warnings if configuration is not supported by the NIC */
3634 rte_eth_dev_info_get(port_id, &dev_info);
3635 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3636 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3637 printf("Warning: hardware IP checksum enabled but not "
3638 "supported by port %d\n", port_id);
3640 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3641 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3642 printf("Warning: hardware UDP checksum enabled but not "
3643 "supported by port %d\n", port_id);
3645 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3646 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3647 printf("Warning: hardware TCP checksum enabled but not "
3648 "supported by port %d\n", port_id);
3650 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3651 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3652 printf("Warning: hardware SCTP checksum enabled but not "
3653 "supported by port %d\n", port_id);
3655 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3656 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3657 printf("Warning: hardware outer IP checksum enabled but not "
3658 "supported by port %d\n", port_id);
3663 cmd_csum_parsed(void *parsed_result,
3664 __attribute__((unused)) struct cmdline *cl,
3665 __attribute__((unused)) void *data)
3667 struct cmd_csum_result *res = parsed_result;
3669 uint64_t csum_offloads = 0;
3670 struct rte_eth_dev_info dev_info;
3672 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3673 printf("invalid port %d\n", res->port_id);
3676 if (!port_is_stopped(res->port_id)) {
3677 printf("Please stop port %d first\n", res->port_id);
3681 rte_eth_dev_info_get(res->port_id, &dev_info);
3682 if (!strcmp(res->mode, "set")) {
3684 if (!strcmp(res->hwsw, "hw"))
3687 if (!strcmp(res->proto, "ip")) {
3688 if (dev_info.tx_offload_capa &
3689 DEV_TX_OFFLOAD_IPV4_CKSUM) {
3690 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3692 printf("IP checksum offload is not supported "
3693 "by port %u\n", res->port_id);
3695 } else if (!strcmp(res->proto, "udp")) {
3696 if (dev_info.tx_offload_capa &
3697 DEV_TX_OFFLOAD_UDP_CKSUM) {
3698 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3700 printf("UDP checksum offload is not supported "
3701 "by port %u\n", res->port_id);
3703 } else if (!strcmp(res->proto, "tcp")) {
3704 if (dev_info.tx_offload_capa &
3705 DEV_TX_OFFLOAD_TCP_CKSUM) {
3706 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3708 printf("TCP checksum offload is not supported "
3709 "by port %u\n", res->port_id);
3711 } else if (!strcmp(res->proto, "sctp")) {
3712 if (dev_info.tx_offload_capa &
3713 DEV_TX_OFFLOAD_SCTP_CKSUM) {
3714 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3716 printf("SCTP checksum offload is not supported "
3717 "by port %u\n", res->port_id);
3719 } else if (!strcmp(res->proto, "outer-ip")) {
3720 if (dev_info.tx_offload_capa &
3721 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) {
3723 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3725 printf("Outer IP checksum offload is not "
3726 "supported by port %u\n", res->port_id);
3731 ports[res->port_id].dev_conf.txmode.offloads |=
3734 ports[res->port_id].dev_conf.txmode.offloads &=
3738 csum_show(res->port_id);
3740 cmd_reconfig_device_queue(res->port_id, 1, 1);
3743 cmdline_parse_token_string_t cmd_csum_csum =
3744 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3746 cmdline_parse_token_string_t cmd_csum_mode =
3747 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3749 cmdline_parse_token_string_t cmd_csum_proto =
3750 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3751 proto, "ip#tcp#udp#sctp#outer-ip");
3752 cmdline_parse_token_string_t cmd_csum_hwsw =
3753 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3755 cmdline_parse_token_num_t cmd_csum_portid =
3756 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3759 cmdline_parse_inst_t cmd_csum_set = {
3760 .f = cmd_csum_parsed,
3762 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3763 "Enable/Disable hardware calculation of L3/L4 checksum when "
3764 "using csum forward engine",
3766 (void *)&cmd_csum_csum,
3767 (void *)&cmd_csum_mode,
3768 (void *)&cmd_csum_proto,
3769 (void *)&cmd_csum_hwsw,
3770 (void *)&cmd_csum_portid,
3775 cmdline_parse_token_string_t cmd_csum_mode_show =
3776 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3779 cmdline_parse_inst_t cmd_csum_show = {
3780 .f = cmd_csum_parsed,
3782 .help_str = "csum show <port_id>: Show checksum offload configuration",
3784 (void *)&cmd_csum_csum,
3785 (void *)&cmd_csum_mode_show,
3786 (void *)&cmd_csum_portid,
3791 /* Enable/disable tunnel parsing */
3792 struct cmd_csum_tunnel_result {
3793 cmdline_fixed_string_t csum;
3794 cmdline_fixed_string_t parse;
3795 cmdline_fixed_string_t onoff;
3800 cmd_csum_tunnel_parsed(void *parsed_result,
3801 __attribute__((unused)) struct cmdline *cl,
3802 __attribute__((unused)) void *data)
3804 struct cmd_csum_tunnel_result *res = parsed_result;
3806 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3809 if (!strcmp(res->onoff, "on"))
3810 ports[res->port_id].parse_tunnel = 1;
3812 ports[res->port_id].parse_tunnel = 0;
3814 csum_show(res->port_id);
3817 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3818 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3820 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3821 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3822 parse, "parse_tunnel");
3823 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3824 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3826 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3827 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3830 cmdline_parse_inst_t cmd_csum_tunnel = {
3831 .f = cmd_csum_tunnel_parsed,
3833 .help_str = "csum parse_tunnel on|off <port_id>: "
3834 "Enable/Disable parsing of tunnels for csum engine",
3836 (void *)&cmd_csum_tunnel_csum,
3837 (void *)&cmd_csum_tunnel_parse,
3838 (void *)&cmd_csum_tunnel_onoff,
3839 (void *)&cmd_csum_tunnel_portid,
3844 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3845 struct cmd_tso_set_result {
3846 cmdline_fixed_string_t tso;
3847 cmdline_fixed_string_t mode;
3853 cmd_tso_set_parsed(void *parsed_result,
3854 __attribute__((unused)) struct cmdline *cl,
3855 __attribute__((unused)) void *data)
3857 struct cmd_tso_set_result *res = parsed_result;
3858 struct rte_eth_dev_info dev_info;
3860 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3862 if (!port_is_stopped(res->port_id)) {
3863 printf("Please stop port %d first\n", res->port_id);
3867 if (!strcmp(res->mode, "set"))
3868 ports[res->port_id].tso_segsz = res->tso_segsz;
3870 rte_eth_dev_info_get(res->port_id, &dev_info);
3871 if ((ports[res->port_id].tso_segsz != 0) &&
3872 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3873 printf("Error: TSO is not supported by port %d\n",
3878 if (ports[res->port_id].tso_segsz == 0) {
3879 ports[res->port_id].dev_conf.txmode.offloads &=
3880 ~DEV_TX_OFFLOAD_TCP_TSO;
3881 printf("TSO for non-tunneled packets is disabled\n");
3883 ports[res->port_id].dev_conf.txmode.offloads |=
3884 DEV_TX_OFFLOAD_TCP_TSO;
3885 printf("TSO segment size for non-tunneled packets is %d\n",
3886 ports[res->port_id].tso_segsz);
3889 /* display warnings if configuration is not supported by the NIC */
3890 rte_eth_dev_info_get(res->port_id, &dev_info);
3891 if ((ports[res->port_id].tso_segsz != 0) &&
3892 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3893 printf("Warning: TSO enabled but not "
3894 "supported by port %d\n", res->port_id);
3897 cmd_reconfig_device_queue(res->port_id, 1, 1);
3900 cmdline_parse_token_string_t cmd_tso_set_tso =
3901 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3903 cmdline_parse_token_string_t cmd_tso_set_mode =
3904 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3906 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3907 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3909 cmdline_parse_token_num_t cmd_tso_set_portid =
3910 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3913 cmdline_parse_inst_t cmd_tso_set = {
3914 .f = cmd_tso_set_parsed,
3916 .help_str = "tso set <tso_segsz> <port_id>: "
3917 "Set TSO segment size of non-tunneled packets for csum engine "
3920 (void *)&cmd_tso_set_tso,
3921 (void *)&cmd_tso_set_mode,
3922 (void *)&cmd_tso_set_tso_segsz,
3923 (void *)&cmd_tso_set_portid,
3928 cmdline_parse_token_string_t cmd_tso_show_mode =
3929 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3933 cmdline_parse_inst_t cmd_tso_show = {
3934 .f = cmd_tso_set_parsed,
3936 .help_str = "tso show <port_id>: "
3937 "Show TSO segment size of non-tunneled packets for csum engine",
3939 (void *)&cmd_tso_set_tso,
3940 (void *)&cmd_tso_show_mode,
3941 (void *)&cmd_tso_set_portid,
3946 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3947 struct cmd_tunnel_tso_set_result {
3948 cmdline_fixed_string_t tso;
3949 cmdline_fixed_string_t mode;
3954 static struct rte_eth_dev_info
3955 check_tunnel_tso_nic_support(portid_t port_id)
3957 struct rte_eth_dev_info dev_info;
3959 rte_eth_dev_info_get(port_id, &dev_info);
3960 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3961 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
3962 "not enabled for port %d\n", port_id);
3963 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3964 printf("Warning: GRE TUNNEL TSO not supported therefore "
3965 "not enabled for port %d\n", port_id);
3966 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3967 printf("Warning: IPIP TUNNEL TSO not supported therefore "
3968 "not enabled for port %d\n", port_id);
3969 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3970 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
3971 "not enabled for port %d\n", port_id);
3976 cmd_tunnel_tso_set_parsed(void *parsed_result,
3977 __attribute__((unused)) struct cmdline *cl,
3978 __attribute__((unused)) void *data)
3980 struct cmd_tunnel_tso_set_result *res = parsed_result;
3981 struct rte_eth_dev_info dev_info;
3983 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3985 if (!port_is_stopped(res->port_id)) {
3986 printf("Please stop port %d first\n", res->port_id);
3990 if (!strcmp(res->mode, "set"))
3991 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3993 dev_info = check_tunnel_tso_nic_support(res->port_id);
3994 if (ports[res->port_id].tunnel_tso_segsz == 0) {
3995 ports[res->port_id].dev_conf.txmode.offloads &=
3996 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
3997 DEV_TX_OFFLOAD_GRE_TNL_TSO |
3998 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
3999 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4000 printf("TSO for tunneled packets is disabled\n");
4002 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4003 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4004 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4005 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4007 ports[res->port_id].dev_conf.txmode.offloads |=
4008 (tso_offloads & dev_info.tx_offload_capa);
4009 printf("TSO segment size for tunneled packets is %d\n",
4010 ports[res->port_id].tunnel_tso_segsz);
4012 /* Below conditions are needed to make it work:
4013 * (1) tunnel TSO is supported by the NIC;
4014 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4016 * (3) for tunneled pkts with outer L3 of IPv4,
4017 * "csum set outer-ip" must be set to hw, because after tso,
4018 * total_len of outer IP header is changed, and the checksum
4019 * of outer IP header calculated by sw should be wrong; that
4020 * is not necessary for IPv6 tunneled pkts because there's no
4021 * checksum in IP header anymore.
4024 if (!ports[res->port_id].parse_tunnel)
4025 printf("Warning: csum parse_tunnel must be set "
4026 "so that tunneled packets are recognized\n");
4027 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4028 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4029 printf("Warning: csum set outer-ip must be set to hw "
4030 "if outer L3 is IPv4; not necessary for IPv6\n");
4033 cmd_reconfig_device_queue(res->port_id, 1, 1);
4036 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4037 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4039 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4040 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4042 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4043 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4045 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4046 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4049 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4050 .f = cmd_tunnel_tso_set_parsed,
4052 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4053 "Set TSO segment size of tunneled packets for csum engine "
4056 (void *)&cmd_tunnel_tso_set_tso,
4057 (void *)&cmd_tunnel_tso_set_mode,
4058 (void *)&cmd_tunnel_tso_set_tso_segsz,
4059 (void *)&cmd_tunnel_tso_set_portid,
4064 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4065 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4069 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4070 .f = cmd_tunnel_tso_set_parsed,
4072 .help_str = "tunnel_tso show <port_id> "
4073 "Show TSO segment size of tunneled packets for csum engine",
4075 (void *)&cmd_tunnel_tso_set_tso,
4076 (void *)&cmd_tunnel_tso_show_mode,
4077 (void *)&cmd_tunnel_tso_set_portid,
4082 /* *** SET GRO FOR A PORT *** */
4083 struct cmd_gro_enable_result {
4084 cmdline_fixed_string_t cmd_set;
4085 cmdline_fixed_string_t cmd_port;
4086 cmdline_fixed_string_t cmd_keyword;
4087 cmdline_fixed_string_t cmd_onoff;
4092 cmd_gro_enable_parsed(void *parsed_result,
4093 __attribute__((unused)) struct cmdline *cl,
4094 __attribute__((unused)) void *data)
4096 struct cmd_gro_enable_result *res;
4098 res = parsed_result;
4099 if (!strcmp(res->cmd_keyword, "gro"))
4100 setup_gro(res->cmd_onoff, res->cmd_pid);
4103 cmdline_parse_token_string_t cmd_gro_enable_set =
4104 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4106 cmdline_parse_token_string_t cmd_gro_enable_port =
4107 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4108 cmd_keyword, "port");
4109 cmdline_parse_token_num_t cmd_gro_enable_pid =
4110 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4112 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4113 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4114 cmd_keyword, "gro");
4115 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4116 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4117 cmd_onoff, "on#off");
4119 cmdline_parse_inst_t cmd_gro_enable = {
4120 .f = cmd_gro_enable_parsed,
4122 .help_str = "set port <port_id> gro on|off",
4124 (void *)&cmd_gro_enable_set,
4125 (void *)&cmd_gro_enable_port,
4126 (void *)&cmd_gro_enable_pid,
4127 (void *)&cmd_gro_enable_keyword,
4128 (void *)&cmd_gro_enable_onoff,
4133 /* *** DISPLAY GRO CONFIGURATION *** */
4134 struct cmd_gro_show_result {
4135 cmdline_fixed_string_t cmd_show;
4136 cmdline_fixed_string_t cmd_port;
4137 cmdline_fixed_string_t cmd_keyword;
4142 cmd_gro_show_parsed(void *parsed_result,
4143 __attribute__((unused)) struct cmdline *cl,
4144 __attribute__((unused)) void *data)
4146 struct cmd_gro_show_result *res;
4148 res = parsed_result;
4149 if (!strcmp(res->cmd_keyword, "gro"))
4150 show_gro(res->cmd_pid);
4153 cmdline_parse_token_string_t cmd_gro_show_show =
4154 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4156 cmdline_parse_token_string_t cmd_gro_show_port =
4157 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4159 cmdline_parse_token_num_t cmd_gro_show_pid =
4160 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4162 cmdline_parse_token_string_t cmd_gro_show_keyword =
4163 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4164 cmd_keyword, "gro");
4166 cmdline_parse_inst_t cmd_gro_show = {
4167 .f = cmd_gro_show_parsed,
4169 .help_str = "show port <port_id> gro",
4171 (void *)&cmd_gro_show_show,
4172 (void *)&cmd_gro_show_port,
4173 (void *)&cmd_gro_show_pid,
4174 (void *)&cmd_gro_show_keyword,
4179 /* *** SET FLUSH CYCLES FOR GRO *** */
4180 struct cmd_gro_flush_result {
4181 cmdline_fixed_string_t cmd_set;
4182 cmdline_fixed_string_t cmd_keyword;
4183 cmdline_fixed_string_t cmd_flush;
4188 cmd_gro_flush_parsed(void *parsed_result,
4189 __attribute__((unused)) struct cmdline *cl,
4190 __attribute__((unused)) void *data)
4192 struct cmd_gro_flush_result *res;
4194 res = parsed_result;
4195 if ((!strcmp(res->cmd_keyword, "gro")) &&
4196 (!strcmp(res->cmd_flush, "flush")))
4197 setup_gro_flush_cycles(res->cmd_cycles);
4200 cmdline_parse_token_string_t cmd_gro_flush_set =
4201 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4203 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4204 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4205 cmd_keyword, "gro");
4206 cmdline_parse_token_string_t cmd_gro_flush_flush =
4207 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4208 cmd_flush, "flush");
4209 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4210 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4213 cmdline_parse_inst_t cmd_gro_flush = {
4214 .f = cmd_gro_flush_parsed,
4216 .help_str = "set gro flush <cycles>",
4218 (void *)&cmd_gro_flush_set,
4219 (void *)&cmd_gro_flush_keyword,
4220 (void *)&cmd_gro_flush_flush,
4221 (void *)&cmd_gro_flush_cycles,
4226 /* *** ENABLE/DISABLE GSO *** */
4227 struct cmd_gso_enable_result {
4228 cmdline_fixed_string_t cmd_set;
4229 cmdline_fixed_string_t cmd_port;
4230 cmdline_fixed_string_t cmd_keyword;
4231 cmdline_fixed_string_t cmd_mode;
4236 cmd_gso_enable_parsed(void *parsed_result,
4237 __attribute__((unused)) struct cmdline *cl,
4238 __attribute__((unused)) void *data)
4240 struct cmd_gso_enable_result *res;
4242 res = parsed_result;
4243 if (!strcmp(res->cmd_keyword, "gso"))
4244 setup_gso(res->cmd_mode, res->cmd_pid);
4247 cmdline_parse_token_string_t cmd_gso_enable_set =
4248 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4250 cmdline_parse_token_string_t cmd_gso_enable_port =
4251 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4253 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4254 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4255 cmd_keyword, "gso");
4256 cmdline_parse_token_string_t cmd_gso_enable_mode =
4257 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4258 cmd_mode, "on#off");
4259 cmdline_parse_token_num_t cmd_gso_enable_pid =
4260 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4263 cmdline_parse_inst_t cmd_gso_enable = {
4264 .f = cmd_gso_enable_parsed,
4266 .help_str = "set port <port_id> gso on|off",
4268 (void *)&cmd_gso_enable_set,
4269 (void *)&cmd_gso_enable_port,
4270 (void *)&cmd_gso_enable_pid,
4271 (void *)&cmd_gso_enable_keyword,
4272 (void *)&cmd_gso_enable_mode,
4277 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4278 struct cmd_gso_size_result {
4279 cmdline_fixed_string_t cmd_set;
4280 cmdline_fixed_string_t cmd_keyword;
4281 cmdline_fixed_string_t cmd_segsz;
4286 cmd_gso_size_parsed(void *parsed_result,
4287 __attribute__((unused)) struct cmdline *cl,
4288 __attribute__((unused)) void *data)
4290 struct cmd_gso_size_result *res = parsed_result;
4292 if (test_done == 0) {
4293 printf("Before setting GSO segsz, please first"
4294 " stop fowarding\n");
4298 if (!strcmp(res->cmd_keyword, "gso") &&
4299 !strcmp(res->cmd_segsz, "segsz")) {
4300 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4301 printf("gso_size should be larger than %zu."
4302 " Please input a legal value\n",
4303 RTE_GSO_SEG_SIZE_MIN);
4305 gso_max_segment_size = res->cmd_size;
4309 cmdline_parse_token_string_t cmd_gso_size_set =
4310 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4312 cmdline_parse_token_string_t cmd_gso_size_keyword =
4313 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4314 cmd_keyword, "gso");
4315 cmdline_parse_token_string_t cmd_gso_size_segsz =
4316 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4317 cmd_segsz, "segsz");
4318 cmdline_parse_token_num_t cmd_gso_size_size =
4319 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4322 cmdline_parse_inst_t cmd_gso_size = {
4323 .f = cmd_gso_size_parsed,
4325 .help_str = "set gso segsz <length>",
4327 (void *)&cmd_gso_size_set,
4328 (void *)&cmd_gso_size_keyword,
4329 (void *)&cmd_gso_size_segsz,
4330 (void *)&cmd_gso_size_size,
4335 /* *** SHOW GSO CONFIGURATION *** */
4336 struct cmd_gso_show_result {
4337 cmdline_fixed_string_t cmd_show;
4338 cmdline_fixed_string_t cmd_port;
4339 cmdline_fixed_string_t cmd_keyword;
4344 cmd_gso_show_parsed(void *parsed_result,
4345 __attribute__((unused)) struct cmdline *cl,
4346 __attribute__((unused)) void *data)
4348 struct cmd_gso_show_result *res = parsed_result;
4350 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4351 printf("invalid port id %u\n", res->cmd_pid);
4354 if (!strcmp(res->cmd_keyword, "gso")) {
4355 if (gso_ports[res->cmd_pid].enable) {
4356 printf("Max GSO'd packet size: %uB\n"
4357 "Supported GSO types: TCP/IPv4, "
4358 "VxLAN with inner TCP/IPv4 packet, "
4359 "GRE with inner TCP/IPv4 packet\n",
4360 gso_max_segment_size);
4362 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4366 cmdline_parse_token_string_t cmd_gso_show_show =
4367 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4369 cmdline_parse_token_string_t cmd_gso_show_port =
4370 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4372 cmdline_parse_token_string_t cmd_gso_show_keyword =
4373 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4374 cmd_keyword, "gso");
4375 cmdline_parse_token_num_t cmd_gso_show_pid =
4376 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4379 cmdline_parse_inst_t cmd_gso_show = {
4380 .f = cmd_gso_show_parsed,
4382 .help_str = "show port <port_id> gso",
4384 (void *)&cmd_gso_show_show,
4385 (void *)&cmd_gso_show_port,
4386 (void *)&cmd_gso_show_pid,
4387 (void *)&cmd_gso_show_keyword,
4392 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4393 struct cmd_set_flush_rx {
4394 cmdline_fixed_string_t set;
4395 cmdline_fixed_string_t flush_rx;
4396 cmdline_fixed_string_t mode;
4400 cmd_set_flush_rx_parsed(void *parsed_result,
4401 __attribute__((unused)) struct cmdline *cl,
4402 __attribute__((unused)) void *data)
4404 struct cmd_set_flush_rx *res = parsed_result;
4405 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4408 cmdline_parse_token_string_t cmd_setflushrx_set =
4409 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4411 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4412 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4413 flush_rx, "flush_rx");
4414 cmdline_parse_token_string_t cmd_setflushrx_mode =
4415 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4419 cmdline_parse_inst_t cmd_set_flush_rx = {
4420 .f = cmd_set_flush_rx_parsed,
4421 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4424 (void *)&cmd_setflushrx_set,
4425 (void *)&cmd_setflushrx_flush_rx,
4426 (void *)&cmd_setflushrx_mode,
4431 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4432 struct cmd_set_link_check {
4433 cmdline_fixed_string_t set;
4434 cmdline_fixed_string_t link_check;
4435 cmdline_fixed_string_t mode;
4439 cmd_set_link_check_parsed(void *parsed_result,
4440 __attribute__((unused)) struct cmdline *cl,
4441 __attribute__((unused)) void *data)
4443 struct cmd_set_link_check *res = parsed_result;
4444 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4447 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4448 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4450 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4451 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4452 link_check, "link_check");
4453 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4454 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4458 cmdline_parse_inst_t cmd_set_link_check = {
4459 .f = cmd_set_link_check_parsed,
4460 .help_str = "set link_check on|off: Enable/Disable link status check "
4461 "when starting/stopping a port",
4464 (void *)&cmd_setlinkcheck_set,
4465 (void *)&cmd_setlinkcheck_link_check,
4466 (void *)&cmd_setlinkcheck_mode,
4471 /* *** SET NIC BYPASS MODE *** */
4472 struct cmd_set_bypass_mode_result {
4473 cmdline_fixed_string_t set;
4474 cmdline_fixed_string_t bypass;
4475 cmdline_fixed_string_t mode;
4476 cmdline_fixed_string_t value;
4481 cmd_set_bypass_mode_parsed(void *parsed_result,
4482 __attribute__((unused)) struct cmdline *cl,
4483 __attribute__((unused)) void *data)
4485 struct cmd_set_bypass_mode_result *res = parsed_result;
4486 portid_t port_id = res->port_id;
4487 int32_t rc = -EINVAL;
4489 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4490 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4492 if (!strcmp(res->value, "bypass"))
4493 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4494 else if (!strcmp(res->value, "isolate"))
4495 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4497 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4499 /* Set the bypass mode for the relevant port. */
4500 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4503 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4506 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4507 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4509 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4510 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4512 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4513 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4515 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4516 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4517 value, "normal#bypass#isolate");
4518 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4519 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4522 cmdline_parse_inst_t cmd_set_bypass_mode = {
4523 .f = cmd_set_bypass_mode_parsed,
4524 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4525 "Set the NIC bypass mode for port_id",
4528 (void *)&cmd_setbypass_mode_set,
4529 (void *)&cmd_setbypass_mode_bypass,
4530 (void *)&cmd_setbypass_mode_mode,
4531 (void *)&cmd_setbypass_mode_value,
4532 (void *)&cmd_setbypass_mode_port,
4537 /* *** SET NIC BYPASS EVENT *** */
4538 struct cmd_set_bypass_event_result {
4539 cmdline_fixed_string_t set;
4540 cmdline_fixed_string_t bypass;
4541 cmdline_fixed_string_t event;
4542 cmdline_fixed_string_t event_value;
4543 cmdline_fixed_string_t mode;
4544 cmdline_fixed_string_t mode_value;
4549 cmd_set_bypass_event_parsed(void *parsed_result,
4550 __attribute__((unused)) struct cmdline *cl,
4551 __attribute__((unused)) void *data)
4553 int32_t rc = -EINVAL;
4554 struct cmd_set_bypass_event_result *res = parsed_result;
4555 portid_t port_id = res->port_id;
4557 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4558 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4559 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4561 if (!strcmp(res->event_value, "timeout"))
4562 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4563 else if (!strcmp(res->event_value, "os_on"))
4564 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4565 else if (!strcmp(res->event_value, "os_off"))
4566 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4567 else if (!strcmp(res->event_value, "power_on"))
4568 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4569 else if (!strcmp(res->event_value, "power_off"))
4570 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4572 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4574 if (!strcmp(res->mode_value, "bypass"))
4575 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4576 else if (!strcmp(res->mode_value, "isolate"))
4577 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4579 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4581 /* Set the watchdog timeout. */
4582 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4585 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4586 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4590 printf("Failed to set timeout value %u "
4591 "for port %d, errto code: %d.\n",
4592 bypass_timeout, port_id, rc);
4596 /* Set the bypass event to transition to bypass mode. */
4597 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4602 printf("\t Failed to set bypass event for port = %d.\n",
4606 cmdline_parse_token_string_t cmd_setbypass_event_set =
4607 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4609 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4610 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4612 cmdline_parse_token_string_t cmd_setbypass_event_event =
4613 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4615 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4616 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4617 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4618 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4619 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4621 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4622 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4623 mode_value, "normal#bypass#isolate");
4624 cmdline_parse_token_num_t cmd_setbypass_event_port =
4625 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4628 cmdline_parse_inst_t cmd_set_bypass_event = {
4629 .f = cmd_set_bypass_event_parsed,
4630 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4631 "power_off mode normal|bypass|isolate <port_id>: "
4632 "Set the NIC bypass event mode for port_id",
4635 (void *)&cmd_setbypass_event_set,
4636 (void *)&cmd_setbypass_event_bypass,
4637 (void *)&cmd_setbypass_event_event,
4638 (void *)&cmd_setbypass_event_event_value,
4639 (void *)&cmd_setbypass_event_mode,
4640 (void *)&cmd_setbypass_event_mode_value,
4641 (void *)&cmd_setbypass_event_port,
4647 /* *** SET NIC BYPASS TIMEOUT *** */
4648 struct cmd_set_bypass_timeout_result {
4649 cmdline_fixed_string_t set;
4650 cmdline_fixed_string_t bypass;
4651 cmdline_fixed_string_t timeout;
4652 cmdline_fixed_string_t value;
4656 cmd_set_bypass_timeout_parsed(void *parsed_result,
4657 __attribute__((unused)) struct cmdline *cl,
4658 __attribute__((unused)) void *data)
4660 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4662 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4663 if (!strcmp(res->value, "1.5"))
4664 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4665 else if (!strcmp(res->value, "2"))
4666 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4667 else if (!strcmp(res->value, "3"))
4668 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4669 else if (!strcmp(res->value, "4"))
4670 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4671 else if (!strcmp(res->value, "8"))
4672 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4673 else if (!strcmp(res->value, "16"))
4674 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4675 else if (!strcmp(res->value, "32"))
4676 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4678 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4682 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4683 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4685 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4686 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4688 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4689 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4690 timeout, "timeout");
4691 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4692 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4693 value, "0#1.5#2#3#4#8#16#32");
4695 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4696 .f = cmd_set_bypass_timeout_parsed,
4697 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4698 "Set the NIC bypass watchdog timeout in seconds",
4701 (void *)&cmd_setbypass_timeout_set,
4702 (void *)&cmd_setbypass_timeout_bypass,
4703 (void *)&cmd_setbypass_timeout_timeout,
4704 (void *)&cmd_setbypass_timeout_value,
4709 /* *** SHOW NIC BYPASS MODE *** */
4710 struct cmd_show_bypass_config_result {
4711 cmdline_fixed_string_t show;
4712 cmdline_fixed_string_t bypass;
4713 cmdline_fixed_string_t config;
4718 cmd_show_bypass_config_parsed(void *parsed_result,
4719 __attribute__((unused)) struct cmdline *cl,
4720 __attribute__((unused)) void *data)
4722 struct cmd_show_bypass_config_result *res = parsed_result;
4723 portid_t port_id = res->port_id;
4725 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4726 uint32_t event_mode;
4727 uint32_t bypass_mode;
4728 uint32_t timeout = bypass_timeout;
4731 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4732 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4733 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4734 {"UNKNOWN", "normal", "bypass", "isolate"};
4735 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4742 int num_events = (sizeof events) / (sizeof events[0]);
4744 /* Display the bypass mode.*/
4745 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4746 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4750 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4751 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4753 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4756 /* Display the bypass timeout.*/
4757 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4758 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4760 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4762 /* Display the bypass events and associated modes. */
4763 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4765 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4766 printf("\tFailed to get bypass mode for event = %s\n",
4769 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4770 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4772 printf("\tbypass event: %-16s = %s\n", events[i],
4778 printf("\tFailed to get bypass configuration for port = %d\n",
4782 cmdline_parse_token_string_t cmd_showbypass_config_show =
4783 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4785 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4786 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4788 cmdline_parse_token_string_t cmd_showbypass_config_config =
4789 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4791 cmdline_parse_token_num_t cmd_showbypass_config_port =
4792 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4795 cmdline_parse_inst_t cmd_show_bypass_config = {
4796 .f = cmd_show_bypass_config_parsed,
4797 .help_str = "show bypass config <port_id>: "
4798 "Show the NIC bypass config for port_id",
4801 (void *)&cmd_showbypass_config_show,
4802 (void *)&cmd_showbypass_config_bypass,
4803 (void *)&cmd_showbypass_config_config,
4804 (void *)&cmd_showbypass_config_port,
4809 #ifdef RTE_LIBRTE_PMD_BOND
4810 /* *** SET BONDING MODE *** */
4811 struct cmd_set_bonding_mode_result {
4812 cmdline_fixed_string_t set;
4813 cmdline_fixed_string_t bonding;
4814 cmdline_fixed_string_t mode;
4819 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4820 __attribute__((unused)) struct cmdline *cl,
4821 __attribute__((unused)) void *data)
4823 struct cmd_set_bonding_mode_result *res = parsed_result;
4824 portid_t port_id = res->port_id;
4826 /* Set the bonding mode for the relevant port. */
4827 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4828 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4831 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4832 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4834 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4835 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4836 bonding, "bonding");
4837 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4838 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4840 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4841 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4843 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4844 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4847 cmdline_parse_inst_t cmd_set_bonding_mode = {
4848 .f = cmd_set_bonding_mode_parsed,
4849 .help_str = "set bonding mode <mode_value> <port_id>: "
4850 "Set the bonding mode for port_id",
4853 (void *) &cmd_setbonding_mode_set,
4854 (void *) &cmd_setbonding_mode_bonding,
4855 (void *) &cmd_setbonding_mode_mode,
4856 (void *) &cmd_setbonding_mode_value,
4857 (void *) &cmd_setbonding_mode_port,
4862 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4863 struct cmd_set_bonding_lacp_dedicated_queues_result {
4864 cmdline_fixed_string_t set;
4865 cmdline_fixed_string_t bonding;
4866 cmdline_fixed_string_t lacp;
4867 cmdline_fixed_string_t dedicated_queues;
4869 cmdline_fixed_string_t mode;
4872 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4873 __attribute__((unused)) struct cmdline *cl,
4874 __attribute__((unused)) void *data)
4876 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4877 portid_t port_id = res->port_id;
4878 struct rte_port *port;
4880 port = &ports[port_id];
4882 /** Check if the port is not started **/
4883 if (port->port_status != RTE_PORT_STOPPED) {
4884 printf("Please stop port %d first\n", port_id);
4888 if (!strcmp(res->mode, "enable")) {
4889 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4890 printf("Dedicate queues for LACP control packets"
4893 printf("Enabling dedicate queues for LACP control "
4894 "packets on port %d failed\n", port_id);
4895 } else if (!strcmp(res->mode, "disable")) {
4896 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4897 printf("Dedicated queues for LACP control packets "
4900 printf("Disabling dedicated queues for LACP control "
4901 "traffic on port %d failed\n", port_id);
4905 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4906 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4908 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4909 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4910 bonding, "bonding");
4911 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4912 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4914 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4915 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4916 dedicated_queues, "dedicated_queues");
4917 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4918 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4920 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4921 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4922 mode, "enable#disable");
4924 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4925 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4926 .help_str = "set bonding lacp dedicated_queues <port_id> "
4928 "Enable/disable dedicated queues for LACP control traffic for port_id",
4931 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4932 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4933 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4934 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4935 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4936 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4941 /* *** SET BALANCE XMIT POLICY *** */
4942 struct cmd_set_bonding_balance_xmit_policy_result {
4943 cmdline_fixed_string_t set;
4944 cmdline_fixed_string_t bonding;
4945 cmdline_fixed_string_t balance_xmit_policy;
4947 cmdline_fixed_string_t policy;
4950 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4951 __attribute__((unused)) struct cmdline *cl,
4952 __attribute__((unused)) void *data)
4954 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4955 portid_t port_id = res->port_id;
4958 if (!strcmp(res->policy, "l2")) {
4959 policy = BALANCE_XMIT_POLICY_LAYER2;
4960 } else if (!strcmp(res->policy, "l23")) {
4961 policy = BALANCE_XMIT_POLICY_LAYER23;
4962 } else if (!strcmp(res->policy, "l34")) {
4963 policy = BALANCE_XMIT_POLICY_LAYER34;
4965 printf("\t Invalid xmit policy selection");
4969 /* Set the bonding mode for the relevant port. */
4970 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4971 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4976 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4977 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4979 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4980 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4981 bonding, "bonding");
4982 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4983 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4984 balance_xmit_policy, "balance_xmit_policy");
4985 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4986 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4988 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4989 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4990 policy, "l2#l23#l34");
4992 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4993 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4994 .help_str = "set bonding balance_xmit_policy <port_id> "
4996 "Set the bonding balance_xmit_policy for port_id",
4999 (void *)&cmd_setbonding_balance_xmit_policy_set,
5000 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5001 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5002 (void *)&cmd_setbonding_balance_xmit_policy_port,
5003 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5008 /* *** SHOW NIC BONDING CONFIGURATION *** */
5009 struct cmd_show_bonding_config_result {
5010 cmdline_fixed_string_t show;
5011 cmdline_fixed_string_t bonding;
5012 cmdline_fixed_string_t config;
5016 static void cmd_show_bonding_config_parsed(void *parsed_result,
5017 __attribute__((unused)) struct cmdline *cl,
5018 __attribute__((unused)) void *data)
5020 struct cmd_show_bonding_config_result *res = parsed_result;
5021 int bonding_mode, agg_mode;
5022 portid_t slaves[RTE_MAX_ETHPORTS];
5023 int num_slaves, num_active_slaves;
5026 portid_t port_id = res->port_id;
5028 /* Display the bonding mode.*/
5029 bonding_mode = rte_eth_bond_mode_get(port_id);
5030 if (bonding_mode < 0) {
5031 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5034 printf("\tBonding mode: %d\n", bonding_mode);
5036 if (bonding_mode == BONDING_MODE_BALANCE) {
5037 int balance_xmit_policy;
5039 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5040 if (balance_xmit_policy < 0) {
5041 printf("\tFailed to get balance xmit policy for port = %d\n",
5045 printf("\tBalance Xmit Policy: ");
5047 switch (balance_xmit_policy) {
5048 case BALANCE_XMIT_POLICY_LAYER2:
5049 printf("BALANCE_XMIT_POLICY_LAYER2");
5051 case BALANCE_XMIT_POLICY_LAYER23:
5052 printf("BALANCE_XMIT_POLICY_LAYER23");
5054 case BALANCE_XMIT_POLICY_LAYER34:
5055 printf("BALANCE_XMIT_POLICY_LAYER34");
5062 if (bonding_mode == BONDING_MODE_8023AD) {
5063 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5064 printf("\tIEEE802.3AD Aggregator Mode: ");
5067 printf("bandwidth");
5079 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5081 if (num_slaves < 0) {
5082 printf("\tFailed to get slave list for port = %d\n", port_id);
5085 if (num_slaves > 0) {
5086 printf("\tSlaves (%d): [", num_slaves);
5087 for (i = 0; i < num_slaves - 1; i++)
5088 printf("%d ", slaves[i]);
5090 printf("%d]\n", slaves[num_slaves - 1]);
5092 printf("\tSlaves: []\n");
5096 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5099 if (num_active_slaves < 0) {
5100 printf("\tFailed to get active slave list for port = %d\n", port_id);
5103 if (num_active_slaves > 0) {
5104 printf("\tActive Slaves (%d): [", num_active_slaves);
5105 for (i = 0; i < num_active_slaves - 1; i++)
5106 printf("%d ", slaves[i]);
5108 printf("%d]\n", slaves[num_active_slaves - 1]);
5111 printf("\tActive Slaves: []\n");
5115 primary_id = rte_eth_bond_primary_get(port_id);
5116 if (primary_id < 0) {
5117 printf("\tFailed to get primary slave for port = %d\n", port_id);
5120 printf("\tPrimary: [%d]\n", primary_id);
5124 cmdline_parse_token_string_t cmd_showbonding_config_show =
5125 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5127 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5128 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5129 bonding, "bonding");
5130 cmdline_parse_token_string_t cmd_showbonding_config_config =
5131 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5133 cmdline_parse_token_num_t cmd_showbonding_config_port =
5134 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5137 cmdline_parse_inst_t cmd_show_bonding_config = {
5138 .f = cmd_show_bonding_config_parsed,
5139 .help_str = "show bonding config <port_id>: "
5140 "Show the bonding config for port_id",
5143 (void *)&cmd_showbonding_config_show,
5144 (void *)&cmd_showbonding_config_bonding,
5145 (void *)&cmd_showbonding_config_config,
5146 (void *)&cmd_showbonding_config_port,
5151 /* *** SET BONDING PRIMARY *** */
5152 struct cmd_set_bonding_primary_result {
5153 cmdline_fixed_string_t set;
5154 cmdline_fixed_string_t bonding;
5155 cmdline_fixed_string_t primary;
5160 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5161 __attribute__((unused)) struct cmdline *cl,
5162 __attribute__((unused)) void *data)
5164 struct cmd_set_bonding_primary_result *res = parsed_result;
5165 portid_t master_port_id = res->port_id;
5166 portid_t slave_port_id = res->slave_id;
5168 /* Set the primary slave for a bonded device. */
5169 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5170 printf("\t Failed to set primary slave for port = %d.\n",
5177 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5178 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5180 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5181 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5182 bonding, "bonding");
5183 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5184 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5185 primary, "primary");
5186 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5187 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5189 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5190 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5193 cmdline_parse_inst_t cmd_set_bonding_primary = {
5194 .f = cmd_set_bonding_primary_parsed,
5195 .help_str = "set bonding primary <slave_id> <port_id>: "
5196 "Set the primary slave for port_id",
5199 (void *)&cmd_setbonding_primary_set,
5200 (void *)&cmd_setbonding_primary_bonding,
5201 (void *)&cmd_setbonding_primary_primary,
5202 (void *)&cmd_setbonding_primary_slave,
5203 (void *)&cmd_setbonding_primary_port,
5208 /* *** ADD SLAVE *** */
5209 struct cmd_add_bonding_slave_result {
5210 cmdline_fixed_string_t add;
5211 cmdline_fixed_string_t bonding;
5212 cmdline_fixed_string_t slave;
5217 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5218 __attribute__((unused)) struct cmdline *cl,
5219 __attribute__((unused)) void *data)
5221 struct cmd_add_bonding_slave_result *res = parsed_result;
5222 portid_t master_port_id = res->port_id;
5223 portid_t slave_port_id = res->slave_id;
5225 /* add the slave for a bonded device. */
5226 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5227 printf("\t Failed to add slave %d to master port = %d.\n",
5228 slave_port_id, master_port_id);
5232 set_port_slave_flag(slave_port_id);
5235 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5236 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5238 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5239 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5240 bonding, "bonding");
5241 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5242 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5244 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5245 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5247 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5248 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5251 cmdline_parse_inst_t cmd_add_bonding_slave = {
5252 .f = cmd_add_bonding_slave_parsed,
5253 .help_str = "add bonding slave <slave_id> <port_id>: "
5254 "Add a slave device to a bonded device",
5257 (void *)&cmd_addbonding_slave_add,
5258 (void *)&cmd_addbonding_slave_bonding,
5259 (void *)&cmd_addbonding_slave_slave,
5260 (void *)&cmd_addbonding_slave_slaveid,
5261 (void *)&cmd_addbonding_slave_port,
5266 /* *** REMOVE SLAVE *** */
5267 struct cmd_remove_bonding_slave_result {
5268 cmdline_fixed_string_t remove;
5269 cmdline_fixed_string_t bonding;
5270 cmdline_fixed_string_t slave;
5275 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5276 __attribute__((unused)) struct cmdline *cl,
5277 __attribute__((unused)) void *data)
5279 struct cmd_remove_bonding_slave_result *res = parsed_result;
5280 portid_t master_port_id = res->port_id;
5281 portid_t slave_port_id = res->slave_id;
5283 /* remove the slave from a bonded device. */
5284 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5285 printf("\t Failed to remove slave %d from master port = %d.\n",
5286 slave_port_id, master_port_id);
5290 clear_port_slave_flag(slave_port_id);
5293 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5294 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5296 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5297 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5298 bonding, "bonding");
5299 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5300 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5302 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5303 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5305 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5306 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5309 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5310 .f = cmd_remove_bonding_slave_parsed,
5311 .help_str = "remove bonding slave <slave_id> <port_id>: "
5312 "Remove a slave device from a bonded device",
5315 (void *)&cmd_removebonding_slave_remove,
5316 (void *)&cmd_removebonding_slave_bonding,
5317 (void *)&cmd_removebonding_slave_slave,
5318 (void *)&cmd_removebonding_slave_slaveid,
5319 (void *)&cmd_removebonding_slave_port,
5324 /* *** CREATE BONDED DEVICE *** */
5325 struct cmd_create_bonded_device_result {
5326 cmdline_fixed_string_t create;
5327 cmdline_fixed_string_t bonded;
5328 cmdline_fixed_string_t device;
5333 static int bond_dev_num = 0;
5335 static void cmd_create_bonded_device_parsed(void *parsed_result,
5336 __attribute__((unused)) struct cmdline *cl,
5337 __attribute__((unused)) void *data)
5339 struct cmd_create_bonded_device_result *res = parsed_result;
5340 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5343 if (test_done == 0) {
5344 printf("Please stop forwarding first\n");
5348 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5351 /* Create a new bonded device. */
5352 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5354 printf("\t Failed to create bonded device.\n");
5357 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5360 /* Update number of ports */
5361 nb_ports = rte_eth_dev_count();
5362 reconfig(port_id, res->socket);
5363 rte_eth_promiscuous_enable(port_id);
5368 cmdline_parse_token_string_t cmd_createbonded_device_create =
5369 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5371 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5372 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5374 cmdline_parse_token_string_t cmd_createbonded_device_device =
5375 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5377 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5378 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5380 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5381 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5384 cmdline_parse_inst_t cmd_create_bonded_device = {
5385 .f = cmd_create_bonded_device_parsed,
5386 .help_str = "create bonded device <mode> <socket>: "
5387 "Create a new bonded device with specific bonding mode and socket",
5390 (void *)&cmd_createbonded_device_create,
5391 (void *)&cmd_createbonded_device_bonded,
5392 (void *)&cmd_createbonded_device_device,
5393 (void *)&cmd_createbonded_device_mode,
5394 (void *)&cmd_createbonded_device_socket,
5399 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5400 struct cmd_set_bond_mac_addr_result {
5401 cmdline_fixed_string_t set;
5402 cmdline_fixed_string_t bonding;
5403 cmdline_fixed_string_t mac_addr;
5405 struct ether_addr address;
5408 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5409 __attribute__((unused)) struct cmdline *cl,
5410 __attribute__((unused)) void *data)
5412 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5415 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5418 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5420 /* check the return value and print it if is < 0 */
5422 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5425 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5426 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5427 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5428 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5430 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5431 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5433 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5434 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5436 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5437 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5439 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5440 .f = cmd_set_bond_mac_addr_parsed,
5442 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5444 (void *)&cmd_set_bond_mac_addr_set,
5445 (void *)&cmd_set_bond_mac_addr_bonding,
5446 (void *)&cmd_set_bond_mac_addr_mac,
5447 (void *)&cmd_set_bond_mac_addr_portnum,
5448 (void *)&cmd_set_bond_mac_addr_addr,
5454 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5455 struct cmd_set_bond_mon_period_result {
5456 cmdline_fixed_string_t set;
5457 cmdline_fixed_string_t bonding;
5458 cmdline_fixed_string_t mon_period;
5463 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5464 __attribute__((unused)) struct cmdline *cl,
5465 __attribute__((unused)) void *data)
5467 struct cmd_set_bond_mon_period_result *res = parsed_result;
5470 if (res->port_num >= nb_ports) {
5471 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5475 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5477 /* check the return value and print it if is < 0 */
5479 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5482 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5483 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5485 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5486 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5487 bonding, "bonding");
5488 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5489 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5490 mon_period, "mon_period");
5491 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5492 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5494 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5495 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5498 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5499 .f = cmd_set_bond_mon_period_parsed,
5501 .help_str = "set bonding mon_period <port_id> <period_ms>",
5503 (void *)&cmd_set_bond_mon_period_set,
5504 (void *)&cmd_set_bond_mon_period_bonding,
5505 (void *)&cmd_set_bond_mon_period_mon_period,
5506 (void *)&cmd_set_bond_mon_period_portnum,
5507 (void *)&cmd_set_bond_mon_period_period_ms,
5514 struct cmd_set_bonding_agg_mode_policy_result {
5515 cmdline_fixed_string_t set;
5516 cmdline_fixed_string_t bonding;
5517 cmdline_fixed_string_t agg_mode;
5519 cmdline_fixed_string_t policy;
5524 cmd_set_bonding_agg_mode(void *parsed_result,
5525 __attribute__((unused)) struct cmdline *cl,
5526 __attribute__((unused)) void *data)
5528 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5529 uint8_t policy = AGG_BANDWIDTH;
5531 if (res->port_num >= nb_ports) {
5532 printf("Port id %d must be less than %d\n",
5533 res->port_num, nb_ports);
5537 if (!strcmp(res->policy, "bandwidth"))
5538 policy = AGG_BANDWIDTH;
5539 else if (!strcmp(res->policy, "stable"))
5540 policy = AGG_STABLE;
5541 else if (!strcmp(res->policy, "count"))
5544 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5548 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5549 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5551 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5552 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5553 bonding, "bonding");
5555 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5556 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5557 agg_mode, "agg_mode");
5559 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5560 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5563 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5564 TOKEN_STRING_INITIALIZER(
5565 struct cmd_set_bonding_balance_xmit_policy_result,
5566 policy, "stable#bandwidth#count");
5568 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5569 .f = cmd_set_bonding_agg_mode,
5571 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5573 (void *)&cmd_set_bonding_agg_mode_set,
5574 (void *)&cmd_set_bonding_agg_mode_bonding,
5575 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5576 (void *)&cmd_set_bonding_agg_mode_portnum,
5577 (void *)&cmd_set_bonding_agg_mode_policy_string,
5583 #endif /* RTE_LIBRTE_PMD_BOND */
5585 /* *** SET FORWARDING MODE *** */
5586 struct cmd_set_fwd_mode_result {
5587 cmdline_fixed_string_t set;
5588 cmdline_fixed_string_t fwd;
5589 cmdline_fixed_string_t mode;
5592 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5593 __attribute__((unused)) struct cmdline *cl,
5594 __attribute__((unused)) void *data)
5596 struct cmd_set_fwd_mode_result *res = parsed_result;
5599 set_pkt_forwarding_mode(res->mode);
5602 cmdline_parse_token_string_t cmd_setfwd_set =
5603 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5604 cmdline_parse_token_string_t cmd_setfwd_fwd =
5605 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5606 cmdline_parse_token_string_t cmd_setfwd_mode =
5607 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5608 "" /* defined at init */);
5610 cmdline_parse_inst_t cmd_set_fwd_mode = {
5611 .f = cmd_set_fwd_mode_parsed,
5613 .help_str = NULL, /* defined at init */
5615 (void *)&cmd_setfwd_set,
5616 (void *)&cmd_setfwd_fwd,
5617 (void *)&cmd_setfwd_mode,
5622 static void cmd_set_fwd_mode_init(void)
5625 static char token[128];
5626 static char help[256];
5627 cmdline_parse_token_string_t *token_struct;
5629 modes = list_pkt_forwarding_modes();
5630 snprintf(help, sizeof(help), "set fwd %s: "
5631 "Set packet forwarding mode", modes);
5632 cmd_set_fwd_mode.help_str = help;
5634 /* string token separator is # */
5635 for (c = token; *modes != '\0'; modes++)
5640 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5641 token_struct->string_data.str = token;
5644 /* *** SET RETRY FORWARDING MODE *** */
5645 struct cmd_set_fwd_retry_mode_result {
5646 cmdline_fixed_string_t set;
5647 cmdline_fixed_string_t fwd;
5648 cmdline_fixed_string_t mode;
5649 cmdline_fixed_string_t retry;
5652 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5653 __attribute__((unused)) struct cmdline *cl,
5654 __attribute__((unused)) void *data)
5656 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5659 set_pkt_forwarding_mode(res->mode);
5662 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5663 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5665 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5666 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5668 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5669 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5671 "" /* defined at init */);
5672 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5673 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5676 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5677 .f = cmd_set_fwd_retry_mode_parsed,
5679 .help_str = NULL, /* defined at init */
5681 (void *)&cmd_setfwd_retry_set,
5682 (void *)&cmd_setfwd_retry_fwd,
5683 (void *)&cmd_setfwd_retry_mode,
5684 (void *)&cmd_setfwd_retry_retry,
5689 static void cmd_set_fwd_retry_mode_init(void)
5692 static char token[128];
5693 static char help[256];
5694 cmdline_parse_token_string_t *token_struct;
5696 modes = list_pkt_forwarding_retry_modes();
5697 snprintf(help, sizeof(help), "set fwd %s retry: "
5698 "Set packet forwarding mode with retry", modes);
5699 cmd_set_fwd_retry_mode.help_str = help;
5701 /* string token separator is # */
5702 for (c = token; *modes != '\0'; modes++)
5707 token_struct = (cmdline_parse_token_string_t *)
5708 cmd_set_fwd_retry_mode.tokens[2];
5709 token_struct->string_data.str = token;
5712 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5713 struct cmd_set_burst_tx_retry_result {
5714 cmdline_fixed_string_t set;
5715 cmdline_fixed_string_t burst;
5716 cmdline_fixed_string_t tx;
5717 cmdline_fixed_string_t delay;
5719 cmdline_fixed_string_t retry;
5723 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5724 __attribute__((unused)) struct cmdline *cl,
5725 __attribute__((unused)) void *data)
5727 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5729 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5730 && !strcmp(res->tx, "tx")) {
5731 if (!strcmp(res->delay, "delay"))
5732 burst_tx_delay_time = res->time;
5733 if (!strcmp(res->retry, "retry"))
5734 burst_tx_retry_num = res->retry_num;
5739 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5740 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5741 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5742 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5744 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5745 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5746 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5747 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5748 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5749 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5750 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5751 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5752 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5753 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5755 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5756 .f = cmd_set_burst_tx_retry_parsed,
5757 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5759 (void *)&cmd_set_burst_tx_retry_set,
5760 (void *)&cmd_set_burst_tx_retry_burst,
5761 (void *)&cmd_set_burst_tx_retry_tx,
5762 (void *)&cmd_set_burst_tx_retry_delay,
5763 (void *)&cmd_set_burst_tx_retry_time,
5764 (void *)&cmd_set_burst_tx_retry_retry,
5765 (void *)&cmd_set_burst_tx_retry_retry_num,
5770 /* *** SET PROMISC MODE *** */
5771 struct cmd_set_promisc_mode_result {
5772 cmdline_fixed_string_t set;
5773 cmdline_fixed_string_t promisc;
5774 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5775 uint16_t port_num; /* valid if "allports" argument == 0 */
5776 cmdline_fixed_string_t mode;
5779 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5780 __attribute__((unused)) struct cmdline *cl,
5783 struct cmd_set_promisc_mode_result *res = parsed_result;
5787 if (!strcmp(res->mode, "on"))
5794 RTE_ETH_FOREACH_DEV(i) {
5796 rte_eth_promiscuous_enable(i);
5798 rte_eth_promiscuous_disable(i);
5803 rte_eth_promiscuous_enable(res->port_num);
5805 rte_eth_promiscuous_disable(res->port_num);
5809 cmdline_parse_token_string_t cmd_setpromisc_set =
5810 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5811 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5812 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5814 cmdline_parse_token_string_t cmd_setpromisc_portall =
5815 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5817 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5818 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5820 cmdline_parse_token_string_t cmd_setpromisc_mode =
5821 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5824 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5825 .f = cmd_set_promisc_mode_parsed,
5827 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5829 (void *)&cmd_setpromisc_set,
5830 (void *)&cmd_setpromisc_promisc,
5831 (void *)&cmd_setpromisc_portall,
5832 (void *)&cmd_setpromisc_mode,
5837 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5838 .f = cmd_set_promisc_mode_parsed,
5840 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5842 (void *)&cmd_setpromisc_set,
5843 (void *)&cmd_setpromisc_promisc,
5844 (void *)&cmd_setpromisc_portnum,
5845 (void *)&cmd_setpromisc_mode,
5850 /* *** SET ALLMULTI MODE *** */
5851 struct cmd_set_allmulti_mode_result {
5852 cmdline_fixed_string_t set;
5853 cmdline_fixed_string_t allmulti;
5854 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5855 uint16_t port_num; /* valid if "allports" argument == 0 */
5856 cmdline_fixed_string_t mode;
5859 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5860 __attribute__((unused)) struct cmdline *cl,
5863 struct cmd_set_allmulti_mode_result *res = parsed_result;
5867 if (!strcmp(res->mode, "on"))
5874 RTE_ETH_FOREACH_DEV(i) {
5876 rte_eth_allmulticast_enable(i);
5878 rte_eth_allmulticast_disable(i);
5883 rte_eth_allmulticast_enable(res->port_num);
5885 rte_eth_allmulticast_disable(res->port_num);
5889 cmdline_parse_token_string_t cmd_setallmulti_set =
5890 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5891 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5892 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5894 cmdline_parse_token_string_t cmd_setallmulti_portall =
5895 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5897 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5898 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5900 cmdline_parse_token_string_t cmd_setallmulti_mode =
5901 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5904 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5905 .f = cmd_set_allmulti_mode_parsed,
5907 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5909 (void *)&cmd_setallmulti_set,
5910 (void *)&cmd_setallmulti_allmulti,
5911 (void *)&cmd_setallmulti_portall,
5912 (void *)&cmd_setallmulti_mode,
5917 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5918 .f = cmd_set_allmulti_mode_parsed,
5920 .help_str = "set allmulti <port_id> on|off: "
5921 "Set allmulti mode on port_id",
5923 (void *)&cmd_setallmulti_set,
5924 (void *)&cmd_setallmulti_allmulti,
5925 (void *)&cmd_setallmulti_portnum,
5926 (void *)&cmd_setallmulti_mode,
5931 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5932 struct cmd_link_flow_ctrl_set_result {
5933 cmdline_fixed_string_t set;
5934 cmdline_fixed_string_t flow_ctrl;
5935 cmdline_fixed_string_t rx;
5936 cmdline_fixed_string_t rx_lfc_mode;
5937 cmdline_fixed_string_t tx;
5938 cmdline_fixed_string_t tx_lfc_mode;
5939 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5940 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5941 cmdline_fixed_string_t autoneg_str;
5942 cmdline_fixed_string_t autoneg;
5943 cmdline_fixed_string_t hw_str;
5944 uint32_t high_water;
5945 cmdline_fixed_string_t lw_str;
5947 cmdline_fixed_string_t pt_str;
5948 uint16_t pause_time;
5949 cmdline_fixed_string_t xon_str;
5954 cmdline_parse_token_string_t cmd_lfc_set_set =
5955 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5957 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5958 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5959 flow_ctrl, "flow_ctrl");
5960 cmdline_parse_token_string_t cmd_lfc_set_rx =
5961 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5963 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5964 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5965 rx_lfc_mode, "on#off");
5966 cmdline_parse_token_string_t cmd_lfc_set_tx =
5967 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5969 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5970 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5971 tx_lfc_mode, "on#off");
5972 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5973 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5974 hw_str, "high_water");
5975 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5976 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5977 high_water, UINT32);
5978 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5979 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5980 lw_str, "low_water");
5981 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5982 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5984 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5985 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5986 pt_str, "pause_time");
5987 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5988 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5989 pause_time, UINT16);
5990 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5991 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5992 xon_str, "send_xon");
5993 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5994 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5996 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5997 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5998 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5999 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6000 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6001 mac_ctrl_frame_fwd_mode, "on#off");
6002 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6003 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6004 autoneg_str, "autoneg");
6005 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6006 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6008 cmdline_parse_token_num_t cmd_lfc_set_portid =
6009 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6012 /* forward declaration */
6014 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6017 cmdline_parse_inst_t cmd_link_flow_control_set = {
6018 .f = cmd_link_flow_ctrl_set_parsed,
6020 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6021 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6022 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6024 (void *)&cmd_lfc_set_set,
6025 (void *)&cmd_lfc_set_flow_ctrl,
6026 (void *)&cmd_lfc_set_rx,
6027 (void *)&cmd_lfc_set_rx_mode,
6028 (void *)&cmd_lfc_set_tx,
6029 (void *)&cmd_lfc_set_tx_mode,
6030 (void *)&cmd_lfc_set_high_water,
6031 (void *)&cmd_lfc_set_low_water,
6032 (void *)&cmd_lfc_set_pause_time,
6033 (void *)&cmd_lfc_set_send_xon,
6034 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6035 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6036 (void *)&cmd_lfc_set_autoneg_str,
6037 (void *)&cmd_lfc_set_autoneg,
6038 (void *)&cmd_lfc_set_portid,
6043 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6044 .f = cmd_link_flow_ctrl_set_parsed,
6045 .data = (void *)&cmd_link_flow_control_set_rx,
6046 .help_str = "set flow_ctrl rx on|off <port_id>: "
6047 "Change rx flow control parameter",
6049 (void *)&cmd_lfc_set_set,
6050 (void *)&cmd_lfc_set_flow_ctrl,
6051 (void *)&cmd_lfc_set_rx,
6052 (void *)&cmd_lfc_set_rx_mode,
6053 (void *)&cmd_lfc_set_portid,
6058 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6059 .f = cmd_link_flow_ctrl_set_parsed,
6060 .data = (void *)&cmd_link_flow_control_set_tx,
6061 .help_str = "set flow_ctrl tx on|off <port_id>: "
6062 "Change tx flow control parameter",
6064 (void *)&cmd_lfc_set_set,
6065 (void *)&cmd_lfc_set_flow_ctrl,
6066 (void *)&cmd_lfc_set_tx,
6067 (void *)&cmd_lfc_set_tx_mode,
6068 (void *)&cmd_lfc_set_portid,
6073 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6074 .f = cmd_link_flow_ctrl_set_parsed,
6075 .data = (void *)&cmd_link_flow_control_set_hw,
6076 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6077 "Change high water flow control parameter",
6079 (void *)&cmd_lfc_set_set,
6080 (void *)&cmd_lfc_set_flow_ctrl,
6081 (void *)&cmd_lfc_set_high_water_str,
6082 (void *)&cmd_lfc_set_high_water,
6083 (void *)&cmd_lfc_set_portid,
6088 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6089 .f = cmd_link_flow_ctrl_set_parsed,
6090 .data = (void *)&cmd_link_flow_control_set_lw,
6091 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6092 "Change low water flow control parameter",
6094 (void *)&cmd_lfc_set_set,
6095 (void *)&cmd_lfc_set_flow_ctrl,
6096 (void *)&cmd_lfc_set_low_water_str,
6097 (void *)&cmd_lfc_set_low_water,
6098 (void *)&cmd_lfc_set_portid,
6103 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6104 .f = cmd_link_flow_ctrl_set_parsed,
6105 .data = (void *)&cmd_link_flow_control_set_pt,
6106 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6107 "Change pause time flow control parameter",
6109 (void *)&cmd_lfc_set_set,
6110 (void *)&cmd_lfc_set_flow_ctrl,
6111 (void *)&cmd_lfc_set_pause_time_str,
6112 (void *)&cmd_lfc_set_pause_time,
6113 (void *)&cmd_lfc_set_portid,
6118 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6119 .f = cmd_link_flow_ctrl_set_parsed,
6120 .data = (void *)&cmd_link_flow_control_set_xon,
6121 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6122 "Change send_xon flow control parameter",
6124 (void *)&cmd_lfc_set_set,
6125 (void *)&cmd_lfc_set_flow_ctrl,
6126 (void *)&cmd_lfc_set_send_xon_str,
6127 (void *)&cmd_lfc_set_send_xon,
6128 (void *)&cmd_lfc_set_portid,
6133 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6134 .f = cmd_link_flow_ctrl_set_parsed,
6135 .data = (void *)&cmd_link_flow_control_set_macfwd,
6136 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6137 "Change mac ctrl fwd flow control parameter",
6139 (void *)&cmd_lfc_set_set,
6140 (void *)&cmd_lfc_set_flow_ctrl,
6141 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6142 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6143 (void *)&cmd_lfc_set_portid,
6148 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6149 .f = cmd_link_flow_ctrl_set_parsed,
6150 .data = (void *)&cmd_link_flow_control_set_autoneg,
6151 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6152 "Change autoneg flow control parameter",
6154 (void *)&cmd_lfc_set_set,
6155 (void *)&cmd_lfc_set_flow_ctrl,
6156 (void *)&cmd_lfc_set_autoneg_str,
6157 (void *)&cmd_lfc_set_autoneg,
6158 (void *)&cmd_lfc_set_portid,
6164 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6165 __attribute__((unused)) struct cmdline *cl,
6168 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6169 cmdline_parse_inst_t *cmd = data;
6170 struct rte_eth_fc_conf fc_conf;
6176 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6177 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6178 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6179 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6181 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6182 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6185 /* Partial command line, retrieve current configuration */
6187 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6189 printf("cannot get current flow ctrl parameters, return"
6190 "code = %d\n", ret);
6194 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6195 (fc_conf.mode == RTE_FC_FULL))
6197 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6198 (fc_conf.mode == RTE_FC_FULL))
6202 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6203 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6205 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6206 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6208 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6210 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6211 fc_conf.high_water = res->high_water;
6213 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6214 fc_conf.low_water = res->low_water;
6216 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6217 fc_conf.pause_time = res->pause_time;
6219 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6220 fc_conf.send_xon = res->send_xon;
6222 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6223 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6224 fc_conf.mac_ctrl_frame_fwd = 1;
6226 fc_conf.mac_ctrl_frame_fwd = 0;
6229 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6230 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6232 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6234 printf("bad flow contrl parameter, return code = %d \n", ret);
6237 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6238 struct cmd_priority_flow_ctrl_set_result {
6239 cmdline_fixed_string_t set;
6240 cmdline_fixed_string_t pfc_ctrl;
6241 cmdline_fixed_string_t rx;
6242 cmdline_fixed_string_t rx_pfc_mode;
6243 cmdline_fixed_string_t tx;
6244 cmdline_fixed_string_t tx_pfc_mode;
6245 uint32_t high_water;
6247 uint16_t pause_time;
6253 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6254 __attribute__((unused)) struct cmdline *cl,
6255 __attribute__((unused)) void *data)
6257 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6258 struct rte_eth_pfc_conf pfc_conf;
6259 int rx_fc_enable, tx_fc_enable;
6263 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6264 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6265 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6266 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6268 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6269 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6272 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6273 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6274 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6275 pfc_conf.fc.high_water = res->high_water;
6276 pfc_conf.fc.low_water = res->low_water;
6277 pfc_conf.fc.pause_time = res->pause_time;
6278 pfc_conf.priority = res->priority;
6280 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6282 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6285 cmdline_parse_token_string_t cmd_pfc_set_set =
6286 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6288 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6289 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6290 pfc_ctrl, "pfc_ctrl");
6291 cmdline_parse_token_string_t cmd_pfc_set_rx =
6292 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6294 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6295 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6296 rx_pfc_mode, "on#off");
6297 cmdline_parse_token_string_t cmd_pfc_set_tx =
6298 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6300 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6301 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6302 tx_pfc_mode, "on#off");
6303 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6304 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6305 high_water, UINT32);
6306 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6307 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6309 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6310 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6311 pause_time, UINT16);
6312 cmdline_parse_token_num_t cmd_pfc_set_priority =
6313 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6315 cmdline_parse_token_num_t cmd_pfc_set_portid =
6316 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6319 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6320 .f = cmd_priority_flow_ctrl_set_parsed,
6322 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6323 "<pause_time> <priority> <port_id>: "
6324 "Configure the Ethernet priority flow control",
6326 (void *)&cmd_pfc_set_set,
6327 (void *)&cmd_pfc_set_flow_ctrl,
6328 (void *)&cmd_pfc_set_rx,
6329 (void *)&cmd_pfc_set_rx_mode,
6330 (void *)&cmd_pfc_set_tx,
6331 (void *)&cmd_pfc_set_tx_mode,
6332 (void *)&cmd_pfc_set_high_water,
6333 (void *)&cmd_pfc_set_low_water,
6334 (void *)&cmd_pfc_set_pause_time,
6335 (void *)&cmd_pfc_set_priority,
6336 (void *)&cmd_pfc_set_portid,
6341 /* *** RESET CONFIGURATION *** */
6342 struct cmd_reset_result {
6343 cmdline_fixed_string_t reset;
6344 cmdline_fixed_string_t def;
6347 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6349 __attribute__((unused)) void *data)
6351 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6352 set_def_fwd_config();
6355 cmdline_parse_token_string_t cmd_reset_set =
6356 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6357 cmdline_parse_token_string_t cmd_reset_def =
6358 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6361 cmdline_parse_inst_t cmd_reset = {
6362 .f = cmd_reset_parsed,
6364 .help_str = "set default: Reset default forwarding configuration",
6366 (void *)&cmd_reset_set,
6367 (void *)&cmd_reset_def,
6372 /* *** START FORWARDING *** */
6373 struct cmd_start_result {
6374 cmdline_fixed_string_t start;
6377 cmdline_parse_token_string_t cmd_start_start =
6378 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6380 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6381 __attribute__((unused)) struct cmdline *cl,
6382 __attribute__((unused)) void *data)
6384 start_packet_forwarding(0);
6387 cmdline_parse_inst_t cmd_start = {
6388 .f = cmd_start_parsed,
6390 .help_str = "start: Start packet forwarding",
6392 (void *)&cmd_start_start,
6397 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6398 struct cmd_start_tx_first_result {
6399 cmdline_fixed_string_t start;
6400 cmdline_fixed_string_t tx_first;
6404 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6405 __attribute__((unused)) struct cmdline *cl,
6406 __attribute__((unused)) void *data)
6408 start_packet_forwarding(1);
6411 cmdline_parse_token_string_t cmd_start_tx_first_start =
6412 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6414 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6415 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6416 tx_first, "tx_first");
6418 cmdline_parse_inst_t cmd_start_tx_first = {
6419 .f = cmd_start_tx_first_parsed,
6421 .help_str = "start tx_first: Start packet forwarding, "
6422 "after sending 1 burst of packets",
6424 (void *)&cmd_start_tx_first_start,
6425 (void *)&cmd_start_tx_first_tx_first,
6430 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6431 struct cmd_start_tx_first_n_result {
6432 cmdline_fixed_string_t start;
6433 cmdline_fixed_string_t tx_first;
6438 cmd_start_tx_first_n_parsed(void *parsed_result,
6439 __attribute__((unused)) struct cmdline *cl,
6440 __attribute__((unused)) void *data)
6442 struct cmd_start_tx_first_n_result *res = parsed_result;
6444 start_packet_forwarding(res->tx_num);
6447 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6448 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6450 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6451 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6452 tx_first, "tx_first");
6453 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6454 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6457 cmdline_parse_inst_t cmd_start_tx_first_n = {
6458 .f = cmd_start_tx_first_n_parsed,
6460 .help_str = "start tx_first <num>: "
6461 "packet forwarding, after sending <num> bursts of packets",
6463 (void *)&cmd_start_tx_first_n_start,
6464 (void *)&cmd_start_tx_first_n_tx_first,
6465 (void *)&cmd_start_tx_first_n_tx_num,
6470 /* *** SET LINK UP *** */
6471 struct cmd_set_link_up_result {
6472 cmdline_fixed_string_t set;
6473 cmdline_fixed_string_t link_up;
6474 cmdline_fixed_string_t port;
6478 cmdline_parse_token_string_t cmd_set_link_up_set =
6479 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6480 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6481 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6483 cmdline_parse_token_string_t cmd_set_link_up_port =
6484 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6485 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6486 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6488 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6489 __attribute__((unused)) struct cmdline *cl,
6490 __attribute__((unused)) void *data)
6492 struct cmd_set_link_up_result *res = parsed_result;
6493 dev_set_link_up(res->port_id);
6496 cmdline_parse_inst_t cmd_set_link_up = {
6497 .f = cmd_set_link_up_parsed,
6499 .help_str = "set link-up port <port id>",
6501 (void *)&cmd_set_link_up_set,
6502 (void *)&cmd_set_link_up_link_up,
6503 (void *)&cmd_set_link_up_port,
6504 (void *)&cmd_set_link_up_port_id,
6509 /* *** SET LINK DOWN *** */
6510 struct cmd_set_link_down_result {
6511 cmdline_fixed_string_t set;
6512 cmdline_fixed_string_t link_down;
6513 cmdline_fixed_string_t port;
6517 cmdline_parse_token_string_t cmd_set_link_down_set =
6518 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6519 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6520 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6522 cmdline_parse_token_string_t cmd_set_link_down_port =
6523 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6524 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6525 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6527 static void cmd_set_link_down_parsed(
6528 __attribute__((unused)) void *parsed_result,
6529 __attribute__((unused)) struct cmdline *cl,
6530 __attribute__((unused)) void *data)
6532 struct cmd_set_link_down_result *res = parsed_result;
6533 dev_set_link_down(res->port_id);
6536 cmdline_parse_inst_t cmd_set_link_down = {
6537 .f = cmd_set_link_down_parsed,
6539 .help_str = "set link-down port <port id>",
6541 (void *)&cmd_set_link_down_set,
6542 (void *)&cmd_set_link_down_link_down,
6543 (void *)&cmd_set_link_down_port,
6544 (void *)&cmd_set_link_down_port_id,
6549 /* *** SHOW CFG *** */
6550 struct cmd_showcfg_result {
6551 cmdline_fixed_string_t show;
6552 cmdline_fixed_string_t cfg;
6553 cmdline_fixed_string_t what;
6556 static void cmd_showcfg_parsed(void *parsed_result,
6557 __attribute__((unused)) struct cmdline *cl,
6558 __attribute__((unused)) void *data)
6560 struct cmd_showcfg_result *res = parsed_result;
6561 if (!strcmp(res->what, "rxtx"))
6562 rxtx_config_display();
6563 else if (!strcmp(res->what, "cores"))
6564 fwd_lcores_config_display();
6565 else if (!strcmp(res->what, "fwd"))
6566 pkt_fwd_config_display(&cur_fwd_config);
6567 else if (!strcmp(res->what, "txpkts"))
6568 show_tx_pkt_segments();
6571 cmdline_parse_token_string_t cmd_showcfg_show =
6572 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6573 cmdline_parse_token_string_t cmd_showcfg_port =
6574 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6575 cmdline_parse_token_string_t cmd_showcfg_what =
6576 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6577 "rxtx#cores#fwd#txpkts");
6579 cmdline_parse_inst_t cmd_showcfg = {
6580 .f = cmd_showcfg_parsed,
6582 .help_str = "show config rxtx|cores|fwd|txpkts",
6584 (void *)&cmd_showcfg_show,
6585 (void *)&cmd_showcfg_port,
6586 (void *)&cmd_showcfg_what,
6591 /* *** SHOW ALL PORT INFO *** */
6592 struct cmd_showportall_result {
6593 cmdline_fixed_string_t show;
6594 cmdline_fixed_string_t port;
6595 cmdline_fixed_string_t what;
6596 cmdline_fixed_string_t all;
6599 static void cmd_showportall_parsed(void *parsed_result,
6600 __attribute__((unused)) struct cmdline *cl,
6601 __attribute__((unused)) void *data)
6605 struct cmd_showportall_result *res = parsed_result;
6606 if (!strcmp(res->show, "clear")) {
6607 if (!strcmp(res->what, "stats"))
6608 RTE_ETH_FOREACH_DEV(i)
6610 else if (!strcmp(res->what, "xstats"))
6611 RTE_ETH_FOREACH_DEV(i)
6612 nic_xstats_clear(i);
6613 } else if (!strcmp(res->what, "info"))
6614 RTE_ETH_FOREACH_DEV(i)
6615 port_infos_display(i);
6616 else if (!strcmp(res->what, "stats"))
6617 RTE_ETH_FOREACH_DEV(i)
6618 nic_stats_display(i);
6619 else if (!strcmp(res->what, "xstats"))
6620 RTE_ETH_FOREACH_DEV(i)
6621 nic_xstats_display(i);
6622 else if (!strcmp(res->what, "fdir"))
6623 RTE_ETH_FOREACH_DEV(i)
6625 else if (!strcmp(res->what, "stat_qmap"))
6626 RTE_ETH_FOREACH_DEV(i)
6627 nic_stats_mapping_display(i);
6628 else if (!strcmp(res->what, "dcb_tc"))
6629 RTE_ETH_FOREACH_DEV(i)
6630 port_dcb_info_display(i);
6631 else if (!strcmp(res->what, "cap"))
6632 RTE_ETH_FOREACH_DEV(i)
6633 port_offload_cap_display(i);
6636 cmdline_parse_token_string_t cmd_showportall_show =
6637 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6639 cmdline_parse_token_string_t cmd_showportall_port =
6640 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6641 cmdline_parse_token_string_t cmd_showportall_what =
6642 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6643 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6644 cmdline_parse_token_string_t cmd_showportall_all =
6645 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6646 cmdline_parse_inst_t cmd_showportall = {
6647 .f = cmd_showportall_parsed,
6649 .help_str = "show|clear port "
6650 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6652 (void *)&cmd_showportall_show,
6653 (void *)&cmd_showportall_port,
6654 (void *)&cmd_showportall_what,
6655 (void *)&cmd_showportall_all,
6660 /* *** SHOW PORT INFO *** */
6661 struct cmd_showport_result {
6662 cmdline_fixed_string_t show;
6663 cmdline_fixed_string_t port;
6664 cmdline_fixed_string_t what;
6668 static void cmd_showport_parsed(void *parsed_result,
6669 __attribute__((unused)) struct cmdline *cl,
6670 __attribute__((unused)) void *data)
6672 struct cmd_showport_result *res = parsed_result;
6673 if (!strcmp(res->show, "clear")) {
6674 if (!strcmp(res->what, "stats"))
6675 nic_stats_clear(res->portnum);
6676 else if (!strcmp(res->what, "xstats"))
6677 nic_xstats_clear(res->portnum);
6678 } else if (!strcmp(res->what, "info"))
6679 port_infos_display(res->portnum);
6680 else if (!strcmp(res->what, "stats"))
6681 nic_stats_display(res->portnum);
6682 else if (!strcmp(res->what, "xstats"))
6683 nic_xstats_display(res->portnum);
6684 else if (!strcmp(res->what, "fdir"))
6685 fdir_get_infos(res->portnum);
6686 else if (!strcmp(res->what, "stat_qmap"))
6687 nic_stats_mapping_display(res->portnum);
6688 else if (!strcmp(res->what, "dcb_tc"))
6689 port_dcb_info_display(res->portnum);
6690 else if (!strcmp(res->what, "cap"))
6691 port_offload_cap_display(res->portnum);
6694 cmdline_parse_token_string_t cmd_showport_show =
6695 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6697 cmdline_parse_token_string_t cmd_showport_port =
6698 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6699 cmdline_parse_token_string_t cmd_showport_what =
6700 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6701 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6702 cmdline_parse_token_num_t cmd_showport_portnum =
6703 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6705 cmdline_parse_inst_t cmd_showport = {
6706 .f = cmd_showport_parsed,
6708 .help_str = "show|clear port "
6709 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6712 (void *)&cmd_showport_show,
6713 (void *)&cmd_showport_port,
6714 (void *)&cmd_showport_what,
6715 (void *)&cmd_showport_portnum,
6720 /* *** SHOW QUEUE INFO *** */
6721 struct cmd_showqueue_result {
6722 cmdline_fixed_string_t show;
6723 cmdline_fixed_string_t type;
6724 cmdline_fixed_string_t what;
6730 cmd_showqueue_parsed(void *parsed_result,
6731 __attribute__((unused)) struct cmdline *cl,
6732 __attribute__((unused)) void *data)
6734 struct cmd_showqueue_result *res = parsed_result;
6736 if (!strcmp(res->type, "rxq"))
6737 rx_queue_infos_display(res->portnum, res->queuenum);
6738 else if (!strcmp(res->type, "txq"))
6739 tx_queue_infos_display(res->portnum, res->queuenum);
6742 cmdline_parse_token_string_t cmd_showqueue_show =
6743 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6744 cmdline_parse_token_string_t cmd_showqueue_type =
6745 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6746 cmdline_parse_token_string_t cmd_showqueue_what =
6747 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6748 cmdline_parse_token_num_t cmd_showqueue_portnum =
6749 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6750 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6751 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6753 cmdline_parse_inst_t cmd_showqueue = {
6754 .f = cmd_showqueue_parsed,
6756 .help_str = "show rxq|txq info <port_id> <queue_id>",
6758 (void *)&cmd_showqueue_show,
6759 (void *)&cmd_showqueue_type,
6760 (void *)&cmd_showqueue_what,
6761 (void *)&cmd_showqueue_portnum,
6762 (void *)&cmd_showqueue_queuenum,
6767 /* *** READ PORT REGISTER *** */
6768 struct cmd_read_reg_result {
6769 cmdline_fixed_string_t read;
6770 cmdline_fixed_string_t reg;
6776 cmd_read_reg_parsed(void *parsed_result,
6777 __attribute__((unused)) struct cmdline *cl,
6778 __attribute__((unused)) void *data)
6780 struct cmd_read_reg_result *res = parsed_result;
6781 port_reg_display(res->port_id, res->reg_off);
6784 cmdline_parse_token_string_t cmd_read_reg_read =
6785 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6786 cmdline_parse_token_string_t cmd_read_reg_reg =
6787 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6788 cmdline_parse_token_num_t cmd_read_reg_port_id =
6789 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6790 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6791 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6793 cmdline_parse_inst_t cmd_read_reg = {
6794 .f = cmd_read_reg_parsed,
6796 .help_str = "read reg <port_id> <reg_off>",
6798 (void *)&cmd_read_reg_read,
6799 (void *)&cmd_read_reg_reg,
6800 (void *)&cmd_read_reg_port_id,
6801 (void *)&cmd_read_reg_reg_off,
6806 /* *** READ PORT REGISTER BIT FIELD *** */
6807 struct cmd_read_reg_bit_field_result {
6808 cmdline_fixed_string_t read;
6809 cmdline_fixed_string_t regfield;
6817 cmd_read_reg_bit_field_parsed(void *parsed_result,
6818 __attribute__((unused)) struct cmdline *cl,
6819 __attribute__((unused)) void *data)
6821 struct cmd_read_reg_bit_field_result *res = parsed_result;
6822 port_reg_bit_field_display(res->port_id, res->reg_off,
6823 res->bit1_pos, res->bit2_pos);
6826 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6827 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6829 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6830 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6831 regfield, "regfield");
6832 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6833 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6835 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6836 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6838 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6839 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6841 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6842 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6845 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6846 .f = cmd_read_reg_bit_field_parsed,
6848 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6849 "Read register bit field between bit_x and bit_y included",
6851 (void *)&cmd_read_reg_bit_field_read,
6852 (void *)&cmd_read_reg_bit_field_regfield,
6853 (void *)&cmd_read_reg_bit_field_port_id,
6854 (void *)&cmd_read_reg_bit_field_reg_off,
6855 (void *)&cmd_read_reg_bit_field_bit1_pos,
6856 (void *)&cmd_read_reg_bit_field_bit2_pos,
6861 /* *** READ PORT REGISTER BIT *** */
6862 struct cmd_read_reg_bit_result {
6863 cmdline_fixed_string_t read;
6864 cmdline_fixed_string_t regbit;
6871 cmd_read_reg_bit_parsed(void *parsed_result,
6872 __attribute__((unused)) struct cmdline *cl,
6873 __attribute__((unused)) void *data)
6875 struct cmd_read_reg_bit_result *res = parsed_result;
6876 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6879 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6880 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6881 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6882 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6884 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6885 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6886 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6887 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6888 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6889 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6891 cmdline_parse_inst_t cmd_read_reg_bit = {
6892 .f = cmd_read_reg_bit_parsed,
6894 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6896 (void *)&cmd_read_reg_bit_read,
6897 (void *)&cmd_read_reg_bit_regbit,
6898 (void *)&cmd_read_reg_bit_port_id,
6899 (void *)&cmd_read_reg_bit_reg_off,
6900 (void *)&cmd_read_reg_bit_bit_pos,
6905 /* *** WRITE PORT REGISTER *** */
6906 struct cmd_write_reg_result {
6907 cmdline_fixed_string_t write;
6908 cmdline_fixed_string_t reg;
6915 cmd_write_reg_parsed(void *parsed_result,
6916 __attribute__((unused)) struct cmdline *cl,
6917 __attribute__((unused)) void *data)
6919 struct cmd_write_reg_result *res = parsed_result;
6920 port_reg_set(res->port_id, res->reg_off, res->value);
6923 cmdline_parse_token_string_t cmd_write_reg_write =
6924 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6925 cmdline_parse_token_string_t cmd_write_reg_reg =
6926 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6927 cmdline_parse_token_num_t cmd_write_reg_port_id =
6928 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6929 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6930 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6931 cmdline_parse_token_num_t cmd_write_reg_value =
6932 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6934 cmdline_parse_inst_t cmd_write_reg = {
6935 .f = cmd_write_reg_parsed,
6937 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6939 (void *)&cmd_write_reg_write,
6940 (void *)&cmd_write_reg_reg,
6941 (void *)&cmd_write_reg_port_id,
6942 (void *)&cmd_write_reg_reg_off,
6943 (void *)&cmd_write_reg_value,
6948 /* *** WRITE PORT REGISTER BIT FIELD *** */
6949 struct cmd_write_reg_bit_field_result {
6950 cmdline_fixed_string_t write;
6951 cmdline_fixed_string_t regfield;
6960 cmd_write_reg_bit_field_parsed(void *parsed_result,
6961 __attribute__((unused)) struct cmdline *cl,
6962 __attribute__((unused)) void *data)
6964 struct cmd_write_reg_bit_field_result *res = parsed_result;
6965 port_reg_bit_field_set(res->port_id, res->reg_off,
6966 res->bit1_pos, res->bit2_pos, res->value);
6969 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6970 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6972 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6973 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6974 regfield, "regfield");
6975 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6976 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6978 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6979 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6981 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6982 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6984 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6985 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6987 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6988 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6991 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6992 .f = cmd_write_reg_bit_field_parsed,
6994 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6996 "Set register bit field between bit_x and bit_y included",
6998 (void *)&cmd_write_reg_bit_field_write,
6999 (void *)&cmd_write_reg_bit_field_regfield,
7000 (void *)&cmd_write_reg_bit_field_port_id,
7001 (void *)&cmd_write_reg_bit_field_reg_off,
7002 (void *)&cmd_write_reg_bit_field_bit1_pos,
7003 (void *)&cmd_write_reg_bit_field_bit2_pos,
7004 (void *)&cmd_write_reg_bit_field_value,
7009 /* *** WRITE PORT REGISTER BIT *** */
7010 struct cmd_write_reg_bit_result {
7011 cmdline_fixed_string_t write;
7012 cmdline_fixed_string_t regbit;
7020 cmd_write_reg_bit_parsed(void *parsed_result,
7021 __attribute__((unused)) struct cmdline *cl,
7022 __attribute__((unused)) void *data)
7024 struct cmd_write_reg_bit_result *res = parsed_result;
7025 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7028 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7029 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7031 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7032 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7034 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7035 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7036 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7037 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7038 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7039 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7040 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7041 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7043 cmdline_parse_inst_t cmd_write_reg_bit = {
7044 .f = cmd_write_reg_bit_parsed,
7046 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7049 (void *)&cmd_write_reg_bit_write,
7050 (void *)&cmd_write_reg_bit_regbit,
7051 (void *)&cmd_write_reg_bit_port_id,
7052 (void *)&cmd_write_reg_bit_reg_off,
7053 (void *)&cmd_write_reg_bit_bit_pos,
7054 (void *)&cmd_write_reg_bit_value,
7059 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7060 struct cmd_read_rxd_txd_result {
7061 cmdline_fixed_string_t read;
7062 cmdline_fixed_string_t rxd_txd;
7069 cmd_read_rxd_txd_parsed(void *parsed_result,
7070 __attribute__((unused)) struct cmdline *cl,
7071 __attribute__((unused)) void *data)
7073 struct cmd_read_rxd_txd_result *res = parsed_result;
7075 if (!strcmp(res->rxd_txd, "rxd"))
7076 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7077 else if (!strcmp(res->rxd_txd, "txd"))
7078 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7081 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7082 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7083 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7084 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7086 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7087 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7088 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7089 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7090 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7091 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7093 cmdline_parse_inst_t cmd_read_rxd_txd = {
7094 .f = cmd_read_rxd_txd_parsed,
7096 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7098 (void *)&cmd_read_rxd_txd_read,
7099 (void *)&cmd_read_rxd_txd_rxd_txd,
7100 (void *)&cmd_read_rxd_txd_port_id,
7101 (void *)&cmd_read_rxd_txd_queue_id,
7102 (void *)&cmd_read_rxd_txd_desc_id,
7108 struct cmd_quit_result {
7109 cmdline_fixed_string_t quit;
7112 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7114 __attribute__((unused)) void *data)
7120 cmdline_parse_token_string_t cmd_quit_quit =
7121 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7123 cmdline_parse_inst_t cmd_quit = {
7124 .f = cmd_quit_parsed,
7126 .help_str = "quit: Exit application",
7128 (void *)&cmd_quit_quit,
7133 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7134 struct cmd_mac_addr_result {
7135 cmdline_fixed_string_t mac_addr_cmd;
7136 cmdline_fixed_string_t what;
7138 struct ether_addr address;
7141 static void cmd_mac_addr_parsed(void *parsed_result,
7142 __attribute__((unused)) struct cmdline *cl,
7143 __attribute__((unused)) void *data)
7145 struct cmd_mac_addr_result *res = parsed_result;
7148 if (strcmp(res->what, "add") == 0)
7149 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7150 else if (strcmp(res->what, "set") == 0)
7151 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7154 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7156 /* check the return value and print it if is < 0 */
7158 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7162 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7163 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7165 cmdline_parse_token_string_t cmd_mac_addr_what =
7166 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7168 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7169 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7171 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7172 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7174 cmdline_parse_inst_t cmd_mac_addr = {
7175 .f = cmd_mac_addr_parsed,
7177 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7178 "Add/Remove/Set MAC address on port_id",
7180 (void *)&cmd_mac_addr_cmd,
7181 (void *)&cmd_mac_addr_what,
7182 (void *)&cmd_mac_addr_portnum,
7183 (void *)&cmd_mac_addr_addr,
7188 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7189 struct cmd_eth_peer_result {
7190 cmdline_fixed_string_t set;
7191 cmdline_fixed_string_t eth_peer;
7193 cmdline_fixed_string_t peer_addr;
7196 static void cmd_set_eth_peer_parsed(void *parsed_result,
7197 __attribute__((unused)) struct cmdline *cl,
7198 __attribute__((unused)) void *data)
7200 struct cmd_eth_peer_result *res = parsed_result;
7202 if (test_done == 0) {
7203 printf("Please stop forwarding first\n");
7206 if (!strcmp(res->eth_peer, "eth-peer")) {
7207 set_fwd_eth_peer(res->port_id, res->peer_addr);
7211 cmdline_parse_token_string_t cmd_eth_peer_set =
7212 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7213 cmdline_parse_token_string_t cmd_eth_peer =
7214 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7215 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7216 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7217 cmdline_parse_token_string_t cmd_eth_peer_addr =
7218 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7220 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7221 .f = cmd_set_eth_peer_parsed,
7223 .help_str = "set eth-peer <port_id> <peer_mac>",
7225 (void *)&cmd_eth_peer_set,
7226 (void *)&cmd_eth_peer,
7227 (void *)&cmd_eth_peer_port_id,
7228 (void *)&cmd_eth_peer_addr,
7233 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7234 struct cmd_set_qmap_result {
7235 cmdline_fixed_string_t set;
7236 cmdline_fixed_string_t qmap;
7237 cmdline_fixed_string_t what;
7244 cmd_set_qmap_parsed(void *parsed_result,
7245 __attribute__((unused)) struct cmdline *cl,
7246 __attribute__((unused)) void *data)
7248 struct cmd_set_qmap_result *res = parsed_result;
7249 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7251 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7254 cmdline_parse_token_string_t cmd_setqmap_set =
7255 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7257 cmdline_parse_token_string_t cmd_setqmap_qmap =
7258 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7260 cmdline_parse_token_string_t cmd_setqmap_what =
7261 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7263 cmdline_parse_token_num_t cmd_setqmap_portid =
7264 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7266 cmdline_parse_token_num_t cmd_setqmap_queueid =
7267 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7269 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7270 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7273 cmdline_parse_inst_t cmd_set_qmap = {
7274 .f = cmd_set_qmap_parsed,
7276 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7277 "Set statistics mapping value on tx|rx queue_id of port_id",
7279 (void *)&cmd_setqmap_set,
7280 (void *)&cmd_setqmap_qmap,
7281 (void *)&cmd_setqmap_what,
7282 (void *)&cmd_setqmap_portid,
7283 (void *)&cmd_setqmap_queueid,
7284 (void *)&cmd_setqmap_mapvalue,
7289 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7290 struct cmd_set_xstats_hide_zero_result {
7291 cmdline_fixed_string_t keyword;
7292 cmdline_fixed_string_t name;
7293 cmdline_fixed_string_t on_off;
7297 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7298 __attribute__((unused)) struct cmdline *cl,
7299 __attribute__((unused)) void *data)
7301 struct cmd_set_xstats_hide_zero_result *res;
7302 uint16_t on_off = 0;
7304 res = parsed_result;
7305 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7306 set_xstats_hide_zero(on_off);
7309 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7310 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7312 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7313 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7314 name, "xstats-hide-zero");
7315 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7316 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7319 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7320 .f = cmd_set_xstats_hide_zero_parsed,
7322 .help_str = "set xstats-hide-zero on|off",
7324 (void *)&cmd_set_xstats_hide_zero_keyword,
7325 (void *)&cmd_set_xstats_hide_zero_name,
7326 (void *)&cmd_set_xstats_hide_zero_on_off,
7331 /* *** CONFIGURE UNICAST HASH TABLE *** */
7332 struct cmd_set_uc_hash_table {
7333 cmdline_fixed_string_t set;
7334 cmdline_fixed_string_t port;
7336 cmdline_fixed_string_t what;
7337 struct ether_addr address;
7338 cmdline_fixed_string_t mode;
7342 cmd_set_uc_hash_parsed(void *parsed_result,
7343 __attribute__((unused)) struct cmdline *cl,
7344 __attribute__((unused)) void *data)
7347 struct cmd_set_uc_hash_table *res = parsed_result;
7349 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7351 if (strcmp(res->what, "uta") == 0)
7352 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7353 &res->address,(uint8_t)is_on);
7355 printf("bad unicast hash table parameter, return code = %d \n", ret);
7359 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7360 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7362 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7363 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7365 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7366 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7368 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7369 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7371 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7372 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7374 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7375 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7378 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7379 .f = cmd_set_uc_hash_parsed,
7381 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7383 (void *)&cmd_set_uc_hash_set,
7384 (void *)&cmd_set_uc_hash_port,
7385 (void *)&cmd_set_uc_hash_portid,
7386 (void *)&cmd_set_uc_hash_what,
7387 (void *)&cmd_set_uc_hash_mac,
7388 (void *)&cmd_set_uc_hash_mode,
7393 struct cmd_set_uc_all_hash_table {
7394 cmdline_fixed_string_t set;
7395 cmdline_fixed_string_t port;
7397 cmdline_fixed_string_t what;
7398 cmdline_fixed_string_t value;
7399 cmdline_fixed_string_t mode;
7403 cmd_set_uc_all_hash_parsed(void *parsed_result,
7404 __attribute__((unused)) struct cmdline *cl,
7405 __attribute__((unused)) void *data)
7408 struct cmd_set_uc_all_hash_table *res = parsed_result;
7410 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7412 if ((strcmp(res->what, "uta") == 0) &&
7413 (strcmp(res->value, "all") == 0))
7414 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7416 printf("bad unicast hash table parameter,"
7417 "return code = %d \n", ret);
7420 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7421 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7423 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7424 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7426 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7427 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7429 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7430 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7432 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7433 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7435 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7436 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7439 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7440 .f = cmd_set_uc_all_hash_parsed,
7442 .help_str = "set port <port_id> uta all on|off",
7444 (void *)&cmd_set_uc_all_hash_set,
7445 (void *)&cmd_set_uc_all_hash_port,
7446 (void *)&cmd_set_uc_all_hash_portid,
7447 (void *)&cmd_set_uc_all_hash_what,
7448 (void *)&cmd_set_uc_all_hash_value,
7449 (void *)&cmd_set_uc_all_hash_mode,
7454 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7455 struct cmd_set_vf_macvlan_filter {
7456 cmdline_fixed_string_t set;
7457 cmdline_fixed_string_t port;
7459 cmdline_fixed_string_t vf;
7461 struct ether_addr address;
7462 cmdline_fixed_string_t filter_type;
7463 cmdline_fixed_string_t mode;
7467 cmd_set_vf_macvlan_parsed(void *parsed_result,
7468 __attribute__((unused)) struct cmdline *cl,
7469 __attribute__((unused)) void *data)
7472 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7473 struct rte_eth_mac_filter filter;
7475 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7477 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7479 /* set VF MAC filter */
7483 filter.dst_id = res->vf_id;
7485 if (!strcmp(res->filter_type, "exact-mac"))
7486 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7487 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7488 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7489 else if (!strcmp(res->filter_type, "hashmac"))
7490 filter.filter_type = RTE_MAC_HASH_MATCH;
7491 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7492 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7494 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7497 ret = rte_eth_dev_filter_ctrl(res->port_id,
7498 RTE_ETH_FILTER_MACVLAN,
7502 ret = rte_eth_dev_filter_ctrl(res->port_id,
7503 RTE_ETH_FILTER_MACVLAN,
7504 RTE_ETH_FILTER_DELETE,
7508 printf("bad set MAC hash parameter, return code = %d\n", ret);
7512 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7513 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7515 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7516 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7518 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7519 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7521 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7522 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7524 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7525 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7527 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7528 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7530 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7531 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7532 filter_type, "exact-mac#exact-mac-vlan"
7533 "#hashmac#hashmac-vlan");
7534 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7535 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7538 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7539 .f = cmd_set_vf_macvlan_parsed,
7541 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7542 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7543 "Exact match rule: exact match of MAC or MAC and VLAN; "
7544 "hash match rule: hash match of MAC and exact match of VLAN",
7546 (void *)&cmd_set_vf_macvlan_set,
7547 (void *)&cmd_set_vf_macvlan_port,
7548 (void *)&cmd_set_vf_macvlan_portid,
7549 (void *)&cmd_set_vf_macvlan_vf,
7550 (void *)&cmd_set_vf_macvlan_vf_id,
7551 (void *)&cmd_set_vf_macvlan_mac,
7552 (void *)&cmd_set_vf_macvlan_filter_type,
7553 (void *)&cmd_set_vf_macvlan_mode,
7558 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7559 struct cmd_set_vf_traffic {
7560 cmdline_fixed_string_t set;
7561 cmdline_fixed_string_t port;
7563 cmdline_fixed_string_t vf;
7565 cmdline_fixed_string_t what;
7566 cmdline_fixed_string_t mode;
7570 cmd_set_vf_traffic_parsed(void *parsed_result,
7571 __attribute__((unused)) struct cmdline *cl,
7572 __attribute__((unused)) void *data)
7574 struct cmd_set_vf_traffic *res = parsed_result;
7575 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7576 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7578 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7581 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7582 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7584 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7585 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7587 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7588 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7590 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7591 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7593 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7594 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7596 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7597 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7599 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7600 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7603 cmdline_parse_inst_t cmd_set_vf_traffic = {
7604 .f = cmd_set_vf_traffic_parsed,
7606 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7608 (void *)&cmd_setvf_traffic_set,
7609 (void *)&cmd_setvf_traffic_port,
7610 (void *)&cmd_setvf_traffic_portid,
7611 (void *)&cmd_setvf_traffic_vf,
7612 (void *)&cmd_setvf_traffic_vfid,
7613 (void *)&cmd_setvf_traffic_what,
7614 (void *)&cmd_setvf_traffic_mode,
7619 /* *** CONFIGURE VF RECEIVE MODE *** */
7620 struct cmd_set_vf_rxmode {
7621 cmdline_fixed_string_t set;
7622 cmdline_fixed_string_t port;
7624 cmdline_fixed_string_t vf;
7626 cmdline_fixed_string_t what;
7627 cmdline_fixed_string_t mode;
7628 cmdline_fixed_string_t on;
7632 cmd_set_vf_rxmode_parsed(void *parsed_result,
7633 __attribute__((unused)) struct cmdline *cl,
7634 __attribute__((unused)) void *data)
7637 uint16_t rx_mode = 0;
7638 struct cmd_set_vf_rxmode *res = parsed_result;
7640 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7641 if (!strcmp(res->what,"rxmode")) {
7642 if (!strcmp(res->mode, "AUPE"))
7643 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7644 else if (!strcmp(res->mode, "ROPE"))
7645 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7646 else if (!strcmp(res->mode, "BAM"))
7647 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7648 else if (!strncmp(res->mode, "MPE",3))
7649 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7652 RTE_SET_USED(is_on);
7654 #ifdef RTE_LIBRTE_IXGBE_PMD
7655 if (ret == -ENOTSUP)
7656 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7657 rx_mode, (uint8_t)is_on);
7659 #ifdef RTE_LIBRTE_BNXT_PMD
7660 if (ret == -ENOTSUP)
7661 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7662 rx_mode, (uint8_t)is_on);
7665 printf("bad VF receive mode parameter, return code = %d \n",
7669 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7670 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7672 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7673 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7675 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7676 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7678 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7679 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7681 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7682 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7684 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7685 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7687 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7688 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7689 mode, "AUPE#ROPE#BAM#MPE");
7690 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7691 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7694 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7695 .f = cmd_set_vf_rxmode_parsed,
7697 .help_str = "set port <port_id> vf <vf_id> rxmode "
7698 "AUPE|ROPE|BAM|MPE on|off",
7700 (void *)&cmd_set_vf_rxmode_set,
7701 (void *)&cmd_set_vf_rxmode_port,
7702 (void *)&cmd_set_vf_rxmode_portid,
7703 (void *)&cmd_set_vf_rxmode_vf,
7704 (void *)&cmd_set_vf_rxmode_vfid,
7705 (void *)&cmd_set_vf_rxmode_what,
7706 (void *)&cmd_set_vf_rxmode_mode,
7707 (void *)&cmd_set_vf_rxmode_on,
7712 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7713 struct cmd_vf_mac_addr_result {
7714 cmdline_fixed_string_t mac_addr_cmd;
7715 cmdline_fixed_string_t what;
7716 cmdline_fixed_string_t port;
7718 cmdline_fixed_string_t vf;
7720 struct ether_addr address;
7723 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7724 __attribute__((unused)) struct cmdline *cl,
7725 __attribute__((unused)) void *data)
7727 struct cmd_vf_mac_addr_result *res = parsed_result;
7730 if (strcmp(res->what, "add") != 0)
7733 #ifdef RTE_LIBRTE_I40E_PMD
7734 if (ret == -ENOTSUP)
7735 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7738 #ifdef RTE_LIBRTE_BNXT_PMD
7739 if (ret == -ENOTSUP)
7740 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7745 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7749 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7750 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7751 mac_addr_cmd,"mac_addr");
7752 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7753 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7755 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7756 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7758 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7759 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7761 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7762 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7764 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7765 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7767 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7768 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7771 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7772 .f = cmd_vf_mac_addr_parsed,
7774 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7775 "Add MAC address filtering for a VF on port_id",
7777 (void *)&cmd_vf_mac_addr_cmd,
7778 (void *)&cmd_vf_mac_addr_what,
7779 (void *)&cmd_vf_mac_addr_port,
7780 (void *)&cmd_vf_mac_addr_portnum,
7781 (void *)&cmd_vf_mac_addr_vf,
7782 (void *)&cmd_vf_mac_addr_vfnum,
7783 (void *)&cmd_vf_mac_addr_addr,
7788 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7789 struct cmd_vf_rx_vlan_filter {
7790 cmdline_fixed_string_t rx_vlan;
7791 cmdline_fixed_string_t what;
7793 cmdline_fixed_string_t port;
7795 cmdline_fixed_string_t vf;
7800 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7801 __attribute__((unused)) struct cmdline *cl,
7802 __attribute__((unused)) void *data)
7804 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7807 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7809 #ifdef RTE_LIBRTE_IXGBE_PMD
7810 if (ret == -ENOTSUP)
7811 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7812 res->vlan_id, res->vf_mask, is_add);
7814 #ifdef RTE_LIBRTE_I40E_PMD
7815 if (ret == -ENOTSUP)
7816 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7817 res->vlan_id, res->vf_mask, is_add);
7819 #ifdef RTE_LIBRTE_BNXT_PMD
7820 if (ret == -ENOTSUP)
7821 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7822 res->vlan_id, res->vf_mask, is_add);
7829 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7830 res->vlan_id, res->vf_mask);
7833 printf("invalid port_id %d\n", res->port_id);
7836 printf("function not implemented or supported\n");
7839 printf("programming error: (%s)\n", strerror(-ret));
7843 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7844 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7845 rx_vlan, "rx_vlan");
7846 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7847 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7849 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7850 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7852 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7853 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7855 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7856 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7858 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7859 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7861 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7862 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7865 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7866 .f = cmd_vf_rx_vlan_filter_parsed,
7868 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7869 "(vf_mask = hexadecimal VF mask)",
7871 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7872 (void *)&cmd_vf_rx_vlan_filter_what,
7873 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7874 (void *)&cmd_vf_rx_vlan_filter_port,
7875 (void *)&cmd_vf_rx_vlan_filter_portid,
7876 (void *)&cmd_vf_rx_vlan_filter_vf,
7877 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7882 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7883 struct cmd_queue_rate_limit_result {
7884 cmdline_fixed_string_t set;
7885 cmdline_fixed_string_t port;
7887 cmdline_fixed_string_t queue;
7889 cmdline_fixed_string_t rate;
7893 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7894 __attribute__((unused)) struct cmdline *cl,
7895 __attribute__((unused)) void *data)
7897 struct cmd_queue_rate_limit_result *res = parsed_result;
7900 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7901 && (strcmp(res->queue, "queue") == 0)
7902 && (strcmp(res->rate, "rate") == 0))
7903 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7906 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7910 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7911 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7913 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7914 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7916 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7917 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7919 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7920 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7922 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7923 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7925 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7926 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7928 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7929 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7932 cmdline_parse_inst_t cmd_queue_rate_limit = {
7933 .f = cmd_queue_rate_limit_parsed,
7935 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7936 "Set rate limit for a queue on port_id",
7938 (void *)&cmd_queue_rate_limit_set,
7939 (void *)&cmd_queue_rate_limit_port,
7940 (void *)&cmd_queue_rate_limit_portnum,
7941 (void *)&cmd_queue_rate_limit_queue,
7942 (void *)&cmd_queue_rate_limit_queuenum,
7943 (void *)&cmd_queue_rate_limit_rate,
7944 (void *)&cmd_queue_rate_limit_ratenum,
7949 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7950 struct cmd_vf_rate_limit_result {
7951 cmdline_fixed_string_t set;
7952 cmdline_fixed_string_t port;
7954 cmdline_fixed_string_t vf;
7956 cmdline_fixed_string_t rate;
7958 cmdline_fixed_string_t q_msk;
7962 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7963 __attribute__((unused)) struct cmdline *cl,
7964 __attribute__((unused)) void *data)
7966 struct cmd_vf_rate_limit_result *res = parsed_result;
7969 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7970 && (strcmp(res->vf, "vf") == 0)
7971 && (strcmp(res->rate, "rate") == 0)
7972 && (strcmp(res->q_msk, "queue_mask") == 0))
7973 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7974 res->rate_num, res->q_msk_val);
7976 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7980 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7981 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7983 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7984 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7986 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7987 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7989 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7990 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7992 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7993 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7995 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7996 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7998 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7999 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8001 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8002 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8003 q_msk, "queue_mask");
8004 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8005 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8008 cmdline_parse_inst_t cmd_vf_rate_limit = {
8009 .f = cmd_vf_rate_limit_parsed,
8011 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8012 "queue_mask <queue_mask_value>: "
8013 "Set rate limit for queues of VF on port_id",
8015 (void *)&cmd_vf_rate_limit_set,
8016 (void *)&cmd_vf_rate_limit_port,
8017 (void *)&cmd_vf_rate_limit_portnum,
8018 (void *)&cmd_vf_rate_limit_vf,
8019 (void *)&cmd_vf_rate_limit_vfnum,
8020 (void *)&cmd_vf_rate_limit_rate,
8021 (void *)&cmd_vf_rate_limit_ratenum,
8022 (void *)&cmd_vf_rate_limit_q_msk,
8023 (void *)&cmd_vf_rate_limit_q_msk_val,
8028 /* *** ADD TUNNEL FILTER OF A PORT *** */
8029 struct cmd_tunnel_filter_result {
8030 cmdline_fixed_string_t cmd;
8031 cmdline_fixed_string_t what;
8033 struct ether_addr outer_mac;
8034 struct ether_addr inner_mac;
8035 cmdline_ipaddr_t ip_value;
8036 uint16_t inner_vlan;
8037 cmdline_fixed_string_t tunnel_type;
8038 cmdline_fixed_string_t filter_type;
8044 cmd_tunnel_filter_parsed(void *parsed_result,
8045 __attribute__((unused)) struct cmdline *cl,
8046 __attribute__((unused)) void *data)
8048 struct cmd_tunnel_filter_result *res = parsed_result;
8049 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8052 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8054 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8055 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8056 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8058 if (res->ip_value.family == AF_INET) {
8059 tunnel_filter_conf.ip_addr.ipv4_addr =
8060 res->ip_value.addr.ipv4.s_addr;
8061 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8063 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8064 &(res->ip_value.addr.ipv6),
8065 sizeof(struct in6_addr));
8066 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8069 if (!strcmp(res->filter_type, "imac-ivlan"))
8070 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8071 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8072 tunnel_filter_conf.filter_type =
8073 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8074 else if (!strcmp(res->filter_type, "imac-tenid"))
8075 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8076 else if (!strcmp(res->filter_type, "imac"))
8077 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8078 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8079 tunnel_filter_conf.filter_type =
8080 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8081 else if (!strcmp(res->filter_type, "oip"))
8082 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8083 else if (!strcmp(res->filter_type, "iip"))
8084 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8086 printf("The filter type is not supported");
8090 if (!strcmp(res->tunnel_type, "vxlan"))
8091 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8092 else if (!strcmp(res->tunnel_type, "nvgre"))
8093 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8094 else if (!strcmp(res->tunnel_type, "ipingre"))
8095 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8097 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8101 tunnel_filter_conf.tenant_id = res->tenant_id;
8102 tunnel_filter_conf.queue_id = res->queue_num;
8103 if (!strcmp(res->what, "add"))
8104 ret = rte_eth_dev_filter_ctrl(res->port_id,
8105 RTE_ETH_FILTER_TUNNEL,
8107 &tunnel_filter_conf);
8109 ret = rte_eth_dev_filter_ctrl(res->port_id,
8110 RTE_ETH_FILTER_TUNNEL,
8111 RTE_ETH_FILTER_DELETE,
8112 &tunnel_filter_conf);
8114 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8118 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8119 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8120 cmd, "tunnel_filter");
8121 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8122 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8124 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8125 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8127 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8128 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8130 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8131 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8133 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8134 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8135 inner_vlan, UINT16);
8136 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8137 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8139 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8140 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8141 tunnel_type, "vxlan#nvgre#ipingre");
8143 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8144 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8145 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8146 "imac#omac-imac-tenid");
8147 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8148 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8150 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8151 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8154 cmdline_parse_inst_t cmd_tunnel_filter = {
8155 .f = cmd_tunnel_filter_parsed,
8157 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8158 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8159 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8160 "<queue_id>: Add/Rm tunnel filter of a port",
8162 (void *)&cmd_tunnel_filter_cmd,
8163 (void *)&cmd_tunnel_filter_what,
8164 (void *)&cmd_tunnel_filter_port_id,
8165 (void *)&cmd_tunnel_filter_outer_mac,
8166 (void *)&cmd_tunnel_filter_inner_mac,
8167 (void *)&cmd_tunnel_filter_ip_value,
8168 (void *)&cmd_tunnel_filter_innner_vlan,
8169 (void *)&cmd_tunnel_filter_tunnel_type,
8170 (void *)&cmd_tunnel_filter_filter_type,
8171 (void *)&cmd_tunnel_filter_tenant_id,
8172 (void *)&cmd_tunnel_filter_queue_num,
8177 /* *** CONFIGURE TUNNEL UDP PORT *** */
8178 struct cmd_tunnel_udp_config {
8179 cmdline_fixed_string_t cmd;
8180 cmdline_fixed_string_t what;
8186 cmd_tunnel_udp_config_parsed(void *parsed_result,
8187 __attribute__((unused)) struct cmdline *cl,
8188 __attribute__((unused)) void *data)
8190 struct cmd_tunnel_udp_config *res = parsed_result;
8191 struct rte_eth_udp_tunnel tunnel_udp;
8194 tunnel_udp.udp_port = res->udp_port;
8196 if (!strcmp(res->cmd, "rx_vxlan_port"))
8197 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8199 if (!strcmp(res->what, "add"))
8200 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8203 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8207 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8210 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8211 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8212 cmd, "rx_vxlan_port");
8213 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8214 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8216 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8217 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8219 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8220 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8223 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8224 .f = cmd_tunnel_udp_config_parsed,
8226 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8227 "Add/Remove a tunneling UDP port filter",
8229 (void *)&cmd_tunnel_udp_config_cmd,
8230 (void *)&cmd_tunnel_udp_config_what,
8231 (void *)&cmd_tunnel_udp_config_udp_port,
8232 (void *)&cmd_tunnel_udp_config_port_id,
8237 /* *** GLOBAL CONFIG *** */
8238 struct cmd_global_config_result {
8239 cmdline_fixed_string_t cmd;
8241 cmdline_fixed_string_t cfg_type;
8246 cmd_global_config_parsed(void *parsed_result,
8247 __attribute__((unused)) struct cmdline *cl,
8248 __attribute__((unused)) void *data)
8250 struct cmd_global_config_result *res = parsed_result;
8251 struct rte_eth_global_cfg conf;
8254 memset(&conf, 0, sizeof(conf));
8255 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8256 conf.cfg.gre_key_len = res->len;
8257 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8258 RTE_ETH_FILTER_SET, &conf);
8260 printf("Global config error\n");
8263 cmdline_parse_token_string_t cmd_global_config_cmd =
8264 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8266 cmdline_parse_token_num_t cmd_global_config_port_id =
8267 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8269 cmdline_parse_token_string_t cmd_global_config_type =
8270 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8271 cfg_type, "gre-key-len");
8272 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8273 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8276 cmdline_parse_inst_t cmd_global_config = {
8277 .f = cmd_global_config_parsed,
8278 .data = (void *)NULL,
8279 .help_str = "global_config <port_id> gre-key-len <key_len>",
8281 (void *)&cmd_global_config_cmd,
8282 (void *)&cmd_global_config_port_id,
8283 (void *)&cmd_global_config_type,
8284 (void *)&cmd_global_config_gre_key_len,
8289 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8290 struct cmd_set_mirror_mask_result {
8291 cmdline_fixed_string_t set;
8292 cmdline_fixed_string_t port;
8294 cmdline_fixed_string_t mirror;
8296 cmdline_fixed_string_t what;
8297 cmdline_fixed_string_t value;
8298 cmdline_fixed_string_t dstpool;
8300 cmdline_fixed_string_t on;
8303 cmdline_parse_token_string_t cmd_mirror_mask_set =
8304 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8306 cmdline_parse_token_string_t cmd_mirror_mask_port =
8307 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8309 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8310 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8312 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8313 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8314 mirror, "mirror-rule");
8315 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8316 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8318 cmdline_parse_token_string_t cmd_mirror_mask_what =
8319 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8320 what, "pool-mirror-up#pool-mirror-down"
8322 cmdline_parse_token_string_t cmd_mirror_mask_value =
8323 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8325 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8326 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8327 dstpool, "dst-pool");
8328 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8329 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8331 cmdline_parse_token_string_t cmd_mirror_mask_on =
8332 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8336 cmd_set_mirror_mask_parsed(void *parsed_result,
8337 __attribute__((unused)) struct cmdline *cl,
8338 __attribute__((unused)) void *data)
8341 struct cmd_set_mirror_mask_result *res = parsed_result;
8342 struct rte_eth_mirror_conf mr_conf;
8344 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8346 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8348 mr_conf.dst_pool = res->dstpool_id;
8350 if (!strcmp(res->what, "pool-mirror-up")) {
8351 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8352 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8353 } else if (!strcmp(res->what, "pool-mirror-down")) {
8354 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8355 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8356 } else if (!strcmp(res->what, "vlan-mirror")) {
8357 mr_conf.rule_type = ETH_MIRROR_VLAN;
8358 nb_item = parse_item_list(res->value, "vlan",
8359 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8363 for (i = 0; i < nb_item; i++) {
8364 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8365 printf("Invalid vlan_id: must be < 4096\n");
8369 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8370 mr_conf.vlan.vlan_mask |= 1ULL << i;
8374 if (!strcmp(res->on, "on"))
8375 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8378 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8381 printf("mirror rule add error: (%s)\n", strerror(-ret));
8384 cmdline_parse_inst_t cmd_set_mirror_mask = {
8385 .f = cmd_set_mirror_mask_parsed,
8387 .help_str = "set port <port_id> mirror-rule <rule_id> "
8388 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8389 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8391 (void *)&cmd_mirror_mask_set,
8392 (void *)&cmd_mirror_mask_port,
8393 (void *)&cmd_mirror_mask_portid,
8394 (void *)&cmd_mirror_mask_mirror,
8395 (void *)&cmd_mirror_mask_ruleid,
8396 (void *)&cmd_mirror_mask_what,
8397 (void *)&cmd_mirror_mask_value,
8398 (void *)&cmd_mirror_mask_dstpool,
8399 (void *)&cmd_mirror_mask_poolid,
8400 (void *)&cmd_mirror_mask_on,
8405 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8406 struct cmd_set_mirror_link_result {
8407 cmdline_fixed_string_t set;
8408 cmdline_fixed_string_t port;
8410 cmdline_fixed_string_t mirror;
8412 cmdline_fixed_string_t what;
8413 cmdline_fixed_string_t dstpool;
8415 cmdline_fixed_string_t on;
8418 cmdline_parse_token_string_t cmd_mirror_link_set =
8419 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8421 cmdline_parse_token_string_t cmd_mirror_link_port =
8422 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8424 cmdline_parse_token_num_t cmd_mirror_link_portid =
8425 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8427 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8428 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8429 mirror, "mirror-rule");
8430 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8431 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8433 cmdline_parse_token_string_t cmd_mirror_link_what =
8434 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8435 what, "uplink-mirror#downlink-mirror");
8436 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8437 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8438 dstpool, "dst-pool");
8439 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8440 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8442 cmdline_parse_token_string_t cmd_mirror_link_on =
8443 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8447 cmd_set_mirror_link_parsed(void *parsed_result,
8448 __attribute__((unused)) struct cmdline *cl,
8449 __attribute__((unused)) void *data)
8452 struct cmd_set_mirror_link_result *res = parsed_result;
8453 struct rte_eth_mirror_conf mr_conf;
8455 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8456 if (!strcmp(res->what, "uplink-mirror"))
8457 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8459 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8461 mr_conf.dst_pool = res->dstpool_id;
8463 if (!strcmp(res->on, "on"))
8464 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8467 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8470 /* check the return value and print it if is < 0 */
8472 printf("mirror rule add error: (%s)\n", strerror(-ret));
8476 cmdline_parse_inst_t cmd_set_mirror_link = {
8477 .f = cmd_set_mirror_link_parsed,
8479 .help_str = "set port <port_id> mirror-rule <rule_id> "
8480 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8482 (void *)&cmd_mirror_link_set,
8483 (void *)&cmd_mirror_link_port,
8484 (void *)&cmd_mirror_link_portid,
8485 (void *)&cmd_mirror_link_mirror,
8486 (void *)&cmd_mirror_link_ruleid,
8487 (void *)&cmd_mirror_link_what,
8488 (void *)&cmd_mirror_link_dstpool,
8489 (void *)&cmd_mirror_link_poolid,
8490 (void *)&cmd_mirror_link_on,
8495 /* *** RESET VM MIRROR RULE *** */
8496 struct cmd_rm_mirror_rule_result {
8497 cmdline_fixed_string_t reset;
8498 cmdline_fixed_string_t port;
8500 cmdline_fixed_string_t mirror;
8504 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8505 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8507 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8508 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8510 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8511 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8513 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8514 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8515 mirror, "mirror-rule");
8516 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8517 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8521 cmd_reset_mirror_rule_parsed(void *parsed_result,
8522 __attribute__((unused)) struct cmdline *cl,
8523 __attribute__((unused)) void *data)
8526 struct cmd_set_mirror_link_result *res = parsed_result;
8528 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8530 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8533 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8534 .f = cmd_reset_mirror_rule_parsed,
8536 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8538 (void *)&cmd_rm_mirror_rule_reset,
8539 (void *)&cmd_rm_mirror_rule_port,
8540 (void *)&cmd_rm_mirror_rule_portid,
8541 (void *)&cmd_rm_mirror_rule_mirror,
8542 (void *)&cmd_rm_mirror_rule_ruleid,
8547 /* ******************************************************************************** */
8549 struct cmd_dump_result {
8550 cmdline_fixed_string_t dump;
8554 dump_struct_sizes(void)
8556 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8557 DUMP_SIZE(struct rte_mbuf);
8558 DUMP_SIZE(struct rte_mempool);
8559 DUMP_SIZE(struct rte_ring);
8563 static void cmd_dump_parsed(void *parsed_result,
8564 __attribute__((unused)) struct cmdline *cl,
8565 __attribute__((unused)) void *data)
8567 struct cmd_dump_result *res = parsed_result;
8569 if (!strcmp(res->dump, "dump_physmem"))
8570 rte_dump_physmem_layout(stdout);
8571 else if (!strcmp(res->dump, "dump_memzone"))
8572 rte_memzone_dump(stdout);
8573 else if (!strcmp(res->dump, "dump_struct_sizes"))
8574 dump_struct_sizes();
8575 else if (!strcmp(res->dump, "dump_ring"))
8576 rte_ring_list_dump(stdout);
8577 else if (!strcmp(res->dump, "dump_mempool"))
8578 rte_mempool_list_dump(stdout);
8579 else if (!strcmp(res->dump, "dump_devargs"))
8580 rte_eal_devargs_dump(stdout);
8581 else if (!strcmp(res->dump, "dump_log_types"))
8582 rte_log_dump(stdout);
8585 cmdline_parse_token_string_t cmd_dump_dump =
8586 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8589 "dump_struct_sizes#"
8595 cmdline_parse_inst_t cmd_dump = {
8596 .f = cmd_dump_parsed, /* function to call */
8597 .data = NULL, /* 2nd arg of func */
8598 .help_str = "Dump status",
8599 .tokens = { /* token list, NULL terminated */
8600 (void *)&cmd_dump_dump,
8605 /* ******************************************************************************** */
8607 struct cmd_dump_one_result {
8608 cmdline_fixed_string_t dump;
8609 cmdline_fixed_string_t name;
8612 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8613 __attribute__((unused)) void *data)
8615 struct cmd_dump_one_result *res = parsed_result;
8617 if (!strcmp(res->dump, "dump_ring")) {
8619 r = rte_ring_lookup(res->name);
8621 cmdline_printf(cl, "Cannot find ring\n");
8624 rte_ring_dump(stdout, r);
8625 } else if (!strcmp(res->dump, "dump_mempool")) {
8626 struct rte_mempool *mp;
8627 mp = rte_mempool_lookup(res->name);
8629 cmdline_printf(cl, "Cannot find mempool\n");
8632 rte_mempool_dump(stdout, mp);
8636 cmdline_parse_token_string_t cmd_dump_one_dump =
8637 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8638 "dump_ring#dump_mempool");
8640 cmdline_parse_token_string_t cmd_dump_one_name =
8641 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8643 cmdline_parse_inst_t cmd_dump_one = {
8644 .f = cmd_dump_one_parsed, /* function to call */
8645 .data = NULL, /* 2nd arg of func */
8646 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8647 .tokens = { /* token list, NULL terminated */
8648 (void *)&cmd_dump_one_dump,
8649 (void *)&cmd_dump_one_name,
8654 /* *** Add/Del syn filter *** */
8655 struct cmd_syn_filter_result {
8656 cmdline_fixed_string_t filter;
8658 cmdline_fixed_string_t ops;
8659 cmdline_fixed_string_t priority;
8660 cmdline_fixed_string_t high;
8661 cmdline_fixed_string_t queue;
8666 cmd_syn_filter_parsed(void *parsed_result,
8667 __attribute__((unused)) struct cmdline *cl,
8668 __attribute__((unused)) void *data)
8670 struct cmd_syn_filter_result *res = parsed_result;
8671 struct rte_eth_syn_filter syn_filter;
8674 ret = rte_eth_dev_filter_supported(res->port_id,
8675 RTE_ETH_FILTER_SYN);
8677 printf("syn filter is not supported on port %u.\n",
8682 memset(&syn_filter, 0, sizeof(syn_filter));
8684 if (!strcmp(res->ops, "add")) {
8685 if (!strcmp(res->high, "high"))
8686 syn_filter.hig_pri = 1;
8688 syn_filter.hig_pri = 0;
8690 syn_filter.queue = res->queue_id;
8691 ret = rte_eth_dev_filter_ctrl(res->port_id,
8696 ret = rte_eth_dev_filter_ctrl(res->port_id,
8698 RTE_ETH_FILTER_DELETE,
8702 printf("syn filter programming error: (%s)\n",
8706 cmdline_parse_token_string_t cmd_syn_filter_filter =
8707 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8708 filter, "syn_filter");
8709 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8710 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8712 cmdline_parse_token_string_t cmd_syn_filter_ops =
8713 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8715 cmdline_parse_token_string_t cmd_syn_filter_priority =
8716 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8717 priority, "priority");
8718 cmdline_parse_token_string_t cmd_syn_filter_high =
8719 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8721 cmdline_parse_token_string_t cmd_syn_filter_queue =
8722 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8724 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8725 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8728 cmdline_parse_inst_t cmd_syn_filter = {
8729 .f = cmd_syn_filter_parsed,
8731 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8732 "<queue_id>: Add/Delete syn filter",
8734 (void *)&cmd_syn_filter_filter,
8735 (void *)&cmd_syn_filter_port_id,
8736 (void *)&cmd_syn_filter_ops,
8737 (void *)&cmd_syn_filter_priority,
8738 (void *)&cmd_syn_filter_high,
8739 (void *)&cmd_syn_filter_queue,
8740 (void *)&cmd_syn_filter_queue_id,
8745 /* *** queue region set *** */
8746 struct cmd_queue_region_result {
8747 cmdline_fixed_string_t set;
8748 cmdline_fixed_string_t port;
8750 cmdline_fixed_string_t cmd;
8751 cmdline_fixed_string_t region;
8753 cmdline_fixed_string_t queue_start_index;
8755 cmdline_fixed_string_t queue_num;
8756 uint8_t queue_num_value;
8760 cmd_queue_region_parsed(void *parsed_result,
8761 __attribute__((unused)) struct cmdline *cl,
8762 __attribute__((unused)) void *data)
8764 struct cmd_queue_region_result *res = parsed_result;
8766 #ifdef RTE_LIBRTE_I40E_PMD
8767 struct rte_pmd_i40e_queue_region_conf region_conf;
8768 enum rte_pmd_i40e_queue_region_op op_type;
8771 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8774 #ifdef RTE_LIBRTE_I40E_PMD
8775 memset(®ion_conf, 0, sizeof(region_conf));
8776 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8777 region_conf.region_id = res->region_id;
8778 region_conf.queue_num = res->queue_num_value;
8779 region_conf.queue_start_index = res->queue_id;
8781 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8782 op_type, ®ion_conf);
8789 printf("function not implemented or supported\n");
8792 printf("queue region config error: (%s)\n", strerror(-ret));
8796 cmdline_parse_token_string_t cmd_queue_region_set =
8797 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8799 cmdline_parse_token_string_t cmd_queue_region_port =
8800 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8801 cmdline_parse_token_num_t cmd_queue_region_port_id =
8802 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8804 cmdline_parse_token_string_t cmd_queue_region_cmd =
8805 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8806 cmd, "queue-region");
8807 cmdline_parse_token_string_t cmd_queue_region_id =
8808 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8809 region, "region_id");
8810 cmdline_parse_token_num_t cmd_queue_region_index =
8811 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8813 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8814 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8815 queue_start_index, "queue_start_index");
8816 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8817 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8819 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8820 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8821 queue_num, "queue_num");
8822 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8823 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8824 queue_num_value, UINT8);
8826 cmdline_parse_inst_t cmd_queue_region = {
8827 .f = cmd_queue_region_parsed,
8829 .help_str = "set port <port_id> queue-region region_id <value> "
8830 "queue_start_index <value> queue_num <value>: Set a queue region",
8832 (void *)&cmd_queue_region_set,
8833 (void *)&cmd_queue_region_port,
8834 (void *)&cmd_queue_region_port_id,
8835 (void *)&cmd_queue_region_cmd,
8836 (void *)&cmd_queue_region_id,
8837 (void *)&cmd_queue_region_index,
8838 (void *)&cmd_queue_region_queue_start_index,
8839 (void *)&cmd_queue_region_queue_id,
8840 (void *)&cmd_queue_region_queue_num,
8841 (void *)&cmd_queue_region_queue_num_value,
8846 /* *** queue region and flowtype set *** */
8847 struct cmd_region_flowtype_result {
8848 cmdline_fixed_string_t set;
8849 cmdline_fixed_string_t port;
8851 cmdline_fixed_string_t cmd;
8852 cmdline_fixed_string_t region;
8854 cmdline_fixed_string_t flowtype;
8855 uint8_t flowtype_id;
8859 cmd_region_flowtype_parsed(void *parsed_result,
8860 __attribute__((unused)) struct cmdline *cl,
8861 __attribute__((unused)) void *data)
8863 struct cmd_region_flowtype_result *res = parsed_result;
8865 #ifdef RTE_LIBRTE_I40E_PMD
8866 struct rte_pmd_i40e_queue_region_conf region_conf;
8867 enum rte_pmd_i40e_queue_region_op op_type;
8870 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8873 #ifdef RTE_LIBRTE_I40E_PMD
8874 memset(®ion_conf, 0, sizeof(region_conf));
8876 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8877 region_conf.region_id = res->region_id;
8878 region_conf.hw_flowtype = res->flowtype_id;
8880 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8881 op_type, ®ion_conf);
8888 printf("function not implemented or supported\n");
8891 printf("region flowtype config error: (%s)\n", strerror(-ret));
8895 cmdline_parse_token_string_t cmd_region_flowtype_set =
8896 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8898 cmdline_parse_token_string_t cmd_region_flowtype_port =
8899 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8901 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8902 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8904 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8905 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8906 cmd, "queue-region");
8907 cmdline_parse_token_string_t cmd_region_flowtype_index =
8908 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8909 region, "region_id");
8910 cmdline_parse_token_num_t cmd_region_flowtype_id =
8911 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8913 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8914 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8915 flowtype, "flowtype");
8916 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8917 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8918 flowtype_id, UINT8);
8919 cmdline_parse_inst_t cmd_region_flowtype = {
8920 .f = cmd_region_flowtype_parsed,
8922 .help_str = "set port <port_id> queue-region region_id <value> "
8923 "flowtype <value>: Set a flowtype region index",
8925 (void *)&cmd_region_flowtype_set,
8926 (void *)&cmd_region_flowtype_port,
8927 (void *)&cmd_region_flowtype_port_index,
8928 (void *)&cmd_region_flowtype_cmd,
8929 (void *)&cmd_region_flowtype_index,
8930 (void *)&cmd_region_flowtype_id,
8931 (void *)&cmd_region_flowtype_flow_index,
8932 (void *)&cmd_region_flowtype_flow_id,
8937 /* *** User Priority (UP) to queue region (region_id) set *** */
8938 struct cmd_user_priority_region_result {
8939 cmdline_fixed_string_t set;
8940 cmdline_fixed_string_t port;
8942 cmdline_fixed_string_t cmd;
8943 cmdline_fixed_string_t user_priority;
8944 uint8_t user_priority_id;
8945 cmdline_fixed_string_t region;
8950 cmd_user_priority_region_parsed(void *parsed_result,
8951 __attribute__((unused)) struct cmdline *cl,
8952 __attribute__((unused)) void *data)
8954 struct cmd_user_priority_region_result *res = parsed_result;
8956 #ifdef RTE_LIBRTE_I40E_PMD
8957 struct rte_pmd_i40e_queue_region_conf region_conf;
8958 enum rte_pmd_i40e_queue_region_op op_type;
8961 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8964 #ifdef RTE_LIBRTE_I40E_PMD
8965 memset(®ion_conf, 0, sizeof(region_conf));
8966 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8967 region_conf.user_priority = res->user_priority_id;
8968 region_conf.region_id = res->region_id;
8970 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8971 op_type, ®ion_conf);
8978 printf("function not implemented or supported\n");
8981 printf("user_priority region config error: (%s)\n",
8986 cmdline_parse_token_string_t cmd_user_priority_region_set =
8987 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8989 cmdline_parse_token_string_t cmd_user_priority_region_port =
8990 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8992 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8993 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8995 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
8996 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8997 cmd, "queue-region");
8998 cmdline_parse_token_string_t cmd_user_priority_region_UP =
8999 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9000 user_priority, "UP");
9001 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9002 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9003 user_priority_id, UINT8);
9004 cmdline_parse_token_string_t cmd_user_priority_region_region =
9005 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9006 region, "region_id");
9007 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9008 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9011 cmdline_parse_inst_t cmd_user_priority_region = {
9012 .f = cmd_user_priority_region_parsed,
9014 .help_str = "set port <port_id> queue-region UP <value> "
9015 "region_id <value>: Set the mapping of User Priority (UP) "
9016 "to queue region (region_id) ",
9018 (void *)&cmd_user_priority_region_set,
9019 (void *)&cmd_user_priority_region_port,
9020 (void *)&cmd_user_priority_region_port_index,
9021 (void *)&cmd_user_priority_region_cmd,
9022 (void *)&cmd_user_priority_region_UP,
9023 (void *)&cmd_user_priority_region_UP_id,
9024 (void *)&cmd_user_priority_region_region,
9025 (void *)&cmd_user_priority_region_region_id,
9030 /* *** flush all queue region related configuration *** */
9031 struct cmd_flush_queue_region_result {
9032 cmdline_fixed_string_t set;
9033 cmdline_fixed_string_t port;
9035 cmdline_fixed_string_t cmd;
9036 cmdline_fixed_string_t flush;
9037 cmdline_fixed_string_t what;
9041 cmd_flush_queue_region_parsed(void *parsed_result,
9042 __attribute__((unused)) struct cmdline *cl,
9043 __attribute__((unused)) void *data)
9045 struct cmd_flush_queue_region_result *res = parsed_result;
9047 #ifdef RTE_LIBRTE_I40E_PMD
9048 struct rte_pmd_i40e_queue_region_conf region_conf;
9049 enum rte_pmd_i40e_queue_region_op op_type;
9052 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9055 #ifdef RTE_LIBRTE_I40E_PMD
9056 memset(®ion_conf, 0, sizeof(region_conf));
9058 if (strcmp(res->what, "on") == 0)
9059 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9061 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9063 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9064 op_type, ®ion_conf);
9071 printf("function not implemented or supported\n");
9074 printf("queue region config flush error: (%s)\n",
9079 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9080 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9082 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9083 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9085 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9086 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9088 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9089 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9090 cmd, "queue-region");
9091 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9092 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9094 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9095 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9098 cmdline_parse_inst_t cmd_flush_queue_region = {
9099 .f = cmd_flush_queue_region_parsed,
9101 .help_str = "set port <port_id> queue-region flush on|off"
9102 ": flush all queue region related configuration",
9104 (void *)&cmd_flush_queue_region_set,
9105 (void *)&cmd_flush_queue_region_port,
9106 (void *)&cmd_flush_queue_region_port_index,
9107 (void *)&cmd_flush_queue_region_cmd,
9108 (void *)&cmd_flush_queue_region_flush,
9109 (void *)&cmd_flush_queue_region_what,
9114 /* *** get all queue region related configuration info *** */
9115 struct cmd_show_queue_region_info {
9116 cmdline_fixed_string_t show;
9117 cmdline_fixed_string_t port;
9119 cmdline_fixed_string_t cmd;
9123 cmd_show_queue_region_info_parsed(void *parsed_result,
9124 __attribute__((unused)) struct cmdline *cl,
9125 __attribute__((unused)) void *data)
9127 struct cmd_show_queue_region_info *res = parsed_result;
9129 #ifdef RTE_LIBRTE_I40E_PMD
9130 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9131 enum rte_pmd_i40e_queue_region_op op_type;
9134 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9137 #ifdef RTE_LIBRTE_I40E_PMD
9138 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9140 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9142 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9143 op_type, &rte_pmd_regions);
9145 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9152 printf("function not implemented or supported\n");
9155 printf("queue region config info show error: (%s)\n",
9160 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9161 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9163 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9164 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9166 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9167 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9169 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9170 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9171 cmd, "queue-region");
9173 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9174 .f = cmd_show_queue_region_info_parsed,
9176 .help_str = "show port <port_id> queue-region"
9177 ": show all queue region related configuration info",
9179 (void *)&cmd_show_queue_region_info_get,
9180 (void *)&cmd_show_queue_region_info_port,
9181 (void *)&cmd_show_queue_region_info_port_index,
9182 (void *)&cmd_show_queue_region_info_cmd,
9187 /* *** ADD/REMOVE A 2tuple FILTER *** */
9188 struct cmd_2tuple_filter_result {
9189 cmdline_fixed_string_t filter;
9191 cmdline_fixed_string_t ops;
9192 cmdline_fixed_string_t dst_port;
9193 uint16_t dst_port_value;
9194 cmdline_fixed_string_t protocol;
9195 uint8_t protocol_value;
9196 cmdline_fixed_string_t mask;
9198 cmdline_fixed_string_t tcp_flags;
9199 uint8_t tcp_flags_value;
9200 cmdline_fixed_string_t priority;
9201 uint8_t priority_value;
9202 cmdline_fixed_string_t queue;
9207 cmd_2tuple_filter_parsed(void *parsed_result,
9208 __attribute__((unused)) struct cmdline *cl,
9209 __attribute__((unused)) void *data)
9211 struct rte_eth_ntuple_filter filter;
9212 struct cmd_2tuple_filter_result *res = parsed_result;
9215 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9217 printf("ntuple filter is not supported on port %u.\n",
9222 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9224 filter.flags = RTE_2TUPLE_FLAGS;
9225 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9226 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9227 filter.proto = res->protocol_value;
9228 filter.priority = res->priority_value;
9229 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9230 printf("nonzero tcp_flags is only meaningful"
9231 " when protocol is TCP.\n");
9234 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9235 printf("invalid TCP flags.\n");
9239 if (res->tcp_flags_value != 0) {
9240 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9241 filter.tcp_flags = res->tcp_flags_value;
9244 /* need convert to big endian. */
9245 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9246 filter.queue = res->queue_id;
9248 if (!strcmp(res->ops, "add"))
9249 ret = rte_eth_dev_filter_ctrl(res->port_id,
9250 RTE_ETH_FILTER_NTUPLE,
9254 ret = rte_eth_dev_filter_ctrl(res->port_id,
9255 RTE_ETH_FILTER_NTUPLE,
9256 RTE_ETH_FILTER_DELETE,
9259 printf("2tuple filter programming error: (%s)\n",
9264 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9265 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9266 filter, "2tuple_filter");
9267 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9268 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9270 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9271 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9273 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9274 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9275 dst_port, "dst_port");
9276 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9277 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9278 dst_port_value, UINT16);
9279 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9280 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9281 protocol, "protocol");
9282 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9283 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9284 protocol_value, UINT8);
9285 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9286 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9288 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9289 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9291 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9292 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9293 tcp_flags, "tcp_flags");
9294 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9295 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9296 tcp_flags_value, UINT8);
9297 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9298 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9299 priority, "priority");
9300 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9301 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9302 priority_value, UINT8);
9303 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9304 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9306 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9307 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9310 cmdline_parse_inst_t cmd_2tuple_filter = {
9311 .f = cmd_2tuple_filter_parsed,
9313 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9314 "<value> mask <value> tcp_flags <value> priority <value> queue "
9315 "<queue_id>: Add a 2tuple filter",
9317 (void *)&cmd_2tuple_filter_filter,
9318 (void *)&cmd_2tuple_filter_port_id,
9319 (void *)&cmd_2tuple_filter_ops,
9320 (void *)&cmd_2tuple_filter_dst_port,
9321 (void *)&cmd_2tuple_filter_dst_port_value,
9322 (void *)&cmd_2tuple_filter_protocol,
9323 (void *)&cmd_2tuple_filter_protocol_value,
9324 (void *)&cmd_2tuple_filter_mask,
9325 (void *)&cmd_2tuple_filter_mask_value,
9326 (void *)&cmd_2tuple_filter_tcp_flags,
9327 (void *)&cmd_2tuple_filter_tcp_flags_value,
9328 (void *)&cmd_2tuple_filter_priority,
9329 (void *)&cmd_2tuple_filter_priority_value,
9330 (void *)&cmd_2tuple_filter_queue,
9331 (void *)&cmd_2tuple_filter_queue_id,
9336 /* *** ADD/REMOVE A 5tuple FILTER *** */
9337 struct cmd_5tuple_filter_result {
9338 cmdline_fixed_string_t filter;
9340 cmdline_fixed_string_t ops;
9341 cmdline_fixed_string_t dst_ip;
9342 cmdline_ipaddr_t dst_ip_value;
9343 cmdline_fixed_string_t src_ip;
9344 cmdline_ipaddr_t src_ip_value;
9345 cmdline_fixed_string_t dst_port;
9346 uint16_t dst_port_value;
9347 cmdline_fixed_string_t src_port;
9348 uint16_t src_port_value;
9349 cmdline_fixed_string_t protocol;
9350 uint8_t protocol_value;
9351 cmdline_fixed_string_t mask;
9353 cmdline_fixed_string_t tcp_flags;
9354 uint8_t tcp_flags_value;
9355 cmdline_fixed_string_t priority;
9356 uint8_t priority_value;
9357 cmdline_fixed_string_t queue;
9362 cmd_5tuple_filter_parsed(void *parsed_result,
9363 __attribute__((unused)) struct cmdline *cl,
9364 __attribute__((unused)) void *data)
9366 struct rte_eth_ntuple_filter filter;
9367 struct cmd_5tuple_filter_result *res = parsed_result;
9370 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9372 printf("ntuple filter is not supported on port %u.\n",
9377 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9379 filter.flags = RTE_5TUPLE_FLAGS;
9380 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9381 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9382 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9383 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9384 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9385 filter.proto = res->protocol_value;
9386 filter.priority = res->priority_value;
9387 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9388 printf("nonzero tcp_flags is only meaningful"
9389 " when protocol is TCP.\n");
9392 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9393 printf("invalid TCP flags.\n");
9397 if (res->tcp_flags_value != 0) {
9398 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9399 filter.tcp_flags = res->tcp_flags_value;
9402 if (res->dst_ip_value.family == AF_INET)
9403 /* no need to convert, already big endian. */
9404 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9406 if (filter.dst_ip_mask == 0) {
9407 printf("can not support ipv6 involved compare.\n");
9413 if (res->src_ip_value.family == AF_INET)
9414 /* no need to convert, already big endian. */
9415 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9417 if (filter.src_ip_mask == 0) {
9418 printf("can not support ipv6 involved compare.\n");
9423 /* need convert to big endian. */
9424 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9425 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9426 filter.queue = res->queue_id;
9428 if (!strcmp(res->ops, "add"))
9429 ret = rte_eth_dev_filter_ctrl(res->port_id,
9430 RTE_ETH_FILTER_NTUPLE,
9434 ret = rte_eth_dev_filter_ctrl(res->port_id,
9435 RTE_ETH_FILTER_NTUPLE,
9436 RTE_ETH_FILTER_DELETE,
9439 printf("5tuple filter programming error: (%s)\n",
9443 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9444 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9445 filter, "5tuple_filter");
9446 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9447 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9449 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9450 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9452 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9453 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9455 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9456 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9458 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9459 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9461 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9462 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9464 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9465 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9466 dst_port, "dst_port");
9467 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9468 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9469 dst_port_value, UINT16);
9470 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9471 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9472 src_port, "src_port");
9473 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9474 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9475 src_port_value, UINT16);
9476 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9477 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9478 protocol, "protocol");
9479 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9480 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9481 protocol_value, UINT8);
9482 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9483 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9485 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9486 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9488 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9489 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9490 tcp_flags, "tcp_flags");
9491 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9492 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9493 tcp_flags_value, UINT8);
9494 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9495 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9496 priority, "priority");
9497 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9498 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9499 priority_value, UINT8);
9500 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9501 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9503 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9504 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9507 cmdline_parse_inst_t cmd_5tuple_filter = {
9508 .f = cmd_5tuple_filter_parsed,
9510 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9511 "src_ip <value> dst_port <value> src_port <value> "
9512 "protocol <value> mask <value> tcp_flags <value> "
9513 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9515 (void *)&cmd_5tuple_filter_filter,
9516 (void *)&cmd_5tuple_filter_port_id,
9517 (void *)&cmd_5tuple_filter_ops,
9518 (void *)&cmd_5tuple_filter_dst_ip,
9519 (void *)&cmd_5tuple_filter_dst_ip_value,
9520 (void *)&cmd_5tuple_filter_src_ip,
9521 (void *)&cmd_5tuple_filter_src_ip_value,
9522 (void *)&cmd_5tuple_filter_dst_port,
9523 (void *)&cmd_5tuple_filter_dst_port_value,
9524 (void *)&cmd_5tuple_filter_src_port,
9525 (void *)&cmd_5tuple_filter_src_port_value,
9526 (void *)&cmd_5tuple_filter_protocol,
9527 (void *)&cmd_5tuple_filter_protocol_value,
9528 (void *)&cmd_5tuple_filter_mask,
9529 (void *)&cmd_5tuple_filter_mask_value,
9530 (void *)&cmd_5tuple_filter_tcp_flags,
9531 (void *)&cmd_5tuple_filter_tcp_flags_value,
9532 (void *)&cmd_5tuple_filter_priority,
9533 (void *)&cmd_5tuple_filter_priority_value,
9534 (void *)&cmd_5tuple_filter_queue,
9535 (void *)&cmd_5tuple_filter_queue_id,
9540 /* *** ADD/REMOVE A flex FILTER *** */
9541 struct cmd_flex_filter_result {
9542 cmdline_fixed_string_t filter;
9543 cmdline_fixed_string_t ops;
9545 cmdline_fixed_string_t len;
9547 cmdline_fixed_string_t bytes;
9548 cmdline_fixed_string_t bytes_value;
9549 cmdline_fixed_string_t mask;
9550 cmdline_fixed_string_t mask_value;
9551 cmdline_fixed_string_t priority;
9552 uint8_t priority_value;
9553 cmdline_fixed_string_t queue;
9557 static int xdigit2val(unsigned char c)
9562 else if (isupper(c))
9570 cmd_flex_filter_parsed(void *parsed_result,
9571 __attribute__((unused)) struct cmdline *cl,
9572 __attribute__((unused)) void *data)
9575 struct rte_eth_flex_filter filter;
9576 struct cmd_flex_filter_result *res = parsed_result;
9577 char *bytes_ptr, *mask_ptr;
9578 uint16_t len, i, j = 0;
9583 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9584 printf("the len exceed the max length 128\n");
9587 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9588 filter.len = res->len_value;
9589 filter.priority = res->priority_value;
9590 filter.queue = res->queue_id;
9591 bytes_ptr = res->bytes_value;
9592 mask_ptr = res->mask_value;
9594 /* translate bytes string to array. */
9595 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9596 (bytes_ptr[1] == 'X')))
9598 len = strnlen(bytes_ptr, res->len_value * 2);
9599 if (len == 0 || (len % 8 != 0)) {
9600 printf("please check len and bytes input\n");
9603 for (i = 0; i < len; i++) {
9605 if (isxdigit(c) == 0) {
9606 /* invalid characters. */
9607 printf("invalid input\n");
9610 val = xdigit2val(c);
9613 filter.bytes[j] = byte;
9614 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9621 /* translate mask string to uint8_t array. */
9622 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9623 (mask_ptr[1] == 'X')))
9625 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9627 printf("invalid input\n");
9632 for (i = 0; i < len; i++) {
9634 if (isxdigit(c) == 0) {
9635 /* invalid characters. */
9636 printf("invalid input\n");
9639 val = xdigit2val(c);
9642 filter.mask[j] = byte;
9643 printf("mask[%d]:%02x ", j, filter.mask[j]);
9651 if (!strcmp(res->ops, "add"))
9652 ret = rte_eth_dev_filter_ctrl(res->port_id,
9653 RTE_ETH_FILTER_FLEXIBLE,
9657 ret = rte_eth_dev_filter_ctrl(res->port_id,
9658 RTE_ETH_FILTER_FLEXIBLE,
9659 RTE_ETH_FILTER_DELETE,
9663 printf("flex filter setting error: (%s)\n", strerror(-ret));
9666 cmdline_parse_token_string_t cmd_flex_filter_filter =
9667 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9668 filter, "flex_filter");
9669 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9670 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9672 cmdline_parse_token_string_t cmd_flex_filter_ops =
9673 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9675 cmdline_parse_token_string_t cmd_flex_filter_len =
9676 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9678 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9679 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9681 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9682 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9684 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9685 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9687 cmdline_parse_token_string_t cmd_flex_filter_mask =
9688 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9690 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9691 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9693 cmdline_parse_token_string_t cmd_flex_filter_priority =
9694 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9695 priority, "priority");
9696 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9697 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9698 priority_value, UINT8);
9699 cmdline_parse_token_string_t cmd_flex_filter_queue =
9700 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9702 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9703 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9705 cmdline_parse_inst_t cmd_flex_filter = {
9706 .f = cmd_flex_filter_parsed,
9708 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9709 "<value> mask <value> priority <value> queue <queue_id>: "
9710 "Add/Del a flex filter",
9712 (void *)&cmd_flex_filter_filter,
9713 (void *)&cmd_flex_filter_port_id,
9714 (void *)&cmd_flex_filter_ops,
9715 (void *)&cmd_flex_filter_len,
9716 (void *)&cmd_flex_filter_len_value,
9717 (void *)&cmd_flex_filter_bytes,
9718 (void *)&cmd_flex_filter_bytes_value,
9719 (void *)&cmd_flex_filter_mask,
9720 (void *)&cmd_flex_filter_mask_value,
9721 (void *)&cmd_flex_filter_priority,
9722 (void *)&cmd_flex_filter_priority_value,
9723 (void *)&cmd_flex_filter_queue,
9724 (void *)&cmd_flex_filter_queue_id,
9729 /* *** Filters Control *** */
9731 /* *** deal with ethertype filter *** */
9732 struct cmd_ethertype_filter_result {
9733 cmdline_fixed_string_t filter;
9735 cmdline_fixed_string_t ops;
9736 cmdline_fixed_string_t mac;
9737 struct ether_addr mac_addr;
9738 cmdline_fixed_string_t ethertype;
9739 uint16_t ethertype_value;
9740 cmdline_fixed_string_t drop;
9741 cmdline_fixed_string_t queue;
9745 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9746 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9747 filter, "ethertype_filter");
9748 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9749 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9751 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9752 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9754 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9755 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9756 mac, "mac_addr#mac_ignr");
9757 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9758 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9760 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9761 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9762 ethertype, "ethertype");
9763 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9764 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9765 ethertype_value, UINT16);
9766 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9767 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9769 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9770 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9772 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9773 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9777 cmd_ethertype_filter_parsed(void *parsed_result,
9778 __attribute__((unused)) struct cmdline *cl,
9779 __attribute__((unused)) void *data)
9781 struct cmd_ethertype_filter_result *res = parsed_result;
9782 struct rte_eth_ethertype_filter filter;
9785 ret = rte_eth_dev_filter_supported(res->port_id,
9786 RTE_ETH_FILTER_ETHERTYPE);
9788 printf("ethertype filter is not supported on port %u.\n",
9793 memset(&filter, 0, sizeof(filter));
9794 if (!strcmp(res->mac, "mac_addr")) {
9795 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9796 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9797 sizeof(struct ether_addr));
9799 if (!strcmp(res->drop, "drop"))
9800 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9801 filter.ether_type = res->ethertype_value;
9802 filter.queue = res->queue_id;
9804 if (!strcmp(res->ops, "add"))
9805 ret = rte_eth_dev_filter_ctrl(res->port_id,
9806 RTE_ETH_FILTER_ETHERTYPE,
9810 ret = rte_eth_dev_filter_ctrl(res->port_id,
9811 RTE_ETH_FILTER_ETHERTYPE,
9812 RTE_ETH_FILTER_DELETE,
9815 printf("ethertype filter programming error: (%s)\n",
9819 cmdline_parse_inst_t cmd_ethertype_filter = {
9820 .f = cmd_ethertype_filter_parsed,
9822 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9823 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9824 "Add or delete an ethertype filter entry",
9826 (void *)&cmd_ethertype_filter_filter,
9827 (void *)&cmd_ethertype_filter_port_id,
9828 (void *)&cmd_ethertype_filter_ops,
9829 (void *)&cmd_ethertype_filter_mac,
9830 (void *)&cmd_ethertype_filter_mac_addr,
9831 (void *)&cmd_ethertype_filter_ethertype,
9832 (void *)&cmd_ethertype_filter_ethertype_value,
9833 (void *)&cmd_ethertype_filter_drop,
9834 (void *)&cmd_ethertype_filter_queue,
9835 (void *)&cmd_ethertype_filter_queue_id,
9840 /* *** deal with flow director filter *** */
9841 struct cmd_flow_director_result {
9842 cmdline_fixed_string_t flow_director_filter;
9844 cmdline_fixed_string_t mode;
9845 cmdline_fixed_string_t mode_value;
9846 cmdline_fixed_string_t ops;
9847 cmdline_fixed_string_t flow;
9848 cmdline_fixed_string_t flow_type;
9849 cmdline_fixed_string_t ether;
9850 uint16_t ether_type;
9851 cmdline_fixed_string_t src;
9852 cmdline_ipaddr_t ip_src;
9854 cmdline_fixed_string_t dst;
9855 cmdline_ipaddr_t ip_dst;
9857 cmdline_fixed_string_t verify_tag;
9858 uint32_t verify_tag_value;
9859 cmdline_ipaddr_t tos;
9861 cmdline_ipaddr_t proto;
9862 uint8_t proto_value;
9863 cmdline_ipaddr_t ttl;
9865 cmdline_fixed_string_t vlan;
9866 uint16_t vlan_value;
9867 cmdline_fixed_string_t flexbytes;
9868 cmdline_fixed_string_t flexbytes_value;
9869 cmdline_fixed_string_t pf_vf;
9870 cmdline_fixed_string_t drop;
9871 cmdline_fixed_string_t queue;
9873 cmdline_fixed_string_t fd_id;
9874 uint32_t fd_id_value;
9875 cmdline_fixed_string_t mac;
9876 struct ether_addr mac_addr;
9877 cmdline_fixed_string_t tunnel;
9878 cmdline_fixed_string_t tunnel_type;
9879 cmdline_fixed_string_t tunnel_id;
9880 uint32_t tunnel_id_value;
9884 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9887 const char *p, *p0 = q_arg;
9889 unsigned long int_fld;
9890 char *str_fld[max_num];
9895 p = strchr(p0, '(');
9899 p0 = strchr(p, ')');
9904 if (size >= sizeof(s))
9907 snprintf(s, sizeof(s), "%.*s", size, p);
9908 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9909 if (ret < 0 || ret > max_num)
9911 for (i = 0; i < ret; i++) {
9913 int_fld = strtoul(str_fld[i], &end, 0);
9914 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9916 flexbytes[i] = (uint8_t)int_fld;
9922 str2flowtype(char *string)
9925 static const struct {
9928 } flowtype_str[] = {
9929 {"raw", RTE_ETH_FLOW_RAW},
9930 {"ipv4", RTE_ETH_FLOW_IPV4},
9931 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9932 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9933 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9934 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9935 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9936 {"ipv6", RTE_ETH_FLOW_IPV6},
9937 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9938 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9939 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9940 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9941 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9942 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9945 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9946 if (!strcmp(flowtype_str[i].str, string))
9947 return flowtype_str[i].type;
9950 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9951 return (uint16_t)atoi(string);
9953 return RTE_ETH_FLOW_UNKNOWN;
9956 static enum rte_eth_fdir_tunnel_type
9957 str2fdir_tunneltype(char *string)
9961 static const struct {
9963 enum rte_eth_fdir_tunnel_type type;
9964 } tunneltype_str[] = {
9965 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9966 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9969 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9970 if (!strcmp(tunneltype_str[i].str, string))
9971 return tunneltype_str[i].type;
9973 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9976 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9978 if ((ip_addr).family == AF_INET) \
9979 (ip) = (ip_addr).addr.ipv4.s_addr; \
9981 printf("invalid parameter.\n"); \
9986 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9988 if ((ip_addr).family == AF_INET6) \
9990 &((ip_addr).addr.ipv6), \
9991 sizeof(struct in6_addr)); \
9993 printf("invalid parameter.\n"); \
9999 cmd_flow_director_filter_parsed(void *parsed_result,
10000 __attribute__((unused)) struct cmdline *cl,
10001 __attribute__((unused)) void *data)
10003 struct cmd_flow_director_result *res = parsed_result;
10004 struct rte_eth_fdir_filter entry;
10005 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10007 unsigned long vf_id;
10010 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10012 printf("flow director is not supported on port %u.\n",
10016 memset(flexbytes, 0, sizeof(flexbytes));
10017 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10019 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10020 if (strcmp(res->mode_value, "MAC-VLAN")) {
10021 printf("Please set mode to MAC-VLAN.\n");
10024 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10025 if (strcmp(res->mode_value, "Tunnel")) {
10026 printf("Please set mode to Tunnel.\n");
10030 if (strcmp(res->mode_value, "IP")) {
10031 printf("Please set mode to IP.\n");
10034 entry.input.flow_type = str2flowtype(res->flow_type);
10037 ret = parse_flexbytes(res->flexbytes_value,
10039 RTE_ETH_FDIR_MAX_FLEXLEN);
10041 printf("error: Cannot parse flexbytes input.\n");
10045 switch (entry.input.flow_type) {
10046 case RTE_ETH_FLOW_FRAG_IPV4:
10047 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10048 entry.input.flow.ip4_flow.proto = res->proto_value;
10050 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10051 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10052 IPV4_ADDR_TO_UINT(res->ip_dst,
10053 entry.input.flow.ip4_flow.dst_ip);
10054 IPV4_ADDR_TO_UINT(res->ip_src,
10055 entry.input.flow.ip4_flow.src_ip);
10056 entry.input.flow.ip4_flow.tos = res->tos_value;
10057 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10058 /* need convert to big endian. */
10059 entry.input.flow.udp4_flow.dst_port =
10060 rte_cpu_to_be_16(res->port_dst);
10061 entry.input.flow.udp4_flow.src_port =
10062 rte_cpu_to_be_16(res->port_src);
10064 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10065 IPV4_ADDR_TO_UINT(res->ip_dst,
10066 entry.input.flow.sctp4_flow.ip.dst_ip);
10067 IPV4_ADDR_TO_UINT(res->ip_src,
10068 entry.input.flow.sctp4_flow.ip.src_ip);
10069 entry.input.flow.ip4_flow.tos = res->tos_value;
10070 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10071 /* need convert to big endian. */
10072 entry.input.flow.sctp4_flow.dst_port =
10073 rte_cpu_to_be_16(res->port_dst);
10074 entry.input.flow.sctp4_flow.src_port =
10075 rte_cpu_to_be_16(res->port_src);
10076 entry.input.flow.sctp4_flow.verify_tag =
10077 rte_cpu_to_be_32(res->verify_tag_value);
10079 case RTE_ETH_FLOW_FRAG_IPV6:
10080 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10081 entry.input.flow.ipv6_flow.proto = res->proto_value;
10083 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10084 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10085 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10086 entry.input.flow.ipv6_flow.dst_ip);
10087 IPV6_ADDR_TO_ARRAY(res->ip_src,
10088 entry.input.flow.ipv6_flow.src_ip);
10089 entry.input.flow.ipv6_flow.tc = res->tos_value;
10090 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10091 /* need convert to big endian. */
10092 entry.input.flow.udp6_flow.dst_port =
10093 rte_cpu_to_be_16(res->port_dst);
10094 entry.input.flow.udp6_flow.src_port =
10095 rte_cpu_to_be_16(res->port_src);
10097 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10098 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10099 entry.input.flow.sctp6_flow.ip.dst_ip);
10100 IPV6_ADDR_TO_ARRAY(res->ip_src,
10101 entry.input.flow.sctp6_flow.ip.src_ip);
10102 entry.input.flow.ipv6_flow.tc = res->tos_value;
10103 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10104 /* need convert to big endian. */
10105 entry.input.flow.sctp6_flow.dst_port =
10106 rte_cpu_to_be_16(res->port_dst);
10107 entry.input.flow.sctp6_flow.src_port =
10108 rte_cpu_to_be_16(res->port_src);
10109 entry.input.flow.sctp6_flow.verify_tag =
10110 rte_cpu_to_be_32(res->verify_tag_value);
10112 case RTE_ETH_FLOW_L2_PAYLOAD:
10113 entry.input.flow.l2_flow.ether_type =
10114 rte_cpu_to_be_16(res->ether_type);
10120 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10121 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10123 sizeof(struct ether_addr));
10125 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10126 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10128 sizeof(struct ether_addr));
10129 entry.input.flow.tunnel_flow.tunnel_type =
10130 str2fdir_tunneltype(res->tunnel_type);
10131 entry.input.flow.tunnel_flow.tunnel_id =
10132 rte_cpu_to_be_32(res->tunnel_id_value);
10135 rte_memcpy(entry.input.flow_ext.flexbytes,
10137 RTE_ETH_FDIR_MAX_FLEXLEN);
10139 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10141 entry.action.flex_off = 0; /*use 0 by default */
10142 if (!strcmp(res->drop, "drop"))
10143 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10145 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10147 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10148 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10149 if (!strcmp(res->pf_vf, "pf"))
10150 entry.input.flow_ext.is_vf = 0;
10151 else if (!strncmp(res->pf_vf, "vf", 2)) {
10152 struct rte_eth_dev_info dev_info;
10154 memset(&dev_info, 0, sizeof(dev_info));
10155 rte_eth_dev_info_get(res->port_id, &dev_info);
10157 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10158 if (errno != 0 || *end != '\0' ||
10159 vf_id >= dev_info.max_vfs) {
10160 printf("invalid parameter %s.\n", res->pf_vf);
10163 entry.input.flow_ext.is_vf = 1;
10164 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10166 printf("invalid parameter %s.\n", res->pf_vf);
10171 /* set to report FD ID by default */
10172 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10173 entry.action.rx_queue = res->queue_id;
10174 entry.soft_id = res->fd_id_value;
10175 if (!strcmp(res->ops, "add"))
10176 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10177 RTE_ETH_FILTER_ADD, &entry);
10178 else if (!strcmp(res->ops, "del"))
10179 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10180 RTE_ETH_FILTER_DELETE, &entry);
10182 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10183 RTE_ETH_FILTER_UPDATE, &entry);
10185 printf("flow director programming error: (%s)\n",
10189 cmdline_parse_token_string_t cmd_flow_director_filter =
10190 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10191 flow_director_filter, "flow_director_filter");
10192 cmdline_parse_token_num_t cmd_flow_director_port_id =
10193 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10195 cmdline_parse_token_string_t cmd_flow_director_ops =
10196 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10197 ops, "add#del#update");
10198 cmdline_parse_token_string_t cmd_flow_director_flow =
10199 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10201 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10202 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10203 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10204 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
10205 cmdline_parse_token_string_t cmd_flow_director_ether =
10206 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10208 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10209 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10210 ether_type, UINT16);
10211 cmdline_parse_token_string_t cmd_flow_director_src =
10212 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10214 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10215 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10217 cmdline_parse_token_num_t cmd_flow_director_port_src =
10218 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10220 cmdline_parse_token_string_t cmd_flow_director_dst =
10221 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10223 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10224 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10226 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10227 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10229 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10230 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10231 verify_tag, "verify_tag");
10232 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10233 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10234 verify_tag_value, UINT32);
10235 cmdline_parse_token_string_t cmd_flow_director_tos =
10236 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10238 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10239 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10241 cmdline_parse_token_string_t cmd_flow_director_proto =
10242 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10244 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10245 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10246 proto_value, UINT8);
10247 cmdline_parse_token_string_t cmd_flow_director_ttl =
10248 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10250 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10251 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10253 cmdline_parse_token_string_t cmd_flow_director_vlan =
10254 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10256 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10257 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10258 vlan_value, UINT16);
10259 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10261 flexbytes, "flexbytes");
10262 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10263 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10264 flexbytes_value, NULL);
10265 cmdline_parse_token_string_t cmd_flow_director_drop =
10266 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10268 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10269 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10271 cmdline_parse_token_string_t cmd_flow_director_queue =
10272 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10274 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10275 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10277 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10278 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10280 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10281 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10282 fd_id_value, UINT32);
10284 cmdline_parse_token_string_t cmd_flow_director_mode =
10285 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10287 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10288 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10290 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10291 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10292 mode_value, "MAC-VLAN");
10293 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10294 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10295 mode_value, "Tunnel");
10296 cmdline_parse_token_string_t cmd_flow_director_mac =
10297 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10299 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10300 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10302 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10303 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10305 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10306 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10307 tunnel_type, "NVGRE#VxLAN");
10308 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10309 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10310 tunnel_id, "tunnel-id");
10311 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10312 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10313 tunnel_id_value, UINT32);
10315 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10316 .f = cmd_flow_director_filter_parsed,
10318 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10319 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10320 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10321 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10322 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10323 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10324 "fd_id <fd_id_value>: "
10325 "Add or delete an ip flow director entry on NIC",
10327 (void *)&cmd_flow_director_filter,
10328 (void *)&cmd_flow_director_port_id,
10329 (void *)&cmd_flow_director_mode,
10330 (void *)&cmd_flow_director_mode_ip,
10331 (void *)&cmd_flow_director_ops,
10332 (void *)&cmd_flow_director_flow,
10333 (void *)&cmd_flow_director_flow_type,
10334 (void *)&cmd_flow_director_src,
10335 (void *)&cmd_flow_director_ip_src,
10336 (void *)&cmd_flow_director_dst,
10337 (void *)&cmd_flow_director_ip_dst,
10338 (void *)&cmd_flow_director_tos,
10339 (void *)&cmd_flow_director_tos_value,
10340 (void *)&cmd_flow_director_proto,
10341 (void *)&cmd_flow_director_proto_value,
10342 (void *)&cmd_flow_director_ttl,
10343 (void *)&cmd_flow_director_ttl_value,
10344 (void *)&cmd_flow_director_vlan,
10345 (void *)&cmd_flow_director_vlan_value,
10346 (void *)&cmd_flow_director_flexbytes,
10347 (void *)&cmd_flow_director_flexbytes_value,
10348 (void *)&cmd_flow_director_drop,
10349 (void *)&cmd_flow_director_pf_vf,
10350 (void *)&cmd_flow_director_queue,
10351 (void *)&cmd_flow_director_queue_id,
10352 (void *)&cmd_flow_director_fd_id,
10353 (void *)&cmd_flow_director_fd_id_value,
10358 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10359 .f = cmd_flow_director_filter_parsed,
10361 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10362 "director entry on NIC",
10364 (void *)&cmd_flow_director_filter,
10365 (void *)&cmd_flow_director_port_id,
10366 (void *)&cmd_flow_director_mode,
10367 (void *)&cmd_flow_director_mode_ip,
10368 (void *)&cmd_flow_director_ops,
10369 (void *)&cmd_flow_director_flow,
10370 (void *)&cmd_flow_director_flow_type,
10371 (void *)&cmd_flow_director_src,
10372 (void *)&cmd_flow_director_ip_src,
10373 (void *)&cmd_flow_director_port_src,
10374 (void *)&cmd_flow_director_dst,
10375 (void *)&cmd_flow_director_ip_dst,
10376 (void *)&cmd_flow_director_port_dst,
10377 (void *)&cmd_flow_director_tos,
10378 (void *)&cmd_flow_director_tos_value,
10379 (void *)&cmd_flow_director_ttl,
10380 (void *)&cmd_flow_director_ttl_value,
10381 (void *)&cmd_flow_director_vlan,
10382 (void *)&cmd_flow_director_vlan_value,
10383 (void *)&cmd_flow_director_flexbytes,
10384 (void *)&cmd_flow_director_flexbytes_value,
10385 (void *)&cmd_flow_director_drop,
10386 (void *)&cmd_flow_director_pf_vf,
10387 (void *)&cmd_flow_director_queue,
10388 (void *)&cmd_flow_director_queue_id,
10389 (void *)&cmd_flow_director_fd_id,
10390 (void *)&cmd_flow_director_fd_id_value,
10395 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10396 .f = cmd_flow_director_filter_parsed,
10398 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10399 "director entry on NIC",
10401 (void *)&cmd_flow_director_filter,
10402 (void *)&cmd_flow_director_port_id,
10403 (void *)&cmd_flow_director_mode,
10404 (void *)&cmd_flow_director_mode_ip,
10405 (void *)&cmd_flow_director_ops,
10406 (void *)&cmd_flow_director_flow,
10407 (void *)&cmd_flow_director_flow_type,
10408 (void *)&cmd_flow_director_src,
10409 (void *)&cmd_flow_director_ip_src,
10410 (void *)&cmd_flow_director_port_dst,
10411 (void *)&cmd_flow_director_dst,
10412 (void *)&cmd_flow_director_ip_dst,
10413 (void *)&cmd_flow_director_port_dst,
10414 (void *)&cmd_flow_director_verify_tag,
10415 (void *)&cmd_flow_director_verify_tag_value,
10416 (void *)&cmd_flow_director_tos,
10417 (void *)&cmd_flow_director_tos_value,
10418 (void *)&cmd_flow_director_ttl,
10419 (void *)&cmd_flow_director_ttl_value,
10420 (void *)&cmd_flow_director_vlan,
10421 (void *)&cmd_flow_director_vlan_value,
10422 (void *)&cmd_flow_director_flexbytes,
10423 (void *)&cmd_flow_director_flexbytes_value,
10424 (void *)&cmd_flow_director_drop,
10425 (void *)&cmd_flow_director_pf_vf,
10426 (void *)&cmd_flow_director_queue,
10427 (void *)&cmd_flow_director_queue_id,
10428 (void *)&cmd_flow_director_fd_id,
10429 (void *)&cmd_flow_director_fd_id_value,
10434 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10435 .f = cmd_flow_director_filter_parsed,
10437 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10438 "director entry on NIC",
10440 (void *)&cmd_flow_director_filter,
10441 (void *)&cmd_flow_director_port_id,
10442 (void *)&cmd_flow_director_mode,
10443 (void *)&cmd_flow_director_mode_ip,
10444 (void *)&cmd_flow_director_ops,
10445 (void *)&cmd_flow_director_flow,
10446 (void *)&cmd_flow_director_flow_type,
10447 (void *)&cmd_flow_director_ether,
10448 (void *)&cmd_flow_director_ether_type,
10449 (void *)&cmd_flow_director_flexbytes,
10450 (void *)&cmd_flow_director_flexbytes_value,
10451 (void *)&cmd_flow_director_drop,
10452 (void *)&cmd_flow_director_pf_vf,
10453 (void *)&cmd_flow_director_queue,
10454 (void *)&cmd_flow_director_queue_id,
10455 (void *)&cmd_flow_director_fd_id,
10456 (void *)&cmd_flow_director_fd_id_value,
10461 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10462 .f = cmd_flow_director_filter_parsed,
10464 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10465 "director entry on NIC",
10467 (void *)&cmd_flow_director_filter,
10468 (void *)&cmd_flow_director_port_id,
10469 (void *)&cmd_flow_director_mode,
10470 (void *)&cmd_flow_director_mode_mac_vlan,
10471 (void *)&cmd_flow_director_ops,
10472 (void *)&cmd_flow_director_mac,
10473 (void *)&cmd_flow_director_mac_addr,
10474 (void *)&cmd_flow_director_vlan,
10475 (void *)&cmd_flow_director_vlan_value,
10476 (void *)&cmd_flow_director_flexbytes,
10477 (void *)&cmd_flow_director_flexbytes_value,
10478 (void *)&cmd_flow_director_drop,
10479 (void *)&cmd_flow_director_queue,
10480 (void *)&cmd_flow_director_queue_id,
10481 (void *)&cmd_flow_director_fd_id,
10482 (void *)&cmd_flow_director_fd_id_value,
10487 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10488 .f = cmd_flow_director_filter_parsed,
10490 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10491 "director entry on NIC",
10493 (void *)&cmd_flow_director_filter,
10494 (void *)&cmd_flow_director_port_id,
10495 (void *)&cmd_flow_director_mode,
10496 (void *)&cmd_flow_director_mode_tunnel,
10497 (void *)&cmd_flow_director_ops,
10498 (void *)&cmd_flow_director_mac,
10499 (void *)&cmd_flow_director_mac_addr,
10500 (void *)&cmd_flow_director_vlan,
10501 (void *)&cmd_flow_director_vlan_value,
10502 (void *)&cmd_flow_director_tunnel,
10503 (void *)&cmd_flow_director_tunnel_type,
10504 (void *)&cmd_flow_director_tunnel_id,
10505 (void *)&cmd_flow_director_tunnel_id_value,
10506 (void *)&cmd_flow_director_flexbytes,
10507 (void *)&cmd_flow_director_flexbytes_value,
10508 (void *)&cmd_flow_director_drop,
10509 (void *)&cmd_flow_director_queue,
10510 (void *)&cmd_flow_director_queue_id,
10511 (void *)&cmd_flow_director_fd_id,
10512 (void *)&cmd_flow_director_fd_id_value,
10517 struct cmd_flush_flow_director_result {
10518 cmdline_fixed_string_t flush_flow_director;
10522 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10523 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10524 flush_flow_director, "flush_flow_director");
10525 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10526 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10530 cmd_flush_flow_director_parsed(void *parsed_result,
10531 __attribute__((unused)) struct cmdline *cl,
10532 __attribute__((unused)) void *data)
10534 struct cmd_flow_director_result *res = parsed_result;
10537 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10539 printf("flow director is not supported on port %u.\n",
10544 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10545 RTE_ETH_FILTER_FLUSH, NULL);
10547 printf("flow director table flushing error: (%s)\n",
10551 cmdline_parse_inst_t cmd_flush_flow_director = {
10552 .f = cmd_flush_flow_director_parsed,
10554 .help_str = "flush_flow_director <port_id>: "
10555 "Flush all flow director entries of a device on NIC",
10557 (void *)&cmd_flush_flow_director_flush,
10558 (void *)&cmd_flush_flow_director_port_id,
10563 /* *** deal with flow director mask *** */
10564 struct cmd_flow_director_mask_result {
10565 cmdline_fixed_string_t flow_director_mask;
10567 cmdline_fixed_string_t mode;
10568 cmdline_fixed_string_t mode_value;
10569 cmdline_fixed_string_t vlan;
10570 uint16_t vlan_mask;
10571 cmdline_fixed_string_t src_mask;
10572 cmdline_ipaddr_t ipv4_src;
10573 cmdline_ipaddr_t ipv6_src;
10575 cmdline_fixed_string_t dst_mask;
10576 cmdline_ipaddr_t ipv4_dst;
10577 cmdline_ipaddr_t ipv6_dst;
10579 cmdline_fixed_string_t mac;
10580 uint8_t mac_addr_byte_mask;
10581 cmdline_fixed_string_t tunnel_id;
10582 uint32_t tunnel_id_mask;
10583 cmdline_fixed_string_t tunnel_type;
10584 uint8_t tunnel_type_mask;
10588 cmd_flow_director_mask_parsed(void *parsed_result,
10589 __attribute__((unused)) struct cmdline *cl,
10590 __attribute__((unused)) void *data)
10592 struct cmd_flow_director_mask_result *res = parsed_result;
10593 struct rte_eth_fdir_masks *mask;
10594 struct rte_port *port;
10596 if (res->port_id > nb_ports) {
10597 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10601 port = &ports[res->port_id];
10602 /** Check if the port is not started **/
10603 if (port->port_status != RTE_PORT_STOPPED) {
10604 printf("Please stop port %d first\n", res->port_id);
10608 mask = &port->dev_conf.fdir_conf.mask;
10610 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10611 if (strcmp(res->mode_value, "MAC-VLAN")) {
10612 printf("Please set mode to MAC-VLAN.\n");
10616 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10617 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10618 if (strcmp(res->mode_value, "Tunnel")) {
10619 printf("Please set mode to Tunnel.\n");
10623 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10624 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10625 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10626 mask->tunnel_type_mask = res->tunnel_type_mask;
10628 if (strcmp(res->mode_value, "IP")) {
10629 printf("Please set mode to IP.\n");
10633 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10634 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10635 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10636 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10637 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10638 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10639 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10642 cmd_reconfig_device_queue(res->port_id, 1, 1);
10645 cmdline_parse_token_string_t cmd_flow_director_mask =
10646 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10647 flow_director_mask, "flow_director_mask");
10648 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10649 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10651 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10652 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10654 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10655 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10656 vlan_mask, UINT16);
10657 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10658 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10659 src_mask, "src_mask");
10660 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10661 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10663 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10664 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10666 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10667 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10669 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10670 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10671 dst_mask, "dst_mask");
10672 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10673 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10675 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10676 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10678 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10679 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10682 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10683 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10685 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10686 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10688 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10689 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10690 mode_value, "MAC-VLAN");
10691 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10692 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10693 mode_value, "Tunnel");
10694 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10695 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10697 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10698 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10699 mac_addr_byte_mask, UINT8);
10700 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10701 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10702 tunnel_type, "tunnel-type");
10703 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10704 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10705 tunnel_type_mask, UINT8);
10706 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10707 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10708 tunnel_id, "tunnel-id");
10709 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10710 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10711 tunnel_id_mask, UINT32);
10713 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10714 .f = cmd_flow_director_mask_parsed,
10716 .help_str = "flow_director_mask ... : "
10717 "Set IP mode flow director's mask on NIC",
10719 (void *)&cmd_flow_director_mask,
10720 (void *)&cmd_flow_director_mask_port_id,
10721 (void *)&cmd_flow_director_mask_mode,
10722 (void *)&cmd_flow_director_mask_mode_ip,
10723 (void *)&cmd_flow_director_mask_vlan,
10724 (void *)&cmd_flow_director_mask_vlan_value,
10725 (void *)&cmd_flow_director_mask_src,
10726 (void *)&cmd_flow_director_mask_ipv4_src,
10727 (void *)&cmd_flow_director_mask_ipv6_src,
10728 (void *)&cmd_flow_director_mask_port_src,
10729 (void *)&cmd_flow_director_mask_dst,
10730 (void *)&cmd_flow_director_mask_ipv4_dst,
10731 (void *)&cmd_flow_director_mask_ipv6_dst,
10732 (void *)&cmd_flow_director_mask_port_dst,
10737 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10738 .f = cmd_flow_director_mask_parsed,
10740 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10741 "flow director's mask on NIC",
10743 (void *)&cmd_flow_director_mask,
10744 (void *)&cmd_flow_director_mask_port_id,
10745 (void *)&cmd_flow_director_mask_mode,
10746 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10747 (void *)&cmd_flow_director_mask_vlan,
10748 (void *)&cmd_flow_director_mask_vlan_value,
10753 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10754 .f = cmd_flow_director_mask_parsed,
10756 .help_str = "flow_director_mask ... : Set tunnel mode "
10757 "flow director's mask on NIC",
10759 (void *)&cmd_flow_director_mask,
10760 (void *)&cmd_flow_director_mask_port_id,
10761 (void *)&cmd_flow_director_mask_mode,
10762 (void *)&cmd_flow_director_mask_mode_tunnel,
10763 (void *)&cmd_flow_director_mask_vlan,
10764 (void *)&cmd_flow_director_mask_vlan_value,
10765 (void *)&cmd_flow_director_mask_mac,
10766 (void *)&cmd_flow_director_mask_mac_value,
10767 (void *)&cmd_flow_director_mask_tunnel_type,
10768 (void *)&cmd_flow_director_mask_tunnel_type_value,
10769 (void *)&cmd_flow_director_mask_tunnel_id,
10770 (void *)&cmd_flow_director_mask_tunnel_id_value,
10775 /* *** deal with flow director mask on flexible payload *** */
10776 struct cmd_flow_director_flex_mask_result {
10777 cmdline_fixed_string_t flow_director_flexmask;
10779 cmdline_fixed_string_t flow;
10780 cmdline_fixed_string_t flow_type;
10781 cmdline_fixed_string_t mask;
10785 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10786 __attribute__((unused)) struct cmdline *cl,
10787 __attribute__((unused)) void *data)
10789 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10790 struct rte_eth_fdir_info fdir_info;
10791 struct rte_eth_fdir_flex_mask flex_mask;
10792 struct rte_port *port;
10793 uint32_t flow_type_mask;
10797 if (res->port_id > nb_ports) {
10798 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10802 port = &ports[res->port_id];
10803 /** Check if the port is not started **/
10804 if (port->port_status != RTE_PORT_STOPPED) {
10805 printf("Please stop port %d first\n", res->port_id);
10809 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10810 ret = parse_flexbytes(res->mask,
10812 RTE_ETH_FDIR_MAX_FLEXLEN);
10814 printf("error: Cannot parse mask input.\n");
10818 memset(&fdir_info, 0, sizeof(fdir_info));
10819 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10820 RTE_ETH_FILTER_INFO, &fdir_info);
10822 printf("Cannot get FDir filter info\n");
10826 if (!strcmp(res->flow_type, "none")) {
10827 /* means don't specify the flow type */
10828 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10829 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10830 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10831 0, sizeof(struct rte_eth_fdir_flex_mask));
10832 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10833 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10835 sizeof(struct rte_eth_fdir_flex_mask));
10836 cmd_reconfig_device_queue(res->port_id, 1, 1);
10839 flow_type_mask = fdir_info.flow_types_mask[0];
10840 if (!strcmp(res->flow_type, "all")) {
10841 if (!flow_type_mask) {
10842 printf("No flow type supported\n");
10845 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10846 if (flow_type_mask & (1 << i)) {
10847 flex_mask.flow_type = i;
10848 fdir_set_flex_mask(res->port_id, &flex_mask);
10851 cmd_reconfig_device_queue(res->port_id, 1, 1);
10854 flex_mask.flow_type = str2flowtype(res->flow_type);
10855 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10856 printf("Flow type %s not supported on port %d\n",
10857 res->flow_type, res->port_id);
10860 fdir_set_flex_mask(res->port_id, &flex_mask);
10861 cmd_reconfig_device_queue(res->port_id, 1, 1);
10864 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10866 flow_director_flexmask,
10867 "flow_director_flex_mask");
10868 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10869 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10871 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10872 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10874 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10875 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10876 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10877 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10878 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10882 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10883 .f = cmd_flow_director_flex_mask_parsed,
10885 .help_str = "flow_director_flex_mask ... : "
10886 "Set flow director's flex mask on NIC",
10888 (void *)&cmd_flow_director_flexmask,
10889 (void *)&cmd_flow_director_flexmask_port_id,
10890 (void *)&cmd_flow_director_flexmask_flow,
10891 (void *)&cmd_flow_director_flexmask_flow_type,
10892 (void *)&cmd_flow_director_flexmask_mask,
10897 /* *** deal with flow director flexible payload configuration *** */
10898 struct cmd_flow_director_flexpayload_result {
10899 cmdline_fixed_string_t flow_director_flexpayload;
10901 cmdline_fixed_string_t payload_layer;
10902 cmdline_fixed_string_t payload_cfg;
10906 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10909 const char *p, *p0 = q_arg;
10911 unsigned long int_fld;
10912 char *str_fld[max_num];
10917 p = strchr(p0, '(');
10921 p0 = strchr(p, ')');
10926 if (size >= sizeof(s))
10929 snprintf(s, sizeof(s), "%.*s", size, p);
10930 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10931 if (ret < 0 || ret > max_num)
10933 for (i = 0; i < ret; i++) {
10935 int_fld = strtoul(str_fld[i], &end, 0);
10936 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10938 offsets[i] = (uint16_t)int_fld;
10944 cmd_flow_director_flxpld_parsed(void *parsed_result,
10945 __attribute__((unused)) struct cmdline *cl,
10946 __attribute__((unused)) void *data)
10948 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10949 struct rte_eth_flex_payload_cfg flex_cfg;
10950 struct rte_port *port;
10953 if (res->port_id > nb_ports) {
10954 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10958 port = &ports[res->port_id];
10959 /** Check if the port is not started **/
10960 if (port->port_status != RTE_PORT_STOPPED) {
10961 printf("Please stop port %d first\n", res->port_id);
10965 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10967 if (!strcmp(res->payload_layer, "raw"))
10968 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10969 else if (!strcmp(res->payload_layer, "l2"))
10970 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10971 else if (!strcmp(res->payload_layer, "l3"))
10972 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10973 else if (!strcmp(res->payload_layer, "l4"))
10974 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10976 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10977 RTE_ETH_FDIR_MAX_FLEXLEN);
10979 printf("error: Cannot parse flex payload input.\n");
10983 fdir_set_flex_payload(res->port_id, &flex_cfg);
10984 cmd_reconfig_device_queue(res->port_id, 1, 1);
10987 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10988 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10989 flow_director_flexpayload,
10990 "flow_director_flex_payload");
10991 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10992 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10994 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10995 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10996 payload_layer, "raw#l2#l3#l4");
10997 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10998 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10999 payload_cfg, NULL);
11001 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11002 .f = cmd_flow_director_flxpld_parsed,
11004 .help_str = "flow_director_flexpayload ... : "
11005 "Set flow director's flex payload on NIC",
11007 (void *)&cmd_flow_director_flexpayload,
11008 (void *)&cmd_flow_director_flexpayload_port_id,
11009 (void *)&cmd_flow_director_flexpayload_payload_layer,
11010 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11015 /* Generic flow interface command. */
11016 extern cmdline_parse_inst_t cmd_flow;
11018 /* *** Classification Filters Control *** */
11019 /* *** Get symmetric hash enable per port *** */
11020 struct cmd_get_sym_hash_ena_per_port_result {
11021 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11026 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11027 __rte_unused struct cmdline *cl,
11028 __rte_unused void *data)
11030 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11031 struct rte_eth_hash_filter_info info;
11034 if (rte_eth_dev_filter_supported(res->port_id,
11035 RTE_ETH_FILTER_HASH) < 0) {
11036 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11041 memset(&info, 0, sizeof(info));
11042 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11043 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11044 RTE_ETH_FILTER_GET, &info);
11047 printf("Cannot get symmetric hash enable per port "
11048 "on port %u\n", res->port_id);
11052 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11053 "enabled" : "disabled", res->port_id);
11056 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11057 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11058 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11059 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11060 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11063 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11064 .f = cmd_get_sym_hash_per_port_parsed,
11066 .help_str = "get_sym_hash_ena_per_port <port_id>",
11068 (void *)&cmd_get_sym_hash_ena_per_port_all,
11069 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11074 /* *** Set symmetric hash enable per port *** */
11075 struct cmd_set_sym_hash_ena_per_port_result {
11076 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11077 cmdline_fixed_string_t enable;
11082 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11083 __rte_unused struct cmdline *cl,
11084 __rte_unused void *data)
11086 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11087 struct rte_eth_hash_filter_info info;
11090 if (rte_eth_dev_filter_supported(res->port_id,
11091 RTE_ETH_FILTER_HASH) < 0) {
11092 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11097 memset(&info, 0, sizeof(info));
11098 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11099 if (!strcmp(res->enable, "enable"))
11100 info.info.enable = 1;
11101 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11102 RTE_ETH_FILTER_SET, &info);
11104 printf("Cannot set symmetric hash enable per port on "
11105 "port %u\n", res->port_id);
11108 printf("Symmetric hash has been set to %s on port %u\n",
11109 res->enable, res->port_id);
11112 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11113 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11114 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11115 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11116 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11118 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11119 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11120 enable, "enable#disable");
11122 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11123 .f = cmd_set_sym_hash_per_port_parsed,
11125 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11127 (void *)&cmd_set_sym_hash_ena_per_port_all,
11128 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11129 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11134 /* Get global config of hash function */
11135 struct cmd_get_hash_global_config_result {
11136 cmdline_fixed_string_t get_hash_global_config;
11141 flowtype_to_str(uint16_t ftype)
11147 } ftype_table[] = {
11148 {"ipv4", RTE_ETH_FLOW_IPV4},
11149 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11150 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11151 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11152 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11153 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11154 {"ipv6", RTE_ETH_FLOW_IPV6},
11155 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11156 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11157 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11158 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11159 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11160 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11161 {"port", RTE_ETH_FLOW_PORT},
11162 {"vxlan", RTE_ETH_FLOW_VXLAN},
11163 {"geneve", RTE_ETH_FLOW_GENEVE},
11164 {"nvgre", RTE_ETH_FLOW_NVGRE},
11167 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11168 if (ftype_table[i].ftype == ftype)
11169 return ftype_table[i].str;
11176 cmd_get_hash_global_config_parsed(void *parsed_result,
11177 __rte_unused struct cmdline *cl,
11178 __rte_unused void *data)
11180 struct cmd_get_hash_global_config_result *res = parsed_result;
11181 struct rte_eth_hash_filter_info info;
11182 uint32_t idx, offset;
11187 if (rte_eth_dev_filter_supported(res->port_id,
11188 RTE_ETH_FILTER_HASH) < 0) {
11189 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11194 memset(&info, 0, sizeof(info));
11195 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11196 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11197 RTE_ETH_FILTER_GET, &info);
11199 printf("Cannot get hash global configurations by port %d\n",
11204 switch (info.info.global_conf.hash_func) {
11205 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11206 printf("Hash function is Toeplitz\n");
11208 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11209 printf("Hash function is Simple XOR\n");
11212 printf("Unknown hash function\n");
11216 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11217 idx = i / UINT32_BIT;
11218 offset = i % UINT32_BIT;
11219 if (!(info.info.global_conf.valid_bit_mask[idx] &
11222 str = flowtype_to_str(i);
11225 printf("Symmetric hash is %s globally for flow type %s "
11227 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11228 (1UL << offset)) ? "enabled" : "disabled"), str,
11233 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11234 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11235 get_hash_global_config, "get_hash_global_config");
11236 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11237 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11240 cmdline_parse_inst_t cmd_get_hash_global_config = {
11241 .f = cmd_get_hash_global_config_parsed,
11243 .help_str = "get_hash_global_config <port_id>",
11245 (void *)&cmd_get_hash_global_config_all,
11246 (void *)&cmd_get_hash_global_config_port_id,
11251 /* Set global config of hash function */
11252 struct cmd_set_hash_global_config_result {
11253 cmdline_fixed_string_t set_hash_global_config;
11255 cmdline_fixed_string_t hash_func;
11256 cmdline_fixed_string_t flow_type;
11257 cmdline_fixed_string_t enable;
11261 cmd_set_hash_global_config_parsed(void *parsed_result,
11262 __rte_unused struct cmdline *cl,
11263 __rte_unused void *data)
11265 struct cmd_set_hash_global_config_result *res = parsed_result;
11266 struct rte_eth_hash_filter_info info;
11267 uint32_t ftype, idx, offset;
11270 if (rte_eth_dev_filter_supported(res->port_id,
11271 RTE_ETH_FILTER_HASH) < 0) {
11272 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11276 memset(&info, 0, sizeof(info));
11277 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11278 if (!strcmp(res->hash_func, "toeplitz"))
11279 info.info.global_conf.hash_func =
11280 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11281 else if (!strcmp(res->hash_func, "simple_xor"))
11282 info.info.global_conf.hash_func =
11283 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11284 else if (!strcmp(res->hash_func, "default"))
11285 info.info.global_conf.hash_func =
11286 RTE_ETH_HASH_FUNCTION_DEFAULT;
11288 ftype = str2flowtype(res->flow_type);
11289 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11290 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11291 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11292 if (!strcmp(res->enable, "enable"))
11293 info.info.global_conf.sym_hash_enable_mask[idx] |=
11295 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11296 RTE_ETH_FILTER_SET, &info);
11298 printf("Cannot set global hash configurations by port %d\n",
11301 printf("Global hash configurations have been set "
11302 "succcessfully by port %d\n", res->port_id);
11305 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11306 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11307 set_hash_global_config, "set_hash_global_config");
11308 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11309 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11311 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11312 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11313 hash_func, "toeplitz#simple_xor#default");
11314 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11315 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11317 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11318 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11319 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11320 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11321 enable, "enable#disable");
11323 cmdline_parse_inst_t cmd_set_hash_global_config = {
11324 .f = cmd_set_hash_global_config_parsed,
11326 .help_str = "set_hash_global_config <port_id> "
11327 "toeplitz|simple_xor|default "
11328 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11329 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11330 "l2_payload enable|disable",
11332 (void *)&cmd_set_hash_global_config_all,
11333 (void *)&cmd_set_hash_global_config_port_id,
11334 (void *)&cmd_set_hash_global_config_hash_func,
11335 (void *)&cmd_set_hash_global_config_flow_type,
11336 (void *)&cmd_set_hash_global_config_enable,
11341 /* Set hash input set */
11342 struct cmd_set_hash_input_set_result {
11343 cmdline_fixed_string_t set_hash_input_set;
11345 cmdline_fixed_string_t flow_type;
11346 cmdline_fixed_string_t inset_field;
11347 cmdline_fixed_string_t select;
11350 static enum rte_eth_input_set_field
11351 str2inset(char *string)
11355 static const struct {
11357 enum rte_eth_input_set_field inset;
11358 } inset_table[] = {
11359 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11360 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11361 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11362 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11363 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11364 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11365 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11366 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11367 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11368 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11369 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11370 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11371 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11372 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11373 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11374 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11375 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11376 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11377 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11378 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11379 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11380 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11381 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11382 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11383 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11384 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11385 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11386 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11387 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11388 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11389 {"none", RTE_ETH_INPUT_SET_NONE},
11392 for (i = 0; i < RTE_DIM(inset_table); i++) {
11393 if (!strcmp(string, inset_table[i].str))
11394 return inset_table[i].inset;
11397 return RTE_ETH_INPUT_SET_UNKNOWN;
11401 cmd_set_hash_input_set_parsed(void *parsed_result,
11402 __rte_unused struct cmdline *cl,
11403 __rte_unused void *data)
11405 struct cmd_set_hash_input_set_result *res = parsed_result;
11406 struct rte_eth_hash_filter_info info;
11408 memset(&info, 0, sizeof(info));
11409 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11410 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11411 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11412 info.info.input_set_conf.inset_size = 1;
11413 if (!strcmp(res->select, "select"))
11414 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11415 else if (!strcmp(res->select, "add"))
11416 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11417 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11418 RTE_ETH_FILTER_SET, &info);
11421 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11422 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11423 set_hash_input_set, "set_hash_input_set");
11424 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11425 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11427 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11428 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11430 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11431 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11433 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11434 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11435 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11436 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11437 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11439 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11440 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11441 select, "select#add");
11443 cmdline_parse_inst_t cmd_set_hash_input_set = {
11444 .f = cmd_set_hash_input_set_parsed,
11446 .help_str = "set_hash_input_set <port_id> "
11447 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11448 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11449 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11450 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11451 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11452 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11453 "fld-7th|fld-8th|none select|add",
11455 (void *)&cmd_set_hash_input_set_cmd,
11456 (void *)&cmd_set_hash_input_set_port_id,
11457 (void *)&cmd_set_hash_input_set_flow_type,
11458 (void *)&cmd_set_hash_input_set_field,
11459 (void *)&cmd_set_hash_input_set_select,
11464 /* Set flow director input set */
11465 struct cmd_set_fdir_input_set_result {
11466 cmdline_fixed_string_t set_fdir_input_set;
11468 cmdline_fixed_string_t flow_type;
11469 cmdline_fixed_string_t inset_field;
11470 cmdline_fixed_string_t select;
11474 cmd_set_fdir_input_set_parsed(void *parsed_result,
11475 __rte_unused struct cmdline *cl,
11476 __rte_unused void *data)
11478 struct cmd_set_fdir_input_set_result *res = parsed_result;
11479 struct rte_eth_fdir_filter_info info;
11481 memset(&info, 0, sizeof(info));
11482 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11483 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11484 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11485 info.info.input_set_conf.inset_size = 1;
11486 if (!strcmp(res->select, "select"))
11487 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11488 else if (!strcmp(res->select, "add"))
11489 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11490 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11491 RTE_ETH_FILTER_SET, &info);
11494 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11495 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11496 set_fdir_input_set, "set_fdir_input_set");
11497 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11498 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11500 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11501 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11503 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11504 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11505 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11506 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11508 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11509 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11510 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11511 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11512 "sctp-veri-tag#none");
11513 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11514 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11515 select, "select#add");
11517 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11518 .f = cmd_set_fdir_input_set_parsed,
11520 .help_str = "set_fdir_input_set <port_id> "
11521 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11522 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11523 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11524 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11525 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11526 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11527 "sctp-veri-tag|none select|add",
11529 (void *)&cmd_set_fdir_input_set_cmd,
11530 (void *)&cmd_set_fdir_input_set_port_id,
11531 (void *)&cmd_set_fdir_input_set_flow_type,
11532 (void *)&cmd_set_fdir_input_set_field,
11533 (void *)&cmd_set_fdir_input_set_select,
11538 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11539 struct cmd_mcast_addr_result {
11540 cmdline_fixed_string_t mcast_addr_cmd;
11541 cmdline_fixed_string_t what;
11543 struct ether_addr mc_addr;
11546 static void cmd_mcast_addr_parsed(void *parsed_result,
11547 __attribute__((unused)) struct cmdline *cl,
11548 __attribute__((unused)) void *data)
11550 struct cmd_mcast_addr_result *res = parsed_result;
11552 if (!is_multicast_ether_addr(&res->mc_addr)) {
11553 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11554 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11555 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11556 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11559 if (strcmp(res->what, "add") == 0)
11560 mcast_addr_add(res->port_num, &res->mc_addr);
11562 mcast_addr_remove(res->port_num, &res->mc_addr);
11565 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11566 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11567 mcast_addr_cmd, "mcast_addr");
11568 cmdline_parse_token_string_t cmd_mcast_addr_what =
11569 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11571 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11572 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11573 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11574 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11576 cmdline_parse_inst_t cmd_mcast_addr = {
11577 .f = cmd_mcast_addr_parsed,
11579 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11580 "Add/Remove multicast MAC address on port_id",
11582 (void *)&cmd_mcast_addr_cmd,
11583 (void *)&cmd_mcast_addr_what,
11584 (void *)&cmd_mcast_addr_portnum,
11585 (void *)&cmd_mcast_addr_addr,
11590 /* l2 tunnel config
11591 * only support E-tag now.
11594 /* Ether type config */
11595 struct cmd_config_l2_tunnel_eth_type_result {
11596 cmdline_fixed_string_t port;
11597 cmdline_fixed_string_t config;
11598 cmdline_fixed_string_t all;
11600 cmdline_fixed_string_t l2_tunnel;
11601 cmdline_fixed_string_t l2_tunnel_type;
11602 cmdline_fixed_string_t eth_type;
11603 uint16_t eth_type_val;
11606 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11607 TOKEN_STRING_INITIALIZER
11608 (struct cmd_config_l2_tunnel_eth_type_result,
11610 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11611 TOKEN_STRING_INITIALIZER
11612 (struct cmd_config_l2_tunnel_eth_type_result,
11614 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11615 TOKEN_STRING_INITIALIZER
11616 (struct cmd_config_l2_tunnel_eth_type_result,
11618 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11619 TOKEN_NUM_INITIALIZER
11620 (struct cmd_config_l2_tunnel_eth_type_result,
11622 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11623 TOKEN_STRING_INITIALIZER
11624 (struct cmd_config_l2_tunnel_eth_type_result,
11625 l2_tunnel, "l2-tunnel");
11626 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11627 TOKEN_STRING_INITIALIZER
11628 (struct cmd_config_l2_tunnel_eth_type_result,
11629 l2_tunnel_type, "E-tag");
11630 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11631 TOKEN_STRING_INITIALIZER
11632 (struct cmd_config_l2_tunnel_eth_type_result,
11633 eth_type, "ether-type");
11634 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11635 TOKEN_NUM_INITIALIZER
11636 (struct cmd_config_l2_tunnel_eth_type_result,
11637 eth_type_val, UINT16);
11639 static enum rte_eth_tunnel_type
11640 str2fdir_l2_tunnel_type(char *string)
11644 static const struct {
11646 enum rte_eth_tunnel_type type;
11647 } l2_tunnel_type_str[] = {
11648 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11651 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11652 if (!strcmp(l2_tunnel_type_str[i].str, string))
11653 return l2_tunnel_type_str[i].type;
11655 return RTE_TUNNEL_TYPE_NONE;
11658 /* ether type config for all ports */
11660 cmd_config_l2_tunnel_eth_type_all_parsed
11661 (void *parsed_result,
11662 __attribute__((unused)) struct cmdline *cl,
11663 __attribute__((unused)) void *data)
11665 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11666 struct rte_eth_l2_tunnel_conf entry;
11669 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11670 entry.ether_type = res->eth_type_val;
11672 RTE_ETH_FOREACH_DEV(pid) {
11673 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11677 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11678 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11680 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11682 (void *)&cmd_config_l2_tunnel_eth_type_port,
11683 (void *)&cmd_config_l2_tunnel_eth_type_config,
11684 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11685 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11686 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11687 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11688 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11693 /* ether type config for a specific port */
11695 cmd_config_l2_tunnel_eth_type_specific_parsed(
11696 void *parsed_result,
11697 __attribute__((unused)) struct cmdline *cl,
11698 __attribute__((unused)) void *data)
11700 struct cmd_config_l2_tunnel_eth_type_result *res =
11702 struct rte_eth_l2_tunnel_conf entry;
11704 if (port_id_is_invalid(res->id, ENABLED_WARN))
11707 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11708 entry.ether_type = res->eth_type_val;
11710 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11713 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11714 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11716 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11718 (void *)&cmd_config_l2_tunnel_eth_type_port,
11719 (void *)&cmd_config_l2_tunnel_eth_type_config,
11720 (void *)&cmd_config_l2_tunnel_eth_type_id,
11721 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11722 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11723 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11724 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11729 /* Enable/disable l2 tunnel */
11730 struct cmd_config_l2_tunnel_en_dis_result {
11731 cmdline_fixed_string_t port;
11732 cmdline_fixed_string_t config;
11733 cmdline_fixed_string_t all;
11735 cmdline_fixed_string_t l2_tunnel;
11736 cmdline_fixed_string_t l2_tunnel_type;
11737 cmdline_fixed_string_t en_dis;
11740 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11741 TOKEN_STRING_INITIALIZER
11742 (struct cmd_config_l2_tunnel_en_dis_result,
11744 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11745 TOKEN_STRING_INITIALIZER
11746 (struct cmd_config_l2_tunnel_en_dis_result,
11748 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11749 TOKEN_STRING_INITIALIZER
11750 (struct cmd_config_l2_tunnel_en_dis_result,
11752 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11753 TOKEN_NUM_INITIALIZER
11754 (struct cmd_config_l2_tunnel_en_dis_result,
11756 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11757 TOKEN_STRING_INITIALIZER
11758 (struct cmd_config_l2_tunnel_en_dis_result,
11759 l2_tunnel, "l2-tunnel");
11760 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11761 TOKEN_STRING_INITIALIZER
11762 (struct cmd_config_l2_tunnel_en_dis_result,
11763 l2_tunnel_type, "E-tag");
11764 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11765 TOKEN_STRING_INITIALIZER
11766 (struct cmd_config_l2_tunnel_en_dis_result,
11767 en_dis, "enable#disable");
11769 /* enable/disable l2 tunnel for all ports */
11771 cmd_config_l2_tunnel_en_dis_all_parsed(
11772 void *parsed_result,
11773 __attribute__((unused)) struct cmdline *cl,
11774 __attribute__((unused)) void *data)
11776 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11777 struct rte_eth_l2_tunnel_conf entry;
11781 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11783 if (!strcmp("enable", res->en_dis))
11788 RTE_ETH_FOREACH_DEV(pid) {
11789 rte_eth_dev_l2_tunnel_offload_set(pid,
11791 ETH_L2_TUNNEL_ENABLE_MASK,
11796 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11797 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11799 .help_str = "port config all l2-tunnel E-tag enable|disable",
11801 (void *)&cmd_config_l2_tunnel_en_dis_port,
11802 (void *)&cmd_config_l2_tunnel_en_dis_config,
11803 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11804 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11805 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11806 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11811 /* enable/disable l2 tunnel for a port */
11813 cmd_config_l2_tunnel_en_dis_specific_parsed(
11814 void *parsed_result,
11815 __attribute__((unused)) struct cmdline *cl,
11816 __attribute__((unused)) void *data)
11818 struct cmd_config_l2_tunnel_en_dis_result *res =
11820 struct rte_eth_l2_tunnel_conf entry;
11822 if (port_id_is_invalid(res->id, ENABLED_WARN))
11825 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11827 if (!strcmp("enable", res->en_dis))
11828 rte_eth_dev_l2_tunnel_offload_set(res->id,
11830 ETH_L2_TUNNEL_ENABLE_MASK,
11833 rte_eth_dev_l2_tunnel_offload_set(res->id,
11835 ETH_L2_TUNNEL_ENABLE_MASK,
11839 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11840 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11842 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11844 (void *)&cmd_config_l2_tunnel_en_dis_port,
11845 (void *)&cmd_config_l2_tunnel_en_dis_config,
11846 (void *)&cmd_config_l2_tunnel_en_dis_id,
11847 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11848 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11849 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11854 /* E-tag configuration */
11856 /* Common result structure for all E-tag configuration */
11857 struct cmd_config_e_tag_result {
11858 cmdline_fixed_string_t e_tag;
11859 cmdline_fixed_string_t set;
11860 cmdline_fixed_string_t insertion;
11861 cmdline_fixed_string_t stripping;
11862 cmdline_fixed_string_t forwarding;
11863 cmdline_fixed_string_t filter;
11864 cmdline_fixed_string_t add;
11865 cmdline_fixed_string_t del;
11866 cmdline_fixed_string_t on;
11867 cmdline_fixed_string_t off;
11868 cmdline_fixed_string_t on_off;
11869 cmdline_fixed_string_t port_tag_id;
11870 uint32_t port_tag_id_val;
11871 cmdline_fixed_string_t e_tag_id;
11872 uint16_t e_tag_id_val;
11873 cmdline_fixed_string_t dst_pool;
11874 uint8_t dst_pool_val;
11875 cmdline_fixed_string_t port;
11877 cmdline_fixed_string_t vf;
11881 /* Common CLI fields for all E-tag configuration */
11882 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11883 TOKEN_STRING_INITIALIZER
11884 (struct cmd_config_e_tag_result,
11886 cmdline_parse_token_string_t cmd_config_e_tag_set =
11887 TOKEN_STRING_INITIALIZER
11888 (struct cmd_config_e_tag_result,
11890 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11891 TOKEN_STRING_INITIALIZER
11892 (struct cmd_config_e_tag_result,
11893 insertion, "insertion");
11894 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11895 TOKEN_STRING_INITIALIZER
11896 (struct cmd_config_e_tag_result,
11897 stripping, "stripping");
11898 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11899 TOKEN_STRING_INITIALIZER
11900 (struct cmd_config_e_tag_result,
11901 forwarding, "forwarding");
11902 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11903 TOKEN_STRING_INITIALIZER
11904 (struct cmd_config_e_tag_result,
11906 cmdline_parse_token_string_t cmd_config_e_tag_add =
11907 TOKEN_STRING_INITIALIZER
11908 (struct cmd_config_e_tag_result,
11910 cmdline_parse_token_string_t cmd_config_e_tag_del =
11911 TOKEN_STRING_INITIALIZER
11912 (struct cmd_config_e_tag_result,
11914 cmdline_parse_token_string_t cmd_config_e_tag_on =
11915 TOKEN_STRING_INITIALIZER
11916 (struct cmd_config_e_tag_result,
11918 cmdline_parse_token_string_t cmd_config_e_tag_off =
11919 TOKEN_STRING_INITIALIZER
11920 (struct cmd_config_e_tag_result,
11922 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11923 TOKEN_STRING_INITIALIZER
11924 (struct cmd_config_e_tag_result,
11926 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11927 TOKEN_STRING_INITIALIZER
11928 (struct cmd_config_e_tag_result,
11929 port_tag_id, "port-tag-id");
11930 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11931 TOKEN_NUM_INITIALIZER
11932 (struct cmd_config_e_tag_result,
11933 port_tag_id_val, UINT32);
11934 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11935 TOKEN_STRING_INITIALIZER
11936 (struct cmd_config_e_tag_result,
11937 e_tag_id, "e-tag-id");
11938 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11939 TOKEN_NUM_INITIALIZER
11940 (struct cmd_config_e_tag_result,
11941 e_tag_id_val, UINT16);
11942 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11943 TOKEN_STRING_INITIALIZER
11944 (struct cmd_config_e_tag_result,
11945 dst_pool, "dst-pool");
11946 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11947 TOKEN_NUM_INITIALIZER
11948 (struct cmd_config_e_tag_result,
11949 dst_pool_val, UINT8);
11950 cmdline_parse_token_string_t cmd_config_e_tag_port =
11951 TOKEN_STRING_INITIALIZER
11952 (struct cmd_config_e_tag_result,
11954 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11955 TOKEN_NUM_INITIALIZER
11956 (struct cmd_config_e_tag_result,
11958 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11959 TOKEN_STRING_INITIALIZER
11960 (struct cmd_config_e_tag_result,
11962 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11963 TOKEN_NUM_INITIALIZER
11964 (struct cmd_config_e_tag_result,
11967 /* E-tag insertion configuration */
11969 cmd_config_e_tag_insertion_en_parsed(
11970 void *parsed_result,
11971 __attribute__((unused)) struct cmdline *cl,
11972 __attribute__((unused)) void *data)
11974 struct cmd_config_e_tag_result *res =
11976 struct rte_eth_l2_tunnel_conf entry;
11978 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11981 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11982 entry.tunnel_id = res->port_tag_id_val;
11983 entry.vf_id = res->vf_id;
11984 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11986 ETH_L2_TUNNEL_INSERTION_MASK,
11991 cmd_config_e_tag_insertion_dis_parsed(
11992 void *parsed_result,
11993 __attribute__((unused)) struct cmdline *cl,
11994 __attribute__((unused)) void *data)
11996 struct cmd_config_e_tag_result *res =
11998 struct rte_eth_l2_tunnel_conf entry;
12000 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12003 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12004 entry.vf_id = res->vf_id;
12006 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12008 ETH_L2_TUNNEL_INSERTION_MASK,
12012 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12013 .f = cmd_config_e_tag_insertion_en_parsed,
12015 .help_str = "E-tag ... : E-tag insertion enable",
12017 (void *)&cmd_config_e_tag_e_tag,
12018 (void *)&cmd_config_e_tag_set,
12019 (void *)&cmd_config_e_tag_insertion,
12020 (void *)&cmd_config_e_tag_on,
12021 (void *)&cmd_config_e_tag_port_tag_id,
12022 (void *)&cmd_config_e_tag_port_tag_id_val,
12023 (void *)&cmd_config_e_tag_port,
12024 (void *)&cmd_config_e_tag_port_id,
12025 (void *)&cmd_config_e_tag_vf,
12026 (void *)&cmd_config_e_tag_vf_id,
12031 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12032 .f = cmd_config_e_tag_insertion_dis_parsed,
12034 .help_str = "E-tag ... : E-tag insertion disable",
12036 (void *)&cmd_config_e_tag_e_tag,
12037 (void *)&cmd_config_e_tag_set,
12038 (void *)&cmd_config_e_tag_insertion,
12039 (void *)&cmd_config_e_tag_off,
12040 (void *)&cmd_config_e_tag_port,
12041 (void *)&cmd_config_e_tag_port_id,
12042 (void *)&cmd_config_e_tag_vf,
12043 (void *)&cmd_config_e_tag_vf_id,
12048 /* E-tag stripping configuration */
12050 cmd_config_e_tag_stripping_parsed(
12051 void *parsed_result,
12052 __attribute__((unused)) struct cmdline *cl,
12053 __attribute__((unused)) void *data)
12055 struct cmd_config_e_tag_result *res =
12057 struct rte_eth_l2_tunnel_conf entry;
12059 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12062 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12064 if (!strcmp(res->on_off, "on"))
12065 rte_eth_dev_l2_tunnel_offload_set
12068 ETH_L2_TUNNEL_STRIPPING_MASK,
12071 rte_eth_dev_l2_tunnel_offload_set
12074 ETH_L2_TUNNEL_STRIPPING_MASK,
12078 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12079 .f = cmd_config_e_tag_stripping_parsed,
12081 .help_str = "E-tag ... : E-tag stripping enable/disable",
12083 (void *)&cmd_config_e_tag_e_tag,
12084 (void *)&cmd_config_e_tag_set,
12085 (void *)&cmd_config_e_tag_stripping,
12086 (void *)&cmd_config_e_tag_on_off,
12087 (void *)&cmd_config_e_tag_port,
12088 (void *)&cmd_config_e_tag_port_id,
12093 /* E-tag forwarding configuration */
12095 cmd_config_e_tag_forwarding_parsed(
12096 void *parsed_result,
12097 __attribute__((unused)) struct cmdline *cl,
12098 __attribute__((unused)) void *data)
12100 struct cmd_config_e_tag_result *res = parsed_result;
12101 struct rte_eth_l2_tunnel_conf entry;
12103 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12106 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12108 if (!strcmp(res->on_off, "on"))
12109 rte_eth_dev_l2_tunnel_offload_set
12112 ETH_L2_TUNNEL_FORWARDING_MASK,
12115 rte_eth_dev_l2_tunnel_offload_set
12118 ETH_L2_TUNNEL_FORWARDING_MASK,
12122 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12123 .f = cmd_config_e_tag_forwarding_parsed,
12125 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12127 (void *)&cmd_config_e_tag_e_tag,
12128 (void *)&cmd_config_e_tag_set,
12129 (void *)&cmd_config_e_tag_forwarding,
12130 (void *)&cmd_config_e_tag_on_off,
12131 (void *)&cmd_config_e_tag_port,
12132 (void *)&cmd_config_e_tag_port_id,
12137 /* E-tag filter configuration */
12139 cmd_config_e_tag_filter_add_parsed(
12140 void *parsed_result,
12141 __attribute__((unused)) struct cmdline *cl,
12142 __attribute__((unused)) void *data)
12144 struct cmd_config_e_tag_result *res = parsed_result;
12145 struct rte_eth_l2_tunnel_conf entry;
12148 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12151 if (res->e_tag_id_val > 0x3fff) {
12152 printf("e-tag-id must be equal or less than 0x3fff.\n");
12156 ret = rte_eth_dev_filter_supported(res->port_id,
12157 RTE_ETH_FILTER_L2_TUNNEL);
12159 printf("E-tag filter is not supported on port %u.\n",
12164 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12165 entry.tunnel_id = res->e_tag_id_val;
12166 entry.pool = res->dst_pool_val;
12168 ret = rte_eth_dev_filter_ctrl(res->port_id,
12169 RTE_ETH_FILTER_L2_TUNNEL,
12170 RTE_ETH_FILTER_ADD,
12173 printf("E-tag filter programming error: (%s)\n",
12177 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12178 .f = cmd_config_e_tag_filter_add_parsed,
12180 .help_str = "E-tag ... : E-tag filter add",
12182 (void *)&cmd_config_e_tag_e_tag,
12183 (void *)&cmd_config_e_tag_set,
12184 (void *)&cmd_config_e_tag_filter,
12185 (void *)&cmd_config_e_tag_add,
12186 (void *)&cmd_config_e_tag_e_tag_id,
12187 (void *)&cmd_config_e_tag_e_tag_id_val,
12188 (void *)&cmd_config_e_tag_dst_pool,
12189 (void *)&cmd_config_e_tag_dst_pool_val,
12190 (void *)&cmd_config_e_tag_port,
12191 (void *)&cmd_config_e_tag_port_id,
12197 cmd_config_e_tag_filter_del_parsed(
12198 void *parsed_result,
12199 __attribute__((unused)) struct cmdline *cl,
12200 __attribute__((unused)) void *data)
12202 struct cmd_config_e_tag_result *res = parsed_result;
12203 struct rte_eth_l2_tunnel_conf entry;
12206 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12209 if (res->e_tag_id_val > 0x3fff) {
12210 printf("e-tag-id must be less than 0x3fff.\n");
12214 ret = rte_eth_dev_filter_supported(res->port_id,
12215 RTE_ETH_FILTER_L2_TUNNEL);
12217 printf("E-tag filter is not supported on port %u.\n",
12222 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12223 entry.tunnel_id = res->e_tag_id_val;
12225 ret = rte_eth_dev_filter_ctrl(res->port_id,
12226 RTE_ETH_FILTER_L2_TUNNEL,
12227 RTE_ETH_FILTER_DELETE,
12230 printf("E-tag filter programming error: (%s)\n",
12234 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12235 .f = cmd_config_e_tag_filter_del_parsed,
12237 .help_str = "E-tag ... : E-tag filter delete",
12239 (void *)&cmd_config_e_tag_e_tag,
12240 (void *)&cmd_config_e_tag_set,
12241 (void *)&cmd_config_e_tag_filter,
12242 (void *)&cmd_config_e_tag_del,
12243 (void *)&cmd_config_e_tag_e_tag_id,
12244 (void *)&cmd_config_e_tag_e_tag_id_val,
12245 (void *)&cmd_config_e_tag_port,
12246 (void *)&cmd_config_e_tag_port_id,
12251 /* vf vlan anti spoof configuration */
12253 /* Common result structure for vf vlan anti spoof */
12254 struct cmd_vf_vlan_anti_spoof_result {
12255 cmdline_fixed_string_t set;
12256 cmdline_fixed_string_t vf;
12257 cmdline_fixed_string_t vlan;
12258 cmdline_fixed_string_t antispoof;
12261 cmdline_fixed_string_t on_off;
12264 /* Common CLI fields for vf vlan anti spoof enable disable */
12265 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12266 TOKEN_STRING_INITIALIZER
12267 (struct cmd_vf_vlan_anti_spoof_result,
12269 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12270 TOKEN_STRING_INITIALIZER
12271 (struct cmd_vf_vlan_anti_spoof_result,
12273 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12274 TOKEN_STRING_INITIALIZER
12275 (struct cmd_vf_vlan_anti_spoof_result,
12277 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12278 TOKEN_STRING_INITIALIZER
12279 (struct cmd_vf_vlan_anti_spoof_result,
12280 antispoof, "antispoof");
12281 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12282 TOKEN_NUM_INITIALIZER
12283 (struct cmd_vf_vlan_anti_spoof_result,
12285 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12286 TOKEN_NUM_INITIALIZER
12287 (struct cmd_vf_vlan_anti_spoof_result,
12289 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12290 TOKEN_STRING_INITIALIZER
12291 (struct cmd_vf_vlan_anti_spoof_result,
12295 cmd_set_vf_vlan_anti_spoof_parsed(
12296 void *parsed_result,
12297 __attribute__((unused)) struct cmdline *cl,
12298 __attribute__((unused)) void *data)
12300 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12301 int ret = -ENOTSUP;
12303 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12305 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12308 #ifdef RTE_LIBRTE_IXGBE_PMD
12309 if (ret == -ENOTSUP)
12310 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12311 res->vf_id, is_on);
12313 #ifdef RTE_LIBRTE_I40E_PMD
12314 if (ret == -ENOTSUP)
12315 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12316 res->vf_id, is_on);
12318 #ifdef RTE_LIBRTE_BNXT_PMD
12319 if (ret == -ENOTSUP)
12320 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12321 res->vf_id, is_on);
12328 printf("invalid vf_id %d\n", res->vf_id);
12331 printf("invalid port_id %d\n", res->port_id);
12334 printf("function not implemented\n");
12337 printf("programming error: (%s)\n", strerror(-ret));
12341 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12342 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12344 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12346 (void *)&cmd_vf_vlan_anti_spoof_set,
12347 (void *)&cmd_vf_vlan_anti_spoof_vf,
12348 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12349 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12350 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12351 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12352 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12357 /* vf mac anti spoof configuration */
12359 /* Common result structure for vf mac anti spoof */
12360 struct cmd_vf_mac_anti_spoof_result {
12361 cmdline_fixed_string_t set;
12362 cmdline_fixed_string_t vf;
12363 cmdline_fixed_string_t mac;
12364 cmdline_fixed_string_t antispoof;
12367 cmdline_fixed_string_t on_off;
12370 /* Common CLI fields for vf mac anti spoof enable disable */
12371 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12372 TOKEN_STRING_INITIALIZER
12373 (struct cmd_vf_mac_anti_spoof_result,
12375 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12376 TOKEN_STRING_INITIALIZER
12377 (struct cmd_vf_mac_anti_spoof_result,
12379 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12380 TOKEN_STRING_INITIALIZER
12381 (struct cmd_vf_mac_anti_spoof_result,
12383 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12384 TOKEN_STRING_INITIALIZER
12385 (struct cmd_vf_mac_anti_spoof_result,
12386 antispoof, "antispoof");
12387 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12388 TOKEN_NUM_INITIALIZER
12389 (struct cmd_vf_mac_anti_spoof_result,
12391 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12392 TOKEN_NUM_INITIALIZER
12393 (struct cmd_vf_mac_anti_spoof_result,
12395 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12396 TOKEN_STRING_INITIALIZER
12397 (struct cmd_vf_mac_anti_spoof_result,
12401 cmd_set_vf_mac_anti_spoof_parsed(
12402 void *parsed_result,
12403 __attribute__((unused)) struct cmdline *cl,
12404 __attribute__((unused)) void *data)
12406 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12407 int ret = -ENOTSUP;
12409 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12411 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12414 #ifdef RTE_LIBRTE_IXGBE_PMD
12415 if (ret == -ENOTSUP)
12416 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12417 res->vf_id, is_on);
12419 #ifdef RTE_LIBRTE_I40E_PMD
12420 if (ret == -ENOTSUP)
12421 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12422 res->vf_id, is_on);
12424 #ifdef RTE_LIBRTE_BNXT_PMD
12425 if (ret == -ENOTSUP)
12426 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12427 res->vf_id, is_on);
12434 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12437 printf("invalid port_id %d\n", res->port_id);
12440 printf("function not implemented\n");
12443 printf("programming error: (%s)\n", strerror(-ret));
12447 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12448 .f = cmd_set_vf_mac_anti_spoof_parsed,
12450 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12452 (void *)&cmd_vf_mac_anti_spoof_set,
12453 (void *)&cmd_vf_mac_anti_spoof_vf,
12454 (void *)&cmd_vf_mac_anti_spoof_mac,
12455 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12456 (void *)&cmd_vf_mac_anti_spoof_port_id,
12457 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12458 (void *)&cmd_vf_mac_anti_spoof_on_off,
12463 /* vf vlan strip queue configuration */
12465 /* Common result structure for vf mac anti spoof */
12466 struct cmd_vf_vlan_stripq_result {
12467 cmdline_fixed_string_t set;
12468 cmdline_fixed_string_t vf;
12469 cmdline_fixed_string_t vlan;
12470 cmdline_fixed_string_t stripq;
12473 cmdline_fixed_string_t on_off;
12476 /* Common CLI fields for vf vlan strip enable disable */
12477 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12478 TOKEN_STRING_INITIALIZER
12479 (struct cmd_vf_vlan_stripq_result,
12481 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12482 TOKEN_STRING_INITIALIZER
12483 (struct cmd_vf_vlan_stripq_result,
12485 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12486 TOKEN_STRING_INITIALIZER
12487 (struct cmd_vf_vlan_stripq_result,
12489 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12490 TOKEN_STRING_INITIALIZER
12491 (struct cmd_vf_vlan_stripq_result,
12493 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12494 TOKEN_NUM_INITIALIZER
12495 (struct cmd_vf_vlan_stripq_result,
12497 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12498 TOKEN_NUM_INITIALIZER
12499 (struct cmd_vf_vlan_stripq_result,
12501 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12502 TOKEN_STRING_INITIALIZER
12503 (struct cmd_vf_vlan_stripq_result,
12507 cmd_set_vf_vlan_stripq_parsed(
12508 void *parsed_result,
12509 __attribute__((unused)) struct cmdline *cl,
12510 __attribute__((unused)) void *data)
12512 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12513 int ret = -ENOTSUP;
12515 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12517 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12520 #ifdef RTE_LIBRTE_IXGBE_PMD
12521 if (ret == -ENOTSUP)
12522 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12523 res->vf_id, is_on);
12525 #ifdef RTE_LIBRTE_I40E_PMD
12526 if (ret == -ENOTSUP)
12527 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12528 res->vf_id, is_on);
12530 #ifdef RTE_LIBRTE_BNXT_PMD
12531 if (ret == -ENOTSUP)
12532 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12533 res->vf_id, is_on);
12540 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12543 printf("invalid port_id %d\n", res->port_id);
12546 printf("function not implemented\n");
12549 printf("programming error: (%s)\n", strerror(-ret));
12553 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12554 .f = cmd_set_vf_vlan_stripq_parsed,
12556 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12558 (void *)&cmd_vf_vlan_stripq_set,
12559 (void *)&cmd_vf_vlan_stripq_vf,
12560 (void *)&cmd_vf_vlan_stripq_vlan,
12561 (void *)&cmd_vf_vlan_stripq_stripq,
12562 (void *)&cmd_vf_vlan_stripq_port_id,
12563 (void *)&cmd_vf_vlan_stripq_vf_id,
12564 (void *)&cmd_vf_vlan_stripq_on_off,
12569 /* vf vlan insert configuration */
12571 /* Common result structure for vf vlan insert */
12572 struct cmd_vf_vlan_insert_result {
12573 cmdline_fixed_string_t set;
12574 cmdline_fixed_string_t vf;
12575 cmdline_fixed_string_t vlan;
12576 cmdline_fixed_string_t insert;
12582 /* Common CLI fields for vf vlan insert enable disable */
12583 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12584 TOKEN_STRING_INITIALIZER
12585 (struct cmd_vf_vlan_insert_result,
12587 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12588 TOKEN_STRING_INITIALIZER
12589 (struct cmd_vf_vlan_insert_result,
12591 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12592 TOKEN_STRING_INITIALIZER
12593 (struct cmd_vf_vlan_insert_result,
12595 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12596 TOKEN_STRING_INITIALIZER
12597 (struct cmd_vf_vlan_insert_result,
12599 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12600 TOKEN_NUM_INITIALIZER
12601 (struct cmd_vf_vlan_insert_result,
12603 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12604 TOKEN_NUM_INITIALIZER
12605 (struct cmd_vf_vlan_insert_result,
12607 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12608 TOKEN_NUM_INITIALIZER
12609 (struct cmd_vf_vlan_insert_result,
12613 cmd_set_vf_vlan_insert_parsed(
12614 void *parsed_result,
12615 __attribute__((unused)) struct cmdline *cl,
12616 __attribute__((unused)) void *data)
12618 struct cmd_vf_vlan_insert_result *res = parsed_result;
12619 int ret = -ENOTSUP;
12621 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12624 #ifdef RTE_LIBRTE_IXGBE_PMD
12625 if (ret == -ENOTSUP)
12626 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12629 #ifdef RTE_LIBRTE_I40E_PMD
12630 if (ret == -ENOTSUP)
12631 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12634 #ifdef RTE_LIBRTE_BNXT_PMD
12635 if (ret == -ENOTSUP)
12636 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12644 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12647 printf("invalid port_id %d\n", res->port_id);
12650 printf("function not implemented\n");
12653 printf("programming error: (%s)\n", strerror(-ret));
12657 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12658 .f = cmd_set_vf_vlan_insert_parsed,
12660 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12662 (void *)&cmd_vf_vlan_insert_set,
12663 (void *)&cmd_vf_vlan_insert_vf,
12664 (void *)&cmd_vf_vlan_insert_vlan,
12665 (void *)&cmd_vf_vlan_insert_insert,
12666 (void *)&cmd_vf_vlan_insert_port_id,
12667 (void *)&cmd_vf_vlan_insert_vf_id,
12668 (void *)&cmd_vf_vlan_insert_vlan_id,
12673 /* tx loopback configuration */
12675 /* Common result structure for tx loopback */
12676 struct cmd_tx_loopback_result {
12677 cmdline_fixed_string_t set;
12678 cmdline_fixed_string_t tx;
12679 cmdline_fixed_string_t loopback;
12681 cmdline_fixed_string_t on_off;
12684 /* Common CLI fields for tx loopback enable disable */
12685 cmdline_parse_token_string_t cmd_tx_loopback_set =
12686 TOKEN_STRING_INITIALIZER
12687 (struct cmd_tx_loopback_result,
12689 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12690 TOKEN_STRING_INITIALIZER
12691 (struct cmd_tx_loopback_result,
12693 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12694 TOKEN_STRING_INITIALIZER
12695 (struct cmd_tx_loopback_result,
12696 loopback, "loopback");
12697 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12698 TOKEN_NUM_INITIALIZER
12699 (struct cmd_tx_loopback_result,
12701 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12702 TOKEN_STRING_INITIALIZER
12703 (struct cmd_tx_loopback_result,
12707 cmd_set_tx_loopback_parsed(
12708 void *parsed_result,
12709 __attribute__((unused)) struct cmdline *cl,
12710 __attribute__((unused)) void *data)
12712 struct cmd_tx_loopback_result *res = parsed_result;
12713 int ret = -ENOTSUP;
12715 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12717 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12720 #ifdef RTE_LIBRTE_IXGBE_PMD
12721 if (ret == -ENOTSUP)
12722 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12724 #ifdef RTE_LIBRTE_I40E_PMD
12725 if (ret == -ENOTSUP)
12726 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12728 #ifdef RTE_LIBRTE_BNXT_PMD
12729 if (ret == -ENOTSUP)
12730 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12737 printf("invalid is_on %d\n", is_on);
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_tx_loopback = {
12751 .f = cmd_set_tx_loopback_parsed,
12753 .help_str = "set tx loopback <port_id> on|off",
12755 (void *)&cmd_tx_loopback_set,
12756 (void *)&cmd_tx_loopback_tx,
12757 (void *)&cmd_tx_loopback_loopback,
12758 (void *)&cmd_tx_loopback_port_id,
12759 (void *)&cmd_tx_loopback_on_off,
12764 /* all queues drop enable configuration */
12766 /* Common result structure for all queues drop enable */
12767 struct cmd_all_queues_drop_en_result {
12768 cmdline_fixed_string_t set;
12769 cmdline_fixed_string_t all;
12770 cmdline_fixed_string_t queues;
12771 cmdline_fixed_string_t drop;
12773 cmdline_fixed_string_t on_off;
12776 /* Common CLI fields for tx loopback enable disable */
12777 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12778 TOKEN_STRING_INITIALIZER
12779 (struct cmd_all_queues_drop_en_result,
12781 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12782 TOKEN_STRING_INITIALIZER
12783 (struct cmd_all_queues_drop_en_result,
12785 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12786 TOKEN_STRING_INITIALIZER
12787 (struct cmd_all_queues_drop_en_result,
12789 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12790 TOKEN_STRING_INITIALIZER
12791 (struct cmd_all_queues_drop_en_result,
12793 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12794 TOKEN_NUM_INITIALIZER
12795 (struct cmd_all_queues_drop_en_result,
12797 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12798 TOKEN_STRING_INITIALIZER
12799 (struct cmd_all_queues_drop_en_result,
12803 cmd_set_all_queues_drop_en_parsed(
12804 void *parsed_result,
12805 __attribute__((unused)) struct cmdline *cl,
12806 __attribute__((unused)) void *data)
12808 struct cmd_all_queues_drop_en_result *res = parsed_result;
12809 int ret = -ENOTSUP;
12810 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12812 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12815 #ifdef RTE_LIBRTE_IXGBE_PMD
12816 if (ret == -ENOTSUP)
12817 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12819 #ifdef RTE_LIBRTE_BNXT_PMD
12820 if (ret == -ENOTSUP)
12821 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12827 printf("invalid is_on %d\n", is_on);
12830 printf("invalid port_id %d\n", res->port_id);
12833 printf("function not implemented\n");
12836 printf("programming error: (%s)\n", strerror(-ret));
12840 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12841 .f = cmd_set_all_queues_drop_en_parsed,
12843 .help_str = "set all queues drop <port_id> on|off",
12845 (void *)&cmd_all_queues_drop_en_set,
12846 (void *)&cmd_all_queues_drop_en_all,
12847 (void *)&cmd_all_queues_drop_en_queues,
12848 (void *)&cmd_all_queues_drop_en_drop,
12849 (void *)&cmd_all_queues_drop_en_port_id,
12850 (void *)&cmd_all_queues_drop_en_on_off,
12855 /* vf split drop enable configuration */
12857 /* Common result structure for vf split drop enable */
12858 struct cmd_vf_split_drop_en_result {
12859 cmdline_fixed_string_t set;
12860 cmdline_fixed_string_t vf;
12861 cmdline_fixed_string_t split;
12862 cmdline_fixed_string_t drop;
12865 cmdline_fixed_string_t on_off;
12868 /* Common CLI fields for vf split drop enable disable */
12869 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12870 TOKEN_STRING_INITIALIZER
12871 (struct cmd_vf_split_drop_en_result,
12873 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12874 TOKEN_STRING_INITIALIZER
12875 (struct cmd_vf_split_drop_en_result,
12877 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12878 TOKEN_STRING_INITIALIZER
12879 (struct cmd_vf_split_drop_en_result,
12881 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12882 TOKEN_STRING_INITIALIZER
12883 (struct cmd_vf_split_drop_en_result,
12885 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12886 TOKEN_NUM_INITIALIZER
12887 (struct cmd_vf_split_drop_en_result,
12889 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12890 TOKEN_NUM_INITIALIZER
12891 (struct cmd_vf_split_drop_en_result,
12893 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12894 TOKEN_STRING_INITIALIZER
12895 (struct cmd_vf_split_drop_en_result,
12899 cmd_set_vf_split_drop_en_parsed(
12900 void *parsed_result,
12901 __attribute__((unused)) struct cmdline *cl,
12902 __attribute__((unused)) void *data)
12904 struct cmd_vf_split_drop_en_result *res = parsed_result;
12905 int ret = -ENOTSUP;
12906 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12908 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12911 #ifdef RTE_LIBRTE_IXGBE_PMD
12912 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12919 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12922 printf("invalid port_id %d\n", res->port_id);
12925 printf("not supported on port %d\n", res->port_id);
12928 printf("programming error: (%s)\n", strerror(-ret));
12932 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12933 .f = cmd_set_vf_split_drop_en_parsed,
12935 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12937 (void *)&cmd_vf_split_drop_en_set,
12938 (void *)&cmd_vf_split_drop_en_vf,
12939 (void *)&cmd_vf_split_drop_en_split,
12940 (void *)&cmd_vf_split_drop_en_drop,
12941 (void *)&cmd_vf_split_drop_en_port_id,
12942 (void *)&cmd_vf_split_drop_en_vf_id,
12943 (void *)&cmd_vf_split_drop_en_on_off,
12948 /* vf mac address configuration */
12950 /* Common result structure for vf mac address */
12951 struct cmd_set_vf_mac_addr_result {
12952 cmdline_fixed_string_t set;
12953 cmdline_fixed_string_t vf;
12954 cmdline_fixed_string_t mac;
12955 cmdline_fixed_string_t addr;
12958 struct ether_addr mac_addr;
12962 /* Common CLI fields for vf split drop enable disable */
12963 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12964 TOKEN_STRING_INITIALIZER
12965 (struct cmd_set_vf_mac_addr_result,
12967 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12968 TOKEN_STRING_INITIALIZER
12969 (struct cmd_set_vf_mac_addr_result,
12971 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12972 TOKEN_STRING_INITIALIZER
12973 (struct cmd_set_vf_mac_addr_result,
12975 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12976 TOKEN_STRING_INITIALIZER
12977 (struct cmd_set_vf_mac_addr_result,
12979 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12980 TOKEN_NUM_INITIALIZER
12981 (struct cmd_set_vf_mac_addr_result,
12983 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12984 TOKEN_NUM_INITIALIZER
12985 (struct cmd_set_vf_mac_addr_result,
12987 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12988 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12992 cmd_set_vf_mac_addr_parsed(
12993 void *parsed_result,
12994 __attribute__((unused)) struct cmdline *cl,
12995 __attribute__((unused)) void *data)
12997 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12998 int ret = -ENOTSUP;
13000 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13003 #ifdef RTE_LIBRTE_IXGBE_PMD
13004 if (ret == -ENOTSUP)
13005 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13008 #ifdef RTE_LIBRTE_I40E_PMD
13009 if (ret == -ENOTSUP)
13010 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13013 #ifdef RTE_LIBRTE_BNXT_PMD
13014 if (ret == -ENOTSUP)
13015 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13023 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13026 printf("invalid port_id %d\n", res->port_id);
13029 printf("function not implemented\n");
13032 printf("programming error: (%s)\n", strerror(-ret));
13036 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13037 .f = cmd_set_vf_mac_addr_parsed,
13039 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13041 (void *)&cmd_set_vf_mac_addr_set,
13042 (void *)&cmd_set_vf_mac_addr_vf,
13043 (void *)&cmd_set_vf_mac_addr_mac,
13044 (void *)&cmd_set_vf_mac_addr_addr,
13045 (void *)&cmd_set_vf_mac_addr_port_id,
13046 (void *)&cmd_set_vf_mac_addr_vf_id,
13047 (void *)&cmd_set_vf_mac_addr_mac_addr,
13052 /* MACsec configuration */
13054 /* Common result structure for MACsec offload enable */
13055 struct cmd_macsec_offload_on_result {
13056 cmdline_fixed_string_t set;
13057 cmdline_fixed_string_t macsec;
13058 cmdline_fixed_string_t offload;
13060 cmdline_fixed_string_t on;
13061 cmdline_fixed_string_t encrypt;
13062 cmdline_fixed_string_t en_on_off;
13063 cmdline_fixed_string_t replay_protect;
13064 cmdline_fixed_string_t rp_on_off;
13067 /* Common CLI fields for MACsec offload disable */
13068 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13069 TOKEN_STRING_INITIALIZER
13070 (struct cmd_macsec_offload_on_result,
13072 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13073 TOKEN_STRING_INITIALIZER
13074 (struct cmd_macsec_offload_on_result,
13076 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13077 TOKEN_STRING_INITIALIZER
13078 (struct cmd_macsec_offload_on_result,
13079 offload, "offload");
13080 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13081 TOKEN_NUM_INITIALIZER
13082 (struct cmd_macsec_offload_on_result,
13084 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13085 TOKEN_STRING_INITIALIZER
13086 (struct cmd_macsec_offload_on_result,
13088 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13089 TOKEN_STRING_INITIALIZER
13090 (struct cmd_macsec_offload_on_result,
13091 encrypt, "encrypt");
13092 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13093 TOKEN_STRING_INITIALIZER
13094 (struct cmd_macsec_offload_on_result,
13095 en_on_off, "on#off");
13096 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13097 TOKEN_STRING_INITIALIZER
13098 (struct cmd_macsec_offload_on_result,
13099 replay_protect, "replay-protect");
13100 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13101 TOKEN_STRING_INITIALIZER
13102 (struct cmd_macsec_offload_on_result,
13103 rp_on_off, "on#off");
13106 cmd_set_macsec_offload_on_parsed(
13107 void *parsed_result,
13108 __attribute__((unused)) struct cmdline *cl,
13109 __attribute__((unused)) void *data)
13111 struct cmd_macsec_offload_on_result *res = parsed_result;
13112 int ret = -ENOTSUP;
13113 portid_t port_id = res->port_id;
13114 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13115 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13116 struct rte_eth_dev_info dev_info;
13118 if (port_id_is_invalid(port_id, ENABLED_WARN))
13120 if (!port_is_stopped(port_id)) {
13121 printf("Please stop port %d first\n", port_id);
13125 rte_eth_dev_info_get(port_id, &dev_info);
13126 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13127 #ifdef RTE_LIBRTE_IXGBE_PMD
13128 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13136 ports[port_id].dev_conf.txmode.offloads |=
13137 DEV_TX_OFFLOAD_MACSEC_INSERT;
13138 cmd_reconfig_device_queue(port_id, 1, 1);
13141 printf("invalid port_id %d\n", port_id);
13144 printf("not supported on port %d\n", port_id);
13147 printf("programming error: (%s)\n", strerror(-ret));
13151 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13152 .f = cmd_set_macsec_offload_on_parsed,
13154 .help_str = "set macsec offload <port_id> on "
13155 "encrypt on|off replay-protect on|off",
13157 (void *)&cmd_macsec_offload_on_set,
13158 (void *)&cmd_macsec_offload_on_macsec,
13159 (void *)&cmd_macsec_offload_on_offload,
13160 (void *)&cmd_macsec_offload_on_port_id,
13161 (void *)&cmd_macsec_offload_on_on,
13162 (void *)&cmd_macsec_offload_on_encrypt,
13163 (void *)&cmd_macsec_offload_on_en_on_off,
13164 (void *)&cmd_macsec_offload_on_replay_protect,
13165 (void *)&cmd_macsec_offload_on_rp_on_off,
13170 /* Common result structure for MACsec offload disable */
13171 struct cmd_macsec_offload_off_result {
13172 cmdline_fixed_string_t set;
13173 cmdline_fixed_string_t macsec;
13174 cmdline_fixed_string_t offload;
13176 cmdline_fixed_string_t off;
13179 /* Common CLI fields for MACsec offload disable */
13180 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13181 TOKEN_STRING_INITIALIZER
13182 (struct cmd_macsec_offload_off_result,
13184 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13185 TOKEN_STRING_INITIALIZER
13186 (struct cmd_macsec_offload_off_result,
13188 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13189 TOKEN_STRING_INITIALIZER
13190 (struct cmd_macsec_offload_off_result,
13191 offload, "offload");
13192 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13193 TOKEN_NUM_INITIALIZER
13194 (struct cmd_macsec_offload_off_result,
13196 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13197 TOKEN_STRING_INITIALIZER
13198 (struct cmd_macsec_offload_off_result,
13202 cmd_set_macsec_offload_off_parsed(
13203 void *parsed_result,
13204 __attribute__((unused)) struct cmdline *cl,
13205 __attribute__((unused)) void *data)
13207 struct cmd_macsec_offload_off_result *res = parsed_result;
13208 int ret = -ENOTSUP;
13209 struct rte_eth_dev_info dev_info;
13210 portid_t port_id = res->port_id;
13212 if (port_id_is_invalid(port_id, ENABLED_WARN))
13214 if (!port_is_stopped(port_id)) {
13215 printf("Please stop port %d first\n", port_id);
13219 rte_eth_dev_info_get(port_id, &dev_info);
13220 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13221 #ifdef RTE_LIBRTE_IXGBE_PMD
13222 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13227 ports[port_id].dev_conf.txmode.offloads &=
13228 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13229 cmd_reconfig_device_queue(port_id, 1, 1);
13232 printf("invalid port_id %d\n", port_id);
13235 printf("not supported on port %d\n", port_id);
13238 printf("programming error: (%s)\n", strerror(-ret));
13242 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13243 .f = cmd_set_macsec_offload_off_parsed,
13245 .help_str = "set macsec offload <port_id> off",
13247 (void *)&cmd_macsec_offload_off_set,
13248 (void *)&cmd_macsec_offload_off_macsec,
13249 (void *)&cmd_macsec_offload_off_offload,
13250 (void *)&cmd_macsec_offload_off_port_id,
13251 (void *)&cmd_macsec_offload_off_off,
13256 /* Common result structure for MACsec secure connection configure */
13257 struct cmd_macsec_sc_result {
13258 cmdline_fixed_string_t set;
13259 cmdline_fixed_string_t macsec;
13260 cmdline_fixed_string_t sc;
13261 cmdline_fixed_string_t tx_rx;
13263 struct ether_addr mac;
13267 /* Common CLI fields for MACsec secure connection configure */
13268 cmdline_parse_token_string_t cmd_macsec_sc_set =
13269 TOKEN_STRING_INITIALIZER
13270 (struct cmd_macsec_sc_result,
13272 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13273 TOKEN_STRING_INITIALIZER
13274 (struct cmd_macsec_sc_result,
13276 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13277 TOKEN_STRING_INITIALIZER
13278 (struct cmd_macsec_sc_result,
13280 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13281 TOKEN_STRING_INITIALIZER
13282 (struct cmd_macsec_sc_result,
13284 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13285 TOKEN_NUM_INITIALIZER
13286 (struct cmd_macsec_sc_result,
13288 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13289 TOKEN_ETHERADDR_INITIALIZER
13290 (struct cmd_macsec_sc_result,
13292 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13293 TOKEN_NUM_INITIALIZER
13294 (struct cmd_macsec_sc_result,
13298 cmd_set_macsec_sc_parsed(
13299 void *parsed_result,
13300 __attribute__((unused)) struct cmdline *cl,
13301 __attribute__((unused)) void *data)
13303 struct cmd_macsec_sc_result *res = parsed_result;
13304 int ret = -ENOTSUP;
13305 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13307 #ifdef RTE_LIBRTE_IXGBE_PMD
13309 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13310 res->mac.addr_bytes) :
13311 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13312 res->mac.addr_bytes, res->pi);
13314 RTE_SET_USED(is_tx);
13320 printf("invalid port_id %d\n", res->port_id);
13323 printf("not supported on port %d\n", res->port_id);
13326 printf("programming error: (%s)\n", strerror(-ret));
13330 cmdline_parse_inst_t cmd_set_macsec_sc = {
13331 .f = cmd_set_macsec_sc_parsed,
13333 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13335 (void *)&cmd_macsec_sc_set,
13336 (void *)&cmd_macsec_sc_macsec,
13337 (void *)&cmd_macsec_sc_sc,
13338 (void *)&cmd_macsec_sc_tx_rx,
13339 (void *)&cmd_macsec_sc_port_id,
13340 (void *)&cmd_macsec_sc_mac,
13341 (void *)&cmd_macsec_sc_pi,
13346 /* Common result structure for MACsec secure connection configure */
13347 struct cmd_macsec_sa_result {
13348 cmdline_fixed_string_t set;
13349 cmdline_fixed_string_t macsec;
13350 cmdline_fixed_string_t sa;
13351 cmdline_fixed_string_t tx_rx;
13356 cmdline_fixed_string_t key;
13359 /* Common CLI fields for MACsec secure connection configure */
13360 cmdline_parse_token_string_t cmd_macsec_sa_set =
13361 TOKEN_STRING_INITIALIZER
13362 (struct cmd_macsec_sa_result,
13364 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13365 TOKEN_STRING_INITIALIZER
13366 (struct cmd_macsec_sa_result,
13368 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13369 TOKEN_STRING_INITIALIZER
13370 (struct cmd_macsec_sa_result,
13372 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13373 TOKEN_STRING_INITIALIZER
13374 (struct cmd_macsec_sa_result,
13376 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13377 TOKEN_NUM_INITIALIZER
13378 (struct cmd_macsec_sa_result,
13380 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13381 TOKEN_NUM_INITIALIZER
13382 (struct cmd_macsec_sa_result,
13384 cmdline_parse_token_num_t cmd_macsec_sa_an =
13385 TOKEN_NUM_INITIALIZER
13386 (struct cmd_macsec_sa_result,
13388 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13389 TOKEN_NUM_INITIALIZER
13390 (struct cmd_macsec_sa_result,
13392 cmdline_parse_token_string_t cmd_macsec_sa_key =
13393 TOKEN_STRING_INITIALIZER
13394 (struct cmd_macsec_sa_result,
13398 cmd_set_macsec_sa_parsed(
13399 void *parsed_result,
13400 __attribute__((unused)) struct cmdline *cl,
13401 __attribute__((unused)) void *data)
13403 struct cmd_macsec_sa_result *res = parsed_result;
13404 int ret = -ENOTSUP;
13405 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13406 uint8_t key[16] = { 0 };
13412 key_len = strlen(res->key) / 2;
13416 for (i = 0; i < key_len; i++) {
13417 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13420 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13423 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13426 #ifdef RTE_LIBRTE_IXGBE_PMD
13428 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13429 res->idx, res->an, res->pn, key) :
13430 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13431 res->idx, res->an, res->pn, key);
13433 RTE_SET_USED(is_tx);
13440 printf("invalid idx %d or an %d\n", res->idx, res->an);
13443 printf("invalid port_id %d\n", res->port_id);
13446 printf("not supported on port %d\n", res->port_id);
13449 printf("programming error: (%s)\n", strerror(-ret));
13453 cmdline_parse_inst_t cmd_set_macsec_sa = {
13454 .f = cmd_set_macsec_sa_parsed,
13456 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13458 (void *)&cmd_macsec_sa_set,
13459 (void *)&cmd_macsec_sa_macsec,
13460 (void *)&cmd_macsec_sa_sa,
13461 (void *)&cmd_macsec_sa_tx_rx,
13462 (void *)&cmd_macsec_sa_port_id,
13463 (void *)&cmd_macsec_sa_idx,
13464 (void *)&cmd_macsec_sa_an,
13465 (void *)&cmd_macsec_sa_pn,
13466 (void *)&cmd_macsec_sa_key,
13471 /* VF unicast promiscuous mode configuration */
13473 /* Common result structure for VF unicast promiscuous mode */
13474 struct cmd_vf_promisc_result {
13475 cmdline_fixed_string_t set;
13476 cmdline_fixed_string_t vf;
13477 cmdline_fixed_string_t promisc;
13480 cmdline_fixed_string_t on_off;
13483 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13484 cmdline_parse_token_string_t cmd_vf_promisc_set =
13485 TOKEN_STRING_INITIALIZER
13486 (struct cmd_vf_promisc_result,
13488 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13489 TOKEN_STRING_INITIALIZER
13490 (struct cmd_vf_promisc_result,
13492 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13493 TOKEN_STRING_INITIALIZER
13494 (struct cmd_vf_promisc_result,
13495 promisc, "promisc");
13496 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13497 TOKEN_NUM_INITIALIZER
13498 (struct cmd_vf_promisc_result,
13500 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13501 TOKEN_NUM_INITIALIZER
13502 (struct cmd_vf_promisc_result,
13504 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13505 TOKEN_STRING_INITIALIZER
13506 (struct cmd_vf_promisc_result,
13510 cmd_set_vf_promisc_parsed(
13511 void *parsed_result,
13512 __attribute__((unused)) struct cmdline *cl,
13513 __attribute__((unused)) void *data)
13515 struct cmd_vf_promisc_result *res = parsed_result;
13516 int ret = -ENOTSUP;
13518 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13520 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13523 #ifdef RTE_LIBRTE_I40E_PMD
13524 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13525 res->vf_id, is_on);
13532 printf("invalid vf_id %d\n", res->vf_id);
13535 printf("invalid port_id %d\n", res->port_id);
13538 printf("function not implemented\n");
13541 printf("programming error: (%s)\n", strerror(-ret));
13545 cmdline_parse_inst_t cmd_set_vf_promisc = {
13546 .f = cmd_set_vf_promisc_parsed,
13548 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13549 "Set unicast promiscuous mode for a VF from the PF",
13551 (void *)&cmd_vf_promisc_set,
13552 (void *)&cmd_vf_promisc_vf,
13553 (void *)&cmd_vf_promisc_promisc,
13554 (void *)&cmd_vf_promisc_port_id,
13555 (void *)&cmd_vf_promisc_vf_id,
13556 (void *)&cmd_vf_promisc_on_off,
13561 /* VF multicast promiscuous mode configuration */
13563 /* Common result structure for VF multicast promiscuous mode */
13564 struct cmd_vf_allmulti_result {
13565 cmdline_fixed_string_t set;
13566 cmdline_fixed_string_t vf;
13567 cmdline_fixed_string_t allmulti;
13570 cmdline_fixed_string_t on_off;
13573 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13574 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13575 TOKEN_STRING_INITIALIZER
13576 (struct cmd_vf_allmulti_result,
13578 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13579 TOKEN_STRING_INITIALIZER
13580 (struct cmd_vf_allmulti_result,
13582 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13583 TOKEN_STRING_INITIALIZER
13584 (struct cmd_vf_allmulti_result,
13585 allmulti, "allmulti");
13586 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13587 TOKEN_NUM_INITIALIZER
13588 (struct cmd_vf_allmulti_result,
13590 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13591 TOKEN_NUM_INITIALIZER
13592 (struct cmd_vf_allmulti_result,
13594 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13595 TOKEN_STRING_INITIALIZER
13596 (struct cmd_vf_allmulti_result,
13600 cmd_set_vf_allmulti_parsed(
13601 void *parsed_result,
13602 __attribute__((unused)) struct cmdline *cl,
13603 __attribute__((unused)) void *data)
13605 struct cmd_vf_allmulti_result *res = parsed_result;
13606 int ret = -ENOTSUP;
13608 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13610 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13613 #ifdef RTE_LIBRTE_I40E_PMD
13614 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13615 res->vf_id, is_on);
13622 printf("invalid vf_id %d\n", res->vf_id);
13625 printf("invalid port_id %d\n", res->port_id);
13628 printf("function not implemented\n");
13631 printf("programming error: (%s)\n", strerror(-ret));
13635 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13636 .f = cmd_set_vf_allmulti_parsed,
13638 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13639 "Set multicast promiscuous mode for a VF from the PF",
13641 (void *)&cmd_vf_allmulti_set,
13642 (void *)&cmd_vf_allmulti_vf,
13643 (void *)&cmd_vf_allmulti_allmulti,
13644 (void *)&cmd_vf_allmulti_port_id,
13645 (void *)&cmd_vf_allmulti_vf_id,
13646 (void *)&cmd_vf_allmulti_on_off,
13651 /* vf broadcast mode configuration */
13653 /* Common result structure for vf broadcast */
13654 struct cmd_set_vf_broadcast_result {
13655 cmdline_fixed_string_t set;
13656 cmdline_fixed_string_t vf;
13657 cmdline_fixed_string_t broadcast;
13660 cmdline_fixed_string_t on_off;
13663 /* Common CLI fields for vf broadcast enable disable */
13664 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13665 TOKEN_STRING_INITIALIZER
13666 (struct cmd_set_vf_broadcast_result,
13668 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13669 TOKEN_STRING_INITIALIZER
13670 (struct cmd_set_vf_broadcast_result,
13672 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13673 TOKEN_STRING_INITIALIZER
13674 (struct cmd_set_vf_broadcast_result,
13675 broadcast, "broadcast");
13676 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13677 TOKEN_NUM_INITIALIZER
13678 (struct cmd_set_vf_broadcast_result,
13680 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13681 TOKEN_NUM_INITIALIZER
13682 (struct cmd_set_vf_broadcast_result,
13684 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13685 TOKEN_STRING_INITIALIZER
13686 (struct cmd_set_vf_broadcast_result,
13690 cmd_set_vf_broadcast_parsed(
13691 void *parsed_result,
13692 __attribute__((unused)) struct cmdline *cl,
13693 __attribute__((unused)) void *data)
13695 struct cmd_set_vf_broadcast_result *res = parsed_result;
13696 int ret = -ENOTSUP;
13698 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13700 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13703 #ifdef RTE_LIBRTE_I40E_PMD
13704 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13705 res->vf_id, is_on);
13712 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13715 printf("invalid port_id %d\n", res->port_id);
13718 printf("function not implemented\n");
13721 printf("programming error: (%s)\n", strerror(-ret));
13725 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13726 .f = cmd_set_vf_broadcast_parsed,
13728 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13730 (void *)&cmd_set_vf_broadcast_set,
13731 (void *)&cmd_set_vf_broadcast_vf,
13732 (void *)&cmd_set_vf_broadcast_broadcast,
13733 (void *)&cmd_set_vf_broadcast_port_id,
13734 (void *)&cmd_set_vf_broadcast_vf_id,
13735 (void *)&cmd_set_vf_broadcast_on_off,
13740 /* vf vlan tag configuration */
13742 /* Common result structure for vf vlan tag */
13743 struct cmd_set_vf_vlan_tag_result {
13744 cmdline_fixed_string_t set;
13745 cmdline_fixed_string_t vf;
13746 cmdline_fixed_string_t vlan;
13747 cmdline_fixed_string_t tag;
13750 cmdline_fixed_string_t on_off;
13753 /* Common CLI fields for vf vlan tag enable disable */
13754 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13755 TOKEN_STRING_INITIALIZER
13756 (struct cmd_set_vf_vlan_tag_result,
13758 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13759 TOKEN_STRING_INITIALIZER
13760 (struct cmd_set_vf_vlan_tag_result,
13762 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13763 TOKEN_STRING_INITIALIZER
13764 (struct cmd_set_vf_vlan_tag_result,
13766 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13767 TOKEN_STRING_INITIALIZER
13768 (struct cmd_set_vf_vlan_tag_result,
13770 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13771 TOKEN_NUM_INITIALIZER
13772 (struct cmd_set_vf_vlan_tag_result,
13774 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13775 TOKEN_NUM_INITIALIZER
13776 (struct cmd_set_vf_vlan_tag_result,
13778 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13779 TOKEN_STRING_INITIALIZER
13780 (struct cmd_set_vf_vlan_tag_result,
13784 cmd_set_vf_vlan_tag_parsed(
13785 void *parsed_result,
13786 __attribute__((unused)) struct cmdline *cl,
13787 __attribute__((unused)) void *data)
13789 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13790 int ret = -ENOTSUP;
13792 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13794 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13797 #ifdef RTE_LIBRTE_I40E_PMD
13798 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13799 res->vf_id, is_on);
13806 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13809 printf("invalid port_id %d\n", res->port_id);
13812 printf("function not implemented\n");
13815 printf("programming error: (%s)\n", strerror(-ret));
13819 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13820 .f = cmd_set_vf_vlan_tag_parsed,
13822 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13824 (void *)&cmd_set_vf_vlan_tag_set,
13825 (void *)&cmd_set_vf_vlan_tag_vf,
13826 (void *)&cmd_set_vf_vlan_tag_vlan,
13827 (void *)&cmd_set_vf_vlan_tag_tag,
13828 (void *)&cmd_set_vf_vlan_tag_port_id,
13829 (void *)&cmd_set_vf_vlan_tag_vf_id,
13830 (void *)&cmd_set_vf_vlan_tag_on_off,
13835 /* Common definition of VF and TC TX bandwidth configuration */
13836 struct cmd_vf_tc_bw_result {
13837 cmdline_fixed_string_t set;
13838 cmdline_fixed_string_t vf;
13839 cmdline_fixed_string_t tc;
13840 cmdline_fixed_string_t tx;
13841 cmdline_fixed_string_t min_bw;
13842 cmdline_fixed_string_t max_bw;
13843 cmdline_fixed_string_t strict_link_prio;
13848 cmdline_fixed_string_t bw_list;
13852 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13853 TOKEN_STRING_INITIALIZER
13854 (struct cmd_vf_tc_bw_result,
13856 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13857 TOKEN_STRING_INITIALIZER
13858 (struct cmd_vf_tc_bw_result,
13860 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13861 TOKEN_STRING_INITIALIZER
13862 (struct cmd_vf_tc_bw_result,
13864 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13865 TOKEN_STRING_INITIALIZER
13866 (struct cmd_vf_tc_bw_result,
13868 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13869 TOKEN_STRING_INITIALIZER
13870 (struct cmd_vf_tc_bw_result,
13871 strict_link_prio, "strict-link-priority");
13872 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13873 TOKEN_STRING_INITIALIZER
13874 (struct cmd_vf_tc_bw_result,
13875 min_bw, "min-bandwidth");
13876 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13877 TOKEN_STRING_INITIALIZER
13878 (struct cmd_vf_tc_bw_result,
13879 max_bw, "max-bandwidth");
13880 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13881 TOKEN_NUM_INITIALIZER
13882 (struct cmd_vf_tc_bw_result,
13884 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13885 TOKEN_NUM_INITIALIZER
13886 (struct cmd_vf_tc_bw_result,
13888 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13889 TOKEN_NUM_INITIALIZER
13890 (struct cmd_vf_tc_bw_result,
13892 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13893 TOKEN_NUM_INITIALIZER
13894 (struct cmd_vf_tc_bw_result,
13896 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13897 TOKEN_STRING_INITIALIZER
13898 (struct cmd_vf_tc_bw_result,
13900 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13901 TOKEN_NUM_INITIALIZER
13902 (struct cmd_vf_tc_bw_result,
13905 /* VF max bandwidth setting */
13907 cmd_vf_max_bw_parsed(
13908 void *parsed_result,
13909 __attribute__((unused)) struct cmdline *cl,
13910 __attribute__((unused)) void *data)
13912 struct cmd_vf_tc_bw_result *res = parsed_result;
13913 int ret = -ENOTSUP;
13915 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13918 #ifdef RTE_LIBRTE_I40E_PMD
13919 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13920 res->vf_id, res->bw);
13927 printf("invalid vf_id %d or bandwidth %d\n",
13928 res->vf_id, res->bw);
13931 printf("invalid port_id %d\n", res->port_id);
13934 printf("function not implemented\n");
13937 printf("programming error: (%s)\n", strerror(-ret));
13941 cmdline_parse_inst_t cmd_vf_max_bw = {
13942 .f = cmd_vf_max_bw_parsed,
13944 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13946 (void *)&cmd_vf_tc_bw_set,
13947 (void *)&cmd_vf_tc_bw_vf,
13948 (void *)&cmd_vf_tc_bw_tx,
13949 (void *)&cmd_vf_tc_bw_max_bw,
13950 (void *)&cmd_vf_tc_bw_port_id,
13951 (void *)&cmd_vf_tc_bw_vf_id,
13952 (void *)&cmd_vf_tc_bw_bw,
13958 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13963 const char *p, *p0 = str;
13970 p = strchr(p0, '(');
13972 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13976 p0 = strchr(p, ')');
13978 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13982 if (size >= sizeof(s)) {
13983 printf("The string size exceeds the internal buffer size\n");
13986 snprintf(s, sizeof(s), "%.*s", size, p);
13987 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13989 printf("Failed to get the bandwidth list. ");
13993 for (i = 0; i < ret; i++)
13994 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13999 /* TC min bandwidth setting */
14001 cmd_vf_tc_min_bw_parsed(
14002 void *parsed_result,
14003 __attribute__((unused)) struct cmdline *cl,
14004 __attribute__((unused)) void *data)
14006 struct cmd_vf_tc_bw_result *res = parsed_result;
14009 int ret = -ENOTSUP;
14011 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14014 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14018 #ifdef RTE_LIBRTE_I40E_PMD
14019 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14027 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14030 printf("invalid port_id %d\n", res->port_id);
14033 printf("function not implemented\n");
14036 printf("programming error: (%s)\n", strerror(-ret));
14040 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14041 .f = cmd_vf_tc_min_bw_parsed,
14043 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14044 " <bw1, bw2, ...>",
14046 (void *)&cmd_vf_tc_bw_set,
14047 (void *)&cmd_vf_tc_bw_vf,
14048 (void *)&cmd_vf_tc_bw_tc,
14049 (void *)&cmd_vf_tc_bw_tx,
14050 (void *)&cmd_vf_tc_bw_min_bw,
14051 (void *)&cmd_vf_tc_bw_port_id,
14052 (void *)&cmd_vf_tc_bw_vf_id,
14053 (void *)&cmd_vf_tc_bw_bw_list,
14059 cmd_tc_min_bw_parsed(
14060 void *parsed_result,
14061 __attribute__((unused)) struct cmdline *cl,
14062 __attribute__((unused)) void *data)
14064 struct cmd_vf_tc_bw_result *res = parsed_result;
14065 struct rte_port *port;
14068 int ret = -ENOTSUP;
14070 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14073 port = &ports[res->port_id];
14074 /** Check if the port is not started **/
14075 if (port->port_status != RTE_PORT_STOPPED) {
14076 printf("Please stop port %d first\n", res->port_id);
14080 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14084 #ifdef RTE_LIBRTE_IXGBE_PMD
14085 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14092 printf("invalid bandwidth\n");
14095 printf("invalid port_id %d\n", res->port_id);
14098 printf("function not implemented\n");
14101 printf("programming error: (%s)\n", strerror(-ret));
14105 cmdline_parse_inst_t cmd_tc_min_bw = {
14106 .f = cmd_tc_min_bw_parsed,
14108 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14110 (void *)&cmd_vf_tc_bw_set,
14111 (void *)&cmd_vf_tc_bw_tc,
14112 (void *)&cmd_vf_tc_bw_tx,
14113 (void *)&cmd_vf_tc_bw_min_bw,
14114 (void *)&cmd_vf_tc_bw_port_id,
14115 (void *)&cmd_vf_tc_bw_bw_list,
14120 /* TC max bandwidth setting */
14122 cmd_vf_tc_max_bw_parsed(
14123 void *parsed_result,
14124 __attribute__((unused)) struct cmdline *cl,
14125 __attribute__((unused)) void *data)
14127 struct cmd_vf_tc_bw_result *res = parsed_result;
14128 int ret = -ENOTSUP;
14130 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14133 #ifdef RTE_LIBRTE_I40E_PMD
14134 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14135 res->tc_no, res->bw);
14142 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14143 res->vf_id, res->tc_no, res->bw);
14146 printf("invalid port_id %d\n", res->port_id);
14149 printf("function not implemented\n");
14152 printf("programming error: (%s)\n", strerror(-ret));
14156 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14157 .f = cmd_vf_tc_max_bw_parsed,
14159 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14162 (void *)&cmd_vf_tc_bw_set,
14163 (void *)&cmd_vf_tc_bw_vf,
14164 (void *)&cmd_vf_tc_bw_tc,
14165 (void *)&cmd_vf_tc_bw_tx,
14166 (void *)&cmd_vf_tc_bw_max_bw,
14167 (void *)&cmd_vf_tc_bw_port_id,
14168 (void *)&cmd_vf_tc_bw_vf_id,
14169 (void *)&cmd_vf_tc_bw_tc_no,
14170 (void *)&cmd_vf_tc_bw_bw,
14176 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14178 /* *** Set Port default Traffic Management Hierarchy *** */
14179 struct cmd_set_port_tm_hierarchy_default_result {
14180 cmdline_fixed_string_t set;
14181 cmdline_fixed_string_t port;
14182 cmdline_fixed_string_t tm;
14183 cmdline_fixed_string_t hierarchy;
14184 cmdline_fixed_string_t def;
14188 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14189 TOKEN_STRING_INITIALIZER(
14190 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14191 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14192 TOKEN_STRING_INITIALIZER(
14193 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14194 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14195 TOKEN_STRING_INITIALIZER(
14196 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14197 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14198 TOKEN_STRING_INITIALIZER(
14199 struct cmd_set_port_tm_hierarchy_default_result,
14200 hierarchy, "hierarchy");
14201 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14202 TOKEN_STRING_INITIALIZER(
14203 struct cmd_set_port_tm_hierarchy_default_result,
14205 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14206 TOKEN_NUM_INITIALIZER(
14207 struct cmd_set_port_tm_hierarchy_default_result,
14210 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14211 __attribute__((unused)) struct cmdline *cl,
14212 __attribute__((unused)) void *data)
14214 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14215 struct rte_port *p;
14216 portid_t port_id = res->port_id;
14218 if (port_id_is_invalid(port_id, ENABLED_WARN))
14221 p = &ports[port_id];
14224 if (p->softport.tm_flag == 0) {
14225 printf(" tm not enabled on port %u (error)\n", port_id);
14229 /* Forward mode: tm */
14230 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14231 printf(" tm mode not enabled(error)\n");
14235 /* Set the default tm hierarchy */
14236 p->softport.tm.default_hierarchy_enable = 1;
14239 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14240 .f = cmd_set_port_tm_hierarchy_default_parsed,
14242 .help_str = "set port tm hierarchy default <port_id>",
14244 (void *)&cmd_set_port_tm_hierarchy_default_set,
14245 (void *)&cmd_set_port_tm_hierarchy_default_port,
14246 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14247 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14248 (void *)&cmd_set_port_tm_hierarchy_default_default,
14249 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14255 /* Strict link priority scheduling mode setting */
14257 cmd_strict_link_prio_parsed(
14258 void *parsed_result,
14259 __attribute__((unused)) struct cmdline *cl,
14260 __attribute__((unused)) void *data)
14262 struct cmd_vf_tc_bw_result *res = parsed_result;
14263 int ret = -ENOTSUP;
14265 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14268 #ifdef RTE_LIBRTE_I40E_PMD
14269 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14276 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14279 printf("invalid port_id %d\n", res->port_id);
14282 printf("function not implemented\n");
14285 printf("programming error: (%s)\n", strerror(-ret));
14289 cmdline_parse_inst_t cmd_strict_link_prio = {
14290 .f = cmd_strict_link_prio_parsed,
14292 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14294 (void *)&cmd_vf_tc_bw_set,
14295 (void *)&cmd_vf_tc_bw_tx,
14296 (void *)&cmd_vf_tc_bw_strict_link_prio,
14297 (void *)&cmd_vf_tc_bw_port_id,
14298 (void *)&cmd_vf_tc_bw_tc_map,
14303 /* Load dynamic device personalization*/
14304 struct cmd_ddp_add_result {
14305 cmdline_fixed_string_t ddp;
14306 cmdline_fixed_string_t add;
14311 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14312 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14313 cmdline_parse_token_string_t cmd_ddp_add_add =
14314 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14315 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14316 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14317 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14318 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14321 cmd_ddp_add_parsed(
14322 void *parsed_result,
14323 __attribute__((unused)) struct cmdline *cl,
14324 __attribute__((unused)) void *data)
14326 struct cmd_ddp_add_result *res = parsed_result;
14332 int ret = -ENOTSUP;
14334 if (res->port_id > nb_ports) {
14335 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14339 if (!all_ports_stopped()) {
14340 printf("Please stop all ports first\n");
14344 filepath = strdup(res->filepath);
14345 if (filepath == NULL) {
14346 printf("Failed to allocate memory\n");
14349 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14351 buff = open_ddp_package_file(file_fld[0], &size);
14353 free((void *)filepath);
14357 #ifdef RTE_LIBRTE_I40E_PMD
14358 if (ret == -ENOTSUP)
14359 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14361 RTE_PMD_I40E_PKG_OP_WR_ADD);
14364 if (ret == -EEXIST)
14365 printf("Profile has already existed.\n");
14367 printf("Failed to load profile.\n");
14368 else if (file_num == 2)
14369 save_ddp_package_file(file_fld[1], buff, size);
14371 close_ddp_package_file(buff);
14372 free((void *)filepath);
14375 cmdline_parse_inst_t cmd_ddp_add = {
14376 .f = cmd_ddp_add_parsed,
14378 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14380 (void *)&cmd_ddp_add_ddp,
14381 (void *)&cmd_ddp_add_add,
14382 (void *)&cmd_ddp_add_port_id,
14383 (void *)&cmd_ddp_add_filepath,
14388 /* Delete dynamic device personalization*/
14389 struct cmd_ddp_del_result {
14390 cmdline_fixed_string_t ddp;
14391 cmdline_fixed_string_t del;
14396 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14397 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14398 cmdline_parse_token_string_t cmd_ddp_del_del =
14399 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14400 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14401 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14402 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14403 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14406 cmd_ddp_del_parsed(
14407 void *parsed_result,
14408 __attribute__((unused)) struct cmdline *cl,
14409 __attribute__((unused)) void *data)
14411 struct cmd_ddp_del_result *res = parsed_result;
14414 int ret = -ENOTSUP;
14416 if (res->port_id > nb_ports) {
14417 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14421 if (!all_ports_stopped()) {
14422 printf("Please stop all ports first\n");
14426 buff = open_ddp_package_file(res->filepath, &size);
14430 #ifdef RTE_LIBRTE_I40E_PMD
14431 if (ret == -ENOTSUP)
14432 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14434 RTE_PMD_I40E_PKG_OP_WR_DEL);
14437 if (ret == -EACCES)
14438 printf("Profile does not exist.\n");
14440 printf("Failed to delete profile.\n");
14442 close_ddp_package_file(buff);
14445 cmdline_parse_inst_t cmd_ddp_del = {
14446 .f = cmd_ddp_del_parsed,
14448 .help_str = "ddp del <port_id> <profile_path>",
14450 (void *)&cmd_ddp_del_ddp,
14451 (void *)&cmd_ddp_del_del,
14452 (void *)&cmd_ddp_del_port_id,
14453 (void *)&cmd_ddp_del_filepath,
14458 /* Get dynamic device personalization profile info */
14459 struct cmd_ddp_info_result {
14460 cmdline_fixed_string_t ddp;
14461 cmdline_fixed_string_t get;
14462 cmdline_fixed_string_t info;
14466 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14467 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14468 cmdline_parse_token_string_t cmd_ddp_info_get =
14469 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14470 cmdline_parse_token_string_t cmd_ddp_info_info =
14471 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14472 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14473 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14476 cmd_ddp_info_parsed(
14477 void *parsed_result,
14478 __attribute__((unused)) struct cmdline *cl,
14479 __attribute__((unused)) void *data)
14481 struct cmd_ddp_info_result *res = parsed_result;
14484 int ret = -ENOTSUP;
14485 #ifdef RTE_LIBRTE_I40E_PMD
14488 uint32_t buff_size = 0;
14489 struct rte_pmd_i40e_profile_info info;
14490 uint32_t dev_num = 0;
14491 struct rte_pmd_i40e_ddp_device_id *devs;
14492 uint32_t proto_num = 0;
14493 struct rte_pmd_i40e_proto_info *proto = NULL;
14494 uint32_t pctype_num = 0;
14495 struct rte_pmd_i40e_ptype_info *pctype;
14496 uint32_t ptype_num = 0;
14497 struct rte_pmd_i40e_ptype_info *ptype;
14502 pkg = open_ddp_package_file(res->filepath, &pkg_size);
14506 #ifdef RTE_LIBRTE_I40E_PMD
14507 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14508 (uint8_t *)&info, sizeof(info),
14509 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14511 printf("Global Track id: 0x%x\n", info.track_id);
14512 printf("Global Version: %d.%d.%d.%d\n",
14513 info.version.major,
14514 info.version.minor,
14515 info.version.update,
14516 info.version.draft);
14517 printf("Global Package name: %s\n\n", info.name);
14520 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14521 (uint8_t *)&info, sizeof(info),
14522 RTE_PMD_I40E_PKG_INFO_HEADER);
14524 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14525 printf("i40e Profile Version: %d.%d.%d.%d\n",
14526 info.version.major,
14527 info.version.minor,
14528 info.version.update,
14529 info.version.draft);
14530 printf("i40e Profile name: %s\n\n", info.name);
14533 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14534 (uint8_t *)&buff_size, sizeof(buff_size),
14535 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14536 if (!ret && buff_size) {
14537 buff = (uint8_t *)malloc(buff_size);
14539 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14541 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14543 printf("Package Notes:\n%s\n\n", buff);
14548 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14549 (uint8_t *)&dev_num, sizeof(dev_num),
14550 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14551 if (!ret && dev_num) {
14552 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14553 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14555 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14556 (uint8_t *)devs, buff_size,
14557 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14559 printf("List of supported devices:\n");
14560 for (i = 0; i < dev_num; i++) {
14561 printf(" %04X:%04X %04X:%04X\n",
14562 devs[i].vendor_dev_id >> 16,
14563 devs[i].vendor_dev_id & 0xFFFF,
14564 devs[i].sub_vendor_dev_id >> 16,
14565 devs[i].sub_vendor_dev_id & 0xFFFF);
14573 /* get information about protocols and packet types */
14574 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14575 (uint8_t *)&proto_num, sizeof(proto_num),
14576 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14577 if (ret || !proto_num)
14578 goto no_print_return;
14580 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14581 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14583 goto no_print_return;
14585 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14587 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14589 printf("List of used protocols:\n");
14590 for (i = 0; i < proto_num; i++)
14591 printf(" %2u: %s\n", proto[i].proto_id,
14595 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14596 (uint8_t *)&pctype_num, sizeof(pctype_num),
14597 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14598 if (ret || !pctype_num)
14599 goto no_print_pctypes;
14601 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14602 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14604 goto no_print_pctypes;
14606 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14608 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14611 goto no_print_pctypes;
14614 printf("List of defined packet classification types:\n");
14615 for (i = 0; i < pctype_num; i++) {
14616 printf(" %2u:", pctype[i].ptype_id);
14617 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14618 proto_id = pctype[i].protocols[j];
14619 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14620 for (n = 0; n < proto_num; n++) {
14621 if (proto[n].proto_id == proto_id) {
14622 printf(" %s", proto[n].name);
14635 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14637 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14638 if (ret || !ptype_num)
14639 goto no_print_return;
14641 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14642 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14644 goto no_print_return;
14646 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14648 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14651 goto no_print_return;
14653 printf("List of defined packet types:\n");
14654 for (i = 0; i < ptype_num; i++) {
14655 printf(" %2u:", ptype[i].ptype_id);
14656 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14657 proto_id = ptype[i].protocols[j];
14658 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14659 for (n = 0; n < proto_num; n++) {
14660 if (proto[n].proto_id == proto_id) {
14661 printf(" %s", proto[n].name);
14677 if (ret == -ENOTSUP)
14678 printf("Function not supported in PMD driver\n");
14679 close_ddp_package_file(pkg);
14682 cmdline_parse_inst_t cmd_ddp_get_info = {
14683 .f = cmd_ddp_info_parsed,
14685 .help_str = "ddp get info <profile_path>",
14687 (void *)&cmd_ddp_info_ddp,
14688 (void *)&cmd_ddp_info_get,
14689 (void *)&cmd_ddp_info_info,
14690 (void *)&cmd_ddp_info_filepath,
14695 /* Get dynamic device personalization profile info list*/
14696 #define PROFILE_INFO_SIZE 48
14697 #define MAX_PROFILE_NUM 16
14699 struct cmd_ddp_get_list_result {
14700 cmdline_fixed_string_t ddp;
14701 cmdline_fixed_string_t get;
14702 cmdline_fixed_string_t list;
14706 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14707 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14708 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14709 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14710 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14711 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14712 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14713 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14716 cmd_ddp_get_list_parsed(
14717 void *parsed_result,
14718 __attribute__((unused)) struct cmdline *cl,
14719 __attribute__((unused)) void *data)
14721 struct cmd_ddp_get_list_result *res = parsed_result;
14722 #ifdef RTE_LIBRTE_I40E_PMD
14723 struct rte_pmd_i40e_profile_list *p_list;
14724 struct rte_pmd_i40e_profile_info *p_info;
14729 int ret = -ENOTSUP;
14731 if (res->port_id > nb_ports) {
14732 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14736 #ifdef RTE_LIBRTE_I40E_PMD
14737 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14738 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14740 printf("%s: Failed to malloc buffer\n", __func__);
14742 if (ret == -ENOTSUP)
14743 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14744 (uint8_t *)p_list, size);
14747 p_num = p_list->p_count;
14748 printf("Profile number is: %d\n\n", p_num);
14750 for (i = 0; i < p_num; i++) {
14751 p_info = &p_list->p_info[i];
14752 printf("Profile %d:\n", i);
14753 printf("Track id: 0x%x\n", p_info->track_id);
14754 printf("Version: %d.%d.%d.%d\n",
14755 p_info->version.major,
14756 p_info->version.minor,
14757 p_info->version.update,
14758 p_info->version.draft);
14759 printf("Profile name: %s\n\n", p_info->name);
14767 printf("Failed to get ddp list\n");
14770 cmdline_parse_inst_t cmd_ddp_get_list = {
14771 .f = cmd_ddp_get_list_parsed,
14773 .help_str = "ddp get list <port_id>",
14775 (void *)&cmd_ddp_get_list_ddp,
14776 (void *)&cmd_ddp_get_list_get,
14777 (void *)&cmd_ddp_get_list_list,
14778 (void *)&cmd_ddp_get_list_port_id,
14783 /* show vf stats */
14785 /* Common result structure for show vf stats */
14786 struct cmd_show_vf_stats_result {
14787 cmdline_fixed_string_t show;
14788 cmdline_fixed_string_t vf;
14789 cmdline_fixed_string_t stats;
14794 /* Common CLI fields show vf stats*/
14795 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14796 TOKEN_STRING_INITIALIZER
14797 (struct cmd_show_vf_stats_result,
14799 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14800 TOKEN_STRING_INITIALIZER
14801 (struct cmd_show_vf_stats_result,
14803 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14804 TOKEN_STRING_INITIALIZER
14805 (struct cmd_show_vf_stats_result,
14807 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14808 TOKEN_NUM_INITIALIZER
14809 (struct cmd_show_vf_stats_result,
14811 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14812 TOKEN_NUM_INITIALIZER
14813 (struct cmd_show_vf_stats_result,
14817 cmd_show_vf_stats_parsed(
14818 void *parsed_result,
14819 __attribute__((unused)) struct cmdline *cl,
14820 __attribute__((unused)) void *data)
14822 struct cmd_show_vf_stats_result *res = parsed_result;
14823 struct rte_eth_stats stats;
14824 int ret = -ENOTSUP;
14825 static const char *nic_stats_border = "########################";
14827 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14830 memset(&stats, 0, sizeof(stats));
14832 #ifdef RTE_LIBRTE_I40E_PMD
14833 if (ret == -ENOTSUP)
14834 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14838 #ifdef RTE_LIBRTE_BNXT_PMD
14839 if (ret == -ENOTSUP)
14840 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14849 printf("invalid vf_id %d\n", res->vf_id);
14852 printf("invalid port_id %d\n", res->port_id);
14855 printf("function not implemented\n");
14858 printf("programming error: (%s)\n", strerror(-ret));
14861 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14862 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14864 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14866 stats.ipackets, stats.imissed, stats.ibytes);
14867 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14868 printf(" RX-nombuf: %-10"PRIu64"\n",
14870 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14872 stats.opackets, stats.oerrors, stats.obytes);
14874 printf(" %s############################%s\n",
14875 nic_stats_border, nic_stats_border);
14878 cmdline_parse_inst_t cmd_show_vf_stats = {
14879 .f = cmd_show_vf_stats_parsed,
14881 .help_str = "show vf stats <port_id> <vf_id>",
14883 (void *)&cmd_show_vf_stats_show,
14884 (void *)&cmd_show_vf_stats_vf,
14885 (void *)&cmd_show_vf_stats_stats,
14886 (void *)&cmd_show_vf_stats_port_id,
14887 (void *)&cmd_show_vf_stats_vf_id,
14892 /* clear vf stats */
14894 /* Common result structure for clear vf stats */
14895 struct cmd_clear_vf_stats_result {
14896 cmdline_fixed_string_t clear;
14897 cmdline_fixed_string_t vf;
14898 cmdline_fixed_string_t stats;
14903 /* Common CLI fields clear vf stats*/
14904 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14905 TOKEN_STRING_INITIALIZER
14906 (struct cmd_clear_vf_stats_result,
14908 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14909 TOKEN_STRING_INITIALIZER
14910 (struct cmd_clear_vf_stats_result,
14912 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14913 TOKEN_STRING_INITIALIZER
14914 (struct cmd_clear_vf_stats_result,
14916 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14917 TOKEN_NUM_INITIALIZER
14918 (struct cmd_clear_vf_stats_result,
14920 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14921 TOKEN_NUM_INITIALIZER
14922 (struct cmd_clear_vf_stats_result,
14926 cmd_clear_vf_stats_parsed(
14927 void *parsed_result,
14928 __attribute__((unused)) struct cmdline *cl,
14929 __attribute__((unused)) void *data)
14931 struct cmd_clear_vf_stats_result *res = parsed_result;
14932 int ret = -ENOTSUP;
14934 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14937 #ifdef RTE_LIBRTE_I40E_PMD
14938 if (ret == -ENOTSUP)
14939 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14942 #ifdef RTE_LIBRTE_BNXT_PMD
14943 if (ret == -ENOTSUP)
14944 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14952 printf("invalid vf_id %d\n", res->vf_id);
14955 printf("invalid port_id %d\n", res->port_id);
14958 printf("function not implemented\n");
14961 printf("programming error: (%s)\n", strerror(-ret));
14965 cmdline_parse_inst_t cmd_clear_vf_stats = {
14966 .f = cmd_clear_vf_stats_parsed,
14968 .help_str = "clear vf stats <port_id> <vf_id>",
14970 (void *)&cmd_clear_vf_stats_clear,
14971 (void *)&cmd_clear_vf_stats_vf,
14972 (void *)&cmd_clear_vf_stats_stats,
14973 (void *)&cmd_clear_vf_stats_port_id,
14974 (void *)&cmd_clear_vf_stats_vf_id,
14979 /* port config pctype mapping reset */
14981 /* Common result structure for port config pctype mapping reset */
14982 struct cmd_pctype_mapping_reset_result {
14983 cmdline_fixed_string_t port;
14984 cmdline_fixed_string_t config;
14986 cmdline_fixed_string_t pctype;
14987 cmdline_fixed_string_t mapping;
14988 cmdline_fixed_string_t reset;
14991 /* Common CLI fields for port config pctype mapping reset*/
14992 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14993 TOKEN_STRING_INITIALIZER
14994 (struct cmd_pctype_mapping_reset_result,
14996 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14997 TOKEN_STRING_INITIALIZER
14998 (struct cmd_pctype_mapping_reset_result,
15000 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15001 TOKEN_NUM_INITIALIZER
15002 (struct cmd_pctype_mapping_reset_result,
15004 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15005 TOKEN_STRING_INITIALIZER
15006 (struct cmd_pctype_mapping_reset_result,
15008 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15009 TOKEN_STRING_INITIALIZER
15010 (struct cmd_pctype_mapping_reset_result,
15011 mapping, "mapping");
15012 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15013 TOKEN_STRING_INITIALIZER
15014 (struct cmd_pctype_mapping_reset_result,
15018 cmd_pctype_mapping_reset_parsed(
15019 void *parsed_result,
15020 __attribute__((unused)) struct cmdline *cl,
15021 __attribute__((unused)) void *data)
15023 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15024 int ret = -ENOTSUP;
15026 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15029 #ifdef RTE_LIBRTE_I40E_PMD
15030 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15037 printf("invalid port_id %d\n", res->port_id);
15040 printf("function not implemented\n");
15043 printf("programming error: (%s)\n", strerror(-ret));
15047 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15048 .f = cmd_pctype_mapping_reset_parsed,
15050 .help_str = "port config <port_id> pctype mapping reset",
15052 (void *)&cmd_pctype_mapping_reset_port,
15053 (void *)&cmd_pctype_mapping_reset_config,
15054 (void *)&cmd_pctype_mapping_reset_port_id,
15055 (void *)&cmd_pctype_mapping_reset_pctype,
15056 (void *)&cmd_pctype_mapping_reset_mapping,
15057 (void *)&cmd_pctype_mapping_reset_reset,
15062 /* show port pctype mapping */
15064 /* Common result structure for show port pctype mapping */
15065 struct cmd_pctype_mapping_get_result {
15066 cmdline_fixed_string_t show;
15067 cmdline_fixed_string_t port;
15069 cmdline_fixed_string_t pctype;
15070 cmdline_fixed_string_t mapping;
15073 /* Common CLI fields for pctype mapping get */
15074 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15075 TOKEN_STRING_INITIALIZER
15076 (struct cmd_pctype_mapping_get_result,
15078 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15079 TOKEN_STRING_INITIALIZER
15080 (struct cmd_pctype_mapping_get_result,
15082 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15083 TOKEN_NUM_INITIALIZER
15084 (struct cmd_pctype_mapping_get_result,
15086 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15087 TOKEN_STRING_INITIALIZER
15088 (struct cmd_pctype_mapping_get_result,
15090 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15091 TOKEN_STRING_INITIALIZER
15092 (struct cmd_pctype_mapping_get_result,
15093 mapping, "mapping");
15096 cmd_pctype_mapping_get_parsed(
15097 void *parsed_result,
15098 __attribute__((unused)) struct cmdline *cl,
15099 __attribute__((unused)) void *data)
15101 struct cmd_pctype_mapping_get_result *res = parsed_result;
15102 int ret = -ENOTSUP;
15103 #ifdef RTE_LIBRTE_I40E_PMD
15104 struct rte_pmd_i40e_flow_type_mapping
15105 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15106 int i, j, first_pctype;
15109 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15112 #ifdef RTE_LIBRTE_I40E_PMD
15113 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15120 printf("invalid port_id %d\n", res->port_id);
15123 printf("function not implemented\n");
15126 printf("programming error: (%s)\n", strerror(-ret));
15130 #ifdef RTE_LIBRTE_I40E_PMD
15131 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15132 if (mapping[i].pctype != 0ULL) {
15135 printf("pctype: ");
15136 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15137 if (mapping[i].pctype & (1ULL << j)) {
15138 printf(first_pctype ?
15139 "%02d" : ",%02d", j);
15143 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15149 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15150 .f = cmd_pctype_mapping_get_parsed,
15152 .help_str = "show port <port_id> pctype mapping",
15154 (void *)&cmd_pctype_mapping_get_show,
15155 (void *)&cmd_pctype_mapping_get_port,
15156 (void *)&cmd_pctype_mapping_get_port_id,
15157 (void *)&cmd_pctype_mapping_get_pctype,
15158 (void *)&cmd_pctype_mapping_get_mapping,
15163 /* port config pctype mapping update */
15165 /* Common result structure for port config pctype mapping update */
15166 struct cmd_pctype_mapping_update_result {
15167 cmdline_fixed_string_t port;
15168 cmdline_fixed_string_t config;
15170 cmdline_fixed_string_t pctype;
15171 cmdline_fixed_string_t mapping;
15172 cmdline_fixed_string_t update;
15173 cmdline_fixed_string_t pctype_list;
15174 uint16_t flow_type;
15177 /* Common CLI fields for pctype mapping update*/
15178 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15179 TOKEN_STRING_INITIALIZER
15180 (struct cmd_pctype_mapping_update_result,
15182 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15183 TOKEN_STRING_INITIALIZER
15184 (struct cmd_pctype_mapping_update_result,
15186 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15187 TOKEN_NUM_INITIALIZER
15188 (struct cmd_pctype_mapping_update_result,
15190 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15191 TOKEN_STRING_INITIALIZER
15192 (struct cmd_pctype_mapping_update_result,
15194 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15195 TOKEN_STRING_INITIALIZER
15196 (struct cmd_pctype_mapping_update_result,
15197 mapping, "mapping");
15198 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15199 TOKEN_STRING_INITIALIZER
15200 (struct cmd_pctype_mapping_update_result,
15202 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15203 TOKEN_STRING_INITIALIZER
15204 (struct cmd_pctype_mapping_update_result,
15205 pctype_list, NULL);
15206 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15207 TOKEN_NUM_INITIALIZER
15208 (struct cmd_pctype_mapping_update_result,
15209 flow_type, UINT16);
15212 cmd_pctype_mapping_update_parsed(
15213 void *parsed_result,
15214 __attribute__((unused)) struct cmdline *cl,
15215 __attribute__((unused)) void *data)
15217 struct cmd_pctype_mapping_update_result *res = parsed_result;
15218 int ret = -ENOTSUP;
15219 #ifdef RTE_LIBRTE_I40E_PMD
15220 struct rte_pmd_i40e_flow_type_mapping mapping;
15222 unsigned int nb_item;
15223 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15226 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15229 #ifdef RTE_LIBRTE_I40E_PMD
15230 nb_item = parse_item_list(res->pctype_list, "pctypes",
15231 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15232 mapping.flow_type = res->flow_type;
15233 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15234 mapping.pctype |= (1ULL << pctype_list[i]);
15235 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15245 printf("invalid pctype or flow type\n");
15248 printf("invalid port_id %d\n", res->port_id);
15251 printf("function not implemented\n");
15254 printf("programming error: (%s)\n", strerror(-ret));
15258 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15259 .f = cmd_pctype_mapping_update_parsed,
15261 .help_str = "port config <port_id> pctype mapping update"
15262 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15264 (void *)&cmd_pctype_mapping_update_port,
15265 (void *)&cmd_pctype_mapping_update_config,
15266 (void *)&cmd_pctype_mapping_update_port_id,
15267 (void *)&cmd_pctype_mapping_update_pctype,
15268 (void *)&cmd_pctype_mapping_update_mapping,
15269 (void *)&cmd_pctype_mapping_update_update,
15270 (void *)&cmd_pctype_mapping_update_pc_type,
15271 (void *)&cmd_pctype_mapping_update_flow_type,
15276 /* ptype mapping get */
15278 /* Common result structure for ptype mapping get */
15279 struct cmd_ptype_mapping_get_result {
15280 cmdline_fixed_string_t ptype;
15281 cmdline_fixed_string_t mapping;
15282 cmdline_fixed_string_t get;
15284 uint8_t valid_only;
15287 /* Common CLI fields for ptype mapping get */
15288 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15289 TOKEN_STRING_INITIALIZER
15290 (struct cmd_ptype_mapping_get_result,
15292 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15293 TOKEN_STRING_INITIALIZER
15294 (struct cmd_ptype_mapping_get_result,
15295 mapping, "mapping");
15296 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15297 TOKEN_STRING_INITIALIZER
15298 (struct cmd_ptype_mapping_get_result,
15300 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15301 TOKEN_NUM_INITIALIZER
15302 (struct cmd_ptype_mapping_get_result,
15304 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15305 TOKEN_NUM_INITIALIZER
15306 (struct cmd_ptype_mapping_get_result,
15307 valid_only, UINT8);
15310 cmd_ptype_mapping_get_parsed(
15311 void *parsed_result,
15312 __attribute__((unused)) struct cmdline *cl,
15313 __attribute__((unused)) void *data)
15315 struct cmd_ptype_mapping_get_result *res = parsed_result;
15316 int ret = -ENOTSUP;
15317 #ifdef RTE_LIBRTE_I40E_PMD
15318 int max_ptype_num = 256;
15319 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15324 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15327 #ifdef RTE_LIBRTE_I40E_PMD
15328 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15339 printf("invalid port_id %d\n", res->port_id);
15342 printf("function not implemented\n");
15345 printf("programming error: (%s)\n", strerror(-ret));
15348 #ifdef RTE_LIBRTE_I40E_PMD
15350 for (i = 0; i < count; i++)
15351 printf("%3d\t0x%08x\n",
15352 mapping[i].hw_ptype, mapping[i].sw_ptype);
15357 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15358 .f = cmd_ptype_mapping_get_parsed,
15360 .help_str = "ptype mapping get <port_id> <valid_only>",
15362 (void *)&cmd_ptype_mapping_get_ptype,
15363 (void *)&cmd_ptype_mapping_get_mapping,
15364 (void *)&cmd_ptype_mapping_get_get,
15365 (void *)&cmd_ptype_mapping_get_port_id,
15366 (void *)&cmd_ptype_mapping_get_valid_only,
15371 /* ptype mapping replace */
15373 /* Common result structure for ptype mapping replace */
15374 struct cmd_ptype_mapping_replace_result {
15375 cmdline_fixed_string_t ptype;
15376 cmdline_fixed_string_t mapping;
15377 cmdline_fixed_string_t replace;
15384 /* Common CLI fields for ptype mapping replace */
15385 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15386 TOKEN_STRING_INITIALIZER
15387 (struct cmd_ptype_mapping_replace_result,
15389 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15390 TOKEN_STRING_INITIALIZER
15391 (struct cmd_ptype_mapping_replace_result,
15392 mapping, "mapping");
15393 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15394 TOKEN_STRING_INITIALIZER
15395 (struct cmd_ptype_mapping_replace_result,
15396 replace, "replace");
15397 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15398 TOKEN_NUM_INITIALIZER
15399 (struct cmd_ptype_mapping_replace_result,
15401 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15402 TOKEN_NUM_INITIALIZER
15403 (struct cmd_ptype_mapping_replace_result,
15405 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15406 TOKEN_NUM_INITIALIZER
15407 (struct cmd_ptype_mapping_replace_result,
15409 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15410 TOKEN_NUM_INITIALIZER
15411 (struct cmd_ptype_mapping_replace_result,
15415 cmd_ptype_mapping_replace_parsed(
15416 void *parsed_result,
15417 __attribute__((unused)) struct cmdline *cl,
15418 __attribute__((unused)) void *data)
15420 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15421 int ret = -ENOTSUP;
15423 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15426 #ifdef RTE_LIBRTE_I40E_PMD
15427 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15437 printf("invalid ptype 0x%8x or 0x%8x\n",
15438 res->target, res->pkt_type);
15441 printf("invalid port_id %d\n", res->port_id);
15444 printf("function not implemented\n");
15447 printf("programming error: (%s)\n", strerror(-ret));
15451 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15452 .f = cmd_ptype_mapping_replace_parsed,
15455 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15457 (void *)&cmd_ptype_mapping_replace_ptype,
15458 (void *)&cmd_ptype_mapping_replace_mapping,
15459 (void *)&cmd_ptype_mapping_replace_replace,
15460 (void *)&cmd_ptype_mapping_replace_port_id,
15461 (void *)&cmd_ptype_mapping_replace_target,
15462 (void *)&cmd_ptype_mapping_replace_mask,
15463 (void *)&cmd_ptype_mapping_replace_pkt_type,
15468 /* ptype mapping reset */
15470 /* Common result structure for ptype mapping reset */
15471 struct cmd_ptype_mapping_reset_result {
15472 cmdline_fixed_string_t ptype;
15473 cmdline_fixed_string_t mapping;
15474 cmdline_fixed_string_t reset;
15478 /* Common CLI fields for ptype mapping reset*/
15479 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15480 TOKEN_STRING_INITIALIZER
15481 (struct cmd_ptype_mapping_reset_result,
15483 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15484 TOKEN_STRING_INITIALIZER
15485 (struct cmd_ptype_mapping_reset_result,
15486 mapping, "mapping");
15487 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15488 TOKEN_STRING_INITIALIZER
15489 (struct cmd_ptype_mapping_reset_result,
15491 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15492 TOKEN_NUM_INITIALIZER
15493 (struct cmd_ptype_mapping_reset_result,
15497 cmd_ptype_mapping_reset_parsed(
15498 void *parsed_result,
15499 __attribute__((unused)) struct cmdline *cl,
15500 __attribute__((unused)) void *data)
15502 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15503 int ret = -ENOTSUP;
15505 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15508 #ifdef RTE_LIBRTE_I40E_PMD
15509 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15516 printf("invalid port_id %d\n", res->port_id);
15519 printf("function not implemented\n");
15522 printf("programming error: (%s)\n", strerror(-ret));
15526 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15527 .f = cmd_ptype_mapping_reset_parsed,
15529 .help_str = "ptype mapping reset <port_id>",
15531 (void *)&cmd_ptype_mapping_reset_ptype,
15532 (void *)&cmd_ptype_mapping_reset_mapping,
15533 (void *)&cmd_ptype_mapping_reset_reset,
15534 (void *)&cmd_ptype_mapping_reset_port_id,
15539 /* ptype mapping update */
15541 /* Common result structure for ptype mapping update */
15542 struct cmd_ptype_mapping_update_result {
15543 cmdline_fixed_string_t ptype;
15544 cmdline_fixed_string_t mapping;
15545 cmdline_fixed_string_t reset;
15551 /* Common CLI fields for ptype mapping update*/
15552 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15553 TOKEN_STRING_INITIALIZER
15554 (struct cmd_ptype_mapping_update_result,
15556 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15557 TOKEN_STRING_INITIALIZER
15558 (struct cmd_ptype_mapping_update_result,
15559 mapping, "mapping");
15560 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15561 TOKEN_STRING_INITIALIZER
15562 (struct cmd_ptype_mapping_update_result,
15564 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15565 TOKEN_NUM_INITIALIZER
15566 (struct cmd_ptype_mapping_update_result,
15568 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15569 TOKEN_NUM_INITIALIZER
15570 (struct cmd_ptype_mapping_update_result,
15572 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15573 TOKEN_NUM_INITIALIZER
15574 (struct cmd_ptype_mapping_update_result,
15578 cmd_ptype_mapping_update_parsed(
15579 void *parsed_result,
15580 __attribute__((unused)) struct cmdline *cl,
15581 __attribute__((unused)) void *data)
15583 struct cmd_ptype_mapping_update_result *res = parsed_result;
15584 int ret = -ENOTSUP;
15585 #ifdef RTE_LIBRTE_I40E_PMD
15586 struct rte_pmd_i40e_ptype_mapping mapping;
15588 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15591 #ifdef RTE_LIBRTE_I40E_PMD
15592 mapping.hw_ptype = res->hw_ptype;
15593 mapping.sw_ptype = res->sw_ptype;
15594 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15604 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15607 printf("invalid port_id %d\n", res->port_id);
15610 printf("function not implemented\n");
15613 printf("programming error: (%s)\n", strerror(-ret));
15617 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15618 .f = cmd_ptype_mapping_update_parsed,
15620 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15622 (void *)&cmd_ptype_mapping_update_ptype,
15623 (void *)&cmd_ptype_mapping_update_mapping,
15624 (void *)&cmd_ptype_mapping_update_update,
15625 (void *)&cmd_ptype_mapping_update_port_id,
15626 (void *)&cmd_ptype_mapping_update_hw_ptype,
15627 (void *)&cmd_ptype_mapping_update_sw_ptype,
15632 /* Common result structure for file commands */
15633 struct cmd_cmdfile_result {
15634 cmdline_fixed_string_t load;
15635 cmdline_fixed_string_t filename;
15638 /* Common CLI fields for file commands */
15639 cmdline_parse_token_string_t cmd_load_cmdfile =
15640 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15641 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15642 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15645 cmd_load_from_file_parsed(
15646 void *parsed_result,
15647 __attribute__((unused)) struct cmdline *cl,
15648 __attribute__((unused)) void *data)
15650 struct cmd_cmdfile_result *res = parsed_result;
15652 cmdline_read_from_file(res->filename);
15655 cmdline_parse_inst_t cmd_load_from_file = {
15656 .f = cmd_load_from_file_parsed,
15658 .help_str = "load <filename>",
15660 (void *)&cmd_load_cmdfile,
15661 (void *)&cmd_load_cmdfile_filename,
15666 /* ******************************************************************************** */
15668 /* list of instructions */
15669 cmdline_parse_ctx_t main_ctx[] = {
15670 (cmdline_parse_inst_t *)&cmd_help_brief,
15671 (cmdline_parse_inst_t *)&cmd_help_long,
15672 (cmdline_parse_inst_t *)&cmd_quit,
15673 (cmdline_parse_inst_t *)&cmd_load_from_file,
15674 (cmdline_parse_inst_t *)&cmd_showport,
15675 (cmdline_parse_inst_t *)&cmd_showqueue,
15676 (cmdline_parse_inst_t *)&cmd_showportall,
15677 (cmdline_parse_inst_t *)&cmd_showcfg,
15678 (cmdline_parse_inst_t *)&cmd_start,
15679 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15680 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15681 (cmdline_parse_inst_t *)&cmd_set_link_up,
15682 (cmdline_parse_inst_t *)&cmd_set_link_down,
15683 (cmdline_parse_inst_t *)&cmd_reset,
15684 (cmdline_parse_inst_t *)&cmd_set_numbers,
15685 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15686 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15687 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15688 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15689 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15690 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15691 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15692 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15693 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15694 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15695 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15696 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15697 (cmdline_parse_inst_t *)&cmd_set_link_check,
15698 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15699 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15700 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15701 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15702 #ifdef RTE_LIBRTE_PMD_BOND
15703 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15704 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15705 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15706 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15707 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15708 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15709 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15710 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15711 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15712 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15713 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15715 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15716 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15717 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15718 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15719 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15720 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15721 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15722 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15723 (cmdline_parse_inst_t *)&cmd_csum_set,
15724 (cmdline_parse_inst_t *)&cmd_csum_show,
15725 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15726 (cmdline_parse_inst_t *)&cmd_tso_set,
15727 (cmdline_parse_inst_t *)&cmd_tso_show,
15728 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15729 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15730 (cmdline_parse_inst_t *)&cmd_gro_enable,
15731 (cmdline_parse_inst_t *)&cmd_gro_flush,
15732 (cmdline_parse_inst_t *)&cmd_gro_show,
15733 (cmdline_parse_inst_t *)&cmd_gso_enable,
15734 (cmdline_parse_inst_t *)&cmd_gso_size,
15735 (cmdline_parse_inst_t *)&cmd_gso_show,
15736 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15737 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15738 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15739 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15740 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15741 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15742 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15743 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15744 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15745 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15746 (cmdline_parse_inst_t *)&cmd_config_dcb,
15747 (cmdline_parse_inst_t *)&cmd_read_reg,
15748 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15749 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15750 (cmdline_parse_inst_t *)&cmd_write_reg,
15751 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15752 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15753 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15754 (cmdline_parse_inst_t *)&cmd_stop,
15755 (cmdline_parse_inst_t *)&cmd_mac_addr,
15756 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
15757 (cmdline_parse_inst_t *)&cmd_set_qmap,
15758 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
15759 (cmdline_parse_inst_t *)&cmd_operate_port,
15760 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15761 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15762 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15763 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15764 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15765 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15766 (cmdline_parse_inst_t *)&cmd_config_mtu,
15767 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15768 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15769 (cmdline_parse_inst_t *)&cmd_config_rss,
15770 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15771 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15772 (cmdline_parse_inst_t *)&cmd_showport_reta,
15773 (cmdline_parse_inst_t *)&cmd_config_burst,
15774 (cmdline_parse_inst_t *)&cmd_config_thresh,
15775 (cmdline_parse_inst_t *)&cmd_config_threshold,
15776 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15777 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15778 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15779 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15780 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15781 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15782 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15783 (cmdline_parse_inst_t *)&cmd_global_config,
15784 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15785 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15786 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15787 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15788 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15789 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15790 (cmdline_parse_inst_t *)&cmd_dump,
15791 (cmdline_parse_inst_t *)&cmd_dump_one,
15792 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15793 (cmdline_parse_inst_t *)&cmd_syn_filter,
15794 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15795 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15796 (cmdline_parse_inst_t *)&cmd_flex_filter,
15797 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15798 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15799 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15800 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15801 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15802 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15803 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15804 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15805 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15806 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15807 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15808 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15809 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15810 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15811 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15812 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15813 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15814 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15815 (cmdline_parse_inst_t *)&cmd_flow,
15816 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
15817 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15818 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15819 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15820 (cmdline_parse_inst_t *)&cmd_create_port_meter,
15821 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
15822 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
15823 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15824 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15825 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
15826 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15827 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15828 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15829 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15830 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15831 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15832 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15833 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15834 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15835 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15836 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15837 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15838 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15839 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15840 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15841 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15842 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15843 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15844 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15845 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15846 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15847 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15848 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15849 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15850 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15851 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15852 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15853 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15854 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15855 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15856 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15857 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15858 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15859 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15860 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15861 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15862 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15863 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15864 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15865 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15866 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15868 (cmdline_parse_inst_t *)&cmd_ddp_add,
15869 (cmdline_parse_inst_t *)&cmd_ddp_del,
15870 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15871 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15872 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15873 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15874 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15875 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15876 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15877 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15879 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15880 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15881 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15882 (cmdline_parse_inst_t *)&cmd_queue_region,
15883 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15884 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15885 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15886 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15887 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15888 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15889 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15890 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15891 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15892 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15893 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15894 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15895 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15896 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15897 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15898 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
15899 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
15900 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
15901 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
15902 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
15903 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
15907 /* read cmdline commands from file */
15909 cmdline_read_from_file(const char *filename)
15911 struct cmdline *cl;
15913 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15915 printf("Failed to create file based cmdline context: %s\n",
15920 cmdline_interact(cl);
15925 printf("Read CLI commands from %s\n", filename);
15928 /* prompt function, called from main on MASTER lcore */
15932 /* initialize non-constant commands */
15933 cmd_set_fwd_mode_init();
15934 cmd_set_fwd_retry_mode_init();
15936 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15937 if (testpmd_cl == NULL)
15939 cmdline_interact(testpmd_cl);
15940 cmdline_stdin_exit(testpmd_cl);
15946 if (testpmd_cl != NULL)
15947 cmdline_quit(testpmd_cl);
15951 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15953 if (id == (portid_t)RTE_PORT_ALL) {
15956 RTE_ETH_FOREACH_DEV(pid) {
15957 /* check if need_reconfig has been set to 1 */
15958 if (ports[pid].need_reconfig == 0)
15959 ports[pid].need_reconfig = dev;
15960 /* check if need_reconfig_queues has been set to 1 */
15961 if (ports[pid].need_reconfig_queues == 0)
15962 ports[pid].need_reconfig_queues = queue;
15964 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15965 /* check if need_reconfig has been set to 1 */
15966 if (ports[id].need_reconfig == 0)
15967 ports[id].need_reconfig = dev;
15968 /* check if need_reconfig_queues has been set to 1 */
15969 if (ports[id].need_reconfig_queues == 0)
15970 ports[id].need_reconfig_queues = queue;