4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 #include <net/socket.h>
47 #include <sys/socket.h>
50 #include <netinet/in.h>
52 #include <sys/queue.h>
54 #include <rte_common.h>
55 #include <rte_byteorder.h>
57 #include <rte_debug.h>
58 #include <rte_cycles.h>
59 #include <rte_memory.h>
60 #include <rte_memzone.h>
61 #include <rte_malloc.h>
62 #include <rte_launch.h>
64 #include <rte_per_lcore.h>
65 #include <rte_lcore.h>
66 #include <rte_atomic.h>
67 #include <rte_branch_prediction.h>
69 #include <rte_mempool.h>
70 #include <rte_interrupts.h>
72 #include <rte_ether.h>
73 #include <rte_ethdev.h>
74 #include <rte_string_fns.h>
75 #include <rte_devargs.h>
76 #include <rte_eth_ctrl.h>
80 #include <cmdline_rdline.h>
81 #include <cmdline_parse.h>
82 #include <cmdline_parse_num.h>
83 #include <cmdline_parse_string.h>
84 #include <cmdline_parse_ipaddr.h>
85 #include <cmdline_parse_etheraddr.h>
86 #include <cmdline_socket.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
90 #include <rte_eth_bond_8023ad.h>
92 #ifdef RTE_LIBRTE_IXGBE_PMD
93 #include <rte_pmd_ixgbe.h>
95 #ifdef RTE_LIBRTE_I40E_PMD
96 #include <rte_pmd_i40e.h>
98 #ifdef RTE_LIBRTE_BNXT_PMD
99 #include <rte_pmd_bnxt.h>
103 static struct cmdline *testpmd_cl;
105 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
107 /* *** Help command with introduction. *** */
108 struct cmd_help_brief_result {
109 cmdline_fixed_string_t help;
112 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
114 __attribute__((unused)) void *data)
119 "Help is available for the following sections:\n\n"
120 " help control : Start and stop forwarding.\n"
121 " help display : Displaying port, stats and config "
123 " help config : Configuration information.\n"
124 " help ports : Configuring ports.\n"
125 " help registers : Reading and setting port registers.\n"
126 " help filters : Filters configuration help.\n"
127 " help all : All of the above sections.\n\n"
132 cmdline_parse_token_string_t cmd_help_brief_help =
133 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
135 cmdline_parse_inst_t cmd_help_brief = {
136 .f = cmd_help_brief_parsed,
138 .help_str = "help: Show help",
140 (void *)&cmd_help_brief_help,
145 /* *** Help command with help sections. *** */
146 struct cmd_help_long_result {
147 cmdline_fixed_string_t help;
148 cmdline_fixed_string_t section;
151 static void cmd_help_long_parsed(void *parsed_result,
153 __attribute__((unused)) void *data)
156 struct cmd_help_long_result *res = parsed_result;
158 if (!strcmp(res->section, "all"))
161 if (show_all || !strcmp(res->section, "control")) {
166 "Control forwarding:\n"
167 "-------------------\n\n"
170 " Start packet forwarding with current configuration.\n\n"
173 " Start packet forwarding with current config"
174 " after sending one burst of packets.\n\n"
177 " Stop packet forwarding, and display accumulated"
181 " Quit to prompt.\n\n"
185 if (show_all || !strcmp(res->section, "display")) {
193 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
194 " Display information for port_id, or all.\n\n"
196 "show port X rss reta (size) (mask0,mask1,...)\n"
197 " Display the rss redirection table entry indicated"
198 " by masks on port X. size is used to indicate the"
199 " hardware supported reta size\n\n"
201 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
202 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
203 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
204 " Display the RSS hash functions and RSS hash key"
207 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
208 " Clear information for port_id, or all.\n\n"
210 "show (rxq|txq) info (port_id) (queue_id)\n"
211 " Display information for configured RX/TX queue.\n\n"
213 "show config (rxtx|cores|fwd|txpkts)\n"
214 " Display the given configuration.\n\n"
216 "read rxd (port_id) (queue_id) (rxd_id)\n"
217 " Display an RX descriptor of a port RX queue.\n\n"
219 "read txd (port_id) (queue_id) (txd_id)\n"
220 " Display a TX descriptor of a port TX queue.\n\n"
222 "ddp get list (port_id)\n"
223 " Get ddp profile info list\n\n"
225 "ddp get info (profile_path)\n"
226 " Get ddp profile information.\n\n"
228 "show vf stats (port_id) (vf_id)\n"
229 " Display a VF's statistics.\n\n"
231 "clear vf stats (port_id) (vf_id)\n"
232 " Reset a VF's statistics.\n\n"
234 "show port (port_id) pctype mapping\n"
235 " Get flow ptype to pctype mapping on a port\n\n"
240 if (show_all || !strcmp(res->section, "config")) {
246 "Configuration changes only become active when"
247 " forwarding is started/restarted.\n\n"
250 " Reset forwarding to the default configuration.\n\n"
252 "set verbose (level)\n"
253 " Set the debug verbosity level X.\n\n"
256 " Set number of ports.\n\n"
259 " Set number of cores.\n\n"
261 "set coremask (mask)\n"
262 " Set the forwarding cores hexadecimal mask.\n\n"
264 "set portmask (mask)\n"
265 " Set the forwarding ports hexadecimal mask.\n\n"
268 " Set number of packets per burst.\n\n"
270 "set burst tx delay (microseconds) retry (num)\n"
271 " Set the transmit delay time and number of retries,"
272 " effective when retry is enabled.\n\n"
274 "set txpkts (x[,y]*)\n"
275 " Set the length of each segment of TXONLY"
276 " and optionally CSUM packets.\n\n"
278 "set txsplit (off|on|rand)\n"
279 " Set the split policy for the TX packets."
280 " Right now only applicable for CSUM and TXONLY"
283 "set corelist (x[,y]*)\n"
284 " Set the list of forwarding cores.\n\n"
286 "set portlist (x[,y]*)\n"
287 " Set the list of forwarding ports.\n\n"
289 "set tx loopback (port_id) (on|off)\n"
290 " Enable or disable tx loopback.\n\n"
292 "set all queues drop (port_id) (on|off)\n"
293 " Set drop enable bit for all queues.\n\n"
295 "set vf split drop (port_id) (vf_id) (on|off)\n"
296 " Set split drop enable bit for a VF from the PF.\n\n"
298 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
299 " Set MAC antispoof for a VF from the PF.\n\n"
301 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
302 " Enable MACsec offload.\n\n"
304 "set macsec offload (port_id) off\n"
305 " Disable MACsec offload.\n\n"
307 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
308 " Configure MACsec secure connection (SC).\n\n"
310 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
311 " Configure MACsec secure association (SA).\n\n"
313 "set vf broadcast (port_id) (vf_id) (on|off)\n"
314 " Set VF broadcast for a VF from the PF.\n\n"
316 "vlan set strip (on|off) (port_id)\n"
317 " Set the VLAN strip on a port.\n\n"
319 "vlan set stripq (on|off) (port_id,queue_id)\n"
320 " Set the VLAN strip for a queue on a port.\n\n"
322 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
323 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
325 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
326 " Set VLAN insert for a VF from the PF.\n\n"
328 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
329 " Set VLAN antispoof for a VF from the PF.\n\n"
331 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
332 " Set VLAN tag for a VF from the PF.\n\n"
334 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
335 " Set a VF's max bandwidth(Mbps).\n\n"
337 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
338 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
340 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
341 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
343 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
344 " Set some TCs' strict link priority mode on a physical port.\n\n"
346 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
347 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
349 "vlan set filter (on|off) (port_id)\n"
350 " Set the VLAN filter on a port.\n\n"
352 "vlan set qinq (on|off) (port_id)\n"
353 " Set the VLAN QinQ (extended queue in queue)"
356 "vlan set (inner|outer) tpid (value) (port_id)\n"
357 " Set the VLAN TPID for Packet Filtering on"
360 "rx_vlan add (vlan_id|all) (port_id)\n"
361 " Add a vlan_id, or all identifiers, to the set"
362 " of VLAN identifiers filtered by port_id.\n\n"
364 "rx_vlan rm (vlan_id|all) (port_id)\n"
365 " Remove a vlan_id, or all identifiers, from the set"
366 " of VLAN identifiers filtered by port_id.\n\n"
368 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
369 " Add a vlan_id, to the set of VLAN identifiers"
370 "filtered for VF(s) from port_id.\n\n"
372 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
373 " Remove a vlan_id, to the set of VLAN identifiers"
374 "filtered for VF(s) from port_id.\n\n"
376 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
377 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
378 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
379 " add a tunnel filter of a port.\n\n"
381 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
382 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
383 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
384 " remove a tunnel filter of a port.\n\n"
386 "rx_vxlan_port add (udp_port) (port_id)\n"
387 " Add an UDP port for VXLAN packet filter on a port\n\n"
389 "rx_vxlan_port rm (udp_port) (port_id)\n"
390 " Remove an UDP port for VXLAN packet filter on a port\n\n"
392 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
393 " Set hardware insertion of VLAN IDs (single or double VLAN "
394 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
396 "tx_vlan set pvid port_id vlan_id (on|off)\n"
397 " Set port based TX VLAN insertion.\n\n"
399 "tx_vlan reset (port_id)\n"
400 " Disable hardware insertion of a VLAN header in"
401 " packets sent on a port.\n\n"
403 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
404 " Select hardware or software calculation of the"
405 " checksum when transmitting a packet using the"
406 " csum forward engine.\n"
407 " ip|udp|tcp|sctp always concern the inner layer.\n"
408 " outer-ip concerns the outer IP layer in"
409 " case the packet is recognized as a tunnel packet by"
410 " the forward engine (vxlan, gre and ipip are supported)\n"
411 " Please check the NIC datasheet for HW limits.\n\n"
413 "csum parse-tunnel (on|off) (tx_port_id)\n"
414 " If disabled, treat tunnel packets as non-tunneled"
415 " packets (treat inner headers as payload). The port\n"
416 " argument is the port used for TX in csum forward"
419 "csum show (port_id)\n"
420 " Display tx checksum offload configuration\n\n"
422 "tso set (segsize) (portid)\n"
423 " Enable TCP Segmentation Offload in csum forward"
425 " Please check the NIC datasheet for HW limits.\n\n"
428 " Display the status of TCP Segmentation Offload.\n\n"
430 "gro (on|off) (port_id)"
431 " Enable or disable Generic Receive Offload in"
432 " csum forwarding engine.\n\n"
434 "gro set (max_flow_num) (max_item_num_per_flow) (port_id)\n"
435 " Set max flow number and max packet number per-flow"
439 " Set packet forwarding mode.\n\n"
441 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
442 " Add a MAC address on port_id.\n\n"
444 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
445 " Remove a MAC address from port_id.\n\n"
447 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
448 " Set the default MAC address for port_id.\n\n"
450 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
451 " Add a MAC address for a VF on the port.\n\n"
453 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
454 " Set the MAC address for a VF from the PF.\n\n"
456 "set port (port_id) uta (mac_address|all) (on|off)\n"
457 " Add/Remove a or all unicast hash filter(s)"
460 "set promisc (port_id|all) (on|off)\n"
461 " Set the promiscuous mode on port_id, or all.\n\n"
463 "set allmulti (port_id|all) (on|off)\n"
464 " Set the allmulti mode on port_id, or all.\n\n"
466 "set vf promisc (port_id) (vf_id) (on|off)\n"
467 " Set unicast promiscuous mode for a VF from the PF.\n\n"
469 "set vf allmulti (port_id) (vf_id) (on|off)\n"
470 " Set multicast promiscuous mode for a VF from the PF.\n\n"
472 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
473 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
474 " (on|off) autoneg (on|off) (port_id)\n"
475 "set flow_ctrl rx (on|off) (portid)\n"
476 "set flow_ctrl tx (on|off) (portid)\n"
477 "set flow_ctrl high_water (high_water) (portid)\n"
478 "set flow_ctrl low_water (low_water) (portid)\n"
479 "set flow_ctrl pause_time (pause_time) (portid)\n"
480 "set flow_ctrl send_xon (send_xon) (portid)\n"
481 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
482 "set flow_ctrl autoneg (on|off) (port_id)\n"
483 " Set the link flow control parameter on a port.\n\n"
485 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
486 " (low_water) (pause_time) (priority) (port_id)\n"
487 " Set the priority flow control parameter on a"
490 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
491 " Set statistics mapping (qmapping 0..15) for RX/TX"
493 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
494 " on port 0 to mapping 5.\n\n"
496 "set port (port_id) vf (vf_id) rx|tx on|off\n"
497 " Enable/Disable a VF receive/tranmit from a port\n\n"
499 "set port (port_id) vf (vf_id) (mac_addr)"
500 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
501 " Add/Remove unicast or multicast MAC addr filter"
504 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
506 " AUPE:accepts untagged VLAN;"
507 "ROPE:accept unicast hash\n\n"
508 " BAM:accepts broadcast packets;"
509 "MPE:accepts all multicast packets\n\n"
510 " Enable/Disable a VF receive mode of a port\n\n"
512 "set port (port_id) queue (queue_id) rate (rate_num)\n"
513 " Set rate limit for a queue of a port\n\n"
515 "set port (port_id) vf (vf_id) rate (rate_num) "
516 "queue_mask (queue_mask_value)\n"
517 " Set rate limit for queues in VF of a port\n\n"
519 "set port (port_id) mirror-rule (rule_id)"
520 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
521 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
522 " Set pool or vlan type mirror rule on a port.\n"
523 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
524 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
527 "set port (port_id) mirror-rule (rule_id)"
528 " (uplink-mirror|downlink-mirror) dst-pool"
529 " (pool_id) (on|off)\n"
530 " Set uplink or downlink type mirror rule on a port.\n"
531 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
532 " 0 on' enable mirror income traffic to pool 0.\n\n"
534 "reset port (port_id) mirror-rule (rule_id)\n"
535 " Reset a mirror rule.\n\n"
537 "set flush_rx (on|off)\n"
538 " Flush (default) or don't flush RX streams before"
539 " forwarding. Mainly used with PCAP drivers.\n\n"
541 "set bypass mode (normal|bypass|isolate) (port_id)\n"
542 " Set the bypass mode for the lowest port on bypass enabled"
545 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
546 "mode (normal|bypass|isolate) (port_id)\n"
547 " Set the event required to initiate specified bypass mode for"
548 " the lowest port on a bypass enabled NIC where:\n"
549 " timeout = enable bypass after watchdog timeout.\n"
550 " os_on = enable bypass when OS/board is powered on.\n"
551 " os_off = enable bypass when OS/board is powered off.\n"
552 " power_on = enable bypass when power supply is turned on.\n"
553 " power_off = enable bypass when power supply is turned off."
556 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
557 " Set the bypass watchdog timeout to 'n' seconds"
558 " where 0 = instant.\n\n"
560 "show bypass config (port_id)\n"
561 " Show the bypass configuration for a bypass enabled NIC"
562 " using the lowest port on the NIC.\n\n"
564 #ifdef RTE_LIBRTE_PMD_BOND
565 "create bonded device (mode) (socket)\n"
566 " Create a new bonded device with specific bonding mode and socket.\n\n"
568 "add bonding slave (slave_id) (port_id)\n"
569 " Add a slave device to a bonded device.\n\n"
571 "remove bonding slave (slave_id) (port_id)\n"
572 " Remove a slave device from a bonded device.\n\n"
574 "set bonding mode (value) (port_id)\n"
575 " Set the bonding mode on a bonded device.\n\n"
577 "set bonding primary (slave_id) (port_id)\n"
578 " Set the primary slave for a bonded device.\n\n"
580 "show bonding config (port_id)\n"
581 " Show the bonding config for port_id.\n\n"
583 "set bonding mac_addr (port_id) (address)\n"
584 " Set the MAC address of a bonded device.\n\n"
586 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
587 " Set Aggregation mode for IEEE802.3AD (mode 4)"
589 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
590 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
592 "set bonding mon_period (port_id) (value)\n"
593 " Set the bonding link status monitoring polling period in ms.\n\n"
595 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
596 " Enable/disable dedicated queues for LACP control traffic.\n\n"
599 "set link-up port (port_id)\n"
600 " Set link up for a port.\n\n"
602 "set link-down port (port_id)\n"
603 " Set link down for a port.\n\n"
605 "E-tag set insertion on port-tag-id (value)"
606 " port (port_id) vf (vf_id)\n"
607 " Enable E-tag insertion for a VF on a port\n\n"
609 "E-tag set insertion off port (port_id) vf (vf_id)\n"
610 " Disable E-tag insertion for a VF on a port\n\n"
612 "E-tag set stripping (on|off) port (port_id)\n"
613 " Enable/disable E-tag stripping on a port\n\n"
615 "E-tag set forwarding (on|off) port (port_id)\n"
616 " Enable/disable E-tag based forwarding"
619 "E-tag set filter add e-tag-id (value) dst-pool"
620 " (pool_id) port (port_id)\n"
621 " Add an E-tag forwarding filter on a port\n\n"
623 "E-tag set filter del e-tag-id (value) port (port_id)\n"
624 " Delete an E-tag forwarding filter on a port\n\n"
626 "ddp add (port_id) (profile_path[,output_path])\n"
627 " Load a profile package on a port\n\n"
629 "ddp del (port_id) (profile_path)\n"
630 " Delete a profile package from a port\n\n"
632 "ptype mapping get (port_id) (valid_only)\n"
633 " Get ptype mapping on a port\n\n"
635 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
636 " Replace target with the pkt_type in ptype mapping\n\n"
638 "ptype mapping reset (port_id)\n"
639 " Reset ptype mapping on a port\n\n"
641 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
642 " Update a ptype mapping item on a port\n\n"
644 , list_pkt_forwarding_modes()
648 if (show_all || !strcmp(res->section, "ports")) {
654 "----------------\n\n"
656 "port start (port_id|all)\n"
657 " Start all ports or port_id.\n\n"
659 "port stop (port_id|all)\n"
660 " Stop all ports or port_id.\n\n"
662 "port close (port_id|all)\n"
663 " Close all ports or port_id.\n\n"
665 "port attach (ident)\n"
666 " Attach physical or virtual dev by pci address or virtual device name\n\n"
668 "port detach (port_id)\n"
669 " Detach physical or virtual dev by port_id\n\n"
671 "port config (port_id|all)"
672 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
673 " duplex (half|full|auto)\n"
674 " Set speed and duplex for all ports or port_id\n\n"
676 "port config all (rxq|txq|rxd|txd) (value)\n"
677 " Set number for rxq/txq/rxd/txd.\n\n"
679 "port config all max-pkt-len (value)\n"
680 " Set the max packet length.\n\n"
682 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
683 "hw-vlan-strip|hw-vlan-extend|drop-en)"
685 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
688 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
689 "geneve|nvgre|none|<flowtype_id>)\n"
690 " Set the RSS mode.\n\n"
692 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
693 " Set the RSS redirection table.\n\n"
695 "port config (port_id) dcb vt (on|off) (traffic_class)"
697 " Set the DCB mode.\n\n"
699 "port config all burst (value)\n"
700 " Set the number of packets per burst.\n\n"
702 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
704 " Set the ring prefetch/host/writeback threshold"
705 " for tx/rx queue.\n\n"
707 "port config all (txfreet|txrst|rxfreet) (value)\n"
708 " Set free threshold for rx/tx, or set"
709 " tx rs bit threshold.\n\n"
710 "port config mtu X value\n"
711 " Set the MTU of port X to a given value\n\n"
713 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
714 " Start/stop a rx/tx queue of port X. Only take effect"
715 " when port X is started\n\n"
717 "port config (port_id|all) l2-tunnel E-tag ether-type"
719 " Set the value of E-tag ether-type.\n\n"
721 "port config (port_id|all) l2-tunnel E-tag"
722 " (enable|disable)\n"
723 " Enable/disable the E-tag support.\n\n"
725 "port config (port_id) pctype mapping reset\n"
726 " Reset flow type to pctype mapping on a port\n\n"
728 "port config (port_id) pctype mapping update"
729 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
730 " Update a flow type to pctype mapping item on a port\n\n"
734 if (show_all || !strcmp(res->section, "registers")) {
742 "read reg (port_id) (address)\n"
743 " Display value of a port register.\n\n"
745 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
746 " Display a port register bit field.\n\n"
748 "read regbit (port_id) (address) (bit_x)\n"
749 " Display a single port register bit.\n\n"
751 "write reg (port_id) (address) (value)\n"
752 " Set value of a port register.\n\n"
754 "write regfield (port_id) (address) (bit_x) (bit_y)"
756 " Set bit field of a port register.\n\n"
758 "write regbit (port_id) (address) (bit_x) (value)\n"
759 " Set single bit value of a port register.\n\n"
762 if (show_all || !strcmp(res->section, "filters")) {
770 "ethertype_filter (port_id) (add|del)"
771 " (mac_addr|mac_ignr) (mac_address) ethertype"
772 " (ether_type) (drop|fwd) queue (queue_id)\n"
773 " Add/Del an ethertype filter.\n\n"
775 "2tuple_filter (port_id) (add|del)"
776 " dst_port (dst_port_value) protocol (protocol_value)"
777 " mask (mask_value) tcp_flags (tcp_flags_value)"
778 " priority (prio_value) queue (queue_id)\n"
779 " Add/Del a 2tuple filter.\n\n"
781 "5tuple_filter (port_id) (add|del)"
782 " dst_ip (dst_address) src_ip (src_address)"
783 " dst_port (dst_port_value) src_port (src_port_value)"
784 " protocol (protocol_value)"
785 " mask (mask_value) tcp_flags (tcp_flags_value)"
786 " priority (prio_value) queue (queue_id)\n"
787 " Add/Del a 5tuple filter.\n\n"
789 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
790 " Add/Del syn filter.\n\n"
792 "flex_filter (port_id) (add|del) len (len_value)"
793 " bytes (bytes_value) mask (mask_value)"
794 " priority (prio_value) queue (queue_id)\n"
795 " Add/Del a flex filter.\n\n"
797 "flow_director_filter (port_id) mode IP (add|del|update)"
798 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
799 " src (src_ip_address) dst (dst_ip_address)"
800 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
801 " vlan (vlan_value) flexbytes (flexbytes_value)"
802 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
803 " fd_id (fd_id_value)\n"
804 " Add/Del an IP type flow director filter.\n\n"
806 "flow_director_filter (port_id) mode IP (add|del|update)"
807 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
808 " src (src_ip_address) (src_port)"
809 " dst (dst_ip_address) (dst_port)"
810 " tos (tos_value) ttl (ttl_value)"
811 " vlan (vlan_value) flexbytes (flexbytes_value)"
812 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
813 " fd_id (fd_id_value)\n"
814 " Add/Del an UDP/TCP type flow director filter.\n\n"
816 "flow_director_filter (port_id) mode IP (add|del|update)"
817 " flow (ipv4-sctp|ipv6-sctp)"
818 " src (src_ip_address) (src_port)"
819 " dst (dst_ip_address) (dst_port)"
820 " tag (verification_tag) "
821 " tos (tos_value) ttl (ttl_value)"
823 " flexbytes (flexbytes_value) (drop|fwd)"
824 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
825 " Add/Del a SCTP type flow director filter.\n\n"
827 "flow_director_filter (port_id) mode IP (add|del|update)"
828 " flow l2_payload ether (ethertype)"
829 " flexbytes (flexbytes_value) (drop|fwd)"
830 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
831 " Add/Del a l2 payload type flow director filter.\n\n"
833 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
834 " mac (mac_address) vlan (vlan_value)"
835 " flexbytes (flexbytes_value) (drop|fwd)"
836 " queue (queue_id) fd_id (fd_id_value)\n"
837 " Add/Del a MAC-VLAN flow director filter.\n\n"
839 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
840 " mac (mac_address) vlan (vlan_value)"
841 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
842 " flexbytes (flexbytes_value) (drop|fwd)"
843 " queue (queue_id) fd_id (fd_id_value)\n"
844 " Add/Del a Tunnel flow director filter.\n\n"
846 "flush_flow_director (port_id)\n"
847 " Flush all flow director entries of a device.\n\n"
849 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
850 " src_mask (ipv4_src) (ipv6_src) (src_port)"
851 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
852 " Set flow director IP mask.\n\n"
854 "flow_director_mask (port_id) mode MAC-VLAN"
855 " vlan (vlan_value)\n"
856 " Set flow director MAC-VLAN mask.\n\n"
858 "flow_director_mask (port_id) mode Tunnel"
859 " vlan (vlan_value) mac (mac_value)"
860 " tunnel-type (tunnel_type_value)"
861 " tunnel-id (tunnel_id_value)\n"
862 " Set flow director Tunnel mask.\n\n"
864 "flow_director_flex_mask (port_id)"
865 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
866 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
868 " Configure mask of flex payload.\n\n"
870 "flow_director_flex_payload (port_id)"
871 " (raw|l2|l3|l4) (config)\n"
872 " Configure flex payload selection.\n\n"
874 "get_sym_hash_ena_per_port (port_id)\n"
875 " get symmetric hash enable configuration per port.\n\n"
877 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
878 " set symmetric hash enable configuration per port"
879 " to enable or disable.\n\n"
881 "get_hash_global_config (port_id)\n"
882 " Get the global configurations of hash filters.\n\n"
884 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
885 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
886 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
887 " (enable|disable)\n"
888 " Set the global configurations of hash filters.\n\n"
890 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
891 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
892 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
893 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
894 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
895 "ipv6-next-header|udp-src-port|udp-dst-port|"
896 "tcp-src-port|tcp-dst-port|sctp-src-port|"
897 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
898 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
899 "fld-8th|none) (select|add)\n"
900 " Set the input set for hash.\n\n"
902 "set_fdir_input_set (port_id) "
903 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
904 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
905 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
906 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
907 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
908 "udp-dst-port|tcp-src-port|tcp-dst-port|"
909 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
911 " Set the input set for FDir.\n\n"
913 "flow validate {port_id}"
914 " [group {group_id}] [priority {level}]"
915 " [ingress] [egress]"
916 " pattern {item} [/ {item} [...]] / end"
917 " actions {action} [/ {action} [...]] / end\n"
918 " Check whether a flow rule can be created.\n\n"
920 "flow create {port_id}"
921 " [group {group_id}] [priority {level}]"
922 " [ingress] [egress]"
923 " pattern {item} [/ {item} [...]] / end"
924 " actions {action} [/ {action} [...]] / end\n"
925 " Create a flow rule.\n\n"
927 "flow destroy {port_id} rule {rule_id} [...]\n"
928 " Destroy specific flow rules.\n\n"
930 "flow flush {port_id}\n"
931 " Destroy all flow rules.\n\n"
933 "flow query {port_id} {rule_id} {action}\n"
934 " Query an existing flow rule.\n\n"
936 "flow list {port_id} [group {group_id}] [...]\n"
937 " List existing flow rules sorted by priority,"
938 " filtered by group identifiers.\n\n"
940 "flow isolate {port_id} {boolean}\n"
941 " Restrict ingress traffic to the defined"
947 cmdline_parse_token_string_t cmd_help_long_help =
948 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
950 cmdline_parse_token_string_t cmd_help_long_section =
951 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
952 "all#control#display#config#"
953 "ports#registers#filters");
955 cmdline_parse_inst_t cmd_help_long = {
956 .f = cmd_help_long_parsed,
958 .help_str = "help all|control|display|config|ports|register|filters: "
961 (void *)&cmd_help_long_help,
962 (void *)&cmd_help_long_section,
968 /* *** start/stop/close all ports *** */
969 struct cmd_operate_port_result {
970 cmdline_fixed_string_t keyword;
971 cmdline_fixed_string_t name;
972 cmdline_fixed_string_t value;
975 static void cmd_operate_port_parsed(void *parsed_result,
976 __attribute__((unused)) struct cmdline *cl,
977 __attribute__((unused)) void *data)
979 struct cmd_operate_port_result *res = parsed_result;
981 if (!strcmp(res->name, "start"))
982 start_port(RTE_PORT_ALL);
983 else if (!strcmp(res->name, "stop"))
984 stop_port(RTE_PORT_ALL);
985 else if (!strcmp(res->name, "close"))
986 close_port(RTE_PORT_ALL);
987 else if (!strcmp(res->name, "reset"))
988 reset_port(RTE_PORT_ALL);
990 printf("Unknown parameter\n");
993 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
994 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
996 cmdline_parse_token_string_t cmd_operate_port_all_port =
997 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
998 "start#stop#close#reset");
999 cmdline_parse_token_string_t cmd_operate_port_all_all =
1000 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1002 cmdline_parse_inst_t cmd_operate_port = {
1003 .f = cmd_operate_port_parsed,
1005 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1007 (void *)&cmd_operate_port_all_cmd,
1008 (void *)&cmd_operate_port_all_port,
1009 (void *)&cmd_operate_port_all_all,
1014 /* *** start/stop/close specific port *** */
1015 struct cmd_operate_specific_port_result {
1016 cmdline_fixed_string_t keyword;
1017 cmdline_fixed_string_t name;
1021 static void cmd_operate_specific_port_parsed(void *parsed_result,
1022 __attribute__((unused)) struct cmdline *cl,
1023 __attribute__((unused)) void *data)
1025 struct cmd_operate_specific_port_result *res = parsed_result;
1027 if (!strcmp(res->name, "start"))
1028 start_port(res->value);
1029 else if (!strcmp(res->name, "stop"))
1030 stop_port(res->value);
1031 else if (!strcmp(res->name, "close"))
1032 close_port(res->value);
1033 else if (!strcmp(res->name, "reset"))
1034 reset_port(res->value);
1036 printf("Unknown parameter\n");
1039 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1040 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1042 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1043 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1044 name, "start#stop#close#reset");
1045 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1046 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1049 cmdline_parse_inst_t cmd_operate_specific_port = {
1050 .f = cmd_operate_specific_port_parsed,
1052 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1054 (void *)&cmd_operate_specific_port_cmd,
1055 (void *)&cmd_operate_specific_port_port,
1056 (void *)&cmd_operate_specific_port_id,
1061 /* *** attach a specified port *** */
1062 struct cmd_operate_attach_port_result {
1063 cmdline_fixed_string_t port;
1064 cmdline_fixed_string_t keyword;
1065 cmdline_fixed_string_t identifier;
1068 static void cmd_operate_attach_port_parsed(void *parsed_result,
1069 __attribute__((unused)) struct cmdline *cl,
1070 __attribute__((unused)) void *data)
1072 struct cmd_operate_attach_port_result *res = parsed_result;
1074 if (!strcmp(res->keyword, "attach"))
1075 attach_port(res->identifier);
1077 printf("Unknown parameter\n");
1080 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1081 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1083 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1084 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1086 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1087 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1090 cmdline_parse_inst_t cmd_operate_attach_port = {
1091 .f = cmd_operate_attach_port_parsed,
1093 .help_str = "port attach <identifier>: "
1094 "(identifier: pci address or virtual dev name)",
1096 (void *)&cmd_operate_attach_port_port,
1097 (void *)&cmd_operate_attach_port_keyword,
1098 (void *)&cmd_operate_attach_port_identifier,
1103 /* *** detach a specified port *** */
1104 struct cmd_operate_detach_port_result {
1105 cmdline_fixed_string_t port;
1106 cmdline_fixed_string_t keyword;
1110 static void cmd_operate_detach_port_parsed(void *parsed_result,
1111 __attribute__((unused)) struct cmdline *cl,
1112 __attribute__((unused)) void *data)
1114 struct cmd_operate_detach_port_result *res = parsed_result;
1116 if (!strcmp(res->keyword, "detach"))
1117 detach_port(res->port_id);
1119 printf("Unknown parameter\n");
1122 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1123 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1125 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1126 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1128 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1129 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1132 cmdline_parse_inst_t cmd_operate_detach_port = {
1133 .f = cmd_operate_detach_port_parsed,
1135 .help_str = "port detach <port_id>",
1137 (void *)&cmd_operate_detach_port_port,
1138 (void *)&cmd_operate_detach_port_keyword,
1139 (void *)&cmd_operate_detach_port_port_id,
1144 /* *** configure speed for all ports *** */
1145 struct cmd_config_speed_all {
1146 cmdline_fixed_string_t port;
1147 cmdline_fixed_string_t keyword;
1148 cmdline_fixed_string_t all;
1149 cmdline_fixed_string_t item1;
1150 cmdline_fixed_string_t item2;
1151 cmdline_fixed_string_t value1;
1152 cmdline_fixed_string_t value2;
1156 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1161 if (!strcmp(duplexstr, "half")) {
1162 duplex = ETH_LINK_HALF_DUPLEX;
1163 } else if (!strcmp(duplexstr, "full")) {
1164 duplex = ETH_LINK_FULL_DUPLEX;
1165 } else if (!strcmp(duplexstr, "auto")) {
1166 duplex = ETH_LINK_FULL_DUPLEX;
1168 printf("Unknown duplex parameter\n");
1172 if (!strcmp(speedstr, "10")) {
1173 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1174 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1175 } else if (!strcmp(speedstr, "100")) {
1176 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1177 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1179 if (duplex != ETH_LINK_FULL_DUPLEX) {
1180 printf("Invalid speed/duplex parameters\n");
1183 if (!strcmp(speedstr, "1000")) {
1184 *speed = ETH_LINK_SPEED_1G;
1185 } else if (!strcmp(speedstr, "10000")) {
1186 *speed = ETH_LINK_SPEED_10G;
1187 } else if (!strcmp(speedstr, "25000")) {
1188 *speed = ETH_LINK_SPEED_25G;
1189 } else if (!strcmp(speedstr, "40000")) {
1190 *speed = ETH_LINK_SPEED_40G;
1191 } else if (!strcmp(speedstr, "50000")) {
1192 *speed = ETH_LINK_SPEED_50G;
1193 } else if (!strcmp(speedstr, "100000")) {
1194 *speed = ETH_LINK_SPEED_100G;
1195 } else if (!strcmp(speedstr, "auto")) {
1196 *speed = ETH_LINK_SPEED_AUTONEG;
1198 printf("Unknown speed parameter\n");
1207 cmd_config_speed_all_parsed(void *parsed_result,
1208 __attribute__((unused)) struct cmdline *cl,
1209 __attribute__((unused)) void *data)
1211 struct cmd_config_speed_all *res = parsed_result;
1212 uint32_t link_speed;
1215 if (!all_ports_stopped()) {
1216 printf("Please stop all ports first\n");
1220 if (parse_and_check_speed_duplex(res->value1, res->value2,
1224 RTE_ETH_FOREACH_DEV(pid) {
1225 ports[pid].dev_conf.link_speeds = link_speed;
1228 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1231 cmdline_parse_token_string_t cmd_config_speed_all_port =
1232 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1233 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1234 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1236 cmdline_parse_token_string_t cmd_config_speed_all_all =
1237 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1238 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1239 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1240 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1241 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1242 "10#100#1000#10000#25000#40000#50000#100000#auto");
1243 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1244 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1245 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1246 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1249 cmdline_parse_inst_t cmd_config_speed_all = {
1250 .f = cmd_config_speed_all_parsed,
1252 .help_str = "port config all speed "
1253 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1256 (void *)&cmd_config_speed_all_port,
1257 (void *)&cmd_config_speed_all_keyword,
1258 (void *)&cmd_config_speed_all_all,
1259 (void *)&cmd_config_speed_all_item1,
1260 (void *)&cmd_config_speed_all_value1,
1261 (void *)&cmd_config_speed_all_item2,
1262 (void *)&cmd_config_speed_all_value2,
1267 /* *** configure speed for specific port *** */
1268 struct cmd_config_speed_specific {
1269 cmdline_fixed_string_t port;
1270 cmdline_fixed_string_t keyword;
1272 cmdline_fixed_string_t item1;
1273 cmdline_fixed_string_t item2;
1274 cmdline_fixed_string_t value1;
1275 cmdline_fixed_string_t value2;
1279 cmd_config_speed_specific_parsed(void *parsed_result,
1280 __attribute__((unused)) struct cmdline *cl,
1281 __attribute__((unused)) void *data)
1283 struct cmd_config_speed_specific *res = parsed_result;
1284 uint32_t link_speed;
1286 if (!all_ports_stopped()) {
1287 printf("Please stop all ports first\n");
1291 if (port_id_is_invalid(res->id, ENABLED_WARN))
1294 if (parse_and_check_speed_duplex(res->value1, res->value2,
1298 ports[res->id].dev_conf.link_speeds = link_speed;
1300 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1304 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1305 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1307 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1308 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1310 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1311 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1312 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1313 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1315 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1316 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1317 "10#100#1000#10000#25000#40000#50000#100000#auto");
1318 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1319 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1321 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1322 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1325 cmdline_parse_inst_t cmd_config_speed_specific = {
1326 .f = cmd_config_speed_specific_parsed,
1328 .help_str = "port config <port_id> speed "
1329 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1332 (void *)&cmd_config_speed_specific_port,
1333 (void *)&cmd_config_speed_specific_keyword,
1334 (void *)&cmd_config_speed_specific_id,
1335 (void *)&cmd_config_speed_specific_item1,
1336 (void *)&cmd_config_speed_specific_value1,
1337 (void *)&cmd_config_speed_specific_item2,
1338 (void *)&cmd_config_speed_specific_value2,
1343 /* *** configure txq/rxq, txd/rxd *** */
1344 struct cmd_config_rx_tx {
1345 cmdline_fixed_string_t port;
1346 cmdline_fixed_string_t keyword;
1347 cmdline_fixed_string_t all;
1348 cmdline_fixed_string_t name;
1353 cmd_config_rx_tx_parsed(void *parsed_result,
1354 __attribute__((unused)) struct cmdline *cl,
1355 __attribute__((unused)) void *data)
1357 struct cmd_config_rx_tx *res = parsed_result;
1359 if (!all_ports_stopped()) {
1360 printf("Please stop all ports first\n");
1363 if (!strcmp(res->name, "rxq")) {
1364 if (!res->value && !nb_txq) {
1365 printf("Warning: Either rx or tx queues should be non zero\n");
1368 nb_rxq = res->value;
1370 else if (!strcmp(res->name, "txq")) {
1371 if (!res->value && !nb_rxq) {
1372 printf("Warning: Either rx or tx queues should be non zero\n");
1375 nb_txq = res->value;
1377 else if (!strcmp(res->name, "rxd")) {
1378 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1379 printf("rxd %d invalid - must be > 0 && <= %d\n",
1380 res->value, RTE_TEST_RX_DESC_MAX);
1383 nb_rxd = res->value;
1384 } else if (!strcmp(res->name, "txd")) {
1385 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1386 printf("txd %d invalid - must be > 0 && <= %d\n",
1387 res->value, RTE_TEST_TX_DESC_MAX);
1390 nb_txd = res->value;
1392 printf("Unknown parameter\n");
1400 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1403 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1404 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1405 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1406 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1407 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1408 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1409 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1410 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1412 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1413 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1415 cmdline_parse_inst_t cmd_config_rx_tx = {
1416 .f = cmd_config_rx_tx_parsed,
1418 .help_str = "port config all rxq|txq|rxd|txd <value>",
1420 (void *)&cmd_config_rx_tx_port,
1421 (void *)&cmd_config_rx_tx_keyword,
1422 (void *)&cmd_config_rx_tx_all,
1423 (void *)&cmd_config_rx_tx_name,
1424 (void *)&cmd_config_rx_tx_value,
1429 /* *** config max packet length *** */
1430 struct cmd_config_max_pkt_len_result {
1431 cmdline_fixed_string_t port;
1432 cmdline_fixed_string_t keyword;
1433 cmdline_fixed_string_t all;
1434 cmdline_fixed_string_t name;
1439 cmd_config_max_pkt_len_parsed(void *parsed_result,
1440 __attribute__((unused)) struct cmdline *cl,
1441 __attribute__((unused)) void *data)
1443 struct cmd_config_max_pkt_len_result *res = parsed_result;
1445 if (!all_ports_stopped()) {
1446 printf("Please stop all ports first\n");
1450 if (!strcmp(res->name, "max-pkt-len")) {
1451 if (res->value < ETHER_MIN_LEN) {
1452 printf("max-pkt-len can not be less than %d\n",
1456 if (res->value == rx_mode.max_rx_pkt_len)
1459 rx_mode.max_rx_pkt_len = res->value;
1460 if (res->value > ETHER_MAX_LEN)
1461 rx_mode.jumbo_frame = 1;
1463 rx_mode.jumbo_frame = 0;
1465 printf("Unknown parameter\n");
1471 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1474 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1475 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1477 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1478 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1480 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1481 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1483 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1484 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1486 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1487 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1490 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1491 .f = cmd_config_max_pkt_len_parsed,
1493 .help_str = "port config all max-pkt-len <value>",
1495 (void *)&cmd_config_max_pkt_len_port,
1496 (void *)&cmd_config_max_pkt_len_keyword,
1497 (void *)&cmd_config_max_pkt_len_all,
1498 (void *)&cmd_config_max_pkt_len_name,
1499 (void *)&cmd_config_max_pkt_len_value,
1504 /* *** configure port MTU *** */
1505 struct cmd_config_mtu_result {
1506 cmdline_fixed_string_t port;
1507 cmdline_fixed_string_t keyword;
1508 cmdline_fixed_string_t mtu;
1514 cmd_config_mtu_parsed(void *parsed_result,
1515 __attribute__((unused)) struct cmdline *cl,
1516 __attribute__((unused)) void *data)
1518 struct cmd_config_mtu_result *res = parsed_result;
1520 if (res->value < ETHER_MIN_LEN) {
1521 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1524 port_mtu_set(res->port_id, res->value);
1527 cmdline_parse_token_string_t cmd_config_mtu_port =
1528 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1530 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1531 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1533 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1534 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1536 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1537 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1538 cmdline_parse_token_num_t cmd_config_mtu_value =
1539 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1541 cmdline_parse_inst_t cmd_config_mtu = {
1542 .f = cmd_config_mtu_parsed,
1544 .help_str = "port config mtu <port_id> <value>",
1546 (void *)&cmd_config_mtu_port,
1547 (void *)&cmd_config_mtu_keyword,
1548 (void *)&cmd_config_mtu_mtu,
1549 (void *)&cmd_config_mtu_port_id,
1550 (void *)&cmd_config_mtu_value,
1555 /* *** configure rx mode *** */
1556 struct cmd_config_rx_mode_flag {
1557 cmdline_fixed_string_t port;
1558 cmdline_fixed_string_t keyword;
1559 cmdline_fixed_string_t all;
1560 cmdline_fixed_string_t name;
1561 cmdline_fixed_string_t value;
1565 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1566 __attribute__((unused)) struct cmdline *cl,
1567 __attribute__((unused)) void *data)
1569 struct cmd_config_rx_mode_flag *res = parsed_result;
1571 if (!all_ports_stopped()) {
1572 printf("Please stop all ports first\n");
1576 if (!strcmp(res->name, "crc-strip")) {
1577 if (!strcmp(res->value, "on"))
1578 rx_mode.hw_strip_crc = 1;
1579 else if (!strcmp(res->value, "off"))
1580 rx_mode.hw_strip_crc = 0;
1582 printf("Unknown parameter\n");
1585 } else if (!strcmp(res->name, "scatter")) {
1586 if (!strcmp(res->value, "on"))
1587 rx_mode.enable_scatter = 1;
1588 else if (!strcmp(res->value, "off"))
1589 rx_mode.enable_scatter = 0;
1591 printf("Unknown parameter\n");
1594 } else if (!strcmp(res->name, "rx-cksum")) {
1595 if (!strcmp(res->value, "on"))
1596 rx_mode.hw_ip_checksum = 1;
1597 else if (!strcmp(res->value, "off"))
1598 rx_mode.hw_ip_checksum = 0;
1600 printf("Unknown parameter\n");
1603 } else if (!strcmp(res->name, "hw-vlan")) {
1604 if (!strcmp(res->value, "on")) {
1605 rx_mode.hw_vlan_filter = 1;
1606 rx_mode.hw_vlan_strip = 1;
1608 else if (!strcmp(res->value, "off")) {
1609 rx_mode.hw_vlan_filter = 0;
1610 rx_mode.hw_vlan_strip = 0;
1613 printf("Unknown parameter\n");
1616 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1617 if (!strcmp(res->value, "on"))
1618 rx_mode.hw_vlan_filter = 1;
1619 else if (!strcmp(res->value, "off"))
1620 rx_mode.hw_vlan_filter = 0;
1622 printf("Unknown parameter\n");
1625 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1626 if (!strcmp(res->value, "on"))
1627 rx_mode.hw_vlan_strip = 1;
1628 else if (!strcmp(res->value, "off"))
1629 rx_mode.hw_vlan_strip = 0;
1631 printf("Unknown parameter\n");
1634 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1635 if (!strcmp(res->value, "on"))
1636 rx_mode.hw_vlan_extend = 1;
1637 else if (!strcmp(res->value, "off"))
1638 rx_mode.hw_vlan_extend = 0;
1640 printf("Unknown parameter\n");
1643 } else if (!strcmp(res->name, "drop-en")) {
1644 if (!strcmp(res->value, "on"))
1646 else if (!strcmp(res->value, "off"))
1649 printf("Unknown parameter\n");
1653 printf("Unknown parameter\n");
1659 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1662 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1663 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1664 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1665 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1667 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1668 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1669 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1670 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1671 "crc-strip#scatter#rx-cksum#hw-vlan#"
1672 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1673 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1677 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1678 .f = cmd_config_rx_mode_flag_parsed,
1680 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1681 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1683 (void *)&cmd_config_rx_mode_flag_port,
1684 (void *)&cmd_config_rx_mode_flag_keyword,
1685 (void *)&cmd_config_rx_mode_flag_all,
1686 (void *)&cmd_config_rx_mode_flag_name,
1687 (void *)&cmd_config_rx_mode_flag_value,
1692 /* *** configure rss *** */
1693 struct cmd_config_rss {
1694 cmdline_fixed_string_t port;
1695 cmdline_fixed_string_t keyword;
1696 cmdline_fixed_string_t all;
1697 cmdline_fixed_string_t name;
1698 cmdline_fixed_string_t value;
1702 cmd_config_rss_parsed(void *parsed_result,
1703 __attribute__((unused)) struct cmdline *cl,
1704 __attribute__((unused)) void *data)
1706 struct cmd_config_rss *res = parsed_result;
1707 struct rte_eth_rss_conf rss_conf;
1711 if (!strcmp(res->value, "all"))
1712 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1713 ETH_RSS_UDP | ETH_RSS_SCTP |
1715 else if (!strcmp(res->value, "ip"))
1716 rss_conf.rss_hf = ETH_RSS_IP;
1717 else if (!strcmp(res->value, "udp"))
1718 rss_conf.rss_hf = ETH_RSS_UDP;
1719 else if (!strcmp(res->value, "tcp"))
1720 rss_conf.rss_hf = ETH_RSS_TCP;
1721 else if (!strcmp(res->value, "sctp"))
1722 rss_conf.rss_hf = ETH_RSS_SCTP;
1723 else if (!strcmp(res->value, "ether"))
1724 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1725 else if (!strcmp(res->value, "port"))
1726 rss_conf.rss_hf = ETH_RSS_PORT;
1727 else if (!strcmp(res->value, "vxlan"))
1728 rss_conf.rss_hf = ETH_RSS_VXLAN;
1729 else if (!strcmp(res->value, "geneve"))
1730 rss_conf.rss_hf = ETH_RSS_GENEVE;
1731 else if (!strcmp(res->value, "nvgre"))
1732 rss_conf.rss_hf = ETH_RSS_NVGRE;
1733 else if (!strcmp(res->value, "none"))
1734 rss_conf.rss_hf = 0;
1735 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1736 atoi(res->value) < 64)
1737 rss_conf.rss_hf = 1ULL << atoi(res->value);
1739 printf("Unknown parameter\n");
1742 rss_conf.rss_key = NULL;
1743 for (i = 0; i < rte_eth_dev_count(); i++) {
1744 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1746 printf("Configuration of RSS hash at ethernet port %d "
1747 "failed with error (%d): %s.\n",
1748 i, -diag, strerror(-diag));
1752 cmdline_parse_token_string_t cmd_config_rss_port =
1753 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1754 cmdline_parse_token_string_t cmd_config_rss_keyword =
1755 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1756 cmdline_parse_token_string_t cmd_config_rss_all =
1757 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1758 cmdline_parse_token_string_t cmd_config_rss_name =
1759 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1760 cmdline_parse_token_string_t cmd_config_rss_value =
1761 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1763 cmdline_parse_inst_t cmd_config_rss = {
1764 .f = cmd_config_rss_parsed,
1766 .help_str = "port config all rss "
1767 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1769 (void *)&cmd_config_rss_port,
1770 (void *)&cmd_config_rss_keyword,
1771 (void *)&cmd_config_rss_all,
1772 (void *)&cmd_config_rss_name,
1773 (void *)&cmd_config_rss_value,
1778 /* *** configure rss hash key *** */
1779 struct cmd_config_rss_hash_key {
1780 cmdline_fixed_string_t port;
1781 cmdline_fixed_string_t config;
1783 cmdline_fixed_string_t rss_hash_key;
1784 cmdline_fixed_string_t rss_type;
1785 cmdline_fixed_string_t key;
1789 hexa_digit_to_value(char hexa_digit)
1791 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1792 return (uint8_t) (hexa_digit - '0');
1793 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1794 return (uint8_t) ((hexa_digit - 'a') + 10);
1795 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1796 return (uint8_t) ((hexa_digit - 'A') + 10);
1797 /* Invalid hexa digit */
1802 parse_and_check_key_hexa_digit(char *key, int idx)
1806 hexa_v = hexa_digit_to_value(key[idx]);
1808 printf("invalid key: character %c at position %d is not a "
1809 "valid hexa digit\n", key[idx], idx);
1814 cmd_config_rss_hash_key_parsed(void *parsed_result,
1815 __attribute__((unused)) struct cmdline *cl,
1816 __attribute__((unused)) void *data)
1818 struct cmd_config_rss_hash_key *res = parsed_result;
1819 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1823 struct rte_eth_dev_info dev_info;
1824 uint8_t hash_key_size;
1827 memset(&dev_info, 0, sizeof(dev_info));
1828 rte_eth_dev_info_get(res->port_id, &dev_info);
1829 if (dev_info.hash_key_size > 0 &&
1830 dev_info.hash_key_size <= sizeof(hash_key))
1831 hash_key_size = dev_info.hash_key_size;
1833 printf("dev_info did not provide a valid hash key size\n");
1836 /* Check the length of the RSS hash key */
1837 key_len = strlen(res->key);
1838 if (key_len != (hash_key_size * 2)) {
1839 printf("key length: %d invalid - key must be a string of %d"
1840 " hexa-decimal numbers\n",
1841 (int) key_len, hash_key_size * 2);
1844 /* Translate RSS hash key into binary representation */
1845 for (i = 0; i < hash_key_size; i++) {
1846 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1849 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1852 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1854 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1858 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1859 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1860 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1861 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1863 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1864 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1865 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1866 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1867 rss_hash_key, "rss-hash-key");
1868 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1869 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1870 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1871 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1872 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1873 "ipv6-tcp-ex#ipv6-udp-ex");
1874 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1875 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1877 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1878 .f = cmd_config_rss_hash_key_parsed,
1880 .help_str = "port config <port_id> rss-hash-key "
1881 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1882 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1883 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1884 "<string of hex digits (variable length, NIC dependent)>",
1886 (void *)&cmd_config_rss_hash_key_port,
1887 (void *)&cmd_config_rss_hash_key_config,
1888 (void *)&cmd_config_rss_hash_key_port_id,
1889 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1890 (void *)&cmd_config_rss_hash_key_rss_type,
1891 (void *)&cmd_config_rss_hash_key_value,
1896 /* *** configure port rxq/txq start/stop *** */
1897 struct cmd_config_rxtx_queue {
1898 cmdline_fixed_string_t port;
1900 cmdline_fixed_string_t rxtxq;
1902 cmdline_fixed_string_t opname;
1906 cmd_config_rxtx_queue_parsed(void *parsed_result,
1907 __attribute__((unused)) struct cmdline *cl,
1908 __attribute__((unused)) void *data)
1910 struct cmd_config_rxtx_queue *res = parsed_result;
1915 if (test_done == 0) {
1916 printf("Please stop forwarding first\n");
1920 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1923 if (port_is_started(res->portid) != 1) {
1924 printf("Please start port %u first\n", res->portid);
1928 if (!strcmp(res->rxtxq, "rxq"))
1930 else if (!strcmp(res->rxtxq, "txq"))
1933 printf("Unknown parameter\n");
1937 if (isrx && rx_queue_id_is_invalid(res->qid))
1939 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1942 if (!strcmp(res->opname, "start"))
1944 else if (!strcmp(res->opname, "stop"))
1947 printf("Unknown parameter\n");
1951 if (isstart && isrx)
1952 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1953 else if (!isstart && isrx)
1954 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1955 else if (isstart && !isrx)
1956 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1958 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1960 if (ret == -ENOTSUP)
1961 printf("Function not supported in PMD driver\n");
1964 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1965 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1966 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1967 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1968 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1969 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1970 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1971 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1972 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1973 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1976 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1977 .f = cmd_config_rxtx_queue_parsed,
1979 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1981 (void *)&cmd_config_speed_all_port,
1982 (void *)&cmd_config_rxtx_queue_portid,
1983 (void *)&cmd_config_rxtx_queue_rxtxq,
1984 (void *)&cmd_config_rxtx_queue_qid,
1985 (void *)&cmd_config_rxtx_queue_opname,
1990 /* *** Configure RSS RETA *** */
1991 struct cmd_config_rss_reta {
1992 cmdline_fixed_string_t port;
1993 cmdline_fixed_string_t keyword;
1995 cmdline_fixed_string_t name;
1996 cmdline_fixed_string_t list_name;
1997 cmdline_fixed_string_t list_of_items;
2001 parse_reta_config(const char *str,
2002 struct rte_eth_rss_reta_entry64 *reta_conf,
2003 uint16_t nb_entries)
2007 uint16_t hash_index, idx, shift;
2010 const char *p, *p0 = str;
2017 unsigned long int_fld[_NUM_FLD];
2018 char *str_fld[_NUM_FLD];
2020 while ((p = strchr(p0,'(')) != NULL) {
2022 if((p0 = strchr(p,')')) == NULL)
2026 if(size >= sizeof(s))
2029 snprintf(s, sizeof(s), "%.*s", size, p);
2030 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2032 for (i = 0; i < _NUM_FLD; i++) {
2034 int_fld[i] = strtoul(str_fld[i], &end, 0);
2035 if (errno != 0 || end == str_fld[i] ||
2040 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2041 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2043 if (hash_index >= nb_entries) {
2044 printf("Invalid RETA hash index=%d\n", hash_index);
2048 idx = hash_index / RTE_RETA_GROUP_SIZE;
2049 shift = hash_index % RTE_RETA_GROUP_SIZE;
2050 reta_conf[idx].mask |= (1ULL << shift);
2051 reta_conf[idx].reta[shift] = nb_queue;
2058 cmd_set_rss_reta_parsed(void *parsed_result,
2059 __attribute__((unused)) struct cmdline *cl,
2060 __attribute__((unused)) void *data)
2063 struct rte_eth_dev_info dev_info;
2064 struct rte_eth_rss_reta_entry64 reta_conf[8];
2065 struct cmd_config_rss_reta *res = parsed_result;
2067 memset(&dev_info, 0, sizeof(dev_info));
2068 rte_eth_dev_info_get(res->port_id, &dev_info);
2069 if (dev_info.reta_size == 0) {
2070 printf("Redirection table size is 0 which is "
2071 "invalid for RSS\n");
2074 printf("The reta size of port %d is %u\n",
2075 res->port_id, dev_info.reta_size);
2076 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2077 printf("Currently do not support more than %u entries of "
2078 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2082 memset(reta_conf, 0, sizeof(reta_conf));
2083 if (!strcmp(res->list_name, "reta")) {
2084 if (parse_reta_config(res->list_of_items, reta_conf,
2085 dev_info.reta_size)) {
2086 printf("Invalid RSS Redirection Table "
2087 "config entered\n");
2090 ret = rte_eth_dev_rss_reta_update(res->port_id,
2091 reta_conf, dev_info.reta_size);
2093 printf("Bad redirection table parameter, "
2094 "return code = %d \n", ret);
2098 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2099 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2100 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2101 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2102 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2103 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2104 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2105 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2106 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2107 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2108 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2109 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2111 cmdline_parse_inst_t cmd_config_rss_reta = {
2112 .f = cmd_set_rss_reta_parsed,
2114 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2116 (void *)&cmd_config_rss_reta_port,
2117 (void *)&cmd_config_rss_reta_keyword,
2118 (void *)&cmd_config_rss_reta_port_id,
2119 (void *)&cmd_config_rss_reta_name,
2120 (void *)&cmd_config_rss_reta_list_name,
2121 (void *)&cmd_config_rss_reta_list_of_items,
2126 /* *** SHOW PORT RETA INFO *** */
2127 struct cmd_showport_reta {
2128 cmdline_fixed_string_t show;
2129 cmdline_fixed_string_t port;
2131 cmdline_fixed_string_t rss;
2132 cmdline_fixed_string_t reta;
2134 cmdline_fixed_string_t list_of_items;
2138 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2139 uint16_t nb_entries,
2143 const char *p, *p0 = str;
2148 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2149 RTE_RETA_GROUP_SIZE;
2152 p = strchr(p0, '(');
2156 p0 = strchr(p, ')');
2160 if (size >= sizeof(s)) {
2161 printf("The string size exceeds the internal buffer size\n");
2164 snprintf(s, sizeof(s), "%.*s", size, p);
2165 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2166 if (ret <= 0 || ret != num) {
2167 printf("The bits of masks do not match the number of "
2168 "reta entries: %u\n", num);
2171 for (i = 0; i < ret; i++)
2172 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2178 cmd_showport_reta_parsed(void *parsed_result,
2179 __attribute__((unused)) struct cmdline *cl,
2180 __attribute__((unused)) void *data)
2182 struct cmd_showport_reta *res = parsed_result;
2183 struct rte_eth_rss_reta_entry64 reta_conf[8];
2184 struct rte_eth_dev_info dev_info;
2186 memset(&dev_info, 0, sizeof(dev_info));
2187 rte_eth_dev_info_get(res->port_id, &dev_info);
2188 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2189 res->size > ETH_RSS_RETA_SIZE_512) {
2190 printf("Invalid redirection table size: %u\n", res->size);
2194 memset(reta_conf, 0, sizeof(reta_conf));
2195 if (showport_parse_reta_config(reta_conf, res->size,
2196 res->list_of_items) < 0) {
2197 printf("Invalid string: %s for reta masks\n",
2198 res->list_of_items);
2201 port_rss_reta_info(res->port_id, reta_conf, res->size);
2204 cmdline_parse_token_string_t cmd_showport_reta_show =
2205 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2206 cmdline_parse_token_string_t cmd_showport_reta_port =
2207 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2208 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2209 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2210 cmdline_parse_token_string_t cmd_showport_reta_rss =
2211 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2212 cmdline_parse_token_string_t cmd_showport_reta_reta =
2213 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2214 cmdline_parse_token_num_t cmd_showport_reta_size =
2215 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2216 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2217 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2218 list_of_items, NULL);
2220 cmdline_parse_inst_t cmd_showport_reta = {
2221 .f = cmd_showport_reta_parsed,
2223 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2225 (void *)&cmd_showport_reta_show,
2226 (void *)&cmd_showport_reta_port,
2227 (void *)&cmd_showport_reta_port_id,
2228 (void *)&cmd_showport_reta_rss,
2229 (void *)&cmd_showport_reta_reta,
2230 (void *)&cmd_showport_reta_size,
2231 (void *)&cmd_showport_reta_list_of_items,
2236 /* *** Show RSS hash configuration *** */
2237 struct cmd_showport_rss_hash {
2238 cmdline_fixed_string_t show;
2239 cmdline_fixed_string_t port;
2241 cmdline_fixed_string_t rss_hash;
2242 cmdline_fixed_string_t rss_type;
2243 cmdline_fixed_string_t key; /* optional argument */
2246 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2247 __attribute__((unused)) struct cmdline *cl,
2250 struct cmd_showport_rss_hash *res = parsed_result;
2252 port_rss_hash_conf_show(res->port_id, res->rss_type,
2253 show_rss_key != NULL);
2256 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2257 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2258 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2259 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2260 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2261 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2262 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2263 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2265 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2266 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2267 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2268 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2269 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2270 "ipv6-tcp-ex#ipv6-udp-ex");
2271 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2272 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2274 cmdline_parse_inst_t cmd_showport_rss_hash = {
2275 .f = cmd_showport_rss_hash_parsed,
2277 .help_str = "show port <port_id> rss-hash "
2278 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2279 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2280 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2282 (void *)&cmd_showport_rss_hash_show,
2283 (void *)&cmd_showport_rss_hash_port,
2284 (void *)&cmd_showport_rss_hash_port_id,
2285 (void *)&cmd_showport_rss_hash_rss_hash,
2286 (void *)&cmd_showport_rss_hash_rss_hash_info,
2291 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2292 .f = cmd_showport_rss_hash_parsed,
2294 .help_str = "show port <port_id> rss-hash "
2295 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2296 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2297 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2299 (void *)&cmd_showport_rss_hash_show,
2300 (void *)&cmd_showport_rss_hash_port,
2301 (void *)&cmd_showport_rss_hash_port_id,
2302 (void *)&cmd_showport_rss_hash_rss_hash,
2303 (void *)&cmd_showport_rss_hash_rss_hash_info,
2304 (void *)&cmd_showport_rss_hash_rss_key,
2309 /* *** Configure DCB *** */
2310 struct cmd_config_dcb {
2311 cmdline_fixed_string_t port;
2312 cmdline_fixed_string_t config;
2314 cmdline_fixed_string_t dcb;
2315 cmdline_fixed_string_t vt;
2316 cmdline_fixed_string_t vt_en;
2318 cmdline_fixed_string_t pfc;
2319 cmdline_fixed_string_t pfc_en;
2323 cmd_config_dcb_parsed(void *parsed_result,
2324 __attribute__((unused)) struct cmdline *cl,
2325 __attribute__((unused)) void *data)
2327 struct cmd_config_dcb *res = parsed_result;
2328 portid_t port_id = res->port_id;
2329 struct rte_port *port;
2333 port = &ports[port_id];
2334 /** Check if the port is not started **/
2335 if (port->port_status != RTE_PORT_STOPPED) {
2336 printf("Please stop port %d first\n", port_id);
2340 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2341 printf("The invalid number of traffic class,"
2342 " only 4 or 8 allowed.\n");
2346 if (nb_fwd_lcores < res->num_tcs) {
2347 printf("nb_cores shouldn't be less than number of TCs.\n");
2350 if (!strncmp(res->pfc_en, "on", 2))
2355 /* DCB in VT mode */
2356 if (!strncmp(res->vt_en, "on", 2))
2357 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2358 (enum rte_eth_nb_tcs)res->num_tcs,
2361 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2362 (enum rte_eth_nb_tcs)res->num_tcs,
2367 printf("Cannot initialize network ports.\n");
2371 cmd_reconfig_device_queue(port_id, 1, 1);
2374 cmdline_parse_token_string_t cmd_config_dcb_port =
2375 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2376 cmdline_parse_token_string_t cmd_config_dcb_config =
2377 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2378 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2379 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2380 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2381 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2382 cmdline_parse_token_string_t cmd_config_dcb_vt =
2383 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2384 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2385 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2386 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2387 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2388 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2389 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2390 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2391 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2393 cmdline_parse_inst_t cmd_config_dcb = {
2394 .f = cmd_config_dcb_parsed,
2396 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2398 (void *)&cmd_config_dcb_port,
2399 (void *)&cmd_config_dcb_config,
2400 (void *)&cmd_config_dcb_port_id,
2401 (void *)&cmd_config_dcb_dcb,
2402 (void *)&cmd_config_dcb_vt,
2403 (void *)&cmd_config_dcb_vt_en,
2404 (void *)&cmd_config_dcb_num_tcs,
2405 (void *)&cmd_config_dcb_pfc,
2406 (void *)&cmd_config_dcb_pfc_en,
2411 /* *** configure number of packets per burst *** */
2412 struct cmd_config_burst {
2413 cmdline_fixed_string_t port;
2414 cmdline_fixed_string_t keyword;
2415 cmdline_fixed_string_t all;
2416 cmdline_fixed_string_t name;
2421 cmd_config_burst_parsed(void *parsed_result,
2422 __attribute__((unused)) struct cmdline *cl,
2423 __attribute__((unused)) void *data)
2425 struct cmd_config_burst *res = parsed_result;
2427 if (!all_ports_stopped()) {
2428 printf("Please stop all ports first\n");
2432 if (!strcmp(res->name, "burst")) {
2433 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2434 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2437 nb_pkt_per_burst = res->value;
2439 printf("Unknown parameter\n");
2445 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2448 cmdline_parse_token_string_t cmd_config_burst_port =
2449 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2450 cmdline_parse_token_string_t cmd_config_burst_keyword =
2451 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2452 cmdline_parse_token_string_t cmd_config_burst_all =
2453 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2454 cmdline_parse_token_string_t cmd_config_burst_name =
2455 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2456 cmdline_parse_token_num_t cmd_config_burst_value =
2457 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2459 cmdline_parse_inst_t cmd_config_burst = {
2460 .f = cmd_config_burst_parsed,
2462 .help_str = "port config all burst <value>",
2464 (void *)&cmd_config_burst_port,
2465 (void *)&cmd_config_burst_keyword,
2466 (void *)&cmd_config_burst_all,
2467 (void *)&cmd_config_burst_name,
2468 (void *)&cmd_config_burst_value,
2473 /* *** configure rx/tx queues *** */
2474 struct cmd_config_thresh {
2475 cmdline_fixed_string_t port;
2476 cmdline_fixed_string_t keyword;
2477 cmdline_fixed_string_t all;
2478 cmdline_fixed_string_t name;
2483 cmd_config_thresh_parsed(void *parsed_result,
2484 __attribute__((unused)) struct cmdline *cl,
2485 __attribute__((unused)) void *data)
2487 struct cmd_config_thresh *res = parsed_result;
2489 if (!all_ports_stopped()) {
2490 printf("Please stop all ports first\n");
2494 if (!strcmp(res->name, "txpt"))
2495 tx_pthresh = res->value;
2496 else if(!strcmp(res->name, "txht"))
2497 tx_hthresh = res->value;
2498 else if(!strcmp(res->name, "txwt"))
2499 tx_wthresh = res->value;
2500 else if(!strcmp(res->name, "rxpt"))
2501 rx_pthresh = res->value;
2502 else if(!strcmp(res->name, "rxht"))
2503 rx_hthresh = res->value;
2504 else if(!strcmp(res->name, "rxwt"))
2505 rx_wthresh = res->value;
2507 printf("Unknown parameter\n");
2513 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2516 cmdline_parse_token_string_t cmd_config_thresh_port =
2517 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2518 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2519 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2520 cmdline_parse_token_string_t cmd_config_thresh_all =
2521 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2522 cmdline_parse_token_string_t cmd_config_thresh_name =
2523 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2524 "txpt#txht#txwt#rxpt#rxht#rxwt");
2525 cmdline_parse_token_num_t cmd_config_thresh_value =
2526 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2528 cmdline_parse_inst_t cmd_config_thresh = {
2529 .f = cmd_config_thresh_parsed,
2531 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2533 (void *)&cmd_config_thresh_port,
2534 (void *)&cmd_config_thresh_keyword,
2535 (void *)&cmd_config_thresh_all,
2536 (void *)&cmd_config_thresh_name,
2537 (void *)&cmd_config_thresh_value,
2542 /* *** configure free/rs threshold *** */
2543 struct cmd_config_threshold {
2544 cmdline_fixed_string_t port;
2545 cmdline_fixed_string_t keyword;
2546 cmdline_fixed_string_t all;
2547 cmdline_fixed_string_t name;
2552 cmd_config_threshold_parsed(void *parsed_result,
2553 __attribute__((unused)) struct cmdline *cl,
2554 __attribute__((unused)) void *data)
2556 struct cmd_config_threshold *res = parsed_result;
2558 if (!all_ports_stopped()) {
2559 printf("Please stop all ports first\n");
2563 if (!strcmp(res->name, "txfreet"))
2564 tx_free_thresh = res->value;
2565 else if (!strcmp(res->name, "txrst"))
2566 tx_rs_thresh = res->value;
2567 else if (!strcmp(res->name, "rxfreet"))
2568 rx_free_thresh = res->value;
2570 printf("Unknown parameter\n");
2576 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2579 cmdline_parse_token_string_t cmd_config_threshold_port =
2580 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2581 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2582 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2584 cmdline_parse_token_string_t cmd_config_threshold_all =
2585 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2586 cmdline_parse_token_string_t cmd_config_threshold_name =
2587 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2588 "txfreet#txrst#rxfreet");
2589 cmdline_parse_token_num_t cmd_config_threshold_value =
2590 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2592 cmdline_parse_inst_t cmd_config_threshold = {
2593 .f = cmd_config_threshold_parsed,
2595 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2597 (void *)&cmd_config_threshold_port,
2598 (void *)&cmd_config_threshold_keyword,
2599 (void *)&cmd_config_threshold_all,
2600 (void *)&cmd_config_threshold_name,
2601 (void *)&cmd_config_threshold_value,
2607 struct cmd_stop_result {
2608 cmdline_fixed_string_t stop;
2611 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2612 __attribute__((unused)) struct cmdline *cl,
2613 __attribute__((unused)) void *data)
2615 stop_packet_forwarding();
2618 cmdline_parse_token_string_t cmd_stop_stop =
2619 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2621 cmdline_parse_inst_t cmd_stop = {
2622 .f = cmd_stop_parsed,
2624 .help_str = "stop: Stop packet forwarding",
2626 (void *)&cmd_stop_stop,
2631 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2634 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2635 unsigned int *parsed_items, int check_unique_values)
2637 unsigned int nb_item;
2645 * First parse all items in the list and store their value.
2650 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2652 if ((c >= '0') && (c <= '9')) {
2653 value = (unsigned int) (value * 10 + (c - '0'));
2658 printf("character %c is not a decimal digit\n", c);
2662 printf("No valid value before comma\n");
2665 if (nb_item < max_items) {
2666 parsed_items[nb_item] = value;
2672 if (nb_item >= max_items) {
2673 printf("Number of %s = %u > %u (maximum items)\n",
2674 item_name, nb_item + 1, max_items);
2677 parsed_items[nb_item++] = value;
2678 if (! check_unique_values)
2682 * Then, check that all values in the list are differents.
2683 * No optimization here...
2685 for (i = 0; i < nb_item; i++) {
2686 for (j = i + 1; j < nb_item; j++) {
2687 if (parsed_items[j] == parsed_items[i]) {
2688 printf("duplicated %s %u at index %u and %u\n",
2689 item_name, parsed_items[i], i, j);
2697 struct cmd_set_list_result {
2698 cmdline_fixed_string_t cmd_keyword;
2699 cmdline_fixed_string_t list_name;
2700 cmdline_fixed_string_t list_of_items;
2703 static void cmd_set_list_parsed(void *parsed_result,
2704 __attribute__((unused)) struct cmdline *cl,
2705 __attribute__((unused)) void *data)
2707 struct cmd_set_list_result *res;
2709 unsigned int lcorelist[RTE_MAX_LCORE];
2710 unsigned int portlist[RTE_MAX_ETHPORTS];
2712 unsigned int nb_item;
2714 if (test_done == 0) {
2715 printf("Please stop forwarding first\n");
2719 res = parsed_result;
2720 if (!strcmp(res->list_name, "corelist")) {
2721 nb_item = parse_item_list(res->list_of_items, "core",
2723 parsed_items.lcorelist, 1);
2725 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2730 if (!strcmp(res->list_name, "portlist")) {
2731 nb_item = parse_item_list(res->list_of_items, "port",
2733 parsed_items.portlist, 1);
2735 set_fwd_ports_list(parsed_items.portlist, nb_item);
2741 cmdline_parse_token_string_t cmd_set_list_keyword =
2742 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2744 cmdline_parse_token_string_t cmd_set_list_name =
2745 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2746 "corelist#portlist");
2747 cmdline_parse_token_string_t cmd_set_list_of_items =
2748 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2751 cmdline_parse_inst_t cmd_set_fwd_list = {
2752 .f = cmd_set_list_parsed,
2754 .help_str = "set corelist|portlist <list0[,list1]*>",
2756 (void *)&cmd_set_list_keyword,
2757 (void *)&cmd_set_list_name,
2758 (void *)&cmd_set_list_of_items,
2763 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2765 struct cmd_setmask_result {
2766 cmdline_fixed_string_t set;
2767 cmdline_fixed_string_t mask;
2771 static void cmd_set_mask_parsed(void *parsed_result,
2772 __attribute__((unused)) struct cmdline *cl,
2773 __attribute__((unused)) void *data)
2775 struct cmd_setmask_result *res = parsed_result;
2777 if (test_done == 0) {
2778 printf("Please stop forwarding first\n");
2781 if (!strcmp(res->mask, "coremask")) {
2782 set_fwd_lcores_mask(res->hexavalue);
2784 } else if (!strcmp(res->mask, "portmask")) {
2785 set_fwd_ports_mask(res->hexavalue);
2790 cmdline_parse_token_string_t cmd_setmask_set =
2791 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2792 cmdline_parse_token_string_t cmd_setmask_mask =
2793 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2794 "coremask#portmask");
2795 cmdline_parse_token_num_t cmd_setmask_value =
2796 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2798 cmdline_parse_inst_t cmd_set_fwd_mask = {
2799 .f = cmd_set_mask_parsed,
2801 .help_str = "set coremask|portmask <hexadecimal value>",
2803 (void *)&cmd_setmask_set,
2804 (void *)&cmd_setmask_mask,
2805 (void *)&cmd_setmask_value,
2811 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2813 struct cmd_set_result {
2814 cmdline_fixed_string_t set;
2815 cmdline_fixed_string_t what;
2819 static void cmd_set_parsed(void *parsed_result,
2820 __attribute__((unused)) struct cmdline *cl,
2821 __attribute__((unused)) void *data)
2823 struct cmd_set_result *res = parsed_result;
2824 if (!strcmp(res->what, "nbport")) {
2825 set_fwd_ports_number(res->value);
2827 } else if (!strcmp(res->what, "nbcore")) {
2828 set_fwd_lcores_number(res->value);
2830 } else if (!strcmp(res->what, "burst"))
2831 set_nb_pkt_per_burst(res->value);
2832 else if (!strcmp(res->what, "verbose"))
2833 set_verbose_level(res->value);
2836 cmdline_parse_token_string_t cmd_set_set =
2837 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2838 cmdline_parse_token_string_t cmd_set_what =
2839 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2840 "nbport#nbcore#burst#verbose");
2841 cmdline_parse_token_num_t cmd_set_value =
2842 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2844 cmdline_parse_inst_t cmd_set_numbers = {
2845 .f = cmd_set_parsed,
2847 .help_str = "set nbport|nbcore|burst|verbose <value>",
2849 (void *)&cmd_set_set,
2850 (void *)&cmd_set_what,
2851 (void *)&cmd_set_value,
2856 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2858 struct cmd_set_txpkts_result {
2859 cmdline_fixed_string_t cmd_keyword;
2860 cmdline_fixed_string_t txpkts;
2861 cmdline_fixed_string_t seg_lengths;
2865 cmd_set_txpkts_parsed(void *parsed_result,
2866 __attribute__((unused)) struct cmdline *cl,
2867 __attribute__((unused)) void *data)
2869 struct cmd_set_txpkts_result *res;
2870 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2871 unsigned int nb_segs;
2873 res = parsed_result;
2874 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2875 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2877 set_tx_pkt_segments(seg_lengths, nb_segs);
2880 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2881 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2882 cmd_keyword, "set");
2883 cmdline_parse_token_string_t cmd_set_txpkts_name =
2884 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2886 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2887 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2890 cmdline_parse_inst_t cmd_set_txpkts = {
2891 .f = cmd_set_txpkts_parsed,
2893 .help_str = "set txpkts <len0[,len1]*>",
2895 (void *)&cmd_set_txpkts_keyword,
2896 (void *)&cmd_set_txpkts_name,
2897 (void *)&cmd_set_txpkts_lengths,
2902 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2904 struct cmd_set_txsplit_result {
2905 cmdline_fixed_string_t cmd_keyword;
2906 cmdline_fixed_string_t txsplit;
2907 cmdline_fixed_string_t mode;
2911 cmd_set_txsplit_parsed(void *parsed_result,
2912 __attribute__((unused)) struct cmdline *cl,
2913 __attribute__((unused)) void *data)
2915 struct cmd_set_txsplit_result *res;
2917 res = parsed_result;
2918 set_tx_pkt_split(res->mode);
2921 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2922 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2923 cmd_keyword, "set");
2924 cmdline_parse_token_string_t cmd_set_txsplit_name =
2925 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2926 txsplit, "txsplit");
2927 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2928 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2931 cmdline_parse_inst_t cmd_set_txsplit = {
2932 .f = cmd_set_txsplit_parsed,
2934 .help_str = "set txsplit on|off|rand",
2936 (void *)&cmd_set_txsplit_keyword,
2937 (void *)&cmd_set_txsplit_name,
2938 (void *)&cmd_set_txsplit_mode,
2943 /* *** CONFIG TX QUEUE FLAGS *** */
2945 struct cmd_config_txqflags_result {
2946 cmdline_fixed_string_t port;
2947 cmdline_fixed_string_t config;
2948 cmdline_fixed_string_t all;
2949 cmdline_fixed_string_t what;
2953 static void cmd_config_txqflags_parsed(void *parsed_result,
2954 __attribute__((unused)) struct cmdline *cl,
2955 __attribute__((unused)) void *data)
2957 struct cmd_config_txqflags_result *res = parsed_result;
2959 if (!all_ports_stopped()) {
2960 printf("Please stop all ports first\n");
2964 if (strcmp(res->what, "txqflags")) {
2965 printf("Unknown parameter\n");
2969 if (res->hexvalue >= 0) {
2970 txq_flags = res->hexvalue;
2972 printf("txqflags must be >= 0\n");
2978 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2981 cmdline_parse_token_string_t cmd_config_txqflags_port =
2982 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2984 cmdline_parse_token_string_t cmd_config_txqflags_config =
2985 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2987 cmdline_parse_token_string_t cmd_config_txqflags_all =
2988 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2990 cmdline_parse_token_string_t cmd_config_txqflags_what =
2991 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2993 cmdline_parse_token_num_t cmd_config_txqflags_value =
2994 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2997 cmdline_parse_inst_t cmd_config_txqflags = {
2998 .f = cmd_config_txqflags_parsed,
3000 .help_str = "port config all txqflags <value>",
3002 (void *)&cmd_config_txqflags_port,
3003 (void *)&cmd_config_txqflags_config,
3004 (void *)&cmd_config_txqflags_all,
3005 (void *)&cmd_config_txqflags_what,
3006 (void *)&cmd_config_txqflags_value,
3011 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3012 struct cmd_rx_vlan_filter_all_result {
3013 cmdline_fixed_string_t rx_vlan;
3014 cmdline_fixed_string_t what;
3015 cmdline_fixed_string_t all;
3020 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3021 __attribute__((unused)) struct cmdline *cl,
3022 __attribute__((unused)) void *data)
3024 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3026 if (!strcmp(res->what, "add"))
3027 rx_vlan_all_filter_set(res->port_id, 1);
3029 rx_vlan_all_filter_set(res->port_id, 0);
3032 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3033 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3034 rx_vlan, "rx_vlan");
3035 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3036 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3038 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3039 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3041 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3042 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3045 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3046 .f = cmd_rx_vlan_filter_all_parsed,
3048 .help_str = "rx_vlan add|rm all <port_id>: "
3049 "Add/Remove all identifiers to/from the set of VLAN "
3050 "identifiers filtered by a port",
3052 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3053 (void *)&cmd_rx_vlan_filter_all_what,
3054 (void *)&cmd_rx_vlan_filter_all_all,
3055 (void *)&cmd_rx_vlan_filter_all_portid,
3060 /* *** VLAN OFFLOAD SET ON A PORT *** */
3061 struct cmd_vlan_offload_result {
3062 cmdline_fixed_string_t vlan;
3063 cmdline_fixed_string_t set;
3064 cmdline_fixed_string_t vlan_type;
3065 cmdline_fixed_string_t what;
3066 cmdline_fixed_string_t on;
3067 cmdline_fixed_string_t port_id;
3071 cmd_vlan_offload_parsed(void *parsed_result,
3072 __attribute__((unused)) struct cmdline *cl,
3073 __attribute__((unused)) void *data)
3076 struct cmd_vlan_offload_result *res = parsed_result;
3079 portid_t port_id = 0;
3083 len = strnlen(str, STR_TOKEN_SIZE);
3085 /* Get port_id first */
3093 tmp = strtoul(str, NULL, 0);
3094 /* If port_id greater that what portid_t can represent, return */
3095 if(tmp >= RTE_MAX_ETHPORTS)
3097 port_id = (portid_t)tmp;
3099 if (!strcmp(res->on, "on"))
3104 if (!strcmp(res->what, "strip"))
3105 rx_vlan_strip_set(port_id, on);
3106 else if(!strcmp(res->what, "stripq")){
3107 uint16_t queue_id = 0;
3109 /* No queue_id, return */
3111 printf("must specify (port,queue_id)\n");
3114 tmp = strtoul(str + i + 1, NULL, 0);
3115 /* If queue_id greater that what 16-bits can represent, return */
3119 queue_id = (uint16_t)tmp;
3120 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3122 else if (!strcmp(res->what, "filter"))
3123 rx_vlan_filter_set(port_id, on);
3125 vlan_extend_set(port_id, on);
3130 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3131 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3133 cmdline_parse_token_string_t cmd_vlan_offload_set =
3134 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3136 cmdline_parse_token_string_t cmd_vlan_offload_what =
3137 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3138 what, "strip#filter#qinq#stripq");
3139 cmdline_parse_token_string_t cmd_vlan_offload_on =
3140 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3142 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3143 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3146 cmdline_parse_inst_t cmd_vlan_offload = {
3147 .f = cmd_vlan_offload_parsed,
3149 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3150 "<port_id[,queue_id]>: "
3151 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3153 (void *)&cmd_vlan_offload_vlan,
3154 (void *)&cmd_vlan_offload_set,
3155 (void *)&cmd_vlan_offload_what,
3156 (void *)&cmd_vlan_offload_on,
3157 (void *)&cmd_vlan_offload_portid,
3162 /* *** VLAN TPID SET ON A PORT *** */
3163 struct cmd_vlan_tpid_result {
3164 cmdline_fixed_string_t vlan;
3165 cmdline_fixed_string_t set;
3166 cmdline_fixed_string_t vlan_type;
3167 cmdline_fixed_string_t what;
3173 cmd_vlan_tpid_parsed(void *parsed_result,
3174 __attribute__((unused)) struct cmdline *cl,
3175 __attribute__((unused)) void *data)
3177 struct cmd_vlan_tpid_result *res = parsed_result;
3178 enum rte_vlan_type vlan_type;
3180 if (!strcmp(res->vlan_type, "inner"))
3181 vlan_type = ETH_VLAN_TYPE_INNER;
3182 else if (!strcmp(res->vlan_type, "outer"))
3183 vlan_type = ETH_VLAN_TYPE_OUTER;
3185 printf("Unknown vlan type\n");
3188 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3191 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3192 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3194 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3195 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3197 cmdline_parse_token_string_t cmd_vlan_type =
3198 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3199 vlan_type, "inner#outer");
3200 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3201 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3203 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3204 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3206 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3207 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3210 cmdline_parse_inst_t cmd_vlan_tpid = {
3211 .f = cmd_vlan_tpid_parsed,
3213 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3214 "Set the VLAN Ether type",
3216 (void *)&cmd_vlan_tpid_vlan,
3217 (void *)&cmd_vlan_tpid_set,
3218 (void *)&cmd_vlan_type,
3219 (void *)&cmd_vlan_tpid_what,
3220 (void *)&cmd_vlan_tpid_tpid,
3221 (void *)&cmd_vlan_tpid_portid,
3226 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3227 struct cmd_rx_vlan_filter_result {
3228 cmdline_fixed_string_t rx_vlan;
3229 cmdline_fixed_string_t what;
3235 cmd_rx_vlan_filter_parsed(void *parsed_result,
3236 __attribute__((unused)) struct cmdline *cl,
3237 __attribute__((unused)) void *data)
3239 struct cmd_rx_vlan_filter_result *res = parsed_result;
3241 if (!strcmp(res->what, "add"))
3242 rx_vft_set(res->port_id, res->vlan_id, 1);
3244 rx_vft_set(res->port_id, res->vlan_id, 0);
3247 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3248 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3249 rx_vlan, "rx_vlan");
3250 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3251 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3253 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3254 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3256 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3257 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3260 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3261 .f = cmd_rx_vlan_filter_parsed,
3263 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3264 "Add/Remove a VLAN identifier to/from the set of VLAN "
3265 "identifiers filtered by a port",
3267 (void *)&cmd_rx_vlan_filter_rx_vlan,
3268 (void *)&cmd_rx_vlan_filter_what,
3269 (void *)&cmd_rx_vlan_filter_vlanid,
3270 (void *)&cmd_rx_vlan_filter_portid,
3275 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3276 struct cmd_tx_vlan_set_result {
3277 cmdline_fixed_string_t tx_vlan;
3278 cmdline_fixed_string_t set;
3284 cmd_tx_vlan_set_parsed(void *parsed_result,
3285 __attribute__((unused)) struct cmdline *cl,
3286 __attribute__((unused)) void *data)
3288 struct cmd_tx_vlan_set_result *res = parsed_result;
3290 tx_vlan_set(res->port_id, res->vlan_id);
3293 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3294 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3295 tx_vlan, "tx_vlan");
3296 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3297 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3299 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3300 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3302 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3303 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3306 cmdline_parse_inst_t cmd_tx_vlan_set = {
3307 .f = cmd_tx_vlan_set_parsed,
3309 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3310 "Enable hardware insertion of a single VLAN header "
3311 "with a given TAG Identifier in packets sent on a port",
3313 (void *)&cmd_tx_vlan_set_tx_vlan,
3314 (void *)&cmd_tx_vlan_set_set,
3315 (void *)&cmd_tx_vlan_set_portid,
3316 (void *)&cmd_tx_vlan_set_vlanid,
3321 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3322 struct cmd_tx_vlan_set_qinq_result {
3323 cmdline_fixed_string_t tx_vlan;
3324 cmdline_fixed_string_t set;
3327 uint16_t vlan_id_outer;
3331 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3332 __attribute__((unused)) struct cmdline *cl,
3333 __attribute__((unused)) void *data)
3335 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3337 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3340 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3341 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3342 tx_vlan, "tx_vlan");
3343 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3344 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3346 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3347 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3349 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3350 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3352 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3353 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3354 vlan_id_outer, UINT16);
3356 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3357 .f = cmd_tx_vlan_set_qinq_parsed,
3359 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3360 "Enable hardware insertion of double VLAN header "
3361 "with given TAG Identifiers in packets sent on a port",
3363 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3364 (void *)&cmd_tx_vlan_set_qinq_set,
3365 (void *)&cmd_tx_vlan_set_qinq_portid,
3366 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3367 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3372 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3373 struct cmd_tx_vlan_set_pvid_result {
3374 cmdline_fixed_string_t tx_vlan;
3375 cmdline_fixed_string_t set;
3376 cmdline_fixed_string_t pvid;
3379 cmdline_fixed_string_t mode;
3383 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3384 __attribute__((unused)) struct cmdline *cl,
3385 __attribute__((unused)) void *data)
3387 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3389 if (strcmp(res->mode, "on") == 0)
3390 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3392 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3395 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3396 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3397 tx_vlan, "tx_vlan");
3398 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3399 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3401 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3402 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3404 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3405 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3407 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3408 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3410 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3411 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3414 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3415 .f = cmd_tx_vlan_set_pvid_parsed,
3417 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3419 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3420 (void *)&cmd_tx_vlan_set_pvid_set,
3421 (void *)&cmd_tx_vlan_set_pvid_pvid,
3422 (void *)&cmd_tx_vlan_set_pvid_port_id,
3423 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3424 (void *)&cmd_tx_vlan_set_pvid_mode,
3429 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3430 struct cmd_tx_vlan_reset_result {
3431 cmdline_fixed_string_t tx_vlan;
3432 cmdline_fixed_string_t reset;
3437 cmd_tx_vlan_reset_parsed(void *parsed_result,
3438 __attribute__((unused)) struct cmdline *cl,
3439 __attribute__((unused)) void *data)
3441 struct cmd_tx_vlan_reset_result *res = parsed_result;
3443 tx_vlan_reset(res->port_id);
3446 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3447 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3448 tx_vlan, "tx_vlan");
3449 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3450 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3452 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3453 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3456 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3457 .f = cmd_tx_vlan_reset_parsed,
3459 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3460 "VLAN header in packets sent on a port",
3462 (void *)&cmd_tx_vlan_reset_tx_vlan,
3463 (void *)&cmd_tx_vlan_reset_reset,
3464 (void *)&cmd_tx_vlan_reset_portid,
3470 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3471 struct cmd_csum_result {
3472 cmdline_fixed_string_t csum;
3473 cmdline_fixed_string_t mode;
3474 cmdline_fixed_string_t proto;
3475 cmdline_fixed_string_t hwsw;
3480 csum_show(int port_id)
3482 struct rte_eth_dev_info dev_info;
3485 ol_flags = ports[port_id].tx_ol_flags;
3486 printf("Parse tunnel is %s\n",
3487 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3488 printf("IP checksum offload is %s\n",
3489 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3490 printf("UDP checksum offload is %s\n",
3491 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3492 printf("TCP checksum offload is %s\n",
3493 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3494 printf("SCTP checksum offload is %s\n",
3495 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3496 printf("Outer-Ip checksum offload is %s\n",
3497 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3499 /* display warnings if configuration is not supported by the NIC */
3500 rte_eth_dev_info_get(port_id, &dev_info);
3501 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3502 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3503 printf("Warning: hardware IP checksum enabled but not "
3504 "supported by port %d\n", port_id);
3506 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3507 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3508 printf("Warning: hardware UDP checksum enabled but not "
3509 "supported by port %d\n", port_id);
3511 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3512 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3513 printf("Warning: hardware TCP checksum enabled but not "
3514 "supported by port %d\n", port_id);
3516 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3517 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3518 printf("Warning: hardware SCTP checksum enabled but not "
3519 "supported by port %d\n", port_id);
3521 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3522 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3523 printf("Warning: hardware outer IP checksum enabled but not "
3524 "supported by port %d\n", port_id);
3529 cmd_csum_parsed(void *parsed_result,
3530 __attribute__((unused)) struct cmdline *cl,
3531 __attribute__((unused)) void *data)
3533 struct cmd_csum_result *res = parsed_result;
3537 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3538 printf("invalid port %d\n", res->port_id);
3542 if (!strcmp(res->mode, "set")) {
3544 if (!strcmp(res->hwsw, "hw"))
3547 if (!strcmp(res->proto, "ip")) {
3548 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3549 } else if (!strcmp(res->proto, "udp")) {
3550 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3551 } else if (!strcmp(res->proto, "tcp")) {
3552 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3553 } else if (!strcmp(res->proto, "sctp")) {
3554 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3555 } else if (!strcmp(res->proto, "outer-ip")) {
3556 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3560 ports[res->port_id].tx_ol_flags |= mask;
3562 ports[res->port_id].tx_ol_flags &= (~mask);
3564 csum_show(res->port_id);
3567 cmdline_parse_token_string_t cmd_csum_csum =
3568 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3570 cmdline_parse_token_string_t cmd_csum_mode =
3571 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3573 cmdline_parse_token_string_t cmd_csum_proto =
3574 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3575 proto, "ip#tcp#udp#sctp#outer-ip");
3576 cmdline_parse_token_string_t cmd_csum_hwsw =
3577 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3579 cmdline_parse_token_num_t cmd_csum_portid =
3580 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3583 cmdline_parse_inst_t cmd_csum_set = {
3584 .f = cmd_csum_parsed,
3586 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3587 "Enable/Disable hardware calculation of L3/L4 checksum when "
3588 "using csum forward engine",
3590 (void *)&cmd_csum_csum,
3591 (void *)&cmd_csum_mode,
3592 (void *)&cmd_csum_proto,
3593 (void *)&cmd_csum_hwsw,
3594 (void *)&cmd_csum_portid,
3599 cmdline_parse_token_string_t cmd_csum_mode_show =
3600 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3603 cmdline_parse_inst_t cmd_csum_show = {
3604 .f = cmd_csum_parsed,
3606 .help_str = "csum show <port_id>: Show checksum offload configuration",
3608 (void *)&cmd_csum_csum,
3609 (void *)&cmd_csum_mode_show,
3610 (void *)&cmd_csum_portid,
3615 /* Enable/disable tunnel parsing */
3616 struct cmd_csum_tunnel_result {
3617 cmdline_fixed_string_t csum;
3618 cmdline_fixed_string_t parse;
3619 cmdline_fixed_string_t onoff;
3624 cmd_csum_tunnel_parsed(void *parsed_result,
3625 __attribute__((unused)) struct cmdline *cl,
3626 __attribute__((unused)) void *data)
3628 struct cmd_csum_tunnel_result *res = parsed_result;
3630 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3633 if (!strcmp(res->onoff, "on"))
3634 ports[res->port_id].tx_ol_flags |=
3635 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3637 ports[res->port_id].tx_ol_flags &=
3638 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3640 csum_show(res->port_id);
3643 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3644 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3646 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3647 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3648 parse, "parse_tunnel");
3649 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3650 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3652 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3653 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3656 cmdline_parse_inst_t cmd_csum_tunnel = {
3657 .f = cmd_csum_tunnel_parsed,
3659 .help_str = "csum parse_tunnel on|off <port_id>: "
3660 "Enable/Disable parsing of tunnels for csum engine",
3662 (void *)&cmd_csum_tunnel_csum,
3663 (void *)&cmd_csum_tunnel_parse,
3664 (void *)&cmd_csum_tunnel_onoff,
3665 (void *)&cmd_csum_tunnel_portid,
3670 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3671 struct cmd_tso_set_result {
3672 cmdline_fixed_string_t tso;
3673 cmdline_fixed_string_t mode;
3679 cmd_tso_set_parsed(void *parsed_result,
3680 __attribute__((unused)) struct cmdline *cl,
3681 __attribute__((unused)) void *data)
3683 struct cmd_tso_set_result *res = parsed_result;
3684 struct rte_eth_dev_info dev_info;
3686 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3689 if (!strcmp(res->mode, "set"))
3690 ports[res->port_id].tso_segsz = res->tso_segsz;
3692 if (ports[res->port_id].tso_segsz == 0)
3693 printf("TSO for non-tunneled packets is disabled\n");
3695 printf("TSO segment size for non-tunneled packets is %d\n",
3696 ports[res->port_id].tso_segsz);
3698 /* display warnings if configuration is not supported by the NIC */
3699 rte_eth_dev_info_get(res->port_id, &dev_info);
3700 if ((ports[res->port_id].tso_segsz != 0) &&
3701 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3702 printf("Warning: TSO enabled but not "
3703 "supported by port %d\n", res->port_id);
3707 cmdline_parse_token_string_t cmd_tso_set_tso =
3708 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3710 cmdline_parse_token_string_t cmd_tso_set_mode =
3711 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3713 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3714 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3716 cmdline_parse_token_num_t cmd_tso_set_portid =
3717 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3720 cmdline_parse_inst_t cmd_tso_set = {
3721 .f = cmd_tso_set_parsed,
3723 .help_str = "tso set <tso_segsz> <port_id>: "
3724 "Set TSO segment size of non-tunneled packets for csum engine "
3727 (void *)&cmd_tso_set_tso,
3728 (void *)&cmd_tso_set_mode,
3729 (void *)&cmd_tso_set_tso_segsz,
3730 (void *)&cmd_tso_set_portid,
3735 cmdline_parse_token_string_t cmd_tso_show_mode =
3736 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3740 cmdline_parse_inst_t cmd_tso_show = {
3741 .f = cmd_tso_set_parsed,
3743 .help_str = "tso show <port_id>: "
3744 "Show TSO segment size of non-tunneled packets for csum engine",
3746 (void *)&cmd_tso_set_tso,
3747 (void *)&cmd_tso_show_mode,
3748 (void *)&cmd_tso_set_portid,
3753 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3754 struct cmd_tunnel_tso_set_result {
3755 cmdline_fixed_string_t tso;
3756 cmdline_fixed_string_t mode;
3762 check_tunnel_tso_nic_support(uint8_t port_id)
3764 struct rte_eth_dev_info dev_info;
3766 rte_eth_dev_info_get(port_id, &dev_info);
3767 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3768 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3769 "supported by port %d\n", port_id);
3770 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3771 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3772 "supported by port %d\n", port_id);
3773 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3774 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3775 "supported by port %d\n", port_id);
3776 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3777 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3778 "supported by port %d\n", port_id);
3782 cmd_tunnel_tso_set_parsed(void *parsed_result,
3783 __attribute__((unused)) struct cmdline *cl,
3784 __attribute__((unused)) void *data)
3786 struct cmd_tunnel_tso_set_result *res = parsed_result;
3788 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3791 if (!strcmp(res->mode, "set"))
3792 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3794 if (ports[res->port_id].tunnel_tso_segsz == 0)
3795 printf("TSO for tunneled packets is disabled\n");
3797 printf("TSO segment size for tunneled packets is %d\n",
3798 ports[res->port_id].tunnel_tso_segsz);
3800 /* Below conditions are needed to make it work:
3801 * (1) tunnel TSO is supported by the NIC;
3802 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3804 * (3) for tunneled pkts with outer L3 of IPv4,
3805 * "csum set outer-ip" must be set to hw, because after tso,
3806 * total_len of outer IP header is changed, and the checksum
3807 * of outer IP header calculated by sw should be wrong; that
3808 * is not necessary for IPv6 tunneled pkts because there's no
3809 * checksum in IP header anymore.
3811 check_tunnel_tso_nic_support(res->port_id);
3813 if (!(ports[res->port_id].tx_ol_flags &
3814 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3815 printf("Warning: csum parse_tunnel must be set "
3816 "so that tunneled packets are recognized\n");
3817 if (!(ports[res->port_id].tx_ol_flags &
3818 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3819 printf("Warning: csum set outer-ip must be set to hw "
3820 "if outer L3 is IPv4; not necessary for IPv6\n");
3824 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3825 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3827 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3828 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3830 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3831 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3833 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3834 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3837 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3838 .f = cmd_tunnel_tso_set_parsed,
3840 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3841 "Set TSO segment size of tunneled packets for csum engine "
3844 (void *)&cmd_tunnel_tso_set_tso,
3845 (void *)&cmd_tunnel_tso_set_mode,
3846 (void *)&cmd_tunnel_tso_set_tso_segsz,
3847 (void *)&cmd_tunnel_tso_set_portid,
3852 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3853 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3857 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3858 .f = cmd_tunnel_tso_set_parsed,
3860 .help_str = "tunnel_tso show <port_id> "
3861 "Show TSO segment size of tunneled packets for csum engine",
3863 (void *)&cmd_tunnel_tso_set_tso,
3864 (void *)&cmd_tunnel_tso_show_mode,
3865 (void *)&cmd_tunnel_tso_set_portid,
3870 /* *** SET GRO FOR A PORT *** */
3871 struct cmd_gro_result {
3872 cmdline_fixed_string_t cmd_keyword;
3873 cmdline_fixed_string_t mode;
3878 cmd_enable_gro_parsed(void *parsed_result,
3879 __attribute__((unused)) struct cmdline *cl,
3880 __attribute__((unused)) void *data)
3882 struct cmd_gro_result *res;
3884 res = parsed_result;
3885 setup_gro(res->mode, res->port_id);
3888 cmdline_parse_token_string_t cmd_gro_keyword =
3889 TOKEN_STRING_INITIALIZER(struct cmd_gro_result,
3890 cmd_keyword, "gro");
3891 cmdline_parse_token_string_t cmd_gro_mode =
3892 TOKEN_STRING_INITIALIZER(struct cmd_gro_result,
3894 cmdline_parse_token_num_t cmd_gro_pid =
3895 TOKEN_NUM_INITIALIZER(struct cmd_gro_result,
3898 cmdline_parse_inst_t cmd_enable_gro = {
3899 .f = cmd_enable_gro_parsed,
3901 .help_str = "gro (on|off) (port_id)",
3903 (void *)&cmd_gro_keyword,
3904 (void *)&cmd_gro_mode,
3905 (void *)&cmd_gro_pid,
3910 /* *** SET MAX FLOW NUMBER AND ITEM NUM PER FLOW FOR GRO *** */
3911 struct cmd_gro_set_result {
3912 cmdline_fixed_string_t gro;
3913 cmdline_fixed_string_t mode;
3915 uint16_t item_num_per_flow;
3920 cmd_gro_set_parsed(void *parsed_result,
3921 __attribute__((unused)) struct cmdline *cl,
3922 __attribute__((unused)) void *data)
3924 struct cmd_gro_set_result *res = parsed_result;
3926 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3928 if (test_done == 0) {
3929 printf("Before set GRO flow_num and item_num_per_flow,"
3930 " please stop forwarding first\n");
3934 if (!strcmp(res->mode, "set")) {
3935 if (res->flow_num == 0)
3936 printf("Invalid flow number. Revert to default value:"
3937 " %u.\n", GRO_DEFAULT_FLOW_NUM);
3939 gro_ports[res->port_id].param.max_flow_num =
3942 if (res->item_num_per_flow == 0)
3943 printf("Invalid item number per-flow. Revert"
3944 " to default value:%u.\n",
3945 GRO_DEFAULT_ITEM_NUM_PER_FLOW);
3947 gro_ports[res->port_id].param.max_item_per_flow =
3948 res->item_num_per_flow;
3952 cmdline_parse_token_string_t cmd_gro_set_gro =
3953 TOKEN_STRING_INITIALIZER(struct cmd_gro_set_result,
3955 cmdline_parse_token_string_t cmd_gro_set_mode =
3956 TOKEN_STRING_INITIALIZER(struct cmd_gro_set_result,
3958 cmdline_parse_token_num_t cmd_gro_set_flow_num =
3959 TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result,
3961 cmdline_parse_token_num_t cmd_gro_set_item_num_per_flow =
3962 TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result,
3963 item_num_per_flow, UINT16);
3964 cmdline_parse_token_num_t cmd_gro_set_portid =
3965 TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result,
3968 cmdline_parse_inst_t cmd_gro_set = {
3969 .f = cmd_gro_set_parsed,
3971 .help_str = "gro set <max_flow_num> <max_item_num_per_flow> "
3972 "<port_id>: set max flow number and max packet number per-flow "
3975 (void *)&cmd_gro_set_gro,
3976 (void *)&cmd_gro_set_mode,
3977 (void *)&cmd_gro_set_flow_num,
3978 (void *)&cmd_gro_set_item_num_per_flow,
3979 (void *)&cmd_gro_set_portid,
3984 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3985 struct cmd_set_flush_rx {
3986 cmdline_fixed_string_t set;
3987 cmdline_fixed_string_t flush_rx;
3988 cmdline_fixed_string_t mode;
3992 cmd_set_flush_rx_parsed(void *parsed_result,
3993 __attribute__((unused)) struct cmdline *cl,
3994 __attribute__((unused)) void *data)
3996 struct cmd_set_flush_rx *res = parsed_result;
3997 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4000 cmdline_parse_token_string_t cmd_setflushrx_set =
4001 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4003 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4004 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4005 flush_rx, "flush_rx");
4006 cmdline_parse_token_string_t cmd_setflushrx_mode =
4007 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4011 cmdline_parse_inst_t cmd_set_flush_rx = {
4012 .f = cmd_set_flush_rx_parsed,
4013 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4016 (void *)&cmd_setflushrx_set,
4017 (void *)&cmd_setflushrx_flush_rx,
4018 (void *)&cmd_setflushrx_mode,
4023 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4024 struct cmd_set_link_check {
4025 cmdline_fixed_string_t set;
4026 cmdline_fixed_string_t link_check;
4027 cmdline_fixed_string_t mode;
4031 cmd_set_link_check_parsed(void *parsed_result,
4032 __attribute__((unused)) struct cmdline *cl,
4033 __attribute__((unused)) void *data)
4035 struct cmd_set_link_check *res = parsed_result;
4036 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4039 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4040 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4042 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4043 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4044 link_check, "link_check");
4045 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4046 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4050 cmdline_parse_inst_t cmd_set_link_check = {
4051 .f = cmd_set_link_check_parsed,
4052 .help_str = "set link_check on|off: Enable/Disable link status check "
4053 "when starting/stopping a port",
4056 (void *)&cmd_setlinkcheck_set,
4057 (void *)&cmd_setlinkcheck_link_check,
4058 (void *)&cmd_setlinkcheck_mode,
4063 /* *** SET NIC BYPASS MODE *** */
4064 struct cmd_set_bypass_mode_result {
4065 cmdline_fixed_string_t set;
4066 cmdline_fixed_string_t bypass;
4067 cmdline_fixed_string_t mode;
4068 cmdline_fixed_string_t value;
4073 cmd_set_bypass_mode_parsed(void *parsed_result,
4074 __attribute__((unused)) struct cmdline *cl,
4075 __attribute__((unused)) void *data)
4077 struct cmd_set_bypass_mode_result *res = parsed_result;
4078 portid_t port_id = res->port_id;
4079 int32_t rc = -EINVAL;
4081 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4082 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4084 if (!strcmp(res->value, "bypass"))
4085 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4086 else if (!strcmp(res->value, "isolate"))
4087 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4089 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4091 /* Set the bypass mode for the relevant port. */
4092 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4095 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4098 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4099 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4101 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4102 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4104 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4105 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4107 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4108 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4109 value, "normal#bypass#isolate");
4110 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4111 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4114 cmdline_parse_inst_t cmd_set_bypass_mode = {
4115 .f = cmd_set_bypass_mode_parsed,
4116 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4117 "Set the NIC bypass mode for port_id",
4120 (void *)&cmd_setbypass_mode_set,
4121 (void *)&cmd_setbypass_mode_bypass,
4122 (void *)&cmd_setbypass_mode_mode,
4123 (void *)&cmd_setbypass_mode_value,
4124 (void *)&cmd_setbypass_mode_port,
4129 /* *** SET NIC BYPASS EVENT *** */
4130 struct cmd_set_bypass_event_result {
4131 cmdline_fixed_string_t set;
4132 cmdline_fixed_string_t bypass;
4133 cmdline_fixed_string_t event;
4134 cmdline_fixed_string_t event_value;
4135 cmdline_fixed_string_t mode;
4136 cmdline_fixed_string_t mode_value;
4141 cmd_set_bypass_event_parsed(void *parsed_result,
4142 __attribute__((unused)) struct cmdline *cl,
4143 __attribute__((unused)) void *data)
4145 int32_t rc = -EINVAL;
4146 struct cmd_set_bypass_event_result *res = parsed_result;
4147 portid_t port_id = res->port_id;
4149 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4150 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4151 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4153 if (!strcmp(res->event_value, "timeout"))
4154 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4155 else if (!strcmp(res->event_value, "os_on"))
4156 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4157 else if (!strcmp(res->event_value, "os_off"))
4158 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4159 else if (!strcmp(res->event_value, "power_on"))
4160 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4161 else if (!strcmp(res->event_value, "power_off"))
4162 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4164 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4166 if (!strcmp(res->mode_value, "bypass"))
4167 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4168 else if (!strcmp(res->mode_value, "isolate"))
4169 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4171 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4173 /* Set the watchdog timeout. */
4174 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4177 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4178 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4182 printf("Failed to set timeout value %u "
4183 "for port %d, errto code: %d.\n",
4184 bypass_timeout, port_id, rc);
4188 /* Set the bypass event to transition to bypass mode. */
4189 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4194 printf("\t Failed to set bypass event for port = %d.\n",
4198 cmdline_parse_token_string_t cmd_setbypass_event_set =
4199 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4201 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4202 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4204 cmdline_parse_token_string_t cmd_setbypass_event_event =
4205 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4207 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4208 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4209 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4210 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4211 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4213 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4214 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4215 mode_value, "normal#bypass#isolate");
4216 cmdline_parse_token_num_t cmd_setbypass_event_port =
4217 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4220 cmdline_parse_inst_t cmd_set_bypass_event = {
4221 .f = cmd_set_bypass_event_parsed,
4222 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4223 "power_off mode normal|bypass|isolate <port_id>: "
4224 "Set the NIC bypass event mode for port_id",
4227 (void *)&cmd_setbypass_event_set,
4228 (void *)&cmd_setbypass_event_bypass,
4229 (void *)&cmd_setbypass_event_event,
4230 (void *)&cmd_setbypass_event_event_value,
4231 (void *)&cmd_setbypass_event_mode,
4232 (void *)&cmd_setbypass_event_mode_value,
4233 (void *)&cmd_setbypass_event_port,
4239 /* *** SET NIC BYPASS TIMEOUT *** */
4240 struct cmd_set_bypass_timeout_result {
4241 cmdline_fixed_string_t set;
4242 cmdline_fixed_string_t bypass;
4243 cmdline_fixed_string_t timeout;
4244 cmdline_fixed_string_t value;
4248 cmd_set_bypass_timeout_parsed(void *parsed_result,
4249 __attribute__((unused)) struct cmdline *cl,
4250 __attribute__((unused)) void *data)
4252 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4254 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4255 if (!strcmp(res->value, "1.5"))
4256 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4257 else if (!strcmp(res->value, "2"))
4258 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4259 else if (!strcmp(res->value, "3"))
4260 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4261 else if (!strcmp(res->value, "4"))
4262 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4263 else if (!strcmp(res->value, "8"))
4264 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4265 else if (!strcmp(res->value, "16"))
4266 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4267 else if (!strcmp(res->value, "32"))
4268 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4270 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4274 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4275 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4277 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4278 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4280 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4281 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4282 timeout, "timeout");
4283 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4284 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4285 value, "0#1.5#2#3#4#8#16#32");
4287 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4288 .f = cmd_set_bypass_timeout_parsed,
4289 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4290 "Set the NIC bypass watchdog timeout in seconds",
4293 (void *)&cmd_setbypass_timeout_set,
4294 (void *)&cmd_setbypass_timeout_bypass,
4295 (void *)&cmd_setbypass_timeout_timeout,
4296 (void *)&cmd_setbypass_timeout_value,
4301 /* *** SHOW NIC BYPASS MODE *** */
4302 struct cmd_show_bypass_config_result {
4303 cmdline_fixed_string_t show;
4304 cmdline_fixed_string_t bypass;
4305 cmdline_fixed_string_t config;
4310 cmd_show_bypass_config_parsed(void *parsed_result,
4311 __attribute__((unused)) struct cmdline *cl,
4312 __attribute__((unused)) void *data)
4314 struct cmd_show_bypass_config_result *res = parsed_result;
4315 portid_t port_id = res->port_id;
4317 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4318 uint32_t event_mode;
4319 uint32_t bypass_mode;
4320 uint32_t timeout = bypass_timeout;
4323 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4324 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4325 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4326 {"UNKNOWN", "normal", "bypass", "isolate"};
4327 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4334 int num_events = (sizeof events) / (sizeof events[0]);
4336 /* Display the bypass mode.*/
4337 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4338 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4342 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4343 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4345 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4348 /* Display the bypass timeout.*/
4349 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4350 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4352 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4354 /* Display the bypass events and associated modes. */
4355 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4357 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4358 printf("\tFailed to get bypass mode for event = %s\n",
4361 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4362 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4364 printf("\tbypass event: %-16s = %s\n", events[i],
4370 printf("\tFailed to get bypass configuration for port = %d\n",
4374 cmdline_parse_token_string_t cmd_showbypass_config_show =
4375 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4377 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4378 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4380 cmdline_parse_token_string_t cmd_showbypass_config_config =
4381 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4383 cmdline_parse_token_num_t cmd_showbypass_config_port =
4384 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4387 cmdline_parse_inst_t cmd_show_bypass_config = {
4388 .f = cmd_show_bypass_config_parsed,
4389 .help_str = "show bypass config <port_id>: "
4390 "Show the NIC bypass config for port_id",
4393 (void *)&cmd_showbypass_config_show,
4394 (void *)&cmd_showbypass_config_bypass,
4395 (void *)&cmd_showbypass_config_config,
4396 (void *)&cmd_showbypass_config_port,
4401 #ifdef RTE_LIBRTE_PMD_BOND
4402 /* *** SET BONDING MODE *** */
4403 struct cmd_set_bonding_mode_result {
4404 cmdline_fixed_string_t set;
4405 cmdline_fixed_string_t bonding;
4406 cmdline_fixed_string_t mode;
4411 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4412 __attribute__((unused)) struct cmdline *cl,
4413 __attribute__((unused)) void *data)
4415 struct cmd_set_bonding_mode_result *res = parsed_result;
4416 portid_t port_id = res->port_id;
4418 /* Set the bonding mode for the relevant port. */
4419 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4420 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4423 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4424 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4426 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4427 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4428 bonding, "bonding");
4429 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4430 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4432 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4433 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4435 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4436 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4439 cmdline_parse_inst_t cmd_set_bonding_mode = {
4440 .f = cmd_set_bonding_mode_parsed,
4441 .help_str = "set bonding mode <mode_value> <port_id>: "
4442 "Set the bonding mode for port_id",
4445 (void *) &cmd_setbonding_mode_set,
4446 (void *) &cmd_setbonding_mode_bonding,
4447 (void *) &cmd_setbonding_mode_mode,
4448 (void *) &cmd_setbonding_mode_value,
4449 (void *) &cmd_setbonding_mode_port,
4454 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4455 struct cmd_set_bonding_lacp_dedicated_queues_result {
4456 cmdline_fixed_string_t set;
4457 cmdline_fixed_string_t bonding;
4458 cmdline_fixed_string_t lacp;
4459 cmdline_fixed_string_t dedicated_queues;
4461 cmdline_fixed_string_t mode;
4464 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4465 __attribute__((unused)) struct cmdline *cl,
4466 __attribute__((unused)) void *data)
4468 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4469 portid_t port_id = res->port_id;
4470 struct rte_port *port;
4472 port = &ports[port_id];
4474 /** Check if the port is not started **/
4475 if (port->port_status != RTE_PORT_STOPPED) {
4476 printf("Please stop port %d first\n", port_id);
4480 if (!strcmp(res->mode, "enable")) {
4481 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4482 printf("Dedicate queues for LACP control packets"
4485 printf("Enabling dedicate queues for LACP control "
4486 "packets on port %d failed\n", port_id);
4487 } else if (!strcmp(res->mode, "disable")) {
4488 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4489 printf("Dedicated queues for LACP control packets "
4492 printf("Disabling dedicated queues for LACP control "
4493 "traffic on port %d failed\n", port_id);
4497 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4498 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4500 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4501 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4502 bonding, "bonding");
4503 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4504 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4506 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4507 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4508 dedicated_queues, "dedicated_queues");
4509 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4510 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4512 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4513 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4514 mode, "enable#disable");
4516 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4517 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4518 .help_str = "set bonding lacp dedicated_queues <port_id> "
4520 "Enable/disable dedicated queues for LACP control traffic for port_id",
4523 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4524 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4525 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4526 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4527 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4528 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4533 /* *** SET BALANCE XMIT POLICY *** */
4534 struct cmd_set_bonding_balance_xmit_policy_result {
4535 cmdline_fixed_string_t set;
4536 cmdline_fixed_string_t bonding;
4537 cmdline_fixed_string_t balance_xmit_policy;
4539 cmdline_fixed_string_t policy;
4542 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4543 __attribute__((unused)) struct cmdline *cl,
4544 __attribute__((unused)) void *data)
4546 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4547 portid_t port_id = res->port_id;
4550 if (!strcmp(res->policy, "l2")) {
4551 policy = BALANCE_XMIT_POLICY_LAYER2;
4552 } else if (!strcmp(res->policy, "l23")) {
4553 policy = BALANCE_XMIT_POLICY_LAYER23;
4554 } else if (!strcmp(res->policy, "l34")) {
4555 policy = BALANCE_XMIT_POLICY_LAYER34;
4557 printf("\t Invalid xmit policy selection");
4561 /* Set the bonding mode for the relevant port. */
4562 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4563 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4568 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4569 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4571 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4572 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4573 bonding, "bonding");
4574 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4575 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4576 balance_xmit_policy, "balance_xmit_policy");
4577 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4578 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4580 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4581 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4582 policy, "l2#l23#l34");
4584 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4585 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4586 .help_str = "set bonding balance_xmit_policy <port_id> "
4588 "Set the bonding balance_xmit_policy for port_id",
4591 (void *)&cmd_setbonding_balance_xmit_policy_set,
4592 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4593 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4594 (void *)&cmd_setbonding_balance_xmit_policy_port,
4595 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4600 /* *** SHOW NIC BONDING CONFIGURATION *** */
4601 struct cmd_show_bonding_config_result {
4602 cmdline_fixed_string_t show;
4603 cmdline_fixed_string_t bonding;
4604 cmdline_fixed_string_t config;
4608 static void cmd_show_bonding_config_parsed(void *parsed_result,
4609 __attribute__((unused)) struct cmdline *cl,
4610 __attribute__((unused)) void *data)
4612 struct cmd_show_bonding_config_result *res = parsed_result;
4613 int bonding_mode, agg_mode;
4614 uint8_t slaves[RTE_MAX_ETHPORTS];
4615 int num_slaves, num_active_slaves;
4618 portid_t port_id = res->port_id;
4620 /* Display the bonding mode.*/
4621 bonding_mode = rte_eth_bond_mode_get(port_id);
4622 if (bonding_mode < 0) {
4623 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4626 printf("\tBonding mode: %d\n", bonding_mode);
4628 if (bonding_mode == BONDING_MODE_BALANCE) {
4629 int balance_xmit_policy;
4631 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4632 if (balance_xmit_policy < 0) {
4633 printf("\tFailed to get balance xmit policy for port = %d\n",
4637 printf("\tBalance Xmit Policy: ");
4639 switch (balance_xmit_policy) {
4640 case BALANCE_XMIT_POLICY_LAYER2:
4641 printf("BALANCE_XMIT_POLICY_LAYER2");
4643 case BALANCE_XMIT_POLICY_LAYER23:
4644 printf("BALANCE_XMIT_POLICY_LAYER23");
4646 case BALANCE_XMIT_POLICY_LAYER34:
4647 printf("BALANCE_XMIT_POLICY_LAYER34");
4654 if (bonding_mode == BONDING_MODE_8023AD) {
4655 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
4656 printf("\tIEEE802.3AD Aggregator Mode: ");
4659 printf("bandwidth");
4671 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4673 if (num_slaves < 0) {
4674 printf("\tFailed to get slave list for port = %d\n", port_id);
4677 if (num_slaves > 0) {
4678 printf("\tSlaves (%d): [", num_slaves);
4679 for (i = 0; i < num_slaves - 1; i++)
4680 printf("%d ", slaves[i]);
4682 printf("%d]\n", slaves[num_slaves - 1]);
4684 printf("\tSlaves: []\n");
4688 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4691 if (num_active_slaves < 0) {
4692 printf("\tFailed to get active slave list for port = %d\n", port_id);
4695 if (num_active_slaves > 0) {
4696 printf("\tActive Slaves (%d): [", num_active_slaves);
4697 for (i = 0; i < num_active_slaves - 1; i++)
4698 printf("%d ", slaves[i]);
4700 printf("%d]\n", slaves[num_active_slaves - 1]);
4703 printf("\tActive Slaves: []\n");
4707 primary_id = rte_eth_bond_primary_get(port_id);
4708 if (primary_id < 0) {
4709 printf("\tFailed to get primary slave for port = %d\n", port_id);
4712 printf("\tPrimary: [%d]\n", primary_id);
4716 cmdline_parse_token_string_t cmd_showbonding_config_show =
4717 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4719 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4720 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4721 bonding, "bonding");
4722 cmdline_parse_token_string_t cmd_showbonding_config_config =
4723 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4725 cmdline_parse_token_num_t cmd_showbonding_config_port =
4726 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4729 cmdline_parse_inst_t cmd_show_bonding_config = {
4730 .f = cmd_show_bonding_config_parsed,
4731 .help_str = "show bonding config <port_id>: "
4732 "Show the bonding config for port_id",
4735 (void *)&cmd_showbonding_config_show,
4736 (void *)&cmd_showbonding_config_bonding,
4737 (void *)&cmd_showbonding_config_config,
4738 (void *)&cmd_showbonding_config_port,
4743 /* *** SET BONDING PRIMARY *** */
4744 struct cmd_set_bonding_primary_result {
4745 cmdline_fixed_string_t set;
4746 cmdline_fixed_string_t bonding;
4747 cmdline_fixed_string_t primary;
4752 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4753 __attribute__((unused)) struct cmdline *cl,
4754 __attribute__((unused)) void *data)
4756 struct cmd_set_bonding_primary_result *res = parsed_result;
4757 portid_t master_port_id = res->port_id;
4758 portid_t slave_port_id = res->slave_id;
4760 /* Set the primary slave for a bonded device. */
4761 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4762 printf("\t Failed to set primary slave for port = %d.\n",
4769 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4770 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4772 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4773 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4774 bonding, "bonding");
4775 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4776 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4777 primary, "primary");
4778 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4779 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4781 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4782 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4785 cmdline_parse_inst_t cmd_set_bonding_primary = {
4786 .f = cmd_set_bonding_primary_parsed,
4787 .help_str = "set bonding primary <slave_id> <port_id>: "
4788 "Set the primary slave for port_id",
4791 (void *)&cmd_setbonding_primary_set,
4792 (void *)&cmd_setbonding_primary_bonding,
4793 (void *)&cmd_setbonding_primary_primary,
4794 (void *)&cmd_setbonding_primary_slave,
4795 (void *)&cmd_setbonding_primary_port,
4800 /* *** ADD SLAVE *** */
4801 struct cmd_add_bonding_slave_result {
4802 cmdline_fixed_string_t add;
4803 cmdline_fixed_string_t bonding;
4804 cmdline_fixed_string_t slave;
4809 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4810 __attribute__((unused)) struct cmdline *cl,
4811 __attribute__((unused)) void *data)
4813 struct cmd_add_bonding_slave_result *res = parsed_result;
4814 portid_t master_port_id = res->port_id;
4815 portid_t slave_port_id = res->slave_id;
4817 /* add the slave for a bonded device. */
4818 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4819 printf("\t Failed to add slave %d to master port = %d.\n",
4820 slave_port_id, master_port_id);
4824 set_port_slave_flag(slave_port_id);
4827 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4828 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4830 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4831 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4832 bonding, "bonding");
4833 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4834 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4836 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4837 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4839 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4840 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4843 cmdline_parse_inst_t cmd_add_bonding_slave = {
4844 .f = cmd_add_bonding_slave_parsed,
4845 .help_str = "add bonding slave <slave_id> <port_id>: "
4846 "Add a slave device to a bonded device",
4849 (void *)&cmd_addbonding_slave_add,
4850 (void *)&cmd_addbonding_slave_bonding,
4851 (void *)&cmd_addbonding_slave_slave,
4852 (void *)&cmd_addbonding_slave_slaveid,
4853 (void *)&cmd_addbonding_slave_port,
4858 /* *** REMOVE SLAVE *** */
4859 struct cmd_remove_bonding_slave_result {
4860 cmdline_fixed_string_t remove;
4861 cmdline_fixed_string_t bonding;
4862 cmdline_fixed_string_t slave;
4867 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4868 __attribute__((unused)) struct cmdline *cl,
4869 __attribute__((unused)) void *data)
4871 struct cmd_remove_bonding_slave_result *res = parsed_result;
4872 portid_t master_port_id = res->port_id;
4873 portid_t slave_port_id = res->slave_id;
4875 /* remove the slave from a bonded device. */
4876 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4877 printf("\t Failed to remove slave %d from master port = %d.\n",
4878 slave_port_id, master_port_id);
4882 clear_port_slave_flag(slave_port_id);
4885 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4886 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4888 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4889 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4890 bonding, "bonding");
4891 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4892 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4894 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4895 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4897 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4898 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4901 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4902 .f = cmd_remove_bonding_slave_parsed,
4903 .help_str = "remove bonding slave <slave_id> <port_id>: "
4904 "Remove a slave device from a bonded device",
4907 (void *)&cmd_removebonding_slave_remove,
4908 (void *)&cmd_removebonding_slave_bonding,
4909 (void *)&cmd_removebonding_slave_slave,
4910 (void *)&cmd_removebonding_slave_slaveid,
4911 (void *)&cmd_removebonding_slave_port,
4916 /* *** CREATE BONDED DEVICE *** */
4917 struct cmd_create_bonded_device_result {
4918 cmdline_fixed_string_t create;
4919 cmdline_fixed_string_t bonded;
4920 cmdline_fixed_string_t device;
4925 static int bond_dev_num = 0;
4927 static void cmd_create_bonded_device_parsed(void *parsed_result,
4928 __attribute__((unused)) struct cmdline *cl,
4929 __attribute__((unused)) void *data)
4931 struct cmd_create_bonded_device_result *res = parsed_result;
4932 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4935 if (test_done == 0) {
4936 printf("Please stop forwarding first\n");
4940 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
4943 /* Create a new bonded device. */
4944 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4946 printf("\t Failed to create bonded device.\n");
4949 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4952 /* Update number of ports */
4953 nb_ports = rte_eth_dev_count();
4954 reconfig(port_id, res->socket);
4955 rte_eth_promiscuous_enable(port_id);
4960 cmdline_parse_token_string_t cmd_createbonded_device_create =
4961 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4963 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4964 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4966 cmdline_parse_token_string_t cmd_createbonded_device_device =
4967 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4969 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4970 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4972 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4973 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4976 cmdline_parse_inst_t cmd_create_bonded_device = {
4977 .f = cmd_create_bonded_device_parsed,
4978 .help_str = "create bonded device <mode> <socket>: "
4979 "Create a new bonded device with specific bonding mode and socket",
4982 (void *)&cmd_createbonded_device_create,
4983 (void *)&cmd_createbonded_device_bonded,
4984 (void *)&cmd_createbonded_device_device,
4985 (void *)&cmd_createbonded_device_mode,
4986 (void *)&cmd_createbonded_device_socket,
4991 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4992 struct cmd_set_bond_mac_addr_result {
4993 cmdline_fixed_string_t set;
4994 cmdline_fixed_string_t bonding;
4995 cmdline_fixed_string_t mac_addr;
4997 struct ether_addr address;
5000 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5001 __attribute__((unused)) struct cmdline *cl,
5002 __attribute__((unused)) void *data)
5004 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5007 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5010 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5012 /* check the return value and print it if is < 0 */
5014 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5017 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5018 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5019 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5020 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5022 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5023 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5025 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5026 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
5027 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5028 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5030 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5031 .f = cmd_set_bond_mac_addr_parsed,
5033 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5035 (void *)&cmd_set_bond_mac_addr_set,
5036 (void *)&cmd_set_bond_mac_addr_bonding,
5037 (void *)&cmd_set_bond_mac_addr_mac,
5038 (void *)&cmd_set_bond_mac_addr_portnum,
5039 (void *)&cmd_set_bond_mac_addr_addr,
5045 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5046 struct cmd_set_bond_mon_period_result {
5047 cmdline_fixed_string_t set;
5048 cmdline_fixed_string_t bonding;
5049 cmdline_fixed_string_t mon_period;
5054 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5055 __attribute__((unused)) struct cmdline *cl,
5056 __attribute__((unused)) void *data)
5058 struct cmd_set_bond_mon_period_result *res = parsed_result;
5061 if (res->port_num >= nb_ports) {
5062 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5066 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5068 /* check the return value and print it if is < 0 */
5070 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5073 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5074 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5076 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5077 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5078 bonding, "bonding");
5079 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5080 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5081 mon_period, "mon_period");
5082 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5083 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5085 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5086 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5089 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5090 .f = cmd_set_bond_mon_period_parsed,
5092 .help_str = "set bonding mon_period <port_id> <period_ms>",
5094 (void *)&cmd_set_bond_mon_period_set,
5095 (void *)&cmd_set_bond_mon_period_bonding,
5096 (void *)&cmd_set_bond_mon_period_mon_period,
5097 (void *)&cmd_set_bond_mon_period_portnum,
5098 (void *)&cmd_set_bond_mon_period_period_ms,
5105 struct cmd_set_bonding_agg_mode_policy_result {
5106 cmdline_fixed_string_t set;
5107 cmdline_fixed_string_t bonding;
5108 cmdline_fixed_string_t agg_mode;
5110 cmdline_fixed_string_t policy;
5115 cmd_set_bonding_agg_mode(void *parsed_result,
5116 __attribute__((unused)) struct cmdline *cl,
5117 __attribute__((unused)) void *data)
5119 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5120 uint8_t policy = AGG_BANDWIDTH;
5122 if (res->port_num >= nb_ports) {
5123 printf("Port id %d must be less than %d\n",
5124 res->port_num, nb_ports);
5128 if (!strcmp(res->policy, "bandwidth"))
5129 policy = AGG_BANDWIDTH;
5130 else if (!strcmp(res->policy, "stable"))
5131 policy = AGG_STABLE;
5132 else if (!strcmp(res->policy, "count"))
5135 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5139 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5140 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5142 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5143 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5144 bonding, "bonding");
5146 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5147 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5148 agg_mode, "agg_mode");
5150 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5151 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5154 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5155 TOKEN_STRING_INITIALIZER(
5156 struct cmd_set_bonding_balance_xmit_policy_result,
5157 policy, "stable#bandwidth#count");
5159 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5160 .f = cmd_set_bonding_agg_mode,
5162 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5164 (void *)&cmd_set_bonding_agg_mode_set,
5165 (void *)&cmd_set_bonding_agg_mode_bonding,
5166 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5167 (void *)&cmd_set_bonding_agg_mode_portnum,
5168 (void *)&cmd_set_bonding_agg_mode_policy_string,
5174 #endif /* RTE_LIBRTE_PMD_BOND */
5176 /* *** SET FORWARDING MODE *** */
5177 struct cmd_set_fwd_mode_result {
5178 cmdline_fixed_string_t set;
5179 cmdline_fixed_string_t fwd;
5180 cmdline_fixed_string_t mode;
5183 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5184 __attribute__((unused)) struct cmdline *cl,
5185 __attribute__((unused)) void *data)
5187 struct cmd_set_fwd_mode_result *res = parsed_result;
5190 set_pkt_forwarding_mode(res->mode);
5193 cmdline_parse_token_string_t cmd_setfwd_set =
5194 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5195 cmdline_parse_token_string_t cmd_setfwd_fwd =
5196 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5197 cmdline_parse_token_string_t cmd_setfwd_mode =
5198 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5199 "" /* defined at init */);
5201 cmdline_parse_inst_t cmd_set_fwd_mode = {
5202 .f = cmd_set_fwd_mode_parsed,
5204 .help_str = NULL, /* defined at init */
5206 (void *)&cmd_setfwd_set,
5207 (void *)&cmd_setfwd_fwd,
5208 (void *)&cmd_setfwd_mode,
5213 static void cmd_set_fwd_mode_init(void)
5216 static char token[128];
5217 static char help[256];
5218 cmdline_parse_token_string_t *token_struct;
5220 modes = list_pkt_forwarding_modes();
5221 snprintf(help, sizeof(help), "set fwd %s: "
5222 "Set packet forwarding mode", modes);
5223 cmd_set_fwd_mode.help_str = help;
5225 /* string token separator is # */
5226 for (c = token; *modes != '\0'; modes++)
5231 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5232 token_struct->string_data.str = token;
5235 /* *** SET RETRY FORWARDING MODE *** */
5236 struct cmd_set_fwd_retry_mode_result {
5237 cmdline_fixed_string_t set;
5238 cmdline_fixed_string_t fwd;
5239 cmdline_fixed_string_t mode;
5240 cmdline_fixed_string_t retry;
5243 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5244 __attribute__((unused)) struct cmdline *cl,
5245 __attribute__((unused)) void *data)
5247 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5250 set_pkt_forwarding_mode(res->mode);
5253 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5254 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5256 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5257 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5259 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5260 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5262 "" /* defined at init */);
5263 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5264 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5267 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5268 .f = cmd_set_fwd_retry_mode_parsed,
5270 .help_str = NULL, /* defined at init */
5272 (void *)&cmd_setfwd_retry_set,
5273 (void *)&cmd_setfwd_retry_fwd,
5274 (void *)&cmd_setfwd_retry_mode,
5275 (void *)&cmd_setfwd_retry_retry,
5280 static void cmd_set_fwd_retry_mode_init(void)
5283 static char token[128];
5284 static char help[256];
5285 cmdline_parse_token_string_t *token_struct;
5287 modes = list_pkt_forwarding_retry_modes();
5288 snprintf(help, sizeof(help), "set fwd %s retry: "
5289 "Set packet forwarding mode with retry", modes);
5290 cmd_set_fwd_retry_mode.help_str = help;
5292 /* string token separator is # */
5293 for (c = token; *modes != '\0'; modes++)
5298 token_struct = (cmdline_parse_token_string_t *)
5299 cmd_set_fwd_retry_mode.tokens[2];
5300 token_struct->string_data.str = token;
5303 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5304 struct cmd_set_burst_tx_retry_result {
5305 cmdline_fixed_string_t set;
5306 cmdline_fixed_string_t burst;
5307 cmdline_fixed_string_t tx;
5308 cmdline_fixed_string_t delay;
5310 cmdline_fixed_string_t retry;
5314 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5315 __attribute__((unused)) struct cmdline *cl,
5316 __attribute__((unused)) void *data)
5318 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5320 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5321 && !strcmp(res->tx, "tx")) {
5322 if (!strcmp(res->delay, "delay"))
5323 burst_tx_delay_time = res->time;
5324 if (!strcmp(res->retry, "retry"))
5325 burst_tx_retry_num = res->retry_num;
5330 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5331 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5332 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5333 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5335 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5336 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5337 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5338 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5339 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5340 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5341 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5342 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5343 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5344 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5346 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5347 .f = cmd_set_burst_tx_retry_parsed,
5348 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5350 (void *)&cmd_set_burst_tx_retry_set,
5351 (void *)&cmd_set_burst_tx_retry_burst,
5352 (void *)&cmd_set_burst_tx_retry_tx,
5353 (void *)&cmd_set_burst_tx_retry_delay,
5354 (void *)&cmd_set_burst_tx_retry_time,
5355 (void *)&cmd_set_burst_tx_retry_retry,
5356 (void *)&cmd_set_burst_tx_retry_retry_num,
5361 /* *** SET PROMISC MODE *** */
5362 struct cmd_set_promisc_mode_result {
5363 cmdline_fixed_string_t set;
5364 cmdline_fixed_string_t promisc;
5365 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5366 uint8_t port_num; /* valid if "allports" argument == 0 */
5367 cmdline_fixed_string_t mode;
5370 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5371 __attribute__((unused)) struct cmdline *cl,
5374 struct cmd_set_promisc_mode_result *res = parsed_result;
5378 if (!strcmp(res->mode, "on"))
5385 RTE_ETH_FOREACH_DEV(i) {
5387 rte_eth_promiscuous_enable(i);
5389 rte_eth_promiscuous_disable(i);
5394 rte_eth_promiscuous_enable(res->port_num);
5396 rte_eth_promiscuous_disable(res->port_num);
5400 cmdline_parse_token_string_t cmd_setpromisc_set =
5401 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5402 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5403 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5405 cmdline_parse_token_string_t cmd_setpromisc_portall =
5406 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5408 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5409 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5411 cmdline_parse_token_string_t cmd_setpromisc_mode =
5412 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5415 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5416 .f = cmd_set_promisc_mode_parsed,
5418 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5420 (void *)&cmd_setpromisc_set,
5421 (void *)&cmd_setpromisc_promisc,
5422 (void *)&cmd_setpromisc_portall,
5423 (void *)&cmd_setpromisc_mode,
5428 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5429 .f = cmd_set_promisc_mode_parsed,
5431 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5433 (void *)&cmd_setpromisc_set,
5434 (void *)&cmd_setpromisc_promisc,
5435 (void *)&cmd_setpromisc_portnum,
5436 (void *)&cmd_setpromisc_mode,
5441 /* *** SET ALLMULTI MODE *** */
5442 struct cmd_set_allmulti_mode_result {
5443 cmdline_fixed_string_t set;
5444 cmdline_fixed_string_t allmulti;
5445 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5446 uint8_t port_num; /* valid if "allports" argument == 0 */
5447 cmdline_fixed_string_t mode;
5450 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5451 __attribute__((unused)) struct cmdline *cl,
5454 struct cmd_set_allmulti_mode_result *res = parsed_result;
5458 if (!strcmp(res->mode, "on"))
5465 RTE_ETH_FOREACH_DEV(i) {
5467 rte_eth_allmulticast_enable(i);
5469 rte_eth_allmulticast_disable(i);
5474 rte_eth_allmulticast_enable(res->port_num);
5476 rte_eth_allmulticast_disable(res->port_num);
5480 cmdline_parse_token_string_t cmd_setallmulti_set =
5481 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5482 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5483 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5485 cmdline_parse_token_string_t cmd_setallmulti_portall =
5486 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5488 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5489 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5491 cmdline_parse_token_string_t cmd_setallmulti_mode =
5492 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5495 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5496 .f = cmd_set_allmulti_mode_parsed,
5498 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5500 (void *)&cmd_setallmulti_set,
5501 (void *)&cmd_setallmulti_allmulti,
5502 (void *)&cmd_setallmulti_portall,
5503 (void *)&cmd_setallmulti_mode,
5508 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5509 .f = cmd_set_allmulti_mode_parsed,
5511 .help_str = "set allmulti <port_id> on|off: "
5512 "Set allmulti mode on port_id",
5514 (void *)&cmd_setallmulti_set,
5515 (void *)&cmd_setallmulti_allmulti,
5516 (void *)&cmd_setallmulti_portnum,
5517 (void *)&cmd_setallmulti_mode,
5522 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5523 struct cmd_link_flow_ctrl_set_result {
5524 cmdline_fixed_string_t set;
5525 cmdline_fixed_string_t flow_ctrl;
5526 cmdline_fixed_string_t rx;
5527 cmdline_fixed_string_t rx_lfc_mode;
5528 cmdline_fixed_string_t tx;
5529 cmdline_fixed_string_t tx_lfc_mode;
5530 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5531 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5532 cmdline_fixed_string_t autoneg_str;
5533 cmdline_fixed_string_t autoneg;
5534 cmdline_fixed_string_t hw_str;
5535 uint32_t high_water;
5536 cmdline_fixed_string_t lw_str;
5538 cmdline_fixed_string_t pt_str;
5539 uint16_t pause_time;
5540 cmdline_fixed_string_t xon_str;
5545 cmdline_parse_token_string_t cmd_lfc_set_set =
5546 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5548 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5549 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5550 flow_ctrl, "flow_ctrl");
5551 cmdline_parse_token_string_t cmd_lfc_set_rx =
5552 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5554 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5555 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5556 rx_lfc_mode, "on#off");
5557 cmdline_parse_token_string_t cmd_lfc_set_tx =
5558 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5560 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5561 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5562 tx_lfc_mode, "on#off");
5563 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5564 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5565 hw_str, "high_water");
5566 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5567 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5568 high_water, UINT32);
5569 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5570 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5571 lw_str, "low_water");
5572 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5573 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5575 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5576 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5577 pt_str, "pause_time");
5578 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5579 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5580 pause_time, UINT16);
5581 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5582 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5583 xon_str, "send_xon");
5584 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5585 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5587 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5588 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5589 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5590 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5591 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5592 mac_ctrl_frame_fwd_mode, "on#off");
5593 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5594 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5595 autoneg_str, "autoneg");
5596 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5597 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5599 cmdline_parse_token_num_t cmd_lfc_set_portid =
5600 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5603 /* forward declaration */
5605 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5608 cmdline_parse_inst_t cmd_link_flow_control_set = {
5609 .f = cmd_link_flow_ctrl_set_parsed,
5611 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5612 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5613 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5615 (void *)&cmd_lfc_set_set,
5616 (void *)&cmd_lfc_set_flow_ctrl,
5617 (void *)&cmd_lfc_set_rx,
5618 (void *)&cmd_lfc_set_rx_mode,
5619 (void *)&cmd_lfc_set_tx,
5620 (void *)&cmd_lfc_set_tx_mode,
5621 (void *)&cmd_lfc_set_high_water,
5622 (void *)&cmd_lfc_set_low_water,
5623 (void *)&cmd_lfc_set_pause_time,
5624 (void *)&cmd_lfc_set_send_xon,
5625 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5626 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5627 (void *)&cmd_lfc_set_autoneg_str,
5628 (void *)&cmd_lfc_set_autoneg,
5629 (void *)&cmd_lfc_set_portid,
5634 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5635 .f = cmd_link_flow_ctrl_set_parsed,
5636 .data = (void *)&cmd_link_flow_control_set_rx,
5637 .help_str = "set flow_ctrl rx on|off <port_id>: "
5638 "Change rx flow control parameter",
5640 (void *)&cmd_lfc_set_set,
5641 (void *)&cmd_lfc_set_flow_ctrl,
5642 (void *)&cmd_lfc_set_rx,
5643 (void *)&cmd_lfc_set_rx_mode,
5644 (void *)&cmd_lfc_set_portid,
5649 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5650 .f = cmd_link_flow_ctrl_set_parsed,
5651 .data = (void *)&cmd_link_flow_control_set_tx,
5652 .help_str = "set flow_ctrl tx on|off <port_id>: "
5653 "Change tx flow control parameter",
5655 (void *)&cmd_lfc_set_set,
5656 (void *)&cmd_lfc_set_flow_ctrl,
5657 (void *)&cmd_lfc_set_tx,
5658 (void *)&cmd_lfc_set_tx_mode,
5659 (void *)&cmd_lfc_set_portid,
5664 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5665 .f = cmd_link_flow_ctrl_set_parsed,
5666 .data = (void *)&cmd_link_flow_control_set_hw,
5667 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5668 "Change high water flow control parameter",
5670 (void *)&cmd_lfc_set_set,
5671 (void *)&cmd_lfc_set_flow_ctrl,
5672 (void *)&cmd_lfc_set_high_water_str,
5673 (void *)&cmd_lfc_set_high_water,
5674 (void *)&cmd_lfc_set_portid,
5679 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5680 .f = cmd_link_flow_ctrl_set_parsed,
5681 .data = (void *)&cmd_link_flow_control_set_lw,
5682 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5683 "Change low water flow control parameter",
5685 (void *)&cmd_lfc_set_set,
5686 (void *)&cmd_lfc_set_flow_ctrl,
5687 (void *)&cmd_lfc_set_low_water_str,
5688 (void *)&cmd_lfc_set_low_water,
5689 (void *)&cmd_lfc_set_portid,
5694 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5695 .f = cmd_link_flow_ctrl_set_parsed,
5696 .data = (void *)&cmd_link_flow_control_set_pt,
5697 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5698 "Change pause time flow control parameter",
5700 (void *)&cmd_lfc_set_set,
5701 (void *)&cmd_lfc_set_flow_ctrl,
5702 (void *)&cmd_lfc_set_pause_time_str,
5703 (void *)&cmd_lfc_set_pause_time,
5704 (void *)&cmd_lfc_set_portid,
5709 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5710 .f = cmd_link_flow_ctrl_set_parsed,
5711 .data = (void *)&cmd_link_flow_control_set_xon,
5712 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5713 "Change send_xon flow control parameter",
5715 (void *)&cmd_lfc_set_set,
5716 (void *)&cmd_lfc_set_flow_ctrl,
5717 (void *)&cmd_lfc_set_send_xon_str,
5718 (void *)&cmd_lfc_set_send_xon,
5719 (void *)&cmd_lfc_set_portid,
5724 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5725 .f = cmd_link_flow_ctrl_set_parsed,
5726 .data = (void *)&cmd_link_flow_control_set_macfwd,
5727 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5728 "Change mac ctrl fwd flow control parameter",
5730 (void *)&cmd_lfc_set_set,
5731 (void *)&cmd_lfc_set_flow_ctrl,
5732 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5733 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5734 (void *)&cmd_lfc_set_portid,
5739 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5740 .f = cmd_link_flow_ctrl_set_parsed,
5741 .data = (void *)&cmd_link_flow_control_set_autoneg,
5742 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5743 "Change autoneg flow control parameter",
5745 (void *)&cmd_lfc_set_set,
5746 (void *)&cmd_lfc_set_flow_ctrl,
5747 (void *)&cmd_lfc_set_autoneg_str,
5748 (void *)&cmd_lfc_set_autoneg,
5749 (void *)&cmd_lfc_set_portid,
5755 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5756 __attribute__((unused)) struct cmdline *cl,
5759 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5760 cmdline_parse_inst_t *cmd = data;
5761 struct rte_eth_fc_conf fc_conf;
5767 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5768 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5769 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5770 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5772 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5773 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5776 /* Partial command line, retrieve current configuration */
5778 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5780 printf("cannot get current flow ctrl parameters, return"
5781 "code = %d\n", ret);
5785 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5786 (fc_conf.mode == RTE_FC_FULL))
5788 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5789 (fc_conf.mode == RTE_FC_FULL))
5793 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5794 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5796 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5797 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5799 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5801 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5802 fc_conf.high_water = res->high_water;
5804 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5805 fc_conf.low_water = res->low_water;
5807 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5808 fc_conf.pause_time = res->pause_time;
5810 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5811 fc_conf.send_xon = res->send_xon;
5813 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5814 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5815 fc_conf.mac_ctrl_frame_fwd = 1;
5817 fc_conf.mac_ctrl_frame_fwd = 0;
5820 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5821 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5823 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5825 printf("bad flow contrl parameter, return code = %d \n", ret);
5828 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5829 struct cmd_priority_flow_ctrl_set_result {
5830 cmdline_fixed_string_t set;
5831 cmdline_fixed_string_t pfc_ctrl;
5832 cmdline_fixed_string_t rx;
5833 cmdline_fixed_string_t rx_pfc_mode;
5834 cmdline_fixed_string_t tx;
5835 cmdline_fixed_string_t tx_pfc_mode;
5836 uint32_t high_water;
5838 uint16_t pause_time;
5844 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5845 __attribute__((unused)) struct cmdline *cl,
5846 __attribute__((unused)) void *data)
5848 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5849 struct rte_eth_pfc_conf pfc_conf;
5850 int rx_fc_enable, tx_fc_enable;
5854 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5855 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5856 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5857 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5859 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5860 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5863 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5864 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5865 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5866 pfc_conf.fc.high_water = res->high_water;
5867 pfc_conf.fc.low_water = res->low_water;
5868 pfc_conf.fc.pause_time = res->pause_time;
5869 pfc_conf.priority = res->priority;
5871 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5873 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5876 cmdline_parse_token_string_t cmd_pfc_set_set =
5877 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5879 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5880 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5881 pfc_ctrl, "pfc_ctrl");
5882 cmdline_parse_token_string_t cmd_pfc_set_rx =
5883 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5885 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5886 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5887 rx_pfc_mode, "on#off");
5888 cmdline_parse_token_string_t cmd_pfc_set_tx =
5889 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5891 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5892 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5893 tx_pfc_mode, "on#off");
5894 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5895 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5896 high_water, UINT32);
5897 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5898 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5900 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5901 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5902 pause_time, UINT16);
5903 cmdline_parse_token_num_t cmd_pfc_set_priority =
5904 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5906 cmdline_parse_token_num_t cmd_pfc_set_portid =
5907 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5910 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5911 .f = cmd_priority_flow_ctrl_set_parsed,
5913 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5914 "<pause_time> <priority> <port_id>: "
5915 "Configure the Ethernet priority flow control",
5917 (void *)&cmd_pfc_set_set,
5918 (void *)&cmd_pfc_set_flow_ctrl,
5919 (void *)&cmd_pfc_set_rx,
5920 (void *)&cmd_pfc_set_rx_mode,
5921 (void *)&cmd_pfc_set_tx,
5922 (void *)&cmd_pfc_set_tx_mode,
5923 (void *)&cmd_pfc_set_high_water,
5924 (void *)&cmd_pfc_set_low_water,
5925 (void *)&cmd_pfc_set_pause_time,
5926 (void *)&cmd_pfc_set_priority,
5927 (void *)&cmd_pfc_set_portid,
5932 /* *** RESET CONFIGURATION *** */
5933 struct cmd_reset_result {
5934 cmdline_fixed_string_t reset;
5935 cmdline_fixed_string_t def;
5938 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5940 __attribute__((unused)) void *data)
5942 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5943 set_def_fwd_config();
5946 cmdline_parse_token_string_t cmd_reset_set =
5947 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5948 cmdline_parse_token_string_t cmd_reset_def =
5949 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5952 cmdline_parse_inst_t cmd_reset = {
5953 .f = cmd_reset_parsed,
5955 .help_str = "set default: Reset default forwarding configuration",
5957 (void *)&cmd_reset_set,
5958 (void *)&cmd_reset_def,
5963 /* *** START FORWARDING *** */
5964 struct cmd_start_result {
5965 cmdline_fixed_string_t start;
5968 cmdline_parse_token_string_t cmd_start_start =
5969 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5971 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5972 __attribute__((unused)) struct cmdline *cl,
5973 __attribute__((unused)) void *data)
5975 start_packet_forwarding(0);
5978 cmdline_parse_inst_t cmd_start = {
5979 .f = cmd_start_parsed,
5981 .help_str = "start: Start packet forwarding",
5983 (void *)&cmd_start_start,
5988 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5989 struct cmd_start_tx_first_result {
5990 cmdline_fixed_string_t start;
5991 cmdline_fixed_string_t tx_first;
5995 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5996 __attribute__((unused)) struct cmdline *cl,
5997 __attribute__((unused)) void *data)
5999 start_packet_forwarding(1);
6002 cmdline_parse_token_string_t cmd_start_tx_first_start =
6003 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6005 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6006 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6007 tx_first, "tx_first");
6009 cmdline_parse_inst_t cmd_start_tx_first = {
6010 .f = cmd_start_tx_first_parsed,
6012 .help_str = "start tx_first: Start packet forwarding, "
6013 "after sending 1 burst of packets",
6015 (void *)&cmd_start_tx_first_start,
6016 (void *)&cmd_start_tx_first_tx_first,
6021 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6022 struct cmd_start_tx_first_n_result {
6023 cmdline_fixed_string_t start;
6024 cmdline_fixed_string_t tx_first;
6029 cmd_start_tx_first_n_parsed(void *parsed_result,
6030 __attribute__((unused)) struct cmdline *cl,
6031 __attribute__((unused)) void *data)
6033 struct cmd_start_tx_first_n_result *res = parsed_result;
6035 start_packet_forwarding(res->tx_num);
6038 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6039 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6041 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6042 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6043 tx_first, "tx_first");
6044 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6045 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6048 cmdline_parse_inst_t cmd_start_tx_first_n = {
6049 .f = cmd_start_tx_first_n_parsed,
6051 .help_str = "start tx_first <num>: "
6052 "packet forwarding, after sending <num> bursts of packets",
6054 (void *)&cmd_start_tx_first_n_start,
6055 (void *)&cmd_start_tx_first_n_tx_first,
6056 (void *)&cmd_start_tx_first_n_tx_num,
6061 /* *** SET LINK UP *** */
6062 struct cmd_set_link_up_result {
6063 cmdline_fixed_string_t set;
6064 cmdline_fixed_string_t link_up;
6065 cmdline_fixed_string_t port;
6069 cmdline_parse_token_string_t cmd_set_link_up_set =
6070 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6071 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6072 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6074 cmdline_parse_token_string_t cmd_set_link_up_port =
6075 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6076 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6077 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
6079 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6080 __attribute__((unused)) struct cmdline *cl,
6081 __attribute__((unused)) void *data)
6083 struct cmd_set_link_up_result *res = parsed_result;
6084 dev_set_link_up(res->port_id);
6087 cmdline_parse_inst_t cmd_set_link_up = {
6088 .f = cmd_set_link_up_parsed,
6090 .help_str = "set link-up port <port id>",
6092 (void *)&cmd_set_link_up_set,
6093 (void *)&cmd_set_link_up_link_up,
6094 (void *)&cmd_set_link_up_port,
6095 (void *)&cmd_set_link_up_port_id,
6100 /* *** SET LINK DOWN *** */
6101 struct cmd_set_link_down_result {
6102 cmdline_fixed_string_t set;
6103 cmdline_fixed_string_t link_down;
6104 cmdline_fixed_string_t port;
6108 cmdline_parse_token_string_t cmd_set_link_down_set =
6109 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6110 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6111 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6113 cmdline_parse_token_string_t cmd_set_link_down_port =
6114 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6115 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6116 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
6118 static void cmd_set_link_down_parsed(
6119 __attribute__((unused)) void *parsed_result,
6120 __attribute__((unused)) struct cmdline *cl,
6121 __attribute__((unused)) void *data)
6123 struct cmd_set_link_down_result *res = parsed_result;
6124 dev_set_link_down(res->port_id);
6127 cmdline_parse_inst_t cmd_set_link_down = {
6128 .f = cmd_set_link_down_parsed,
6130 .help_str = "set link-down port <port id>",
6132 (void *)&cmd_set_link_down_set,
6133 (void *)&cmd_set_link_down_link_down,
6134 (void *)&cmd_set_link_down_port,
6135 (void *)&cmd_set_link_down_port_id,
6140 /* *** SHOW CFG *** */
6141 struct cmd_showcfg_result {
6142 cmdline_fixed_string_t show;
6143 cmdline_fixed_string_t cfg;
6144 cmdline_fixed_string_t what;
6147 static void cmd_showcfg_parsed(void *parsed_result,
6148 __attribute__((unused)) struct cmdline *cl,
6149 __attribute__((unused)) void *data)
6151 struct cmd_showcfg_result *res = parsed_result;
6152 if (!strcmp(res->what, "rxtx"))
6153 rxtx_config_display();
6154 else if (!strcmp(res->what, "cores"))
6155 fwd_lcores_config_display();
6156 else if (!strcmp(res->what, "fwd"))
6157 pkt_fwd_config_display(&cur_fwd_config);
6158 else if (!strcmp(res->what, "txpkts"))
6159 show_tx_pkt_segments();
6162 cmdline_parse_token_string_t cmd_showcfg_show =
6163 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6164 cmdline_parse_token_string_t cmd_showcfg_port =
6165 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6166 cmdline_parse_token_string_t cmd_showcfg_what =
6167 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6168 "rxtx#cores#fwd#txpkts");
6170 cmdline_parse_inst_t cmd_showcfg = {
6171 .f = cmd_showcfg_parsed,
6173 .help_str = "show config rxtx|cores|fwd|txpkts",
6175 (void *)&cmd_showcfg_show,
6176 (void *)&cmd_showcfg_port,
6177 (void *)&cmd_showcfg_what,
6182 /* *** SHOW ALL PORT INFO *** */
6183 struct cmd_showportall_result {
6184 cmdline_fixed_string_t show;
6185 cmdline_fixed_string_t port;
6186 cmdline_fixed_string_t what;
6187 cmdline_fixed_string_t all;
6190 static void cmd_showportall_parsed(void *parsed_result,
6191 __attribute__((unused)) struct cmdline *cl,
6192 __attribute__((unused)) void *data)
6196 struct cmd_showportall_result *res = parsed_result;
6197 if (!strcmp(res->show, "clear")) {
6198 if (!strcmp(res->what, "stats"))
6199 RTE_ETH_FOREACH_DEV(i)
6201 else if (!strcmp(res->what, "xstats"))
6202 RTE_ETH_FOREACH_DEV(i)
6203 nic_xstats_clear(i);
6204 } else if (!strcmp(res->what, "info"))
6205 RTE_ETH_FOREACH_DEV(i)
6206 port_infos_display(i);
6207 else if (!strcmp(res->what, "stats"))
6208 RTE_ETH_FOREACH_DEV(i)
6209 nic_stats_display(i);
6210 else if (!strcmp(res->what, "xstats"))
6211 RTE_ETH_FOREACH_DEV(i)
6212 nic_xstats_display(i);
6213 else if (!strcmp(res->what, "fdir"))
6214 RTE_ETH_FOREACH_DEV(i)
6216 else if (!strcmp(res->what, "stat_qmap"))
6217 RTE_ETH_FOREACH_DEV(i)
6218 nic_stats_mapping_display(i);
6219 else if (!strcmp(res->what, "dcb_tc"))
6220 RTE_ETH_FOREACH_DEV(i)
6221 port_dcb_info_display(i);
6222 else if (!strcmp(res->what, "cap"))
6223 RTE_ETH_FOREACH_DEV(i)
6224 port_offload_cap_display(i);
6227 cmdline_parse_token_string_t cmd_showportall_show =
6228 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6230 cmdline_parse_token_string_t cmd_showportall_port =
6231 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6232 cmdline_parse_token_string_t cmd_showportall_what =
6233 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6234 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6235 cmdline_parse_token_string_t cmd_showportall_all =
6236 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6237 cmdline_parse_inst_t cmd_showportall = {
6238 .f = cmd_showportall_parsed,
6240 .help_str = "show|clear port "
6241 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6243 (void *)&cmd_showportall_show,
6244 (void *)&cmd_showportall_port,
6245 (void *)&cmd_showportall_what,
6246 (void *)&cmd_showportall_all,
6251 /* *** SHOW PORT INFO *** */
6252 struct cmd_showport_result {
6253 cmdline_fixed_string_t show;
6254 cmdline_fixed_string_t port;
6255 cmdline_fixed_string_t what;
6259 static void cmd_showport_parsed(void *parsed_result,
6260 __attribute__((unused)) struct cmdline *cl,
6261 __attribute__((unused)) void *data)
6263 struct cmd_showport_result *res = parsed_result;
6264 if (!strcmp(res->show, "clear")) {
6265 if (!strcmp(res->what, "stats"))
6266 nic_stats_clear(res->portnum);
6267 else if (!strcmp(res->what, "xstats"))
6268 nic_xstats_clear(res->portnum);
6269 } else if (!strcmp(res->what, "info"))
6270 port_infos_display(res->portnum);
6271 else if (!strcmp(res->what, "stats"))
6272 nic_stats_display(res->portnum);
6273 else if (!strcmp(res->what, "xstats"))
6274 nic_xstats_display(res->portnum);
6275 else if (!strcmp(res->what, "fdir"))
6276 fdir_get_infos(res->portnum);
6277 else if (!strcmp(res->what, "stat_qmap"))
6278 nic_stats_mapping_display(res->portnum);
6279 else if (!strcmp(res->what, "dcb_tc"))
6280 port_dcb_info_display(res->portnum);
6281 else if (!strcmp(res->what, "cap"))
6282 port_offload_cap_display(res->portnum);
6285 cmdline_parse_token_string_t cmd_showport_show =
6286 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6288 cmdline_parse_token_string_t cmd_showport_port =
6289 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6290 cmdline_parse_token_string_t cmd_showport_what =
6291 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6292 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6293 cmdline_parse_token_num_t cmd_showport_portnum =
6294 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
6296 cmdline_parse_inst_t cmd_showport = {
6297 .f = cmd_showport_parsed,
6299 .help_str = "show|clear port "
6300 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6303 (void *)&cmd_showport_show,
6304 (void *)&cmd_showport_port,
6305 (void *)&cmd_showport_what,
6306 (void *)&cmd_showport_portnum,
6311 /* *** SHOW QUEUE INFO *** */
6312 struct cmd_showqueue_result {
6313 cmdline_fixed_string_t show;
6314 cmdline_fixed_string_t type;
6315 cmdline_fixed_string_t what;
6321 cmd_showqueue_parsed(void *parsed_result,
6322 __attribute__((unused)) struct cmdline *cl,
6323 __attribute__((unused)) void *data)
6325 struct cmd_showqueue_result *res = parsed_result;
6327 if (!strcmp(res->type, "rxq"))
6328 rx_queue_infos_display(res->portnum, res->queuenum);
6329 else if (!strcmp(res->type, "txq"))
6330 tx_queue_infos_display(res->portnum, res->queuenum);
6333 cmdline_parse_token_string_t cmd_showqueue_show =
6334 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6335 cmdline_parse_token_string_t cmd_showqueue_type =
6336 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6337 cmdline_parse_token_string_t cmd_showqueue_what =
6338 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6339 cmdline_parse_token_num_t cmd_showqueue_portnum =
6340 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6341 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6342 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6344 cmdline_parse_inst_t cmd_showqueue = {
6345 .f = cmd_showqueue_parsed,
6347 .help_str = "show rxq|txq info <port_id> <queue_id>",
6349 (void *)&cmd_showqueue_show,
6350 (void *)&cmd_showqueue_type,
6351 (void *)&cmd_showqueue_what,
6352 (void *)&cmd_showqueue_portnum,
6353 (void *)&cmd_showqueue_queuenum,
6358 /* *** READ PORT REGISTER *** */
6359 struct cmd_read_reg_result {
6360 cmdline_fixed_string_t read;
6361 cmdline_fixed_string_t reg;
6367 cmd_read_reg_parsed(void *parsed_result,
6368 __attribute__((unused)) struct cmdline *cl,
6369 __attribute__((unused)) void *data)
6371 struct cmd_read_reg_result *res = parsed_result;
6372 port_reg_display(res->port_id, res->reg_off);
6375 cmdline_parse_token_string_t cmd_read_reg_read =
6376 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6377 cmdline_parse_token_string_t cmd_read_reg_reg =
6378 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6379 cmdline_parse_token_num_t cmd_read_reg_port_id =
6380 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6381 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6382 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6384 cmdline_parse_inst_t cmd_read_reg = {
6385 .f = cmd_read_reg_parsed,
6387 .help_str = "read reg <port_id> <reg_off>",
6389 (void *)&cmd_read_reg_read,
6390 (void *)&cmd_read_reg_reg,
6391 (void *)&cmd_read_reg_port_id,
6392 (void *)&cmd_read_reg_reg_off,
6397 /* *** READ PORT REGISTER BIT FIELD *** */
6398 struct cmd_read_reg_bit_field_result {
6399 cmdline_fixed_string_t read;
6400 cmdline_fixed_string_t regfield;
6408 cmd_read_reg_bit_field_parsed(void *parsed_result,
6409 __attribute__((unused)) struct cmdline *cl,
6410 __attribute__((unused)) void *data)
6412 struct cmd_read_reg_bit_field_result *res = parsed_result;
6413 port_reg_bit_field_display(res->port_id, res->reg_off,
6414 res->bit1_pos, res->bit2_pos);
6417 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6418 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6420 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6421 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6422 regfield, "regfield");
6423 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6424 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6426 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6427 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6429 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6430 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6432 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6433 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6436 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6437 .f = cmd_read_reg_bit_field_parsed,
6439 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6440 "Read register bit field between bit_x and bit_y included",
6442 (void *)&cmd_read_reg_bit_field_read,
6443 (void *)&cmd_read_reg_bit_field_regfield,
6444 (void *)&cmd_read_reg_bit_field_port_id,
6445 (void *)&cmd_read_reg_bit_field_reg_off,
6446 (void *)&cmd_read_reg_bit_field_bit1_pos,
6447 (void *)&cmd_read_reg_bit_field_bit2_pos,
6452 /* *** READ PORT REGISTER BIT *** */
6453 struct cmd_read_reg_bit_result {
6454 cmdline_fixed_string_t read;
6455 cmdline_fixed_string_t regbit;
6462 cmd_read_reg_bit_parsed(void *parsed_result,
6463 __attribute__((unused)) struct cmdline *cl,
6464 __attribute__((unused)) void *data)
6466 struct cmd_read_reg_bit_result *res = parsed_result;
6467 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6470 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6471 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6472 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6473 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6475 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6476 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6477 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6478 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6479 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6480 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6482 cmdline_parse_inst_t cmd_read_reg_bit = {
6483 .f = cmd_read_reg_bit_parsed,
6485 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6487 (void *)&cmd_read_reg_bit_read,
6488 (void *)&cmd_read_reg_bit_regbit,
6489 (void *)&cmd_read_reg_bit_port_id,
6490 (void *)&cmd_read_reg_bit_reg_off,
6491 (void *)&cmd_read_reg_bit_bit_pos,
6496 /* *** WRITE PORT REGISTER *** */
6497 struct cmd_write_reg_result {
6498 cmdline_fixed_string_t write;
6499 cmdline_fixed_string_t reg;
6506 cmd_write_reg_parsed(void *parsed_result,
6507 __attribute__((unused)) struct cmdline *cl,
6508 __attribute__((unused)) void *data)
6510 struct cmd_write_reg_result *res = parsed_result;
6511 port_reg_set(res->port_id, res->reg_off, res->value);
6514 cmdline_parse_token_string_t cmd_write_reg_write =
6515 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6516 cmdline_parse_token_string_t cmd_write_reg_reg =
6517 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6518 cmdline_parse_token_num_t cmd_write_reg_port_id =
6519 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6520 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6521 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6522 cmdline_parse_token_num_t cmd_write_reg_value =
6523 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6525 cmdline_parse_inst_t cmd_write_reg = {
6526 .f = cmd_write_reg_parsed,
6528 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6530 (void *)&cmd_write_reg_write,
6531 (void *)&cmd_write_reg_reg,
6532 (void *)&cmd_write_reg_port_id,
6533 (void *)&cmd_write_reg_reg_off,
6534 (void *)&cmd_write_reg_value,
6539 /* *** WRITE PORT REGISTER BIT FIELD *** */
6540 struct cmd_write_reg_bit_field_result {
6541 cmdline_fixed_string_t write;
6542 cmdline_fixed_string_t regfield;
6551 cmd_write_reg_bit_field_parsed(void *parsed_result,
6552 __attribute__((unused)) struct cmdline *cl,
6553 __attribute__((unused)) void *data)
6555 struct cmd_write_reg_bit_field_result *res = parsed_result;
6556 port_reg_bit_field_set(res->port_id, res->reg_off,
6557 res->bit1_pos, res->bit2_pos, res->value);
6560 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6561 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6563 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6564 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6565 regfield, "regfield");
6566 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6567 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6569 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6570 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6572 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6573 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6575 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6576 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6578 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6579 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6582 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6583 .f = cmd_write_reg_bit_field_parsed,
6585 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6587 "Set register bit field between bit_x and bit_y included",
6589 (void *)&cmd_write_reg_bit_field_write,
6590 (void *)&cmd_write_reg_bit_field_regfield,
6591 (void *)&cmd_write_reg_bit_field_port_id,
6592 (void *)&cmd_write_reg_bit_field_reg_off,
6593 (void *)&cmd_write_reg_bit_field_bit1_pos,
6594 (void *)&cmd_write_reg_bit_field_bit2_pos,
6595 (void *)&cmd_write_reg_bit_field_value,
6600 /* *** WRITE PORT REGISTER BIT *** */
6601 struct cmd_write_reg_bit_result {
6602 cmdline_fixed_string_t write;
6603 cmdline_fixed_string_t regbit;
6611 cmd_write_reg_bit_parsed(void *parsed_result,
6612 __attribute__((unused)) struct cmdline *cl,
6613 __attribute__((unused)) void *data)
6615 struct cmd_write_reg_bit_result *res = parsed_result;
6616 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6619 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6620 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6622 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6623 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6625 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6626 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6627 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6628 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6629 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6630 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6631 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6632 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6634 cmdline_parse_inst_t cmd_write_reg_bit = {
6635 .f = cmd_write_reg_bit_parsed,
6637 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6640 (void *)&cmd_write_reg_bit_write,
6641 (void *)&cmd_write_reg_bit_regbit,
6642 (void *)&cmd_write_reg_bit_port_id,
6643 (void *)&cmd_write_reg_bit_reg_off,
6644 (void *)&cmd_write_reg_bit_bit_pos,
6645 (void *)&cmd_write_reg_bit_value,
6650 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6651 struct cmd_read_rxd_txd_result {
6652 cmdline_fixed_string_t read;
6653 cmdline_fixed_string_t rxd_txd;
6660 cmd_read_rxd_txd_parsed(void *parsed_result,
6661 __attribute__((unused)) struct cmdline *cl,
6662 __attribute__((unused)) void *data)
6664 struct cmd_read_rxd_txd_result *res = parsed_result;
6666 if (!strcmp(res->rxd_txd, "rxd"))
6667 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6668 else if (!strcmp(res->rxd_txd, "txd"))
6669 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6672 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6673 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6674 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6675 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6677 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6678 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6679 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6680 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6681 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6682 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6684 cmdline_parse_inst_t cmd_read_rxd_txd = {
6685 .f = cmd_read_rxd_txd_parsed,
6687 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6689 (void *)&cmd_read_rxd_txd_read,
6690 (void *)&cmd_read_rxd_txd_rxd_txd,
6691 (void *)&cmd_read_rxd_txd_port_id,
6692 (void *)&cmd_read_rxd_txd_queue_id,
6693 (void *)&cmd_read_rxd_txd_desc_id,
6699 struct cmd_quit_result {
6700 cmdline_fixed_string_t quit;
6703 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6705 __attribute__((unused)) void *data)
6711 cmdline_parse_token_string_t cmd_quit_quit =
6712 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6714 cmdline_parse_inst_t cmd_quit = {
6715 .f = cmd_quit_parsed,
6717 .help_str = "quit: Exit application",
6719 (void *)&cmd_quit_quit,
6724 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6725 struct cmd_mac_addr_result {
6726 cmdline_fixed_string_t mac_addr_cmd;
6727 cmdline_fixed_string_t what;
6729 struct ether_addr address;
6732 static void cmd_mac_addr_parsed(void *parsed_result,
6733 __attribute__((unused)) struct cmdline *cl,
6734 __attribute__((unused)) void *data)
6736 struct cmd_mac_addr_result *res = parsed_result;
6739 if (strcmp(res->what, "add") == 0)
6740 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6741 else if (strcmp(res->what, "set") == 0)
6742 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6745 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6747 /* check the return value and print it if is < 0 */
6749 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6753 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6754 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6756 cmdline_parse_token_string_t cmd_mac_addr_what =
6757 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6759 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6760 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6761 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6762 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6764 cmdline_parse_inst_t cmd_mac_addr = {
6765 .f = cmd_mac_addr_parsed,
6767 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6768 "Add/Remove/Set MAC address on port_id",
6770 (void *)&cmd_mac_addr_cmd,
6771 (void *)&cmd_mac_addr_what,
6772 (void *)&cmd_mac_addr_portnum,
6773 (void *)&cmd_mac_addr_addr,
6779 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6780 struct cmd_set_qmap_result {
6781 cmdline_fixed_string_t set;
6782 cmdline_fixed_string_t qmap;
6783 cmdline_fixed_string_t what;
6790 cmd_set_qmap_parsed(void *parsed_result,
6791 __attribute__((unused)) struct cmdline *cl,
6792 __attribute__((unused)) void *data)
6794 struct cmd_set_qmap_result *res = parsed_result;
6795 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6797 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6800 cmdline_parse_token_string_t cmd_setqmap_set =
6801 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6803 cmdline_parse_token_string_t cmd_setqmap_qmap =
6804 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6806 cmdline_parse_token_string_t cmd_setqmap_what =
6807 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6809 cmdline_parse_token_num_t cmd_setqmap_portid =
6810 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6812 cmdline_parse_token_num_t cmd_setqmap_queueid =
6813 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6815 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6816 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6819 cmdline_parse_inst_t cmd_set_qmap = {
6820 .f = cmd_set_qmap_parsed,
6822 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6823 "Set statistics mapping value on tx|rx queue_id of port_id",
6825 (void *)&cmd_setqmap_set,
6826 (void *)&cmd_setqmap_qmap,
6827 (void *)&cmd_setqmap_what,
6828 (void *)&cmd_setqmap_portid,
6829 (void *)&cmd_setqmap_queueid,
6830 (void *)&cmd_setqmap_mapvalue,
6835 /* *** CONFIGURE UNICAST HASH TABLE *** */
6836 struct cmd_set_uc_hash_table {
6837 cmdline_fixed_string_t set;
6838 cmdline_fixed_string_t port;
6840 cmdline_fixed_string_t what;
6841 struct ether_addr address;
6842 cmdline_fixed_string_t mode;
6846 cmd_set_uc_hash_parsed(void *parsed_result,
6847 __attribute__((unused)) struct cmdline *cl,
6848 __attribute__((unused)) void *data)
6851 struct cmd_set_uc_hash_table *res = parsed_result;
6853 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6855 if (strcmp(res->what, "uta") == 0)
6856 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6857 &res->address,(uint8_t)is_on);
6859 printf("bad unicast hash table parameter, return code = %d \n", ret);
6863 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6864 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6866 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6867 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6869 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6870 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6872 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6873 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6875 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6876 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6878 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6879 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6882 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6883 .f = cmd_set_uc_hash_parsed,
6885 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6887 (void *)&cmd_set_uc_hash_set,
6888 (void *)&cmd_set_uc_hash_port,
6889 (void *)&cmd_set_uc_hash_portid,
6890 (void *)&cmd_set_uc_hash_what,
6891 (void *)&cmd_set_uc_hash_mac,
6892 (void *)&cmd_set_uc_hash_mode,
6897 struct cmd_set_uc_all_hash_table {
6898 cmdline_fixed_string_t set;
6899 cmdline_fixed_string_t port;
6901 cmdline_fixed_string_t what;
6902 cmdline_fixed_string_t value;
6903 cmdline_fixed_string_t mode;
6907 cmd_set_uc_all_hash_parsed(void *parsed_result,
6908 __attribute__((unused)) struct cmdline *cl,
6909 __attribute__((unused)) void *data)
6912 struct cmd_set_uc_all_hash_table *res = parsed_result;
6914 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6916 if ((strcmp(res->what, "uta") == 0) &&
6917 (strcmp(res->value, "all") == 0))
6918 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6920 printf("bad unicast hash table parameter,"
6921 "return code = %d \n", ret);
6924 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6925 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6927 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6928 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6930 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6931 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6933 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6934 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6936 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6937 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6939 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6940 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6943 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6944 .f = cmd_set_uc_all_hash_parsed,
6946 .help_str = "set port <port_id> uta all on|off",
6948 (void *)&cmd_set_uc_all_hash_set,
6949 (void *)&cmd_set_uc_all_hash_port,
6950 (void *)&cmd_set_uc_all_hash_portid,
6951 (void *)&cmd_set_uc_all_hash_what,
6952 (void *)&cmd_set_uc_all_hash_value,
6953 (void *)&cmd_set_uc_all_hash_mode,
6958 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6959 struct cmd_set_vf_macvlan_filter {
6960 cmdline_fixed_string_t set;
6961 cmdline_fixed_string_t port;
6963 cmdline_fixed_string_t vf;
6965 struct ether_addr address;
6966 cmdline_fixed_string_t filter_type;
6967 cmdline_fixed_string_t mode;
6971 cmd_set_vf_macvlan_parsed(void *parsed_result,
6972 __attribute__((unused)) struct cmdline *cl,
6973 __attribute__((unused)) void *data)
6976 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6977 struct rte_eth_mac_filter filter;
6979 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6981 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6983 /* set VF MAC filter */
6987 filter.dst_id = res->vf_id;
6989 if (!strcmp(res->filter_type, "exact-mac"))
6990 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6991 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6992 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6993 else if (!strcmp(res->filter_type, "hashmac"))
6994 filter.filter_type = RTE_MAC_HASH_MATCH;
6995 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6996 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6998 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7001 ret = rte_eth_dev_filter_ctrl(res->port_id,
7002 RTE_ETH_FILTER_MACVLAN,
7006 ret = rte_eth_dev_filter_ctrl(res->port_id,
7007 RTE_ETH_FILTER_MACVLAN,
7008 RTE_ETH_FILTER_DELETE,
7012 printf("bad set MAC hash parameter, return code = %d\n", ret);
7016 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7017 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7019 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7020 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7022 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7023 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7025 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7026 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7028 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7029 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7031 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7032 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7034 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7035 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7036 filter_type, "exact-mac#exact-mac-vlan"
7037 "#hashmac#hashmac-vlan");
7038 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7039 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7042 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7043 .f = cmd_set_vf_macvlan_parsed,
7045 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7046 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7047 "Exact match rule: exact match of MAC or MAC and VLAN; "
7048 "hash match rule: hash match of MAC and exact match of VLAN",
7050 (void *)&cmd_set_vf_macvlan_set,
7051 (void *)&cmd_set_vf_macvlan_port,
7052 (void *)&cmd_set_vf_macvlan_portid,
7053 (void *)&cmd_set_vf_macvlan_vf,
7054 (void *)&cmd_set_vf_macvlan_vf_id,
7055 (void *)&cmd_set_vf_macvlan_mac,
7056 (void *)&cmd_set_vf_macvlan_filter_type,
7057 (void *)&cmd_set_vf_macvlan_mode,
7062 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7063 struct cmd_set_vf_traffic {
7064 cmdline_fixed_string_t set;
7065 cmdline_fixed_string_t port;
7067 cmdline_fixed_string_t vf;
7069 cmdline_fixed_string_t what;
7070 cmdline_fixed_string_t mode;
7074 cmd_set_vf_traffic_parsed(void *parsed_result,
7075 __attribute__((unused)) struct cmdline *cl,
7076 __attribute__((unused)) void *data)
7078 struct cmd_set_vf_traffic *res = parsed_result;
7079 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7080 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7082 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7085 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7086 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7088 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7089 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7091 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7092 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7094 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7095 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7097 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7098 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7100 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7101 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7103 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7104 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7107 cmdline_parse_inst_t cmd_set_vf_traffic = {
7108 .f = cmd_set_vf_traffic_parsed,
7110 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7112 (void *)&cmd_setvf_traffic_set,
7113 (void *)&cmd_setvf_traffic_port,
7114 (void *)&cmd_setvf_traffic_portid,
7115 (void *)&cmd_setvf_traffic_vf,
7116 (void *)&cmd_setvf_traffic_vfid,
7117 (void *)&cmd_setvf_traffic_what,
7118 (void *)&cmd_setvf_traffic_mode,
7123 /* *** CONFIGURE VF RECEIVE MODE *** */
7124 struct cmd_set_vf_rxmode {
7125 cmdline_fixed_string_t set;
7126 cmdline_fixed_string_t port;
7128 cmdline_fixed_string_t vf;
7130 cmdline_fixed_string_t what;
7131 cmdline_fixed_string_t mode;
7132 cmdline_fixed_string_t on;
7136 cmd_set_vf_rxmode_parsed(void *parsed_result,
7137 __attribute__((unused)) struct cmdline *cl,
7138 __attribute__((unused)) void *data)
7141 uint16_t rx_mode = 0;
7142 struct cmd_set_vf_rxmode *res = parsed_result;
7144 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7145 if (!strcmp(res->what,"rxmode")) {
7146 if (!strcmp(res->mode, "AUPE"))
7147 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7148 else if (!strcmp(res->mode, "ROPE"))
7149 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7150 else if (!strcmp(res->mode, "BAM"))
7151 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7152 else if (!strncmp(res->mode, "MPE",3))
7153 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7156 #ifdef RTE_LIBRTE_IXGBE_PMD
7157 if (ret == -ENOTSUP)
7158 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7159 rx_mode, (uint8_t)is_on);
7161 #ifdef RTE_LIBRTE_BNXT_PMD
7162 if (ret == -ENOTSUP)
7163 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7164 rx_mode, (uint8_t)is_on);
7167 printf("bad VF receive mode parameter, return code = %d \n",
7171 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7172 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7174 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7175 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7177 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7178 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7180 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7181 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7183 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7184 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7186 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7187 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7189 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7190 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7191 mode, "AUPE#ROPE#BAM#MPE");
7192 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7193 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7196 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7197 .f = cmd_set_vf_rxmode_parsed,
7199 .help_str = "set port <port_id> vf <vf_id> rxmode "
7200 "AUPE|ROPE|BAM|MPE on|off",
7202 (void *)&cmd_set_vf_rxmode_set,
7203 (void *)&cmd_set_vf_rxmode_port,
7204 (void *)&cmd_set_vf_rxmode_portid,
7205 (void *)&cmd_set_vf_rxmode_vf,
7206 (void *)&cmd_set_vf_rxmode_vfid,
7207 (void *)&cmd_set_vf_rxmode_what,
7208 (void *)&cmd_set_vf_rxmode_mode,
7209 (void *)&cmd_set_vf_rxmode_on,
7214 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7215 struct cmd_vf_mac_addr_result {
7216 cmdline_fixed_string_t mac_addr_cmd;
7217 cmdline_fixed_string_t what;
7218 cmdline_fixed_string_t port;
7220 cmdline_fixed_string_t vf;
7222 struct ether_addr address;
7225 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7226 __attribute__((unused)) struct cmdline *cl,
7227 __attribute__((unused)) void *data)
7229 struct cmd_vf_mac_addr_result *res = parsed_result;
7232 if (strcmp(res->what, "add") != 0)
7235 #ifdef RTE_LIBRTE_I40E_PMD
7236 if (ret == -ENOTSUP)
7237 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7240 #ifdef RTE_LIBRTE_BNXT_PMD
7241 if (ret == -ENOTSUP)
7242 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7247 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7251 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7252 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7253 mac_addr_cmd,"mac_addr");
7254 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7255 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7257 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7258 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7260 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7261 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7263 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7264 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7266 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7267 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7269 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7270 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7273 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7274 .f = cmd_vf_mac_addr_parsed,
7276 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7277 "Add MAC address filtering for a VF on port_id",
7279 (void *)&cmd_vf_mac_addr_cmd,
7280 (void *)&cmd_vf_mac_addr_what,
7281 (void *)&cmd_vf_mac_addr_port,
7282 (void *)&cmd_vf_mac_addr_portnum,
7283 (void *)&cmd_vf_mac_addr_vf,
7284 (void *)&cmd_vf_mac_addr_vfnum,
7285 (void *)&cmd_vf_mac_addr_addr,
7290 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7291 struct cmd_vf_rx_vlan_filter {
7292 cmdline_fixed_string_t rx_vlan;
7293 cmdline_fixed_string_t what;
7295 cmdline_fixed_string_t port;
7297 cmdline_fixed_string_t vf;
7302 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7303 __attribute__((unused)) struct cmdline *cl,
7304 __attribute__((unused)) void *data)
7306 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7309 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7311 #ifdef RTE_LIBRTE_IXGBE_PMD
7312 if (ret == -ENOTSUP)
7313 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7314 res->vlan_id, res->vf_mask, is_add);
7316 #ifdef RTE_LIBRTE_I40E_PMD
7317 if (ret == -ENOTSUP)
7318 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7319 res->vlan_id, res->vf_mask, is_add);
7321 #ifdef RTE_LIBRTE_BNXT_PMD
7322 if (ret == -ENOTSUP)
7323 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7324 res->vlan_id, res->vf_mask, is_add);
7331 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7332 res->vlan_id, res->vf_mask);
7335 printf("invalid port_id %d\n", res->port_id);
7338 printf("function not implemented or supported\n");
7341 printf("programming error: (%s)\n", strerror(-ret));
7345 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7346 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7347 rx_vlan, "rx_vlan");
7348 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7349 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7351 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7352 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7354 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7355 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7357 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7358 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7360 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7361 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7363 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7364 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7367 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7368 .f = cmd_vf_rx_vlan_filter_parsed,
7370 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7371 "(vf_mask = hexadecimal VF mask)",
7373 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7374 (void *)&cmd_vf_rx_vlan_filter_what,
7375 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7376 (void *)&cmd_vf_rx_vlan_filter_port,
7377 (void *)&cmd_vf_rx_vlan_filter_portid,
7378 (void *)&cmd_vf_rx_vlan_filter_vf,
7379 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7384 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7385 struct cmd_queue_rate_limit_result {
7386 cmdline_fixed_string_t set;
7387 cmdline_fixed_string_t port;
7389 cmdline_fixed_string_t queue;
7391 cmdline_fixed_string_t rate;
7395 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7396 __attribute__((unused)) struct cmdline *cl,
7397 __attribute__((unused)) void *data)
7399 struct cmd_queue_rate_limit_result *res = parsed_result;
7402 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7403 && (strcmp(res->queue, "queue") == 0)
7404 && (strcmp(res->rate, "rate") == 0))
7405 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7408 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7412 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7413 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7415 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7416 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7418 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7419 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7421 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7422 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7424 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7425 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7427 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7428 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7430 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7431 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7434 cmdline_parse_inst_t cmd_queue_rate_limit = {
7435 .f = cmd_queue_rate_limit_parsed,
7437 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7438 "Set rate limit for a queue on port_id",
7440 (void *)&cmd_queue_rate_limit_set,
7441 (void *)&cmd_queue_rate_limit_port,
7442 (void *)&cmd_queue_rate_limit_portnum,
7443 (void *)&cmd_queue_rate_limit_queue,
7444 (void *)&cmd_queue_rate_limit_queuenum,
7445 (void *)&cmd_queue_rate_limit_rate,
7446 (void *)&cmd_queue_rate_limit_ratenum,
7451 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7452 struct cmd_vf_rate_limit_result {
7453 cmdline_fixed_string_t set;
7454 cmdline_fixed_string_t port;
7456 cmdline_fixed_string_t vf;
7458 cmdline_fixed_string_t rate;
7460 cmdline_fixed_string_t q_msk;
7464 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7465 __attribute__((unused)) struct cmdline *cl,
7466 __attribute__((unused)) void *data)
7468 struct cmd_vf_rate_limit_result *res = parsed_result;
7471 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7472 && (strcmp(res->vf, "vf") == 0)
7473 && (strcmp(res->rate, "rate") == 0)
7474 && (strcmp(res->q_msk, "queue_mask") == 0))
7475 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7476 res->rate_num, res->q_msk_val);
7478 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7482 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7483 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7485 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7486 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7488 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7489 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7491 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7492 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7494 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7495 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7497 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7498 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7500 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7501 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7503 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7504 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7505 q_msk, "queue_mask");
7506 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7507 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7510 cmdline_parse_inst_t cmd_vf_rate_limit = {
7511 .f = cmd_vf_rate_limit_parsed,
7513 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7514 "queue_mask <queue_mask_value>: "
7515 "Set rate limit for queues of VF on port_id",
7517 (void *)&cmd_vf_rate_limit_set,
7518 (void *)&cmd_vf_rate_limit_port,
7519 (void *)&cmd_vf_rate_limit_portnum,
7520 (void *)&cmd_vf_rate_limit_vf,
7521 (void *)&cmd_vf_rate_limit_vfnum,
7522 (void *)&cmd_vf_rate_limit_rate,
7523 (void *)&cmd_vf_rate_limit_ratenum,
7524 (void *)&cmd_vf_rate_limit_q_msk,
7525 (void *)&cmd_vf_rate_limit_q_msk_val,
7530 /* *** ADD TUNNEL FILTER OF A PORT *** */
7531 struct cmd_tunnel_filter_result {
7532 cmdline_fixed_string_t cmd;
7533 cmdline_fixed_string_t what;
7535 struct ether_addr outer_mac;
7536 struct ether_addr inner_mac;
7537 cmdline_ipaddr_t ip_value;
7538 uint16_t inner_vlan;
7539 cmdline_fixed_string_t tunnel_type;
7540 cmdline_fixed_string_t filter_type;
7546 cmd_tunnel_filter_parsed(void *parsed_result,
7547 __attribute__((unused)) struct cmdline *cl,
7548 __attribute__((unused)) void *data)
7550 struct cmd_tunnel_filter_result *res = parsed_result;
7551 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7554 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7556 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7557 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7558 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7560 if (res->ip_value.family == AF_INET) {
7561 tunnel_filter_conf.ip_addr.ipv4_addr =
7562 res->ip_value.addr.ipv4.s_addr;
7563 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7565 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7566 &(res->ip_value.addr.ipv6),
7567 sizeof(struct in6_addr));
7568 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7571 if (!strcmp(res->filter_type, "imac-ivlan"))
7572 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7573 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7574 tunnel_filter_conf.filter_type =
7575 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7576 else if (!strcmp(res->filter_type, "imac-tenid"))
7577 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7578 else if (!strcmp(res->filter_type, "imac"))
7579 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7580 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7581 tunnel_filter_conf.filter_type =
7582 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7583 else if (!strcmp(res->filter_type, "oip"))
7584 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7585 else if (!strcmp(res->filter_type, "iip"))
7586 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7588 printf("The filter type is not supported");
7592 if (!strcmp(res->tunnel_type, "vxlan"))
7593 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7594 else if (!strcmp(res->tunnel_type, "nvgre"))
7595 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7596 else if (!strcmp(res->tunnel_type, "ipingre"))
7597 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7599 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7603 tunnel_filter_conf.tenant_id = res->tenant_id;
7604 tunnel_filter_conf.queue_id = res->queue_num;
7605 if (!strcmp(res->what, "add"))
7606 ret = rte_eth_dev_filter_ctrl(res->port_id,
7607 RTE_ETH_FILTER_TUNNEL,
7609 &tunnel_filter_conf);
7611 ret = rte_eth_dev_filter_ctrl(res->port_id,
7612 RTE_ETH_FILTER_TUNNEL,
7613 RTE_ETH_FILTER_DELETE,
7614 &tunnel_filter_conf);
7616 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7620 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7621 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7622 cmd, "tunnel_filter");
7623 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7624 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7626 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7627 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7629 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7630 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7632 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7633 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7635 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7636 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7637 inner_vlan, UINT16);
7638 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7639 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7641 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7642 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7643 tunnel_type, "vxlan#nvgre#ipingre");
7645 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7646 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7647 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7648 "imac#omac-imac-tenid");
7649 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7650 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7652 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7653 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7656 cmdline_parse_inst_t cmd_tunnel_filter = {
7657 .f = cmd_tunnel_filter_parsed,
7659 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7660 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7661 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7662 "<queue_id>: Add/Rm tunnel filter of a port",
7664 (void *)&cmd_tunnel_filter_cmd,
7665 (void *)&cmd_tunnel_filter_what,
7666 (void *)&cmd_tunnel_filter_port_id,
7667 (void *)&cmd_tunnel_filter_outer_mac,
7668 (void *)&cmd_tunnel_filter_inner_mac,
7669 (void *)&cmd_tunnel_filter_ip_value,
7670 (void *)&cmd_tunnel_filter_innner_vlan,
7671 (void *)&cmd_tunnel_filter_tunnel_type,
7672 (void *)&cmd_tunnel_filter_filter_type,
7673 (void *)&cmd_tunnel_filter_tenant_id,
7674 (void *)&cmd_tunnel_filter_queue_num,
7679 /* *** CONFIGURE TUNNEL UDP PORT *** */
7680 struct cmd_tunnel_udp_config {
7681 cmdline_fixed_string_t cmd;
7682 cmdline_fixed_string_t what;
7688 cmd_tunnel_udp_config_parsed(void *parsed_result,
7689 __attribute__((unused)) struct cmdline *cl,
7690 __attribute__((unused)) void *data)
7692 struct cmd_tunnel_udp_config *res = parsed_result;
7693 struct rte_eth_udp_tunnel tunnel_udp;
7696 tunnel_udp.udp_port = res->udp_port;
7698 if (!strcmp(res->cmd, "rx_vxlan_port"))
7699 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7701 if (!strcmp(res->what, "add"))
7702 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7705 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7709 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7712 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7713 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7714 cmd, "rx_vxlan_port");
7715 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7716 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7718 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7719 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7721 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7722 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7725 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7726 .f = cmd_tunnel_udp_config_parsed,
7728 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7729 "Add/Remove a tunneling UDP port filter",
7731 (void *)&cmd_tunnel_udp_config_cmd,
7732 (void *)&cmd_tunnel_udp_config_what,
7733 (void *)&cmd_tunnel_udp_config_udp_port,
7734 (void *)&cmd_tunnel_udp_config_port_id,
7739 /* *** GLOBAL CONFIG *** */
7740 struct cmd_global_config_result {
7741 cmdline_fixed_string_t cmd;
7743 cmdline_fixed_string_t cfg_type;
7748 cmd_global_config_parsed(void *parsed_result,
7749 __attribute__((unused)) struct cmdline *cl,
7750 __attribute__((unused)) void *data)
7752 struct cmd_global_config_result *res = parsed_result;
7753 struct rte_eth_global_cfg conf;
7756 memset(&conf, 0, sizeof(conf));
7757 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7758 conf.cfg.gre_key_len = res->len;
7759 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7760 RTE_ETH_FILTER_SET, &conf);
7762 printf("Global config error\n");
7765 cmdline_parse_token_string_t cmd_global_config_cmd =
7766 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7768 cmdline_parse_token_num_t cmd_global_config_port_id =
7769 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7770 cmdline_parse_token_string_t cmd_global_config_type =
7771 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7772 cfg_type, "gre-key-len");
7773 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7774 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7777 cmdline_parse_inst_t cmd_global_config = {
7778 .f = cmd_global_config_parsed,
7779 .data = (void *)NULL,
7780 .help_str = "global_config <port_id> gre-key-len <key_len>",
7782 (void *)&cmd_global_config_cmd,
7783 (void *)&cmd_global_config_port_id,
7784 (void *)&cmd_global_config_type,
7785 (void *)&cmd_global_config_gre_key_len,
7790 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7791 struct cmd_set_mirror_mask_result {
7792 cmdline_fixed_string_t set;
7793 cmdline_fixed_string_t port;
7795 cmdline_fixed_string_t mirror;
7797 cmdline_fixed_string_t what;
7798 cmdline_fixed_string_t value;
7799 cmdline_fixed_string_t dstpool;
7801 cmdline_fixed_string_t on;
7804 cmdline_parse_token_string_t cmd_mirror_mask_set =
7805 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7807 cmdline_parse_token_string_t cmd_mirror_mask_port =
7808 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7810 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7811 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7813 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7814 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7815 mirror, "mirror-rule");
7816 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7817 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7819 cmdline_parse_token_string_t cmd_mirror_mask_what =
7820 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7821 what, "pool-mirror-up#pool-mirror-down"
7823 cmdline_parse_token_string_t cmd_mirror_mask_value =
7824 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7826 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7827 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7828 dstpool, "dst-pool");
7829 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7830 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7832 cmdline_parse_token_string_t cmd_mirror_mask_on =
7833 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7837 cmd_set_mirror_mask_parsed(void *parsed_result,
7838 __attribute__((unused)) struct cmdline *cl,
7839 __attribute__((unused)) void *data)
7842 struct cmd_set_mirror_mask_result *res = parsed_result;
7843 struct rte_eth_mirror_conf mr_conf;
7845 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7847 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7849 mr_conf.dst_pool = res->dstpool_id;
7851 if (!strcmp(res->what, "pool-mirror-up")) {
7852 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7853 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7854 } else if (!strcmp(res->what, "pool-mirror-down")) {
7855 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7856 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7857 } else if (!strcmp(res->what, "vlan-mirror")) {
7858 mr_conf.rule_type = ETH_MIRROR_VLAN;
7859 nb_item = parse_item_list(res->value, "vlan",
7860 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7864 for (i = 0; i < nb_item; i++) {
7865 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7866 printf("Invalid vlan_id: must be < 4096\n");
7870 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7871 mr_conf.vlan.vlan_mask |= 1ULL << i;
7875 if (!strcmp(res->on, "on"))
7876 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7879 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7882 printf("mirror rule add error: (%s)\n", strerror(-ret));
7885 cmdline_parse_inst_t cmd_set_mirror_mask = {
7886 .f = cmd_set_mirror_mask_parsed,
7888 .help_str = "set port <port_id> mirror-rule <rule_id> "
7889 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7890 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7892 (void *)&cmd_mirror_mask_set,
7893 (void *)&cmd_mirror_mask_port,
7894 (void *)&cmd_mirror_mask_portid,
7895 (void *)&cmd_mirror_mask_mirror,
7896 (void *)&cmd_mirror_mask_ruleid,
7897 (void *)&cmd_mirror_mask_what,
7898 (void *)&cmd_mirror_mask_value,
7899 (void *)&cmd_mirror_mask_dstpool,
7900 (void *)&cmd_mirror_mask_poolid,
7901 (void *)&cmd_mirror_mask_on,
7906 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7907 struct cmd_set_mirror_link_result {
7908 cmdline_fixed_string_t set;
7909 cmdline_fixed_string_t port;
7911 cmdline_fixed_string_t mirror;
7913 cmdline_fixed_string_t what;
7914 cmdline_fixed_string_t dstpool;
7916 cmdline_fixed_string_t on;
7919 cmdline_parse_token_string_t cmd_mirror_link_set =
7920 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7922 cmdline_parse_token_string_t cmd_mirror_link_port =
7923 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7925 cmdline_parse_token_num_t cmd_mirror_link_portid =
7926 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7928 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7929 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7930 mirror, "mirror-rule");
7931 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7932 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7934 cmdline_parse_token_string_t cmd_mirror_link_what =
7935 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7936 what, "uplink-mirror#downlink-mirror");
7937 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7938 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7939 dstpool, "dst-pool");
7940 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7941 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7943 cmdline_parse_token_string_t cmd_mirror_link_on =
7944 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7948 cmd_set_mirror_link_parsed(void *parsed_result,
7949 __attribute__((unused)) struct cmdline *cl,
7950 __attribute__((unused)) void *data)
7953 struct cmd_set_mirror_link_result *res = parsed_result;
7954 struct rte_eth_mirror_conf mr_conf;
7956 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7957 if (!strcmp(res->what, "uplink-mirror"))
7958 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7960 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7962 mr_conf.dst_pool = res->dstpool_id;
7964 if (!strcmp(res->on, "on"))
7965 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7968 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7971 /* check the return value and print it if is < 0 */
7973 printf("mirror rule add error: (%s)\n", strerror(-ret));
7977 cmdline_parse_inst_t cmd_set_mirror_link = {
7978 .f = cmd_set_mirror_link_parsed,
7980 .help_str = "set port <port_id> mirror-rule <rule_id> "
7981 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7983 (void *)&cmd_mirror_link_set,
7984 (void *)&cmd_mirror_link_port,
7985 (void *)&cmd_mirror_link_portid,
7986 (void *)&cmd_mirror_link_mirror,
7987 (void *)&cmd_mirror_link_ruleid,
7988 (void *)&cmd_mirror_link_what,
7989 (void *)&cmd_mirror_link_dstpool,
7990 (void *)&cmd_mirror_link_poolid,
7991 (void *)&cmd_mirror_link_on,
7996 /* *** RESET VM MIRROR RULE *** */
7997 struct cmd_rm_mirror_rule_result {
7998 cmdline_fixed_string_t reset;
7999 cmdline_fixed_string_t port;
8001 cmdline_fixed_string_t mirror;
8005 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8006 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8008 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8009 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8011 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8012 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8014 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8015 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8016 mirror, "mirror-rule");
8017 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8018 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8022 cmd_reset_mirror_rule_parsed(void *parsed_result,
8023 __attribute__((unused)) struct cmdline *cl,
8024 __attribute__((unused)) void *data)
8027 struct cmd_set_mirror_link_result *res = parsed_result;
8029 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8031 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8034 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8035 .f = cmd_reset_mirror_rule_parsed,
8037 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8039 (void *)&cmd_rm_mirror_rule_reset,
8040 (void *)&cmd_rm_mirror_rule_port,
8041 (void *)&cmd_rm_mirror_rule_portid,
8042 (void *)&cmd_rm_mirror_rule_mirror,
8043 (void *)&cmd_rm_mirror_rule_ruleid,
8048 /* ******************************************************************************** */
8050 struct cmd_dump_result {
8051 cmdline_fixed_string_t dump;
8055 dump_struct_sizes(void)
8057 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8058 DUMP_SIZE(struct rte_mbuf);
8059 DUMP_SIZE(struct rte_mempool);
8060 DUMP_SIZE(struct rte_ring);
8064 static void cmd_dump_parsed(void *parsed_result,
8065 __attribute__((unused)) struct cmdline *cl,
8066 __attribute__((unused)) void *data)
8068 struct cmd_dump_result *res = parsed_result;
8070 if (!strcmp(res->dump, "dump_physmem"))
8071 rte_dump_physmem_layout(stdout);
8072 else if (!strcmp(res->dump, "dump_memzone"))
8073 rte_memzone_dump(stdout);
8074 else if (!strcmp(res->dump, "dump_struct_sizes"))
8075 dump_struct_sizes();
8076 else if (!strcmp(res->dump, "dump_ring"))
8077 rte_ring_list_dump(stdout);
8078 else if (!strcmp(res->dump, "dump_mempool"))
8079 rte_mempool_list_dump(stdout);
8080 else if (!strcmp(res->dump, "dump_devargs"))
8081 rte_eal_devargs_dump(stdout);
8082 else if (!strcmp(res->dump, "dump_log_types"))
8083 rte_log_dump(stdout);
8086 cmdline_parse_token_string_t cmd_dump_dump =
8087 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8090 "dump_struct_sizes#"
8096 cmdline_parse_inst_t cmd_dump = {
8097 .f = cmd_dump_parsed, /* function to call */
8098 .data = NULL, /* 2nd arg of func */
8099 .help_str = "Dump status",
8100 .tokens = { /* token list, NULL terminated */
8101 (void *)&cmd_dump_dump,
8106 /* ******************************************************************************** */
8108 struct cmd_dump_one_result {
8109 cmdline_fixed_string_t dump;
8110 cmdline_fixed_string_t name;
8113 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8114 __attribute__((unused)) void *data)
8116 struct cmd_dump_one_result *res = parsed_result;
8118 if (!strcmp(res->dump, "dump_ring")) {
8120 r = rte_ring_lookup(res->name);
8122 cmdline_printf(cl, "Cannot find ring\n");
8125 rte_ring_dump(stdout, r);
8126 } else if (!strcmp(res->dump, "dump_mempool")) {
8127 struct rte_mempool *mp;
8128 mp = rte_mempool_lookup(res->name);
8130 cmdline_printf(cl, "Cannot find mempool\n");
8133 rte_mempool_dump(stdout, mp);
8137 cmdline_parse_token_string_t cmd_dump_one_dump =
8138 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8139 "dump_ring#dump_mempool");
8141 cmdline_parse_token_string_t cmd_dump_one_name =
8142 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8144 cmdline_parse_inst_t cmd_dump_one = {
8145 .f = cmd_dump_one_parsed, /* function to call */
8146 .data = NULL, /* 2nd arg of func */
8147 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8148 .tokens = { /* token list, NULL terminated */
8149 (void *)&cmd_dump_one_dump,
8150 (void *)&cmd_dump_one_name,
8155 /* *** Add/Del syn filter *** */
8156 struct cmd_syn_filter_result {
8157 cmdline_fixed_string_t filter;
8159 cmdline_fixed_string_t ops;
8160 cmdline_fixed_string_t priority;
8161 cmdline_fixed_string_t high;
8162 cmdline_fixed_string_t queue;
8167 cmd_syn_filter_parsed(void *parsed_result,
8168 __attribute__((unused)) struct cmdline *cl,
8169 __attribute__((unused)) void *data)
8171 struct cmd_syn_filter_result *res = parsed_result;
8172 struct rte_eth_syn_filter syn_filter;
8175 ret = rte_eth_dev_filter_supported(res->port_id,
8176 RTE_ETH_FILTER_SYN);
8178 printf("syn filter is not supported on port %u.\n",
8183 memset(&syn_filter, 0, sizeof(syn_filter));
8185 if (!strcmp(res->ops, "add")) {
8186 if (!strcmp(res->high, "high"))
8187 syn_filter.hig_pri = 1;
8189 syn_filter.hig_pri = 0;
8191 syn_filter.queue = res->queue_id;
8192 ret = rte_eth_dev_filter_ctrl(res->port_id,
8197 ret = rte_eth_dev_filter_ctrl(res->port_id,
8199 RTE_ETH_FILTER_DELETE,
8203 printf("syn filter programming error: (%s)\n",
8207 cmdline_parse_token_string_t cmd_syn_filter_filter =
8208 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8209 filter, "syn_filter");
8210 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8211 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8213 cmdline_parse_token_string_t cmd_syn_filter_ops =
8214 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8216 cmdline_parse_token_string_t cmd_syn_filter_priority =
8217 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8218 priority, "priority");
8219 cmdline_parse_token_string_t cmd_syn_filter_high =
8220 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8222 cmdline_parse_token_string_t cmd_syn_filter_queue =
8223 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8225 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8226 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8229 cmdline_parse_inst_t cmd_syn_filter = {
8230 .f = cmd_syn_filter_parsed,
8232 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8233 "<queue_id>: Add/Delete syn filter",
8235 (void *)&cmd_syn_filter_filter,
8236 (void *)&cmd_syn_filter_port_id,
8237 (void *)&cmd_syn_filter_ops,
8238 (void *)&cmd_syn_filter_priority,
8239 (void *)&cmd_syn_filter_high,
8240 (void *)&cmd_syn_filter_queue,
8241 (void *)&cmd_syn_filter_queue_id,
8246 /* *** ADD/REMOVE A 2tuple FILTER *** */
8247 struct cmd_2tuple_filter_result {
8248 cmdline_fixed_string_t filter;
8250 cmdline_fixed_string_t ops;
8251 cmdline_fixed_string_t dst_port;
8252 uint16_t dst_port_value;
8253 cmdline_fixed_string_t protocol;
8254 uint8_t protocol_value;
8255 cmdline_fixed_string_t mask;
8257 cmdline_fixed_string_t tcp_flags;
8258 uint8_t tcp_flags_value;
8259 cmdline_fixed_string_t priority;
8260 uint8_t priority_value;
8261 cmdline_fixed_string_t queue;
8266 cmd_2tuple_filter_parsed(void *parsed_result,
8267 __attribute__((unused)) struct cmdline *cl,
8268 __attribute__((unused)) void *data)
8270 struct rte_eth_ntuple_filter filter;
8271 struct cmd_2tuple_filter_result *res = parsed_result;
8274 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8276 printf("ntuple filter is not supported on port %u.\n",
8281 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8283 filter.flags = RTE_2TUPLE_FLAGS;
8284 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8285 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8286 filter.proto = res->protocol_value;
8287 filter.priority = res->priority_value;
8288 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8289 printf("nonzero tcp_flags is only meaningful"
8290 " when protocol is TCP.\n");
8293 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8294 printf("invalid TCP flags.\n");
8298 if (res->tcp_flags_value != 0) {
8299 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8300 filter.tcp_flags = res->tcp_flags_value;
8303 /* need convert to big endian. */
8304 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8305 filter.queue = res->queue_id;
8307 if (!strcmp(res->ops, "add"))
8308 ret = rte_eth_dev_filter_ctrl(res->port_id,
8309 RTE_ETH_FILTER_NTUPLE,
8313 ret = rte_eth_dev_filter_ctrl(res->port_id,
8314 RTE_ETH_FILTER_NTUPLE,
8315 RTE_ETH_FILTER_DELETE,
8318 printf("2tuple filter programming error: (%s)\n",
8323 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
8324 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8325 filter, "2tuple_filter");
8326 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
8327 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8329 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
8330 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8332 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
8333 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8334 dst_port, "dst_port");
8335 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
8336 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8337 dst_port_value, UINT16);
8338 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
8339 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8340 protocol, "protocol");
8341 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
8342 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8343 protocol_value, UINT8);
8344 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8345 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8347 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8348 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8350 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8351 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8352 tcp_flags, "tcp_flags");
8353 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8354 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8355 tcp_flags_value, UINT8);
8356 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8357 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8358 priority, "priority");
8359 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8360 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8361 priority_value, UINT8);
8362 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8363 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8365 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8366 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8369 cmdline_parse_inst_t cmd_2tuple_filter = {
8370 .f = cmd_2tuple_filter_parsed,
8372 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8373 "<value> mask <value> tcp_flags <value> priority <value> queue "
8374 "<queue_id>: Add a 2tuple filter",
8376 (void *)&cmd_2tuple_filter_filter,
8377 (void *)&cmd_2tuple_filter_port_id,
8378 (void *)&cmd_2tuple_filter_ops,
8379 (void *)&cmd_2tuple_filter_dst_port,
8380 (void *)&cmd_2tuple_filter_dst_port_value,
8381 (void *)&cmd_2tuple_filter_protocol,
8382 (void *)&cmd_2tuple_filter_protocol_value,
8383 (void *)&cmd_2tuple_filter_mask,
8384 (void *)&cmd_2tuple_filter_mask_value,
8385 (void *)&cmd_2tuple_filter_tcp_flags,
8386 (void *)&cmd_2tuple_filter_tcp_flags_value,
8387 (void *)&cmd_2tuple_filter_priority,
8388 (void *)&cmd_2tuple_filter_priority_value,
8389 (void *)&cmd_2tuple_filter_queue,
8390 (void *)&cmd_2tuple_filter_queue_id,
8395 /* *** ADD/REMOVE A 5tuple FILTER *** */
8396 struct cmd_5tuple_filter_result {
8397 cmdline_fixed_string_t filter;
8399 cmdline_fixed_string_t ops;
8400 cmdline_fixed_string_t dst_ip;
8401 cmdline_ipaddr_t dst_ip_value;
8402 cmdline_fixed_string_t src_ip;
8403 cmdline_ipaddr_t src_ip_value;
8404 cmdline_fixed_string_t dst_port;
8405 uint16_t dst_port_value;
8406 cmdline_fixed_string_t src_port;
8407 uint16_t src_port_value;
8408 cmdline_fixed_string_t protocol;
8409 uint8_t protocol_value;
8410 cmdline_fixed_string_t mask;
8412 cmdline_fixed_string_t tcp_flags;
8413 uint8_t tcp_flags_value;
8414 cmdline_fixed_string_t priority;
8415 uint8_t priority_value;
8416 cmdline_fixed_string_t queue;
8421 cmd_5tuple_filter_parsed(void *parsed_result,
8422 __attribute__((unused)) struct cmdline *cl,
8423 __attribute__((unused)) void *data)
8425 struct rte_eth_ntuple_filter filter;
8426 struct cmd_5tuple_filter_result *res = parsed_result;
8429 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8431 printf("ntuple filter is not supported on port %u.\n",
8436 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8438 filter.flags = RTE_5TUPLE_FLAGS;
8439 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8440 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8441 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8442 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8443 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8444 filter.proto = res->protocol_value;
8445 filter.priority = res->priority_value;
8446 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8447 printf("nonzero tcp_flags is only meaningful"
8448 " when protocol is TCP.\n");
8451 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8452 printf("invalid TCP flags.\n");
8456 if (res->tcp_flags_value != 0) {
8457 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8458 filter.tcp_flags = res->tcp_flags_value;
8461 if (res->dst_ip_value.family == AF_INET)
8462 /* no need to convert, already big endian. */
8463 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8465 if (filter.dst_ip_mask == 0) {
8466 printf("can not support ipv6 involved compare.\n");
8472 if (res->src_ip_value.family == AF_INET)
8473 /* no need to convert, already big endian. */
8474 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8476 if (filter.src_ip_mask == 0) {
8477 printf("can not support ipv6 involved compare.\n");
8482 /* need convert to big endian. */
8483 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8484 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8485 filter.queue = res->queue_id;
8487 if (!strcmp(res->ops, "add"))
8488 ret = rte_eth_dev_filter_ctrl(res->port_id,
8489 RTE_ETH_FILTER_NTUPLE,
8493 ret = rte_eth_dev_filter_ctrl(res->port_id,
8494 RTE_ETH_FILTER_NTUPLE,
8495 RTE_ETH_FILTER_DELETE,
8498 printf("5tuple filter programming error: (%s)\n",
8502 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8503 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8504 filter, "5tuple_filter");
8505 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8506 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8508 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8509 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8511 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8512 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8514 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8515 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8517 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8518 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8520 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8521 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8523 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8524 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8525 dst_port, "dst_port");
8526 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8527 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8528 dst_port_value, UINT16);
8529 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8530 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8531 src_port, "src_port");
8532 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8533 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8534 src_port_value, UINT16);
8535 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8536 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8537 protocol, "protocol");
8538 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8539 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8540 protocol_value, UINT8);
8541 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8542 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8544 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8545 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8547 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8548 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8549 tcp_flags, "tcp_flags");
8550 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8551 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8552 tcp_flags_value, UINT8);
8553 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8554 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8555 priority, "priority");
8556 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8557 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8558 priority_value, UINT8);
8559 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8560 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8562 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8563 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8566 cmdline_parse_inst_t cmd_5tuple_filter = {
8567 .f = cmd_5tuple_filter_parsed,
8569 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8570 "src_ip <value> dst_port <value> src_port <value> "
8571 "protocol <value> mask <value> tcp_flags <value> "
8572 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8574 (void *)&cmd_5tuple_filter_filter,
8575 (void *)&cmd_5tuple_filter_port_id,
8576 (void *)&cmd_5tuple_filter_ops,
8577 (void *)&cmd_5tuple_filter_dst_ip,
8578 (void *)&cmd_5tuple_filter_dst_ip_value,
8579 (void *)&cmd_5tuple_filter_src_ip,
8580 (void *)&cmd_5tuple_filter_src_ip_value,
8581 (void *)&cmd_5tuple_filter_dst_port,
8582 (void *)&cmd_5tuple_filter_dst_port_value,
8583 (void *)&cmd_5tuple_filter_src_port,
8584 (void *)&cmd_5tuple_filter_src_port_value,
8585 (void *)&cmd_5tuple_filter_protocol,
8586 (void *)&cmd_5tuple_filter_protocol_value,
8587 (void *)&cmd_5tuple_filter_mask,
8588 (void *)&cmd_5tuple_filter_mask_value,
8589 (void *)&cmd_5tuple_filter_tcp_flags,
8590 (void *)&cmd_5tuple_filter_tcp_flags_value,
8591 (void *)&cmd_5tuple_filter_priority,
8592 (void *)&cmd_5tuple_filter_priority_value,
8593 (void *)&cmd_5tuple_filter_queue,
8594 (void *)&cmd_5tuple_filter_queue_id,
8599 /* *** ADD/REMOVE A flex FILTER *** */
8600 struct cmd_flex_filter_result {
8601 cmdline_fixed_string_t filter;
8602 cmdline_fixed_string_t ops;
8604 cmdline_fixed_string_t len;
8606 cmdline_fixed_string_t bytes;
8607 cmdline_fixed_string_t bytes_value;
8608 cmdline_fixed_string_t mask;
8609 cmdline_fixed_string_t mask_value;
8610 cmdline_fixed_string_t priority;
8611 uint8_t priority_value;
8612 cmdline_fixed_string_t queue;
8616 static int xdigit2val(unsigned char c)
8621 else if (isupper(c))
8629 cmd_flex_filter_parsed(void *parsed_result,
8630 __attribute__((unused)) struct cmdline *cl,
8631 __attribute__((unused)) void *data)
8634 struct rte_eth_flex_filter filter;
8635 struct cmd_flex_filter_result *res = parsed_result;
8636 char *bytes_ptr, *mask_ptr;
8637 uint16_t len, i, j = 0;
8642 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8643 printf("the len exceed the max length 128\n");
8646 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8647 filter.len = res->len_value;
8648 filter.priority = res->priority_value;
8649 filter.queue = res->queue_id;
8650 bytes_ptr = res->bytes_value;
8651 mask_ptr = res->mask_value;
8653 /* translate bytes string to array. */
8654 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8655 (bytes_ptr[1] == 'X')))
8657 len = strnlen(bytes_ptr, res->len_value * 2);
8658 if (len == 0 || (len % 8 != 0)) {
8659 printf("please check len and bytes input\n");
8662 for (i = 0; i < len; i++) {
8664 if (isxdigit(c) == 0) {
8665 /* invalid characters. */
8666 printf("invalid input\n");
8669 val = xdigit2val(c);
8672 filter.bytes[j] = byte;
8673 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8680 /* translate mask string to uint8_t array. */
8681 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8682 (mask_ptr[1] == 'X')))
8684 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8686 printf("invalid input\n");
8691 for (i = 0; i < len; i++) {
8693 if (isxdigit(c) == 0) {
8694 /* invalid characters. */
8695 printf("invalid input\n");
8698 val = xdigit2val(c);
8701 filter.mask[j] = byte;
8702 printf("mask[%d]:%02x ", j, filter.mask[j]);
8710 if (!strcmp(res->ops, "add"))
8711 ret = rte_eth_dev_filter_ctrl(res->port_id,
8712 RTE_ETH_FILTER_FLEXIBLE,
8716 ret = rte_eth_dev_filter_ctrl(res->port_id,
8717 RTE_ETH_FILTER_FLEXIBLE,
8718 RTE_ETH_FILTER_DELETE,
8722 printf("flex filter setting error: (%s)\n", strerror(-ret));
8725 cmdline_parse_token_string_t cmd_flex_filter_filter =
8726 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8727 filter, "flex_filter");
8728 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8729 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8731 cmdline_parse_token_string_t cmd_flex_filter_ops =
8732 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8734 cmdline_parse_token_string_t cmd_flex_filter_len =
8735 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8737 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8738 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8740 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8741 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8743 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8744 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8746 cmdline_parse_token_string_t cmd_flex_filter_mask =
8747 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8749 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8750 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8752 cmdline_parse_token_string_t cmd_flex_filter_priority =
8753 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8754 priority, "priority");
8755 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8756 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8757 priority_value, UINT8);
8758 cmdline_parse_token_string_t cmd_flex_filter_queue =
8759 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8761 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8762 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8764 cmdline_parse_inst_t cmd_flex_filter = {
8765 .f = cmd_flex_filter_parsed,
8767 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8768 "<value> mask <value> priority <value> queue <queue_id>: "
8769 "Add/Del a flex filter",
8771 (void *)&cmd_flex_filter_filter,
8772 (void *)&cmd_flex_filter_port_id,
8773 (void *)&cmd_flex_filter_ops,
8774 (void *)&cmd_flex_filter_len,
8775 (void *)&cmd_flex_filter_len_value,
8776 (void *)&cmd_flex_filter_bytes,
8777 (void *)&cmd_flex_filter_bytes_value,
8778 (void *)&cmd_flex_filter_mask,
8779 (void *)&cmd_flex_filter_mask_value,
8780 (void *)&cmd_flex_filter_priority,
8781 (void *)&cmd_flex_filter_priority_value,
8782 (void *)&cmd_flex_filter_queue,
8783 (void *)&cmd_flex_filter_queue_id,
8788 /* *** Filters Control *** */
8790 /* *** deal with ethertype filter *** */
8791 struct cmd_ethertype_filter_result {
8792 cmdline_fixed_string_t filter;
8794 cmdline_fixed_string_t ops;
8795 cmdline_fixed_string_t mac;
8796 struct ether_addr mac_addr;
8797 cmdline_fixed_string_t ethertype;
8798 uint16_t ethertype_value;
8799 cmdline_fixed_string_t drop;
8800 cmdline_fixed_string_t queue;
8804 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8805 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8806 filter, "ethertype_filter");
8807 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8808 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8810 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8811 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8813 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8814 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8815 mac, "mac_addr#mac_ignr");
8816 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8817 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8819 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8820 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8821 ethertype, "ethertype");
8822 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8823 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8824 ethertype_value, UINT16);
8825 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8826 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8828 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8829 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8831 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8832 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8836 cmd_ethertype_filter_parsed(void *parsed_result,
8837 __attribute__((unused)) struct cmdline *cl,
8838 __attribute__((unused)) void *data)
8840 struct cmd_ethertype_filter_result *res = parsed_result;
8841 struct rte_eth_ethertype_filter filter;
8844 ret = rte_eth_dev_filter_supported(res->port_id,
8845 RTE_ETH_FILTER_ETHERTYPE);
8847 printf("ethertype filter is not supported on port %u.\n",
8852 memset(&filter, 0, sizeof(filter));
8853 if (!strcmp(res->mac, "mac_addr")) {
8854 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8855 rte_memcpy(&filter.mac_addr, &res->mac_addr,
8856 sizeof(struct ether_addr));
8858 if (!strcmp(res->drop, "drop"))
8859 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8860 filter.ether_type = res->ethertype_value;
8861 filter.queue = res->queue_id;
8863 if (!strcmp(res->ops, "add"))
8864 ret = rte_eth_dev_filter_ctrl(res->port_id,
8865 RTE_ETH_FILTER_ETHERTYPE,
8869 ret = rte_eth_dev_filter_ctrl(res->port_id,
8870 RTE_ETH_FILTER_ETHERTYPE,
8871 RTE_ETH_FILTER_DELETE,
8874 printf("ethertype filter programming error: (%s)\n",
8878 cmdline_parse_inst_t cmd_ethertype_filter = {
8879 .f = cmd_ethertype_filter_parsed,
8881 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8882 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8883 "Add or delete an ethertype filter entry",
8885 (void *)&cmd_ethertype_filter_filter,
8886 (void *)&cmd_ethertype_filter_port_id,
8887 (void *)&cmd_ethertype_filter_ops,
8888 (void *)&cmd_ethertype_filter_mac,
8889 (void *)&cmd_ethertype_filter_mac_addr,
8890 (void *)&cmd_ethertype_filter_ethertype,
8891 (void *)&cmd_ethertype_filter_ethertype_value,
8892 (void *)&cmd_ethertype_filter_drop,
8893 (void *)&cmd_ethertype_filter_queue,
8894 (void *)&cmd_ethertype_filter_queue_id,
8899 /* *** deal with flow director filter *** */
8900 struct cmd_flow_director_result {
8901 cmdline_fixed_string_t flow_director_filter;
8903 cmdline_fixed_string_t mode;
8904 cmdline_fixed_string_t mode_value;
8905 cmdline_fixed_string_t ops;
8906 cmdline_fixed_string_t flow;
8907 cmdline_fixed_string_t flow_type;
8908 cmdline_fixed_string_t ether;
8909 uint16_t ether_type;
8910 cmdline_fixed_string_t src;
8911 cmdline_ipaddr_t ip_src;
8913 cmdline_fixed_string_t dst;
8914 cmdline_ipaddr_t ip_dst;
8916 cmdline_fixed_string_t verify_tag;
8917 uint32_t verify_tag_value;
8918 cmdline_ipaddr_t tos;
8920 cmdline_ipaddr_t proto;
8921 uint8_t proto_value;
8922 cmdline_ipaddr_t ttl;
8924 cmdline_fixed_string_t vlan;
8925 uint16_t vlan_value;
8926 cmdline_fixed_string_t flexbytes;
8927 cmdline_fixed_string_t flexbytes_value;
8928 cmdline_fixed_string_t pf_vf;
8929 cmdline_fixed_string_t drop;
8930 cmdline_fixed_string_t queue;
8932 cmdline_fixed_string_t fd_id;
8933 uint32_t fd_id_value;
8934 cmdline_fixed_string_t mac;
8935 struct ether_addr mac_addr;
8936 cmdline_fixed_string_t tunnel;
8937 cmdline_fixed_string_t tunnel_type;
8938 cmdline_fixed_string_t tunnel_id;
8939 uint32_t tunnel_id_value;
8943 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8946 const char *p, *p0 = q_arg;
8948 unsigned long int_fld;
8949 char *str_fld[max_num];
8954 p = strchr(p0, '(');
8958 p0 = strchr(p, ')');
8963 if (size >= sizeof(s))
8966 snprintf(s, sizeof(s), "%.*s", size, p);
8967 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8968 if (ret < 0 || ret > max_num)
8970 for (i = 0; i < ret; i++) {
8972 int_fld = strtoul(str_fld[i], &end, 0);
8973 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8975 flexbytes[i] = (uint8_t)int_fld;
8981 str2flowtype(char *string)
8984 static const struct {
8987 } flowtype_str[] = {
8988 {"raw", RTE_ETH_FLOW_RAW},
8989 {"ipv4", RTE_ETH_FLOW_IPV4},
8990 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8991 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8992 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8993 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8994 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8995 {"ipv6", RTE_ETH_FLOW_IPV6},
8996 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8997 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8998 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8999 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9000 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9001 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9004 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9005 if (!strcmp(flowtype_str[i].str, string))
9006 return flowtype_str[i].type;
9009 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9010 return (uint16_t)atoi(string);
9012 return RTE_ETH_FLOW_UNKNOWN;
9015 static enum rte_eth_fdir_tunnel_type
9016 str2fdir_tunneltype(char *string)
9020 static const struct {
9022 enum rte_eth_fdir_tunnel_type type;
9023 } tunneltype_str[] = {
9024 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9025 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9028 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9029 if (!strcmp(tunneltype_str[i].str, string))
9030 return tunneltype_str[i].type;
9032 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9035 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9037 if ((ip_addr).family == AF_INET) \
9038 (ip) = (ip_addr).addr.ipv4.s_addr; \
9040 printf("invalid parameter.\n"); \
9045 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9047 if ((ip_addr).family == AF_INET6) \
9049 &((ip_addr).addr.ipv6), \
9050 sizeof(struct in6_addr)); \
9052 printf("invalid parameter.\n"); \
9058 cmd_flow_director_filter_parsed(void *parsed_result,
9059 __attribute__((unused)) struct cmdline *cl,
9060 __attribute__((unused)) void *data)
9062 struct cmd_flow_director_result *res = parsed_result;
9063 struct rte_eth_fdir_filter entry;
9064 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9066 unsigned long vf_id;
9069 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9071 printf("flow director is not supported on port %u.\n",
9075 memset(flexbytes, 0, sizeof(flexbytes));
9076 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9078 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9079 if (strcmp(res->mode_value, "MAC-VLAN")) {
9080 printf("Please set mode to MAC-VLAN.\n");
9083 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9084 if (strcmp(res->mode_value, "Tunnel")) {
9085 printf("Please set mode to Tunnel.\n");
9089 if (strcmp(res->mode_value, "IP")) {
9090 printf("Please set mode to IP.\n");
9093 entry.input.flow_type = str2flowtype(res->flow_type);
9096 ret = parse_flexbytes(res->flexbytes_value,
9098 RTE_ETH_FDIR_MAX_FLEXLEN);
9100 printf("error: Cannot parse flexbytes input.\n");
9104 switch (entry.input.flow_type) {
9105 case RTE_ETH_FLOW_FRAG_IPV4:
9106 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9107 entry.input.flow.ip4_flow.proto = res->proto_value;
9109 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9110 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9111 IPV4_ADDR_TO_UINT(res->ip_dst,
9112 entry.input.flow.ip4_flow.dst_ip);
9113 IPV4_ADDR_TO_UINT(res->ip_src,
9114 entry.input.flow.ip4_flow.src_ip);
9115 entry.input.flow.ip4_flow.tos = res->tos_value;
9116 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9117 /* need convert to big endian. */
9118 entry.input.flow.udp4_flow.dst_port =
9119 rte_cpu_to_be_16(res->port_dst);
9120 entry.input.flow.udp4_flow.src_port =
9121 rte_cpu_to_be_16(res->port_src);
9123 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9124 IPV4_ADDR_TO_UINT(res->ip_dst,
9125 entry.input.flow.sctp4_flow.ip.dst_ip);
9126 IPV4_ADDR_TO_UINT(res->ip_src,
9127 entry.input.flow.sctp4_flow.ip.src_ip);
9128 entry.input.flow.ip4_flow.tos = res->tos_value;
9129 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9130 /* need convert to big endian. */
9131 entry.input.flow.sctp4_flow.dst_port =
9132 rte_cpu_to_be_16(res->port_dst);
9133 entry.input.flow.sctp4_flow.src_port =
9134 rte_cpu_to_be_16(res->port_src);
9135 entry.input.flow.sctp4_flow.verify_tag =
9136 rte_cpu_to_be_32(res->verify_tag_value);
9138 case RTE_ETH_FLOW_FRAG_IPV6:
9139 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9140 entry.input.flow.ipv6_flow.proto = res->proto_value;
9142 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9143 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9144 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9145 entry.input.flow.ipv6_flow.dst_ip);
9146 IPV6_ADDR_TO_ARRAY(res->ip_src,
9147 entry.input.flow.ipv6_flow.src_ip);
9148 entry.input.flow.ipv6_flow.tc = res->tos_value;
9149 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9150 /* need convert to big endian. */
9151 entry.input.flow.udp6_flow.dst_port =
9152 rte_cpu_to_be_16(res->port_dst);
9153 entry.input.flow.udp6_flow.src_port =
9154 rte_cpu_to_be_16(res->port_src);
9156 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9157 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9158 entry.input.flow.sctp6_flow.ip.dst_ip);
9159 IPV6_ADDR_TO_ARRAY(res->ip_src,
9160 entry.input.flow.sctp6_flow.ip.src_ip);
9161 entry.input.flow.ipv6_flow.tc = res->tos_value;
9162 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9163 /* need convert to big endian. */
9164 entry.input.flow.sctp6_flow.dst_port =
9165 rte_cpu_to_be_16(res->port_dst);
9166 entry.input.flow.sctp6_flow.src_port =
9167 rte_cpu_to_be_16(res->port_src);
9168 entry.input.flow.sctp6_flow.verify_tag =
9169 rte_cpu_to_be_32(res->verify_tag_value);
9171 case RTE_ETH_FLOW_L2_PAYLOAD:
9172 entry.input.flow.l2_flow.ether_type =
9173 rte_cpu_to_be_16(res->ether_type);
9179 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
9180 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
9182 sizeof(struct ether_addr));
9184 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9185 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
9187 sizeof(struct ether_addr));
9188 entry.input.flow.tunnel_flow.tunnel_type =
9189 str2fdir_tunneltype(res->tunnel_type);
9190 entry.input.flow.tunnel_flow.tunnel_id =
9191 rte_cpu_to_be_32(res->tunnel_id_value);
9194 rte_memcpy(entry.input.flow_ext.flexbytes,
9196 RTE_ETH_FDIR_MAX_FLEXLEN);
9198 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
9200 entry.action.flex_off = 0; /*use 0 by default */
9201 if (!strcmp(res->drop, "drop"))
9202 entry.action.behavior = RTE_ETH_FDIR_REJECT;
9204 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
9206 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
9207 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
9208 if (!strcmp(res->pf_vf, "pf"))
9209 entry.input.flow_ext.is_vf = 0;
9210 else if (!strncmp(res->pf_vf, "vf", 2)) {
9211 struct rte_eth_dev_info dev_info;
9213 memset(&dev_info, 0, sizeof(dev_info));
9214 rte_eth_dev_info_get(res->port_id, &dev_info);
9216 vf_id = strtoul(res->pf_vf + 2, &end, 10);
9217 if (errno != 0 || *end != '\0' ||
9218 vf_id >= dev_info.max_vfs) {
9219 printf("invalid parameter %s.\n", res->pf_vf);
9222 entry.input.flow_ext.is_vf = 1;
9223 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
9225 printf("invalid parameter %s.\n", res->pf_vf);
9230 /* set to report FD ID by default */
9231 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
9232 entry.action.rx_queue = res->queue_id;
9233 entry.soft_id = res->fd_id_value;
9234 if (!strcmp(res->ops, "add"))
9235 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9236 RTE_ETH_FILTER_ADD, &entry);
9237 else if (!strcmp(res->ops, "del"))
9238 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9239 RTE_ETH_FILTER_DELETE, &entry);
9241 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9242 RTE_ETH_FILTER_UPDATE, &entry);
9244 printf("flow director programming error: (%s)\n",
9248 cmdline_parse_token_string_t cmd_flow_director_filter =
9249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9250 flow_director_filter, "flow_director_filter");
9251 cmdline_parse_token_num_t cmd_flow_director_port_id =
9252 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9254 cmdline_parse_token_string_t cmd_flow_director_ops =
9255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9256 ops, "add#del#update");
9257 cmdline_parse_token_string_t cmd_flow_director_flow =
9258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9260 cmdline_parse_token_string_t cmd_flow_director_flow_type =
9261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9262 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9263 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
9264 cmdline_parse_token_string_t cmd_flow_director_ether =
9265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9267 cmdline_parse_token_num_t cmd_flow_director_ether_type =
9268 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9269 ether_type, UINT16);
9270 cmdline_parse_token_string_t cmd_flow_director_src =
9271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9273 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
9274 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9276 cmdline_parse_token_num_t cmd_flow_director_port_src =
9277 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9279 cmdline_parse_token_string_t cmd_flow_director_dst =
9280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9282 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
9283 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9285 cmdline_parse_token_num_t cmd_flow_director_port_dst =
9286 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9288 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
9289 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9290 verify_tag, "verify_tag");
9291 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
9292 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9293 verify_tag_value, UINT32);
9294 cmdline_parse_token_string_t cmd_flow_director_tos =
9295 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9297 cmdline_parse_token_num_t cmd_flow_director_tos_value =
9298 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9300 cmdline_parse_token_string_t cmd_flow_director_proto =
9301 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9303 cmdline_parse_token_num_t cmd_flow_director_proto_value =
9304 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9305 proto_value, UINT8);
9306 cmdline_parse_token_string_t cmd_flow_director_ttl =
9307 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9309 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
9310 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9312 cmdline_parse_token_string_t cmd_flow_director_vlan =
9313 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9315 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
9316 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9317 vlan_value, UINT16);
9318 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
9319 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9320 flexbytes, "flexbytes");
9321 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
9322 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9323 flexbytes_value, NULL);
9324 cmdline_parse_token_string_t cmd_flow_director_drop =
9325 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9327 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
9328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9330 cmdline_parse_token_string_t cmd_flow_director_queue =
9331 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9333 cmdline_parse_token_num_t cmd_flow_director_queue_id =
9334 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9336 cmdline_parse_token_string_t cmd_flow_director_fd_id =
9337 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9339 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
9340 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9341 fd_id_value, UINT32);
9343 cmdline_parse_token_string_t cmd_flow_director_mode =
9344 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9346 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
9347 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9349 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9350 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9351 mode_value, "MAC-VLAN");
9352 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9353 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9354 mode_value, "Tunnel");
9355 cmdline_parse_token_string_t cmd_flow_director_mac =
9356 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9358 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9359 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9361 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9364 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9366 tunnel_type, "NVGRE#VxLAN");
9367 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9368 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9369 tunnel_id, "tunnel-id");
9370 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9371 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9372 tunnel_id_value, UINT32);
9374 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9375 .f = cmd_flow_director_filter_parsed,
9377 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9378 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9379 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9380 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9381 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9382 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9383 "fd_id <fd_id_value>: "
9384 "Add or delete an ip flow director entry on NIC",
9386 (void *)&cmd_flow_director_filter,
9387 (void *)&cmd_flow_director_port_id,
9388 (void *)&cmd_flow_director_mode,
9389 (void *)&cmd_flow_director_mode_ip,
9390 (void *)&cmd_flow_director_ops,
9391 (void *)&cmd_flow_director_flow,
9392 (void *)&cmd_flow_director_flow_type,
9393 (void *)&cmd_flow_director_src,
9394 (void *)&cmd_flow_director_ip_src,
9395 (void *)&cmd_flow_director_dst,
9396 (void *)&cmd_flow_director_ip_dst,
9397 (void *)&cmd_flow_director_tos,
9398 (void *)&cmd_flow_director_tos_value,
9399 (void *)&cmd_flow_director_proto,
9400 (void *)&cmd_flow_director_proto_value,
9401 (void *)&cmd_flow_director_ttl,
9402 (void *)&cmd_flow_director_ttl_value,
9403 (void *)&cmd_flow_director_vlan,
9404 (void *)&cmd_flow_director_vlan_value,
9405 (void *)&cmd_flow_director_flexbytes,
9406 (void *)&cmd_flow_director_flexbytes_value,
9407 (void *)&cmd_flow_director_drop,
9408 (void *)&cmd_flow_director_pf_vf,
9409 (void *)&cmd_flow_director_queue,
9410 (void *)&cmd_flow_director_queue_id,
9411 (void *)&cmd_flow_director_fd_id,
9412 (void *)&cmd_flow_director_fd_id_value,
9417 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9418 .f = cmd_flow_director_filter_parsed,
9420 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9421 "director entry on NIC",
9423 (void *)&cmd_flow_director_filter,
9424 (void *)&cmd_flow_director_port_id,
9425 (void *)&cmd_flow_director_mode,
9426 (void *)&cmd_flow_director_mode_ip,
9427 (void *)&cmd_flow_director_ops,
9428 (void *)&cmd_flow_director_flow,
9429 (void *)&cmd_flow_director_flow_type,
9430 (void *)&cmd_flow_director_src,
9431 (void *)&cmd_flow_director_ip_src,
9432 (void *)&cmd_flow_director_port_src,
9433 (void *)&cmd_flow_director_dst,
9434 (void *)&cmd_flow_director_ip_dst,
9435 (void *)&cmd_flow_director_port_dst,
9436 (void *)&cmd_flow_director_tos,
9437 (void *)&cmd_flow_director_tos_value,
9438 (void *)&cmd_flow_director_ttl,
9439 (void *)&cmd_flow_director_ttl_value,
9440 (void *)&cmd_flow_director_vlan,
9441 (void *)&cmd_flow_director_vlan_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_pf_vf,
9446 (void *)&cmd_flow_director_queue,
9447 (void *)&cmd_flow_director_queue_id,
9448 (void *)&cmd_flow_director_fd_id,
9449 (void *)&cmd_flow_director_fd_id_value,
9454 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9455 .f = cmd_flow_director_filter_parsed,
9457 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9458 "director entry on NIC",
9460 (void *)&cmd_flow_director_filter,
9461 (void *)&cmd_flow_director_port_id,
9462 (void *)&cmd_flow_director_mode,
9463 (void *)&cmd_flow_director_mode_ip,
9464 (void *)&cmd_flow_director_ops,
9465 (void *)&cmd_flow_director_flow,
9466 (void *)&cmd_flow_director_flow_type,
9467 (void *)&cmd_flow_director_src,
9468 (void *)&cmd_flow_director_ip_src,
9469 (void *)&cmd_flow_director_port_dst,
9470 (void *)&cmd_flow_director_dst,
9471 (void *)&cmd_flow_director_ip_dst,
9472 (void *)&cmd_flow_director_port_dst,
9473 (void *)&cmd_flow_director_verify_tag,
9474 (void *)&cmd_flow_director_verify_tag_value,
9475 (void *)&cmd_flow_director_tos,
9476 (void *)&cmd_flow_director_tos_value,
9477 (void *)&cmd_flow_director_ttl,
9478 (void *)&cmd_flow_director_ttl_value,
9479 (void *)&cmd_flow_director_vlan,
9480 (void *)&cmd_flow_director_vlan_value,
9481 (void *)&cmd_flow_director_flexbytes,
9482 (void *)&cmd_flow_director_flexbytes_value,
9483 (void *)&cmd_flow_director_drop,
9484 (void *)&cmd_flow_director_pf_vf,
9485 (void *)&cmd_flow_director_queue,
9486 (void *)&cmd_flow_director_queue_id,
9487 (void *)&cmd_flow_director_fd_id,
9488 (void *)&cmd_flow_director_fd_id_value,
9493 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9494 .f = cmd_flow_director_filter_parsed,
9496 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9497 "director entry on NIC",
9499 (void *)&cmd_flow_director_filter,
9500 (void *)&cmd_flow_director_port_id,
9501 (void *)&cmd_flow_director_mode,
9502 (void *)&cmd_flow_director_mode_ip,
9503 (void *)&cmd_flow_director_ops,
9504 (void *)&cmd_flow_director_flow,
9505 (void *)&cmd_flow_director_flow_type,
9506 (void *)&cmd_flow_director_ether,
9507 (void *)&cmd_flow_director_ether_type,
9508 (void *)&cmd_flow_director_flexbytes,
9509 (void *)&cmd_flow_director_flexbytes_value,
9510 (void *)&cmd_flow_director_drop,
9511 (void *)&cmd_flow_director_pf_vf,
9512 (void *)&cmd_flow_director_queue,
9513 (void *)&cmd_flow_director_queue_id,
9514 (void *)&cmd_flow_director_fd_id,
9515 (void *)&cmd_flow_director_fd_id_value,
9520 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9521 .f = cmd_flow_director_filter_parsed,
9523 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9524 "director entry on NIC",
9526 (void *)&cmd_flow_director_filter,
9527 (void *)&cmd_flow_director_port_id,
9528 (void *)&cmd_flow_director_mode,
9529 (void *)&cmd_flow_director_mode_mac_vlan,
9530 (void *)&cmd_flow_director_ops,
9531 (void *)&cmd_flow_director_mac,
9532 (void *)&cmd_flow_director_mac_addr,
9533 (void *)&cmd_flow_director_vlan,
9534 (void *)&cmd_flow_director_vlan_value,
9535 (void *)&cmd_flow_director_flexbytes,
9536 (void *)&cmd_flow_director_flexbytes_value,
9537 (void *)&cmd_flow_director_drop,
9538 (void *)&cmd_flow_director_queue,
9539 (void *)&cmd_flow_director_queue_id,
9540 (void *)&cmd_flow_director_fd_id,
9541 (void *)&cmd_flow_director_fd_id_value,
9546 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9547 .f = cmd_flow_director_filter_parsed,
9549 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9550 "director entry on NIC",
9552 (void *)&cmd_flow_director_filter,
9553 (void *)&cmd_flow_director_port_id,
9554 (void *)&cmd_flow_director_mode,
9555 (void *)&cmd_flow_director_mode_tunnel,
9556 (void *)&cmd_flow_director_ops,
9557 (void *)&cmd_flow_director_mac,
9558 (void *)&cmd_flow_director_mac_addr,
9559 (void *)&cmd_flow_director_vlan,
9560 (void *)&cmd_flow_director_vlan_value,
9561 (void *)&cmd_flow_director_tunnel,
9562 (void *)&cmd_flow_director_tunnel_type,
9563 (void *)&cmd_flow_director_tunnel_id,
9564 (void *)&cmd_flow_director_tunnel_id_value,
9565 (void *)&cmd_flow_director_flexbytes,
9566 (void *)&cmd_flow_director_flexbytes_value,
9567 (void *)&cmd_flow_director_drop,
9568 (void *)&cmd_flow_director_queue,
9569 (void *)&cmd_flow_director_queue_id,
9570 (void *)&cmd_flow_director_fd_id,
9571 (void *)&cmd_flow_director_fd_id_value,
9576 struct cmd_flush_flow_director_result {
9577 cmdline_fixed_string_t flush_flow_director;
9581 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9582 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9583 flush_flow_director, "flush_flow_director");
9584 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9585 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9589 cmd_flush_flow_director_parsed(void *parsed_result,
9590 __attribute__((unused)) struct cmdline *cl,
9591 __attribute__((unused)) void *data)
9593 struct cmd_flow_director_result *res = parsed_result;
9596 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9598 printf("flow director is not supported on port %u.\n",
9603 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9604 RTE_ETH_FILTER_FLUSH, NULL);
9606 printf("flow director table flushing error: (%s)\n",
9610 cmdline_parse_inst_t cmd_flush_flow_director = {
9611 .f = cmd_flush_flow_director_parsed,
9613 .help_str = "flush_flow_director <port_id>: "
9614 "Flush all flow director entries of a device on NIC",
9616 (void *)&cmd_flush_flow_director_flush,
9617 (void *)&cmd_flush_flow_director_port_id,
9622 /* *** deal with flow director mask *** */
9623 struct cmd_flow_director_mask_result {
9624 cmdline_fixed_string_t flow_director_mask;
9626 cmdline_fixed_string_t mode;
9627 cmdline_fixed_string_t mode_value;
9628 cmdline_fixed_string_t vlan;
9630 cmdline_fixed_string_t src_mask;
9631 cmdline_ipaddr_t ipv4_src;
9632 cmdline_ipaddr_t ipv6_src;
9634 cmdline_fixed_string_t dst_mask;
9635 cmdline_ipaddr_t ipv4_dst;
9636 cmdline_ipaddr_t ipv6_dst;
9638 cmdline_fixed_string_t mac;
9639 uint8_t mac_addr_byte_mask;
9640 cmdline_fixed_string_t tunnel_id;
9641 uint32_t tunnel_id_mask;
9642 cmdline_fixed_string_t tunnel_type;
9643 uint8_t tunnel_type_mask;
9647 cmd_flow_director_mask_parsed(void *parsed_result,
9648 __attribute__((unused)) struct cmdline *cl,
9649 __attribute__((unused)) void *data)
9651 struct cmd_flow_director_mask_result *res = parsed_result;
9652 struct rte_eth_fdir_masks *mask;
9653 struct rte_port *port;
9655 if (res->port_id > nb_ports) {
9656 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9660 port = &ports[res->port_id];
9661 /** Check if the port is not started **/
9662 if (port->port_status != RTE_PORT_STOPPED) {
9663 printf("Please stop port %d first\n", res->port_id);
9667 mask = &port->dev_conf.fdir_conf.mask;
9669 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9670 if (strcmp(res->mode_value, "MAC-VLAN")) {
9671 printf("Please set mode to MAC-VLAN.\n");
9675 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9676 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9677 if (strcmp(res->mode_value, "Tunnel")) {
9678 printf("Please set mode to Tunnel.\n");
9682 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9683 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9684 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9685 mask->tunnel_type_mask = res->tunnel_type_mask;
9687 if (strcmp(res->mode_value, "IP")) {
9688 printf("Please set mode to IP.\n");
9692 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9693 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9694 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9695 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9696 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9697 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9698 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9701 cmd_reconfig_device_queue(res->port_id, 1, 1);
9704 cmdline_parse_token_string_t cmd_flow_director_mask =
9705 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9706 flow_director_mask, "flow_director_mask");
9707 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9708 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9710 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9711 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9713 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9714 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9716 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9718 src_mask, "src_mask");
9719 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9720 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9722 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9723 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9725 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9726 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9728 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9729 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9730 dst_mask, "dst_mask");
9731 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9732 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9734 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9735 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9737 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9738 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9741 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9744 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9745 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9747 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9748 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9749 mode_value, "MAC-VLAN");
9750 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9751 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9752 mode_value, "Tunnel");
9753 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9756 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9757 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9758 mac_addr_byte_mask, UINT8);
9759 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9761 tunnel_type, "tunnel-type");
9762 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9763 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9764 tunnel_type_mask, UINT8);
9765 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9767 tunnel_id, "tunnel-id");
9768 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9769 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9770 tunnel_id_mask, UINT32);
9772 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9773 .f = cmd_flow_director_mask_parsed,
9775 .help_str = "flow_director_mask ... : "
9776 "Set IP mode flow director's mask on NIC",
9778 (void *)&cmd_flow_director_mask,
9779 (void *)&cmd_flow_director_mask_port_id,
9780 (void *)&cmd_flow_director_mask_mode,
9781 (void *)&cmd_flow_director_mask_mode_ip,
9782 (void *)&cmd_flow_director_mask_vlan,
9783 (void *)&cmd_flow_director_mask_vlan_value,
9784 (void *)&cmd_flow_director_mask_src,
9785 (void *)&cmd_flow_director_mask_ipv4_src,
9786 (void *)&cmd_flow_director_mask_ipv6_src,
9787 (void *)&cmd_flow_director_mask_port_src,
9788 (void *)&cmd_flow_director_mask_dst,
9789 (void *)&cmd_flow_director_mask_ipv4_dst,
9790 (void *)&cmd_flow_director_mask_ipv6_dst,
9791 (void *)&cmd_flow_director_mask_port_dst,
9796 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9797 .f = cmd_flow_director_mask_parsed,
9799 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9800 "flow director's mask on NIC",
9802 (void *)&cmd_flow_director_mask,
9803 (void *)&cmd_flow_director_mask_port_id,
9804 (void *)&cmd_flow_director_mask_mode,
9805 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9806 (void *)&cmd_flow_director_mask_vlan,
9807 (void *)&cmd_flow_director_mask_vlan_value,
9812 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9813 .f = cmd_flow_director_mask_parsed,
9815 .help_str = "flow_director_mask ... : Set tunnel mode "
9816 "flow director's mask on NIC",
9818 (void *)&cmd_flow_director_mask,
9819 (void *)&cmd_flow_director_mask_port_id,
9820 (void *)&cmd_flow_director_mask_mode,
9821 (void *)&cmd_flow_director_mask_mode_tunnel,
9822 (void *)&cmd_flow_director_mask_vlan,
9823 (void *)&cmd_flow_director_mask_vlan_value,
9824 (void *)&cmd_flow_director_mask_mac,
9825 (void *)&cmd_flow_director_mask_mac_value,
9826 (void *)&cmd_flow_director_mask_tunnel_type,
9827 (void *)&cmd_flow_director_mask_tunnel_type_value,
9828 (void *)&cmd_flow_director_mask_tunnel_id,
9829 (void *)&cmd_flow_director_mask_tunnel_id_value,
9834 /* *** deal with flow director mask on flexible payload *** */
9835 struct cmd_flow_director_flex_mask_result {
9836 cmdline_fixed_string_t flow_director_flexmask;
9838 cmdline_fixed_string_t flow;
9839 cmdline_fixed_string_t flow_type;
9840 cmdline_fixed_string_t mask;
9844 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9845 __attribute__((unused)) struct cmdline *cl,
9846 __attribute__((unused)) void *data)
9848 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9849 struct rte_eth_fdir_info fdir_info;
9850 struct rte_eth_fdir_flex_mask flex_mask;
9851 struct rte_port *port;
9852 uint32_t flow_type_mask;
9856 if (res->port_id > nb_ports) {
9857 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9861 port = &ports[res->port_id];
9862 /** Check if the port is not started **/
9863 if (port->port_status != RTE_PORT_STOPPED) {
9864 printf("Please stop port %d first\n", res->port_id);
9868 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9869 ret = parse_flexbytes(res->mask,
9871 RTE_ETH_FDIR_MAX_FLEXLEN);
9873 printf("error: Cannot parse mask input.\n");
9877 memset(&fdir_info, 0, sizeof(fdir_info));
9878 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9879 RTE_ETH_FILTER_INFO, &fdir_info);
9881 printf("Cannot get FDir filter info\n");
9885 if (!strcmp(res->flow_type, "none")) {
9886 /* means don't specify the flow type */
9887 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9888 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9889 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9890 0, sizeof(struct rte_eth_fdir_flex_mask));
9891 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9892 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9894 sizeof(struct rte_eth_fdir_flex_mask));
9895 cmd_reconfig_device_queue(res->port_id, 1, 1);
9898 flow_type_mask = fdir_info.flow_types_mask[0];
9899 if (!strcmp(res->flow_type, "all")) {
9900 if (!flow_type_mask) {
9901 printf("No flow type supported\n");
9904 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9905 if (flow_type_mask & (1 << i)) {
9906 flex_mask.flow_type = i;
9907 fdir_set_flex_mask(res->port_id, &flex_mask);
9910 cmd_reconfig_device_queue(res->port_id, 1, 1);
9913 flex_mask.flow_type = str2flowtype(res->flow_type);
9914 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9915 printf("Flow type %s not supported on port %d\n",
9916 res->flow_type, res->port_id);
9919 fdir_set_flex_mask(res->port_id, &flex_mask);
9920 cmd_reconfig_device_queue(res->port_id, 1, 1);
9923 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9924 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9925 flow_director_flexmask,
9926 "flow_director_flex_mask");
9927 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9928 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9930 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9933 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9934 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9935 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9936 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9937 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9938 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9941 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9942 .f = cmd_flow_director_flex_mask_parsed,
9944 .help_str = "flow_director_flex_mask ... : "
9945 "Set flow director's flex mask on NIC",
9947 (void *)&cmd_flow_director_flexmask,
9948 (void *)&cmd_flow_director_flexmask_port_id,
9949 (void *)&cmd_flow_director_flexmask_flow,
9950 (void *)&cmd_flow_director_flexmask_flow_type,
9951 (void *)&cmd_flow_director_flexmask_mask,
9956 /* *** deal with flow director flexible payload configuration *** */
9957 struct cmd_flow_director_flexpayload_result {
9958 cmdline_fixed_string_t flow_director_flexpayload;
9960 cmdline_fixed_string_t payload_layer;
9961 cmdline_fixed_string_t payload_cfg;
9965 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9968 const char *p, *p0 = q_arg;
9970 unsigned long int_fld;
9971 char *str_fld[max_num];
9976 p = strchr(p0, '(');
9980 p0 = strchr(p, ')');
9985 if (size >= sizeof(s))
9988 snprintf(s, sizeof(s), "%.*s", size, p);
9989 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9990 if (ret < 0 || ret > max_num)
9992 for (i = 0; i < ret; i++) {
9994 int_fld = strtoul(str_fld[i], &end, 0);
9995 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9997 offsets[i] = (uint16_t)int_fld;
10003 cmd_flow_director_flxpld_parsed(void *parsed_result,
10004 __attribute__((unused)) struct cmdline *cl,
10005 __attribute__((unused)) void *data)
10007 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10008 struct rte_eth_flex_payload_cfg flex_cfg;
10009 struct rte_port *port;
10012 if (res->port_id > nb_ports) {
10013 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10017 port = &ports[res->port_id];
10018 /** Check if the port is not started **/
10019 if (port->port_status != RTE_PORT_STOPPED) {
10020 printf("Please stop port %d first\n", res->port_id);
10024 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10026 if (!strcmp(res->payload_layer, "raw"))
10027 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10028 else if (!strcmp(res->payload_layer, "l2"))
10029 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10030 else if (!strcmp(res->payload_layer, "l3"))
10031 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10032 else if (!strcmp(res->payload_layer, "l4"))
10033 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10035 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10036 RTE_ETH_FDIR_MAX_FLEXLEN);
10038 printf("error: Cannot parse flex payload input.\n");
10042 fdir_set_flex_payload(res->port_id, &flex_cfg);
10043 cmd_reconfig_device_queue(res->port_id, 1, 1);
10046 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10047 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10048 flow_director_flexpayload,
10049 "flow_director_flex_payload");
10050 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10051 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10053 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10054 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10055 payload_layer, "raw#l2#l3#l4");
10056 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10057 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10058 payload_cfg, NULL);
10060 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10061 .f = cmd_flow_director_flxpld_parsed,
10063 .help_str = "flow_director_flexpayload ... : "
10064 "Set flow director's flex payload on NIC",
10066 (void *)&cmd_flow_director_flexpayload,
10067 (void *)&cmd_flow_director_flexpayload_port_id,
10068 (void *)&cmd_flow_director_flexpayload_payload_layer,
10069 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10074 /* Generic flow interface command. */
10075 extern cmdline_parse_inst_t cmd_flow;
10077 /* *** Classification Filters Control *** */
10078 /* *** Get symmetric hash enable per port *** */
10079 struct cmd_get_sym_hash_ena_per_port_result {
10080 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10085 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10086 __rte_unused struct cmdline *cl,
10087 __rte_unused void *data)
10089 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10090 struct rte_eth_hash_filter_info info;
10093 if (rte_eth_dev_filter_supported(res->port_id,
10094 RTE_ETH_FILTER_HASH) < 0) {
10095 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10100 memset(&info, 0, sizeof(info));
10101 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10102 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10103 RTE_ETH_FILTER_GET, &info);
10106 printf("Cannot get symmetric hash enable per port "
10107 "on port %u\n", res->port_id);
10111 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10112 "enabled" : "disabled", res->port_id);
10115 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10116 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10117 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10118 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10119 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10122 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10123 .f = cmd_get_sym_hash_per_port_parsed,
10125 .help_str = "get_sym_hash_ena_per_port <port_id>",
10127 (void *)&cmd_get_sym_hash_ena_per_port_all,
10128 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10133 /* *** Set symmetric hash enable per port *** */
10134 struct cmd_set_sym_hash_ena_per_port_result {
10135 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10136 cmdline_fixed_string_t enable;
10141 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10142 __rte_unused struct cmdline *cl,
10143 __rte_unused void *data)
10145 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10146 struct rte_eth_hash_filter_info info;
10149 if (rte_eth_dev_filter_supported(res->port_id,
10150 RTE_ETH_FILTER_HASH) < 0) {
10151 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10156 memset(&info, 0, sizeof(info));
10157 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10158 if (!strcmp(res->enable, "enable"))
10159 info.info.enable = 1;
10160 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10161 RTE_ETH_FILTER_SET, &info);
10163 printf("Cannot set symmetric hash enable per port on "
10164 "port %u\n", res->port_id);
10167 printf("Symmetric hash has been set to %s on port %u\n",
10168 res->enable, res->port_id);
10171 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
10172 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10173 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
10174 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
10175 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10177 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
10178 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10179 enable, "enable#disable");
10181 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
10182 .f = cmd_set_sym_hash_per_port_parsed,
10184 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
10186 (void *)&cmd_set_sym_hash_ena_per_port_all,
10187 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
10188 (void *)&cmd_set_sym_hash_ena_per_port_enable,
10193 /* Get global config of hash function */
10194 struct cmd_get_hash_global_config_result {
10195 cmdline_fixed_string_t get_hash_global_config;
10200 flowtype_to_str(uint16_t ftype)
10206 } ftype_table[] = {
10207 {"ipv4", RTE_ETH_FLOW_IPV4},
10208 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10209 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10210 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10211 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10212 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10213 {"ipv6", RTE_ETH_FLOW_IPV6},
10214 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10215 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10216 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10217 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10218 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10219 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10220 {"port", RTE_ETH_FLOW_PORT},
10221 {"vxlan", RTE_ETH_FLOW_VXLAN},
10222 {"geneve", RTE_ETH_FLOW_GENEVE},
10223 {"nvgre", RTE_ETH_FLOW_NVGRE},
10226 for (i = 0; i < RTE_DIM(ftype_table); i++) {
10227 if (ftype_table[i].ftype == ftype)
10228 return ftype_table[i].str;
10235 cmd_get_hash_global_config_parsed(void *parsed_result,
10236 __rte_unused struct cmdline *cl,
10237 __rte_unused void *data)
10239 struct cmd_get_hash_global_config_result *res = parsed_result;
10240 struct rte_eth_hash_filter_info info;
10241 uint32_t idx, offset;
10246 if (rte_eth_dev_filter_supported(res->port_id,
10247 RTE_ETH_FILTER_HASH) < 0) {
10248 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10253 memset(&info, 0, sizeof(info));
10254 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10255 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10256 RTE_ETH_FILTER_GET, &info);
10258 printf("Cannot get hash global configurations by port %d\n",
10263 switch (info.info.global_conf.hash_func) {
10264 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
10265 printf("Hash function is Toeplitz\n");
10267 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
10268 printf("Hash function is Simple XOR\n");
10271 printf("Unknown hash function\n");
10275 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
10276 idx = i / UINT32_BIT;
10277 offset = i % UINT32_BIT;
10278 if (!(info.info.global_conf.valid_bit_mask[idx] &
10281 str = flowtype_to_str(i);
10284 printf("Symmetric hash is %s globally for flow type %s "
10286 ((info.info.global_conf.sym_hash_enable_mask[idx] &
10287 (1UL << offset)) ? "enabled" : "disabled"), str,
10292 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
10293 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
10294 get_hash_global_config, "get_hash_global_config");
10295 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
10296 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
10299 cmdline_parse_inst_t cmd_get_hash_global_config = {
10300 .f = cmd_get_hash_global_config_parsed,
10302 .help_str = "get_hash_global_config <port_id>",
10304 (void *)&cmd_get_hash_global_config_all,
10305 (void *)&cmd_get_hash_global_config_port_id,
10310 /* Set global config of hash function */
10311 struct cmd_set_hash_global_config_result {
10312 cmdline_fixed_string_t set_hash_global_config;
10314 cmdline_fixed_string_t hash_func;
10315 cmdline_fixed_string_t flow_type;
10316 cmdline_fixed_string_t enable;
10320 cmd_set_hash_global_config_parsed(void *parsed_result,
10321 __rte_unused struct cmdline *cl,
10322 __rte_unused void *data)
10324 struct cmd_set_hash_global_config_result *res = parsed_result;
10325 struct rte_eth_hash_filter_info info;
10326 uint32_t ftype, idx, offset;
10329 if (rte_eth_dev_filter_supported(res->port_id,
10330 RTE_ETH_FILTER_HASH) < 0) {
10331 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10335 memset(&info, 0, sizeof(info));
10336 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10337 if (!strcmp(res->hash_func, "toeplitz"))
10338 info.info.global_conf.hash_func =
10339 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
10340 else if (!strcmp(res->hash_func, "simple_xor"))
10341 info.info.global_conf.hash_func =
10342 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
10343 else if (!strcmp(res->hash_func, "default"))
10344 info.info.global_conf.hash_func =
10345 RTE_ETH_HASH_FUNCTION_DEFAULT;
10347 ftype = str2flowtype(res->flow_type);
10348 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10349 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10350 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10351 if (!strcmp(res->enable, "enable"))
10352 info.info.global_conf.sym_hash_enable_mask[idx] |=
10354 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10355 RTE_ETH_FILTER_SET, &info);
10357 printf("Cannot set global hash configurations by port %d\n",
10360 printf("Global hash configurations have been set "
10361 "succcessfully by port %d\n", res->port_id);
10364 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10365 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10366 set_hash_global_config, "set_hash_global_config");
10367 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10368 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10370 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10371 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10372 hash_func, "toeplitz#simple_xor#default");
10373 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10374 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10376 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10377 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10378 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10379 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10380 enable, "enable#disable");
10382 cmdline_parse_inst_t cmd_set_hash_global_config = {
10383 .f = cmd_set_hash_global_config_parsed,
10385 .help_str = "set_hash_global_config <port_id> "
10386 "toeplitz|simple_xor|default "
10387 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10388 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10389 "l2_payload enable|disable",
10391 (void *)&cmd_set_hash_global_config_all,
10392 (void *)&cmd_set_hash_global_config_port_id,
10393 (void *)&cmd_set_hash_global_config_hash_func,
10394 (void *)&cmd_set_hash_global_config_flow_type,
10395 (void *)&cmd_set_hash_global_config_enable,
10400 /* Set hash input set */
10401 struct cmd_set_hash_input_set_result {
10402 cmdline_fixed_string_t set_hash_input_set;
10404 cmdline_fixed_string_t flow_type;
10405 cmdline_fixed_string_t inset_field;
10406 cmdline_fixed_string_t select;
10409 static enum rte_eth_input_set_field
10410 str2inset(char *string)
10414 static const struct {
10416 enum rte_eth_input_set_field inset;
10417 } inset_table[] = {
10418 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10419 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10420 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10421 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10422 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10423 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10424 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10425 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10426 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10427 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10428 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10429 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10430 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10431 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10432 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10433 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10434 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10435 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10436 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10437 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10438 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10439 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10440 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10441 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10442 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10443 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10444 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10445 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10446 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10447 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10448 {"none", RTE_ETH_INPUT_SET_NONE},
10451 for (i = 0; i < RTE_DIM(inset_table); i++) {
10452 if (!strcmp(string, inset_table[i].str))
10453 return inset_table[i].inset;
10456 return RTE_ETH_INPUT_SET_UNKNOWN;
10460 cmd_set_hash_input_set_parsed(void *parsed_result,
10461 __rte_unused struct cmdline *cl,
10462 __rte_unused void *data)
10464 struct cmd_set_hash_input_set_result *res = parsed_result;
10465 struct rte_eth_hash_filter_info info;
10467 memset(&info, 0, sizeof(info));
10468 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10469 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10470 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10471 info.info.input_set_conf.inset_size = 1;
10472 if (!strcmp(res->select, "select"))
10473 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10474 else if (!strcmp(res->select, "add"))
10475 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10476 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10477 RTE_ETH_FILTER_SET, &info);
10480 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10481 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10482 set_hash_input_set, "set_hash_input_set");
10483 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10484 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10486 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10487 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10489 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10490 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10492 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10493 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10494 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10495 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10496 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10498 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10499 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10500 select, "select#add");
10502 cmdline_parse_inst_t cmd_set_hash_input_set = {
10503 .f = cmd_set_hash_input_set_parsed,
10505 .help_str = "set_hash_input_set <port_id> "
10506 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10507 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
10508 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10509 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10510 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10511 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10512 "fld-7th|fld-8th|none select|add",
10514 (void *)&cmd_set_hash_input_set_cmd,
10515 (void *)&cmd_set_hash_input_set_port_id,
10516 (void *)&cmd_set_hash_input_set_flow_type,
10517 (void *)&cmd_set_hash_input_set_field,
10518 (void *)&cmd_set_hash_input_set_select,
10523 /* Set flow director input set */
10524 struct cmd_set_fdir_input_set_result {
10525 cmdline_fixed_string_t set_fdir_input_set;
10527 cmdline_fixed_string_t flow_type;
10528 cmdline_fixed_string_t inset_field;
10529 cmdline_fixed_string_t select;
10533 cmd_set_fdir_input_set_parsed(void *parsed_result,
10534 __rte_unused struct cmdline *cl,
10535 __rte_unused void *data)
10537 struct cmd_set_fdir_input_set_result *res = parsed_result;
10538 struct rte_eth_fdir_filter_info info;
10540 memset(&info, 0, sizeof(info));
10541 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10542 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10543 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10544 info.info.input_set_conf.inset_size = 1;
10545 if (!strcmp(res->select, "select"))
10546 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10547 else if (!strcmp(res->select, "add"))
10548 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10549 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10550 RTE_ETH_FILTER_SET, &info);
10553 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10554 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10555 set_fdir_input_set, "set_fdir_input_set");
10556 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10557 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10559 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10560 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10562 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10563 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10564 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10565 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10567 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10568 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10569 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10570 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10571 "sctp-veri-tag#none");
10572 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10573 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10574 select, "select#add");
10576 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10577 .f = cmd_set_fdir_input_set_parsed,
10579 .help_str = "set_fdir_input_set <port_id> "
10580 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10581 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10582 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10583 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10584 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10585 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10586 "sctp-veri-tag|none select|add",
10588 (void *)&cmd_set_fdir_input_set_cmd,
10589 (void *)&cmd_set_fdir_input_set_port_id,
10590 (void *)&cmd_set_fdir_input_set_flow_type,
10591 (void *)&cmd_set_fdir_input_set_field,
10592 (void *)&cmd_set_fdir_input_set_select,
10597 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10598 struct cmd_mcast_addr_result {
10599 cmdline_fixed_string_t mcast_addr_cmd;
10600 cmdline_fixed_string_t what;
10602 struct ether_addr mc_addr;
10605 static void cmd_mcast_addr_parsed(void *parsed_result,
10606 __attribute__((unused)) struct cmdline *cl,
10607 __attribute__((unused)) void *data)
10609 struct cmd_mcast_addr_result *res = parsed_result;
10611 if (!is_multicast_ether_addr(&res->mc_addr)) {
10612 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10613 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10614 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10615 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10618 if (strcmp(res->what, "add") == 0)
10619 mcast_addr_add(res->port_num, &res->mc_addr);
10621 mcast_addr_remove(res->port_num, &res->mc_addr);
10624 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10625 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10626 mcast_addr_cmd, "mcast_addr");
10627 cmdline_parse_token_string_t cmd_mcast_addr_what =
10628 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10630 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10631 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10632 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10633 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10635 cmdline_parse_inst_t cmd_mcast_addr = {
10636 .f = cmd_mcast_addr_parsed,
10638 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10639 "Add/Remove multicast MAC address on port_id",
10641 (void *)&cmd_mcast_addr_cmd,
10642 (void *)&cmd_mcast_addr_what,
10643 (void *)&cmd_mcast_addr_portnum,
10644 (void *)&cmd_mcast_addr_addr,
10649 /* l2 tunnel config
10650 * only support E-tag now.
10653 /* Ether type config */
10654 struct cmd_config_l2_tunnel_eth_type_result {
10655 cmdline_fixed_string_t port;
10656 cmdline_fixed_string_t config;
10657 cmdline_fixed_string_t all;
10659 cmdline_fixed_string_t l2_tunnel;
10660 cmdline_fixed_string_t l2_tunnel_type;
10661 cmdline_fixed_string_t eth_type;
10662 uint16_t eth_type_val;
10665 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10666 TOKEN_STRING_INITIALIZER
10667 (struct cmd_config_l2_tunnel_eth_type_result,
10669 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10670 TOKEN_STRING_INITIALIZER
10671 (struct cmd_config_l2_tunnel_eth_type_result,
10673 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10674 TOKEN_STRING_INITIALIZER
10675 (struct cmd_config_l2_tunnel_eth_type_result,
10677 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10678 TOKEN_NUM_INITIALIZER
10679 (struct cmd_config_l2_tunnel_eth_type_result,
10681 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10682 TOKEN_STRING_INITIALIZER
10683 (struct cmd_config_l2_tunnel_eth_type_result,
10684 l2_tunnel, "l2-tunnel");
10685 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10686 TOKEN_STRING_INITIALIZER
10687 (struct cmd_config_l2_tunnel_eth_type_result,
10688 l2_tunnel_type, "E-tag");
10689 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10690 TOKEN_STRING_INITIALIZER
10691 (struct cmd_config_l2_tunnel_eth_type_result,
10692 eth_type, "ether-type");
10693 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10694 TOKEN_NUM_INITIALIZER
10695 (struct cmd_config_l2_tunnel_eth_type_result,
10696 eth_type_val, UINT16);
10698 static enum rte_eth_tunnel_type
10699 str2fdir_l2_tunnel_type(char *string)
10703 static const struct {
10705 enum rte_eth_tunnel_type type;
10706 } l2_tunnel_type_str[] = {
10707 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10710 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10711 if (!strcmp(l2_tunnel_type_str[i].str, string))
10712 return l2_tunnel_type_str[i].type;
10714 return RTE_TUNNEL_TYPE_NONE;
10717 /* ether type config for all ports */
10719 cmd_config_l2_tunnel_eth_type_all_parsed
10720 (void *parsed_result,
10721 __attribute__((unused)) struct cmdline *cl,
10722 __attribute__((unused)) void *data)
10724 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10725 struct rte_eth_l2_tunnel_conf entry;
10728 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10729 entry.ether_type = res->eth_type_val;
10731 RTE_ETH_FOREACH_DEV(pid) {
10732 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10736 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10737 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10739 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10741 (void *)&cmd_config_l2_tunnel_eth_type_port,
10742 (void *)&cmd_config_l2_tunnel_eth_type_config,
10743 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10744 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10745 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10746 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10747 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10752 /* ether type config for a specific port */
10754 cmd_config_l2_tunnel_eth_type_specific_parsed(
10755 void *parsed_result,
10756 __attribute__((unused)) struct cmdline *cl,
10757 __attribute__((unused)) void *data)
10759 struct cmd_config_l2_tunnel_eth_type_result *res =
10761 struct rte_eth_l2_tunnel_conf entry;
10763 if (port_id_is_invalid(res->id, ENABLED_WARN))
10766 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10767 entry.ether_type = res->eth_type_val;
10769 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10772 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10773 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10775 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10777 (void *)&cmd_config_l2_tunnel_eth_type_port,
10778 (void *)&cmd_config_l2_tunnel_eth_type_config,
10779 (void *)&cmd_config_l2_tunnel_eth_type_id,
10780 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10781 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10782 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10783 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10788 /* Enable/disable l2 tunnel */
10789 struct cmd_config_l2_tunnel_en_dis_result {
10790 cmdline_fixed_string_t port;
10791 cmdline_fixed_string_t config;
10792 cmdline_fixed_string_t all;
10794 cmdline_fixed_string_t l2_tunnel;
10795 cmdline_fixed_string_t l2_tunnel_type;
10796 cmdline_fixed_string_t en_dis;
10799 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10800 TOKEN_STRING_INITIALIZER
10801 (struct cmd_config_l2_tunnel_en_dis_result,
10803 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10804 TOKEN_STRING_INITIALIZER
10805 (struct cmd_config_l2_tunnel_en_dis_result,
10807 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10808 TOKEN_STRING_INITIALIZER
10809 (struct cmd_config_l2_tunnel_en_dis_result,
10811 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10812 TOKEN_NUM_INITIALIZER
10813 (struct cmd_config_l2_tunnel_en_dis_result,
10815 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10816 TOKEN_STRING_INITIALIZER
10817 (struct cmd_config_l2_tunnel_en_dis_result,
10818 l2_tunnel, "l2-tunnel");
10819 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10820 TOKEN_STRING_INITIALIZER
10821 (struct cmd_config_l2_tunnel_en_dis_result,
10822 l2_tunnel_type, "E-tag");
10823 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10824 TOKEN_STRING_INITIALIZER
10825 (struct cmd_config_l2_tunnel_en_dis_result,
10826 en_dis, "enable#disable");
10828 /* enable/disable l2 tunnel for all ports */
10830 cmd_config_l2_tunnel_en_dis_all_parsed(
10831 void *parsed_result,
10832 __attribute__((unused)) struct cmdline *cl,
10833 __attribute__((unused)) void *data)
10835 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10836 struct rte_eth_l2_tunnel_conf entry;
10840 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10842 if (!strcmp("enable", res->en_dis))
10847 RTE_ETH_FOREACH_DEV(pid) {
10848 rte_eth_dev_l2_tunnel_offload_set(pid,
10850 ETH_L2_TUNNEL_ENABLE_MASK,
10855 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10856 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10858 .help_str = "port config all l2-tunnel E-tag enable|disable",
10860 (void *)&cmd_config_l2_tunnel_en_dis_port,
10861 (void *)&cmd_config_l2_tunnel_en_dis_config,
10862 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10863 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10864 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10865 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10870 /* enable/disable l2 tunnel for a port */
10872 cmd_config_l2_tunnel_en_dis_specific_parsed(
10873 void *parsed_result,
10874 __attribute__((unused)) struct cmdline *cl,
10875 __attribute__((unused)) void *data)
10877 struct cmd_config_l2_tunnel_en_dis_result *res =
10879 struct rte_eth_l2_tunnel_conf entry;
10881 if (port_id_is_invalid(res->id, ENABLED_WARN))
10884 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10886 if (!strcmp("enable", res->en_dis))
10887 rte_eth_dev_l2_tunnel_offload_set(res->id,
10889 ETH_L2_TUNNEL_ENABLE_MASK,
10892 rte_eth_dev_l2_tunnel_offload_set(res->id,
10894 ETH_L2_TUNNEL_ENABLE_MASK,
10898 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10899 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10901 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10903 (void *)&cmd_config_l2_tunnel_en_dis_port,
10904 (void *)&cmd_config_l2_tunnel_en_dis_config,
10905 (void *)&cmd_config_l2_tunnel_en_dis_id,
10906 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10907 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10908 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10913 /* E-tag configuration */
10915 /* Common result structure for all E-tag configuration */
10916 struct cmd_config_e_tag_result {
10917 cmdline_fixed_string_t e_tag;
10918 cmdline_fixed_string_t set;
10919 cmdline_fixed_string_t insertion;
10920 cmdline_fixed_string_t stripping;
10921 cmdline_fixed_string_t forwarding;
10922 cmdline_fixed_string_t filter;
10923 cmdline_fixed_string_t add;
10924 cmdline_fixed_string_t del;
10925 cmdline_fixed_string_t on;
10926 cmdline_fixed_string_t off;
10927 cmdline_fixed_string_t on_off;
10928 cmdline_fixed_string_t port_tag_id;
10929 uint32_t port_tag_id_val;
10930 cmdline_fixed_string_t e_tag_id;
10931 uint16_t e_tag_id_val;
10932 cmdline_fixed_string_t dst_pool;
10933 uint8_t dst_pool_val;
10934 cmdline_fixed_string_t port;
10936 cmdline_fixed_string_t vf;
10940 /* Common CLI fields for all E-tag configuration */
10941 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10942 TOKEN_STRING_INITIALIZER
10943 (struct cmd_config_e_tag_result,
10945 cmdline_parse_token_string_t cmd_config_e_tag_set =
10946 TOKEN_STRING_INITIALIZER
10947 (struct cmd_config_e_tag_result,
10949 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10950 TOKEN_STRING_INITIALIZER
10951 (struct cmd_config_e_tag_result,
10952 insertion, "insertion");
10953 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10954 TOKEN_STRING_INITIALIZER
10955 (struct cmd_config_e_tag_result,
10956 stripping, "stripping");
10957 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10958 TOKEN_STRING_INITIALIZER
10959 (struct cmd_config_e_tag_result,
10960 forwarding, "forwarding");
10961 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10962 TOKEN_STRING_INITIALIZER
10963 (struct cmd_config_e_tag_result,
10965 cmdline_parse_token_string_t cmd_config_e_tag_add =
10966 TOKEN_STRING_INITIALIZER
10967 (struct cmd_config_e_tag_result,
10969 cmdline_parse_token_string_t cmd_config_e_tag_del =
10970 TOKEN_STRING_INITIALIZER
10971 (struct cmd_config_e_tag_result,
10973 cmdline_parse_token_string_t cmd_config_e_tag_on =
10974 TOKEN_STRING_INITIALIZER
10975 (struct cmd_config_e_tag_result,
10977 cmdline_parse_token_string_t cmd_config_e_tag_off =
10978 TOKEN_STRING_INITIALIZER
10979 (struct cmd_config_e_tag_result,
10981 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10982 TOKEN_STRING_INITIALIZER
10983 (struct cmd_config_e_tag_result,
10985 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10986 TOKEN_STRING_INITIALIZER
10987 (struct cmd_config_e_tag_result,
10988 port_tag_id, "port-tag-id");
10989 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10990 TOKEN_NUM_INITIALIZER
10991 (struct cmd_config_e_tag_result,
10992 port_tag_id_val, UINT32);
10993 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10994 TOKEN_STRING_INITIALIZER
10995 (struct cmd_config_e_tag_result,
10996 e_tag_id, "e-tag-id");
10997 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10998 TOKEN_NUM_INITIALIZER
10999 (struct cmd_config_e_tag_result,
11000 e_tag_id_val, UINT16);
11001 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11002 TOKEN_STRING_INITIALIZER
11003 (struct cmd_config_e_tag_result,
11004 dst_pool, "dst-pool");
11005 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11006 TOKEN_NUM_INITIALIZER
11007 (struct cmd_config_e_tag_result,
11008 dst_pool_val, UINT8);
11009 cmdline_parse_token_string_t cmd_config_e_tag_port =
11010 TOKEN_STRING_INITIALIZER
11011 (struct cmd_config_e_tag_result,
11013 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11014 TOKEN_NUM_INITIALIZER
11015 (struct cmd_config_e_tag_result,
11017 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11018 TOKEN_STRING_INITIALIZER
11019 (struct cmd_config_e_tag_result,
11021 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11022 TOKEN_NUM_INITIALIZER
11023 (struct cmd_config_e_tag_result,
11026 /* E-tag insertion configuration */
11028 cmd_config_e_tag_insertion_en_parsed(
11029 void *parsed_result,
11030 __attribute__((unused)) struct cmdline *cl,
11031 __attribute__((unused)) void *data)
11033 struct cmd_config_e_tag_result *res =
11035 struct rte_eth_l2_tunnel_conf entry;
11037 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11040 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11041 entry.tunnel_id = res->port_tag_id_val;
11042 entry.vf_id = res->vf_id;
11043 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11045 ETH_L2_TUNNEL_INSERTION_MASK,
11050 cmd_config_e_tag_insertion_dis_parsed(
11051 void *parsed_result,
11052 __attribute__((unused)) struct cmdline *cl,
11053 __attribute__((unused)) void *data)
11055 struct cmd_config_e_tag_result *res =
11057 struct rte_eth_l2_tunnel_conf entry;
11059 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11062 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11063 entry.vf_id = res->vf_id;
11065 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11067 ETH_L2_TUNNEL_INSERTION_MASK,
11071 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11072 .f = cmd_config_e_tag_insertion_en_parsed,
11074 .help_str = "E-tag ... : E-tag insertion enable",
11076 (void *)&cmd_config_e_tag_e_tag,
11077 (void *)&cmd_config_e_tag_set,
11078 (void *)&cmd_config_e_tag_insertion,
11079 (void *)&cmd_config_e_tag_on,
11080 (void *)&cmd_config_e_tag_port_tag_id,
11081 (void *)&cmd_config_e_tag_port_tag_id_val,
11082 (void *)&cmd_config_e_tag_port,
11083 (void *)&cmd_config_e_tag_port_id,
11084 (void *)&cmd_config_e_tag_vf,
11085 (void *)&cmd_config_e_tag_vf_id,
11090 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11091 .f = cmd_config_e_tag_insertion_dis_parsed,
11093 .help_str = "E-tag ... : E-tag insertion disable",
11095 (void *)&cmd_config_e_tag_e_tag,
11096 (void *)&cmd_config_e_tag_set,
11097 (void *)&cmd_config_e_tag_insertion,
11098 (void *)&cmd_config_e_tag_off,
11099 (void *)&cmd_config_e_tag_port,
11100 (void *)&cmd_config_e_tag_port_id,
11101 (void *)&cmd_config_e_tag_vf,
11102 (void *)&cmd_config_e_tag_vf_id,
11107 /* E-tag stripping configuration */
11109 cmd_config_e_tag_stripping_parsed(
11110 void *parsed_result,
11111 __attribute__((unused)) struct cmdline *cl,
11112 __attribute__((unused)) void *data)
11114 struct cmd_config_e_tag_result *res =
11116 struct rte_eth_l2_tunnel_conf entry;
11118 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11121 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11123 if (!strcmp(res->on_off, "on"))
11124 rte_eth_dev_l2_tunnel_offload_set
11127 ETH_L2_TUNNEL_STRIPPING_MASK,
11130 rte_eth_dev_l2_tunnel_offload_set
11133 ETH_L2_TUNNEL_STRIPPING_MASK,
11137 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11138 .f = cmd_config_e_tag_stripping_parsed,
11140 .help_str = "E-tag ... : E-tag stripping enable/disable",
11142 (void *)&cmd_config_e_tag_e_tag,
11143 (void *)&cmd_config_e_tag_set,
11144 (void *)&cmd_config_e_tag_stripping,
11145 (void *)&cmd_config_e_tag_on_off,
11146 (void *)&cmd_config_e_tag_port,
11147 (void *)&cmd_config_e_tag_port_id,
11152 /* E-tag forwarding configuration */
11154 cmd_config_e_tag_forwarding_parsed(
11155 void *parsed_result,
11156 __attribute__((unused)) struct cmdline *cl,
11157 __attribute__((unused)) void *data)
11159 struct cmd_config_e_tag_result *res = parsed_result;
11160 struct rte_eth_l2_tunnel_conf entry;
11162 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11165 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11167 if (!strcmp(res->on_off, "on"))
11168 rte_eth_dev_l2_tunnel_offload_set
11171 ETH_L2_TUNNEL_FORWARDING_MASK,
11174 rte_eth_dev_l2_tunnel_offload_set
11177 ETH_L2_TUNNEL_FORWARDING_MASK,
11181 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11182 .f = cmd_config_e_tag_forwarding_parsed,
11184 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11186 (void *)&cmd_config_e_tag_e_tag,
11187 (void *)&cmd_config_e_tag_set,
11188 (void *)&cmd_config_e_tag_forwarding,
11189 (void *)&cmd_config_e_tag_on_off,
11190 (void *)&cmd_config_e_tag_port,
11191 (void *)&cmd_config_e_tag_port_id,
11196 /* E-tag filter configuration */
11198 cmd_config_e_tag_filter_add_parsed(
11199 void *parsed_result,
11200 __attribute__((unused)) struct cmdline *cl,
11201 __attribute__((unused)) void *data)
11203 struct cmd_config_e_tag_result *res = parsed_result;
11204 struct rte_eth_l2_tunnel_conf entry;
11207 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11210 if (res->e_tag_id_val > 0x3fff) {
11211 printf("e-tag-id must be equal or less than 0x3fff.\n");
11215 ret = rte_eth_dev_filter_supported(res->port_id,
11216 RTE_ETH_FILTER_L2_TUNNEL);
11218 printf("E-tag filter is not supported on port %u.\n",
11223 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11224 entry.tunnel_id = res->e_tag_id_val;
11225 entry.pool = res->dst_pool_val;
11227 ret = rte_eth_dev_filter_ctrl(res->port_id,
11228 RTE_ETH_FILTER_L2_TUNNEL,
11229 RTE_ETH_FILTER_ADD,
11232 printf("E-tag filter programming error: (%s)\n",
11236 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
11237 .f = cmd_config_e_tag_filter_add_parsed,
11239 .help_str = "E-tag ... : E-tag filter add",
11241 (void *)&cmd_config_e_tag_e_tag,
11242 (void *)&cmd_config_e_tag_set,
11243 (void *)&cmd_config_e_tag_filter,
11244 (void *)&cmd_config_e_tag_add,
11245 (void *)&cmd_config_e_tag_e_tag_id,
11246 (void *)&cmd_config_e_tag_e_tag_id_val,
11247 (void *)&cmd_config_e_tag_dst_pool,
11248 (void *)&cmd_config_e_tag_dst_pool_val,
11249 (void *)&cmd_config_e_tag_port,
11250 (void *)&cmd_config_e_tag_port_id,
11256 cmd_config_e_tag_filter_del_parsed(
11257 void *parsed_result,
11258 __attribute__((unused)) struct cmdline *cl,
11259 __attribute__((unused)) void *data)
11261 struct cmd_config_e_tag_result *res = parsed_result;
11262 struct rte_eth_l2_tunnel_conf entry;
11265 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11268 if (res->e_tag_id_val > 0x3fff) {
11269 printf("e-tag-id must be less than 0x3fff.\n");
11273 ret = rte_eth_dev_filter_supported(res->port_id,
11274 RTE_ETH_FILTER_L2_TUNNEL);
11276 printf("E-tag filter is not supported on port %u.\n",
11281 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11282 entry.tunnel_id = res->e_tag_id_val;
11284 ret = rte_eth_dev_filter_ctrl(res->port_id,
11285 RTE_ETH_FILTER_L2_TUNNEL,
11286 RTE_ETH_FILTER_DELETE,
11289 printf("E-tag filter programming error: (%s)\n",
11293 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
11294 .f = cmd_config_e_tag_filter_del_parsed,
11296 .help_str = "E-tag ... : E-tag filter delete",
11298 (void *)&cmd_config_e_tag_e_tag,
11299 (void *)&cmd_config_e_tag_set,
11300 (void *)&cmd_config_e_tag_filter,
11301 (void *)&cmd_config_e_tag_del,
11302 (void *)&cmd_config_e_tag_e_tag_id,
11303 (void *)&cmd_config_e_tag_e_tag_id_val,
11304 (void *)&cmd_config_e_tag_port,
11305 (void *)&cmd_config_e_tag_port_id,
11310 /* vf vlan anti spoof configuration */
11312 /* Common result structure for vf vlan anti spoof */
11313 struct cmd_vf_vlan_anti_spoof_result {
11314 cmdline_fixed_string_t set;
11315 cmdline_fixed_string_t vf;
11316 cmdline_fixed_string_t vlan;
11317 cmdline_fixed_string_t antispoof;
11320 cmdline_fixed_string_t on_off;
11323 /* Common CLI fields for vf vlan anti spoof enable disable */
11324 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11325 TOKEN_STRING_INITIALIZER
11326 (struct cmd_vf_vlan_anti_spoof_result,
11328 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11329 TOKEN_STRING_INITIALIZER
11330 (struct cmd_vf_vlan_anti_spoof_result,
11332 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11333 TOKEN_STRING_INITIALIZER
11334 (struct cmd_vf_vlan_anti_spoof_result,
11336 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11337 TOKEN_STRING_INITIALIZER
11338 (struct cmd_vf_vlan_anti_spoof_result,
11339 antispoof, "antispoof");
11340 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11341 TOKEN_NUM_INITIALIZER
11342 (struct cmd_vf_vlan_anti_spoof_result,
11344 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11345 TOKEN_NUM_INITIALIZER
11346 (struct cmd_vf_vlan_anti_spoof_result,
11348 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11349 TOKEN_STRING_INITIALIZER
11350 (struct cmd_vf_vlan_anti_spoof_result,
11354 cmd_set_vf_vlan_anti_spoof_parsed(
11355 void *parsed_result,
11356 __attribute__((unused)) struct cmdline *cl,
11357 __attribute__((unused)) void *data)
11359 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11360 int ret = -ENOTSUP;
11362 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11364 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11367 #ifdef RTE_LIBRTE_IXGBE_PMD
11368 if (ret == -ENOTSUP)
11369 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11370 res->vf_id, is_on);
11372 #ifdef RTE_LIBRTE_I40E_PMD
11373 if (ret == -ENOTSUP)
11374 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11375 res->vf_id, is_on);
11377 #ifdef RTE_LIBRTE_BNXT_PMD
11378 if (ret == -ENOTSUP)
11379 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11380 res->vf_id, is_on);
11387 printf("invalid vf_id %d\n", res->vf_id);
11390 printf("invalid port_id %d\n", res->port_id);
11393 printf("function not implemented\n");
11396 printf("programming error: (%s)\n", strerror(-ret));
11400 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11401 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11403 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11405 (void *)&cmd_vf_vlan_anti_spoof_set,
11406 (void *)&cmd_vf_vlan_anti_spoof_vf,
11407 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11408 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11409 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11410 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11411 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11416 /* vf mac anti spoof configuration */
11418 /* Common result structure for vf mac anti spoof */
11419 struct cmd_vf_mac_anti_spoof_result {
11420 cmdline_fixed_string_t set;
11421 cmdline_fixed_string_t vf;
11422 cmdline_fixed_string_t mac;
11423 cmdline_fixed_string_t antispoof;
11426 cmdline_fixed_string_t on_off;
11429 /* Common CLI fields for vf mac anti spoof enable disable */
11430 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11431 TOKEN_STRING_INITIALIZER
11432 (struct cmd_vf_mac_anti_spoof_result,
11434 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11435 TOKEN_STRING_INITIALIZER
11436 (struct cmd_vf_mac_anti_spoof_result,
11438 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11439 TOKEN_STRING_INITIALIZER
11440 (struct cmd_vf_mac_anti_spoof_result,
11442 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11443 TOKEN_STRING_INITIALIZER
11444 (struct cmd_vf_mac_anti_spoof_result,
11445 antispoof, "antispoof");
11446 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11447 TOKEN_NUM_INITIALIZER
11448 (struct cmd_vf_mac_anti_spoof_result,
11450 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11451 TOKEN_NUM_INITIALIZER
11452 (struct cmd_vf_mac_anti_spoof_result,
11454 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11455 TOKEN_STRING_INITIALIZER
11456 (struct cmd_vf_mac_anti_spoof_result,
11460 cmd_set_vf_mac_anti_spoof_parsed(
11461 void *parsed_result,
11462 __attribute__((unused)) struct cmdline *cl,
11463 __attribute__((unused)) void *data)
11465 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11466 int ret = -ENOTSUP;
11468 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11470 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11473 #ifdef RTE_LIBRTE_IXGBE_PMD
11474 if (ret == -ENOTSUP)
11475 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11476 res->vf_id, is_on);
11478 #ifdef RTE_LIBRTE_I40E_PMD
11479 if (ret == -ENOTSUP)
11480 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11481 res->vf_id, is_on);
11483 #ifdef RTE_LIBRTE_BNXT_PMD
11484 if (ret == -ENOTSUP)
11485 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11486 res->vf_id, is_on);
11493 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11496 printf("invalid port_id %d\n", res->port_id);
11499 printf("function not implemented\n");
11502 printf("programming error: (%s)\n", strerror(-ret));
11506 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11507 .f = cmd_set_vf_mac_anti_spoof_parsed,
11509 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11511 (void *)&cmd_vf_mac_anti_spoof_set,
11512 (void *)&cmd_vf_mac_anti_spoof_vf,
11513 (void *)&cmd_vf_mac_anti_spoof_mac,
11514 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11515 (void *)&cmd_vf_mac_anti_spoof_port_id,
11516 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11517 (void *)&cmd_vf_mac_anti_spoof_on_off,
11522 /* vf vlan strip queue configuration */
11524 /* Common result structure for vf mac anti spoof */
11525 struct cmd_vf_vlan_stripq_result {
11526 cmdline_fixed_string_t set;
11527 cmdline_fixed_string_t vf;
11528 cmdline_fixed_string_t vlan;
11529 cmdline_fixed_string_t stripq;
11532 cmdline_fixed_string_t on_off;
11535 /* Common CLI fields for vf vlan strip enable disable */
11536 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11537 TOKEN_STRING_INITIALIZER
11538 (struct cmd_vf_vlan_stripq_result,
11540 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11541 TOKEN_STRING_INITIALIZER
11542 (struct cmd_vf_vlan_stripq_result,
11544 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11545 TOKEN_STRING_INITIALIZER
11546 (struct cmd_vf_vlan_stripq_result,
11548 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11549 TOKEN_STRING_INITIALIZER
11550 (struct cmd_vf_vlan_stripq_result,
11552 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11553 TOKEN_NUM_INITIALIZER
11554 (struct cmd_vf_vlan_stripq_result,
11556 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11557 TOKEN_NUM_INITIALIZER
11558 (struct cmd_vf_vlan_stripq_result,
11560 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11561 TOKEN_STRING_INITIALIZER
11562 (struct cmd_vf_vlan_stripq_result,
11566 cmd_set_vf_vlan_stripq_parsed(
11567 void *parsed_result,
11568 __attribute__((unused)) struct cmdline *cl,
11569 __attribute__((unused)) void *data)
11571 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11572 int ret = -ENOTSUP;
11574 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11576 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11579 #ifdef RTE_LIBRTE_IXGBE_PMD
11580 if (ret == -ENOTSUP)
11581 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11582 res->vf_id, is_on);
11584 #ifdef RTE_LIBRTE_I40E_PMD
11585 if (ret == -ENOTSUP)
11586 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11587 res->vf_id, is_on);
11589 #ifdef RTE_LIBRTE_BNXT_PMD
11590 if (ret == -ENOTSUP)
11591 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11592 res->vf_id, is_on);
11599 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11602 printf("invalid port_id %d\n", res->port_id);
11605 printf("function not implemented\n");
11608 printf("programming error: (%s)\n", strerror(-ret));
11612 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11613 .f = cmd_set_vf_vlan_stripq_parsed,
11615 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11617 (void *)&cmd_vf_vlan_stripq_set,
11618 (void *)&cmd_vf_vlan_stripq_vf,
11619 (void *)&cmd_vf_vlan_stripq_vlan,
11620 (void *)&cmd_vf_vlan_stripq_stripq,
11621 (void *)&cmd_vf_vlan_stripq_port_id,
11622 (void *)&cmd_vf_vlan_stripq_vf_id,
11623 (void *)&cmd_vf_vlan_stripq_on_off,
11628 /* vf vlan insert configuration */
11630 /* Common result structure for vf vlan insert */
11631 struct cmd_vf_vlan_insert_result {
11632 cmdline_fixed_string_t set;
11633 cmdline_fixed_string_t vf;
11634 cmdline_fixed_string_t vlan;
11635 cmdline_fixed_string_t insert;
11641 /* Common CLI fields for vf vlan insert enable disable */
11642 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11643 TOKEN_STRING_INITIALIZER
11644 (struct cmd_vf_vlan_insert_result,
11646 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11647 TOKEN_STRING_INITIALIZER
11648 (struct cmd_vf_vlan_insert_result,
11650 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11651 TOKEN_STRING_INITIALIZER
11652 (struct cmd_vf_vlan_insert_result,
11654 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11655 TOKEN_STRING_INITIALIZER
11656 (struct cmd_vf_vlan_insert_result,
11658 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11659 TOKEN_NUM_INITIALIZER
11660 (struct cmd_vf_vlan_insert_result,
11662 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11663 TOKEN_NUM_INITIALIZER
11664 (struct cmd_vf_vlan_insert_result,
11666 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11667 TOKEN_NUM_INITIALIZER
11668 (struct cmd_vf_vlan_insert_result,
11672 cmd_set_vf_vlan_insert_parsed(
11673 void *parsed_result,
11674 __attribute__((unused)) struct cmdline *cl,
11675 __attribute__((unused)) void *data)
11677 struct cmd_vf_vlan_insert_result *res = parsed_result;
11678 int ret = -ENOTSUP;
11680 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11683 #ifdef RTE_LIBRTE_IXGBE_PMD
11684 if (ret == -ENOTSUP)
11685 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11688 #ifdef RTE_LIBRTE_I40E_PMD
11689 if (ret == -ENOTSUP)
11690 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11693 #ifdef RTE_LIBRTE_BNXT_PMD
11694 if (ret == -ENOTSUP)
11695 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11703 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11706 printf("invalid port_id %d\n", res->port_id);
11709 printf("function not implemented\n");
11712 printf("programming error: (%s)\n", strerror(-ret));
11716 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11717 .f = cmd_set_vf_vlan_insert_parsed,
11719 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11721 (void *)&cmd_vf_vlan_insert_set,
11722 (void *)&cmd_vf_vlan_insert_vf,
11723 (void *)&cmd_vf_vlan_insert_vlan,
11724 (void *)&cmd_vf_vlan_insert_insert,
11725 (void *)&cmd_vf_vlan_insert_port_id,
11726 (void *)&cmd_vf_vlan_insert_vf_id,
11727 (void *)&cmd_vf_vlan_insert_vlan_id,
11732 /* tx loopback configuration */
11734 /* Common result structure for tx loopback */
11735 struct cmd_tx_loopback_result {
11736 cmdline_fixed_string_t set;
11737 cmdline_fixed_string_t tx;
11738 cmdline_fixed_string_t loopback;
11740 cmdline_fixed_string_t on_off;
11743 /* Common CLI fields for tx loopback enable disable */
11744 cmdline_parse_token_string_t cmd_tx_loopback_set =
11745 TOKEN_STRING_INITIALIZER
11746 (struct cmd_tx_loopback_result,
11748 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11749 TOKEN_STRING_INITIALIZER
11750 (struct cmd_tx_loopback_result,
11752 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11753 TOKEN_STRING_INITIALIZER
11754 (struct cmd_tx_loopback_result,
11755 loopback, "loopback");
11756 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11757 TOKEN_NUM_INITIALIZER
11758 (struct cmd_tx_loopback_result,
11760 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11761 TOKEN_STRING_INITIALIZER
11762 (struct cmd_tx_loopback_result,
11766 cmd_set_tx_loopback_parsed(
11767 void *parsed_result,
11768 __attribute__((unused)) struct cmdline *cl,
11769 __attribute__((unused)) void *data)
11771 struct cmd_tx_loopback_result *res = parsed_result;
11772 int ret = -ENOTSUP;
11774 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11776 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11779 #ifdef RTE_LIBRTE_IXGBE_PMD
11780 if (ret == -ENOTSUP)
11781 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11783 #ifdef RTE_LIBRTE_I40E_PMD
11784 if (ret == -ENOTSUP)
11785 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11787 #ifdef RTE_LIBRTE_BNXT_PMD
11788 if (ret == -ENOTSUP)
11789 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11796 printf("invalid is_on %d\n", is_on);
11799 printf("invalid port_id %d\n", res->port_id);
11802 printf("function not implemented\n");
11805 printf("programming error: (%s)\n", strerror(-ret));
11809 cmdline_parse_inst_t cmd_set_tx_loopback = {
11810 .f = cmd_set_tx_loopback_parsed,
11812 .help_str = "set tx loopback <port_id> on|off",
11814 (void *)&cmd_tx_loopback_set,
11815 (void *)&cmd_tx_loopback_tx,
11816 (void *)&cmd_tx_loopback_loopback,
11817 (void *)&cmd_tx_loopback_port_id,
11818 (void *)&cmd_tx_loopback_on_off,
11823 /* all queues drop enable configuration */
11825 /* Common result structure for all queues drop enable */
11826 struct cmd_all_queues_drop_en_result {
11827 cmdline_fixed_string_t set;
11828 cmdline_fixed_string_t all;
11829 cmdline_fixed_string_t queues;
11830 cmdline_fixed_string_t drop;
11832 cmdline_fixed_string_t on_off;
11835 /* Common CLI fields for tx loopback enable disable */
11836 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11837 TOKEN_STRING_INITIALIZER
11838 (struct cmd_all_queues_drop_en_result,
11840 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11841 TOKEN_STRING_INITIALIZER
11842 (struct cmd_all_queues_drop_en_result,
11844 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11845 TOKEN_STRING_INITIALIZER
11846 (struct cmd_all_queues_drop_en_result,
11848 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11849 TOKEN_STRING_INITIALIZER
11850 (struct cmd_all_queues_drop_en_result,
11852 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11853 TOKEN_NUM_INITIALIZER
11854 (struct cmd_all_queues_drop_en_result,
11856 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11857 TOKEN_STRING_INITIALIZER
11858 (struct cmd_all_queues_drop_en_result,
11862 cmd_set_all_queues_drop_en_parsed(
11863 void *parsed_result,
11864 __attribute__((unused)) struct cmdline *cl,
11865 __attribute__((unused)) void *data)
11867 struct cmd_all_queues_drop_en_result *res = parsed_result;
11868 int ret = -ENOTSUP;
11869 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11871 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11874 #ifdef RTE_LIBRTE_IXGBE_PMD
11875 if (ret == -ENOTSUP)
11876 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11878 #ifdef RTE_LIBRTE_BNXT_PMD
11879 if (ret == -ENOTSUP)
11880 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11886 printf("invalid is_on %d\n", is_on);
11889 printf("invalid port_id %d\n", res->port_id);
11892 printf("function not implemented\n");
11895 printf("programming error: (%s)\n", strerror(-ret));
11899 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11900 .f = cmd_set_all_queues_drop_en_parsed,
11902 .help_str = "set all queues drop <port_id> on|off",
11904 (void *)&cmd_all_queues_drop_en_set,
11905 (void *)&cmd_all_queues_drop_en_all,
11906 (void *)&cmd_all_queues_drop_en_queues,
11907 (void *)&cmd_all_queues_drop_en_drop,
11908 (void *)&cmd_all_queues_drop_en_port_id,
11909 (void *)&cmd_all_queues_drop_en_on_off,
11914 /* vf split drop enable configuration */
11916 /* Common result structure for vf split drop enable */
11917 struct cmd_vf_split_drop_en_result {
11918 cmdline_fixed_string_t set;
11919 cmdline_fixed_string_t vf;
11920 cmdline_fixed_string_t split;
11921 cmdline_fixed_string_t drop;
11924 cmdline_fixed_string_t on_off;
11927 /* Common CLI fields for vf split drop enable disable */
11928 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11929 TOKEN_STRING_INITIALIZER
11930 (struct cmd_vf_split_drop_en_result,
11932 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11933 TOKEN_STRING_INITIALIZER
11934 (struct cmd_vf_split_drop_en_result,
11936 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11937 TOKEN_STRING_INITIALIZER
11938 (struct cmd_vf_split_drop_en_result,
11940 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11941 TOKEN_STRING_INITIALIZER
11942 (struct cmd_vf_split_drop_en_result,
11944 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11945 TOKEN_NUM_INITIALIZER
11946 (struct cmd_vf_split_drop_en_result,
11948 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11949 TOKEN_NUM_INITIALIZER
11950 (struct cmd_vf_split_drop_en_result,
11952 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11953 TOKEN_STRING_INITIALIZER
11954 (struct cmd_vf_split_drop_en_result,
11958 cmd_set_vf_split_drop_en_parsed(
11959 void *parsed_result,
11960 __attribute__((unused)) struct cmdline *cl,
11961 __attribute__((unused)) void *data)
11963 struct cmd_vf_split_drop_en_result *res = parsed_result;
11964 int ret = -ENOTSUP;
11965 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11970 #ifdef RTE_LIBRTE_IXGBE_PMD
11971 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11978 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11981 printf("invalid port_id %d\n", res->port_id);
11984 printf("not supported on port %d\n", res->port_id);
11987 printf("programming error: (%s)\n", strerror(-ret));
11991 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11992 .f = cmd_set_vf_split_drop_en_parsed,
11994 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11996 (void *)&cmd_vf_split_drop_en_set,
11997 (void *)&cmd_vf_split_drop_en_vf,
11998 (void *)&cmd_vf_split_drop_en_split,
11999 (void *)&cmd_vf_split_drop_en_drop,
12000 (void *)&cmd_vf_split_drop_en_port_id,
12001 (void *)&cmd_vf_split_drop_en_vf_id,
12002 (void *)&cmd_vf_split_drop_en_on_off,
12007 /* vf mac address configuration */
12009 /* Common result structure for vf mac address */
12010 struct cmd_set_vf_mac_addr_result {
12011 cmdline_fixed_string_t set;
12012 cmdline_fixed_string_t vf;
12013 cmdline_fixed_string_t mac;
12014 cmdline_fixed_string_t addr;
12017 struct ether_addr mac_addr;
12021 /* Common CLI fields for vf split drop enable disable */
12022 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12023 TOKEN_STRING_INITIALIZER
12024 (struct cmd_set_vf_mac_addr_result,
12026 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12027 TOKEN_STRING_INITIALIZER
12028 (struct cmd_set_vf_mac_addr_result,
12030 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12031 TOKEN_STRING_INITIALIZER
12032 (struct cmd_set_vf_mac_addr_result,
12034 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12035 TOKEN_STRING_INITIALIZER
12036 (struct cmd_set_vf_mac_addr_result,
12038 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12039 TOKEN_NUM_INITIALIZER
12040 (struct cmd_set_vf_mac_addr_result,
12042 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12043 TOKEN_NUM_INITIALIZER
12044 (struct cmd_set_vf_mac_addr_result,
12046 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12047 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12051 cmd_set_vf_mac_addr_parsed(
12052 void *parsed_result,
12053 __attribute__((unused)) struct cmdline *cl,
12054 __attribute__((unused)) void *data)
12056 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12057 int ret = -ENOTSUP;
12059 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12062 #ifdef RTE_LIBRTE_IXGBE_PMD
12063 if (ret == -ENOTSUP)
12064 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12067 #ifdef RTE_LIBRTE_I40E_PMD
12068 if (ret == -ENOTSUP)
12069 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12072 #ifdef RTE_LIBRTE_BNXT_PMD
12073 if (ret == -ENOTSUP)
12074 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12082 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12085 printf("invalid port_id %d\n", res->port_id);
12088 printf("function not implemented\n");
12091 printf("programming error: (%s)\n", strerror(-ret));
12095 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12096 .f = cmd_set_vf_mac_addr_parsed,
12098 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12100 (void *)&cmd_set_vf_mac_addr_set,
12101 (void *)&cmd_set_vf_mac_addr_vf,
12102 (void *)&cmd_set_vf_mac_addr_mac,
12103 (void *)&cmd_set_vf_mac_addr_addr,
12104 (void *)&cmd_set_vf_mac_addr_port_id,
12105 (void *)&cmd_set_vf_mac_addr_vf_id,
12106 (void *)&cmd_set_vf_mac_addr_mac_addr,
12111 /* MACsec configuration */
12113 /* Common result structure for MACsec offload enable */
12114 struct cmd_macsec_offload_on_result {
12115 cmdline_fixed_string_t set;
12116 cmdline_fixed_string_t macsec;
12117 cmdline_fixed_string_t offload;
12119 cmdline_fixed_string_t on;
12120 cmdline_fixed_string_t encrypt;
12121 cmdline_fixed_string_t en_on_off;
12122 cmdline_fixed_string_t replay_protect;
12123 cmdline_fixed_string_t rp_on_off;
12126 /* Common CLI fields for MACsec offload disable */
12127 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12128 TOKEN_STRING_INITIALIZER
12129 (struct cmd_macsec_offload_on_result,
12131 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12132 TOKEN_STRING_INITIALIZER
12133 (struct cmd_macsec_offload_on_result,
12135 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12136 TOKEN_STRING_INITIALIZER
12137 (struct cmd_macsec_offload_on_result,
12138 offload, "offload");
12139 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12140 TOKEN_NUM_INITIALIZER
12141 (struct cmd_macsec_offload_on_result,
12143 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12144 TOKEN_STRING_INITIALIZER
12145 (struct cmd_macsec_offload_on_result,
12147 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12148 TOKEN_STRING_INITIALIZER
12149 (struct cmd_macsec_offload_on_result,
12150 encrypt, "encrypt");
12151 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12152 TOKEN_STRING_INITIALIZER
12153 (struct cmd_macsec_offload_on_result,
12154 en_on_off, "on#off");
12155 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12156 TOKEN_STRING_INITIALIZER
12157 (struct cmd_macsec_offload_on_result,
12158 replay_protect, "replay-protect");
12159 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12160 TOKEN_STRING_INITIALIZER
12161 (struct cmd_macsec_offload_on_result,
12162 rp_on_off, "on#off");
12165 cmd_set_macsec_offload_on_parsed(
12166 void *parsed_result,
12167 __attribute__((unused)) struct cmdline *cl,
12168 __attribute__((unused)) void *data)
12170 struct cmd_macsec_offload_on_result *res = parsed_result;
12171 int ret = -ENOTSUP;
12172 portid_t port_id = res->port_id;
12173 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12174 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12176 if (port_id_is_invalid(port_id, ENABLED_WARN))
12179 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
12180 #ifdef RTE_LIBRTE_IXGBE_PMD
12181 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12190 printf("invalid port_id %d\n", port_id);
12193 printf("not supported on port %d\n", port_id);
12196 printf("programming error: (%s)\n", strerror(-ret));
12200 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12201 .f = cmd_set_macsec_offload_on_parsed,
12203 .help_str = "set macsec offload <port_id> on "
12204 "encrypt on|off replay-protect on|off",
12206 (void *)&cmd_macsec_offload_on_set,
12207 (void *)&cmd_macsec_offload_on_macsec,
12208 (void *)&cmd_macsec_offload_on_offload,
12209 (void *)&cmd_macsec_offload_on_port_id,
12210 (void *)&cmd_macsec_offload_on_on,
12211 (void *)&cmd_macsec_offload_on_encrypt,
12212 (void *)&cmd_macsec_offload_on_en_on_off,
12213 (void *)&cmd_macsec_offload_on_replay_protect,
12214 (void *)&cmd_macsec_offload_on_rp_on_off,
12219 /* Common result structure for MACsec offload disable */
12220 struct cmd_macsec_offload_off_result {
12221 cmdline_fixed_string_t set;
12222 cmdline_fixed_string_t macsec;
12223 cmdline_fixed_string_t offload;
12225 cmdline_fixed_string_t off;
12228 /* Common CLI fields for MACsec offload disable */
12229 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12230 TOKEN_STRING_INITIALIZER
12231 (struct cmd_macsec_offload_off_result,
12233 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12234 TOKEN_STRING_INITIALIZER
12235 (struct cmd_macsec_offload_off_result,
12237 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12238 TOKEN_STRING_INITIALIZER
12239 (struct cmd_macsec_offload_off_result,
12240 offload, "offload");
12241 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12242 TOKEN_NUM_INITIALIZER
12243 (struct cmd_macsec_offload_off_result,
12245 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12246 TOKEN_STRING_INITIALIZER
12247 (struct cmd_macsec_offload_off_result,
12251 cmd_set_macsec_offload_off_parsed(
12252 void *parsed_result,
12253 __attribute__((unused)) struct cmdline *cl,
12254 __attribute__((unused)) void *data)
12256 struct cmd_macsec_offload_off_result *res = parsed_result;
12257 int ret = -ENOTSUP;
12258 portid_t port_id = res->port_id;
12260 if (port_id_is_invalid(port_id, ENABLED_WARN))
12263 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
12264 #ifdef RTE_LIBRTE_IXGBE_PMD
12265 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12272 printf("invalid port_id %d\n", port_id);
12275 printf("not supported on port %d\n", port_id);
12278 printf("programming error: (%s)\n", strerror(-ret));
12282 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12283 .f = cmd_set_macsec_offload_off_parsed,
12285 .help_str = "set macsec offload <port_id> off",
12287 (void *)&cmd_macsec_offload_off_set,
12288 (void *)&cmd_macsec_offload_off_macsec,
12289 (void *)&cmd_macsec_offload_off_offload,
12290 (void *)&cmd_macsec_offload_off_port_id,
12291 (void *)&cmd_macsec_offload_off_off,
12296 /* Common result structure for MACsec secure connection configure */
12297 struct cmd_macsec_sc_result {
12298 cmdline_fixed_string_t set;
12299 cmdline_fixed_string_t macsec;
12300 cmdline_fixed_string_t sc;
12301 cmdline_fixed_string_t tx_rx;
12303 struct ether_addr mac;
12307 /* Common CLI fields for MACsec secure connection configure */
12308 cmdline_parse_token_string_t cmd_macsec_sc_set =
12309 TOKEN_STRING_INITIALIZER
12310 (struct cmd_macsec_sc_result,
12312 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12313 TOKEN_STRING_INITIALIZER
12314 (struct cmd_macsec_sc_result,
12316 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12317 TOKEN_STRING_INITIALIZER
12318 (struct cmd_macsec_sc_result,
12320 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12321 TOKEN_STRING_INITIALIZER
12322 (struct cmd_macsec_sc_result,
12324 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12325 TOKEN_NUM_INITIALIZER
12326 (struct cmd_macsec_sc_result,
12328 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12329 TOKEN_ETHERADDR_INITIALIZER
12330 (struct cmd_macsec_sc_result,
12332 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12333 TOKEN_NUM_INITIALIZER
12334 (struct cmd_macsec_sc_result,
12338 cmd_set_macsec_sc_parsed(
12339 void *parsed_result,
12340 __attribute__((unused)) struct cmdline *cl,
12341 __attribute__((unused)) void *data)
12343 struct cmd_macsec_sc_result *res = parsed_result;
12344 int ret = -ENOTSUP;
12345 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12347 #ifdef RTE_LIBRTE_IXGBE_PMD
12349 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12350 res->mac.addr_bytes) :
12351 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12352 res->mac.addr_bytes, res->pi);
12354 RTE_SET_USED(is_tx);
12360 printf("invalid port_id %d\n", res->port_id);
12363 printf("not supported on port %d\n", res->port_id);
12366 printf("programming error: (%s)\n", strerror(-ret));
12370 cmdline_parse_inst_t cmd_set_macsec_sc = {
12371 .f = cmd_set_macsec_sc_parsed,
12373 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12375 (void *)&cmd_macsec_sc_set,
12376 (void *)&cmd_macsec_sc_macsec,
12377 (void *)&cmd_macsec_sc_sc,
12378 (void *)&cmd_macsec_sc_tx_rx,
12379 (void *)&cmd_macsec_sc_port_id,
12380 (void *)&cmd_macsec_sc_mac,
12381 (void *)&cmd_macsec_sc_pi,
12386 /* Common result structure for MACsec secure connection configure */
12387 struct cmd_macsec_sa_result {
12388 cmdline_fixed_string_t set;
12389 cmdline_fixed_string_t macsec;
12390 cmdline_fixed_string_t sa;
12391 cmdline_fixed_string_t tx_rx;
12396 cmdline_fixed_string_t key;
12399 /* Common CLI fields for MACsec secure connection configure */
12400 cmdline_parse_token_string_t cmd_macsec_sa_set =
12401 TOKEN_STRING_INITIALIZER
12402 (struct cmd_macsec_sa_result,
12404 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12405 TOKEN_STRING_INITIALIZER
12406 (struct cmd_macsec_sa_result,
12408 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12409 TOKEN_STRING_INITIALIZER
12410 (struct cmd_macsec_sa_result,
12412 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12413 TOKEN_STRING_INITIALIZER
12414 (struct cmd_macsec_sa_result,
12416 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12417 TOKEN_NUM_INITIALIZER
12418 (struct cmd_macsec_sa_result,
12420 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12421 TOKEN_NUM_INITIALIZER
12422 (struct cmd_macsec_sa_result,
12424 cmdline_parse_token_num_t cmd_macsec_sa_an =
12425 TOKEN_NUM_INITIALIZER
12426 (struct cmd_macsec_sa_result,
12428 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12429 TOKEN_NUM_INITIALIZER
12430 (struct cmd_macsec_sa_result,
12432 cmdline_parse_token_string_t cmd_macsec_sa_key =
12433 TOKEN_STRING_INITIALIZER
12434 (struct cmd_macsec_sa_result,
12438 cmd_set_macsec_sa_parsed(
12439 void *parsed_result,
12440 __attribute__((unused)) struct cmdline *cl,
12441 __attribute__((unused)) void *data)
12443 struct cmd_macsec_sa_result *res = parsed_result;
12444 int ret = -ENOTSUP;
12445 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12446 uint8_t key[16] = { 0 };
12452 key_len = strlen(res->key) / 2;
12456 for (i = 0; i < key_len; i++) {
12457 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12460 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12463 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12466 #ifdef RTE_LIBRTE_IXGBE_PMD
12468 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12469 res->idx, res->an, res->pn, key) :
12470 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12471 res->idx, res->an, res->pn, key);
12473 RTE_SET_USED(is_tx);
12480 printf("invalid idx %d or an %d\n", res->idx, res->an);
12483 printf("invalid port_id %d\n", res->port_id);
12486 printf("not supported on port %d\n", res->port_id);
12489 printf("programming error: (%s)\n", strerror(-ret));
12493 cmdline_parse_inst_t cmd_set_macsec_sa = {
12494 .f = cmd_set_macsec_sa_parsed,
12496 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12498 (void *)&cmd_macsec_sa_set,
12499 (void *)&cmd_macsec_sa_macsec,
12500 (void *)&cmd_macsec_sa_sa,
12501 (void *)&cmd_macsec_sa_tx_rx,
12502 (void *)&cmd_macsec_sa_port_id,
12503 (void *)&cmd_macsec_sa_idx,
12504 (void *)&cmd_macsec_sa_an,
12505 (void *)&cmd_macsec_sa_pn,
12506 (void *)&cmd_macsec_sa_key,
12511 /* VF unicast promiscuous mode configuration */
12513 /* Common result structure for VF unicast promiscuous mode */
12514 struct cmd_vf_promisc_result {
12515 cmdline_fixed_string_t set;
12516 cmdline_fixed_string_t vf;
12517 cmdline_fixed_string_t promisc;
12520 cmdline_fixed_string_t on_off;
12523 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12524 cmdline_parse_token_string_t cmd_vf_promisc_set =
12525 TOKEN_STRING_INITIALIZER
12526 (struct cmd_vf_promisc_result,
12528 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12529 TOKEN_STRING_INITIALIZER
12530 (struct cmd_vf_promisc_result,
12532 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12533 TOKEN_STRING_INITIALIZER
12534 (struct cmd_vf_promisc_result,
12535 promisc, "promisc");
12536 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12537 TOKEN_NUM_INITIALIZER
12538 (struct cmd_vf_promisc_result,
12540 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12541 TOKEN_NUM_INITIALIZER
12542 (struct cmd_vf_promisc_result,
12544 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12545 TOKEN_STRING_INITIALIZER
12546 (struct cmd_vf_promisc_result,
12550 cmd_set_vf_promisc_parsed(
12551 void *parsed_result,
12552 __attribute__((unused)) struct cmdline *cl,
12553 __attribute__((unused)) void *data)
12555 struct cmd_vf_promisc_result *res = parsed_result;
12556 int ret = -ENOTSUP;
12558 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12560 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12563 #ifdef RTE_LIBRTE_I40E_PMD
12564 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12565 res->vf_id, is_on);
12572 printf("invalid vf_id %d\n", res->vf_id);
12575 printf("invalid port_id %d\n", res->port_id);
12578 printf("function not implemented\n");
12581 printf("programming error: (%s)\n", strerror(-ret));
12585 cmdline_parse_inst_t cmd_set_vf_promisc = {
12586 .f = cmd_set_vf_promisc_parsed,
12588 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12589 "Set unicast promiscuous mode for a VF from the PF",
12591 (void *)&cmd_vf_promisc_set,
12592 (void *)&cmd_vf_promisc_vf,
12593 (void *)&cmd_vf_promisc_promisc,
12594 (void *)&cmd_vf_promisc_port_id,
12595 (void *)&cmd_vf_promisc_vf_id,
12596 (void *)&cmd_vf_promisc_on_off,
12601 /* VF multicast promiscuous mode configuration */
12603 /* Common result structure for VF multicast promiscuous mode */
12604 struct cmd_vf_allmulti_result {
12605 cmdline_fixed_string_t set;
12606 cmdline_fixed_string_t vf;
12607 cmdline_fixed_string_t allmulti;
12610 cmdline_fixed_string_t on_off;
12613 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12614 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12615 TOKEN_STRING_INITIALIZER
12616 (struct cmd_vf_allmulti_result,
12618 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12619 TOKEN_STRING_INITIALIZER
12620 (struct cmd_vf_allmulti_result,
12622 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12623 TOKEN_STRING_INITIALIZER
12624 (struct cmd_vf_allmulti_result,
12625 allmulti, "allmulti");
12626 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12627 TOKEN_NUM_INITIALIZER
12628 (struct cmd_vf_allmulti_result,
12630 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12631 TOKEN_NUM_INITIALIZER
12632 (struct cmd_vf_allmulti_result,
12634 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12635 TOKEN_STRING_INITIALIZER
12636 (struct cmd_vf_allmulti_result,
12640 cmd_set_vf_allmulti_parsed(
12641 void *parsed_result,
12642 __attribute__((unused)) struct cmdline *cl,
12643 __attribute__((unused)) void *data)
12645 struct cmd_vf_allmulti_result *res = parsed_result;
12646 int ret = -ENOTSUP;
12648 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12650 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12653 #ifdef RTE_LIBRTE_I40E_PMD
12654 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12655 res->vf_id, is_on);
12662 printf("invalid vf_id %d\n", res->vf_id);
12665 printf("invalid port_id %d\n", res->port_id);
12668 printf("function not implemented\n");
12671 printf("programming error: (%s)\n", strerror(-ret));
12675 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12676 .f = cmd_set_vf_allmulti_parsed,
12678 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12679 "Set multicast promiscuous mode for a VF from the PF",
12681 (void *)&cmd_vf_allmulti_set,
12682 (void *)&cmd_vf_allmulti_vf,
12683 (void *)&cmd_vf_allmulti_allmulti,
12684 (void *)&cmd_vf_allmulti_port_id,
12685 (void *)&cmd_vf_allmulti_vf_id,
12686 (void *)&cmd_vf_allmulti_on_off,
12691 /* vf broadcast mode configuration */
12693 /* Common result structure for vf broadcast */
12694 struct cmd_set_vf_broadcast_result {
12695 cmdline_fixed_string_t set;
12696 cmdline_fixed_string_t vf;
12697 cmdline_fixed_string_t broadcast;
12700 cmdline_fixed_string_t on_off;
12703 /* Common CLI fields for vf broadcast enable disable */
12704 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12705 TOKEN_STRING_INITIALIZER
12706 (struct cmd_set_vf_broadcast_result,
12708 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12709 TOKEN_STRING_INITIALIZER
12710 (struct cmd_set_vf_broadcast_result,
12712 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12713 TOKEN_STRING_INITIALIZER
12714 (struct cmd_set_vf_broadcast_result,
12715 broadcast, "broadcast");
12716 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12717 TOKEN_NUM_INITIALIZER
12718 (struct cmd_set_vf_broadcast_result,
12720 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12721 TOKEN_NUM_INITIALIZER
12722 (struct cmd_set_vf_broadcast_result,
12724 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12725 TOKEN_STRING_INITIALIZER
12726 (struct cmd_set_vf_broadcast_result,
12730 cmd_set_vf_broadcast_parsed(
12731 void *parsed_result,
12732 __attribute__((unused)) struct cmdline *cl,
12733 __attribute__((unused)) void *data)
12735 struct cmd_set_vf_broadcast_result *res = parsed_result;
12736 int ret = -ENOTSUP;
12738 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12740 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12743 #ifdef RTE_LIBRTE_I40E_PMD
12744 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12745 res->vf_id, is_on);
12752 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12755 printf("invalid port_id %d\n", res->port_id);
12758 printf("function not implemented\n");
12761 printf("programming error: (%s)\n", strerror(-ret));
12765 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12766 .f = cmd_set_vf_broadcast_parsed,
12768 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12770 (void *)&cmd_set_vf_broadcast_set,
12771 (void *)&cmd_set_vf_broadcast_vf,
12772 (void *)&cmd_set_vf_broadcast_broadcast,
12773 (void *)&cmd_set_vf_broadcast_port_id,
12774 (void *)&cmd_set_vf_broadcast_vf_id,
12775 (void *)&cmd_set_vf_broadcast_on_off,
12780 /* vf vlan tag configuration */
12782 /* Common result structure for vf vlan tag */
12783 struct cmd_set_vf_vlan_tag_result {
12784 cmdline_fixed_string_t set;
12785 cmdline_fixed_string_t vf;
12786 cmdline_fixed_string_t vlan;
12787 cmdline_fixed_string_t tag;
12790 cmdline_fixed_string_t on_off;
12793 /* Common CLI fields for vf vlan tag enable disable */
12794 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12795 TOKEN_STRING_INITIALIZER
12796 (struct cmd_set_vf_vlan_tag_result,
12798 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12799 TOKEN_STRING_INITIALIZER
12800 (struct cmd_set_vf_vlan_tag_result,
12802 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12803 TOKEN_STRING_INITIALIZER
12804 (struct cmd_set_vf_vlan_tag_result,
12806 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12807 TOKEN_STRING_INITIALIZER
12808 (struct cmd_set_vf_vlan_tag_result,
12810 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12811 TOKEN_NUM_INITIALIZER
12812 (struct cmd_set_vf_vlan_tag_result,
12814 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12815 TOKEN_NUM_INITIALIZER
12816 (struct cmd_set_vf_vlan_tag_result,
12818 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12819 TOKEN_STRING_INITIALIZER
12820 (struct cmd_set_vf_vlan_tag_result,
12824 cmd_set_vf_vlan_tag_parsed(
12825 void *parsed_result,
12826 __attribute__((unused)) struct cmdline *cl,
12827 __attribute__((unused)) void *data)
12829 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12830 int ret = -ENOTSUP;
12832 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12834 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12837 #ifdef RTE_LIBRTE_I40E_PMD
12838 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12839 res->vf_id, is_on);
12846 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12849 printf("invalid port_id %d\n", res->port_id);
12852 printf("function not implemented\n");
12855 printf("programming error: (%s)\n", strerror(-ret));
12859 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12860 .f = cmd_set_vf_vlan_tag_parsed,
12862 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12864 (void *)&cmd_set_vf_vlan_tag_set,
12865 (void *)&cmd_set_vf_vlan_tag_vf,
12866 (void *)&cmd_set_vf_vlan_tag_vlan,
12867 (void *)&cmd_set_vf_vlan_tag_tag,
12868 (void *)&cmd_set_vf_vlan_tag_port_id,
12869 (void *)&cmd_set_vf_vlan_tag_vf_id,
12870 (void *)&cmd_set_vf_vlan_tag_on_off,
12875 /* Common definition of VF and TC TX bandwidth configuration */
12876 struct cmd_vf_tc_bw_result {
12877 cmdline_fixed_string_t set;
12878 cmdline_fixed_string_t vf;
12879 cmdline_fixed_string_t tc;
12880 cmdline_fixed_string_t tx;
12881 cmdline_fixed_string_t min_bw;
12882 cmdline_fixed_string_t max_bw;
12883 cmdline_fixed_string_t strict_link_prio;
12888 cmdline_fixed_string_t bw_list;
12892 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12893 TOKEN_STRING_INITIALIZER
12894 (struct cmd_vf_tc_bw_result,
12896 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12897 TOKEN_STRING_INITIALIZER
12898 (struct cmd_vf_tc_bw_result,
12900 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12901 TOKEN_STRING_INITIALIZER
12902 (struct cmd_vf_tc_bw_result,
12904 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12905 TOKEN_STRING_INITIALIZER
12906 (struct cmd_vf_tc_bw_result,
12908 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12909 TOKEN_STRING_INITIALIZER
12910 (struct cmd_vf_tc_bw_result,
12911 strict_link_prio, "strict-link-priority");
12912 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12913 TOKEN_STRING_INITIALIZER
12914 (struct cmd_vf_tc_bw_result,
12915 min_bw, "min-bandwidth");
12916 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12917 TOKEN_STRING_INITIALIZER
12918 (struct cmd_vf_tc_bw_result,
12919 max_bw, "max-bandwidth");
12920 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12921 TOKEN_NUM_INITIALIZER
12922 (struct cmd_vf_tc_bw_result,
12924 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12925 TOKEN_NUM_INITIALIZER
12926 (struct cmd_vf_tc_bw_result,
12928 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12929 TOKEN_NUM_INITIALIZER
12930 (struct cmd_vf_tc_bw_result,
12932 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12933 TOKEN_NUM_INITIALIZER
12934 (struct cmd_vf_tc_bw_result,
12936 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12937 TOKEN_STRING_INITIALIZER
12938 (struct cmd_vf_tc_bw_result,
12940 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12941 TOKEN_NUM_INITIALIZER
12942 (struct cmd_vf_tc_bw_result,
12945 /* VF max bandwidth setting */
12947 cmd_vf_max_bw_parsed(
12948 void *parsed_result,
12949 __attribute__((unused)) struct cmdline *cl,
12950 __attribute__((unused)) void *data)
12952 struct cmd_vf_tc_bw_result *res = parsed_result;
12953 int ret = -ENOTSUP;
12955 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12958 #ifdef RTE_LIBRTE_I40E_PMD
12959 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12960 res->vf_id, res->bw);
12967 printf("invalid vf_id %d or bandwidth %d\n",
12968 res->vf_id, res->bw);
12971 printf("invalid port_id %d\n", res->port_id);
12974 printf("function not implemented\n");
12977 printf("programming error: (%s)\n", strerror(-ret));
12981 cmdline_parse_inst_t cmd_vf_max_bw = {
12982 .f = cmd_vf_max_bw_parsed,
12984 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12986 (void *)&cmd_vf_tc_bw_set,
12987 (void *)&cmd_vf_tc_bw_vf,
12988 (void *)&cmd_vf_tc_bw_tx,
12989 (void *)&cmd_vf_tc_bw_max_bw,
12990 (void *)&cmd_vf_tc_bw_port_id,
12991 (void *)&cmd_vf_tc_bw_vf_id,
12992 (void *)&cmd_vf_tc_bw_bw,
12998 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13003 const char *p, *p0 = str;
13010 p = strchr(p0, '(');
13012 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13016 p0 = strchr(p, ')');
13018 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13022 if (size >= sizeof(s)) {
13023 printf("The string size exceeds the internal buffer size\n");
13026 snprintf(s, sizeof(s), "%.*s", size, p);
13027 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13029 printf("Failed to get the bandwidth list. ");
13033 for (i = 0; i < ret; i++)
13034 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13039 /* TC min bandwidth setting */
13041 cmd_vf_tc_min_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;
13049 int ret = -ENOTSUP;
13051 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13054 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13058 #ifdef RTE_LIBRTE_I40E_PMD
13059 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13067 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13070 printf("invalid port_id %d\n", res->port_id);
13073 printf("function not implemented\n");
13076 printf("programming error: (%s)\n", strerror(-ret));
13080 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13081 .f = cmd_vf_tc_min_bw_parsed,
13083 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13084 " <bw1, bw2, ...>",
13086 (void *)&cmd_vf_tc_bw_set,
13087 (void *)&cmd_vf_tc_bw_vf,
13088 (void *)&cmd_vf_tc_bw_tc,
13089 (void *)&cmd_vf_tc_bw_tx,
13090 (void *)&cmd_vf_tc_bw_min_bw,
13091 (void *)&cmd_vf_tc_bw_port_id,
13092 (void *)&cmd_vf_tc_bw_vf_id,
13093 (void *)&cmd_vf_tc_bw_bw_list,
13099 cmd_tc_min_bw_parsed(
13100 void *parsed_result,
13101 __attribute__((unused)) struct cmdline *cl,
13102 __attribute__((unused)) void *data)
13104 struct cmd_vf_tc_bw_result *res = parsed_result;
13105 struct rte_port *port;
13108 int ret = -ENOTSUP;
13110 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13113 port = &ports[res->port_id];
13114 /** Check if the port is not started **/
13115 if (port->port_status != RTE_PORT_STOPPED) {
13116 printf("Please stop port %d first\n", res->port_id);
13120 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13124 #ifdef RTE_LIBRTE_IXGBE_PMD
13125 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13132 printf("invalid bandwidth\n");
13135 printf("invalid port_id %d\n", res->port_id);
13138 printf("function not implemented\n");
13141 printf("programming error: (%s)\n", strerror(-ret));
13145 cmdline_parse_inst_t cmd_tc_min_bw = {
13146 .f = cmd_tc_min_bw_parsed,
13148 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13150 (void *)&cmd_vf_tc_bw_set,
13151 (void *)&cmd_vf_tc_bw_tc,
13152 (void *)&cmd_vf_tc_bw_tx,
13153 (void *)&cmd_vf_tc_bw_min_bw,
13154 (void *)&cmd_vf_tc_bw_port_id,
13155 (void *)&cmd_vf_tc_bw_bw_list,
13160 /* TC max bandwidth setting */
13162 cmd_vf_tc_max_bw_parsed(
13163 void *parsed_result,
13164 __attribute__((unused)) struct cmdline *cl,
13165 __attribute__((unused)) void *data)
13167 struct cmd_vf_tc_bw_result *res = parsed_result;
13168 int ret = -ENOTSUP;
13170 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13173 #ifdef RTE_LIBRTE_I40E_PMD
13174 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13175 res->tc_no, res->bw);
13182 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13183 res->vf_id, res->tc_no, res->bw);
13186 printf("invalid port_id %d\n", res->port_id);
13189 printf("function not implemented\n");
13192 printf("programming error: (%s)\n", strerror(-ret));
13196 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13197 .f = cmd_vf_tc_max_bw_parsed,
13199 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13202 (void *)&cmd_vf_tc_bw_set,
13203 (void *)&cmd_vf_tc_bw_vf,
13204 (void *)&cmd_vf_tc_bw_tc,
13205 (void *)&cmd_vf_tc_bw_tx,
13206 (void *)&cmd_vf_tc_bw_max_bw,
13207 (void *)&cmd_vf_tc_bw_port_id,
13208 (void *)&cmd_vf_tc_bw_vf_id,
13209 (void *)&cmd_vf_tc_bw_tc_no,
13210 (void *)&cmd_vf_tc_bw_bw,
13215 /* Strict link priority scheduling mode setting */
13217 cmd_strict_link_prio_parsed(
13218 void *parsed_result,
13219 __attribute__((unused)) struct cmdline *cl,
13220 __attribute__((unused)) void *data)
13222 struct cmd_vf_tc_bw_result *res = parsed_result;
13223 int ret = -ENOTSUP;
13225 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13228 #ifdef RTE_LIBRTE_I40E_PMD
13229 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13236 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13239 printf("invalid port_id %d\n", res->port_id);
13242 printf("function not implemented\n");
13245 printf("programming error: (%s)\n", strerror(-ret));
13249 cmdline_parse_inst_t cmd_strict_link_prio = {
13250 .f = cmd_strict_link_prio_parsed,
13252 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13254 (void *)&cmd_vf_tc_bw_set,
13255 (void *)&cmd_vf_tc_bw_tx,
13256 (void *)&cmd_vf_tc_bw_strict_link_prio,
13257 (void *)&cmd_vf_tc_bw_port_id,
13258 (void *)&cmd_vf_tc_bw_tc_map,
13263 /* Load dynamic device personalization*/
13264 struct cmd_ddp_add_result {
13265 cmdline_fixed_string_t ddp;
13266 cmdline_fixed_string_t add;
13271 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13272 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13273 cmdline_parse_token_string_t cmd_ddp_add_add =
13274 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13275 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13276 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
13277 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13278 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13281 cmd_ddp_add_parsed(
13282 void *parsed_result,
13283 __attribute__((unused)) struct cmdline *cl,
13284 __attribute__((unused)) void *data)
13286 struct cmd_ddp_add_result *res = parsed_result;
13292 int ret = -ENOTSUP;
13294 if (res->port_id > nb_ports) {
13295 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13299 if (!all_ports_stopped()) {
13300 printf("Please stop all ports first\n");
13304 filepath = strdup(res->filepath);
13305 if (filepath == NULL) {
13306 printf("Failed to allocate memory\n");
13309 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13311 buff = open_ddp_package_file(file_fld[0], &size);
13313 free((void *)filepath);
13317 #ifdef RTE_LIBRTE_I40E_PMD
13318 if (ret == -ENOTSUP)
13319 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13321 RTE_PMD_I40E_PKG_OP_WR_ADD);
13324 if (ret == -EEXIST)
13325 printf("Profile has already existed.\n");
13327 printf("Failed to load profile.\n");
13328 else if (file_num == 2)
13329 save_ddp_package_file(file_fld[1], buff, size);
13331 close_ddp_package_file(buff);
13332 free((void *)filepath);
13335 cmdline_parse_inst_t cmd_ddp_add = {
13336 .f = cmd_ddp_add_parsed,
13338 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
13340 (void *)&cmd_ddp_add_ddp,
13341 (void *)&cmd_ddp_add_add,
13342 (void *)&cmd_ddp_add_port_id,
13343 (void *)&cmd_ddp_add_filepath,
13348 /* Delete dynamic device personalization*/
13349 struct cmd_ddp_del_result {
13350 cmdline_fixed_string_t ddp;
13351 cmdline_fixed_string_t del;
13356 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13357 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13358 cmdline_parse_token_string_t cmd_ddp_del_del =
13359 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13360 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13361 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT8);
13362 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13363 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13366 cmd_ddp_del_parsed(
13367 void *parsed_result,
13368 __attribute__((unused)) struct cmdline *cl,
13369 __attribute__((unused)) void *data)
13371 struct cmd_ddp_del_result *res = parsed_result;
13374 int ret = -ENOTSUP;
13376 if (res->port_id > nb_ports) {
13377 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13381 if (!all_ports_stopped()) {
13382 printf("Please stop all ports first\n");
13386 buff = open_ddp_package_file(res->filepath, &size);
13390 #ifdef RTE_LIBRTE_I40E_PMD
13391 if (ret == -ENOTSUP)
13392 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13394 RTE_PMD_I40E_PKG_OP_WR_DEL);
13397 if (ret == -EACCES)
13398 printf("Profile does not exist.\n");
13400 printf("Failed to delete profile.\n");
13402 close_ddp_package_file(buff);
13405 cmdline_parse_inst_t cmd_ddp_del = {
13406 .f = cmd_ddp_del_parsed,
13408 .help_str = "ddp del <port_id> <profile_path>",
13410 (void *)&cmd_ddp_del_ddp,
13411 (void *)&cmd_ddp_del_del,
13412 (void *)&cmd_ddp_del_port_id,
13413 (void *)&cmd_ddp_del_filepath,
13418 /* Get dynamic device personalization profile info */
13419 struct cmd_ddp_info_result {
13420 cmdline_fixed_string_t ddp;
13421 cmdline_fixed_string_t get;
13422 cmdline_fixed_string_t info;
13426 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13427 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13428 cmdline_parse_token_string_t cmd_ddp_info_get =
13429 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13430 cmdline_parse_token_string_t cmd_ddp_info_info =
13431 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13432 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13433 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13436 cmd_ddp_info_parsed(
13437 void *parsed_result,
13438 __attribute__((unused)) struct cmdline *cl,
13439 __attribute__((unused)) void *data)
13441 struct cmd_ddp_info_result *res = parsed_result;
13444 int ret = -ENOTSUP;
13445 #ifdef RTE_LIBRTE_I40E_PMD
13448 uint32_t buff_size = 0;
13449 struct rte_pmd_i40e_profile_info info;
13450 uint32_t dev_num = 0;
13451 struct rte_pmd_i40e_ddp_device_id *devs;
13452 uint32_t proto_num = 0;
13453 struct rte_pmd_i40e_proto_info *proto;
13454 uint32_t pctype_num = 0;
13455 struct rte_pmd_i40e_ptype_info *pctype;
13456 uint32_t ptype_num = 0;
13457 struct rte_pmd_i40e_ptype_info *ptype;
13462 pkg = open_ddp_package_file(res->filepath, &pkg_size);
13466 #ifdef RTE_LIBRTE_I40E_PMD
13467 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13468 (uint8_t *)&info, sizeof(info),
13469 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13471 printf("Global Track id: 0x%x\n", info.track_id);
13472 printf("Global Version: %d.%d.%d.%d\n",
13473 info.version.major,
13474 info.version.minor,
13475 info.version.update,
13476 info.version.draft);
13477 printf("Global Package name: %s\n\n", info.name);
13480 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13481 (uint8_t *)&info, sizeof(info),
13482 RTE_PMD_I40E_PKG_INFO_HEADER);
13484 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13485 printf("i40e Profile Version: %d.%d.%d.%d\n",
13486 info.version.major,
13487 info.version.minor,
13488 info.version.update,
13489 info.version.draft);
13490 printf("i40e Profile name: %s\n\n", info.name);
13493 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13494 (uint8_t *)&buff_size, sizeof(buff_size),
13495 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13496 if (!ret && buff_size) {
13497 buff = (uint8_t *)malloc(buff_size);
13499 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13501 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13503 printf("Package Notes:\n%s\n\n", buff);
13508 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13509 (uint8_t *)&dev_num, sizeof(dev_num),
13510 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13511 if (!ret && dev_num) {
13512 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
13513 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
13515 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13516 (uint8_t *)devs, buff_size,
13517 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13519 printf("List of supported devices:\n");
13520 for (i = 0; i < dev_num; i++) {
13521 printf(" %04X:%04X %04X:%04X\n",
13522 devs[i].vendor_dev_id >> 16,
13523 devs[i].vendor_dev_id & 0xFFFF,
13524 devs[i].sub_vendor_dev_id >> 16,
13525 devs[i].sub_vendor_dev_id & 0xFFFF);
13533 /* get information about protocols and packet types */
13534 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13535 (uint8_t *)&proto_num, sizeof(proto_num),
13536 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
13537 if (ret || !proto_num)
13538 goto no_print_return;
13540 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
13541 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
13543 goto no_print_return;
13545 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
13547 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
13549 printf("List of used protocols:\n");
13550 for (i = 0; i < proto_num; i++)
13551 printf(" %2u: %s\n", proto[i].proto_id,
13555 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13556 (uint8_t *)&pctype_num, sizeof(pctype_num),
13557 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
13558 if (ret || !pctype_num)
13559 goto no_print_pctypes;
13561 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13562 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13564 goto no_print_pctypes;
13566 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
13568 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
13571 goto no_print_pctypes;
13574 printf("List of defined packet classification types:\n");
13575 for (i = 0; i < pctype_num; i++) {
13576 printf(" %2u:", pctype[i].ptype_id);
13577 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13578 proto_id = pctype[i].protocols[j];
13579 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13580 for (n = 0; n < proto_num; n++) {
13581 if (proto[n].proto_id == proto_id) {
13582 printf(" %s", proto[n].name);
13595 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
13597 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
13598 if (ret || !ptype_num)
13599 goto no_print_return;
13601 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13602 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13604 goto no_print_return;
13606 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
13608 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
13611 goto no_print_return;
13613 printf("List of defined packet types:\n");
13614 for (i = 0; i < ptype_num; i++) {
13615 printf(" %2u:", ptype[i].ptype_id);
13616 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13617 proto_id = ptype[i].protocols[j];
13618 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13619 for (n = 0; n < proto_num; n++) {
13620 if (proto[n].proto_id == proto_id) {
13621 printf(" %s", proto[n].name);
13636 if (ret == -ENOTSUP)
13637 printf("Function not supported in PMD driver\n");
13638 close_ddp_package_file(pkg);
13641 cmdline_parse_inst_t cmd_ddp_get_info = {
13642 .f = cmd_ddp_info_parsed,
13644 .help_str = "ddp get info <profile_path>",
13646 (void *)&cmd_ddp_info_ddp,
13647 (void *)&cmd_ddp_info_get,
13648 (void *)&cmd_ddp_info_info,
13649 (void *)&cmd_ddp_info_filepath,
13654 /* Get dynamic device personalization profile info list*/
13655 #define PROFILE_INFO_SIZE 48
13656 #define MAX_PROFILE_NUM 16
13658 struct cmd_ddp_get_list_result {
13659 cmdline_fixed_string_t ddp;
13660 cmdline_fixed_string_t get;
13661 cmdline_fixed_string_t list;
13665 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
13666 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
13667 cmdline_parse_token_string_t cmd_ddp_get_list_get =
13668 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
13669 cmdline_parse_token_string_t cmd_ddp_get_list_list =
13670 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
13671 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
13672 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
13675 cmd_ddp_get_list_parsed(
13676 void *parsed_result,
13677 __attribute__((unused)) struct cmdline *cl,
13678 __attribute__((unused)) void *data)
13680 struct cmd_ddp_get_list_result *res = parsed_result;
13681 #ifdef RTE_LIBRTE_I40E_PMD
13682 struct rte_pmd_i40e_profile_list *p_list;
13683 struct rte_pmd_i40e_profile_info *p_info;
13688 int ret = -ENOTSUP;
13690 if (res->port_id > nb_ports) {
13691 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13695 #ifdef RTE_LIBRTE_I40E_PMD
13696 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
13697 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
13699 printf("%s: Failed to malloc buffer\n", __func__);
13701 if (ret == -ENOTSUP)
13702 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
13703 (uint8_t *)p_list, size);
13706 p_num = p_list->p_count;
13707 printf("Profile number is: %d\n\n", p_num);
13709 for (i = 0; i < p_num; i++) {
13710 p_info = &p_list->p_info[i];
13711 printf("Profile %d:\n", i);
13712 printf("Track id: 0x%x\n", p_info->track_id);
13713 printf("Version: %d.%d.%d.%d\n",
13714 p_info->version.major,
13715 p_info->version.minor,
13716 p_info->version.update,
13717 p_info->version.draft);
13718 printf("Profile name: %s\n\n", p_info->name);
13726 printf("Failed to get ddp list\n");
13729 cmdline_parse_inst_t cmd_ddp_get_list = {
13730 .f = cmd_ddp_get_list_parsed,
13732 .help_str = "ddp get list <port_id>",
13734 (void *)&cmd_ddp_get_list_ddp,
13735 (void *)&cmd_ddp_get_list_get,
13736 (void *)&cmd_ddp_get_list_list,
13737 (void *)&cmd_ddp_get_list_port_id,
13742 /* show vf stats */
13744 /* Common result structure for show vf stats */
13745 struct cmd_show_vf_stats_result {
13746 cmdline_fixed_string_t show;
13747 cmdline_fixed_string_t vf;
13748 cmdline_fixed_string_t stats;
13753 /* Common CLI fields show vf stats*/
13754 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13755 TOKEN_STRING_INITIALIZER
13756 (struct cmd_show_vf_stats_result,
13758 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13759 TOKEN_STRING_INITIALIZER
13760 (struct cmd_show_vf_stats_result,
13762 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13763 TOKEN_STRING_INITIALIZER
13764 (struct cmd_show_vf_stats_result,
13766 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13767 TOKEN_NUM_INITIALIZER
13768 (struct cmd_show_vf_stats_result,
13770 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13771 TOKEN_NUM_INITIALIZER
13772 (struct cmd_show_vf_stats_result,
13776 cmd_show_vf_stats_parsed(
13777 void *parsed_result,
13778 __attribute__((unused)) struct cmdline *cl,
13779 __attribute__((unused)) void *data)
13781 struct cmd_show_vf_stats_result *res = parsed_result;
13782 struct rte_eth_stats stats;
13783 int ret = -ENOTSUP;
13784 static const char *nic_stats_border = "########################";
13786 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13789 memset(&stats, 0, sizeof(stats));
13791 #ifdef RTE_LIBRTE_I40E_PMD
13792 if (ret == -ENOTSUP)
13793 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13797 #ifdef RTE_LIBRTE_BNXT_PMD
13798 if (ret == -ENOTSUP)
13799 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
13808 printf("invalid vf_id %d\n", res->vf_id);
13811 printf("invalid port_id %d\n", res->port_id);
13814 printf("function not implemented\n");
13817 printf("programming error: (%s)\n", strerror(-ret));
13820 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13821 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13823 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13825 stats.ipackets, stats.imissed, stats.ibytes);
13826 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13827 printf(" RX-nombuf: %-10"PRIu64"\n",
13829 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13831 stats.opackets, stats.oerrors, stats.obytes);
13833 printf(" %s############################%s\n",
13834 nic_stats_border, nic_stats_border);
13837 cmdline_parse_inst_t cmd_show_vf_stats = {
13838 .f = cmd_show_vf_stats_parsed,
13840 .help_str = "show vf stats <port_id> <vf_id>",
13842 (void *)&cmd_show_vf_stats_show,
13843 (void *)&cmd_show_vf_stats_vf,
13844 (void *)&cmd_show_vf_stats_stats,
13845 (void *)&cmd_show_vf_stats_port_id,
13846 (void *)&cmd_show_vf_stats_vf_id,
13851 /* clear vf stats */
13853 /* Common result structure for clear vf stats */
13854 struct cmd_clear_vf_stats_result {
13855 cmdline_fixed_string_t clear;
13856 cmdline_fixed_string_t vf;
13857 cmdline_fixed_string_t stats;
13862 /* Common CLI fields clear vf stats*/
13863 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13864 TOKEN_STRING_INITIALIZER
13865 (struct cmd_clear_vf_stats_result,
13867 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13868 TOKEN_STRING_INITIALIZER
13869 (struct cmd_clear_vf_stats_result,
13871 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13872 TOKEN_STRING_INITIALIZER
13873 (struct cmd_clear_vf_stats_result,
13875 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13876 TOKEN_NUM_INITIALIZER
13877 (struct cmd_clear_vf_stats_result,
13879 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13880 TOKEN_NUM_INITIALIZER
13881 (struct cmd_clear_vf_stats_result,
13885 cmd_clear_vf_stats_parsed(
13886 void *parsed_result,
13887 __attribute__((unused)) struct cmdline *cl,
13888 __attribute__((unused)) void *data)
13890 struct cmd_clear_vf_stats_result *res = parsed_result;
13891 int ret = -ENOTSUP;
13893 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13896 #ifdef RTE_LIBRTE_I40E_PMD
13897 if (ret == -ENOTSUP)
13898 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13901 #ifdef RTE_LIBRTE_BNXT_PMD
13902 if (ret == -ENOTSUP)
13903 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
13911 printf("invalid vf_id %d\n", res->vf_id);
13914 printf("invalid port_id %d\n", res->port_id);
13917 printf("function not implemented\n");
13920 printf("programming error: (%s)\n", strerror(-ret));
13924 cmdline_parse_inst_t cmd_clear_vf_stats = {
13925 .f = cmd_clear_vf_stats_parsed,
13927 .help_str = "clear vf stats <port_id> <vf_id>",
13929 (void *)&cmd_clear_vf_stats_clear,
13930 (void *)&cmd_clear_vf_stats_vf,
13931 (void *)&cmd_clear_vf_stats_stats,
13932 (void *)&cmd_clear_vf_stats_port_id,
13933 (void *)&cmd_clear_vf_stats_vf_id,
13938 /* port config pctype mapping reset */
13940 /* Common result structure for port config pctype mapping reset */
13941 struct cmd_pctype_mapping_reset_result {
13942 cmdline_fixed_string_t port;
13943 cmdline_fixed_string_t config;
13945 cmdline_fixed_string_t pctype;
13946 cmdline_fixed_string_t mapping;
13947 cmdline_fixed_string_t reset;
13950 /* Common CLI fields for port config pctype mapping reset*/
13951 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
13952 TOKEN_STRING_INITIALIZER
13953 (struct cmd_pctype_mapping_reset_result,
13955 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
13956 TOKEN_STRING_INITIALIZER
13957 (struct cmd_pctype_mapping_reset_result,
13959 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
13960 TOKEN_NUM_INITIALIZER
13961 (struct cmd_pctype_mapping_reset_result,
13963 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
13964 TOKEN_STRING_INITIALIZER
13965 (struct cmd_pctype_mapping_reset_result,
13967 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
13968 TOKEN_STRING_INITIALIZER
13969 (struct cmd_pctype_mapping_reset_result,
13970 mapping, "mapping");
13971 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
13972 TOKEN_STRING_INITIALIZER
13973 (struct cmd_pctype_mapping_reset_result,
13977 cmd_pctype_mapping_reset_parsed(
13978 void *parsed_result,
13979 __attribute__((unused)) struct cmdline *cl,
13980 __attribute__((unused)) void *data)
13982 struct cmd_pctype_mapping_reset_result *res = parsed_result;
13983 int ret = -ENOTSUP;
13985 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13988 #ifdef RTE_LIBRTE_I40E_PMD
13989 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
13996 printf("invalid port_id %d\n", res->port_id);
13999 printf("function not implemented\n");
14002 printf("programming error: (%s)\n", strerror(-ret));
14006 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14007 .f = cmd_pctype_mapping_reset_parsed,
14009 .help_str = "port config <port_id> pctype mapping reset",
14011 (void *)&cmd_pctype_mapping_reset_port,
14012 (void *)&cmd_pctype_mapping_reset_config,
14013 (void *)&cmd_pctype_mapping_reset_port_id,
14014 (void *)&cmd_pctype_mapping_reset_pctype,
14015 (void *)&cmd_pctype_mapping_reset_mapping,
14016 (void *)&cmd_pctype_mapping_reset_reset,
14021 /* show port pctype mapping */
14023 /* Common result structure for show port pctype mapping */
14024 struct cmd_pctype_mapping_get_result {
14025 cmdline_fixed_string_t show;
14026 cmdline_fixed_string_t port;
14028 cmdline_fixed_string_t pctype;
14029 cmdline_fixed_string_t mapping;
14032 /* Common CLI fields for pctype mapping get */
14033 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14034 TOKEN_STRING_INITIALIZER
14035 (struct cmd_pctype_mapping_get_result,
14037 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14038 TOKEN_STRING_INITIALIZER
14039 (struct cmd_pctype_mapping_get_result,
14041 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14042 TOKEN_NUM_INITIALIZER
14043 (struct cmd_pctype_mapping_get_result,
14045 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14046 TOKEN_STRING_INITIALIZER
14047 (struct cmd_pctype_mapping_get_result,
14049 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14050 TOKEN_STRING_INITIALIZER
14051 (struct cmd_pctype_mapping_get_result,
14052 mapping, "mapping");
14055 cmd_pctype_mapping_get_parsed(
14056 void *parsed_result,
14057 __attribute__((unused)) struct cmdline *cl,
14058 __attribute__((unused)) void *data)
14060 struct cmd_pctype_mapping_get_result *res = parsed_result;
14061 int ret = -ENOTSUP;
14062 #ifdef RTE_LIBRTE_I40E_PMD
14063 struct rte_pmd_i40e_flow_type_mapping
14064 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14065 int i, j, first_pctype;
14068 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14071 #ifdef RTE_LIBRTE_I40E_PMD
14072 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14079 printf("invalid port_id %d\n", res->port_id);
14082 printf("function not implemented\n");
14085 printf("programming error: (%s)\n", strerror(-ret));
14089 #ifdef RTE_LIBRTE_I40E_PMD
14090 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14091 if (mapping[i].pctype != 0ULL) {
14094 printf("pctype: ");
14095 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14096 if (mapping[i].pctype & (1ULL << j)) {
14097 printf(first_pctype ?
14098 "%02d" : ",%02d", j);
14102 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14108 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14109 .f = cmd_pctype_mapping_get_parsed,
14111 .help_str = "show port <port_id> pctype mapping",
14113 (void *)&cmd_pctype_mapping_get_show,
14114 (void *)&cmd_pctype_mapping_get_port,
14115 (void *)&cmd_pctype_mapping_get_port_id,
14116 (void *)&cmd_pctype_mapping_get_pctype,
14117 (void *)&cmd_pctype_mapping_get_mapping,
14122 /* port config pctype mapping update */
14124 /* Common result structure for port config pctype mapping update */
14125 struct cmd_pctype_mapping_update_result {
14126 cmdline_fixed_string_t port;
14127 cmdline_fixed_string_t config;
14129 cmdline_fixed_string_t pctype;
14130 cmdline_fixed_string_t mapping;
14131 cmdline_fixed_string_t update;
14132 cmdline_fixed_string_t pctype_list;
14133 uint16_t flow_type;
14136 /* Common CLI fields for pctype mapping update*/
14137 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14138 TOKEN_STRING_INITIALIZER
14139 (struct cmd_pctype_mapping_update_result,
14141 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14142 TOKEN_STRING_INITIALIZER
14143 (struct cmd_pctype_mapping_update_result,
14145 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14146 TOKEN_NUM_INITIALIZER
14147 (struct cmd_pctype_mapping_update_result,
14149 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14150 TOKEN_STRING_INITIALIZER
14151 (struct cmd_pctype_mapping_update_result,
14153 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14154 TOKEN_STRING_INITIALIZER
14155 (struct cmd_pctype_mapping_update_result,
14156 mapping, "mapping");
14157 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
14158 TOKEN_STRING_INITIALIZER
14159 (struct cmd_pctype_mapping_update_result,
14161 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
14162 TOKEN_STRING_INITIALIZER
14163 (struct cmd_pctype_mapping_update_result,
14164 pctype_list, NULL);
14165 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
14166 TOKEN_NUM_INITIALIZER
14167 (struct cmd_pctype_mapping_update_result,
14168 flow_type, UINT16);
14171 cmd_pctype_mapping_update_parsed(
14172 void *parsed_result,
14173 __attribute__((unused)) struct cmdline *cl,
14174 __attribute__((unused)) void *data)
14176 struct cmd_pctype_mapping_update_result *res = parsed_result;
14177 int ret = -ENOTSUP;
14178 #ifdef RTE_LIBRTE_I40E_PMD
14179 struct rte_pmd_i40e_flow_type_mapping mapping;
14182 unsigned int nb_item;
14183 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
14185 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14188 nb_item = parse_item_list(res->pctype_list, "pctypes",
14189 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
14191 #ifdef RTE_LIBRTE_I40E_PMD
14192 mapping.flow_type = res->flow_type;
14193 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
14194 mapping.pctype |= (1ULL << pctype_list[i]);
14195 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
14205 printf("invalid pctype or flow type\n");
14208 printf("invalid port_id %d\n", res->port_id);
14211 printf("function not implemented\n");
14214 printf("programming error: (%s)\n", strerror(-ret));
14218 cmdline_parse_inst_t cmd_pctype_mapping_update = {
14219 .f = cmd_pctype_mapping_update_parsed,
14221 .help_str = "port config <port_id> pctype mapping update"
14222 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
14224 (void *)&cmd_pctype_mapping_update_port,
14225 (void *)&cmd_pctype_mapping_update_config,
14226 (void *)&cmd_pctype_mapping_update_port_id,
14227 (void *)&cmd_pctype_mapping_update_pctype,
14228 (void *)&cmd_pctype_mapping_update_mapping,
14229 (void *)&cmd_pctype_mapping_update_update,
14230 (void *)&cmd_pctype_mapping_update_pc_type,
14231 (void *)&cmd_pctype_mapping_update_flow_type,
14236 /* ptype mapping get */
14238 /* Common result structure for ptype mapping get */
14239 struct cmd_ptype_mapping_get_result {
14240 cmdline_fixed_string_t ptype;
14241 cmdline_fixed_string_t mapping;
14242 cmdline_fixed_string_t get;
14244 uint8_t valid_only;
14247 /* Common CLI fields for ptype mapping get */
14248 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
14249 TOKEN_STRING_INITIALIZER
14250 (struct cmd_ptype_mapping_get_result,
14252 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
14253 TOKEN_STRING_INITIALIZER
14254 (struct cmd_ptype_mapping_get_result,
14255 mapping, "mapping");
14256 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
14257 TOKEN_STRING_INITIALIZER
14258 (struct cmd_ptype_mapping_get_result,
14260 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
14261 TOKEN_NUM_INITIALIZER
14262 (struct cmd_ptype_mapping_get_result,
14264 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
14265 TOKEN_NUM_INITIALIZER
14266 (struct cmd_ptype_mapping_get_result,
14267 valid_only, UINT8);
14270 cmd_ptype_mapping_get_parsed(
14271 void *parsed_result,
14272 __attribute__((unused)) struct cmdline *cl,
14273 __attribute__((unused)) void *data)
14275 struct cmd_ptype_mapping_get_result *res = parsed_result;
14276 int ret = -ENOTSUP;
14277 #ifdef RTE_LIBRTE_I40E_PMD
14278 int max_ptype_num = 256;
14279 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
14284 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14287 #ifdef RTE_LIBRTE_I40E_PMD
14288 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
14299 printf("invalid port_id %d\n", res->port_id);
14302 printf("function not implemented\n");
14305 printf("programming error: (%s)\n", strerror(-ret));
14308 #ifdef RTE_LIBRTE_I40E_PMD
14310 for (i = 0; i < count; i++)
14311 printf("%3d\t0x%08x\n",
14312 mapping[i].hw_ptype, mapping[i].sw_ptype);
14317 cmdline_parse_inst_t cmd_ptype_mapping_get = {
14318 .f = cmd_ptype_mapping_get_parsed,
14320 .help_str = "ptype mapping get <port_id> <valid_only>",
14322 (void *)&cmd_ptype_mapping_get_ptype,
14323 (void *)&cmd_ptype_mapping_get_mapping,
14324 (void *)&cmd_ptype_mapping_get_get,
14325 (void *)&cmd_ptype_mapping_get_port_id,
14326 (void *)&cmd_ptype_mapping_get_valid_only,
14331 /* ptype mapping replace */
14333 /* Common result structure for ptype mapping replace */
14334 struct cmd_ptype_mapping_replace_result {
14335 cmdline_fixed_string_t ptype;
14336 cmdline_fixed_string_t mapping;
14337 cmdline_fixed_string_t replace;
14344 /* Common CLI fields for ptype mapping replace */
14345 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
14346 TOKEN_STRING_INITIALIZER
14347 (struct cmd_ptype_mapping_replace_result,
14349 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
14350 TOKEN_STRING_INITIALIZER
14351 (struct cmd_ptype_mapping_replace_result,
14352 mapping, "mapping");
14353 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
14354 TOKEN_STRING_INITIALIZER
14355 (struct cmd_ptype_mapping_replace_result,
14356 replace, "replace");
14357 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
14358 TOKEN_NUM_INITIALIZER
14359 (struct cmd_ptype_mapping_replace_result,
14361 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
14362 TOKEN_NUM_INITIALIZER
14363 (struct cmd_ptype_mapping_replace_result,
14365 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
14366 TOKEN_NUM_INITIALIZER
14367 (struct cmd_ptype_mapping_replace_result,
14369 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
14370 TOKEN_NUM_INITIALIZER
14371 (struct cmd_ptype_mapping_replace_result,
14375 cmd_ptype_mapping_replace_parsed(
14376 void *parsed_result,
14377 __attribute__((unused)) struct cmdline *cl,
14378 __attribute__((unused)) void *data)
14380 struct cmd_ptype_mapping_replace_result *res = parsed_result;
14381 int ret = -ENOTSUP;
14383 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14386 #ifdef RTE_LIBRTE_I40E_PMD
14387 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
14397 printf("invalid ptype 0x%8x or 0x%8x\n",
14398 res->target, res->pkt_type);
14401 printf("invalid port_id %d\n", res->port_id);
14404 printf("function not implemented\n");
14407 printf("programming error: (%s)\n", strerror(-ret));
14411 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
14412 .f = cmd_ptype_mapping_replace_parsed,
14415 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
14417 (void *)&cmd_ptype_mapping_replace_ptype,
14418 (void *)&cmd_ptype_mapping_replace_mapping,
14419 (void *)&cmd_ptype_mapping_replace_replace,
14420 (void *)&cmd_ptype_mapping_replace_port_id,
14421 (void *)&cmd_ptype_mapping_replace_target,
14422 (void *)&cmd_ptype_mapping_replace_mask,
14423 (void *)&cmd_ptype_mapping_replace_pkt_type,
14428 /* ptype mapping reset */
14430 /* Common result structure for ptype mapping reset */
14431 struct cmd_ptype_mapping_reset_result {
14432 cmdline_fixed_string_t ptype;
14433 cmdline_fixed_string_t mapping;
14434 cmdline_fixed_string_t reset;
14438 /* Common CLI fields for ptype mapping reset*/
14439 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
14440 TOKEN_STRING_INITIALIZER
14441 (struct cmd_ptype_mapping_reset_result,
14443 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
14444 TOKEN_STRING_INITIALIZER
14445 (struct cmd_ptype_mapping_reset_result,
14446 mapping, "mapping");
14447 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
14448 TOKEN_STRING_INITIALIZER
14449 (struct cmd_ptype_mapping_reset_result,
14451 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
14452 TOKEN_NUM_INITIALIZER
14453 (struct cmd_ptype_mapping_reset_result,
14457 cmd_ptype_mapping_reset_parsed(
14458 void *parsed_result,
14459 __attribute__((unused)) struct cmdline *cl,
14460 __attribute__((unused)) void *data)
14462 struct cmd_ptype_mapping_reset_result *res = parsed_result;
14463 int ret = -ENOTSUP;
14465 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14468 #ifdef RTE_LIBRTE_I40E_PMD
14469 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
14476 printf("invalid port_id %d\n", res->port_id);
14479 printf("function not implemented\n");
14482 printf("programming error: (%s)\n", strerror(-ret));
14486 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
14487 .f = cmd_ptype_mapping_reset_parsed,
14489 .help_str = "ptype mapping reset <port_id>",
14491 (void *)&cmd_ptype_mapping_reset_ptype,
14492 (void *)&cmd_ptype_mapping_reset_mapping,
14493 (void *)&cmd_ptype_mapping_reset_reset,
14494 (void *)&cmd_ptype_mapping_reset_port_id,
14499 /* ptype mapping update */
14501 /* Common result structure for ptype mapping update */
14502 struct cmd_ptype_mapping_update_result {
14503 cmdline_fixed_string_t ptype;
14504 cmdline_fixed_string_t mapping;
14505 cmdline_fixed_string_t reset;
14511 /* Common CLI fields for ptype mapping update*/
14512 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
14513 TOKEN_STRING_INITIALIZER
14514 (struct cmd_ptype_mapping_update_result,
14516 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
14517 TOKEN_STRING_INITIALIZER
14518 (struct cmd_ptype_mapping_update_result,
14519 mapping, "mapping");
14520 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
14521 TOKEN_STRING_INITIALIZER
14522 (struct cmd_ptype_mapping_update_result,
14524 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
14525 TOKEN_NUM_INITIALIZER
14526 (struct cmd_ptype_mapping_update_result,
14528 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
14529 TOKEN_NUM_INITIALIZER
14530 (struct cmd_ptype_mapping_update_result,
14532 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
14533 TOKEN_NUM_INITIALIZER
14534 (struct cmd_ptype_mapping_update_result,
14538 cmd_ptype_mapping_update_parsed(
14539 void *parsed_result,
14540 __attribute__((unused)) struct cmdline *cl,
14541 __attribute__((unused)) void *data)
14543 struct cmd_ptype_mapping_update_result *res = parsed_result;
14544 int ret = -ENOTSUP;
14545 #ifdef RTE_LIBRTE_I40E_PMD
14546 struct rte_pmd_i40e_ptype_mapping mapping;
14548 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14551 #ifdef RTE_LIBRTE_I40E_PMD
14552 mapping.hw_ptype = res->hw_ptype;
14553 mapping.sw_ptype = res->sw_ptype;
14554 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
14564 printf("invalid ptype 0x%8x\n", res->sw_ptype);
14567 printf("invalid port_id %d\n", res->port_id);
14570 printf("function not implemented\n");
14573 printf("programming error: (%s)\n", strerror(-ret));
14577 cmdline_parse_inst_t cmd_ptype_mapping_update = {
14578 .f = cmd_ptype_mapping_update_parsed,
14580 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
14582 (void *)&cmd_ptype_mapping_update_ptype,
14583 (void *)&cmd_ptype_mapping_update_mapping,
14584 (void *)&cmd_ptype_mapping_update_update,
14585 (void *)&cmd_ptype_mapping_update_port_id,
14586 (void *)&cmd_ptype_mapping_update_hw_ptype,
14587 (void *)&cmd_ptype_mapping_update_sw_ptype,
14592 /* Common result structure for file commands */
14593 struct cmd_cmdfile_result {
14594 cmdline_fixed_string_t load;
14595 cmdline_fixed_string_t filename;
14598 /* Common CLI fields for file commands */
14599 cmdline_parse_token_string_t cmd_load_cmdfile =
14600 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
14601 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
14602 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
14605 cmd_load_from_file_parsed(
14606 void *parsed_result,
14607 __attribute__((unused)) struct cmdline *cl,
14608 __attribute__((unused)) void *data)
14610 struct cmd_cmdfile_result *res = parsed_result;
14612 cmdline_read_from_file(res->filename);
14615 cmdline_parse_inst_t cmd_load_from_file = {
14616 .f = cmd_load_from_file_parsed,
14618 .help_str = "load <filename>",
14620 (void *)&cmd_load_cmdfile,
14621 (void *)&cmd_load_cmdfile_filename,
14626 /* ******************************************************************************** */
14628 /* list of instructions */
14629 cmdline_parse_ctx_t main_ctx[] = {
14630 (cmdline_parse_inst_t *)&cmd_help_brief,
14631 (cmdline_parse_inst_t *)&cmd_help_long,
14632 (cmdline_parse_inst_t *)&cmd_quit,
14633 (cmdline_parse_inst_t *)&cmd_load_from_file,
14634 (cmdline_parse_inst_t *)&cmd_showport,
14635 (cmdline_parse_inst_t *)&cmd_showqueue,
14636 (cmdline_parse_inst_t *)&cmd_showportall,
14637 (cmdline_parse_inst_t *)&cmd_showcfg,
14638 (cmdline_parse_inst_t *)&cmd_start,
14639 (cmdline_parse_inst_t *)&cmd_start_tx_first,
14640 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
14641 (cmdline_parse_inst_t *)&cmd_set_link_up,
14642 (cmdline_parse_inst_t *)&cmd_set_link_down,
14643 (cmdline_parse_inst_t *)&cmd_reset,
14644 (cmdline_parse_inst_t *)&cmd_set_numbers,
14645 (cmdline_parse_inst_t *)&cmd_set_txpkts,
14646 (cmdline_parse_inst_t *)&cmd_set_txsplit,
14647 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
14648 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
14649 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
14650 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
14651 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
14652 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
14653 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
14654 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
14655 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
14656 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
14657 (cmdline_parse_inst_t *)&cmd_set_link_check,
14658 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
14659 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
14660 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
14661 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
14662 #ifdef RTE_LIBRTE_PMD_BOND
14663 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
14664 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
14665 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
14666 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
14667 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
14668 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
14669 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
14670 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
14671 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
14672 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
14673 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
14675 (cmdline_parse_inst_t *)&cmd_vlan_offload,
14676 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
14677 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
14678 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
14679 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
14680 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
14681 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
14682 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
14683 (cmdline_parse_inst_t *)&cmd_csum_set,
14684 (cmdline_parse_inst_t *)&cmd_csum_show,
14685 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
14686 (cmdline_parse_inst_t *)&cmd_tso_set,
14687 (cmdline_parse_inst_t *)&cmd_tso_show,
14688 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
14689 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
14690 (cmdline_parse_inst_t *)&cmd_enable_gro,
14691 (cmdline_parse_inst_t *)&cmd_gro_set,
14692 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
14693 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
14694 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
14695 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
14696 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
14697 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
14698 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
14699 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
14700 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
14701 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
14702 (cmdline_parse_inst_t *)&cmd_config_dcb,
14703 (cmdline_parse_inst_t *)&cmd_read_reg,
14704 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
14705 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
14706 (cmdline_parse_inst_t *)&cmd_write_reg,
14707 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
14708 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
14709 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
14710 (cmdline_parse_inst_t *)&cmd_stop,
14711 (cmdline_parse_inst_t *)&cmd_mac_addr,
14712 (cmdline_parse_inst_t *)&cmd_set_qmap,
14713 (cmdline_parse_inst_t *)&cmd_operate_port,
14714 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
14715 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
14716 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
14717 (cmdline_parse_inst_t *)&cmd_config_speed_all,
14718 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
14719 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
14720 (cmdline_parse_inst_t *)&cmd_config_mtu,
14721 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
14722 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
14723 (cmdline_parse_inst_t *)&cmd_config_rss,
14724 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
14725 (cmdline_parse_inst_t *)&cmd_config_txqflags,
14726 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
14727 (cmdline_parse_inst_t *)&cmd_showport_reta,
14728 (cmdline_parse_inst_t *)&cmd_config_burst,
14729 (cmdline_parse_inst_t *)&cmd_config_thresh,
14730 (cmdline_parse_inst_t *)&cmd_config_threshold,
14731 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
14732 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
14733 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
14734 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
14735 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
14736 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
14737 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
14738 (cmdline_parse_inst_t *)&cmd_global_config,
14739 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
14740 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
14741 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
14742 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
14743 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
14744 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
14745 (cmdline_parse_inst_t *)&cmd_dump,
14746 (cmdline_parse_inst_t *)&cmd_dump_one,
14747 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
14748 (cmdline_parse_inst_t *)&cmd_syn_filter,
14749 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
14750 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
14751 (cmdline_parse_inst_t *)&cmd_flex_filter,
14752 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
14753 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
14754 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
14755 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
14756 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
14757 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
14758 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
14759 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
14760 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
14761 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
14762 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
14763 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
14764 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
14765 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
14766 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
14767 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
14768 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
14769 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
14770 (cmdline_parse_inst_t *)&cmd_flow,
14771 (cmdline_parse_inst_t *)&cmd_mcast_addr,
14772 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
14773 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
14774 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
14775 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
14776 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
14777 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
14778 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
14779 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
14780 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
14781 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
14782 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
14783 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
14784 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
14785 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
14786 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
14787 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
14788 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
14789 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
14790 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
14791 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
14792 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
14793 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
14794 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
14795 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
14796 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
14797 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
14798 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
14799 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
14800 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
14801 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
14802 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
14803 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
14804 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
14805 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
14806 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
14807 (cmdline_parse_inst_t *)&cmd_ddp_add,
14808 (cmdline_parse_inst_t *)&cmd_ddp_del,
14809 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
14810 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
14811 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
14812 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
14813 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
14814 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
14815 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
14816 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
14818 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
14819 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
14820 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
14824 /* read cmdline commands from file */
14826 cmdline_read_from_file(const char *filename)
14828 struct cmdline *cl;
14830 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14832 printf("Failed to create file based cmdline context: %s\n",
14837 cmdline_interact(cl);
14842 printf("Read CLI commands from %s\n", filename);
14845 /* prompt function, called from main on MASTER lcore */
14849 /* initialize non-constant commands */
14850 cmd_set_fwd_mode_init();
14851 cmd_set_fwd_retry_mode_init();
14853 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14854 if (testpmd_cl == NULL)
14856 cmdline_interact(testpmd_cl);
14857 cmdline_stdin_exit(testpmd_cl);
14863 if (testpmd_cl != NULL)
14864 cmdline_quit(testpmd_cl);
14868 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14870 if (id == (portid_t)RTE_PORT_ALL) {
14873 RTE_ETH_FOREACH_DEV(pid) {
14874 /* check if need_reconfig has been set to 1 */
14875 if (ports[pid].need_reconfig == 0)
14876 ports[pid].need_reconfig = dev;
14877 /* check if need_reconfig_queues has been set to 1 */
14878 if (ports[pid].need_reconfig_queues == 0)
14879 ports[pid].need_reconfig_queues = queue;
14881 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14882 /* check if need_reconfig has been set to 1 */
14883 if (ports[id].need_reconfig == 0)
14884 ports[id].need_reconfig = dev;
14885 /* check if need_reconfig_queues has been set to 1 */
14886 if (ports[id].need_reconfig_queues == 0)
14887 ports[id].need_reconfig_queues = queue;