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"
104 static struct cmdline *testpmd_cl;
106 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
108 /* *** Help command with introduction. *** */
109 struct cmd_help_brief_result {
110 cmdline_fixed_string_t help;
113 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
115 __attribute__((unused)) void *data)
120 "Help is available for the following sections:\n\n"
121 " help control : Start and stop forwarding.\n"
122 " help display : Displaying port, stats and config "
124 " help config : Configuration information.\n"
125 " help ports : Configuring ports.\n"
126 " help registers : Reading and setting port registers.\n"
127 " help filters : Filters configuration help.\n"
128 " help all : All of the above sections.\n\n"
133 cmdline_parse_token_string_t cmd_help_brief_help =
134 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
136 cmdline_parse_inst_t cmd_help_brief = {
137 .f = cmd_help_brief_parsed,
139 .help_str = "help: Show help",
141 (void *)&cmd_help_brief_help,
146 /* *** Help command with help sections. *** */
147 struct cmd_help_long_result {
148 cmdline_fixed_string_t help;
149 cmdline_fixed_string_t section;
152 static void cmd_help_long_parsed(void *parsed_result,
154 __attribute__((unused)) void *data)
157 struct cmd_help_long_result *res = parsed_result;
159 if (!strcmp(res->section, "all"))
162 if (show_all || !strcmp(res->section, "control")) {
167 "Control forwarding:\n"
168 "-------------------\n\n"
171 " Start packet forwarding with current configuration.\n\n"
174 " Start packet forwarding with current config"
175 " after sending one burst of packets.\n\n"
178 " Stop packet forwarding, and display accumulated"
182 " Quit to prompt.\n\n"
186 if (show_all || !strcmp(res->section, "display")) {
194 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
195 " Display information for port_id, or all.\n\n"
197 "show port X rss reta (size) (mask0,mask1,...)\n"
198 " Display the rss redirection table entry indicated"
199 " by masks on port X. size is used to indicate the"
200 " hardware supported reta size\n\n"
202 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
203 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
204 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
205 " Display the RSS hash functions and RSS hash key"
208 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
209 " Clear information for port_id, or all.\n\n"
211 "show (rxq|txq) info (port_id) (queue_id)\n"
212 " Display information for configured RX/TX queue.\n\n"
214 "show config (rxtx|cores|fwd|txpkts)\n"
215 " Display the given configuration.\n\n"
217 "read rxd (port_id) (queue_id) (rxd_id)\n"
218 " Display an RX descriptor of a port RX queue.\n\n"
220 "read txd (port_id) (queue_id) (txd_id)\n"
221 " Display a TX descriptor of a port TX queue.\n\n"
223 "ddp get list (port_id)\n"
224 " Get ddp profile info list\n\n"
226 "ddp get info (profile_path)\n"
227 " Get ddp profile information.\n\n"
229 "show vf stats (port_id) (vf_id)\n"
230 " Display a VF's statistics.\n\n"
232 "clear vf stats (port_id) (vf_id)\n"
233 " Reset a VF's statistics.\n\n"
235 "show port (port_id) pctype mapping\n"
236 " Get flow ptype to pctype mapping on a port\n\n"
238 "show port meter stats (port_id) (meter_id) (clear)\n"
239 " Get meter stats on a port\n\n"
243 if (show_all || !strcmp(res->section, "config")) {
249 "Configuration changes only become active when"
250 " forwarding is started/restarted.\n\n"
253 " Reset forwarding to the default configuration.\n\n"
255 "set verbose (level)\n"
256 " Set the debug verbosity level X.\n\n"
259 " Set number of ports.\n\n"
262 " Set number of cores.\n\n"
264 "set coremask (mask)\n"
265 " Set the forwarding cores hexadecimal mask.\n\n"
267 "set portmask (mask)\n"
268 " Set the forwarding ports hexadecimal mask.\n\n"
271 " Set number of packets per burst.\n\n"
273 "set burst tx delay (microseconds) retry (num)\n"
274 " Set the transmit delay time and number of retries,"
275 " effective when retry is enabled.\n\n"
277 "set txpkts (x[,y]*)\n"
278 " Set the length of each segment of TXONLY"
279 " and optionally CSUM packets.\n\n"
281 "set txsplit (off|on|rand)\n"
282 " Set the split policy for the TX packets."
283 " Right now only applicable for CSUM and TXONLY"
286 "set corelist (x[,y]*)\n"
287 " Set the list of forwarding cores.\n\n"
289 "set portlist (x[,y]*)\n"
290 " Set the list of forwarding ports.\n\n"
292 "set tx loopback (port_id) (on|off)\n"
293 " Enable or disable tx loopback.\n\n"
295 "set all queues drop (port_id) (on|off)\n"
296 " Set drop enable bit for all queues.\n\n"
298 "set vf split drop (port_id) (vf_id) (on|off)\n"
299 " Set split drop enable bit for a VF from the PF.\n\n"
301 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
302 " Set MAC antispoof for a VF from the PF.\n\n"
304 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
305 " Enable MACsec offload.\n\n"
307 "set macsec offload (port_id) off\n"
308 " Disable MACsec offload.\n\n"
310 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
311 " Configure MACsec secure connection (SC).\n\n"
313 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
314 " Configure MACsec secure association (SA).\n\n"
316 "set vf broadcast (port_id) (vf_id) (on|off)\n"
317 " Set VF broadcast for a VF from the PF.\n\n"
319 "vlan set strip (on|off) (port_id)\n"
320 " Set the VLAN strip on a port.\n\n"
322 "vlan set stripq (on|off) (port_id,queue_id)\n"
323 " Set the VLAN strip for a queue on a port.\n\n"
325 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
326 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
328 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
329 " Set VLAN insert for a VF from the PF.\n\n"
331 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
332 " Set VLAN antispoof for a VF from the PF.\n\n"
334 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
335 " Set VLAN tag for a VF from the PF.\n\n"
337 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
338 " Set a VF's max bandwidth(Mbps).\n\n"
340 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
341 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
343 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
344 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
346 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
347 " Set some TCs' strict link priority mode on a physical port.\n\n"
349 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
350 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
352 "vlan set filter (on|off) (port_id)\n"
353 " Set the VLAN filter on a port.\n\n"
355 "vlan set qinq (on|off) (port_id)\n"
356 " Set the VLAN QinQ (extended queue in queue)"
359 "vlan set (inner|outer) tpid (value) (port_id)\n"
360 " Set the VLAN TPID for Packet Filtering on"
363 "rx_vlan add (vlan_id|all) (port_id)\n"
364 " Add a vlan_id, or all identifiers, to the set"
365 " of VLAN identifiers filtered by port_id.\n\n"
367 "rx_vlan rm (vlan_id|all) (port_id)\n"
368 " Remove a vlan_id, or all identifiers, from the set"
369 " of VLAN identifiers filtered by port_id.\n\n"
371 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
372 " Add a vlan_id, to the set of VLAN identifiers"
373 "filtered for VF(s) from port_id.\n\n"
375 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
376 " Remove a vlan_id, to the set of VLAN identifiers"
377 "filtered for VF(s) from port_id.\n\n"
379 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
380 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
381 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
382 " add a tunnel filter of a port.\n\n"
384 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
385 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
386 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
387 " remove a tunnel filter of a port.\n\n"
389 "rx_vxlan_port add (udp_port) (port_id)\n"
390 " Add an UDP port for VXLAN packet filter on a port\n\n"
392 "rx_vxlan_port rm (udp_port) (port_id)\n"
393 " Remove an UDP port for VXLAN packet filter on a port\n\n"
395 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
396 " Set hardware insertion of VLAN IDs (single or double VLAN "
397 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
399 "tx_vlan set pvid port_id vlan_id (on|off)\n"
400 " Set port based TX VLAN insertion.\n\n"
402 "tx_vlan reset (port_id)\n"
403 " Disable hardware insertion of a VLAN header in"
404 " packets sent on a port.\n\n"
406 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
407 " Select hardware or software calculation of the"
408 " checksum when transmitting a packet using the"
409 " csum forward engine.\n"
410 " ip|udp|tcp|sctp always concern the inner layer.\n"
411 " outer-ip concerns the outer IP layer in"
412 " case the packet is recognized as a tunnel packet by"
413 " the forward engine (vxlan, gre and ipip are supported)\n"
414 " Please check the NIC datasheet for HW limits.\n\n"
416 "csum parse-tunnel (on|off) (tx_port_id)\n"
417 " If disabled, treat tunnel packets as non-tunneled"
418 " packets (treat inner headers as payload). The port\n"
419 " argument is the port used for TX in csum forward"
422 "csum show (port_id)\n"
423 " Display tx checksum offload configuration\n\n"
425 "tso set (segsize) (portid)\n"
426 " Enable TCP Segmentation Offload in csum forward"
428 " Please check the NIC datasheet for HW limits.\n\n"
431 " Display the status of TCP Segmentation Offload.\n\n"
433 "set port (port_id) gro on|off\n"
434 " Enable or disable Generic Receive Offload in"
435 " csum forwarding engine.\n\n"
437 "show port (port_id) gro\n"
438 " Display GRO configuration.\n\n"
440 "set gro flush (cycles)\n"
441 " Set the cycle to flush GROed packets from"
442 " reassembly tables.\n\n"
444 "set port (port_id) gso (on|off)"
445 " Enable or disable Generic Segmentation Offload in"
446 " csum forwarding engine.\n\n"
448 "set gso segsz (length)\n"
449 " Set max packet length for output GSO segments,"
450 " including packet header and payload.\n\n"
452 "show port (port_id) gso\n"
453 " Show GSO configuration.\n\n"
456 " Set packet forwarding mode.\n\n"
458 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
459 " Add a MAC address on port_id.\n\n"
461 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
462 " Remove a MAC address from port_id.\n\n"
464 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
465 " Set the default MAC address for port_id.\n\n"
467 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
468 " Add a MAC address for a VF on the port.\n\n"
470 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
471 " Set the MAC address for a VF from the PF.\n\n"
473 "set port (port_id) uta (mac_address|all) (on|off)\n"
474 " Add/Remove a or all unicast hash filter(s)"
477 "set promisc (port_id|all) (on|off)\n"
478 " Set the promiscuous mode on port_id, or all.\n\n"
480 "set allmulti (port_id|all) (on|off)\n"
481 " Set the allmulti mode on port_id, or all.\n\n"
483 "set vf promisc (port_id) (vf_id) (on|off)\n"
484 " Set unicast promiscuous mode for a VF from the PF.\n\n"
486 "set vf allmulti (port_id) (vf_id) (on|off)\n"
487 " Set multicast promiscuous mode for a VF from the PF.\n\n"
489 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
490 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
491 " (on|off) autoneg (on|off) (port_id)\n"
492 "set flow_ctrl rx (on|off) (portid)\n"
493 "set flow_ctrl tx (on|off) (portid)\n"
494 "set flow_ctrl high_water (high_water) (portid)\n"
495 "set flow_ctrl low_water (low_water) (portid)\n"
496 "set flow_ctrl pause_time (pause_time) (portid)\n"
497 "set flow_ctrl send_xon (send_xon) (portid)\n"
498 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
499 "set flow_ctrl autoneg (on|off) (port_id)\n"
500 " Set the link flow control parameter on a port.\n\n"
502 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
503 " (low_water) (pause_time) (priority) (port_id)\n"
504 " Set the priority flow control parameter on a"
507 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
508 " Set statistics mapping (qmapping 0..15) for RX/TX"
510 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
511 " on port 0 to mapping 5.\n\n"
513 "set port (port_id) vf (vf_id) rx|tx on|off\n"
514 " Enable/Disable a VF receive/tranmit from a port\n\n"
516 "set port (port_id) vf (vf_id) (mac_addr)"
517 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
518 " Add/Remove unicast or multicast MAC addr filter"
521 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
523 " AUPE:accepts untagged VLAN;"
524 "ROPE:accept unicast hash\n\n"
525 " BAM:accepts broadcast packets;"
526 "MPE:accepts all multicast packets\n\n"
527 " Enable/Disable a VF receive mode of a port\n\n"
529 "set port (port_id) queue (queue_id) rate (rate_num)\n"
530 " Set rate limit for a queue of a port\n\n"
532 "set port (port_id) vf (vf_id) rate (rate_num) "
533 "queue_mask (queue_mask_value)\n"
534 " Set rate limit for queues in VF of a port\n\n"
536 "set port (port_id) mirror-rule (rule_id)"
537 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
538 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
539 " Set pool or vlan type mirror rule on a port.\n"
540 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
541 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
544 "set port (port_id) mirror-rule (rule_id)"
545 " (uplink-mirror|downlink-mirror) dst-pool"
546 " (pool_id) (on|off)\n"
547 " Set uplink or downlink type mirror rule on a port.\n"
548 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
549 " 0 on' enable mirror income traffic to pool 0.\n\n"
551 "reset port (port_id) mirror-rule (rule_id)\n"
552 " Reset a mirror rule.\n\n"
554 "set flush_rx (on|off)\n"
555 " Flush (default) or don't flush RX streams before"
556 " forwarding. Mainly used with PCAP drivers.\n\n"
558 "set bypass mode (normal|bypass|isolate) (port_id)\n"
559 " Set the bypass mode for the lowest port on bypass enabled"
562 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
563 "mode (normal|bypass|isolate) (port_id)\n"
564 " Set the event required to initiate specified bypass mode for"
565 " the lowest port on a bypass enabled NIC where:\n"
566 " timeout = enable bypass after watchdog timeout.\n"
567 " os_on = enable bypass when OS/board is powered on.\n"
568 " os_off = enable bypass when OS/board is powered off.\n"
569 " power_on = enable bypass when power supply is turned on.\n"
570 " power_off = enable bypass when power supply is turned off."
573 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
574 " Set the bypass watchdog timeout to 'n' seconds"
575 " where 0 = instant.\n\n"
577 "show bypass config (port_id)\n"
578 " Show the bypass configuration for a bypass enabled NIC"
579 " using the lowest port on the NIC.\n\n"
581 #ifdef RTE_LIBRTE_PMD_BOND
582 "create bonded device (mode) (socket)\n"
583 " Create a new bonded device with specific bonding mode and socket.\n\n"
585 "add bonding slave (slave_id) (port_id)\n"
586 " Add a slave device to a bonded device.\n\n"
588 "remove bonding slave (slave_id) (port_id)\n"
589 " Remove a slave device from a bonded device.\n\n"
591 "set bonding mode (value) (port_id)\n"
592 " Set the bonding mode on a bonded device.\n\n"
594 "set bonding primary (slave_id) (port_id)\n"
595 " Set the primary slave for a bonded device.\n\n"
597 "show bonding config (port_id)\n"
598 " Show the bonding config for port_id.\n\n"
600 "set bonding mac_addr (port_id) (address)\n"
601 " Set the MAC address of a bonded device.\n\n"
603 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
604 " Set Aggregation mode for IEEE802.3AD (mode 4)"
606 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
607 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
609 "set bonding mon_period (port_id) (value)\n"
610 " Set the bonding link status monitoring polling period in ms.\n\n"
612 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
613 " Enable/disable dedicated queues for LACP control traffic.\n\n"
616 "set link-up port (port_id)\n"
617 " Set link up for a port.\n\n"
619 "set link-down port (port_id)\n"
620 " Set link down for a port.\n\n"
622 "E-tag set insertion on port-tag-id (value)"
623 " port (port_id) vf (vf_id)\n"
624 " Enable E-tag insertion for a VF on a port\n\n"
626 "E-tag set insertion off port (port_id) vf (vf_id)\n"
627 " Disable E-tag insertion for a VF on a port\n\n"
629 "E-tag set stripping (on|off) port (port_id)\n"
630 " Enable/disable E-tag stripping on a port\n\n"
632 "E-tag set forwarding (on|off) port (port_id)\n"
633 " Enable/disable E-tag based forwarding"
636 "E-tag set filter add e-tag-id (value) dst-pool"
637 " (pool_id) port (port_id)\n"
638 " Add an E-tag forwarding filter on a port\n\n"
640 "E-tag set filter del e-tag-id (value) port (port_id)\n"
641 " Delete an E-tag forwarding filter on a port\n\n"
643 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
644 "set port tm hierarchy default (port_id)\n"
645 " Set default traffic Management hierarchy on a port\n\n"
648 "ddp add (port_id) (profile_path[,output_path])\n"
649 " Load a profile package on a port\n\n"
651 "ddp del (port_id) (profile_path)\n"
652 " Delete a profile package from a port\n\n"
654 "ptype mapping get (port_id) (valid_only)\n"
655 " Get ptype mapping on a port\n\n"
657 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
658 " Replace target with the pkt_type in ptype mapping\n\n"
660 "ptype mapping reset (port_id)\n"
661 " Reset ptype mapping on a port\n\n"
663 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
664 " Update a ptype mapping item on a port\n\n"
666 "set port (port_id) queue-region region_id (value) "
667 "queue_start_index (value) queue_num (value)\n"
668 " Set a queue region on a port\n\n"
670 "set port (port_id) queue-region region_id (value) "
672 " Set a flowtype region index on a port\n\n"
674 "set port (port_id) queue-region UP (value) region_id (value)\n"
675 " Set the mapping of User Priority to "
676 "queue region on a port\n\n"
678 "set port (port_id) queue-region flush (on|off)\n"
679 " flush all queue region related configuration\n\n"
681 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (color_aware)\n"
682 " meter profile add - srtcm rfc 2697\n\n"
684 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
685 " meter profile add - trtcm rfc 2698\n\n"
687 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
688 " meter profile add - trtcm rfc 4115\n\n"
690 "del port meter profile (port_id) (profile_id)\n"
691 " meter profile delete\n\n"
693 "set port meter (port_id) (mtr_id) (profile_id) (g_action) (y_action) (r_action) (stats_mask) (shared)\n"
696 "del port meter (port_id) (mtr_id)\n"
699 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
700 " meter update meter profile\n\n"
702 "set port meter policer action (port_id) (mtr_id) (color) (action)\n"
703 " meter update policer action\n\n"
705 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
706 " meter update stats\n\n"
708 "show port (port_id) queue-region\n"
709 " show all queue region related configuration info\n\n"
711 , list_pkt_forwarding_modes()
715 if (show_all || !strcmp(res->section, "ports")) {
721 "----------------\n\n"
723 "port start (port_id|all)\n"
724 " Start all ports or port_id.\n\n"
726 "port stop (port_id|all)\n"
727 " Stop all ports or port_id.\n\n"
729 "port close (port_id|all)\n"
730 " Close all ports or port_id.\n\n"
732 "port attach (ident)\n"
733 " Attach physical or virtual dev by pci address or virtual device name\n\n"
735 "port detach (port_id)\n"
736 " Detach physical or virtual dev by port_id\n\n"
738 "port config (port_id|all)"
739 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
740 " duplex (half|full|auto)\n"
741 " Set speed and duplex for all ports or port_id\n\n"
743 "port config all (rxq|txq|rxd|txd) (value)\n"
744 " Set number for rxq/txq/rxd/txd.\n\n"
746 "port config all max-pkt-len (value)\n"
747 " Set the max packet length.\n\n"
749 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
750 "hw-vlan-strip|hw-vlan-extend|drop-en)"
752 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
755 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
756 "geneve|nvgre|none|<flowtype_id>)\n"
757 " Set the RSS mode.\n\n"
759 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
760 " Set the RSS redirection table.\n\n"
762 "port config (port_id) dcb vt (on|off) (traffic_class)"
764 " Set the DCB mode.\n\n"
766 "port config all burst (value)\n"
767 " Set the number of packets per burst.\n\n"
769 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
771 " Set the ring prefetch/host/writeback threshold"
772 " for tx/rx queue.\n\n"
774 "port config all (txfreet|txrst|rxfreet) (value)\n"
775 " Set free threshold for rx/tx, or set"
776 " tx rs bit threshold.\n\n"
777 "port config mtu X value\n"
778 " Set the MTU of port X to a given value\n\n"
780 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
781 " Start/stop a rx/tx queue of port X. Only take effect"
782 " when port X is started\n\n"
784 "port config (port_id|all) l2-tunnel E-tag ether-type"
786 " Set the value of E-tag ether-type.\n\n"
788 "port config (port_id|all) l2-tunnel E-tag"
789 " (enable|disable)\n"
790 " Enable/disable the E-tag support.\n\n"
792 "port config (port_id) pctype mapping reset\n"
793 " Reset flow type to pctype mapping on a port\n\n"
795 "port config (port_id) pctype mapping update"
796 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
797 " Update a flow type to pctype mapping item on a port\n\n"
801 if (show_all || !strcmp(res->section, "registers")) {
809 "read reg (port_id) (address)\n"
810 " Display value of a port register.\n\n"
812 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
813 " Display a port register bit field.\n\n"
815 "read regbit (port_id) (address) (bit_x)\n"
816 " Display a single port register bit.\n\n"
818 "write reg (port_id) (address) (value)\n"
819 " Set value of a port register.\n\n"
821 "write regfield (port_id) (address) (bit_x) (bit_y)"
823 " Set bit field of a port register.\n\n"
825 "write regbit (port_id) (address) (bit_x) (value)\n"
826 " Set single bit value of a port register.\n\n"
829 if (show_all || !strcmp(res->section, "filters")) {
837 "ethertype_filter (port_id) (add|del)"
838 " (mac_addr|mac_ignr) (mac_address) ethertype"
839 " (ether_type) (drop|fwd) queue (queue_id)\n"
840 " Add/Del an ethertype filter.\n\n"
842 "2tuple_filter (port_id) (add|del)"
843 " dst_port (dst_port_value) protocol (protocol_value)"
844 " mask (mask_value) tcp_flags (tcp_flags_value)"
845 " priority (prio_value) queue (queue_id)\n"
846 " Add/Del a 2tuple filter.\n\n"
848 "5tuple_filter (port_id) (add|del)"
849 " dst_ip (dst_address) src_ip (src_address)"
850 " dst_port (dst_port_value) src_port (src_port_value)"
851 " protocol (protocol_value)"
852 " mask (mask_value) tcp_flags (tcp_flags_value)"
853 " priority (prio_value) queue (queue_id)\n"
854 " Add/Del a 5tuple filter.\n\n"
856 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
857 " Add/Del syn filter.\n\n"
859 "flex_filter (port_id) (add|del) len (len_value)"
860 " bytes (bytes_value) mask (mask_value)"
861 " priority (prio_value) queue (queue_id)\n"
862 " Add/Del a flex filter.\n\n"
864 "flow_director_filter (port_id) mode IP (add|del|update)"
865 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
866 " src (src_ip_address) dst (dst_ip_address)"
867 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
868 " vlan (vlan_value) flexbytes (flexbytes_value)"
869 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
870 " fd_id (fd_id_value)\n"
871 " Add/Del an IP type flow director filter.\n\n"
873 "flow_director_filter (port_id) mode IP (add|del|update)"
874 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
875 " src (src_ip_address) (src_port)"
876 " dst (dst_ip_address) (dst_port)"
877 " tos (tos_value) ttl (ttl_value)"
878 " vlan (vlan_value) flexbytes (flexbytes_value)"
879 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
880 " fd_id (fd_id_value)\n"
881 " Add/Del an UDP/TCP type flow director filter.\n\n"
883 "flow_director_filter (port_id) mode IP (add|del|update)"
884 " flow (ipv4-sctp|ipv6-sctp)"
885 " src (src_ip_address) (src_port)"
886 " dst (dst_ip_address) (dst_port)"
887 " tag (verification_tag) "
888 " tos (tos_value) ttl (ttl_value)"
890 " flexbytes (flexbytes_value) (drop|fwd)"
891 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
892 " Add/Del a SCTP type flow director filter.\n\n"
894 "flow_director_filter (port_id) mode IP (add|del|update)"
895 " flow l2_payload ether (ethertype)"
896 " flexbytes (flexbytes_value) (drop|fwd)"
897 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
898 " Add/Del a l2 payload type flow director filter.\n\n"
900 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
901 " mac (mac_address) vlan (vlan_value)"
902 " flexbytes (flexbytes_value) (drop|fwd)"
903 " queue (queue_id) fd_id (fd_id_value)\n"
904 " Add/Del a MAC-VLAN flow director filter.\n\n"
906 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
907 " mac (mac_address) vlan (vlan_value)"
908 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
909 " flexbytes (flexbytes_value) (drop|fwd)"
910 " queue (queue_id) fd_id (fd_id_value)\n"
911 " Add/Del a Tunnel flow director filter.\n\n"
913 "flush_flow_director (port_id)\n"
914 " Flush all flow director entries of a device.\n\n"
916 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
917 " src_mask (ipv4_src) (ipv6_src) (src_port)"
918 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
919 " Set flow director IP mask.\n\n"
921 "flow_director_mask (port_id) mode MAC-VLAN"
922 " vlan (vlan_value)\n"
923 " Set flow director MAC-VLAN mask.\n\n"
925 "flow_director_mask (port_id) mode Tunnel"
926 " vlan (vlan_value) mac (mac_value)"
927 " tunnel-type (tunnel_type_value)"
928 " tunnel-id (tunnel_id_value)\n"
929 " Set flow director Tunnel mask.\n\n"
931 "flow_director_flex_mask (port_id)"
932 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
933 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
935 " Configure mask of flex payload.\n\n"
937 "flow_director_flex_payload (port_id)"
938 " (raw|l2|l3|l4) (config)\n"
939 " Configure flex payload selection.\n\n"
941 "get_sym_hash_ena_per_port (port_id)\n"
942 " get symmetric hash enable configuration per port.\n\n"
944 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
945 " set symmetric hash enable configuration per port"
946 " to enable or disable.\n\n"
948 "get_hash_global_config (port_id)\n"
949 " Get the global configurations of hash filters.\n\n"
951 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
952 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
953 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
954 " (enable|disable)\n"
955 " Set the global configurations of hash filters.\n\n"
957 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
958 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
959 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
960 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
961 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
962 "ipv6-next-header|udp-src-port|udp-dst-port|"
963 "tcp-src-port|tcp-dst-port|sctp-src-port|"
964 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
965 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
966 "fld-8th|none) (select|add)\n"
967 " Set the input set for hash.\n\n"
969 "set_fdir_input_set (port_id) "
970 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
971 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
972 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
973 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
974 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
975 "udp-dst-port|tcp-src-port|tcp-dst-port|"
976 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
978 " Set the input set for FDir.\n\n"
980 "flow validate {port_id}"
981 " [group {group_id}] [priority {level}]"
982 " [ingress] [egress]"
983 " pattern {item} [/ {item} [...]] / end"
984 " actions {action} [/ {action} [...]] / end\n"
985 " Check whether a flow rule can be created.\n\n"
987 "flow create {port_id}"
988 " [group {group_id}] [priority {level}]"
989 " [ingress] [egress]"
990 " pattern {item} [/ {item} [...]] / end"
991 " actions {action} [/ {action} [...]] / end\n"
992 " Create a flow rule.\n\n"
994 "flow destroy {port_id} rule {rule_id} [...]\n"
995 " Destroy specific flow rules.\n\n"
997 "flow flush {port_id}\n"
998 " Destroy all flow rules.\n\n"
1000 "flow query {port_id} {rule_id} {action}\n"
1001 " Query an existing flow rule.\n\n"
1003 "flow list {port_id} [group {group_id}] [...]\n"
1004 " List existing flow rules sorted by priority,"
1005 " filtered by group identifiers.\n\n"
1007 "flow isolate {port_id} {boolean}\n"
1008 " Restrict ingress traffic to the defined"
1014 cmdline_parse_token_string_t cmd_help_long_help =
1015 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1017 cmdline_parse_token_string_t cmd_help_long_section =
1018 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1019 "all#control#display#config#"
1020 "ports#registers#filters");
1022 cmdline_parse_inst_t cmd_help_long = {
1023 .f = cmd_help_long_parsed,
1025 .help_str = "help all|control|display|config|ports|register|filters: "
1028 (void *)&cmd_help_long_help,
1029 (void *)&cmd_help_long_section,
1035 /* *** start/stop/close all ports *** */
1036 struct cmd_operate_port_result {
1037 cmdline_fixed_string_t keyword;
1038 cmdline_fixed_string_t name;
1039 cmdline_fixed_string_t value;
1042 static void cmd_operate_port_parsed(void *parsed_result,
1043 __attribute__((unused)) struct cmdline *cl,
1044 __attribute__((unused)) void *data)
1046 struct cmd_operate_port_result *res = parsed_result;
1048 if (!strcmp(res->name, "start"))
1049 start_port(RTE_PORT_ALL);
1050 else if (!strcmp(res->name, "stop"))
1051 stop_port(RTE_PORT_ALL);
1052 else if (!strcmp(res->name, "close"))
1053 close_port(RTE_PORT_ALL);
1054 else if (!strcmp(res->name, "reset"))
1055 reset_port(RTE_PORT_ALL);
1057 printf("Unknown parameter\n");
1060 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1061 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1063 cmdline_parse_token_string_t cmd_operate_port_all_port =
1064 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1065 "start#stop#close#reset");
1066 cmdline_parse_token_string_t cmd_operate_port_all_all =
1067 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1069 cmdline_parse_inst_t cmd_operate_port = {
1070 .f = cmd_operate_port_parsed,
1072 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1074 (void *)&cmd_operate_port_all_cmd,
1075 (void *)&cmd_operate_port_all_port,
1076 (void *)&cmd_operate_port_all_all,
1081 /* *** start/stop/close specific port *** */
1082 struct cmd_operate_specific_port_result {
1083 cmdline_fixed_string_t keyword;
1084 cmdline_fixed_string_t name;
1088 static void cmd_operate_specific_port_parsed(void *parsed_result,
1089 __attribute__((unused)) struct cmdline *cl,
1090 __attribute__((unused)) void *data)
1092 struct cmd_operate_specific_port_result *res = parsed_result;
1094 if (!strcmp(res->name, "start"))
1095 start_port(res->value);
1096 else if (!strcmp(res->name, "stop"))
1097 stop_port(res->value);
1098 else if (!strcmp(res->name, "close"))
1099 close_port(res->value);
1100 else if (!strcmp(res->name, "reset"))
1101 reset_port(res->value);
1103 printf("Unknown parameter\n");
1106 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1107 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1109 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1110 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1111 name, "start#stop#close#reset");
1112 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1113 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1116 cmdline_parse_inst_t cmd_operate_specific_port = {
1117 .f = cmd_operate_specific_port_parsed,
1119 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1121 (void *)&cmd_operate_specific_port_cmd,
1122 (void *)&cmd_operate_specific_port_port,
1123 (void *)&cmd_operate_specific_port_id,
1128 /* *** attach a specified port *** */
1129 struct cmd_operate_attach_port_result {
1130 cmdline_fixed_string_t port;
1131 cmdline_fixed_string_t keyword;
1132 cmdline_fixed_string_t identifier;
1135 static void cmd_operate_attach_port_parsed(void *parsed_result,
1136 __attribute__((unused)) struct cmdline *cl,
1137 __attribute__((unused)) void *data)
1139 struct cmd_operate_attach_port_result *res = parsed_result;
1141 if (!strcmp(res->keyword, "attach"))
1142 attach_port(res->identifier);
1144 printf("Unknown parameter\n");
1147 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1148 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1150 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1151 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1153 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1154 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1157 cmdline_parse_inst_t cmd_operate_attach_port = {
1158 .f = cmd_operate_attach_port_parsed,
1160 .help_str = "port attach <identifier>: "
1161 "(identifier: pci address or virtual dev name)",
1163 (void *)&cmd_operate_attach_port_port,
1164 (void *)&cmd_operate_attach_port_keyword,
1165 (void *)&cmd_operate_attach_port_identifier,
1170 /* *** detach a specified port *** */
1171 struct cmd_operate_detach_port_result {
1172 cmdline_fixed_string_t port;
1173 cmdline_fixed_string_t keyword;
1177 static void cmd_operate_detach_port_parsed(void *parsed_result,
1178 __attribute__((unused)) struct cmdline *cl,
1179 __attribute__((unused)) void *data)
1181 struct cmd_operate_detach_port_result *res = parsed_result;
1183 if (!strcmp(res->keyword, "detach"))
1184 detach_port(res->port_id);
1186 printf("Unknown parameter\n");
1189 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1190 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1192 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1193 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1195 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1196 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1199 cmdline_parse_inst_t cmd_operate_detach_port = {
1200 .f = cmd_operate_detach_port_parsed,
1202 .help_str = "port detach <port_id>",
1204 (void *)&cmd_operate_detach_port_port,
1205 (void *)&cmd_operate_detach_port_keyword,
1206 (void *)&cmd_operate_detach_port_port_id,
1211 /* *** configure speed for all ports *** */
1212 struct cmd_config_speed_all {
1213 cmdline_fixed_string_t port;
1214 cmdline_fixed_string_t keyword;
1215 cmdline_fixed_string_t all;
1216 cmdline_fixed_string_t item1;
1217 cmdline_fixed_string_t item2;
1218 cmdline_fixed_string_t value1;
1219 cmdline_fixed_string_t value2;
1223 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1228 if (!strcmp(duplexstr, "half")) {
1229 duplex = ETH_LINK_HALF_DUPLEX;
1230 } else if (!strcmp(duplexstr, "full")) {
1231 duplex = ETH_LINK_FULL_DUPLEX;
1232 } else if (!strcmp(duplexstr, "auto")) {
1233 duplex = ETH_LINK_FULL_DUPLEX;
1235 printf("Unknown duplex parameter\n");
1239 if (!strcmp(speedstr, "10")) {
1240 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1241 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1242 } else if (!strcmp(speedstr, "100")) {
1243 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1244 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1246 if (duplex != ETH_LINK_FULL_DUPLEX) {
1247 printf("Invalid speed/duplex parameters\n");
1250 if (!strcmp(speedstr, "1000")) {
1251 *speed = ETH_LINK_SPEED_1G;
1252 } else if (!strcmp(speedstr, "10000")) {
1253 *speed = ETH_LINK_SPEED_10G;
1254 } else if (!strcmp(speedstr, "25000")) {
1255 *speed = ETH_LINK_SPEED_25G;
1256 } else if (!strcmp(speedstr, "40000")) {
1257 *speed = ETH_LINK_SPEED_40G;
1258 } else if (!strcmp(speedstr, "50000")) {
1259 *speed = ETH_LINK_SPEED_50G;
1260 } else if (!strcmp(speedstr, "100000")) {
1261 *speed = ETH_LINK_SPEED_100G;
1262 } else if (!strcmp(speedstr, "auto")) {
1263 *speed = ETH_LINK_SPEED_AUTONEG;
1265 printf("Unknown speed parameter\n");
1274 cmd_config_speed_all_parsed(void *parsed_result,
1275 __attribute__((unused)) struct cmdline *cl,
1276 __attribute__((unused)) void *data)
1278 struct cmd_config_speed_all *res = parsed_result;
1279 uint32_t link_speed;
1282 if (!all_ports_stopped()) {
1283 printf("Please stop all ports first\n");
1287 if (parse_and_check_speed_duplex(res->value1, res->value2,
1291 RTE_ETH_FOREACH_DEV(pid) {
1292 ports[pid].dev_conf.link_speeds = link_speed;
1295 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1298 cmdline_parse_token_string_t cmd_config_speed_all_port =
1299 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1300 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1301 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1303 cmdline_parse_token_string_t cmd_config_speed_all_all =
1304 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1305 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1306 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1307 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1308 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1309 "10#100#1000#10000#25000#40000#50000#100000#auto");
1310 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1311 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1312 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1313 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1316 cmdline_parse_inst_t cmd_config_speed_all = {
1317 .f = cmd_config_speed_all_parsed,
1319 .help_str = "port config all speed "
1320 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1323 (void *)&cmd_config_speed_all_port,
1324 (void *)&cmd_config_speed_all_keyword,
1325 (void *)&cmd_config_speed_all_all,
1326 (void *)&cmd_config_speed_all_item1,
1327 (void *)&cmd_config_speed_all_value1,
1328 (void *)&cmd_config_speed_all_item2,
1329 (void *)&cmd_config_speed_all_value2,
1334 /* *** configure speed for specific port *** */
1335 struct cmd_config_speed_specific {
1336 cmdline_fixed_string_t port;
1337 cmdline_fixed_string_t keyword;
1339 cmdline_fixed_string_t item1;
1340 cmdline_fixed_string_t item2;
1341 cmdline_fixed_string_t value1;
1342 cmdline_fixed_string_t value2;
1346 cmd_config_speed_specific_parsed(void *parsed_result,
1347 __attribute__((unused)) struct cmdline *cl,
1348 __attribute__((unused)) void *data)
1350 struct cmd_config_speed_specific *res = parsed_result;
1351 uint32_t link_speed;
1353 if (!all_ports_stopped()) {
1354 printf("Please stop all ports first\n");
1358 if (port_id_is_invalid(res->id, ENABLED_WARN))
1361 if (parse_and_check_speed_duplex(res->value1, res->value2,
1365 ports[res->id].dev_conf.link_speeds = link_speed;
1367 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1371 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1372 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1374 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1375 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1377 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1378 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1379 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1380 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1382 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1383 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1384 "10#100#1000#10000#25000#40000#50000#100000#auto");
1385 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1386 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1388 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1389 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1392 cmdline_parse_inst_t cmd_config_speed_specific = {
1393 .f = cmd_config_speed_specific_parsed,
1395 .help_str = "port config <port_id> speed "
1396 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1399 (void *)&cmd_config_speed_specific_port,
1400 (void *)&cmd_config_speed_specific_keyword,
1401 (void *)&cmd_config_speed_specific_id,
1402 (void *)&cmd_config_speed_specific_item1,
1403 (void *)&cmd_config_speed_specific_value1,
1404 (void *)&cmd_config_speed_specific_item2,
1405 (void *)&cmd_config_speed_specific_value2,
1410 /* *** configure txq/rxq, txd/rxd *** */
1411 struct cmd_config_rx_tx {
1412 cmdline_fixed_string_t port;
1413 cmdline_fixed_string_t keyword;
1414 cmdline_fixed_string_t all;
1415 cmdline_fixed_string_t name;
1420 cmd_config_rx_tx_parsed(void *parsed_result,
1421 __attribute__((unused)) struct cmdline *cl,
1422 __attribute__((unused)) void *data)
1424 struct cmd_config_rx_tx *res = parsed_result;
1426 if (!all_ports_stopped()) {
1427 printf("Please stop all ports first\n");
1430 if (!strcmp(res->name, "rxq")) {
1431 if (!res->value && !nb_txq) {
1432 printf("Warning: Either rx or tx queues should be non zero\n");
1435 nb_rxq = res->value;
1437 else if (!strcmp(res->name, "txq")) {
1438 if (!res->value && !nb_rxq) {
1439 printf("Warning: Either rx or tx queues should be non zero\n");
1442 nb_txq = res->value;
1444 else if (!strcmp(res->name, "rxd")) {
1445 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1446 printf("rxd %d invalid - must be > 0 && <= %d\n",
1447 res->value, RTE_TEST_RX_DESC_MAX);
1450 nb_rxd = res->value;
1451 } else if (!strcmp(res->name, "txd")) {
1452 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1453 printf("txd %d invalid - must be > 0 && <= %d\n",
1454 res->value, RTE_TEST_TX_DESC_MAX);
1457 nb_txd = res->value;
1459 printf("Unknown parameter\n");
1467 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1470 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1471 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1472 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1473 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1474 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1475 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1476 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1477 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1479 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1480 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1482 cmdline_parse_inst_t cmd_config_rx_tx = {
1483 .f = cmd_config_rx_tx_parsed,
1485 .help_str = "port config all rxq|txq|rxd|txd <value>",
1487 (void *)&cmd_config_rx_tx_port,
1488 (void *)&cmd_config_rx_tx_keyword,
1489 (void *)&cmd_config_rx_tx_all,
1490 (void *)&cmd_config_rx_tx_name,
1491 (void *)&cmd_config_rx_tx_value,
1496 /* *** config max packet length *** */
1497 struct cmd_config_max_pkt_len_result {
1498 cmdline_fixed_string_t port;
1499 cmdline_fixed_string_t keyword;
1500 cmdline_fixed_string_t all;
1501 cmdline_fixed_string_t name;
1506 cmd_config_max_pkt_len_parsed(void *parsed_result,
1507 __attribute__((unused)) struct cmdline *cl,
1508 __attribute__((unused)) void *data)
1510 struct cmd_config_max_pkt_len_result *res = parsed_result;
1512 if (!all_ports_stopped()) {
1513 printf("Please stop all ports first\n");
1517 if (!strcmp(res->name, "max-pkt-len")) {
1518 if (res->value < ETHER_MIN_LEN) {
1519 printf("max-pkt-len can not be less than %d\n",
1523 if (res->value == rx_mode.max_rx_pkt_len)
1526 rx_mode.max_rx_pkt_len = res->value;
1527 if (res->value > ETHER_MAX_LEN)
1528 rx_mode.jumbo_frame = 1;
1530 rx_mode.jumbo_frame = 0;
1532 printf("Unknown parameter\n");
1538 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1541 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1542 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1544 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1545 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1547 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1548 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1550 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1551 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1553 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1554 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1557 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1558 .f = cmd_config_max_pkt_len_parsed,
1560 .help_str = "port config all max-pkt-len <value>",
1562 (void *)&cmd_config_max_pkt_len_port,
1563 (void *)&cmd_config_max_pkt_len_keyword,
1564 (void *)&cmd_config_max_pkt_len_all,
1565 (void *)&cmd_config_max_pkt_len_name,
1566 (void *)&cmd_config_max_pkt_len_value,
1571 /* *** configure port MTU *** */
1572 struct cmd_config_mtu_result {
1573 cmdline_fixed_string_t port;
1574 cmdline_fixed_string_t keyword;
1575 cmdline_fixed_string_t mtu;
1581 cmd_config_mtu_parsed(void *parsed_result,
1582 __attribute__((unused)) struct cmdline *cl,
1583 __attribute__((unused)) void *data)
1585 struct cmd_config_mtu_result *res = parsed_result;
1587 if (res->value < ETHER_MIN_LEN) {
1588 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1591 port_mtu_set(res->port_id, res->value);
1594 cmdline_parse_token_string_t cmd_config_mtu_port =
1595 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1597 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1598 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1600 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1601 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1603 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1604 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1605 cmdline_parse_token_num_t cmd_config_mtu_value =
1606 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1608 cmdline_parse_inst_t cmd_config_mtu = {
1609 .f = cmd_config_mtu_parsed,
1611 .help_str = "port config mtu <port_id> <value>",
1613 (void *)&cmd_config_mtu_port,
1614 (void *)&cmd_config_mtu_keyword,
1615 (void *)&cmd_config_mtu_mtu,
1616 (void *)&cmd_config_mtu_port_id,
1617 (void *)&cmd_config_mtu_value,
1622 /* *** configure rx mode *** */
1623 struct cmd_config_rx_mode_flag {
1624 cmdline_fixed_string_t port;
1625 cmdline_fixed_string_t keyword;
1626 cmdline_fixed_string_t all;
1627 cmdline_fixed_string_t name;
1628 cmdline_fixed_string_t value;
1632 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1633 __attribute__((unused)) struct cmdline *cl,
1634 __attribute__((unused)) void *data)
1636 struct cmd_config_rx_mode_flag *res = parsed_result;
1638 if (!all_ports_stopped()) {
1639 printf("Please stop all ports first\n");
1643 if (!strcmp(res->name, "crc-strip")) {
1644 if (!strcmp(res->value, "on"))
1645 rx_mode.hw_strip_crc = 1;
1646 else if (!strcmp(res->value, "off"))
1647 rx_mode.hw_strip_crc = 0;
1649 printf("Unknown parameter\n");
1652 } else if (!strcmp(res->name, "scatter")) {
1653 if (!strcmp(res->value, "on"))
1654 rx_mode.enable_scatter = 1;
1655 else if (!strcmp(res->value, "off"))
1656 rx_mode.enable_scatter = 0;
1658 printf("Unknown parameter\n");
1661 } else if (!strcmp(res->name, "rx-cksum")) {
1662 if (!strcmp(res->value, "on"))
1663 rx_mode.hw_ip_checksum = 1;
1664 else if (!strcmp(res->value, "off"))
1665 rx_mode.hw_ip_checksum = 0;
1667 printf("Unknown parameter\n");
1670 } else if (!strcmp(res->name, "rx-timestamp")) {
1671 if (!strcmp(res->value, "on"))
1672 rx_mode.hw_timestamp = 1;
1673 else if (!strcmp(res->value, "off"))
1674 rx_mode.hw_timestamp = 0;
1676 printf("Unknown parameter\n");
1679 } else if (!strcmp(res->name, "hw-vlan")) {
1680 if (!strcmp(res->value, "on")) {
1681 rx_mode.hw_vlan_filter = 1;
1682 rx_mode.hw_vlan_strip = 1;
1684 else if (!strcmp(res->value, "off")) {
1685 rx_mode.hw_vlan_filter = 0;
1686 rx_mode.hw_vlan_strip = 0;
1689 printf("Unknown parameter\n");
1692 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1693 if (!strcmp(res->value, "on"))
1694 rx_mode.hw_vlan_filter = 1;
1695 else if (!strcmp(res->value, "off"))
1696 rx_mode.hw_vlan_filter = 0;
1698 printf("Unknown parameter\n");
1701 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1702 if (!strcmp(res->value, "on"))
1703 rx_mode.hw_vlan_strip = 1;
1704 else if (!strcmp(res->value, "off"))
1705 rx_mode.hw_vlan_strip = 0;
1707 printf("Unknown parameter\n");
1710 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1711 if (!strcmp(res->value, "on"))
1712 rx_mode.hw_vlan_extend = 1;
1713 else if (!strcmp(res->value, "off"))
1714 rx_mode.hw_vlan_extend = 0;
1716 printf("Unknown parameter\n");
1719 } else if (!strcmp(res->name, "drop-en")) {
1720 if (!strcmp(res->value, "on"))
1722 else if (!strcmp(res->value, "off"))
1725 printf("Unknown parameter\n");
1729 printf("Unknown parameter\n");
1735 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1738 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1739 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1740 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1741 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1743 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1744 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1745 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1746 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1747 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1748 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1749 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1750 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1753 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1754 .f = cmd_config_rx_mode_flag_parsed,
1756 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1757 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1759 (void *)&cmd_config_rx_mode_flag_port,
1760 (void *)&cmd_config_rx_mode_flag_keyword,
1761 (void *)&cmd_config_rx_mode_flag_all,
1762 (void *)&cmd_config_rx_mode_flag_name,
1763 (void *)&cmd_config_rx_mode_flag_value,
1768 /* *** configure rss *** */
1769 struct cmd_config_rss {
1770 cmdline_fixed_string_t port;
1771 cmdline_fixed_string_t keyword;
1772 cmdline_fixed_string_t all;
1773 cmdline_fixed_string_t name;
1774 cmdline_fixed_string_t value;
1778 cmd_config_rss_parsed(void *parsed_result,
1779 __attribute__((unused)) struct cmdline *cl,
1780 __attribute__((unused)) void *data)
1782 struct cmd_config_rss *res = parsed_result;
1783 struct rte_eth_rss_conf rss_conf;
1787 if (!strcmp(res->value, "all"))
1788 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1789 ETH_RSS_UDP | ETH_RSS_SCTP |
1791 else if (!strcmp(res->value, "ip"))
1792 rss_conf.rss_hf = ETH_RSS_IP;
1793 else if (!strcmp(res->value, "udp"))
1794 rss_conf.rss_hf = ETH_RSS_UDP;
1795 else if (!strcmp(res->value, "tcp"))
1796 rss_conf.rss_hf = ETH_RSS_TCP;
1797 else if (!strcmp(res->value, "sctp"))
1798 rss_conf.rss_hf = ETH_RSS_SCTP;
1799 else if (!strcmp(res->value, "ether"))
1800 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1801 else if (!strcmp(res->value, "port"))
1802 rss_conf.rss_hf = ETH_RSS_PORT;
1803 else if (!strcmp(res->value, "vxlan"))
1804 rss_conf.rss_hf = ETH_RSS_VXLAN;
1805 else if (!strcmp(res->value, "geneve"))
1806 rss_conf.rss_hf = ETH_RSS_GENEVE;
1807 else if (!strcmp(res->value, "nvgre"))
1808 rss_conf.rss_hf = ETH_RSS_NVGRE;
1809 else if (!strcmp(res->value, "none"))
1810 rss_conf.rss_hf = 0;
1811 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1812 atoi(res->value) < 64)
1813 rss_conf.rss_hf = 1ULL << atoi(res->value);
1815 printf("Unknown parameter\n");
1818 rss_conf.rss_key = NULL;
1819 for (i = 0; i < rte_eth_dev_count(); i++) {
1820 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1822 printf("Configuration of RSS hash at ethernet port %d "
1823 "failed with error (%d): %s.\n",
1824 i, -diag, strerror(-diag));
1828 cmdline_parse_token_string_t cmd_config_rss_port =
1829 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1830 cmdline_parse_token_string_t cmd_config_rss_keyword =
1831 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1832 cmdline_parse_token_string_t cmd_config_rss_all =
1833 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1834 cmdline_parse_token_string_t cmd_config_rss_name =
1835 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1836 cmdline_parse_token_string_t cmd_config_rss_value =
1837 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1839 cmdline_parse_inst_t cmd_config_rss = {
1840 .f = cmd_config_rss_parsed,
1842 .help_str = "port config all rss "
1843 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1845 (void *)&cmd_config_rss_port,
1846 (void *)&cmd_config_rss_keyword,
1847 (void *)&cmd_config_rss_all,
1848 (void *)&cmd_config_rss_name,
1849 (void *)&cmd_config_rss_value,
1854 /* *** configure rss hash key *** */
1855 struct cmd_config_rss_hash_key {
1856 cmdline_fixed_string_t port;
1857 cmdline_fixed_string_t config;
1859 cmdline_fixed_string_t rss_hash_key;
1860 cmdline_fixed_string_t rss_type;
1861 cmdline_fixed_string_t key;
1865 hexa_digit_to_value(char hexa_digit)
1867 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1868 return (uint8_t) (hexa_digit - '0');
1869 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1870 return (uint8_t) ((hexa_digit - 'a') + 10);
1871 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1872 return (uint8_t) ((hexa_digit - 'A') + 10);
1873 /* Invalid hexa digit */
1878 parse_and_check_key_hexa_digit(char *key, int idx)
1882 hexa_v = hexa_digit_to_value(key[idx]);
1884 printf("invalid key: character %c at position %d is not a "
1885 "valid hexa digit\n", key[idx], idx);
1890 cmd_config_rss_hash_key_parsed(void *parsed_result,
1891 __attribute__((unused)) struct cmdline *cl,
1892 __attribute__((unused)) void *data)
1894 struct cmd_config_rss_hash_key *res = parsed_result;
1895 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1899 struct rte_eth_dev_info dev_info;
1900 uint8_t hash_key_size;
1903 memset(&dev_info, 0, sizeof(dev_info));
1904 rte_eth_dev_info_get(res->port_id, &dev_info);
1905 if (dev_info.hash_key_size > 0 &&
1906 dev_info.hash_key_size <= sizeof(hash_key))
1907 hash_key_size = dev_info.hash_key_size;
1909 printf("dev_info did not provide a valid hash key size\n");
1912 /* Check the length of the RSS hash key */
1913 key_len = strlen(res->key);
1914 if (key_len != (hash_key_size * 2)) {
1915 printf("key length: %d invalid - key must be a string of %d"
1916 " hexa-decimal numbers\n",
1917 (int) key_len, hash_key_size * 2);
1920 /* Translate RSS hash key into binary representation */
1921 for (i = 0; i < hash_key_size; i++) {
1922 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1925 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1928 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1930 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1934 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1935 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1936 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1937 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1939 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1940 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
1941 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1942 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1943 rss_hash_key, "rss-hash-key");
1944 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1945 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1946 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1947 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1948 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1949 "ipv6-tcp-ex#ipv6-udp-ex");
1950 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1951 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1953 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1954 .f = cmd_config_rss_hash_key_parsed,
1956 .help_str = "port config <port_id> rss-hash-key "
1957 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1958 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1959 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1960 "<string of hex digits (variable length, NIC dependent)>",
1962 (void *)&cmd_config_rss_hash_key_port,
1963 (void *)&cmd_config_rss_hash_key_config,
1964 (void *)&cmd_config_rss_hash_key_port_id,
1965 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1966 (void *)&cmd_config_rss_hash_key_rss_type,
1967 (void *)&cmd_config_rss_hash_key_value,
1972 /* *** configure port rxq/txq start/stop *** */
1973 struct cmd_config_rxtx_queue {
1974 cmdline_fixed_string_t port;
1976 cmdline_fixed_string_t rxtxq;
1978 cmdline_fixed_string_t opname;
1982 cmd_config_rxtx_queue_parsed(void *parsed_result,
1983 __attribute__((unused)) struct cmdline *cl,
1984 __attribute__((unused)) void *data)
1986 struct cmd_config_rxtx_queue *res = parsed_result;
1991 if (test_done == 0) {
1992 printf("Please stop forwarding first\n");
1996 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1999 if (port_is_started(res->portid) != 1) {
2000 printf("Please start port %u first\n", res->portid);
2004 if (!strcmp(res->rxtxq, "rxq"))
2006 else if (!strcmp(res->rxtxq, "txq"))
2009 printf("Unknown parameter\n");
2013 if (isrx && rx_queue_id_is_invalid(res->qid))
2015 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2018 if (!strcmp(res->opname, "start"))
2020 else if (!strcmp(res->opname, "stop"))
2023 printf("Unknown parameter\n");
2027 if (isstart && isrx)
2028 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2029 else if (!isstart && isrx)
2030 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2031 else if (isstart && !isrx)
2032 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2034 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2036 if (ret == -ENOTSUP)
2037 printf("Function not supported in PMD driver\n");
2040 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2041 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2042 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2043 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2044 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2045 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2046 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2047 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2048 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2049 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2052 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2053 .f = cmd_config_rxtx_queue_parsed,
2055 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2057 (void *)&cmd_config_speed_all_port,
2058 (void *)&cmd_config_rxtx_queue_portid,
2059 (void *)&cmd_config_rxtx_queue_rxtxq,
2060 (void *)&cmd_config_rxtx_queue_qid,
2061 (void *)&cmd_config_rxtx_queue_opname,
2066 /* *** Configure RSS RETA *** */
2067 struct cmd_config_rss_reta {
2068 cmdline_fixed_string_t port;
2069 cmdline_fixed_string_t keyword;
2071 cmdline_fixed_string_t name;
2072 cmdline_fixed_string_t list_name;
2073 cmdline_fixed_string_t list_of_items;
2077 parse_reta_config(const char *str,
2078 struct rte_eth_rss_reta_entry64 *reta_conf,
2079 uint16_t nb_entries)
2083 uint16_t hash_index, idx, shift;
2086 const char *p, *p0 = str;
2093 unsigned long int_fld[_NUM_FLD];
2094 char *str_fld[_NUM_FLD];
2096 while ((p = strchr(p0,'(')) != NULL) {
2098 if((p0 = strchr(p,')')) == NULL)
2102 if(size >= sizeof(s))
2105 snprintf(s, sizeof(s), "%.*s", size, p);
2106 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2108 for (i = 0; i < _NUM_FLD; i++) {
2110 int_fld[i] = strtoul(str_fld[i], &end, 0);
2111 if (errno != 0 || end == str_fld[i] ||
2116 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2117 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2119 if (hash_index >= nb_entries) {
2120 printf("Invalid RETA hash index=%d\n", hash_index);
2124 idx = hash_index / RTE_RETA_GROUP_SIZE;
2125 shift = hash_index % RTE_RETA_GROUP_SIZE;
2126 reta_conf[idx].mask |= (1ULL << shift);
2127 reta_conf[idx].reta[shift] = nb_queue;
2134 cmd_set_rss_reta_parsed(void *parsed_result,
2135 __attribute__((unused)) struct cmdline *cl,
2136 __attribute__((unused)) void *data)
2139 struct rte_eth_dev_info dev_info;
2140 struct rte_eth_rss_reta_entry64 reta_conf[8];
2141 struct cmd_config_rss_reta *res = parsed_result;
2143 memset(&dev_info, 0, sizeof(dev_info));
2144 rte_eth_dev_info_get(res->port_id, &dev_info);
2145 if (dev_info.reta_size == 0) {
2146 printf("Redirection table size is 0 which is "
2147 "invalid for RSS\n");
2150 printf("The reta size of port %d is %u\n",
2151 res->port_id, dev_info.reta_size);
2152 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2153 printf("Currently do not support more than %u entries of "
2154 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2158 memset(reta_conf, 0, sizeof(reta_conf));
2159 if (!strcmp(res->list_name, "reta")) {
2160 if (parse_reta_config(res->list_of_items, reta_conf,
2161 dev_info.reta_size)) {
2162 printf("Invalid RSS Redirection Table "
2163 "config entered\n");
2166 ret = rte_eth_dev_rss_reta_update(res->port_id,
2167 reta_conf, dev_info.reta_size);
2169 printf("Bad redirection table parameter, "
2170 "return code = %d \n", ret);
2174 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2175 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2176 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2177 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2178 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2179 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2180 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2181 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2182 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2183 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2184 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2185 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2187 cmdline_parse_inst_t cmd_config_rss_reta = {
2188 .f = cmd_set_rss_reta_parsed,
2190 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2192 (void *)&cmd_config_rss_reta_port,
2193 (void *)&cmd_config_rss_reta_keyword,
2194 (void *)&cmd_config_rss_reta_port_id,
2195 (void *)&cmd_config_rss_reta_name,
2196 (void *)&cmd_config_rss_reta_list_name,
2197 (void *)&cmd_config_rss_reta_list_of_items,
2202 /* *** SHOW PORT RETA INFO *** */
2203 struct cmd_showport_reta {
2204 cmdline_fixed_string_t show;
2205 cmdline_fixed_string_t port;
2207 cmdline_fixed_string_t rss;
2208 cmdline_fixed_string_t reta;
2210 cmdline_fixed_string_t list_of_items;
2214 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2215 uint16_t nb_entries,
2219 const char *p, *p0 = str;
2224 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2225 RTE_RETA_GROUP_SIZE;
2228 p = strchr(p0, '(');
2232 p0 = strchr(p, ')');
2236 if (size >= sizeof(s)) {
2237 printf("The string size exceeds the internal buffer size\n");
2240 snprintf(s, sizeof(s), "%.*s", size, p);
2241 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2242 if (ret <= 0 || ret != num) {
2243 printf("The bits of masks do not match the number of "
2244 "reta entries: %u\n", num);
2247 for (i = 0; i < ret; i++)
2248 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2254 cmd_showport_reta_parsed(void *parsed_result,
2255 __attribute__((unused)) struct cmdline *cl,
2256 __attribute__((unused)) void *data)
2258 struct cmd_showport_reta *res = parsed_result;
2259 struct rte_eth_rss_reta_entry64 reta_conf[8];
2260 struct rte_eth_dev_info dev_info;
2261 uint16_t max_reta_size;
2263 memset(&dev_info, 0, sizeof(dev_info));
2264 rte_eth_dev_info_get(res->port_id, &dev_info);
2265 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2266 if (res->size == 0 || res->size > max_reta_size) {
2267 printf("Invalid redirection table size: %u (1-%u)\n",
2268 res->size, max_reta_size);
2272 memset(reta_conf, 0, sizeof(reta_conf));
2273 if (showport_parse_reta_config(reta_conf, res->size,
2274 res->list_of_items) < 0) {
2275 printf("Invalid string: %s for reta masks\n",
2276 res->list_of_items);
2279 port_rss_reta_info(res->port_id, reta_conf, res->size);
2282 cmdline_parse_token_string_t cmd_showport_reta_show =
2283 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2284 cmdline_parse_token_string_t cmd_showport_reta_port =
2285 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2286 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2287 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2288 cmdline_parse_token_string_t cmd_showport_reta_rss =
2289 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2290 cmdline_parse_token_string_t cmd_showport_reta_reta =
2291 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2292 cmdline_parse_token_num_t cmd_showport_reta_size =
2293 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2294 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2295 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2296 list_of_items, NULL);
2298 cmdline_parse_inst_t cmd_showport_reta = {
2299 .f = cmd_showport_reta_parsed,
2301 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2303 (void *)&cmd_showport_reta_show,
2304 (void *)&cmd_showport_reta_port,
2305 (void *)&cmd_showport_reta_port_id,
2306 (void *)&cmd_showport_reta_rss,
2307 (void *)&cmd_showport_reta_reta,
2308 (void *)&cmd_showport_reta_size,
2309 (void *)&cmd_showport_reta_list_of_items,
2314 /* *** Show RSS hash configuration *** */
2315 struct cmd_showport_rss_hash {
2316 cmdline_fixed_string_t show;
2317 cmdline_fixed_string_t port;
2319 cmdline_fixed_string_t rss_hash;
2320 cmdline_fixed_string_t rss_type;
2321 cmdline_fixed_string_t key; /* optional argument */
2324 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2325 __attribute__((unused)) struct cmdline *cl,
2328 struct cmd_showport_rss_hash *res = parsed_result;
2330 port_rss_hash_conf_show(res->port_id, res->rss_type,
2331 show_rss_key != NULL);
2334 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2335 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2336 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2337 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2338 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2339 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2340 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2341 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2343 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2344 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2345 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2346 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2347 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2348 "ipv6-tcp-ex#ipv6-udp-ex");
2349 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2350 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2352 cmdline_parse_inst_t cmd_showport_rss_hash = {
2353 .f = cmd_showport_rss_hash_parsed,
2355 .help_str = "show port <port_id> rss-hash "
2356 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2357 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2358 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2360 (void *)&cmd_showport_rss_hash_show,
2361 (void *)&cmd_showport_rss_hash_port,
2362 (void *)&cmd_showport_rss_hash_port_id,
2363 (void *)&cmd_showport_rss_hash_rss_hash,
2364 (void *)&cmd_showport_rss_hash_rss_hash_info,
2369 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2370 .f = cmd_showport_rss_hash_parsed,
2372 .help_str = "show port <port_id> rss-hash "
2373 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2374 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2375 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2377 (void *)&cmd_showport_rss_hash_show,
2378 (void *)&cmd_showport_rss_hash_port,
2379 (void *)&cmd_showport_rss_hash_port_id,
2380 (void *)&cmd_showport_rss_hash_rss_hash,
2381 (void *)&cmd_showport_rss_hash_rss_hash_info,
2382 (void *)&cmd_showport_rss_hash_rss_key,
2387 /* *** Configure DCB *** */
2388 struct cmd_config_dcb {
2389 cmdline_fixed_string_t port;
2390 cmdline_fixed_string_t config;
2392 cmdline_fixed_string_t dcb;
2393 cmdline_fixed_string_t vt;
2394 cmdline_fixed_string_t vt_en;
2396 cmdline_fixed_string_t pfc;
2397 cmdline_fixed_string_t pfc_en;
2401 cmd_config_dcb_parsed(void *parsed_result,
2402 __attribute__((unused)) struct cmdline *cl,
2403 __attribute__((unused)) void *data)
2405 struct cmd_config_dcb *res = parsed_result;
2406 portid_t port_id = res->port_id;
2407 struct rte_port *port;
2411 port = &ports[port_id];
2412 /** Check if the port is not started **/
2413 if (port->port_status != RTE_PORT_STOPPED) {
2414 printf("Please stop port %d first\n", port_id);
2418 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2419 printf("The invalid number of traffic class,"
2420 " only 4 or 8 allowed.\n");
2424 if (nb_fwd_lcores < res->num_tcs) {
2425 printf("nb_cores shouldn't be less than number of TCs.\n");
2428 if (!strncmp(res->pfc_en, "on", 2))
2433 /* DCB in VT mode */
2434 if (!strncmp(res->vt_en, "on", 2))
2435 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2436 (enum rte_eth_nb_tcs)res->num_tcs,
2439 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2440 (enum rte_eth_nb_tcs)res->num_tcs,
2445 printf("Cannot initialize network ports.\n");
2449 cmd_reconfig_device_queue(port_id, 1, 1);
2452 cmdline_parse_token_string_t cmd_config_dcb_port =
2453 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2454 cmdline_parse_token_string_t cmd_config_dcb_config =
2455 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2456 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2457 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2458 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2459 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2460 cmdline_parse_token_string_t cmd_config_dcb_vt =
2461 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2462 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2463 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2464 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2465 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2466 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2467 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2468 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2469 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2471 cmdline_parse_inst_t cmd_config_dcb = {
2472 .f = cmd_config_dcb_parsed,
2474 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2476 (void *)&cmd_config_dcb_port,
2477 (void *)&cmd_config_dcb_config,
2478 (void *)&cmd_config_dcb_port_id,
2479 (void *)&cmd_config_dcb_dcb,
2480 (void *)&cmd_config_dcb_vt,
2481 (void *)&cmd_config_dcb_vt_en,
2482 (void *)&cmd_config_dcb_num_tcs,
2483 (void *)&cmd_config_dcb_pfc,
2484 (void *)&cmd_config_dcb_pfc_en,
2489 /* *** configure number of packets per burst *** */
2490 struct cmd_config_burst {
2491 cmdline_fixed_string_t port;
2492 cmdline_fixed_string_t keyword;
2493 cmdline_fixed_string_t all;
2494 cmdline_fixed_string_t name;
2499 cmd_config_burst_parsed(void *parsed_result,
2500 __attribute__((unused)) struct cmdline *cl,
2501 __attribute__((unused)) void *data)
2503 struct cmd_config_burst *res = parsed_result;
2505 if (!all_ports_stopped()) {
2506 printf("Please stop all ports first\n");
2510 if (!strcmp(res->name, "burst")) {
2511 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2512 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2515 nb_pkt_per_burst = res->value;
2517 printf("Unknown parameter\n");
2523 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2526 cmdline_parse_token_string_t cmd_config_burst_port =
2527 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2528 cmdline_parse_token_string_t cmd_config_burst_keyword =
2529 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2530 cmdline_parse_token_string_t cmd_config_burst_all =
2531 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2532 cmdline_parse_token_string_t cmd_config_burst_name =
2533 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2534 cmdline_parse_token_num_t cmd_config_burst_value =
2535 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2537 cmdline_parse_inst_t cmd_config_burst = {
2538 .f = cmd_config_burst_parsed,
2540 .help_str = "port config all burst <value>",
2542 (void *)&cmd_config_burst_port,
2543 (void *)&cmd_config_burst_keyword,
2544 (void *)&cmd_config_burst_all,
2545 (void *)&cmd_config_burst_name,
2546 (void *)&cmd_config_burst_value,
2551 /* *** configure rx/tx queues *** */
2552 struct cmd_config_thresh {
2553 cmdline_fixed_string_t port;
2554 cmdline_fixed_string_t keyword;
2555 cmdline_fixed_string_t all;
2556 cmdline_fixed_string_t name;
2561 cmd_config_thresh_parsed(void *parsed_result,
2562 __attribute__((unused)) struct cmdline *cl,
2563 __attribute__((unused)) void *data)
2565 struct cmd_config_thresh *res = parsed_result;
2567 if (!all_ports_stopped()) {
2568 printf("Please stop all ports first\n");
2572 if (!strcmp(res->name, "txpt"))
2573 tx_pthresh = res->value;
2574 else if(!strcmp(res->name, "txht"))
2575 tx_hthresh = res->value;
2576 else if(!strcmp(res->name, "txwt"))
2577 tx_wthresh = res->value;
2578 else if(!strcmp(res->name, "rxpt"))
2579 rx_pthresh = res->value;
2580 else if(!strcmp(res->name, "rxht"))
2581 rx_hthresh = res->value;
2582 else if(!strcmp(res->name, "rxwt"))
2583 rx_wthresh = res->value;
2585 printf("Unknown parameter\n");
2591 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2594 cmdline_parse_token_string_t cmd_config_thresh_port =
2595 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2596 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2597 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2598 cmdline_parse_token_string_t cmd_config_thresh_all =
2599 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2600 cmdline_parse_token_string_t cmd_config_thresh_name =
2601 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2602 "txpt#txht#txwt#rxpt#rxht#rxwt");
2603 cmdline_parse_token_num_t cmd_config_thresh_value =
2604 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2606 cmdline_parse_inst_t cmd_config_thresh = {
2607 .f = cmd_config_thresh_parsed,
2609 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2611 (void *)&cmd_config_thresh_port,
2612 (void *)&cmd_config_thresh_keyword,
2613 (void *)&cmd_config_thresh_all,
2614 (void *)&cmd_config_thresh_name,
2615 (void *)&cmd_config_thresh_value,
2620 /* *** configure free/rs threshold *** */
2621 struct cmd_config_threshold {
2622 cmdline_fixed_string_t port;
2623 cmdline_fixed_string_t keyword;
2624 cmdline_fixed_string_t all;
2625 cmdline_fixed_string_t name;
2630 cmd_config_threshold_parsed(void *parsed_result,
2631 __attribute__((unused)) struct cmdline *cl,
2632 __attribute__((unused)) void *data)
2634 struct cmd_config_threshold *res = parsed_result;
2636 if (!all_ports_stopped()) {
2637 printf("Please stop all ports first\n");
2641 if (!strcmp(res->name, "txfreet"))
2642 tx_free_thresh = res->value;
2643 else if (!strcmp(res->name, "txrst"))
2644 tx_rs_thresh = res->value;
2645 else if (!strcmp(res->name, "rxfreet"))
2646 rx_free_thresh = res->value;
2648 printf("Unknown parameter\n");
2654 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2657 cmdline_parse_token_string_t cmd_config_threshold_port =
2658 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2659 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2660 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2662 cmdline_parse_token_string_t cmd_config_threshold_all =
2663 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2664 cmdline_parse_token_string_t cmd_config_threshold_name =
2665 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2666 "txfreet#txrst#rxfreet");
2667 cmdline_parse_token_num_t cmd_config_threshold_value =
2668 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2670 cmdline_parse_inst_t cmd_config_threshold = {
2671 .f = cmd_config_threshold_parsed,
2673 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2675 (void *)&cmd_config_threshold_port,
2676 (void *)&cmd_config_threshold_keyword,
2677 (void *)&cmd_config_threshold_all,
2678 (void *)&cmd_config_threshold_name,
2679 (void *)&cmd_config_threshold_value,
2685 struct cmd_stop_result {
2686 cmdline_fixed_string_t stop;
2689 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2690 __attribute__((unused)) struct cmdline *cl,
2691 __attribute__((unused)) void *data)
2693 stop_packet_forwarding();
2696 cmdline_parse_token_string_t cmd_stop_stop =
2697 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2699 cmdline_parse_inst_t cmd_stop = {
2700 .f = cmd_stop_parsed,
2702 .help_str = "stop: Stop packet forwarding",
2704 (void *)&cmd_stop_stop,
2709 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2712 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2713 unsigned int *parsed_items, int check_unique_values)
2715 unsigned int nb_item;
2723 * First parse all items in the list and store their value.
2728 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2730 if ((c >= '0') && (c <= '9')) {
2731 value = (unsigned int) (value * 10 + (c - '0'));
2736 printf("character %c is not a decimal digit\n", c);
2740 printf("No valid value before comma\n");
2743 if (nb_item < max_items) {
2744 parsed_items[nb_item] = value;
2750 if (nb_item >= max_items) {
2751 printf("Number of %s = %u > %u (maximum items)\n",
2752 item_name, nb_item + 1, max_items);
2755 parsed_items[nb_item++] = value;
2756 if (! check_unique_values)
2760 * Then, check that all values in the list are differents.
2761 * No optimization here...
2763 for (i = 0; i < nb_item; i++) {
2764 for (j = i + 1; j < nb_item; j++) {
2765 if (parsed_items[j] == parsed_items[i]) {
2766 printf("duplicated %s %u at index %u and %u\n",
2767 item_name, parsed_items[i], i, j);
2775 struct cmd_set_list_result {
2776 cmdline_fixed_string_t cmd_keyword;
2777 cmdline_fixed_string_t list_name;
2778 cmdline_fixed_string_t list_of_items;
2781 static void cmd_set_list_parsed(void *parsed_result,
2782 __attribute__((unused)) struct cmdline *cl,
2783 __attribute__((unused)) void *data)
2785 struct cmd_set_list_result *res;
2787 unsigned int lcorelist[RTE_MAX_LCORE];
2788 unsigned int portlist[RTE_MAX_ETHPORTS];
2790 unsigned int nb_item;
2792 if (test_done == 0) {
2793 printf("Please stop forwarding first\n");
2797 res = parsed_result;
2798 if (!strcmp(res->list_name, "corelist")) {
2799 nb_item = parse_item_list(res->list_of_items, "core",
2801 parsed_items.lcorelist, 1);
2803 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2808 if (!strcmp(res->list_name, "portlist")) {
2809 nb_item = parse_item_list(res->list_of_items, "port",
2811 parsed_items.portlist, 1);
2813 set_fwd_ports_list(parsed_items.portlist, nb_item);
2819 cmdline_parse_token_string_t cmd_set_list_keyword =
2820 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2822 cmdline_parse_token_string_t cmd_set_list_name =
2823 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2824 "corelist#portlist");
2825 cmdline_parse_token_string_t cmd_set_list_of_items =
2826 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2829 cmdline_parse_inst_t cmd_set_fwd_list = {
2830 .f = cmd_set_list_parsed,
2832 .help_str = "set corelist|portlist <list0[,list1]*>",
2834 (void *)&cmd_set_list_keyword,
2835 (void *)&cmd_set_list_name,
2836 (void *)&cmd_set_list_of_items,
2841 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2843 struct cmd_setmask_result {
2844 cmdline_fixed_string_t set;
2845 cmdline_fixed_string_t mask;
2849 static void cmd_set_mask_parsed(void *parsed_result,
2850 __attribute__((unused)) struct cmdline *cl,
2851 __attribute__((unused)) void *data)
2853 struct cmd_setmask_result *res = parsed_result;
2855 if (test_done == 0) {
2856 printf("Please stop forwarding first\n");
2859 if (!strcmp(res->mask, "coremask")) {
2860 set_fwd_lcores_mask(res->hexavalue);
2862 } else if (!strcmp(res->mask, "portmask")) {
2863 set_fwd_ports_mask(res->hexavalue);
2868 cmdline_parse_token_string_t cmd_setmask_set =
2869 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2870 cmdline_parse_token_string_t cmd_setmask_mask =
2871 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2872 "coremask#portmask");
2873 cmdline_parse_token_num_t cmd_setmask_value =
2874 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2876 cmdline_parse_inst_t cmd_set_fwd_mask = {
2877 .f = cmd_set_mask_parsed,
2879 .help_str = "set coremask|portmask <hexadecimal value>",
2881 (void *)&cmd_setmask_set,
2882 (void *)&cmd_setmask_mask,
2883 (void *)&cmd_setmask_value,
2889 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2891 struct cmd_set_result {
2892 cmdline_fixed_string_t set;
2893 cmdline_fixed_string_t what;
2897 static void cmd_set_parsed(void *parsed_result,
2898 __attribute__((unused)) struct cmdline *cl,
2899 __attribute__((unused)) void *data)
2901 struct cmd_set_result *res = parsed_result;
2902 if (!strcmp(res->what, "nbport")) {
2903 set_fwd_ports_number(res->value);
2905 } else if (!strcmp(res->what, "nbcore")) {
2906 set_fwd_lcores_number(res->value);
2908 } else if (!strcmp(res->what, "burst"))
2909 set_nb_pkt_per_burst(res->value);
2910 else if (!strcmp(res->what, "verbose"))
2911 set_verbose_level(res->value);
2914 cmdline_parse_token_string_t cmd_set_set =
2915 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2916 cmdline_parse_token_string_t cmd_set_what =
2917 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2918 "nbport#nbcore#burst#verbose");
2919 cmdline_parse_token_num_t cmd_set_value =
2920 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2922 cmdline_parse_inst_t cmd_set_numbers = {
2923 .f = cmd_set_parsed,
2925 .help_str = "set nbport|nbcore|burst|verbose <value>",
2927 (void *)&cmd_set_set,
2928 (void *)&cmd_set_what,
2929 (void *)&cmd_set_value,
2934 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2936 struct cmd_set_txpkts_result {
2937 cmdline_fixed_string_t cmd_keyword;
2938 cmdline_fixed_string_t txpkts;
2939 cmdline_fixed_string_t seg_lengths;
2943 cmd_set_txpkts_parsed(void *parsed_result,
2944 __attribute__((unused)) struct cmdline *cl,
2945 __attribute__((unused)) void *data)
2947 struct cmd_set_txpkts_result *res;
2948 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2949 unsigned int nb_segs;
2951 res = parsed_result;
2952 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2953 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2955 set_tx_pkt_segments(seg_lengths, nb_segs);
2958 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2959 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2960 cmd_keyword, "set");
2961 cmdline_parse_token_string_t cmd_set_txpkts_name =
2962 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2964 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2965 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2968 cmdline_parse_inst_t cmd_set_txpkts = {
2969 .f = cmd_set_txpkts_parsed,
2971 .help_str = "set txpkts <len0[,len1]*>",
2973 (void *)&cmd_set_txpkts_keyword,
2974 (void *)&cmd_set_txpkts_name,
2975 (void *)&cmd_set_txpkts_lengths,
2980 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2982 struct cmd_set_txsplit_result {
2983 cmdline_fixed_string_t cmd_keyword;
2984 cmdline_fixed_string_t txsplit;
2985 cmdline_fixed_string_t mode;
2989 cmd_set_txsplit_parsed(void *parsed_result,
2990 __attribute__((unused)) struct cmdline *cl,
2991 __attribute__((unused)) void *data)
2993 struct cmd_set_txsplit_result *res;
2995 res = parsed_result;
2996 set_tx_pkt_split(res->mode);
2999 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3000 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3001 cmd_keyword, "set");
3002 cmdline_parse_token_string_t cmd_set_txsplit_name =
3003 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3004 txsplit, "txsplit");
3005 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3006 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3009 cmdline_parse_inst_t cmd_set_txsplit = {
3010 .f = cmd_set_txsplit_parsed,
3012 .help_str = "set txsplit on|off|rand",
3014 (void *)&cmd_set_txsplit_keyword,
3015 (void *)&cmd_set_txsplit_name,
3016 (void *)&cmd_set_txsplit_mode,
3021 /* *** CONFIG TX QUEUE FLAGS *** */
3023 struct cmd_config_txqflags_result {
3024 cmdline_fixed_string_t port;
3025 cmdline_fixed_string_t config;
3026 cmdline_fixed_string_t all;
3027 cmdline_fixed_string_t what;
3031 static void cmd_config_txqflags_parsed(void *parsed_result,
3032 __attribute__((unused)) struct cmdline *cl,
3033 __attribute__((unused)) void *data)
3035 struct cmd_config_txqflags_result *res = parsed_result;
3037 if (!all_ports_stopped()) {
3038 printf("Please stop all ports first\n");
3042 if (strcmp(res->what, "txqflags")) {
3043 printf("Unknown parameter\n");
3047 if (res->hexvalue >= 0) {
3048 txq_flags = res->hexvalue;
3050 printf("txqflags must be >= 0\n");
3056 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3059 cmdline_parse_token_string_t cmd_config_txqflags_port =
3060 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
3062 cmdline_parse_token_string_t cmd_config_txqflags_config =
3063 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
3065 cmdline_parse_token_string_t cmd_config_txqflags_all =
3066 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
3068 cmdline_parse_token_string_t cmd_config_txqflags_what =
3069 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
3071 cmdline_parse_token_num_t cmd_config_txqflags_value =
3072 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
3075 cmdline_parse_inst_t cmd_config_txqflags = {
3076 .f = cmd_config_txqflags_parsed,
3078 .help_str = "port config all txqflags <value>",
3080 (void *)&cmd_config_txqflags_port,
3081 (void *)&cmd_config_txqflags_config,
3082 (void *)&cmd_config_txqflags_all,
3083 (void *)&cmd_config_txqflags_what,
3084 (void *)&cmd_config_txqflags_value,
3089 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3090 struct cmd_rx_vlan_filter_all_result {
3091 cmdline_fixed_string_t rx_vlan;
3092 cmdline_fixed_string_t what;
3093 cmdline_fixed_string_t all;
3098 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3099 __attribute__((unused)) struct cmdline *cl,
3100 __attribute__((unused)) void *data)
3102 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3104 if (!strcmp(res->what, "add"))
3105 rx_vlan_all_filter_set(res->port_id, 1);
3107 rx_vlan_all_filter_set(res->port_id, 0);
3110 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3111 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3112 rx_vlan, "rx_vlan");
3113 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3114 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3116 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3117 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3119 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3120 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3123 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3124 .f = cmd_rx_vlan_filter_all_parsed,
3126 .help_str = "rx_vlan add|rm all <port_id>: "
3127 "Add/Remove all identifiers to/from the set of VLAN "
3128 "identifiers filtered by a port",
3130 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3131 (void *)&cmd_rx_vlan_filter_all_what,
3132 (void *)&cmd_rx_vlan_filter_all_all,
3133 (void *)&cmd_rx_vlan_filter_all_portid,
3138 /* *** VLAN OFFLOAD SET ON A PORT *** */
3139 struct cmd_vlan_offload_result {
3140 cmdline_fixed_string_t vlan;
3141 cmdline_fixed_string_t set;
3142 cmdline_fixed_string_t vlan_type;
3143 cmdline_fixed_string_t what;
3144 cmdline_fixed_string_t on;
3145 cmdline_fixed_string_t port_id;
3149 cmd_vlan_offload_parsed(void *parsed_result,
3150 __attribute__((unused)) struct cmdline *cl,
3151 __attribute__((unused)) void *data)
3154 struct cmd_vlan_offload_result *res = parsed_result;
3157 portid_t port_id = 0;
3161 len = strnlen(str, STR_TOKEN_SIZE);
3163 /* Get port_id first */
3171 tmp = strtoul(str, NULL, 0);
3172 /* If port_id greater that what portid_t can represent, return */
3173 if(tmp >= RTE_MAX_ETHPORTS)
3175 port_id = (portid_t)tmp;
3177 if (!strcmp(res->on, "on"))
3182 if (!strcmp(res->what, "strip"))
3183 rx_vlan_strip_set(port_id, on);
3184 else if(!strcmp(res->what, "stripq")){
3185 uint16_t queue_id = 0;
3187 /* No queue_id, return */
3189 printf("must specify (port,queue_id)\n");
3192 tmp = strtoul(str + i + 1, NULL, 0);
3193 /* If queue_id greater that what 16-bits can represent, return */
3197 queue_id = (uint16_t)tmp;
3198 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3200 else if (!strcmp(res->what, "filter"))
3201 rx_vlan_filter_set(port_id, on);
3203 vlan_extend_set(port_id, on);
3208 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3209 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3211 cmdline_parse_token_string_t cmd_vlan_offload_set =
3212 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3214 cmdline_parse_token_string_t cmd_vlan_offload_what =
3215 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3216 what, "strip#filter#qinq#stripq");
3217 cmdline_parse_token_string_t cmd_vlan_offload_on =
3218 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3220 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3221 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3224 cmdline_parse_inst_t cmd_vlan_offload = {
3225 .f = cmd_vlan_offload_parsed,
3227 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3228 "<port_id[,queue_id]>: "
3229 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3231 (void *)&cmd_vlan_offload_vlan,
3232 (void *)&cmd_vlan_offload_set,
3233 (void *)&cmd_vlan_offload_what,
3234 (void *)&cmd_vlan_offload_on,
3235 (void *)&cmd_vlan_offload_portid,
3240 /* *** VLAN TPID SET ON A PORT *** */
3241 struct cmd_vlan_tpid_result {
3242 cmdline_fixed_string_t vlan;
3243 cmdline_fixed_string_t set;
3244 cmdline_fixed_string_t vlan_type;
3245 cmdline_fixed_string_t what;
3251 cmd_vlan_tpid_parsed(void *parsed_result,
3252 __attribute__((unused)) struct cmdline *cl,
3253 __attribute__((unused)) void *data)
3255 struct cmd_vlan_tpid_result *res = parsed_result;
3256 enum rte_vlan_type vlan_type;
3258 if (!strcmp(res->vlan_type, "inner"))
3259 vlan_type = ETH_VLAN_TYPE_INNER;
3260 else if (!strcmp(res->vlan_type, "outer"))
3261 vlan_type = ETH_VLAN_TYPE_OUTER;
3263 printf("Unknown vlan type\n");
3266 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3269 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3270 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3272 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3273 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3275 cmdline_parse_token_string_t cmd_vlan_type =
3276 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3277 vlan_type, "inner#outer");
3278 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3279 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3281 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3282 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3284 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3285 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3288 cmdline_parse_inst_t cmd_vlan_tpid = {
3289 .f = cmd_vlan_tpid_parsed,
3291 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3292 "Set the VLAN Ether type",
3294 (void *)&cmd_vlan_tpid_vlan,
3295 (void *)&cmd_vlan_tpid_set,
3296 (void *)&cmd_vlan_type,
3297 (void *)&cmd_vlan_tpid_what,
3298 (void *)&cmd_vlan_tpid_tpid,
3299 (void *)&cmd_vlan_tpid_portid,
3304 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3305 struct cmd_rx_vlan_filter_result {
3306 cmdline_fixed_string_t rx_vlan;
3307 cmdline_fixed_string_t what;
3313 cmd_rx_vlan_filter_parsed(void *parsed_result,
3314 __attribute__((unused)) struct cmdline *cl,
3315 __attribute__((unused)) void *data)
3317 struct cmd_rx_vlan_filter_result *res = parsed_result;
3319 if (!strcmp(res->what, "add"))
3320 rx_vft_set(res->port_id, res->vlan_id, 1);
3322 rx_vft_set(res->port_id, res->vlan_id, 0);
3325 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3326 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3327 rx_vlan, "rx_vlan");
3328 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3329 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3331 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3332 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3334 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3335 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3338 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3339 .f = cmd_rx_vlan_filter_parsed,
3341 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3342 "Add/Remove a VLAN identifier to/from the set of VLAN "
3343 "identifiers filtered by a port",
3345 (void *)&cmd_rx_vlan_filter_rx_vlan,
3346 (void *)&cmd_rx_vlan_filter_what,
3347 (void *)&cmd_rx_vlan_filter_vlanid,
3348 (void *)&cmd_rx_vlan_filter_portid,
3353 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3354 struct cmd_tx_vlan_set_result {
3355 cmdline_fixed_string_t tx_vlan;
3356 cmdline_fixed_string_t set;
3362 cmd_tx_vlan_set_parsed(void *parsed_result,
3363 __attribute__((unused)) struct cmdline *cl,
3364 __attribute__((unused)) void *data)
3366 struct cmd_tx_vlan_set_result *res = parsed_result;
3368 tx_vlan_set(res->port_id, res->vlan_id);
3371 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3372 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3373 tx_vlan, "tx_vlan");
3374 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3375 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3377 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3378 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3380 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3381 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3384 cmdline_parse_inst_t cmd_tx_vlan_set = {
3385 .f = cmd_tx_vlan_set_parsed,
3387 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3388 "Enable hardware insertion of a single VLAN header "
3389 "with a given TAG Identifier in packets sent on a port",
3391 (void *)&cmd_tx_vlan_set_tx_vlan,
3392 (void *)&cmd_tx_vlan_set_set,
3393 (void *)&cmd_tx_vlan_set_portid,
3394 (void *)&cmd_tx_vlan_set_vlanid,
3399 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3400 struct cmd_tx_vlan_set_qinq_result {
3401 cmdline_fixed_string_t tx_vlan;
3402 cmdline_fixed_string_t set;
3405 uint16_t vlan_id_outer;
3409 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3410 __attribute__((unused)) struct cmdline *cl,
3411 __attribute__((unused)) void *data)
3413 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3415 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3418 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3419 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3420 tx_vlan, "tx_vlan");
3421 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3422 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3424 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3425 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3427 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3428 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3430 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3431 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3432 vlan_id_outer, UINT16);
3434 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3435 .f = cmd_tx_vlan_set_qinq_parsed,
3437 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3438 "Enable hardware insertion of double VLAN header "
3439 "with given TAG Identifiers in packets sent on a port",
3441 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3442 (void *)&cmd_tx_vlan_set_qinq_set,
3443 (void *)&cmd_tx_vlan_set_qinq_portid,
3444 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3445 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3450 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3451 struct cmd_tx_vlan_set_pvid_result {
3452 cmdline_fixed_string_t tx_vlan;
3453 cmdline_fixed_string_t set;
3454 cmdline_fixed_string_t pvid;
3457 cmdline_fixed_string_t mode;
3461 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3462 __attribute__((unused)) struct cmdline *cl,
3463 __attribute__((unused)) void *data)
3465 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3467 if (strcmp(res->mode, "on") == 0)
3468 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3470 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3473 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3474 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3475 tx_vlan, "tx_vlan");
3476 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3477 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3479 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3480 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3482 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3483 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3485 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3486 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3488 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3489 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3492 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3493 .f = cmd_tx_vlan_set_pvid_parsed,
3495 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3497 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3498 (void *)&cmd_tx_vlan_set_pvid_set,
3499 (void *)&cmd_tx_vlan_set_pvid_pvid,
3500 (void *)&cmd_tx_vlan_set_pvid_port_id,
3501 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3502 (void *)&cmd_tx_vlan_set_pvid_mode,
3507 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3508 struct cmd_tx_vlan_reset_result {
3509 cmdline_fixed_string_t tx_vlan;
3510 cmdline_fixed_string_t reset;
3515 cmd_tx_vlan_reset_parsed(void *parsed_result,
3516 __attribute__((unused)) struct cmdline *cl,
3517 __attribute__((unused)) void *data)
3519 struct cmd_tx_vlan_reset_result *res = parsed_result;
3521 tx_vlan_reset(res->port_id);
3524 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3525 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3526 tx_vlan, "tx_vlan");
3527 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3528 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3530 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3531 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3534 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3535 .f = cmd_tx_vlan_reset_parsed,
3537 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3538 "VLAN header in packets sent on a port",
3540 (void *)&cmd_tx_vlan_reset_tx_vlan,
3541 (void *)&cmd_tx_vlan_reset_reset,
3542 (void *)&cmd_tx_vlan_reset_portid,
3548 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3549 struct cmd_csum_result {
3550 cmdline_fixed_string_t csum;
3551 cmdline_fixed_string_t mode;
3552 cmdline_fixed_string_t proto;
3553 cmdline_fixed_string_t hwsw;
3558 csum_show(int port_id)
3560 struct rte_eth_dev_info dev_info;
3563 ol_flags = ports[port_id].tx_ol_flags;
3564 printf("Parse tunnel is %s\n",
3565 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3566 printf("IP checksum offload is %s\n",
3567 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3568 printf("UDP checksum offload is %s\n",
3569 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3570 printf("TCP checksum offload is %s\n",
3571 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3572 printf("SCTP checksum offload is %s\n",
3573 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3574 printf("Outer-Ip checksum offload is %s\n",
3575 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3577 /* display warnings if configuration is not supported by the NIC */
3578 rte_eth_dev_info_get(port_id, &dev_info);
3579 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3580 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3581 printf("Warning: hardware IP checksum enabled but not "
3582 "supported by port %d\n", port_id);
3584 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3585 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3586 printf("Warning: hardware UDP checksum enabled but not "
3587 "supported by port %d\n", port_id);
3589 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3590 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3591 printf("Warning: hardware TCP checksum enabled but not "
3592 "supported by port %d\n", port_id);
3594 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3595 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3596 printf("Warning: hardware SCTP checksum enabled but not "
3597 "supported by port %d\n", port_id);
3599 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3600 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3601 printf("Warning: hardware outer IP checksum enabled but not "
3602 "supported by port %d\n", port_id);
3607 cmd_csum_parsed(void *parsed_result,
3608 __attribute__((unused)) struct cmdline *cl,
3609 __attribute__((unused)) void *data)
3611 struct cmd_csum_result *res = parsed_result;
3615 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3616 printf("invalid port %d\n", res->port_id);
3620 if (!strcmp(res->mode, "set")) {
3622 if (!strcmp(res->hwsw, "hw"))
3625 if (!strcmp(res->proto, "ip")) {
3626 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3627 } else if (!strcmp(res->proto, "udp")) {
3628 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3629 } else if (!strcmp(res->proto, "tcp")) {
3630 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3631 } else if (!strcmp(res->proto, "sctp")) {
3632 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3633 } else if (!strcmp(res->proto, "outer-ip")) {
3634 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3638 ports[res->port_id].tx_ol_flags |= mask;
3640 ports[res->port_id].tx_ol_flags &= (~mask);
3642 csum_show(res->port_id);
3645 cmdline_parse_token_string_t cmd_csum_csum =
3646 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3648 cmdline_parse_token_string_t cmd_csum_mode =
3649 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3651 cmdline_parse_token_string_t cmd_csum_proto =
3652 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3653 proto, "ip#tcp#udp#sctp#outer-ip");
3654 cmdline_parse_token_string_t cmd_csum_hwsw =
3655 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3657 cmdline_parse_token_num_t cmd_csum_portid =
3658 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3661 cmdline_parse_inst_t cmd_csum_set = {
3662 .f = cmd_csum_parsed,
3664 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3665 "Enable/Disable hardware calculation of L3/L4 checksum when "
3666 "using csum forward engine",
3668 (void *)&cmd_csum_csum,
3669 (void *)&cmd_csum_mode,
3670 (void *)&cmd_csum_proto,
3671 (void *)&cmd_csum_hwsw,
3672 (void *)&cmd_csum_portid,
3677 cmdline_parse_token_string_t cmd_csum_mode_show =
3678 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3681 cmdline_parse_inst_t cmd_csum_show = {
3682 .f = cmd_csum_parsed,
3684 .help_str = "csum show <port_id>: Show checksum offload configuration",
3686 (void *)&cmd_csum_csum,
3687 (void *)&cmd_csum_mode_show,
3688 (void *)&cmd_csum_portid,
3693 /* Enable/disable tunnel parsing */
3694 struct cmd_csum_tunnel_result {
3695 cmdline_fixed_string_t csum;
3696 cmdline_fixed_string_t parse;
3697 cmdline_fixed_string_t onoff;
3702 cmd_csum_tunnel_parsed(void *parsed_result,
3703 __attribute__((unused)) struct cmdline *cl,
3704 __attribute__((unused)) void *data)
3706 struct cmd_csum_tunnel_result *res = parsed_result;
3708 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3711 if (!strcmp(res->onoff, "on"))
3712 ports[res->port_id].tx_ol_flags |=
3713 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3715 ports[res->port_id].tx_ol_flags &=
3716 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3718 csum_show(res->port_id);
3721 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3722 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3724 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3725 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3726 parse, "parse_tunnel");
3727 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3728 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3730 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3731 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3734 cmdline_parse_inst_t cmd_csum_tunnel = {
3735 .f = cmd_csum_tunnel_parsed,
3737 .help_str = "csum parse_tunnel on|off <port_id>: "
3738 "Enable/Disable parsing of tunnels for csum engine",
3740 (void *)&cmd_csum_tunnel_csum,
3741 (void *)&cmd_csum_tunnel_parse,
3742 (void *)&cmd_csum_tunnel_onoff,
3743 (void *)&cmd_csum_tunnel_portid,
3748 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3749 struct cmd_tso_set_result {
3750 cmdline_fixed_string_t tso;
3751 cmdline_fixed_string_t mode;
3757 cmd_tso_set_parsed(void *parsed_result,
3758 __attribute__((unused)) struct cmdline *cl,
3759 __attribute__((unused)) void *data)
3761 struct cmd_tso_set_result *res = parsed_result;
3762 struct rte_eth_dev_info dev_info;
3764 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3767 if (!strcmp(res->mode, "set"))
3768 ports[res->port_id].tso_segsz = res->tso_segsz;
3770 if (ports[res->port_id].tso_segsz == 0)
3771 printf("TSO for non-tunneled packets is disabled\n");
3773 printf("TSO segment size for non-tunneled packets is %d\n",
3774 ports[res->port_id].tso_segsz);
3776 /* display warnings if configuration is not supported by the NIC */
3777 rte_eth_dev_info_get(res->port_id, &dev_info);
3778 if ((ports[res->port_id].tso_segsz != 0) &&
3779 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3780 printf("Warning: TSO enabled but not "
3781 "supported by port %d\n", res->port_id);
3785 cmdline_parse_token_string_t cmd_tso_set_tso =
3786 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3788 cmdline_parse_token_string_t cmd_tso_set_mode =
3789 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3791 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3792 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3794 cmdline_parse_token_num_t cmd_tso_set_portid =
3795 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3798 cmdline_parse_inst_t cmd_tso_set = {
3799 .f = cmd_tso_set_parsed,
3801 .help_str = "tso set <tso_segsz> <port_id>: "
3802 "Set TSO segment size of non-tunneled packets for csum engine "
3805 (void *)&cmd_tso_set_tso,
3806 (void *)&cmd_tso_set_mode,
3807 (void *)&cmd_tso_set_tso_segsz,
3808 (void *)&cmd_tso_set_portid,
3813 cmdline_parse_token_string_t cmd_tso_show_mode =
3814 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3818 cmdline_parse_inst_t cmd_tso_show = {
3819 .f = cmd_tso_set_parsed,
3821 .help_str = "tso show <port_id>: "
3822 "Show TSO segment size of non-tunneled packets for csum engine",
3824 (void *)&cmd_tso_set_tso,
3825 (void *)&cmd_tso_show_mode,
3826 (void *)&cmd_tso_set_portid,
3831 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3832 struct cmd_tunnel_tso_set_result {
3833 cmdline_fixed_string_t tso;
3834 cmdline_fixed_string_t mode;
3840 check_tunnel_tso_nic_support(portid_t port_id)
3842 struct rte_eth_dev_info dev_info;
3844 rte_eth_dev_info_get(port_id, &dev_info);
3845 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3846 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3847 "supported by port %d\n", port_id);
3848 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3849 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3850 "supported by port %d\n", port_id);
3851 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3852 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3853 "supported by port %d\n", port_id);
3854 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3855 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3856 "supported by port %d\n", port_id);
3860 cmd_tunnel_tso_set_parsed(void *parsed_result,
3861 __attribute__((unused)) struct cmdline *cl,
3862 __attribute__((unused)) void *data)
3864 struct cmd_tunnel_tso_set_result *res = parsed_result;
3866 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3869 if (!strcmp(res->mode, "set"))
3870 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3872 if (ports[res->port_id].tunnel_tso_segsz == 0)
3873 printf("TSO for tunneled packets is disabled\n");
3875 printf("TSO segment size for tunneled packets is %d\n",
3876 ports[res->port_id].tunnel_tso_segsz);
3878 /* Below conditions are needed to make it work:
3879 * (1) tunnel TSO is supported by the NIC;
3880 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3882 * (3) for tunneled pkts with outer L3 of IPv4,
3883 * "csum set outer-ip" must be set to hw, because after tso,
3884 * total_len of outer IP header is changed, and the checksum
3885 * of outer IP header calculated by sw should be wrong; that
3886 * is not necessary for IPv6 tunneled pkts because there's no
3887 * checksum in IP header anymore.
3889 check_tunnel_tso_nic_support(res->port_id);
3891 if (!(ports[res->port_id].tx_ol_flags &
3892 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3893 printf("Warning: csum parse_tunnel must be set "
3894 "so that tunneled packets are recognized\n");
3895 if (!(ports[res->port_id].tx_ol_flags &
3896 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3897 printf("Warning: csum set outer-ip must be set to hw "
3898 "if outer L3 is IPv4; not necessary for IPv6\n");
3902 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3903 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3905 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3906 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3908 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3909 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3911 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3912 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3915 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3916 .f = cmd_tunnel_tso_set_parsed,
3918 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3919 "Set TSO segment size of tunneled packets for csum engine "
3922 (void *)&cmd_tunnel_tso_set_tso,
3923 (void *)&cmd_tunnel_tso_set_mode,
3924 (void *)&cmd_tunnel_tso_set_tso_segsz,
3925 (void *)&cmd_tunnel_tso_set_portid,
3930 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3931 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3935 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3936 .f = cmd_tunnel_tso_set_parsed,
3938 .help_str = "tunnel_tso show <port_id> "
3939 "Show TSO segment size of tunneled packets for csum engine",
3941 (void *)&cmd_tunnel_tso_set_tso,
3942 (void *)&cmd_tunnel_tso_show_mode,
3943 (void *)&cmd_tunnel_tso_set_portid,
3948 /* *** SET GRO FOR A PORT *** */
3949 struct cmd_gro_enable_result {
3950 cmdline_fixed_string_t cmd_set;
3951 cmdline_fixed_string_t cmd_port;
3952 cmdline_fixed_string_t cmd_keyword;
3953 cmdline_fixed_string_t cmd_onoff;
3958 cmd_gro_enable_parsed(void *parsed_result,
3959 __attribute__((unused)) struct cmdline *cl,
3960 __attribute__((unused)) void *data)
3962 struct cmd_gro_enable_result *res;
3964 res = parsed_result;
3965 if (!strcmp(res->cmd_keyword, "gro"))
3966 setup_gro(res->cmd_onoff, res->cmd_pid);
3969 cmdline_parse_token_string_t cmd_gro_enable_set =
3970 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3972 cmdline_parse_token_string_t cmd_gro_enable_port =
3973 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3974 cmd_keyword, "port");
3975 cmdline_parse_token_num_t cmd_gro_enable_pid =
3976 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
3978 cmdline_parse_token_string_t cmd_gro_enable_keyword =
3979 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3980 cmd_keyword, "gro");
3981 cmdline_parse_token_string_t cmd_gro_enable_onoff =
3982 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3983 cmd_onoff, "on#off");
3985 cmdline_parse_inst_t cmd_gro_enable = {
3986 .f = cmd_gro_enable_parsed,
3988 .help_str = "set port <port_id> gro on|off",
3990 (void *)&cmd_gro_enable_set,
3991 (void *)&cmd_gro_enable_port,
3992 (void *)&cmd_gro_enable_pid,
3993 (void *)&cmd_gro_enable_keyword,
3994 (void *)&cmd_gro_enable_onoff,
3999 /* *** DISPLAY GRO CONFIGURATION *** */
4000 struct cmd_gro_show_result {
4001 cmdline_fixed_string_t cmd_show;
4002 cmdline_fixed_string_t cmd_port;
4003 cmdline_fixed_string_t cmd_keyword;
4008 cmd_gro_show_parsed(void *parsed_result,
4009 __attribute__((unused)) struct cmdline *cl,
4010 __attribute__((unused)) void *data)
4012 struct cmd_gro_show_result *res;
4014 res = parsed_result;
4015 if (!strcmp(res->cmd_keyword, "gro"))
4016 show_gro(res->cmd_pid);
4019 cmdline_parse_token_string_t cmd_gro_show_show =
4020 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4022 cmdline_parse_token_string_t cmd_gro_show_port =
4023 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4025 cmdline_parse_token_num_t cmd_gro_show_pid =
4026 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4028 cmdline_parse_token_string_t cmd_gro_show_keyword =
4029 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4030 cmd_keyword, "gro");
4032 cmdline_parse_inst_t cmd_gro_show = {
4033 .f = cmd_gro_show_parsed,
4035 .help_str = "show port <port_id> gro",
4037 (void *)&cmd_gro_show_show,
4038 (void *)&cmd_gro_show_port,
4039 (void *)&cmd_gro_show_pid,
4040 (void *)&cmd_gro_show_keyword,
4045 /* *** SET FLUSH CYCLES FOR GRO *** */
4046 struct cmd_gro_flush_result {
4047 cmdline_fixed_string_t cmd_set;
4048 cmdline_fixed_string_t cmd_keyword;
4049 cmdline_fixed_string_t cmd_flush;
4054 cmd_gro_flush_parsed(void *parsed_result,
4055 __attribute__((unused)) struct cmdline *cl,
4056 __attribute__((unused)) void *data)
4058 struct cmd_gro_flush_result *res;
4060 res = parsed_result;
4061 if ((!strcmp(res->cmd_keyword, "gro")) &&
4062 (!strcmp(res->cmd_flush, "flush")))
4063 setup_gro_flush_cycles(res->cmd_cycles);
4066 cmdline_parse_token_string_t cmd_gro_flush_set =
4067 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4069 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4070 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4071 cmd_keyword, "gro");
4072 cmdline_parse_token_string_t cmd_gro_flush_flush =
4073 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4074 cmd_flush, "flush");
4075 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4076 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4079 cmdline_parse_inst_t cmd_gro_flush = {
4080 .f = cmd_gro_flush_parsed,
4082 .help_str = "set gro flush <cycles>",
4084 (void *)&cmd_gro_flush_set,
4085 (void *)&cmd_gro_flush_keyword,
4086 (void *)&cmd_gro_flush_flush,
4087 (void *)&cmd_gro_flush_cycles,
4092 /* *** ENABLE/DISABLE GSO *** */
4093 struct cmd_gso_enable_result {
4094 cmdline_fixed_string_t cmd_set;
4095 cmdline_fixed_string_t cmd_port;
4096 cmdline_fixed_string_t cmd_keyword;
4097 cmdline_fixed_string_t cmd_mode;
4102 cmd_gso_enable_parsed(void *parsed_result,
4103 __attribute__((unused)) struct cmdline *cl,
4104 __attribute__((unused)) void *data)
4106 struct cmd_gso_enable_result *res;
4108 res = parsed_result;
4109 if (!strcmp(res->cmd_keyword, "gso"))
4110 setup_gso(res->cmd_mode, res->cmd_pid);
4113 cmdline_parse_token_string_t cmd_gso_enable_set =
4114 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4116 cmdline_parse_token_string_t cmd_gso_enable_port =
4117 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4119 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4120 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4121 cmd_keyword, "gso");
4122 cmdline_parse_token_string_t cmd_gso_enable_mode =
4123 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4124 cmd_mode, "on#off");
4125 cmdline_parse_token_num_t cmd_gso_enable_pid =
4126 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4129 cmdline_parse_inst_t cmd_gso_enable = {
4130 .f = cmd_gso_enable_parsed,
4132 .help_str = "set port <port_id> gso on|off",
4134 (void *)&cmd_gso_enable_set,
4135 (void *)&cmd_gso_enable_port,
4136 (void *)&cmd_gso_enable_pid,
4137 (void *)&cmd_gso_enable_keyword,
4138 (void *)&cmd_gso_enable_mode,
4143 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4144 struct cmd_gso_size_result {
4145 cmdline_fixed_string_t cmd_set;
4146 cmdline_fixed_string_t cmd_keyword;
4147 cmdline_fixed_string_t cmd_segsz;
4152 cmd_gso_size_parsed(void *parsed_result,
4153 __attribute__((unused)) struct cmdline *cl,
4154 __attribute__((unused)) void *data)
4156 struct cmd_gso_size_result *res = parsed_result;
4158 if (test_done == 0) {
4159 printf("Before setting GSO segsz, please first"
4160 " stop fowarding\n");
4164 if (!strcmp(res->cmd_keyword, "gso") &&
4165 !strcmp(res->cmd_segsz, "segsz")) {
4166 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4167 printf("gso_size should be larger than %zu."
4168 " Please input a legal value\n",
4169 RTE_GSO_SEG_SIZE_MIN);
4171 gso_max_segment_size = res->cmd_size;
4175 cmdline_parse_token_string_t cmd_gso_size_set =
4176 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4178 cmdline_parse_token_string_t cmd_gso_size_keyword =
4179 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4180 cmd_keyword, "gso");
4181 cmdline_parse_token_string_t cmd_gso_size_segsz =
4182 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4183 cmd_segsz, "segsz");
4184 cmdline_parse_token_num_t cmd_gso_size_size =
4185 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4188 cmdline_parse_inst_t cmd_gso_size = {
4189 .f = cmd_gso_size_parsed,
4191 .help_str = "set gso segsz <length>",
4193 (void *)&cmd_gso_size_set,
4194 (void *)&cmd_gso_size_keyword,
4195 (void *)&cmd_gso_size_segsz,
4196 (void *)&cmd_gso_size_size,
4201 /* *** SHOW GSO CONFIGURATION *** */
4202 struct cmd_gso_show_result {
4203 cmdline_fixed_string_t cmd_show;
4204 cmdline_fixed_string_t cmd_port;
4205 cmdline_fixed_string_t cmd_keyword;
4210 cmd_gso_show_parsed(void *parsed_result,
4211 __attribute__((unused)) struct cmdline *cl,
4212 __attribute__((unused)) void *data)
4214 struct cmd_gso_show_result *res = parsed_result;
4216 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4217 printf("invalid port id %u\n", res->cmd_pid);
4220 if (!strcmp(res->cmd_keyword, "gso")) {
4221 if (gso_ports[res->cmd_pid].enable) {
4222 printf("Max GSO'd packet size: %uB\n"
4223 "Supported GSO types: TCP/IPv4, "
4224 "VxLAN with inner TCP/IPv4 packet, "
4225 "GRE with inner TCP/IPv4 packet\n",
4226 gso_max_segment_size);
4228 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4232 cmdline_parse_token_string_t cmd_gso_show_show =
4233 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4235 cmdline_parse_token_string_t cmd_gso_show_port =
4236 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4238 cmdline_parse_token_string_t cmd_gso_show_keyword =
4239 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4240 cmd_keyword, "gso");
4241 cmdline_parse_token_num_t cmd_gso_show_pid =
4242 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4245 cmdline_parse_inst_t cmd_gso_show = {
4246 .f = cmd_gso_show_parsed,
4248 .help_str = "show port <port_id> gso",
4250 (void *)&cmd_gso_show_show,
4251 (void *)&cmd_gso_show_port,
4252 (void *)&cmd_gso_show_pid,
4253 (void *)&cmd_gso_show_keyword,
4258 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4259 struct cmd_set_flush_rx {
4260 cmdline_fixed_string_t set;
4261 cmdline_fixed_string_t flush_rx;
4262 cmdline_fixed_string_t mode;
4266 cmd_set_flush_rx_parsed(void *parsed_result,
4267 __attribute__((unused)) struct cmdline *cl,
4268 __attribute__((unused)) void *data)
4270 struct cmd_set_flush_rx *res = parsed_result;
4271 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4274 cmdline_parse_token_string_t cmd_setflushrx_set =
4275 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4277 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4278 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4279 flush_rx, "flush_rx");
4280 cmdline_parse_token_string_t cmd_setflushrx_mode =
4281 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4285 cmdline_parse_inst_t cmd_set_flush_rx = {
4286 .f = cmd_set_flush_rx_parsed,
4287 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4290 (void *)&cmd_setflushrx_set,
4291 (void *)&cmd_setflushrx_flush_rx,
4292 (void *)&cmd_setflushrx_mode,
4297 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4298 struct cmd_set_link_check {
4299 cmdline_fixed_string_t set;
4300 cmdline_fixed_string_t link_check;
4301 cmdline_fixed_string_t mode;
4305 cmd_set_link_check_parsed(void *parsed_result,
4306 __attribute__((unused)) struct cmdline *cl,
4307 __attribute__((unused)) void *data)
4309 struct cmd_set_link_check *res = parsed_result;
4310 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4313 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4314 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4316 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4317 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4318 link_check, "link_check");
4319 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4320 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4324 cmdline_parse_inst_t cmd_set_link_check = {
4325 .f = cmd_set_link_check_parsed,
4326 .help_str = "set link_check on|off: Enable/Disable link status check "
4327 "when starting/stopping a port",
4330 (void *)&cmd_setlinkcheck_set,
4331 (void *)&cmd_setlinkcheck_link_check,
4332 (void *)&cmd_setlinkcheck_mode,
4337 /* *** SET NIC BYPASS MODE *** */
4338 struct cmd_set_bypass_mode_result {
4339 cmdline_fixed_string_t set;
4340 cmdline_fixed_string_t bypass;
4341 cmdline_fixed_string_t mode;
4342 cmdline_fixed_string_t value;
4347 cmd_set_bypass_mode_parsed(void *parsed_result,
4348 __attribute__((unused)) struct cmdline *cl,
4349 __attribute__((unused)) void *data)
4351 struct cmd_set_bypass_mode_result *res = parsed_result;
4352 portid_t port_id = res->port_id;
4353 int32_t rc = -EINVAL;
4355 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4356 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4358 if (!strcmp(res->value, "bypass"))
4359 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4360 else if (!strcmp(res->value, "isolate"))
4361 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4363 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4365 /* Set the bypass mode for the relevant port. */
4366 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4369 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4372 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4373 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4375 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4376 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4378 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4379 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4381 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4382 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4383 value, "normal#bypass#isolate");
4384 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4385 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4388 cmdline_parse_inst_t cmd_set_bypass_mode = {
4389 .f = cmd_set_bypass_mode_parsed,
4390 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4391 "Set the NIC bypass mode for port_id",
4394 (void *)&cmd_setbypass_mode_set,
4395 (void *)&cmd_setbypass_mode_bypass,
4396 (void *)&cmd_setbypass_mode_mode,
4397 (void *)&cmd_setbypass_mode_value,
4398 (void *)&cmd_setbypass_mode_port,
4403 /* *** SET NIC BYPASS EVENT *** */
4404 struct cmd_set_bypass_event_result {
4405 cmdline_fixed_string_t set;
4406 cmdline_fixed_string_t bypass;
4407 cmdline_fixed_string_t event;
4408 cmdline_fixed_string_t event_value;
4409 cmdline_fixed_string_t mode;
4410 cmdline_fixed_string_t mode_value;
4415 cmd_set_bypass_event_parsed(void *parsed_result,
4416 __attribute__((unused)) struct cmdline *cl,
4417 __attribute__((unused)) void *data)
4419 int32_t rc = -EINVAL;
4420 struct cmd_set_bypass_event_result *res = parsed_result;
4421 portid_t port_id = res->port_id;
4423 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4424 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4425 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4427 if (!strcmp(res->event_value, "timeout"))
4428 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4429 else if (!strcmp(res->event_value, "os_on"))
4430 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4431 else if (!strcmp(res->event_value, "os_off"))
4432 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4433 else if (!strcmp(res->event_value, "power_on"))
4434 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4435 else if (!strcmp(res->event_value, "power_off"))
4436 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4438 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4440 if (!strcmp(res->mode_value, "bypass"))
4441 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4442 else if (!strcmp(res->mode_value, "isolate"))
4443 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4445 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4447 /* Set the watchdog timeout. */
4448 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4451 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4452 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4456 printf("Failed to set timeout value %u "
4457 "for port %d, errto code: %d.\n",
4458 bypass_timeout, port_id, rc);
4462 /* Set the bypass event to transition to bypass mode. */
4463 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4468 printf("\t Failed to set bypass event for port = %d.\n",
4472 cmdline_parse_token_string_t cmd_setbypass_event_set =
4473 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4475 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4476 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4478 cmdline_parse_token_string_t cmd_setbypass_event_event =
4479 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4481 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4482 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4483 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4484 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4485 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4487 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4488 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4489 mode_value, "normal#bypass#isolate");
4490 cmdline_parse_token_num_t cmd_setbypass_event_port =
4491 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4494 cmdline_parse_inst_t cmd_set_bypass_event = {
4495 .f = cmd_set_bypass_event_parsed,
4496 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4497 "power_off mode normal|bypass|isolate <port_id>: "
4498 "Set the NIC bypass event mode for port_id",
4501 (void *)&cmd_setbypass_event_set,
4502 (void *)&cmd_setbypass_event_bypass,
4503 (void *)&cmd_setbypass_event_event,
4504 (void *)&cmd_setbypass_event_event_value,
4505 (void *)&cmd_setbypass_event_mode,
4506 (void *)&cmd_setbypass_event_mode_value,
4507 (void *)&cmd_setbypass_event_port,
4513 /* *** SET NIC BYPASS TIMEOUT *** */
4514 struct cmd_set_bypass_timeout_result {
4515 cmdline_fixed_string_t set;
4516 cmdline_fixed_string_t bypass;
4517 cmdline_fixed_string_t timeout;
4518 cmdline_fixed_string_t value;
4522 cmd_set_bypass_timeout_parsed(void *parsed_result,
4523 __attribute__((unused)) struct cmdline *cl,
4524 __attribute__((unused)) void *data)
4526 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4528 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4529 if (!strcmp(res->value, "1.5"))
4530 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4531 else if (!strcmp(res->value, "2"))
4532 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4533 else if (!strcmp(res->value, "3"))
4534 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4535 else if (!strcmp(res->value, "4"))
4536 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4537 else if (!strcmp(res->value, "8"))
4538 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4539 else if (!strcmp(res->value, "16"))
4540 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4541 else if (!strcmp(res->value, "32"))
4542 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4544 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4548 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4549 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4551 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4552 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4554 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4555 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4556 timeout, "timeout");
4557 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4558 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4559 value, "0#1.5#2#3#4#8#16#32");
4561 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4562 .f = cmd_set_bypass_timeout_parsed,
4563 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4564 "Set the NIC bypass watchdog timeout in seconds",
4567 (void *)&cmd_setbypass_timeout_set,
4568 (void *)&cmd_setbypass_timeout_bypass,
4569 (void *)&cmd_setbypass_timeout_timeout,
4570 (void *)&cmd_setbypass_timeout_value,
4575 /* *** SHOW NIC BYPASS MODE *** */
4576 struct cmd_show_bypass_config_result {
4577 cmdline_fixed_string_t show;
4578 cmdline_fixed_string_t bypass;
4579 cmdline_fixed_string_t config;
4584 cmd_show_bypass_config_parsed(void *parsed_result,
4585 __attribute__((unused)) struct cmdline *cl,
4586 __attribute__((unused)) void *data)
4588 struct cmd_show_bypass_config_result *res = parsed_result;
4589 portid_t port_id = res->port_id;
4591 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4592 uint32_t event_mode;
4593 uint32_t bypass_mode;
4594 uint32_t timeout = bypass_timeout;
4597 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4598 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4599 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4600 {"UNKNOWN", "normal", "bypass", "isolate"};
4601 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4608 int num_events = (sizeof events) / (sizeof events[0]);
4610 /* Display the bypass mode.*/
4611 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4612 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4616 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4617 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4619 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4622 /* Display the bypass timeout.*/
4623 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4624 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4626 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4628 /* Display the bypass events and associated modes. */
4629 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4631 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4632 printf("\tFailed to get bypass mode for event = %s\n",
4635 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4636 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4638 printf("\tbypass event: %-16s = %s\n", events[i],
4644 printf("\tFailed to get bypass configuration for port = %d\n",
4648 cmdline_parse_token_string_t cmd_showbypass_config_show =
4649 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4651 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4652 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4654 cmdline_parse_token_string_t cmd_showbypass_config_config =
4655 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4657 cmdline_parse_token_num_t cmd_showbypass_config_port =
4658 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4661 cmdline_parse_inst_t cmd_show_bypass_config = {
4662 .f = cmd_show_bypass_config_parsed,
4663 .help_str = "show bypass config <port_id>: "
4664 "Show the NIC bypass config for port_id",
4667 (void *)&cmd_showbypass_config_show,
4668 (void *)&cmd_showbypass_config_bypass,
4669 (void *)&cmd_showbypass_config_config,
4670 (void *)&cmd_showbypass_config_port,
4675 #ifdef RTE_LIBRTE_PMD_BOND
4676 /* *** SET BONDING MODE *** */
4677 struct cmd_set_bonding_mode_result {
4678 cmdline_fixed_string_t set;
4679 cmdline_fixed_string_t bonding;
4680 cmdline_fixed_string_t mode;
4685 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4686 __attribute__((unused)) struct cmdline *cl,
4687 __attribute__((unused)) void *data)
4689 struct cmd_set_bonding_mode_result *res = parsed_result;
4690 portid_t port_id = res->port_id;
4692 /* Set the bonding mode for the relevant port. */
4693 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4694 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4697 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4698 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4700 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4701 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4702 bonding, "bonding");
4703 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4704 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4706 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4707 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4709 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4710 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4713 cmdline_parse_inst_t cmd_set_bonding_mode = {
4714 .f = cmd_set_bonding_mode_parsed,
4715 .help_str = "set bonding mode <mode_value> <port_id>: "
4716 "Set the bonding mode for port_id",
4719 (void *) &cmd_setbonding_mode_set,
4720 (void *) &cmd_setbonding_mode_bonding,
4721 (void *) &cmd_setbonding_mode_mode,
4722 (void *) &cmd_setbonding_mode_value,
4723 (void *) &cmd_setbonding_mode_port,
4728 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4729 struct cmd_set_bonding_lacp_dedicated_queues_result {
4730 cmdline_fixed_string_t set;
4731 cmdline_fixed_string_t bonding;
4732 cmdline_fixed_string_t lacp;
4733 cmdline_fixed_string_t dedicated_queues;
4735 cmdline_fixed_string_t mode;
4738 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4739 __attribute__((unused)) struct cmdline *cl,
4740 __attribute__((unused)) void *data)
4742 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4743 portid_t port_id = res->port_id;
4744 struct rte_port *port;
4746 port = &ports[port_id];
4748 /** Check if the port is not started **/
4749 if (port->port_status != RTE_PORT_STOPPED) {
4750 printf("Please stop port %d first\n", port_id);
4754 if (!strcmp(res->mode, "enable")) {
4755 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4756 printf("Dedicate queues for LACP control packets"
4759 printf("Enabling dedicate queues for LACP control "
4760 "packets on port %d failed\n", port_id);
4761 } else if (!strcmp(res->mode, "disable")) {
4762 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4763 printf("Dedicated queues for LACP control packets "
4766 printf("Disabling dedicated queues for LACP control "
4767 "traffic on port %d failed\n", port_id);
4771 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4772 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4774 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4775 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4776 bonding, "bonding");
4777 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4778 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4780 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4781 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4782 dedicated_queues, "dedicated_queues");
4783 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4784 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4786 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4787 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4788 mode, "enable#disable");
4790 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4791 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4792 .help_str = "set bonding lacp dedicated_queues <port_id> "
4794 "Enable/disable dedicated queues for LACP control traffic for port_id",
4797 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4798 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4799 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4800 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4801 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4802 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4807 /* *** SET BALANCE XMIT POLICY *** */
4808 struct cmd_set_bonding_balance_xmit_policy_result {
4809 cmdline_fixed_string_t set;
4810 cmdline_fixed_string_t bonding;
4811 cmdline_fixed_string_t balance_xmit_policy;
4813 cmdline_fixed_string_t policy;
4816 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4817 __attribute__((unused)) struct cmdline *cl,
4818 __attribute__((unused)) void *data)
4820 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4821 portid_t port_id = res->port_id;
4824 if (!strcmp(res->policy, "l2")) {
4825 policy = BALANCE_XMIT_POLICY_LAYER2;
4826 } else if (!strcmp(res->policy, "l23")) {
4827 policy = BALANCE_XMIT_POLICY_LAYER23;
4828 } else if (!strcmp(res->policy, "l34")) {
4829 policy = BALANCE_XMIT_POLICY_LAYER34;
4831 printf("\t Invalid xmit policy selection");
4835 /* Set the bonding mode for the relevant port. */
4836 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4837 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4842 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4843 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4845 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4846 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4847 bonding, "bonding");
4848 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4849 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4850 balance_xmit_policy, "balance_xmit_policy");
4851 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4852 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4854 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4855 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4856 policy, "l2#l23#l34");
4858 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4859 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4860 .help_str = "set bonding balance_xmit_policy <port_id> "
4862 "Set the bonding balance_xmit_policy for port_id",
4865 (void *)&cmd_setbonding_balance_xmit_policy_set,
4866 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4867 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4868 (void *)&cmd_setbonding_balance_xmit_policy_port,
4869 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4874 /* *** SHOW NIC BONDING CONFIGURATION *** */
4875 struct cmd_show_bonding_config_result {
4876 cmdline_fixed_string_t show;
4877 cmdline_fixed_string_t bonding;
4878 cmdline_fixed_string_t config;
4882 static void cmd_show_bonding_config_parsed(void *parsed_result,
4883 __attribute__((unused)) struct cmdline *cl,
4884 __attribute__((unused)) void *data)
4886 struct cmd_show_bonding_config_result *res = parsed_result;
4887 int bonding_mode, agg_mode;
4888 portid_t slaves[RTE_MAX_ETHPORTS];
4889 int num_slaves, num_active_slaves;
4892 portid_t port_id = res->port_id;
4894 /* Display the bonding mode.*/
4895 bonding_mode = rte_eth_bond_mode_get(port_id);
4896 if (bonding_mode < 0) {
4897 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4900 printf("\tBonding mode: %d\n", bonding_mode);
4902 if (bonding_mode == BONDING_MODE_BALANCE) {
4903 int balance_xmit_policy;
4905 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4906 if (balance_xmit_policy < 0) {
4907 printf("\tFailed to get balance xmit policy for port = %d\n",
4911 printf("\tBalance Xmit Policy: ");
4913 switch (balance_xmit_policy) {
4914 case BALANCE_XMIT_POLICY_LAYER2:
4915 printf("BALANCE_XMIT_POLICY_LAYER2");
4917 case BALANCE_XMIT_POLICY_LAYER23:
4918 printf("BALANCE_XMIT_POLICY_LAYER23");
4920 case BALANCE_XMIT_POLICY_LAYER34:
4921 printf("BALANCE_XMIT_POLICY_LAYER34");
4928 if (bonding_mode == BONDING_MODE_8023AD) {
4929 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
4930 printf("\tIEEE802.3AD Aggregator Mode: ");
4933 printf("bandwidth");
4945 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4947 if (num_slaves < 0) {
4948 printf("\tFailed to get slave list for port = %d\n", port_id);
4951 if (num_slaves > 0) {
4952 printf("\tSlaves (%d): [", num_slaves);
4953 for (i = 0; i < num_slaves - 1; i++)
4954 printf("%d ", slaves[i]);
4956 printf("%d]\n", slaves[num_slaves - 1]);
4958 printf("\tSlaves: []\n");
4962 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4965 if (num_active_slaves < 0) {
4966 printf("\tFailed to get active slave list for port = %d\n", port_id);
4969 if (num_active_slaves > 0) {
4970 printf("\tActive Slaves (%d): [", num_active_slaves);
4971 for (i = 0; i < num_active_slaves - 1; i++)
4972 printf("%d ", slaves[i]);
4974 printf("%d]\n", slaves[num_active_slaves - 1]);
4977 printf("\tActive Slaves: []\n");
4981 primary_id = rte_eth_bond_primary_get(port_id);
4982 if (primary_id < 0) {
4983 printf("\tFailed to get primary slave for port = %d\n", port_id);
4986 printf("\tPrimary: [%d]\n", primary_id);
4990 cmdline_parse_token_string_t cmd_showbonding_config_show =
4991 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4993 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4994 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4995 bonding, "bonding");
4996 cmdline_parse_token_string_t cmd_showbonding_config_config =
4997 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4999 cmdline_parse_token_num_t cmd_showbonding_config_port =
5000 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5003 cmdline_parse_inst_t cmd_show_bonding_config = {
5004 .f = cmd_show_bonding_config_parsed,
5005 .help_str = "show bonding config <port_id>: "
5006 "Show the bonding config for port_id",
5009 (void *)&cmd_showbonding_config_show,
5010 (void *)&cmd_showbonding_config_bonding,
5011 (void *)&cmd_showbonding_config_config,
5012 (void *)&cmd_showbonding_config_port,
5017 /* *** SET BONDING PRIMARY *** */
5018 struct cmd_set_bonding_primary_result {
5019 cmdline_fixed_string_t set;
5020 cmdline_fixed_string_t bonding;
5021 cmdline_fixed_string_t primary;
5026 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5027 __attribute__((unused)) struct cmdline *cl,
5028 __attribute__((unused)) void *data)
5030 struct cmd_set_bonding_primary_result *res = parsed_result;
5031 portid_t master_port_id = res->port_id;
5032 portid_t slave_port_id = res->slave_id;
5034 /* Set the primary slave for a bonded device. */
5035 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5036 printf("\t Failed to set primary slave for port = %d.\n",
5043 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5044 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5046 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5047 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5048 bonding, "bonding");
5049 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5050 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5051 primary, "primary");
5052 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5053 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5055 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5056 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5059 cmdline_parse_inst_t cmd_set_bonding_primary = {
5060 .f = cmd_set_bonding_primary_parsed,
5061 .help_str = "set bonding primary <slave_id> <port_id>: "
5062 "Set the primary slave for port_id",
5065 (void *)&cmd_setbonding_primary_set,
5066 (void *)&cmd_setbonding_primary_bonding,
5067 (void *)&cmd_setbonding_primary_primary,
5068 (void *)&cmd_setbonding_primary_slave,
5069 (void *)&cmd_setbonding_primary_port,
5074 /* *** ADD SLAVE *** */
5075 struct cmd_add_bonding_slave_result {
5076 cmdline_fixed_string_t add;
5077 cmdline_fixed_string_t bonding;
5078 cmdline_fixed_string_t slave;
5083 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5084 __attribute__((unused)) struct cmdline *cl,
5085 __attribute__((unused)) void *data)
5087 struct cmd_add_bonding_slave_result *res = parsed_result;
5088 portid_t master_port_id = res->port_id;
5089 portid_t slave_port_id = res->slave_id;
5091 /* add the slave for a bonded device. */
5092 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5093 printf("\t Failed to add slave %d to master port = %d.\n",
5094 slave_port_id, master_port_id);
5098 set_port_slave_flag(slave_port_id);
5101 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5102 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5104 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5105 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5106 bonding, "bonding");
5107 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5108 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5110 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5111 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5113 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5114 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5117 cmdline_parse_inst_t cmd_add_bonding_slave = {
5118 .f = cmd_add_bonding_slave_parsed,
5119 .help_str = "add bonding slave <slave_id> <port_id>: "
5120 "Add a slave device to a bonded device",
5123 (void *)&cmd_addbonding_slave_add,
5124 (void *)&cmd_addbonding_slave_bonding,
5125 (void *)&cmd_addbonding_slave_slave,
5126 (void *)&cmd_addbonding_slave_slaveid,
5127 (void *)&cmd_addbonding_slave_port,
5132 /* *** REMOVE SLAVE *** */
5133 struct cmd_remove_bonding_slave_result {
5134 cmdline_fixed_string_t remove;
5135 cmdline_fixed_string_t bonding;
5136 cmdline_fixed_string_t slave;
5141 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5142 __attribute__((unused)) struct cmdline *cl,
5143 __attribute__((unused)) void *data)
5145 struct cmd_remove_bonding_slave_result *res = parsed_result;
5146 portid_t master_port_id = res->port_id;
5147 portid_t slave_port_id = res->slave_id;
5149 /* remove the slave from a bonded device. */
5150 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5151 printf("\t Failed to remove slave %d from master port = %d.\n",
5152 slave_port_id, master_port_id);
5156 clear_port_slave_flag(slave_port_id);
5159 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5160 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5162 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5163 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5164 bonding, "bonding");
5165 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5166 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5168 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5169 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5171 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5172 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5175 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5176 .f = cmd_remove_bonding_slave_parsed,
5177 .help_str = "remove bonding slave <slave_id> <port_id>: "
5178 "Remove a slave device from a bonded device",
5181 (void *)&cmd_removebonding_slave_remove,
5182 (void *)&cmd_removebonding_slave_bonding,
5183 (void *)&cmd_removebonding_slave_slave,
5184 (void *)&cmd_removebonding_slave_slaveid,
5185 (void *)&cmd_removebonding_slave_port,
5190 /* *** CREATE BONDED DEVICE *** */
5191 struct cmd_create_bonded_device_result {
5192 cmdline_fixed_string_t create;
5193 cmdline_fixed_string_t bonded;
5194 cmdline_fixed_string_t device;
5199 static int bond_dev_num = 0;
5201 static void cmd_create_bonded_device_parsed(void *parsed_result,
5202 __attribute__((unused)) struct cmdline *cl,
5203 __attribute__((unused)) void *data)
5205 struct cmd_create_bonded_device_result *res = parsed_result;
5206 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5209 if (test_done == 0) {
5210 printf("Please stop forwarding first\n");
5214 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5217 /* Create a new bonded device. */
5218 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5220 printf("\t Failed to create bonded device.\n");
5223 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5226 /* Update number of ports */
5227 nb_ports = rte_eth_dev_count();
5228 reconfig(port_id, res->socket);
5229 rte_eth_promiscuous_enable(port_id);
5234 cmdline_parse_token_string_t cmd_createbonded_device_create =
5235 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5237 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5238 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5240 cmdline_parse_token_string_t cmd_createbonded_device_device =
5241 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5243 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5244 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5246 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5247 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5250 cmdline_parse_inst_t cmd_create_bonded_device = {
5251 .f = cmd_create_bonded_device_parsed,
5252 .help_str = "create bonded device <mode> <socket>: "
5253 "Create a new bonded device with specific bonding mode and socket",
5256 (void *)&cmd_createbonded_device_create,
5257 (void *)&cmd_createbonded_device_bonded,
5258 (void *)&cmd_createbonded_device_device,
5259 (void *)&cmd_createbonded_device_mode,
5260 (void *)&cmd_createbonded_device_socket,
5265 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5266 struct cmd_set_bond_mac_addr_result {
5267 cmdline_fixed_string_t set;
5268 cmdline_fixed_string_t bonding;
5269 cmdline_fixed_string_t mac_addr;
5271 struct ether_addr address;
5274 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5275 __attribute__((unused)) struct cmdline *cl,
5276 __attribute__((unused)) void *data)
5278 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5281 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5284 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5286 /* check the return value and print it if is < 0 */
5288 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5291 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5292 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5293 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5294 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5296 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5297 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5299 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5300 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5302 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5303 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5305 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5306 .f = cmd_set_bond_mac_addr_parsed,
5308 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5310 (void *)&cmd_set_bond_mac_addr_set,
5311 (void *)&cmd_set_bond_mac_addr_bonding,
5312 (void *)&cmd_set_bond_mac_addr_mac,
5313 (void *)&cmd_set_bond_mac_addr_portnum,
5314 (void *)&cmd_set_bond_mac_addr_addr,
5320 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5321 struct cmd_set_bond_mon_period_result {
5322 cmdline_fixed_string_t set;
5323 cmdline_fixed_string_t bonding;
5324 cmdline_fixed_string_t mon_period;
5329 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5330 __attribute__((unused)) struct cmdline *cl,
5331 __attribute__((unused)) void *data)
5333 struct cmd_set_bond_mon_period_result *res = parsed_result;
5336 if (res->port_num >= nb_ports) {
5337 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5341 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5343 /* check the return value and print it if is < 0 */
5345 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5348 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5349 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5351 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5352 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5353 bonding, "bonding");
5354 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5355 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5356 mon_period, "mon_period");
5357 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5358 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5360 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5361 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5364 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5365 .f = cmd_set_bond_mon_period_parsed,
5367 .help_str = "set bonding mon_period <port_id> <period_ms>",
5369 (void *)&cmd_set_bond_mon_period_set,
5370 (void *)&cmd_set_bond_mon_period_bonding,
5371 (void *)&cmd_set_bond_mon_period_mon_period,
5372 (void *)&cmd_set_bond_mon_period_portnum,
5373 (void *)&cmd_set_bond_mon_period_period_ms,
5380 struct cmd_set_bonding_agg_mode_policy_result {
5381 cmdline_fixed_string_t set;
5382 cmdline_fixed_string_t bonding;
5383 cmdline_fixed_string_t agg_mode;
5385 cmdline_fixed_string_t policy;
5390 cmd_set_bonding_agg_mode(void *parsed_result,
5391 __attribute__((unused)) struct cmdline *cl,
5392 __attribute__((unused)) void *data)
5394 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5395 uint8_t policy = AGG_BANDWIDTH;
5397 if (res->port_num >= nb_ports) {
5398 printf("Port id %d must be less than %d\n",
5399 res->port_num, nb_ports);
5403 if (!strcmp(res->policy, "bandwidth"))
5404 policy = AGG_BANDWIDTH;
5405 else if (!strcmp(res->policy, "stable"))
5406 policy = AGG_STABLE;
5407 else if (!strcmp(res->policy, "count"))
5410 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5414 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5415 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5417 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5418 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5419 bonding, "bonding");
5421 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5422 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5423 agg_mode, "agg_mode");
5425 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5426 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5429 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5430 TOKEN_STRING_INITIALIZER(
5431 struct cmd_set_bonding_balance_xmit_policy_result,
5432 policy, "stable#bandwidth#count");
5434 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5435 .f = cmd_set_bonding_agg_mode,
5437 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5439 (void *)&cmd_set_bonding_agg_mode_set,
5440 (void *)&cmd_set_bonding_agg_mode_bonding,
5441 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5442 (void *)&cmd_set_bonding_agg_mode_portnum,
5443 (void *)&cmd_set_bonding_agg_mode_policy_string,
5449 #endif /* RTE_LIBRTE_PMD_BOND */
5451 /* *** SET FORWARDING MODE *** */
5452 struct cmd_set_fwd_mode_result {
5453 cmdline_fixed_string_t set;
5454 cmdline_fixed_string_t fwd;
5455 cmdline_fixed_string_t mode;
5458 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5459 __attribute__((unused)) struct cmdline *cl,
5460 __attribute__((unused)) void *data)
5462 struct cmd_set_fwd_mode_result *res = parsed_result;
5465 set_pkt_forwarding_mode(res->mode);
5468 cmdline_parse_token_string_t cmd_setfwd_set =
5469 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5470 cmdline_parse_token_string_t cmd_setfwd_fwd =
5471 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5472 cmdline_parse_token_string_t cmd_setfwd_mode =
5473 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5474 "" /* defined at init */);
5476 cmdline_parse_inst_t cmd_set_fwd_mode = {
5477 .f = cmd_set_fwd_mode_parsed,
5479 .help_str = NULL, /* defined at init */
5481 (void *)&cmd_setfwd_set,
5482 (void *)&cmd_setfwd_fwd,
5483 (void *)&cmd_setfwd_mode,
5488 static void cmd_set_fwd_mode_init(void)
5491 static char token[128];
5492 static char help[256];
5493 cmdline_parse_token_string_t *token_struct;
5495 modes = list_pkt_forwarding_modes();
5496 snprintf(help, sizeof(help), "set fwd %s: "
5497 "Set packet forwarding mode", modes);
5498 cmd_set_fwd_mode.help_str = help;
5500 /* string token separator is # */
5501 for (c = token; *modes != '\0'; modes++)
5506 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5507 token_struct->string_data.str = token;
5510 /* *** SET RETRY FORWARDING MODE *** */
5511 struct cmd_set_fwd_retry_mode_result {
5512 cmdline_fixed_string_t set;
5513 cmdline_fixed_string_t fwd;
5514 cmdline_fixed_string_t mode;
5515 cmdline_fixed_string_t retry;
5518 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5519 __attribute__((unused)) struct cmdline *cl,
5520 __attribute__((unused)) void *data)
5522 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5525 set_pkt_forwarding_mode(res->mode);
5528 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5529 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5531 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5532 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5534 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5535 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5537 "" /* defined at init */);
5538 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5539 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5542 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5543 .f = cmd_set_fwd_retry_mode_parsed,
5545 .help_str = NULL, /* defined at init */
5547 (void *)&cmd_setfwd_retry_set,
5548 (void *)&cmd_setfwd_retry_fwd,
5549 (void *)&cmd_setfwd_retry_mode,
5550 (void *)&cmd_setfwd_retry_retry,
5555 static void cmd_set_fwd_retry_mode_init(void)
5558 static char token[128];
5559 static char help[256];
5560 cmdline_parse_token_string_t *token_struct;
5562 modes = list_pkt_forwarding_retry_modes();
5563 snprintf(help, sizeof(help), "set fwd %s retry: "
5564 "Set packet forwarding mode with retry", modes);
5565 cmd_set_fwd_retry_mode.help_str = help;
5567 /* string token separator is # */
5568 for (c = token; *modes != '\0'; modes++)
5573 token_struct = (cmdline_parse_token_string_t *)
5574 cmd_set_fwd_retry_mode.tokens[2];
5575 token_struct->string_data.str = token;
5578 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5579 struct cmd_set_burst_tx_retry_result {
5580 cmdline_fixed_string_t set;
5581 cmdline_fixed_string_t burst;
5582 cmdline_fixed_string_t tx;
5583 cmdline_fixed_string_t delay;
5585 cmdline_fixed_string_t retry;
5589 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5590 __attribute__((unused)) struct cmdline *cl,
5591 __attribute__((unused)) void *data)
5593 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5595 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5596 && !strcmp(res->tx, "tx")) {
5597 if (!strcmp(res->delay, "delay"))
5598 burst_tx_delay_time = res->time;
5599 if (!strcmp(res->retry, "retry"))
5600 burst_tx_retry_num = res->retry_num;
5605 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5606 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5607 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5608 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5610 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5611 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5612 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5613 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5614 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5615 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5616 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5617 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5618 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5619 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5621 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5622 .f = cmd_set_burst_tx_retry_parsed,
5623 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5625 (void *)&cmd_set_burst_tx_retry_set,
5626 (void *)&cmd_set_burst_tx_retry_burst,
5627 (void *)&cmd_set_burst_tx_retry_tx,
5628 (void *)&cmd_set_burst_tx_retry_delay,
5629 (void *)&cmd_set_burst_tx_retry_time,
5630 (void *)&cmd_set_burst_tx_retry_retry,
5631 (void *)&cmd_set_burst_tx_retry_retry_num,
5636 /* *** SET PROMISC MODE *** */
5637 struct cmd_set_promisc_mode_result {
5638 cmdline_fixed_string_t set;
5639 cmdline_fixed_string_t promisc;
5640 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5641 uint16_t port_num; /* valid if "allports" argument == 0 */
5642 cmdline_fixed_string_t mode;
5645 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5646 __attribute__((unused)) struct cmdline *cl,
5649 struct cmd_set_promisc_mode_result *res = parsed_result;
5653 if (!strcmp(res->mode, "on"))
5660 RTE_ETH_FOREACH_DEV(i) {
5662 rte_eth_promiscuous_enable(i);
5664 rte_eth_promiscuous_disable(i);
5669 rte_eth_promiscuous_enable(res->port_num);
5671 rte_eth_promiscuous_disable(res->port_num);
5675 cmdline_parse_token_string_t cmd_setpromisc_set =
5676 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5677 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5678 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5680 cmdline_parse_token_string_t cmd_setpromisc_portall =
5681 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5683 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5684 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5686 cmdline_parse_token_string_t cmd_setpromisc_mode =
5687 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5690 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5691 .f = cmd_set_promisc_mode_parsed,
5693 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5695 (void *)&cmd_setpromisc_set,
5696 (void *)&cmd_setpromisc_promisc,
5697 (void *)&cmd_setpromisc_portall,
5698 (void *)&cmd_setpromisc_mode,
5703 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5704 .f = cmd_set_promisc_mode_parsed,
5706 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5708 (void *)&cmd_setpromisc_set,
5709 (void *)&cmd_setpromisc_promisc,
5710 (void *)&cmd_setpromisc_portnum,
5711 (void *)&cmd_setpromisc_mode,
5716 /* *** SET ALLMULTI MODE *** */
5717 struct cmd_set_allmulti_mode_result {
5718 cmdline_fixed_string_t set;
5719 cmdline_fixed_string_t allmulti;
5720 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5721 uint16_t port_num; /* valid if "allports" argument == 0 */
5722 cmdline_fixed_string_t mode;
5725 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5726 __attribute__((unused)) struct cmdline *cl,
5729 struct cmd_set_allmulti_mode_result *res = parsed_result;
5733 if (!strcmp(res->mode, "on"))
5740 RTE_ETH_FOREACH_DEV(i) {
5742 rte_eth_allmulticast_enable(i);
5744 rte_eth_allmulticast_disable(i);
5749 rte_eth_allmulticast_enable(res->port_num);
5751 rte_eth_allmulticast_disable(res->port_num);
5755 cmdline_parse_token_string_t cmd_setallmulti_set =
5756 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5757 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5758 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5760 cmdline_parse_token_string_t cmd_setallmulti_portall =
5761 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5763 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5764 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5766 cmdline_parse_token_string_t cmd_setallmulti_mode =
5767 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5770 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5771 .f = cmd_set_allmulti_mode_parsed,
5773 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5775 (void *)&cmd_setallmulti_set,
5776 (void *)&cmd_setallmulti_allmulti,
5777 (void *)&cmd_setallmulti_portall,
5778 (void *)&cmd_setallmulti_mode,
5783 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5784 .f = cmd_set_allmulti_mode_parsed,
5786 .help_str = "set allmulti <port_id> on|off: "
5787 "Set allmulti mode on port_id",
5789 (void *)&cmd_setallmulti_set,
5790 (void *)&cmd_setallmulti_allmulti,
5791 (void *)&cmd_setallmulti_portnum,
5792 (void *)&cmd_setallmulti_mode,
5797 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5798 struct cmd_link_flow_ctrl_set_result {
5799 cmdline_fixed_string_t set;
5800 cmdline_fixed_string_t flow_ctrl;
5801 cmdline_fixed_string_t rx;
5802 cmdline_fixed_string_t rx_lfc_mode;
5803 cmdline_fixed_string_t tx;
5804 cmdline_fixed_string_t tx_lfc_mode;
5805 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5806 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5807 cmdline_fixed_string_t autoneg_str;
5808 cmdline_fixed_string_t autoneg;
5809 cmdline_fixed_string_t hw_str;
5810 uint32_t high_water;
5811 cmdline_fixed_string_t lw_str;
5813 cmdline_fixed_string_t pt_str;
5814 uint16_t pause_time;
5815 cmdline_fixed_string_t xon_str;
5820 cmdline_parse_token_string_t cmd_lfc_set_set =
5821 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5823 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5824 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5825 flow_ctrl, "flow_ctrl");
5826 cmdline_parse_token_string_t cmd_lfc_set_rx =
5827 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5829 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5830 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5831 rx_lfc_mode, "on#off");
5832 cmdline_parse_token_string_t cmd_lfc_set_tx =
5833 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5835 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5836 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5837 tx_lfc_mode, "on#off");
5838 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5839 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5840 hw_str, "high_water");
5841 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5842 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5843 high_water, UINT32);
5844 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5845 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5846 lw_str, "low_water");
5847 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5848 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5850 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5851 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5852 pt_str, "pause_time");
5853 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5854 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5855 pause_time, UINT16);
5856 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5857 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5858 xon_str, "send_xon");
5859 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5860 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5862 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5863 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5864 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5865 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5866 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5867 mac_ctrl_frame_fwd_mode, "on#off");
5868 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5869 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5870 autoneg_str, "autoneg");
5871 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5872 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5874 cmdline_parse_token_num_t cmd_lfc_set_portid =
5875 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5878 /* forward declaration */
5880 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5883 cmdline_parse_inst_t cmd_link_flow_control_set = {
5884 .f = cmd_link_flow_ctrl_set_parsed,
5886 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5887 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5888 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5890 (void *)&cmd_lfc_set_set,
5891 (void *)&cmd_lfc_set_flow_ctrl,
5892 (void *)&cmd_lfc_set_rx,
5893 (void *)&cmd_lfc_set_rx_mode,
5894 (void *)&cmd_lfc_set_tx,
5895 (void *)&cmd_lfc_set_tx_mode,
5896 (void *)&cmd_lfc_set_high_water,
5897 (void *)&cmd_lfc_set_low_water,
5898 (void *)&cmd_lfc_set_pause_time,
5899 (void *)&cmd_lfc_set_send_xon,
5900 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5901 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5902 (void *)&cmd_lfc_set_autoneg_str,
5903 (void *)&cmd_lfc_set_autoneg,
5904 (void *)&cmd_lfc_set_portid,
5909 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5910 .f = cmd_link_flow_ctrl_set_parsed,
5911 .data = (void *)&cmd_link_flow_control_set_rx,
5912 .help_str = "set flow_ctrl rx on|off <port_id>: "
5913 "Change rx flow control parameter",
5915 (void *)&cmd_lfc_set_set,
5916 (void *)&cmd_lfc_set_flow_ctrl,
5917 (void *)&cmd_lfc_set_rx,
5918 (void *)&cmd_lfc_set_rx_mode,
5919 (void *)&cmd_lfc_set_portid,
5924 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5925 .f = cmd_link_flow_ctrl_set_parsed,
5926 .data = (void *)&cmd_link_flow_control_set_tx,
5927 .help_str = "set flow_ctrl tx on|off <port_id>: "
5928 "Change tx flow control parameter",
5930 (void *)&cmd_lfc_set_set,
5931 (void *)&cmd_lfc_set_flow_ctrl,
5932 (void *)&cmd_lfc_set_tx,
5933 (void *)&cmd_lfc_set_tx_mode,
5934 (void *)&cmd_lfc_set_portid,
5939 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5940 .f = cmd_link_flow_ctrl_set_parsed,
5941 .data = (void *)&cmd_link_flow_control_set_hw,
5942 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5943 "Change high water flow control parameter",
5945 (void *)&cmd_lfc_set_set,
5946 (void *)&cmd_lfc_set_flow_ctrl,
5947 (void *)&cmd_lfc_set_high_water_str,
5948 (void *)&cmd_lfc_set_high_water,
5949 (void *)&cmd_lfc_set_portid,
5954 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5955 .f = cmd_link_flow_ctrl_set_parsed,
5956 .data = (void *)&cmd_link_flow_control_set_lw,
5957 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5958 "Change low water flow control parameter",
5960 (void *)&cmd_lfc_set_set,
5961 (void *)&cmd_lfc_set_flow_ctrl,
5962 (void *)&cmd_lfc_set_low_water_str,
5963 (void *)&cmd_lfc_set_low_water,
5964 (void *)&cmd_lfc_set_portid,
5969 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5970 .f = cmd_link_flow_ctrl_set_parsed,
5971 .data = (void *)&cmd_link_flow_control_set_pt,
5972 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5973 "Change pause time flow control parameter",
5975 (void *)&cmd_lfc_set_set,
5976 (void *)&cmd_lfc_set_flow_ctrl,
5977 (void *)&cmd_lfc_set_pause_time_str,
5978 (void *)&cmd_lfc_set_pause_time,
5979 (void *)&cmd_lfc_set_portid,
5984 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5985 .f = cmd_link_flow_ctrl_set_parsed,
5986 .data = (void *)&cmd_link_flow_control_set_xon,
5987 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5988 "Change send_xon flow control parameter",
5990 (void *)&cmd_lfc_set_set,
5991 (void *)&cmd_lfc_set_flow_ctrl,
5992 (void *)&cmd_lfc_set_send_xon_str,
5993 (void *)&cmd_lfc_set_send_xon,
5994 (void *)&cmd_lfc_set_portid,
5999 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6000 .f = cmd_link_flow_ctrl_set_parsed,
6001 .data = (void *)&cmd_link_flow_control_set_macfwd,
6002 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6003 "Change mac ctrl fwd flow control parameter",
6005 (void *)&cmd_lfc_set_set,
6006 (void *)&cmd_lfc_set_flow_ctrl,
6007 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6008 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6009 (void *)&cmd_lfc_set_portid,
6014 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6015 .f = cmd_link_flow_ctrl_set_parsed,
6016 .data = (void *)&cmd_link_flow_control_set_autoneg,
6017 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6018 "Change autoneg flow control parameter",
6020 (void *)&cmd_lfc_set_set,
6021 (void *)&cmd_lfc_set_flow_ctrl,
6022 (void *)&cmd_lfc_set_autoneg_str,
6023 (void *)&cmd_lfc_set_autoneg,
6024 (void *)&cmd_lfc_set_portid,
6030 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6031 __attribute__((unused)) struct cmdline *cl,
6034 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6035 cmdline_parse_inst_t *cmd = data;
6036 struct rte_eth_fc_conf fc_conf;
6042 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6043 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6044 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6045 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6047 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6048 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6051 /* Partial command line, retrieve current configuration */
6053 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6055 printf("cannot get current flow ctrl parameters, return"
6056 "code = %d\n", ret);
6060 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6061 (fc_conf.mode == RTE_FC_FULL))
6063 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6064 (fc_conf.mode == RTE_FC_FULL))
6068 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6069 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6071 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6072 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6074 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6076 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6077 fc_conf.high_water = res->high_water;
6079 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6080 fc_conf.low_water = res->low_water;
6082 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6083 fc_conf.pause_time = res->pause_time;
6085 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6086 fc_conf.send_xon = res->send_xon;
6088 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6089 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6090 fc_conf.mac_ctrl_frame_fwd = 1;
6092 fc_conf.mac_ctrl_frame_fwd = 0;
6095 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6096 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6098 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6100 printf("bad flow contrl parameter, return code = %d \n", ret);
6103 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6104 struct cmd_priority_flow_ctrl_set_result {
6105 cmdline_fixed_string_t set;
6106 cmdline_fixed_string_t pfc_ctrl;
6107 cmdline_fixed_string_t rx;
6108 cmdline_fixed_string_t rx_pfc_mode;
6109 cmdline_fixed_string_t tx;
6110 cmdline_fixed_string_t tx_pfc_mode;
6111 uint32_t high_water;
6113 uint16_t pause_time;
6119 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6120 __attribute__((unused)) struct cmdline *cl,
6121 __attribute__((unused)) void *data)
6123 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6124 struct rte_eth_pfc_conf pfc_conf;
6125 int rx_fc_enable, tx_fc_enable;
6129 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6130 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6131 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6132 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6134 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6135 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6138 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6139 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6140 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6141 pfc_conf.fc.high_water = res->high_water;
6142 pfc_conf.fc.low_water = res->low_water;
6143 pfc_conf.fc.pause_time = res->pause_time;
6144 pfc_conf.priority = res->priority;
6146 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6148 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6151 cmdline_parse_token_string_t cmd_pfc_set_set =
6152 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6154 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6155 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6156 pfc_ctrl, "pfc_ctrl");
6157 cmdline_parse_token_string_t cmd_pfc_set_rx =
6158 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6160 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6161 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6162 rx_pfc_mode, "on#off");
6163 cmdline_parse_token_string_t cmd_pfc_set_tx =
6164 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6166 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6167 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6168 tx_pfc_mode, "on#off");
6169 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6170 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6171 high_water, UINT32);
6172 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6173 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6175 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6176 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6177 pause_time, UINT16);
6178 cmdline_parse_token_num_t cmd_pfc_set_priority =
6179 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6181 cmdline_parse_token_num_t cmd_pfc_set_portid =
6182 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6185 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6186 .f = cmd_priority_flow_ctrl_set_parsed,
6188 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6189 "<pause_time> <priority> <port_id>: "
6190 "Configure the Ethernet priority flow control",
6192 (void *)&cmd_pfc_set_set,
6193 (void *)&cmd_pfc_set_flow_ctrl,
6194 (void *)&cmd_pfc_set_rx,
6195 (void *)&cmd_pfc_set_rx_mode,
6196 (void *)&cmd_pfc_set_tx,
6197 (void *)&cmd_pfc_set_tx_mode,
6198 (void *)&cmd_pfc_set_high_water,
6199 (void *)&cmd_pfc_set_low_water,
6200 (void *)&cmd_pfc_set_pause_time,
6201 (void *)&cmd_pfc_set_priority,
6202 (void *)&cmd_pfc_set_portid,
6207 /* *** RESET CONFIGURATION *** */
6208 struct cmd_reset_result {
6209 cmdline_fixed_string_t reset;
6210 cmdline_fixed_string_t def;
6213 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6215 __attribute__((unused)) void *data)
6217 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6218 set_def_fwd_config();
6221 cmdline_parse_token_string_t cmd_reset_set =
6222 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6223 cmdline_parse_token_string_t cmd_reset_def =
6224 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6227 cmdline_parse_inst_t cmd_reset = {
6228 .f = cmd_reset_parsed,
6230 .help_str = "set default: Reset default forwarding configuration",
6232 (void *)&cmd_reset_set,
6233 (void *)&cmd_reset_def,
6238 /* *** START FORWARDING *** */
6239 struct cmd_start_result {
6240 cmdline_fixed_string_t start;
6243 cmdline_parse_token_string_t cmd_start_start =
6244 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6246 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6247 __attribute__((unused)) struct cmdline *cl,
6248 __attribute__((unused)) void *data)
6250 start_packet_forwarding(0);
6253 cmdline_parse_inst_t cmd_start = {
6254 .f = cmd_start_parsed,
6256 .help_str = "start: Start packet forwarding",
6258 (void *)&cmd_start_start,
6263 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6264 struct cmd_start_tx_first_result {
6265 cmdline_fixed_string_t start;
6266 cmdline_fixed_string_t tx_first;
6270 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6271 __attribute__((unused)) struct cmdline *cl,
6272 __attribute__((unused)) void *data)
6274 start_packet_forwarding(1);
6277 cmdline_parse_token_string_t cmd_start_tx_first_start =
6278 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6280 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6281 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6282 tx_first, "tx_first");
6284 cmdline_parse_inst_t cmd_start_tx_first = {
6285 .f = cmd_start_tx_first_parsed,
6287 .help_str = "start tx_first: Start packet forwarding, "
6288 "after sending 1 burst of packets",
6290 (void *)&cmd_start_tx_first_start,
6291 (void *)&cmd_start_tx_first_tx_first,
6296 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6297 struct cmd_start_tx_first_n_result {
6298 cmdline_fixed_string_t start;
6299 cmdline_fixed_string_t tx_first;
6304 cmd_start_tx_first_n_parsed(void *parsed_result,
6305 __attribute__((unused)) struct cmdline *cl,
6306 __attribute__((unused)) void *data)
6308 struct cmd_start_tx_first_n_result *res = parsed_result;
6310 start_packet_forwarding(res->tx_num);
6313 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6314 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6316 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6317 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6318 tx_first, "tx_first");
6319 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6320 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6323 cmdline_parse_inst_t cmd_start_tx_first_n = {
6324 .f = cmd_start_tx_first_n_parsed,
6326 .help_str = "start tx_first <num>: "
6327 "packet forwarding, after sending <num> bursts of packets",
6329 (void *)&cmd_start_tx_first_n_start,
6330 (void *)&cmd_start_tx_first_n_tx_first,
6331 (void *)&cmd_start_tx_first_n_tx_num,
6336 /* *** SET LINK UP *** */
6337 struct cmd_set_link_up_result {
6338 cmdline_fixed_string_t set;
6339 cmdline_fixed_string_t link_up;
6340 cmdline_fixed_string_t port;
6344 cmdline_parse_token_string_t cmd_set_link_up_set =
6345 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6346 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6347 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6349 cmdline_parse_token_string_t cmd_set_link_up_port =
6350 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6351 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6352 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6354 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6355 __attribute__((unused)) struct cmdline *cl,
6356 __attribute__((unused)) void *data)
6358 struct cmd_set_link_up_result *res = parsed_result;
6359 dev_set_link_up(res->port_id);
6362 cmdline_parse_inst_t cmd_set_link_up = {
6363 .f = cmd_set_link_up_parsed,
6365 .help_str = "set link-up port <port id>",
6367 (void *)&cmd_set_link_up_set,
6368 (void *)&cmd_set_link_up_link_up,
6369 (void *)&cmd_set_link_up_port,
6370 (void *)&cmd_set_link_up_port_id,
6375 /* *** SET LINK DOWN *** */
6376 struct cmd_set_link_down_result {
6377 cmdline_fixed_string_t set;
6378 cmdline_fixed_string_t link_down;
6379 cmdline_fixed_string_t port;
6383 cmdline_parse_token_string_t cmd_set_link_down_set =
6384 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6385 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6386 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6388 cmdline_parse_token_string_t cmd_set_link_down_port =
6389 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6390 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6391 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6393 static void cmd_set_link_down_parsed(
6394 __attribute__((unused)) void *parsed_result,
6395 __attribute__((unused)) struct cmdline *cl,
6396 __attribute__((unused)) void *data)
6398 struct cmd_set_link_down_result *res = parsed_result;
6399 dev_set_link_down(res->port_id);
6402 cmdline_parse_inst_t cmd_set_link_down = {
6403 .f = cmd_set_link_down_parsed,
6405 .help_str = "set link-down port <port id>",
6407 (void *)&cmd_set_link_down_set,
6408 (void *)&cmd_set_link_down_link_down,
6409 (void *)&cmd_set_link_down_port,
6410 (void *)&cmd_set_link_down_port_id,
6415 /* *** SHOW CFG *** */
6416 struct cmd_showcfg_result {
6417 cmdline_fixed_string_t show;
6418 cmdline_fixed_string_t cfg;
6419 cmdline_fixed_string_t what;
6422 static void cmd_showcfg_parsed(void *parsed_result,
6423 __attribute__((unused)) struct cmdline *cl,
6424 __attribute__((unused)) void *data)
6426 struct cmd_showcfg_result *res = parsed_result;
6427 if (!strcmp(res->what, "rxtx"))
6428 rxtx_config_display();
6429 else if (!strcmp(res->what, "cores"))
6430 fwd_lcores_config_display();
6431 else if (!strcmp(res->what, "fwd"))
6432 pkt_fwd_config_display(&cur_fwd_config);
6433 else if (!strcmp(res->what, "txpkts"))
6434 show_tx_pkt_segments();
6437 cmdline_parse_token_string_t cmd_showcfg_show =
6438 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6439 cmdline_parse_token_string_t cmd_showcfg_port =
6440 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6441 cmdline_parse_token_string_t cmd_showcfg_what =
6442 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6443 "rxtx#cores#fwd#txpkts");
6445 cmdline_parse_inst_t cmd_showcfg = {
6446 .f = cmd_showcfg_parsed,
6448 .help_str = "show config rxtx|cores|fwd|txpkts",
6450 (void *)&cmd_showcfg_show,
6451 (void *)&cmd_showcfg_port,
6452 (void *)&cmd_showcfg_what,
6457 /* *** SHOW ALL PORT INFO *** */
6458 struct cmd_showportall_result {
6459 cmdline_fixed_string_t show;
6460 cmdline_fixed_string_t port;
6461 cmdline_fixed_string_t what;
6462 cmdline_fixed_string_t all;
6465 static void cmd_showportall_parsed(void *parsed_result,
6466 __attribute__((unused)) struct cmdline *cl,
6467 __attribute__((unused)) void *data)
6471 struct cmd_showportall_result *res = parsed_result;
6472 if (!strcmp(res->show, "clear")) {
6473 if (!strcmp(res->what, "stats"))
6474 RTE_ETH_FOREACH_DEV(i)
6476 else if (!strcmp(res->what, "xstats"))
6477 RTE_ETH_FOREACH_DEV(i)
6478 nic_xstats_clear(i);
6479 } else if (!strcmp(res->what, "info"))
6480 RTE_ETH_FOREACH_DEV(i)
6481 port_infos_display(i);
6482 else if (!strcmp(res->what, "stats"))
6483 RTE_ETH_FOREACH_DEV(i)
6484 nic_stats_display(i);
6485 else if (!strcmp(res->what, "xstats"))
6486 RTE_ETH_FOREACH_DEV(i)
6487 nic_xstats_display(i);
6488 else if (!strcmp(res->what, "fdir"))
6489 RTE_ETH_FOREACH_DEV(i)
6491 else if (!strcmp(res->what, "stat_qmap"))
6492 RTE_ETH_FOREACH_DEV(i)
6493 nic_stats_mapping_display(i);
6494 else if (!strcmp(res->what, "dcb_tc"))
6495 RTE_ETH_FOREACH_DEV(i)
6496 port_dcb_info_display(i);
6497 else if (!strcmp(res->what, "cap"))
6498 RTE_ETH_FOREACH_DEV(i)
6499 port_offload_cap_display(i);
6502 cmdline_parse_token_string_t cmd_showportall_show =
6503 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6505 cmdline_parse_token_string_t cmd_showportall_port =
6506 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6507 cmdline_parse_token_string_t cmd_showportall_what =
6508 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6509 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6510 cmdline_parse_token_string_t cmd_showportall_all =
6511 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6512 cmdline_parse_inst_t cmd_showportall = {
6513 .f = cmd_showportall_parsed,
6515 .help_str = "show|clear port "
6516 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6518 (void *)&cmd_showportall_show,
6519 (void *)&cmd_showportall_port,
6520 (void *)&cmd_showportall_what,
6521 (void *)&cmd_showportall_all,
6526 /* *** SHOW PORT INFO *** */
6527 struct cmd_showport_result {
6528 cmdline_fixed_string_t show;
6529 cmdline_fixed_string_t port;
6530 cmdline_fixed_string_t what;
6534 static void cmd_showport_parsed(void *parsed_result,
6535 __attribute__((unused)) struct cmdline *cl,
6536 __attribute__((unused)) void *data)
6538 struct cmd_showport_result *res = parsed_result;
6539 if (!strcmp(res->show, "clear")) {
6540 if (!strcmp(res->what, "stats"))
6541 nic_stats_clear(res->portnum);
6542 else if (!strcmp(res->what, "xstats"))
6543 nic_xstats_clear(res->portnum);
6544 } else if (!strcmp(res->what, "info"))
6545 port_infos_display(res->portnum);
6546 else if (!strcmp(res->what, "stats"))
6547 nic_stats_display(res->portnum);
6548 else if (!strcmp(res->what, "xstats"))
6549 nic_xstats_display(res->portnum);
6550 else if (!strcmp(res->what, "fdir"))
6551 fdir_get_infos(res->portnum);
6552 else if (!strcmp(res->what, "stat_qmap"))
6553 nic_stats_mapping_display(res->portnum);
6554 else if (!strcmp(res->what, "dcb_tc"))
6555 port_dcb_info_display(res->portnum);
6556 else if (!strcmp(res->what, "cap"))
6557 port_offload_cap_display(res->portnum);
6560 cmdline_parse_token_string_t cmd_showport_show =
6561 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6563 cmdline_parse_token_string_t cmd_showport_port =
6564 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6565 cmdline_parse_token_string_t cmd_showport_what =
6566 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6567 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6568 cmdline_parse_token_num_t cmd_showport_portnum =
6569 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6571 cmdline_parse_inst_t cmd_showport = {
6572 .f = cmd_showport_parsed,
6574 .help_str = "show|clear port "
6575 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6578 (void *)&cmd_showport_show,
6579 (void *)&cmd_showport_port,
6580 (void *)&cmd_showport_what,
6581 (void *)&cmd_showport_portnum,
6586 /* *** SHOW QUEUE INFO *** */
6587 struct cmd_showqueue_result {
6588 cmdline_fixed_string_t show;
6589 cmdline_fixed_string_t type;
6590 cmdline_fixed_string_t what;
6596 cmd_showqueue_parsed(void *parsed_result,
6597 __attribute__((unused)) struct cmdline *cl,
6598 __attribute__((unused)) void *data)
6600 struct cmd_showqueue_result *res = parsed_result;
6602 if (!strcmp(res->type, "rxq"))
6603 rx_queue_infos_display(res->portnum, res->queuenum);
6604 else if (!strcmp(res->type, "txq"))
6605 tx_queue_infos_display(res->portnum, res->queuenum);
6608 cmdline_parse_token_string_t cmd_showqueue_show =
6609 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6610 cmdline_parse_token_string_t cmd_showqueue_type =
6611 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6612 cmdline_parse_token_string_t cmd_showqueue_what =
6613 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6614 cmdline_parse_token_num_t cmd_showqueue_portnum =
6615 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6616 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6617 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6619 cmdline_parse_inst_t cmd_showqueue = {
6620 .f = cmd_showqueue_parsed,
6622 .help_str = "show rxq|txq info <port_id> <queue_id>",
6624 (void *)&cmd_showqueue_show,
6625 (void *)&cmd_showqueue_type,
6626 (void *)&cmd_showqueue_what,
6627 (void *)&cmd_showqueue_portnum,
6628 (void *)&cmd_showqueue_queuenum,
6633 /* *** READ PORT REGISTER *** */
6634 struct cmd_read_reg_result {
6635 cmdline_fixed_string_t read;
6636 cmdline_fixed_string_t reg;
6642 cmd_read_reg_parsed(void *parsed_result,
6643 __attribute__((unused)) struct cmdline *cl,
6644 __attribute__((unused)) void *data)
6646 struct cmd_read_reg_result *res = parsed_result;
6647 port_reg_display(res->port_id, res->reg_off);
6650 cmdline_parse_token_string_t cmd_read_reg_read =
6651 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6652 cmdline_parse_token_string_t cmd_read_reg_reg =
6653 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6654 cmdline_parse_token_num_t cmd_read_reg_port_id =
6655 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6656 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6657 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6659 cmdline_parse_inst_t cmd_read_reg = {
6660 .f = cmd_read_reg_parsed,
6662 .help_str = "read reg <port_id> <reg_off>",
6664 (void *)&cmd_read_reg_read,
6665 (void *)&cmd_read_reg_reg,
6666 (void *)&cmd_read_reg_port_id,
6667 (void *)&cmd_read_reg_reg_off,
6672 /* *** READ PORT REGISTER BIT FIELD *** */
6673 struct cmd_read_reg_bit_field_result {
6674 cmdline_fixed_string_t read;
6675 cmdline_fixed_string_t regfield;
6683 cmd_read_reg_bit_field_parsed(void *parsed_result,
6684 __attribute__((unused)) struct cmdline *cl,
6685 __attribute__((unused)) void *data)
6687 struct cmd_read_reg_bit_field_result *res = parsed_result;
6688 port_reg_bit_field_display(res->port_id, res->reg_off,
6689 res->bit1_pos, res->bit2_pos);
6692 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6693 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6695 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6696 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6697 regfield, "regfield");
6698 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6699 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6701 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6702 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6704 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6705 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6707 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6708 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6711 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6712 .f = cmd_read_reg_bit_field_parsed,
6714 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6715 "Read register bit field between bit_x and bit_y included",
6717 (void *)&cmd_read_reg_bit_field_read,
6718 (void *)&cmd_read_reg_bit_field_regfield,
6719 (void *)&cmd_read_reg_bit_field_port_id,
6720 (void *)&cmd_read_reg_bit_field_reg_off,
6721 (void *)&cmd_read_reg_bit_field_bit1_pos,
6722 (void *)&cmd_read_reg_bit_field_bit2_pos,
6727 /* *** READ PORT REGISTER BIT *** */
6728 struct cmd_read_reg_bit_result {
6729 cmdline_fixed_string_t read;
6730 cmdline_fixed_string_t regbit;
6737 cmd_read_reg_bit_parsed(void *parsed_result,
6738 __attribute__((unused)) struct cmdline *cl,
6739 __attribute__((unused)) void *data)
6741 struct cmd_read_reg_bit_result *res = parsed_result;
6742 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6745 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6746 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6747 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6748 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6750 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6751 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6752 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6753 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6754 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6755 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6757 cmdline_parse_inst_t cmd_read_reg_bit = {
6758 .f = cmd_read_reg_bit_parsed,
6760 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6762 (void *)&cmd_read_reg_bit_read,
6763 (void *)&cmd_read_reg_bit_regbit,
6764 (void *)&cmd_read_reg_bit_port_id,
6765 (void *)&cmd_read_reg_bit_reg_off,
6766 (void *)&cmd_read_reg_bit_bit_pos,
6771 /* *** WRITE PORT REGISTER *** */
6772 struct cmd_write_reg_result {
6773 cmdline_fixed_string_t write;
6774 cmdline_fixed_string_t reg;
6781 cmd_write_reg_parsed(void *parsed_result,
6782 __attribute__((unused)) struct cmdline *cl,
6783 __attribute__((unused)) void *data)
6785 struct cmd_write_reg_result *res = parsed_result;
6786 port_reg_set(res->port_id, res->reg_off, res->value);
6789 cmdline_parse_token_string_t cmd_write_reg_write =
6790 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6791 cmdline_parse_token_string_t cmd_write_reg_reg =
6792 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6793 cmdline_parse_token_num_t cmd_write_reg_port_id =
6794 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6795 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6796 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6797 cmdline_parse_token_num_t cmd_write_reg_value =
6798 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6800 cmdline_parse_inst_t cmd_write_reg = {
6801 .f = cmd_write_reg_parsed,
6803 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6805 (void *)&cmd_write_reg_write,
6806 (void *)&cmd_write_reg_reg,
6807 (void *)&cmd_write_reg_port_id,
6808 (void *)&cmd_write_reg_reg_off,
6809 (void *)&cmd_write_reg_value,
6814 /* *** WRITE PORT REGISTER BIT FIELD *** */
6815 struct cmd_write_reg_bit_field_result {
6816 cmdline_fixed_string_t write;
6817 cmdline_fixed_string_t regfield;
6826 cmd_write_reg_bit_field_parsed(void *parsed_result,
6827 __attribute__((unused)) struct cmdline *cl,
6828 __attribute__((unused)) void *data)
6830 struct cmd_write_reg_bit_field_result *res = parsed_result;
6831 port_reg_bit_field_set(res->port_id, res->reg_off,
6832 res->bit1_pos, res->bit2_pos, res->value);
6835 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6836 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6838 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6839 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6840 regfield, "regfield");
6841 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6842 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6844 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6845 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6847 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6848 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6850 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6851 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6853 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6854 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6857 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6858 .f = cmd_write_reg_bit_field_parsed,
6860 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6862 "Set register bit field between bit_x and bit_y included",
6864 (void *)&cmd_write_reg_bit_field_write,
6865 (void *)&cmd_write_reg_bit_field_regfield,
6866 (void *)&cmd_write_reg_bit_field_port_id,
6867 (void *)&cmd_write_reg_bit_field_reg_off,
6868 (void *)&cmd_write_reg_bit_field_bit1_pos,
6869 (void *)&cmd_write_reg_bit_field_bit2_pos,
6870 (void *)&cmd_write_reg_bit_field_value,
6875 /* *** WRITE PORT REGISTER BIT *** */
6876 struct cmd_write_reg_bit_result {
6877 cmdline_fixed_string_t write;
6878 cmdline_fixed_string_t regbit;
6886 cmd_write_reg_bit_parsed(void *parsed_result,
6887 __attribute__((unused)) struct cmdline *cl,
6888 __attribute__((unused)) void *data)
6890 struct cmd_write_reg_bit_result *res = parsed_result;
6891 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6894 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6895 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6897 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6898 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6900 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6901 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
6902 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6903 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6904 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6905 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6906 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6907 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6909 cmdline_parse_inst_t cmd_write_reg_bit = {
6910 .f = cmd_write_reg_bit_parsed,
6912 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6915 (void *)&cmd_write_reg_bit_write,
6916 (void *)&cmd_write_reg_bit_regbit,
6917 (void *)&cmd_write_reg_bit_port_id,
6918 (void *)&cmd_write_reg_bit_reg_off,
6919 (void *)&cmd_write_reg_bit_bit_pos,
6920 (void *)&cmd_write_reg_bit_value,
6925 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6926 struct cmd_read_rxd_txd_result {
6927 cmdline_fixed_string_t read;
6928 cmdline_fixed_string_t rxd_txd;
6935 cmd_read_rxd_txd_parsed(void *parsed_result,
6936 __attribute__((unused)) struct cmdline *cl,
6937 __attribute__((unused)) void *data)
6939 struct cmd_read_rxd_txd_result *res = parsed_result;
6941 if (!strcmp(res->rxd_txd, "rxd"))
6942 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6943 else if (!strcmp(res->rxd_txd, "txd"))
6944 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6947 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6948 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6949 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6950 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6952 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6953 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
6954 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6955 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6956 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6957 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6959 cmdline_parse_inst_t cmd_read_rxd_txd = {
6960 .f = cmd_read_rxd_txd_parsed,
6962 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6964 (void *)&cmd_read_rxd_txd_read,
6965 (void *)&cmd_read_rxd_txd_rxd_txd,
6966 (void *)&cmd_read_rxd_txd_port_id,
6967 (void *)&cmd_read_rxd_txd_queue_id,
6968 (void *)&cmd_read_rxd_txd_desc_id,
6974 struct cmd_quit_result {
6975 cmdline_fixed_string_t quit;
6978 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6980 __attribute__((unused)) void *data)
6986 cmdline_parse_token_string_t cmd_quit_quit =
6987 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6989 cmdline_parse_inst_t cmd_quit = {
6990 .f = cmd_quit_parsed,
6992 .help_str = "quit: Exit application",
6994 (void *)&cmd_quit_quit,
6999 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7000 struct cmd_mac_addr_result {
7001 cmdline_fixed_string_t mac_addr_cmd;
7002 cmdline_fixed_string_t what;
7004 struct ether_addr address;
7007 static void cmd_mac_addr_parsed(void *parsed_result,
7008 __attribute__((unused)) struct cmdline *cl,
7009 __attribute__((unused)) void *data)
7011 struct cmd_mac_addr_result *res = parsed_result;
7014 if (strcmp(res->what, "add") == 0)
7015 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7016 else if (strcmp(res->what, "set") == 0)
7017 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7020 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7022 /* check the return value and print it if is < 0 */
7024 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7028 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7029 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7031 cmdline_parse_token_string_t cmd_mac_addr_what =
7032 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7034 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7035 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7037 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7038 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7040 cmdline_parse_inst_t cmd_mac_addr = {
7041 .f = cmd_mac_addr_parsed,
7043 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7044 "Add/Remove/Set MAC address on port_id",
7046 (void *)&cmd_mac_addr_cmd,
7047 (void *)&cmd_mac_addr_what,
7048 (void *)&cmd_mac_addr_portnum,
7049 (void *)&cmd_mac_addr_addr,
7055 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7056 struct cmd_set_qmap_result {
7057 cmdline_fixed_string_t set;
7058 cmdline_fixed_string_t qmap;
7059 cmdline_fixed_string_t what;
7066 cmd_set_qmap_parsed(void *parsed_result,
7067 __attribute__((unused)) struct cmdline *cl,
7068 __attribute__((unused)) void *data)
7070 struct cmd_set_qmap_result *res = parsed_result;
7071 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7073 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7076 cmdline_parse_token_string_t cmd_setqmap_set =
7077 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7079 cmdline_parse_token_string_t cmd_setqmap_qmap =
7080 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7082 cmdline_parse_token_string_t cmd_setqmap_what =
7083 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7085 cmdline_parse_token_num_t cmd_setqmap_portid =
7086 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7088 cmdline_parse_token_num_t cmd_setqmap_queueid =
7089 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7091 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7092 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7095 cmdline_parse_inst_t cmd_set_qmap = {
7096 .f = cmd_set_qmap_parsed,
7098 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7099 "Set statistics mapping value on tx|rx queue_id of port_id",
7101 (void *)&cmd_setqmap_set,
7102 (void *)&cmd_setqmap_qmap,
7103 (void *)&cmd_setqmap_what,
7104 (void *)&cmd_setqmap_portid,
7105 (void *)&cmd_setqmap_queueid,
7106 (void *)&cmd_setqmap_mapvalue,
7111 /* *** CONFIGURE UNICAST HASH TABLE *** */
7112 struct cmd_set_uc_hash_table {
7113 cmdline_fixed_string_t set;
7114 cmdline_fixed_string_t port;
7116 cmdline_fixed_string_t what;
7117 struct ether_addr address;
7118 cmdline_fixed_string_t mode;
7122 cmd_set_uc_hash_parsed(void *parsed_result,
7123 __attribute__((unused)) struct cmdline *cl,
7124 __attribute__((unused)) void *data)
7127 struct cmd_set_uc_hash_table *res = parsed_result;
7129 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7131 if (strcmp(res->what, "uta") == 0)
7132 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7133 &res->address,(uint8_t)is_on);
7135 printf("bad unicast hash table parameter, return code = %d \n", ret);
7139 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7140 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7142 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7143 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7145 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7146 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7148 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7149 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7151 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7152 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7154 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7155 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7158 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7159 .f = cmd_set_uc_hash_parsed,
7161 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7163 (void *)&cmd_set_uc_hash_set,
7164 (void *)&cmd_set_uc_hash_port,
7165 (void *)&cmd_set_uc_hash_portid,
7166 (void *)&cmd_set_uc_hash_what,
7167 (void *)&cmd_set_uc_hash_mac,
7168 (void *)&cmd_set_uc_hash_mode,
7173 struct cmd_set_uc_all_hash_table {
7174 cmdline_fixed_string_t set;
7175 cmdline_fixed_string_t port;
7177 cmdline_fixed_string_t what;
7178 cmdline_fixed_string_t value;
7179 cmdline_fixed_string_t mode;
7183 cmd_set_uc_all_hash_parsed(void *parsed_result,
7184 __attribute__((unused)) struct cmdline *cl,
7185 __attribute__((unused)) void *data)
7188 struct cmd_set_uc_all_hash_table *res = parsed_result;
7190 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7192 if ((strcmp(res->what, "uta") == 0) &&
7193 (strcmp(res->value, "all") == 0))
7194 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7196 printf("bad unicast hash table parameter,"
7197 "return code = %d \n", ret);
7200 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7201 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7203 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7204 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7206 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7207 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7209 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7210 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7212 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7213 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7215 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7216 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7219 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7220 .f = cmd_set_uc_all_hash_parsed,
7222 .help_str = "set port <port_id> uta all on|off",
7224 (void *)&cmd_set_uc_all_hash_set,
7225 (void *)&cmd_set_uc_all_hash_port,
7226 (void *)&cmd_set_uc_all_hash_portid,
7227 (void *)&cmd_set_uc_all_hash_what,
7228 (void *)&cmd_set_uc_all_hash_value,
7229 (void *)&cmd_set_uc_all_hash_mode,
7234 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7235 struct cmd_set_vf_macvlan_filter {
7236 cmdline_fixed_string_t set;
7237 cmdline_fixed_string_t port;
7239 cmdline_fixed_string_t vf;
7241 struct ether_addr address;
7242 cmdline_fixed_string_t filter_type;
7243 cmdline_fixed_string_t mode;
7247 cmd_set_vf_macvlan_parsed(void *parsed_result,
7248 __attribute__((unused)) struct cmdline *cl,
7249 __attribute__((unused)) void *data)
7252 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7253 struct rte_eth_mac_filter filter;
7255 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7257 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7259 /* set VF MAC filter */
7263 filter.dst_id = res->vf_id;
7265 if (!strcmp(res->filter_type, "exact-mac"))
7266 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7267 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7268 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7269 else if (!strcmp(res->filter_type, "hashmac"))
7270 filter.filter_type = RTE_MAC_HASH_MATCH;
7271 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7272 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7274 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7277 ret = rte_eth_dev_filter_ctrl(res->port_id,
7278 RTE_ETH_FILTER_MACVLAN,
7282 ret = rte_eth_dev_filter_ctrl(res->port_id,
7283 RTE_ETH_FILTER_MACVLAN,
7284 RTE_ETH_FILTER_DELETE,
7288 printf("bad set MAC hash parameter, return code = %d\n", ret);
7292 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7293 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7295 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7296 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7298 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7299 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7301 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7302 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7304 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7305 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7307 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7308 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7310 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7311 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7312 filter_type, "exact-mac#exact-mac-vlan"
7313 "#hashmac#hashmac-vlan");
7314 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7315 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7318 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7319 .f = cmd_set_vf_macvlan_parsed,
7321 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7322 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7323 "Exact match rule: exact match of MAC or MAC and VLAN; "
7324 "hash match rule: hash match of MAC and exact match of VLAN",
7326 (void *)&cmd_set_vf_macvlan_set,
7327 (void *)&cmd_set_vf_macvlan_port,
7328 (void *)&cmd_set_vf_macvlan_portid,
7329 (void *)&cmd_set_vf_macvlan_vf,
7330 (void *)&cmd_set_vf_macvlan_vf_id,
7331 (void *)&cmd_set_vf_macvlan_mac,
7332 (void *)&cmd_set_vf_macvlan_filter_type,
7333 (void *)&cmd_set_vf_macvlan_mode,
7338 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7339 struct cmd_set_vf_traffic {
7340 cmdline_fixed_string_t set;
7341 cmdline_fixed_string_t port;
7343 cmdline_fixed_string_t vf;
7345 cmdline_fixed_string_t what;
7346 cmdline_fixed_string_t mode;
7350 cmd_set_vf_traffic_parsed(void *parsed_result,
7351 __attribute__((unused)) struct cmdline *cl,
7352 __attribute__((unused)) void *data)
7354 struct cmd_set_vf_traffic *res = parsed_result;
7355 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7356 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7358 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7361 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7362 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7364 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7365 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7367 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7368 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7370 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7371 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7373 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7374 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7376 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7377 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7379 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7380 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7383 cmdline_parse_inst_t cmd_set_vf_traffic = {
7384 .f = cmd_set_vf_traffic_parsed,
7386 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7388 (void *)&cmd_setvf_traffic_set,
7389 (void *)&cmd_setvf_traffic_port,
7390 (void *)&cmd_setvf_traffic_portid,
7391 (void *)&cmd_setvf_traffic_vf,
7392 (void *)&cmd_setvf_traffic_vfid,
7393 (void *)&cmd_setvf_traffic_what,
7394 (void *)&cmd_setvf_traffic_mode,
7399 /* *** CONFIGURE VF RECEIVE MODE *** */
7400 struct cmd_set_vf_rxmode {
7401 cmdline_fixed_string_t set;
7402 cmdline_fixed_string_t port;
7404 cmdline_fixed_string_t vf;
7406 cmdline_fixed_string_t what;
7407 cmdline_fixed_string_t mode;
7408 cmdline_fixed_string_t on;
7412 cmd_set_vf_rxmode_parsed(void *parsed_result,
7413 __attribute__((unused)) struct cmdline *cl,
7414 __attribute__((unused)) void *data)
7417 uint16_t rx_mode = 0;
7418 struct cmd_set_vf_rxmode *res = parsed_result;
7420 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7421 if (!strcmp(res->what,"rxmode")) {
7422 if (!strcmp(res->mode, "AUPE"))
7423 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7424 else if (!strcmp(res->mode, "ROPE"))
7425 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7426 else if (!strcmp(res->mode, "BAM"))
7427 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7428 else if (!strncmp(res->mode, "MPE",3))
7429 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7432 #ifdef RTE_LIBRTE_IXGBE_PMD
7433 if (ret == -ENOTSUP)
7434 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7435 rx_mode, (uint8_t)is_on);
7437 #ifdef RTE_LIBRTE_BNXT_PMD
7438 if (ret == -ENOTSUP)
7439 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7440 rx_mode, (uint8_t)is_on);
7443 printf("bad VF receive mode parameter, return code = %d \n",
7447 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7448 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7450 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7451 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7453 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7454 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7456 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7457 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7459 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7460 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7462 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7463 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7465 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7466 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7467 mode, "AUPE#ROPE#BAM#MPE");
7468 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7469 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7472 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7473 .f = cmd_set_vf_rxmode_parsed,
7475 .help_str = "set port <port_id> vf <vf_id> rxmode "
7476 "AUPE|ROPE|BAM|MPE on|off",
7478 (void *)&cmd_set_vf_rxmode_set,
7479 (void *)&cmd_set_vf_rxmode_port,
7480 (void *)&cmd_set_vf_rxmode_portid,
7481 (void *)&cmd_set_vf_rxmode_vf,
7482 (void *)&cmd_set_vf_rxmode_vfid,
7483 (void *)&cmd_set_vf_rxmode_what,
7484 (void *)&cmd_set_vf_rxmode_mode,
7485 (void *)&cmd_set_vf_rxmode_on,
7490 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7491 struct cmd_vf_mac_addr_result {
7492 cmdline_fixed_string_t mac_addr_cmd;
7493 cmdline_fixed_string_t what;
7494 cmdline_fixed_string_t port;
7496 cmdline_fixed_string_t vf;
7498 struct ether_addr address;
7501 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7502 __attribute__((unused)) struct cmdline *cl,
7503 __attribute__((unused)) void *data)
7505 struct cmd_vf_mac_addr_result *res = parsed_result;
7508 if (strcmp(res->what, "add") != 0)
7511 #ifdef RTE_LIBRTE_I40E_PMD
7512 if (ret == -ENOTSUP)
7513 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7516 #ifdef RTE_LIBRTE_BNXT_PMD
7517 if (ret == -ENOTSUP)
7518 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7523 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7527 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7528 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7529 mac_addr_cmd,"mac_addr");
7530 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7531 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7533 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7534 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7536 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7537 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7539 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7540 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7542 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7543 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7545 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7546 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7549 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7550 .f = cmd_vf_mac_addr_parsed,
7552 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7553 "Add MAC address filtering for a VF on port_id",
7555 (void *)&cmd_vf_mac_addr_cmd,
7556 (void *)&cmd_vf_mac_addr_what,
7557 (void *)&cmd_vf_mac_addr_port,
7558 (void *)&cmd_vf_mac_addr_portnum,
7559 (void *)&cmd_vf_mac_addr_vf,
7560 (void *)&cmd_vf_mac_addr_vfnum,
7561 (void *)&cmd_vf_mac_addr_addr,
7566 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7567 struct cmd_vf_rx_vlan_filter {
7568 cmdline_fixed_string_t rx_vlan;
7569 cmdline_fixed_string_t what;
7571 cmdline_fixed_string_t port;
7573 cmdline_fixed_string_t vf;
7578 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7579 __attribute__((unused)) struct cmdline *cl,
7580 __attribute__((unused)) void *data)
7582 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7585 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7587 #ifdef RTE_LIBRTE_IXGBE_PMD
7588 if (ret == -ENOTSUP)
7589 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7590 res->vlan_id, res->vf_mask, is_add);
7592 #ifdef RTE_LIBRTE_I40E_PMD
7593 if (ret == -ENOTSUP)
7594 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7595 res->vlan_id, res->vf_mask, is_add);
7597 #ifdef RTE_LIBRTE_BNXT_PMD
7598 if (ret == -ENOTSUP)
7599 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7600 res->vlan_id, res->vf_mask, is_add);
7607 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7608 res->vlan_id, res->vf_mask);
7611 printf("invalid port_id %d\n", res->port_id);
7614 printf("function not implemented or supported\n");
7617 printf("programming error: (%s)\n", strerror(-ret));
7621 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7622 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7623 rx_vlan, "rx_vlan");
7624 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7625 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7627 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7628 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7630 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7631 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7633 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7634 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7636 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7637 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7639 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7640 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7643 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7644 .f = cmd_vf_rx_vlan_filter_parsed,
7646 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7647 "(vf_mask = hexadecimal VF mask)",
7649 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7650 (void *)&cmd_vf_rx_vlan_filter_what,
7651 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7652 (void *)&cmd_vf_rx_vlan_filter_port,
7653 (void *)&cmd_vf_rx_vlan_filter_portid,
7654 (void *)&cmd_vf_rx_vlan_filter_vf,
7655 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7660 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7661 struct cmd_queue_rate_limit_result {
7662 cmdline_fixed_string_t set;
7663 cmdline_fixed_string_t port;
7665 cmdline_fixed_string_t queue;
7667 cmdline_fixed_string_t rate;
7671 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7672 __attribute__((unused)) struct cmdline *cl,
7673 __attribute__((unused)) void *data)
7675 struct cmd_queue_rate_limit_result *res = parsed_result;
7678 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7679 && (strcmp(res->queue, "queue") == 0)
7680 && (strcmp(res->rate, "rate") == 0))
7681 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7684 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7688 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7689 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7691 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7692 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7694 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7695 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7697 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7698 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7700 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7701 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7703 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7704 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7706 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7707 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7710 cmdline_parse_inst_t cmd_queue_rate_limit = {
7711 .f = cmd_queue_rate_limit_parsed,
7713 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7714 "Set rate limit for a queue on port_id",
7716 (void *)&cmd_queue_rate_limit_set,
7717 (void *)&cmd_queue_rate_limit_port,
7718 (void *)&cmd_queue_rate_limit_portnum,
7719 (void *)&cmd_queue_rate_limit_queue,
7720 (void *)&cmd_queue_rate_limit_queuenum,
7721 (void *)&cmd_queue_rate_limit_rate,
7722 (void *)&cmd_queue_rate_limit_ratenum,
7727 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7728 struct cmd_vf_rate_limit_result {
7729 cmdline_fixed_string_t set;
7730 cmdline_fixed_string_t port;
7732 cmdline_fixed_string_t vf;
7734 cmdline_fixed_string_t rate;
7736 cmdline_fixed_string_t q_msk;
7740 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7741 __attribute__((unused)) struct cmdline *cl,
7742 __attribute__((unused)) void *data)
7744 struct cmd_vf_rate_limit_result *res = parsed_result;
7747 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7748 && (strcmp(res->vf, "vf") == 0)
7749 && (strcmp(res->rate, "rate") == 0)
7750 && (strcmp(res->q_msk, "queue_mask") == 0))
7751 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7752 res->rate_num, res->q_msk_val);
7754 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7758 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7759 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7761 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7762 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7764 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7765 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7767 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7768 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7770 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7771 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7773 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7774 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7776 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7777 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7779 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7780 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7781 q_msk, "queue_mask");
7782 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7783 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7786 cmdline_parse_inst_t cmd_vf_rate_limit = {
7787 .f = cmd_vf_rate_limit_parsed,
7789 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7790 "queue_mask <queue_mask_value>: "
7791 "Set rate limit for queues of VF on port_id",
7793 (void *)&cmd_vf_rate_limit_set,
7794 (void *)&cmd_vf_rate_limit_port,
7795 (void *)&cmd_vf_rate_limit_portnum,
7796 (void *)&cmd_vf_rate_limit_vf,
7797 (void *)&cmd_vf_rate_limit_vfnum,
7798 (void *)&cmd_vf_rate_limit_rate,
7799 (void *)&cmd_vf_rate_limit_ratenum,
7800 (void *)&cmd_vf_rate_limit_q_msk,
7801 (void *)&cmd_vf_rate_limit_q_msk_val,
7806 /* *** ADD TUNNEL FILTER OF A PORT *** */
7807 struct cmd_tunnel_filter_result {
7808 cmdline_fixed_string_t cmd;
7809 cmdline_fixed_string_t what;
7811 struct ether_addr outer_mac;
7812 struct ether_addr inner_mac;
7813 cmdline_ipaddr_t ip_value;
7814 uint16_t inner_vlan;
7815 cmdline_fixed_string_t tunnel_type;
7816 cmdline_fixed_string_t filter_type;
7822 cmd_tunnel_filter_parsed(void *parsed_result,
7823 __attribute__((unused)) struct cmdline *cl,
7824 __attribute__((unused)) void *data)
7826 struct cmd_tunnel_filter_result *res = parsed_result;
7827 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7830 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7832 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7833 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7834 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7836 if (res->ip_value.family == AF_INET) {
7837 tunnel_filter_conf.ip_addr.ipv4_addr =
7838 res->ip_value.addr.ipv4.s_addr;
7839 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7841 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7842 &(res->ip_value.addr.ipv6),
7843 sizeof(struct in6_addr));
7844 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7847 if (!strcmp(res->filter_type, "imac-ivlan"))
7848 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7849 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7850 tunnel_filter_conf.filter_type =
7851 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7852 else if (!strcmp(res->filter_type, "imac-tenid"))
7853 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7854 else if (!strcmp(res->filter_type, "imac"))
7855 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7856 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7857 tunnel_filter_conf.filter_type =
7858 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7859 else if (!strcmp(res->filter_type, "oip"))
7860 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7861 else if (!strcmp(res->filter_type, "iip"))
7862 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7864 printf("The filter type is not supported");
7868 if (!strcmp(res->tunnel_type, "vxlan"))
7869 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7870 else if (!strcmp(res->tunnel_type, "nvgre"))
7871 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7872 else if (!strcmp(res->tunnel_type, "ipingre"))
7873 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7875 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7879 tunnel_filter_conf.tenant_id = res->tenant_id;
7880 tunnel_filter_conf.queue_id = res->queue_num;
7881 if (!strcmp(res->what, "add"))
7882 ret = rte_eth_dev_filter_ctrl(res->port_id,
7883 RTE_ETH_FILTER_TUNNEL,
7885 &tunnel_filter_conf);
7887 ret = rte_eth_dev_filter_ctrl(res->port_id,
7888 RTE_ETH_FILTER_TUNNEL,
7889 RTE_ETH_FILTER_DELETE,
7890 &tunnel_filter_conf);
7892 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7896 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7897 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7898 cmd, "tunnel_filter");
7899 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7900 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7902 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7903 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7905 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7906 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7908 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7909 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7911 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7912 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7913 inner_vlan, UINT16);
7914 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7915 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7917 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7918 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7919 tunnel_type, "vxlan#nvgre#ipingre");
7921 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7922 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7923 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7924 "imac#omac-imac-tenid");
7925 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7926 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7928 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7929 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7932 cmdline_parse_inst_t cmd_tunnel_filter = {
7933 .f = cmd_tunnel_filter_parsed,
7935 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7936 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7937 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7938 "<queue_id>: Add/Rm tunnel filter of a port",
7940 (void *)&cmd_tunnel_filter_cmd,
7941 (void *)&cmd_tunnel_filter_what,
7942 (void *)&cmd_tunnel_filter_port_id,
7943 (void *)&cmd_tunnel_filter_outer_mac,
7944 (void *)&cmd_tunnel_filter_inner_mac,
7945 (void *)&cmd_tunnel_filter_ip_value,
7946 (void *)&cmd_tunnel_filter_innner_vlan,
7947 (void *)&cmd_tunnel_filter_tunnel_type,
7948 (void *)&cmd_tunnel_filter_filter_type,
7949 (void *)&cmd_tunnel_filter_tenant_id,
7950 (void *)&cmd_tunnel_filter_queue_num,
7955 /* *** CONFIGURE TUNNEL UDP PORT *** */
7956 struct cmd_tunnel_udp_config {
7957 cmdline_fixed_string_t cmd;
7958 cmdline_fixed_string_t what;
7964 cmd_tunnel_udp_config_parsed(void *parsed_result,
7965 __attribute__((unused)) struct cmdline *cl,
7966 __attribute__((unused)) void *data)
7968 struct cmd_tunnel_udp_config *res = parsed_result;
7969 struct rte_eth_udp_tunnel tunnel_udp;
7972 tunnel_udp.udp_port = res->udp_port;
7974 if (!strcmp(res->cmd, "rx_vxlan_port"))
7975 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7977 if (!strcmp(res->what, "add"))
7978 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7981 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7985 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7988 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7989 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7990 cmd, "rx_vxlan_port");
7991 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7992 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7994 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7995 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7997 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7998 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8001 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8002 .f = cmd_tunnel_udp_config_parsed,
8004 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8005 "Add/Remove a tunneling UDP port filter",
8007 (void *)&cmd_tunnel_udp_config_cmd,
8008 (void *)&cmd_tunnel_udp_config_what,
8009 (void *)&cmd_tunnel_udp_config_udp_port,
8010 (void *)&cmd_tunnel_udp_config_port_id,
8015 /* *** GLOBAL CONFIG *** */
8016 struct cmd_global_config_result {
8017 cmdline_fixed_string_t cmd;
8019 cmdline_fixed_string_t cfg_type;
8024 cmd_global_config_parsed(void *parsed_result,
8025 __attribute__((unused)) struct cmdline *cl,
8026 __attribute__((unused)) void *data)
8028 struct cmd_global_config_result *res = parsed_result;
8029 struct rte_eth_global_cfg conf;
8032 memset(&conf, 0, sizeof(conf));
8033 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8034 conf.cfg.gre_key_len = res->len;
8035 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8036 RTE_ETH_FILTER_SET, &conf);
8038 printf("Global config error\n");
8041 cmdline_parse_token_string_t cmd_global_config_cmd =
8042 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8044 cmdline_parse_token_num_t cmd_global_config_port_id =
8045 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8047 cmdline_parse_token_string_t cmd_global_config_type =
8048 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8049 cfg_type, "gre-key-len");
8050 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8051 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8054 cmdline_parse_inst_t cmd_global_config = {
8055 .f = cmd_global_config_parsed,
8056 .data = (void *)NULL,
8057 .help_str = "global_config <port_id> gre-key-len <key_len>",
8059 (void *)&cmd_global_config_cmd,
8060 (void *)&cmd_global_config_port_id,
8061 (void *)&cmd_global_config_type,
8062 (void *)&cmd_global_config_gre_key_len,
8067 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8068 struct cmd_set_mirror_mask_result {
8069 cmdline_fixed_string_t set;
8070 cmdline_fixed_string_t port;
8072 cmdline_fixed_string_t mirror;
8074 cmdline_fixed_string_t what;
8075 cmdline_fixed_string_t value;
8076 cmdline_fixed_string_t dstpool;
8078 cmdline_fixed_string_t on;
8081 cmdline_parse_token_string_t cmd_mirror_mask_set =
8082 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8084 cmdline_parse_token_string_t cmd_mirror_mask_port =
8085 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8087 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8088 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8090 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8091 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8092 mirror, "mirror-rule");
8093 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8094 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8096 cmdline_parse_token_string_t cmd_mirror_mask_what =
8097 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8098 what, "pool-mirror-up#pool-mirror-down"
8100 cmdline_parse_token_string_t cmd_mirror_mask_value =
8101 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8103 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8104 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8105 dstpool, "dst-pool");
8106 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8107 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8109 cmdline_parse_token_string_t cmd_mirror_mask_on =
8110 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8114 cmd_set_mirror_mask_parsed(void *parsed_result,
8115 __attribute__((unused)) struct cmdline *cl,
8116 __attribute__((unused)) void *data)
8119 struct cmd_set_mirror_mask_result *res = parsed_result;
8120 struct rte_eth_mirror_conf mr_conf;
8122 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8124 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8126 mr_conf.dst_pool = res->dstpool_id;
8128 if (!strcmp(res->what, "pool-mirror-up")) {
8129 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8130 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8131 } else if (!strcmp(res->what, "pool-mirror-down")) {
8132 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8133 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8134 } else if (!strcmp(res->what, "vlan-mirror")) {
8135 mr_conf.rule_type = ETH_MIRROR_VLAN;
8136 nb_item = parse_item_list(res->value, "vlan",
8137 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8141 for (i = 0; i < nb_item; i++) {
8142 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8143 printf("Invalid vlan_id: must be < 4096\n");
8147 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8148 mr_conf.vlan.vlan_mask |= 1ULL << i;
8152 if (!strcmp(res->on, "on"))
8153 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8156 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8159 printf("mirror rule add error: (%s)\n", strerror(-ret));
8162 cmdline_parse_inst_t cmd_set_mirror_mask = {
8163 .f = cmd_set_mirror_mask_parsed,
8165 .help_str = "set port <port_id> mirror-rule <rule_id> "
8166 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8167 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8169 (void *)&cmd_mirror_mask_set,
8170 (void *)&cmd_mirror_mask_port,
8171 (void *)&cmd_mirror_mask_portid,
8172 (void *)&cmd_mirror_mask_mirror,
8173 (void *)&cmd_mirror_mask_ruleid,
8174 (void *)&cmd_mirror_mask_what,
8175 (void *)&cmd_mirror_mask_value,
8176 (void *)&cmd_mirror_mask_dstpool,
8177 (void *)&cmd_mirror_mask_poolid,
8178 (void *)&cmd_mirror_mask_on,
8183 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8184 struct cmd_set_mirror_link_result {
8185 cmdline_fixed_string_t set;
8186 cmdline_fixed_string_t port;
8188 cmdline_fixed_string_t mirror;
8190 cmdline_fixed_string_t what;
8191 cmdline_fixed_string_t dstpool;
8193 cmdline_fixed_string_t on;
8196 cmdline_parse_token_string_t cmd_mirror_link_set =
8197 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8199 cmdline_parse_token_string_t cmd_mirror_link_port =
8200 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8202 cmdline_parse_token_num_t cmd_mirror_link_portid =
8203 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8205 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8206 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8207 mirror, "mirror-rule");
8208 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8209 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8211 cmdline_parse_token_string_t cmd_mirror_link_what =
8212 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8213 what, "uplink-mirror#downlink-mirror");
8214 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8215 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8216 dstpool, "dst-pool");
8217 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8218 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8220 cmdline_parse_token_string_t cmd_mirror_link_on =
8221 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8225 cmd_set_mirror_link_parsed(void *parsed_result,
8226 __attribute__((unused)) struct cmdline *cl,
8227 __attribute__((unused)) void *data)
8230 struct cmd_set_mirror_link_result *res = parsed_result;
8231 struct rte_eth_mirror_conf mr_conf;
8233 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8234 if (!strcmp(res->what, "uplink-mirror"))
8235 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8237 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8239 mr_conf.dst_pool = res->dstpool_id;
8241 if (!strcmp(res->on, "on"))
8242 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8245 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8248 /* check the return value and print it if is < 0 */
8250 printf("mirror rule add error: (%s)\n", strerror(-ret));
8254 cmdline_parse_inst_t cmd_set_mirror_link = {
8255 .f = cmd_set_mirror_link_parsed,
8257 .help_str = "set port <port_id> mirror-rule <rule_id> "
8258 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8260 (void *)&cmd_mirror_link_set,
8261 (void *)&cmd_mirror_link_port,
8262 (void *)&cmd_mirror_link_portid,
8263 (void *)&cmd_mirror_link_mirror,
8264 (void *)&cmd_mirror_link_ruleid,
8265 (void *)&cmd_mirror_link_what,
8266 (void *)&cmd_mirror_link_dstpool,
8267 (void *)&cmd_mirror_link_poolid,
8268 (void *)&cmd_mirror_link_on,
8273 /* *** RESET VM MIRROR RULE *** */
8274 struct cmd_rm_mirror_rule_result {
8275 cmdline_fixed_string_t reset;
8276 cmdline_fixed_string_t port;
8278 cmdline_fixed_string_t mirror;
8282 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8283 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8285 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8286 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8288 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8289 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8291 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8292 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8293 mirror, "mirror-rule");
8294 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8295 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8299 cmd_reset_mirror_rule_parsed(void *parsed_result,
8300 __attribute__((unused)) struct cmdline *cl,
8301 __attribute__((unused)) void *data)
8304 struct cmd_set_mirror_link_result *res = parsed_result;
8306 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8308 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8311 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8312 .f = cmd_reset_mirror_rule_parsed,
8314 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8316 (void *)&cmd_rm_mirror_rule_reset,
8317 (void *)&cmd_rm_mirror_rule_port,
8318 (void *)&cmd_rm_mirror_rule_portid,
8319 (void *)&cmd_rm_mirror_rule_mirror,
8320 (void *)&cmd_rm_mirror_rule_ruleid,
8325 /* ******************************************************************************** */
8327 struct cmd_dump_result {
8328 cmdline_fixed_string_t dump;
8332 dump_struct_sizes(void)
8334 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8335 DUMP_SIZE(struct rte_mbuf);
8336 DUMP_SIZE(struct rte_mempool);
8337 DUMP_SIZE(struct rte_ring);
8341 static void cmd_dump_parsed(void *parsed_result,
8342 __attribute__((unused)) struct cmdline *cl,
8343 __attribute__((unused)) void *data)
8345 struct cmd_dump_result *res = parsed_result;
8347 if (!strcmp(res->dump, "dump_physmem"))
8348 rte_dump_physmem_layout(stdout);
8349 else if (!strcmp(res->dump, "dump_memzone"))
8350 rte_memzone_dump(stdout);
8351 else if (!strcmp(res->dump, "dump_struct_sizes"))
8352 dump_struct_sizes();
8353 else if (!strcmp(res->dump, "dump_ring"))
8354 rte_ring_list_dump(stdout);
8355 else if (!strcmp(res->dump, "dump_mempool"))
8356 rte_mempool_list_dump(stdout);
8357 else if (!strcmp(res->dump, "dump_devargs"))
8358 rte_eal_devargs_dump(stdout);
8359 else if (!strcmp(res->dump, "dump_log_types"))
8360 rte_log_dump(stdout);
8363 cmdline_parse_token_string_t cmd_dump_dump =
8364 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8367 "dump_struct_sizes#"
8373 cmdline_parse_inst_t cmd_dump = {
8374 .f = cmd_dump_parsed, /* function to call */
8375 .data = NULL, /* 2nd arg of func */
8376 .help_str = "Dump status",
8377 .tokens = { /* token list, NULL terminated */
8378 (void *)&cmd_dump_dump,
8383 /* ******************************************************************************** */
8385 struct cmd_dump_one_result {
8386 cmdline_fixed_string_t dump;
8387 cmdline_fixed_string_t name;
8390 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8391 __attribute__((unused)) void *data)
8393 struct cmd_dump_one_result *res = parsed_result;
8395 if (!strcmp(res->dump, "dump_ring")) {
8397 r = rte_ring_lookup(res->name);
8399 cmdline_printf(cl, "Cannot find ring\n");
8402 rte_ring_dump(stdout, r);
8403 } else if (!strcmp(res->dump, "dump_mempool")) {
8404 struct rte_mempool *mp;
8405 mp = rte_mempool_lookup(res->name);
8407 cmdline_printf(cl, "Cannot find mempool\n");
8410 rte_mempool_dump(stdout, mp);
8414 cmdline_parse_token_string_t cmd_dump_one_dump =
8415 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8416 "dump_ring#dump_mempool");
8418 cmdline_parse_token_string_t cmd_dump_one_name =
8419 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8421 cmdline_parse_inst_t cmd_dump_one = {
8422 .f = cmd_dump_one_parsed, /* function to call */
8423 .data = NULL, /* 2nd arg of func */
8424 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8425 .tokens = { /* token list, NULL terminated */
8426 (void *)&cmd_dump_one_dump,
8427 (void *)&cmd_dump_one_name,
8432 /* *** Add/Del syn filter *** */
8433 struct cmd_syn_filter_result {
8434 cmdline_fixed_string_t filter;
8436 cmdline_fixed_string_t ops;
8437 cmdline_fixed_string_t priority;
8438 cmdline_fixed_string_t high;
8439 cmdline_fixed_string_t queue;
8444 cmd_syn_filter_parsed(void *parsed_result,
8445 __attribute__((unused)) struct cmdline *cl,
8446 __attribute__((unused)) void *data)
8448 struct cmd_syn_filter_result *res = parsed_result;
8449 struct rte_eth_syn_filter syn_filter;
8452 ret = rte_eth_dev_filter_supported(res->port_id,
8453 RTE_ETH_FILTER_SYN);
8455 printf("syn filter is not supported on port %u.\n",
8460 memset(&syn_filter, 0, sizeof(syn_filter));
8462 if (!strcmp(res->ops, "add")) {
8463 if (!strcmp(res->high, "high"))
8464 syn_filter.hig_pri = 1;
8466 syn_filter.hig_pri = 0;
8468 syn_filter.queue = res->queue_id;
8469 ret = rte_eth_dev_filter_ctrl(res->port_id,
8474 ret = rte_eth_dev_filter_ctrl(res->port_id,
8476 RTE_ETH_FILTER_DELETE,
8480 printf("syn filter programming error: (%s)\n",
8484 cmdline_parse_token_string_t cmd_syn_filter_filter =
8485 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8486 filter, "syn_filter");
8487 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8488 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8490 cmdline_parse_token_string_t cmd_syn_filter_ops =
8491 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8493 cmdline_parse_token_string_t cmd_syn_filter_priority =
8494 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8495 priority, "priority");
8496 cmdline_parse_token_string_t cmd_syn_filter_high =
8497 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8499 cmdline_parse_token_string_t cmd_syn_filter_queue =
8500 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8502 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8503 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8506 cmdline_parse_inst_t cmd_syn_filter = {
8507 .f = cmd_syn_filter_parsed,
8509 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8510 "<queue_id>: Add/Delete syn filter",
8512 (void *)&cmd_syn_filter_filter,
8513 (void *)&cmd_syn_filter_port_id,
8514 (void *)&cmd_syn_filter_ops,
8515 (void *)&cmd_syn_filter_priority,
8516 (void *)&cmd_syn_filter_high,
8517 (void *)&cmd_syn_filter_queue,
8518 (void *)&cmd_syn_filter_queue_id,
8523 /* *** queue region set *** */
8524 struct cmd_queue_region_result {
8525 cmdline_fixed_string_t set;
8526 cmdline_fixed_string_t port;
8528 cmdline_fixed_string_t cmd;
8529 cmdline_fixed_string_t region;
8531 cmdline_fixed_string_t queue_start_index;
8533 cmdline_fixed_string_t queue_num;
8534 uint8_t queue_num_value;
8538 cmd_queue_region_parsed(void *parsed_result,
8539 __attribute__((unused)) struct cmdline *cl,
8540 __attribute__((unused)) void *data)
8542 struct cmd_queue_region_result *res = parsed_result;
8544 #ifdef RTE_LIBRTE_I40E_PMD
8545 struct rte_pmd_i40e_queue_region_conf region_conf;
8546 enum rte_pmd_i40e_queue_region_op op_type;
8549 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8552 #ifdef RTE_LIBRTE_I40E_PMD
8553 memset(®ion_conf, 0, sizeof(region_conf));
8554 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8555 region_conf.region_id = res->region_id;
8556 region_conf.queue_num = res->queue_num_value;
8557 region_conf.queue_start_index = res->queue_id;
8559 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8560 op_type, ®ion_conf);
8567 printf("function not implemented or supported\n");
8570 printf("queue region config error: (%s)\n", strerror(-ret));
8574 cmdline_parse_token_string_t cmd_queue_region_set =
8575 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8577 cmdline_parse_token_string_t cmd_queue_region_port =
8578 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8579 cmdline_parse_token_num_t cmd_queue_region_port_id =
8580 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8582 cmdline_parse_token_string_t cmd_queue_region_cmd =
8583 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8584 cmd, "queue-region");
8585 cmdline_parse_token_string_t cmd_queue_region_id =
8586 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8587 region, "region_id");
8588 cmdline_parse_token_num_t cmd_queue_region_index =
8589 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8591 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8592 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8593 queue_start_index, "queue_start_index");
8594 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8595 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8597 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8598 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8599 queue_num, "queue_num");
8600 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8601 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8602 queue_num_value, UINT8);
8604 cmdline_parse_inst_t cmd_queue_region = {
8605 .f = cmd_queue_region_parsed,
8607 .help_str = "set port <port_id> queue-region region_id <value> "
8608 "queue_start_index <value> queue_num <value>: Set a queue region",
8610 (void *)&cmd_queue_region_set,
8611 (void *)&cmd_queue_region_port,
8612 (void *)&cmd_queue_region_port_id,
8613 (void *)&cmd_queue_region_cmd,
8614 (void *)&cmd_queue_region_id,
8615 (void *)&cmd_queue_region_index,
8616 (void *)&cmd_queue_region_queue_start_index,
8617 (void *)&cmd_queue_region_queue_id,
8618 (void *)&cmd_queue_region_queue_num,
8619 (void *)&cmd_queue_region_queue_num_value,
8624 /* *** queue region and flowtype set *** */
8625 struct cmd_region_flowtype_result {
8626 cmdline_fixed_string_t set;
8627 cmdline_fixed_string_t port;
8629 cmdline_fixed_string_t cmd;
8630 cmdline_fixed_string_t region;
8632 cmdline_fixed_string_t flowtype;
8633 uint8_t flowtype_id;
8637 cmd_region_flowtype_parsed(void *parsed_result,
8638 __attribute__((unused)) struct cmdline *cl,
8639 __attribute__((unused)) void *data)
8641 struct cmd_region_flowtype_result *res = parsed_result;
8643 #ifdef RTE_LIBRTE_I40E_PMD
8644 struct rte_pmd_i40e_queue_region_conf region_conf;
8645 enum rte_pmd_i40e_queue_region_op op_type;
8648 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8651 #ifdef RTE_LIBRTE_I40E_PMD
8652 memset(®ion_conf, 0, sizeof(region_conf));
8654 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8655 region_conf.region_id = res->region_id;
8656 region_conf.hw_flowtype = res->flowtype_id;
8658 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8659 op_type, ®ion_conf);
8666 printf("function not implemented or supported\n");
8669 printf("region flowtype config error: (%s)\n", strerror(-ret));
8673 cmdline_parse_token_string_t cmd_region_flowtype_set =
8674 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8676 cmdline_parse_token_string_t cmd_region_flowtype_port =
8677 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8679 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8680 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8682 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8683 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8684 cmd, "queue-region");
8685 cmdline_parse_token_string_t cmd_region_flowtype_index =
8686 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8687 region, "region_id");
8688 cmdline_parse_token_num_t cmd_region_flowtype_id =
8689 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8691 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8692 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8693 flowtype, "flowtype");
8694 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8695 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8696 flowtype_id, UINT8);
8697 cmdline_parse_inst_t cmd_region_flowtype = {
8698 .f = cmd_region_flowtype_parsed,
8700 .help_str = "set port <port_id> queue-region region_id <value> "
8701 "flowtype <value>: Set a flowtype region index",
8703 (void *)&cmd_region_flowtype_set,
8704 (void *)&cmd_region_flowtype_port,
8705 (void *)&cmd_region_flowtype_port_index,
8706 (void *)&cmd_region_flowtype_cmd,
8707 (void *)&cmd_region_flowtype_index,
8708 (void *)&cmd_region_flowtype_id,
8709 (void *)&cmd_region_flowtype_flow_index,
8710 (void *)&cmd_region_flowtype_flow_id,
8715 /* *** User Priority (UP) to queue region (region_id) set *** */
8716 struct cmd_user_priority_region_result {
8717 cmdline_fixed_string_t set;
8718 cmdline_fixed_string_t port;
8720 cmdline_fixed_string_t cmd;
8721 cmdline_fixed_string_t user_priority;
8722 uint8_t user_priority_id;
8723 cmdline_fixed_string_t region;
8728 cmd_user_priority_region_parsed(void *parsed_result,
8729 __attribute__((unused)) struct cmdline *cl,
8730 __attribute__((unused)) void *data)
8732 struct cmd_user_priority_region_result *res = parsed_result;
8734 #ifdef RTE_LIBRTE_I40E_PMD
8735 struct rte_pmd_i40e_queue_region_conf region_conf;
8736 enum rte_pmd_i40e_queue_region_op op_type;
8739 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8742 #ifdef RTE_LIBRTE_I40E_PMD
8743 memset(®ion_conf, 0, sizeof(region_conf));
8744 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8745 region_conf.user_priority = res->user_priority_id;
8746 region_conf.region_id = res->region_id;
8748 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8749 op_type, ®ion_conf);
8756 printf("function not implemented or supported\n");
8759 printf("user_priority region config error: (%s)\n",
8764 cmdline_parse_token_string_t cmd_user_priority_region_set =
8765 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8767 cmdline_parse_token_string_t cmd_user_priority_region_port =
8768 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8770 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8771 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8773 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
8774 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8775 cmd, "queue-region");
8776 cmdline_parse_token_string_t cmd_user_priority_region_UP =
8777 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8778 user_priority, "UP");
8779 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
8780 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8781 user_priority_id, UINT8);
8782 cmdline_parse_token_string_t cmd_user_priority_region_region =
8783 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8784 region, "region_id");
8785 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
8786 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8789 cmdline_parse_inst_t cmd_user_priority_region = {
8790 .f = cmd_user_priority_region_parsed,
8792 .help_str = "set port <port_id> queue-region UP <value> "
8793 "region_id <value>: Set the mapping of User Priority (UP) "
8794 "to queue region (region_id) ",
8796 (void *)&cmd_user_priority_region_set,
8797 (void *)&cmd_user_priority_region_port,
8798 (void *)&cmd_user_priority_region_port_index,
8799 (void *)&cmd_user_priority_region_cmd,
8800 (void *)&cmd_user_priority_region_UP,
8801 (void *)&cmd_user_priority_region_UP_id,
8802 (void *)&cmd_user_priority_region_region,
8803 (void *)&cmd_user_priority_region_region_id,
8808 /* *** flush all queue region related configuration *** */
8809 struct cmd_flush_queue_region_result {
8810 cmdline_fixed_string_t set;
8811 cmdline_fixed_string_t port;
8813 cmdline_fixed_string_t cmd;
8814 cmdline_fixed_string_t flush;
8815 cmdline_fixed_string_t what;
8819 cmd_flush_queue_region_parsed(void *parsed_result,
8820 __attribute__((unused)) struct cmdline *cl,
8821 __attribute__((unused)) void *data)
8823 struct cmd_flush_queue_region_result *res = parsed_result;
8825 #ifdef RTE_LIBRTE_I40E_PMD
8826 struct rte_pmd_i40e_queue_region_conf region_conf;
8827 enum rte_pmd_i40e_queue_region_op op_type;
8830 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8833 #ifdef RTE_LIBRTE_I40E_PMD
8834 memset(®ion_conf, 0, sizeof(region_conf));
8836 if (strcmp(res->what, "on") == 0)
8837 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
8839 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
8841 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8842 op_type, ®ion_conf);
8849 printf("function not implemented or supported\n");
8852 printf("queue region config flush error: (%s)\n",
8857 cmdline_parse_token_string_t cmd_flush_queue_region_set =
8858 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8860 cmdline_parse_token_string_t cmd_flush_queue_region_port =
8861 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8863 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
8864 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
8866 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
8867 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8868 cmd, "queue-region");
8869 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
8870 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8872 cmdline_parse_token_string_t cmd_flush_queue_region_what =
8873 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8876 cmdline_parse_inst_t cmd_flush_queue_region = {
8877 .f = cmd_flush_queue_region_parsed,
8879 .help_str = "set port <port_id> queue-region flush on|off"
8880 ": flush all queue region related configuration",
8882 (void *)&cmd_flush_queue_region_set,
8883 (void *)&cmd_flush_queue_region_port,
8884 (void *)&cmd_flush_queue_region_port_index,
8885 (void *)&cmd_flush_queue_region_cmd,
8886 (void *)&cmd_flush_queue_region_flush,
8887 (void *)&cmd_flush_queue_region_what,
8892 /* *** get all queue region related configuration info *** */
8893 struct cmd_show_queue_region_info {
8894 cmdline_fixed_string_t show;
8895 cmdline_fixed_string_t port;
8897 cmdline_fixed_string_t cmd;
8901 cmd_show_queue_region_info_parsed(void *parsed_result,
8902 __attribute__((unused)) struct cmdline *cl,
8903 __attribute__((unused)) void *data)
8905 struct cmd_show_queue_region_info *res = parsed_result;
8907 #ifdef RTE_LIBRTE_I40E_PMD
8908 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
8909 enum rte_pmd_i40e_queue_region_op op_type;
8912 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8915 #ifdef RTE_LIBRTE_I40E_PMD
8916 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
8918 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
8920 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8921 op_type, &rte_pmd_regions);
8923 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
8930 printf("function not implemented or supported\n");
8933 printf("queue region config info show error: (%s)\n",
8938 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
8939 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
8941 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
8942 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
8944 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
8945 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
8947 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
8948 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
8949 cmd, "queue-region");
8951 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
8952 .f = cmd_show_queue_region_info_parsed,
8954 .help_str = "show port <port_id> queue-region"
8955 ": show all queue region related configuration info",
8957 (void *)&cmd_show_queue_region_info_get,
8958 (void *)&cmd_show_queue_region_info_port,
8959 (void *)&cmd_show_queue_region_info_port_index,
8960 (void *)&cmd_show_queue_region_info_cmd,
8965 /* *** ADD/REMOVE A 2tuple FILTER *** */
8966 struct cmd_2tuple_filter_result {
8967 cmdline_fixed_string_t filter;
8969 cmdline_fixed_string_t ops;
8970 cmdline_fixed_string_t dst_port;
8971 uint16_t dst_port_value;
8972 cmdline_fixed_string_t protocol;
8973 uint8_t protocol_value;
8974 cmdline_fixed_string_t mask;
8976 cmdline_fixed_string_t tcp_flags;
8977 uint8_t tcp_flags_value;
8978 cmdline_fixed_string_t priority;
8979 uint8_t priority_value;
8980 cmdline_fixed_string_t queue;
8985 cmd_2tuple_filter_parsed(void *parsed_result,
8986 __attribute__((unused)) struct cmdline *cl,
8987 __attribute__((unused)) void *data)
8989 struct rte_eth_ntuple_filter filter;
8990 struct cmd_2tuple_filter_result *res = parsed_result;
8993 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8995 printf("ntuple filter is not supported on port %u.\n",
9000 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9002 filter.flags = RTE_2TUPLE_FLAGS;
9003 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9004 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9005 filter.proto = res->protocol_value;
9006 filter.priority = res->priority_value;
9007 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9008 printf("nonzero tcp_flags is only meaningful"
9009 " when protocol is TCP.\n");
9012 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9013 printf("invalid TCP flags.\n");
9017 if (res->tcp_flags_value != 0) {
9018 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9019 filter.tcp_flags = res->tcp_flags_value;
9022 /* need convert to big endian. */
9023 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9024 filter.queue = res->queue_id;
9026 if (!strcmp(res->ops, "add"))
9027 ret = rte_eth_dev_filter_ctrl(res->port_id,
9028 RTE_ETH_FILTER_NTUPLE,
9032 ret = rte_eth_dev_filter_ctrl(res->port_id,
9033 RTE_ETH_FILTER_NTUPLE,
9034 RTE_ETH_FILTER_DELETE,
9037 printf("2tuple filter programming error: (%s)\n",
9042 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9043 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9044 filter, "2tuple_filter");
9045 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9046 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9048 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9049 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9051 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9052 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9053 dst_port, "dst_port");
9054 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9055 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9056 dst_port_value, UINT16);
9057 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9058 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9059 protocol, "protocol");
9060 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9061 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9062 protocol_value, UINT8);
9063 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9064 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9066 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9067 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9069 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9070 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9071 tcp_flags, "tcp_flags");
9072 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9073 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9074 tcp_flags_value, UINT8);
9075 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9076 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9077 priority, "priority");
9078 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9079 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9080 priority_value, UINT8);
9081 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9082 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9084 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9085 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9088 cmdline_parse_inst_t cmd_2tuple_filter = {
9089 .f = cmd_2tuple_filter_parsed,
9091 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9092 "<value> mask <value> tcp_flags <value> priority <value> queue "
9093 "<queue_id>: Add a 2tuple filter",
9095 (void *)&cmd_2tuple_filter_filter,
9096 (void *)&cmd_2tuple_filter_port_id,
9097 (void *)&cmd_2tuple_filter_ops,
9098 (void *)&cmd_2tuple_filter_dst_port,
9099 (void *)&cmd_2tuple_filter_dst_port_value,
9100 (void *)&cmd_2tuple_filter_protocol,
9101 (void *)&cmd_2tuple_filter_protocol_value,
9102 (void *)&cmd_2tuple_filter_mask,
9103 (void *)&cmd_2tuple_filter_mask_value,
9104 (void *)&cmd_2tuple_filter_tcp_flags,
9105 (void *)&cmd_2tuple_filter_tcp_flags_value,
9106 (void *)&cmd_2tuple_filter_priority,
9107 (void *)&cmd_2tuple_filter_priority_value,
9108 (void *)&cmd_2tuple_filter_queue,
9109 (void *)&cmd_2tuple_filter_queue_id,
9114 /* *** ADD/REMOVE A 5tuple FILTER *** */
9115 struct cmd_5tuple_filter_result {
9116 cmdline_fixed_string_t filter;
9118 cmdline_fixed_string_t ops;
9119 cmdline_fixed_string_t dst_ip;
9120 cmdline_ipaddr_t dst_ip_value;
9121 cmdline_fixed_string_t src_ip;
9122 cmdline_ipaddr_t src_ip_value;
9123 cmdline_fixed_string_t dst_port;
9124 uint16_t dst_port_value;
9125 cmdline_fixed_string_t src_port;
9126 uint16_t src_port_value;
9127 cmdline_fixed_string_t protocol;
9128 uint8_t protocol_value;
9129 cmdline_fixed_string_t mask;
9131 cmdline_fixed_string_t tcp_flags;
9132 uint8_t tcp_flags_value;
9133 cmdline_fixed_string_t priority;
9134 uint8_t priority_value;
9135 cmdline_fixed_string_t queue;
9140 cmd_5tuple_filter_parsed(void *parsed_result,
9141 __attribute__((unused)) struct cmdline *cl,
9142 __attribute__((unused)) void *data)
9144 struct rte_eth_ntuple_filter filter;
9145 struct cmd_5tuple_filter_result *res = parsed_result;
9148 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9150 printf("ntuple filter is not supported on port %u.\n",
9155 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9157 filter.flags = RTE_5TUPLE_FLAGS;
9158 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9159 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9160 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9161 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9162 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9163 filter.proto = res->protocol_value;
9164 filter.priority = res->priority_value;
9165 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9166 printf("nonzero tcp_flags is only meaningful"
9167 " when protocol is TCP.\n");
9170 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9171 printf("invalid TCP flags.\n");
9175 if (res->tcp_flags_value != 0) {
9176 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9177 filter.tcp_flags = res->tcp_flags_value;
9180 if (res->dst_ip_value.family == AF_INET)
9181 /* no need to convert, already big endian. */
9182 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9184 if (filter.dst_ip_mask == 0) {
9185 printf("can not support ipv6 involved compare.\n");
9191 if (res->src_ip_value.family == AF_INET)
9192 /* no need to convert, already big endian. */
9193 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9195 if (filter.src_ip_mask == 0) {
9196 printf("can not support ipv6 involved compare.\n");
9201 /* need convert to big endian. */
9202 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9203 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9204 filter.queue = res->queue_id;
9206 if (!strcmp(res->ops, "add"))
9207 ret = rte_eth_dev_filter_ctrl(res->port_id,
9208 RTE_ETH_FILTER_NTUPLE,
9212 ret = rte_eth_dev_filter_ctrl(res->port_id,
9213 RTE_ETH_FILTER_NTUPLE,
9214 RTE_ETH_FILTER_DELETE,
9217 printf("5tuple filter programming error: (%s)\n",
9221 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9222 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9223 filter, "5tuple_filter");
9224 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9225 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9227 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9228 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9230 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9231 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9233 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9234 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9236 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9237 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9239 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9240 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9242 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9243 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9244 dst_port, "dst_port");
9245 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9246 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9247 dst_port_value, UINT16);
9248 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9249 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9250 src_port, "src_port");
9251 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9252 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9253 src_port_value, UINT16);
9254 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9255 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9256 protocol, "protocol");
9257 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9258 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9259 protocol_value, UINT8);
9260 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9261 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9263 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9264 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9266 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9267 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9268 tcp_flags, "tcp_flags");
9269 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9270 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9271 tcp_flags_value, UINT8);
9272 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9273 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9274 priority, "priority");
9275 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9276 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9277 priority_value, UINT8);
9278 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9279 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9281 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9282 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9285 cmdline_parse_inst_t cmd_5tuple_filter = {
9286 .f = cmd_5tuple_filter_parsed,
9288 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9289 "src_ip <value> dst_port <value> src_port <value> "
9290 "protocol <value> mask <value> tcp_flags <value> "
9291 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9293 (void *)&cmd_5tuple_filter_filter,
9294 (void *)&cmd_5tuple_filter_port_id,
9295 (void *)&cmd_5tuple_filter_ops,
9296 (void *)&cmd_5tuple_filter_dst_ip,
9297 (void *)&cmd_5tuple_filter_dst_ip_value,
9298 (void *)&cmd_5tuple_filter_src_ip,
9299 (void *)&cmd_5tuple_filter_src_ip_value,
9300 (void *)&cmd_5tuple_filter_dst_port,
9301 (void *)&cmd_5tuple_filter_dst_port_value,
9302 (void *)&cmd_5tuple_filter_src_port,
9303 (void *)&cmd_5tuple_filter_src_port_value,
9304 (void *)&cmd_5tuple_filter_protocol,
9305 (void *)&cmd_5tuple_filter_protocol_value,
9306 (void *)&cmd_5tuple_filter_mask,
9307 (void *)&cmd_5tuple_filter_mask_value,
9308 (void *)&cmd_5tuple_filter_tcp_flags,
9309 (void *)&cmd_5tuple_filter_tcp_flags_value,
9310 (void *)&cmd_5tuple_filter_priority,
9311 (void *)&cmd_5tuple_filter_priority_value,
9312 (void *)&cmd_5tuple_filter_queue,
9313 (void *)&cmd_5tuple_filter_queue_id,
9318 /* *** ADD/REMOVE A flex FILTER *** */
9319 struct cmd_flex_filter_result {
9320 cmdline_fixed_string_t filter;
9321 cmdline_fixed_string_t ops;
9323 cmdline_fixed_string_t len;
9325 cmdline_fixed_string_t bytes;
9326 cmdline_fixed_string_t bytes_value;
9327 cmdline_fixed_string_t mask;
9328 cmdline_fixed_string_t mask_value;
9329 cmdline_fixed_string_t priority;
9330 uint8_t priority_value;
9331 cmdline_fixed_string_t queue;
9335 static int xdigit2val(unsigned char c)
9340 else if (isupper(c))
9348 cmd_flex_filter_parsed(void *parsed_result,
9349 __attribute__((unused)) struct cmdline *cl,
9350 __attribute__((unused)) void *data)
9353 struct rte_eth_flex_filter filter;
9354 struct cmd_flex_filter_result *res = parsed_result;
9355 char *bytes_ptr, *mask_ptr;
9356 uint16_t len, i, j = 0;
9361 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9362 printf("the len exceed the max length 128\n");
9365 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9366 filter.len = res->len_value;
9367 filter.priority = res->priority_value;
9368 filter.queue = res->queue_id;
9369 bytes_ptr = res->bytes_value;
9370 mask_ptr = res->mask_value;
9372 /* translate bytes string to array. */
9373 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9374 (bytes_ptr[1] == 'X')))
9376 len = strnlen(bytes_ptr, res->len_value * 2);
9377 if (len == 0 || (len % 8 != 0)) {
9378 printf("please check len and bytes input\n");
9381 for (i = 0; i < len; i++) {
9383 if (isxdigit(c) == 0) {
9384 /* invalid characters. */
9385 printf("invalid input\n");
9388 val = xdigit2val(c);
9391 filter.bytes[j] = byte;
9392 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9399 /* translate mask string to uint8_t array. */
9400 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9401 (mask_ptr[1] == 'X')))
9403 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9405 printf("invalid input\n");
9410 for (i = 0; i < len; i++) {
9412 if (isxdigit(c) == 0) {
9413 /* invalid characters. */
9414 printf("invalid input\n");
9417 val = xdigit2val(c);
9420 filter.mask[j] = byte;
9421 printf("mask[%d]:%02x ", j, filter.mask[j]);
9429 if (!strcmp(res->ops, "add"))
9430 ret = rte_eth_dev_filter_ctrl(res->port_id,
9431 RTE_ETH_FILTER_FLEXIBLE,
9435 ret = rte_eth_dev_filter_ctrl(res->port_id,
9436 RTE_ETH_FILTER_FLEXIBLE,
9437 RTE_ETH_FILTER_DELETE,
9441 printf("flex filter setting error: (%s)\n", strerror(-ret));
9444 cmdline_parse_token_string_t cmd_flex_filter_filter =
9445 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9446 filter, "flex_filter");
9447 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9448 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9450 cmdline_parse_token_string_t cmd_flex_filter_ops =
9451 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9453 cmdline_parse_token_string_t cmd_flex_filter_len =
9454 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9456 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9457 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9459 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9460 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9462 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9463 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9465 cmdline_parse_token_string_t cmd_flex_filter_mask =
9466 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9468 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9469 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9471 cmdline_parse_token_string_t cmd_flex_filter_priority =
9472 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9473 priority, "priority");
9474 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9475 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9476 priority_value, UINT8);
9477 cmdline_parse_token_string_t cmd_flex_filter_queue =
9478 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9480 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9481 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9483 cmdline_parse_inst_t cmd_flex_filter = {
9484 .f = cmd_flex_filter_parsed,
9486 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9487 "<value> mask <value> priority <value> queue <queue_id>: "
9488 "Add/Del a flex filter",
9490 (void *)&cmd_flex_filter_filter,
9491 (void *)&cmd_flex_filter_port_id,
9492 (void *)&cmd_flex_filter_ops,
9493 (void *)&cmd_flex_filter_len,
9494 (void *)&cmd_flex_filter_len_value,
9495 (void *)&cmd_flex_filter_bytes,
9496 (void *)&cmd_flex_filter_bytes_value,
9497 (void *)&cmd_flex_filter_mask,
9498 (void *)&cmd_flex_filter_mask_value,
9499 (void *)&cmd_flex_filter_priority,
9500 (void *)&cmd_flex_filter_priority_value,
9501 (void *)&cmd_flex_filter_queue,
9502 (void *)&cmd_flex_filter_queue_id,
9507 /* *** Filters Control *** */
9509 /* *** deal with ethertype filter *** */
9510 struct cmd_ethertype_filter_result {
9511 cmdline_fixed_string_t filter;
9513 cmdline_fixed_string_t ops;
9514 cmdline_fixed_string_t mac;
9515 struct ether_addr mac_addr;
9516 cmdline_fixed_string_t ethertype;
9517 uint16_t ethertype_value;
9518 cmdline_fixed_string_t drop;
9519 cmdline_fixed_string_t queue;
9523 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9524 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9525 filter, "ethertype_filter");
9526 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9527 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9529 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9530 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9532 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9533 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9534 mac, "mac_addr#mac_ignr");
9535 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9536 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9538 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9539 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9540 ethertype, "ethertype");
9541 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9542 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9543 ethertype_value, UINT16);
9544 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9545 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9547 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9548 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9550 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9551 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9555 cmd_ethertype_filter_parsed(void *parsed_result,
9556 __attribute__((unused)) struct cmdline *cl,
9557 __attribute__((unused)) void *data)
9559 struct cmd_ethertype_filter_result *res = parsed_result;
9560 struct rte_eth_ethertype_filter filter;
9563 ret = rte_eth_dev_filter_supported(res->port_id,
9564 RTE_ETH_FILTER_ETHERTYPE);
9566 printf("ethertype filter is not supported on port %u.\n",
9571 memset(&filter, 0, sizeof(filter));
9572 if (!strcmp(res->mac, "mac_addr")) {
9573 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9574 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9575 sizeof(struct ether_addr));
9577 if (!strcmp(res->drop, "drop"))
9578 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9579 filter.ether_type = res->ethertype_value;
9580 filter.queue = res->queue_id;
9582 if (!strcmp(res->ops, "add"))
9583 ret = rte_eth_dev_filter_ctrl(res->port_id,
9584 RTE_ETH_FILTER_ETHERTYPE,
9588 ret = rte_eth_dev_filter_ctrl(res->port_id,
9589 RTE_ETH_FILTER_ETHERTYPE,
9590 RTE_ETH_FILTER_DELETE,
9593 printf("ethertype filter programming error: (%s)\n",
9597 cmdline_parse_inst_t cmd_ethertype_filter = {
9598 .f = cmd_ethertype_filter_parsed,
9600 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9601 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9602 "Add or delete an ethertype filter entry",
9604 (void *)&cmd_ethertype_filter_filter,
9605 (void *)&cmd_ethertype_filter_port_id,
9606 (void *)&cmd_ethertype_filter_ops,
9607 (void *)&cmd_ethertype_filter_mac,
9608 (void *)&cmd_ethertype_filter_mac_addr,
9609 (void *)&cmd_ethertype_filter_ethertype,
9610 (void *)&cmd_ethertype_filter_ethertype_value,
9611 (void *)&cmd_ethertype_filter_drop,
9612 (void *)&cmd_ethertype_filter_queue,
9613 (void *)&cmd_ethertype_filter_queue_id,
9618 /* *** deal with flow director filter *** */
9619 struct cmd_flow_director_result {
9620 cmdline_fixed_string_t flow_director_filter;
9622 cmdline_fixed_string_t mode;
9623 cmdline_fixed_string_t mode_value;
9624 cmdline_fixed_string_t ops;
9625 cmdline_fixed_string_t flow;
9626 cmdline_fixed_string_t flow_type;
9627 cmdline_fixed_string_t ether;
9628 uint16_t ether_type;
9629 cmdline_fixed_string_t src;
9630 cmdline_ipaddr_t ip_src;
9632 cmdline_fixed_string_t dst;
9633 cmdline_ipaddr_t ip_dst;
9635 cmdline_fixed_string_t verify_tag;
9636 uint32_t verify_tag_value;
9637 cmdline_ipaddr_t tos;
9639 cmdline_ipaddr_t proto;
9640 uint8_t proto_value;
9641 cmdline_ipaddr_t ttl;
9643 cmdline_fixed_string_t vlan;
9644 uint16_t vlan_value;
9645 cmdline_fixed_string_t flexbytes;
9646 cmdline_fixed_string_t flexbytes_value;
9647 cmdline_fixed_string_t pf_vf;
9648 cmdline_fixed_string_t drop;
9649 cmdline_fixed_string_t queue;
9651 cmdline_fixed_string_t fd_id;
9652 uint32_t fd_id_value;
9653 cmdline_fixed_string_t mac;
9654 struct ether_addr mac_addr;
9655 cmdline_fixed_string_t tunnel;
9656 cmdline_fixed_string_t tunnel_type;
9657 cmdline_fixed_string_t tunnel_id;
9658 uint32_t tunnel_id_value;
9662 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9665 const char *p, *p0 = q_arg;
9667 unsigned long int_fld;
9668 char *str_fld[max_num];
9673 p = strchr(p0, '(');
9677 p0 = strchr(p, ')');
9682 if (size >= sizeof(s))
9685 snprintf(s, sizeof(s), "%.*s", size, p);
9686 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9687 if (ret < 0 || ret > max_num)
9689 for (i = 0; i < ret; i++) {
9691 int_fld = strtoul(str_fld[i], &end, 0);
9692 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9694 flexbytes[i] = (uint8_t)int_fld;
9700 str2flowtype(char *string)
9703 static const struct {
9706 } flowtype_str[] = {
9707 {"raw", RTE_ETH_FLOW_RAW},
9708 {"ipv4", RTE_ETH_FLOW_IPV4},
9709 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9710 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9711 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9712 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9713 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9714 {"ipv6", RTE_ETH_FLOW_IPV6},
9715 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9716 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9717 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9718 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9719 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9720 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9723 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9724 if (!strcmp(flowtype_str[i].str, string))
9725 return flowtype_str[i].type;
9728 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9729 return (uint16_t)atoi(string);
9731 return RTE_ETH_FLOW_UNKNOWN;
9734 static enum rte_eth_fdir_tunnel_type
9735 str2fdir_tunneltype(char *string)
9739 static const struct {
9741 enum rte_eth_fdir_tunnel_type type;
9742 } tunneltype_str[] = {
9743 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9744 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9747 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9748 if (!strcmp(tunneltype_str[i].str, string))
9749 return tunneltype_str[i].type;
9751 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9754 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9756 if ((ip_addr).family == AF_INET) \
9757 (ip) = (ip_addr).addr.ipv4.s_addr; \
9759 printf("invalid parameter.\n"); \
9764 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9766 if ((ip_addr).family == AF_INET6) \
9768 &((ip_addr).addr.ipv6), \
9769 sizeof(struct in6_addr)); \
9771 printf("invalid parameter.\n"); \
9777 cmd_flow_director_filter_parsed(void *parsed_result,
9778 __attribute__((unused)) struct cmdline *cl,
9779 __attribute__((unused)) void *data)
9781 struct cmd_flow_director_result *res = parsed_result;
9782 struct rte_eth_fdir_filter entry;
9783 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9785 unsigned long vf_id;
9788 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9790 printf("flow director is not supported on port %u.\n",
9794 memset(flexbytes, 0, sizeof(flexbytes));
9795 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9797 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9798 if (strcmp(res->mode_value, "MAC-VLAN")) {
9799 printf("Please set mode to MAC-VLAN.\n");
9802 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9803 if (strcmp(res->mode_value, "Tunnel")) {
9804 printf("Please set mode to Tunnel.\n");
9808 if (strcmp(res->mode_value, "IP")) {
9809 printf("Please set mode to IP.\n");
9812 entry.input.flow_type = str2flowtype(res->flow_type);
9815 ret = parse_flexbytes(res->flexbytes_value,
9817 RTE_ETH_FDIR_MAX_FLEXLEN);
9819 printf("error: Cannot parse flexbytes input.\n");
9823 switch (entry.input.flow_type) {
9824 case RTE_ETH_FLOW_FRAG_IPV4:
9825 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9826 entry.input.flow.ip4_flow.proto = res->proto_value;
9828 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9829 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9830 IPV4_ADDR_TO_UINT(res->ip_dst,
9831 entry.input.flow.ip4_flow.dst_ip);
9832 IPV4_ADDR_TO_UINT(res->ip_src,
9833 entry.input.flow.ip4_flow.src_ip);
9834 entry.input.flow.ip4_flow.tos = res->tos_value;
9835 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9836 /* need convert to big endian. */
9837 entry.input.flow.udp4_flow.dst_port =
9838 rte_cpu_to_be_16(res->port_dst);
9839 entry.input.flow.udp4_flow.src_port =
9840 rte_cpu_to_be_16(res->port_src);
9842 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9843 IPV4_ADDR_TO_UINT(res->ip_dst,
9844 entry.input.flow.sctp4_flow.ip.dst_ip);
9845 IPV4_ADDR_TO_UINT(res->ip_src,
9846 entry.input.flow.sctp4_flow.ip.src_ip);
9847 entry.input.flow.ip4_flow.tos = res->tos_value;
9848 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9849 /* need convert to big endian. */
9850 entry.input.flow.sctp4_flow.dst_port =
9851 rte_cpu_to_be_16(res->port_dst);
9852 entry.input.flow.sctp4_flow.src_port =
9853 rte_cpu_to_be_16(res->port_src);
9854 entry.input.flow.sctp4_flow.verify_tag =
9855 rte_cpu_to_be_32(res->verify_tag_value);
9857 case RTE_ETH_FLOW_FRAG_IPV6:
9858 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9859 entry.input.flow.ipv6_flow.proto = res->proto_value;
9861 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9862 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9863 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9864 entry.input.flow.ipv6_flow.dst_ip);
9865 IPV6_ADDR_TO_ARRAY(res->ip_src,
9866 entry.input.flow.ipv6_flow.src_ip);
9867 entry.input.flow.ipv6_flow.tc = res->tos_value;
9868 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9869 /* need convert to big endian. */
9870 entry.input.flow.udp6_flow.dst_port =
9871 rte_cpu_to_be_16(res->port_dst);
9872 entry.input.flow.udp6_flow.src_port =
9873 rte_cpu_to_be_16(res->port_src);
9875 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9876 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9877 entry.input.flow.sctp6_flow.ip.dst_ip);
9878 IPV6_ADDR_TO_ARRAY(res->ip_src,
9879 entry.input.flow.sctp6_flow.ip.src_ip);
9880 entry.input.flow.ipv6_flow.tc = res->tos_value;
9881 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9882 /* need convert to big endian. */
9883 entry.input.flow.sctp6_flow.dst_port =
9884 rte_cpu_to_be_16(res->port_dst);
9885 entry.input.flow.sctp6_flow.src_port =
9886 rte_cpu_to_be_16(res->port_src);
9887 entry.input.flow.sctp6_flow.verify_tag =
9888 rte_cpu_to_be_32(res->verify_tag_value);
9890 case RTE_ETH_FLOW_L2_PAYLOAD:
9891 entry.input.flow.l2_flow.ether_type =
9892 rte_cpu_to_be_16(res->ether_type);
9898 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
9899 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
9901 sizeof(struct ether_addr));
9903 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9904 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
9906 sizeof(struct ether_addr));
9907 entry.input.flow.tunnel_flow.tunnel_type =
9908 str2fdir_tunneltype(res->tunnel_type);
9909 entry.input.flow.tunnel_flow.tunnel_id =
9910 rte_cpu_to_be_32(res->tunnel_id_value);
9913 rte_memcpy(entry.input.flow_ext.flexbytes,
9915 RTE_ETH_FDIR_MAX_FLEXLEN);
9917 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
9919 entry.action.flex_off = 0; /*use 0 by default */
9920 if (!strcmp(res->drop, "drop"))
9921 entry.action.behavior = RTE_ETH_FDIR_REJECT;
9923 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
9925 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
9926 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
9927 if (!strcmp(res->pf_vf, "pf"))
9928 entry.input.flow_ext.is_vf = 0;
9929 else if (!strncmp(res->pf_vf, "vf", 2)) {
9930 struct rte_eth_dev_info dev_info;
9932 memset(&dev_info, 0, sizeof(dev_info));
9933 rte_eth_dev_info_get(res->port_id, &dev_info);
9935 vf_id = strtoul(res->pf_vf + 2, &end, 10);
9936 if (errno != 0 || *end != '\0' ||
9937 vf_id >= dev_info.max_vfs) {
9938 printf("invalid parameter %s.\n", res->pf_vf);
9941 entry.input.flow_ext.is_vf = 1;
9942 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
9944 printf("invalid parameter %s.\n", res->pf_vf);
9949 /* set to report FD ID by default */
9950 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
9951 entry.action.rx_queue = res->queue_id;
9952 entry.soft_id = res->fd_id_value;
9953 if (!strcmp(res->ops, "add"))
9954 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9955 RTE_ETH_FILTER_ADD, &entry);
9956 else if (!strcmp(res->ops, "del"))
9957 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9958 RTE_ETH_FILTER_DELETE, &entry);
9960 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9961 RTE_ETH_FILTER_UPDATE, &entry);
9963 printf("flow director programming error: (%s)\n",
9967 cmdline_parse_token_string_t cmd_flow_director_filter =
9968 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9969 flow_director_filter, "flow_director_filter");
9970 cmdline_parse_token_num_t cmd_flow_director_port_id =
9971 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9973 cmdline_parse_token_string_t cmd_flow_director_ops =
9974 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9975 ops, "add#del#update");
9976 cmdline_parse_token_string_t cmd_flow_director_flow =
9977 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9979 cmdline_parse_token_string_t cmd_flow_director_flow_type =
9980 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9981 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9982 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
9983 cmdline_parse_token_string_t cmd_flow_director_ether =
9984 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9986 cmdline_parse_token_num_t cmd_flow_director_ether_type =
9987 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9988 ether_type, UINT16);
9989 cmdline_parse_token_string_t cmd_flow_director_src =
9990 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9992 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
9993 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9995 cmdline_parse_token_num_t cmd_flow_director_port_src =
9996 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9998 cmdline_parse_token_string_t cmd_flow_director_dst =
9999 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10001 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10002 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10004 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10005 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10007 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10008 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10009 verify_tag, "verify_tag");
10010 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10011 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10012 verify_tag_value, UINT32);
10013 cmdline_parse_token_string_t cmd_flow_director_tos =
10014 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10016 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10017 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10019 cmdline_parse_token_string_t cmd_flow_director_proto =
10020 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10022 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10023 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10024 proto_value, UINT8);
10025 cmdline_parse_token_string_t cmd_flow_director_ttl =
10026 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10028 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10029 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10031 cmdline_parse_token_string_t cmd_flow_director_vlan =
10032 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10034 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10035 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10036 vlan_value, UINT16);
10037 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10038 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10039 flexbytes, "flexbytes");
10040 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10041 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10042 flexbytes_value, NULL);
10043 cmdline_parse_token_string_t cmd_flow_director_drop =
10044 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10046 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10047 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10049 cmdline_parse_token_string_t cmd_flow_director_queue =
10050 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10052 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10053 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10055 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10056 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10058 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10059 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10060 fd_id_value, UINT32);
10062 cmdline_parse_token_string_t cmd_flow_director_mode =
10063 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10065 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10066 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10068 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10069 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10070 mode_value, "MAC-VLAN");
10071 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10072 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10073 mode_value, "Tunnel");
10074 cmdline_parse_token_string_t cmd_flow_director_mac =
10075 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10077 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10078 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10080 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10081 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10083 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10084 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10085 tunnel_type, "NVGRE#VxLAN");
10086 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10087 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10088 tunnel_id, "tunnel-id");
10089 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10090 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10091 tunnel_id_value, UINT32);
10093 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10094 .f = cmd_flow_director_filter_parsed,
10096 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10097 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10098 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10099 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10100 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10101 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
10102 "fd_id <fd_id_value>: "
10103 "Add or delete an ip flow director entry on NIC",
10105 (void *)&cmd_flow_director_filter,
10106 (void *)&cmd_flow_director_port_id,
10107 (void *)&cmd_flow_director_mode,
10108 (void *)&cmd_flow_director_mode_ip,
10109 (void *)&cmd_flow_director_ops,
10110 (void *)&cmd_flow_director_flow,
10111 (void *)&cmd_flow_director_flow_type,
10112 (void *)&cmd_flow_director_src,
10113 (void *)&cmd_flow_director_ip_src,
10114 (void *)&cmd_flow_director_dst,
10115 (void *)&cmd_flow_director_ip_dst,
10116 (void *)&cmd_flow_director_tos,
10117 (void *)&cmd_flow_director_tos_value,
10118 (void *)&cmd_flow_director_proto,
10119 (void *)&cmd_flow_director_proto_value,
10120 (void *)&cmd_flow_director_ttl,
10121 (void *)&cmd_flow_director_ttl_value,
10122 (void *)&cmd_flow_director_vlan,
10123 (void *)&cmd_flow_director_vlan_value,
10124 (void *)&cmd_flow_director_flexbytes,
10125 (void *)&cmd_flow_director_flexbytes_value,
10126 (void *)&cmd_flow_director_drop,
10127 (void *)&cmd_flow_director_pf_vf,
10128 (void *)&cmd_flow_director_queue,
10129 (void *)&cmd_flow_director_queue_id,
10130 (void *)&cmd_flow_director_fd_id,
10131 (void *)&cmd_flow_director_fd_id_value,
10136 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10137 .f = cmd_flow_director_filter_parsed,
10139 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10140 "director entry on NIC",
10142 (void *)&cmd_flow_director_filter,
10143 (void *)&cmd_flow_director_port_id,
10144 (void *)&cmd_flow_director_mode,
10145 (void *)&cmd_flow_director_mode_ip,
10146 (void *)&cmd_flow_director_ops,
10147 (void *)&cmd_flow_director_flow,
10148 (void *)&cmd_flow_director_flow_type,
10149 (void *)&cmd_flow_director_src,
10150 (void *)&cmd_flow_director_ip_src,
10151 (void *)&cmd_flow_director_port_src,
10152 (void *)&cmd_flow_director_dst,
10153 (void *)&cmd_flow_director_ip_dst,
10154 (void *)&cmd_flow_director_port_dst,
10155 (void *)&cmd_flow_director_tos,
10156 (void *)&cmd_flow_director_tos_value,
10157 (void *)&cmd_flow_director_ttl,
10158 (void *)&cmd_flow_director_ttl_value,
10159 (void *)&cmd_flow_director_vlan,
10160 (void *)&cmd_flow_director_vlan_value,
10161 (void *)&cmd_flow_director_flexbytes,
10162 (void *)&cmd_flow_director_flexbytes_value,
10163 (void *)&cmd_flow_director_drop,
10164 (void *)&cmd_flow_director_pf_vf,
10165 (void *)&cmd_flow_director_queue,
10166 (void *)&cmd_flow_director_queue_id,
10167 (void *)&cmd_flow_director_fd_id,
10168 (void *)&cmd_flow_director_fd_id_value,
10173 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10174 .f = cmd_flow_director_filter_parsed,
10176 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10177 "director entry on NIC",
10179 (void *)&cmd_flow_director_filter,
10180 (void *)&cmd_flow_director_port_id,
10181 (void *)&cmd_flow_director_mode,
10182 (void *)&cmd_flow_director_mode_ip,
10183 (void *)&cmd_flow_director_ops,
10184 (void *)&cmd_flow_director_flow,
10185 (void *)&cmd_flow_director_flow_type,
10186 (void *)&cmd_flow_director_src,
10187 (void *)&cmd_flow_director_ip_src,
10188 (void *)&cmd_flow_director_port_dst,
10189 (void *)&cmd_flow_director_dst,
10190 (void *)&cmd_flow_director_ip_dst,
10191 (void *)&cmd_flow_director_port_dst,
10192 (void *)&cmd_flow_director_verify_tag,
10193 (void *)&cmd_flow_director_verify_tag_value,
10194 (void *)&cmd_flow_director_tos,
10195 (void *)&cmd_flow_director_tos_value,
10196 (void *)&cmd_flow_director_ttl,
10197 (void *)&cmd_flow_director_ttl_value,
10198 (void *)&cmd_flow_director_vlan,
10199 (void *)&cmd_flow_director_vlan_value,
10200 (void *)&cmd_flow_director_flexbytes,
10201 (void *)&cmd_flow_director_flexbytes_value,
10202 (void *)&cmd_flow_director_drop,
10203 (void *)&cmd_flow_director_pf_vf,
10204 (void *)&cmd_flow_director_queue,
10205 (void *)&cmd_flow_director_queue_id,
10206 (void *)&cmd_flow_director_fd_id,
10207 (void *)&cmd_flow_director_fd_id_value,
10212 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10213 .f = cmd_flow_director_filter_parsed,
10215 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10216 "director entry on NIC",
10218 (void *)&cmd_flow_director_filter,
10219 (void *)&cmd_flow_director_port_id,
10220 (void *)&cmd_flow_director_mode,
10221 (void *)&cmd_flow_director_mode_ip,
10222 (void *)&cmd_flow_director_ops,
10223 (void *)&cmd_flow_director_flow,
10224 (void *)&cmd_flow_director_flow_type,
10225 (void *)&cmd_flow_director_ether,
10226 (void *)&cmd_flow_director_ether_type,
10227 (void *)&cmd_flow_director_flexbytes,
10228 (void *)&cmd_flow_director_flexbytes_value,
10229 (void *)&cmd_flow_director_drop,
10230 (void *)&cmd_flow_director_pf_vf,
10231 (void *)&cmd_flow_director_queue,
10232 (void *)&cmd_flow_director_queue_id,
10233 (void *)&cmd_flow_director_fd_id,
10234 (void *)&cmd_flow_director_fd_id_value,
10239 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10240 .f = cmd_flow_director_filter_parsed,
10242 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10243 "director entry on NIC",
10245 (void *)&cmd_flow_director_filter,
10246 (void *)&cmd_flow_director_port_id,
10247 (void *)&cmd_flow_director_mode,
10248 (void *)&cmd_flow_director_mode_mac_vlan,
10249 (void *)&cmd_flow_director_ops,
10250 (void *)&cmd_flow_director_mac,
10251 (void *)&cmd_flow_director_mac_addr,
10252 (void *)&cmd_flow_director_vlan,
10253 (void *)&cmd_flow_director_vlan_value,
10254 (void *)&cmd_flow_director_flexbytes,
10255 (void *)&cmd_flow_director_flexbytes_value,
10256 (void *)&cmd_flow_director_drop,
10257 (void *)&cmd_flow_director_queue,
10258 (void *)&cmd_flow_director_queue_id,
10259 (void *)&cmd_flow_director_fd_id,
10260 (void *)&cmd_flow_director_fd_id_value,
10265 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10266 .f = cmd_flow_director_filter_parsed,
10268 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10269 "director entry on NIC",
10271 (void *)&cmd_flow_director_filter,
10272 (void *)&cmd_flow_director_port_id,
10273 (void *)&cmd_flow_director_mode,
10274 (void *)&cmd_flow_director_mode_tunnel,
10275 (void *)&cmd_flow_director_ops,
10276 (void *)&cmd_flow_director_mac,
10277 (void *)&cmd_flow_director_mac_addr,
10278 (void *)&cmd_flow_director_vlan,
10279 (void *)&cmd_flow_director_vlan_value,
10280 (void *)&cmd_flow_director_tunnel,
10281 (void *)&cmd_flow_director_tunnel_type,
10282 (void *)&cmd_flow_director_tunnel_id,
10283 (void *)&cmd_flow_director_tunnel_id_value,
10284 (void *)&cmd_flow_director_flexbytes,
10285 (void *)&cmd_flow_director_flexbytes_value,
10286 (void *)&cmd_flow_director_drop,
10287 (void *)&cmd_flow_director_queue,
10288 (void *)&cmd_flow_director_queue_id,
10289 (void *)&cmd_flow_director_fd_id,
10290 (void *)&cmd_flow_director_fd_id_value,
10295 struct cmd_flush_flow_director_result {
10296 cmdline_fixed_string_t flush_flow_director;
10300 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10301 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10302 flush_flow_director, "flush_flow_director");
10303 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10304 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10308 cmd_flush_flow_director_parsed(void *parsed_result,
10309 __attribute__((unused)) struct cmdline *cl,
10310 __attribute__((unused)) void *data)
10312 struct cmd_flow_director_result *res = parsed_result;
10315 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10317 printf("flow director is not supported on port %u.\n",
10322 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10323 RTE_ETH_FILTER_FLUSH, NULL);
10325 printf("flow director table flushing error: (%s)\n",
10329 cmdline_parse_inst_t cmd_flush_flow_director = {
10330 .f = cmd_flush_flow_director_parsed,
10332 .help_str = "flush_flow_director <port_id>: "
10333 "Flush all flow director entries of a device on NIC",
10335 (void *)&cmd_flush_flow_director_flush,
10336 (void *)&cmd_flush_flow_director_port_id,
10341 /* *** deal with flow director mask *** */
10342 struct cmd_flow_director_mask_result {
10343 cmdline_fixed_string_t flow_director_mask;
10345 cmdline_fixed_string_t mode;
10346 cmdline_fixed_string_t mode_value;
10347 cmdline_fixed_string_t vlan;
10348 uint16_t vlan_mask;
10349 cmdline_fixed_string_t src_mask;
10350 cmdline_ipaddr_t ipv4_src;
10351 cmdline_ipaddr_t ipv6_src;
10353 cmdline_fixed_string_t dst_mask;
10354 cmdline_ipaddr_t ipv4_dst;
10355 cmdline_ipaddr_t ipv6_dst;
10357 cmdline_fixed_string_t mac;
10358 uint8_t mac_addr_byte_mask;
10359 cmdline_fixed_string_t tunnel_id;
10360 uint32_t tunnel_id_mask;
10361 cmdline_fixed_string_t tunnel_type;
10362 uint8_t tunnel_type_mask;
10366 cmd_flow_director_mask_parsed(void *parsed_result,
10367 __attribute__((unused)) struct cmdline *cl,
10368 __attribute__((unused)) void *data)
10370 struct cmd_flow_director_mask_result *res = parsed_result;
10371 struct rte_eth_fdir_masks *mask;
10372 struct rte_port *port;
10374 if (res->port_id > nb_ports) {
10375 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10379 port = &ports[res->port_id];
10380 /** Check if the port is not started **/
10381 if (port->port_status != RTE_PORT_STOPPED) {
10382 printf("Please stop port %d first\n", res->port_id);
10386 mask = &port->dev_conf.fdir_conf.mask;
10388 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10389 if (strcmp(res->mode_value, "MAC-VLAN")) {
10390 printf("Please set mode to MAC-VLAN.\n");
10394 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10395 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10396 if (strcmp(res->mode_value, "Tunnel")) {
10397 printf("Please set mode to Tunnel.\n");
10401 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10402 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10403 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10404 mask->tunnel_type_mask = res->tunnel_type_mask;
10406 if (strcmp(res->mode_value, "IP")) {
10407 printf("Please set mode to IP.\n");
10411 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10412 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10413 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10414 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10415 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10416 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10417 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10420 cmd_reconfig_device_queue(res->port_id, 1, 1);
10423 cmdline_parse_token_string_t cmd_flow_director_mask =
10424 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10425 flow_director_mask, "flow_director_mask");
10426 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10427 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10429 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10432 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10433 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10434 vlan_mask, UINT16);
10435 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10436 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10437 src_mask, "src_mask");
10438 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10439 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10441 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10442 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10444 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10445 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10447 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10448 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10449 dst_mask, "dst_mask");
10450 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10451 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10453 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10454 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10456 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10457 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10460 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10461 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10463 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10464 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10466 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10467 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10468 mode_value, "MAC-VLAN");
10469 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10470 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10471 mode_value, "Tunnel");
10472 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10473 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10475 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10476 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10477 mac_addr_byte_mask, UINT8);
10478 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10479 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10480 tunnel_type, "tunnel-type");
10481 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10482 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10483 tunnel_type_mask, UINT8);
10484 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10485 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10486 tunnel_id, "tunnel-id");
10487 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10488 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10489 tunnel_id_mask, UINT32);
10491 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10492 .f = cmd_flow_director_mask_parsed,
10494 .help_str = "flow_director_mask ... : "
10495 "Set IP mode flow director's mask on NIC",
10497 (void *)&cmd_flow_director_mask,
10498 (void *)&cmd_flow_director_mask_port_id,
10499 (void *)&cmd_flow_director_mask_mode,
10500 (void *)&cmd_flow_director_mask_mode_ip,
10501 (void *)&cmd_flow_director_mask_vlan,
10502 (void *)&cmd_flow_director_mask_vlan_value,
10503 (void *)&cmd_flow_director_mask_src,
10504 (void *)&cmd_flow_director_mask_ipv4_src,
10505 (void *)&cmd_flow_director_mask_ipv6_src,
10506 (void *)&cmd_flow_director_mask_port_src,
10507 (void *)&cmd_flow_director_mask_dst,
10508 (void *)&cmd_flow_director_mask_ipv4_dst,
10509 (void *)&cmd_flow_director_mask_ipv6_dst,
10510 (void *)&cmd_flow_director_mask_port_dst,
10515 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10516 .f = cmd_flow_director_mask_parsed,
10518 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10519 "flow director's mask on NIC",
10521 (void *)&cmd_flow_director_mask,
10522 (void *)&cmd_flow_director_mask_port_id,
10523 (void *)&cmd_flow_director_mask_mode,
10524 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10525 (void *)&cmd_flow_director_mask_vlan,
10526 (void *)&cmd_flow_director_mask_vlan_value,
10531 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10532 .f = cmd_flow_director_mask_parsed,
10534 .help_str = "flow_director_mask ... : Set tunnel mode "
10535 "flow director's mask on NIC",
10537 (void *)&cmd_flow_director_mask,
10538 (void *)&cmd_flow_director_mask_port_id,
10539 (void *)&cmd_flow_director_mask_mode,
10540 (void *)&cmd_flow_director_mask_mode_tunnel,
10541 (void *)&cmd_flow_director_mask_vlan,
10542 (void *)&cmd_flow_director_mask_vlan_value,
10543 (void *)&cmd_flow_director_mask_mac,
10544 (void *)&cmd_flow_director_mask_mac_value,
10545 (void *)&cmd_flow_director_mask_tunnel_type,
10546 (void *)&cmd_flow_director_mask_tunnel_type_value,
10547 (void *)&cmd_flow_director_mask_tunnel_id,
10548 (void *)&cmd_flow_director_mask_tunnel_id_value,
10553 /* *** deal with flow director mask on flexible payload *** */
10554 struct cmd_flow_director_flex_mask_result {
10555 cmdline_fixed_string_t flow_director_flexmask;
10557 cmdline_fixed_string_t flow;
10558 cmdline_fixed_string_t flow_type;
10559 cmdline_fixed_string_t mask;
10563 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10564 __attribute__((unused)) struct cmdline *cl,
10565 __attribute__((unused)) void *data)
10567 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10568 struct rte_eth_fdir_info fdir_info;
10569 struct rte_eth_fdir_flex_mask flex_mask;
10570 struct rte_port *port;
10571 uint32_t flow_type_mask;
10575 if (res->port_id > nb_ports) {
10576 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10580 port = &ports[res->port_id];
10581 /** Check if the port is not started **/
10582 if (port->port_status != RTE_PORT_STOPPED) {
10583 printf("Please stop port %d first\n", res->port_id);
10587 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10588 ret = parse_flexbytes(res->mask,
10590 RTE_ETH_FDIR_MAX_FLEXLEN);
10592 printf("error: Cannot parse mask input.\n");
10596 memset(&fdir_info, 0, sizeof(fdir_info));
10597 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10598 RTE_ETH_FILTER_INFO, &fdir_info);
10600 printf("Cannot get FDir filter info\n");
10604 if (!strcmp(res->flow_type, "none")) {
10605 /* means don't specify the flow type */
10606 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10607 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10608 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10609 0, sizeof(struct rte_eth_fdir_flex_mask));
10610 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10611 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10613 sizeof(struct rte_eth_fdir_flex_mask));
10614 cmd_reconfig_device_queue(res->port_id, 1, 1);
10617 flow_type_mask = fdir_info.flow_types_mask[0];
10618 if (!strcmp(res->flow_type, "all")) {
10619 if (!flow_type_mask) {
10620 printf("No flow type supported\n");
10623 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10624 if (flow_type_mask & (1 << i)) {
10625 flex_mask.flow_type = i;
10626 fdir_set_flex_mask(res->port_id, &flex_mask);
10629 cmd_reconfig_device_queue(res->port_id, 1, 1);
10632 flex_mask.flow_type = str2flowtype(res->flow_type);
10633 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10634 printf("Flow type %s not supported on port %d\n",
10635 res->flow_type, res->port_id);
10638 fdir_set_flex_mask(res->port_id, &flex_mask);
10639 cmd_reconfig_device_queue(res->port_id, 1, 1);
10642 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10643 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10644 flow_director_flexmask,
10645 "flow_director_flex_mask");
10646 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10647 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10649 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10650 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10652 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10653 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10654 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10655 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10656 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10657 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10660 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10661 .f = cmd_flow_director_flex_mask_parsed,
10663 .help_str = "flow_director_flex_mask ... : "
10664 "Set flow director's flex mask on NIC",
10666 (void *)&cmd_flow_director_flexmask,
10667 (void *)&cmd_flow_director_flexmask_port_id,
10668 (void *)&cmd_flow_director_flexmask_flow,
10669 (void *)&cmd_flow_director_flexmask_flow_type,
10670 (void *)&cmd_flow_director_flexmask_mask,
10675 /* *** deal with flow director flexible payload configuration *** */
10676 struct cmd_flow_director_flexpayload_result {
10677 cmdline_fixed_string_t flow_director_flexpayload;
10679 cmdline_fixed_string_t payload_layer;
10680 cmdline_fixed_string_t payload_cfg;
10684 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10687 const char *p, *p0 = q_arg;
10689 unsigned long int_fld;
10690 char *str_fld[max_num];
10695 p = strchr(p0, '(');
10699 p0 = strchr(p, ')');
10704 if (size >= sizeof(s))
10707 snprintf(s, sizeof(s), "%.*s", size, p);
10708 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10709 if (ret < 0 || ret > max_num)
10711 for (i = 0; i < ret; i++) {
10713 int_fld = strtoul(str_fld[i], &end, 0);
10714 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10716 offsets[i] = (uint16_t)int_fld;
10722 cmd_flow_director_flxpld_parsed(void *parsed_result,
10723 __attribute__((unused)) struct cmdline *cl,
10724 __attribute__((unused)) void *data)
10726 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10727 struct rte_eth_flex_payload_cfg flex_cfg;
10728 struct rte_port *port;
10731 if (res->port_id > nb_ports) {
10732 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10736 port = &ports[res->port_id];
10737 /** Check if the port is not started **/
10738 if (port->port_status != RTE_PORT_STOPPED) {
10739 printf("Please stop port %d first\n", res->port_id);
10743 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10745 if (!strcmp(res->payload_layer, "raw"))
10746 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10747 else if (!strcmp(res->payload_layer, "l2"))
10748 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10749 else if (!strcmp(res->payload_layer, "l3"))
10750 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10751 else if (!strcmp(res->payload_layer, "l4"))
10752 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10754 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10755 RTE_ETH_FDIR_MAX_FLEXLEN);
10757 printf("error: Cannot parse flex payload input.\n");
10761 fdir_set_flex_payload(res->port_id, &flex_cfg);
10762 cmd_reconfig_device_queue(res->port_id, 1, 1);
10765 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10767 flow_director_flexpayload,
10768 "flow_director_flex_payload");
10769 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10770 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10772 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10773 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10774 payload_layer, "raw#l2#l3#l4");
10775 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10776 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10777 payload_cfg, NULL);
10779 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10780 .f = cmd_flow_director_flxpld_parsed,
10782 .help_str = "flow_director_flexpayload ... : "
10783 "Set flow director's flex payload on NIC",
10785 (void *)&cmd_flow_director_flexpayload,
10786 (void *)&cmd_flow_director_flexpayload_port_id,
10787 (void *)&cmd_flow_director_flexpayload_payload_layer,
10788 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10793 /* Generic flow interface command. */
10794 extern cmdline_parse_inst_t cmd_flow;
10796 /* *** Classification Filters Control *** */
10797 /* *** Get symmetric hash enable per port *** */
10798 struct cmd_get_sym_hash_ena_per_port_result {
10799 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10804 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10805 __rte_unused struct cmdline *cl,
10806 __rte_unused void *data)
10808 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10809 struct rte_eth_hash_filter_info info;
10812 if (rte_eth_dev_filter_supported(res->port_id,
10813 RTE_ETH_FILTER_HASH) < 0) {
10814 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10819 memset(&info, 0, sizeof(info));
10820 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10821 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10822 RTE_ETH_FILTER_GET, &info);
10825 printf("Cannot get symmetric hash enable per port "
10826 "on port %u\n", res->port_id);
10830 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10831 "enabled" : "disabled", res->port_id);
10834 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10835 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10836 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10837 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10838 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10841 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10842 .f = cmd_get_sym_hash_per_port_parsed,
10844 .help_str = "get_sym_hash_ena_per_port <port_id>",
10846 (void *)&cmd_get_sym_hash_ena_per_port_all,
10847 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10852 /* *** Set symmetric hash enable per port *** */
10853 struct cmd_set_sym_hash_ena_per_port_result {
10854 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10855 cmdline_fixed_string_t enable;
10860 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10861 __rte_unused struct cmdline *cl,
10862 __rte_unused void *data)
10864 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10865 struct rte_eth_hash_filter_info info;
10868 if (rte_eth_dev_filter_supported(res->port_id,
10869 RTE_ETH_FILTER_HASH) < 0) {
10870 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10875 memset(&info, 0, sizeof(info));
10876 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10877 if (!strcmp(res->enable, "enable"))
10878 info.info.enable = 1;
10879 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10880 RTE_ETH_FILTER_SET, &info);
10882 printf("Cannot set symmetric hash enable per port on "
10883 "port %u\n", res->port_id);
10886 printf("Symmetric hash has been set to %s on port %u\n",
10887 res->enable, res->port_id);
10890 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
10891 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10892 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
10893 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
10894 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10896 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
10897 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10898 enable, "enable#disable");
10900 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
10901 .f = cmd_set_sym_hash_per_port_parsed,
10903 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
10905 (void *)&cmd_set_sym_hash_ena_per_port_all,
10906 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
10907 (void *)&cmd_set_sym_hash_ena_per_port_enable,
10912 /* Get global config of hash function */
10913 struct cmd_get_hash_global_config_result {
10914 cmdline_fixed_string_t get_hash_global_config;
10919 flowtype_to_str(uint16_t ftype)
10925 } ftype_table[] = {
10926 {"ipv4", RTE_ETH_FLOW_IPV4},
10927 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10928 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10929 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10930 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10931 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10932 {"ipv6", RTE_ETH_FLOW_IPV6},
10933 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10934 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10935 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10936 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10937 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10938 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10939 {"port", RTE_ETH_FLOW_PORT},
10940 {"vxlan", RTE_ETH_FLOW_VXLAN},
10941 {"geneve", RTE_ETH_FLOW_GENEVE},
10942 {"nvgre", RTE_ETH_FLOW_NVGRE},
10945 for (i = 0; i < RTE_DIM(ftype_table); i++) {
10946 if (ftype_table[i].ftype == ftype)
10947 return ftype_table[i].str;
10954 cmd_get_hash_global_config_parsed(void *parsed_result,
10955 __rte_unused struct cmdline *cl,
10956 __rte_unused void *data)
10958 struct cmd_get_hash_global_config_result *res = parsed_result;
10959 struct rte_eth_hash_filter_info info;
10960 uint32_t idx, offset;
10965 if (rte_eth_dev_filter_supported(res->port_id,
10966 RTE_ETH_FILTER_HASH) < 0) {
10967 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10972 memset(&info, 0, sizeof(info));
10973 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10974 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10975 RTE_ETH_FILTER_GET, &info);
10977 printf("Cannot get hash global configurations by port %d\n",
10982 switch (info.info.global_conf.hash_func) {
10983 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
10984 printf("Hash function is Toeplitz\n");
10986 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
10987 printf("Hash function is Simple XOR\n");
10990 printf("Unknown hash function\n");
10994 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
10995 idx = i / UINT32_BIT;
10996 offset = i % UINT32_BIT;
10997 if (!(info.info.global_conf.valid_bit_mask[idx] &
11000 str = flowtype_to_str(i);
11003 printf("Symmetric hash is %s globally for flow type %s "
11005 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11006 (1UL << offset)) ? "enabled" : "disabled"), str,
11011 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11012 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11013 get_hash_global_config, "get_hash_global_config");
11014 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11015 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11018 cmdline_parse_inst_t cmd_get_hash_global_config = {
11019 .f = cmd_get_hash_global_config_parsed,
11021 .help_str = "get_hash_global_config <port_id>",
11023 (void *)&cmd_get_hash_global_config_all,
11024 (void *)&cmd_get_hash_global_config_port_id,
11029 /* Set global config of hash function */
11030 struct cmd_set_hash_global_config_result {
11031 cmdline_fixed_string_t set_hash_global_config;
11033 cmdline_fixed_string_t hash_func;
11034 cmdline_fixed_string_t flow_type;
11035 cmdline_fixed_string_t enable;
11039 cmd_set_hash_global_config_parsed(void *parsed_result,
11040 __rte_unused struct cmdline *cl,
11041 __rte_unused void *data)
11043 struct cmd_set_hash_global_config_result *res = parsed_result;
11044 struct rte_eth_hash_filter_info info;
11045 uint32_t ftype, idx, offset;
11048 if (rte_eth_dev_filter_supported(res->port_id,
11049 RTE_ETH_FILTER_HASH) < 0) {
11050 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11054 memset(&info, 0, sizeof(info));
11055 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11056 if (!strcmp(res->hash_func, "toeplitz"))
11057 info.info.global_conf.hash_func =
11058 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11059 else if (!strcmp(res->hash_func, "simple_xor"))
11060 info.info.global_conf.hash_func =
11061 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11062 else if (!strcmp(res->hash_func, "default"))
11063 info.info.global_conf.hash_func =
11064 RTE_ETH_HASH_FUNCTION_DEFAULT;
11066 ftype = str2flowtype(res->flow_type);
11067 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11068 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11069 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11070 if (!strcmp(res->enable, "enable"))
11071 info.info.global_conf.sym_hash_enable_mask[idx] |=
11073 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11074 RTE_ETH_FILTER_SET, &info);
11076 printf("Cannot set global hash configurations by port %d\n",
11079 printf("Global hash configurations have been set "
11080 "succcessfully by port %d\n", res->port_id);
11083 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11084 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11085 set_hash_global_config, "set_hash_global_config");
11086 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11087 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11089 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11090 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11091 hash_func, "toeplitz#simple_xor#default");
11092 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11093 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11095 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11096 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11097 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11098 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11099 enable, "enable#disable");
11101 cmdline_parse_inst_t cmd_set_hash_global_config = {
11102 .f = cmd_set_hash_global_config_parsed,
11104 .help_str = "set_hash_global_config <port_id> "
11105 "toeplitz|simple_xor|default "
11106 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11107 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11108 "l2_payload enable|disable",
11110 (void *)&cmd_set_hash_global_config_all,
11111 (void *)&cmd_set_hash_global_config_port_id,
11112 (void *)&cmd_set_hash_global_config_hash_func,
11113 (void *)&cmd_set_hash_global_config_flow_type,
11114 (void *)&cmd_set_hash_global_config_enable,
11119 /* Set hash input set */
11120 struct cmd_set_hash_input_set_result {
11121 cmdline_fixed_string_t set_hash_input_set;
11123 cmdline_fixed_string_t flow_type;
11124 cmdline_fixed_string_t inset_field;
11125 cmdline_fixed_string_t select;
11128 static enum rte_eth_input_set_field
11129 str2inset(char *string)
11133 static const struct {
11135 enum rte_eth_input_set_field inset;
11136 } inset_table[] = {
11137 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11138 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11139 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11140 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11141 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11142 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11143 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11144 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11145 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11146 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11147 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11148 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11149 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11150 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11151 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11152 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11153 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11154 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11155 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11156 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11157 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11158 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11159 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11160 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11161 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11162 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11163 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11164 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11165 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11166 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11167 {"none", RTE_ETH_INPUT_SET_NONE},
11170 for (i = 0; i < RTE_DIM(inset_table); i++) {
11171 if (!strcmp(string, inset_table[i].str))
11172 return inset_table[i].inset;
11175 return RTE_ETH_INPUT_SET_UNKNOWN;
11179 cmd_set_hash_input_set_parsed(void *parsed_result,
11180 __rte_unused struct cmdline *cl,
11181 __rte_unused void *data)
11183 struct cmd_set_hash_input_set_result *res = parsed_result;
11184 struct rte_eth_hash_filter_info info;
11186 memset(&info, 0, sizeof(info));
11187 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11188 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11189 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11190 info.info.input_set_conf.inset_size = 1;
11191 if (!strcmp(res->select, "select"))
11192 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11193 else if (!strcmp(res->select, "add"))
11194 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11195 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11196 RTE_ETH_FILTER_SET, &info);
11199 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11200 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11201 set_hash_input_set, "set_hash_input_set");
11202 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11203 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11205 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11206 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11208 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11209 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11211 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11212 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11213 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11214 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11215 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11217 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11218 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11219 select, "select#add");
11221 cmdline_parse_inst_t cmd_set_hash_input_set = {
11222 .f = cmd_set_hash_input_set_parsed,
11224 .help_str = "set_hash_input_set <port_id> "
11225 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11226 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11227 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11228 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11229 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11230 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11231 "fld-7th|fld-8th|none select|add",
11233 (void *)&cmd_set_hash_input_set_cmd,
11234 (void *)&cmd_set_hash_input_set_port_id,
11235 (void *)&cmd_set_hash_input_set_flow_type,
11236 (void *)&cmd_set_hash_input_set_field,
11237 (void *)&cmd_set_hash_input_set_select,
11242 /* Set flow director input set */
11243 struct cmd_set_fdir_input_set_result {
11244 cmdline_fixed_string_t set_fdir_input_set;
11246 cmdline_fixed_string_t flow_type;
11247 cmdline_fixed_string_t inset_field;
11248 cmdline_fixed_string_t select;
11252 cmd_set_fdir_input_set_parsed(void *parsed_result,
11253 __rte_unused struct cmdline *cl,
11254 __rte_unused void *data)
11256 struct cmd_set_fdir_input_set_result *res = parsed_result;
11257 struct rte_eth_fdir_filter_info info;
11259 memset(&info, 0, sizeof(info));
11260 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11261 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11262 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11263 info.info.input_set_conf.inset_size = 1;
11264 if (!strcmp(res->select, "select"))
11265 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11266 else if (!strcmp(res->select, "add"))
11267 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11268 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11269 RTE_ETH_FILTER_SET, &info);
11272 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11273 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11274 set_fdir_input_set, "set_fdir_input_set");
11275 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11276 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11278 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11279 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11281 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11282 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11283 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11284 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11286 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11287 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11288 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11289 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11290 "sctp-veri-tag#none");
11291 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11292 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11293 select, "select#add");
11295 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11296 .f = cmd_set_fdir_input_set_parsed,
11298 .help_str = "set_fdir_input_set <port_id> "
11299 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11300 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11301 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11302 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11303 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11304 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11305 "sctp-veri-tag|none select|add",
11307 (void *)&cmd_set_fdir_input_set_cmd,
11308 (void *)&cmd_set_fdir_input_set_port_id,
11309 (void *)&cmd_set_fdir_input_set_flow_type,
11310 (void *)&cmd_set_fdir_input_set_field,
11311 (void *)&cmd_set_fdir_input_set_select,
11316 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11317 struct cmd_mcast_addr_result {
11318 cmdline_fixed_string_t mcast_addr_cmd;
11319 cmdline_fixed_string_t what;
11321 struct ether_addr mc_addr;
11324 static void cmd_mcast_addr_parsed(void *parsed_result,
11325 __attribute__((unused)) struct cmdline *cl,
11326 __attribute__((unused)) void *data)
11328 struct cmd_mcast_addr_result *res = parsed_result;
11330 if (!is_multicast_ether_addr(&res->mc_addr)) {
11331 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11332 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11333 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11334 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11337 if (strcmp(res->what, "add") == 0)
11338 mcast_addr_add(res->port_num, &res->mc_addr);
11340 mcast_addr_remove(res->port_num, &res->mc_addr);
11343 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11344 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11345 mcast_addr_cmd, "mcast_addr");
11346 cmdline_parse_token_string_t cmd_mcast_addr_what =
11347 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11349 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11350 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11351 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11352 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11354 cmdline_parse_inst_t cmd_mcast_addr = {
11355 .f = cmd_mcast_addr_parsed,
11357 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11358 "Add/Remove multicast MAC address on port_id",
11360 (void *)&cmd_mcast_addr_cmd,
11361 (void *)&cmd_mcast_addr_what,
11362 (void *)&cmd_mcast_addr_portnum,
11363 (void *)&cmd_mcast_addr_addr,
11368 /* l2 tunnel config
11369 * only support E-tag now.
11372 /* Ether type config */
11373 struct cmd_config_l2_tunnel_eth_type_result {
11374 cmdline_fixed_string_t port;
11375 cmdline_fixed_string_t config;
11376 cmdline_fixed_string_t all;
11378 cmdline_fixed_string_t l2_tunnel;
11379 cmdline_fixed_string_t l2_tunnel_type;
11380 cmdline_fixed_string_t eth_type;
11381 uint16_t eth_type_val;
11384 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11385 TOKEN_STRING_INITIALIZER
11386 (struct cmd_config_l2_tunnel_eth_type_result,
11388 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11389 TOKEN_STRING_INITIALIZER
11390 (struct cmd_config_l2_tunnel_eth_type_result,
11392 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11393 TOKEN_STRING_INITIALIZER
11394 (struct cmd_config_l2_tunnel_eth_type_result,
11396 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11397 TOKEN_NUM_INITIALIZER
11398 (struct cmd_config_l2_tunnel_eth_type_result,
11400 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11401 TOKEN_STRING_INITIALIZER
11402 (struct cmd_config_l2_tunnel_eth_type_result,
11403 l2_tunnel, "l2-tunnel");
11404 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11405 TOKEN_STRING_INITIALIZER
11406 (struct cmd_config_l2_tunnel_eth_type_result,
11407 l2_tunnel_type, "E-tag");
11408 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11409 TOKEN_STRING_INITIALIZER
11410 (struct cmd_config_l2_tunnel_eth_type_result,
11411 eth_type, "ether-type");
11412 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11413 TOKEN_NUM_INITIALIZER
11414 (struct cmd_config_l2_tunnel_eth_type_result,
11415 eth_type_val, UINT16);
11417 static enum rte_eth_tunnel_type
11418 str2fdir_l2_tunnel_type(char *string)
11422 static const struct {
11424 enum rte_eth_tunnel_type type;
11425 } l2_tunnel_type_str[] = {
11426 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11429 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11430 if (!strcmp(l2_tunnel_type_str[i].str, string))
11431 return l2_tunnel_type_str[i].type;
11433 return RTE_TUNNEL_TYPE_NONE;
11436 /* ether type config for all ports */
11438 cmd_config_l2_tunnel_eth_type_all_parsed
11439 (void *parsed_result,
11440 __attribute__((unused)) struct cmdline *cl,
11441 __attribute__((unused)) void *data)
11443 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11444 struct rte_eth_l2_tunnel_conf entry;
11447 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11448 entry.ether_type = res->eth_type_val;
11450 RTE_ETH_FOREACH_DEV(pid) {
11451 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11455 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11456 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11458 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11460 (void *)&cmd_config_l2_tunnel_eth_type_port,
11461 (void *)&cmd_config_l2_tunnel_eth_type_config,
11462 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11463 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11464 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11465 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11466 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11471 /* ether type config for a specific port */
11473 cmd_config_l2_tunnel_eth_type_specific_parsed(
11474 void *parsed_result,
11475 __attribute__((unused)) struct cmdline *cl,
11476 __attribute__((unused)) void *data)
11478 struct cmd_config_l2_tunnel_eth_type_result *res =
11480 struct rte_eth_l2_tunnel_conf entry;
11482 if (port_id_is_invalid(res->id, ENABLED_WARN))
11485 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11486 entry.ether_type = res->eth_type_val;
11488 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11491 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11492 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11494 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11496 (void *)&cmd_config_l2_tunnel_eth_type_port,
11497 (void *)&cmd_config_l2_tunnel_eth_type_config,
11498 (void *)&cmd_config_l2_tunnel_eth_type_id,
11499 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11500 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11501 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11502 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11507 /* Enable/disable l2 tunnel */
11508 struct cmd_config_l2_tunnel_en_dis_result {
11509 cmdline_fixed_string_t port;
11510 cmdline_fixed_string_t config;
11511 cmdline_fixed_string_t all;
11513 cmdline_fixed_string_t l2_tunnel;
11514 cmdline_fixed_string_t l2_tunnel_type;
11515 cmdline_fixed_string_t en_dis;
11518 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11519 TOKEN_STRING_INITIALIZER
11520 (struct cmd_config_l2_tunnel_en_dis_result,
11522 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11523 TOKEN_STRING_INITIALIZER
11524 (struct cmd_config_l2_tunnel_en_dis_result,
11526 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11527 TOKEN_STRING_INITIALIZER
11528 (struct cmd_config_l2_tunnel_en_dis_result,
11530 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11531 TOKEN_NUM_INITIALIZER
11532 (struct cmd_config_l2_tunnel_en_dis_result,
11534 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11535 TOKEN_STRING_INITIALIZER
11536 (struct cmd_config_l2_tunnel_en_dis_result,
11537 l2_tunnel, "l2-tunnel");
11538 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11539 TOKEN_STRING_INITIALIZER
11540 (struct cmd_config_l2_tunnel_en_dis_result,
11541 l2_tunnel_type, "E-tag");
11542 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11543 TOKEN_STRING_INITIALIZER
11544 (struct cmd_config_l2_tunnel_en_dis_result,
11545 en_dis, "enable#disable");
11547 /* enable/disable l2 tunnel for all ports */
11549 cmd_config_l2_tunnel_en_dis_all_parsed(
11550 void *parsed_result,
11551 __attribute__((unused)) struct cmdline *cl,
11552 __attribute__((unused)) void *data)
11554 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11555 struct rte_eth_l2_tunnel_conf entry;
11559 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11561 if (!strcmp("enable", res->en_dis))
11566 RTE_ETH_FOREACH_DEV(pid) {
11567 rte_eth_dev_l2_tunnel_offload_set(pid,
11569 ETH_L2_TUNNEL_ENABLE_MASK,
11574 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11575 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11577 .help_str = "port config all l2-tunnel E-tag enable|disable",
11579 (void *)&cmd_config_l2_tunnel_en_dis_port,
11580 (void *)&cmd_config_l2_tunnel_en_dis_config,
11581 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11582 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11583 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11584 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11589 /* enable/disable l2 tunnel for a port */
11591 cmd_config_l2_tunnel_en_dis_specific_parsed(
11592 void *parsed_result,
11593 __attribute__((unused)) struct cmdline *cl,
11594 __attribute__((unused)) void *data)
11596 struct cmd_config_l2_tunnel_en_dis_result *res =
11598 struct rte_eth_l2_tunnel_conf entry;
11600 if (port_id_is_invalid(res->id, ENABLED_WARN))
11603 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11605 if (!strcmp("enable", res->en_dis))
11606 rte_eth_dev_l2_tunnel_offload_set(res->id,
11608 ETH_L2_TUNNEL_ENABLE_MASK,
11611 rte_eth_dev_l2_tunnel_offload_set(res->id,
11613 ETH_L2_TUNNEL_ENABLE_MASK,
11617 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11618 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11620 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11622 (void *)&cmd_config_l2_tunnel_en_dis_port,
11623 (void *)&cmd_config_l2_tunnel_en_dis_config,
11624 (void *)&cmd_config_l2_tunnel_en_dis_id,
11625 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11626 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11627 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11632 /* E-tag configuration */
11634 /* Common result structure for all E-tag configuration */
11635 struct cmd_config_e_tag_result {
11636 cmdline_fixed_string_t e_tag;
11637 cmdline_fixed_string_t set;
11638 cmdline_fixed_string_t insertion;
11639 cmdline_fixed_string_t stripping;
11640 cmdline_fixed_string_t forwarding;
11641 cmdline_fixed_string_t filter;
11642 cmdline_fixed_string_t add;
11643 cmdline_fixed_string_t del;
11644 cmdline_fixed_string_t on;
11645 cmdline_fixed_string_t off;
11646 cmdline_fixed_string_t on_off;
11647 cmdline_fixed_string_t port_tag_id;
11648 uint32_t port_tag_id_val;
11649 cmdline_fixed_string_t e_tag_id;
11650 uint16_t e_tag_id_val;
11651 cmdline_fixed_string_t dst_pool;
11652 uint8_t dst_pool_val;
11653 cmdline_fixed_string_t port;
11655 cmdline_fixed_string_t vf;
11659 /* Common CLI fields for all E-tag configuration */
11660 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11661 TOKEN_STRING_INITIALIZER
11662 (struct cmd_config_e_tag_result,
11664 cmdline_parse_token_string_t cmd_config_e_tag_set =
11665 TOKEN_STRING_INITIALIZER
11666 (struct cmd_config_e_tag_result,
11668 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11669 TOKEN_STRING_INITIALIZER
11670 (struct cmd_config_e_tag_result,
11671 insertion, "insertion");
11672 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11673 TOKEN_STRING_INITIALIZER
11674 (struct cmd_config_e_tag_result,
11675 stripping, "stripping");
11676 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11677 TOKEN_STRING_INITIALIZER
11678 (struct cmd_config_e_tag_result,
11679 forwarding, "forwarding");
11680 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11681 TOKEN_STRING_INITIALIZER
11682 (struct cmd_config_e_tag_result,
11684 cmdline_parse_token_string_t cmd_config_e_tag_add =
11685 TOKEN_STRING_INITIALIZER
11686 (struct cmd_config_e_tag_result,
11688 cmdline_parse_token_string_t cmd_config_e_tag_del =
11689 TOKEN_STRING_INITIALIZER
11690 (struct cmd_config_e_tag_result,
11692 cmdline_parse_token_string_t cmd_config_e_tag_on =
11693 TOKEN_STRING_INITIALIZER
11694 (struct cmd_config_e_tag_result,
11696 cmdline_parse_token_string_t cmd_config_e_tag_off =
11697 TOKEN_STRING_INITIALIZER
11698 (struct cmd_config_e_tag_result,
11700 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11701 TOKEN_STRING_INITIALIZER
11702 (struct cmd_config_e_tag_result,
11704 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11705 TOKEN_STRING_INITIALIZER
11706 (struct cmd_config_e_tag_result,
11707 port_tag_id, "port-tag-id");
11708 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11709 TOKEN_NUM_INITIALIZER
11710 (struct cmd_config_e_tag_result,
11711 port_tag_id_val, UINT32);
11712 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11713 TOKEN_STRING_INITIALIZER
11714 (struct cmd_config_e_tag_result,
11715 e_tag_id, "e-tag-id");
11716 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11717 TOKEN_NUM_INITIALIZER
11718 (struct cmd_config_e_tag_result,
11719 e_tag_id_val, UINT16);
11720 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11721 TOKEN_STRING_INITIALIZER
11722 (struct cmd_config_e_tag_result,
11723 dst_pool, "dst-pool");
11724 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11725 TOKEN_NUM_INITIALIZER
11726 (struct cmd_config_e_tag_result,
11727 dst_pool_val, UINT8);
11728 cmdline_parse_token_string_t cmd_config_e_tag_port =
11729 TOKEN_STRING_INITIALIZER
11730 (struct cmd_config_e_tag_result,
11732 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11733 TOKEN_NUM_INITIALIZER
11734 (struct cmd_config_e_tag_result,
11736 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11737 TOKEN_STRING_INITIALIZER
11738 (struct cmd_config_e_tag_result,
11740 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11741 TOKEN_NUM_INITIALIZER
11742 (struct cmd_config_e_tag_result,
11745 /* E-tag insertion configuration */
11747 cmd_config_e_tag_insertion_en_parsed(
11748 void *parsed_result,
11749 __attribute__((unused)) struct cmdline *cl,
11750 __attribute__((unused)) void *data)
11752 struct cmd_config_e_tag_result *res =
11754 struct rte_eth_l2_tunnel_conf entry;
11756 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11759 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11760 entry.tunnel_id = res->port_tag_id_val;
11761 entry.vf_id = res->vf_id;
11762 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11764 ETH_L2_TUNNEL_INSERTION_MASK,
11769 cmd_config_e_tag_insertion_dis_parsed(
11770 void *parsed_result,
11771 __attribute__((unused)) struct cmdline *cl,
11772 __attribute__((unused)) void *data)
11774 struct cmd_config_e_tag_result *res =
11776 struct rte_eth_l2_tunnel_conf entry;
11778 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11781 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11782 entry.vf_id = res->vf_id;
11784 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11786 ETH_L2_TUNNEL_INSERTION_MASK,
11790 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11791 .f = cmd_config_e_tag_insertion_en_parsed,
11793 .help_str = "E-tag ... : E-tag insertion enable",
11795 (void *)&cmd_config_e_tag_e_tag,
11796 (void *)&cmd_config_e_tag_set,
11797 (void *)&cmd_config_e_tag_insertion,
11798 (void *)&cmd_config_e_tag_on,
11799 (void *)&cmd_config_e_tag_port_tag_id,
11800 (void *)&cmd_config_e_tag_port_tag_id_val,
11801 (void *)&cmd_config_e_tag_port,
11802 (void *)&cmd_config_e_tag_port_id,
11803 (void *)&cmd_config_e_tag_vf,
11804 (void *)&cmd_config_e_tag_vf_id,
11809 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11810 .f = cmd_config_e_tag_insertion_dis_parsed,
11812 .help_str = "E-tag ... : E-tag insertion disable",
11814 (void *)&cmd_config_e_tag_e_tag,
11815 (void *)&cmd_config_e_tag_set,
11816 (void *)&cmd_config_e_tag_insertion,
11817 (void *)&cmd_config_e_tag_off,
11818 (void *)&cmd_config_e_tag_port,
11819 (void *)&cmd_config_e_tag_port_id,
11820 (void *)&cmd_config_e_tag_vf,
11821 (void *)&cmd_config_e_tag_vf_id,
11826 /* E-tag stripping configuration */
11828 cmd_config_e_tag_stripping_parsed(
11829 void *parsed_result,
11830 __attribute__((unused)) struct cmdline *cl,
11831 __attribute__((unused)) void *data)
11833 struct cmd_config_e_tag_result *res =
11835 struct rte_eth_l2_tunnel_conf entry;
11837 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11840 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11842 if (!strcmp(res->on_off, "on"))
11843 rte_eth_dev_l2_tunnel_offload_set
11846 ETH_L2_TUNNEL_STRIPPING_MASK,
11849 rte_eth_dev_l2_tunnel_offload_set
11852 ETH_L2_TUNNEL_STRIPPING_MASK,
11856 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11857 .f = cmd_config_e_tag_stripping_parsed,
11859 .help_str = "E-tag ... : E-tag stripping enable/disable",
11861 (void *)&cmd_config_e_tag_e_tag,
11862 (void *)&cmd_config_e_tag_set,
11863 (void *)&cmd_config_e_tag_stripping,
11864 (void *)&cmd_config_e_tag_on_off,
11865 (void *)&cmd_config_e_tag_port,
11866 (void *)&cmd_config_e_tag_port_id,
11871 /* E-tag forwarding configuration */
11873 cmd_config_e_tag_forwarding_parsed(
11874 void *parsed_result,
11875 __attribute__((unused)) struct cmdline *cl,
11876 __attribute__((unused)) void *data)
11878 struct cmd_config_e_tag_result *res = parsed_result;
11879 struct rte_eth_l2_tunnel_conf entry;
11881 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11884 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11886 if (!strcmp(res->on_off, "on"))
11887 rte_eth_dev_l2_tunnel_offload_set
11890 ETH_L2_TUNNEL_FORWARDING_MASK,
11893 rte_eth_dev_l2_tunnel_offload_set
11896 ETH_L2_TUNNEL_FORWARDING_MASK,
11900 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11901 .f = cmd_config_e_tag_forwarding_parsed,
11903 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11905 (void *)&cmd_config_e_tag_e_tag,
11906 (void *)&cmd_config_e_tag_set,
11907 (void *)&cmd_config_e_tag_forwarding,
11908 (void *)&cmd_config_e_tag_on_off,
11909 (void *)&cmd_config_e_tag_port,
11910 (void *)&cmd_config_e_tag_port_id,
11915 /* E-tag filter configuration */
11917 cmd_config_e_tag_filter_add_parsed(
11918 void *parsed_result,
11919 __attribute__((unused)) struct cmdline *cl,
11920 __attribute__((unused)) void *data)
11922 struct cmd_config_e_tag_result *res = parsed_result;
11923 struct rte_eth_l2_tunnel_conf entry;
11926 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11929 if (res->e_tag_id_val > 0x3fff) {
11930 printf("e-tag-id must be equal or less than 0x3fff.\n");
11934 ret = rte_eth_dev_filter_supported(res->port_id,
11935 RTE_ETH_FILTER_L2_TUNNEL);
11937 printf("E-tag filter is not supported on port %u.\n",
11942 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11943 entry.tunnel_id = res->e_tag_id_val;
11944 entry.pool = res->dst_pool_val;
11946 ret = rte_eth_dev_filter_ctrl(res->port_id,
11947 RTE_ETH_FILTER_L2_TUNNEL,
11948 RTE_ETH_FILTER_ADD,
11951 printf("E-tag filter programming error: (%s)\n",
11955 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
11956 .f = cmd_config_e_tag_filter_add_parsed,
11958 .help_str = "E-tag ... : E-tag filter add",
11960 (void *)&cmd_config_e_tag_e_tag,
11961 (void *)&cmd_config_e_tag_set,
11962 (void *)&cmd_config_e_tag_filter,
11963 (void *)&cmd_config_e_tag_add,
11964 (void *)&cmd_config_e_tag_e_tag_id,
11965 (void *)&cmd_config_e_tag_e_tag_id_val,
11966 (void *)&cmd_config_e_tag_dst_pool,
11967 (void *)&cmd_config_e_tag_dst_pool_val,
11968 (void *)&cmd_config_e_tag_port,
11969 (void *)&cmd_config_e_tag_port_id,
11975 cmd_config_e_tag_filter_del_parsed(
11976 void *parsed_result,
11977 __attribute__((unused)) struct cmdline *cl,
11978 __attribute__((unused)) void *data)
11980 struct cmd_config_e_tag_result *res = parsed_result;
11981 struct rte_eth_l2_tunnel_conf entry;
11984 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11987 if (res->e_tag_id_val > 0x3fff) {
11988 printf("e-tag-id must be less than 0x3fff.\n");
11992 ret = rte_eth_dev_filter_supported(res->port_id,
11993 RTE_ETH_FILTER_L2_TUNNEL);
11995 printf("E-tag filter is not supported on port %u.\n",
12000 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12001 entry.tunnel_id = res->e_tag_id_val;
12003 ret = rte_eth_dev_filter_ctrl(res->port_id,
12004 RTE_ETH_FILTER_L2_TUNNEL,
12005 RTE_ETH_FILTER_DELETE,
12008 printf("E-tag filter programming error: (%s)\n",
12012 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12013 .f = cmd_config_e_tag_filter_del_parsed,
12015 .help_str = "E-tag ... : E-tag filter delete",
12017 (void *)&cmd_config_e_tag_e_tag,
12018 (void *)&cmd_config_e_tag_set,
12019 (void *)&cmd_config_e_tag_filter,
12020 (void *)&cmd_config_e_tag_del,
12021 (void *)&cmd_config_e_tag_e_tag_id,
12022 (void *)&cmd_config_e_tag_e_tag_id_val,
12023 (void *)&cmd_config_e_tag_port,
12024 (void *)&cmd_config_e_tag_port_id,
12029 /* vf vlan anti spoof configuration */
12031 /* Common result structure for vf vlan anti spoof */
12032 struct cmd_vf_vlan_anti_spoof_result {
12033 cmdline_fixed_string_t set;
12034 cmdline_fixed_string_t vf;
12035 cmdline_fixed_string_t vlan;
12036 cmdline_fixed_string_t antispoof;
12039 cmdline_fixed_string_t on_off;
12042 /* Common CLI fields for vf vlan anti spoof enable disable */
12043 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12044 TOKEN_STRING_INITIALIZER
12045 (struct cmd_vf_vlan_anti_spoof_result,
12047 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12048 TOKEN_STRING_INITIALIZER
12049 (struct cmd_vf_vlan_anti_spoof_result,
12051 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12052 TOKEN_STRING_INITIALIZER
12053 (struct cmd_vf_vlan_anti_spoof_result,
12055 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12056 TOKEN_STRING_INITIALIZER
12057 (struct cmd_vf_vlan_anti_spoof_result,
12058 antispoof, "antispoof");
12059 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12060 TOKEN_NUM_INITIALIZER
12061 (struct cmd_vf_vlan_anti_spoof_result,
12063 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12064 TOKEN_NUM_INITIALIZER
12065 (struct cmd_vf_vlan_anti_spoof_result,
12067 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12068 TOKEN_STRING_INITIALIZER
12069 (struct cmd_vf_vlan_anti_spoof_result,
12073 cmd_set_vf_vlan_anti_spoof_parsed(
12074 void *parsed_result,
12075 __attribute__((unused)) struct cmdline *cl,
12076 __attribute__((unused)) void *data)
12078 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12079 int ret = -ENOTSUP;
12081 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12083 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12086 #ifdef RTE_LIBRTE_IXGBE_PMD
12087 if (ret == -ENOTSUP)
12088 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12089 res->vf_id, is_on);
12091 #ifdef RTE_LIBRTE_I40E_PMD
12092 if (ret == -ENOTSUP)
12093 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12094 res->vf_id, is_on);
12096 #ifdef RTE_LIBRTE_BNXT_PMD
12097 if (ret == -ENOTSUP)
12098 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12099 res->vf_id, is_on);
12106 printf("invalid vf_id %d\n", res->vf_id);
12109 printf("invalid port_id %d\n", res->port_id);
12112 printf("function not implemented\n");
12115 printf("programming error: (%s)\n", strerror(-ret));
12119 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12120 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12122 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12124 (void *)&cmd_vf_vlan_anti_spoof_set,
12125 (void *)&cmd_vf_vlan_anti_spoof_vf,
12126 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12127 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12128 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12129 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12130 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12135 /* vf mac anti spoof configuration */
12137 /* Common result structure for vf mac anti spoof */
12138 struct cmd_vf_mac_anti_spoof_result {
12139 cmdline_fixed_string_t set;
12140 cmdline_fixed_string_t vf;
12141 cmdline_fixed_string_t mac;
12142 cmdline_fixed_string_t antispoof;
12145 cmdline_fixed_string_t on_off;
12148 /* Common CLI fields for vf mac anti spoof enable disable */
12149 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12150 TOKEN_STRING_INITIALIZER
12151 (struct cmd_vf_mac_anti_spoof_result,
12153 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12154 TOKEN_STRING_INITIALIZER
12155 (struct cmd_vf_mac_anti_spoof_result,
12157 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12158 TOKEN_STRING_INITIALIZER
12159 (struct cmd_vf_mac_anti_spoof_result,
12161 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12162 TOKEN_STRING_INITIALIZER
12163 (struct cmd_vf_mac_anti_spoof_result,
12164 antispoof, "antispoof");
12165 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12166 TOKEN_NUM_INITIALIZER
12167 (struct cmd_vf_mac_anti_spoof_result,
12169 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12170 TOKEN_NUM_INITIALIZER
12171 (struct cmd_vf_mac_anti_spoof_result,
12173 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12174 TOKEN_STRING_INITIALIZER
12175 (struct cmd_vf_mac_anti_spoof_result,
12179 cmd_set_vf_mac_anti_spoof_parsed(
12180 void *parsed_result,
12181 __attribute__((unused)) struct cmdline *cl,
12182 __attribute__((unused)) void *data)
12184 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12185 int ret = -ENOTSUP;
12187 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12189 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12192 #ifdef RTE_LIBRTE_IXGBE_PMD
12193 if (ret == -ENOTSUP)
12194 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12195 res->vf_id, is_on);
12197 #ifdef RTE_LIBRTE_I40E_PMD
12198 if (ret == -ENOTSUP)
12199 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12200 res->vf_id, is_on);
12202 #ifdef RTE_LIBRTE_BNXT_PMD
12203 if (ret == -ENOTSUP)
12204 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12205 res->vf_id, is_on);
12212 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12215 printf("invalid port_id %d\n", res->port_id);
12218 printf("function not implemented\n");
12221 printf("programming error: (%s)\n", strerror(-ret));
12225 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12226 .f = cmd_set_vf_mac_anti_spoof_parsed,
12228 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12230 (void *)&cmd_vf_mac_anti_spoof_set,
12231 (void *)&cmd_vf_mac_anti_spoof_vf,
12232 (void *)&cmd_vf_mac_anti_spoof_mac,
12233 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12234 (void *)&cmd_vf_mac_anti_spoof_port_id,
12235 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12236 (void *)&cmd_vf_mac_anti_spoof_on_off,
12241 /* vf vlan strip queue configuration */
12243 /* Common result structure for vf mac anti spoof */
12244 struct cmd_vf_vlan_stripq_result {
12245 cmdline_fixed_string_t set;
12246 cmdline_fixed_string_t vf;
12247 cmdline_fixed_string_t vlan;
12248 cmdline_fixed_string_t stripq;
12251 cmdline_fixed_string_t on_off;
12254 /* Common CLI fields for vf vlan strip enable disable */
12255 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12256 TOKEN_STRING_INITIALIZER
12257 (struct cmd_vf_vlan_stripq_result,
12259 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12260 TOKEN_STRING_INITIALIZER
12261 (struct cmd_vf_vlan_stripq_result,
12263 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12264 TOKEN_STRING_INITIALIZER
12265 (struct cmd_vf_vlan_stripq_result,
12267 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12268 TOKEN_STRING_INITIALIZER
12269 (struct cmd_vf_vlan_stripq_result,
12271 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12272 TOKEN_NUM_INITIALIZER
12273 (struct cmd_vf_vlan_stripq_result,
12275 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12276 TOKEN_NUM_INITIALIZER
12277 (struct cmd_vf_vlan_stripq_result,
12279 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12280 TOKEN_STRING_INITIALIZER
12281 (struct cmd_vf_vlan_stripq_result,
12285 cmd_set_vf_vlan_stripq_parsed(
12286 void *parsed_result,
12287 __attribute__((unused)) struct cmdline *cl,
12288 __attribute__((unused)) void *data)
12290 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12291 int ret = -ENOTSUP;
12293 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12295 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12298 #ifdef RTE_LIBRTE_IXGBE_PMD
12299 if (ret == -ENOTSUP)
12300 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12301 res->vf_id, is_on);
12303 #ifdef RTE_LIBRTE_I40E_PMD
12304 if (ret == -ENOTSUP)
12305 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12306 res->vf_id, is_on);
12308 #ifdef RTE_LIBRTE_BNXT_PMD
12309 if (ret == -ENOTSUP)
12310 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12311 res->vf_id, is_on);
12318 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12321 printf("invalid port_id %d\n", res->port_id);
12324 printf("function not implemented\n");
12327 printf("programming error: (%s)\n", strerror(-ret));
12331 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12332 .f = cmd_set_vf_vlan_stripq_parsed,
12334 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12336 (void *)&cmd_vf_vlan_stripq_set,
12337 (void *)&cmd_vf_vlan_stripq_vf,
12338 (void *)&cmd_vf_vlan_stripq_vlan,
12339 (void *)&cmd_vf_vlan_stripq_stripq,
12340 (void *)&cmd_vf_vlan_stripq_port_id,
12341 (void *)&cmd_vf_vlan_stripq_vf_id,
12342 (void *)&cmd_vf_vlan_stripq_on_off,
12347 /* vf vlan insert configuration */
12349 /* Common result structure for vf vlan insert */
12350 struct cmd_vf_vlan_insert_result {
12351 cmdline_fixed_string_t set;
12352 cmdline_fixed_string_t vf;
12353 cmdline_fixed_string_t vlan;
12354 cmdline_fixed_string_t insert;
12360 /* Common CLI fields for vf vlan insert enable disable */
12361 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12362 TOKEN_STRING_INITIALIZER
12363 (struct cmd_vf_vlan_insert_result,
12365 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12366 TOKEN_STRING_INITIALIZER
12367 (struct cmd_vf_vlan_insert_result,
12369 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12370 TOKEN_STRING_INITIALIZER
12371 (struct cmd_vf_vlan_insert_result,
12373 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12374 TOKEN_STRING_INITIALIZER
12375 (struct cmd_vf_vlan_insert_result,
12377 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12378 TOKEN_NUM_INITIALIZER
12379 (struct cmd_vf_vlan_insert_result,
12381 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12382 TOKEN_NUM_INITIALIZER
12383 (struct cmd_vf_vlan_insert_result,
12385 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12386 TOKEN_NUM_INITIALIZER
12387 (struct cmd_vf_vlan_insert_result,
12391 cmd_set_vf_vlan_insert_parsed(
12392 void *parsed_result,
12393 __attribute__((unused)) struct cmdline *cl,
12394 __attribute__((unused)) void *data)
12396 struct cmd_vf_vlan_insert_result *res = parsed_result;
12397 int ret = -ENOTSUP;
12399 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12402 #ifdef RTE_LIBRTE_IXGBE_PMD
12403 if (ret == -ENOTSUP)
12404 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12407 #ifdef RTE_LIBRTE_I40E_PMD
12408 if (ret == -ENOTSUP)
12409 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12412 #ifdef RTE_LIBRTE_BNXT_PMD
12413 if (ret == -ENOTSUP)
12414 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12422 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12425 printf("invalid port_id %d\n", res->port_id);
12428 printf("function not implemented\n");
12431 printf("programming error: (%s)\n", strerror(-ret));
12435 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12436 .f = cmd_set_vf_vlan_insert_parsed,
12438 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12440 (void *)&cmd_vf_vlan_insert_set,
12441 (void *)&cmd_vf_vlan_insert_vf,
12442 (void *)&cmd_vf_vlan_insert_vlan,
12443 (void *)&cmd_vf_vlan_insert_insert,
12444 (void *)&cmd_vf_vlan_insert_port_id,
12445 (void *)&cmd_vf_vlan_insert_vf_id,
12446 (void *)&cmd_vf_vlan_insert_vlan_id,
12451 /* tx loopback configuration */
12453 /* Common result structure for tx loopback */
12454 struct cmd_tx_loopback_result {
12455 cmdline_fixed_string_t set;
12456 cmdline_fixed_string_t tx;
12457 cmdline_fixed_string_t loopback;
12459 cmdline_fixed_string_t on_off;
12462 /* Common CLI fields for tx loopback enable disable */
12463 cmdline_parse_token_string_t cmd_tx_loopback_set =
12464 TOKEN_STRING_INITIALIZER
12465 (struct cmd_tx_loopback_result,
12467 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12468 TOKEN_STRING_INITIALIZER
12469 (struct cmd_tx_loopback_result,
12471 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12472 TOKEN_STRING_INITIALIZER
12473 (struct cmd_tx_loopback_result,
12474 loopback, "loopback");
12475 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12476 TOKEN_NUM_INITIALIZER
12477 (struct cmd_tx_loopback_result,
12479 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12480 TOKEN_STRING_INITIALIZER
12481 (struct cmd_tx_loopback_result,
12485 cmd_set_tx_loopback_parsed(
12486 void *parsed_result,
12487 __attribute__((unused)) struct cmdline *cl,
12488 __attribute__((unused)) void *data)
12490 struct cmd_tx_loopback_result *res = parsed_result;
12491 int ret = -ENOTSUP;
12493 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12495 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12498 #ifdef RTE_LIBRTE_IXGBE_PMD
12499 if (ret == -ENOTSUP)
12500 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12502 #ifdef RTE_LIBRTE_I40E_PMD
12503 if (ret == -ENOTSUP)
12504 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12506 #ifdef RTE_LIBRTE_BNXT_PMD
12507 if (ret == -ENOTSUP)
12508 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12515 printf("invalid is_on %d\n", is_on);
12518 printf("invalid port_id %d\n", res->port_id);
12521 printf("function not implemented\n");
12524 printf("programming error: (%s)\n", strerror(-ret));
12528 cmdline_parse_inst_t cmd_set_tx_loopback = {
12529 .f = cmd_set_tx_loopback_parsed,
12531 .help_str = "set tx loopback <port_id> on|off",
12533 (void *)&cmd_tx_loopback_set,
12534 (void *)&cmd_tx_loopback_tx,
12535 (void *)&cmd_tx_loopback_loopback,
12536 (void *)&cmd_tx_loopback_port_id,
12537 (void *)&cmd_tx_loopback_on_off,
12542 /* all queues drop enable configuration */
12544 /* Common result structure for all queues drop enable */
12545 struct cmd_all_queues_drop_en_result {
12546 cmdline_fixed_string_t set;
12547 cmdline_fixed_string_t all;
12548 cmdline_fixed_string_t queues;
12549 cmdline_fixed_string_t drop;
12551 cmdline_fixed_string_t on_off;
12554 /* Common CLI fields for tx loopback enable disable */
12555 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12556 TOKEN_STRING_INITIALIZER
12557 (struct cmd_all_queues_drop_en_result,
12559 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12560 TOKEN_STRING_INITIALIZER
12561 (struct cmd_all_queues_drop_en_result,
12563 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12564 TOKEN_STRING_INITIALIZER
12565 (struct cmd_all_queues_drop_en_result,
12567 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12568 TOKEN_STRING_INITIALIZER
12569 (struct cmd_all_queues_drop_en_result,
12571 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12572 TOKEN_NUM_INITIALIZER
12573 (struct cmd_all_queues_drop_en_result,
12575 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12576 TOKEN_STRING_INITIALIZER
12577 (struct cmd_all_queues_drop_en_result,
12581 cmd_set_all_queues_drop_en_parsed(
12582 void *parsed_result,
12583 __attribute__((unused)) struct cmdline *cl,
12584 __attribute__((unused)) void *data)
12586 struct cmd_all_queues_drop_en_result *res = parsed_result;
12587 int ret = -ENOTSUP;
12588 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12590 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12593 #ifdef RTE_LIBRTE_IXGBE_PMD
12594 if (ret == -ENOTSUP)
12595 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12597 #ifdef RTE_LIBRTE_BNXT_PMD
12598 if (ret == -ENOTSUP)
12599 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12605 printf("invalid is_on %d\n", is_on);
12608 printf("invalid port_id %d\n", res->port_id);
12611 printf("function not implemented\n");
12614 printf("programming error: (%s)\n", strerror(-ret));
12618 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12619 .f = cmd_set_all_queues_drop_en_parsed,
12621 .help_str = "set all queues drop <port_id> on|off",
12623 (void *)&cmd_all_queues_drop_en_set,
12624 (void *)&cmd_all_queues_drop_en_all,
12625 (void *)&cmd_all_queues_drop_en_queues,
12626 (void *)&cmd_all_queues_drop_en_drop,
12627 (void *)&cmd_all_queues_drop_en_port_id,
12628 (void *)&cmd_all_queues_drop_en_on_off,
12633 /* vf split drop enable configuration */
12635 /* Common result structure for vf split drop enable */
12636 struct cmd_vf_split_drop_en_result {
12637 cmdline_fixed_string_t set;
12638 cmdline_fixed_string_t vf;
12639 cmdline_fixed_string_t split;
12640 cmdline_fixed_string_t drop;
12643 cmdline_fixed_string_t on_off;
12646 /* Common CLI fields for vf split drop enable disable */
12647 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12648 TOKEN_STRING_INITIALIZER
12649 (struct cmd_vf_split_drop_en_result,
12651 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12652 TOKEN_STRING_INITIALIZER
12653 (struct cmd_vf_split_drop_en_result,
12655 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12656 TOKEN_STRING_INITIALIZER
12657 (struct cmd_vf_split_drop_en_result,
12659 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12660 TOKEN_STRING_INITIALIZER
12661 (struct cmd_vf_split_drop_en_result,
12663 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12664 TOKEN_NUM_INITIALIZER
12665 (struct cmd_vf_split_drop_en_result,
12667 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12668 TOKEN_NUM_INITIALIZER
12669 (struct cmd_vf_split_drop_en_result,
12671 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12672 TOKEN_STRING_INITIALIZER
12673 (struct cmd_vf_split_drop_en_result,
12677 cmd_set_vf_split_drop_en_parsed(
12678 void *parsed_result,
12679 __attribute__((unused)) struct cmdline *cl,
12680 __attribute__((unused)) void *data)
12682 struct cmd_vf_split_drop_en_result *res = parsed_result;
12683 int ret = -ENOTSUP;
12684 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12686 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12689 #ifdef RTE_LIBRTE_IXGBE_PMD
12690 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12697 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12700 printf("invalid port_id %d\n", res->port_id);
12703 printf("not supported on port %d\n", res->port_id);
12706 printf("programming error: (%s)\n", strerror(-ret));
12710 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12711 .f = cmd_set_vf_split_drop_en_parsed,
12713 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12715 (void *)&cmd_vf_split_drop_en_set,
12716 (void *)&cmd_vf_split_drop_en_vf,
12717 (void *)&cmd_vf_split_drop_en_split,
12718 (void *)&cmd_vf_split_drop_en_drop,
12719 (void *)&cmd_vf_split_drop_en_port_id,
12720 (void *)&cmd_vf_split_drop_en_vf_id,
12721 (void *)&cmd_vf_split_drop_en_on_off,
12726 /* vf mac address configuration */
12728 /* Common result structure for vf mac address */
12729 struct cmd_set_vf_mac_addr_result {
12730 cmdline_fixed_string_t set;
12731 cmdline_fixed_string_t vf;
12732 cmdline_fixed_string_t mac;
12733 cmdline_fixed_string_t addr;
12736 struct ether_addr mac_addr;
12740 /* Common CLI fields for vf split drop enable disable */
12741 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12742 TOKEN_STRING_INITIALIZER
12743 (struct cmd_set_vf_mac_addr_result,
12745 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12746 TOKEN_STRING_INITIALIZER
12747 (struct cmd_set_vf_mac_addr_result,
12749 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12750 TOKEN_STRING_INITIALIZER
12751 (struct cmd_set_vf_mac_addr_result,
12753 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12754 TOKEN_STRING_INITIALIZER
12755 (struct cmd_set_vf_mac_addr_result,
12757 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12758 TOKEN_NUM_INITIALIZER
12759 (struct cmd_set_vf_mac_addr_result,
12761 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12762 TOKEN_NUM_INITIALIZER
12763 (struct cmd_set_vf_mac_addr_result,
12765 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12766 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12770 cmd_set_vf_mac_addr_parsed(
12771 void *parsed_result,
12772 __attribute__((unused)) struct cmdline *cl,
12773 __attribute__((unused)) void *data)
12775 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12776 int ret = -ENOTSUP;
12778 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12781 #ifdef RTE_LIBRTE_IXGBE_PMD
12782 if (ret == -ENOTSUP)
12783 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12786 #ifdef RTE_LIBRTE_I40E_PMD
12787 if (ret == -ENOTSUP)
12788 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12791 #ifdef RTE_LIBRTE_BNXT_PMD
12792 if (ret == -ENOTSUP)
12793 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12801 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12804 printf("invalid port_id %d\n", res->port_id);
12807 printf("function not implemented\n");
12810 printf("programming error: (%s)\n", strerror(-ret));
12814 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12815 .f = cmd_set_vf_mac_addr_parsed,
12817 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12819 (void *)&cmd_set_vf_mac_addr_set,
12820 (void *)&cmd_set_vf_mac_addr_vf,
12821 (void *)&cmd_set_vf_mac_addr_mac,
12822 (void *)&cmd_set_vf_mac_addr_addr,
12823 (void *)&cmd_set_vf_mac_addr_port_id,
12824 (void *)&cmd_set_vf_mac_addr_vf_id,
12825 (void *)&cmd_set_vf_mac_addr_mac_addr,
12830 /* MACsec configuration */
12832 /* Common result structure for MACsec offload enable */
12833 struct cmd_macsec_offload_on_result {
12834 cmdline_fixed_string_t set;
12835 cmdline_fixed_string_t macsec;
12836 cmdline_fixed_string_t offload;
12838 cmdline_fixed_string_t on;
12839 cmdline_fixed_string_t encrypt;
12840 cmdline_fixed_string_t en_on_off;
12841 cmdline_fixed_string_t replay_protect;
12842 cmdline_fixed_string_t rp_on_off;
12845 /* Common CLI fields for MACsec offload disable */
12846 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12847 TOKEN_STRING_INITIALIZER
12848 (struct cmd_macsec_offload_on_result,
12850 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12851 TOKEN_STRING_INITIALIZER
12852 (struct cmd_macsec_offload_on_result,
12854 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12855 TOKEN_STRING_INITIALIZER
12856 (struct cmd_macsec_offload_on_result,
12857 offload, "offload");
12858 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12859 TOKEN_NUM_INITIALIZER
12860 (struct cmd_macsec_offload_on_result,
12862 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12863 TOKEN_STRING_INITIALIZER
12864 (struct cmd_macsec_offload_on_result,
12866 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12867 TOKEN_STRING_INITIALIZER
12868 (struct cmd_macsec_offload_on_result,
12869 encrypt, "encrypt");
12870 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12871 TOKEN_STRING_INITIALIZER
12872 (struct cmd_macsec_offload_on_result,
12873 en_on_off, "on#off");
12874 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12875 TOKEN_STRING_INITIALIZER
12876 (struct cmd_macsec_offload_on_result,
12877 replay_protect, "replay-protect");
12878 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12879 TOKEN_STRING_INITIALIZER
12880 (struct cmd_macsec_offload_on_result,
12881 rp_on_off, "on#off");
12884 cmd_set_macsec_offload_on_parsed(
12885 void *parsed_result,
12886 __attribute__((unused)) struct cmdline *cl,
12887 __attribute__((unused)) void *data)
12889 struct cmd_macsec_offload_on_result *res = parsed_result;
12890 int ret = -ENOTSUP;
12891 portid_t port_id = res->port_id;
12892 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12893 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12895 if (port_id_is_invalid(port_id, ENABLED_WARN))
12898 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
12899 #ifdef RTE_LIBRTE_IXGBE_PMD
12900 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12909 printf("invalid port_id %d\n", port_id);
12912 printf("not supported on port %d\n", port_id);
12915 printf("programming error: (%s)\n", strerror(-ret));
12919 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12920 .f = cmd_set_macsec_offload_on_parsed,
12922 .help_str = "set macsec offload <port_id> on "
12923 "encrypt on|off replay-protect on|off",
12925 (void *)&cmd_macsec_offload_on_set,
12926 (void *)&cmd_macsec_offload_on_macsec,
12927 (void *)&cmd_macsec_offload_on_offload,
12928 (void *)&cmd_macsec_offload_on_port_id,
12929 (void *)&cmd_macsec_offload_on_on,
12930 (void *)&cmd_macsec_offload_on_encrypt,
12931 (void *)&cmd_macsec_offload_on_en_on_off,
12932 (void *)&cmd_macsec_offload_on_replay_protect,
12933 (void *)&cmd_macsec_offload_on_rp_on_off,
12938 /* Common result structure for MACsec offload disable */
12939 struct cmd_macsec_offload_off_result {
12940 cmdline_fixed_string_t set;
12941 cmdline_fixed_string_t macsec;
12942 cmdline_fixed_string_t offload;
12944 cmdline_fixed_string_t off;
12947 /* Common CLI fields for MACsec offload disable */
12948 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12949 TOKEN_STRING_INITIALIZER
12950 (struct cmd_macsec_offload_off_result,
12952 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12953 TOKEN_STRING_INITIALIZER
12954 (struct cmd_macsec_offload_off_result,
12956 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12957 TOKEN_STRING_INITIALIZER
12958 (struct cmd_macsec_offload_off_result,
12959 offload, "offload");
12960 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12961 TOKEN_NUM_INITIALIZER
12962 (struct cmd_macsec_offload_off_result,
12964 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12965 TOKEN_STRING_INITIALIZER
12966 (struct cmd_macsec_offload_off_result,
12970 cmd_set_macsec_offload_off_parsed(
12971 void *parsed_result,
12972 __attribute__((unused)) struct cmdline *cl,
12973 __attribute__((unused)) void *data)
12975 struct cmd_macsec_offload_off_result *res = parsed_result;
12976 int ret = -ENOTSUP;
12977 portid_t port_id = res->port_id;
12979 if (port_id_is_invalid(port_id, ENABLED_WARN))
12982 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
12983 #ifdef RTE_LIBRTE_IXGBE_PMD
12984 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12991 printf("invalid port_id %d\n", port_id);
12994 printf("not supported on port %d\n", port_id);
12997 printf("programming error: (%s)\n", strerror(-ret));
13001 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13002 .f = cmd_set_macsec_offload_off_parsed,
13004 .help_str = "set macsec offload <port_id> off",
13006 (void *)&cmd_macsec_offload_off_set,
13007 (void *)&cmd_macsec_offload_off_macsec,
13008 (void *)&cmd_macsec_offload_off_offload,
13009 (void *)&cmd_macsec_offload_off_port_id,
13010 (void *)&cmd_macsec_offload_off_off,
13015 /* Common result structure for MACsec secure connection configure */
13016 struct cmd_macsec_sc_result {
13017 cmdline_fixed_string_t set;
13018 cmdline_fixed_string_t macsec;
13019 cmdline_fixed_string_t sc;
13020 cmdline_fixed_string_t tx_rx;
13022 struct ether_addr mac;
13026 /* Common CLI fields for MACsec secure connection configure */
13027 cmdline_parse_token_string_t cmd_macsec_sc_set =
13028 TOKEN_STRING_INITIALIZER
13029 (struct cmd_macsec_sc_result,
13031 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13032 TOKEN_STRING_INITIALIZER
13033 (struct cmd_macsec_sc_result,
13035 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13036 TOKEN_STRING_INITIALIZER
13037 (struct cmd_macsec_sc_result,
13039 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13040 TOKEN_STRING_INITIALIZER
13041 (struct cmd_macsec_sc_result,
13043 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13044 TOKEN_NUM_INITIALIZER
13045 (struct cmd_macsec_sc_result,
13047 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13048 TOKEN_ETHERADDR_INITIALIZER
13049 (struct cmd_macsec_sc_result,
13051 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13052 TOKEN_NUM_INITIALIZER
13053 (struct cmd_macsec_sc_result,
13057 cmd_set_macsec_sc_parsed(
13058 void *parsed_result,
13059 __attribute__((unused)) struct cmdline *cl,
13060 __attribute__((unused)) void *data)
13062 struct cmd_macsec_sc_result *res = parsed_result;
13063 int ret = -ENOTSUP;
13064 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13066 #ifdef RTE_LIBRTE_IXGBE_PMD
13068 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13069 res->mac.addr_bytes) :
13070 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13071 res->mac.addr_bytes, res->pi);
13073 RTE_SET_USED(is_tx);
13079 printf("invalid port_id %d\n", res->port_id);
13082 printf("not supported on port %d\n", res->port_id);
13085 printf("programming error: (%s)\n", strerror(-ret));
13089 cmdline_parse_inst_t cmd_set_macsec_sc = {
13090 .f = cmd_set_macsec_sc_parsed,
13092 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13094 (void *)&cmd_macsec_sc_set,
13095 (void *)&cmd_macsec_sc_macsec,
13096 (void *)&cmd_macsec_sc_sc,
13097 (void *)&cmd_macsec_sc_tx_rx,
13098 (void *)&cmd_macsec_sc_port_id,
13099 (void *)&cmd_macsec_sc_mac,
13100 (void *)&cmd_macsec_sc_pi,
13105 /* Common result structure for MACsec secure connection configure */
13106 struct cmd_macsec_sa_result {
13107 cmdline_fixed_string_t set;
13108 cmdline_fixed_string_t macsec;
13109 cmdline_fixed_string_t sa;
13110 cmdline_fixed_string_t tx_rx;
13115 cmdline_fixed_string_t key;
13118 /* Common CLI fields for MACsec secure connection configure */
13119 cmdline_parse_token_string_t cmd_macsec_sa_set =
13120 TOKEN_STRING_INITIALIZER
13121 (struct cmd_macsec_sa_result,
13123 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13124 TOKEN_STRING_INITIALIZER
13125 (struct cmd_macsec_sa_result,
13127 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13128 TOKEN_STRING_INITIALIZER
13129 (struct cmd_macsec_sa_result,
13131 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13132 TOKEN_STRING_INITIALIZER
13133 (struct cmd_macsec_sa_result,
13135 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13136 TOKEN_NUM_INITIALIZER
13137 (struct cmd_macsec_sa_result,
13139 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13140 TOKEN_NUM_INITIALIZER
13141 (struct cmd_macsec_sa_result,
13143 cmdline_parse_token_num_t cmd_macsec_sa_an =
13144 TOKEN_NUM_INITIALIZER
13145 (struct cmd_macsec_sa_result,
13147 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13148 TOKEN_NUM_INITIALIZER
13149 (struct cmd_macsec_sa_result,
13151 cmdline_parse_token_string_t cmd_macsec_sa_key =
13152 TOKEN_STRING_INITIALIZER
13153 (struct cmd_macsec_sa_result,
13157 cmd_set_macsec_sa_parsed(
13158 void *parsed_result,
13159 __attribute__((unused)) struct cmdline *cl,
13160 __attribute__((unused)) void *data)
13162 struct cmd_macsec_sa_result *res = parsed_result;
13163 int ret = -ENOTSUP;
13164 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13165 uint8_t key[16] = { 0 };
13171 key_len = strlen(res->key) / 2;
13175 for (i = 0; i < key_len; i++) {
13176 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13179 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13182 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13185 #ifdef RTE_LIBRTE_IXGBE_PMD
13187 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13188 res->idx, res->an, res->pn, key) :
13189 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13190 res->idx, res->an, res->pn, key);
13192 RTE_SET_USED(is_tx);
13199 printf("invalid idx %d or an %d\n", res->idx, res->an);
13202 printf("invalid port_id %d\n", res->port_id);
13205 printf("not supported on port %d\n", res->port_id);
13208 printf("programming error: (%s)\n", strerror(-ret));
13212 cmdline_parse_inst_t cmd_set_macsec_sa = {
13213 .f = cmd_set_macsec_sa_parsed,
13215 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13217 (void *)&cmd_macsec_sa_set,
13218 (void *)&cmd_macsec_sa_macsec,
13219 (void *)&cmd_macsec_sa_sa,
13220 (void *)&cmd_macsec_sa_tx_rx,
13221 (void *)&cmd_macsec_sa_port_id,
13222 (void *)&cmd_macsec_sa_idx,
13223 (void *)&cmd_macsec_sa_an,
13224 (void *)&cmd_macsec_sa_pn,
13225 (void *)&cmd_macsec_sa_key,
13230 /* VF unicast promiscuous mode configuration */
13232 /* Common result structure for VF unicast promiscuous mode */
13233 struct cmd_vf_promisc_result {
13234 cmdline_fixed_string_t set;
13235 cmdline_fixed_string_t vf;
13236 cmdline_fixed_string_t promisc;
13239 cmdline_fixed_string_t on_off;
13242 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13243 cmdline_parse_token_string_t cmd_vf_promisc_set =
13244 TOKEN_STRING_INITIALIZER
13245 (struct cmd_vf_promisc_result,
13247 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13248 TOKEN_STRING_INITIALIZER
13249 (struct cmd_vf_promisc_result,
13251 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13252 TOKEN_STRING_INITIALIZER
13253 (struct cmd_vf_promisc_result,
13254 promisc, "promisc");
13255 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13256 TOKEN_NUM_INITIALIZER
13257 (struct cmd_vf_promisc_result,
13259 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13260 TOKEN_NUM_INITIALIZER
13261 (struct cmd_vf_promisc_result,
13263 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13264 TOKEN_STRING_INITIALIZER
13265 (struct cmd_vf_promisc_result,
13269 cmd_set_vf_promisc_parsed(
13270 void *parsed_result,
13271 __attribute__((unused)) struct cmdline *cl,
13272 __attribute__((unused)) void *data)
13274 struct cmd_vf_promisc_result *res = parsed_result;
13275 int ret = -ENOTSUP;
13277 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13279 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13282 #ifdef RTE_LIBRTE_I40E_PMD
13283 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13284 res->vf_id, is_on);
13291 printf("invalid vf_id %d\n", res->vf_id);
13294 printf("invalid port_id %d\n", res->port_id);
13297 printf("function not implemented\n");
13300 printf("programming error: (%s)\n", strerror(-ret));
13304 cmdline_parse_inst_t cmd_set_vf_promisc = {
13305 .f = cmd_set_vf_promisc_parsed,
13307 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13308 "Set unicast promiscuous mode for a VF from the PF",
13310 (void *)&cmd_vf_promisc_set,
13311 (void *)&cmd_vf_promisc_vf,
13312 (void *)&cmd_vf_promisc_promisc,
13313 (void *)&cmd_vf_promisc_port_id,
13314 (void *)&cmd_vf_promisc_vf_id,
13315 (void *)&cmd_vf_promisc_on_off,
13320 /* VF multicast promiscuous mode configuration */
13322 /* Common result structure for VF multicast promiscuous mode */
13323 struct cmd_vf_allmulti_result {
13324 cmdline_fixed_string_t set;
13325 cmdline_fixed_string_t vf;
13326 cmdline_fixed_string_t allmulti;
13329 cmdline_fixed_string_t on_off;
13332 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13333 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13334 TOKEN_STRING_INITIALIZER
13335 (struct cmd_vf_allmulti_result,
13337 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13338 TOKEN_STRING_INITIALIZER
13339 (struct cmd_vf_allmulti_result,
13341 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13342 TOKEN_STRING_INITIALIZER
13343 (struct cmd_vf_allmulti_result,
13344 allmulti, "allmulti");
13345 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13346 TOKEN_NUM_INITIALIZER
13347 (struct cmd_vf_allmulti_result,
13349 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13350 TOKEN_NUM_INITIALIZER
13351 (struct cmd_vf_allmulti_result,
13353 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13354 TOKEN_STRING_INITIALIZER
13355 (struct cmd_vf_allmulti_result,
13359 cmd_set_vf_allmulti_parsed(
13360 void *parsed_result,
13361 __attribute__((unused)) struct cmdline *cl,
13362 __attribute__((unused)) void *data)
13364 struct cmd_vf_allmulti_result *res = parsed_result;
13365 int ret = -ENOTSUP;
13367 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13369 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13372 #ifdef RTE_LIBRTE_I40E_PMD
13373 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13374 res->vf_id, is_on);
13381 printf("invalid vf_id %d\n", res->vf_id);
13384 printf("invalid port_id %d\n", res->port_id);
13387 printf("function not implemented\n");
13390 printf("programming error: (%s)\n", strerror(-ret));
13394 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13395 .f = cmd_set_vf_allmulti_parsed,
13397 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13398 "Set multicast promiscuous mode for a VF from the PF",
13400 (void *)&cmd_vf_allmulti_set,
13401 (void *)&cmd_vf_allmulti_vf,
13402 (void *)&cmd_vf_allmulti_allmulti,
13403 (void *)&cmd_vf_allmulti_port_id,
13404 (void *)&cmd_vf_allmulti_vf_id,
13405 (void *)&cmd_vf_allmulti_on_off,
13410 /* vf broadcast mode configuration */
13412 /* Common result structure for vf broadcast */
13413 struct cmd_set_vf_broadcast_result {
13414 cmdline_fixed_string_t set;
13415 cmdline_fixed_string_t vf;
13416 cmdline_fixed_string_t broadcast;
13419 cmdline_fixed_string_t on_off;
13422 /* Common CLI fields for vf broadcast enable disable */
13423 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13424 TOKEN_STRING_INITIALIZER
13425 (struct cmd_set_vf_broadcast_result,
13427 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13428 TOKEN_STRING_INITIALIZER
13429 (struct cmd_set_vf_broadcast_result,
13431 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13432 TOKEN_STRING_INITIALIZER
13433 (struct cmd_set_vf_broadcast_result,
13434 broadcast, "broadcast");
13435 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13436 TOKEN_NUM_INITIALIZER
13437 (struct cmd_set_vf_broadcast_result,
13439 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13440 TOKEN_NUM_INITIALIZER
13441 (struct cmd_set_vf_broadcast_result,
13443 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13444 TOKEN_STRING_INITIALIZER
13445 (struct cmd_set_vf_broadcast_result,
13449 cmd_set_vf_broadcast_parsed(
13450 void *parsed_result,
13451 __attribute__((unused)) struct cmdline *cl,
13452 __attribute__((unused)) void *data)
13454 struct cmd_set_vf_broadcast_result *res = parsed_result;
13455 int ret = -ENOTSUP;
13457 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13459 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13462 #ifdef RTE_LIBRTE_I40E_PMD
13463 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13464 res->vf_id, is_on);
13471 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13474 printf("invalid port_id %d\n", res->port_id);
13477 printf("function not implemented\n");
13480 printf("programming error: (%s)\n", strerror(-ret));
13484 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13485 .f = cmd_set_vf_broadcast_parsed,
13487 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13489 (void *)&cmd_set_vf_broadcast_set,
13490 (void *)&cmd_set_vf_broadcast_vf,
13491 (void *)&cmd_set_vf_broadcast_broadcast,
13492 (void *)&cmd_set_vf_broadcast_port_id,
13493 (void *)&cmd_set_vf_broadcast_vf_id,
13494 (void *)&cmd_set_vf_broadcast_on_off,
13499 /* vf vlan tag configuration */
13501 /* Common result structure for vf vlan tag */
13502 struct cmd_set_vf_vlan_tag_result {
13503 cmdline_fixed_string_t set;
13504 cmdline_fixed_string_t vf;
13505 cmdline_fixed_string_t vlan;
13506 cmdline_fixed_string_t tag;
13509 cmdline_fixed_string_t on_off;
13512 /* Common CLI fields for vf vlan tag enable disable */
13513 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13514 TOKEN_STRING_INITIALIZER
13515 (struct cmd_set_vf_vlan_tag_result,
13517 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13518 TOKEN_STRING_INITIALIZER
13519 (struct cmd_set_vf_vlan_tag_result,
13521 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13522 TOKEN_STRING_INITIALIZER
13523 (struct cmd_set_vf_vlan_tag_result,
13525 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13526 TOKEN_STRING_INITIALIZER
13527 (struct cmd_set_vf_vlan_tag_result,
13529 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13530 TOKEN_NUM_INITIALIZER
13531 (struct cmd_set_vf_vlan_tag_result,
13533 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13534 TOKEN_NUM_INITIALIZER
13535 (struct cmd_set_vf_vlan_tag_result,
13537 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13538 TOKEN_STRING_INITIALIZER
13539 (struct cmd_set_vf_vlan_tag_result,
13543 cmd_set_vf_vlan_tag_parsed(
13544 void *parsed_result,
13545 __attribute__((unused)) struct cmdline *cl,
13546 __attribute__((unused)) void *data)
13548 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13549 int ret = -ENOTSUP;
13551 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13553 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13556 #ifdef RTE_LIBRTE_I40E_PMD
13557 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13558 res->vf_id, is_on);
13565 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13568 printf("invalid port_id %d\n", res->port_id);
13571 printf("function not implemented\n");
13574 printf("programming error: (%s)\n", strerror(-ret));
13578 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13579 .f = cmd_set_vf_vlan_tag_parsed,
13581 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13583 (void *)&cmd_set_vf_vlan_tag_set,
13584 (void *)&cmd_set_vf_vlan_tag_vf,
13585 (void *)&cmd_set_vf_vlan_tag_vlan,
13586 (void *)&cmd_set_vf_vlan_tag_tag,
13587 (void *)&cmd_set_vf_vlan_tag_port_id,
13588 (void *)&cmd_set_vf_vlan_tag_vf_id,
13589 (void *)&cmd_set_vf_vlan_tag_on_off,
13594 /* Common definition of VF and TC TX bandwidth configuration */
13595 struct cmd_vf_tc_bw_result {
13596 cmdline_fixed_string_t set;
13597 cmdline_fixed_string_t vf;
13598 cmdline_fixed_string_t tc;
13599 cmdline_fixed_string_t tx;
13600 cmdline_fixed_string_t min_bw;
13601 cmdline_fixed_string_t max_bw;
13602 cmdline_fixed_string_t strict_link_prio;
13607 cmdline_fixed_string_t bw_list;
13611 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13612 TOKEN_STRING_INITIALIZER
13613 (struct cmd_vf_tc_bw_result,
13615 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13616 TOKEN_STRING_INITIALIZER
13617 (struct cmd_vf_tc_bw_result,
13619 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13620 TOKEN_STRING_INITIALIZER
13621 (struct cmd_vf_tc_bw_result,
13623 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13624 TOKEN_STRING_INITIALIZER
13625 (struct cmd_vf_tc_bw_result,
13627 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13628 TOKEN_STRING_INITIALIZER
13629 (struct cmd_vf_tc_bw_result,
13630 strict_link_prio, "strict-link-priority");
13631 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13632 TOKEN_STRING_INITIALIZER
13633 (struct cmd_vf_tc_bw_result,
13634 min_bw, "min-bandwidth");
13635 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13636 TOKEN_STRING_INITIALIZER
13637 (struct cmd_vf_tc_bw_result,
13638 max_bw, "max-bandwidth");
13639 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13640 TOKEN_NUM_INITIALIZER
13641 (struct cmd_vf_tc_bw_result,
13643 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13644 TOKEN_NUM_INITIALIZER
13645 (struct cmd_vf_tc_bw_result,
13647 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13648 TOKEN_NUM_INITIALIZER
13649 (struct cmd_vf_tc_bw_result,
13651 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13652 TOKEN_NUM_INITIALIZER
13653 (struct cmd_vf_tc_bw_result,
13655 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13656 TOKEN_STRING_INITIALIZER
13657 (struct cmd_vf_tc_bw_result,
13659 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13660 TOKEN_NUM_INITIALIZER
13661 (struct cmd_vf_tc_bw_result,
13664 /* VF max bandwidth setting */
13666 cmd_vf_max_bw_parsed(
13667 void *parsed_result,
13668 __attribute__((unused)) struct cmdline *cl,
13669 __attribute__((unused)) void *data)
13671 struct cmd_vf_tc_bw_result *res = parsed_result;
13672 int ret = -ENOTSUP;
13674 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13677 #ifdef RTE_LIBRTE_I40E_PMD
13678 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13679 res->vf_id, res->bw);
13686 printf("invalid vf_id %d or bandwidth %d\n",
13687 res->vf_id, res->bw);
13690 printf("invalid port_id %d\n", res->port_id);
13693 printf("function not implemented\n");
13696 printf("programming error: (%s)\n", strerror(-ret));
13700 cmdline_parse_inst_t cmd_vf_max_bw = {
13701 .f = cmd_vf_max_bw_parsed,
13703 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13705 (void *)&cmd_vf_tc_bw_set,
13706 (void *)&cmd_vf_tc_bw_vf,
13707 (void *)&cmd_vf_tc_bw_tx,
13708 (void *)&cmd_vf_tc_bw_max_bw,
13709 (void *)&cmd_vf_tc_bw_port_id,
13710 (void *)&cmd_vf_tc_bw_vf_id,
13711 (void *)&cmd_vf_tc_bw_bw,
13717 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13722 const char *p, *p0 = str;
13729 p = strchr(p0, '(');
13731 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13735 p0 = strchr(p, ')');
13737 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13741 if (size >= sizeof(s)) {
13742 printf("The string size exceeds the internal buffer size\n");
13745 snprintf(s, sizeof(s), "%.*s", size, p);
13746 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13748 printf("Failed to get the bandwidth list. ");
13752 for (i = 0; i < ret; i++)
13753 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13758 /* TC min bandwidth setting */
13760 cmd_vf_tc_min_bw_parsed(
13761 void *parsed_result,
13762 __attribute__((unused)) struct cmdline *cl,
13763 __attribute__((unused)) void *data)
13765 struct cmd_vf_tc_bw_result *res = parsed_result;
13768 int ret = -ENOTSUP;
13770 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13773 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13777 #ifdef RTE_LIBRTE_I40E_PMD
13778 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13786 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13789 printf("invalid port_id %d\n", res->port_id);
13792 printf("function not implemented\n");
13795 printf("programming error: (%s)\n", strerror(-ret));
13799 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13800 .f = cmd_vf_tc_min_bw_parsed,
13802 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13803 " <bw1, bw2, ...>",
13805 (void *)&cmd_vf_tc_bw_set,
13806 (void *)&cmd_vf_tc_bw_vf,
13807 (void *)&cmd_vf_tc_bw_tc,
13808 (void *)&cmd_vf_tc_bw_tx,
13809 (void *)&cmd_vf_tc_bw_min_bw,
13810 (void *)&cmd_vf_tc_bw_port_id,
13811 (void *)&cmd_vf_tc_bw_vf_id,
13812 (void *)&cmd_vf_tc_bw_bw_list,
13818 cmd_tc_min_bw_parsed(
13819 void *parsed_result,
13820 __attribute__((unused)) struct cmdline *cl,
13821 __attribute__((unused)) void *data)
13823 struct cmd_vf_tc_bw_result *res = parsed_result;
13824 struct rte_port *port;
13827 int ret = -ENOTSUP;
13829 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13832 port = &ports[res->port_id];
13833 /** Check if the port is not started **/
13834 if (port->port_status != RTE_PORT_STOPPED) {
13835 printf("Please stop port %d first\n", res->port_id);
13839 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13843 #ifdef RTE_LIBRTE_IXGBE_PMD
13844 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13851 printf("invalid bandwidth\n");
13854 printf("invalid port_id %d\n", res->port_id);
13857 printf("function not implemented\n");
13860 printf("programming error: (%s)\n", strerror(-ret));
13864 cmdline_parse_inst_t cmd_tc_min_bw = {
13865 .f = cmd_tc_min_bw_parsed,
13867 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13869 (void *)&cmd_vf_tc_bw_set,
13870 (void *)&cmd_vf_tc_bw_tc,
13871 (void *)&cmd_vf_tc_bw_tx,
13872 (void *)&cmd_vf_tc_bw_min_bw,
13873 (void *)&cmd_vf_tc_bw_port_id,
13874 (void *)&cmd_vf_tc_bw_bw_list,
13879 /* TC max bandwidth setting */
13881 cmd_vf_tc_max_bw_parsed(
13882 void *parsed_result,
13883 __attribute__((unused)) struct cmdline *cl,
13884 __attribute__((unused)) void *data)
13886 struct cmd_vf_tc_bw_result *res = parsed_result;
13887 int ret = -ENOTSUP;
13889 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13892 #ifdef RTE_LIBRTE_I40E_PMD
13893 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13894 res->tc_no, res->bw);
13901 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13902 res->vf_id, res->tc_no, res->bw);
13905 printf("invalid port_id %d\n", res->port_id);
13908 printf("function not implemented\n");
13911 printf("programming error: (%s)\n", strerror(-ret));
13915 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13916 .f = cmd_vf_tc_max_bw_parsed,
13918 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13921 (void *)&cmd_vf_tc_bw_set,
13922 (void *)&cmd_vf_tc_bw_vf,
13923 (void *)&cmd_vf_tc_bw_tc,
13924 (void *)&cmd_vf_tc_bw_tx,
13925 (void *)&cmd_vf_tc_bw_max_bw,
13926 (void *)&cmd_vf_tc_bw_port_id,
13927 (void *)&cmd_vf_tc_bw_vf_id,
13928 (void *)&cmd_vf_tc_bw_tc_no,
13929 (void *)&cmd_vf_tc_bw_bw,
13935 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
13937 /* *** Set Port default Traffic Management Hierarchy *** */
13938 struct cmd_set_port_tm_hierarchy_default_result {
13939 cmdline_fixed_string_t set;
13940 cmdline_fixed_string_t port;
13941 cmdline_fixed_string_t tm;
13942 cmdline_fixed_string_t hierarchy;
13943 cmdline_fixed_string_t def;
13947 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
13948 TOKEN_STRING_INITIALIZER(
13949 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
13950 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
13951 TOKEN_STRING_INITIALIZER(
13952 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
13953 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
13954 TOKEN_STRING_INITIALIZER(
13955 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
13956 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
13957 TOKEN_STRING_INITIALIZER(
13958 struct cmd_set_port_tm_hierarchy_default_result,
13959 hierarchy, "hierarchy");
13960 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
13961 TOKEN_STRING_INITIALIZER(
13962 struct cmd_set_port_tm_hierarchy_default_result,
13964 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
13965 TOKEN_NUM_INITIALIZER(
13966 struct cmd_set_port_tm_hierarchy_default_result,
13969 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
13970 __attribute__((unused)) struct cmdline *cl,
13971 __attribute__((unused)) void *data)
13973 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
13974 struct rte_port *p;
13975 portid_t port_id = res->port_id;
13977 if (port_id_is_invalid(port_id, ENABLED_WARN))
13980 p = &ports[port_id];
13983 if (p->softport.tm_flag == 0) {
13984 printf(" tm not enabled on port %u (error)\n", port_id);
13988 /* Forward mode: tm */
13989 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
13990 printf(" tm mode not enabled(error)\n");
13994 /* Set the default tm hierarchy */
13995 p->softport.tm.default_hierarchy_enable = 1;
13998 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
13999 .f = cmd_set_port_tm_hierarchy_default_parsed,
14001 .help_str = "set port tm hierarchy default <port_id>",
14003 (void *)&cmd_set_port_tm_hierarchy_default_set,
14004 (void *)&cmd_set_port_tm_hierarchy_default_port,
14005 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14006 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14007 (void *)&cmd_set_port_tm_hierarchy_default_default,
14008 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14014 /* Strict link priority scheduling mode setting */
14016 cmd_strict_link_prio_parsed(
14017 void *parsed_result,
14018 __attribute__((unused)) struct cmdline *cl,
14019 __attribute__((unused)) void *data)
14021 struct cmd_vf_tc_bw_result *res = parsed_result;
14022 int ret = -ENOTSUP;
14024 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14027 #ifdef RTE_LIBRTE_I40E_PMD
14028 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14035 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14038 printf("invalid port_id %d\n", res->port_id);
14041 printf("function not implemented\n");
14044 printf("programming error: (%s)\n", strerror(-ret));
14048 cmdline_parse_inst_t cmd_strict_link_prio = {
14049 .f = cmd_strict_link_prio_parsed,
14051 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14053 (void *)&cmd_vf_tc_bw_set,
14054 (void *)&cmd_vf_tc_bw_tx,
14055 (void *)&cmd_vf_tc_bw_strict_link_prio,
14056 (void *)&cmd_vf_tc_bw_port_id,
14057 (void *)&cmd_vf_tc_bw_tc_map,
14062 /* Load dynamic device personalization*/
14063 struct cmd_ddp_add_result {
14064 cmdline_fixed_string_t ddp;
14065 cmdline_fixed_string_t add;
14070 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14071 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14072 cmdline_parse_token_string_t cmd_ddp_add_add =
14073 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14074 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14075 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14076 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14077 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14080 cmd_ddp_add_parsed(
14081 void *parsed_result,
14082 __attribute__((unused)) struct cmdline *cl,
14083 __attribute__((unused)) void *data)
14085 struct cmd_ddp_add_result *res = parsed_result;
14091 int ret = -ENOTSUP;
14093 if (res->port_id > nb_ports) {
14094 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14098 if (!all_ports_stopped()) {
14099 printf("Please stop all ports first\n");
14103 filepath = strdup(res->filepath);
14104 if (filepath == NULL) {
14105 printf("Failed to allocate memory\n");
14108 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14110 buff = open_ddp_package_file(file_fld[0], &size);
14112 free((void *)filepath);
14116 #ifdef RTE_LIBRTE_I40E_PMD
14117 if (ret == -ENOTSUP)
14118 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14120 RTE_PMD_I40E_PKG_OP_WR_ADD);
14123 if (ret == -EEXIST)
14124 printf("Profile has already existed.\n");
14126 printf("Failed to load profile.\n");
14127 else if (file_num == 2)
14128 save_ddp_package_file(file_fld[1], buff, size);
14130 close_ddp_package_file(buff);
14131 free((void *)filepath);
14134 cmdline_parse_inst_t cmd_ddp_add = {
14135 .f = cmd_ddp_add_parsed,
14137 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14139 (void *)&cmd_ddp_add_ddp,
14140 (void *)&cmd_ddp_add_add,
14141 (void *)&cmd_ddp_add_port_id,
14142 (void *)&cmd_ddp_add_filepath,
14147 /* Delete dynamic device personalization*/
14148 struct cmd_ddp_del_result {
14149 cmdline_fixed_string_t ddp;
14150 cmdline_fixed_string_t del;
14155 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14156 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14157 cmdline_parse_token_string_t cmd_ddp_del_del =
14158 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14159 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14160 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14161 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14162 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14165 cmd_ddp_del_parsed(
14166 void *parsed_result,
14167 __attribute__((unused)) struct cmdline *cl,
14168 __attribute__((unused)) void *data)
14170 struct cmd_ddp_del_result *res = parsed_result;
14173 int ret = -ENOTSUP;
14175 if (res->port_id > nb_ports) {
14176 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14180 if (!all_ports_stopped()) {
14181 printf("Please stop all ports first\n");
14185 buff = open_ddp_package_file(res->filepath, &size);
14189 #ifdef RTE_LIBRTE_I40E_PMD
14190 if (ret == -ENOTSUP)
14191 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14193 RTE_PMD_I40E_PKG_OP_WR_DEL);
14196 if (ret == -EACCES)
14197 printf("Profile does not exist.\n");
14199 printf("Failed to delete profile.\n");
14201 close_ddp_package_file(buff);
14204 cmdline_parse_inst_t cmd_ddp_del = {
14205 .f = cmd_ddp_del_parsed,
14207 .help_str = "ddp del <port_id> <profile_path>",
14209 (void *)&cmd_ddp_del_ddp,
14210 (void *)&cmd_ddp_del_del,
14211 (void *)&cmd_ddp_del_port_id,
14212 (void *)&cmd_ddp_del_filepath,
14217 /* Get dynamic device personalization profile info */
14218 struct cmd_ddp_info_result {
14219 cmdline_fixed_string_t ddp;
14220 cmdline_fixed_string_t get;
14221 cmdline_fixed_string_t info;
14225 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14226 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14227 cmdline_parse_token_string_t cmd_ddp_info_get =
14228 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14229 cmdline_parse_token_string_t cmd_ddp_info_info =
14230 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14231 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14232 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14235 cmd_ddp_info_parsed(
14236 void *parsed_result,
14237 __attribute__((unused)) struct cmdline *cl,
14238 __attribute__((unused)) void *data)
14240 struct cmd_ddp_info_result *res = parsed_result;
14243 int ret = -ENOTSUP;
14244 #ifdef RTE_LIBRTE_I40E_PMD
14247 uint32_t buff_size = 0;
14248 struct rte_pmd_i40e_profile_info info;
14249 uint32_t dev_num = 0;
14250 struct rte_pmd_i40e_ddp_device_id *devs;
14251 uint32_t proto_num = 0;
14252 struct rte_pmd_i40e_proto_info *proto;
14253 uint32_t pctype_num = 0;
14254 struct rte_pmd_i40e_ptype_info *pctype;
14255 uint32_t ptype_num = 0;
14256 struct rte_pmd_i40e_ptype_info *ptype;
14261 pkg = open_ddp_package_file(res->filepath, &pkg_size);
14265 #ifdef RTE_LIBRTE_I40E_PMD
14266 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14267 (uint8_t *)&info, sizeof(info),
14268 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14270 printf("Global Track id: 0x%x\n", info.track_id);
14271 printf("Global Version: %d.%d.%d.%d\n",
14272 info.version.major,
14273 info.version.minor,
14274 info.version.update,
14275 info.version.draft);
14276 printf("Global Package name: %s\n\n", info.name);
14279 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14280 (uint8_t *)&info, sizeof(info),
14281 RTE_PMD_I40E_PKG_INFO_HEADER);
14283 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14284 printf("i40e Profile Version: %d.%d.%d.%d\n",
14285 info.version.major,
14286 info.version.minor,
14287 info.version.update,
14288 info.version.draft);
14289 printf("i40e Profile name: %s\n\n", info.name);
14292 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14293 (uint8_t *)&buff_size, sizeof(buff_size),
14294 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14295 if (!ret && buff_size) {
14296 buff = (uint8_t *)malloc(buff_size);
14298 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14300 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14302 printf("Package Notes:\n%s\n\n", buff);
14307 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14308 (uint8_t *)&dev_num, sizeof(dev_num),
14309 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14310 if (!ret && dev_num) {
14311 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14312 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14314 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14315 (uint8_t *)devs, buff_size,
14316 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14318 printf("List of supported devices:\n");
14319 for (i = 0; i < dev_num; i++) {
14320 printf(" %04X:%04X %04X:%04X\n",
14321 devs[i].vendor_dev_id >> 16,
14322 devs[i].vendor_dev_id & 0xFFFF,
14323 devs[i].sub_vendor_dev_id >> 16,
14324 devs[i].sub_vendor_dev_id & 0xFFFF);
14332 /* get information about protocols and packet types */
14333 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14334 (uint8_t *)&proto_num, sizeof(proto_num),
14335 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14336 if (ret || !proto_num)
14337 goto no_print_return;
14339 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14340 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14342 goto no_print_return;
14344 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14346 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14348 printf("List of used protocols:\n");
14349 for (i = 0; i < proto_num; i++)
14350 printf(" %2u: %s\n", proto[i].proto_id,
14354 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14355 (uint8_t *)&pctype_num, sizeof(pctype_num),
14356 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14357 if (ret || !pctype_num)
14358 goto no_print_pctypes;
14360 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14361 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14363 goto no_print_pctypes;
14365 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14367 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14370 goto no_print_pctypes;
14373 printf("List of defined packet classification types:\n");
14374 for (i = 0; i < pctype_num; i++) {
14375 printf(" %2u:", pctype[i].ptype_id);
14376 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14377 proto_id = pctype[i].protocols[j];
14378 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14379 for (n = 0; n < proto_num; n++) {
14380 if (proto[n].proto_id == proto_id) {
14381 printf(" %s", proto[n].name);
14394 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14396 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14397 if (ret || !ptype_num)
14398 goto no_print_return;
14400 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14401 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14403 goto no_print_return;
14405 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14407 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14410 goto no_print_return;
14412 printf("List of defined packet types:\n");
14413 for (i = 0; i < ptype_num; i++) {
14414 printf(" %2u:", ptype[i].ptype_id);
14415 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14416 proto_id = ptype[i].protocols[j];
14417 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14418 for (n = 0; n < proto_num; n++) {
14419 if (proto[n].proto_id == proto_id) {
14420 printf(" %s", proto[n].name);
14435 if (ret == -ENOTSUP)
14436 printf("Function not supported in PMD driver\n");
14437 close_ddp_package_file(pkg);
14440 cmdline_parse_inst_t cmd_ddp_get_info = {
14441 .f = cmd_ddp_info_parsed,
14443 .help_str = "ddp get info <profile_path>",
14445 (void *)&cmd_ddp_info_ddp,
14446 (void *)&cmd_ddp_info_get,
14447 (void *)&cmd_ddp_info_info,
14448 (void *)&cmd_ddp_info_filepath,
14453 /* Get dynamic device personalization profile info list*/
14454 #define PROFILE_INFO_SIZE 48
14455 #define MAX_PROFILE_NUM 16
14457 struct cmd_ddp_get_list_result {
14458 cmdline_fixed_string_t ddp;
14459 cmdline_fixed_string_t get;
14460 cmdline_fixed_string_t list;
14464 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14465 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14466 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14467 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14468 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14469 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14470 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14471 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14474 cmd_ddp_get_list_parsed(
14475 void *parsed_result,
14476 __attribute__((unused)) struct cmdline *cl,
14477 __attribute__((unused)) void *data)
14479 struct cmd_ddp_get_list_result *res = parsed_result;
14480 #ifdef RTE_LIBRTE_I40E_PMD
14481 struct rte_pmd_i40e_profile_list *p_list;
14482 struct rte_pmd_i40e_profile_info *p_info;
14487 int ret = -ENOTSUP;
14489 if (res->port_id > nb_ports) {
14490 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14494 #ifdef RTE_LIBRTE_I40E_PMD
14495 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14496 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14498 printf("%s: Failed to malloc buffer\n", __func__);
14500 if (ret == -ENOTSUP)
14501 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14502 (uint8_t *)p_list, size);
14505 p_num = p_list->p_count;
14506 printf("Profile number is: %d\n\n", p_num);
14508 for (i = 0; i < p_num; i++) {
14509 p_info = &p_list->p_info[i];
14510 printf("Profile %d:\n", i);
14511 printf("Track id: 0x%x\n", p_info->track_id);
14512 printf("Version: %d.%d.%d.%d\n",
14513 p_info->version.major,
14514 p_info->version.minor,
14515 p_info->version.update,
14516 p_info->version.draft);
14517 printf("Profile name: %s\n\n", p_info->name);
14525 printf("Failed to get ddp list\n");
14528 cmdline_parse_inst_t cmd_ddp_get_list = {
14529 .f = cmd_ddp_get_list_parsed,
14531 .help_str = "ddp get list <port_id>",
14533 (void *)&cmd_ddp_get_list_ddp,
14534 (void *)&cmd_ddp_get_list_get,
14535 (void *)&cmd_ddp_get_list_list,
14536 (void *)&cmd_ddp_get_list_port_id,
14541 /* show vf stats */
14543 /* Common result structure for show vf stats */
14544 struct cmd_show_vf_stats_result {
14545 cmdline_fixed_string_t show;
14546 cmdline_fixed_string_t vf;
14547 cmdline_fixed_string_t stats;
14552 /* Common CLI fields show vf stats*/
14553 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14554 TOKEN_STRING_INITIALIZER
14555 (struct cmd_show_vf_stats_result,
14557 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14558 TOKEN_STRING_INITIALIZER
14559 (struct cmd_show_vf_stats_result,
14561 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14562 TOKEN_STRING_INITIALIZER
14563 (struct cmd_show_vf_stats_result,
14565 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14566 TOKEN_NUM_INITIALIZER
14567 (struct cmd_show_vf_stats_result,
14569 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14570 TOKEN_NUM_INITIALIZER
14571 (struct cmd_show_vf_stats_result,
14575 cmd_show_vf_stats_parsed(
14576 void *parsed_result,
14577 __attribute__((unused)) struct cmdline *cl,
14578 __attribute__((unused)) void *data)
14580 struct cmd_show_vf_stats_result *res = parsed_result;
14581 struct rte_eth_stats stats;
14582 int ret = -ENOTSUP;
14583 static const char *nic_stats_border = "########################";
14585 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14588 memset(&stats, 0, sizeof(stats));
14590 #ifdef RTE_LIBRTE_I40E_PMD
14591 if (ret == -ENOTSUP)
14592 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14596 #ifdef RTE_LIBRTE_BNXT_PMD
14597 if (ret == -ENOTSUP)
14598 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14607 printf("invalid vf_id %d\n", res->vf_id);
14610 printf("invalid port_id %d\n", res->port_id);
14613 printf("function not implemented\n");
14616 printf("programming error: (%s)\n", strerror(-ret));
14619 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14620 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14622 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14624 stats.ipackets, stats.imissed, stats.ibytes);
14625 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14626 printf(" RX-nombuf: %-10"PRIu64"\n",
14628 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14630 stats.opackets, stats.oerrors, stats.obytes);
14632 printf(" %s############################%s\n",
14633 nic_stats_border, nic_stats_border);
14636 cmdline_parse_inst_t cmd_show_vf_stats = {
14637 .f = cmd_show_vf_stats_parsed,
14639 .help_str = "show vf stats <port_id> <vf_id>",
14641 (void *)&cmd_show_vf_stats_show,
14642 (void *)&cmd_show_vf_stats_vf,
14643 (void *)&cmd_show_vf_stats_stats,
14644 (void *)&cmd_show_vf_stats_port_id,
14645 (void *)&cmd_show_vf_stats_vf_id,
14650 /* clear vf stats */
14652 /* Common result structure for clear vf stats */
14653 struct cmd_clear_vf_stats_result {
14654 cmdline_fixed_string_t clear;
14655 cmdline_fixed_string_t vf;
14656 cmdline_fixed_string_t stats;
14661 /* Common CLI fields clear vf stats*/
14662 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14663 TOKEN_STRING_INITIALIZER
14664 (struct cmd_clear_vf_stats_result,
14666 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14667 TOKEN_STRING_INITIALIZER
14668 (struct cmd_clear_vf_stats_result,
14670 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14671 TOKEN_STRING_INITIALIZER
14672 (struct cmd_clear_vf_stats_result,
14674 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14675 TOKEN_NUM_INITIALIZER
14676 (struct cmd_clear_vf_stats_result,
14678 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14679 TOKEN_NUM_INITIALIZER
14680 (struct cmd_clear_vf_stats_result,
14684 cmd_clear_vf_stats_parsed(
14685 void *parsed_result,
14686 __attribute__((unused)) struct cmdline *cl,
14687 __attribute__((unused)) void *data)
14689 struct cmd_clear_vf_stats_result *res = parsed_result;
14690 int ret = -ENOTSUP;
14692 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14695 #ifdef RTE_LIBRTE_I40E_PMD
14696 if (ret == -ENOTSUP)
14697 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14700 #ifdef RTE_LIBRTE_BNXT_PMD
14701 if (ret == -ENOTSUP)
14702 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14710 printf("invalid vf_id %d\n", res->vf_id);
14713 printf("invalid port_id %d\n", res->port_id);
14716 printf("function not implemented\n");
14719 printf("programming error: (%s)\n", strerror(-ret));
14723 cmdline_parse_inst_t cmd_clear_vf_stats = {
14724 .f = cmd_clear_vf_stats_parsed,
14726 .help_str = "clear vf stats <port_id> <vf_id>",
14728 (void *)&cmd_clear_vf_stats_clear,
14729 (void *)&cmd_clear_vf_stats_vf,
14730 (void *)&cmd_clear_vf_stats_stats,
14731 (void *)&cmd_clear_vf_stats_port_id,
14732 (void *)&cmd_clear_vf_stats_vf_id,
14737 /* port config pctype mapping reset */
14739 /* Common result structure for port config pctype mapping reset */
14740 struct cmd_pctype_mapping_reset_result {
14741 cmdline_fixed_string_t port;
14742 cmdline_fixed_string_t config;
14744 cmdline_fixed_string_t pctype;
14745 cmdline_fixed_string_t mapping;
14746 cmdline_fixed_string_t reset;
14749 /* Common CLI fields for port config pctype mapping reset*/
14750 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14751 TOKEN_STRING_INITIALIZER
14752 (struct cmd_pctype_mapping_reset_result,
14754 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14755 TOKEN_STRING_INITIALIZER
14756 (struct cmd_pctype_mapping_reset_result,
14758 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14759 TOKEN_NUM_INITIALIZER
14760 (struct cmd_pctype_mapping_reset_result,
14762 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14763 TOKEN_STRING_INITIALIZER
14764 (struct cmd_pctype_mapping_reset_result,
14766 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14767 TOKEN_STRING_INITIALIZER
14768 (struct cmd_pctype_mapping_reset_result,
14769 mapping, "mapping");
14770 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14771 TOKEN_STRING_INITIALIZER
14772 (struct cmd_pctype_mapping_reset_result,
14776 cmd_pctype_mapping_reset_parsed(
14777 void *parsed_result,
14778 __attribute__((unused)) struct cmdline *cl,
14779 __attribute__((unused)) void *data)
14781 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14782 int ret = -ENOTSUP;
14784 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14787 #ifdef RTE_LIBRTE_I40E_PMD
14788 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14795 printf("invalid port_id %d\n", res->port_id);
14798 printf("function not implemented\n");
14801 printf("programming error: (%s)\n", strerror(-ret));
14805 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14806 .f = cmd_pctype_mapping_reset_parsed,
14808 .help_str = "port config <port_id> pctype mapping reset",
14810 (void *)&cmd_pctype_mapping_reset_port,
14811 (void *)&cmd_pctype_mapping_reset_config,
14812 (void *)&cmd_pctype_mapping_reset_port_id,
14813 (void *)&cmd_pctype_mapping_reset_pctype,
14814 (void *)&cmd_pctype_mapping_reset_mapping,
14815 (void *)&cmd_pctype_mapping_reset_reset,
14820 /* show port pctype mapping */
14822 /* Common result structure for show port pctype mapping */
14823 struct cmd_pctype_mapping_get_result {
14824 cmdline_fixed_string_t show;
14825 cmdline_fixed_string_t port;
14827 cmdline_fixed_string_t pctype;
14828 cmdline_fixed_string_t mapping;
14831 /* Common CLI fields for pctype mapping get */
14832 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14833 TOKEN_STRING_INITIALIZER
14834 (struct cmd_pctype_mapping_get_result,
14836 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14837 TOKEN_STRING_INITIALIZER
14838 (struct cmd_pctype_mapping_get_result,
14840 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14841 TOKEN_NUM_INITIALIZER
14842 (struct cmd_pctype_mapping_get_result,
14844 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14845 TOKEN_STRING_INITIALIZER
14846 (struct cmd_pctype_mapping_get_result,
14848 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14849 TOKEN_STRING_INITIALIZER
14850 (struct cmd_pctype_mapping_get_result,
14851 mapping, "mapping");
14854 cmd_pctype_mapping_get_parsed(
14855 void *parsed_result,
14856 __attribute__((unused)) struct cmdline *cl,
14857 __attribute__((unused)) void *data)
14859 struct cmd_pctype_mapping_get_result *res = parsed_result;
14860 int ret = -ENOTSUP;
14861 #ifdef RTE_LIBRTE_I40E_PMD
14862 struct rte_pmd_i40e_flow_type_mapping
14863 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14864 int i, j, first_pctype;
14867 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14870 #ifdef RTE_LIBRTE_I40E_PMD
14871 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14878 printf("invalid port_id %d\n", res->port_id);
14881 printf("function not implemented\n");
14884 printf("programming error: (%s)\n", strerror(-ret));
14888 #ifdef RTE_LIBRTE_I40E_PMD
14889 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14890 if (mapping[i].pctype != 0ULL) {
14893 printf("pctype: ");
14894 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14895 if (mapping[i].pctype & (1ULL << j)) {
14896 printf(first_pctype ?
14897 "%02d" : ",%02d", j);
14901 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14907 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14908 .f = cmd_pctype_mapping_get_parsed,
14910 .help_str = "show port <port_id> pctype mapping",
14912 (void *)&cmd_pctype_mapping_get_show,
14913 (void *)&cmd_pctype_mapping_get_port,
14914 (void *)&cmd_pctype_mapping_get_port_id,
14915 (void *)&cmd_pctype_mapping_get_pctype,
14916 (void *)&cmd_pctype_mapping_get_mapping,
14921 /* port config pctype mapping update */
14923 /* Common result structure for port config pctype mapping update */
14924 struct cmd_pctype_mapping_update_result {
14925 cmdline_fixed_string_t port;
14926 cmdline_fixed_string_t config;
14928 cmdline_fixed_string_t pctype;
14929 cmdline_fixed_string_t mapping;
14930 cmdline_fixed_string_t update;
14931 cmdline_fixed_string_t pctype_list;
14932 uint16_t flow_type;
14935 /* Common CLI fields for pctype mapping update*/
14936 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14937 TOKEN_STRING_INITIALIZER
14938 (struct cmd_pctype_mapping_update_result,
14940 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14941 TOKEN_STRING_INITIALIZER
14942 (struct cmd_pctype_mapping_update_result,
14944 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14945 TOKEN_NUM_INITIALIZER
14946 (struct cmd_pctype_mapping_update_result,
14948 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14949 TOKEN_STRING_INITIALIZER
14950 (struct cmd_pctype_mapping_update_result,
14952 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14953 TOKEN_STRING_INITIALIZER
14954 (struct cmd_pctype_mapping_update_result,
14955 mapping, "mapping");
14956 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
14957 TOKEN_STRING_INITIALIZER
14958 (struct cmd_pctype_mapping_update_result,
14960 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
14961 TOKEN_STRING_INITIALIZER
14962 (struct cmd_pctype_mapping_update_result,
14963 pctype_list, NULL);
14964 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
14965 TOKEN_NUM_INITIALIZER
14966 (struct cmd_pctype_mapping_update_result,
14967 flow_type, UINT16);
14970 cmd_pctype_mapping_update_parsed(
14971 void *parsed_result,
14972 __attribute__((unused)) struct cmdline *cl,
14973 __attribute__((unused)) void *data)
14975 struct cmd_pctype_mapping_update_result *res = parsed_result;
14976 int ret = -ENOTSUP;
14977 #ifdef RTE_LIBRTE_I40E_PMD
14978 struct rte_pmd_i40e_flow_type_mapping mapping;
14980 unsigned int nb_item;
14981 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
14984 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14987 #ifdef RTE_LIBRTE_I40E_PMD
14988 nb_item = parse_item_list(res->pctype_list, "pctypes",
14989 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
14990 mapping.flow_type = res->flow_type;
14991 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
14992 mapping.pctype |= (1ULL << pctype_list[i]);
14993 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15003 printf("invalid pctype or flow type\n");
15006 printf("invalid port_id %d\n", res->port_id);
15009 printf("function not implemented\n");
15012 printf("programming error: (%s)\n", strerror(-ret));
15016 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15017 .f = cmd_pctype_mapping_update_parsed,
15019 .help_str = "port config <port_id> pctype mapping update"
15020 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15022 (void *)&cmd_pctype_mapping_update_port,
15023 (void *)&cmd_pctype_mapping_update_config,
15024 (void *)&cmd_pctype_mapping_update_port_id,
15025 (void *)&cmd_pctype_mapping_update_pctype,
15026 (void *)&cmd_pctype_mapping_update_mapping,
15027 (void *)&cmd_pctype_mapping_update_update,
15028 (void *)&cmd_pctype_mapping_update_pc_type,
15029 (void *)&cmd_pctype_mapping_update_flow_type,
15034 /* ptype mapping get */
15036 /* Common result structure for ptype mapping get */
15037 struct cmd_ptype_mapping_get_result {
15038 cmdline_fixed_string_t ptype;
15039 cmdline_fixed_string_t mapping;
15040 cmdline_fixed_string_t get;
15042 uint8_t valid_only;
15045 /* Common CLI fields for ptype mapping get */
15046 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15047 TOKEN_STRING_INITIALIZER
15048 (struct cmd_ptype_mapping_get_result,
15050 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15051 TOKEN_STRING_INITIALIZER
15052 (struct cmd_ptype_mapping_get_result,
15053 mapping, "mapping");
15054 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15055 TOKEN_STRING_INITIALIZER
15056 (struct cmd_ptype_mapping_get_result,
15058 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15059 TOKEN_NUM_INITIALIZER
15060 (struct cmd_ptype_mapping_get_result,
15062 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15063 TOKEN_NUM_INITIALIZER
15064 (struct cmd_ptype_mapping_get_result,
15065 valid_only, UINT8);
15068 cmd_ptype_mapping_get_parsed(
15069 void *parsed_result,
15070 __attribute__((unused)) struct cmdline *cl,
15071 __attribute__((unused)) void *data)
15073 struct cmd_ptype_mapping_get_result *res = parsed_result;
15074 int ret = -ENOTSUP;
15075 #ifdef RTE_LIBRTE_I40E_PMD
15076 int max_ptype_num = 256;
15077 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15082 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15085 #ifdef RTE_LIBRTE_I40E_PMD
15086 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15097 printf("invalid port_id %d\n", res->port_id);
15100 printf("function not implemented\n");
15103 printf("programming error: (%s)\n", strerror(-ret));
15106 #ifdef RTE_LIBRTE_I40E_PMD
15108 for (i = 0; i < count; i++)
15109 printf("%3d\t0x%08x\n",
15110 mapping[i].hw_ptype, mapping[i].sw_ptype);
15115 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15116 .f = cmd_ptype_mapping_get_parsed,
15118 .help_str = "ptype mapping get <port_id> <valid_only>",
15120 (void *)&cmd_ptype_mapping_get_ptype,
15121 (void *)&cmd_ptype_mapping_get_mapping,
15122 (void *)&cmd_ptype_mapping_get_get,
15123 (void *)&cmd_ptype_mapping_get_port_id,
15124 (void *)&cmd_ptype_mapping_get_valid_only,
15129 /* ptype mapping replace */
15131 /* Common result structure for ptype mapping replace */
15132 struct cmd_ptype_mapping_replace_result {
15133 cmdline_fixed_string_t ptype;
15134 cmdline_fixed_string_t mapping;
15135 cmdline_fixed_string_t replace;
15142 /* Common CLI fields for ptype mapping replace */
15143 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15144 TOKEN_STRING_INITIALIZER
15145 (struct cmd_ptype_mapping_replace_result,
15147 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15148 TOKEN_STRING_INITIALIZER
15149 (struct cmd_ptype_mapping_replace_result,
15150 mapping, "mapping");
15151 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15152 TOKEN_STRING_INITIALIZER
15153 (struct cmd_ptype_mapping_replace_result,
15154 replace, "replace");
15155 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15156 TOKEN_NUM_INITIALIZER
15157 (struct cmd_ptype_mapping_replace_result,
15159 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15160 TOKEN_NUM_INITIALIZER
15161 (struct cmd_ptype_mapping_replace_result,
15163 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15164 TOKEN_NUM_INITIALIZER
15165 (struct cmd_ptype_mapping_replace_result,
15167 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15168 TOKEN_NUM_INITIALIZER
15169 (struct cmd_ptype_mapping_replace_result,
15173 cmd_ptype_mapping_replace_parsed(
15174 void *parsed_result,
15175 __attribute__((unused)) struct cmdline *cl,
15176 __attribute__((unused)) void *data)
15178 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15179 int ret = -ENOTSUP;
15181 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15184 #ifdef RTE_LIBRTE_I40E_PMD
15185 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15195 printf("invalid ptype 0x%8x or 0x%8x\n",
15196 res->target, res->pkt_type);
15199 printf("invalid port_id %d\n", res->port_id);
15202 printf("function not implemented\n");
15205 printf("programming error: (%s)\n", strerror(-ret));
15209 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15210 .f = cmd_ptype_mapping_replace_parsed,
15213 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15215 (void *)&cmd_ptype_mapping_replace_ptype,
15216 (void *)&cmd_ptype_mapping_replace_mapping,
15217 (void *)&cmd_ptype_mapping_replace_replace,
15218 (void *)&cmd_ptype_mapping_replace_port_id,
15219 (void *)&cmd_ptype_mapping_replace_target,
15220 (void *)&cmd_ptype_mapping_replace_mask,
15221 (void *)&cmd_ptype_mapping_replace_pkt_type,
15226 /* ptype mapping reset */
15228 /* Common result structure for ptype mapping reset */
15229 struct cmd_ptype_mapping_reset_result {
15230 cmdline_fixed_string_t ptype;
15231 cmdline_fixed_string_t mapping;
15232 cmdline_fixed_string_t reset;
15236 /* Common CLI fields for ptype mapping reset*/
15237 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15238 TOKEN_STRING_INITIALIZER
15239 (struct cmd_ptype_mapping_reset_result,
15241 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15242 TOKEN_STRING_INITIALIZER
15243 (struct cmd_ptype_mapping_reset_result,
15244 mapping, "mapping");
15245 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15246 TOKEN_STRING_INITIALIZER
15247 (struct cmd_ptype_mapping_reset_result,
15249 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15250 TOKEN_NUM_INITIALIZER
15251 (struct cmd_ptype_mapping_reset_result,
15255 cmd_ptype_mapping_reset_parsed(
15256 void *parsed_result,
15257 __attribute__((unused)) struct cmdline *cl,
15258 __attribute__((unused)) void *data)
15260 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15261 int ret = -ENOTSUP;
15263 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15266 #ifdef RTE_LIBRTE_I40E_PMD
15267 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15274 printf("invalid port_id %d\n", res->port_id);
15277 printf("function not implemented\n");
15280 printf("programming error: (%s)\n", strerror(-ret));
15284 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15285 .f = cmd_ptype_mapping_reset_parsed,
15287 .help_str = "ptype mapping reset <port_id>",
15289 (void *)&cmd_ptype_mapping_reset_ptype,
15290 (void *)&cmd_ptype_mapping_reset_mapping,
15291 (void *)&cmd_ptype_mapping_reset_reset,
15292 (void *)&cmd_ptype_mapping_reset_port_id,
15297 /* ptype mapping update */
15299 /* Common result structure for ptype mapping update */
15300 struct cmd_ptype_mapping_update_result {
15301 cmdline_fixed_string_t ptype;
15302 cmdline_fixed_string_t mapping;
15303 cmdline_fixed_string_t reset;
15309 /* Common CLI fields for ptype mapping update*/
15310 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15311 TOKEN_STRING_INITIALIZER
15312 (struct cmd_ptype_mapping_update_result,
15314 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15315 TOKEN_STRING_INITIALIZER
15316 (struct cmd_ptype_mapping_update_result,
15317 mapping, "mapping");
15318 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15319 TOKEN_STRING_INITIALIZER
15320 (struct cmd_ptype_mapping_update_result,
15322 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15323 TOKEN_NUM_INITIALIZER
15324 (struct cmd_ptype_mapping_update_result,
15326 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15327 TOKEN_NUM_INITIALIZER
15328 (struct cmd_ptype_mapping_update_result,
15330 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15331 TOKEN_NUM_INITIALIZER
15332 (struct cmd_ptype_mapping_update_result,
15336 cmd_ptype_mapping_update_parsed(
15337 void *parsed_result,
15338 __attribute__((unused)) struct cmdline *cl,
15339 __attribute__((unused)) void *data)
15341 struct cmd_ptype_mapping_update_result *res = parsed_result;
15342 int ret = -ENOTSUP;
15343 #ifdef RTE_LIBRTE_I40E_PMD
15344 struct rte_pmd_i40e_ptype_mapping mapping;
15346 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15349 #ifdef RTE_LIBRTE_I40E_PMD
15350 mapping.hw_ptype = res->hw_ptype;
15351 mapping.sw_ptype = res->sw_ptype;
15352 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15362 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15365 printf("invalid port_id %d\n", res->port_id);
15368 printf("function not implemented\n");
15371 printf("programming error: (%s)\n", strerror(-ret));
15375 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15376 .f = cmd_ptype_mapping_update_parsed,
15378 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15380 (void *)&cmd_ptype_mapping_update_ptype,
15381 (void *)&cmd_ptype_mapping_update_mapping,
15382 (void *)&cmd_ptype_mapping_update_update,
15383 (void *)&cmd_ptype_mapping_update_port_id,
15384 (void *)&cmd_ptype_mapping_update_hw_ptype,
15385 (void *)&cmd_ptype_mapping_update_sw_ptype,
15390 /* Common result structure for file commands */
15391 struct cmd_cmdfile_result {
15392 cmdline_fixed_string_t load;
15393 cmdline_fixed_string_t filename;
15396 /* Common CLI fields for file commands */
15397 cmdline_parse_token_string_t cmd_load_cmdfile =
15398 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15399 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15400 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15403 cmd_load_from_file_parsed(
15404 void *parsed_result,
15405 __attribute__((unused)) struct cmdline *cl,
15406 __attribute__((unused)) void *data)
15408 struct cmd_cmdfile_result *res = parsed_result;
15410 cmdline_read_from_file(res->filename);
15413 cmdline_parse_inst_t cmd_load_from_file = {
15414 .f = cmd_load_from_file_parsed,
15416 .help_str = "load <filename>",
15418 (void *)&cmd_load_cmdfile,
15419 (void *)&cmd_load_cmdfile_filename,
15424 /* ******************************************************************************** */
15426 /* list of instructions */
15427 cmdline_parse_ctx_t main_ctx[] = {
15428 (cmdline_parse_inst_t *)&cmd_help_brief,
15429 (cmdline_parse_inst_t *)&cmd_help_long,
15430 (cmdline_parse_inst_t *)&cmd_quit,
15431 (cmdline_parse_inst_t *)&cmd_load_from_file,
15432 (cmdline_parse_inst_t *)&cmd_showport,
15433 (cmdline_parse_inst_t *)&cmd_showqueue,
15434 (cmdline_parse_inst_t *)&cmd_showportall,
15435 (cmdline_parse_inst_t *)&cmd_showcfg,
15436 (cmdline_parse_inst_t *)&cmd_start,
15437 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15438 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15439 (cmdline_parse_inst_t *)&cmd_set_link_up,
15440 (cmdline_parse_inst_t *)&cmd_set_link_down,
15441 (cmdline_parse_inst_t *)&cmd_reset,
15442 (cmdline_parse_inst_t *)&cmd_set_numbers,
15443 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15444 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15445 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15446 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15447 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15448 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15449 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15450 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15451 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15452 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15453 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15454 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15455 (cmdline_parse_inst_t *)&cmd_set_link_check,
15456 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15457 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15458 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15459 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15460 #ifdef RTE_LIBRTE_PMD_BOND
15461 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15462 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15463 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15464 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15465 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15466 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15467 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15468 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15469 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15470 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15471 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15473 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15474 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15475 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15476 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15477 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15478 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15479 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15480 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15481 (cmdline_parse_inst_t *)&cmd_csum_set,
15482 (cmdline_parse_inst_t *)&cmd_csum_show,
15483 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15484 (cmdline_parse_inst_t *)&cmd_tso_set,
15485 (cmdline_parse_inst_t *)&cmd_tso_show,
15486 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15487 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15488 (cmdline_parse_inst_t *)&cmd_gro_enable,
15489 (cmdline_parse_inst_t *)&cmd_gro_flush,
15490 (cmdline_parse_inst_t *)&cmd_gro_show,
15491 (cmdline_parse_inst_t *)&cmd_gso_enable,
15492 (cmdline_parse_inst_t *)&cmd_gso_size,
15493 (cmdline_parse_inst_t *)&cmd_gso_show,
15494 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15495 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15496 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15497 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15498 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15499 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15500 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15501 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15502 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15503 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15504 (cmdline_parse_inst_t *)&cmd_config_dcb,
15505 (cmdline_parse_inst_t *)&cmd_read_reg,
15506 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15507 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15508 (cmdline_parse_inst_t *)&cmd_write_reg,
15509 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15510 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15511 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15512 (cmdline_parse_inst_t *)&cmd_stop,
15513 (cmdline_parse_inst_t *)&cmd_mac_addr,
15514 (cmdline_parse_inst_t *)&cmd_set_qmap,
15515 (cmdline_parse_inst_t *)&cmd_operate_port,
15516 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15517 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15518 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15519 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15520 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15521 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15522 (cmdline_parse_inst_t *)&cmd_config_mtu,
15523 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15524 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15525 (cmdline_parse_inst_t *)&cmd_config_rss,
15526 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15527 (cmdline_parse_inst_t *)&cmd_config_txqflags,
15528 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15529 (cmdline_parse_inst_t *)&cmd_showport_reta,
15530 (cmdline_parse_inst_t *)&cmd_config_burst,
15531 (cmdline_parse_inst_t *)&cmd_config_thresh,
15532 (cmdline_parse_inst_t *)&cmd_config_threshold,
15533 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15534 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15535 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15536 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15537 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15538 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15539 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15540 (cmdline_parse_inst_t *)&cmd_global_config,
15541 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15542 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15543 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15544 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15545 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15546 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15547 (cmdline_parse_inst_t *)&cmd_dump,
15548 (cmdline_parse_inst_t *)&cmd_dump_one,
15549 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15550 (cmdline_parse_inst_t *)&cmd_syn_filter,
15551 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15552 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15553 (cmdline_parse_inst_t *)&cmd_flex_filter,
15554 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15555 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15556 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15557 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15558 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15559 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15560 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15561 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15562 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15563 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15564 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15565 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15566 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15567 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15568 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15569 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15570 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15571 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15572 (cmdline_parse_inst_t *)&cmd_flow,
15573 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15574 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15575 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15576 (cmdline_parse_inst_t *)&cmd_set_port_meter,
15577 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15578 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15579 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15580 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15581 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15582 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15583 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15584 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15585 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15586 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15587 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15588 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15589 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15590 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15591 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15592 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15593 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15594 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15595 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15596 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15597 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15598 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15599 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15600 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15601 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15602 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15603 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15604 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15605 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15606 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15607 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15608 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15609 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15610 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15611 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15612 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15613 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15614 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15615 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15616 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15617 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15618 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15619 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15621 (cmdline_parse_inst_t *)&cmd_ddp_add,
15622 (cmdline_parse_inst_t *)&cmd_ddp_del,
15623 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15624 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15625 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15626 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15627 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15628 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15629 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15630 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15632 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15633 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15634 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15635 (cmdline_parse_inst_t *)&cmd_queue_region,
15636 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15637 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15638 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15639 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15643 /* read cmdline commands from file */
15645 cmdline_read_from_file(const char *filename)
15647 struct cmdline *cl;
15649 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15651 printf("Failed to create file based cmdline context: %s\n",
15656 cmdline_interact(cl);
15661 printf("Read CLI commands from %s\n", filename);
15664 /* prompt function, called from main on MASTER lcore */
15668 /* initialize non-constant commands */
15669 cmd_set_fwd_mode_init();
15670 cmd_set_fwd_retry_mode_init();
15672 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15673 if (testpmd_cl == NULL)
15675 cmdline_interact(testpmd_cl);
15676 cmdline_stdin_exit(testpmd_cl);
15682 if (testpmd_cl != NULL)
15683 cmdline_quit(testpmd_cl);
15687 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15689 if (id == (portid_t)RTE_PORT_ALL) {
15692 RTE_ETH_FOREACH_DEV(pid) {
15693 /* check if need_reconfig has been set to 1 */
15694 if (ports[pid].need_reconfig == 0)
15695 ports[pid].need_reconfig = dev;
15696 /* check if need_reconfig_queues has been set to 1 */
15697 if (ports[pid].need_reconfig_queues == 0)
15698 ports[pid].need_reconfig_queues = queue;
15700 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15701 /* check if need_reconfig has been set to 1 */
15702 if (ports[id].need_reconfig == 0)
15703 ports[id].need_reconfig = dev;
15704 /* check if need_reconfig_queues has been set to 1 */
15705 if (ports[id].need_reconfig_queues == 0)
15706 ports[id].need_reconfig_queues = queue;