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.
46 #include <net/socket.h>
48 #include <sys/socket.h>
51 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include <rte_common.h>
56 #include <rte_byteorder.h>
58 #include <rte_debug.h>
59 #include <rte_cycles.h>
60 #include <rte_memory.h>
61 #include <rte_memzone.h>
62 #include <rte_malloc.h>
63 #include <rte_launch.h>
65 #include <rte_per_lcore.h>
66 #include <rte_lcore.h>
67 #include <rte_atomic.h>
68 #include <rte_branch_prediction.h>
70 #include <rte_mempool.h>
71 #include <rte_interrupts.h>
73 #include <rte_ether.h>
74 #include <rte_ethdev.h>
75 #include <rte_string_fns.h>
76 #include <rte_devargs.h>
77 #include <rte_eth_ctrl.h>
81 #include <cmdline_rdline.h>
82 #include <cmdline_parse.h>
83 #include <cmdline_parse_num.h>
84 #include <cmdline_parse_string.h>
85 #include <cmdline_parse_ipaddr.h>
86 #include <cmdline_parse_etheraddr.h>
87 #include <cmdline_socket.h>
89 #ifdef RTE_LIBRTE_PMD_BOND
90 #include <rte_eth_bond.h>
91 #include <rte_eth_bond_8023ad.h>
93 #ifdef RTE_LIBRTE_IXGBE_PMD
94 #include <rte_pmd_ixgbe.h>
96 #ifdef RTE_LIBRTE_I40E_PMD
97 #include <rte_pmd_i40e.h>
99 #ifdef RTE_LIBRTE_BNXT_PMD
100 #include <rte_pmd_bnxt.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"
237 if (show_all || !strcmp(res->section, "config")) {
243 "Configuration changes only become active when"
244 " forwarding is started/restarted.\n\n"
247 " Reset forwarding to the default configuration.\n\n"
249 "set verbose (level)\n"
250 " Set the debug verbosity level X.\n\n"
253 " Set number of ports.\n\n"
256 " Set number of cores.\n\n"
258 "set coremask (mask)\n"
259 " Set the forwarding cores hexadecimal mask.\n\n"
261 "set portmask (mask)\n"
262 " Set the forwarding ports hexadecimal mask.\n\n"
265 " Set number of packets per burst.\n\n"
267 "set burst tx delay (microseconds) retry (num)\n"
268 " Set the transmit delay time and number of retries,"
269 " effective when retry is enabled.\n\n"
271 "set txpkts (x[,y]*)\n"
272 " Set the length of each segment of TXONLY"
273 " and optionally CSUM packets.\n\n"
275 "set txsplit (off|on|rand)\n"
276 " Set the split policy for the TX packets."
277 " Right now only applicable for CSUM and TXONLY"
280 "set corelist (x[,y]*)\n"
281 " Set the list of forwarding cores.\n\n"
283 "set portlist (x[,y]*)\n"
284 " Set the list of forwarding ports.\n\n"
286 "set tx loopback (port_id) (on|off)\n"
287 " Enable or disable tx loopback.\n\n"
289 "set all queues drop (port_id) (on|off)\n"
290 " Set drop enable bit for all queues.\n\n"
292 "set vf split drop (port_id) (vf_id) (on|off)\n"
293 " Set split drop enable bit for a VF from the PF.\n\n"
295 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
296 " Set MAC antispoof for a VF from the PF.\n\n"
298 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
299 " Enable MACsec offload.\n\n"
301 "set macsec offload (port_id) off\n"
302 " Disable MACsec offload.\n\n"
304 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
305 " Configure MACsec secure connection (SC).\n\n"
307 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
308 " Configure MACsec secure association (SA).\n\n"
310 "set vf broadcast (port_id) (vf_id) (on|off)\n"
311 " Set VF broadcast for a VF from the PF.\n\n"
313 "vlan set strip (on|off) (port_id)\n"
314 " Set the VLAN strip on a port.\n\n"
316 "vlan set stripq (on|off) (port_id,queue_id)\n"
317 " Set the VLAN strip for a queue on a port.\n\n"
319 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
320 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
322 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
323 " Set VLAN insert for a VF from the PF.\n\n"
325 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
326 " Set VLAN antispoof for a VF from the PF.\n\n"
328 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
329 " Set VLAN tag for a VF from the PF.\n\n"
331 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
332 " Set a VF's max bandwidth(Mbps).\n\n"
334 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
335 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
337 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
338 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
340 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
341 " Set some TCs' strict link priority mode on a physical port.\n\n"
343 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
344 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
346 "vlan set filter (on|off) (port_id)\n"
347 " Set the VLAN filter on a port.\n\n"
349 "vlan set qinq (on|off) (port_id)\n"
350 " Set the VLAN QinQ (extended queue in queue)"
353 "vlan set (inner|outer) tpid (value) (port_id)\n"
354 " Set the VLAN TPID for Packet Filtering on"
357 "rx_vlan add (vlan_id|all) (port_id)\n"
358 " Add a vlan_id, or all identifiers, to the set"
359 " of VLAN identifiers filtered by port_id.\n\n"
361 "rx_vlan rm (vlan_id|all) (port_id)\n"
362 " Remove a vlan_id, or all identifiers, from the set"
363 " of VLAN identifiers filtered by port_id.\n\n"
365 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
366 " Add a vlan_id, to the set of VLAN identifiers"
367 "filtered for VF(s) from port_id.\n\n"
369 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
370 " Remove a vlan_id, to the set of VLAN identifiers"
371 "filtered for VF(s) from port_id.\n\n"
373 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
374 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
375 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
376 " add a tunnel filter of a port.\n\n"
378 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
379 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
380 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
381 " remove a tunnel filter of a port.\n\n"
383 "rx_vxlan_port add (udp_port) (port_id)\n"
384 " Add an UDP port for VXLAN packet filter on a port\n\n"
386 "rx_vxlan_port rm (udp_port) (port_id)\n"
387 " Remove an UDP port for VXLAN packet filter on a port\n\n"
389 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
390 " Set hardware insertion of VLAN IDs (single or double VLAN "
391 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
393 "tx_vlan set pvid port_id vlan_id (on|off)\n"
394 " Set port based TX VLAN insertion.\n\n"
396 "tx_vlan reset (port_id)\n"
397 " Disable hardware insertion of a VLAN header in"
398 " packets sent on a port.\n\n"
400 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
401 " Select hardware or software calculation of the"
402 " checksum when transmitting a packet using the"
403 " csum forward engine.\n"
404 " ip|udp|tcp|sctp always concern the inner layer.\n"
405 " outer-ip concerns the outer IP layer in"
406 " case the packet is recognized as a tunnel packet by"
407 " the forward engine (vxlan, gre and ipip are supported)\n"
408 " Please check the NIC datasheet for HW limits.\n\n"
410 "csum parse-tunnel (on|off) (tx_port_id)\n"
411 " If disabled, treat tunnel packets as non-tunneled"
412 " packets (treat inner headers as payload). The port\n"
413 " argument is the port used for TX in csum forward"
416 "csum show (port_id)\n"
417 " Display tx checksum offload configuration\n\n"
419 "tso set (segsize) (portid)\n"
420 " Enable TCP Segmentation Offload in csum forward"
422 " Please check the NIC datasheet for HW limits.\n\n"
425 " Display the status of TCP Segmentation Offload.\n\n"
427 "gro (on|off) (port_id)"
428 " Enable or disable Generic Receive Offload in io"
429 " forward engine.\n\n"
431 "gro set (max_flow_num) (max_item_num_per_flow) (port_id)\n"
432 " Set max flow number and max packet number per-flow"
436 " Set packet forwarding mode.\n\n"
438 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
439 " Add a MAC address on port_id.\n\n"
441 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
442 " Remove a MAC address from port_id.\n\n"
444 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
445 " Set the default MAC address for port_id.\n\n"
447 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
448 " Add a MAC address for a VF on the port.\n\n"
450 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
451 " Set the MAC address for a VF from the PF.\n\n"
453 "set port (port_id) uta (mac_address|all) (on|off)\n"
454 " Add/Remove a or all unicast hash filter(s)"
457 "set promisc (port_id|all) (on|off)\n"
458 " Set the promiscuous mode on port_id, or all.\n\n"
460 "set allmulti (port_id|all) (on|off)\n"
461 " Set the allmulti mode on port_id, or all.\n\n"
463 "set vf promisc (port_id) (vf_id) (on|off)\n"
464 " Set unicast promiscuous mode for a VF from the PF.\n\n"
466 "set vf allmulti (port_id) (vf_id) (on|off)\n"
467 " Set multicast promiscuous mode for a VF from the PF.\n\n"
469 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
470 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
471 " (on|off) autoneg (on|off) (port_id)\n"
472 "set flow_ctrl rx (on|off) (portid)\n"
473 "set flow_ctrl tx (on|off) (portid)\n"
474 "set flow_ctrl high_water (high_water) (portid)\n"
475 "set flow_ctrl low_water (low_water) (portid)\n"
476 "set flow_ctrl pause_time (pause_time) (portid)\n"
477 "set flow_ctrl send_xon (send_xon) (portid)\n"
478 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
479 "set flow_ctrl autoneg (on|off) (port_id)\n"
480 " Set the link flow control parameter on a port.\n\n"
482 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
483 " (low_water) (pause_time) (priority) (port_id)\n"
484 " Set the priority flow control parameter on a"
487 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
488 " Set statistics mapping (qmapping 0..15) for RX/TX"
490 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
491 " on port 0 to mapping 5.\n\n"
493 "set port (port_id) vf (vf_id) rx|tx on|off\n"
494 " Enable/Disable a VF receive/tranmit from a port\n\n"
496 "set port (port_id) vf (vf_id) (mac_addr)"
497 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
498 " Add/Remove unicast or multicast MAC addr filter"
501 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
503 " AUPE:accepts untagged VLAN;"
504 "ROPE:accept unicast hash\n\n"
505 " BAM:accepts broadcast packets;"
506 "MPE:accepts all multicast packets\n\n"
507 " Enable/Disable a VF receive mode of a port\n\n"
509 "set port (port_id) queue (queue_id) rate (rate_num)\n"
510 " Set rate limit for a queue of a port\n\n"
512 "set port (port_id) vf (vf_id) rate (rate_num) "
513 "queue_mask (queue_mask_value)\n"
514 " Set rate limit for queues in VF of a port\n\n"
516 "set port (port_id) mirror-rule (rule_id)"
517 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
518 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
519 " Set pool or vlan type mirror rule on a port.\n"
520 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
521 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
524 "set port (port_id) mirror-rule (rule_id)"
525 " (uplink-mirror|downlink-mirror) dst-pool"
526 " (pool_id) (on|off)\n"
527 " Set uplink or downlink type mirror rule on a port.\n"
528 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
529 " 0 on' enable mirror income traffic to pool 0.\n\n"
531 "reset port (port_id) mirror-rule (rule_id)\n"
532 " Reset a mirror rule.\n\n"
534 "set flush_rx (on|off)\n"
535 " Flush (default) or don't flush RX streams before"
536 " forwarding. Mainly used with PCAP drivers.\n\n"
538 "set bypass mode (normal|bypass|isolate) (port_id)\n"
539 " Set the bypass mode for the lowest port on bypass enabled"
542 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
543 "mode (normal|bypass|isolate) (port_id)\n"
544 " Set the event required to initiate specified bypass mode for"
545 " the lowest port on a bypass enabled NIC where:\n"
546 " timeout = enable bypass after watchdog timeout.\n"
547 " os_on = enable bypass when OS/board is powered on.\n"
548 " os_off = enable bypass when OS/board is powered off.\n"
549 " power_on = enable bypass when power supply is turned on.\n"
550 " power_off = enable bypass when power supply is turned off."
553 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
554 " Set the bypass watchdog timeout to 'n' seconds"
555 " where 0 = instant.\n\n"
557 "show bypass config (port_id)\n"
558 " Show the bypass configuration for a bypass enabled NIC"
559 " using the lowest port on the NIC.\n\n"
561 #ifdef RTE_LIBRTE_PMD_BOND
562 "create bonded device (mode) (socket)\n"
563 " Create a new bonded device with specific bonding mode and socket.\n\n"
565 "add bonding slave (slave_id) (port_id)\n"
566 " Add a slave device to a bonded device.\n\n"
568 "remove bonding slave (slave_id) (port_id)\n"
569 " Remove a slave device from a bonded device.\n\n"
571 "set bonding mode (value) (port_id)\n"
572 " Set the bonding mode on a bonded device.\n\n"
574 "set bonding primary (slave_id) (port_id)\n"
575 " Set the primary slave for a bonded device.\n\n"
577 "show bonding config (port_id)\n"
578 " Show the bonding config for port_id.\n\n"
580 "set bonding mac_addr (port_id) (address)\n"
581 " Set the MAC address of a bonded device.\n\n"
583 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
584 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
586 "set bonding mon_period (port_id) (value)\n"
587 " Set the bonding link status monitoring polling period in ms.\n\n"
589 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
590 " Enable/disable dedicated queues for LACP control traffic.\n\n"
593 "set link-up port (port_id)\n"
594 " Set link up for a port.\n\n"
596 "set link-down port (port_id)\n"
597 " Set link down for a port.\n\n"
599 "E-tag set insertion on port-tag-id (value)"
600 " port (port_id) vf (vf_id)\n"
601 " Enable E-tag insertion for a VF on a port\n\n"
603 "E-tag set insertion off port (port_id) vf (vf_id)\n"
604 " Disable E-tag insertion for a VF on a port\n\n"
606 "E-tag set stripping (on|off) port (port_id)\n"
607 " Enable/disable E-tag stripping on a port\n\n"
609 "E-tag set forwarding (on|off) port (port_id)\n"
610 " Enable/disable E-tag based forwarding"
613 "E-tag set filter add e-tag-id (value) dst-pool"
614 " (pool_id) port (port_id)\n"
615 " Add an E-tag forwarding filter on a port\n\n"
617 "E-tag set filter del e-tag-id (value) port (port_id)\n"
618 " Delete an E-tag forwarding filter on a port\n\n"
620 "ddp add (port_id) (profile_path[,output_path])\n"
621 " Load a profile package on a port\n\n"
623 "ddp del (port_id) (profile_path)\n"
624 " Delete a profile package from a port\n\n"
626 "ptype mapping get (port_id) (valid_only)\n"
627 " Get ptype mapping on a port\n\n"
629 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
630 " Replace target with the pkt_type in ptype mapping\n\n"
632 "ptype mapping reset (port_id)\n"
633 " Reset ptype mapping on a port\n\n"
635 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
636 " Update a ptype mapping item on a port\n\n"
638 , list_pkt_forwarding_modes()
642 if (show_all || !strcmp(res->section, "ports")) {
648 "----------------\n\n"
650 "port start (port_id|all)\n"
651 " Start all ports or port_id.\n\n"
653 "port stop (port_id|all)\n"
654 " Stop all ports or port_id.\n\n"
656 "port close (port_id|all)\n"
657 " Close all ports or port_id.\n\n"
659 "port attach (ident)\n"
660 " Attach physical or virtual dev by pci address or virtual device name\n\n"
662 "port detach (port_id)\n"
663 " Detach physical or virtual dev by port_id\n\n"
665 "port config (port_id|all)"
666 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
667 " duplex (half|full|auto)\n"
668 " Set speed and duplex for all ports or port_id\n\n"
670 "port config all (rxq|txq|rxd|txd) (value)\n"
671 " Set number for rxq/txq/rxd/txd.\n\n"
673 "port config all max-pkt-len (value)\n"
674 " Set the max packet length.\n\n"
676 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
677 "hw-vlan-strip|hw-vlan-extend|drop-en)"
679 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
682 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
683 " Set the RSS mode.\n\n"
685 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
686 " Set the RSS redirection table.\n\n"
688 "port config (port_id) dcb vt (on|off) (traffic_class)"
690 " Set the DCB mode.\n\n"
692 "port config all burst (value)\n"
693 " Set the number of packets per burst.\n\n"
695 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
697 " Set the ring prefetch/host/writeback threshold"
698 " for tx/rx queue.\n\n"
700 "port config all (txfreet|txrst|rxfreet) (value)\n"
701 " Set free threshold for rx/tx, or set"
702 " tx rs bit threshold.\n\n"
703 "port config mtu X value\n"
704 " Set the MTU of port X to a given value\n\n"
706 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
707 " Start/stop a rx/tx queue of port X. Only take effect"
708 " when port X is started\n\n"
710 "port config (port_id|all) l2-tunnel E-tag ether-type"
712 " Set the value of E-tag ether-type.\n\n"
714 "port config (port_id|all) l2-tunnel E-tag"
715 " (enable|disable)\n"
716 " Enable/disable the E-tag support.\n\n"
720 if (show_all || !strcmp(res->section, "registers")) {
728 "read reg (port_id) (address)\n"
729 " Display value of a port register.\n\n"
731 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
732 " Display a port register bit field.\n\n"
734 "read regbit (port_id) (address) (bit_x)\n"
735 " Display a single port register bit.\n\n"
737 "write reg (port_id) (address) (value)\n"
738 " Set value of a port register.\n\n"
740 "write regfield (port_id) (address) (bit_x) (bit_y)"
742 " Set bit field of a port register.\n\n"
744 "write regbit (port_id) (address) (bit_x) (value)\n"
745 " Set single bit value of a port register.\n\n"
748 if (show_all || !strcmp(res->section, "filters")) {
756 "ethertype_filter (port_id) (add|del)"
757 " (mac_addr|mac_ignr) (mac_address) ethertype"
758 " (ether_type) (drop|fwd) queue (queue_id)\n"
759 " Add/Del an ethertype filter.\n\n"
761 "2tuple_filter (port_id) (add|del)"
762 " dst_port (dst_port_value) protocol (protocol_value)"
763 " mask (mask_value) tcp_flags (tcp_flags_value)"
764 " priority (prio_value) queue (queue_id)\n"
765 " Add/Del a 2tuple filter.\n\n"
767 "5tuple_filter (port_id) (add|del)"
768 " dst_ip (dst_address) src_ip (src_address)"
769 " dst_port (dst_port_value) src_port (src_port_value)"
770 " protocol (protocol_value)"
771 " mask (mask_value) tcp_flags (tcp_flags_value)"
772 " priority (prio_value) queue (queue_id)\n"
773 " Add/Del a 5tuple filter.\n\n"
775 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
776 " Add/Del syn filter.\n\n"
778 "flex_filter (port_id) (add|del) len (len_value)"
779 " bytes (bytes_value) mask (mask_value)"
780 " priority (prio_value) queue (queue_id)\n"
781 " Add/Del a flex filter.\n\n"
783 "flow_director_filter (port_id) mode IP (add|del|update)"
784 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
785 " src (src_ip_address) dst (dst_ip_address)"
786 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
787 " vlan (vlan_value) flexbytes (flexbytes_value)"
788 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
789 " fd_id (fd_id_value)\n"
790 " Add/Del an IP type flow director filter.\n\n"
792 "flow_director_filter (port_id) mode IP (add|del|update)"
793 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
794 " src (src_ip_address) (src_port)"
795 " dst (dst_ip_address) (dst_port)"
796 " tos (tos_value) ttl (ttl_value)"
797 " vlan (vlan_value) flexbytes (flexbytes_value)"
798 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
799 " fd_id (fd_id_value)\n"
800 " Add/Del an UDP/TCP type flow director filter.\n\n"
802 "flow_director_filter (port_id) mode IP (add|del|update)"
803 " flow (ipv4-sctp|ipv6-sctp)"
804 " src (src_ip_address) (src_port)"
805 " dst (dst_ip_address) (dst_port)"
806 " tag (verification_tag) "
807 " tos (tos_value) ttl (ttl_value)"
809 " flexbytes (flexbytes_value) (drop|fwd)"
810 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
811 " Add/Del a SCTP type flow director filter.\n\n"
813 "flow_director_filter (port_id) mode IP (add|del|update)"
814 " flow l2_payload ether (ethertype)"
815 " flexbytes (flexbytes_value) (drop|fwd)"
816 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
817 " Add/Del a l2 payload type flow director filter.\n\n"
819 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
820 " mac (mac_address) vlan (vlan_value)"
821 " flexbytes (flexbytes_value) (drop|fwd)"
822 " queue (queue_id) fd_id (fd_id_value)\n"
823 " Add/Del a MAC-VLAN flow director filter.\n\n"
825 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
826 " mac (mac_address) vlan (vlan_value)"
827 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
828 " flexbytes (flexbytes_value) (drop|fwd)"
829 " queue (queue_id) fd_id (fd_id_value)\n"
830 " Add/Del a Tunnel flow director filter.\n\n"
832 "flush_flow_director (port_id)\n"
833 " Flush all flow director entries of a device.\n\n"
835 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
836 " src_mask (ipv4_src) (ipv6_src) (src_port)"
837 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
838 " Set flow director IP mask.\n\n"
840 "flow_director_mask (port_id) mode MAC-VLAN"
841 " vlan (vlan_value)\n"
842 " Set flow director MAC-VLAN mask.\n\n"
844 "flow_director_mask (port_id) mode Tunnel"
845 " vlan (vlan_value) mac (mac_value)"
846 " tunnel-type (tunnel_type_value)"
847 " tunnel-id (tunnel_id_value)\n"
848 " Set flow director Tunnel mask.\n\n"
850 "flow_director_flex_mask (port_id)"
851 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
852 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
854 " Configure mask of flex payload.\n\n"
856 "flow_director_flex_payload (port_id)"
857 " (raw|l2|l3|l4) (config)\n"
858 " Configure flex payload selection.\n\n"
860 "get_sym_hash_ena_per_port (port_id)\n"
861 " get symmetric hash enable configuration per port.\n\n"
863 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
864 " set symmetric hash enable configuration per port"
865 " to enable or disable.\n\n"
867 "get_hash_global_config (port_id)\n"
868 " Get the global configurations of hash filters.\n\n"
870 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
871 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
872 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
873 " (enable|disable)\n"
874 " Set the global configurations of hash filters.\n\n"
876 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
877 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
878 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
879 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
880 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
881 "ipv6-next-header|udp-src-port|udp-dst-port|"
882 "tcp-src-port|tcp-dst-port|sctp-src-port|"
883 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
884 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
885 "fld-8th|none) (select|add)\n"
886 " Set the input set for hash.\n\n"
888 "set_fdir_input_set (port_id) "
889 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
890 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
891 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
892 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
893 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
894 "udp-dst-port|tcp-src-port|tcp-dst-port|"
895 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
897 " Set the input set for FDir.\n\n"
899 "flow validate {port_id}"
900 " [group {group_id}] [priority {level}]"
901 " [ingress] [egress]"
902 " pattern {item} [/ {item} [...]] / end"
903 " actions {action} [/ {action} [...]] / end\n"
904 " Check whether a flow rule can be created.\n\n"
906 "flow create {port_id}"
907 " [group {group_id}] [priority {level}]"
908 " [ingress] [egress]"
909 " pattern {item} [/ {item} [...]] / end"
910 " actions {action} [/ {action} [...]] / end\n"
911 " Create a flow rule.\n\n"
913 "flow destroy {port_id} rule {rule_id} [...]\n"
914 " Destroy specific flow rules.\n\n"
916 "flow flush {port_id}\n"
917 " Destroy all flow rules.\n\n"
919 "flow query {port_id} {rule_id} {action}\n"
920 " Query an existing flow rule.\n\n"
922 "flow list {port_id} [group {group_id}] [...]\n"
923 " List existing flow rules sorted by priority,"
924 " filtered by group identifiers.\n\n"
926 "flow isolate {port_id} {boolean}\n"
927 " Restrict ingress traffic to the defined"
933 cmdline_parse_token_string_t cmd_help_long_help =
934 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
936 cmdline_parse_token_string_t cmd_help_long_section =
937 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
938 "all#control#display#config#"
939 "ports#registers#filters");
941 cmdline_parse_inst_t cmd_help_long = {
942 .f = cmd_help_long_parsed,
944 .help_str = "help all|control|display|config|ports|register|filters: "
947 (void *)&cmd_help_long_help,
948 (void *)&cmd_help_long_section,
954 /* *** start/stop/close all ports *** */
955 struct cmd_operate_port_result {
956 cmdline_fixed_string_t keyword;
957 cmdline_fixed_string_t name;
958 cmdline_fixed_string_t value;
961 static void cmd_operate_port_parsed(void *parsed_result,
962 __attribute__((unused)) struct cmdline *cl,
963 __attribute__((unused)) void *data)
965 struct cmd_operate_port_result *res = parsed_result;
967 if (!strcmp(res->name, "start"))
968 start_port(RTE_PORT_ALL);
969 else if (!strcmp(res->name, "stop"))
970 stop_port(RTE_PORT_ALL);
971 else if (!strcmp(res->name, "close"))
972 close_port(RTE_PORT_ALL);
974 printf("Unknown parameter\n");
977 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
978 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
980 cmdline_parse_token_string_t cmd_operate_port_all_port =
981 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
983 cmdline_parse_token_string_t cmd_operate_port_all_all =
984 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
986 cmdline_parse_inst_t cmd_operate_port = {
987 .f = cmd_operate_port_parsed,
989 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
991 (void *)&cmd_operate_port_all_cmd,
992 (void *)&cmd_operate_port_all_port,
993 (void *)&cmd_operate_port_all_all,
998 /* *** start/stop/close specific port *** */
999 struct cmd_operate_specific_port_result {
1000 cmdline_fixed_string_t keyword;
1001 cmdline_fixed_string_t name;
1005 static void cmd_operate_specific_port_parsed(void *parsed_result,
1006 __attribute__((unused)) struct cmdline *cl,
1007 __attribute__((unused)) void *data)
1009 struct cmd_operate_specific_port_result *res = parsed_result;
1011 if (!strcmp(res->name, "start"))
1012 start_port(res->value);
1013 else if (!strcmp(res->name, "stop"))
1014 stop_port(res->value);
1015 else if (!strcmp(res->name, "close"))
1016 close_port(res->value);
1018 printf("Unknown parameter\n");
1021 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1022 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1024 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1025 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1026 name, "start#stop#close");
1027 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1028 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1031 cmdline_parse_inst_t cmd_operate_specific_port = {
1032 .f = cmd_operate_specific_port_parsed,
1034 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
1036 (void *)&cmd_operate_specific_port_cmd,
1037 (void *)&cmd_operate_specific_port_port,
1038 (void *)&cmd_operate_specific_port_id,
1043 /* *** attach a specified port *** */
1044 struct cmd_operate_attach_port_result {
1045 cmdline_fixed_string_t port;
1046 cmdline_fixed_string_t keyword;
1047 cmdline_fixed_string_t identifier;
1050 static void cmd_operate_attach_port_parsed(void *parsed_result,
1051 __attribute__((unused)) struct cmdline *cl,
1052 __attribute__((unused)) void *data)
1054 struct cmd_operate_attach_port_result *res = parsed_result;
1056 if (!strcmp(res->keyword, "attach"))
1057 attach_port(res->identifier);
1059 printf("Unknown parameter\n");
1062 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1063 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1065 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1066 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1068 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1069 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1072 cmdline_parse_inst_t cmd_operate_attach_port = {
1073 .f = cmd_operate_attach_port_parsed,
1075 .help_str = "port attach <identifier>: "
1076 "(identifier: pci address or virtual dev name)",
1078 (void *)&cmd_operate_attach_port_port,
1079 (void *)&cmd_operate_attach_port_keyword,
1080 (void *)&cmd_operate_attach_port_identifier,
1085 /* *** detach a specified port *** */
1086 struct cmd_operate_detach_port_result {
1087 cmdline_fixed_string_t port;
1088 cmdline_fixed_string_t keyword;
1092 static void cmd_operate_detach_port_parsed(void *parsed_result,
1093 __attribute__((unused)) struct cmdline *cl,
1094 __attribute__((unused)) void *data)
1096 struct cmd_operate_detach_port_result *res = parsed_result;
1098 if (!strcmp(res->keyword, "detach"))
1099 detach_port(res->port_id);
1101 printf("Unknown parameter\n");
1104 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1105 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1107 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1108 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1110 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1111 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1114 cmdline_parse_inst_t cmd_operate_detach_port = {
1115 .f = cmd_operate_detach_port_parsed,
1117 .help_str = "port detach <port_id>",
1119 (void *)&cmd_operate_detach_port_port,
1120 (void *)&cmd_operate_detach_port_keyword,
1121 (void *)&cmd_operate_detach_port_port_id,
1126 /* *** configure speed for all ports *** */
1127 struct cmd_config_speed_all {
1128 cmdline_fixed_string_t port;
1129 cmdline_fixed_string_t keyword;
1130 cmdline_fixed_string_t all;
1131 cmdline_fixed_string_t item1;
1132 cmdline_fixed_string_t item2;
1133 cmdline_fixed_string_t value1;
1134 cmdline_fixed_string_t value2;
1138 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1143 if (!strcmp(duplexstr, "half")) {
1144 duplex = ETH_LINK_HALF_DUPLEX;
1145 } else if (!strcmp(duplexstr, "full")) {
1146 duplex = ETH_LINK_FULL_DUPLEX;
1147 } else if (!strcmp(duplexstr, "auto")) {
1148 duplex = ETH_LINK_FULL_DUPLEX;
1150 printf("Unknown duplex parameter\n");
1154 if (!strcmp(speedstr, "10")) {
1155 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1156 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1157 } else if (!strcmp(speedstr, "100")) {
1158 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1159 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1161 if (duplex != ETH_LINK_FULL_DUPLEX) {
1162 printf("Invalid speed/duplex parameters\n");
1165 if (!strcmp(speedstr, "1000")) {
1166 *speed = ETH_LINK_SPEED_1G;
1167 } else if (!strcmp(speedstr, "10000")) {
1168 *speed = ETH_LINK_SPEED_10G;
1169 } else if (!strcmp(speedstr, "25000")) {
1170 *speed = ETH_LINK_SPEED_25G;
1171 } else if (!strcmp(speedstr, "40000")) {
1172 *speed = ETH_LINK_SPEED_40G;
1173 } else if (!strcmp(speedstr, "50000")) {
1174 *speed = ETH_LINK_SPEED_50G;
1175 } else if (!strcmp(speedstr, "100000")) {
1176 *speed = ETH_LINK_SPEED_100G;
1177 } else if (!strcmp(speedstr, "auto")) {
1178 *speed = ETH_LINK_SPEED_AUTONEG;
1180 printf("Unknown speed parameter\n");
1189 cmd_config_speed_all_parsed(void *parsed_result,
1190 __attribute__((unused)) struct cmdline *cl,
1191 __attribute__((unused)) void *data)
1193 struct cmd_config_speed_all *res = parsed_result;
1194 uint32_t link_speed;
1197 if (!all_ports_stopped()) {
1198 printf("Please stop all ports first\n");
1202 if (parse_and_check_speed_duplex(res->value1, res->value2,
1206 RTE_ETH_FOREACH_DEV(pid) {
1207 ports[pid].dev_conf.link_speeds = link_speed;
1210 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1213 cmdline_parse_token_string_t cmd_config_speed_all_port =
1214 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1215 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1216 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1218 cmdline_parse_token_string_t cmd_config_speed_all_all =
1219 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1220 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1221 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1222 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1223 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1224 "10#100#1000#10000#25000#40000#50000#100000#auto");
1225 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1226 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1227 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1228 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1231 cmdline_parse_inst_t cmd_config_speed_all = {
1232 .f = cmd_config_speed_all_parsed,
1234 .help_str = "port config all speed "
1235 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1238 (void *)&cmd_config_speed_all_port,
1239 (void *)&cmd_config_speed_all_keyword,
1240 (void *)&cmd_config_speed_all_all,
1241 (void *)&cmd_config_speed_all_item1,
1242 (void *)&cmd_config_speed_all_value1,
1243 (void *)&cmd_config_speed_all_item2,
1244 (void *)&cmd_config_speed_all_value2,
1249 /* *** configure speed for specific port *** */
1250 struct cmd_config_speed_specific {
1251 cmdline_fixed_string_t port;
1252 cmdline_fixed_string_t keyword;
1254 cmdline_fixed_string_t item1;
1255 cmdline_fixed_string_t item2;
1256 cmdline_fixed_string_t value1;
1257 cmdline_fixed_string_t value2;
1261 cmd_config_speed_specific_parsed(void *parsed_result,
1262 __attribute__((unused)) struct cmdline *cl,
1263 __attribute__((unused)) void *data)
1265 struct cmd_config_speed_specific *res = parsed_result;
1266 uint32_t link_speed;
1268 if (!all_ports_stopped()) {
1269 printf("Please stop all ports first\n");
1273 if (port_id_is_invalid(res->id, ENABLED_WARN))
1276 if (parse_and_check_speed_duplex(res->value1, res->value2,
1280 ports[res->id].dev_conf.link_speeds = link_speed;
1282 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1286 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1287 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1289 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1290 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1292 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1293 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1294 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1295 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1297 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1298 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1299 "10#100#1000#10000#25000#40000#50000#100000#auto");
1300 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1301 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1303 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1304 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1307 cmdline_parse_inst_t cmd_config_speed_specific = {
1308 .f = cmd_config_speed_specific_parsed,
1310 .help_str = "port config <port_id> speed "
1311 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1314 (void *)&cmd_config_speed_specific_port,
1315 (void *)&cmd_config_speed_specific_keyword,
1316 (void *)&cmd_config_speed_specific_id,
1317 (void *)&cmd_config_speed_specific_item1,
1318 (void *)&cmd_config_speed_specific_value1,
1319 (void *)&cmd_config_speed_specific_item2,
1320 (void *)&cmd_config_speed_specific_value2,
1325 /* *** configure txq/rxq, txd/rxd *** */
1326 struct cmd_config_rx_tx {
1327 cmdline_fixed_string_t port;
1328 cmdline_fixed_string_t keyword;
1329 cmdline_fixed_string_t all;
1330 cmdline_fixed_string_t name;
1335 cmd_config_rx_tx_parsed(void *parsed_result,
1336 __attribute__((unused)) struct cmdline *cl,
1337 __attribute__((unused)) void *data)
1339 struct cmd_config_rx_tx *res = parsed_result;
1341 if (!all_ports_stopped()) {
1342 printf("Please stop all ports first\n");
1345 if (!strcmp(res->name, "rxq")) {
1346 if (!res->value && !nb_txq) {
1347 printf("Warning: Either rx or tx queues should be non zero\n");
1350 nb_rxq = res->value;
1352 else if (!strcmp(res->name, "txq")) {
1353 if (!res->value && !nb_rxq) {
1354 printf("Warning: Either rx or tx queues should be non zero\n");
1357 nb_txq = res->value;
1359 else if (!strcmp(res->name, "rxd")) {
1360 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1361 printf("rxd %d invalid - must be > 0 && <= %d\n",
1362 res->value, RTE_TEST_RX_DESC_MAX);
1365 nb_rxd = res->value;
1366 } else if (!strcmp(res->name, "txd")) {
1367 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1368 printf("txd %d invalid - must be > 0 && <= %d\n",
1369 res->value, RTE_TEST_TX_DESC_MAX);
1372 nb_txd = res->value;
1374 printf("Unknown parameter\n");
1382 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1385 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1386 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1387 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1388 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1389 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1390 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1391 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1394 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1395 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1397 cmdline_parse_inst_t cmd_config_rx_tx = {
1398 .f = cmd_config_rx_tx_parsed,
1400 .help_str = "port config all rxq|txq|rxd|txd <value>",
1402 (void *)&cmd_config_rx_tx_port,
1403 (void *)&cmd_config_rx_tx_keyword,
1404 (void *)&cmd_config_rx_tx_all,
1405 (void *)&cmd_config_rx_tx_name,
1406 (void *)&cmd_config_rx_tx_value,
1411 /* *** config max packet length *** */
1412 struct cmd_config_max_pkt_len_result {
1413 cmdline_fixed_string_t port;
1414 cmdline_fixed_string_t keyword;
1415 cmdline_fixed_string_t all;
1416 cmdline_fixed_string_t name;
1421 cmd_config_max_pkt_len_parsed(void *parsed_result,
1422 __attribute__((unused)) struct cmdline *cl,
1423 __attribute__((unused)) void *data)
1425 struct cmd_config_max_pkt_len_result *res = parsed_result;
1427 if (!all_ports_stopped()) {
1428 printf("Please stop all ports first\n");
1432 if (!strcmp(res->name, "max-pkt-len")) {
1433 if (res->value < ETHER_MIN_LEN) {
1434 printf("max-pkt-len can not be less than %d\n",
1438 if (res->value == rx_mode.max_rx_pkt_len)
1441 rx_mode.max_rx_pkt_len = res->value;
1442 if (res->value > ETHER_MAX_LEN)
1443 rx_mode.jumbo_frame = 1;
1445 rx_mode.jumbo_frame = 0;
1447 printf("Unknown parameter\n");
1453 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1456 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1457 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1459 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1460 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1462 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1463 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1465 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1468 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1469 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1472 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1473 .f = cmd_config_max_pkt_len_parsed,
1475 .help_str = "port config all max-pkt-len <value>",
1477 (void *)&cmd_config_max_pkt_len_port,
1478 (void *)&cmd_config_max_pkt_len_keyword,
1479 (void *)&cmd_config_max_pkt_len_all,
1480 (void *)&cmd_config_max_pkt_len_name,
1481 (void *)&cmd_config_max_pkt_len_value,
1486 /* *** configure port MTU *** */
1487 struct cmd_config_mtu_result {
1488 cmdline_fixed_string_t port;
1489 cmdline_fixed_string_t keyword;
1490 cmdline_fixed_string_t mtu;
1496 cmd_config_mtu_parsed(void *parsed_result,
1497 __attribute__((unused)) struct cmdline *cl,
1498 __attribute__((unused)) void *data)
1500 struct cmd_config_mtu_result *res = parsed_result;
1502 if (res->value < ETHER_MIN_LEN) {
1503 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1506 port_mtu_set(res->port_id, res->value);
1509 cmdline_parse_token_string_t cmd_config_mtu_port =
1510 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1512 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1513 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1515 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1516 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1518 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1519 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1520 cmdline_parse_token_num_t cmd_config_mtu_value =
1521 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1523 cmdline_parse_inst_t cmd_config_mtu = {
1524 .f = cmd_config_mtu_parsed,
1526 .help_str = "port config mtu <port_id> <value>",
1528 (void *)&cmd_config_mtu_port,
1529 (void *)&cmd_config_mtu_keyword,
1530 (void *)&cmd_config_mtu_mtu,
1531 (void *)&cmd_config_mtu_port_id,
1532 (void *)&cmd_config_mtu_value,
1537 /* *** configure rx mode *** */
1538 struct cmd_config_rx_mode_flag {
1539 cmdline_fixed_string_t port;
1540 cmdline_fixed_string_t keyword;
1541 cmdline_fixed_string_t all;
1542 cmdline_fixed_string_t name;
1543 cmdline_fixed_string_t value;
1547 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1548 __attribute__((unused)) struct cmdline *cl,
1549 __attribute__((unused)) void *data)
1551 struct cmd_config_rx_mode_flag *res = parsed_result;
1553 if (!all_ports_stopped()) {
1554 printf("Please stop all ports first\n");
1558 if (!strcmp(res->name, "crc-strip")) {
1559 if (!strcmp(res->value, "on"))
1560 rx_mode.hw_strip_crc = 1;
1561 else if (!strcmp(res->value, "off"))
1562 rx_mode.hw_strip_crc = 0;
1564 printf("Unknown parameter\n");
1567 } else if (!strcmp(res->name, "scatter")) {
1568 if (!strcmp(res->value, "on"))
1569 rx_mode.enable_scatter = 1;
1570 else if (!strcmp(res->value, "off"))
1571 rx_mode.enable_scatter = 0;
1573 printf("Unknown parameter\n");
1576 } else if (!strcmp(res->name, "rx-cksum")) {
1577 if (!strcmp(res->value, "on"))
1578 rx_mode.hw_ip_checksum = 1;
1579 else if (!strcmp(res->value, "off"))
1580 rx_mode.hw_ip_checksum = 0;
1582 printf("Unknown parameter\n");
1585 } else if (!strcmp(res->name, "hw-vlan")) {
1586 if (!strcmp(res->value, "on")) {
1587 rx_mode.hw_vlan_filter = 1;
1588 rx_mode.hw_vlan_strip = 1;
1590 else if (!strcmp(res->value, "off")) {
1591 rx_mode.hw_vlan_filter = 0;
1592 rx_mode.hw_vlan_strip = 0;
1595 printf("Unknown parameter\n");
1598 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1599 if (!strcmp(res->value, "on"))
1600 rx_mode.hw_vlan_filter = 1;
1601 else if (!strcmp(res->value, "off"))
1602 rx_mode.hw_vlan_filter = 0;
1604 printf("Unknown parameter\n");
1607 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1608 if (!strcmp(res->value, "on"))
1609 rx_mode.hw_vlan_strip = 1;
1610 else if (!strcmp(res->value, "off"))
1611 rx_mode.hw_vlan_strip = 0;
1613 printf("Unknown parameter\n");
1616 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1617 if (!strcmp(res->value, "on"))
1618 rx_mode.hw_vlan_extend = 1;
1619 else if (!strcmp(res->value, "off"))
1620 rx_mode.hw_vlan_extend = 0;
1622 printf("Unknown parameter\n");
1625 } else if (!strcmp(res->name, "drop-en")) {
1626 if (!strcmp(res->value, "on"))
1628 else if (!strcmp(res->value, "off"))
1631 printf("Unknown parameter\n");
1635 printf("Unknown parameter\n");
1641 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1644 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1645 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1646 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1647 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1649 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1651 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1652 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1653 "crc-strip#scatter#rx-cksum#hw-vlan#"
1654 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1655 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1659 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1660 .f = cmd_config_rx_mode_flag_parsed,
1662 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1663 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1665 (void *)&cmd_config_rx_mode_flag_port,
1666 (void *)&cmd_config_rx_mode_flag_keyword,
1667 (void *)&cmd_config_rx_mode_flag_all,
1668 (void *)&cmd_config_rx_mode_flag_name,
1669 (void *)&cmd_config_rx_mode_flag_value,
1674 /* *** configure rss *** */
1675 struct cmd_config_rss {
1676 cmdline_fixed_string_t port;
1677 cmdline_fixed_string_t keyword;
1678 cmdline_fixed_string_t all;
1679 cmdline_fixed_string_t name;
1680 cmdline_fixed_string_t value;
1684 cmd_config_rss_parsed(void *parsed_result,
1685 __attribute__((unused)) struct cmdline *cl,
1686 __attribute__((unused)) void *data)
1688 struct cmd_config_rss *res = parsed_result;
1689 struct rte_eth_rss_conf rss_conf;
1693 if (!strcmp(res->value, "all"))
1694 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1695 ETH_RSS_UDP | ETH_RSS_SCTP |
1697 else if (!strcmp(res->value, "ip"))
1698 rss_conf.rss_hf = ETH_RSS_IP;
1699 else if (!strcmp(res->value, "udp"))
1700 rss_conf.rss_hf = ETH_RSS_UDP;
1701 else if (!strcmp(res->value, "tcp"))
1702 rss_conf.rss_hf = ETH_RSS_TCP;
1703 else if (!strcmp(res->value, "sctp"))
1704 rss_conf.rss_hf = ETH_RSS_SCTP;
1705 else if (!strcmp(res->value, "ether"))
1706 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1707 else if (!strcmp(res->value, "port"))
1708 rss_conf.rss_hf = ETH_RSS_PORT;
1709 else if (!strcmp(res->value, "vxlan"))
1710 rss_conf.rss_hf = ETH_RSS_VXLAN;
1711 else if (!strcmp(res->value, "geneve"))
1712 rss_conf.rss_hf = ETH_RSS_GENEVE;
1713 else if (!strcmp(res->value, "nvgre"))
1714 rss_conf.rss_hf = ETH_RSS_NVGRE;
1715 else if (!strcmp(res->value, "none"))
1716 rss_conf.rss_hf = 0;
1718 printf("Unknown parameter\n");
1721 rss_conf.rss_key = NULL;
1722 for (i = 0; i < rte_eth_dev_count(); i++) {
1723 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1725 printf("Configuration of RSS hash at ethernet port %d "
1726 "failed with error (%d): %s.\n",
1727 i, -diag, strerror(-diag));
1731 cmdline_parse_token_string_t cmd_config_rss_port =
1732 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1733 cmdline_parse_token_string_t cmd_config_rss_keyword =
1734 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1735 cmdline_parse_token_string_t cmd_config_rss_all =
1736 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1737 cmdline_parse_token_string_t cmd_config_rss_name =
1738 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1739 cmdline_parse_token_string_t cmd_config_rss_value =
1740 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1741 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1743 cmdline_parse_inst_t cmd_config_rss = {
1744 .f = cmd_config_rss_parsed,
1746 .help_str = "port config all rss "
1747 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1749 (void *)&cmd_config_rss_port,
1750 (void *)&cmd_config_rss_keyword,
1751 (void *)&cmd_config_rss_all,
1752 (void *)&cmd_config_rss_name,
1753 (void *)&cmd_config_rss_value,
1758 /* *** configure rss hash key *** */
1759 struct cmd_config_rss_hash_key {
1760 cmdline_fixed_string_t port;
1761 cmdline_fixed_string_t config;
1763 cmdline_fixed_string_t rss_hash_key;
1764 cmdline_fixed_string_t rss_type;
1765 cmdline_fixed_string_t key;
1769 hexa_digit_to_value(char hexa_digit)
1771 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1772 return (uint8_t) (hexa_digit - '0');
1773 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1774 return (uint8_t) ((hexa_digit - 'a') + 10);
1775 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1776 return (uint8_t) ((hexa_digit - 'A') + 10);
1777 /* Invalid hexa digit */
1782 parse_and_check_key_hexa_digit(char *key, int idx)
1786 hexa_v = hexa_digit_to_value(key[idx]);
1788 printf("invalid key: character %c at position %d is not a "
1789 "valid hexa digit\n", key[idx], idx);
1794 cmd_config_rss_hash_key_parsed(void *parsed_result,
1795 __attribute__((unused)) struct cmdline *cl,
1796 __attribute__((unused)) void *data)
1798 struct cmd_config_rss_hash_key *res = parsed_result;
1799 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1803 struct rte_eth_dev_info dev_info;
1804 uint8_t hash_key_size;
1807 memset(&dev_info, 0, sizeof(dev_info));
1808 rte_eth_dev_info_get(res->port_id, &dev_info);
1809 if (dev_info.hash_key_size > 0 &&
1810 dev_info.hash_key_size <= sizeof(hash_key))
1811 hash_key_size = dev_info.hash_key_size;
1813 printf("dev_info did not provide a valid hash key size\n");
1816 /* Check the length of the RSS hash key */
1817 key_len = strlen(res->key);
1818 if (key_len != (hash_key_size * 2)) {
1819 printf("key length: %d invalid - key must be a string of %d"
1820 " hexa-decimal numbers\n",
1821 (int) key_len, hash_key_size * 2);
1824 /* Translate RSS hash key into binary representation */
1825 for (i = 0; i < hash_key_size; i++) {
1826 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1829 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1832 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1834 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1838 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1839 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1840 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1841 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1843 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1844 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1845 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1846 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1847 rss_hash_key, "rss-hash-key");
1848 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1849 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1850 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1851 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1852 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1853 "ipv6-tcp-ex#ipv6-udp-ex");
1854 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1857 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1858 .f = cmd_config_rss_hash_key_parsed,
1860 .help_str = "port config <port_id> rss-hash-key "
1861 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1862 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1863 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1864 "<string of hex digits (variable length, NIC dependent)>",
1866 (void *)&cmd_config_rss_hash_key_port,
1867 (void *)&cmd_config_rss_hash_key_config,
1868 (void *)&cmd_config_rss_hash_key_port_id,
1869 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1870 (void *)&cmd_config_rss_hash_key_rss_type,
1871 (void *)&cmd_config_rss_hash_key_value,
1876 /* *** configure port rxq/txq start/stop *** */
1877 struct cmd_config_rxtx_queue {
1878 cmdline_fixed_string_t port;
1880 cmdline_fixed_string_t rxtxq;
1882 cmdline_fixed_string_t opname;
1886 cmd_config_rxtx_queue_parsed(void *parsed_result,
1887 __attribute__((unused)) struct cmdline *cl,
1888 __attribute__((unused)) void *data)
1890 struct cmd_config_rxtx_queue *res = parsed_result;
1895 if (test_done == 0) {
1896 printf("Please stop forwarding first\n");
1900 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1903 if (port_is_started(res->portid) != 1) {
1904 printf("Please start port %u first\n", res->portid);
1908 if (!strcmp(res->rxtxq, "rxq"))
1910 else if (!strcmp(res->rxtxq, "txq"))
1913 printf("Unknown parameter\n");
1917 if (isrx && rx_queue_id_is_invalid(res->qid))
1919 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1922 if (!strcmp(res->opname, "start"))
1924 else if (!strcmp(res->opname, "stop"))
1927 printf("Unknown parameter\n");
1931 if (isstart && isrx)
1932 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1933 else if (!isstart && isrx)
1934 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1935 else if (isstart && !isrx)
1936 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1938 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1940 if (ret == -ENOTSUP)
1941 printf("Function not supported in PMD driver\n");
1944 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1945 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1946 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1947 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1948 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1949 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1950 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1951 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1952 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1953 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1956 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1957 .f = cmd_config_rxtx_queue_parsed,
1959 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1961 (void *)&cmd_config_speed_all_port,
1962 (void *)&cmd_config_rxtx_queue_portid,
1963 (void *)&cmd_config_rxtx_queue_rxtxq,
1964 (void *)&cmd_config_rxtx_queue_qid,
1965 (void *)&cmd_config_rxtx_queue_opname,
1970 /* *** Configure RSS RETA *** */
1971 struct cmd_config_rss_reta {
1972 cmdline_fixed_string_t port;
1973 cmdline_fixed_string_t keyword;
1975 cmdline_fixed_string_t name;
1976 cmdline_fixed_string_t list_name;
1977 cmdline_fixed_string_t list_of_items;
1981 parse_reta_config(const char *str,
1982 struct rte_eth_rss_reta_entry64 *reta_conf,
1983 uint16_t nb_entries)
1987 uint16_t hash_index, idx, shift;
1990 const char *p, *p0 = str;
1997 unsigned long int_fld[_NUM_FLD];
1998 char *str_fld[_NUM_FLD];
2000 while ((p = strchr(p0,'(')) != NULL) {
2002 if((p0 = strchr(p,')')) == NULL)
2006 if(size >= sizeof(s))
2009 snprintf(s, sizeof(s), "%.*s", size, p);
2010 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2012 for (i = 0; i < _NUM_FLD; i++) {
2014 int_fld[i] = strtoul(str_fld[i], &end, 0);
2015 if (errno != 0 || end == str_fld[i] ||
2020 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2021 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2023 if (hash_index >= nb_entries) {
2024 printf("Invalid RETA hash index=%d\n", hash_index);
2028 idx = hash_index / RTE_RETA_GROUP_SIZE;
2029 shift = hash_index % RTE_RETA_GROUP_SIZE;
2030 reta_conf[idx].mask |= (1ULL << shift);
2031 reta_conf[idx].reta[shift] = nb_queue;
2038 cmd_set_rss_reta_parsed(void *parsed_result,
2039 __attribute__((unused)) struct cmdline *cl,
2040 __attribute__((unused)) void *data)
2043 struct rte_eth_dev_info dev_info;
2044 struct rte_eth_rss_reta_entry64 reta_conf[8];
2045 struct cmd_config_rss_reta *res = parsed_result;
2047 memset(&dev_info, 0, sizeof(dev_info));
2048 rte_eth_dev_info_get(res->port_id, &dev_info);
2049 if (dev_info.reta_size == 0) {
2050 printf("Redirection table size is 0 which is "
2051 "invalid for RSS\n");
2054 printf("The reta size of port %d is %u\n",
2055 res->port_id, dev_info.reta_size);
2056 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2057 printf("Currently do not support more than %u entries of "
2058 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2062 memset(reta_conf, 0, sizeof(reta_conf));
2063 if (!strcmp(res->list_name, "reta")) {
2064 if (parse_reta_config(res->list_of_items, reta_conf,
2065 dev_info.reta_size)) {
2066 printf("Invalid RSS Redirection Table "
2067 "config entered\n");
2070 ret = rte_eth_dev_rss_reta_update(res->port_id,
2071 reta_conf, dev_info.reta_size);
2073 printf("Bad redirection table parameter, "
2074 "return code = %d \n", ret);
2078 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2079 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2080 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2081 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2082 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2083 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2084 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2085 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2086 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2087 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2088 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2089 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2091 cmdline_parse_inst_t cmd_config_rss_reta = {
2092 .f = cmd_set_rss_reta_parsed,
2094 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2096 (void *)&cmd_config_rss_reta_port,
2097 (void *)&cmd_config_rss_reta_keyword,
2098 (void *)&cmd_config_rss_reta_port_id,
2099 (void *)&cmd_config_rss_reta_name,
2100 (void *)&cmd_config_rss_reta_list_name,
2101 (void *)&cmd_config_rss_reta_list_of_items,
2106 /* *** SHOW PORT RETA INFO *** */
2107 struct cmd_showport_reta {
2108 cmdline_fixed_string_t show;
2109 cmdline_fixed_string_t port;
2111 cmdline_fixed_string_t rss;
2112 cmdline_fixed_string_t reta;
2114 cmdline_fixed_string_t list_of_items;
2118 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2119 uint16_t nb_entries,
2123 const char *p, *p0 = str;
2128 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2129 RTE_RETA_GROUP_SIZE;
2132 p = strchr(p0, '(');
2136 p0 = strchr(p, ')');
2140 if (size >= sizeof(s)) {
2141 printf("The string size exceeds the internal buffer size\n");
2144 snprintf(s, sizeof(s), "%.*s", size, p);
2145 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2146 if (ret <= 0 || ret != num) {
2147 printf("The bits of masks do not match the number of "
2148 "reta entries: %u\n", num);
2151 for (i = 0; i < ret; i++)
2152 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2158 cmd_showport_reta_parsed(void *parsed_result,
2159 __attribute__((unused)) struct cmdline *cl,
2160 __attribute__((unused)) void *data)
2162 struct cmd_showport_reta *res = parsed_result;
2163 struct rte_eth_rss_reta_entry64 reta_conf[8];
2164 struct rte_eth_dev_info dev_info;
2166 memset(&dev_info, 0, sizeof(dev_info));
2167 rte_eth_dev_info_get(res->port_id, &dev_info);
2168 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2169 res->size > ETH_RSS_RETA_SIZE_512) {
2170 printf("Invalid redirection table size: %u\n", res->size);
2174 memset(reta_conf, 0, sizeof(reta_conf));
2175 if (showport_parse_reta_config(reta_conf, res->size,
2176 res->list_of_items) < 0) {
2177 printf("Invalid string: %s for reta masks\n",
2178 res->list_of_items);
2181 port_rss_reta_info(res->port_id, reta_conf, res->size);
2184 cmdline_parse_token_string_t cmd_showport_reta_show =
2185 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2186 cmdline_parse_token_string_t cmd_showport_reta_port =
2187 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2188 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2189 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2190 cmdline_parse_token_string_t cmd_showport_reta_rss =
2191 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2192 cmdline_parse_token_string_t cmd_showport_reta_reta =
2193 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2194 cmdline_parse_token_num_t cmd_showport_reta_size =
2195 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2196 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2197 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2198 list_of_items, NULL);
2200 cmdline_parse_inst_t cmd_showport_reta = {
2201 .f = cmd_showport_reta_parsed,
2203 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2205 (void *)&cmd_showport_reta_show,
2206 (void *)&cmd_showport_reta_port,
2207 (void *)&cmd_showport_reta_port_id,
2208 (void *)&cmd_showport_reta_rss,
2209 (void *)&cmd_showport_reta_reta,
2210 (void *)&cmd_showport_reta_size,
2211 (void *)&cmd_showport_reta_list_of_items,
2216 /* *** Show RSS hash configuration *** */
2217 struct cmd_showport_rss_hash {
2218 cmdline_fixed_string_t show;
2219 cmdline_fixed_string_t port;
2221 cmdline_fixed_string_t rss_hash;
2222 cmdline_fixed_string_t rss_type;
2223 cmdline_fixed_string_t key; /* optional argument */
2226 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2227 __attribute__((unused)) struct cmdline *cl,
2230 struct cmd_showport_rss_hash *res = parsed_result;
2232 port_rss_hash_conf_show(res->port_id, res->rss_type,
2233 show_rss_key != NULL);
2236 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2237 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2238 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2239 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2240 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2241 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2242 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2243 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2245 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2246 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2247 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2248 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2249 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2250 "ipv6-tcp-ex#ipv6-udp-ex");
2251 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2252 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2254 cmdline_parse_inst_t cmd_showport_rss_hash = {
2255 .f = cmd_showport_rss_hash_parsed,
2257 .help_str = "show port <port_id> rss-hash "
2258 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2259 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2260 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2262 (void *)&cmd_showport_rss_hash_show,
2263 (void *)&cmd_showport_rss_hash_port,
2264 (void *)&cmd_showport_rss_hash_port_id,
2265 (void *)&cmd_showport_rss_hash_rss_hash,
2266 (void *)&cmd_showport_rss_hash_rss_hash_info,
2271 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2272 .f = cmd_showport_rss_hash_parsed,
2274 .help_str = "show port <port_id> rss-hash "
2275 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2276 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2277 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2279 (void *)&cmd_showport_rss_hash_show,
2280 (void *)&cmd_showport_rss_hash_port,
2281 (void *)&cmd_showport_rss_hash_port_id,
2282 (void *)&cmd_showport_rss_hash_rss_hash,
2283 (void *)&cmd_showport_rss_hash_rss_hash_info,
2284 (void *)&cmd_showport_rss_hash_rss_key,
2289 /* *** Configure DCB *** */
2290 struct cmd_config_dcb {
2291 cmdline_fixed_string_t port;
2292 cmdline_fixed_string_t config;
2294 cmdline_fixed_string_t dcb;
2295 cmdline_fixed_string_t vt;
2296 cmdline_fixed_string_t vt_en;
2298 cmdline_fixed_string_t pfc;
2299 cmdline_fixed_string_t pfc_en;
2303 cmd_config_dcb_parsed(void *parsed_result,
2304 __attribute__((unused)) struct cmdline *cl,
2305 __attribute__((unused)) void *data)
2307 struct cmd_config_dcb *res = parsed_result;
2308 portid_t port_id = res->port_id;
2309 struct rte_port *port;
2313 port = &ports[port_id];
2314 /** Check if the port is not started **/
2315 if (port->port_status != RTE_PORT_STOPPED) {
2316 printf("Please stop port %d first\n", port_id);
2320 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2321 printf("The invalid number of traffic class,"
2322 " only 4 or 8 allowed.\n");
2326 if (nb_fwd_lcores < res->num_tcs) {
2327 printf("nb_cores shouldn't be less than number of TCs.\n");
2330 if (!strncmp(res->pfc_en, "on", 2))
2335 /* DCB in VT mode */
2336 if (!strncmp(res->vt_en, "on", 2))
2337 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2338 (enum rte_eth_nb_tcs)res->num_tcs,
2341 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2342 (enum rte_eth_nb_tcs)res->num_tcs,
2347 printf("Cannot initialize network ports.\n");
2351 cmd_reconfig_device_queue(port_id, 1, 1);
2354 cmdline_parse_token_string_t cmd_config_dcb_port =
2355 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2356 cmdline_parse_token_string_t cmd_config_dcb_config =
2357 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2358 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2359 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2360 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2361 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2362 cmdline_parse_token_string_t cmd_config_dcb_vt =
2363 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2364 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2365 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2366 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2367 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2368 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2369 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2370 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2371 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2373 cmdline_parse_inst_t cmd_config_dcb = {
2374 .f = cmd_config_dcb_parsed,
2376 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2378 (void *)&cmd_config_dcb_port,
2379 (void *)&cmd_config_dcb_config,
2380 (void *)&cmd_config_dcb_port_id,
2381 (void *)&cmd_config_dcb_dcb,
2382 (void *)&cmd_config_dcb_vt,
2383 (void *)&cmd_config_dcb_vt_en,
2384 (void *)&cmd_config_dcb_num_tcs,
2385 (void *)&cmd_config_dcb_pfc,
2386 (void *)&cmd_config_dcb_pfc_en,
2391 /* *** configure number of packets per burst *** */
2392 struct cmd_config_burst {
2393 cmdline_fixed_string_t port;
2394 cmdline_fixed_string_t keyword;
2395 cmdline_fixed_string_t all;
2396 cmdline_fixed_string_t name;
2401 cmd_config_burst_parsed(void *parsed_result,
2402 __attribute__((unused)) struct cmdline *cl,
2403 __attribute__((unused)) void *data)
2405 struct cmd_config_burst *res = parsed_result;
2407 if (!all_ports_stopped()) {
2408 printf("Please stop all ports first\n");
2412 if (!strcmp(res->name, "burst")) {
2413 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2414 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2417 nb_pkt_per_burst = res->value;
2419 printf("Unknown parameter\n");
2425 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2428 cmdline_parse_token_string_t cmd_config_burst_port =
2429 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2430 cmdline_parse_token_string_t cmd_config_burst_keyword =
2431 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2432 cmdline_parse_token_string_t cmd_config_burst_all =
2433 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2434 cmdline_parse_token_string_t cmd_config_burst_name =
2435 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2436 cmdline_parse_token_num_t cmd_config_burst_value =
2437 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2439 cmdline_parse_inst_t cmd_config_burst = {
2440 .f = cmd_config_burst_parsed,
2442 .help_str = "port config all burst <value>",
2444 (void *)&cmd_config_burst_port,
2445 (void *)&cmd_config_burst_keyword,
2446 (void *)&cmd_config_burst_all,
2447 (void *)&cmd_config_burst_name,
2448 (void *)&cmd_config_burst_value,
2453 /* *** configure rx/tx queues *** */
2454 struct cmd_config_thresh {
2455 cmdline_fixed_string_t port;
2456 cmdline_fixed_string_t keyword;
2457 cmdline_fixed_string_t all;
2458 cmdline_fixed_string_t name;
2463 cmd_config_thresh_parsed(void *parsed_result,
2464 __attribute__((unused)) struct cmdline *cl,
2465 __attribute__((unused)) void *data)
2467 struct cmd_config_thresh *res = parsed_result;
2469 if (!all_ports_stopped()) {
2470 printf("Please stop all ports first\n");
2474 if (!strcmp(res->name, "txpt"))
2475 tx_pthresh = res->value;
2476 else if(!strcmp(res->name, "txht"))
2477 tx_hthresh = res->value;
2478 else if(!strcmp(res->name, "txwt"))
2479 tx_wthresh = res->value;
2480 else if(!strcmp(res->name, "rxpt"))
2481 rx_pthresh = res->value;
2482 else if(!strcmp(res->name, "rxht"))
2483 rx_hthresh = res->value;
2484 else if(!strcmp(res->name, "rxwt"))
2485 rx_wthresh = res->value;
2487 printf("Unknown parameter\n");
2493 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2496 cmdline_parse_token_string_t cmd_config_thresh_port =
2497 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2498 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2499 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2500 cmdline_parse_token_string_t cmd_config_thresh_all =
2501 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2502 cmdline_parse_token_string_t cmd_config_thresh_name =
2503 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2504 "txpt#txht#txwt#rxpt#rxht#rxwt");
2505 cmdline_parse_token_num_t cmd_config_thresh_value =
2506 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2508 cmdline_parse_inst_t cmd_config_thresh = {
2509 .f = cmd_config_thresh_parsed,
2511 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2513 (void *)&cmd_config_thresh_port,
2514 (void *)&cmd_config_thresh_keyword,
2515 (void *)&cmd_config_thresh_all,
2516 (void *)&cmd_config_thresh_name,
2517 (void *)&cmd_config_thresh_value,
2522 /* *** configure free/rs threshold *** */
2523 struct cmd_config_threshold {
2524 cmdline_fixed_string_t port;
2525 cmdline_fixed_string_t keyword;
2526 cmdline_fixed_string_t all;
2527 cmdline_fixed_string_t name;
2532 cmd_config_threshold_parsed(void *parsed_result,
2533 __attribute__((unused)) struct cmdline *cl,
2534 __attribute__((unused)) void *data)
2536 struct cmd_config_threshold *res = parsed_result;
2538 if (!all_ports_stopped()) {
2539 printf("Please stop all ports first\n");
2543 if (!strcmp(res->name, "txfreet"))
2544 tx_free_thresh = res->value;
2545 else if (!strcmp(res->name, "txrst"))
2546 tx_rs_thresh = res->value;
2547 else if (!strcmp(res->name, "rxfreet"))
2548 rx_free_thresh = res->value;
2550 printf("Unknown parameter\n");
2556 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2559 cmdline_parse_token_string_t cmd_config_threshold_port =
2560 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2561 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2562 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2564 cmdline_parse_token_string_t cmd_config_threshold_all =
2565 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2566 cmdline_parse_token_string_t cmd_config_threshold_name =
2567 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2568 "txfreet#txrst#rxfreet");
2569 cmdline_parse_token_num_t cmd_config_threshold_value =
2570 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2572 cmdline_parse_inst_t cmd_config_threshold = {
2573 .f = cmd_config_threshold_parsed,
2575 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2577 (void *)&cmd_config_threshold_port,
2578 (void *)&cmd_config_threshold_keyword,
2579 (void *)&cmd_config_threshold_all,
2580 (void *)&cmd_config_threshold_name,
2581 (void *)&cmd_config_threshold_value,
2587 struct cmd_stop_result {
2588 cmdline_fixed_string_t stop;
2591 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2592 __attribute__((unused)) struct cmdline *cl,
2593 __attribute__((unused)) void *data)
2595 stop_packet_forwarding();
2598 cmdline_parse_token_string_t cmd_stop_stop =
2599 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2601 cmdline_parse_inst_t cmd_stop = {
2602 .f = cmd_stop_parsed,
2604 .help_str = "stop: Stop packet forwarding",
2606 (void *)&cmd_stop_stop,
2611 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2614 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2615 unsigned int *parsed_items, int check_unique_values)
2617 unsigned int nb_item;
2625 * First parse all items in the list and store their value.
2630 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2632 if ((c >= '0') && (c <= '9')) {
2633 value = (unsigned int) (value * 10 + (c - '0'));
2638 printf("character %c is not a decimal digit\n", c);
2642 printf("No valid value before comma\n");
2645 if (nb_item < max_items) {
2646 parsed_items[nb_item] = value;
2652 if (nb_item >= max_items) {
2653 printf("Number of %s = %u > %u (maximum items)\n",
2654 item_name, nb_item + 1, max_items);
2657 parsed_items[nb_item++] = value;
2658 if (! check_unique_values)
2662 * Then, check that all values in the list are differents.
2663 * No optimization here...
2665 for (i = 0; i < nb_item; i++) {
2666 for (j = i + 1; j < nb_item; j++) {
2667 if (parsed_items[j] == parsed_items[i]) {
2668 printf("duplicated %s %u at index %u and %u\n",
2669 item_name, parsed_items[i], i, j);
2677 struct cmd_set_list_result {
2678 cmdline_fixed_string_t cmd_keyword;
2679 cmdline_fixed_string_t list_name;
2680 cmdline_fixed_string_t list_of_items;
2683 static void cmd_set_list_parsed(void *parsed_result,
2684 __attribute__((unused)) struct cmdline *cl,
2685 __attribute__((unused)) void *data)
2687 struct cmd_set_list_result *res;
2689 unsigned int lcorelist[RTE_MAX_LCORE];
2690 unsigned int portlist[RTE_MAX_ETHPORTS];
2692 unsigned int nb_item;
2694 if (test_done == 0) {
2695 printf("Please stop forwarding first\n");
2699 res = parsed_result;
2700 if (!strcmp(res->list_name, "corelist")) {
2701 nb_item = parse_item_list(res->list_of_items, "core",
2703 parsed_items.lcorelist, 1);
2705 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2710 if (!strcmp(res->list_name, "portlist")) {
2711 nb_item = parse_item_list(res->list_of_items, "port",
2713 parsed_items.portlist, 1);
2715 set_fwd_ports_list(parsed_items.portlist, nb_item);
2721 cmdline_parse_token_string_t cmd_set_list_keyword =
2722 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2724 cmdline_parse_token_string_t cmd_set_list_name =
2725 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2726 "corelist#portlist");
2727 cmdline_parse_token_string_t cmd_set_list_of_items =
2728 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2731 cmdline_parse_inst_t cmd_set_fwd_list = {
2732 .f = cmd_set_list_parsed,
2734 .help_str = "set corelist|portlist <list0[,list1]*>",
2736 (void *)&cmd_set_list_keyword,
2737 (void *)&cmd_set_list_name,
2738 (void *)&cmd_set_list_of_items,
2743 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2745 struct cmd_setmask_result {
2746 cmdline_fixed_string_t set;
2747 cmdline_fixed_string_t mask;
2751 static void cmd_set_mask_parsed(void *parsed_result,
2752 __attribute__((unused)) struct cmdline *cl,
2753 __attribute__((unused)) void *data)
2755 struct cmd_setmask_result *res = parsed_result;
2757 if (test_done == 0) {
2758 printf("Please stop forwarding first\n");
2761 if (!strcmp(res->mask, "coremask")) {
2762 set_fwd_lcores_mask(res->hexavalue);
2764 } else if (!strcmp(res->mask, "portmask")) {
2765 set_fwd_ports_mask(res->hexavalue);
2770 cmdline_parse_token_string_t cmd_setmask_set =
2771 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2772 cmdline_parse_token_string_t cmd_setmask_mask =
2773 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2774 "coremask#portmask");
2775 cmdline_parse_token_num_t cmd_setmask_value =
2776 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2778 cmdline_parse_inst_t cmd_set_fwd_mask = {
2779 .f = cmd_set_mask_parsed,
2781 .help_str = "set coremask|portmask <hexadecimal value>",
2783 (void *)&cmd_setmask_set,
2784 (void *)&cmd_setmask_mask,
2785 (void *)&cmd_setmask_value,
2791 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2793 struct cmd_set_result {
2794 cmdline_fixed_string_t set;
2795 cmdline_fixed_string_t what;
2799 static void cmd_set_parsed(void *parsed_result,
2800 __attribute__((unused)) struct cmdline *cl,
2801 __attribute__((unused)) void *data)
2803 struct cmd_set_result *res = parsed_result;
2804 if (!strcmp(res->what, "nbport")) {
2805 set_fwd_ports_number(res->value);
2807 } else if (!strcmp(res->what, "nbcore")) {
2808 set_fwd_lcores_number(res->value);
2810 } else if (!strcmp(res->what, "burst"))
2811 set_nb_pkt_per_burst(res->value);
2812 else if (!strcmp(res->what, "verbose"))
2813 set_verbose_level(res->value);
2816 cmdline_parse_token_string_t cmd_set_set =
2817 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2818 cmdline_parse_token_string_t cmd_set_what =
2819 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2820 "nbport#nbcore#burst#verbose");
2821 cmdline_parse_token_num_t cmd_set_value =
2822 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2824 cmdline_parse_inst_t cmd_set_numbers = {
2825 .f = cmd_set_parsed,
2827 .help_str = "set nbport|nbcore|burst|verbose <value>",
2829 (void *)&cmd_set_set,
2830 (void *)&cmd_set_what,
2831 (void *)&cmd_set_value,
2836 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2838 struct cmd_set_txpkts_result {
2839 cmdline_fixed_string_t cmd_keyword;
2840 cmdline_fixed_string_t txpkts;
2841 cmdline_fixed_string_t seg_lengths;
2845 cmd_set_txpkts_parsed(void *parsed_result,
2846 __attribute__((unused)) struct cmdline *cl,
2847 __attribute__((unused)) void *data)
2849 struct cmd_set_txpkts_result *res;
2850 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2851 unsigned int nb_segs;
2853 res = parsed_result;
2854 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2855 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2857 set_tx_pkt_segments(seg_lengths, nb_segs);
2860 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2861 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2862 cmd_keyword, "set");
2863 cmdline_parse_token_string_t cmd_set_txpkts_name =
2864 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2866 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2867 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2870 cmdline_parse_inst_t cmd_set_txpkts = {
2871 .f = cmd_set_txpkts_parsed,
2873 .help_str = "set txpkts <len0[,len1]*>",
2875 (void *)&cmd_set_txpkts_keyword,
2876 (void *)&cmd_set_txpkts_name,
2877 (void *)&cmd_set_txpkts_lengths,
2882 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2884 struct cmd_set_txsplit_result {
2885 cmdline_fixed_string_t cmd_keyword;
2886 cmdline_fixed_string_t txsplit;
2887 cmdline_fixed_string_t mode;
2891 cmd_set_txsplit_parsed(void *parsed_result,
2892 __attribute__((unused)) struct cmdline *cl,
2893 __attribute__((unused)) void *data)
2895 struct cmd_set_txsplit_result *res;
2897 res = parsed_result;
2898 set_tx_pkt_split(res->mode);
2901 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2902 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2903 cmd_keyword, "set");
2904 cmdline_parse_token_string_t cmd_set_txsplit_name =
2905 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2906 txsplit, "txsplit");
2907 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2908 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2911 cmdline_parse_inst_t cmd_set_txsplit = {
2912 .f = cmd_set_txsplit_parsed,
2914 .help_str = "set txsplit on|off|rand",
2916 (void *)&cmd_set_txsplit_keyword,
2917 (void *)&cmd_set_txsplit_name,
2918 (void *)&cmd_set_txsplit_mode,
2923 /* *** CONFIG TX QUEUE FLAGS *** */
2925 struct cmd_config_txqflags_result {
2926 cmdline_fixed_string_t port;
2927 cmdline_fixed_string_t config;
2928 cmdline_fixed_string_t all;
2929 cmdline_fixed_string_t what;
2933 static void cmd_config_txqflags_parsed(void *parsed_result,
2934 __attribute__((unused)) struct cmdline *cl,
2935 __attribute__((unused)) void *data)
2937 struct cmd_config_txqflags_result *res = parsed_result;
2939 if (!all_ports_stopped()) {
2940 printf("Please stop all ports first\n");
2944 if (strcmp(res->what, "txqflags")) {
2945 printf("Unknown parameter\n");
2949 if (res->hexvalue >= 0) {
2950 txq_flags = res->hexvalue;
2952 printf("txqflags must be >= 0\n");
2958 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2961 cmdline_parse_token_string_t cmd_config_txqflags_port =
2962 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2964 cmdline_parse_token_string_t cmd_config_txqflags_config =
2965 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2967 cmdline_parse_token_string_t cmd_config_txqflags_all =
2968 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2970 cmdline_parse_token_string_t cmd_config_txqflags_what =
2971 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2973 cmdline_parse_token_num_t cmd_config_txqflags_value =
2974 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2977 cmdline_parse_inst_t cmd_config_txqflags = {
2978 .f = cmd_config_txqflags_parsed,
2980 .help_str = "port config all txqflags <value>",
2982 (void *)&cmd_config_txqflags_port,
2983 (void *)&cmd_config_txqflags_config,
2984 (void *)&cmd_config_txqflags_all,
2985 (void *)&cmd_config_txqflags_what,
2986 (void *)&cmd_config_txqflags_value,
2991 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2992 struct cmd_rx_vlan_filter_all_result {
2993 cmdline_fixed_string_t rx_vlan;
2994 cmdline_fixed_string_t what;
2995 cmdline_fixed_string_t all;
3000 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3001 __attribute__((unused)) struct cmdline *cl,
3002 __attribute__((unused)) void *data)
3004 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3006 if (!strcmp(res->what, "add"))
3007 rx_vlan_all_filter_set(res->port_id, 1);
3009 rx_vlan_all_filter_set(res->port_id, 0);
3012 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3013 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3014 rx_vlan, "rx_vlan");
3015 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3016 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3018 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3019 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3021 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3022 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3025 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3026 .f = cmd_rx_vlan_filter_all_parsed,
3028 .help_str = "rx_vlan add|rm all <port_id>: "
3029 "Add/Remove all identifiers to/from the set of VLAN "
3030 "identifiers filtered by a port",
3032 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3033 (void *)&cmd_rx_vlan_filter_all_what,
3034 (void *)&cmd_rx_vlan_filter_all_all,
3035 (void *)&cmd_rx_vlan_filter_all_portid,
3040 /* *** VLAN OFFLOAD SET ON A PORT *** */
3041 struct cmd_vlan_offload_result {
3042 cmdline_fixed_string_t vlan;
3043 cmdline_fixed_string_t set;
3044 cmdline_fixed_string_t vlan_type;
3045 cmdline_fixed_string_t what;
3046 cmdline_fixed_string_t on;
3047 cmdline_fixed_string_t port_id;
3051 cmd_vlan_offload_parsed(void *parsed_result,
3052 __attribute__((unused)) struct cmdline *cl,
3053 __attribute__((unused)) void *data)
3056 struct cmd_vlan_offload_result *res = parsed_result;
3059 portid_t port_id = 0;
3063 len = strnlen(str, STR_TOKEN_SIZE);
3065 /* Get port_id first */
3073 tmp = strtoul(str, NULL, 0);
3074 /* If port_id greater that what portid_t can represent, return */
3075 if(tmp >= RTE_MAX_ETHPORTS)
3077 port_id = (portid_t)tmp;
3079 if (!strcmp(res->on, "on"))
3084 if (!strcmp(res->what, "strip"))
3085 rx_vlan_strip_set(port_id, on);
3086 else if(!strcmp(res->what, "stripq")){
3087 uint16_t queue_id = 0;
3089 /* No queue_id, return */
3091 printf("must specify (port,queue_id)\n");
3094 tmp = strtoul(str + i + 1, NULL, 0);
3095 /* If queue_id greater that what 16-bits can represent, return */
3099 queue_id = (uint16_t)tmp;
3100 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3102 else if (!strcmp(res->what, "filter"))
3103 rx_vlan_filter_set(port_id, on);
3105 vlan_extend_set(port_id, on);
3110 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3111 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3113 cmdline_parse_token_string_t cmd_vlan_offload_set =
3114 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3116 cmdline_parse_token_string_t cmd_vlan_offload_what =
3117 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3118 what, "strip#filter#qinq#stripq");
3119 cmdline_parse_token_string_t cmd_vlan_offload_on =
3120 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3122 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3123 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3126 cmdline_parse_inst_t cmd_vlan_offload = {
3127 .f = cmd_vlan_offload_parsed,
3129 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3130 "<port_id[,queue_id]>: "
3131 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3133 (void *)&cmd_vlan_offload_vlan,
3134 (void *)&cmd_vlan_offload_set,
3135 (void *)&cmd_vlan_offload_what,
3136 (void *)&cmd_vlan_offload_on,
3137 (void *)&cmd_vlan_offload_portid,
3142 /* *** VLAN TPID SET ON A PORT *** */
3143 struct cmd_vlan_tpid_result {
3144 cmdline_fixed_string_t vlan;
3145 cmdline_fixed_string_t set;
3146 cmdline_fixed_string_t vlan_type;
3147 cmdline_fixed_string_t what;
3153 cmd_vlan_tpid_parsed(void *parsed_result,
3154 __attribute__((unused)) struct cmdline *cl,
3155 __attribute__((unused)) void *data)
3157 struct cmd_vlan_tpid_result *res = parsed_result;
3158 enum rte_vlan_type vlan_type;
3160 if (!strcmp(res->vlan_type, "inner"))
3161 vlan_type = ETH_VLAN_TYPE_INNER;
3162 else if (!strcmp(res->vlan_type, "outer"))
3163 vlan_type = ETH_VLAN_TYPE_OUTER;
3165 printf("Unknown vlan type\n");
3168 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3171 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3172 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3174 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3175 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3177 cmdline_parse_token_string_t cmd_vlan_type =
3178 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3179 vlan_type, "inner#outer");
3180 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3181 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3183 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3184 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3186 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3187 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3190 cmdline_parse_inst_t cmd_vlan_tpid = {
3191 .f = cmd_vlan_tpid_parsed,
3193 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3194 "Set the VLAN Ether type",
3196 (void *)&cmd_vlan_tpid_vlan,
3197 (void *)&cmd_vlan_tpid_set,
3198 (void *)&cmd_vlan_type,
3199 (void *)&cmd_vlan_tpid_what,
3200 (void *)&cmd_vlan_tpid_tpid,
3201 (void *)&cmd_vlan_tpid_portid,
3206 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3207 struct cmd_rx_vlan_filter_result {
3208 cmdline_fixed_string_t rx_vlan;
3209 cmdline_fixed_string_t what;
3215 cmd_rx_vlan_filter_parsed(void *parsed_result,
3216 __attribute__((unused)) struct cmdline *cl,
3217 __attribute__((unused)) void *data)
3219 struct cmd_rx_vlan_filter_result *res = parsed_result;
3221 if (!strcmp(res->what, "add"))
3222 rx_vft_set(res->port_id, res->vlan_id, 1);
3224 rx_vft_set(res->port_id, res->vlan_id, 0);
3227 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3228 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3229 rx_vlan, "rx_vlan");
3230 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3231 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3233 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3234 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3236 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3237 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3240 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3241 .f = cmd_rx_vlan_filter_parsed,
3243 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3244 "Add/Remove a VLAN identifier to/from the set of VLAN "
3245 "identifiers filtered by a port",
3247 (void *)&cmd_rx_vlan_filter_rx_vlan,
3248 (void *)&cmd_rx_vlan_filter_what,
3249 (void *)&cmd_rx_vlan_filter_vlanid,
3250 (void *)&cmd_rx_vlan_filter_portid,
3255 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3256 struct cmd_tx_vlan_set_result {
3257 cmdline_fixed_string_t tx_vlan;
3258 cmdline_fixed_string_t set;
3264 cmd_tx_vlan_set_parsed(void *parsed_result,
3265 __attribute__((unused)) struct cmdline *cl,
3266 __attribute__((unused)) void *data)
3268 struct cmd_tx_vlan_set_result *res = parsed_result;
3270 tx_vlan_set(res->port_id, res->vlan_id);
3273 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3274 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3275 tx_vlan, "tx_vlan");
3276 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3277 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3279 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3280 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3282 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3283 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3286 cmdline_parse_inst_t cmd_tx_vlan_set = {
3287 .f = cmd_tx_vlan_set_parsed,
3289 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3290 "Enable hardware insertion of a single VLAN header "
3291 "with a given TAG Identifier in packets sent on a port",
3293 (void *)&cmd_tx_vlan_set_tx_vlan,
3294 (void *)&cmd_tx_vlan_set_set,
3295 (void *)&cmd_tx_vlan_set_portid,
3296 (void *)&cmd_tx_vlan_set_vlanid,
3301 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3302 struct cmd_tx_vlan_set_qinq_result {
3303 cmdline_fixed_string_t tx_vlan;
3304 cmdline_fixed_string_t set;
3307 uint16_t vlan_id_outer;
3311 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3312 __attribute__((unused)) struct cmdline *cl,
3313 __attribute__((unused)) void *data)
3315 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3317 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3320 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3321 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3322 tx_vlan, "tx_vlan");
3323 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3324 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3326 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3327 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3329 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3330 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3332 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3333 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3334 vlan_id_outer, UINT16);
3336 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3337 .f = cmd_tx_vlan_set_qinq_parsed,
3339 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3340 "Enable hardware insertion of double VLAN header "
3341 "with given TAG Identifiers in packets sent on a port",
3343 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3344 (void *)&cmd_tx_vlan_set_qinq_set,
3345 (void *)&cmd_tx_vlan_set_qinq_portid,
3346 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3347 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3352 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3353 struct cmd_tx_vlan_set_pvid_result {
3354 cmdline_fixed_string_t tx_vlan;
3355 cmdline_fixed_string_t set;
3356 cmdline_fixed_string_t pvid;
3359 cmdline_fixed_string_t mode;
3363 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3364 __attribute__((unused)) struct cmdline *cl,
3365 __attribute__((unused)) void *data)
3367 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3369 if (strcmp(res->mode, "on") == 0)
3370 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3372 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3375 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3376 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3377 tx_vlan, "tx_vlan");
3378 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3379 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3381 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3382 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3384 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3385 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3387 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3388 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3390 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3391 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3394 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3395 .f = cmd_tx_vlan_set_pvid_parsed,
3397 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3399 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3400 (void *)&cmd_tx_vlan_set_pvid_set,
3401 (void *)&cmd_tx_vlan_set_pvid_pvid,
3402 (void *)&cmd_tx_vlan_set_pvid_port_id,
3403 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3404 (void *)&cmd_tx_vlan_set_pvid_mode,
3409 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3410 struct cmd_tx_vlan_reset_result {
3411 cmdline_fixed_string_t tx_vlan;
3412 cmdline_fixed_string_t reset;
3417 cmd_tx_vlan_reset_parsed(void *parsed_result,
3418 __attribute__((unused)) struct cmdline *cl,
3419 __attribute__((unused)) void *data)
3421 struct cmd_tx_vlan_reset_result *res = parsed_result;
3423 tx_vlan_reset(res->port_id);
3426 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3427 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3428 tx_vlan, "tx_vlan");
3429 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3430 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3432 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3433 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3436 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3437 .f = cmd_tx_vlan_reset_parsed,
3439 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3440 "VLAN header in packets sent on a port",
3442 (void *)&cmd_tx_vlan_reset_tx_vlan,
3443 (void *)&cmd_tx_vlan_reset_reset,
3444 (void *)&cmd_tx_vlan_reset_portid,
3450 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3451 struct cmd_csum_result {
3452 cmdline_fixed_string_t csum;
3453 cmdline_fixed_string_t mode;
3454 cmdline_fixed_string_t proto;
3455 cmdline_fixed_string_t hwsw;
3460 csum_show(int port_id)
3462 struct rte_eth_dev_info dev_info;
3465 ol_flags = ports[port_id].tx_ol_flags;
3466 printf("Parse tunnel is %s\n",
3467 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3468 printf("IP checksum offload is %s\n",
3469 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3470 printf("UDP checksum offload is %s\n",
3471 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3472 printf("TCP checksum offload is %s\n",
3473 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3474 printf("SCTP checksum offload is %s\n",
3475 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3476 printf("Outer-Ip checksum offload is %s\n",
3477 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3479 /* display warnings if configuration is not supported by the NIC */
3480 rte_eth_dev_info_get(port_id, &dev_info);
3481 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3482 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3483 printf("Warning: hardware IP checksum enabled but not "
3484 "supported by port %d\n", port_id);
3486 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3487 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3488 printf("Warning: hardware UDP checksum enabled but not "
3489 "supported by port %d\n", port_id);
3491 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3492 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3493 printf("Warning: hardware TCP checksum enabled but not "
3494 "supported by port %d\n", port_id);
3496 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3497 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3498 printf("Warning: hardware SCTP checksum enabled but not "
3499 "supported by port %d\n", port_id);
3501 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3502 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3503 printf("Warning: hardware outer IP checksum enabled but not "
3504 "supported by port %d\n", port_id);
3509 cmd_csum_parsed(void *parsed_result,
3510 __attribute__((unused)) struct cmdline *cl,
3511 __attribute__((unused)) void *data)
3513 struct cmd_csum_result *res = parsed_result;
3517 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3518 printf("invalid port %d\n", res->port_id);
3522 if (!strcmp(res->mode, "set")) {
3524 if (!strcmp(res->hwsw, "hw"))
3527 if (!strcmp(res->proto, "ip")) {
3528 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3529 } else if (!strcmp(res->proto, "udp")) {
3530 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3531 } else if (!strcmp(res->proto, "tcp")) {
3532 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3533 } else if (!strcmp(res->proto, "sctp")) {
3534 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3535 } else if (!strcmp(res->proto, "outer-ip")) {
3536 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3540 ports[res->port_id].tx_ol_flags |= mask;
3542 ports[res->port_id].tx_ol_flags &= (~mask);
3544 csum_show(res->port_id);
3547 cmdline_parse_token_string_t cmd_csum_csum =
3548 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3550 cmdline_parse_token_string_t cmd_csum_mode =
3551 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3553 cmdline_parse_token_string_t cmd_csum_proto =
3554 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3555 proto, "ip#tcp#udp#sctp#outer-ip");
3556 cmdline_parse_token_string_t cmd_csum_hwsw =
3557 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3559 cmdline_parse_token_num_t cmd_csum_portid =
3560 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3563 cmdline_parse_inst_t cmd_csum_set = {
3564 .f = cmd_csum_parsed,
3566 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3567 "Enable/Disable hardware calculation of L3/L4 checksum when "
3568 "using csum forward engine",
3570 (void *)&cmd_csum_csum,
3571 (void *)&cmd_csum_mode,
3572 (void *)&cmd_csum_proto,
3573 (void *)&cmd_csum_hwsw,
3574 (void *)&cmd_csum_portid,
3579 cmdline_parse_token_string_t cmd_csum_mode_show =
3580 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3583 cmdline_parse_inst_t cmd_csum_show = {
3584 .f = cmd_csum_parsed,
3586 .help_str = "csum show <port_id>: Show checksum offload configuration",
3588 (void *)&cmd_csum_csum,
3589 (void *)&cmd_csum_mode_show,
3590 (void *)&cmd_csum_portid,
3595 /* Enable/disable tunnel parsing */
3596 struct cmd_csum_tunnel_result {
3597 cmdline_fixed_string_t csum;
3598 cmdline_fixed_string_t parse;
3599 cmdline_fixed_string_t onoff;
3604 cmd_csum_tunnel_parsed(void *parsed_result,
3605 __attribute__((unused)) struct cmdline *cl,
3606 __attribute__((unused)) void *data)
3608 struct cmd_csum_tunnel_result *res = parsed_result;
3610 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3613 if (!strcmp(res->onoff, "on"))
3614 ports[res->port_id].tx_ol_flags |=
3615 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3617 ports[res->port_id].tx_ol_flags &=
3618 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3620 csum_show(res->port_id);
3623 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3624 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3626 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3627 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3628 parse, "parse_tunnel");
3629 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3630 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3632 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3633 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3636 cmdline_parse_inst_t cmd_csum_tunnel = {
3637 .f = cmd_csum_tunnel_parsed,
3639 .help_str = "csum parse_tunnel on|off <port_id>: "
3640 "Enable/Disable parsing of tunnels for csum engine",
3642 (void *)&cmd_csum_tunnel_csum,
3643 (void *)&cmd_csum_tunnel_parse,
3644 (void *)&cmd_csum_tunnel_onoff,
3645 (void *)&cmd_csum_tunnel_portid,
3650 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3651 struct cmd_tso_set_result {
3652 cmdline_fixed_string_t tso;
3653 cmdline_fixed_string_t mode;
3659 cmd_tso_set_parsed(void *parsed_result,
3660 __attribute__((unused)) struct cmdline *cl,
3661 __attribute__((unused)) void *data)
3663 struct cmd_tso_set_result *res = parsed_result;
3664 struct rte_eth_dev_info dev_info;
3666 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3669 if (!strcmp(res->mode, "set"))
3670 ports[res->port_id].tso_segsz = res->tso_segsz;
3672 if (ports[res->port_id].tso_segsz == 0)
3673 printf("TSO for non-tunneled packets is disabled\n");
3675 printf("TSO segment size for non-tunneled packets is %d\n",
3676 ports[res->port_id].tso_segsz);
3678 /* display warnings if configuration is not supported by the NIC */
3679 rte_eth_dev_info_get(res->port_id, &dev_info);
3680 if ((ports[res->port_id].tso_segsz != 0) &&
3681 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3682 printf("Warning: TSO enabled but not "
3683 "supported by port %d\n", res->port_id);
3687 cmdline_parse_token_string_t cmd_tso_set_tso =
3688 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3690 cmdline_parse_token_string_t cmd_tso_set_mode =
3691 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3693 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3694 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3696 cmdline_parse_token_num_t cmd_tso_set_portid =
3697 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3700 cmdline_parse_inst_t cmd_tso_set = {
3701 .f = cmd_tso_set_parsed,
3703 .help_str = "tso set <tso_segsz> <port_id>: "
3704 "Set TSO segment size of non-tunneled packets for csum engine "
3707 (void *)&cmd_tso_set_tso,
3708 (void *)&cmd_tso_set_mode,
3709 (void *)&cmd_tso_set_tso_segsz,
3710 (void *)&cmd_tso_set_portid,
3715 cmdline_parse_token_string_t cmd_tso_show_mode =
3716 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3720 cmdline_parse_inst_t cmd_tso_show = {
3721 .f = cmd_tso_set_parsed,
3723 .help_str = "tso show <port_id>: "
3724 "Show TSO segment size of non-tunneled packets for csum engine",
3726 (void *)&cmd_tso_set_tso,
3727 (void *)&cmd_tso_show_mode,
3728 (void *)&cmd_tso_set_portid,
3733 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3734 struct cmd_tunnel_tso_set_result {
3735 cmdline_fixed_string_t tso;
3736 cmdline_fixed_string_t mode;
3742 check_tunnel_tso_nic_support(uint8_t port_id)
3744 struct rte_eth_dev_info dev_info;
3746 rte_eth_dev_info_get(port_id, &dev_info);
3747 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3748 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3749 "supported by port %d\n", port_id);
3750 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3751 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3752 "supported by port %d\n", port_id);
3753 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3754 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3755 "supported by port %d\n", port_id);
3756 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3757 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3758 "supported by port %d\n", port_id);
3762 cmd_tunnel_tso_set_parsed(void *parsed_result,
3763 __attribute__((unused)) struct cmdline *cl,
3764 __attribute__((unused)) void *data)
3766 struct cmd_tunnel_tso_set_result *res = parsed_result;
3768 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3771 if (!strcmp(res->mode, "set"))
3772 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3774 if (ports[res->port_id].tunnel_tso_segsz == 0)
3775 printf("TSO for tunneled packets is disabled\n");
3777 printf("TSO segment size for tunneled packets is %d\n",
3778 ports[res->port_id].tunnel_tso_segsz);
3780 /* Below conditions are needed to make it work:
3781 * (1) tunnel TSO is supported by the NIC;
3782 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3784 * (3) for tunneled pkts with outer L3 of IPv4,
3785 * "csum set outer-ip" must be set to hw, because after tso,
3786 * total_len of outer IP header is changed, and the checksum
3787 * of outer IP header calculated by sw should be wrong; that
3788 * is not necessary for IPv6 tunneled pkts because there's no
3789 * checksum in IP header anymore.
3791 check_tunnel_tso_nic_support(res->port_id);
3793 if (!(ports[res->port_id].tx_ol_flags &
3794 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3795 printf("Warning: csum parse_tunnel must be set "
3796 "so that tunneled packets are recognized\n");
3797 if (!(ports[res->port_id].tx_ol_flags &
3798 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3799 printf("Warning: csum set outer-ip must be set to hw "
3800 "if outer L3 is IPv4; not necessary for IPv6\n");
3804 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3805 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3807 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3808 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3810 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3811 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3813 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3814 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3817 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3818 .f = cmd_tunnel_tso_set_parsed,
3820 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3821 "Set TSO segment size of tunneled packets for csum engine "
3824 (void *)&cmd_tunnel_tso_set_tso,
3825 (void *)&cmd_tunnel_tso_set_mode,
3826 (void *)&cmd_tunnel_tso_set_tso_segsz,
3827 (void *)&cmd_tunnel_tso_set_portid,
3832 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3833 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3837 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3838 .f = cmd_tunnel_tso_set_parsed,
3840 .help_str = "tunnel_tso show <port_id> "
3841 "Show TSO segment size of tunneled packets for csum engine",
3843 (void *)&cmd_tunnel_tso_set_tso,
3844 (void *)&cmd_tunnel_tso_show_mode,
3845 (void *)&cmd_tunnel_tso_set_portid,
3850 /* *** SET GRO FOR A PORT *** */
3851 struct cmd_gro_result {
3852 cmdline_fixed_string_t cmd_keyword;
3853 cmdline_fixed_string_t mode;
3858 cmd_enable_gro_parsed(void *parsed_result,
3859 __attribute__((unused)) struct cmdline *cl,
3860 __attribute__((unused)) void *data)
3862 struct cmd_gro_result *res;
3864 res = parsed_result;
3865 setup_gro(res->mode, res->port_id);
3868 cmdline_parse_token_string_t cmd_gro_keyword =
3869 TOKEN_STRING_INITIALIZER(struct cmd_gro_result,
3870 cmd_keyword, "gro");
3871 cmdline_parse_token_string_t cmd_gro_mode =
3872 TOKEN_STRING_INITIALIZER(struct cmd_gro_result,
3874 cmdline_parse_token_num_t cmd_gro_pid =
3875 TOKEN_NUM_INITIALIZER(struct cmd_gro_result,
3878 cmdline_parse_inst_t cmd_enable_gro = {
3879 .f = cmd_enable_gro_parsed,
3881 .help_str = "gro (on|off) (port_id)",
3883 (void *)&cmd_gro_keyword,
3884 (void *)&cmd_gro_mode,
3885 (void *)&cmd_gro_pid,
3890 /* *** SET MAX FLOW NUMBER AND ITEM NUM PER FLOW FOR GRO *** */
3891 struct cmd_gro_set_result {
3892 cmdline_fixed_string_t gro;
3893 cmdline_fixed_string_t mode;
3895 uint16_t item_num_per_flow;
3900 cmd_gro_set_parsed(void *parsed_result,
3901 __attribute__((unused)) struct cmdline *cl,
3902 __attribute__((unused)) void *data)
3904 struct cmd_gro_set_result *res = parsed_result;
3906 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3908 if (test_done == 0) {
3909 printf("Before set GRO flow_num and item_num_per_flow,"
3910 " please stop forwarding first\n");
3914 if (!strcmp(res->mode, "set")) {
3915 if (res->flow_num == 0)
3916 printf("Invalid flow number. Revert to default value:"
3917 " %u.\n", GRO_DEFAULT_FLOW_NUM);
3919 gro_ports[res->port_id].param.max_flow_num =
3922 if (res->item_num_per_flow == 0)
3923 printf("Invalid item number per-flow. Revert"
3924 " to default value:%u.\n",
3925 GRO_DEFAULT_ITEM_NUM_PER_FLOW);
3927 gro_ports[res->port_id].param.max_item_per_flow =
3928 res->item_num_per_flow;
3932 cmdline_parse_token_string_t cmd_gro_set_gro =
3933 TOKEN_STRING_INITIALIZER(struct cmd_gro_set_result,
3935 cmdline_parse_token_string_t cmd_gro_set_mode =
3936 TOKEN_STRING_INITIALIZER(struct cmd_gro_set_result,
3938 cmdline_parse_token_num_t cmd_gro_set_flow_num =
3939 TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result,
3941 cmdline_parse_token_num_t cmd_gro_set_item_num_per_flow =
3942 TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result,
3943 item_num_per_flow, UINT16);
3944 cmdline_parse_token_num_t cmd_gro_set_portid =
3945 TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result,
3948 cmdline_parse_inst_t cmd_gro_set = {
3949 .f = cmd_gro_set_parsed,
3951 .help_str = "gro set <max_flow_num> <max_item_num_per_flow> "
3952 "<port_id>: set max flow number and max packet number per-flow "
3955 (void *)&cmd_gro_set_gro,
3956 (void *)&cmd_gro_set_mode,
3957 (void *)&cmd_gro_set_flow_num,
3958 (void *)&cmd_gro_set_item_num_per_flow,
3959 (void *)&cmd_gro_set_portid,
3964 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3965 struct cmd_set_flush_rx {
3966 cmdline_fixed_string_t set;
3967 cmdline_fixed_string_t flush_rx;
3968 cmdline_fixed_string_t mode;
3972 cmd_set_flush_rx_parsed(void *parsed_result,
3973 __attribute__((unused)) struct cmdline *cl,
3974 __attribute__((unused)) void *data)
3976 struct cmd_set_flush_rx *res = parsed_result;
3977 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3980 cmdline_parse_token_string_t cmd_setflushrx_set =
3981 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3983 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3984 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3985 flush_rx, "flush_rx");
3986 cmdline_parse_token_string_t cmd_setflushrx_mode =
3987 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3991 cmdline_parse_inst_t cmd_set_flush_rx = {
3992 .f = cmd_set_flush_rx_parsed,
3993 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3996 (void *)&cmd_setflushrx_set,
3997 (void *)&cmd_setflushrx_flush_rx,
3998 (void *)&cmd_setflushrx_mode,
4003 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4004 struct cmd_set_link_check {
4005 cmdline_fixed_string_t set;
4006 cmdline_fixed_string_t link_check;
4007 cmdline_fixed_string_t mode;
4011 cmd_set_link_check_parsed(void *parsed_result,
4012 __attribute__((unused)) struct cmdline *cl,
4013 __attribute__((unused)) void *data)
4015 struct cmd_set_link_check *res = parsed_result;
4016 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4019 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4020 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4022 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4023 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4024 link_check, "link_check");
4025 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4026 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4030 cmdline_parse_inst_t cmd_set_link_check = {
4031 .f = cmd_set_link_check_parsed,
4032 .help_str = "set link_check on|off: Enable/Disable link status check "
4033 "when starting/stopping a port",
4036 (void *)&cmd_setlinkcheck_set,
4037 (void *)&cmd_setlinkcheck_link_check,
4038 (void *)&cmd_setlinkcheck_mode,
4043 /* *** SET NIC BYPASS MODE *** */
4044 struct cmd_set_bypass_mode_result {
4045 cmdline_fixed_string_t set;
4046 cmdline_fixed_string_t bypass;
4047 cmdline_fixed_string_t mode;
4048 cmdline_fixed_string_t value;
4053 cmd_set_bypass_mode_parsed(void *parsed_result,
4054 __attribute__((unused)) struct cmdline *cl,
4055 __attribute__((unused)) void *data)
4057 struct cmd_set_bypass_mode_result *res = parsed_result;
4058 portid_t port_id = res->port_id;
4059 int32_t rc = -EINVAL;
4061 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4062 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4064 if (!strcmp(res->value, "bypass"))
4065 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4066 else if (!strcmp(res->value, "isolate"))
4067 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4069 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4071 /* Set the bypass mode for the relevant port. */
4072 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4075 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4078 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4079 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4081 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4082 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4084 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4085 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4087 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4088 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4089 value, "normal#bypass#isolate");
4090 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4091 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4094 cmdline_parse_inst_t cmd_set_bypass_mode = {
4095 .f = cmd_set_bypass_mode_parsed,
4096 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4097 "Set the NIC bypass mode for port_id",
4100 (void *)&cmd_setbypass_mode_set,
4101 (void *)&cmd_setbypass_mode_bypass,
4102 (void *)&cmd_setbypass_mode_mode,
4103 (void *)&cmd_setbypass_mode_value,
4104 (void *)&cmd_setbypass_mode_port,
4109 /* *** SET NIC BYPASS EVENT *** */
4110 struct cmd_set_bypass_event_result {
4111 cmdline_fixed_string_t set;
4112 cmdline_fixed_string_t bypass;
4113 cmdline_fixed_string_t event;
4114 cmdline_fixed_string_t event_value;
4115 cmdline_fixed_string_t mode;
4116 cmdline_fixed_string_t mode_value;
4121 cmd_set_bypass_event_parsed(void *parsed_result,
4122 __attribute__((unused)) struct cmdline *cl,
4123 __attribute__((unused)) void *data)
4125 int32_t rc = -EINVAL;
4126 struct cmd_set_bypass_event_result *res = parsed_result;
4127 portid_t port_id = res->port_id;
4129 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4130 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4131 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4133 if (!strcmp(res->event_value, "timeout"))
4134 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4135 else if (!strcmp(res->event_value, "os_on"))
4136 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4137 else if (!strcmp(res->event_value, "os_off"))
4138 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4139 else if (!strcmp(res->event_value, "power_on"))
4140 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4141 else if (!strcmp(res->event_value, "power_off"))
4142 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4144 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4146 if (!strcmp(res->mode_value, "bypass"))
4147 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4148 else if (!strcmp(res->mode_value, "isolate"))
4149 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4151 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4153 /* Set the watchdog timeout. */
4154 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4157 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4158 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4162 printf("Failed to set timeout value %u "
4163 "for port %d, errto code: %d.\n",
4164 bypass_timeout, port_id, rc);
4168 /* Set the bypass event to transition to bypass mode. */
4169 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4174 printf("\t Failed to set bypass event for port = %d.\n",
4178 cmdline_parse_token_string_t cmd_setbypass_event_set =
4179 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4181 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4182 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4184 cmdline_parse_token_string_t cmd_setbypass_event_event =
4185 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4187 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4188 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4189 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4190 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4191 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4193 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4194 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4195 mode_value, "normal#bypass#isolate");
4196 cmdline_parse_token_num_t cmd_setbypass_event_port =
4197 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4200 cmdline_parse_inst_t cmd_set_bypass_event = {
4201 .f = cmd_set_bypass_event_parsed,
4202 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4203 "power_off mode normal|bypass|isolate <port_id>: "
4204 "Set the NIC bypass event mode for port_id",
4207 (void *)&cmd_setbypass_event_set,
4208 (void *)&cmd_setbypass_event_bypass,
4209 (void *)&cmd_setbypass_event_event,
4210 (void *)&cmd_setbypass_event_event_value,
4211 (void *)&cmd_setbypass_event_mode,
4212 (void *)&cmd_setbypass_event_mode_value,
4213 (void *)&cmd_setbypass_event_port,
4219 /* *** SET NIC BYPASS TIMEOUT *** */
4220 struct cmd_set_bypass_timeout_result {
4221 cmdline_fixed_string_t set;
4222 cmdline_fixed_string_t bypass;
4223 cmdline_fixed_string_t timeout;
4224 cmdline_fixed_string_t value;
4228 cmd_set_bypass_timeout_parsed(void *parsed_result,
4229 __attribute__((unused)) struct cmdline *cl,
4230 __attribute__((unused)) void *data)
4232 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4234 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4235 if (!strcmp(res->value, "1.5"))
4236 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4237 else if (!strcmp(res->value, "2"))
4238 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4239 else if (!strcmp(res->value, "3"))
4240 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4241 else if (!strcmp(res->value, "4"))
4242 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4243 else if (!strcmp(res->value, "8"))
4244 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4245 else if (!strcmp(res->value, "16"))
4246 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4247 else if (!strcmp(res->value, "32"))
4248 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4250 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4254 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4255 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4257 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4258 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4260 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4261 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4262 timeout, "timeout");
4263 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4264 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4265 value, "0#1.5#2#3#4#8#16#32");
4267 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4268 .f = cmd_set_bypass_timeout_parsed,
4269 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4270 "Set the NIC bypass watchdog timeout in seconds",
4273 (void *)&cmd_setbypass_timeout_set,
4274 (void *)&cmd_setbypass_timeout_bypass,
4275 (void *)&cmd_setbypass_timeout_timeout,
4276 (void *)&cmd_setbypass_timeout_value,
4281 /* *** SHOW NIC BYPASS MODE *** */
4282 struct cmd_show_bypass_config_result {
4283 cmdline_fixed_string_t show;
4284 cmdline_fixed_string_t bypass;
4285 cmdline_fixed_string_t config;
4290 cmd_show_bypass_config_parsed(void *parsed_result,
4291 __attribute__((unused)) struct cmdline *cl,
4292 __attribute__((unused)) void *data)
4294 struct cmd_show_bypass_config_result *res = parsed_result;
4295 portid_t port_id = res->port_id;
4297 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4298 uint32_t event_mode;
4299 uint32_t bypass_mode;
4300 uint32_t timeout = bypass_timeout;
4303 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4304 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4305 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4306 {"UNKNOWN", "normal", "bypass", "isolate"};
4307 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4314 int num_events = (sizeof events) / (sizeof events[0]);
4316 /* Display the bypass mode.*/
4317 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4318 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4322 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4323 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4325 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4328 /* Display the bypass timeout.*/
4329 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4330 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4332 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4334 /* Display the bypass events and associated modes. */
4335 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4337 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4338 printf("\tFailed to get bypass mode for event = %s\n",
4341 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4342 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4344 printf("\tbypass event: %-16s = %s\n", events[i],
4350 printf("\tFailed to get bypass configuration for port = %d\n",
4354 cmdline_parse_token_string_t cmd_showbypass_config_show =
4355 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4357 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4358 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4360 cmdline_parse_token_string_t cmd_showbypass_config_config =
4361 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4363 cmdline_parse_token_num_t cmd_showbypass_config_port =
4364 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4367 cmdline_parse_inst_t cmd_show_bypass_config = {
4368 .f = cmd_show_bypass_config_parsed,
4369 .help_str = "show bypass config <port_id>: "
4370 "Show the NIC bypass config for port_id",
4373 (void *)&cmd_showbypass_config_show,
4374 (void *)&cmd_showbypass_config_bypass,
4375 (void *)&cmd_showbypass_config_config,
4376 (void *)&cmd_showbypass_config_port,
4381 #ifdef RTE_LIBRTE_PMD_BOND
4382 /* *** SET BONDING MODE *** */
4383 struct cmd_set_bonding_mode_result {
4384 cmdline_fixed_string_t set;
4385 cmdline_fixed_string_t bonding;
4386 cmdline_fixed_string_t mode;
4391 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4392 __attribute__((unused)) struct cmdline *cl,
4393 __attribute__((unused)) void *data)
4395 struct cmd_set_bonding_mode_result *res = parsed_result;
4396 portid_t port_id = res->port_id;
4398 /* Set the bonding mode for the relevant port. */
4399 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4400 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4403 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4404 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4406 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4407 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4408 bonding, "bonding");
4409 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4410 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4412 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4413 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4415 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4416 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4419 cmdline_parse_inst_t cmd_set_bonding_mode = {
4420 .f = cmd_set_bonding_mode_parsed,
4421 .help_str = "set bonding mode <mode_value> <port_id>: "
4422 "Set the bonding mode for port_id",
4425 (void *) &cmd_setbonding_mode_set,
4426 (void *) &cmd_setbonding_mode_bonding,
4427 (void *) &cmd_setbonding_mode_mode,
4428 (void *) &cmd_setbonding_mode_value,
4429 (void *) &cmd_setbonding_mode_port,
4434 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4435 struct cmd_set_bonding_lacp_dedicated_queues_result {
4436 cmdline_fixed_string_t set;
4437 cmdline_fixed_string_t bonding;
4438 cmdline_fixed_string_t lacp;
4439 cmdline_fixed_string_t dedicated_queues;
4441 cmdline_fixed_string_t mode;
4444 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4445 __attribute__((unused)) struct cmdline *cl,
4446 __attribute__((unused)) void *data)
4448 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4449 portid_t port_id = res->port_id;
4450 struct rte_port *port;
4452 port = &ports[port_id];
4454 /** Check if the port is not started **/
4455 if (port->port_status != RTE_PORT_STOPPED) {
4456 printf("Please stop port %d first\n", port_id);
4460 if (!strcmp(res->mode, "enable")) {
4461 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4462 printf("Dedicate queues for LACP control packets"
4465 printf("Enabling dedicate queues for LACP control "
4466 "packets on port %d failed\n", port_id);
4467 } else if (!strcmp(res->mode, "disable")) {
4468 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4469 printf("Dedicated queues for LACP control packets "
4472 printf("Disabling dedicated queues for LACP control "
4473 "traffic on port %d failed\n", port_id);
4477 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4478 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4480 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4481 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4482 bonding, "bonding");
4483 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4484 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4486 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4487 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4488 dedicated_queues, "dedicated_queues");
4489 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4490 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4492 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4493 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4494 mode, "enable#disable");
4496 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4497 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4498 .help_str = "set bonding lacp dedicated_queues <port_id> "
4500 "Enable/disable dedicated queues for LACP control traffic for port_id",
4503 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4504 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4505 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4506 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4507 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4508 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4513 /* *** SET BALANCE XMIT POLICY *** */
4514 struct cmd_set_bonding_balance_xmit_policy_result {
4515 cmdline_fixed_string_t set;
4516 cmdline_fixed_string_t bonding;
4517 cmdline_fixed_string_t balance_xmit_policy;
4519 cmdline_fixed_string_t policy;
4522 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4523 __attribute__((unused)) struct cmdline *cl,
4524 __attribute__((unused)) void *data)
4526 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4527 portid_t port_id = res->port_id;
4530 if (!strcmp(res->policy, "l2")) {
4531 policy = BALANCE_XMIT_POLICY_LAYER2;
4532 } else if (!strcmp(res->policy, "l23")) {
4533 policy = BALANCE_XMIT_POLICY_LAYER23;
4534 } else if (!strcmp(res->policy, "l34")) {
4535 policy = BALANCE_XMIT_POLICY_LAYER34;
4537 printf("\t Invalid xmit policy selection");
4541 /* Set the bonding mode for the relevant port. */
4542 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4543 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4548 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4549 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4551 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4552 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4553 bonding, "bonding");
4554 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4555 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4556 balance_xmit_policy, "balance_xmit_policy");
4557 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4558 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4560 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4561 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4562 policy, "l2#l23#l34");
4564 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4565 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4566 .help_str = "set bonding balance_xmit_policy <port_id> "
4568 "Set the bonding balance_xmit_policy for port_id",
4571 (void *)&cmd_setbonding_balance_xmit_policy_set,
4572 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4573 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4574 (void *)&cmd_setbonding_balance_xmit_policy_port,
4575 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4580 /* *** SHOW NIC BONDING CONFIGURATION *** */
4581 struct cmd_show_bonding_config_result {
4582 cmdline_fixed_string_t show;
4583 cmdline_fixed_string_t bonding;
4584 cmdline_fixed_string_t config;
4588 static void cmd_show_bonding_config_parsed(void *parsed_result,
4589 __attribute__((unused)) struct cmdline *cl,
4590 __attribute__((unused)) void *data)
4592 struct cmd_show_bonding_config_result *res = parsed_result;
4594 uint8_t slaves[RTE_MAX_ETHPORTS];
4595 int num_slaves, num_active_slaves;
4598 portid_t port_id = res->port_id;
4600 /* Display the bonding mode.*/
4601 bonding_mode = rte_eth_bond_mode_get(port_id);
4602 if (bonding_mode < 0) {
4603 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4606 printf("\tBonding mode: %d\n", bonding_mode);
4608 if (bonding_mode == BONDING_MODE_BALANCE) {
4609 int balance_xmit_policy;
4611 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4612 if (balance_xmit_policy < 0) {
4613 printf("\tFailed to get balance xmit policy for port = %d\n",
4617 printf("\tBalance Xmit Policy: ");
4619 switch (balance_xmit_policy) {
4620 case BALANCE_XMIT_POLICY_LAYER2:
4621 printf("BALANCE_XMIT_POLICY_LAYER2");
4623 case BALANCE_XMIT_POLICY_LAYER23:
4624 printf("BALANCE_XMIT_POLICY_LAYER23");
4626 case BALANCE_XMIT_POLICY_LAYER34:
4627 printf("BALANCE_XMIT_POLICY_LAYER34");
4634 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4636 if (num_slaves < 0) {
4637 printf("\tFailed to get slave list for port = %d\n", port_id);
4640 if (num_slaves > 0) {
4641 printf("\tSlaves (%d): [", num_slaves);
4642 for (i = 0; i < num_slaves - 1; i++)
4643 printf("%d ", slaves[i]);
4645 printf("%d]\n", slaves[num_slaves - 1]);
4647 printf("\tSlaves: []\n");
4651 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4654 if (num_active_slaves < 0) {
4655 printf("\tFailed to get active slave list for port = %d\n", port_id);
4658 if (num_active_slaves > 0) {
4659 printf("\tActive Slaves (%d): [", num_active_slaves);
4660 for (i = 0; i < num_active_slaves - 1; i++)
4661 printf("%d ", slaves[i]);
4663 printf("%d]\n", slaves[num_active_slaves - 1]);
4666 printf("\tActive Slaves: []\n");
4670 primary_id = rte_eth_bond_primary_get(port_id);
4671 if (primary_id < 0) {
4672 printf("\tFailed to get primary slave for port = %d\n", port_id);
4675 printf("\tPrimary: [%d]\n", primary_id);
4679 cmdline_parse_token_string_t cmd_showbonding_config_show =
4680 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4682 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4683 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4684 bonding, "bonding");
4685 cmdline_parse_token_string_t cmd_showbonding_config_config =
4686 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4688 cmdline_parse_token_num_t cmd_showbonding_config_port =
4689 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4692 cmdline_parse_inst_t cmd_show_bonding_config = {
4693 .f = cmd_show_bonding_config_parsed,
4694 .help_str = "show bonding config <port_id>: "
4695 "Show the bonding config for port_id",
4698 (void *)&cmd_showbonding_config_show,
4699 (void *)&cmd_showbonding_config_bonding,
4700 (void *)&cmd_showbonding_config_config,
4701 (void *)&cmd_showbonding_config_port,
4706 /* *** SET BONDING PRIMARY *** */
4707 struct cmd_set_bonding_primary_result {
4708 cmdline_fixed_string_t set;
4709 cmdline_fixed_string_t bonding;
4710 cmdline_fixed_string_t primary;
4715 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4716 __attribute__((unused)) struct cmdline *cl,
4717 __attribute__((unused)) void *data)
4719 struct cmd_set_bonding_primary_result *res = parsed_result;
4720 portid_t master_port_id = res->port_id;
4721 portid_t slave_port_id = res->slave_id;
4723 /* Set the primary slave for a bonded device. */
4724 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4725 printf("\t Failed to set primary slave for port = %d.\n",
4732 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4733 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4735 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4736 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4737 bonding, "bonding");
4738 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4739 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4740 primary, "primary");
4741 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4742 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4744 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4745 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4748 cmdline_parse_inst_t cmd_set_bonding_primary = {
4749 .f = cmd_set_bonding_primary_parsed,
4750 .help_str = "set bonding primary <slave_id> <port_id>: "
4751 "Set the primary slave for port_id",
4754 (void *)&cmd_setbonding_primary_set,
4755 (void *)&cmd_setbonding_primary_bonding,
4756 (void *)&cmd_setbonding_primary_primary,
4757 (void *)&cmd_setbonding_primary_slave,
4758 (void *)&cmd_setbonding_primary_port,
4763 /* *** ADD SLAVE *** */
4764 struct cmd_add_bonding_slave_result {
4765 cmdline_fixed_string_t add;
4766 cmdline_fixed_string_t bonding;
4767 cmdline_fixed_string_t slave;
4772 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4773 __attribute__((unused)) struct cmdline *cl,
4774 __attribute__((unused)) void *data)
4776 struct cmd_add_bonding_slave_result *res = parsed_result;
4777 portid_t master_port_id = res->port_id;
4778 portid_t slave_port_id = res->slave_id;
4780 /* add the slave for a bonded device. */
4781 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4782 printf("\t Failed to add slave %d to master port = %d.\n",
4783 slave_port_id, master_port_id);
4787 set_port_slave_flag(slave_port_id);
4790 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4791 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4793 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4794 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4795 bonding, "bonding");
4796 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4797 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4799 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4800 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4802 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4803 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4806 cmdline_parse_inst_t cmd_add_bonding_slave = {
4807 .f = cmd_add_bonding_slave_parsed,
4808 .help_str = "add bonding slave <slave_id> <port_id>: "
4809 "Add a slave device to a bonded device",
4812 (void *)&cmd_addbonding_slave_add,
4813 (void *)&cmd_addbonding_slave_bonding,
4814 (void *)&cmd_addbonding_slave_slave,
4815 (void *)&cmd_addbonding_slave_slaveid,
4816 (void *)&cmd_addbonding_slave_port,
4821 /* *** REMOVE SLAVE *** */
4822 struct cmd_remove_bonding_slave_result {
4823 cmdline_fixed_string_t remove;
4824 cmdline_fixed_string_t bonding;
4825 cmdline_fixed_string_t slave;
4830 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4831 __attribute__((unused)) struct cmdline *cl,
4832 __attribute__((unused)) void *data)
4834 struct cmd_remove_bonding_slave_result *res = parsed_result;
4835 portid_t master_port_id = res->port_id;
4836 portid_t slave_port_id = res->slave_id;
4838 /* remove the slave from a bonded device. */
4839 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4840 printf("\t Failed to remove slave %d from master port = %d.\n",
4841 slave_port_id, master_port_id);
4845 clear_port_slave_flag(slave_port_id);
4848 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4849 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4851 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4852 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4853 bonding, "bonding");
4854 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4855 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4857 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4858 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4860 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4861 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4864 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4865 .f = cmd_remove_bonding_slave_parsed,
4866 .help_str = "remove bonding slave <slave_id> <port_id>: "
4867 "Remove a slave device from a bonded device",
4870 (void *)&cmd_removebonding_slave_remove,
4871 (void *)&cmd_removebonding_slave_bonding,
4872 (void *)&cmd_removebonding_slave_slave,
4873 (void *)&cmd_removebonding_slave_slaveid,
4874 (void *)&cmd_removebonding_slave_port,
4879 /* *** CREATE BONDED DEVICE *** */
4880 struct cmd_create_bonded_device_result {
4881 cmdline_fixed_string_t create;
4882 cmdline_fixed_string_t bonded;
4883 cmdline_fixed_string_t device;
4888 static int bond_dev_num = 0;
4890 static void cmd_create_bonded_device_parsed(void *parsed_result,
4891 __attribute__((unused)) struct cmdline *cl,
4892 __attribute__((unused)) void *data)
4894 struct cmd_create_bonded_device_result *res = parsed_result;
4895 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4898 if (test_done == 0) {
4899 printf("Please stop forwarding first\n");
4903 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4906 /* Create a new bonded device. */
4907 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4909 printf("\t Failed to create bonded device.\n");
4912 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4915 /* Update number of ports */
4916 nb_ports = rte_eth_dev_count();
4917 reconfig(port_id, res->socket);
4918 rte_eth_promiscuous_enable(port_id);
4923 cmdline_parse_token_string_t cmd_createbonded_device_create =
4924 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4926 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4927 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4929 cmdline_parse_token_string_t cmd_createbonded_device_device =
4930 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4932 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4933 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4935 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4936 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4939 cmdline_parse_inst_t cmd_create_bonded_device = {
4940 .f = cmd_create_bonded_device_parsed,
4941 .help_str = "create bonded device <mode> <socket>: "
4942 "Create a new bonded device with specific bonding mode and socket",
4945 (void *)&cmd_createbonded_device_create,
4946 (void *)&cmd_createbonded_device_bonded,
4947 (void *)&cmd_createbonded_device_device,
4948 (void *)&cmd_createbonded_device_mode,
4949 (void *)&cmd_createbonded_device_socket,
4954 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4955 struct cmd_set_bond_mac_addr_result {
4956 cmdline_fixed_string_t set;
4957 cmdline_fixed_string_t bonding;
4958 cmdline_fixed_string_t mac_addr;
4960 struct ether_addr address;
4963 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4964 __attribute__((unused)) struct cmdline *cl,
4965 __attribute__((unused)) void *data)
4967 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4970 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4973 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4975 /* check the return value and print it if is < 0 */
4977 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4980 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4981 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4982 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4983 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4985 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4986 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4988 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4989 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4990 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4991 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4993 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4994 .f = cmd_set_bond_mac_addr_parsed,
4996 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4998 (void *)&cmd_set_bond_mac_addr_set,
4999 (void *)&cmd_set_bond_mac_addr_bonding,
5000 (void *)&cmd_set_bond_mac_addr_mac,
5001 (void *)&cmd_set_bond_mac_addr_portnum,
5002 (void *)&cmd_set_bond_mac_addr_addr,
5008 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5009 struct cmd_set_bond_mon_period_result {
5010 cmdline_fixed_string_t set;
5011 cmdline_fixed_string_t bonding;
5012 cmdline_fixed_string_t mon_period;
5017 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5018 __attribute__((unused)) struct cmdline *cl,
5019 __attribute__((unused)) void *data)
5021 struct cmd_set_bond_mon_period_result *res = parsed_result;
5024 if (res->port_num >= nb_ports) {
5025 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5029 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5031 /* check the return value and print it if is < 0 */
5033 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5036 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5037 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5039 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5040 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5041 bonding, "bonding");
5042 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5043 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5044 mon_period, "mon_period");
5045 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5046 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5048 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5049 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5052 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5053 .f = cmd_set_bond_mon_period_parsed,
5055 .help_str = "set bonding mon_period <port_id> <period_ms>",
5057 (void *)&cmd_set_bond_mon_period_set,
5058 (void *)&cmd_set_bond_mon_period_bonding,
5059 (void *)&cmd_set_bond_mon_period_mon_period,
5060 (void *)&cmd_set_bond_mon_period_portnum,
5061 (void *)&cmd_set_bond_mon_period_period_ms,
5066 #endif /* RTE_LIBRTE_PMD_BOND */
5068 /* *** SET FORWARDING MODE *** */
5069 struct cmd_set_fwd_mode_result {
5070 cmdline_fixed_string_t set;
5071 cmdline_fixed_string_t fwd;
5072 cmdline_fixed_string_t mode;
5075 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5076 __attribute__((unused)) struct cmdline *cl,
5077 __attribute__((unused)) void *data)
5079 struct cmd_set_fwd_mode_result *res = parsed_result;
5082 set_pkt_forwarding_mode(res->mode);
5085 cmdline_parse_token_string_t cmd_setfwd_set =
5086 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5087 cmdline_parse_token_string_t cmd_setfwd_fwd =
5088 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5089 cmdline_parse_token_string_t cmd_setfwd_mode =
5090 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5091 "" /* defined at init */);
5093 cmdline_parse_inst_t cmd_set_fwd_mode = {
5094 .f = cmd_set_fwd_mode_parsed,
5096 .help_str = NULL, /* defined at init */
5098 (void *)&cmd_setfwd_set,
5099 (void *)&cmd_setfwd_fwd,
5100 (void *)&cmd_setfwd_mode,
5105 static void cmd_set_fwd_mode_init(void)
5108 static char token[128];
5109 static char help[256];
5110 cmdline_parse_token_string_t *token_struct;
5112 modes = list_pkt_forwarding_modes();
5113 snprintf(help, sizeof(help), "set fwd %s: "
5114 "Set packet forwarding mode", modes);
5115 cmd_set_fwd_mode.help_str = help;
5117 /* string token separator is # */
5118 for (c = token; *modes != '\0'; modes++)
5123 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5124 token_struct->string_data.str = token;
5127 /* *** SET RETRY FORWARDING MODE *** */
5128 struct cmd_set_fwd_retry_mode_result {
5129 cmdline_fixed_string_t set;
5130 cmdline_fixed_string_t fwd;
5131 cmdline_fixed_string_t mode;
5132 cmdline_fixed_string_t retry;
5135 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5136 __attribute__((unused)) struct cmdline *cl,
5137 __attribute__((unused)) void *data)
5139 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5142 set_pkt_forwarding_mode(res->mode);
5145 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5146 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5148 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5149 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5151 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5152 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5154 "" /* defined at init */);
5155 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5156 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5159 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5160 .f = cmd_set_fwd_retry_mode_parsed,
5162 .help_str = NULL, /* defined at init */
5164 (void *)&cmd_setfwd_retry_set,
5165 (void *)&cmd_setfwd_retry_fwd,
5166 (void *)&cmd_setfwd_retry_mode,
5167 (void *)&cmd_setfwd_retry_retry,
5172 static void cmd_set_fwd_retry_mode_init(void)
5175 static char token[128];
5176 static char help[256];
5177 cmdline_parse_token_string_t *token_struct;
5179 modes = list_pkt_forwarding_retry_modes();
5180 snprintf(help, sizeof(help), "set fwd %s retry: "
5181 "Set packet forwarding mode with retry", modes);
5182 cmd_set_fwd_retry_mode.help_str = help;
5184 /* string token separator is # */
5185 for (c = token; *modes != '\0'; modes++)
5190 token_struct = (cmdline_parse_token_string_t *)
5191 cmd_set_fwd_retry_mode.tokens[2];
5192 token_struct->string_data.str = token;
5195 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5196 struct cmd_set_burst_tx_retry_result {
5197 cmdline_fixed_string_t set;
5198 cmdline_fixed_string_t burst;
5199 cmdline_fixed_string_t tx;
5200 cmdline_fixed_string_t delay;
5202 cmdline_fixed_string_t retry;
5206 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5207 __attribute__((unused)) struct cmdline *cl,
5208 __attribute__((unused)) void *data)
5210 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5212 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5213 && !strcmp(res->tx, "tx")) {
5214 if (!strcmp(res->delay, "delay"))
5215 burst_tx_delay_time = res->time;
5216 if (!strcmp(res->retry, "retry"))
5217 burst_tx_retry_num = res->retry_num;
5222 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5223 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5224 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5225 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5227 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5228 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5229 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5230 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5231 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5232 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5233 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5234 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5235 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5236 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5238 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5239 .f = cmd_set_burst_tx_retry_parsed,
5240 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5242 (void *)&cmd_set_burst_tx_retry_set,
5243 (void *)&cmd_set_burst_tx_retry_burst,
5244 (void *)&cmd_set_burst_tx_retry_tx,
5245 (void *)&cmd_set_burst_tx_retry_delay,
5246 (void *)&cmd_set_burst_tx_retry_time,
5247 (void *)&cmd_set_burst_tx_retry_retry,
5248 (void *)&cmd_set_burst_tx_retry_retry_num,
5253 /* *** SET PROMISC MODE *** */
5254 struct cmd_set_promisc_mode_result {
5255 cmdline_fixed_string_t set;
5256 cmdline_fixed_string_t promisc;
5257 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5258 uint8_t port_num; /* valid if "allports" argument == 0 */
5259 cmdline_fixed_string_t mode;
5262 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5263 __attribute__((unused)) struct cmdline *cl,
5266 struct cmd_set_promisc_mode_result *res = parsed_result;
5270 if (!strcmp(res->mode, "on"))
5277 RTE_ETH_FOREACH_DEV(i) {
5279 rte_eth_promiscuous_enable(i);
5281 rte_eth_promiscuous_disable(i);
5286 rte_eth_promiscuous_enable(res->port_num);
5288 rte_eth_promiscuous_disable(res->port_num);
5292 cmdline_parse_token_string_t cmd_setpromisc_set =
5293 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5294 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5295 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5297 cmdline_parse_token_string_t cmd_setpromisc_portall =
5298 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5300 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5301 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5303 cmdline_parse_token_string_t cmd_setpromisc_mode =
5304 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5307 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5308 .f = cmd_set_promisc_mode_parsed,
5310 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5312 (void *)&cmd_setpromisc_set,
5313 (void *)&cmd_setpromisc_promisc,
5314 (void *)&cmd_setpromisc_portall,
5315 (void *)&cmd_setpromisc_mode,
5320 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5321 .f = cmd_set_promisc_mode_parsed,
5323 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5325 (void *)&cmd_setpromisc_set,
5326 (void *)&cmd_setpromisc_promisc,
5327 (void *)&cmd_setpromisc_portnum,
5328 (void *)&cmd_setpromisc_mode,
5333 /* *** SET ALLMULTI MODE *** */
5334 struct cmd_set_allmulti_mode_result {
5335 cmdline_fixed_string_t set;
5336 cmdline_fixed_string_t allmulti;
5337 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5338 uint8_t port_num; /* valid if "allports" argument == 0 */
5339 cmdline_fixed_string_t mode;
5342 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5343 __attribute__((unused)) struct cmdline *cl,
5346 struct cmd_set_allmulti_mode_result *res = parsed_result;
5350 if (!strcmp(res->mode, "on"))
5357 RTE_ETH_FOREACH_DEV(i) {
5359 rte_eth_allmulticast_enable(i);
5361 rte_eth_allmulticast_disable(i);
5366 rte_eth_allmulticast_enable(res->port_num);
5368 rte_eth_allmulticast_disable(res->port_num);
5372 cmdline_parse_token_string_t cmd_setallmulti_set =
5373 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5374 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5375 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5377 cmdline_parse_token_string_t cmd_setallmulti_portall =
5378 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5380 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5381 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5383 cmdline_parse_token_string_t cmd_setallmulti_mode =
5384 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5387 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5388 .f = cmd_set_allmulti_mode_parsed,
5390 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5392 (void *)&cmd_setallmulti_set,
5393 (void *)&cmd_setallmulti_allmulti,
5394 (void *)&cmd_setallmulti_portall,
5395 (void *)&cmd_setallmulti_mode,
5400 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5401 .f = cmd_set_allmulti_mode_parsed,
5403 .help_str = "set allmulti <port_id> on|off: "
5404 "Set allmulti mode on port_id",
5406 (void *)&cmd_setallmulti_set,
5407 (void *)&cmd_setallmulti_allmulti,
5408 (void *)&cmd_setallmulti_portnum,
5409 (void *)&cmd_setallmulti_mode,
5414 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5415 struct cmd_link_flow_ctrl_set_result {
5416 cmdline_fixed_string_t set;
5417 cmdline_fixed_string_t flow_ctrl;
5418 cmdline_fixed_string_t rx;
5419 cmdline_fixed_string_t rx_lfc_mode;
5420 cmdline_fixed_string_t tx;
5421 cmdline_fixed_string_t tx_lfc_mode;
5422 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5423 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5424 cmdline_fixed_string_t autoneg_str;
5425 cmdline_fixed_string_t autoneg;
5426 cmdline_fixed_string_t hw_str;
5427 uint32_t high_water;
5428 cmdline_fixed_string_t lw_str;
5430 cmdline_fixed_string_t pt_str;
5431 uint16_t pause_time;
5432 cmdline_fixed_string_t xon_str;
5437 cmdline_parse_token_string_t cmd_lfc_set_set =
5438 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5440 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5441 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5442 flow_ctrl, "flow_ctrl");
5443 cmdline_parse_token_string_t cmd_lfc_set_rx =
5444 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5446 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5447 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5448 rx_lfc_mode, "on#off");
5449 cmdline_parse_token_string_t cmd_lfc_set_tx =
5450 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5452 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5453 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5454 tx_lfc_mode, "on#off");
5455 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5456 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5457 hw_str, "high_water");
5458 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5459 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5460 high_water, UINT32);
5461 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5462 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5463 lw_str, "low_water");
5464 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5465 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5467 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5468 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5469 pt_str, "pause_time");
5470 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5471 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5472 pause_time, UINT16);
5473 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5474 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5475 xon_str, "send_xon");
5476 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5477 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5479 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5480 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5481 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5482 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5483 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5484 mac_ctrl_frame_fwd_mode, "on#off");
5485 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5486 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5487 autoneg_str, "autoneg");
5488 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5489 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5491 cmdline_parse_token_num_t cmd_lfc_set_portid =
5492 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5495 /* forward declaration */
5497 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5500 cmdline_parse_inst_t cmd_link_flow_control_set = {
5501 .f = cmd_link_flow_ctrl_set_parsed,
5503 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5504 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5505 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5507 (void *)&cmd_lfc_set_set,
5508 (void *)&cmd_lfc_set_flow_ctrl,
5509 (void *)&cmd_lfc_set_rx,
5510 (void *)&cmd_lfc_set_rx_mode,
5511 (void *)&cmd_lfc_set_tx,
5512 (void *)&cmd_lfc_set_tx_mode,
5513 (void *)&cmd_lfc_set_high_water,
5514 (void *)&cmd_lfc_set_low_water,
5515 (void *)&cmd_lfc_set_pause_time,
5516 (void *)&cmd_lfc_set_send_xon,
5517 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5518 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5519 (void *)&cmd_lfc_set_autoneg_str,
5520 (void *)&cmd_lfc_set_autoneg,
5521 (void *)&cmd_lfc_set_portid,
5526 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5527 .f = cmd_link_flow_ctrl_set_parsed,
5528 .data = (void *)&cmd_link_flow_control_set_rx,
5529 .help_str = "set flow_ctrl rx on|off <port_id>: "
5530 "Change rx flow control parameter",
5532 (void *)&cmd_lfc_set_set,
5533 (void *)&cmd_lfc_set_flow_ctrl,
5534 (void *)&cmd_lfc_set_rx,
5535 (void *)&cmd_lfc_set_rx_mode,
5536 (void *)&cmd_lfc_set_portid,
5541 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5542 .f = cmd_link_flow_ctrl_set_parsed,
5543 .data = (void *)&cmd_link_flow_control_set_tx,
5544 .help_str = "set flow_ctrl tx on|off <port_id>: "
5545 "Change tx flow control parameter",
5547 (void *)&cmd_lfc_set_set,
5548 (void *)&cmd_lfc_set_flow_ctrl,
5549 (void *)&cmd_lfc_set_tx,
5550 (void *)&cmd_lfc_set_tx_mode,
5551 (void *)&cmd_lfc_set_portid,
5556 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5557 .f = cmd_link_flow_ctrl_set_parsed,
5558 .data = (void *)&cmd_link_flow_control_set_hw,
5559 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5560 "Change high water flow control parameter",
5562 (void *)&cmd_lfc_set_set,
5563 (void *)&cmd_lfc_set_flow_ctrl,
5564 (void *)&cmd_lfc_set_high_water_str,
5565 (void *)&cmd_lfc_set_high_water,
5566 (void *)&cmd_lfc_set_portid,
5571 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5572 .f = cmd_link_flow_ctrl_set_parsed,
5573 .data = (void *)&cmd_link_flow_control_set_lw,
5574 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5575 "Change low water flow control parameter",
5577 (void *)&cmd_lfc_set_set,
5578 (void *)&cmd_lfc_set_flow_ctrl,
5579 (void *)&cmd_lfc_set_low_water_str,
5580 (void *)&cmd_lfc_set_low_water,
5581 (void *)&cmd_lfc_set_portid,
5586 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5587 .f = cmd_link_flow_ctrl_set_parsed,
5588 .data = (void *)&cmd_link_flow_control_set_pt,
5589 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5590 "Change pause time flow control parameter",
5592 (void *)&cmd_lfc_set_set,
5593 (void *)&cmd_lfc_set_flow_ctrl,
5594 (void *)&cmd_lfc_set_pause_time_str,
5595 (void *)&cmd_lfc_set_pause_time,
5596 (void *)&cmd_lfc_set_portid,
5601 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5602 .f = cmd_link_flow_ctrl_set_parsed,
5603 .data = (void *)&cmd_link_flow_control_set_xon,
5604 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5605 "Change send_xon flow control parameter",
5607 (void *)&cmd_lfc_set_set,
5608 (void *)&cmd_lfc_set_flow_ctrl,
5609 (void *)&cmd_lfc_set_send_xon_str,
5610 (void *)&cmd_lfc_set_send_xon,
5611 (void *)&cmd_lfc_set_portid,
5616 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5617 .f = cmd_link_flow_ctrl_set_parsed,
5618 .data = (void *)&cmd_link_flow_control_set_macfwd,
5619 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5620 "Change mac ctrl fwd flow control parameter",
5622 (void *)&cmd_lfc_set_set,
5623 (void *)&cmd_lfc_set_flow_ctrl,
5624 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5625 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5626 (void *)&cmd_lfc_set_portid,
5631 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5632 .f = cmd_link_flow_ctrl_set_parsed,
5633 .data = (void *)&cmd_link_flow_control_set_autoneg,
5634 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5635 "Change autoneg flow control parameter",
5637 (void *)&cmd_lfc_set_set,
5638 (void *)&cmd_lfc_set_flow_ctrl,
5639 (void *)&cmd_lfc_set_autoneg_str,
5640 (void *)&cmd_lfc_set_autoneg,
5641 (void *)&cmd_lfc_set_portid,
5647 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5648 __attribute__((unused)) struct cmdline *cl,
5651 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5652 cmdline_parse_inst_t *cmd = data;
5653 struct rte_eth_fc_conf fc_conf;
5659 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5660 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5661 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5662 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5664 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5665 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5668 /* Partial command line, retrieve current configuration */
5670 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5672 printf("cannot get current flow ctrl parameters, return"
5673 "code = %d\n", ret);
5677 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5678 (fc_conf.mode == RTE_FC_FULL))
5680 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5681 (fc_conf.mode == RTE_FC_FULL))
5685 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5686 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5688 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5689 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5691 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5693 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5694 fc_conf.high_water = res->high_water;
5696 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5697 fc_conf.low_water = res->low_water;
5699 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5700 fc_conf.pause_time = res->pause_time;
5702 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5703 fc_conf.send_xon = res->send_xon;
5705 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5706 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5707 fc_conf.mac_ctrl_frame_fwd = 1;
5709 fc_conf.mac_ctrl_frame_fwd = 0;
5712 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5713 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5715 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5717 printf("bad flow contrl parameter, return code = %d \n", ret);
5720 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5721 struct cmd_priority_flow_ctrl_set_result {
5722 cmdline_fixed_string_t set;
5723 cmdline_fixed_string_t pfc_ctrl;
5724 cmdline_fixed_string_t rx;
5725 cmdline_fixed_string_t rx_pfc_mode;
5726 cmdline_fixed_string_t tx;
5727 cmdline_fixed_string_t tx_pfc_mode;
5728 uint32_t high_water;
5730 uint16_t pause_time;
5736 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5737 __attribute__((unused)) struct cmdline *cl,
5738 __attribute__((unused)) void *data)
5740 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5741 struct rte_eth_pfc_conf pfc_conf;
5742 int rx_fc_enable, tx_fc_enable;
5746 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5747 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5748 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5749 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5751 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5752 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5755 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5756 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5757 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5758 pfc_conf.fc.high_water = res->high_water;
5759 pfc_conf.fc.low_water = res->low_water;
5760 pfc_conf.fc.pause_time = res->pause_time;
5761 pfc_conf.priority = res->priority;
5763 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5765 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5768 cmdline_parse_token_string_t cmd_pfc_set_set =
5769 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5771 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5772 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5773 pfc_ctrl, "pfc_ctrl");
5774 cmdline_parse_token_string_t cmd_pfc_set_rx =
5775 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5777 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5778 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5779 rx_pfc_mode, "on#off");
5780 cmdline_parse_token_string_t cmd_pfc_set_tx =
5781 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5783 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5784 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5785 tx_pfc_mode, "on#off");
5786 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5787 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5788 high_water, UINT32);
5789 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5790 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5792 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5793 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5794 pause_time, UINT16);
5795 cmdline_parse_token_num_t cmd_pfc_set_priority =
5796 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5798 cmdline_parse_token_num_t cmd_pfc_set_portid =
5799 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5802 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5803 .f = cmd_priority_flow_ctrl_set_parsed,
5805 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5806 "<pause_time> <priority> <port_id>: "
5807 "Configure the Ethernet priority flow control",
5809 (void *)&cmd_pfc_set_set,
5810 (void *)&cmd_pfc_set_flow_ctrl,
5811 (void *)&cmd_pfc_set_rx,
5812 (void *)&cmd_pfc_set_rx_mode,
5813 (void *)&cmd_pfc_set_tx,
5814 (void *)&cmd_pfc_set_tx_mode,
5815 (void *)&cmd_pfc_set_high_water,
5816 (void *)&cmd_pfc_set_low_water,
5817 (void *)&cmd_pfc_set_pause_time,
5818 (void *)&cmd_pfc_set_priority,
5819 (void *)&cmd_pfc_set_portid,
5824 /* *** RESET CONFIGURATION *** */
5825 struct cmd_reset_result {
5826 cmdline_fixed_string_t reset;
5827 cmdline_fixed_string_t def;
5830 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5832 __attribute__((unused)) void *data)
5834 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5835 set_def_fwd_config();
5838 cmdline_parse_token_string_t cmd_reset_set =
5839 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5840 cmdline_parse_token_string_t cmd_reset_def =
5841 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5844 cmdline_parse_inst_t cmd_reset = {
5845 .f = cmd_reset_parsed,
5847 .help_str = "set default: Reset default forwarding configuration",
5849 (void *)&cmd_reset_set,
5850 (void *)&cmd_reset_def,
5855 /* *** START FORWARDING *** */
5856 struct cmd_start_result {
5857 cmdline_fixed_string_t start;
5860 cmdline_parse_token_string_t cmd_start_start =
5861 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5863 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5864 __attribute__((unused)) struct cmdline *cl,
5865 __attribute__((unused)) void *data)
5867 start_packet_forwarding(0);
5870 cmdline_parse_inst_t cmd_start = {
5871 .f = cmd_start_parsed,
5873 .help_str = "start: Start packet forwarding",
5875 (void *)&cmd_start_start,
5880 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5881 struct cmd_start_tx_first_result {
5882 cmdline_fixed_string_t start;
5883 cmdline_fixed_string_t tx_first;
5887 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5888 __attribute__((unused)) struct cmdline *cl,
5889 __attribute__((unused)) void *data)
5891 start_packet_forwarding(1);
5894 cmdline_parse_token_string_t cmd_start_tx_first_start =
5895 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5897 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5898 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5899 tx_first, "tx_first");
5901 cmdline_parse_inst_t cmd_start_tx_first = {
5902 .f = cmd_start_tx_first_parsed,
5904 .help_str = "start tx_first: Start packet forwarding, "
5905 "after sending 1 burst of packets",
5907 (void *)&cmd_start_tx_first_start,
5908 (void *)&cmd_start_tx_first_tx_first,
5913 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5914 struct cmd_start_tx_first_n_result {
5915 cmdline_fixed_string_t start;
5916 cmdline_fixed_string_t tx_first;
5921 cmd_start_tx_first_n_parsed(void *parsed_result,
5922 __attribute__((unused)) struct cmdline *cl,
5923 __attribute__((unused)) void *data)
5925 struct cmd_start_tx_first_n_result *res = parsed_result;
5927 start_packet_forwarding(res->tx_num);
5930 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5931 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5933 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5934 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5935 tx_first, "tx_first");
5936 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5937 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5940 cmdline_parse_inst_t cmd_start_tx_first_n = {
5941 .f = cmd_start_tx_first_n_parsed,
5943 .help_str = "start tx_first <num>: "
5944 "packet forwarding, after sending <num> bursts of packets",
5946 (void *)&cmd_start_tx_first_n_start,
5947 (void *)&cmd_start_tx_first_n_tx_first,
5948 (void *)&cmd_start_tx_first_n_tx_num,
5953 /* *** SET LINK UP *** */
5954 struct cmd_set_link_up_result {
5955 cmdline_fixed_string_t set;
5956 cmdline_fixed_string_t link_up;
5957 cmdline_fixed_string_t port;
5961 cmdline_parse_token_string_t cmd_set_link_up_set =
5962 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5963 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5964 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5966 cmdline_parse_token_string_t cmd_set_link_up_port =
5967 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5968 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5969 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5971 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5972 __attribute__((unused)) struct cmdline *cl,
5973 __attribute__((unused)) void *data)
5975 struct cmd_set_link_up_result *res = parsed_result;
5976 dev_set_link_up(res->port_id);
5979 cmdline_parse_inst_t cmd_set_link_up = {
5980 .f = cmd_set_link_up_parsed,
5982 .help_str = "set link-up port <port id>",
5984 (void *)&cmd_set_link_up_set,
5985 (void *)&cmd_set_link_up_link_up,
5986 (void *)&cmd_set_link_up_port,
5987 (void *)&cmd_set_link_up_port_id,
5992 /* *** SET LINK DOWN *** */
5993 struct cmd_set_link_down_result {
5994 cmdline_fixed_string_t set;
5995 cmdline_fixed_string_t link_down;
5996 cmdline_fixed_string_t port;
6000 cmdline_parse_token_string_t cmd_set_link_down_set =
6001 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6002 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6003 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6005 cmdline_parse_token_string_t cmd_set_link_down_port =
6006 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6007 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6008 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
6010 static void cmd_set_link_down_parsed(
6011 __attribute__((unused)) void *parsed_result,
6012 __attribute__((unused)) struct cmdline *cl,
6013 __attribute__((unused)) void *data)
6015 struct cmd_set_link_down_result *res = parsed_result;
6016 dev_set_link_down(res->port_id);
6019 cmdline_parse_inst_t cmd_set_link_down = {
6020 .f = cmd_set_link_down_parsed,
6022 .help_str = "set link-down port <port id>",
6024 (void *)&cmd_set_link_down_set,
6025 (void *)&cmd_set_link_down_link_down,
6026 (void *)&cmd_set_link_down_port,
6027 (void *)&cmd_set_link_down_port_id,
6032 /* *** SHOW CFG *** */
6033 struct cmd_showcfg_result {
6034 cmdline_fixed_string_t show;
6035 cmdline_fixed_string_t cfg;
6036 cmdline_fixed_string_t what;
6039 static void cmd_showcfg_parsed(void *parsed_result,
6040 __attribute__((unused)) struct cmdline *cl,
6041 __attribute__((unused)) void *data)
6043 struct cmd_showcfg_result *res = parsed_result;
6044 if (!strcmp(res->what, "rxtx"))
6045 rxtx_config_display();
6046 else if (!strcmp(res->what, "cores"))
6047 fwd_lcores_config_display();
6048 else if (!strcmp(res->what, "fwd"))
6049 pkt_fwd_config_display(&cur_fwd_config);
6050 else if (!strcmp(res->what, "txpkts"))
6051 show_tx_pkt_segments();
6054 cmdline_parse_token_string_t cmd_showcfg_show =
6055 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6056 cmdline_parse_token_string_t cmd_showcfg_port =
6057 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6058 cmdline_parse_token_string_t cmd_showcfg_what =
6059 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6060 "rxtx#cores#fwd#txpkts");
6062 cmdline_parse_inst_t cmd_showcfg = {
6063 .f = cmd_showcfg_parsed,
6065 .help_str = "show config rxtx|cores|fwd|txpkts",
6067 (void *)&cmd_showcfg_show,
6068 (void *)&cmd_showcfg_port,
6069 (void *)&cmd_showcfg_what,
6074 /* *** SHOW ALL PORT INFO *** */
6075 struct cmd_showportall_result {
6076 cmdline_fixed_string_t show;
6077 cmdline_fixed_string_t port;
6078 cmdline_fixed_string_t what;
6079 cmdline_fixed_string_t all;
6082 static void cmd_showportall_parsed(void *parsed_result,
6083 __attribute__((unused)) struct cmdline *cl,
6084 __attribute__((unused)) void *data)
6088 struct cmd_showportall_result *res = parsed_result;
6089 if (!strcmp(res->show, "clear")) {
6090 if (!strcmp(res->what, "stats"))
6091 RTE_ETH_FOREACH_DEV(i)
6093 else if (!strcmp(res->what, "xstats"))
6094 RTE_ETH_FOREACH_DEV(i)
6095 nic_xstats_clear(i);
6096 } else if (!strcmp(res->what, "info"))
6097 RTE_ETH_FOREACH_DEV(i)
6098 port_infos_display(i);
6099 else if (!strcmp(res->what, "stats"))
6100 RTE_ETH_FOREACH_DEV(i)
6101 nic_stats_display(i);
6102 else if (!strcmp(res->what, "xstats"))
6103 RTE_ETH_FOREACH_DEV(i)
6104 nic_xstats_display(i);
6105 else if (!strcmp(res->what, "fdir"))
6106 RTE_ETH_FOREACH_DEV(i)
6108 else if (!strcmp(res->what, "stat_qmap"))
6109 RTE_ETH_FOREACH_DEV(i)
6110 nic_stats_mapping_display(i);
6111 else if (!strcmp(res->what, "dcb_tc"))
6112 RTE_ETH_FOREACH_DEV(i)
6113 port_dcb_info_display(i);
6114 else if (!strcmp(res->what, "cap"))
6115 RTE_ETH_FOREACH_DEV(i)
6116 port_offload_cap_display(i);
6119 cmdline_parse_token_string_t cmd_showportall_show =
6120 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6122 cmdline_parse_token_string_t cmd_showportall_port =
6123 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6124 cmdline_parse_token_string_t cmd_showportall_what =
6125 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6126 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6127 cmdline_parse_token_string_t cmd_showportall_all =
6128 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6129 cmdline_parse_inst_t cmd_showportall = {
6130 .f = cmd_showportall_parsed,
6132 .help_str = "show|clear port "
6133 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6135 (void *)&cmd_showportall_show,
6136 (void *)&cmd_showportall_port,
6137 (void *)&cmd_showportall_what,
6138 (void *)&cmd_showportall_all,
6143 /* *** SHOW PORT INFO *** */
6144 struct cmd_showport_result {
6145 cmdline_fixed_string_t show;
6146 cmdline_fixed_string_t port;
6147 cmdline_fixed_string_t what;
6151 static void cmd_showport_parsed(void *parsed_result,
6152 __attribute__((unused)) struct cmdline *cl,
6153 __attribute__((unused)) void *data)
6155 struct cmd_showport_result *res = parsed_result;
6156 if (!strcmp(res->show, "clear")) {
6157 if (!strcmp(res->what, "stats"))
6158 nic_stats_clear(res->portnum);
6159 else if (!strcmp(res->what, "xstats"))
6160 nic_xstats_clear(res->portnum);
6161 } else if (!strcmp(res->what, "info"))
6162 port_infos_display(res->portnum);
6163 else if (!strcmp(res->what, "stats"))
6164 nic_stats_display(res->portnum);
6165 else if (!strcmp(res->what, "xstats"))
6166 nic_xstats_display(res->portnum);
6167 else if (!strcmp(res->what, "fdir"))
6168 fdir_get_infos(res->portnum);
6169 else if (!strcmp(res->what, "stat_qmap"))
6170 nic_stats_mapping_display(res->portnum);
6171 else if (!strcmp(res->what, "dcb_tc"))
6172 port_dcb_info_display(res->portnum);
6173 else if (!strcmp(res->what, "cap"))
6174 port_offload_cap_display(res->portnum);
6177 cmdline_parse_token_string_t cmd_showport_show =
6178 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6180 cmdline_parse_token_string_t cmd_showport_port =
6181 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6182 cmdline_parse_token_string_t cmd_showport_what =
6183 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6184 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6185 cmdline_parse_token_num_t cmd_showport_portnum =
6186 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
6188 cmdline_parse_inst_t cmd_showport = {
6189 .f = cmd_showport_parsed,
6191 .help_str = "show|clear port "
6192 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6195 (void *)&cmd_showport_show,
6196 (void *)&cmd_showport_port,
6197 (void *)&cmd_showport_what,
6198 (void *)&cmd_showport_portnum,
6203 /* *** SHOW QUEUE INFO *** */
6204 struct cmd_showqueue_result {
6205 cmdline_fixed_string_t show;
6206 cmdline_fixed_string_t type;
6207 cmdline_fixed_string_t what;
6213 cmd_showqueue_parsed(void *parsed_result,
6214 __attribute__((unused)) struct cmdline *cl,
6215 __attribute__((unused)) void *data)
6217 struct cmd_showqueue_result *res = parsed_result;
6219 if (!strcmp(res->type, "rxq"))
6220 rx_queue_infos_display(res->portnum, res->queuenum);
6221 else if (!strcmp(res->type, "txq"))
6222 tx_queue_infos_display(res->portnum, res->queuenum);
6225 cmdline_parse_token_string_t cmd_showqueue_show =
6226 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6227 cmdline_parse_token_string_t cmd_showqueue_type =
6228 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6229 cmdline_parse_token_string_t cmd_showqueue_what =
6230 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6231 cmdline_parse_token_num_t cmd_showqueue_portnum =
6232 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6233 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6234 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6236 cmdline_parse_inst_t cmd_showqueue = {
6237 .f = cmd_showqueue_parsed,
6239 .help_str = "show rxq|txq info <port_id> <queue_id>",
6241 (void *)&cmd_showqueue_show,
6242 (void *)&cmd_showqueue_type,
6243 (void *)&cmd_showqueue_what,
6244 (void *)&cmd_showqueue_portnum,
6245 (void *)&cmd_showqueue_queuenum,
6250 /* *** READ PORT REGISTER *** */
6251 struct cmd_read_reg_result {
6252 cmdline_fixed_string_t read;
6253 cmdline_fixed_string_t reg;
6259 cmd_read_reg_parsed(void *parsed_result,
6260 __attribute__((unused)) struct cmdline *cl,
6261 __attribute__((unused)) void *data)
6263 struct cmd_read_reg_result *res = parsed_result;
6264 port_reg_display(res->port_id, res->reg_off);
6267 cmdline_parse_token_string_t cmd_read_reg_read =
6268 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6269 cmdline_parse_token_string_t cmd_read_reg_reg =
6270 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6271 cmdline_parse_token_num_t cmd_read_reg_port_id =
6272 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6273 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6274 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6276 cmdline_parse_inst_t cmd_read_reg = {
6277 .f = cmd_read_reg_parsed,
6279 .help_str = "read reg <port_id> <reg_off>",
6281 (void *)&cmd_read_reg_read,
6282 (void *)&cmd_read_reg_reg,
6283 (void *)&cmd_read_reg_port_id,
6284 (void *)&cmd_read_reg_reg_off,
6289 /* *** READ PORT REGISTER BIT FIELD *** */
6290 struct cmd_read_reg_bit_field_result {
6291 cmdline_fixed_string_t read;
6292 cmdline_fixed_string_t regfield;
6300 cmd_read_reg_bit_field_parsed(void *parsed_result,
6301 __attribute__((unused)) struct cmdline *cl,
6302 __attribute__((unused)) void *data)
6304 struct cmd_read_reg_bit_field_result *res = parsed_result;
6305 port_reg_bit_field_display(res->port_id, res->reg_off,
6306 res->bit1_pos, res->bit2_pos);
6309 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6310 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6312 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6313 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6314 regfield, "regfield");
6315 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6316 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6318 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6319 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6321 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6322 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6324 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6325 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6328 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6329 .f = cmd_read_reg_bit_field_parsed,
6331 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6332 "Read register bit field between bit_x and bit_y included",
6334 (void *)&cmd_read_reg_bit_field_read,
6335 (void *)&cmd_read_reg_bit_field_regfield,
6336 (void *)&cmd_read_reg_bit_field_port_id,
6337 (void *)&cmd_read_reg_bit_field_reg_off,
6338 (void *)&cmd_read_reg_bit_field_bit1_pos,
6339 (void *)&cmd_read_reg_bit_field_bit2_pos,
6344 /* *** READ PORT REGISTER BIT *** */
6345 struct cmd_read_reg_bit_result {
6346 cmdline_fixed_string_t read;
6347 cmdline_fixed_string_t regbit;
6354 cmd_read_reg_bit_parsed(void *parsed_result,
6355 __attribute__((unused)) struct cmdline *cl,
6356 __attribute__((unused)) void *data)
6358 struct cmd_read_reg_bit_result *res = parsed_result;
6359 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6362 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6363 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6364 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6365 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6367 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6368 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6369 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6370 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6371 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6372 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6374 cmdline_parse_inst_t cmd_read_reg_bit = {
6375 .f = cmd_read_reg_bit_parsed,
6377 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6379 (void *)&cmd_read_reg_bit_read,
6380 (void *)&cmd_read_reg_bit_regbit,
6381 (void *)&cmd_read_reg_bit_port_id,
6382 (void *)&cmd_read_reg_bit_reg_off,
6383 (void *)&cmd_read_reg_bit_bit_pos,
6388 /* *** WRITE PORT REGISTER *** */
6389 struct cmd_write_reg_result {
6390 cmdline_fixed_string_t write;
6391 cmdline_fixed_string_t reg;
6398 cmd_write_reg_parsed(void *parsed_result,
6399 __attribute__((unused)) struct cmdline *cl,
6400 __attribute__((unused)) void *data)
6402 struct cmd_write_reg_result *res = parsed_result;
6403 port_reg_set(res->port_id, res->reg_off, res->value);
6406 cmdline_parse_token_string_t cmd_write_reg_write =
6407 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6408 cmdline_parse_token_string_t cmd_write_reg_reg =
6409 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6410 cmdline_parse_token_num_t cmd_write_reg_port_id =
6411 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6412 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6413 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6414 cmdline_parse_token_num_t cmd_write_reg_value =
6415 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6417 cmdline_parse_inst_t cmd_write_reg = {
6418 .f = cmd_write_reg_parsed,
6420 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6422 (void *)&cmd_write_reg_write,
6423 (void *)&cmd_write_reg_reg,
6424 (void *)&cmd_write_reg_port_id,
6425 (void *)&cmd_write_reg_reg_off,
6426 (void *)&cmd_write_reg_value,
6431 /* *** WRITE PORT REGISTER BIT FIELD *** */
6432 struct cmd_write_reg_bit_field_result {
6433 cmdline_fixed_string_t write;
6434 cmdline_fixed_string_t regfield;
6443 cmd_write_reg_bit_field_parsed(void *parsed_result,
6444 __attribute__((unused)) struct cmdline *cl,
6445 __attribute__((unused)) void *data)
6447 struct cmd_write_reg_bit_field_result *res = parsed_result;
6448 port_reg_bit_field_set(res->port_id, res->reg_off,
6449 res->bit1_pos, res->bit2_pos, res->value);
6452 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6453 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6455 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6456 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6457 regfield, "regfield");
6458 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6459 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6461 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6462 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6464 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6465 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6467 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6468 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6470 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6471 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6474 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6475 .f = cmd_write_reg_bit_field_parsed,
6477 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6479 "Set register bit field between bit_x and bit_y included",
6481 (void *)&cmd_write_reg_bit_field_write,
6482 (void *)&cmd_write_reg_bit_field_regfield,
6483 (void *)&cmd_write_reg_bit_field_port_id,
6484 (void *)&cmd_write_reg_bit_field_reg_off,
6485 (void *)&cmd_write_reg_bit_field_bit1_pos,
6486 (void *)&cmd_write_reg_bit_field_bit2_pos,
6487 (void *)&cmd_write_reg_bit_field_value,
6492 /* *** WRITE PORT REGISTER BIT *** */
6493 struct cmd_write_reg_bit_result {
6494 cmdline_fixed_string_t write;
6495 cmdline_fixed_string_t regbit;
6503 cmd_write_reg_bit_parsed(void *parsed_result,
6504 __attribute__((unused)) struct cmdline *cl,
6505 __attribute__((unused)) void *data)
6507 struct cmd_write_reg_bit_result *res = parsed_result;
6508 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6511 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6512 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6514 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6515 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6517 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6518 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6519 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6520 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6521 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6522 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6523 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6524 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6526 cmdline_parse_inst_t cmd_write_reg_bit = {
6527 .f = cmd_write_reg_bit_parsed,
6529 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6532 (void *)&cmd_write_reg_bit_write,
6533 (void *)&cmd_write_reg_bit_regbit,
6534 (void *)&cmd_write_reg_bit_port_id,
6535 (void *)&cmd_write_reg_bit_reg_off,
6536 (void *)&cmd_write_reg_bit_bit_pos,
6537 (void *)&cmd_write_reg_bit_value,
6542 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6543 struct cmd_read_rxd_txd_result {
6544 cmdline_fixed_string_t read;
6545 cmdline_fixed_string_t rxd_txd;
6552 cmd_read_rxd_txd_parsed(void *parsed_result,
6553 __attribute__((unused)) struct cmdline *cl,
6554 __attribute__((unused)) void *data)
6556 struct cmd_read_rxd_txd_result *res = parsed_result;
6558 if (!strcmp(res->rxd_txd, "rxd"))
6559 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6560 else if (!strcmp(res->rxd_txd, "txd"))
6561 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6564 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6565 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6566 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6567 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6569 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6570 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6571 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6572 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6573 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6574 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6576 cmdline_parse_inst_t cmd_read_rxd_txd = {
6577 .f = cmd_read_rxd_txd_parsed,
6579 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6581 (void *)&cmd_read_rxd_txd_read,
6582 (void *)&cmd_read_rxd_txd_rxd_txd,
6583 (void *)&cmd_read_rxd_txd_port_id,
6584 (void *)&cmd_read_rxd_txd_queue_id,
6585 (void *)&cmd_read_rxd_txd_desc_id,
6591 struct cmd_quit_result {
6592 cmdline_fixed_string_t quit;
6595 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6597 __attribute__((unused)) void *data)
6603 cmdline_parse_token_string_t cmd_quit_quit =
6604 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6606 cmdline_parse_inst_t cmd_quit = {
6607 .f = cmd_quit_parsed,
6609 .help_str = "quit: Exit application",
6611 (void *)&cmd_quit_quit,
6616 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6617 struct cmd_mac_addr_result {
6618 cmdline_fixed_string_t mac_addr_cmd;
6619 cmdline_fixed_string_t what;
6621 struct ether_addr address;
6624 static void cmd_mac_addr_parsed(void *parsed_result,
6625 __attribute__((unused)) struct cmdline *cl,
6626 __attribute__((unused)) void *data)
6628 struct cmd_mac_addr_result *res = parsed_result;
6631 if (strcmp(res->what, "add") == 0)
6632 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6633 else if (strcmp(res->what, "set") == 0)
6634 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6637 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6639 /* check the return value and print it if is < 0 */
6641 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6645 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6646 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6648 cmdline_parse_token_string_t cmd_mac_addr_what =
6649 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6651 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6652 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6653 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6654 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6656 cmdline_parse_inst_t cmd_mac_addr = {
6657 .f = cmd_mac_addr_parsed,
6659 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6660 "Add/Remove/Set MAC address on port_id",
6662 (void *)&cmd_mac_addr_cmd,
6663 (void *)&cmd_mac_addr_what,
6664 (void *)&cmd_mac_addr_portnum,
6665 (void *)&cmd_mac_addr_addr,
6671 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6672 struct cmd_set_qmap_result {
6673 cmdline_fixed_string_t set;
6674 cmdline_fixed_string_t qmap;
6675 cmdline_fixed_string_t what;
6682 cmd_set_qmap_parsed(void *parsed_result,
6683 __attribute__((unused)) struct cmdline *cl,
6684 __attribute__((unused)) void *data)
6686 struct cmd_set_qmap_result *res = parsed_result;
6687 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6689 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6692 cmdline_parse_token_string_t cmd_setqmap_set =
6693 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6695 cmdline_parse_token_string_t cmd_setqmap_qmap =
6696 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6698 cmdline_parse_token_string_t cmd_setqmap_what =
6699 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6701 cmdline_parse_token_num_t cmd_setqmap_portid =
6702 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6704 cmdline_parse_token_num_t cmd_setqmap_queueid =
6705 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6707 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6708 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6711 cmdline_parse_inst_t cmd_set_qmap = {
6712 .f = cmd_set_qmap_parsed,
6714 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6715 "Set statistics mapping value on tx|rx queue_id of port_id",
6717 (void *)&cmd_setqmap_set,
6718 (void *)&cmd_setqmap_qmap,
6719 (void *)&cmd_setqmap_what,
6720 (void *)&cmd_setqmap_portid,
6721 (void *)&cmd_setqmap_queueid,
6722 (void *)&cmd_setqmap_mapvalue,
6727 /* *** CONFIGURE UNICAST HASH TABLE *** */
6728 struct cmd_set_uc_hash_table {
6729 cmdline_fixed_string_t set;
6730 cmdline_fixed_string_t port;
6732 cmdline_fixed_string_t what;
6733 struct ether_addr address;
6734 cmdline_fixed_string_t mode;
6738 cmd_set_uc_hash_parsed(void *parsed_result,
6739 __attribute__((unused)) struct cmdline *cl,
6740 __attribute__((unused)) void *data)
6743 struct cmd_set_uc_hash_table *res = parsed_result;
6745 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6747 if (strcmp(res->what, "uta") == 0)
6748 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6749 &res->address,(uint8_t)is_on);
6751 printf("bad unicast hash table parameter, return code = %d \n", ret);
6755 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6756 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6758 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6759 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6761 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6762 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6764 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6765 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6767 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6768 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6770 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6771 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6774 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6775 .f = cmd_set_uc_hash_parsed,
6777 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6779 (void *)&cmd_set_uc_hash_set,
6780 (void *)&cmd_set_uc_hash_port,
6781 (void *)&cmd_set_uc_hash_portid,
6782 (void *)&cmd_set_uc_hash_what,
6783 (void *)&cmd_set_uc_hash_mac,
6784 (void *)&cmd_set_uc_hash_mode,
6789 struct cmd_set_uc_all_hash_table {
6790 cmdline_fixed_string_t set;
6791 cmdline_fixed_string_t port;
6793 cmdline_fixed_string_t what;
6794 cmdline_fixed_string_t value;
6795 cmdline_fixed_string_t mode;
6799 cmd_set_uc_all_hash_parsed(void *parsed_result,
6800 __attribute__((unused)) struct cmdline *cl,
6801 __attribute__((unused)) void *data)
6804 struct cmd_set_uc_all_hash_table *res = parsed_result;
6806 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6808 if ((strcmp(res->what, "uta") == 0) &&
6809 (strcmp(res->value, "all") == 0))
6810 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6812 printf("bad unicast hash table parameter,"
6813 "return code = %d \n", ret);
6816 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6817 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6819 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6820 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6822 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6823 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6825 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6826 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6828 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6829 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6831 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6832 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6835 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6836 .f = cmd_set_uc_all_hash_parsed,
6838 .help_str = "set port <port_id> uta all on|off",
6840 (void *)&cmd_set_uc_all_hash_set,
6841 (void *)&cmd_set_uc_all_hash_port,
6842 (void *)&cmd_set_uc_all_hash_portid,
6843 (void *)&cmd_set_uc_all_hash_what,
6844 (void *)&cmd_set_uc_all_hash_value,
6845 (void *)&cmd_set_uc_all_hash_mode,
6850 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6851 struct cmd_set_vf_macvlan_filter {
6852 cmdline_fixed_string_t set;
6853 cmdline_fixed_string_t port;
6855 cmdline_fixed_string_t vf;
6857 struct ether_addr address;
6858 cmdline_fixed_string_t filter_type;
6859 cmdline_fixed_string_t mode;
6863 cmd_set_vf_macvlan_parsed(void *parsed_result,
6864 __attribute__((unused)) struct cmdline *cl,
6865 __attribute__((unused)) void *data)
6868 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6869 struct rte_eth_mac_filter filter;
6871 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6873 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6875 /* set VF MAC filter */
6879 filter.dst_id = res->vf_id;
6881 if (!strcmp(res->filter_type, "exact-mac"))
6882 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6883 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6884 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6885 else if (!strcmp(res->filter_type, "hashmac"))
6886 filter.filter_type = RTE_MAC_HASH_MATCH;
6887 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6888 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6890 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6893 ret = rte_eth_dev_filter_ctrl(res->port_id,
6894 RTE_ETH_FILTER_MACVLAN,
6898 ret = rte_eth_dev_filter_ctrl(res->port_id,
6899 RTE_ETH_FILTER_MACVLAN,
6900 RTE_ETH_FILTER_DELETE,
6904 printf("bad set MAC hash parameter, return code = %d\n", ret);
6908 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6909 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6911 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6912 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6914 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6915 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6917 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6918 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6920 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6921 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6923 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6924 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6926 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6927 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6928 filter_type, "exact-mac#exact-mac-vlan"
6929 "#hashmac#hashmac-vlan");
6930 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6931 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6934 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6935 .f = cmd_set_vf_macvlan_parsed,
6937 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6938 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6939 "Exact match rule: exact match of MAC or MAC and VLAN; "
6940 "hash match rule: hash match of MAC and exact match of VLAN",
6942 (void *)&cmd_set_vf_macvlan_set,
6943 (void *)&cmd_set_vf_macvlan_port,
6944 (void *)&cmd_set_vf_macvlan_portid,
6945 (void *)&cmd_set_vf_macvlan_vf,
6946 (void *)&cmd_set_vf_macvlan_vf_id,
6947 (void *)&cmd_set_vf_macvlan_mac,
6948 (void *)&cmd_set_vf_macvlan_filter_type,
6949 (void *)&cmd_set_vf_macvlan_mode,
6954 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6955 struct cmd_set_vf_traffic {
6956 cmdline_fixed_string_t set;
6957 cmdline_fixed_string_t port;
6959 cmdline_fixed_string_t vf;
6961 cmdline_fixed_string_t what;
6962 cmdline_fixed_string_t mode;
6966 cmd_set_vf_traffic_parsed(void *parsed_result,
6967 __attribute__((unused)) struct cmdline *cl,
6968 __attribute__((unused)) void *data)
6970 struct cmd_set_vf_traffic *res = parsed_result;
6971 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6972 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6974 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6977 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6978 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6980 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6981 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6983 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6984 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6986 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6987 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6989 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6990 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6992 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6993 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6995 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6996 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6999 cmdline_parse_inst_t cmd_set_vf_traffic = {
7000 .f = cmd_set_vf_traffic_parsed,
7002 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7004 (void *)&cmd_setvf_traffic_set,
7005 (void *)&cmd_setvf_traffic_port,
7006 (void *)&cmd_setvf_traffic_portid,
7007 (void *)&cmd_setvf_traffic_vf,
7008 (void *)&cmd_setvf_traffic_vfid,
7009 (void *)&cmd_setvf_traffic_what,
7010 (void *)&cmd_setvf_traffic_mode,
7015 /* *** CONFIGURE VF RECEIVE MODE *** */
7016 struct cmd_set_vf_rxmode {
7017 cmdline_fixed_string_t set;
7018 cmdline_fixed_string_t port;
7020 cmdline_fixed_string_t vf;
7022 cmdline_fixed_string_t what;
7023 cmdline_fixed_string_t mode;
7024 cmdline_fixed_string_t on;
7028 cmd_set_vf_rxmode_parsed(void *parsed_result,
7029 __attribute__((unused)) struct cmdline *cl,
7030 __attribute__((unused)) void *data)
7033 uint16_t rx_mode = 0;
7034 struct cmd_set_vf_rxmode *res = parsed_result;
7036 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7037 if (!strcmp(res->what,"rxmode")) {
7038 if (!strcmp(res->mode, "AUPE"))
7039 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7040 else if (!strcmp(res->mode, "ROPE"))
7041 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7042 else if (!strcmp(res->mode, "BAM"))
7043 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7044 else if (!strncmp(res->mode, "MPE",3))
7045 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7048 #ifdef RTE_LIBRTE_IXGBE_PMD
7049 if (ret == -ENOTSUP)
7050 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7051 rx_mode, (uint8_t)is_on);
7053 #ifdef RTE_LIBRTE_BNXT_PMD
7054 if (ret == -ENOTSUP)
7055 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7056 rx_mode, (uint8_t)is_on);
7059 printf("bad VF receive mode parameter, return code = %d \n",
7063 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7064 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7066 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7067 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7069 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7070 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7072 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7073 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7075 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7076 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7078 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7079 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7081 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7082 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7083 mode, "AUPE#ROPE#BAM#MPE");
7084 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7085 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7088 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7089 .f = cmd_set_vf_rxmode_parsed,
7091 .help_str = "set port <port_id> vf <vf_id> rxmode "
7092 "AUPE|ROPE|BAM|MPE on|off",
7094 (void *)&cmd_set_vf_rxmode_set,
7095 (void *)&cmd_set_vf_rxmode_port,
7096 (void *)&cmd_set_vf_rxmode_portid,
7097 (void *)&cmd_set_vf_rxmode_vf,
7098 (void *)&cmd_set_vf_rxmode_vfid,
7099 (void *)&cmd_set_vf_rxmode_what,
7100 (void *)&cmd_set_vf_rxmode_mode,
7101 (void *)&cmd_set_vf_rxmode_on,
7106 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7107 struct cmd_vf_mac_addr_result {
7108 cmdline_fixed_string_t mac_addr_cmd;
7109 cmdline_fixed_string_t what;
7110 cmdline_fixed_string_t port;
7112 cmdline_fixed_string_t vf;
7114 struct ether_addr address;
7117 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7118 __attribute__((unused)) struct cmdline *cl,
7119 __attribute__((unused)) void *data)
7121 struct cmd_vf_mac_addr_result *res = parsed_result;
7124 if (strcmp(res->what, "add") == 0)
7125 ret = rte_eth_dev_mac_addr_add(res->port_num,
7126 &res->address, res->vf_num);
7128 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7132 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7133 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7134 mac_addr_cmd,"mac_addr");
7135 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7136 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7138 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7139 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7141 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7142 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7144 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7145 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7147 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7148 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7150 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7151 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7154 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7155 .f = cmd_vf_mac_addr_parsed,
7157 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7158 "Add MAC address filtering for a VF on port_id",
7160 (void *)&cmd_vf_mac_addr_cmd,
7161 (void *)&cmd_vf_mac_addr_what,
7162 (void *)&cmd_vf_mac_addr_port,
7163 (void *)&cmd_vf_mac_addr_portnum,
7164 (void *)&cmd_vf_mac_addr_vf,
7165 (void *)&cmd_vf_mac_addr_vfnum,
7166 (void *)&cmd_vf_mac_addr_addr,
7171 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7172 struct cmd_vf_rx_vlan_filter {
7173 cmdline_fixed_string_t rx_vlan;
7174 cmdline_fixed_string_t what;
7176 cmdline_fixed_string_t port;
7178 cmdline_fixed_string_t vf;
7183 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7184 __attribute__((unused)) struct cmdline *cl,
7185 __attribute__((unused)) void *data)
7187 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7190 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7192 #ifdef RTE_LIBRTE_IXGBE_PMD
7193 if (ret == -ENOTSUP)
7194 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7195 res->vlan_id, res->vf_mask, is_add);
7197 #ifdef RTE_LIBRTE_I40E_PMD
7198 if (ret == -ENOTSUP)
7199 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7200 res->vlan_id, res->vf_mask, is_add);
7202 #ifdef RTE_LIBRTE_BNXT_PMD
7203 if (ret == -ENOTSUP)
7204 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7205 res->vlan_id, res->vf_mask, is_add);
7212 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7213 res->vlan_id, res->vf_mask);
7216 printf("invalid port_id %d\n", res->port_id);
7219 printf("function not implemented or supported\n");
7222 printf("programming error: (%s)\n", strerror(-ret));
7226 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7227 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7228 rx_vlan, "rx_vlan");
7229 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7230 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7232 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7233 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7235 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7236 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7238 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7239 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7241 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7242 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7244 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7245 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7248 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7249 .f = cmd_vf_rx_vlan_filter_parsed,
7251 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7252 "(vf_mask = hexadecimal VF mask)",
7254 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7255 (void *)&cmd_vf_rx_vlan_filter_what,
7256 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7257 (void *)&cmd_vf_rx_vlan_filter_port,
7258 (void *)&cmd_vf_rx_vlan_filter_portid,
7259 (void *)&cmd_vf_rx_vlan_filter_vf,
7260 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7265 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7266 struct cmd_queue_rate_limit_result {
7267 cmdline_fixed_string_t set;
7268 cmdline_fixed_string_t port;
7270 cmdline_fixed_string_t queue;
7272 cmdline_fixed_string_t rate;
7276 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7277 __attribute__((unused)) struct cmdline *cl,
7278 __attribute__((unused)) void *data)
7280 struct cmd_queue_rate_limit_result *res = parsed_result;
7283 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7284 && (strcmp(res->queue, "queue") == 0)
7285 && (strcmp(res->rate, "rate") == 0))
7286 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7289 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7293 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7294 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7296 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7297 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7299 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7300 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7302 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7303 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7305 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7306 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7308 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7309 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7311 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7312 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7315 cmdline_parse_inst_t cmd_queue_rate_limit = {
7316 .f = cmd_queue_rate_limit_parsed,
7318 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7319 "Set rate limit for a queue on port_id",
7321 (void *)&cmd_queue_rate_limit_set,
7322 (void *)&cmd_queue_rate_limit_port,
7323 (void *)&cmd_queue_rate_limit_portnum,
7324 (void *)&cmd_queue_rate_limit_queue,
7325 (void *)&cmd_queue_rate_limit_queuenum,
7326 (void *)&cmd_queue_rate_limit_rate,
7327 (void *)&cmd_queue_rate_limit_ratenum,
7332 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7333 struct cmd_vf_rate_limit_result {
7334 cmdline_fixed_string_t set;
7335 cmdline_fixed_string_t port;
7337 cmdline_fixed_string_t vf;
7339 cmdline_fixed_string_t rate;
7341 cmdline_fixed_string_t q_msk;
7345 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7346 __attribute__((unused)) struct cmdline *cl,
7347 __attribute__((unused)) void *data)
7349 struct cmd_vf_rate_limit_result *res = parsed_result;
7352 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7353 && (strcmp(res->vf, "vf") == 0)
7354 && (strcmp(res->rate, "rate") == 0)
7355 && (strcmp(res->q_msk, "queue_mask") == 0))
7356 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7357 res->rate_num, res->q_msk_val);
7359 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7363 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7364 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7366 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7367 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7369 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7370 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7372 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7373 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7375 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7376 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7378 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7379 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7381 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7382 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7384 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7385 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7386 q_msk, "queue_mask");
7387 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7388 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7391 cmdline_parse_inst_t cmd_vf_rate_limit = {
7392 .f = cmd_vf_rate_limit_parsed,
7394 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7395 "queue_mask <queue_mask_value>: "
7396 "Set rate limit for queues of VF on port_id",
7398 (void *)&cmd_vf_rate_limit_set,
7399 (void *)&cmd_vf_rate_limit_port,
7400 (void *)&cmd_vf_rate_limit_portnum,
7401 (void *)&cmd_vf_rate_limit_vf,
7402 (void *)&cmd_vf_rate_limit_vfnum,
7403 (void *)&cmd_vf_rate_limit_rate,
7404 (void *)&cmd_vf_rate_limit_ratenum,
7405 (void *)&cmd_vf_rate_limit_q_msk,
7406 (void *)&cmd_vf_rate_limit_q_msk_val,
7411 /* *** ADD TUNNEL FILTER OF A PORT *** */
7412 struct cmd_tunnel_filter_result {
7413 cmdline_fixed_string_t cmd;
7414 cmdline_fixed_string_t what;
7416 struct ether_addr outer_mac;
7417 struct ether_addr inner_mac;
7418 cmdline_ipaddr_t ip_value;
7419 uint16_t inner_vlan;
7420 cmdline_fixed_string_t tunnel_type;
7421 cmdline_fixed_string_t filter_type;
7427 cmd_tunnel_filter_parsed(void *parsed_result,
7428 __attribute__((unused)) struct cmdline *cl,
7429 __attribute__((unused)) void *data)
7431 struct cmd_tunnel_filter_result *res = parsed_result;
7432 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7435 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7437 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7438 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7439 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7441 if (res->ip_value.family == AF_INET) {
7442 tunnel_filter_conf.ip_addr.ipv4_addr =
7443 res->ip_value.addr.ipv4.s_addr;
7444 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7446 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7447 &(res->ip_value.addr.ipv6),
7448 sizeof(struct in6_addr));
7449 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7452 if (!strcmp(res->filter_type, "imac-ivlan"))
7453 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7454 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7455 tunnel_filter_conf.filter_type =
7456 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7457 else if (!strcmp(res->filter_type, "imac-tenid"))
7458 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7459 else if (!strcmp(res->filter_type, "imac"))
7460 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7461 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7462 tunnel_filter_conf.filter_type =
7463 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7464 else if (!strcmp(res->filter_type, "oip"))
7465 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7466 else if (!strcmp(res->filter_type, "iip"))
7467 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7469 printf("The filter type is not supported");
7473 if (!strcmp(res->tunnel_type, "vxlan"))
7474 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7475 else if (!strcmp(res->tunnel_type, "nvgre"))
7476 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7477 else if (!strcmp(res->tunnel_type, "ipingre"))
7478 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7480 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7484 tunnel_filter_conf.tenant_id = res->tenant_id;
7485 tunnel_filter_conf.queue_id = res->queue_num;
7486 if (!strcmp(res->what, "add"))
7487 ret = rte_eth_dev_filter_ctrl(res->port_id,
7488 RTE_ETH_FILTER_TUNNEL,
7490 &tunnel_filter_conf);
7492 ret = rte_eth_dev_filter_ctrl(res->port_id,
7493 RTE_ETH_FILTER_TUNNEL,
7494 RTE_ETH_FILTER_DELETE,
7495 &tunnel_filter_conf);
7497 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7501 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7502 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7503 cmd, "tunnel_filter");
7504 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7505 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7507 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7508 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7510 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7511 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7513 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7514 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7516 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7517 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7518 inner_vlan, UINT16);
7519 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7520 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7522 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7523 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7524 tunnel_type, "vxlan#nvgre#ipingre");
7526 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7527 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7528 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7529 "imac#omac-imac-tenid");
7530 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7531 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7533 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7534 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7537 cmdline_parse_inst_t cmd_tunnel_filter = {
7538 .f = cmd_tunnel_filter_parsed,
7540 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7541 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7542 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7543 "<queue_id>: Add/Rm tunnel filter of a port",
7545 (void *)&cmd_tunnel_filter_cmd,
7546 (void *)&cmd_tunnel_filter_what,
7547 (void *)&cmd_tunnel_filter_port_id,
7548 (void *)&cmd_tunnel_filter_outer_mac,
7549 (void *)&cmd_tunnel_filter_inner_mac,
7550 (void *)&cmd_tunnel_filter_ip_value,
7551 (void *)&cmd_tunnel_filter_innner_vlan,
7552 (void *)&cmd_tunnel_filter_tunnel_type,
7553 (void *)&cmd_tunnel_filter_filter_type,
7554 (void *)&cmd_tunnel_filter_tenant_id,
7555 (void *)&cmd_tunnel_filter_queue_num,
7560 /* *** CONFIGURE TUNNEL UDP PORT *** */
7561 struct cmd_tunnel_udp_config {
7562 cmdline_fixed_string_t cmd;
7563 cmdline_fixed_string_t what;
7569 cmd_tunnel_udp_config_parsed(void *parsed_result,
7570 __attribute__((unused)) struct cmdline *cl,
7571 __attribute__((unused)) void *data)
7573 struct cmd_tunnel_udp_config *res = parsed_result;
7574 struct rte_eth_udp_tunnel tunnel_udp;
7577 tunnel_udp.udp_port = res->udp_port;
7579 if (!strcmp(res->cmd, "rx_vxlan_port"))
7580 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7582 if (!strcmp(res->what, "add"))
7583 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7586 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7590 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7593 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7594 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7595 cmd, "rx_vxlan_port");
7596 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7597 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7599 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7600 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7602 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7603 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7606 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7607 .f = cmd_tunnel_udp_config_parsed,
7609 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7610 "Add/Remove a tunneling UDP port filter",
7612 (void *)&cmd_tunnel_udp_config_cmd,
7613 (void *)&cmd_tunnel_udp_config_what,
7614 (void *)&cmd_tunnel_udp_config_udp_port,
7615 (void *)&cmd_tunnel_udp_config_port_id,
7620 /* *** GLOBAL CONFIG *** */
7621 struct cmd_global_config_result {
7622 cmdline_fixed_string_t cmd;
7624 cmdline_fixed_string_t cfg_type;
7629 cmd_global_config_parsed(void *parsed_result,
7630 __attribute__((unused)) struct cmdline *cl,
7631 __attribute__((unused)) void *data)
7633 struct cmd_global_config_result *res = parsed_result;
7634 struct rte_eth_global_cfg conf;
7637 memset(&conf, 0, sizeof(conf));
7638 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7639 conf.cfg.gre_key_len = res->len;
7640 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7641 RTE_ETH_FILTER_SET, &conf);
7643 printf("Global config error\n");
7646 cmdline_parse_token_string_t cmd_global_config_cmd =
7647 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7649 cmdline_parse_token_num_t cmd_global_config_port_id =
7650 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7651 cmdline_parse_token_string_t cmd_global_config_type =
7652 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7653 cfg_type, "gre-key-len");
7654 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7655 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7658 cmdline_parse_inst_t cmd_global_config = {
7659 .f = cmd_global_config_parsed,
7660 .data = (void *)NULL,
7661 .help_str = "global_config <port_id> gre-key-len <key_len>",
7663 (void *)&cmd_global_config_cmd,
7664 (void *)&cmd_global_config_port_id,
7665 (void *)&cmd_global_config_type,
7666 (void *)&cmd_global_config_gre_key_len,
7671 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7672 struct cmd_set_mirror_mask_result {
7673 cmdline_fixed_string_t set;
7674 cmdline_fixed_string_t port;
7676 cmdline_fixed_string_t mirror;
7678 cmdline_fixed_string_t what;
7679 cmdline_fixed_string_t value;
7680 cmdline_fixed_string_t dstpool;
7682 cmdline_fixed_string_t on;
7685 cmdline_parse_token_string_t cmd_mirror_mask_set =
7686 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7688 cmdline_parse_token_string_t cmd_mirror_mask_port =
7689 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7691 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7692 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7694 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7695 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7696 mirror, "mirror-rule");
7697 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7698 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7700 cmdline_parse_token_string_t cmd_mirror_mask_what =
7701 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7702 what, "pool-mirror-up#pool-mirror-down"
7704 cmdline_parse_token_string_t cmd_mirror_mask_value =
7705 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7707 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7708 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7709 dstpool, "dst-pool");
7710 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7711 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7713 cmdline_parse_token_string_t cmd_mirror_mask_on =
7714 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7718 cmd_set_mirror_mask_parsed(void *parsed_result,
7719 __attribute__((unused)) struct cmdline *cl,
7720 __attribute__((unused)) void *data)
7723 struct cmd_set_mirror_mask_result *res = parsed_result;
7724 struct rte_eth_mirror_conf mr_conf;
7726 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7728 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7730 mr_conf.dst_pool = res->dstpool_id;
7732 if (!strcmp(res->what, "pool-mirror-up")) {
7733 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7734 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7735 } else if (!strcmp(res->what, "pool-mirror-down")) {
7736 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7737 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7738 } else if (!strcmp(res->what, "vlan-mirror")) {
7739 mr_conf.rule_type = ETH_MIRROR_VLAN;
7740 nb_item = parse_item_list(res->value, "vlan",
7741 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7745 for (i = 0; i < nb_item; i++) {
7746 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7747 printf("Invalid vlan_id: must be < 4096\n");
7751 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7752 mr_conf.vlan.vlan_mask |= 1ULL << i;
7756 if (!strcmp(res->on, "on"))
7757 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7760 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7763 printf("mirror rule add error: (%s)\n", strerror(-ret));
7766 cmdline_parse_inst_t cmd_set_mirror_mask = {
7767 .f = cmd_set_mirror_mask_parsed,
7769 .help_str = "set port <port_id> mirror-rule <rule_id> "
7770 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7771 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7773 (void *)&cmd_mirror_mask_set,
7774 (void *)&cmd_mirror_mask_port,
7775 (void *)&cmd_mirror_mask_portid,
7776 (void *)&cmd_mirror_mask_mirror,
7777 (void *)&cmd_mirror_mask_ruleid,
7778 (void *)&cmd_mirror_mask_what,
7779 (void *)&cmd_mirror_mask_value,
7780 (void *)&cmd_mirror_mask_dstpool,
7781 (void *)&cmd_mirror_mask_poolid,
7782 (void *)&cmd_mirror_mask_on,
7787 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7788 struct cmd_set_mirror_link_result {
7789 cmdline_fixed_string_t set;
7790 cmdline_fixed_string_t port;
7792 cmdline_fixed_string_t mirror;
7794 cmdline_fixed_string_t what;
7795 cmdline_fixed_string_t dstpool;
7797 cmdline_fixed_string_t on;
7800 cmdline_parse_token_string_t cmd_mirror_link_set =
7801 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7803 cmdline_parse_token_string_t cmd_mirror_link_port =
7804 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7806 cmdline_parse_token_num_t cmd_mirror_link_portid =
7807 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7809 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7810 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7811 mirror, "mirror-rule");
7812 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7813 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7815 cmdline_parse_token_string_t cmd_mirror_link_what =
7816 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7817 what, "uplink-mirror#downlink-mirror");
7818 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7819 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7820 dstpool, "dst-pool");
7821 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7822 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7824 cmdline_parse_token_string_t cmd_mirror_link_on =
7825 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7829 cmd_set_mirror_link_parsed(void *parsed_result,
7830 __attribute__((unused)) struct cmdline *cl,
7831 __attribute__((unused)) void *data)
7834 struct cmd_set_mirror_link_result *res = parsed_result;
7835 struct rte_eth_mirror_conf mr_conf;
7837 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7838 if (!strcmp(res->what, "uplink-mirror"))
7839 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7841 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7843 mr_conf.dst_pool = res->dstpool_id;
7845 if (!strcmp(res->on, "on"))
7846 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7849 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7852 /* check the return value and print it if is < 0 */
7854 printf("mirror rule add error: (%s)\n", strerror(-ret));
7858 cmdline_parse_inst_t cmd_set_mirror_link = {
7859 .f = cmd_set_mirror_link_parsed,
7861 .help_str = "set port <port_id> mirror-rule <rule_id> "
7862 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7864 (void *)&cmd_mirror_link_set,
7865 (void *)&cmd_mirror_link_port,
7866 (void *)&cmd_mirror_link_portid,
7867 (void *)&cmd_mirror_link_mirror,
7868 (void *)&cmd_mirror_link_ruleid,
7869 (void *)&cmd_mirror_link_what,
7870 (void *)&cmd_mirror_link_dstpool,
7871 (void *)&cmd_mirror_link_poolid,
7872 (void *)&cmd_mirror_link_on,
7877 /* *** RESET VM MIRROR RULE *** */
7878 struct cmd_rm_mirror_rule_result {
7879 cmdline_fixed_string_t reset;
7880 cmdline_fixed_string_t port;
7882 cmdline_fixed_string_t mirror;
7886 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7887 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7889 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7890 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7892 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7893 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7895 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7896 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7897 mirror, "mirror-rule");
7898 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7899 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7903 cmd_reset_mirror_rule_parsed(void *parsed_result,
7904 __attribute__((unused)) struct cmdline *cl,
7905 __attribute__((unused)) void *data)
7908 struct cmd_set_mirror_link_result *res = parsed_result;
7910 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7912 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7915 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7916 .f = cmd_reset_mirror_rule_parsed,
7918 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7920 (void *)&cmd_rm_mirror_rule_reset,
7921 (void *)&cmd_rm_mirror_rule_port,
7922 (void *)&cmd_rm_mirror_rule_portid,
7923 (void *)&cmd_rm_mirror_rule_mirror,
7924 (void *)&cmd_rm_mirror_rule_ruleid,
7929 /* ******************************************************************************** */
7931 struct cmd_dump_result {
7932 cmdline_fixed_string_t dump;
7936 dump_struct_sizes(void)
7938 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7939 DUMP_SIZE(struct rte_mbuf);
7940 DUMP_SIZE(struct rte_mempool);
7941 DUMP_SIZE(struct rte_ring);
7945 static void cmd_dump_parsed(void *parsed_result,
7946 __attribute__((unused)) struct cmdline *cl,
7947 __attribute__((unused)) void *data)
7949 struct cmd_dump_result *res = parsed_result;
7951 if (!strcmp(res->dump, "dump_physmem"))
7952 rte_dump_physmem_layout(stdout);
7953 else if (!strcmp(res->dump, "dump_memzone"))
7954 rte_memzone_dump(stdout);
7955 else if (!strcmp(res->dump, "dump_struct_sizes"))
7956 dump_struct_sizes();
7957 else if (!strcmp(res->dump, "dump_ring"))
7958 rte_ring_list_dump(stdout);
7959 else if (!strcmp(res->dump, "dump_mempool"))
7960 rte_mempool_list_dump(stdout);
7961 else if (!strcmp(res->dump, "dump_devargs"))
7962 rte_eal_devargs_dump(stdout);
7963 else if (!strcmp(res->dump, "dump_log_types"))
7964 rte_log_dump(stdout);
7967 cmdline_parse_token_string_t cmd_dump_dump =
7968 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7971 "dump_struct_sizes#"
7977 cmdline_parse_inst_t cmd_dump = {
7978 .f = cmd_dump_parsed, /* function to call */
7979 .data = NULL, /* 2nd arg of func */
7980 .help_str = "Dump status",
7981 .tokens = { /* token list, NULL terminated */
7982 (void *)&cmd_dump_dump,
7987 /* ******************************************************************************** */
7989 struct cmd_dump_one_result {
7990 cmdline_fixed_string_t dump;
7991 cmdline_fixed_string_t name;
7994 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7995 __attribute__((unused)) void *data)
7997 struct cmd_dump_one_result *res = parsed_result;
7999 if (!strcmp(res->dump, "dump_ring")) {
8001 r = rte_ring_lookup(res->name);
8003 cmdline_printf(cl, "Cannot find ring\n");
8006 rte_ring_dump(stdout, r);
8007 } else if (!strcmp(res->dump, "dump_mempool")) {
8008 struct rte_mempool *mp;
8009 mp = rte_mempool_lookup(res->name);
8011 cmdline_printf(cl, "Cannot find mempool\n");
8014 rte_mempool_dump(stdout, mp);
8018 cmdline_parse_token_string_t cmd_dump_one_dump =
8019 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8020 "dump_ring#dump_mempool");
8022 cmdline_parse_token_string_t cmd_dump_one_name =
8023 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8025 cmdline_parse_inst_t cmd_dump_one = {
8026 .f = cmd_dump_one_parsed, /* function to call */
8027 .data = NULL, /* 2nd arg of func */
8028 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8029 .tokens = { /* token list, NULL terminated */
8030 (void *)&cmd_dump_one_dump,
8031 (void *)&cmd_dump_one_name,
8036 /* *** Add/Del syn filter *** */
8037 struct cmd_syn_filter_result {
8038 cmdline_fixed_string_t filter;
8040 cmdline_fixed_string_t ops;
8041 cmdline_fixed_string_t priority;
8042 cmdline_fixed_string_t high;
8043 cmdline_fixed_string_t queue;
8048 cmd_syn_filter_parsed(void *parsed_result,
8049 __attribute__((unused)) struct cmdline *cl,
8050 __attribute__((unused)) void *data)
8052 struct cmd_syn_filter_result *res = parsed_result;
8053 struct rte_eth_syn_filter syn_filter;
8056 ret = rte_eth_dev_filter_supported(res->port_id,
8057 RTE_ETH_FILTER_SYN);
8059 printf("syn filter is not supported on port %u.\n",
8064 memset(&syn_filter, 0, sizeof(syn_filter));
8066 if (!strcmp(res->ops, "add")) {
8067 if (!strcmp(res->high, "high"))
8068 syn_filter.hig_pri = 1;
8070 syn_filter.hig_pri = 0;
8072 syn_filter.queue = res->queue_id;
8073 ret = rte_eth_dev_filter_ctrl(res->port_id,
8078 ret = rte_eth_dev_filter_ctrl(res->port_id,
8080 RTE_ETH_FILTER_DELETE,
8084 printf("syn filter programming error: (%s)\n",
8088 cmdline_parse_token_string_t cmd_syn_filter_filter =
8089 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8090 filter, "syn_filter");
8091 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8092 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8094 cmdline_parse_token_string_t cmd_syn_filter_ops =
8095 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8097 cmdline_parse_token_string_t cmd_syn_filter_priority =
8098 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8099 priority, "priority");
8100 cmdline_parse_token_string_t cmd_syn_filter_high =
8101 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8103 cmdline_parse_token_string_t cmd_syn_filter_queue =
8104 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8106 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8107 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8110 cmdline_parse_inst_t cmd_syn_filter = {
8111 .f = cmd_syn_filter_parsed,
8113 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8114 "<queue_id>: Add/Delete syn filter",
8116 (void *)&cmd_syn_filter_filter,
8117 (void *)&cmd_syn_filter_port_id,
8118 (void *)&cmd_syn_filter_ops,
8119 (void *)&cmd_syn_filter_priority,
8120 (void *)&cmd_syn_filter_high,
8121 (void *)&cmd_syn_filter_queue,
8122 (void *)&cmd_syn_filter_queue_id,
8127 /* *** ADD/REMOVE A 2tuple FILTER *** */
8128 struct cmd_2tuple_filter_result {
8129 cmdline_fixed_string_t filter;
8131 cmdline_fixed_string_t ops;
8132 cmdline_fixed_string_t dst_port;
8133 uint16_t dst_port_value;
8134 cmdline_fixed_string_t protocol;
8135 uint8_t protocol_value;
8136 cmdline_fixed_string_t mask;
8138 cmdline_fixed_string_t tcp_flags;
8139 uint8_t tcp_flags_value;
8140 cmdline_fixed_string_t priority;
8141 uint8_t priority_value;
8142 cmdline_fixed_string_t queue;
8147 cmd_2tuple_filter_parsed(void *parsed_result,
8148 __attribute__((unused)) struct cmdline *cl,
8149 __attribute__((unused)) void *data)
8151 struct rte_eth_ntuple_filter filter;
8152 struct cmd_2tuple_filter_result *res = parsed_result;
8155 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8157 printf("ntuple filter is not supported on port %u.\n",
8162 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8164 filter.flags = RTE_2TUPLE_FLAGS;
8165 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8166 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8167 filter.proto = res->protocol_value;
8168 filter.priority = res->priority_value;
8169 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8170 printf("nonzero tcp_flags is only meaningful"
8171 " when protocol is TCP.\n");
8174 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8175 printf("invalid TCP flags.\n");
8179 if (res->tcp_flags_value != 0) {
8180 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8181 filter.tcp_flags = res->tcp_flags_value;
8184 /* need convert to big endian. */
8185 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8186 filter.queue = res->queue_id;
8188 if (!strcmp(res->ops, "add"))
8189 ret = rte_eth_dev_filter_ctrl(res->port_id,
8190 RTE_ETH_FILTER_NTUPLE,
8194 ret = rte_eth_dev_filter_ctrl(res->port_id,
8195 RTE_ETH_FILTER_NTUPLE,
8196 RTE_ETH_FILTER_DELETE,
8199 printf("2tuple filter programming error: (%s)\n",
8204 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
8205 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8206 filter, "2tuple_filter");
8207 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
8208 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8210 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
8211 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8213 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
8214 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8215 dst_port, "dst_port");
8216 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
8217 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8218 dst_port_value, UINT16);
8219 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
8220 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8221 protocol, "protocol");
8222 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
8223 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8224 protocol_value, UINT8);
8225 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8226 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8228 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8229 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8231 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8232 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8233 tcp_flags, "tcp_flags");
8234 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8235 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8236 tcp_flags_value, UINT8);
8237 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8238 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8239 priority, "priority");
8240 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8241 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8242 priority_value, UINT8);
8243 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8244 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8246 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8247 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8250 cmdline_parse_inst_t cmd_2tuple_filter = {
8251 .f = cmd_2tuple_filter_parsed,
8253 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8254 "<value> mask <value> tcp_flags <value> priority <value> queue "
8255 "<queue_id>: Add a 2tuple filter",
8257 (void *)&cmd_2tuple_filter_filter,
8258 (void *)&cmd_2tuple_filter_port_id,
8259 (void *)&cmd_2tuple_filter_ops,
8260 (void *)&cmd_2tuple_filter_dst_port,
8261 (void *)&cmd_2tuple_filter_dst_port_value,
8262 (void *)&cmd_2tuple_filter_protocol,
8263 (void *)&cmd_2tuple_filter_protocol_value,
8264 (void *)&cmd_2tuple_filter_mask,
8265 (void *)&cmd_2tuple_filter_mask_value,
8266 (void *)&cmd_2tuple_filter_tcp_flags,
8267 (void *)&cmd_2tuple_filter_tcp_flags_value,
8268 (void *)&cmd_2tuple_filter_priority,
8269 (void *)&cmd_2tuple_filter_priority_value,
8270 (void *)&cmd_2tuple_filter_queue,
8271 (void *)&cmd_2tuple_filter_queue_id,
8276 /* *** ADD/REMOVE A 5tuple FILTER *** */
8277 struct cmd_5tuple_filter_result {
8278 cmdline_fixed_string_t filter;
8280 cmdline_fixed_string_t ops;
8281 cmdline_fixed_string_t dst_ip;
8282 cmdline_ipaddr_t dst_ip_value;
8283 cmdline_fixed_string_t src_ip;
8284 cmdline_ipaddr_t src_ip_value;
8285 cmdline_fixed_string_t dst_port;
8286 uint16_t dst_port_value;
8287 cmdline_fixed_string_t src_port;
8288 uint16_t src_port_value;
8289 cmdline_fixed_string_t protocol;
8290 uint8_t protocol_value;
8291 cmdline_fixed_string_t mask;
8293 cmdline_fixed_string_t tcp_flags;
8294 uint8_t tcp_flags_value;
8295 cmdline_fixed_string_t priority;
8296 uint8_t priority_value;
8297 cmdline_fixed_string_t queue;
8302 cmd_5tuple_filter_parsed(void *parsed_result,
8303 __attribute__((unused)) struct cmdline *cl,
8304 __attribute__((unused)) void *data)
8306 struct rte_eth_ntuple_filter filter;
8307 struct cmd_5tuple_filter_result *res = parsed_result;
8310 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8312 printf("ntuple filter is not supported on port %u.\n",
8317 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8319 filter.flags = RTE_5TUPLE_FLAGS;
8320 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8321 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8322 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8323 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8324 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8325 filter.proto = res->protocol_value;
8326 filter.priority = res->priority_value;
8327 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8328 printf("nonzero tcp_flags is only meaningful"
8329 " when protocol is TCP.\n");
8332 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8333 printf("invalid TCP flags.\n");
8337 if (res->tcp_flags_value != 0) {
8338 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8339 filter.tcp_flags = res->tcp_flags_value;
8342 if (res->dst_ip_value.family == AF_INET)
8343 /* no need to convert, already big endian. */
8344 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8346 if (filter.dst_ip_mask == 0) {
8347 printf("can not support ipv6 involved compare.\n");
8353 if (res->src_ip_value.family == AF_INET)
8354 /* no need to convert, already big endian. */
8355 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8357 if (filter.src_ip_mask == 0) {
8358 printf("can not support ipv6 involved compare.\n");
8363 /* need convert to big endian. */
8364 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8365 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8366 filter.queue = res->queue_id;
8368 if (!strcmp(res->ops, "add"))
8369 ret = rte_eth_dev_filter_ctrl(res->port_id,
8370 RTE_ETH_FILTER_NTUPLE,
8374 ret = rte_eth_dev_filter_ctrl(res->port_id,
8375 RTE_ETH_FILTER_NTUPLE,
8376 RTE_ETH_FILTER_DELETE,
8379 printf("5tuple filter programming error: (%s)\n",
8383 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8384 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8385 filter, "5tuple_filter");
8386 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8387 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8389 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8390 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8392 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8393 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8395 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8396 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8398 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8399 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8401 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8402 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8404 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8405 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8406 dst_port, "dst_port");
8407 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8408 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8409 dst_port_value, UINT16);
8410 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8411 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8412 src_port, "src_port");
8413 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8414 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8415 src_port_value, UINT16);
8416 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8417 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8418 protocol, "protocol");
8419 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8420 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8421 protocol_value, UINT8);
8422 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8423 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8425 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8426 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8428 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8429 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8430 tcp_flags, "tcp_flags");
8431 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8432 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8433 tcp_flags_value, UINT8);
8434 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8435 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8436 priority, "priority");
8437 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8438 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8439 priority_value, UINT8);
8440 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8441 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8443 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8444 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8447 cmdline_parse_inst_t cmd_5tuple_filter = {
8448 .f = cmd_5tuple_filter_parsed,
8450 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8451 "src_ip <value> dst_port <value> src_port <value> "
8452 "protocol <value> mask <value> tcp_flags <value> "
8453 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8455 (void *)&cmd_5tuple_filter_filter,
8456 (void *)&cmd_5tuple_filter_port_id,
8457 (void *)&cmd_5tuple_filter_ops,
8458 (void *)&cmd_5tuple_filter_dst_ip,
8459 (void *)&cmd_5tuple_filter_dst_ip_value,
8460 (void *)&cmd_5tuple_filter_src_ip,
8461 (void *)&cmd_5tuple_filter_src_ip_value,
8462 (void *)&cmd_5tuple_filter_dst_port,
8463 (void *)&cmd_5tuple_filter_dst_port_value,
8464 (void *)&cmd_5tuple_filter_src_port,
8465 (void *)&cmd_5tuple_filter_src_port_value,
8466 (void *)&cmd_5tuple_filter_protocol,
8467 (void *)&cmd_5tuple_filter_protocol_value,
8468 (void *)&cmd_5tuple_filter_mask,
8469 (void *)&cmd_5tuple_filter_mask_value,
8470 (void *)&cmd_5tuple_filter_tcp_flags,
8471 (void *)&cmd_5tuple_filter_tcp_flags_value,
8472 (void *)&cmd_5tuple_filter_priority,
8473 (void *)&cmd_5tuple_filter_priority_value,
8474 (void *)&cmd_5tuple_filter_queue,
8475 (void *)&cmd_5tuple_filter_queue_id,
8480 /* *** ADD/REMOVE A flex FILTER *** */
8481 struct cmd_flex_filter_result {
8482 cmdline_fixed_string_t filter;
8483 cmdline_fixed_string_t ops;
8485 cmdline_fixed_string_t len;
8487 cmdline_fixed_string_t bytes;
8488 cmdline_fixed_string_t bytes_value;
8489 cmdline_fixed_string_t mask;
8490 cmdline_fixed_string_t mask_value;
8491 cmdline_fixed_string_t priority;
8492 uint8_t priority_value;
8493 cmdline_fixed_string_t queue;
8497 static int xdigit2val(unsigned char c)
8502 else if (isupper(c))
8510 cmd_flex_filter_parsed(void *parsed_result,
8511 __attribute__((unused)) struct cmdline *cl,
8512 __attribute__((unused)) void *data)
8515 struct rte_eth_flex_filter filter;
8516 struct cmd_flex_filter_result *res = parsed_result;
8517 char *bytes_ptr, *mask_ptr;
8518 uint16_t len, i, j = 0;
8523 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8524 printf("the len exceed the max length 128\n");
8527 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8528 filter.len = res->len_value;
8529 filter.priority = res->priority_value;
8530 filter.queue = res->queue_id;
8531 bytes_ptr = res->bytes_value;
8532 mask_ptr = res->mask_value;
8534 /* translate bytes string to array. */
8535 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8536 (bytes_ptr[1] == 'X')))
8538 len = strnlen(bytes_ptr, res->len_value * 2);
8539 if (len == 0 || (len % 8 != 0)) {
8540 printf("please check len and bytes input\n");
8543 for (i = 0; i < len; i++) {
8545 if (isxdigit(c) == 0) {
8546 /* invalid characters. */
8547 printf("invalid input\n");
8550 val = xdigit2val(c);
8553 filter.bytes[j] = byte;
8554 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8561 /* translate mask string to uint8_t array. */
8562 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8563 (mask_ptr[1] == 'X')))
8565 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8567 printf("invalid input\n");
8572 for (i = 0; i < len; i++) {
8574 if (isxdigit(c) == 0) {
8575 /* invalid characters. */
8576 printf("invalid input\n");
8579 val = xdigit2val(c);
8582 filter.mask[j] = byte;
8583 printf("mask[%d]:%02x ", j, filter.mask[j]);
8591 if (!strcmp(res->ops, "add"))
8592 ret = rte_eth_dev_filter_ctrl(res->port_id,
8593 RTE_ETH_FILTER_FLEXIBLE,
8597 ret = rte_eth_dev_filter_ctrl(res->port_id,
8598 RTE_ETH_FILTER_FLEXIBLE,
8599 RTE_ETH_FILTER_DELETE,
8603 printf("flex filter setting error: (%s)\n", strerror(-ret));
8606 cmdline_parse_token_string_t cmd_flex_filter_filter =
8607 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8608 filter, "flex_filter");
8609 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8610 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8612 cmdline_parse_token_string_t cmd_flex_filter_ops =
8613 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8615 cmdline_parse_token_string_t cmd_flex_filter_len =
8616 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8618 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8619 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8621 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8622 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8624 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8625 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8627 cmdline_parse_token_string_t cmd_flex_filter_mask =
8628 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8630 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8631 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8633 cmdline_parse_token_string_t cmd_flex_filter_priority =
8634 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8635 priority, "priority");
8636 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8637 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8638 priority_value, UINT8);
8639 cmdline_parse_token_string_t cmd_flex_filter_queue =
8640 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8642 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8643 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8645 cmdline_parse_inst_t cmd_flex_filter = {
8646 .f = cmd_flex_filter_parsed,
8648 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8649 "<value> mask <value> priority <value> queue <queue_id>: "
8650 "Add/Del a flex filter",
8652 (void *)&cmd_flex_filter_filter,
8653 (void *)&cmd_flex_filter_port_id,
8654 (void *)&cmd_flex_filter_ops,
8655 (void *)&cmd_flex_filter_len,
8656 (void *)&cmd_flex_filter_len_value,
8657 (void *)&cmd_flex_filter_bytes,
8658 (void *)&cmd_flex_filter_bytes_value,
8659 (void *)&cmd_flex_filter_mask,
8660 (void *)&cmd_flex_filter_mask_value,
8661 (void *)&cmd_flex_filter_priority,
8662 (void *)&cmd_flex_filter_priority_value,
8663 (void *)&cmd_flex_filter_queue,
8664 (void *)&cmd_flex_filter_queue_id,
8669 /* *** Filters Control *** */
8671 /* *** deal with ethertype filter *** */
8672 struct cmd_ethertype_filter_result {
8673 cmdline_fixed_string_t filter;
8675 cmdline_fixed_string_t ops;
8676 cmdline_fixed_string_t mac;
8677 struct ether_addr mac_addr;
8678 cmdline_fixed_string_t ethertype;
8679 uint16_t ethertype_value;
8680 cmdline_fixed_string_t drop;
8681 cmdline_fixed_string_t queue;
8685 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8686 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8687 filter, "ethertype_filter");
8688 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8689 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8691 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8692 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8694 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8695 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8696 mac, "mac_addr#mac_ignr");
8697 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8698 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8700 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8701 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8702 ethertype, "ethertype");
8703 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8704 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8705 ethertype_value, UINT16);
8706 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8707 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8709 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8710 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8712 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8713 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8717 cmd_ethertype_filter_parsed(void *parsed_result,
8718 __attribute__((unused)) struct cmdline *cl,
8719 __attribute__((unused)) void *data)
8721 struct cmd_ethertype_filter_result *res = parsed_result;
8722 struct rte_eth_ethertype_filter filter;
8725 ret = rte_eth_dev_filter_supported(res->port_id,
8726 RTE_ETH_FILTER_ETHERTYPE);
8728 printf("ethertype filter is not supported on port %u.\n",
8733 memset(&filter, 0, sizeof(filter));
8734 if (!strcmp(res->mac, "mac_addr")) {
8735 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8736 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8737 sizeof(struct ether_addr));
8739 if (!strcmp(res->drop, "drop"))
8740 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8741 filter.ether_type = res->ethertype_value;
8742 filter.queue = res->queue_id;
8744 if (!strcmp(res->ops, "add"))
8745 ret = rte_eth_dev_filter_ctrl(res->port_id,
8746 RTE_ETH_FILTER_ETHERTYPE,
8750 ret = rte_eth_dev_filter_ctrl(res->port_id,
8751 RTE_ETH_FILTER_ETHERTYPE,
8752 RTE_ETH_FILTER_DELETE,
8755 printf("ethertype filter programming error: (%s)\n",
8759 cmdline_parse_inst_t cmd_ethertype_filter = {
8760 .f = cmd_ethertype_filter_parsed,
8762 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8763 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8764 "Add or delete an ethertype filter entry",
8766 (void *)&cmd_ethertype_filter_filter,
8767 (void *)&cmd_ethertype_filter_port_id,
8768 (void *)&cmd_ethertype_filter_ops,
8769 (void *)&cmd_ethertype_filter_mac,
8770 (void *)&cmd_ethertype_filter_mac_addr,
8771 (void *)&cmd_ethertype_filter_ethertype,
8772 (void *)&cmd_ethertype_filter_ethertype_value,
8773 (void *)&cmd_ethertype_filter_drop,
8774 (void *)&cmd_ethertype_filter_queue,
8775 (void *)&cmd_ethertype_filter_queue_id,
8780 /* *** deal with flow director filter *** */
8781 struct cmd_flow_director_result {
8782 cmdline_fixed_string_t flow_director_filter;
8784 cmdline_fixed_string_t mode;
8785 cmdline_fixed_string_t mode_value;
8786 cmdline_fixed_string_t ops;
8787 cmdline_fixed_string_t flow;
8788 cmdline_fixed_string_t flow_type;
8789 cmdline_fixed_string_t ether;
8790 uint16_t ether_type;
8791 cmdline_fixed_string_t src;
8792 cmdline_ipaddr_t ip_src;
8794 cmdline_fixed_string_t dst;
8795 cmdline_ipaddr_t ip_dst;
8797 cmdline_fixed_string_t verify_tag;
8798 uint32_t verify_tag_value;
8799 cmdline_ipaddr_t tos;
8801 cmdline_ipaddr_t proto;
8802 uint8_t proto_value;
8803 cmdline_ipaddr_t ttl;
8805 cmdline_fixed_string_t vlan;
8806 uint16_t vlan_value;
8807 cmdline_fixed_string_t flexbytes;
8808 cmdline_fixed_string_t flexbytes_value;
8809 cmdline_fixed_string_t pf_vf;
8810 cmdline_fixed_string_t drop;
8811 cmdline_fixed_string_t queue;
8813 cmdline_fixed_string_t fd_id;
8814 uint32_t fd_id_value;
8815 cmdline_fixed_string_t mac;
8816 struct ether_addr mac_addr;
8817 cmdline_fixed_string_t tunnel;
8818 cmdline_fixed_string_t tunnel_type;
8819 cmdline_fixed_string_t tunnel_id;
8820 uint32_t tunnel_id_value;
8824 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8827 const char *p, *p0 = q_arg;
8829 unsigned long int_fld;
8830 char *str_fld[max_num];
8835 p = strchr(p0, '(');
8839 p0 = strchr(p, ')');
8844 if (size >= sizeof(s))
8847 snprintf(s, sizeof(s), "%.*s", size, p);
8848 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8849 if (ret < 0 || ret > max_num)
8851 for (i = 0; i < ret; i++) {
8853 int_fld = strtoul(str_fld[i], &end, 0);
8854 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8856 flexbytes[i] = (uint8_t)int_fld;
8862 str2flowtype(char *string)
8865 static const struct {
8868 } flowtype_str[] = {
8869 {"raw", RTE_ETH_FLOW_RAW},
8870 {"ipv4", RTE_ETH_FLOW_IPV4},
8871 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8872 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8873 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8874 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8875 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8876 {"ipv6", RTE_ETH_FLOW_IPV6},
8877 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8878 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8879 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8880 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8881 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8882 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8885 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8886 if (!strcmp(flowtype_str[i].str, string))
8887 return flowtype_str[i].type;
8889 return RTE_ETH_FLOW_UNKNOWN;
8892 static enum rte_eth_fdir_tunnel_type
8893 str2fdir_tunneltype(char *string)
8897 static const struct {
8899 enum rte_eth_fdir_tunnel_type type;
8900 } tunneltype_str[] = {
8901 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8902 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8905 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8906 if (!strcmp(tunneltype_str[i].str, string))
8907 return tunneltype_str[i].type;
8909 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8912 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8914 if ((ip_addr).family == AF_INET) \
8915 (ip) = (ip_addr).addr.ipv4.s_addr; \
8917 printf("invalid parameter.\n"); \
8922 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8924 if ((ip_addr).family == AF_INET6) \
8925 (void)rte_memcpy(&(ip), \
8926 &((ip_addr).addr.ipv6), \
8927 sizeof(struct in6_addr)); \
8929 printf("invalid parameter.\n"); \
8935 cmd_flow_director_filter_parsed(void *parsed_result,
8936 __attribute__((unused)) struct cmdline *cl,
8937 __attribute__((unused)) void *data)
8939 struct cmd_flow_director_result *res = parsed_result;
8940 struct rte_eth_fdir_filter entry;
8941 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8943 unsigned long vf_id;
8946 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8948 printf("flow director is not supported on port %u.\n",
8952 memset(flexbytes, 0, sizeof(flexbytes));
8953 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8955 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8956 if (strcmp(res->mode_value, "MAC-VLAN")) {
8957 printf("Please set mode to MAC-VLAN.\n");
8960 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8961 if (strcmp(res->mode_value, "Tunnel")) {
8962 printf("Please set mode to Tunnel.\n");
8966 if (strcmp(res->mode_value, "IP")) {
8967 printf("Please set mode to IP.\n");
8970 entry.input.flow_type = str2flowtype(res->flow_type);
8973 ret = parse_flexbytes(res->flexbytes_value,
8975 RTE_ETH_FDIR_MAX_FLEXLEN);
8977 printf("error: Cannot parse flexbytes input.\n");
8981 switch (entry.input.flow_type) {
8982 case RTE_ETH_FLOW_FRAG_IPV4:
8983 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8984 entry.input.flow.ip4_flow.proto = res->proto_value;
8986 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8987 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8988 IPV4_ADDR_TO_UINT(res->ip_dst,
8989 entry.input.flow.ip4_flow.dst_ip);
8990 IPV4_ADDR_TO_UINT(res->ip_src,
8991 entry.input.flow.ip4_flow.src_ip);
8992 entry.input.flow.ip4_flow.tos = res->tos_value;
8993 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8994 /* need convert to big endian. */
8995 entry.input.flow.udp4_flow.dst_port =
8996 rte_cpu_to_be_16(res->port_dst);
8997 entry.input.flow.udp4_flow.src_port =
8998 rte_cpu_to_be_16(res->port_src);
9000 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9001 IPV4_ADDR_TO_UINT(res->ip_dst,
9002 entry.input.flow.sctp4_flow.ip.dst_ip);
9003 IPV4_ADDR_TO_UINT(res->ip_src,
9004 entry.input.flow.sctp4_flow.ip.src_ip);
9005 entry.input.flow.ip4_flow.tos = res->tos_value;
9006 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9007 /* need convert to big endian. */
9008 entry.input.flow.sctp4_flow.dst_port =
9009 rte_cpu_to_be_16(res->port_dst);
9010 entry.input.flow.sctp4_flow.src_port =
9011 rte_cpu_to_be_16(res->port_src);
9012 entry.input.flow.sctp4_flow.verify_tag =
9013 rte_cpu_to_be_32(res->verify_tag_value);
9015 case RTE_ETH_FLOW_FRAG_IPV6:
9016 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9017 entry.input.flow.ipv6_flow.proto = res->proto_value;
9019 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9020 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9021 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9022 entry.input.flow.ipv6_flow.dst_ip);
9023 IPV6_ADDR_TO_ARRAY(res->ip_src,
9024 entry.input.flow.ipv6_flow.src_ip);
9025 entry.input.flow.ipv6_flow.tc = res->tos_value;
9026 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9027 /* need convert to big endian. */
9028 entry.input.flow.udp6_flow.dst_port =
9029 rte_cpu_to_be_16(res->port_dst);
9030 entry.input.flow.udp6_flow.src_port =
9031 rte_cpu_to_be_16(res->port_src);
9033 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9034 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9035 entry.input.flow.sctp6_flow.ip.dst_ip);
9036 IPV6_ADDR_TO_ARRAY(res->ip_src,
9037 entry.input.flow.sctp6_flow.ip.src_ip);
9038 entry.input.flow.ipv6_flow.tc = res->tos_value;
9039 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9040 /* need convert to big endian. */
9041 entry.input.flow.sctp6_flow.dst_port =
9042 rte_cpu_to_be_16(res->port_dst);
9043 entry.input.flow.sctp6_flow.src_port =
9044 rte_cpu_to_be_16(res->port_src);
9045 entry.input.flow.sctp6_flow.verify_tag =
9046 rte_cpu_to_be_32(res->verify_tag_value);
9048 case RTE_ETH_FLOW_L2_PAYLOAD:
9049 entry.input.flow.l2_flow.ether_type =
9050 rte_cpu_to_be_16(res->ether_type);
9056 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
9057 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
9059 sizeof(struct ether_addr));
9061 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9062 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
9064 sizeof(struct ether_addr));
9065 entry.input.flow.tunnel_flow.tunnel_type =
9066 str2fdir_tunneltype(res->tunnel_type);
9067 entry.input.flow.tunnel_flow.tunnel_id =
9068 rte_cpu_to_be_32(res->tunnel_id_value);
9071 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
9073 RTE_ETH_FDIR_MAX_FLEXLEN);
9075 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
9077 entry.action.flex_off = 0; /*use 0 by default */
9078 if (!strcmp(res->drop, "drop"))
9079 entry.action.behavior = RTE_ETH_FDIR_REJECT;
9081 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
9083 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
9084 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
9085 if (!strcmp(res->pf_vf, "pf"))
9086 entry.input.flow_ext.is_vf = 0;
9087 else if (!strncmp(res->pf_vf, "vf", 2)) {
9088 struct rte_eth_dev_info dev_info;
9090 memset(&dev_info, 0, sizeof(dev_info));
9091 rte_eth_dev_info_get(res->port_id, &dev_info);
9093 vf_id = strtoul(res->pf_vf + 2, &end, 10);
9094 if (errno != 0 || *end != '\0' ||
9095 vf_id >= dev_info.max_vfs) {
9096 printf("invalid parameter %s.\n", res->pf_vf);
9099 entry.input.flow_ext.is_vf = 1;
9100 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
9102 printf("invalid parameter %s.\n", res->pf_vf);
9107 /* set to report FD ID by default */
9108 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
9109 entry.action.rx_queue = res->queue_id;
9110 entry.soft_id = res->fd_id_value;
9111 if (!strcmp(res->ops, "add"))
9112 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9113 RTE_ETH_FILTER_ADD, &entry);
9114 else if (!strcmp(res->ops, "del"))
9115 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9116 RTE_ETH_FILTER_DELETE, &entry);
9118 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9119 RTE_ETH_FILTER_UPDATE, &entry);
9121 printf("flow director programming error: (%s)\n",
9125 cmdline_parse_token_string_t cmd_flow_director_filter =
9126 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9127 flow_director_filter, "flow_director_filter");
9128 cmdline_parse_token_num_t cmd_flow_director_port_id =
9129 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9131 cmdline_parse_token_string_t cmd_flow_director_ops =
9132 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9133 ops, "add#del#update");
9134 cmdline_parse_token_string_t cmd_flow_director_flow =
9135 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9137 cmdline_parse_token_string_t cmd_flow_director_flow_type =
9138 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9139 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9140 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
9141 cmdline_parse_token_string_t cmd_flow_director_ether =
9142 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9144 cmdline_parse_token_num_t cmd_flow_director_ether_type =
9145 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9146 ether_type, UINT16);
9147 cmdline_parse_token_string_t cmd_flow_director_src =
9148 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9150 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
9151 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9153 cmdline_parse_token_num_t cmd_flow_director_port_src =
9154 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9156 cmdline_parse_token_string_t cmd_flow_director_dst =
9157 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9159 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
9160 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9162 cmdline_parse_token_num_t cmd_flow_director_port_dst =
9163 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9165 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
9166 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9167 verify_tag, "verify_tag");
9168 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
9169 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9170 verify_tag_value, UINT32);
9171 cmdline_parse_token_string_t cmd_flow_director_tos =
9172 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9174 cmdline_parse_token_num_t cmd_flow_director_tos_value =
9175 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9177 cmdline_parse_token_string_t cmd_flow_director_proto =
9178 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9180 cmdline_parse_token_num_t cmd_flow_director_proto_value =
9181 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9182 proto_value, UINT8);
9183 cmdline_parse_token_string_t cmd_flow_director_ttl =
9184 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9186 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
9187 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9189 cmdline_parse_token_string_t cmd_flow_director_vlan =
9190 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9192 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
9193 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9194 vlan_value, UINT16);
9195 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
9196 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9197 flexbytes, "flexbytes");
9198 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
9199 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9200 flexbytes_value, NULL);
9201 cmdline_parse_token_string_t cmd_flow_director_drop =
9202 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9204 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
9205 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9207 cmdline_parse_token_string_t cmd_flow_director_queue =
9208 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9210 cmdline_parse_token_num_t cmd_flow_director_queue_id =
9211 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9213 cmdline_parse_token_string_t cmd_flow_director_fd_id =
9214 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9216 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
9217 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9218 fd_id_value, UINT32);
9220 cmdline_parse_token_string_t cmd_flow_director_mode =
9221 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9223 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
9224 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9226 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9227 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9228 mode_value, "MAC-VLAN");
9229 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9230 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9231 mode_value, "Tunnel");
9232 cmdline_parse_token_string_t cmd_flow_director_mac =
9233 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9235 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9236 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9238 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9239 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9241 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9242 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9243 tunnel_type, "NVGRE#VxLAN");
9244 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9246 tunnel_id, "tunnel-id");
9247 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9248 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9249 tunnel_id_value, UINT32);
9251 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9252 .f = cmd_flow_director_filter_parsed,
9254 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9255 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9256 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9257 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9258 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9259 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9260 "fd_id <fd_id_value>: "
9261 "Add or delete an ip flow director entry on NIC",
9263 (void *)&cmd_flow_director_filter,
9264 (void *)&cmd_flow_director_port_id,
9265 (void *)&cmd_flow_director_mode,
9266 (void *)&cmd_flow_director_mode_ip,
9267 (void *)&cmd_flow_director_ops,
9268 (void *)&cmd_flow_director_flow,
9269 (void *)&cmd_flow_director_flow_type,
9270 (void *)&cmd_flow_director_src,
9271 (void *)&cmd_flow_director_ip_src,
9272 (void *)&cmd_flow_director_dst,
9273 (void *)&cmd_flow_director_ip_dst,
9274 (void *)&cmd_flow_director_tos,
9275 (void *)&cmd_flow_director_tos_value,
9276 (void *)&cmd_flow_director_proto,
9277 (void *)&cmd_flow_director_proto_value,
9278 (void *)&cmd_flow_director_ttl,
9279 (void *)&cmd_flow_director_ttl_value,
9280 (void *)&cmd_flow_director_vlan,
9281 (void *)&cmd_flow_director_vlan_value,
9282 (void *)&cmd_flow_director_flexbytes,
9283 (void *)&cmd_flow_director_flexbytes_value,
9284 (void *)&cmd_flow_director_drop,
9285 (void *)&cmd_flow_director_pf_vf,
9286 (void *)&cmd_flow_director_queue,
9287 (void *)&cmd_flow_director_queue_id,
9288 (void *)&cmd_flow_director_fd_id,
9289 (void *)&cmd_flow_director_fd_id_value,
9294 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9295 .f = cmd_flow_director_filter_parsed,
9297 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9298 "director entry on NIC",
9300 (void *)&cmd_flow_director_filter,
9301 (void *)&cmd_flow_director_port_id,
9302 (void *)&cmd_flow_director_mode,
9303 (void *)&cmd_flow_director_mode_ip,
9304 (void *)&cmd_flow_director_ops,
9305 (void *)&cmd_flow_director_flow,
9306 (void *)&cmd_flow_director_flow_type,
9307 (void *)&cmd_flow_director_src,
9308 (void *)&cmd_flow_director_ip_src,
9309 (void *)&cmd_flow_director_port_src,
9310 (void *)&cmd_flow_director_dst,
9311 (void *)&cmd_flow_director_ip_dst,
9312 (void *)&cmd_flow_director_port_dst,
9313 (void *)&cmd_flow_director_tos,
9314 (void *)&cmd_flow_director_tos_value,
9315 (void *)&cmd_flow_director_ttl,
9316 (void *)&cmd_flow_director_ttl_value,
9317 (void *)&cmd_flow_director_vlan,
9318 (void *)&cmd_flow_director_vlan_value,
9319 (void *)&cmd_flow_director_flexbytes,
9320 (void *)&cmd_flow_director_flexbytes_value,
9321 (void *)&cmd_flow_director_drop,
9322 (void *)&cmd_flow_director_pf_vf,
9323 (void *)&cmd_flow_director_queue,
9324 (void *)&cmd_flow_director_queue_id,
9325 (void *)&cmd_flow_director_fd_id,
9326 (void *)&cmd_flow_director_fd_id_value,
9331 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9332 .f = cmd_flow_director_filter_parsed,
9334 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9335 "director entry on NIC",
9337 (void *)&cmd_flow_director_filter,
9338 (void *)&cmd_flow_director_port_id,
9339 (void *)&cmd_flow_director_mode,
9340 (void *)&cmd_flow_director_mode_ip,
9341 (void *)&cmd_flow_director_ops,
9342 (void *)&cmd_flow_director_flow,
9343 (void *)&cmd_flow_director_flow_type,
9344 (void *)&cmd_flow_director_src,
9345 (void *)&cmd_flow_director_ip_src,
9346 (void *)&cmd_flow_director_port_dst,
9347 (void *)&cmd_flow_director_dst,
9348 (void *)&cmd_flow_director_ip_dst,
9349 (void *)&cmd_flow_director_port_dst,
9350 (void *)&cmd_flow_director_verify_tag,
9351 (void *)&cmd_flow_director_verify_tag_value,
9352 (void *)&cmd_flow_director_tos,
9353 (void *)&cmd_flow_director_tos_value,
9354 (void *)&cmd_flow_director_ttl,
9355 (void *)&cmd_flow_director_ttl_value,
9356 (void *)&cmd_flow_director_vlan,
9357 (void *)&cmd_flow_director_vlan_value,
9358 (void *)&cmd_flow_director_flexbytes,
9359 (void *)&cmd_flow_director_flexbytes_value,
9360 (void *)&cmd_flow_director_drop,
9361 (void *)&cmd_flow_director_pf_vf,
9362 (void *)&cmd_flow_director_queue,
9363 (void *)&cmd_flow_director_queue_id,
9364 (void *)&cmd_flow_director_fd_id,
9365 (void *)&cmd_flow_director_fd_id_value,
9370 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9371 .f = cmd_flow_director_filter_parsed,
9373 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9374 "director entry on NIC",
9376 (void *)&cmd_flow_director_filter,
9377 (void *)&cmd_flow_director_port_id,
9378 (void *)&cmd_flow_director_mode,
9379 (void *)&cmd_flow_director_mode_ip,
9380 (void *)&cmd_flow_director_ops,
9381 (void *)&cmd_flow_director_flow,
9382 (void *)&cmd_flow_director_flow_type,
9383 (void *)&cmd_flow_director_ether,
9384 (void *)&cmd_flow_director_ether_type,
9385 (void *)&cmd_flow_director_flexbytes,
9386 (void *)&cmd_flow_director_flexbytes_value,
9387 (void *)&cmd_flow_director_drop,
9388 (void *)&cmd_flow_director_pf_vf,
9389 (void *)&cmd_flow_director_queue,
9390 (void *)&cmd_flow_director_queue_id,
9391 (void *)&cmd_flow_director_fd_id,
9392 (void *)&cmd_flow_director_fd_id_value,
9397 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9398 .f = cmd_flow_director_filter_parsed,
9400 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9401 "director entry on NIC",
9403 (void *)&cmd_flow_director_filter,
9404 (void *)&cmd_flow_director_port_id,
9405 (void *)&cmd_flow_director_mode,
9406 (void *)&cmd_flow_director_mode_mac_vlan,
9407 (void *)&cmd_flow_director_ops,
9408 (void *)&cmd_flow_director_mac,
9409 (void *)&cmd_flow_director_mac_addr,
9410 (void *)&cmd_flow_director_vlan,
9411 (void *)&cmd_flow_director_vlan_value,
9412 (void *)&cmd_flow_director_flexbytes,
9413 (void *)&cmd_flow_director_flexbytes_value,
9414 (void *)&cmd_flow_director_drop,
9415 (void *)&cmd_flow_director_queue,
9416 (void *)&cmd_flow_director_queue_id,
9417 (void *)&cmd_flow_director_fd_id,
9418 (void *)&cmd_flow_director_fd_id_value,
9423 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9424 .f = cmd_flow_director_filter_parsed,
9426 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9427 "director entry on NIC",
9429 (void *)&cmd_flow_director_filter,
9430 (void *)&cmd_flow_director_port_id,
9431 (void *)&cmd_flow_director_mode,
9432 (void *)&cmd_flow_director_mode_tunnel,
9433 (void *)&cmd_flow_director_ops,
9434 (void *)&cmd_flow_director_mac,
9435 (void *)&cmd_flow_director_mac_addr,
9436 (void *)&cmd_flow_director_vlan,
9437 (void *)&cmd_flow_director_vlan_value,
9438 (void *)&cmd_flow_director_tunnel,
9439 (void *)&cmd_flow_director_tunnel_type,
9440 (void *)&cmd_flow_director_tunnel_id,
9441 (void *)&cmd_flow_director_tunnel_id_value,
9442 (void *)&cmd_flow_director_flexbytes,
9443 (void *)&cmd_flow_director_flexbytes_value,
9444 (void *)&cmd_flow_director_drop,
9445 (void *)&cmd_flow_director_queue,
9446 (void *)&cmd_flow_director_queue_id,
9447 (void *)&cmd_flow_director_fd_id,
9448 (void *)&cmd_flow_director_fd_id_value,
9453 struct cmd_flush_flow_director_result {
9454 cmdline_fixed_string_t flush_flow_director;
9458 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9459 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9460 flush_flow_director, "flush_flow_director");
9461 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9462 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9466 cmd_flush_flow_director_parsed(void *parsed_result,
9467 __attribute__((unused)) struct cmdline *cl,
9468 __attribute__((unused)) void *data)
9470 struct cmd_flow_director_result *res = parsed_result;
9473 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9475 printf("flow director is not supported on port %u.\n",
9480 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9481 RTE_ETH_FILTER_FLUSH, NULL);
9483 printf("flow director table flushing error: (%s)\n",
9487 cmdline_parse_inst_t cmd_flush_flow_director = {
9488 .f = cmd_flush_flow_director_parsed,
9490 .help_str = "flush_flow_director <port_id>: "
9491 "Flush all flow director entries of a device on NIC",
9493 (void *)&cmd_flush_flow_director_flush,
9494 (void *)&cmd_flush_flow_director_port_id,
9499 /* *** deal with flow director mask *** */
9500 struct cmd_flow_director_mask_result {
9501 cmdline_fixed_string_t flow_director_mask;
9503 cmdline_fixed_string_t mode;
9504 cmdline_fixed_string_t mode_value;
9505 cmdline_fixed_string_t vlan;
9507 cmdline_fixed_string_t src_mask;
9508 cmdline_ipaddr_t ipv4_src;
9509 cmdline_ipaddr_t ipv6_src;
9511 cmdline_fixed_string_t dst_mask;
9512 cmdline_ipaddr_t ipv4_dst;
9513 cmdline_ipaddr_t ipv6_dst;
9515 cmdline_fixed_string_t mac;
9516 uint8_t mac_addr_byte_mask;
9517 cmdline_fixed_string_t tunnel_id;
9518 uint32_t tunnel_id_mask;
9519 cmdline_fixed_string_t tunnel_type;
9520 uint8_t tunnel_type_mask;
9524 cmd_flow_director_mask_parsed(void *parsed_result,
9525 __attribute__((unused)) struct cmdline *cl,
9526 __attribute__((unused)) void *data)
9528 struct cmd_flow_director_mask_result *res = parsed_result;
9529 struct rte_eth_fdir_masks *mask;
9530 struct rte_port *port;
9532 if (res->port_id > nb_ports) {
9533 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9537 port = &ports[res->port_id];
9538 /** Check if the port is not started **/
9539 if (port->port_status != RTE_PORT_STOPPED) {
9540 printf("Please stop port %d first\n", res->port_id);
9544 mask = &port->dev_conf.fdir_conf.mask;
9546 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9547 if (strcmp(res->mode_value, "MAC-VLAN")) {
9548 printf("Please set mode to MAC-VLAN.\n");
9552 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9553 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9554 if (strcmp(res->mode_value, "Tunnel")) {
9555 printf("Please set mode to Tunnel.\n");
9559 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9560 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9561 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9562 mask->tunnel_type_mask = res->tunnel_type_mask;
9564 if (strcmp(res->mode_value, "IP")) {
9565 printf("Please set mode to IP.\n");
9569 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9570 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9571 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9572 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9573 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9574 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9575 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9578 cmd_reconfig_device_queue(res->port_id, 1, 1);
9581 cmdline_parse_token_string_t cmd_flow_director_mask =
9582 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9583 flow_director_mask, "flow_director_mask");
9584 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9585 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9587 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9588 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9590 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9591 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9593 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9594 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9595 src_mask, "src_mask");
9596 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9597 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9599 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9600 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9602 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9603 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9605 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9606 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9607 dst_mask, "dst_mask");
9608 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9609 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9611 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9612 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9614 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9615 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9618 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9619 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9621 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9622 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9624 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9625 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9626 mode_value, "MAC-VLAN");
9627 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9628 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9629 mode_value, "Tunnel");
9630 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9631 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9633 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9634 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9635 mac_addr_byte_mask, UINT8);
9636 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9637 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9638 tunnel_type, "tunnel-type");
9639 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9640 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9641 tunnel_type_mask, UINT8);
9642 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9643 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9644 tunnel_id, "tunnel-id");
9645 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9646 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9647 tunnel_id_mask, UINT32);
9649 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9650 .f = cmd_flow_director_mask_parsed,
9652 .help_str = "flow_director_mask ... : "
9653 "Set IP mode flow director's mask on NIC",
9655 (void *)&cmd_flow_director_mask,
9656 (void *)&cmd_flow_director_mask_port_id,
9657 (void *)&cmd_flow_director_mask_mode,
9658 (void *)&cmd_flow_director_mask_mode_ip,
9659 (void *)&cmd_flow_director_mask_vlan,
9660 (void *)&cmd_flow_director_mask_vlan_value,
9661 (void *)&cmd_flow_director_mask_src,
9662 (void *)&cmd_flow_director_mask_ipv4_src,
9663 (void *)&cmd_flow_director_mask_ipv6_src,
9664 (void *)&cmd_flow_director_mask_port_src,
9665 (void *)&cmd_flow_director_mask_dst,
9666 (void *)&cmd_flow_director_mask_ipv4_dst,
9667 (void *)&cmd_flow_director_mask_ipv6_dst,
9668 (void *)&cmd_flow_director_mask_port_dst,
9673 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9674 .f = cmd_flow_director_mask_parsed,
9676 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9677 "flow director's mask on NIC",
9679 (void *)&cmd_flow_director_mask,
9680 (void *)&cmd_flow_director_mask_port_id,
9681 (void *)&cmd_flow_director_mask_mode,
9682 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9683 (void *)&cmd_flow_director_mask_vlan,
9684 (void *)&cmd_flow_director_mask_vlan_value,
9689 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9690 .f = cmd_flow_director_mask_parsed,
9692 .help_str = "flow_director_mask ... : Set tunnel mode "
9693 "flow director's mask on NIC",
9695 (void *)&cmd_flow_director_mask,
9696 (void *)&cmd_flow_director_mask_port_id,
9697 (void *)&cmd_flow_director_mask_mode,
9698 (void *)&cmd_flow_director_mask_mode_tunnel,
9699 (void *)&cmd_flow_director_mask_vlan,
9700 (void *)&cmd_flow_director_mask_vlan_value,
9701 (void *)&cmd_flow_director_mask_mac,
9702 (void *)&cmd_flow_director_mask_mac_value,
9703 (void *)&cmd_flow_director_mask_tunnel_type,
9704 (void *)&cmd_flow_director_mask_tunnel_type_value,
9705 (void *)&cmd_flow_director_mask_tunnel_id,
9706 (void *)&cmd_flow_director_mask_tunnel_id_value,
9711 /* *** deal with flow director mask on flexible payload *** */
9712 struct cmd_flow_director_flex_mask_result {
9713 cmdline_fixed_string_t flow_director_flexmask;
9715 cmdline_fixed_string_t flow;
9716 cmdline_fixed_string_t flow_type;
9717 cmdline_fixed_string_t mask;
9721 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9722 __attribute__((unused)) struct cmdline *cl,
9723 __attribute__((unused)) void *data)
9725 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9726 struct rte_eth_fdir_info fdir_info;
9727 struct rte_eth_fdir_flex_mask flex_mask;
9728 struct rte_port *port;
9729 uint32_t flow_type_mask;
9733 if (res->port_id > nb_ports) {
9734 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9738 port = &ports[res->port_id];
9739 /** Check if the port is not started **/
9740 if (port->port_status != RTE_PORT_STOPPED) {
9741 printf("Please stop port %d first\n", res->port_id);
9745 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9746 ret = parse_flexbytes(res->mask,
9748 RTE_ETH_FDIR_MAX_FLEXLEN);
9750 printf("error: Cannot parse mask input.\n");
9754 memset(&fdir_info, 0, sizeof(fdir_info));
9755 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9756 RTE_ETH_FILTER_INFO, &fdir_info);
9758 printf("Cannot get FDir filter info\n");
9762 if (!strcmp(res->flow_type, "none")) {
9763 /* means don't specify the flow type */
9764 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9765 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9766 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9767 0, sizeof(struct rte_eth_fdir_flex_mask));
9768 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9769 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9771 sizeof(struct rte_eth_fdir_flex_mask));
9772 cmd_reconfig_device_queue(res->port_id, 1, 1);
9775 flow_type_mask = fdir_info.flow_types_mask[0];
9776 if (!strcmp(res->flow_type, "all")) {
9777 if (!flow_type_mask) {
9778 printf("No flow type supported\n");
9781 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9782 if (flow_type_mask & (1 << i)) {
9783 flex_mask.flow_type = i;
9784 fdir_set_flex_mask(res->port_id, &flex_mask);
9787 cmd_reconfig_device_queue(res->port_id, 1, 1);
9790 flex_mask.flow_type = str2flowtype(res->flow_type);
9791 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9792 printf("Flow type %s not supported on port %d\n",
9793 res->flow_type, res->port_id);
9796 fdir_set_flex_mask(res->port_id, &flex_mask);
9797 cmd_reconfig_device_queue(res->port_id, 1, 1);
9800 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9801 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9802 flow_director_flexmask,
9803 "flow_director_flex_mask");
9804 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9805 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9807 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9808 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9810 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9811 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9812 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9813 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9814 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9815 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9818 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9819 .f = cmd_flow_director_flex_mask_parsed,
9821 .help_str = "flow_director_flex_mask ... : "
9822 "Set flow director's flex mask on NIC",
9824 (void *)&cmd_flow_director_flexmask,
9825 (void *)&cmd_flow_director_flexmask_port_id,
9826 (void *)&cmd_flow_director_flexmask_flow,
9827 (void *)&cmd_flow_director_flexmask_flow_type,
9828 (void *)&cmd_flow_director_flexmask_mask,
9833 /* *** deal with flow director flexible payload configuration *** */
9834 struct cmd_flow_director_flexpayload_result {
9835 cmdline_fixed_string_t flow_director_flexpayload;
9837 cmdline_fixed_string_t payload_layer;
9838 cmdline_fixed_string_t payload_cfg;
9842 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9845 const char *p, *p0 = q_arg;
9847 unsigned long int_fld;
9848 char *str_fld[max_num];
9853 p = strchr(p0, '(');
9857 p0 = strchr(p, ')');
9862 if (size >= sizeof(s))
9865 snprintf(s, sizeof(s), "%.*s", size, p);
9866 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9867 if (ret < 0 || ret > max_num)
9869 for (i = 0; i < ret; i++) {
9871 int_fld = strtoul(str_fld[i], &end, 0);
9872 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9874 offsets[i] = (uint16_t)int_fld;
9880 cmd_flow_director_flxpld_parsed(void *parsed_result,
9881 __attribute__((unused)) struct cmdline *cl,
9882 __attribute__((unused)) void *data)
9884 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9885 struct rte_eth_flex_payload_cfg flex_cfg;
9886 struct rte_port *port;
9889 if (res->port_id > nb_ports) {
9890 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9894 port = &ports[res->port_id];
9895 /** Check if the port is not started **/
9896 if (port->port_status != RTE_PORT_STOPPED) {
9897 printf("Please stop port %d first\n", res->port_id);
9901 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9903 if (!strcmp(res->payload_layer, "raw"))
9904 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9905 else if (!strcmp(res->payload_layer, "l2"))
9906 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9907 else if (!strcmp(res->payload_layer, "l3"))
9908 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9909 else if (!strcmp(res->payload_layer, "l4"))
9910 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9912 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9913 RTE_ETH_FDIR_MAX_FLEXLEN);
9915 printf("error: Cannot parse flex payload input.\n");
9919 fdir_set_flex_payload(res->port_id, &flex_cfg);
9920 cmd_reconfig_device_queue(res->port_id, 1, 1);
9923 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9924 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9925 flow_director_flexpayload,
9926 "flow_director_flex_payload");
9927 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9928 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9930 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9932 payload_layer, "raw#l2#l3#l4");
9933 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9934 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9937 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9938 .f = cmd_flow_director_flxpld_parsed,
9940 .help_str = "flow_director_flexpayload ... : "
9941 "Set flow director's flex payload on NIC",
9943 (void *)&cmd_flow_director_flexpayload,
9944 (void *)&cmd_flow_director_flexpayload_port_id,
9945 (void *)&cmd_flow_director_flexpayload_payload_layer,
9946 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9951 /* Generic flow interface command. */
9952 extern cmdline_parse_inst_t cmd_flow;
9954 /* *** Classification Filters Control *** */
9955 /* *** Get symmetric hash enable per port *** */
9956 struct cmd_get_sym_hash_ena_per_port_result {
9957 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9962 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9963 __rte_unused struct cmdline *cl,
9964 __rte_unused void *data)
9966 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9967 struct rte_eth_hash_filter_info info;
9970 if (rte_eth_dev_filter_supported(res->port_id,
9971 RTE_ETH_FILTER_HASH) < 0) {
9972 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9977 memset(&info, 0, sizeof(info));
9978 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9979 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9980 RTE_ETH_FILTER_GET, &info);
9983 printf("Cannot get symmetric hash enable per port "
9984 "on port %u\n", res->port_id);
9988 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9989 "enabled" : "disabled", res->port_id);
9992 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9993 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9994 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9995 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9996 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9999 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10000 .f = cmd_get_sym_hash_per_port_parsed,
10002 .help_str = "get_sym_hash_ena_per_port <port_id>",
10004 (void *)&cmd_get_sym_hash_ena_per_port_all,
10005 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10010 /* *** Set symmetric hash enable per port *** */
10011 struct cmd_set_sym_hash_ena_per_port_result {
10012 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10013 cmdline_fixed_string_t enable;
10018 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10019 __rte_unused struct cmdline *cl,
10020 __rte_unused void *data)
10022 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10023 struct rte_eth_hash_filter_info info;
10026 if (rte_eth_dev_filter_supported(res->port_id,
10027 RTE_ETH_FILTER_HASH) < 0) {
10028 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10033 memset(&info, 0, sizeof(info));
10034 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10035 if (!strcmp(res->enable, "enable"))
10036 info.info.enable = 1;
10037 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10038 RTE_ETH_FILTER_SET, &info);
10040 printf("Cannot set symmetric hash enable per port on "
10041 "port %u\n", res->port_id);
10044 printf("Symmetric hash has been set to %s on port %u\n",
10045 res->enable, res->port_id);
10048 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
10049 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10050 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
10051 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
10052 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10054 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
10055 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10056 enable, "enable#disable");
10058 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
10059 .f = cmd_set_sym_hash_per_port_parsed,
10061 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
10063 (void *)&cmd_set_sym_hash_ena_per_port_all,
10064 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
10065 (void *)&cmd_set_sym_hash_ena_per_port_enable,
10070 /* Get global config of hash function */
10071 struct cmd_get_hash_global_config_result {
10072 cmdline_fixed_string_t get_hash_global_config;
10077 flowtype_to_str(uint16_t ftype)
10083 } ftype_table[] = {
10084 {"ipv4", RTE_ETH_FLOW_IPV4},
10085 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10086 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10087 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10088 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10089 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10090 {"ipv6", RTE_ETH_FLOW_IPV6},
10091 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10092 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10093 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10094 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10095 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10096 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10097 {"port", RTE_ETH_FLOW_PORT},
10098 {"vxlan", RTE_ETH_FLOW_VXLAN},
10099 {"geneve", RTE_ETH_FLOW_GENEVE},
10100 {"nvgre", RTE_ETH_FLOW_NVGRE},
10103 for (i = 0; i < RTE_DIM(ftype_table); i++) {
10104 if (ftype_table[i].ftype == ftype)
10105 return ftype_table[i].str;
10112 cmd_get_hash_global_config_parsed(void *parsed_result,
10113 __rte_unused struct cmdline *cl,
10114 __rte_unused void *data)
10116 struct cmd_get_hash_global_config_result *res = parsed_result;
10117 struct rte_eth_hash_filter_info info;
10118 uint32_t idx, offset;
10123 if (rte_eth_dev_filter_supported(res->port_id,
10124 RTE_ETH_FILTER_HASH) < 0) {
10125 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10130 memset(&info, 0, sizeof(info));
10131 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10132 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10133 RTE_ETH_FILTER_GET, &info);
10135 printf("Cannot get hash global configurations by port %d\n",
10140 switch (info.info.global_conf.hash_func) {
10141 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
10142 printf("Hash function is Toeplitz\n");
10144 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
10145 printf("Hash function is Simple XOR\n");
10148 printf("Unknown hash function\n");
10152 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
10153 idx = i / UINT32_BIT;
10154 offset = i % UINT32_BIT;
10155 if (!(info.info.global_conf.valid_bit_mask[idx] &
10158 str = flowtype_to_str(i);
10161 printf("Symmetric hash is %s globally for flow type %s "
10163 ((info.info.global_conf.sym_hash_enable_mask[idx] &
10164 (1UL << offset)) ? "enabled" : "disabled"), str,
10169 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
10170 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
10171 get_hash_global_config, "get_hash_global_config");
10172 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
10173 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
10176 cmdline_parse_inst_t cmd_get_hash_global_config = {
10177 .f = cmd_get_hash_global_config_parsed,
10179 .help_str = "get_hash_global_config <port_id>",
10181 (void *)&cmd_get_hash_global_config_all,
10182 (void *)&cmd_get_hash_global_config_port_id,
10187 /* Set global config of hash function */
10188 struct cmd_set_hash_global_config_result {
10189 cmdline_fixed_string_t set_hash_global_config;
10191 cmdline_fixed_string_t hash_func;
10192 cmdline_fixed_string_t flow_type;
10193 cmdline_fixed_string_t enable;
10197 cmd_set_hash_global_config_parsed(void *parsed_result,
10198 __rte_unused struct cmdline *cl,
10199 __rte_unused void *data)
10201 struct cmd_set_hash_global_config_result *res = parsed_result;
10202 struct rte_eth_hash_filter_info info;
10203 uint32_t ftype, idx, offset;
10206 if (rte_eth_dev_filter_supported(res->port_id,
10207 RTE_ETH_FILTER_HASH) < 0) {
10208 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10212 memset(&info, 0, sizeof(info));
10213 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10214 if (!strcmp(res->hash_func, "toeplitz"))
10215 info.info.global_conf.hash_func =
10216 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
10217 else if (!strcmp(res->hash_func, "simple_xor"))
10218 info.info.global_conf.hash_func =
10219 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
10220 else if (!strcmp(res->hash_func, "default"))
10221 info.info.global_conf.hash_func =
10222 RTE_ETH_HASH_FUNCTION_DEFAULT;
10224 ftype = str2flowtype(res->flow_type);
10225 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10226 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10227 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10228 if (!strcmp(res->enable, "enable"))
10229 info.info.global_conf.sym_hash_enable_mask[idx] |=
10231 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10232 RTE_ETH_FILTER_SET, &info);
10234 printf("Cannot set global hash configurations by port %d\n",
10237 printf("Global hash configurations have been set "
10238 "succcessfully by port %d\n", res->port_id);
10241 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10242 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10243 set_hash_global_config, "set_hash_global_config");
10244 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10245 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10247 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10248 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10249 hash_func, "toeplitz#simple_xor#default");
10250 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10251 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10253 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10254 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10255 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10256 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10257 enable, "enable#disable");
10259 cmdline_parse_inst_t cmd_set_hash_global_config = {
10260 .f = cmd_set_hash_global_config_parsed,
10262 .help_str = "set_hash_global_config <port_id> "
10263 "toeplitz|simple_xor|default "
10264 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10265 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10266 "l2_payload enable|disable",
10268 (void *)&cmd_set_hash_global_config_all,
10269 (void *)&cmd_set_hash_global_config_port_id,
10270 (void *)&cmd_set_hash_global_config_hash_func,
10271 (void *)&cmd_set_hash_global_config_flow_type,
10272 (void *)&cmd_set_hash_global_config_enable,
10277 /* Set hash input set */
10278 struct cmd_set_hash_input_set_result {
10279 cmdline_fixed_string_t set_hash_input_set;
10281 cmdline_fixed_string_t flow_type;
10282 cmdline_fixed_string_t inset_field;
10283 cmdline_fixed_string_t select;
10286 static enum rte_eth_input_set_field
10287 str2inset(char *string)
10291 static const struct {
10293 enum rte_eth_input_set_field inset;
10294 } inset_table[] = {
10295 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10296 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10297 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10298 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10299 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10300 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10301 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10302 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10303 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10304 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10305 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10306 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10307 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10308 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10309 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10310 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10311 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10312 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10313 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10314 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10315 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10316 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10317 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10318 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10319 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10320 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10321 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10322 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10323 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10324 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10325 {"none", RTE_ETH_INPUT_SET_NONE},
10328 for (i = 0; i < RTE_DIM(inset_table); i++) {
10329 if (!strcmp(string, inset_table[i].str))
10330 return inset_table[i].inset;
10333 return RTE_ETH_INPUT_SET_UNKNOWN;
10337 cmd_set_hash_input_set_parsed(void *parsed_result,
10338 __rte_unused struct cmdline *cl,
10339 __rte_unused void *data)
10341 struct cmd_set_hash_input_set_result *res = parsed_result;
10342 struct rte_eth_hash_filter_info info;
10344 memset(&info, 0, sizeof(info));
10345 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10346 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10347 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10348 info.info.input_set_conf.inset_size = 1;
10349 if (!strcmp(res->select, "select"))
10350 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10351 else if (!strcmp(res->select, "add"))
10352 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10353 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10354 RTE_ETH_FILTER_SET, &info);
10357 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10358 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10359 set_hash_input_set, "set_hash_input_set");
10360 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10361 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10363 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10364 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10366 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10367 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10368 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10369 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10371 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10372 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10373 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10374 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10375 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10377 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10378 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10379 select, "select#add");
10381 cmdline_parse_inst_t cmd_set_hash_input_set = {
10382 .f = cmd_set_hash_input_set_parsed,
10384 .help_str = "set_hash_input_set <port_id> "
10385 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10386 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10387 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10388 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10389 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10390 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10391 "fld-7th|fld-8th|none select|add",
10393 (void *)&cmd_set_hash_input_set_cmd,
10394 (void *)&cmd_set_hash_input_set_port_id,
10395 (void *)&cmd_set_hash_input_set_flow_type,
10396 (void *)&cmd_set_hash_input_set_field,
10397 (void *)&cmd_set_hash_input_set_select,
10402 /* Set flow director input set */
10403 struct cmd_set_fdir_input_set_result {
10404 cmdline_fixed_string_t set_fdir_input_set;
10406 cmdline_fixed_string_t flow_type;
10407 cmdline_fixed_string_t inset_field;
10408 cmdline_fixed_string_t select;
10412 cmd_set_fdir_input_set_parsed(void *parsed_result,
10413 __rte_unused struct cmdline *cl,
10414 __rte_unused void *data)
10416 struct cmd_set_fdir_input_set_result *res = parsed_result;
10417 struct rte_eth_fdir_filter_info info;
10419 memset(&info, 0, sizeof(info));
10420 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10421 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10422 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10423 info.info.input_set_conf.inset_size = 1;
10424 if (!strcmp(res->select, "select"))
10425 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10426 else if (!strcmp(res->select, "add"))
10427 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10428 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10429 RTE_ETH_FILTER_SET, &info);
10432 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10433 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10434 set_fdir_input_set, "set_fdir_input_set");
10435 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10436 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10438 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10439 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10441 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10442 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10443 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10444 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10446 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10447 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10448 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10449 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10450 "sctp-veri-tag#none");
10451 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10452 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10453 select, "select#add");
10455 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10456 .f = cmd_set_fdir_input_set_parsed,
10458 .help_str = "set_fdir_input_set <port_id> "
10459 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10460 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10461 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10462 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10463 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10464 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10465 "sctp-veri-tag|none select|add",
10467 (void *)&cmd_set_fdir_input_set_cmd,
10468 (void *)&cmd_set_fdir_input_set_port_id,
10469 (void *)&cmd_set_fdir_input_set_flow_type,
10470 (void *)&cmd_set_fdir_input_set_field,
10471 (void *)&cmd_set_fdir_input_set_select,
10476 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10477 struct cmd_mcast_addr_result {
10478 cmdline_fixed_string_t mcast_addr_cmd;
10479 cmdline_fixed_string_t what;
10481 struct ether_addr mc_addr;
10484 static void cmd_mcast_addr_parsed(void *parsed_result,
10485 __attribute__((unused)) struct cmdline *cl,
10486 __attribute__((unused)) void *data)
10488 struct cmd_mcast_addr_result *res = parsed_result;
10490 if (!is_multicast_ether_addr(&res->mc_addr)) {
10491 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10492 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10493 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10494 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10497 if (strcmp(res->what, "add") == 0)
10498 mcast_addr_add(res->port_num, &res->mc_addr);
10500 mcast_addr_remove(res->port_num, &res->mc_addr);
10503 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10504 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10505 mcast_addr_cmd, "mcast_addr");
10506 cmdline_parse_token_string_t cmd_mcast_addr_what =
10507 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10509 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10510 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10511 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10512 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10514 cmdline_parse_inst_t cmd_mcast_addr = {
10515 .f = cmd_mcast_addr_parsed,
10517 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10518 "Add/Remove multicast MAC address on port_id",
10520 (void *)&cmd_mcast_addr_cmd,
10521 (void *)&cmd_mcast_addr_what,
10522 (void *)&cmd_mcast_addr_portnum,
10523 (void *)&cmd_mcast_addr_addr,
10528 /* l2 tunnel config
10529 * only support E-tag now.
10532 /* Ether type config */
10533 struct cmd_config_l2_tunnel_eth_type_result {
10534 cmdline_fixed_string_t port;
10535 cmdline_fixed_string_t config;
10536 cmdline_fixed_string_t all;
10538 cmdline_fixed_string_t l2_tunnel;
10539 cmdline_fixed_string_t l2_tunnel_type;
10540 cmdline_fixed_string_t eth_type;
10541 uint16_t eth_type_val;
10544 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10545 TOKEN_STRING_INITIALIZER
10546 (struct cmd_config_l2_tunnel_eth_type_result,
10548 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10549 TOKEN_STRING_INITIALIZER
10550 (struct cmd_config_l2_tunnel_eth_type_result,
10552 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10553 TOKEN_STRING_INITIALIZER
10554 (struct cmd_config_l2_tunnel_eth_type_result,
10556 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10557 TOKEN_NUM_INITIALIZER
10558 (struct cmd_config_l2_tunnel_eth_type_result,
10560 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10561 TOKEN_STRING_INITIALIZER
10562 (struct cmd_config_l2_tunnel_eth_type_result,
10563 l2_tunnel, "l2-tunnel");
10564 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10565 TOKEN_STRING_INITIALIZER
10566 (struct cmd_config_l2_tunnel_eth_type_result,
10567 l2_tunnel_type, "E-tag");
10568 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10569 TOKEN_STRING_INITIALIZER
10570 (struct cmd_config_l2_tunnel_eth_type_result,
10571 eth_type, "ether-type");
10572 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10573 TOKEN_NUM_INITIALIZER
10574 (struct cmd_config_l2_tunnel_eth_type_result,
10575 eth_type_val, UINT16);
10577 static enum rte_eth_tunnel_type
10578 str2fdir_l2_tunnel_type(char *string)
10582 static const struct {
10584 enum rte_eth_tunnel_type type;
10585 } l2_tunnel_type_str[] = {
10586 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10589 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10590 if (!strcmp(l2_tunnel_type_str[i].str, string))
10591 return l2_tunnel_type_str[i].type;
10593 return RTE_TUNNEL_TYPE_NONE;
10596 /* ether type config for all ports */
10598 cmd_config_l2_tunnel_eth_type_all_parsed
10599 (void *parsed_result,
10600 __attribute__((unused)) struct cmdline *cl,
10601 __attribute__((unused)) void *data)
10603 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10604 struct rte_eth_l2_tunnel_conf entry;
10607 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10608 entry.ether_type = res->eth_type_val;
10610 RTE_ETH_FOREACH_DEV(pid) {
10611 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10615 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10616 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10618 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10620 (void *)&cmd_config_l2_tunnel_eth_type_port,
10621 (void *)&cmd_config_l2_tunnel_eth_type_config,
10622 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10623 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10624 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10625 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10626 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10631 /* ether type config for a specific port */
10633 cmd_config_l2_tunnel_eth_type_specific_parsed(
10634 void *parsed_result,
10635 __attribute__((unused)) struct cmdline *cl,
10636 __attribute__((unused)) void *data)
10638 struct cmd_config_l2_tunnel_eth_type_result *res =
10640 struct rte_eth_l2_tunnel_conf entry;
10642 if (port_id_is_invalid(res->id, ENABLED_WARN))
10645 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10646 entry.ether_type = res->eth_type_val;
10648 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10651 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10652 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10654 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10656 (void *)&cmd_config_l2_tunnel_eth_type_port,
10657 (void *)&cmd_config_l2_tunnel_eth_type_config,
10658 (void *)&cmd_config_l2_tunnel_eth_type_id,
10659 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10660 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10661 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10662 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10667 /* Enable/disable l2 tunnel */
10668 struct cmd_config_l2_tunnel_en_dis_result {
10669 cmdline_fixed_string_t port;
10670 cmdline_fixed_string_t config;
10671 cmdline_fixed_string_t all;
10673 cmdline_fixed_string_t l2_tunnel;
10674 cmdline_fixed_string_t l2_tunnel_type;
10675 cmdline_fixed_string_t en_dis;
10678 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10679 TOKEN_STRING_INITIALIZER
10680 (struct cmd_config_l2_tunnel_en_dis_result,
10682 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10683 TOKEN_STRING_INITIALIZER
10684 (struct cmd_config_l2_tunnel_en_dis_result,
10686 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10687 TOKEN_STRING_INITIALIZER
10688 (struct cmd_config_l2_tunnel_en_dis_result,
10690 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10691 TOKEN_NUM_INITIALIZER
10692 (struct cmd_config_l2_tunnel_en_dis_result,
10694 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10695 TOKEN_STRING_INITIALIZER
10696 (struct cmd_config_l2_tunnel_en_dis_result,
10697 l2_tunnel, "l2-tunnel");
10698 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10699 TOKEN_STRING_INITIALIZER
10700 (struct cmd_config_l2_tunnel_en_dis_result,
10701 l2_tunnel_type, "E-tag");
10702 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10703 TOKEN_STRING_INITIALIZER
10704 (struct cmd_config_l2_tunnel_en_dis_result,
10705 en_dis, "enable#disable");
10707 /* enable/disable l2 tunnel for all ports */
10709 cmd_config_l2_tunnel_en_dis_all_parsed(
10710 void *parsed_result,
10711 __attribute__((unused)) struct cmdline *cl,
10712 __attribute__((unused)) void *data)
10714 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10715 struct rte_eth_l2_tunnel_conf entry;
10719 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10721 if (!strcmp("enable", res->en_dis))
10726 RTE_ETH_FOREACH_DEV(pid) {
10727 rte_eth_dev_l2_tunnel_offload_set(pid,
10729 ETH_L2_TUNNEL_ENABLE_MASK,
10734 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10735 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10737 .help_str = "port config all l2-tunnel E-tag enable|disable",
10739 (void *)&cmd_config_l2_tunnel_en_dis_port,
10740 (void *)&cmd_config_l2_tunnel_en_dis_config,
10741 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10742 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10743 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10744 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10749 /* enable/disable l2 tunnel for a port */
10751 cmd_config_l2_tunnel_en_dis_specific_parsed(
10752 void *parsed_result,
10753 __attribute__((unused)) struct cmdline *cl,
10754 __attribute__((unused)) void *data)
10756 struct cmd_config_l2_tunnel_en_dis_result *res =
10758 struct rte_eth_l2_tunnel_conf entry;
10760 if (port_id_is_invalid(res->id, ENABLED_WARN))
10763 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10765 if (!strcmp("enable", res->en_dis))
10766 rte_eth_dev_l2_tunnel_offload_set(res->id,
10768 ETH_L2_TUNNEL_ENABLE_MASK,
10771 rte_eth_dev_l2_tunnel_offload_set(res->id,
10773 ETH_L2_TUNNEL_ENABLE_MASK,
10777 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10778 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10780 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10782 (void *)&cmd_config_l2_tunnel_en_dis_port,
10783 (void *)&cmd_config_l2_tunnel_en_dis_config,
10784 (void *)&cmd_config_l2_tunnel_en_dis_id,
10785 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10786 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10787 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10792 /* E-tag configuration */
10794 /* Common result structure for all E-tag configuration */
10795 struct cmd_config_e_tag_result {
10796 cmdline_fixed_string_t e_tag;
10797 cmdline_fixed_string_t set;
10798 cmdline_fixed_string_t insertion;
10799 cmdline_fixed_string_t stripping;
10800 cmdline_fixed_string_t forwarding;
10801 cmdline_fixed_string_t filter;
10802 cmdline_fixed_string_t add;
10803 cmdline_fixed_string_t del;
10804 cmdline_fixed_string_t on;
10805 cmdline_fixed_string_t off;
10806 cmdline_fixed_string_t on_off;
10807 cmdline_fixed_string_t port_tag_id;
10808 uint32_t port_tag_id_val;
10809 cmdline_fixed_string_t e_tag_id;
10810 uint16_t e_tag_id_val;
10811 cmdline_fixed_string_t dst_pool;
10812 uint8_t dst_pool_val;
10813 cmdline_fixed_string_t port;
10815 cmdline_fixed_string_t vf;
10819 /* Common CLI fields for all E-tag configuration */
10820 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10821 TOKEN_STRING_INITIALIZER
10822 (struct cmd_config_e_tag_result,
10824 cmdline_parse_token_string_t cmd_config_e_tag_set =
10825 TOKEN_STRING_INITIALIZER
10826 (struct cmd_config_e_tag_result,
10828 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10829 TOKEN_STRING_INITIALIZER
10830 (struct cmd_config_e_tag_result,
10831 insertion, "insertion");
10832 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10833 TOKEN_STRING_INITIALIZER
10834 (struct cmd_config_e_tag_result,
10835 stripping, "stripping");
10836 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10837 TOKEN_STRING_INITIALIZER
10838 (struct cmd_config_e_tag_result,
10839 forwarding, "forwarding");
10840 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10841 TOKEN_STRING_INITIALIZER
10842 (struct cmd_config_e_tag_result,
10844 cmdline_parse_token_string_t cmd_config_e_tag_add =
10845 TOKEN_STRING_INITIALIZER
10846 (struct cmd_config_e_tag_result,
10848 cmdline_parse_token_string_t cmd_config_e_tag_del =
10849 TOKEN_STRING_INITIALIZER
10850 (struct cmd_config_e_tag_result,
10852 cmdline_parse_token_string_t cmd_config_e_tag_on =
10853 TOKEN_STRING_INITIALIZER
10854 (struct cmd_config_e_tag_result,
10856 cmdline_parse_token_string_t cmd_config_e_tag_off =
10857 TOKEN_STRING_INITIALIZER
10858 (struct cmd_config_e_tag_result,
10860 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10861 TOKEN_STRING_INITIALIZER
10862 (struct cmd_config_e_tag_result,
10864 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10865 TOKEN_STRING_INITIALIZER
10866 (struct cmd_config_e_tag_result,
10867 port_tag_id, "port-tag-id");
10868 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10869 TOKEN_NUM_INITIALIZER
10870 (struct cmd_config_e_tag_result,
10871 port_tag_id_val, UINT32);
10872 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10873 TOKEN_STRING_INITIALIZER
10874 (struct cmd_config_e_tag_result,
10875 e_tag_id, "e-tag-id");
10876 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10877 TOKEN_NUM_INITIALIZER
10878 (struct cmd_config_e_tag_result,
10879 e_tag_id_val, UINT16);
10880 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10881 TOKEN_STRING_INITIALIZER
10882 (struct cmd_config_e_tag_result,
10883 dst_pool, "dst-pool");
10884 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10885 TOKEN_NUM_INITIALIZER
10886 (struct cmd_config_e_tag_result,
10887 dst_pool_val, UINT8);
10888 cmdline_parse_token_string_t cmd_config_e_tag_port =
10889 TOKEN_STRING_INITIALIZER
10890 (struct cmd_config_e_tag_result,
10892 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10893 TOKEN_NUM_INITIALIZER
10894 (struct cmd_config_e_tag_result,
10896 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10897 TOKEN_STRING_INITIALIZER
10898 (struct cmd_config_e_tag_result,
10900 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10901 TOKEN_NUM_INITIALIZER
10902 (struct cmd_config_e_tag_result,
10905 /* E-tag insertion configuration */
10907 cmd_config_e_tag_insertion_en_parsed(
10908 void *parsed_result,
10909 __attribute__((unused)) struct cmdline *cl,
10910 __attribute__((unused)) void *data)
10912 struct cmd_config_e_tag_result *res =
10914 struct rte_eth_l2_tunnel_conf entry;
10916 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10919 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10920 entry.tunnel_id = res->port_tag_id_val;
10921 entry.vf_id = res->vf_id;
10922 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10924 ETH_L2_TUNNEL_INSERTION_MASK,
10929 cmd_config_e_tag_insertion_dis_parsed(
10930 void *parsed_result,
10931 __attribute__((unused)) struct cmdline *cl,
10932 __attribute__((unused)) void *data)
10934 struct cmd_config_e_tag_result *res =
10936 struct rte_eth_l2_tunnel_conf entry;
10938 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10941 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10942 entry.vf_id = res->vf_id;
10944 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10946 ETH_L2_TUNNEL_INSERTION_MASK,
10950 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10951 .f = cmd_config_e_tag_insertion_en_parsed,
10953 .help_str = "E-tag ... : E-tag insertion enable",
10955 (void *)&cmd_config_e_tag_e_tag,
10956 (void *)&cmd_config_e_tag_set,
10957 (void *)&cmd_config_e_tag_insertion,
10958 (void *)&cmd_config_e_tag_on,
10959 (void *)&cmd_config_e_tag_port_tag_id,
10960 (void *)&cmd_config_e_tag_port_tag_id_val,
10961 (void *)&cmd_config_e_tag_port,
10962 (void *)&cmd_config_e_tag_port_id,
10963 (void *)&cmd_config_e_tag_vf,
10964 (void *)&cmd_config_e_tag_vf_id,
10969 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10970 .f = cmd_config_e_tag_insertion_dis_parsed,
10972 .help_str = "E-tag ... : E-tag insertion disable",
10974 (void *)&cmd_config_e_tag_e_tag,
10975 (void *)&cmd_config_e_tag_set,
10976 (void *)&cmd_config_e_tag_insertion,
10977 (void *)&cmd_config_e_tag_off,
10978 (void *)&cmd_config_e_tag_port,
10979 (void *)&cmd_config_e_tag_port_id,
10980 (void *)&cmd_config_e_tag_vf,
10981 (void *)&cmd_config_e_tag_vf_id,
10986 /* E-tag stripping configuration */
10988 cmd_config_e_tag_stripping_parsed(
10989 void *parsed_result,
10990 __attribute__((unused)) struct cmdline *cl,
10991 __attribute__((unused)) void *data)
10993 struct cmd_config_e_tag_result *res =
10995 struct rte_eth_l2_tunnel_conf entry;
10997 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11000 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11002 if (!strcmp(res->on_off, "on"))
11003 rte_eth_dev_l2_tunnel_offload_set
11006 ETH_L2_TUNNEL_STRIPPING_MASK,
11009 rte_eth_dev_l2_tunnel_offload_set
11012 ETH_L2_TUNNEL_STRIPPING_MASK,
11016 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11017 .f = cmd_config_e_tag_stripping_parsed,
11019 .help_str = "E-tag ... : E-tag stripping enable/disable",
11021 (void *)&cmd_config_e_tag_e_tag,
11022 (void *)&cmd_config_e_tag_set,
11023 (void *)&cmd_config_e_tag_stripping,
11024 (void *)&cmd_config_e_tag_on_off,
11025 (void *)&cmd_config_e_tag_port,
11026 (void *)&cmd_config_e_tag_port_id,
11031 /* E-tag forwarding configuration */
11033 cmd_config_e_tag_forwarding_parsed(
11034 void *parsed_result,
11035 __attribute__((unused)) struct cmdline *cl,
11036 __attribute__((unused)) void *data)
11038 struct cmd_config_e_tag_result *res = parsed_result;
11039 struct rte_eth_l2_tunnel_conf entry;
11041 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11044 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11046 if (!strcmp(res->on_off, "on"))
11047 rte_eth_dev_l2_tunnel_offload_set
11050 ETH_L2_TUNNEL_FORWARDING_MASK,
11053 rte_eth_dev_l2_tunnel_offload_set
11056 ETH_L2_TUNNEL_FORWARDING_MASK,
11060 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11061 .f = cmd_config_e_tag_forwarding_parsed,
11063 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11065 (void *)&cmd_config_e_tag_e_tag,
11066 (void *)&cmd_config_e_tag_set,
11067 (void *)&cmd_config_e_tag_forwarding,
11068 (void *)&cmd_config_e_tag_on_off,
11069 (void *)&cmd_config_e_tag_port,
11070 (void *)&cmd_config_e_tag_port_id,
11075 /* E-tag filter configuration */
11077 cmd_config_e_tag_filter_add_parsed(
11078 void *parsed_result,
11079 __attribute__((unused)) struct cmdline *cl,
11080 __attribute__((unused)) void *data)
11082 struct cmd_config_e_tag_result *res = parsed_result;
11083 struct rte_eth_l2_tunnel_conf entry;
11086 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11089 if (res->e_tag_id_val > 0x3fff) {
11090 printf("e-tag-id must be equal or less than 0x3fff.\n");
11094 ret = rte_eth_dev_filter_supported(res->port_id,
11095 RTE_ETH_FILTER_L2_TUNNEL);
11097 printf("E-tag filter is not supported on port %u.\n",
11102 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11103 entry.tunnel_id = res->e_tag_id_val;
11104 entry.pool = res->dst_pool_val;
11106 ret = rte_eth_dev_filter_ctrl(res->port_id,
11107 RTE_ETH_FILTER_L2_TUNNEL,
11108 RTE_ETH_FILTER_ADD,
11111 printf("E-tag filter programming error: (%s)\n",
11115 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
11116 .f = cmd_config_e_tag_filter_add_parsed,
11118 .help_str = "E-tag ... : E-tag filter add",
11120 (void *)&cmd_config_e_tag_e_tag,
11121 (void *)&cmd_config_e_tag_set,
11122 (void *)&cmd_config_e_tag_filter,
11123 (void *)&cmd_config_e_tag_add,
11124 (void *)&cmd_config_e_tag_e_tag_id,
11125 (void *)&cmd_config_e_tag_e_tag_id_val,
11126 (void *)&cmd_config_e_tag_dst_pool,
11127 (void *)&cmd_config_e_tag_dst_pool_val,
11128 (void *)&cmd_config_e_tag_port,
11129 (void *)&cmd_config_e_tag_port_id,
11135 cmd_config_e_tag_filter_del_parsed(
11136 void *parsed_result,
11137 __attribute__((unused)) struct cmdline *cl,
11138 __attribute__((unused)) void *data)
11140 struct cmd_config_e_tag_result *res = parsed_result;
11141 struct rte_eth_l2_tunnel_conf entry;
11144 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11147 if (res->e_tag_id_val > 0x3fff) {
11148 printf("e-tag-id must be less than 0x3fff.\n");
11152 ret = rte_eth_dev_filter_supported(res->port_id,
11153 RTE_ETH_FILTER_L2_TUNNEL);
11155 printf("E-tag filter is not supported on port %u.\n",
11160 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11161 entry.tunnel_id = res->e_tag_id_val;
11163 ret = rte_eth_dev_filter_ctrl(res->port_id,
11164 RTE_ETH_FILTER_L2_TUNNEL,
11165 RTE_ETH_FILTER_DELETE,
11168 printf("E-tag filter programming error: (%s)\n",
11172 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
11173 .f = cmd_config_e_tag_filter_del_parsed,
11175 .help_str = "E-tag ... : E-tag filter delete",
11177 (void *)&cmd_config_e_tag_e_tag,
11178 (void *)&cmd_config_e_tag_set,
11179 (void *)&cmd_config_e_tag_filter,
11180 (void *)&cmd_config_e_tag_del,
11181 (void *)&cmd_config_e_tag_e_tag_id,
11182 (void *)&cmd_config_e_tag_e_tag_id_val,
11183 (void *)&cmd_config_e_tag_port,
11184 (void *)&cmd_config_e_tag_port_id,
11189 /* vf vlan anti spoof configuration */
11191 /* Common result structure for vf vlan anti spoof */
11192 struct cmd_vf_vlan_anti_spoof_result {
11193 cmdline_fixed_string_t set;
11194 cmdline_fixed_string_t vf;
11195 cmdline_fixed_string_t vlan;
11196 cmdline_fixed_string_t antispoof;
11199 cmdline_fixed_string_t on_off;
11202 /* Common CLI fields for vf vlan anti spoof enable disable */
11203 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11204 TOKEN_STRING_INITIALIZER
11205 (struct cmd_vf_vlan_anti_spoof_result,
11207 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11208 TOKEN_STRING_INITIALIZER
11209 (struct cmd_vf_vlan_anti_spoof_result,
11211 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11212 TOKEN_STRING_INITIALIZER
11213 (struct cmd_vf_vlan_anti_spoof_result,
11215 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11216 TOKEN_STRING_INITIALIZER
11217 (struct cmd_vf_vlan_anti_spoof_result,
11218 antispoof, "antispoof");
11219 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11220 TOKEN_NUM_INITIALIZER
11221 (struct cmd_vf_vlan_anti_spoof_result,
11223 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11224 TOKEN_NUM_INITIALIZER
11225 (struct cmd_vf_vlan_anti_spoof_result,
11227 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11228 TOKEN_STRING_INITIALIZER
11229 (struct cmd_vf_vlan_anti_spoof_result,
11233 cmd_set_vf_vlan_anti_spoof_parsed(
11234 void *parsed_result,
11235 __attribute__((unused)) struct cmdline *cl,
11236 __attribute__((unused)) void *data)
11238 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11239 int ret = -ENOTSUP;
11241 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11243 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11246 #ifdef RTE_LIBRTE_IXGBE_PMD
11247 if (ret == -ENOTSUP)
11248 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11249 res->vf_id, is_on);
11251 #ifdef RTE_LIBRTE_I40E_PMD
11252 if (ret == -ENOTSUP)
11253 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11254 res->vf_id, is_on);
11256 #ifdef RTE_LIBRTE_BNXT_PMD
11257 if (ret == -ENOTSUP)
11258 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11259 res->vf_id, is_on);
11266 printf("invalid vf_id %d\n", res->vf_id);
11269 printf("invalid port_id %d\n", res->port_id);
11272 printf("function not implemented\n");
11275 printf("programming error: (%s)\n", strerror(-ret));
11279 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11280 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11282 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11284 (void *)&cmd_vf_vlan_anti_spoof_set,
11285 (void *)&cmd_vf_vlan_anti_spoof_vf,
11286 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11287 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11288 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11289 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11290 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11295 /* vf mac anti spoof configuration */
11297 /* Common result structure for vf mac anti spoof */
11298 struct cmd_vf_mac_anti_spoof_result {
11299 cmdline_fixed_string_t set;
11300 cmdline_fixed_string_t vf;
11301 cmdline_fixed_string_t mac;
11302 cmdline_fixed_string_t antispoof;
11305 cmdline_fixed_string_t on_off;
11308 /* Common CLI fields for vf mac anti spoof enable disable */
11309 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11310 TOKEN_STRING_INITIALIZER
11311 (struct cmd_vf_mac_anti_spoof_result,
11313 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11314 TOKEN_STRING_INITIALIZER
11315 (struct cmd_vf_mac_anti_spoof_result,
11317 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11318 TOKEN_STRING_INITIALIZER
11319 (struct cmd_vf_mac_anti_spoof_result,
11321 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11322 TOKEN_STRING_INITIALIZER
11323 (struct cmd_vf_mac_anti_spoof_result,
11324 antispoof, "antispoof");
11325 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11326 TOKEN_NUM_INITIALIZER
11327 (struct cmd_vf_mac_anti_spoof_result,
11329 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11330 TOKEN_NUM_INITIALIZER
11331 (struct cmd_vf_mac_anti_spoof_result,
11333 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11334 TOKEN_STRING_INITIALIZER
11335 (struct cmd_vf_mac_anti_spoof_result,
11339 cmd_set_vf_mac_anti_spoof_parsed(
11340 void *parsed_result,
11341 __attribute__((unused)) struct cmdline *cl,
11342 __attribute__((unused)) void *data)
11344 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11345 int ret = -ENOTSUP;
11347 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11349 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11352 #ifdef RTE_LIBRTE_IXGBE_PMD
11353 if (ret == -ENOTSUP)
11354 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11355 res->vf_id, is_on);
11357 #ifdef RTE_LIBRTE_I40E_PMD
11358 if (ret == -ENOTSUP)
11359 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11360 res->vf_id, is_on);
11362 #ifdef RTE_LIBRTE_BNXT_PMD
11363 if (ret == -ENOTSUP)
11364 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11365 res->vf_id, is_on);
11372 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11375 printf("invalid port_id %d\n", res->port_id);
11378 printf("function not implemented\n");
11381 printf("programming error: (%s)\n", strerror(-ret));
11385 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11386 .f = cmd_set_vf_mac_anti_spoof_parsed,
11388 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11390 (void *)&cmd_vf_mac_anti_spoof_set,
11391 (void *)&cmd_vf_mac_anti_spoof_vf,
11392 (void *)&cmd_vf_mac_anti_spoof_mac,
11393 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11394 (void *)&cmd_vf_mac_anti_spoof_port_id,
11395 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11396 (void *)&cmd_vf_mac_anti_spoof_on_off,
11401 /* vf vlan strip queue configuration */
11403 /* Common result structure for vf mac anti spoof */
11404 struct cmd_vf_vlan_stripq_result {
11405 cmdline_fixed_string_t set;
11406 cmdline_fixed_string_t vf;
11407 cmdline_fixed_string_t vlan;
11408 cmdline_fixed_string_t stripq;
11411 cmdline_fixed_string_t on_off;
11414 /* Common CLI fields for vf vlan strip enable disable */
11415 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11416 TOKEN_STRING_INITIALIZER
11417 (struct cmd_vf_vlan_stripq_result,
11419 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11420 TOKEN_STRING_INITIALIZER
11421 (struct cmd_vf_vlan_stripq_result,
11423 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11424 TOKEN_STRING_INITIALIZER
11425 (struct cmd_vf_vlan_stripq_result,
11427 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11428 TOKEN_STRING_INITIALIZER
11429 (struct cmd_vf_vlan_stripq_result,
11431 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11432 TOKEN_NUM_INITIALIZER
11433 (struct cmd_vf_vlan_stripq_result,
11435 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11436 TOKEN_NUM_INITIALIZER
11437 (struct cmd_vf_vlan_stripq_result,
11439 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11440 TOKEN_STRING_INITIALIZER
11441 (struct cmd_vf_vlan_stripq_result,
11445 cmd_set_vf_vlan_stripq_parsed(
11446 void *parsed_result,
11447 __attribute__((unused)) struct cmdline *cl,
11448 __attribute__((unused)) void *data)
11450 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11451 int ret = -ENOTSUP;
11453 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11455 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11458 #ifdef RTE_LIBRTE_IXGBE_PMD
11459 if (ret == -ENOTSUP)
11460 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11461 res->vf_id, is_on);
11463 #ifdef RTE_LIBRTE_I40E_PMD
11464 if (ret == -ENOTSUP)
11465 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11466 res->vf_id, is_on);
11468 #ifdef RTE_LIBRTE_BNXT_PMD
11469 if (ret == -ENOTSUP)
11470 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11471 res->vf_id, is_on);
11478 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11481 printf("invalid port_id %d\n", res->port_id);
11484 printf("function not implemented\n");
11487 printf("programming error: (%s)\n", strerror(-ret));
11491 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11492 .f = cmd_set_vf_vlan_stripq_parsed,
11494 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11496 (void *)&cmd_vf_vlan_stripq_set,
11497 (void *)&cmd_vf_vlan_stripq_vf,
11498 (void *)&cmd_vf_vlan_stripq_vlan,
11499 (void *)&cmd_vf_vlan_stripq_stripq,
11500 (void *)&cmd_vf_vlan_stripq_port_id,
11501 (void *)&cmd_vf_vlan_stripq_vf_id,
11502 (void *)&cmd_vf_vlan_stripq_on_off,
11507 /* vf vlan insert configuration */
11509 /* Common result structure for vf vlan insert */
11510 struct cmd_vf_vlan_insert_result {
11511 cmdline_fixed_string_t set;
11512 cmdline_fixed_string_t vf;
11513 cmdline_fixed_string_t vlan;
11514 cmdline_fixed_string_t insert;
11520 /* Common CLI fields for vf vlan insert enable disable */
11521 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11522 TOKEN_STRING_INITIALIZER
11523 (struct cmd_vf_vlan_insert_result,
11525 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11526 TOKEN_STRING_INITIALIZER
11527 (struct cmd_vf_vlan_insert_result,
11529 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11530 TOKEN_STRING_INITIALIZER
11531 (struct cmd_vf_vlan_insert_result,
11533 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11534 TOKEN_STRING_INITIALIZER
11535 (struct cmd_vf_vlan_insert_result,
11537 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11538 TOKEN_NUM_INITIALIZER
11539 (struct cmd_vf_vlan_insert_result,
11541 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11542 TOKEN_NUM_INITIALIZER
11543 (struct cmd_vf_vlan_insert_result,
11545 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11546 TOKEN_NUM_INITIALIZER
11547 (struct cmd_vf_vlan_insert_result,
11551 cmd_set_vf_vlan_insert_parsed(
11552 void *parsed_result,
11553 __attribute__((unused)) struct cmdline *cl,
11554 __attribute__((unused)) void *data)
11556 struct cmd_vf_vlan_insert_result *res = parsed_result;
11557 int ret = -ENOTSUP;
11559 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11562 #ifdef RTE_LIBRTE_IXGBE_PMD
11563 if (ret == -ENOTSUP)
11564 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11567 #ifdef RTE_LIBRTE_I40E_PMD
11568 if (ret == -ENOTSUP)
11569 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11572 #ifdef RTE_LIBRTE_BNXT_PMD
11573 if (ret == -ENOTSUP)
11574 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11582 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11585 printf("invalid port_id %d\n", res->port_id);
11588 printf("function not implemented\n");
11591 printf("programming error: (%s)\n", strerror(-ret));
11595 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11596 .f = cmd_set_vf_vlan_insert_parsed,
11598 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11600 (void *)&cmd_vf_vlan_insert_set,
11601 (void *)&cmd_vf_vlan_insert_vf,
11602 (void *)&cmd_vf_vlan_insert_vlan,
11603 (void *)&cmd_vf_vlan_insert_insert,
11604 (void *)&cmd_vf_vlan_insert_port_id,
11605 (void *)&cmd_vf_vlan_insert_vf_id,
11606 (void *)&cmd_vf_vlan_insert_vlan_id,
11611 /* tx loopback configuration */
11613 /* Common result structure for tx loopback */
11614 struct cmd_tx_loopback_result {
11615 cmdline_fixed_string_t set;
11616 cmdline_fixed_string_t tx;
11617 cmdline_fixed_string_t loopback;
11619 cmdline_fixed_string_t on_off;
11622 /* Common CLI fields for tx loopback enable disable */
11623 cmdline_parse_token_string_t cmd_tx_loopback_set =
11624 TOKEN_STRING_INITIALIZER
11625 (struct cmd_tx_loopback_result,
11627 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11628 TOKEN_STRING_INITIALIZER
11629 (struct cmd_tx_loopback_result,
11631 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11632 TOKEN_STRING_INITIALIZER
11633 (struct cmd_tx_loopback_result,
11634 loopback, "loopback");
11635 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11636 TOKEN_NUM_INITIALIZER
11637 (struct cmd_tx_loopback_result,
11639 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11640 TOKEN_STRING_INITIALIZER
11641 (struct cmd_tx_loopback_result,
11645 cmd_set_tx_loopback_parsed(
11646 void *parsed_result,
11647 __attribute__((unused)) struct cmdline *cl,
11648 __attribute__((unused)) void *data)
11650 struct cmd_tx_loopback_result *res = parsed_result;
11651 int ret = -ENOTSUP;
11653 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11655 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11658 #ifdef RTE_LIBRTE_IXGBE_PMD
11659 if (ret == -ENOTSUP)
11660 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11662 #ifdef RTE_LIBRTE_I40E_PMD
11663 if (ret == -ENOTSUP)
11664 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11666 #ifdef RTE_LIBRTE_BNXT_PMD
11667 if (ret == -ENOTSUP)
11668 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11675 printf("invalid is_on %d\n", is_on);
11678 printf("invalid port_id %d\n", res->port_id);
11681 printf("function not implemented\n");
11684 printf("programming error: (%s)\n", strerror(-ret));
11688 cmdline_parse_inst_t cmd_set_tx_loopback = {
11689 .f = cmd_set_tx_loopback_parsed,
11691 .help_str = "set tx loopback <port_id> on|off",
11693 (void *)&cmd_tx_loopback_set,
11694 (void *)&cmd_tx_loopback_tx,
11695 (void *)&cmd_tx_loopback_loopback,
11696 (void *)&cmd_tx_loopback_port_id,
11697 (void *)&cmd_tx_loopback_on_off,
11702 /* all queues drop enable configuration */
11704 /* Common result structure for all queues drop enable */
11705 struct cmd_all_queues_drop_en_result {
11706 cmdline_fixed_string_t set;
11707 cmdline_fixed_string_t all;
11708 cmdline_fixed_string_t queues;
11709 cmdline_fixed_string_t drop;
11711 cmdline_fixed_string_t on_off;
11714 /* Common CLI fields for tx loopback enable disable */
11715 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11716 TOKEN_STRING_INITIALIZER
11717 (struct cmd_all_queues_drop_en_result,
11719 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11720 TOKEN_STRING_INITIALIZER
11721 (struct cmd_all_queues_drop_en_result,
11723 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11724 TOKEN_STRING_INITIALIZER
11725 (struct cmd_all_queues_drop_en_result,
11727 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11728 TOKEN_STRING_INITIALIZER
11729 (struct cmd_all_queues_drop_en_result,
11731 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11732 TOKEN_NUM_INITIALIZER
11733 (struct cmd_all_queues_drop_en_result,
11735 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11736 TOKEN_STRING_INITIALIZER
11737 (struct cmd_all_queues_drop_en_result,
11741 cmd_set_all_queues_drop_en_parsed(
11742 void *parsed_result,
11743 __attribute__((unused)) struct cmdline *cl,
11744 __attribute__((unused)) void *data)
11746 struct cmd_all_queues_drop_en_result *res = parsed_result;
11747 int ret = -ENOTSUP;
11748 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11750 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11753 #ifdef RTE_LIBRTE_IXGBE_PMD
11754 if (ret == -ENOTSUP)
11755 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11757 #ifdef RTE_LIBRTE_BNXT_PMD
11758 if (ret == -ENOTSUP)
11759 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11765 printf("invalid is_on %d\n", is_on);
11768 printf("invalid port_id %d\n", res->port_id);
11771 printf("function not implemented\n");
11774 printf("programming error: (%s)\n", strerror(-ret));
11778 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11779 .f = cmd_set_all_queues_drop_en_parsed,
11781 .help_str = "set all queues drop <port_id> on|off",
11783 (void *)&cmd_all_queues_drop_en_set,
11784 (void *)&cmd_all_queues_drop_en_all,
11785 (void *)&cmd_all_queues_drop_en_queues,
11786 (void *)&cmd_all_queues_drop_en_drop,
11787 (void *)&cmd_all_queues_drop_en_port_id,
11788 (void *)&cmd_all_queues_drop_en_on_off,
11793 /* vf split drop enable configuration */
11795 /* Common result structure for vf split drop enable */
11796 struct cmd_vf_split_drop_en_result {
11797 cmdline_fixed_string_t set;
11798 cmdline_fixed_string_t vf;
11799 cmdline_fixed_string_t split;
11800 cmdline_fixed_string_t drop;
11803 cmdline_fixed_string_t on_off;
11806 /* Common CLI fields for vf split drop enable disable */
11807 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11808 TOKEN_STRING_INITIALIZER
11809 (struct cmd_vf_split_drop_en_result,
11811 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11812 TOKEN_STRING_INITIALIZER
11813 (struct cmd_vf_split_drop_en_result,
11815 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11816 TOKEN_STRING_INITIALIZER
11817 (struct cmd_vf_split_drop_en_result,
11819 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11820 TOKEN_STRING_INITIALIZER
11821 (struct cmd_vf_split_drop_en_result,
11823 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11824 TOKEN_NUM_INITIALIZER
11825 (struct cmd_vf_split_drop_en_result,
11827 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11828 TOKEN_NUM_INITIALIZER
11829 (struct cmd_vf_split_drop_en_result,
11831 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11832 TOKEN_STRING_INITIALIZER
11833 (struct cmd_vf_split_drop_en_result,
11837 cmd_set_vf_split_drop_en_parsed(
11838 void *parsed_result,
11839 __attribute__((unused)) struct cmdline *cl,
11840 __attribute__((unused)) void *data)
11842 struct cmd_vf_split_drop_en_result *res = parsed_result;
11843 int ret = -ENOTSUP;
11844 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11846 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11849 #ifdef RTE_LIBRTE_IXGBE_PMD
11850 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11857 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11860 printf("invalid port_id %d\n", res->port_id);
11863 printf("not supported on port %d\n", res->port_id);
11866 printf("programming error: (%s)\n", strerror(-ret));
11870 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11871 .f = cmd_set_vf_split_drop_en_parsed,
11873 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11875 (void *)&cmd_vf_split_drop_en_set,
11876 (void *)&cmd_vf_split_drop_en_vf,
11877 (void *)&cmd_vf_split_drop_en_split,
11878 (void *)&cmd_vf_split_drop_en_drop,
11879 (void *)&cmd_vf_split_drop_en_port_id,
11880 (void *)&cmd_vf_split_drop_en_vf_id,
11881 (void *)&cmd_vf_split_drop_en_on_off,
11886 /* vf mac address configuration */
11888 /* Common result structure for vf mac address */
11889 struct cmd_set_vf_mac_addr_result {
11890 cmdline_fixed_string_t set;
11891 cmdline_fixed_string_t vf;
11892 cmdline_fixed_string_t mac;
11893 cmdline_fixed_string_t addr;
11896 struct ether_addr mac_addr;
11900 /* Common CLI fields for vf split drop enable disable */
11901 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11902 TOKEN_STRING_INITIALIZER
11903 (struct cmd_set_vf_mac_addr_result,
11905 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11906 TOKEN_STRING_INITIALIZER
11907 (struct cmd_set_vf_mac_addr_result,
11909 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11910 TOKEN_STRING_INITIALIZER
11911 (struct cmd_set_vf_mac_addr_result,
11913 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11914 TOKEN_STRING_INITIALIZER
11915 (struct cmd_set_vf_mac_addr_result,
11917 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11918 TOKEN_NUM_INITIALIZER
11919 (struct cmd_set_vf_mac_addr_result,
11921 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11922 TOKEN_NUM_INITIALIZER
11923 (struct cmd_set_vf_mac_addr_result,
11925 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11926 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11930 cmd_set_vf_mac_addr_parsed(
11931 void *parsed_result,
11932 __attribute__((unused)) struct cmdline *cl,
11933 __attribute__((unused)) void *data)
11935 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11936 int ret = -ENOTSUP;
11938 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11941 #ifdef RTE_LIBRTE_IXGBE_PMD
11942 if (ret == -ENOTSUP)
11943 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11946 #ifdef RTE_LIBRTE_I40E_PMD
11947 if (ret == -ENOTSUP)
11948 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11951 #ifdef RTE_LIBRTE_BNXT_PMD
11952 if (ret == -ENOTSUP)
11953 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11961 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11964 printf("invalid port_id %d\n", res->port_id);
11967 printf("function not implemented\n");
11970 printf("programming error: (%s)\n", strerror(-ret));
11974 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11975 .f = cmd_set_vf_mac_addr_parsed,
11977 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11979 (void *)&cmd_set_vf_mac_addr_set,
11980 (void *)&cmd_set_vf_mac_addr_vf,
11981 (void *)&cmd_set_vf_mac_addr_mac,
11982 (void *)&cmd_set_vf_mac_addr_addr,
11983 (void *)&cmd_set_vf_mac_addr_port_id,
11984 (void *)&cmd_set_vf_mac_addr_vf_id,
11985 (void *)&cmd_set_vf_mac_addr_mac_addr,
11990 /* MACsec configuration */
11992 /* Common result structure for MACsec offload enable */
11993 struct cmd_macsec_offload_on_result {
11994 cmdline_fixed_string_t set;
11995 cmdline_fixed_string_t macsec;
11996 cmdline_fixed_string_t offload;
11998 cmdline_fixed_string_t on;
11999 cmdline_fixed_string_t encrypt;
12000 cmdline_fixed_string_t en_on_off;
12001 cmdline_fixed_string_t replay_protect;
12002 cmdline_fixed_string_t rp_on_off;
12005 /* Common CLI fields for MACsec offload disable */
12006 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12007 TOKEN_STRING_INITIALIZER
12008 (struct cmd_macsec_offload_on_result,
12010 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12011 TOKEN_STRING_INITIALIZER
12012 (struct cmd_macsec_offload_on_result,
12014 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12015 TOKEN_STRING_INITIALIZER
12016 (struct cmd_macsec_offload_on_result,
12017 offload, "offload");
12018 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12019 TOKEN_NUM_INITIALIZER
12020 (struct cmd_macsec_offload_on_result,
12022 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12023 TOKEN_STRING_INITIALIZER
12024 (struct cmd_macsec_offload_on_result,
12026 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12027 TOKEN_STRING_INITIALIZER
12028 (struct cmd_macsec_offload_on_result,
12029 encrypt, "encrypt");
12030 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12031 TOKEN_STRING_INITIALIZER
12032 (struct cmd_macsec_offload_on_result,
12033 en_on_off, "on#off");
12034 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12035 TOKEN_STRING_INITIALIZER
12036 (struct cmd_macsec_offload_on_result,
12037 replay_protect, "replay-protect");
12038 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12039 TOKEN_STRING_INITIALIZER
12040 (struct cmd_macsec_offload_on_result,
12041 rp_on_off, "on#off");
12044 cmd_set_macsec_offload_on_parsed(
12045 void *parsed_result,
12046 __attribute__((unused)) struct cmdline *cl,
12047 __attribute__((unused)) void *data)
12049 struct cmd_macsec_offload_on_result *res = parsed_result;
12050 int ret = -ENOTSUP;
12051 portid_t port_id = res->port_id;
12052 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12053 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12055 if (port_id_is_invalid(port_id, ENABLED_WARN))
12058 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
12059 #ifdef RTE_LIBRTE_IXGBE_PMD
12060 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12069 printf("invalid port_id %d\n", port_id);
12072 printf("not supported on port %d\n", port_id);
12075 printf("programming error: (%s)\n", strerror(-ret));
12079 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12080 .f = cmd_set_macsec_offload_on_parsed,
12082 .help_str = "set macsec offload <port_id> on "
12083 "encrypt on|off replay-protect on|off",
12085 (void *)&cmd_macsec_offload_on_set,
12086 (void *)&cmd_macsec_offload_on_macsec,
12087 (void *)&cmd_macsec_offload_on_offload,
12088 (void *)&cmd_macsec_offload_on_port_id,
12089 (void *)&cmd_macsec_offload_on_on,
12090 (void *)&cmd_macsec_offload_on_encrypt,
12091 (void *)&cmd_macsec_offload_on_en_on_off,
12092 (void *)&cmd_macsec_offload_on_replay_protect,
12093 (void *)&cmd_macsec_offload_on_rp_on_off,
12098 /* Common result structure for MACsec offload disable */
12099 struct cmd_macsec_offload_off_result {
12100 cmdline_fixed_string_t set;
12101 cmdline_fixed_string_t macsec;
12102 cmdline_fixed_string_t offload;
12104 cmdline_fixed_string_t off;
12107 /* Common CLI fields for MACsec offload disable */
12108 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12109 TOKEN_STRING_INITIALIZER
12110 (struct cmd_macsec_offload_off_result,
12112 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12113 TOKEN_STRING_INITIALIZER
12114 (struct cmd_macsec_offload_off_result,
12116 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12117 TOKEN_STRING_INITIALIZER
12118 (struct cmd_macsec_offload_off_result,
12119 offload, "offload");
12120 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12121 TOKEN_NUM_INITIALIZER
12122 (struct cmd_macsec_offload_off_result,
12124 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12125 TOKEN_STRING_INITIALIZER
12126 (struct cmd_macsec_offload_off_result,
12130 cmd_set_macsec_offload_off_parsed(
12131 void *parsed_result,
12132 __attribute__((unused)) struct cmdline *cl,
12133 __attribute__((unused)) void *data)
12135 struct cmd_macsec_offload_off_result *res = parsed_result;
12136 int ret = -ENOTSUP;
12137 portid_t port_id = res->port_id;
12139 if (port_id_is_invalid(port_id, ENABLED_WARN))
12142 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
12143 #ifdef RTE_LIBRTE_IXGBE_PMD
12144 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12151 printf("invalid port_id %d\n", port_id);
12154 printf("not supported on port %d\n", port_id);
12157 printf("programming error: (%s)\n", strerror(-ret));
12161 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12162 .f = cmd_set_macsec_offload_off_parsed,
12164 .help_str = "set macsec offload <port_id> off",
12166 (void *)&cmd_macsec_offload_off_set,
12167 (void *)&cmd_macsec_offload_off_macsec,
12168 (void *)&cmd_macsec_offload_off_offload,
12169 (void *)&cmd_macsec_offload_off_port_id,
12170 (void *)&cmd_macsec_offload_off_off,
12175 /* Common result structure for MACsec secure connection configure */
12176 struct cmd_macsec_sc_result {
12177 cmdline_fixed_string_t set;
12178 cmdline_fixed_string_t macsec;
12179 cmdline_fixed_string_t sc;
12180 cmdline_fixed_string_t tx_rx;
12182 struct ether_addr mac;
12186 /* Common CLI fields for MACsec secure connection configure */
12187 cmdline_parse_token_string_t cmd_macsec_sc_set =
12188 TOKEN_STRING_INITIALIZER
12189 (struct cmd_macsec_sc_result,
12191 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12192 TOKEN_STRING_INITIALIZER
12193 (struct cmd_macsec_sc_result,
12195 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12196 TOKEN_STRING_INITIALIZER
12197 (struct cmd_macsec_sc_result,
12199 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12200 TOKEN_STRING_INITIALIZER
12201 (struct cmd_macsec_sc_result,
12203 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12204 TOKEN_NUM_INITIALIZER
12205 (struct cmd_macsec_sc_result,
12207 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12208 TOKEN_ETHERADDR_INITIALIZER
12209 (struct cmd_macsec_sc_result,
12211 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12212 TOKEN_NUM_INITIALIZER
12213 (struct cmd_macsec_sc_result,
12217 cmd_set_macsec_sc_parsed(
12218 void *parsed_result,
12219 __attribute__((unused)) struct cmdline *cl,
12220 __attribute__((unused)) void *data)
12222 struct cmd_macsec_sc_result *res = parsed_result;
12223 int ret = -ENOTSUP;
12224 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12226 #ifdef RTE_LIBRTE_IXGBE_PMD
12228 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12229 res->mac.addr_bytes) :
12230 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12231 res->mac.addr_bytes, res->pi);
12233 RTE_SET_USED(is_tx);
12239 printf("invalid port_id %d\n", res->port_id);
12242 printf("not supported on port %d\n", res->port_id);
12245 printf("programming error: (%s)\n", strerror(-ret));
12249 cmdline_parse_inst_t cmd_set_macsec_sc = {
12250 .f = cmd_set_macsec_sc_parsed,
12252 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12254 (void *)&cmd_macsec_sc_set,
12255 (void *)&cmd_macsec_sc_macsec,
12256 (void *)&cmd_macsec_sc_sc,
12257 (void *)&cmd_macsec_sc_tx_rx,
12258 (void *)&cmd_macsec_sc_port_id,
12259 (void *)&cmd_macsec_sc_mac,
12260 (void *)&cmd_macsec_sc_pi,
12265 /* Common result structure for MACsec secure connection configure */
12266 struct cmd_macsec_sa_result {
12267 cmdline_fixed_string_t set;
12268 cmdline_fixed_string_t macsec;
12269 cmdline_fixed_string_t sa;
12270 cmdline_fixed_string_t tx_rx;
12275 cmdline_fixed_string_t key;
12278 /* Common CLI fields for MACsec secure connection configure */
12279 cmdline_parse_token_string_t cmd_macsec_sa_set =
12280 TOKEN_STRING_INITIALIZER
12281 (struct cmd_macsec_sa_result,
12283 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12284 TOKEN_STRING_INITIALIZER
12285 (struct cmd_macsec_sa_result,
12287 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12288 TOKEN_STRING_INITIALIZER
12289 (struct cmd_macsec_sa_result,
12291 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12292 TOKEN_STRING_INITIALIZER
12293 (struct cmd_macsec_sa_result,
12295 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12296 TOKEN_NUM_INITIALIZER
12297 (struct cmd_macsec_sa_result,
12299 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12300 TOKEN_NUM_INITIALIZER
12301 (struct cmd_macsec_sa_result,
12303 cmdline_parse_token_num_t cmd_macsec_sa_an =
12304 TOKEN_NUM_INITIALIZER
12305 (struct cmd_macsec_sa_result,
12307 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12308 TOKEN_NUM_INITIALIZER
12309 (struct cmd_macsec_sa_result,
12311 cmdline_parse_token_string_t cmd_macsec_sa_key =
12312 TOKEN_STRING_INITIALIZER
12313 (struct cmd_macsec_sa_result,
12317 cmd_set_macsec_sa_parsed(
12318 void *parsed_result,
12319 __attribute__((unused)) struct cmdline *cl,
12320 __attribute__((unused)) void *data)
12322 struct cmd_macsec_sa_result *res = parsed_result;
12323 int ret = -ENOTSUP;
12324 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12325 uint8_t key[16] = { 0 };
12331 key_len = strlen(res->key) / 2;
12335 for (i = 0; i < key_len; i++) {
12336 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12339 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12342 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12345 #ifdef RTE_LIBRTE_IXGBE_PMD
12347 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12348 res->idx, res->an, res->pn, key) :
12349 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12350 res->idx, res->an, res->pn, key);
12352 RTE_SET_USED(is_tx);
12359 printf("invalid idx %d or an %d\n", res->idx, res->an);
12362 printf("invalid port_id %d\n", res->port_id);
12365 printf("not supported on port %d\n", res->port_id);
12368 printf("programming error: (%s)\n", strerror(-ret));
12372 cmdline_parse_inst_t cmd_set_macsec_sa = {
12373 .f = cmd_set_macsec_sa_parsed,
12375 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12377 (void *)&cmd_macsec_sa_set,
12378 (void *)&cmd_macsec_sa_macsec,
12379 (void *)&cmd_macsec_sa_sa,
12380 (void *)&cmd_macsec_sa_tx_rx,
12381 (void *)&cmd_macsec_sa_port_id,
12382 (void *)&cmd_macsec_sa_idx,
12383 (void *)&cmd_macsec_sa_an,
12384 (void *)&cmd_macsec_sa_pn,
12385 (void *)&cmd_macsec_sa_key,
12390 /* VF unicast promiscuous mode configuration */
12392 /* Common result structure for VF unicast promiscuous mode */
12393 struct cmd_vf_promisc_result {
12394 cmdline_fixed_string_t set;
12395 cmdline_fixed_string_t vf;
12396 cmdline_fixed_string_t promisc;
12399 cmdline_fixed_string_t on_off;
12402 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12403 cmdline_parse_token_string_t cmd_vf_promisc_set =
12404 TOKEN_STRING_INITIALIZER
12405 (struct cmd_vf_promisc_result,
12407 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12408 TOKEN_STRING_INITIALIZER
12409 (struct cmd_vf_promisc_result,
12411 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12412 TOKEN_STRING_INITIALIZER
12413 (struct cmd_vf_promisc_result,
12414 promisc, "promisc");
12415 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12416 TOKEN_NUM_INITIALIZER
12417 (struct cmd_vf_promisc_result,
12419 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12420 TOKEN_NUM_INITIALIZER
12421 (struct cmd_vf_promisc_result,
12423 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12424 TOKEN_STRING_INITIALIZER
12425 (struct cmd_vf_promisc_result,
12429 cmd_set_vf_promisc_parsed(
12430 void *parsed_result,
12431 __attribute__((unused)) struct cmdline *cl,
12432 __attribute__((unused)) void *data)
12434 struct cmd_vf_promisc_result *res = parsed_result;
12435 int ret = -ENOTSUP;
12437 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12439 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12442 #ifdef RTE_LIBRTE_I40E_PMD
12443 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12444 res->vf_id, is_on);
12451 printf("invalid vf_id %d\n", res->vf_id);
12454 printf("invalid port_id %d\n", res->port_id);
12457 printf("function not implemented\n");
12460 printf("programming error: (%s)\n", strerror(-ret));
12464 cmdline_parse_inst_t cmd_set_vf_promisc = {
12465 .f = cmd_set_vf_promisc_parsed,
12467 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12468 "Set unicast promiscuous mode for a VF from the PF",
12470 (void *)&cmd_vf_promisc_set,
12471 (void *)&cmd_vf_promisc_vf,
12472 (void *)&cmd_vf_promisc_promisc,
12473 (void *)&cmd_vf_promisc_port_id,
12474 (void *)&cmd_vf_promisc_vf_id,
12475 (void *)&cmd_vf_promisc_on_off,
12480 /* VF multicast promiscuous mode configuration */
12482 /* Common result structure for VF multicast promiscuous mode */
12483 struct cmd_vf_allmulti_result {
12484 cmdline_fixed_string_t set;
12485 cmdline_fixed_string_t vf;
12486 cmdline_fixed_string_t allmulti;
12489 cmdline_fixed_string_t on_off;
12492 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12493 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12494 TOKEN_STRING_INITIALIZER
12495 (struct cmd_vf_allmulti_result,
12497 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12498 TOKEN_STRING_INITIALIZER
12499 (struct cmd_vf_allmulti_result,
12501 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12502 TOKEN_STRING_INITIALIZER
12503 (struct cmd_vf_allmulti_result,
12504 allmulti, "allmulti");
12505 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12506 TOKEN_NUM_INITIALIZER
12507 (struct cmd_vf_allmulti_result,
12509 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12510 TOKEN_NUM_INITIALIZER
12511 (struct cmd_vf_allmulti_result,
12513 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12514 TOKEN_STRING_INITIALIZER
12515 (struct cmd_vf_allmulti_result,
12519 cmd_set_vf_allmulti_parsed(
12520 void *parsed_result,
12521 __attribute__((unused)) struct cmdline *cl,
12522 __attribute__((unused)) void *data)
12524 struct cmd_vf_allmulti_result *res = parsed_result;
12525 int ret = -ENOTSUP;
12527 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12529 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12532 #ifdef RTE_LIBRTE_I40E_PMD
12533 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12534 res->vf_id, is_on);
12541 printf("invalid vf_id %d\n", res->vf_id);
12544 printf("invalid port_id %d\n", res->port_id);
12547 printf("function not implemented\n");
12550 printf("programming error: (%s)\n", strerror(-ret));
12554 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12555 .f = cmd_set_vf_allmulti_parsed,
12557 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12558 "Set multicast promiscuous mode for a VF from the PF",
12560 (void *)&cmd_vf_allmulti_set,
12561 (void *)&cmd_vf_allmulti_vf,
12562 (void *)&cmd_vf_allmulti_allmulti,
12563 (void *)&cmd_vf_allmulti_port_id,
12564 (void *)&cmd_vf_allmulti_vf_id,
12565 (void *)&cmd_vf_allmulti_on_off,
12570 /* vf broadcast mode configuration */
12572 /* Common result structure for vf broadcast */
12573 struct cmd_set_vf_broadcast_result {
12574 cmdline_fixed_string_t set;
12575 cmdline_fixed_string_t vf;
12576 cmdline_fixed_string_t broadcast;
12579 cmdline_fixed_string_t on_off;
12582 /* Common CLI fields for vf broadcast enable disable */
12583 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12584 TOKEN_STRING_INITIALIZER
12585 (struct cmd_set_vf_broadcast_result,
12587 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12588 TOKEN_STRING_INITIALIZER
12589 (struct cmd_set_vf_broadcast_result,
12591 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12592 TOKEN_STRING_INITIALIZER
12593 (struct cmd_set_vf_broadcast_result,
12594 broadcast, "broadcast");
12595 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12596 TOKEN_NUM_INITIALIZER
12597 (struct cmd_set_vf_broadcast_result,
12599 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12600 TOKEN_NUM_INITIALIZER
12601 (struct cmd_set_vf_broadcast_result,
12603 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12604 TOKEN_STRING_INITIALIZER
12605 (struct cmd_set_vf_broadcast_result,
12609 cmd_set_vf_broadcast_parsed(
12610 void *parsed_result,
12611 __attribute__((unused)) struct cmdline *cl,
12612 __attribute__((unused)) void *data)
12614 struct cmd_set_vf_broadcast_result *res = parsed_result;
12615 int ret = -ENOTSUP;
12617 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12619 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12622 #ifdef RTE_LIBRTE_I40E_PMD
12623 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12624 res->vf_id, is_on);
12631 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12634 printf("invalid port_id %d\n", res->port_id);
12637 printf("function not implemented\n");
12640 printf("programming error: (%s)\n", strerror(-ret));
12644 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12645 .f = cmd_set_vf_broadcast_parsed,
12647 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12649 (void *)&cmd_set_vf_broadcast_set,
12650 (void *)&cmd_set_vf_broadcast_vf,
12651 (void *)&cmd_set_vf_broadcast_broadcast,
12652 (void *)&cmd_set_vf_broadcast_port_id,
12653 (void *)&cmd_set_vf_broadcast_vf_id,
12654 (void *)&cmd_set_vf_broadcast_on_off,
12659 /* vf vlan tag configuration */
12661 /* Common result structure for vf vlan tag */
12662 struct cmd_set_vf_vlan_tag_result {
12663 cmdline_fixed_string_t set;
12664 cmdline_fixed_string_t vf;
12665 cmdline_fixed_string_t vlan;
12666 cmdline_fixed_string_t tag;
12669 cmdline_fixed_string_t on_off;
12672 /* Common CLI fields for vf vlan tag enable disable */
12673 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12674 TOKEN_STRING_INITIALIZER
12675 (struct cmd_set_vf_vlan_tag_result,
12677 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12678 TOKEN_STRING_INITIALIZER
12679 (struct cmd_set_vf_vlan_tag_result,
12681 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12682 TOKEN_STRING_INITIALIZER
12683 (struct cmd_set_vf_vlan_tag_result,
12685 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12686 TOKEN_STRING_INITIALIZER
12687 (struct cmd_set_vf_vlan_tag_result,
12689 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12690 TOKEN_NUM_INITIALIZER
12691 (struct cmd_set_vf_vlan_tag_result,
12693 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12694 TOKEN_NUM_INITIALIZER
12695 (struct cmd_set_vf_vlan_tag_result,
12697 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12698 TOKEN_STRING_INITIALIZER
12699 (struct cmd_set_vf_vlan_tag_result,
12703 cmd_set_vf_vlan_tag_parsed(
12704 void *parsed_result,
12705 __attribute__((unused)) struct cmdline *cl,
12706 __attribute__((unused)) void *data)
12708 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12709 int ret = -ENOTSUP;
12711 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12713 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12716 #ifdef RTE_LIBRTE_I40E_PMD
12717 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12718 res->vf_id, is_on);
12725 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12728 printf("invalid port_id %d\n", res->port_id);
12731 printf("function not implemented\n");
12734 printf("programming error: (%s)\n", strerror(-ret));
12738 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12739 .f = cmd_set_vf_vlan_tag_parsed,
12741 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12743 (void *)&cmd_set_vf_vlan_tag_set,
12744 (void *)&cmd_set_vf_vlan_tag_vf,
12745 (void *)&cmd_set_vf_vlan_tag_vlan,
12746 (void *)&cmd_set_vf_vlan_tag_tag,
12747 (void *)&cmd_set_vf_vlan_tag_port_id,
12748 (void *)&cmd_set_vf_vlan_tag_vf_id,
12749 (void *)&cmd_set_vf_vlan_tag_on_off,
12754 /* Common definition of VF and TC TX bandwidth configuration */
12755 struct cmd_vf_tc_bw_result {
12756 cmdline_fixed_string_t set;
12757 cmdline_fixed_string_t vf;
12758 cmdline_fixed_string_t tc;
12759 cmdline_fixed_string_t tx;
12760 cmdline_fixed_string_t min_bw;
12761 cmdline_fixed_string_t max_bw;
12762 cmdline_fixed_string_t strict_link_prio;
12767 cmdline_fixed_string_t bw_list;
12771 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12772 TOKEN_STRING_INITIALIZER
12773 (struct cmd_vf_tc_bw_result,
12775 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12776 TOKEN_STRING_INITIALIZER
12777 (struct cmd_vf_tc_bw_result,
12779 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12780 TOKEN_STRING_INITIALIZER
12781 (struct cmd_vf_tc_bw_result,
12783 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12784 TOKEN_STRING_INITIALIZER
12785 (struct cmd_vf_tc_bw_result,
12787 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12788 TOKEN_STRING_INITIALIZER
12789 (struct cmd_vf_tc_bw_result,
12790 strict_link_prio, "strict-link-priority");
12791 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12792 TOKEN_STRING_INITIALIZER
12793 (struct cmd_vf_tc_bw_result,
12794 min_bw, "min-bandwidth");
12795 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12796 TOKEN_STRING_INITIALIZER
12797 (struct cmd_vf_tc_bw_result,
12798 max_bw, "max-bandwidth");
12799 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12800 TOKEN_NUM_INITIALIZER
12801 (struct cmd_vf_tc_bw_result,
12803 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12804 TOKEN_NUM_INITIALIZER
12805 (struct cmd_vf_tc_bw_result,
12807 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12808 TOKEN_NUM_INITIALIZER
12809 (struct cmd_vf_tc_bw_result,
12811 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12812 TOKEN_NUM_INITIALIZER
12813 (struct cmd_vf_tc_bw_result,
12815 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12816 TOKEN_STRING_INITIALIZER
12817 (struct cmd_vf_tc_bw_result,
12819 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12820 TOKEN_NUM_INITIALIZER
12821 (struct cmd_vf_tc_bw_result,
12824 /* VF max bandwidth setting */
12826 cmd_vf_max_bw_parsed(
12827 void *parsed_result,
12828 __attribute__((unused)) struct cmdline *cl,
12829 __attribute__((unused)) void *data)
12831 struct cmd_vf_tc_bw_result *res = parsed_result;
12832 int ret = -ENOTSUP;
12834 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12837 #ifdef RTE_LIBRTE_I40E_PMD
12838 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12839 res->vf_id, res->bw);
12846 printf("invalid vf_id %d or bandwidth %d\n",
12847 res->vf_id, res->bw);
12850 printf("invalid port_id %d\n", res->port_id);
12853 printf("function not implemented\n");
12856 printf("programming error: (%s)\n", strerror(-ret));
12860 cmdline_parse_inst_t cmd_vf_max_bw = {
12861 .f = cmd_vf_max_bw_parsed,
12863 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12865 (void *)&cmd_vf_tc_bw_set,
12866 (void *)&cmd_vf_tc_bw_vf,
12867 (void *)&cmd_vf_tc_bw_tx,
12868 (void *)&cmd_vf_tc_bw_max_bw,
12869 (void *)&cmd_vf_tc_bw_port_id,
12870 (void *)&cmd_vf_tc_bw_vf_id,
12871 (void *)&cmd_vf_tc_bw_bw,
12877 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12882 const char *p, *p0 = str;
12889 p = strchr(p0, '(');
12891 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12895 p0 = strchr(p, ')');
12897 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12901 if (size >= sizeof(s)) {
12902 printf("The string size exceeds the internal buffer size\n");
12905 snprintf(s, sizeof(s), "%.*s", size, p);
12906 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12908 printf("Failed to get the bandwidth list. ");
12912 for (i = 0; i < ret; i++)
12913 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12918 /* TC min bandwidth setting */
12920 cmd_vf_tc_min_bw_parsed(
12921 void *parsed_result,
12922 __attribute__((unused)) struct cmdline *cl,
12923 __attribute__((unused)) void *data)
12925 struct cmd_vf_tc_bw_result *res = parsed_result;
12928 int ret = -ENOTSUP;
12930 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12933 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12937 #ifdef RTE_LIBRTE_I40E_PMD
12938 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12946 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12949 printf("invalid port_id %d\n", res->port_id);
12952 printf("function not implemented\n");
12955 printf("programming error: (%s)\n", strerror(-ret));
12959 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12960 .f = cmd_vf_tc_min_bw_parsed,
12962 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12963 " <bw1, bw2, ...>",
12965 (void *)&cmd_vf_tc_bw_set,
12966 (void *)&cmd_vf_tc_bw_vf,
12967 (void *)&cmd_vf_tc_bw_tc,
12968 (void *)&cmd_vf_tc_bw_tx,
12969 (void *)&cmd_vf_tc_bw_min_bw,
12970 (void *)&cmd_vf_tc_bw_port_id,
12971 (void *)&cmd_vf_tc_bw_vf_id,
12972 (void *)&cmd_vf_tc_bw_bw_list,
12978 cmd_tc_min_bw_parsed(
12979 void *parsed_result,
12980 __attribute__((unused)) struct cmdline *cl,
12981 __attribute__((unused)) void *data)
12983 struct cmd_vf_tc_bw_result *res = parsed_result;
12984 struct rte_port *port;
12987 int ret = -ENOTSUP;
12989 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12992 port = &ports[res->port_id];
12993 /** Check if the port is not started **/
12994 if (port->port_status != RTE_PORT_STOPPED) {
12995 printf("Please stop port %d first\n", res->port_id);
12999 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13003 #ifdef RTE_LIBRTE_IXGBE_PMD
13004 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13011 printf("invalid bandwidth\n");
13014 printf("invalid port_id %d\n", res->port_id);
13017 printf("function not implemented\n");
13020 printf("programming error: (%s)\n", strerror(-ret));
13024 cmdline_parse_inst_t cmd_tc_min_bw = {
13025 .f = cmd_tc_min_bw_parsed,
13027 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13029 (void *)&cmd_vf_tc_bw_set,
13030 (void *)&cmd_vf_tc_bw_tc,
13031 (void *)&cmd_vf_tc_bw_tx,
13032 (void *)&cmd_vf_tc_bw_min_bw,
13033 (void *)&cmd_vf_tc_bw_port_id,
13034 (void *)&cmd_vf_tc_bw_bw_list,
13039 /* TC max bandwidth setting */
13041 cmd_vf_tc_max_bw_parsed(
13042 void *parsed_result,
13043 __attribute__((unused)) struct cmdline *cl,
13044 __attribute__((unused)) void *data)
13046 struct cmd_vf_tc_bw_result *res = parsed_result;
13047 int ret = -ENOTSUP;
13049 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13052 #ifdef RTE_LIBRTE_I40E_PMD
13053 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13054 res->tc_no, res->bw);
13061 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13062 res->vf_id, res->tc_no, res->bw);
13065 printf("invalid port_id %d\n", res->port_id);
13068 printf("function not implemented\n");
13071 printf("programming error: (%s)\n", strerror(-ret));
13075 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13076 .f = cmd_vf_tc_max_bw_parsed,
13078 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13081 (void *)&cmd_vf_tc_bw_set,
13082 (void *)&cmd_vf_tc_bw_vf,
13083 (void *)&cmd_vf_tc_bw_tc,
13084 (void *)&cmd_vf_tc_bw_tx,
13085 (void *)&cmd_vf_tc_bw_max_bw,
13086 (void *)&cmd_vf_tc_bw_port_id,
13087 (void *)&cmd_vf_tc_bw_vf_id,
13088 (void *)&cmd_vf_tc_bw_tc_no,
13089 (void *)&cmd_vf_tc_bw_bw,
13094 /* Strict link priority scheduling mode setting */
13096 cmd_strict_link_prio_parsed(
13097 void *parsed_result,
13098 __attribute__((unused)) struct cmdline *cl,
13099 __attribute__((unused)) void *data)
13101 struct cmd_vf_tc_bw_result *res = parsed_result;
13102 int ret = -ENOTSUP;
13104 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13107 #ifdef RTE_LIBRTE_I40E_PMD
13108 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13115 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13118 printf("invalid port_id %d\n", res->port_id);
13121 printf("function not implemented\n");
13124 printf("programming error: (%s)\n", strerror(-ret));
13128 cmdline_parse_inst_t cmd_strict_link_prio = {
13129 .f = cmd_strict_link_prio_parsed,
13131 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13133 (void *)&cmd_vf_tc_bw_set,
13134 (void *)&cmd_vf_tc_bw_tx,
13135 (void *)&cmd_vf_tc_bw_strict_link_prio,
13136 (void *)&cmd_vf_tc_bw_port_id,
13137 (void *)&cmd_vf_tc_bw_tc_map,
13142 /* Load dynamic device personalization*/
13143 struct cmd_ddp_add_result {
13144 cmdline_fixed_string_t ddp;
13145 cmdline_fixed_string_t add;
13150 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13151 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13152 cmdline_parse_token_string_t cmd_ddp_add_add =
13153 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13154 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13155 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
13156 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13157 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13160 cmd_ddp_add_parsed(
13161 void *parsed_result,
13162 __attribute__((unused)) struct cmdline *cl,
13163 __attribute__((unused)) void *data)
13165 struct cmd_ddp_add_result *res = parsed_result;
13171 int ret = -ENOTSUP;
13173 if (res->port_id > nb_ports) {
13174 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13178 if (!all_ports_stopped()) {
13179 printf("Please stop all ports first\n");
13183 filepath = strdup(res->filepath);
13184 if (filepath == NULL) {
13185 printf("Failed to allocate memory\n");
13188 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13190 buff = open_ddp_package_file(file_fld[0], &size);
13192 free((void *)filepath);
13196 #ifdef RTE_LIBRTE_I40E_PMD
13197 if (ret == -ENOTSUP)
13198 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13200 RTE_PMD_I40E_PKG_OP_WR_ADD);
13203 if (ret == -EEXIST)
13204 printf("Profile has already existed.\n");
13206 printf("Failed to load profile.\n");
13207 else if (file_num == 2)
13208 save_ddp_package_file(file_fld[1], buff, size);
13210 close_ddp_package_file(buff);
13211 free((void *)filepath);
13214 cmdline_parse_inst_t cmd_ddp_add = {
13215 .f = cmd_ddp_add_parsed,
13217 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
13219 (void *)&cmd_ddp_add_ddp,
13220 (void *)&cmd_ddp_add_add,
13221 (void *)&cmd_ddp_add_port_id,
13222 (void *)&cmd_ddp_add_filepath,
13227 /* Delete dynamic device personalization*/
13228 struct cmd_ddp_del_result {
13229 cmdline_fixed_string_t ddp;
13230 cmdline_fixed_string_t del;
13235 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13236 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13237 cmdline_parse_token_string_t cmd_ddp_del_del =
13238 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13239 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13240 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT8);
13241 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13242 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13245 cmd_ddp_del_parsed(
13246 void *parsed_result,
13247 __attribute__((unused)) struct cmdline *cl,
13248 __attribute__((unused)) void *data)
13250 struct cmd_ddp_del_result *res = parsed_result;
13253 int ret = -ENOTSUP;
13255 if (res->port_id > nb_ports) {
13256 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13260 if (!all_ports_stopped()) {
13261 printf("Please stop all ports first\n");
13265 buff = open_ddp_package_file(res->filepath, &size);
13269 #ifdef RTE_LIBRTE_I40E_PMD
13270 if (ret == -ENOTSUP)
13271 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13273 RTE_PMD_I40E_PKG_OP_WR_DEL);
13276 if (ret == -EACCES)
13277 printf("Profile does not exist.\n");
13279 printf("Failed to delete profile.\n");
13281 close_ddp_package_file(buff);
13284 cmdline_parse_inst_t cmd_ddp_del = {
13285 .f = cmd_ddp_del_parsed,
13287 .help_str = "ddp del <port_id> <profile_path>",
13289 (void *)&cmd_ddp_del_ddp,
13290 (void *)&cmd_ddp_del_del,
13291 (void *)&cmd_ddp_del_port_id,
13292 (void *)&cmd_ddp_del_filepath,
13297 /* Get dynamic device personalization profile info */
13298 struct cmd_ddp_info_result {
13299 cmdline_fixed_string_t ddp;
13300 cmdline_fixed_string_t get;
13301 cmdline_fixed_string_t info;
13305 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13306 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13307 cmdline_parse_token_string_t cmd_ddp_info_get =
13308 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13309 cmdline_parse_token_string_t cmd_ddp_info_info =
13310 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13311 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13312 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13315 cmd_ddp_info_parsed(
13316 void *parsed_result,
13317 __attribute__((unused)) struct cmdline *cl,
13318 __attribute__((unused)) void *data)
13320 struct cmd_ddp_info_result *res = parsed_result;
13323 int ret = -ENOTSUP;
13324 #ifdef RTE_LIBRTE_I40E_PMD
13327 uint32_t buff_size;
13328 struct rte_pmd_i40e_profile_info info;
13330 struct rte_pmd_i40e_ddp_device_id *devs;
13333 pkg = open_ddp_package_file(res->filepath, &pkg_size);
13337 #ifdef RTE_LIBRTE_I40E_PMD
13338 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13339 (uint8_t *)&info, sizeof(info),
13340 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13342 printf("Global Track id: 0x%x\n", info.track_id);
13343 printf("Global Version: %d.%d.%d.%d\n",
13344 info.version.major,
13345 info.version.minor,
13346 info.version.update,
13347 info.version.draft);
13348 printf("Global Package name: %s\n\n", info.name);
13351 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13352 (uint8_t *)&info, sizeof(info),
13353 RTE_PMD_I40E_PKG_INFO_HEADER);
13355 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13356 printf("i40e Profile Version: %d.%d.%d.%d\n",
13357 info.version.major,
13358 info.version.minor,
13359 info.version.update,
13360 info.version.draft);
13361 printf("i40e Profile name: %s\n\n", info.name);
13364 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13365 (uint8_t *)&buff_size, sizeof(buff_size),
13366 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13367 if (!ret && buff_size) {
13368 buff = (uint8_t *)malloc(buff_size);
13370 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13372 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13374 printf("Package Notes:\n%s\n\n", buff);
13379 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13380 (uint8_t *)&dev_num, sizeof(dev_num),
13381 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13382 if (!ret && dev_num) {
13383 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(dev_num *
13384 sizeof(struct rte_pmd_i40e_ddp_device_id));
13386 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13387 (uint8_t *)devs, dev_num *
13388 sizeof(struct rte_pmd_i40e_ddp_device_id),
13389 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13391 printf("List of supported devices:\n");
13392 for (i = 0; i < dev_num; i++) {
13393 printf(" %04X:%04X %04X:%04X\n",
13394 devs[i].vendor_dev_id >> 16,
13395 devs[i].vendor_dev_id & 0xFFFF,
13396 devs[i].sub_vendor_dev_id >> 16,
13397 devs[i].sub_vendor_dev_id & 0xFFFF);
13406 if (ret == -ENOTSUP)
13407 printf("Function not supported in PMD driver\n");
13408 close_ddp_package_file(pkg);
13411 cmdline_parse_inst_t cmd_ddp_get_info = {
13412 .f = cmd_ddp_info_parsed,
13414 .help_str = "ddp get info <profile_path>",
13416 (void *)&cmd_ddp_info_ddp,
13417 (void *)&cmd_ddp_info_get,
13418 (void *)&cmd_ddp_info_info,
13419 (void *)&cmd_ddp_info_filepath,
13424 /* Get dynamic device personalization profile info list*/
13425 #define PROFILE_INFO_SIZE 48
13426 #define MAX_PROFILE_NUM 16
13428 struct cmd_ddp_get_list_result {
13429 cmdline_fixed_string_t ddp;
13430 cmdline_fixed_string_t get;
13431 cmdline_fixed_string_t list;
13435 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
13436 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
13437 cmdline_parse_token_string_t cmd_ddp_get_list_get =
13438 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
13439 cmdline_parse_token_string_t cmd_ddp_get_list_list =
13440 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
13441 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
13442 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
13445 cmd_ddp_get_list_parsed(
13446 void *parsed_result,
13447 __attribute__((unused)) struct cmdline *cl,
13448 __attribute__((unused)) void *data)
13450 struct cmd_ddp_get_list_result *res = parsed_result;
13451 #ifdef RTE_LIBRTE_I40E_PMD
13452 struct rte_pmd_i40e_profile_list *p_list;
13453 struct rte_pmd_i40e_profile_info *p_info;
13458 int ret = -ENOTSUP;
13460 if (res->port_id > nb_ports) {
13461 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13465 #ifdef RTE_LIBRTE_I40E_PMD
13466 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
13467 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
13469 printf("%s: Failed to malloc buffer\n", __func__);
13471 if (ret == -ENOTSUP)
13472 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
13473 (uint8_t *)p_list, size);
13476 p_num = p_list->p_count;
13477 printf("Profile number is: %d\n\n", p_num);
13479 for (i = 0; i < p_num; i++) {
13480 p_info = &p_list->p_info[i];
13481 printf("Profile %d:\n", i);
13482 printf("Track id: 0x%x\n", p_info->track_id);
13483 printf("Version: %d.%d.%d.%d\n",
13484 p_info->version.major,
13485 p_info->version.minor,
13486 p_info->version.update,
13487 p_info->version.draft);
13488 printf("Profile name: %s\n\n", p_info->name);
13496 printf("Failed to get ddp list\n");
13499 cmdline_parse_inst_t cmd_ddp_get_list = {
13500 .f = cmd_ddp_get_list_parsed,
13502 .help_str = "ddp get list <port_id>",
13504 (void *)&cmd_ddp_get_list_ddp,
13505 (void *)&cmd_ddp_get_list_get,
13506 (void *)&cmd_ddp_get_list_list,
13507 (void *)&cmd_ddp_get_list_port_id,
13512 /* show vf stats */
13514 /* Common result structure for show vf stats */
13515 struct cmd_show_vf_stats_result {
13516 cmdline_fixed_string_t show;
13517 cmdline_fixed_string_t vf;
13518 cmdline_fixed_string_t stats;
13523 /* Common CLI fields show vf stats*/
13524 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13525 TOKEN_STRING_INITIALIZER
13526 (struct cmd_show_vf_stats_result,
13528 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13529 TOKEN_STRING_INITIALIZER
13530 (struct cmd_show_vf_stats_result,
13532 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13533 TOKEN_STRING_INITIALIZER
13534 (struct cmd_show_vf_stats_result,
13536 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13537 TOKEN_NUM_INITIALIZER
13538 (struct cmd_show_vf_stats_result,
13540 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13541 TOKEN_NUM_INITIALIZER
13542 (struct cmd_show_vf_stats_result,
13546 cmd_show_vf_stats_parsed(
13547 void *parsed_result,
13548 __attribute__((unused)) struct cmdline *cl,
13549 __attribute__((unused)) void *data)
13551 struct cmd_show_vf_stats_result *res = parsed_result;
13552 struct rte_eth_stats stats;
13553 int ret = -ENOTSUP;
13554 static const char *nic_stats_border = "########################";
13556 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13559 memset(&stats, 0, sizeof(stats));
13561 #ifdef RTE_LIBRTE_I40E_PMD
13562 if (ret == -ENOTSUP)
13563 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13567 #ifdef RTE_LIBRTE_BNXT_PMD
13568 if (ret == -ENOTSUP)
13569 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
13578 printf("invalid vf_id %d\n", res->vf_id);
13581 printf("invalid port_id %d\n", res->port_id);
13584 printf("function not implemented\n");
13587 printf("programming error: (%s)\n", strerror(-ret));
13590 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13591 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13593 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13595 stats.ipackets, stats.imissed, stats.ibytes);
13596 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13597 printf(" RX-nombuf: %-10"PRIu64"\n",
13599 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13601 stats.opackets, stats.oerrors, stats.obytes);
13603 printf(" %s############################%s\n",
13604 nic_stats_border, nic_stats_border);
13607 cmdline_parse_inst_t cmd_show_vf_stats = {
13608 .f = cmd_show_vf_stats_parsed,
13610 .help_str = "show vf stats <port_id> <vf_id>",
13612 (void *)&cmd_show_vf_stats_show,
13613 (void *)&cmd_show_vf_stats_vf,
13614 (void *)&cmd_show_vf_stats_stats,
13615 (void *)&cmd_show_vf_stats_port_id,
13616 (void *)&cmd_show_vf_stats_vf_id,
13621 /* clear vf stats */
13623 /* Common result structure for clear vf stats */
13624 struct cmd_clear_vf_stats_result {
13625 cmdline_fixed_string_t clear;
13626 cmdline_fixed_string_t vf;
13627 cmdline_fixed_string_t stats;
13632 /* Common CLI fields clear vf stats*/
13633 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13634 TOKEN_STRING_INITIALIZER
13635 (struct cmd_clear_vf_stats_result,
13637 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13638 TOKEN_STRING_INITIALIZER
13639 (struct cmd_clear_vf_stats_result,
13641 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13642 TOKEN_STRING_INITIALIZER
13643 (struct cmd_clear_vf_stats_result,
13645 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13646 TOKEN_NUM_INITIALIZER
13647 (struct cmd_clear_vf_stats_result,
13649 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13650 TOKEN_NUM_INITIALIZER
13651 (struct cmd_clear_vf_stats_result,
13655 cmd_clear_vf_stats_parsed(
13656 void *parsed_result,
13657 __attribute__((unused)) struct cmdline *cl,
13658 __attribute__((unused)) void *data)
13660 struct cmd_clear_vf_stats_result *res = parsed_result;
13661 int ret = -ENOTSUP;
13663 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13666 #ifdef RTE_LIBRTE_I40E_PMD
13667 if (ret == -ENOTSUP)
13668 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13671 #ifdef RTE_LIBRTE_BNXT_PMD
13672 if (ret == -ENOTSUP)
13673 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
13681 printf("invalid vf_id %d\n", res->vf_id);
13684 printf("invalid port_id %d\n", res->port_id);
13687 printf("function not implemented\n");
13690 printf("programming error: (%s)\n", strerror(-ret));
13694 cmdline_parse_inst_t cmd_clear_vf_stats = {
13695 .f = cmd_clear_vf_stats_parsed,
13697 .help_str = "clear vf stats <port_id> <vf_id>",
13699 (void *)&cmd_clear_vf_stats_clear,
13700 (void *)&cmd_clear_vf_stats_vf,
13701 (void *)&cmd_clear_vf_stats_stats,
13702 (void *)&cmd_clear_vf_stats_port_id,
13703 (void *)&cmd_clear_vf_stats_vf_id,
13708 /* ptype mapping get */
13710 /* Common result structure for ptype mapping get */
13711 struct cmd_ptype_mapping_get_result {
13712 cmdline_fixed_string_t ptype;
13713 cmdline_fixed_string_t mapping;
13714 cmdline_fixed_string_t get;
13716 uint8_t valid_only;
13719 /* Common CLI fields for ptype mapping get */
13720 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
13721 TOKEN_STRING_INITIALIZER
13722 (struct cmd_ptype_mapping_get_result,
13724 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
13725 TOKEN_STRING_INITIALIZER
13726 (struct cmd_ptype_mapping_get_result,
13727 mapping, "mapping");
13728 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
13729 TOKEN_STRING_INITIALIZER
13730 (struct cmd_ptype_mapping_get_result,
13732 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
13733 TOKEN_NUM_INITIALIZER
13734 (struct cmd_ptype_mapping_get_result,
13736 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
13737 TOKEN_NUM_INITIALIZER
13738 (struct cmd_ptype_mapping_get_result,
13739 valid_only, UINT8);
13742 cmd_ptype_mapping_get_parsed(
13743 void *parsed_result,
13744 __attribute__((unused)) struct cmdline *cl,
13745 __attribute__((unused)) void *data)
13747 struct cmd_ptype_mapping_get_result *res = parsed_result;
13748 int ret = -ENOTSUP;
13749 #ifdef RTE_LIBRTE_I40E_PMD
13750 int max_ptype_num = 256;
13751 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
13756 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13759 #ifdef RTE_LIBRTE_I40E_PMD
13760 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
13771 printf("invalid port_id %d\n", res->port_id);
13774 printf("function not implemented\n");
13777 printf("programming error: (%s)\n", strerror(-ret));
13780 #ifdef RTE_LIBRTE_I40E_PMD
13782 for (i = 0; i < count; i++)
13783 printf("%3d\t0x%08x\n",
13784 mapping[i].hw_ptype, mapping[i].sw_ptype);
13789 cmdline_parse_inst_t cmd_ptype_mapping_get = {
13790 .f = cmd_ptype_mapping_get_parsed,
13792 .help_str = "ptype mapping get <port_id> <valid_only>",
13794 (void *)&cmd_ptype_mapping_get_ptype,
13795 (void *)&cmd_ptype_mapping_get_mapping,
13796 (void *)&cmd_ptype_mapping_get_get,
13797 (void *)&cmd_ptype_mapping_get_port_id,
13798 (void *)&cmd_ptype_mapping_get_valid_only,
13803 /* ptype mapping replace */
13805 /* Common result structure for ptype mapping replace */
13806 struct cmd_ptype_mapping_replace_result {
13807 cmdline_fixed_string_t ptype;
13808 cmdline_fixed_string_t mapping;
13809 cmdline_fixed_string_t replace;
13816 /* Common CLI fields for ptype mapping replace */
13817 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
13818 TOKEN_STRING_INITIALIZER
13819 (struct cmd_ptype_mapping_replace_result,
13821 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
13822 TOKEN_STRING_INITIALIZER
13823 (struct cmd_ptype_mapping_replace_result,
13824 mapping, "mapping");
13825 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
13826 TOKEN_STRING_INITIALIZER
13827 (struct cmd_ptype_mapping_replace_result,
13828 replace, "replace");
13829 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
13830 TOKEN_NUM_INITIALIZER
13831 (struct cmd_ptype_mapping_replace_result,
13833 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
13834 TOKEN_NUM_INITIALIZER
13835 (struct cmd_ptype_mapping_replace_result,
13837 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
13838 TOKEN_NUM_INITIALIZER
13839 (struct cmd_ptype_mapping_replace_result,
13841 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
13842 TOKEN_NUM_INITIALIZER
13843 (struct cmd_ptype_mapping_replace_result,
13847 cmd_ptype_mapping_replace_parsed(
13848 void *parsed_result,
13849 __attribute__((unused)) struct cmdline *cl,
13850 __attribute__((unused)) void *data)
13852 struct cmd_ptype_mapping_replace_result *res = parsed_result;
13853 int ret = -ENOTSUP;
13855 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13858 #ifdef RTE_LIBRTE_I40E_PMD
13859 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
13869 printf("invalid ptype 0x%8x or 0x%8x\n",
13870 res->target, res->pkt_type);
13873 printf("invalid port_id %d\n", res->port_id);
13876 printf("function not implemented\n");
13879 printf("programming error: (%s)\n", strerror(-ret));
13883 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
13884 .f = cmd_ptype_mapping_replace_parsed,
13887 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
13889 (void *)&cmd_ptype_mapping_replace_ptype,
13890 (void *)&cmd_ptype_mapping_replace_mapping,
13891 (void *)&cmd_ptype_mapping_replace_replace,
13892 (void *)&cmd_ptype_mapping_replace_port_id,
13893 (void *)&cmd_ptype_mapping_replace_target,
13894 (void *)&cmd_ptype_mapping_replace_mask,
13895 (void *)&cmd_ptype_mapping_replace_pkt_type,
13900 /* ptype mapping reset */
13902 /* Common result structure for ptype mapping reset */
13903 struct cmd_ptype_mapping_reset_result {
13904 cmdline_fixed_string_t ptype;
13905 cmdline_fixed_string_t mapping;
13906 cmdline_fixed_string_t reset;
13910 /* Common CLI fields for ptype mapping reset*/
13911 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
13912 TOKEN_STRING_INITIALIZER
13913 (struct cmd_ptype_mapping_reset_result,
13915 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
13916 TOKEN_STRING_INITIALIZER
13917 (struct cmd_ptype_mapping_reset_result,
13918 mapping, "mapping");
13919 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
13920 TOKEN_STRING_INITIALIZER
13921 (struct cmd_ptype_mapping_reset_result,
13923 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
13924 TOKEN_NUM_INITIALIZER
13925 (struct cmd_ptype_mapping_reset_result,
13929 cmd_ptype_mapping_reset_parsed(
13930 void *parsed_result,
13931 __attribute__((unused)) struct cmdline *cl,
13932 __attribute__((unused)) void *data)
13934 struct cmd_ptype_mapping_reset_result *res = parsed_result;
13935 int ret = -ENOTSUP;
13937 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13940 #ifdef RTE_LIBRTE_I40E_PMD
13941 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
13948 printf("invalid port_id %d\n", res->port_id);
13951 printf("function not implemented\n");
13954 printf("programming error: (%s)\n", strerror(-ret));
13958 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
13959 .f = cmd_ptype_mapping_reset_parsed,
13961 .help_str = "ptype mapping reset <port_id>",
13963 (void *)&cmd_ptype_mapping_reset_ptype,
13964 (void *)&cmd_ptype_mapping_reset_mapping,
13965 (void *)&cmd_ptype_mapping_reset_reset,
13966 (void *)&cmd_ptype_mapping_reset_port_id,
13971 /* ptype mapping update */
13973 /* Common result structure for ptype mapping update */
13974 struct cmd_ptype_mapping_update_result {
13975 cmdline_fixed_string_t ptype;
13976 cmdline_fixed_string_t mapping;
13977 cmdline_fixed_string_t reset;
13983 /* Common CLI fields for ptype mapping update*/
13984 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
13985 TOKEN_STRING_INITIALIZER
13986 (struct cmd_ptype_mapping_update_result,
13988 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
13989 TOKEN_STRING_INITIALIZER
13990 (struct cmd_ptype_mapping_update_result,
13991 mapping, "mapping");
13992 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
13993 TOKEN_STRING_INITIALIZER
13994 (struct cmd_ptype_mapping_update_result,
13996 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
13997 TOKEN_NUM_INITIALIZER
13998 (struct cmd_ptype_mapping_update_result,
14000 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
14001 TOKEN_NUM_INITIALIZER
14002 (struct cmd_ptype_mapping_update_result,
14004 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
14005 TOKEN_NUM_INITIALIZER
14006 (struct cmd_ptype_mapping_update_result,
14010 cmd_ptype_mapping_update_parsed(
14011 void *parsed_result,
14012 __attribute__((unused)) struct cmdline *cl,
14013 __attribute__((unused)) void *data)
14015 struct cmd_ptype_mapping_update_result *res = parsed_result;
14016 int ret = -ENOTSUP;
14017 #ifdef RTE_LIBRTE_I40E_PMD
14018 struct rte_pmd_i40e_ptype_mapping mapping;
14020 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14023 #ifdef RTE_LIBRTE_I40E_PMD
14024 mapping.hw_ptype = res->hw_ptype;
14025 mapping.sw_ptype = res->sw_ptype;
14026 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
14036 printf("invalid ptype 0x%8x\n", res->sw_ptype);
14039 printf("invalid port_id %d\n", res->port_id);
14042 printf("function not implemented\n");
14045 printf("programming error: (%s)\n", strerror(-ret));
14049 cmdline_parse_inst_t cmd_ptype_mapping_update = {
14050 .f = cmd_ptype_mapping_update_parsed,
14052 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
14054 (void *)&cmd_ptype_mapping_update_ptype,
14055 (void *)&cmd_ptype_mapping_update_mapping,
14056 (void *)&cmd_ptype_mapping_update_update,
14057 (void *)&cmd_ptype_mapping_update_port_id,
14058 (void *)&cmd_ptype_mapping_update_hw_ptype,
14059 (void *)&cmd_ptype_mapping_update_sw_ptype,
14064 /* Common result structure for file commands */
14065 struct cmd_cmdfile_result {
14066 cmdline_fixed_string_t load;
14067 cmdline_fixed_string_t filename;
14070 /* Common CLI fields for file commands */
14071 cmdline_parse_token_string_t cmd_load_cmdfile =
14072 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
14073 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
14074 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
14077 cmd_load_from_file_parsed(
14078 void *parsed_result,
14079 __attribute__((unused)) struct cmdline *cl,
14080 __attribute__((unused)) void *data)
14082 struct cmd_cmdfile_result *res = parsed_result;
14084 cmdline_read_from_file(res->filename);
14087 cmdline_parse_inst_t cmd_load_from_file = {
14088 .f = cmd_load_from_file_parsed,
14090 .help_str = "load <filename>",
14092 (void *)&cmd_load_cmdfile,
14093 (void *)&cmd_load_cmdfile_filename,
14098 /* ******************************************************************************** */
14100 /* list of instructions */
14101 cmdline_parse_ctx_t main_ctx[] = {
14102 (cmdline_parse_inst_t *)&cmd_help_brief,
14103 (cmdline_parse_inst_t *)&cmd_help_long,
14104 (cmdline_parse_inst_t *)&cmd_quit,
14105 (cmdline_parse_inst_t *)&cmd_load_from_file,
14106 (cmdline_parse_inst_t *)&cmd_showport,
14107 (cmdline_parse_inst_t *)&cmd_showqueue,
14108 (cmdline_parse_inst_t *)&cmd_showportall,
14109 (cmdline_parse_inst_t *)&cmd_showcfg,
14110 (cmdline_parse_inst_t *)&cmd_start,
14111 (cmdline_parse_inst_t *)&cmd_start_tx_first,
14112 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
14113 (cmdline_parse_inst_t *)&cmd_set_link_up,
14114 (cmdline_parse_inst_t *)&cmd_set_link_down,
14115 (cmdline_parse_inst_t *)&cmd_reset,
14116 (cmdline_parse_inst_t *)&cmd_set_numbers,
14117 (cmdline_parse_inst_t *)&cmd_set_txpkts,
14118 (cmdline_parse_inst_t *)&cmd_set_txsplit,
14119 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
14120 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
14121 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
14122 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
14123 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
14124 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
14125 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
14126 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
14127 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
14128 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
14129 (cmdline_parse_inst_t *)&cmd_set_link_check,
14130 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
14131 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
14132 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
14133 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
14134 #ifdef RTE_LIBRTE_PMD_BOND
14135 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
14136 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
14137 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
14138 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
14139 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
14140 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
14141 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
14142 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
14143 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
14144 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
14146 (cmdline_parse_inst_t *)&cmd_vlan_offload,
14147 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
14148 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
14149 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
14150 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
14151 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
14152 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
14153 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
14154 (cmdline_parse_inst_t *)&cmd_csum_set,
14155 (cmdline_parse_inst_t *)&cmd_csum_show,
14156 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
14157 (cmdline_parse_inst_t *)&cmd_tso_set,
14158 (cmdline_parse_inst_t *)&cmd_tso_show,
14159 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
14160 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
14161 (cmdline_parse_inst_t *)&cmd_enable_gro,
14162 (cmdline_parse_inst_t *)&cmd_gro_set,
14163 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
14164 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
14165 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
14166 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
14167 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
14168 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
14169 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
14170 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
14171 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
14172 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
14173 (cmdline_parse_inst_t *)&cmd_config_dcb,
14174 (cmdline_parse_inst_t *)&cmd_read_reg,
14175 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
14176 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
14177 (cmdline_parse_inst_t *)&cmd_write_reg,
14178 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
14179 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
14180 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
14181 (cmdline_parse_inst_t *)&cmd_stop,
14182 (cmdline_parse_inst_t *)&cmd_mac_addr,
14183 (cmdline_parse_inst_t *)&cmd_set_qmap,
14184 (cmdline_parse_inst_t *)&cmd_operate_port,
14185 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
14186 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
14187 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
14188 (cmdline_parse_inst_t *)&cmd_config_speed_all,
14189 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
14190 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
14191 (cmdline_parse_inst_t *)&cmd_config_mtu,
14192 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
14193 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
14194 (cmdline_parse_inst_t *)&cmd_config_rss,
14195 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
14196 (cmdline_parse_inst_t *)&cmd_config_txqflags,
14197 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
14198 (cmdline_parse_inst_t *)&cmd_showport_reta,
14199 (cmdline_parse_inst_t *)&cmd_config_burst,
14200 (cmdline_parse_inst_t *)&cmd_config_thresh,
14201 (cmdline_parse_inst_t *)&cmd_config_threshold,
14202 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
14203 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
14204 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
14205 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
14206 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
14207 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
14208 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
14209 (cmdline_parse_inst_t *)&cmd_global_config,
14210 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
14211 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
14212 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
14213 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
14214 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
14215 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
14216 (cmdline_parse_inst_t *)&cmd_dump,
14217 (cmdline_parse_inst_t *)&cmd_dump_one,
14218 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
14219 (cmdline_parse_inst_t *)&cmd_syn_filter,
14220 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
14221 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
14222 (cmdline_parse_inst_t *)&cmd_flex_filter,
14223 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
14224 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
14225 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
14226 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
14227 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
14228 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
14229 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
14230 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
14231 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
14232 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
14233 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
14234 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
14235 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
14236 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
14237 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
14238 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
14239 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
14240 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
14241 (cmdline_parse_inst_t *)&cmd_flow,
14242 (cmdline_parse_inst_t *)&cmd_mcast_addr,
14243 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
14244 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
14245 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
14246 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
14247 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
14248 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
14249 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
14250 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
14251 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
14252 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
14253 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
14254 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
14255 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
14256 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
14257 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
14258 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
14259 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
14260 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
14261 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
14262 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
14263 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
14264 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
14265 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
14266 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
14267 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
14268 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
14269 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
14270 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
14271 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
14272 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
14273 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
14274 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
14275 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
14276 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
14277 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
14278 (cmdline_parse_inst_t *)&cmd_ddp_add,
14279 (cmdline_parse_inst_t *)&cmd_ddp_del,
14280 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
14281 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
14282 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
14283 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
14284 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
14285 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
14286 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
14287 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
14291 /* read cmdline commands from file */
14293 cmdline_read_from_file(const char *filename)
14295 struct cmdline *cl;
14297 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14299 printf("Failed to create file based cmdline context: %s\n",
14304 cmdline_interact(cl);
14309 printf("Read CLI commands from %s\n", filename);
14312 /* prompt function, called from main on MASTER lcore */
14316 /* initialize non-constant commands */
14317 cmd_set_fwd_mode_init();
14318 cmd_set_fwd_retry_mode_init();
14320 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14321 if (testpmd_cl == NULL)
14323 cmdline_interact(testpmd_cl);
14324 cmdline_stdin_exit(testpmd_cl);
14330 if (testpmd_cl != NULL)
14331 cmdline_quit(testpmd_cl);
14335 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14337 if (id == (portid_t)RTE_PORT_ALL) {
14340 RTE_ETH_FOREACH_DEV(pid) {
14341 /* check if need_reconfig has been set to 1 */
14342 if (ports[pid].need_reconfig == 0)
14343 ports[pid].need_reconfig = dev;
14344 /* check if need_reconfig_queues has been set to 1 */
14345 if (ports[pid].need_reconfig_queues == 0)
14346 ports[pid].need_reconfig_queues = queue;
14348 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14349 /* check if need_reconfig has been set to 1 */
14350 if (ports[id].need_reconfig == 0)
14351 ports[id].need_reconfig = dev;
14352 /* check if need_reconfig_queues has been set to 1 */
14353 if (ports[id].need_reconfig_queues == 0)
14354 ports[id].need_reconfig_queues = queue;