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 "set port (port_id) gro on|off\n"
431 " Enable or disable Generic Receive Offload in"
432 " csum forwarding engine.\n\n"
434 "show port (port_id) gro\n"
435 " Display GRO configuration.\n\n"
437 "set gro flush (cycles)\n"
438 " Set the cycle to flush GROed packets from"
439 " reassembly tables.\n\n"
441 "set port (port_id) gso (on|off)"
442 " Enable or disable Generic Segmentation Offload in"
443 " csum forwarding engine.\n\n"
445 "set gso segsz (length)\n"
446 " Set max packet length for output GSO segments,"
447 " including packet header and payload.\n\n"
449 "show port (port_id) gso\n"
450 " Show GSO configuration.\n\n"
453 " Set packet forwarding mode.\n\n"
455 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
456 " Add a MAC address on port_id.\n\n"
458 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
459 " Remove a MAC address from port_id.\n\n"
461 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
462 " Set the default MAC address for port_id.\n\n"
464 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
465 " Add a MAC address for a VF on the port.\n\n"
467 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
468 " Set the MAC address for a VF from the PF.\n\n"
470 "set port (port_id) uta (mac_address|all) (on|off)\n"
471 " Add/Remove a or all unicast hash filter(s)"
474 "set promisc (port_id|all) (on|off)\n"
475 " Set the promiscuous mode on port_id, or all.\n\n"
477 "set allmulti (port_id|all) (on|off)\n"
478 " Set the allmulti mode on port_id, or all.\n\n"
480 "set vf promisc (port_id) (vf_id) (on|off)\n"
481 " Set unicast promiscuous mode for a VF from the PF.\n\n"
483 "set vf allmulti (port_id) (vf_id) (on|off)\n"
484 " Set multicast promiscuous mode for a VF from the PF.\n\n"
486 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
487 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
488 " (on|off) autoneg (on|off) (port_id)\n"
489 "set flow_ctrl rx (on|off) (portid)\n"
490 "set flow_ctrl tx (on|off) (portid)\n"
491 "set flow_ctrl high_water (high_water) (portid)\n"
492 "set flow_ctrl low_water (low_water) (portid)\n"
493 "set flow_ctrl pause_time (pause_time) (portid)\n"
494 "set flow_ctrl send_xon (send_xon) (portid)\n"
495 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
496 "set flow_ctrl autoneg (on|off) (port_id)\n"
497 " Set the link flow control parameter on a port.\n\n"
499 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
500 " (low_water) (pause_time) (priority) (port_id)\n"
501 " Set the priority flow control parameter on a"
504 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
505 " Set statistics mapping (qmapping 0..15) for RX/TX"
507 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
508 " on port 0 to mapping 5.\n\n"
510 "set port (port_id) vf (vf_id) rx|tx on|off\n"
511 " Enable/Disable a VF receive/tranmit from a port\n\n"
513 "set port (port_id) vf (vf_id) (mac_addr)"
514 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
515 " Add/Remove unicast or multicast MAC addr filter"
518 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
520 " AUPE:accepts untagged VLAN;"
521 "ROPE:accept unicast hash\n\n"
522 " BAM:accepts broadcast packets;"
523 "MPE:accepts all multicast packets\n\n"
524 " Enable/Disable a VF receive mode of a port\n\n"
526 "set port (port_id) queue (queue_id) rate (rate_num)\n"
527 " Set rate limit for a queue of a port\n\n"
529 "set port (port_id) vf (vf_id) rate (rate_num) "
530 "queue_mask (queue_mask_value)\n"
531 " Set rate limit for queues in VF of a port\n\n"
533 "set port (port_id) mirror-rule (rule_id)"
534 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
535 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
536 " Set pool or vlan type mirror rule on a port.\n"
537 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
538 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
541 "set port (port_id) mirror-rule (rule_id)"
542 " (uplink-mirror|downlink-mirror) dst-pool"
543 " (pool_id) (on|off)\n"
544 " Set uplink or downlink type mirror rule on a port.\n"
545 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
546 " 0 on' enable mirror income traffic to pool 0.\n\n"
548 "reset port (port_id) mirror-rule (rule_id)\n"
549 " Reset a mirror rule.\n\n"
551 "set flush_rx (on|off)\n"
552 " Flush (default) or don't flush RX streams before"
553 " forwarding. Mainly used with PCAP drivers.\n\n"
555 "set bypass mode (normal|bypass|isolate) (port_id)\n"
556 " Set the bypass mode for the lowest port on bypass enabled"
559 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
560 "mode (normal|bypass|isolate) (port_id)\n"
561 " Set the event required to initiate specified bypass mode for"
562 " the lowest port on a bypass enabled NIC where:\n"
563 " timeout = enable bypass after watchdog timeout.\n"
564 " os_on = enable bypass when OS/board is powered on.\n"
565 " os_off = enable bypass when OS/board is powered off.\n"
566 " power_on = enable bypass when power supply is turned on.\n"
567 " power_off = enable bypass when power supply is turned off."
570 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
571 " Set the bypass watchdog timeout to 'n' seconds"
572 " where 0 = instant.\n\n"
574 "show bypass config (port_id)\n"
575 " Show the bypass configuration for a bypass enabled NIC"
576 " using the lowest port on the NIC.\n\n"
578 #ifdef RTE_LIBRTE_PMD_BOND
579 "create bonded device (mode) (socket)\n"
580 " Create a new bonded device with specific bonding mode and socket.\n\n"
582 "add bonding slave (slave_id) (port_id)\n"
583 " Add a slave device to a bonded device.\n\n"
585 "remove bonding slave (slave_id) (port_id)\n"
586 " Remove a slave device from a bonded device.\n\n"
588 "set bonding mode (value) (port_id)\n"
589 " Set the bonding mode on a bonded device.\n\n"
591 "set bonding primary (slave_id) (port_id)\n"
592 " Set the primary slave for a bonded device.\n\n"
594 "show bonding config (port_id)\n"
595 " Show the bonding config for port_id.\n\n"
597 "set bonding mac_addr (port_id) (address)\n"
598 " Set the MAC address of a bonded device.\n\n"
600 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
601 " Set Aggregation mode for IEEE802.3AD (mode 4)"
603 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
604 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
606 "set bonding mon_period (port_id) (value)\n"
607 " Set the bonding link status monitoring polling period in ms.\n\n"
609 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
610 " Enable/disable dedicated queues for LACP control traffic.\n\n"
613 "set link-up port (port_id)\n"
614 " Set link up for a port.\n\n"
616 "set link-down port (port_id)\n"
617 " Set link down for a port.\n\n"
619 "E-tag set insertion on port-tag-id (value)"
620 " port (port_id) vf (vf_id)\n"
621 " Enable E-tag insertion for a VF on a port\n\n"
623 "E-tag set insertion off port (port_id) vf (vf_id)\n"
624 " Disable E-tag insertion for a VF on a port\n\n"
626 "E-tag set stripping (on|off) port (port_id)\n"
627 " Enable/disable E-tag stripping on a port\n\n"
629 "E-tag set forwarding (on|off) port (port_id)\n"
630 " Enable/disable E-tag based forwarding"
633 "E-tag set filter add e-tag-id (value) dst-pool"
634 " (pool_id) port (port_id)\n"
635 " Add an E-tag forwarding filter on a port\n\n"
637 "E-tag set filter del e-tag-id (value) port (port_id)\n"
638 " Delete an E-tag forwarding filter on a port\n\n"
640 "ddp add (port_id) (profile_path[,output_path])\n"
641 " Load a profile package on a port\n\n"
643 "ddp del (port_id) (profile_path)\n"
644 " Delete a profile package from a port\n\n"
646 "ptype mapping get (port_id) (valid_only)\n"
647 " Get ptype mapping on a port\n\n"
649 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
650 " Replace target with the pkt_type in ptype mapping\n\n"
652 "ptype mapping reset (port_id)\n"
653 " Reset ptype mapping on a port\n\n"
655 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
656 " Update a ptype mapping item on a port\n\n"
658 , list_pkt_forwarding_modes()
662 if (show_all || !strcmp(res->section, "ports")) {
668 "----------------\n\n"
670 "port start (port_id|all)\n"
671 " Start all ports or port_id.\n\n"
673 "port stop (port_id|all)\n"
674 " Stop all ports or port_id.\n\n"
676 "port close (port_id|all)\n"
677 " Close all ports or port_id.\n\n"
679 "port attach (ident)\n"
680 " Attach physical or virtual dev by pci address or virtual device name\n\n"
682 "port detach (port_id)\n"
683 " Detach physical or virtual dev by port_id\n\n"
685 "port config (port_id|all)"
686 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
687 " duplex (half|full|auto)\n"
688 " Set speed and duplex for all ports or port_id\n\n"
690 "port config all (rxq|txq|rxd|txd) (value)\n"
691 " Set number for rxq/txq/rxd/txd.\n\n"
693 "port config all max-pkt-len (value)\n"
694 " Set the max packet length.\n\n"
696 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
697 "hw-vlan-strip|hw-vlan-extend|drop-en)"
699 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
702 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
703 "geneve|nvgre|none|<flowtype_id>)\n"
704 " Set the RSS mode.\n\n"
706 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
707 " Set the RSS redirection table.\n\n"
709 "port config (port_id) dcb vt (on|off) (traffic_class)"
711 " Set the DCB mode.\n\n"
713 "port config all burst (value)\n"
714 " Set the number of packets per burst.\n\n"
716 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
718 " Set the ring prefetch/host/writeback threshold"
719 " for tx/rx queue.\n\n"
721 "port config all (txfreet|txrst|rxfreet) (value)\n"
722 " Set free threshold for rx/tx, or set"
723 " tx rs bit threshold.\n\n"
724 "port config mtu X value\n"
725 " Set the MTU of port X to a given value\n\n"
727 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
728 " Start/stop a rx/tx queue of port X. Only take effect"
729 " when port X is started\n\n"
731 "port config (port_id|all) l2-tunnel E-tag ether-type"
733 " Set the value of E-tag ether-type.\n\n"
735 "port config (port_id|all) l2-tunnel E-tag"
736 " (enable|disable)\n"
737 " Enable/disable the E-tag support.\n\n"
739 "port config (port_id) pctype mapping reset\n"
740 " Reset flow type to pctype mapping on a port\n\n"
742 "port config (port_id) pctype mapping update"
743 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
744 " Update a flow type to pctype mapping item on a port\n\n"
748 if (show_all || !strcmp(res->section, "registers")) {
756 "read reg (port_id) (address)\n"
757 " Display value of a port register.\n\n"
759 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
760 " Display a port register bit field.\n\n"
762 "read regbit (port_id) (address) (bit_x)\n"
763 " Display a single port register bit.\n\n"
765 "write reg (port_id) (address) (value)\n"
766 " Set value of a port register.\n\n"
768 "write regfield (port_id) (address) (bit_x) (bit_y)"
770 " Set bit field of a port register.\n\n"
772 "write regbit (port_id) (address) (bit_x) (value)\n"
773 " Set single bit value of a port register.\n\n"
776 if (show_all || !strcmp(res->section, "filters")) {
784 "ethertype_filter (port_id) (add|del)"
785 " (mac_addr|mac_ignr) (mac_address) ethertype"
786 " (ether_type) (drop|fwd) queue (queue_id)\n"
787 " Add/Del an ethertype filter.\n\n"
789 "2tuple_filter (port_id) (add|del)"
790 " dst_port (dst_port_value) protocol (protocol_value)"
791 " mask (mask_value) tcp_flags (tcp_flags_value)"
792 " priority (prio_value) queue (queue_id)\n"
793 " Add/Del a 2tuple filter.\n\n"
795 "5tuple_filter (port_id) (add|del)"
796 " dst_ip (dst_address) src_ip (src_address)"
797 " dst_port (dst_port_value) src_port (src_port_value)"
798 " protocol (protocol_value)"
799 " mask (mask_value) tcp_flags (tcp_flags_value)"
800 " priority (prio_value) queue (queue_id)\n"
801 " Add/Del a 5tuple filter.\n\n"
803 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
804 " Add/Del syn filter.\n\n"
806 "flex_filter (port_id) (add|del) len (len_value)"
807 " bytes (bytes_value) mask (mask_value)"
808 " priority (prio_value) queue (queue_id)\n"
809 " Add/Del a flex filter.\n\n"
811 "flow_director_filter (port_id) mode IP (add|del|update)"
812 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
813 " src (src_ip_address) dst (dst_ip_address)"
814 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
815 " vlan (vlan_value) flexbytes (flexbytes_value)"
816 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
817 " fd_id (fd_id_value)\n"
818 " Add/Del an IP type flow director filter.\n\n"
820 "flow_director_filter (port_id) mode IP (add|del|update)"
821 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
822 " src (src_ip_address) (src_port)"
823 " dst (dst_ip_address) (dst_port)"
824 " tos (tos_value) ttl (ttl_value)"
825 " vlan (vlan_value) flexbytes (flexbytes_value)"
826 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
827 " fd_id (fd_id_value)\n"
828 " Add/Del an UDP/TCP type flow director filter.\n\n"
830 "flow_director_filter (port_id) mode IP (add|del|update)"
831 " flow (ipv4-sctp|ipv6-sctp)"
832 " src (src_ip_address) (src_port)"
833 " dst (dst_ip_address) (dst_port)"
834 " tag (verification_tag) "
835 " tos (tos_value) ttl (ttl_value)"
837 " flexbytes (flexbytes_value) (drop|fwd)"
838 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
839 " Add/Del a SCTP type flow director filter.\n\n"
841 "flow_director_filter (port_id) mode IP (add|del|update)"
842 " flow l2_payload ether (ethertype)"
843 " flexbytes (flexbytes_value) (drop|fwd)"
844 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
845 " Add/Del a l2 payload type flow director filter.\n\n"
847 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
848 " mac (mac_address) vlan (vlan_value)"
849 " flexbytes (flexbytes_value) (drop|fwd)"
850 " queue (queue_id) fd_id (fd_id_value)\n"
851 " Add/Del a MAC-VLAN flow director filter.\n\n"
853 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
854 " mac (mac_address) vlan (vlan_value)"
855 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
856 " flexbytes (flexbytes_value) (drop|fwd)"
857 " queue (queue_id) fd_id (fd_id_value)\n"
858 " Add/Del a Tunnel flow director filter.\n\n"
860 "flush_flow_director (port_id)\n"
861 " Flush all flow director entries of a device.\n\n"
863 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
864 " src_mask (ipv4_src) (ipv6_src) (src_port)"
865 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
866 " Set flow director IP mask.\n\n"
868 "flow_director_mask (port_id) mode MAC-VLAN"
869 " vlan (vlan_value)\n"
870 " Set flow director MAC-VLAN mask.\n\n"
872 "flow_director_mask (port_id) mode Tunnel"
873 " vlan (vlan_value) mac (mac_value)"
874 " tunnel-type (tunnel_type_value)"
875 " tunnel-id (tunnel_id_value)\n"
876 " Set flow director Tunnel mask.\n\n"
878 "flow_director_flex_mask (port_id)"
879 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
880 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
882 " Configure mask of flex payload.\n\n"
884 "flow_director_flex_payload (port_id)"
885 " (raw|l2|l3|l4) (config)\n"
886 " Configure flex payload selection.\n\n"
888 "get_sym_hash_ena_per_port (port_id)\n"
889 " get symmetric hash enable configuration per port.\n\n"
891 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
892 " set symmetric hash enable configuration per port"
893 " to enable or disable.\n\n"
895 "get_hash_global_config (port_id)\n"
896 " Get the global configurations of hash filters.\n\n"
898 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
899 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
900 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
901 " (enable|disable)\n"
902 " Set the global configurations of hash filters.\n\n"
904 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
905 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
906 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
907 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
908 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
909 "ipv6-next-header|udp-src-port|udp-dst-port|"
910 "tcp-src-port|tcp-dst-port|sctp-src-port|"
911 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
912 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
913 "fld-8th|none) (select|add)\n"
914 " Set the input set for hash.\n\n"
916 "set_fdir_input_set (port_id) "
917 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
918 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
919 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
920 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
921 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
922 "udp-dst-port|tcp-src-port|tcp-dst-port|"
923 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
925 " Set the input set for FDir.\n\n"
927 "flow validate {port_id}"
928 " [group {group_id}] [priority {level}]"
929 " [ingress] [egress]"
930 " pattern {item} [/ {item} [...]] / end"
931 " actions {action} [/ {action} [...]] / end\n"
932 " Check whether a flow rule can be created.\n\n"
934 "flow create {port_id}"
935 " [group {group_id}] [priority {level}]"
936 " [ingress] [egress]"
937 " pattern {item} [/ {item} [...]] / end"
938 " actions {action} [/ {action} [...]] / end\n"
939 " Create a flow rule.\n\n"
941 "flow destroy {port_id} rule {rule_id} [...]\n"
942 " Destroy specific flow rules.\n\n"
944 "flow flush {port_id}\n"
945 " Destroy all flow rules.\n\n"
947 "flow query {port_id} {rule_id} {action}\n"
948 " Query an existing flow rule.\n\n"
950 "flow list {port_id} [group {group_id}] [...]\n"
951 " List existing flow rules sorted by priority,"
952 " filtered by group identifiers.\n\n"
954 "flow isolate {port_id} {boolean}\n"
955 " Restrict ingress traffic to the defined"
961 cmdline_parse_token_string_t cmd_help_long_help =
962 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
964 cmdline_parse_token_string_t cmd_help_long_section =
965 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
966 "all#control#display#config#"
967 "ports#registers#filters");
969 cmdline_parse_inst_t cmd_help_long = {
970 .f = cmd_help_long_parsed,
972 .help_str = "help all|control|display|config|ports|register|filters: "
975 (void *)&cmd_help_long_help,
976 (void *)&cmd_help_long_section,
982 /* *** start/stop/close all ports *** */
983 struct cmd_operate_port_result {
984 cmdline_fixed_string_t keyword;
985 cmdline_fixed_string_t name;
986 cmdline_fixed_string_t value;
989 static void cmd_operate_port_parsed(void *parsed_result,
990 __attribute__((unused)) struct cmdline *cl,
991 __attribute__((unused)) void *data)
993 struct cmd_operate_port_result *res = parsed_result;
995 if (!strcmp(res->name, "start"))
996 start_port(RTE_PORT_ALL);
997 else if (!strcmp(res->name, "stop"))
998 stop_port(RTE_PORT_ALL);
999 else if (!strcmp(res->name, "close"))
1000 close_port(RTE_PORT_ALL);
1001 else if (!strcmp(res->name, "reset"))
1002 reset_port(RTE_PORT_ALL);
1004 printf("Unknown parameter\n");
1007 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1008 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1010 cmdline_parse_token_string_t cmd_operate_port_all_port =
1011 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1012 "start#stop#close#reset");
1013 cmdline_parse_token_string_t cmd_operate_port_all_all =
1014 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1016 cmdline_parse_inst_t cmd_operate_port = {
1017 .f = cmd_operate_port_parsed,
1019 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1021 (void *)&cmd_operate_port_all_cmd,
1022 (void *)&cmd_operate_port_all_port,
1023 (void *)&cmd_operate_port_all_all,
1028 /* *** start/stop/close specific port *** */
1029 struct cmd_operate_specific_port_result {
1030 cmdline_fixed_string_t keyword;
1031 cmdline_fixed_string_t name;
1035 static void cmd_operate_specific_port_parsed(void *parsed_result,
1036 __attribute__((unused)) struct cmdline *cl,
1037 __attribute__((unused)) void *data)
1039 struct cmd_operate_specific_port_result *res = parsed_result;
1041 if (!strcmp(res->name, "start"))
1042 start_port(res->value);
1043 else if (!strcmp(res->name, "stop"))
1044 stop_port(res->value);
1045 else if (!strcmp(res->name, "close"))
1046 close_port(res->value);
1047 else if (!strcmp(res->name, "reset"))
1048 reset_port(res->value);
1050 printf("Unknown parameter\n");
1053 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1054 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1056 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1057 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1058 name, "start#stop#close#reset");
1059 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1060 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1063 cmdline_parse_inst_t cmd_operate_specific_port = {
1064 .f = cmd_operate_specific_port_parsed,
1066 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1068 (void *)&cmd_operate_specific_port_cmd,
1069 (void *)&cmd_operate_specific_port_port,
1070 (void *)&cmd_operate_specific_port_id,
1075 /* *** attach a specified port *** */
1076 struct cmd_operate_attach_port_result {
1077 cmdline_fixed_string_t port;
1078 cmdline_fixed_string_t keyword;
1079 cmdline_fixed_string_t identifier;
1082 static void cmd_operate_attach_port_parsed(void *parsed_result,
1083 __attribute__((unused)) struct cmdline *cl,
1084 __attribute__((unused)) void *data)
1086 struct cmd_operate_attach_port_result *res = parsed_result;
1088 if (!strcmp(res->keyword, "attach"))
1089 attach_port(res->identifier);
1091 printf("Unknown parameter\n");
1094 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1095 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1097 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1098 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1100 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1101 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1104 cmdline_parse_inst_t cmd_operate_attach_port = {
1105 .f = cmd_operate_attach_port_parsed,
1107 .help_str = "port attach <identifier>: "
1108 "(identifier: pci address or virtual dev name)",
1110 (void *)&cmd_operate_attach_port_port,
1111 (void *)&cmd_operate_attach_port_keyword,
1112 (void *)&cmd_operate_attach_port_identifier,
1117 /* *** detach a specified port *** */
1118 struct cmd_operate_detach_port_result {
1119 cmdline_fixed_string_t port;
1120 cmdline_fixed_string_t keyword;
1124 static void cmd_operate_detach_port_parsed(void *parsed_result,
1125 __attribute__((unused)) struct cmdline *cl,
1126 __attribute__((unused)) void *data)
1128 struct cmd_operate_detach_port_result *res = parsed_result;
1130 if (!strcmp(res->keyword, "detach"))
1131 detach_port(res->port_id);
1133 printf("Unknown parameter\n");
1136 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1137 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1139 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1140 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1142 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1143 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1146 cmdline_parse_inst_t cmd_operate_detach_port = {
1147 .f = cmd_operate_detach_port_parsed,
1149 .help_str = "port detach <port_id>",
1151 (void *)&cmd_operate_detach_port_port,
1152 (void *)&cmd_operate_detach_port_keyword,
1153 (void *)&cmd_operate_detach_port_port_id,
1158 /* *** configure speed for all ports *** */
1159 struct cmd_config_speed_all {
1160 cmdline_fixed_string_t port;
1161 cmdline_fixed_string_t keyword;
1162 cmdline_fixed_string_t all;
1163 cmdline_fixed_string_t item1;
1164 cmdline_fixed_string_t item2;
1165 cmdline_fixed_string_t value1;
1166 cmdline_fixed_string_t value2;
1170 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1175 if (!strcmp(duplexstr, "half")) {
1176 duplex = ETH_LINK_HALF_DUPLEX;
1177 } else if (!strcmp(duplexstr, "full")) {
1178 duplex = ETH_LINK_FULL_DUPLEX;
1179 } else if (!strcmp(duplexstr, "auto")) {
1180 duplex = ETH_LINK_FULL_DUPLEX;
1182 printf("Unknown duplex parameter\n");
1186 if (!strcmp(speedstr, "10")) {
1187 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1188 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1189 } else if (!strcmp(speedstr, "100")) {
1190 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1191 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1193 if (duplex != ETH_LINK_FULL_DUPLEX) {
1194 printf("Invalid speed/duplex parameters\n");
1197 if (!strcmp(speedstr, "1000")) {
1198 *speed = ETH_LINK_SPEED_1G;
1199 } else if (!strcmp(speedstr, "10000")) {
1200 *speed = ETH_LINK_SPEED_10G;
1201 } else if (!strcmp(speedstr, "25000")) {
1202 *speed = ETH_LINK_SPEED_25G;
1203 } else if (!strcmp(speedstr, "40000")) {
1204 *speed = ETH_LINK_SPEED_40G;
1205 } else if (!strcmp(speedstr, "50000")) {
1206 *speed = ETH_LINK_SPEED_50G;
1207 } else if (!strcmp(speedstr, "100000")) {
1208 *speed = ETH_LINK_SPEED_100G;
1209 } else if (!strcmp(speedstr, "auto")) {
1210 *speed = ETH_LINK_SPEED_AUTONEG;
1212 printf("Unknown speed parameter\n");
1221 cmd_config_speed_all_parsed(void *parsed_result,
1222 __attribute__((unused)) struct cmdline *cl,
1223 __attribute__((unused)) void *data)
1225 struct cmd_config_speed_all *res = parsed_result;
1226 uint32_t link_speed;
1229 if (!all_ports_stopped()) {
1230 printf("Please stop all ports first\n");
1234 if (parse_and_check_speed_duplex(res->value1, res->value2,
1238 RTE_ETH_FOREACH_DEV(pid) {
1239 ports[pid].dev_conf.link_speeds = link_speed;
1242 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1245 cmdline_parse_token_string_t cmd_config_speed_all_port =
1246 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1247 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1248 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1250 cmdline_parse_token_string_t cmd_config_speed_all_all =
1251 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1252 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1253 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1254 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1255 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1256 "10#100#1000#10000#25000#40000#50000#100000#auto");
1257 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1258 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1259 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1260 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1263 cmdline_parse_inst_t cmd_config_speed_all = {
1264 .f = cmd_config_speed_all_parsed,
1266 .help_str = "port config all speed "
1267 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1270 (void *)&cmd_config_speed_all_port,
1271 (void *)&cmd_config_speed_all_keyword,
1272 (void *)&cmd_config_speed_all_all,
1273 (void *)&cmd_config_speed_all_item1,
1274 (void *)&cmd_config_speed_all_value1,
1275 (void *)&cmd_config_speed_all_item2,
1276 (void *)&cmd_config_speed_all_value2,
1281 /* *** configure speed for specific port *** */
1282 struct cmd_config_speed_specific {
1283 cmdline_fixed_string_t port;
1284 cmdline_fixed_string_t keyword;
1286 cmdline_fixed_string_t item1;
1287 cmdline_fixed_string_t item2;
1288 cmdline_fixed_string_t value1;
1289 cmdline_fixed_string_t value2;
1293 cmd_config_speed_specific_parsed(void *parsed_result,
1294 __attribute__((unused)) struct cmdline *cl,
1295 __attribute__((unused)) void *data)
1297 struct cmd_config_speed_specific *res = parsed_result;
1298 uint32_t link_speed;
1300 if (!all_ports_stopped()) {
1301 printf("Please stop all ports first\n");
1305 if (port_id_is_invalid(res->id, ENABLED_WARN))
1308 if (parse_and_check_speed_duplex(res->value1, res->value2,
1312 ports[res->id].dev_conf.link_speeds = link_speed;
1314 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1318 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1319 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1321 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1322 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1324 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1325 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1326 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1327 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1329 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1330 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1331 "10#100#1000#10000#25000#40000#50000#100000#auto");
1332 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1333 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1335 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1336 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1339 cmdline_parse_inst_t cmd_config_speed_specific = {
1340 .f = cmd_config_speed_specific_parsed,
1342 .help_str = "port config <port_id> speed "
1343 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1346 (void *)&cmd_config_speed_specific_port,
1347 (void *)&cmd_config_speed_specific_keyword,
1348 (void *)&cmd_config_speed_specific_id,
1349 (void *)&cmd_config_speed_specific_item1,
1350 (void *)&cmd_config_speed_specific_value1,
1351 (void *)&cmd_config_speed_specific_item2,
1352 (void *)&cmd_config_speed_specific_value2,
1357 /* *** configure txq/rxq, txd/rxd *** */
1358 struct cmd_config_rx_tx {
1359 cmdline_fixed_string_t port;
1360 cmdline_fixed_string_t keyword;
1361 cmdline_fixed_string_t all;
1362 cmdline_fixed_string_t name;
1367 cmd_config_rx_tx_parsed(void *parsed_result,
1368 __attribute__((unused)) struct cmdline *cl,
1369 __attribute__((unused)) void *data)
1371 struct cmd_config_rx_tx *res = parsed_result;
1373 if (!all_ports_stopped()) {
1374 printf("Please stop all ports first\n");
1377 if (!strcmp(res->name, "rxq")) {
1378 if (!res->value && !nb_txq) {
1379 printf("Warning: Either rx or tx queues should be non zero\n");
1382 nb_rxq = res->value;
1384 else if (!strcmp(res->name, "txq")) {
1385 if (!res->value && !nb_rxq) {
1386 printf("Warning: Either rx or tx queues should be non zero\n");
1389 nb_txq = res->value;
1391 else if (!strcmp(res->name, "rxd")) {
1392 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1393 printf("rxd %d invalid - must be > 0 && <= %d\n",
1394 res->value, RTE_TEST_RX_DESC_MAX);
1397 nb_rxd = res->value;
1398 } else if (!strcmp(res->name, "txd")) {
1399 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1400 printf("txd %d invalid - must be > 0 && <= %d\n",
1401 res->value, RTE_TEST_TX_DESC_MAX);
1404 nb_txd = res->value;
1406 printf("Unknown parameter\n");
1414 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1417 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1418 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1419 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1420 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1421 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1422 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1423 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1424 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1426 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1427 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1429 cmdline_parse_inst_t cmd_config_rx_tx = {
1430 .f = cmd_config_rx_tx_parsed,
1432 .help_str = "port config all rxq|txq|rxd|txd <value>",
1434 (void *)&cmd_config_rx_tx_port,
1435 (void *)&cmd_config_rx_tx_keyword,
1436 (void *)&cmd_config_rx_tx_all,
1437 (void *)&cmd_config_rx_tx_name,
1438 (void *)&cmd_config_rx_tx_value,
1443 /* *** config max packet length *** */
1444 struct cmd_config_max_pkt_len_result {
1445 cmdline_fixed_string_t port;
1446 cmdline_fixed_string_t keyword;
1447 cmdline_fixed_string_t all;
1448 cmdline_fixed_string_t name;
1453 cmd_config_max_pkt_len_parsed(void *parsed_result,
1454 __attribute__((unused)) struct cmdline *cl,
1455 __attribute__((unused)) void *data)
1457 struct cmd_config_max_pkt_len_result *res = parsed_result;
1459 if (!all_ports_stopped()) {
1460 printf("Please stop all ports first\n");
1464 if (!strcmp(res->name, "max-pkt-len")) {
1465 if (res->value < ETHER_MIN_LEN) {
1466 printf("max-pkt-len can not be less than %d\n",
1470 if (res->value == rx_mode.max_rx_pkt_len)
1473 rx_mode.max_rx_pkt_len = res->value;
1474 if (res->value > ETHER_MAX_LEN)
1475 rx_mode.jumbo_frame = 1;
1477 rx_mode.jumbo_frame = 0;
1479 printf("Unknown parameter\n");
1485 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1488 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1489 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1491 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1492 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1494 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1495 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1497 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1498 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1500 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1501 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1504 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1505 .f = cmd_config_max_pkt_len_parsed,
1507 .help_str = "port config all max-pkt-len <value>",
1509 (void *)&cmd_config_max_pkt_len_port,
1510 (void *)&cmd_config_max_pkt_len_keyword,
1511 (void *)&cmd_config_max_pkt_len_all,
1512 (void *)&cmd_config_max_pkt_len_name,
1513 (void *)&cmd_config_max_pkt_len_value,
1518 /* *** configure port MTU *** */
1519 struct cmd_config_mtu_result {
1520 cmdline_fixed_string_t port;
1521 cmdline_fixed_string_t keyword;
1522 cmdline_fixed_string_t mtu;
1528 cmd_config_mtu_parsed(void *parsed_result,
1529 __attribute__((unused)) struct cmdline *cl,
1530 __attribute__((unused)) void *data)
1532 struct cmd_config_mtu_result *res = parsed_result;
1534 if (res->value < ETHER_MIN_LEN) {
1535 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1538 port_mtu_set(res->port_id, res->value);
1541 cmdline_parse_token_string_t cmd_config_mtu_port =
1542 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1544 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1545 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1547 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1548 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1550 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1551 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1552 cmdline_parse_token_num_t cmd_config_mtu_value =
1553 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1555 cmdline_parse_inst_t cmd_config_mtu = {
1556 .f = cmd_config_mtu_parsed,
1558 .help_str = "port config mtu <port_id> <value>",
1560 (void *)&cmd_config_mtu_port,
1561 (void *)&cmd_config_mtu_keyword,
1562 (void *)&cmd_config_mtu_mtu,
1563 (void *)&cmd_config_mtu_port_id,
1564 (void *)&cmd_config_mtu_value,
1569 /* *** configure rx mode *** */
1570 struct cmd_config_rx_mode_flag {
1571 cmdline_fixed_string_t port;
1572 cmdline_fixed_string_t keyword;
1573 cmdline_fixed_string_t all;
1574 cmdline_fixed_string_t name;
1575 cmdline_fixed_string_t value;
1579 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1580 __attribute__((unused)) struct cmdline *cl,
1581 __attribute__((unused)) void *data)
1583 struct cmd_config_rx_mode_flag *res = parsed_result;
1585 if (!all_ports_stopped()) {
1586 printf("Please stop all ports first\n");
1590 if (!strcmp(res->name, "crc-strip")) {
1591 if (!strcmp(res->value, "on"))
1592 rx_mode.hw_strip_crc = 1;
1593 else if (!strcmp(res->value, "off"))
1594 rx_mode.hw_strip_crc = 0;
1596 printf("Unknown parameter\n");
1599 } else if (!strcmp(res->name, "scatter")) {
1600 if (!strcmp(res->value, "on"))
1601 rx_mode.enable_scatter = 1;
1602 else if (!strcmp(res->value, "off"))
1603 rx_mode.enable_scatter = 0;
1605 printf("Unknown parameter\n");
1608 } else if (!strcmp(res->name, "rx-cksum")) {
1609 if (!strcmp(res->value, "on"))
1610 rx_mode.hw_ip_checksum = 1;
1611 else if (!strcmp(res->value, "off"))
1612 rx_mode.hw_ip_checksum = 0;
1614 printf("Unknown parameter\n");
1617 } else if (!strcmp(res->name, "hw-vlan")) {
1618 if (!strcmp(res->value, "on")) {
1619 rx_mode.hw_vlan_filter = 1;
1620 rx_mode.hw_vlan_strip = 1;
1622 else if (!strcmp(res->value, "off")) {
1623 rx_mode.hw_vlan_filter = 0;
1624 rx_mode.hw_vlan_strip = 0;
1627 printf("Unknown parameter\n");
1630 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1631 if (!strcmp(res->value, "on"))
1632 rx_mode.hw_vlan_filter = 1;
1633 else if (!strcmp(res->value, "off"))
1634 rx_mode.hw_vlan_filter = 0;
1636 printf("Unknown parameter\n");
1639 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1640 if (!strcmp(res->value, "on"))
1641 rx_mode.hw_vlan_strip = 1;
1642 else if (!strcmp(res->value, "off"))
1643 rx_mode.hw_vlan_strip = 0;
1645 printf("Unknown parameter\n");
1648 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1649 if (!strcmp(res->value, "on"))
1650 rx_mode.hw_vlan_extend = 1;
1651 else if (!strcmp(res->value, "off"))
1652 rx_mode.hw_vlan_extend = 0;
1654 printf("Unknown parameter\n");
1657 } else if (!strcmp(res->name, "drop-en")) {
1658 if (!strcmp(res->value, "on"))
1660 else if (!strcmp(res->value, "off"))
1663 printf("Unknown parameter\n");
1667 printf("Unknown parameter\n");
1673 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1676 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1677 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1678 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1679 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1681 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1682 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1683 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1684 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1685 "crc-strip#scatter#rx-cksum#hw-vlan#"
1686 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1687 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1688 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1691 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1692 .f = cmd_config_rx_mode_flag_parsed,
1694 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1695 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1697 (void *)&cmd_config_rx_mode_flag_port,
1698 (void *)&cmd_config_rx_mode_flag_keyword,
1699 (void *)&cmd_config_rx_mode_flag_all,
1700 (void *)&cmd_config_rx_mode_flag_name,
1701 (void *)&cmd_config_rx_mode_flag_value,
1706 /* *** configure rss *** */
1707 struct cmd_config_rss {
1708 cmdline_fixed_string_t port;
1709 cmdline_fixed_string_t keyword;
1710 cmdline_fixed_string_t all;
1711 cmdline_fixed_string_t name;
1712 cmdline_fixed_string_t value;
1716 cmd_config_rss_parsed(void *parsed_result,
1717 __attribute__((unused)) struct cmdline *cl,
1718 __attribute__((unused)) void *data)
1720 struct cmd_config_rss *res = parsed_result;
1721 struct rte_eth_rss_conf rss_conf;
1725 if (!strcmp(res->value, "all"))
1726 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1727 ETH_RSS_UDP | ETH_RSS_SCTP |
1729 else if (!strcmp(res->value, "ip"))
1730 rss_conf.rss_hf = ETH_RSS_IP;
1731 else if (!strcmp(res->value, "udp"))
1732 rss_conf.rss_hf = ETH_RSS_UDP;
1733 else if (!strcmp(res->value, "tcp"))
1734 rss_conf.rss_hf = ETH_RSS_TCP;
1735 else if (!strcmp(res->value, "sctp"))
1736 rss_conf.rss_hf = ETH_RSS_SCTP;
1737 else if (!strcmp(res->value, "ether"))
1738 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1739 else if (!strcmp(res->value, "port"))
1740 rss_conf.rss_hf = ETH_RSS_PORT;
1741 else if (!strcmp(res->value, "vxlan"))
1742 rss_conf.rss_hf = ETH_RSS_VXLAN;
1743 else if (!strcmp(res->value, "geneve"))
1744 rss_conf.rss_hf = ETH_RSS_GENEVE;
1745 else if (!strcmp(res->value, "nvgre"))
1746 rss_conf.rss_hf = ETH_RSS_NVGRE;
1747 else if (!strcmp(res->value, "none"))
1748 rss_conf.rss_hf = 0;
1749 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1750 atoi(res->value) < 64)
1751 rss_conf.rss_hf = 1ULL << atoi(res->value);
1753 printf("Unknown parameter\n");
1756 rss_conf.rss_key = NULL;
1757 for (i = 0; i < rte_eth_dev_count(); i++) {
1758 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1760 printf("Configuration of RSS hash at ethernet port %d "
1761 "failed with error (%d): %s.\n",
1762 i, -diag, strerror(-diag));
1766 cmdline_parse_token_string_t cmd_config_rss_port =
1767 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1768 cmdline_parse_token_string_t cmd_config_rss_keyword =
1769 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1770 cmdline_parse_token_string_t cmd_config_rss_all =
1771 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1772 cmdline_parse_token_string_t cmd_config_rss_name =
1773 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1774 cmdline_parse_token_string_t cmd_config_rss_value =
1775 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1777 cmdline_parse_inst_t cmd_config_rss = {
1778 .f = cmd_config_rss_parsed,
1780 .help_str = "port config all rss "
1781 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1783 (void *)&cmd_config_rss_port,
1784 (void *)&cmd_config_rss_keyword,
1785 (void *)&cmd_config_rss_all,
1786 (void *)&cmd_config_rss_name,
1787 (void *)&cmd_config_rss_value,
1792 /* *** configure rss hash key *** */
1793 struct cmd_config_rss_hash_key {
1794 cmdline_fixed_string_t port;
1795 cmdline_fixed_string_t config;
1797 cmdline_fixed_string_t rss_hash_key;
1798 cmdline_fixed_string_t rss_type;
1799 cmdline_fixed_string_t key;
1803 hexa_digit_to_value(char hexa_digit)
1805 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1806 return (uint8_t) (hexa_digit - '0');
1807 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1808 return (uint8_t) ((hexa_digit - 'a') + 10);
1809 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1810 return (uint8_t) ((hexa_digit - 'A') + 10);
1811 /* Invalid hexa digit */
1816 parse_and_check_key_hexa_digit(char *key, int idx)
1820 hexa_v = hexa_digit_to_value(key[idx]);
1822 printf("invalid key: character %c at position %d is not a "
1823 "valid hexa digit\n", key[idx], idx);
1828 cmd_config_rss_hash_key_parsed(void *parsed_result,
1829 __attribute__((unused)) struct cmdline *cl,
1830 __attribute__((unused)) void *data)
1832 struct cmd_config_rss_hash_key *res = parsed_result;
1833 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1837 struct rte_eth_dev_info dev_info;
1838 uint8_t hash_key_size;
1841 memset(&dev_info, 0, sizeof(dev_info));
1842 rte_eth_dev_info_get(res->port_id, &dev_info);
1843 if (dev_info.hash_key_size > 0 &&
1844 dev_info.hash_key_size <= sizeof(hash_key))
1845 hash_key_size = dev_info.hash_key_size;
1847 printf("dev_info did not provide a valid hash key size\n");
1850 /* Check the length of the RSS hash key */
1851 key_len = strlen(res->key);
1852 if (key_len != (hash_key_size * 2)) {
1853 printf("key length: %d invalid - key must be a string of %d"
1854 " hexa-decimal numbers\n",
1855 (int) key_len, hash_key_size * 2);
1858 /* Translate RSS hash key into binary representation */
1859 for (i = 0; i < hash_key_size; i++) {
1860 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1863 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1866 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1868 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1872 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1873 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1874 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1875 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1877 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1878 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1879 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1880 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1881 rss_hash_key, "rss-hash-key");
1882 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1883 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1884 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1885 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1886 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1887 "ipv6-tcp-ex#ipv6-udp-ex");
1888 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1889 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1891 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1892 .f = cmd_config_rss_hash_key_parsed,
1894 .help_str = "port config <port_id> rss-hash-key "
1895 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1896 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1897 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1898 "<string of hex digits (variable length, NIC dependent)>",
1900 (void *)&cmd_config_rss_hash_key_port,
1901 (void *)&cmd_config_rss_hash_key_config,
1902 (void *)&cmd_config_rss_hash_key_port_id,
1903 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1904 (void *)&cmd_config_rss_hash_key_rss_type,
1905 (void *)&cmd_config_rss_hash_key_value,
1910 /* *** configure port rxq/txq start/stop *** */
1911 struct cmd_config_rxtx_queue {
1912 cmdline_fixed_string_t port;
1914 cmdline_fixed_string_t rxtxq;
1916 cmdline_fixed_string_t opname;
1920 cmd_config_rxtx_queue_parsed(void *parsed_result,
1921 __attribute__((unused)) struct cmdline *cl,
1922 __attribute__((unused)) void *data)
1924 struct cmd_config_rxtx_queue *res = parsed_result;
1929 if (test_done == 0) {
1930 printf("Please stop forwarding first\n");
1934 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1937 if (port_is_started(res->portid) != 1) {
1938 printf("Please start port %u first\n", res->portid);
1942 if (!strcmp(res->rxtxq, "rxq"))
1944 else if (!strcmp(res->rxtxq, "txq"))
1947 printf("Unknown parameter\n");
1951 if (isrx && rx_queue_id_is_invalid(res->qid))
1953 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1956 if (!strcmp(res->opname, "start"))
1958 else if (!strcmp(res->opname, "stop"))
1961 printf("Unknown parameter\n");
1965 if (isstart && isrx)
1966 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1967 else if (!isstart && isrx)
1968 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1969 else if (isstart && !isrx)
1970 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1972 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1974 if (ret == -ENOTSUP)
1975 printf("Function not supported in PMD driver\n");
1978 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1979 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1980 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1981 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1982 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1983 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1984 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1985 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1986 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1987 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1990 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1991 .f = cmd_config_rxtx_queue_parsed,
1993 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1995 (void *)&cmd_config_speed_all_port,
1996 (void *)&cmd_config_rxtx_queue_portid,
1997 (void *)&cmd_config_rxtx_queue_rxtxq,
1998 (void *)&cmd_config_rxtx_queue_qid,
1999 (void *)&cmd_config_rxtx_queue_opname,
2004 /* *** Configure RSS RETA *** */
2005 struct cmd_config_rss_reta {
2006 cmdline_fixed_string_t port;
2007 cmdline_fixed_string_t keyword;
2009 cmdline_fixed_string_t name;
2010 cmdline_fixed_string_t list_name;
2011 cmdline_fixed_string_t list_of_items;
2015 parse_reta_config(const char *str,
2016 struct rte_eth_rss_reta_entry64 *reta_conf,
2017 uint16_t nb_entries)
2021 uint16_t hash_index, idx, shift;
2024 const char *p, *p0 = str;
2031 unsigned long int_fld[_NUM_FLD];
2032 char *str_fld[_NUM_FLD];
2034 while ((p = strchr(p0,'(')) != NULL) {
2036 if((p0 = strchr(p,')')) == NULL)
2040 if(size >= sizeof(s))
2043 snprintf(s, sizeof(s), "%.*s", size, p);
2044 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2046 for (i = 0; i < _NUM_FLD; i++) {
2048 int_fld[i] = strtoul(str_fld[i], &end, 0);
2049 if (errno != 0 || end == str_fld[i] ||
2054 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2055 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2057 if (hash_index >= nb_entries) {
2058 printf("Invalid RETA hash index=%d\n", hash_index);
2062 idx = hash_index / RTE_RETA_GROUP_SIZE;
2063 shift = hash_index % RTE_RETA_GROUP_SIZE;
2064 reta_conf[idx].mask |= (1ULL << shift);
2065 reta_conf[idx].reta[shift] = nb_queue;
2072 cmd_set_rss_reta_parsed(void *parsed_result,
2073 __attribute__((unused)) struct cmdline *cl,
2074 __attribute__((unused)) void *data)
2077 struct rte_eth_dev_info dev_info;
2078 struct rte_eth_rss_reta_entry64 reta_conf[8];
2079 struct cmd_config_rss_reta *res = parsed_result;
2081 memset(&dev_info, 0, sizeof(dev_info));
2082 rte_eth_dev_info_get(res->port_id, &dev_info);
2083 if (dev_info.reta_size == 0) {
2084 printf("Redirection table size is 0 which is "
2085 "invalid for RSS\n");
2088 printf("The reta size of port %d is %u\n",
2089 res->port_id, dev_info.reta_size);
2090 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2091 printf("Currently do not support more than %u entries of "
2092 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2096 memset(reta_conf, 0, sizeof(reta_conf));
2097 if (!strcmp(res->list_name, "reta")) {
2098 if (parse_reta_config(res->list_of_items, reta_conf,
2099 dev_info.reta_size)) {
2100 printf("Invalid RSS Redirection Table "
2101 "config entered\n");
2104 ret = rte_eth_dev_rss_reta_update(res->port_id,
2105 reta_conf, dev_info.reta_size);
2107 printf("Bad redirection table parameter, "
2108 "return code = %d \n", ret);
2112 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2113 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2114 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2115 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2116 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2117 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2118 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2119 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2120 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2121 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2122 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2123 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2125 cmdline_parse_inst_t cmd_config_rss_reta = {
2126 .f = cmd_set_rss_reta_parsed,
2128 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2130 (void *)&cmd_config_rss_reta_port,
2131 (void *)&cmd_config_rss_reta_keyword,
2132 (void *)&cmd_config_rss_reta_port_id,
2133 (void *)&cmd_config_rss_reta_name,
2134 (void *)&cmd_config_rss_reta_list_name,
2135 (void *)&cmd_config_rss_reta_list_of_items,
2140 /* *** SHOW PORT RETA INFO *** */
2141 struct cmd_showport_reta {
2142 cmdline_fixed_string_t show;
2143 cmdline_fixed_string_t port;
2145 cmdline_fixed_string_t rss;
2146 cmdline_fixed_string_t reta;
2148 cmdline_fixed_string_t list_of_items;
2152 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2153 uint16_t nb_entries,
2157 const char *p, *p0 = str;
2162 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2163 RTE_RETA_GROUP_SIZE;
2166 p = strchr(p0, '(');
2170 p0 = strchr(p, ')');
2174 if (size >= sizeof(s)) {
2175 printf("The string size exceeds the internal buffer size\n");
2178 snprintf(s, sizeof(s), "%.*s", size, p);
2179 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2180 if (ret <= 0 || ret != num) {
2181 printf("The bits of masks do not match the number of "
2182 "reta entries: %u\n", num);
2185 for (i = 0; i < ret; i++)
2186 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2192 cmd_showport_reta_parsed(void *parsed_result,
2193 __attribute__((unused)) struct cmdline *cl,
2194 __attribute__((unused)) void *data)
2196 struct cmd_showport_reta *res = parsed_result;
2197 struct rte_eth_rss_reta_entry64 reta_conf[8];
2198 struct rte_eth_dev_info dev_info;
2199 uint16_t max_reta_size;
2201 memset(&dev_info, 0, sizeof(dev_info));
2202 rte_eth_dev_info_get(res->port_id, &dev_info);
2203 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2204 if (res->size == 0 || res->size > max_reta_size) {
2205 printf("Invalid redirection table size: %u (1-%u)\n",
2206 res->size, max_reta_size);
2210 memset(reta_conf, 0, sizeof(reta_conf));
2211 if (showport_parse_reta_config(reta_conf, res->size,
2212 res->list_of_items) < 0) {
2213 printf("Invalid string: %s for reta masks\n",
2214 res->list_of_items);
2217 port_rss_reta_info(res->port_id, reta_conf, res->size);
2220 cmdline_parse_token_string_t cmd_showport_reta_show =
2221 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2222 cmdline_parse_token_string_t cmd_showport_reta_port =
2223 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2224 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2225 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2226 cmdline_parse_token_string_t cmd_showport_reta_rss =
2227 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2228 cmdline_parse_token_string_t cmd_showport_reta_reta =
2229 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2230 cmdline_parse_token_num_t cmd_showport_reta_size =
2231 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2232 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2233 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2234 list_of_items, NULL);
2236 cmdline_parse_inst_t cmd_showport_reta = {
2237 .f = cmd_showport_reta_parsed,
2239 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2241 (void *)&cmd_showport_reta_show,
2242 (void *)&cmd_showport_reta_port,
2243 (void *)&cmd_showport_reta_port_id,
2244 (void *)&cmd_showport_reta_rss,
2245 (void *)&cmd_showport_reta_reta,
2246 (void *)&cmd_showport_reta_size,
2247 (void *)&cmd_showport_reta_list_of_items,
2252 /* *** Show RSS hash configuration *** */
2253 struct cmd_showport_rss_hash {
2254 cmdline_fixed_string_t show;
2255 cmdline_fixed_string_t port;
2257 cmdline_fixed_string_t rss_hash;
2258 cmdline_fixed_string_t rss_type;
2259 cmdline_fixed_string_t key; /* optional argument */
2262 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2263 __attribute__((unused)) struct cmdline *cl,
2266 struct cmd_showport_rss_hash *res = parsed_result;
2268 port_rss_hash_conf_show(res->port_id, res->rss_type,
2269 show_rss_key != NULL);
2272 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2273 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2274 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2275 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2276 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2277 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2278 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2279 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2281 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2282 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2283 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2284 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2285 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2286 "ipv6-tcp-ex#ipv6-udp-ex");
2287 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2288 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2290 cmdline_parse_inst_t cmd_showport_rss_hash = {
2291 .f = cmd_showport_rss_hash_parsed,
2293 .help_str = "show port <port_id> rss-hash "
2294 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2295 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2296 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2298 (void *)&cmd_showport_rss_hash_show,
2299 (void *)&cmd_showport_rss_hash_port,
2300 (void *)&cmd_showport_rss_hash_port_id,
2301 (void *)&cmd_showport_rss_hash_rss_hash,
2302 (void *)&cmd_showport_rss_hash_rss_hash_info,
2307 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2308 .f = cmd_showport_rss_hash_parsed,
2310 .help_str = "show port <port_id> rss-hash "
2311 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2312 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2313 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2315 (void *)&cmd_showport_rss_hash_show,
2316 (void *)&cmd_showport_rss_hash_port,
2317 (void *)&cmd_showport_rss_hash_port_id,
2318 (void *)&cmd_showport_rss_hash_rss_hash,
2319 (void *)&cmd_showport_rss_hash_rss_hash_info,
2320 (void *)&cmd_showport_rss_hash_rss_key,
2325 /* *** Configure DCB *** */
2326 struct cmd_config_dcb {
2327 cmdline_fixed_string_t port;
2328 cmdline_fixed_string_t config;
2330 cmdline_fixed_string_t dcb;
2331 cmdline_fixed_string_t vt;
2332 cmdline_fixed_string_t vt_en;
2334 cmdline_fixed_string_t pfc;
2335 cmdline_fixed_string_t pfc_en;
2339 cmd_config_dcb_parsed(void *parsed_result,
2340 __attribute__((unused)) struct cmdline *cl,
2341 __attribute__((unused)) void *data)
2343 struct cmd_config_dcb *res = parsed_result;
2344 portid_t port_id = res->port_id;
2345 struct rte_port *port;
2349 port = &ports[port_id];
2350 /** Check if the port is not started **/
2351 if (port->port_status != RTE_PORT_STOPPED) {
2352 printf("Please stop port %d first\n", port_id);
2356 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2357 printf("The invalid number of traffic class,"
2358 " only 4 or 8 allowed.\n");
2362 if (nb_fwd_lcores < res->num_tcs) {
2363 printf("nb_cores shouldn't be less than number of TCs.\n");
2366 if (!strncmp(res->pfc_en, "on", 2))
2371 /* DCB in VT mode */
2372 if (!strncmp(res->vt_en, "on", 2))
2373 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2374 (enum rte_eth_nb_tcs)res->num_tcs,
2377 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2378 (enum rte_eth_nb_tcs)res->num_tcs,
2383 printf("Cannot initialize network ports.\n");
2387 cmd_reconfig_device_queue(port_id, 1, 1);
2390 cmdline_parse_token_string_t cmd_config_dcb_port =
2391 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2392 cmdline_parse_token_string_t cmd_config_dcb_config =
2393 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2394 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2395 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2396 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2397 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2398 cmdline_parse_token_string_t cmd_config_dcb_vt =
2399 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2400 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2401 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2402 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2403 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2404 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2405 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2406 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2407 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2409 cmdline_parse_inst_t cmd_config_dcb = {
2410 .f = cmd_config_dcb_parsed,
2412 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2414 (void *)&cmd_config_dcb_port,
2415 (void *)&cmd_config_dcb_config,
2416 (void *)&cmd_config_dcb_port_id,
2417 (void *)&cmd_config_dcb_dcb,
2418 (void *)&cmd_config_dcb_vt,
2419 (void *)&cmd_config_dcb_vt_en,
2420 (void *)&cmd_config_dcb_num_tcs,
2421 (void *)&cmd_config_dcb_pfc,
2422 (void *)&cmd_config_dcb_pfc_en,
2427 /* *** configure number of packets per burst *** */
2428 struct cmd_config_burst {
2429 cmdline_fixed_string_t port;
2430 cmdline_fixed_string_t keyword;
2431 cmdline_fixed_string_t all;
2432 cmdline_fixed_string_t name;
2437 cmd_config_burst_parsed(void *parsed_result,
2438 __attribute__((unused)) struct cmdline *cl,
2439 __attribute__((unused)) void *data)
2441 struct cmd_config_burst *res = parsed_result;
2443 if (!all_ports_stopped()) {
2444 printf("Please stop all ports first\n");
2448 if (!strcmp(res->name, "burst")) {
2449 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2450 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2453 nb_pkt_per_burst = res->value;
2455 printf("Unknown parameter\n");
2461 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2464 cmdline_parse_token_string_t cmd_config_burst_port =
2465 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2466 cmdline_parse_token_string_t cmd_config_burst_keyword =
2467 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2468 cmdline_parse_token_string_t cmd_config_burst_all =
2469 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2470 cmdline_parse_token_string_t cmd_config_burst_name =
2471 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2472 cmdline_parse_token_num_t cmd_config_burst_value =
2473 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2475 cmdline_parse_inst_t cmd_config_burst = {
2476 .f = cmd_config_burst_parsed,
2478 .help_str = "port config all burst <value>",
2480 (void *)&cmd_config_burst_port,
2481 (void *)&cmd_config_burst_keyword,
2482 (void *)&cmd_config_burst_all,
2483 (void *)&cmd_config_burst_name,
2484 (void *)&cmd_config_burst_value,
2489 /* *** configure rx/tx queues *** */
2490 struct cmd_config_thresh {
2491 cmdline_fixed_string_t port;
2492 cmdline_fixed_string_t keyword;
2493 cmdline_fixed_string_t all;
2494 cmdline_fixed_string_t name;
2499 cmd_config_thresh_parsed(void *parsed_result,
2500 __attribute__((unused)) struct cmdline *cl,
2501 __attribute__((unused)) void *data)
2503 struct cmd_config_thresh *res = parsed_result;
2505 if (!all_ports_stopped()) {
2506 printf("Please stop all ports first\n");
2510 if (!strcmp(res->name, "txpt"))
2511 tx_pthresh = res->value;
2512 else if(!strcmp(res->name, "txht"))
2513 tx_hthresh = res->value;
2514 else if(!strcmp(res->name, "txwt"))
2515 tx_wthresh = res->value;
2516 else if(!strcmp(res->name, "rxpt"))
2517 rx_pthresh = res->value;
2518 else if(!strcmp(res->name, "rxht"))
2519 rx_hthresh = res->value;
2520 else if(!strcmp(res->name, "rxwt"))
2521 rx_wthresh = res->value;
2523 printf("Unknown parameter\n");
2529 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2532 cmdline_parse_token_string_t cmd_config_thresh_port =
2533 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2534 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2535 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2536 cmdline_parse_token_string_t cmd_config_thresh_all =
2537 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2538 cmdline_parse_token_string_t cmd_config_thresh_name =
2539 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2540 "txpt#txht#txwt#rxpt#rxht#rxwt");
2541 cmdline_parse_token_num_t cmd_config_thresh_value =
2542 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2544 cmdline_parse_inst_t cmd_config_thresh = {
2545 .f = cmd_config_thresh_parsed,
2547 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2549 (void *)&cmd_config_thresh_port,
2550 (void *)&cmd_config_thresh_keyword,
2551 (void *)&cmd_config_thresh_all,
2552 (void *)&cmd_config_thresh_name,
2553 (void *)&cmd_config_thresh_value,
2558 /* *** configure free/rs threshold *** */
2559 struct cmd_config_threshold {
2560 cmdline_fixed_string_t port;
2561 cmdline_fixed_string_t keyword;
2562 cmdline_fixed_string_t all;
2563 cmdline_fixed_string_t name;
2568 cmd_config_threshold_parsed(void *parsed_result,
2569 __attribute__((unused)) struct cmdline *cl,
2570 __attribute__((unused)) void *data)
2572 struct cmd_config_threshold *res = parsed_result;
2574 if (!all_ports_stopped()) {
2575 printf("Please stop all ports first\n");
2579 if (!strcmp(res->name, "txfreet"))
2580 tx_free_thresh = res->value;
2581 else if (!strcmp(res->name, "txrst"))
2582 tx_rs_thresh = res->value;
2583 else if (!strcmp(res->name, "rxfreet"))
2584 rx_free_thresh = res->value;
2586 printf("Unknown parameter\n");
2592 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2595 cmdline_parse_token_string_t cmd_config_threshold_port =
2596 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2597 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2598 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2600 cmdline_parse_token_string_t cmd_config_threshold_all =
2601 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2602 cmdline_parse_token_string_t cmd_config_threshold_name =
2603 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2604 "txfreet#txrst#rxfreet");
2605 cmdline_parse_token_num_t cmd_config_threshold_value =
2606 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2608 cmdline_parse_inst_t cmd_config_threshold = {
2609 .f = cmd_config_threshold_parsed,
2611 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2613 (void *)&cmd_config_threshold_port,
2614 (void *)&cmd_config_threshold_keyword,
2615 (void *)&cmd_config_threshold_all,
2616 (void *)&cmd_config_threshold_name,
2617 (void *)&cmd_config_threshold_value,
2623 struct cmd_stop_result {
2624 cmdline_fixed_string_t stop;
2627 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2628 __attribute__((unused)) struct cmdline *cl,
2629 __attribute__((unused)) void *data)
2631 stop_packet_forwarding();
2634 cmdline_parse_token_string_t cmd_stop_stop =
2635 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2637 cmdline_parse_inst_t cmd_stop = {
2638 .f = cmd_stop_parsed,
2640 .help_str = "stop: Stop packet forwarding",
2642 (void *)&cmd_stop_stop,
2647 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2650 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2651 unsigned int *parsed_items, int check_unique_values)
2653 unsigned int nb_item;
2661 * First parse all items in the list and store their value.
2666 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2668 if ((c >= '0') && (c <= '9')) {
2669 value = (unsigned int) (value * 10 + (c - '0'));
2674 printf("character %c is not a decimal digit\n", c);
2678 printf("No valid value before comma\n");
2681 if (nb_item < max_items) {
2682 parsed_items[nb_item] = value;
2688 if (nb_item >= max_items) {
2689 printf("Number of %s = %u > %u (maximum items)\n",
2690 item_name, nb_item + 1, max_items);
2693 parsed_items[nb_item++] = value;
2694 if (! check_unique_values)
2698 * Then, check that all values in the list are differents.
2699 * No optimization here...
2701 for (i = 0; i < nb_item; i++) {
2702 for (j = i + 1; j < nb_item; j++) {
2703 if (parsed_items[j] == parsed_items[i]) {
2704 printf("duplicated %s %u at index %u and %u\n",
2705 item_name, parsed_items[i], i, j);
2713 struct cmd_set_list_result {
2714 cmdline_fixed_string_t cmd_keyword;
2715 cmdline_fixed_string_t list_name;
2716 cmdline_fixed_string_t list_of_items;
2719 static void cmd_set_list_parsed(void *parsed_result,
2720 __attribute__((unused)) struct cmdline *cl,
2721 __attribute__((unused)) void *data)
2723 struct cmd_set_list_result *res;
2725 unsigned int lcorelist[RTE_MAX_LCORE];
2726 unsigned int portlist[RTE_MAX_ETHPORTS];
2728 unsigned int nb_item;
2730 if (test_done == 0) {
2731 printf("Please stop forwarding first\n");
2735 res = parsed_result;
2736 if (!strcmp(res->list_name, "corelist")) {
2737 nb_item = parse_item_list(res->list_of_items, "core",
2739 parsed_items.lcorelist, 1);
2741 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2746 if (!strcmp(res->list_name, "portlist")) {
2747 nb_item = parse_item_list(res->list_of_items, "port",
2749 parsed_items.portlist, 1);
2751 set_fwd_ports_list(parsed_items.portlist, nb_item);
2757 cmdline_parse_token_string_t cmd_set_list_keyword =
2758 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2760 cmdline_parse_token_string_t cmd_set_list_name =
2761 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2762 "corelist#portlist");
2763 cmdline_parse_token_string_t cmd_set_list_of_items =
2764 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2767 cmdline_parse_inst_t cmd_set_fwd_list = {
2768 .f = cmd_set_list_parsed,
2770 .help_str = "set corelist|portlist <list0[,list1]*>",
2772 (void *)&cmd_set_list_keyword,
2773 (void *)&cmd_set_list_name,
2774 (void *)&cmd_set_list_of_items,
2779 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2781 struct cmd_setmask_result {
2782 cmdline_fixed_string_t set;
2783 cmdline_fixed_string_t mask;
2787 static void cmd_set_mask_parsed(void *parsed_result,
2788 __attribute__((unused)) struct cmdline *cl,
2789 __attribute__((unused)) void *data)
2791 struct cmd_setmask_result *res = parsed_result;
2793 if (test_done == 0) {
2794 printf("Please stop forwarding first\n");
2797 if (!strcmp(res->mask, "coremask")) {
2798 set_fwd_lcores_mask(res->hexavalue);
2800 } else if (!strcmp(res->mask, "portmask")) {
2801 set_fwd_ports_mask(res->hexavalue);
2806 cmdline_parse_token_string_t cmd_setmask_set =
2807 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2808 cmdline_parse_token_string_t cmd_setmask_mask =
2809 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2810 "coremask#portmask");
2811 cmdline_parse_token_num_t cmd_setmask_value =
2812 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2814 cmdline_parse_inst_t cmd_set_fwd_mask = {
2815 .f = cmd_set_mask_parsed,
2817 .help_str = "set coremask|portmask <hexadecimal value>",
2819 (void *)&cmd_setmask_set,
2820 (void *)&cmd_setmask_mask,
2821 (void *)&cmd_setmask_value,
2827 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2829 struct cmd_set_result {
2830 cmdline_fixed_string_t set;
2831 cmdline_fixed_string_t what;
2835 static void cmd_set_parsed(void *parsed_result,
2836 __attribute__((unused)) struct cmdline *cl,
2837 __attribute__((unused)) void *data)
2839 struct cmd_set_result *res = parsed_result;
2840 if (!strcmp(res->what, "nbport")) {
2841 set_fwd_ports_number(res->value);
2843 } else if (!strcmp(res->what, "nbcore")) {
2844 set_fwd_lcores_number(res->value);
2846 } else if (!strcmp(res->what, "burst"))
2847 set_nb_pkt_per_burst(res->value);
2848 else if (!strcmp(res->what, "verbose"))
2849 set_verbose_level(res->value);
2852 cmdline_parse_token_string_t cmd_set_set =
2853 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2854 cmdline_parse_token_string_t cmd_set_what =
2855 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2856 "nbport#nbcore#burst#verbose");
2857 cmdline_parse_token_num_t cmd_set_value =
2858 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2860 cmdline_parse_inst_t cmd_set_numbers = {
2861 .f = cmd_set_parsed,
2863 .help_str = "set nbport|nbcore|burst|verbose <value>",
2865 (void *)&cmd_set_set,
2866 (void *)&cmd_set_what,
2867 (void *)&cmd_set_value,
2872 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2874 struct cmd_set_txpkts_result {
2875 cmdline_fixed_string_t cmd_keyword;
2876 cmdline_fixed_string_t txpkts;
2877 cmdline_fixed_string_t seg_lengths;
2881 cmd_set_txpkts_parsed(void *parsed_result,
2882 __attribute__((unused)) struct cmdline *cl,
2883 __attribute__((unused)) void *data)
2885 struct cmd_set_txpkts_result *res;
2886 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2887 unsigned int nb_segs;
2889 res = parsed_result;
2890 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2891 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2893 set_tx_pkt_segments(seg_lengths, nb_segs);
2896 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2897 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2898 cmd_keyword, "set");
2899 cmdline_parse_token_string_t cmd_set_txpkts_name =
2900 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2902 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2903 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2906 cmdline_parse_inst_t cmd_set_txpkts = {
2907 .f = cmd_set_txpkts_parsed,
2909 .help_str = "set txpkts <len0[,len1]*>",
2911 (void *)&cmd_set_txpkts_keyword,
2912 (void *)&cmd_set_txpkts_name,
2913 (void *)&cmd_set_txpkts_lengths,
2918 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2920 struct cmd_set_txsplit_result {
2921 cmdline_fixed_string_t cmd_keyword;
2922 cmdline_fixed_string_t txsplit;
2923 cmdline_fixed_string_t mode;
2927 cmd_set_txsplit_parsed(void *parsed_result,
2928 __attribute__((unused)) struct cmdline *cl,
2929 __attribute__((unused)) void *data)
2931 struct cmd_set_txsplit_result *res;
2933 res = parsed_result;
2934 set_tx_pkt_split(res->mode);
2937 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2938 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2939 cmd_keyword, "set");
2940 cmdline_parse_token_string_t cmd_set_txsplit_name =
2941 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2942 txsplit, "txsplit");
2943 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2944 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2947 cmdline_parse_inst_t cmd_set_txsplit = {
2948 .f = cmd_set_txsplit_parsed,
2950 .help_str = "set txsplit on|off|rand",
2952 (void *)&cmd_set_txsplit_keyword,
2953 (void *)&cmd_set_txsplit_name,
2954 (void *)&cmd_set_txsplit_mode,
2959 /* *** CONFIG TX QUEUE FLAGS *** */
2961 struct cmd_config_txqflags_result {
2962 cmdline_fixed_string_t port;
2963 cmdline_fixed_string_t config;
2964 cmdline_fixed_string_t all;
2965 cmdline_fixed_string_t what;
2969 static void cmd_config_txqflags_parsed(void *parsed_result,
2970 __attribute__((unused)) struct cmdline *cl,
2971 __attribute__((unused)) void *data)
2973 struct cmd_config_txqflags_result *res = parsed_result;
2975 if (!all_ports_stopped()) {
2976 printf("Please stop all ports first\n");
2980 if (strcmp(res->what, "txqflags")) {
2981 printf("Unknown parameter\n");
2985 if (res->hexvalue >= 0) {
2986 txq_flags = res->hexvalue;
2988 printf("txqflags must be >= 0\n");
2994 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2997 cmdline_parse_token_string_t cmd_config_txqflags_port =
2998 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
3000 cmdline_parse_token_string_t cmd_config_txqflags_config =
3001 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
3003 cmdline_parse_token_string_t cmd_config_txqflags_all =
3004 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
3006 cmdline_parse_token_string_t cmd_config_txqflags_what =
3007 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
3009 cmdline_parse_token_num_t cmd_config_txqflags_value =
3010 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
3013 cmdline_parse_inst_t cmd_config_txqflags = {
3014 .f = cmd_config_txqflags_parsed,
3016 .help_str = "port config all txqflags <value>",
3018 (void *)&cmd_config_txqflags_port,
3019 (void *)&cmd_config_txqflags_config,
3020 (void *)&cmd_config_txqflags_all,
3021 (void *)&cmd_config_txqflags_what,
3022 (void *)&cmd_config_txqflags_value,
3027 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3028 struct cmd_rx_vlan_filter_all_result {
3029 cmdline_fixed_string_t rx_vlan;
3030 cmdline_fixed_string_t what;
3031 cmdline_fixed_string_t all;
3036 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3037 __attribute__((unused)) struct cmdline *cl,
3038 __attribute__((unused)) void *data)
3040 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3042 if (!strcmp(res->what, "add"))
3043 rx_vlan_all_filter_set(res->port_id, 1);
3045 rx_vlan_all_filter_set(res->port_id, 0);
3048 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3049 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3050 rx_vlan, "rx_vlan");
3051 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3052 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3054 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3055 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3057 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3058 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3061 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3062 .f = cmd_rx_vlan_filter_all_parsed,
3064 .help_str = "rx_vlan add|rm all <port_id>: "
3065 "Add/Remove all identifiers to/from the set of VLAN "
3066 "identifiers filtered by a port",
3068 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3069 (void *)&cmd_rx_vlan_filter_all_what,
3070 (void *)&cmd_rx_vlan_filter_all_all,
3071 (void *)&cmd_rx_vlan_filter_all_portid,
3076 /* *** VLAN OFFLOAD SET ON A PORT *** */
3077 struct cmd_vlan_offload_result {
3078 cmdline_fixed_string_t vlan;
3079 cmdline_fixed_string_t set;
3080 cmdline_fixed_string_t vlan_type;
3081 cmdline_fixed_string_t what;
3082 cmdline_fixed_string_t on;
3083 cmdline_fixed_string_t port_id;
3087 cmd_vlan_offload_parsed(void *parsed_result,
3088 __attribute__((unused)) struct cmdline *cl,
3089 __attribute__((unused)) void *data)
3092 struct cmd_vlan_offload_result *res = parsed_result;
3095 portid_t port_id = 0;
3099 len = strnlen(str, STR_TOKEN_SIZE);
3101 /* Get port_id first */
3109 tmp = strtoul(str, NULL, 0);
3110 /* If port_id greater that what portid_t can represent, return */
3111 if(tmp >= RTE_MAX_ETHPORTS)
3113 port_id = (portid_t)tmp;
3115 if (!strcmp(res->on, "on"))
3120 if (!strcmp(res->what, "strip"))
3121 rx_vlan_strip_set(port_id, on);
3122 else if(!strcmp(res->what, "stripq")){
3123 uint16_t queue_id = 0;
3125 /* No queue_id, return */
3127 printf("must specify (port,queue_id)\n");
3130 tmp = strtoul(str + i + 1, NULL, 0);
3131 /* If queue_id greater that what 16-bits can represent, return */
3135 queue_id = (uint16_t)tmp;
3136 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3138 else if (!strcmp(res->what, "filter"))
3139 rx_vlan_filter_set(port_id, on);
3141 vlan_extend_set(port_id, on);
3146 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3147 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3149 cmdline_parse_token_string_t cmd_vlan_offload_set =
3150 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3152 cmdline_parse_token_string_t cmd_vlan_offload_what =
3153 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3154 what, "strip#filter#qinq#stripq");
3155 cmdline_parse_token_string_t cmd_vlan_offload_on =
3156 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3158 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3159 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3162 cmdline_parse_inst_t cmd_vlan_offload = {
3163 .f = cmd_vlan_offload_parsed,
3165 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3166 "<port_id[,queue_id]>: "
3167 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3169 (void *)&cmd_vlan_offload_vlan,
3170 (void *)&cmd_vlan_offload_set,
3171 (void *)&cmd_vlan_offload_what,
3172 (void *)&cmd_vlan_offload_on,
3173 (void *)&cmd_vlan_offload_portid,
3178 /* *** VLAN TPID SET ON A PORT *** */
3179 struct cmd_vlan_tpid_result {
3180 cmdline_fixed_string_t vlan;
3181 cmdline_fixed_string_t set;
3182 cmdline_fixed_string_t vlan_type;
3183 cmdline_fixed_string_t what;
3189 cmd_vlan_tpid_parsed(void *parsed_result,
3190 __attribute__((unused)) struct cmdline *cl,
3191 __attribute__((unused)) void *data)
3193 struct cmd_vlan_tpid_result *res = parsed_result;
3194 enum rte_vlan_type vlan_type;
3196 if (!strcmp(res->vlan_type, "inner"))
3197 vlan_type = ETH_VLAN_TYPE_INNER;
3198 else if (!strcmp(res->vlan_type, "outer"))
3199 vlan_type = ETH_VLAN_TYPE_OUTER;
3201 printf("Unknown vlan type\n");
3204 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3207 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3208 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3210 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3211 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3213 cmdline_parse_token_string_t cmd_vlan_type =
3214 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3215 vlan_type, "inner#outer");
3216 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3217 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3219 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3220 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3222 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3223 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3226 cmdline_parse_inst_t cmd_vlan_tpid = {
3227 .f = cmd_vlan_tpid_parsed,
3229 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3230 "Set the VLAN Ether type",
3232 (void *)&cmd_vlan_tpid_vlan,
3233 (void *)&cmd_vlan_tpid_set,
3234 (void *)&cmd_vlan_type,
3235 (void *)&cmd_vlan_tpid_what,
3236 (void *)&cmd_vlan_tpid_tpid,
3237 (void *)&cmd_vlan_tpid_portid,
3242 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3243 struct cmd_rx_vlan_filter_result {
3244 cmdline_fixed_string_t rx_vlan;
3245 cmdline_fixed_string_t what;
3251 cmd_rx_vlan_filter_parsed(void *parsed_result,
3252 __attribute__((unused)) struct cmdline *cl,
3253 __attribute__((unused)) void *data)
3255 struct cmd_rx_vlan_filter_result *res = parsed_result;
3257 if (!strcmp(res->what, "add"))
3258 rx_vft_set(res->port_id, res->vlan_id, 1);
3260 rx_vft_set(res->port_id, res->vlan_id, 0);
3263 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3264 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3265 rx_vlan, "rx_vlan");
3266 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3267 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3269 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3270 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3272 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3273 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3276 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3277 .f = cmd_rx_vlan_filter_parsed,
3279 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3280 "Add/Remove a VLAN identifier to/from the set of VLAN "
3281 "identifiers filtered by a port",
3283 (void *)&cmd_rx_vlan_filter_rx_vlan,
3284 (void *)&cmd_rx_vlan_filter_what,
3285 (void *)&cmd_rx_vlan_filter_vlanid,
3286 (void *)&cmd_rx_vlan_filter_portid,
3291 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3292 struct cmd_tx_vlan_set_result {
3293 cmdline_fixed_string_t tx_vlan;
3294 cmdline_fixed_string_t set;
3300 cmd_tx_vlan_set_parsed(void *parsed_result,
3301 __attribute__((unused)) struct cmdline *cl,
3302 __attribute__((unused)) void *data)
3304 struct cmd_tx_vlan_set_result *res = parsed_result;
3306 tx_vlan_set(res->port_id, res->vlan_id);
3309 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3310 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3311 tx_vlan, "tx_vlan");
3312 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3313 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3315 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3316 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3318 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3319 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3322 cmdline_parse_inst_t cmd_tx_vlan_set = {
3323 .f = cmd_tx_vlan_set_parsed,
3325 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3326 "Enable hardware insertion of a single VLAN header "
3327 "with a given TAG Identifier in packets sent on a port",
3329 (void *)&cmd_tx_vlan_set_tx_vlan,
3330 (void *)&cmd_tx_vlan_set_set,
3331 (void *)&cmd_tx_vlan_set_portid,
3332 (void *)&cmd_tx_vlan_set_vlanid,
3337 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3338 struct cmd_tx_vlan_set_qinq_result {
3339 cmdline_fixed_string_t tx_vlan;
3340 cmdline_fixed_string_t set;
3343 uint16_t vlan_id_outer;
3347 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3348 __attribute__((unused)) struct cmdline *cl,
3349 __attribute__((unused)) void *data)
3351 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3353 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3356 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3357 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3358 tx_vlan, "tx_vlan");
3359 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3360 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3362 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3363 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3365 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3366 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3368 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3369 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3370 vlan_id_outer, UINT16);
3372 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3373 .f = cmd_tx_vlan_set_qinq_parsed,
3375 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3376 "Enable hardware insertion of double VLAN header "
3377 "with given TAG Identifiers in packets sent on a port",
3379 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3380 (void *)&cmd_tx_vlan_set_qinq_set,
3381 (void *)&cmd_tx_vlan_set_qinq_portid,
3382 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3383 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3388 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3389 struct cmd_tx_vlan_set_pvid_result {
3390 cmdline_fixed_string_t tx_vlan;
3391 cmdline_fixed_string_t set;
3392 cmdline_fixed_string_t pvid;
3395 cmdline_fixed_string_t mode;
3399 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3400 __attribute__((unused)) struct cmdline *cl,
3401 __attribute__((unused)) void *data)
3403 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3405 if (strcmp(res->mode, "on") == 0)
3406 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3408 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3411 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3412 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3413 tx_vlan, "tx_vlan");
3414 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3415 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3417 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3418 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3420 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3421 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3423 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3424 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3426 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3427 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3430 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3431 .f = cmd_tx_vlan_set_pvid_parsed,
3433 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3435 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3436 (void *)&cmd_tx_vlan_set_pvid_set,
3437 (void *)&cmd_tx_vlan_set_pvid_pvid,
3438 (void *)&cmd_tx_vlan_set_pvid_port_id,
3439 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3440 (void *)&cmd_tx_vlan_set_pvid_mode,
3445 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3446 struct cmd_tx_vlan_reset_result {
3447 cmdline_fixed_string_t tx_vlan;
3448 cmdline_fixed_string_t reset;
3453 cmd_tx_vlan_reset_parsed(void *parsed_result,
3454 __attribute__((unused)) struct cmdline *cl,
3455 __attribute__((unused)) void *data)
3457 struct cmd_tx_vlan_reset_result *res = parsed_result;
3459 tx_vlan_reset(res->port_id);
3462 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3463 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3464 tx_vlan, "tx_vlan");
3465 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3466 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3468 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3469 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3472 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3473 .f = cmd_tx_vlan_reset_parsed,
3475 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3476 "VLAN header in packets sent on a port",
3478 (void *)&cmd_tx_vlan_reset_tx_vlan,
3479 (void *)&cmd_tx_vlan_reset_reset,
3480 (void *)&cmd_tx_vlan_reset_portid,
3486 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3487 struct cmd_csum_result {
3488 cmdline_fixed_string_t csum;
3489 cmdline_fixed_string_t mode;
3490 cmdline_fixed_string_t proto;
3491 cmdline_fixed_string_t hwsw;
3496 csum_show(int port_id)
3498 struct rte_eth_dev_info dev_info;
3501 ol_flags = ports[port_id].tx_ol_flags;
3502 printf("Parse tunnel is %s\n",
3503 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3504 printf("IP checksum offload is %s\n",
3505 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3506 printf("UDP checksum offload is %s\n",
3507 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3508 printf("TCP checksum offload is %s\n",
3509 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3510 printf("SCTP checksum offload is %s\n",
3511 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3512 printf("Outer-Ip checksum offload is %s\n",
3513 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3515 /* display warnings if configuration is not supported by the NIC */
3516 rte_eth_dev_info_get(port_id, &dev_info);
3517 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3518 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3519 printf("Warning: hardware IP checksum enabled but not "
3520 "supported by port %d\n", port_id);
3522 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3523 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3524 printf("Warning: hardware UDP checksum enabled but not "
3525 "supported by port %d\n", port_id);
3527 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3528 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3529 printf("Warning: hardware TCP checksum enabled but not "
3530 "supported by port %d\n", port_id);
3532 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3533 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3534 printf("Warning: hardware SCTP checksum enabled but not "
3535 "supported by port %d\n", port_id);
3537 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3538 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3539 printf("Warning: hardware outer IP checksum enabled but not "
3540 "supported by port %d\n", port_id);
3545 cmd_csum_parsed(void *parsed_result,
3546 __attribute__((unused)) struct cmdline *cl,
3547 __attribute__((unused)) void *data)
3549 struct cmd_csum_result *res = parsed_result;
3553 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3554 printf("invalid port %d\n", res->port_id);
3558 if (!strcmp(res->mode, "set")) {
3560 if (!strcmp(res->hwsw, "hw"))
3563 if (!strcmp(res->proto, "ip")) {
3564 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3565 } else if (!strcmp(res->proto, "udp")) {
3566 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3567 } else if (!strcmp(res->proto, "tcp")) {
3568 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3569 } else if (!strcmp(res->proto, "sctp")) {
3570 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3571 } else if (!strcmp(res->proto, "outer-ip")) {
3572 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3576 ports[res->port_id].tx_ol_flags |= mask;
3578 ports[res->port_id].tx_ol_flags &= (~mask);
3580 csum_show(res->port_id);
3583 cmdline_parse_token_string_t cmd_csum_csum =
3584 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3586 cmdline_parse_token_string_t cmd_csum_mode =
3587 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3589 cmdline_parse_token_string_t cmd_csum_proto =
3590 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3591 proto, "ip#tcp#udp#sctp#outer-ip");
3592 cmdline_parse_token_string_t cmd_csum_hwsw =
3593 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3595 cmdline_parse_token_num_t cmd_csum_portid =
3596 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3599 cmdline_parse_inst_t cmd_csum_set = {
3600 .f = cmd_csum_parsed,
3602 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3603 "Enable/Disable hardware calculation of L3/L4 checksum when "
3604 "using csum forward engine",
3606 (void *)&cmd_csum_csum,
3607 (void *)&cmd_csum_mode,
3608 (void *)&cmd_csum_proto,
3609 (void *)&cmd_csum_hwsw,
3610 (void *)&cmd_csum_portid,
3615 cmdline_parse_token_string_t cmd_csum_mode_show =
3616 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3619 cmdline_parse_inst_t cmd_csum_show = {
3620 .f = cmd_csum_parsed,
3622 .help_str = "csum show <port_id>: Show checksum offload configuration",
3624 (void *)&cmd_csum_csum,
3625 (void *)&cmd_csum_mode_show,
3626 (void *)&cmd_csum_portid,
3631 /* Enable/disable tunnel parsing */
3632 struct cmd_csum_tunnel_result {
3633 cmdline_fixed_string_t csum;
3634 cmdline_fixed_string_t parse;
3635 cmdline_fixed_string_t onoff;
3640 cmd_csum_tunnel_parsed(void *parsed_result,
3641 __attribute__((unused)) struct cmdline *cl,
3642 __attribute__((unused)) void *data)
3644 struct cmd_csum_tunnel_result *res = parsed_result;
3646 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3649 if (!strcmp(res->onoff, "on"))
3650 ports[res->port_id].tx_ol_flags |=
3651 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3653 ports[res->port_id].tx_ol_flags &=
3654 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3656 csum_show(res->port_id);
3659 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3660 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3662 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3663 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3664 parse, "parse_tunnel");
3665 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3666 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3668 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3669 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3672 cmdline_parse_inst_t cmd_csum_tunnel = {
3673 .f = cmd_csum_tunnel_parsed,
3675 .help_str = "csum parse_tunnel on|off <port_id>: "
3676 "Enable/Disable parsing of tunnels for csum engine",
3678 (void *)&cmd_csum_tunnel_csum,
3679 (void *)&cmd_csum_tunnel_parse,
3680 (void *)&cmd_csum_tunnel_onoff,
3681 (void *)&cmd_csum_tunnel_portid,
3686 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3687 struct cmd_tso_set_result {
3688 cmdline_fixed_string_t tso;
3689 cmdline_fixed_string_t mode;
3695 cmd_tso_set_parsed(void *parsed_result,
3696 __attribute__((unused)) struct cmdline *cl,
3697 __attribute__((unused)) void *data)
3699 struct cmd_tso_set_result *res = parsed_result;
3700 struct rte_eth_dev_info dev_info;
3702 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3705 if (!strcmp(res->mode, "set"))
3706 ports[res->port_id].tso_segsz = res->tso_segsz;
3708 if (ports[res->port_id].tso_segsz == 0)
3709 printf("TSO for non-tunneled packets is disabled\n");
3711 printf("TSO segment size for non-tunneled packets is %d\n",
3712 ports[res->port_id].tso_segsz);
3714 /* display warnings if configuration is not supported by the NIC */
3715 rte_eth_dev_info_get(res->port_id, &dev_info);
3716 if ((ports[res->port_id].tso_segsz != 0) &&
3717 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3718 printf("Warning: TSO enabled but not "
3719 "supported by port %d\n", res->port_id);
3723 cmdline_parse_token_string_t cmd_tso_set_tso =
3724 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3726 cmdline_parse_token_string_t cmd_tso_set_mode =
3727 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3729 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3730 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3732 cmdline_parse_token_num_t cmd_tso_set_portid =
3733 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3736 cmdline_parse_inst_t cmd_tso_set = {
3737 .f = cmd_tso_set_parsed,
3739 .help_str = "tso set <tso_segsz> <port_id>: "
3740 "Set TSO segment size of non-tunneled packets for csum engine "
3743 (void *)&cmd_tso_set_tso,
3744 (void *)&cmd_tso_set_mode,
3745 (void *)&cmd_tso_set_tso_segsz,
3746 (void *)&cmd_tso_set_portid,
3751 cmdline_parse_token_string_t cmd_tso_show_mode =
3752 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3756 cmdline_parse_inst_t cmd_tso_show = {
3757 .f = cmd_tso_set_parsed,
3759 .help_str = "tso show <port_id>: "
3760 "Show TSO segment size of non-tunneled packets for csum engine",
3762 (void *)&cmd_tso_set_tso,
3763 (void *)&cmd_tso_show_mode,
3764 (void *)&cmd_tso_set_portid,
3769 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3770 struct cmd_tunnel_tso_set_result {
3771 cmdline_fixed_string_t tso;
3772 cmdline_fixed_string_t mode;
3778 check_tunnel_tso_nic_support(uint8_t port_id)
3780 struct rte_eth_dev_info dev_info;
3782 rte_eth_dev_info_get(port_id, &dev_info);
3783 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3784 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3785 "supported by port %d\n", port_id);
3786 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3787 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3788 "supported by port %d\n", port_id);
3789 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3790 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3791 "supported by port %d\n", port_id);
3792 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3793 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3794 "supported by port %d\n", port_id);
3798 cmd_tunnel_tso_set_parsed(void *parsed_result,
3799 __attribute__((unused)) struct cmdline *cl,
3800 __attribute__((unused)) void *data)
3802 struct cmd_tunnel_tso_set_result *res = parsed_result;
3804 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3807 if (!strcmp(res->mode, "set"))
3808 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3810 if (ports[res->port_id].tunnel_tso_segsz == 0)
3811 printf("TSO for tunneled packets is disabled\n");
3813 printf("TSO segment size for tunneled packets is %d\n",
3814 ports[res->port_id].tunnel_tso_segsz);
3816 /* Below conditions are needed to make it work:
3817 * (1) tunnel TSO is supported by the NIC;
3818 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3820 * (3) for tunneled pkts with outer L3 of IPv4,
3821 * "csum set outer-ip" must be set to hw, because after tso,
3822 * total_len of outer IP header is changed, and the checksum
3823 * of outer IP header calculated by sw should be wrong; that
3824 * is not necessary for IPv6 tunneled pkts because there's no
3825 * checksum in IP header anymore.
3827 check_tunnel_tso_nic_support(res->port_id);
3829 if (!(ports[res->port_id].tx_ol_flags &
3830 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3831 printf("Warning: csum parse_tunnel must be set "
3832 "so that tunneled packets are recognized\n");
3833 if (!(ports[res->port_id].tx_ol_flags &
3834 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3835 printf("Warning: csum set outer-ip must be set to hw "
3836 "if outer L3 is IPv4; not necessary for IPv6\n");
3840 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3841 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3843 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3844 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3846 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3847 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3849 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3850 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3853 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3854 .f = cmd_tunnel_tso_set_parsed,
3856 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3857 "Set TSO segment size of tunneled packets for csum engine "
3860 (void *)&cmd_tunnel_tso_set_tso,
3861 (void *)&cmd_tunnel_tso_set_mode,
3862 (void *)&cmd_tunnel_tso_set_tso_segsz,
3863 (void *)&cmd_tunnel_tso_set_portid,
3868 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3869 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3873 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3874 .f = cmd_tunnel_tso_set_parsed,
3876 .help_str = "tunnel_tso show <port_id> "
3877 "Show TSO segment size of tunneled packets for csum engine",
3879 (void *)&cmd_tunnel_tso_set_tso,
3880 (void *)&cmd_tunnel_tso_show_mode,
3881 (void *)&cmd_tunnel_tso_set_portid,
3886 /* *** SET GRO FOR A PORT *** */
3887 struct cmd_gro_enable_result {
3888 cmdline_fixed_string_t cmd_set;
3889 cmdline_fixed_string_t cmd_port;
3890 cmdline_fixed_string_t cmd_keyword;
3891 cmdline_fixed_string_t cmd_onoff;
3896 cmd_gro_enable_parsed(void *parsed_result,
3897 __attribute__((unused)) struct cmdline *cl,
3898 __attribute__((unused)) void *data)
3900 struct cmd_gro_enable_result *res;
3902 res = parsed_result;
3903 if (!strcmp(res->cmd_keyword, "gro"))
3904 setup_gro(res->cmd_onoff, res->cmd_pid);
3907 cmdline_parse_token_string_t cmd_gro_enable_set =
3908 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3910 cmdline_parse_token_string_t cmd_gro_enable_port =
3911 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3912 cmd_keyword, "port");
3913 cmdline_parse_token_num_t cmd_gro_enable_pid =
3914 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
3916 cmdline_parse_token_string_t cmd_gro_enable_keyword =
3917 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3918 cmd_keyword, "gro");
3919 cmdline_parse_token_string_t cmd_gro_enable_onoff =
3920 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3921 cmd_onoff, "on#off");
3923 cmdline_parse_inst_t cmd_gro_enable = {
3924 .f = cmd_gro_enable_parsed,
3926 .help_str = "set port <port_id> gro on|off",
3928 (void *)&cmd_gro_enable_set,
3929 (void *)&cmd_gro_enable_port,
3930 (void *)&cmd_gro_enable_pid,
3931 (void *)&cmd_gro_enable_keyword,
3932 (void *)&cmd_gro_enable_onoff,
3937 /* *** DISPLAY GRO CONFIGURATION *** */
3938 struct cmd_gro_show_result {
3939 cmdline_fixed_string_t cmd_show;
3940 cmdline_fixed_string_t cmd_port;
3941 cmdline_fixed_string_t cmd_keyword;
3946 cmd_gro_show_parsed(void *parsed_result,
3947 __attribute__((unused)) struct cmdline *cl,
3948 __attribute__((unused)) void *data)
3950 struct cmd_gro_show_result *res;
3952 res = parsed_result;
3953 if (!strcmp(res->cmd_keyword, "gro"))
3954 show_gro(res->cmd_pid);
3957 cmdline_parse_token_string_t cmd_gro_show_show =
3958 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
3960 cmdline_parse_token_string_t cmd_gro_show_port =
3961 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
3963 cmdline_parse_token_num_t cmd_gro_show_pid =
3964 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
3966 cmdline_parse_token_string_t cmd_gro_show_keyword =
3967 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
3968 cmd_keyword, "gro");
3970 cmdline_parse_inst_t cmd_gro_show = {
3971 .f = cmd_gro_show_parsed,
3973 .help_str = "show port <port_id> gro",
3975 (void *)&cmd_gro_show_show,
3976 (void *)&cmd_gro_show_port,
3977 (void *)&cmd_gro_show_pid,
3978 (void *)&cmd_gro_show_keyword,
3983 /* *** SET FLUSH CYCLES FOR GRO *** */
3984 struct cmd_gro_flush_result {
3985 cmdline_fixed_string_t cmd_set;
3986 cmdline_fixed_string_t cmd_keyword;
3987 cmdline_fixed_string_t cmd_flush;
3992 cmd_gro_flush_parsed(void *parsed_result,
3993 __attribute__((unused)) struct cmdline *cl,
3994 __attribute__((unused)) void *data)
3996 struct cmd_gro_flush_result *res;
3998 res = parsed_result;
3999 if ((!strcmp(res->cmd_keyword, "gro")) &&
4000 (!strcmp(res->cmd_flush, "flush")))
4001 setup_gro_flush_cycles(res->cmd_cycles);
4004 cmdline_parse_token_string_t cmd_gro_flush_set =
4005 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4007 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4008 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4009 cmd_keyword, "gro");
4010 cmdline_parse_token_string_t cmd_gro_flush_flush =
4011 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4012 cmd_flush, "flush");
4013 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4014 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4017 cmdline_parse_inst_t cmd_gro_flush = {
4018 .f = cmd_gro_flush_parsed,
4020 .help_str = "set gro flush <cycles>",
4022 (void *)&cmd_gro_flush_set,
4023 (void *)&cmd_gro_flush_keyword,
4024 (void *)&cmd_gro_flush_flush,
4025 (void *)&cmd_gro_flush_cycles,
4030 /* *** ENABLE/DISABLE GSO *** */
4031 struct cmd_gso_enable_result {
4032 cmdline_fixed_string_t cmd_set;
4033 cmdline_fixed_string_t cmd_port;
4034 cmdline_fixed_string_t cmd_keyword;
4035 cmdline_fixed_string_t cmd_mode;
4040 cmd_gso_enable_parsed(void *parsed_result,
4041 __attribute__((unused)) struct cmdline *cl,
4042 __attribute__((unused)) void *data)
4044 struct cmd_gso_enable_result *res;
4046 res = parsed_result;
4047 if (!strcmp(res->cmd_keyword, "gso"))
4048 setup_gso(res->cmd_mode, res->cmd_pid);
4051 cmdline_parse_token_string_t cmd_gso_enable_set =
4052 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4054 cmdline_parse_token_string_t cmd_gso_enable_port =
4055 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4057 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4058 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4059 cmd_keyword, "gso");
4060 cmdline_parse_token_string_t cmd_gso_enable_mode =
4061 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4062 cmd_mode, "on#off");
4063 cmdline_parse_token_num_t cmd_gso_enable_pid =
4064 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4067 cmdline_parse_inst_t cmd_gso_enable = {
4068 .f = cmd_gso_enable_parsed,
4070 .help_str = "set port <port_id> gso on|off",
4072 (void *)&cmd_gso_enable_set,
4073 (void *)&cmd_gso_enable_port,
4074 (void *)&cmd_gso_enable_pid,
4075 (void *)&cmd_gso_enable_keyword,
4076 (void *)&cmd_gso_enable_mode,
4081 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4082 struct cmd_gso_size_result {
4083 cmdline_fixed_string_t cmd_set;
4084 cmdline_fixed_string_t cmd_keyword;
4085 cmdline_fixed_string_t cmd_segsz;
4090 cmd_gso_size_parsed(void *parsed_result,
4091 __attribute__((unused)) struct cmdline *cl,
4092 __attribute__((unused)) void *data)
4094 struct cmd_gso_size_result *res = parsed_result;
4096 if (test_done == 0) {
4097 printf("Before setting GSO segsz, please first"
4098 " stop fowarding\n");
4102 if (!strcmp(res->cmd_keyword, "gso") &&
4103 !strcmp(res->cmd_segsz, "segsz")) {
4104 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4105 printf("gso_size should be larger than %zu."
4106 " Please input a legal value\n",
4107 RTE_GSO_SEG_SIZE_MIN);
4109 gso_max_segment_size = res->cmd_size;
4113 cmdline_parse_token_string_t cmd_gso_size_set =
4114 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4116 cmdline_parse_token_string_t cmd_gso_size_keyword =
4117 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4118 cmd_keyword, "gso");
4119 cmdline_parse_token_string_t cmd_gso_size_segsz =
4120 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4121 cmd_segsz, "segsz");
4122 cmdline_parse_token_num_t cmd_gso_size_size =
4123 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4126 cmdline_parse_inst_t cmd_gso_size = {
4127 .f = cmd_gso_size_parsed,
4129 .help_str = "set gso segsz <length>",
4131 (void *)&cmd_gso_size_set,
4132 (void *)&cmd_gso_size_keyword,
4133 (void *)&cmd_gso_size_segsz,
4134 (void *)&cmd_gso_size_size,
4139 /* *** SHOW GSO CONFIGURATION *** */
4140 struct cmd_gso_show_result {
4141 cmdline_fixed_string_t cmd_show;
4142 cmdline_fixed_string_t cmd_port;
4143 cmdline_fixed_string_t cmd_keyword;
4148 cmd_gso_show_parsed(void *parsed_result,
4149 __attribute__((unused)) struct cmdline *cl,
4150 __attribute__((unused)) void *data)
4152 struct cmd_gso_show_result *res = parsed_result;
4154 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4155 printf("invalid port id %u\n", res->cmd_pid);
4158 if (!strcmp(res->cmd_keyword, "gso")) {
4159 if (gso_ports[res->cmd_pid].enable) {
4160 printf("Max GSO'd packet size: %uB\n"
4161 "Supported GSO types: TCP/IPv4, "
4162 "VxLAN with inner TCP/IPv4 packet, "
4163 "GRE with inner TCP/IPv4 packet\n",
4164 gso_max_segment_size);
4166 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4170 cmdline_parse_token_string_t cmd_gso_show_show =
4171 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4173 cmdline_parse_token_string_t cmd_gso_show_port =
4174 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4176 cmdline_parse_token_string_t cmd_gso_show_keyword =
4177 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4178 cmd_keyword, "gso");
4179 cmdline_parse_token_num_t cmd_gso_show_pid =
4180 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4183 cmdline_parse_inst_t cmd_gso_show = {
4184 .f = cmd_gso_show_parsed,
4186 .help_str = "show port <port_id> gso",
4188 (void *)&cmd_gso_show_show,
4189 (void *)&cmd_gso_show_port,
4190 (void *)&cmd_gso_show_pid,
4191 (void *)&cmd_gso_show_keyword,
4196 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4197 struct cmd_set_flush_rx {
4198 cmdline_fixed_string_t set;
4199 cmdline_fixed_string_t flush_rx;
4200 cmdline_fixed_string_t mode;
4204 cmd_set_flush_rx_parsed(void *parsed_result,
4205 __attribute__((unused)) struct cmdline *cl,
4206 __attribute__((unused)) void *data)
4208 struct cmd_set_flush_rx *res = parsed_result;
4209 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4212 cmdline_parse_token_string_t cmd_setflushrx_set =
4213 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4215 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4216 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4217 flush_rx, "flush_rx");
4218 cmdline_parse_token_string_t cmd_setflushrx_mode =
4219 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4223 cmdline_parse_inst_t cmd_set_flush_rx = {
4224 .f = cmd_set_flush_rx_parsed,
4225 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4228 (void *)&cmd_setflushrx_set,
4229 (void *)&cmd_setflushrx_flush_rx,
4230 (void *)&cmd_setflushrx_mode,
4235 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4236 struct cmd_set_link_check {
4237 cmdline_fixed_string_t set;
4238 cmdline_fixed_string_t link_check;
4239 cmdline_fixed_string_t mode;
4243 cmd_set_link_check_parsed(void *parsed_result,
4244 __attribute__((unused)) struct cmdline *cl,
4245 __attribute__((unused)) void *data)
4247 struct cmd_set_link_check *res = parsed_result;
4248 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4251 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4252 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4254 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4255 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4256 link_check, "link_check");
4257 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4258 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4262 cmdline_parse_inst_t cmd_set_link_check = {
4263 .f = cmd_set_link_check_parsed,
4264 .help_str = "set link_check on|off: Enable/Disable link status check "
4265 "when starting/stopping a port",
4268 (void *)&cmd_setlinkcheck_set,
4269 (void *)&cmd_setlinkcheck_link_check,
4270 (void *)&cmd_setlinkcheck_mode,
4275 /* *** SET NIC BYPASS MODE *** */
4276 struct cmd_set_bypass_mode_result {
4277 cmdline_fixed_string_t set;
4278 cmdline_fixed_string_t bypass;
4279 cmdline_fixed_string_t mode;
4280 cmdline_fixed_string_t value;
4285 cmd_set_bypass_mode_parsed(void *parsed_result,
4286 __attribute__((unused)) struct cmdline *cl,
4287 __attribute__((unused)) void *data)
4289 struct cmd_set_bypass_mode_result *res = parsed_result;
4290 portid_t port_id = res->port_id;
4291 int32_t rc = -EINVAL;
4293 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4294 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4296 if (!strcmp(res->value, "bypass"))
4297 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4298 else if (!strcmp(res->value, "isolate"))
4299 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4301 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4303 /* Set the bypass mode for the relevant port. */
4304 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4307 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4310 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4311 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4313 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4314 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4316 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4317 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4319 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4320 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4321 value, "normal#bypass#isolate");
4322 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4323 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4326 cmdline_parse_inst_t cmd_set_bypass_mode = {
4327 .f = cmd_set_bypass_mode_parsed,
4328 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4329 "Set the NIC bypass mode for port_id",
4332 (void *)&cmd_setbypass_mode_set,
4333 (void *)&cmd_setbypass_mode_bypass,
4334 (void *)&cmd_setbypass_mode_mode,
4335 (void *)&cmd_setbypass_mode_value,
4336 (void *)&cmd_setbypass_mode_port,
4341 /* *** SET NIC BYPASS EVENT *** */
4342 struct cmd_set_bypass_event_result {
4343 cmdline_fixed_string_t set;
4344 cmdline_fixed_string_t bypass;
4345 cmdline_fixed_string_t event;
4346 cmdline_fixed_string_t event_value;
4347 cmdline_fixed_string_t mode;
4348 cmdline_fixed_string_t mode_value;
4353 cmd_set_bypass_event_parsed(void *parsed_result,
4354 __attribute__((unused)) struct cmdline *cl,
4355 __attribute__((unused)) void *data)
4357 int32_t rc = -EINVAL;
4358 struct cmd_set_bypass_event_result *res = parsed_result;
4359 portid_t port_id = res->port_id;
4361 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4362 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4363 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4365 if (!strcmp(res->event_value, "timeout"))
4366 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4367 else if (!strcmp(res->event_value, "os_on"))
4368 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4369 else if (!strcmp(res->event_value, "os_off"))
4370 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4371 else if (!strcmp(res->event_value, "power_on"))
4372 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4373 else if (!strcmp(res->event_value, "power_off"))
4374 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4376 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4378 if (!strcmp(res->mode_value, "bypass"))
4379 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4380 else if (!strcmp(res->mode_value, "isolate"))
4381 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4383 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4385 /* Set the watchdog timeout. */
4386 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4389 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4390 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4394 printf("Failed to set timeout value %u "
4395 "for port %d, errto code: %d.\n",
4396 bypass_timeout, port_id, rc);
4400 /* Set the bypass event to transition to bypass mode. */
4401 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4406 printf("\t Failed to set bypass event for port = %d.\n",
4410 cmdline_parse_token_string_t cmd_setbypass_event_set =
4411 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4413 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4414 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4416 cmdline_parse_token_string_t cmd_setbypass_event_event =
4417 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4419 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4420 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4421 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4422 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4423 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4425 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4426 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4427 mode_value, "normal#bypass#isolate");
4428 cmdline_parse_token_num_t cmd_setbypass_event_port =
4429 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4432 cmdline_parse_inst_t cmd_set_bypass_event = {
4433 .f = cmd_set_bypass_event_parsed,
4434 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4435 "power_off mode normal|bypass|isolate <port_id>: "
4436 "Set the NIC bypass event mode for port_id",
4439 (void *)&cmd_setbypass_event_set,
4440 (void *)&cmd_setbypass_event_bypass,
4441 (void *)&cmd_setbypass_event_event,
4442 (void *)&cmd_setbypass_event_event_value,
4443 (void *)&cmd_setbypass_event_mode,
4444 (void *)&cmd_setbypass_event_mode_value,
4445 (void *)&cmd_setbypass_event_port,
4451 /* *** SET NIC BYPASS TIMEOUT *** */
4452 struct cmd_set_bypass_timeout_result {
4453 cmdline_fixed_string_t set;
4454 cmdline_fixed_string_t bypass;
4455 cmdline_fixed_string_t timeout;
4456 cmdline_fixed_string_t value;
4460 cmd_set_bypass_timeout_parsed(void *parsed_result,
4461 __attribute__((unused)) struct cmdline *cl,
4462 __attribute__((unused)) void *data)
4464 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4466 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4467 if (!strcmp(res->value, "1.5"))
4468 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4469 else if (!strcmp(res->value, "2"))
4470 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4471 else if (!strcmp(res->value, "3"))
4472 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4473 else if (!strcmp(res->value, "4"))
4474 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4475 else if (!strcmp(res->value, "8"))
4476 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4477 else if (!strcmp(res->value, "16"))
4478 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4479 else if (!strcmp(res->value, "32"))
4480 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4482 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4486 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4487 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4489 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4490 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4492 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4493 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4494 timeout, "timeout");
4495 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4496 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4497 value, "0#1.5#2#3#4#8#16#32");
4499 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4500 .f = cmd_set_bypass_timeout_parsed,
4501 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4502 "Set the NIC bypass watchdog timeout in seconds",
4505 (void *)&cmd_setbypass_timeout_set,
4506 (void *)&cmd_setbypass_timeout_bypass,
4507 (void *)&cmd_setbypass_timeout_timeout,
4508 (void *)&cmd_setbypass_timeout_value,
4513 /* *** SHOW NIC BYPASS MODE *** */
4514 struct cmd_show_bypass_config_result {
4515 cmdline_fixed_string_t show;
4516 cmdline_fixed_string_t bypass;
4517 cmdline_fixed_string_t config;
4522 cmd_show_bypass_config_parsed(void *parsed_result,
4523 __attribute__((unused)) struct cmdline *cl,
4524 __attribute__((unused)) void *data)
4526 struct cmd_show_bypass_config_result *res = parsed_result;
4527 portid_t port_id = res->port_id;
4529 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4530 uint32_t event_mode;
4531 uint32_t bypass_mode;
4532 uint32_t timeout = bypass_timeout;
4535 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4536 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4537 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4538 {"UNKNOWN", "normal", "bypass", "isolate"};
4539 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4546 int num_events = (sizeof events) / (sizeof events[0]);
4548 /* Display the bypass mode.*/
4549 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4550 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4554 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4555 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4557 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4560 /* Display the bypass timeout.*/
4561 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4562 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4564 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4566 /* Display the bypass events and associated modes. */
4567 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4569 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4570 printf("\tFailed to get bypass mode for event = %s\n",
4573 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4574 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4576 printf("\tbypass event: %-16s = %s\n", events[i],
4582 printf("\tFailed to get bypass configuration for port = %d\n",
4586 cmdline_parse_token_string_t cmd_showbypass_config_show =
4587 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4589 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4590 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4592 cmdline_parse_token_string_t cmd_showbypass_config_config =
4593 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4595 cmdline_parse_token_num_t cmd_showbypass_config_port =
4596 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4599 cmdline_parse_inst_t cmd_show_bypass_config = {
4600 .f = cmd_show_bypass_config_parsed,
4601 .help_str = "show bypass config <port_id>: "
4602 "Show the NIC bypass config for port_id",
4605 (void *)&cmd_showbypass_config_show,
4606 (void *)&cmd_showbypass_config_bypass,
4607 (void *)&cmd_showbypass_config_config,
4608 (void *)&cmd_showbypass_config_port,
4613 #ifdef RTE_LIBRTE_PMD_BOND
4614 /* *** SET BONDING MODE *** */
4615 struct cmd_set_bonding_mode_result {
4616 cmdline_fixed_string_t set;
4617 cmdline_fixed_string_t bonding;
4618 cmdline_fixed_string_t mode;
4623 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4624 __attribute__((unused)) struct cmdline *cl,
4625 __attribute__((unused)) void *data)
4627 struct cmd_set_bonding_mode_result *res = parsed_result;
4628 portid_t port_id = res->port_id;
4630 /* Set the bonding mode for the relevant port. */
4631 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4632 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4635 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4636 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4638 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4639 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4640 bonding, "bonding");
4641 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4642 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4644 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4645 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4647 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4648 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4651 cmdline_parse_inst_t cmd_set_bonding_mode = {
4652 .f = cmd_set_bonding_mode_parsed,
4653 .help_str = "set bonding mode <mode_value> <port_id>: "
4654 "Set the bonding mode for port_id",
4657 (void *) &cmd_setbonding_mode_set,
4658 (void *) &cmd_setbonding_mode_bonding,
4659 (void *) &cmd_setbonding_mode_mode,
4660 (void *) &cmd_setbonding_mode_value,
4661 (void *) &cmd_setbonding_mode_port,
4666 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4667 struct cmd_set_bonding_lacp_dedicated_queues_result {
4668 cmdline_fixed_string_t set;
4669 cmdline_fixed_string_t bonding;
4670 cmdline_fixed_string_t lacp;
4671 cmdline_fixed_string_t dedicated_queues;
4673 cmdline_fixed_string_t mode;
4676 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4677 __attribute__((unused)) struct cmdline *cl,
4678 __attribute__((unused)) void *data)
4680 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4681 portid_t port_id = res->port_id;
4682 struct rte_port *port;
4684 port = &ports[port_id];
4686 /** Check if the port is not started **/
4687 if (port->port_status != RTE_PORT_STOPPED) {
4688 printf("Please stop port %d first\n", port_id);
4692 if (!strcmp(res->mode, "enable")) {
4693 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4694 printf("Dedicate queues for LACP control packets"
4697 printf("Enabling dedicate queues for LACP control "
4698 "packets on port %d failed\n", port_id);
4699 } else if (!strcmp(res->mode, "disable")) {
4700 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4701 printf("Dedicated queues for LACP control packets "
4704 printf("Disabling dedicated queues for LACP control "
4705 "traffic on port %d failed\n", port_id);
4709 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4710 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4712 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4713 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4714 bonding, "bonding");
4715 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4716 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4718 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4719 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4720 dedicated_queues, "dedicated_queues");
4721 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4722 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4724 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4725 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4726 mode, "enable#disable");
4728 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4729 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4730 .help_str = "set bonding lacp dedicated_queues <port_id> "
4732 "Enable/disable dedicated queues for LACP control traffic for port_id",
4735 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4736 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4737 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4738 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4739 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4740 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4745 /* *** SET BALANCE XMIT POLICY *** */
4746 struct cmd_set_bonding_balance_xmit_policy_result {
4747 cmdline_fixed_string_t set;
4748 cmdline_fixed_string_t bonding;
4749 cmdline_fixed_string_t balance_xmit_policy;
4751 cmdline_fixed_string_t policy;
4754 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4755 __attribute__((unused)) struct cmdline *cl,
4756 __attribute__((unused)) void *data)
4758 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4759 portid_t port_id = res->port_id;
4762 if (!strcmp(res->policy, "l2")) {
4763 policy = BALANCE_XMIT_POLICY_LAYER2;
4764 } else if (!strcmp(res->policy, "l23")) {
4765 policy = BALANCE_XMIT_POLICY_LAYER23;
4766 } else if (!strcmp(res->policy, "l34")) {
4767 policy = BALANCE_XMIT_POLICY_LAYER34;
4769 printf("\t Invalid xmit policy selection");
4773 /* Set the bonding mode for the relevant port. */
4774 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4775 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4780 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4781 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4783 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4784 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4785 bonding, "bonding");
4786 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4787 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4788 balance_xmit_policy, "balance_xmit_policy");
4789 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4790 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4792 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4793 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4794 policy, "l2#l23#l34");
4796 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4797 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4798 .help_str = "set bonding balance_xmit_policy <port_id> "
4800 "Set the bonding balance_xmit_policy for port_id",
4803 (void *)&cmd_setbonding_balance_xmit_policy_set,
4804 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4805 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4806 (void *)&cmd_setbonding_balance_xmit_policy_port,
4807 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4812 /* *** SHOW NIC BONDING CONFIGURATION *** */
4813 struct cmd_show_bonding_config_result {
4814 cmdline_fixed_string_t show;
4815 cmdline_fixed_string_t bonding;
4816 cmdline_fixed_string_t config;
4820 static void cmd_show_bonding_config_parsed(void *parsed_result,
4821 __attribute__((unused)) struct cmdline *cl,
4822 __attribute__((unused)) void *data)
4824 struct cmd_show_bonding_config_result *res = parsed_result;
4825 int bonding_mode, agg_mode;
4826 portid_t slaves[RTE_MAX_ETHPORTS];
4827 int num_slaves, num_active_slaves;
4830 portid_t port_id = res->port_id;
4832 /* Display the bonding mode.*/
4833 bonding_mode = rte_eth_bond_mode_get(port_id);
4834 if (bonding_mode < 0) {
4835 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4838 printf("\tBonding mode: %d\n", bonding_mode);
4840 if (bonding_mode == BONDING_MODE_BALANCE) {
4841 int balance_xmit_policy;
4843 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4844 if (balance_xmit_policy < 0) {
4845 printf("\tFailed to get balance xmit policy for port = %d\n",
4849 printf("\tBalance Xmit Policy: ");
4851 switch (balance_xmit_policy) {
4852 case BALANCE_XMIT_POLICY_LAYER2:
4853 printf("BALANCE_XMIT_POLICY_LAYER2");
4855 case BALANCE_XMIT_POLICY_LAYER23:
4856 printf("BALANCE_XMIT_POLICY_LAYER23");
4858 case BALANCE_XMIT_POLICY_LAYER34:
4859 printf("BALANCE_XMIT_POLICY_LAYER34");
4866 if (bonding_mode == BONDING_MODE_8023AD) {
4867 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
4868 printf("\tIEEE802.3AD Aggregator Mode: ");
4871 printf("bandwidth");
4883 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4885 if (num_slaves < 0) {
4886 printf("\tFailed to get slave list for port = %d\n", port_id);
4889 if (num_slaves > 0) {
4890 printf("\tSlaves (%d): [", num_slaves);
4891 for (i = 0; i < num_slaves - 1; i++)
4892 printf("%d ", slaves[i]);
4894 printf("%d]\n", slaves[num_slaves - 1]);
4896 printf("\tSlaves: []\n");
4900 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4903 if (num_active_slaves < 0) {
4904 printf("\tFailed to get active slave list for port = %d\n", port_id);
4907 if (num_active_slaves > 0) {
4908 printf("\tActive Slaves (%d): [", num_active_slaves);
4909 for (i = 0; i < num_active_slaves - 1; i++)
4910 printf("%d ", slaves[i]);
4912 printf("%d]\n", slaves[num_active_slaves - 1]);
4915 printf("\tActive Slaves: []\n");
4919 primary_id = rte_eth_bond_primary_get(port_id);
4920 if (primary_id < 0) {
4921 printf("\tFailed to get primary slave for port = %d\n", port_id);
4924 printf("\tPrimary: [%d]\n", primary_id);
4928 cmdline_parse_token_string_t cmd_showbonding_config_show =
4929 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4931 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4932 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4933 bonding, "bonding");
4934 cmdline_parse_token_string_t cmd_showbonding_config_config =
4935 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4937 cmdline_parse_token_num_t cmd_showbonding_config_port =
4938 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4941 cmdline_parse_inst_t cmd_show_bonding_config = {
4942 .f = cmd_show_bonding_config_parsed,
4943 .help_str = "show bonding config <port_id>: "
4944 "Show the bonding config for port_id",
4947 (void *)&cmd_showbonding_config_show,
4948 (void *)&cmd_showbonding_config_bonding,
4949 (void *)&cmd_showbonding_config_config,
4950 (void *)&cmd_showbonding_config_port,
4955 /* *** SET BONDING PRIMARY *** */
4956 struct cmd_set_bonding_primary_result {
4957 cmdline_fixed_string_t set;
4958 cmdline_fixed_string_t bonding;
4959 cmdline_fixed_string_t primary;
4964 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4965 __attribute__((unused)) struct cmdline *cl,
4966 __attribute__((unused)) void *data)
4968 struct cmd_set_bonding_primary_result *res = parsed_result;
4969 portid_t master_port_id = res->port_id;
4970 portid_t slave_port_id = res->slave_id;
4972 /* Set the primary slave for a bonded device. */
4973 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4974 printf("\t Failed to set primary slave for port = %d.\n",
4981 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4982 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4984 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4985 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4986 bonding, "bonding");
4987 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4988 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4989 primary, "primary");
4990 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4991 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4993 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4994 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4997 cmdline_parse_inst_t cmd_set_bonding_primary = {
4998 .f = cmd_set_bonding_primary_parsed,
4999 .help_str = "set bonding primary <slave_id> <port_id>: "
5000 "Set the primary slave for port_id",
5003 (void *)&cmd_setbonding_primary_set,
5004 (void *)&cmd_setbonding_primary_bonding,
5005 (void *)&cmd_setbonding_primary_primary,
5006 (void *)&cmd_setbonding_primary_slave,
5007 (void *)&cmd_setbonding_primary_port,
5012 /* *** ADD SLAVE *** */
5013 struct cmd_add_bonding_slave_result {
5014 cmdline_fixed_string_t add;
5015 cmdline_fixed_string_t bonding;
5016 cmdline_fixed_string_t slave;
5021 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5022 __attribute__((unused)) struct cmdline *cl,
5023 __attribute__((unused)) void *data)
5025 struct cmd_add_bonding_slave_result *res = parsed_result;
5026 portid_t master_port_id = res->port_id;
5027 portid_t slave_port_id = res->slave_id;
5029 /* add the slave for a bonded device. */
5030 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5031 printf("\t Failed to add slave %d to master port = %d.\n",
5032 slave_port_id, master_port_id);
5036 set_port_slave_flag(slave_port_id);
5039 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5040 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5042 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5043 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5044 bonding, "bonding");
5045 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5046 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5048 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5049 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5051 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5052 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5055 cmdline_parse_inst_t cmd_add_bonding_slave = {
5056 .f = cmd_add_bonding_slave_parsed,
5057 .help_str = "add bonding slave <slave_id> <port_id>: "
5058 "Add a slave device to a bonded device",
5061 (void *)&cmd_addbonding_slave_add,
5062 (void *)&cmd_addbonding_slave_bonding,
5063 (void *)&cmd_addbonding_slave_slave,
5064 (void *)&cmd_addbonding_slave_slaveid,
5065 (void *)&cmd_addbonding_slave_port,
5070 /* *** REMOVE SLAVE *** */
5071 struct cmd_remove_bonding_slave_result {
5072 cmdline_fixed_string_t remove;
5073 cmdline_fixed_string_t bonding;
5074 cmdline_fixed_string_t slave;
5079 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5080 __attribute__((unused)) struct cmdline *cl,
5081 __attribute__((unused)) void *data)
5083 struct cmd_remove_bonding_slave_result *res = parsed_result;
5084 portid_t master_port_id = res->port_id;
5085 portid_t slave_port_id = res->slave_id;
5087 /* remove the slave from a bonded device. */
5088 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5089 printf("\t Failed to remove slave %d from master port = %d.\n",
5090 slave_port_id, master_port_id);
5094 clear_port_slave_flag(slave_port_id);
5097 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5098 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5100 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5101 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5102 bonding, "bonding");
5103 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5104 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5106 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5107 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5109 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5110 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5113 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5114 .f = cmd_remove_bonding_slave_parsed,
5115 .help_str = "remove bonding slave <slave_id> <port_id>: "
5116 "Remove a slave device from a bonded device",
5119 (void *)&cmd_removebonding_slave_remove,
5120 (void *)&cmd_removebonding_slave_bonding,
5121 (void *)&cmd_removebonding_slave_slave,
5122 (void *)&cmd_removebonding_slave_slaveid,
5123 (void *)&cmd_removebonding_slave_port,
5128 /* *** CREATE BONDED DEVICE *** */
5129 struct cmd_create_bonded_device_result {
5130 cmdline_fixed_string_t create;
5131 cmdline_fixed_string_t bonded;
5132 cmdline_fixed_string_t device;
5137 static int bond_dev_num = 0;
5139 static void cmd_create_bonded_device_parsed(void *parsed_result,
5140 __attribute__((unused)) struct cmdline *cl,
5141 __attribute__((unused)) void *data)
5143 struct cmd_create_bonded_device_result *res = parsed_result;
5144 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5147 if (test_done == 0) {
5148 printf("Please stop forwarding first\n");
5152 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5155 /* Create a new bonded device. */
5156 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5158 printf("\t Failed to create bonded device.\n");
5161 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5164 /* Update number of ports */
5165 nb_ports = rte_eth_dev_count();
5166 reconfig(port_id, res->socket);
5167 rte_eth_promiscuous_enable(port_id);
5172 cmdline_parse_token_string_t cmd_createbonded_device_create =
5173 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5175 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5176 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5178 cmdline_parse_token_string_t cmd_createbonded_device_device =
5179 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5181 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5182 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5184 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5185 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5188 cmdline_parse_inst_t cmd_create_bonded_device = {
5189 .f = cmd_create_bonded_device_parsed,
5190 .help_str = "create bonded device <mode> <socket>: "
5191 "Create a new bonded device with specific bonding mode and socket",
5194 (void *)&cmd_createbonded_device_create,
5195 (void *)&cmd_createbonded_device_bonded,
5196 (void *)&cmd_createbonded_device_device,
5197 (void *)&cmd_createbonded_device_mode,
5198 (void *)&cmd_createbonded_device_socket,
5203 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5204 struct cmd_set_bond_mac_addr_result {
5205 cmdline_fixed_string_t set;
5206 cmdline_fixed_string_t bonding;
5207 cmdline_fixed_string_t mac_addr;
5209 struct ether_addr address;
5212 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5213 __attribute__((unused)) struct cmdline *cl,
5214 __attribute__((unused)) void *data)
5216 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5219 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5222 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5224 /* check the return value and print it if is < 0 */
5226 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5229 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5230 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5231 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5232 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5234 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5235 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5237 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5238 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
5239 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5240 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5242 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5243 .f = cmd_set_bond_mac_addr_parsed,
5245 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5247 (void *)&cmd_set_bond_mac_addr_set,
5248 (void *)&cmd_set_bond_mac_addr_bonding,
5249 (void *)&cmd_set_bond_mac_addr_mac,
5250 (void *)&cmd_set_bond_mac_addr_portnum,
5251 (void *)&cmd_set_bond_mac_addr_addr,
5257 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5258 struct cmd_set_bond_mon_period_result {
5259 cmdline_fixed_string_t set;
5260 cmdline_fixed_string_t bonding;
5261 cmdline_fixed_string_t mon_period;
5266 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5267 __attribute__((unused)) struct cmdline *cl,
5268 __attribute__((unused)) void *data)
5270 struct cmd_set_bond_mon_period_result *res = parsed_result;
5273 if (res->port_num >= nb_ports) {
5274 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5278 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5280 /* check the return value and print it if is < 0 */
5282 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5285 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5286 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5288 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5289 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5290 bonding, "bonding");
5291 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5292 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5293 mon_period, "mon_period");
5294 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5295 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5297 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5298 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5301 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5302 .f = cmd_set_bond_mon_period_parsed,
5304 .help_str = "set bonding mon_period <port_id> <period_ms>",
5306 (void *)&cmd_set_bond_mon_period_set,
5307 (void *)&cmd_set_bond_mon_period_bonding,
5308 (void *)&cmd_set_bond_mon_period_mon_period,
5309 (void *)&cmd_set_bond_mon_period_portnum,
5310 (void *)&cmd_set_bond_mon_period_period_ms,
5317 struct cmd_set_bonding_agg_mode_policy_result {
5318 cmdline_fixed_string_t set;
5319 cmdline_fixed_string_t bonding;
5320 cmdline_fixed_string_t agg_mode;
5322 cmdline_fixed_string_t policy;
5327 cmd_set_bonding_agg_mode(void *parsed_result,
5328 __attribute__((unused)) struct cmdline *cl,
5329 __attribute__((unused)) void *data)
5331 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5332 uint8_t policy = AGG_BANDWIDTH;
5334 if (res->port_num >= nb_ports) {
5335 printf("Port id %d must be less than %d\n",
5336 res->port_num, nb_ports);
5340 if (!strcmp(res->policy, "bandwidth"))
5341 policy = AGG_BANDWIDTH;
5342 else if (!strcmp(res->policy, "stable"))
5343 policy = AGG_STABLE;
5344 else if (!strcmp(res->policy, "count"))
5347 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5351 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5352 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5354 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5355 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5356 bonding, "bonding");
5358 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5359 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5360 agg_mode, "agg_mode");
5362 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5363 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5366 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5367 TOKEN_STRING_INITIALIZER(
5368 struct cmd_set_bonding_balance_xmit_policy_result,
5369 policy, "stable#bandwidth#count");
5371 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5372 .f = cmd_set_bonding_agg_mode,
5374 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5376 (void *)&cmd_set_bonding_agg_mode_set,
5377 (void *)&cmd_set_bonding_agg_mode_bonding,
5378 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5379 (void *)&cmd_set_bonding_agg_mode_portnum,
5380 (void *)&cmd_set_bonding_agg_mode_policy_string,
5386 #endif /* RTE_LIBRTE_PMD_BOND */
5388 /* *** SET FORWARDING MODE *** */
5389 struct cmd_set_fwd_mode_result {
5390 cmdline_fixed_string_t set;
5391 cmdline_fixed_string_t fwd;
5392 cmdline_fixed_string_t mode;
5395 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5396 __attribute__((unused)) struct cmdline *cl,
5397 __attribute__((unused)) void *data)
5399 struct cmd_set_fwd_mode_result *res = parsed_result;
5402 set_pkt_forwarding_mode(res->mode);
5405 cmdline_parse_token_string_t cmd_setfwd_set =
5406 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5407 cmdline_parse_token_string_t cmd_setfwd_fwd =
5408 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5409 cmdline_parse_token_string_t cmd_setfwd_mode =
5410 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5411 "" /* defined at init */);
5413 cmdline_parse_inst_t cmd_set_fwd_mode = {
5414 .f = cmd_set_fwd_mode_parsed,
5416 .help_str = NULL, /* defined at init */
5418 (void *)&cmd_setfwd_set,
5419 (void *)&cmd_setfwd_fwd,
5420 (void *)&cmd_setfwd_mode,
5425 static void cmd_set_fwd_mode_init(void)
5428 static char token[128];
5429 static char help[256];
5430 cmdline_parse_token_string_t *token_struct;
5432 modes = list_pkt_forwarding_modes();
5433 snprintf(help, sizeof(help), "set fwd %s: "
5434 "Set packet forwarding mode", modes);
5435 cmd_set_fwd_mode.help_str = help;
5437 /* string token separator is # */
5438 for (c = token; *modes != '\0'; modes++)
5443 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5444 token_struct->string_data.str = token;
5447 /* *** SET RETRY FORWARDING MODE *** */
5448 struct cmd_set_fwd_retry_mode_result {
5449 cmdline_fixed_string_t set;
5450 cmdline_fixed_string_t fwd;
5451 cmdline_fixed_string_t mode;
5452 cmdline_fixed_string_t retry;
5455 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5456 __attribute__((unused)) struct cmdline *cl,
5457 __attribute__((unused)) void *data)
5459 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5462 set_pkt_forwarding_mode(res->mode);
5465 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5466 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5468 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5469 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5471 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5472 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5474 "" /* defined at init */);
5475 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5476 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5479 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5480 .f = cmd_set_fwd_retry_mode_parsed,
5482 .help_str = NULL, /* defined at init */
5484 (void *)&cmd_setfwd_retry_set,
5485 (void *)&cmd_setfwd_retry_fwd,
5486 (void *)&cmd_setfwd_retry_mode,
5487 (void *)&cmd_setfwd_retry_retry,
5492 static void cmd_set_fwd_retry_mode_init(void)
5495 static char token[128];
5496 static char help[256];
5497 cmdline_parse_token_string_t *token_struct;
5499 modes = list_pkt_forwarding_retry_modes();
5500 snprintf(help, sizeof(help), "set fwd %s retry: "
5501 "Set packet forwarding mode with retry", modes);
5502 cmd_set_fwd_retry_mode.help_str = help;
5504 /* string token separator is # */
5505 for (c = token; *modes != '\0'; modes++)
5510 token_struct = (cmdline_parse_token_string_t *)
5511 cmd_set_fwd_retry_mode.tokens[2];
5512 token_struct->string_data.str = token;
5515 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5516 struct cmd_set_burst_tx_retry_result {
5517 cmdline_fixed_string_t set;
5518 cmdline_fixed_string_t burst;
5519 cmdline_fixed_string_t tx;
5520 cmdline_fixed_string_t delay;
5522 cmdline_fixed_string_t retry;
5526 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5527 __attribute__((unused)) struct cmdline *cl,
5528 __attribute__((unused)) void *data)
5530 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5532 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5533 && !strcmp(res->tx, "tx")) {
5534 if (!strcmp(res->delay, "delay"))
5535 burst_tx_delay_time = res->time;
5536 if (!strcmp(res->retry, "retry"))
5537 burst_tx_retry_num = res->retry_num;
5542 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5543 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5544 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5545 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5547 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5548 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5549 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5550 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5551 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5552 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5553 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5554 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5555 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5556 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5558 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5559 .f = cmd_set_burst_tx_retry_parsed,
5560 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5562 (void *)&cmd_set_burst_tx_retry_set,
5563 (void *)&cmd_set_burst_tx_retry_burst,
5564 (void *)&cmd_set_burst_tx_retry_tx,
5565 (void *)&cmd_set_burst_tx_retry_delay,
5566 (void *)&cmd_set_burst_tx_retry_time,
5567 (void *)&cmd_set_burst_tx_retry_retry,
5568 (void *)&cmd_set_burst_tx_retry_retry_num,
5573 /* *** SET PROMISC MODE *** */
5574 struct cmd_set_promisc_mode_result {
5575 cmdline_fixed_string_t set;
5576 cmdline_fixed_string_t promisc;
5577 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5578 uint8_t port_num; /* valid if "allports" argument == 0 */
5579 cmdline_fixed_string_t mode;
5582 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5583 __attribute__((unused)) struct cmdline *cl,
5586 struct cmd_set_promisc_mode_result *res = parsed_result;
5590 if (!strcmp(res->mode, "on"))
5597 RTE_ETH_FOREACH_DEV(i) {
5599 rte_eth_promiscuous_enable(i);
5601 rte_eth_promiscuous_disable(i);
5606 rte_eth_promiscuous_enable(res->port_num);
5608 rte_eth_promiscuous_disable(res->port_num);
5612 cmdline_parse_token_string_t cmd_setpromisc_set =
5613 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5614 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5615 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5617 cmdline_parse_token_string_t cmd_setpromisc_portall =
5618 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5620 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5621 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5623 cmdline_parse_token_string_t cmd_setpromisc_mode =
5624 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5627 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5628 .f = cmd_set_promisc_mode_parsed,
5630 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5632 (void *)&cmd_setpromisc_set,
5633 (void *)&cmd_setpromisc_promisc,
5634 (void *)&cmd_setpromisc_portall,
5635 (void *)&cmd_setpromisc_mode,
5640 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5641 .f = cmd_set_promisc_mode_parsed,
5643 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5645 (void *)&cmd_setpromisc_set,
5646 (void *)&cmd_setpromisc_promisc,
5647 (void *)&cmd_setpromisc_portnum,
5648 (void *)&cmd_setpromisc_mode,
5653 /* *** SET ALLMULTI MODE *** */
5654 struct cmd_set_allmulti_mode_result {
5655 cmdline_fixed_string_t set;
5656 cmdline_fixed_string_t allmulti;
5657 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5658 uint8_t port_num; /* valid if "allports" argument == 0 */
5659 cmdline_fixed_string_t mode;
5662 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5663 __attribute__((unused)) struct cmdline *cl,
5666 struct cmd_set_allmulti_mode_result *res = parsed_result;
5670 if (!strcmp(res->mode, "on"))
5677 RTE_ETH_FOREACH_DEV(i) {
5679 rte_eth_allmulticast_enable(i);
5681 rte_eth_allmulticast_disable(i);
5686 rte_eth_allmulticast_enable(res->port_num);
5688 rte_eth_allmulticast_disable(res->port_num);
5692 cmdline_parse_token_string_t cmd_setallmulti_set =
5693 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5694 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5695 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5697 cmdline_parse_token_string_t cmd_setallmulti_portall =
5698 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5700 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5701 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5703 cmdline_parse_token_string_t cmd_setallmulti_mode =
5704 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5707 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5708 .f = cmd_set_allmulti_mode_parsed,
5710 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5712 (void *)&cmd_setallmulti_set,
5713 (void *)&cmd_setallmulti_allmulti,
5714 (void *)&cmd_setallmulti_portall,
5715 (void *)&cmd_setallmulti_mode,
5720 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5721 .f = cmd_set_allmulti_mode_parsed,
5723 .help_str = "set allmulti <port_id> on|off: "
5724 "Set allmulti mode on port_id",
5726 (void *)&cmd_setallmulti_set,
5727 (void *)&cmd_setallmulti_allmulti,
5728 (void *)&cmd_setallmulti_portnum,
5729 (void *)&cmd_setallmulti_mode,
5734 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5735 struct cmd_link_flow_ctrl_set_result {
5736 cmdline_fixed_string_t set;
5737 cmdline_fixed_string_t flow_ctrl;
5738 cmdline_fixed_string_t rx;
5739 cmdline_fixed_string_t rx_lfc_mode;
5740 cmdline_fixed_string_t tx;
5741 cmdline_fixed_string_t tx_lfc_mode;
5742 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5743 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5744 cmdline_fixed_string_t autoneg_str;
5745 cmdline_fixed_string_t autoneg;
5746 cmdline_fixed_string_t hw_str;
5747 uint32_t high_water;
5748 cmdline_fixed_string_t lw_str;
5750 cmdline_fixed_string_t pt_str;
5751 uint16_t pause_time;
5752 cmdline_fixed_string_t xon_str;
5757 cmdline_parse_token_string_t cmd_lfc_set_set =
5758 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5760 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5761 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5762 flow_ctrl, "flow_ctrl");
5763 cmdline_parse_token_string_t cmd_lfc_set_rx =
5764 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5766 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5767 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5768 rx_lfc_mode, "on#off");
5769 cmdline_parse_token_string_t cmd_lfc_set_tx =
5770 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5772 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5773 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5774 tx_lfc_mode, "on#off");
5775 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5776 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5777 hw_str, "high_water");
5778 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5779 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5780 high_water, UINT32);
5781 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5782 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5783 lw_str, "low_water");
5784 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5785 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5787 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5788 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5789 pt_str, "pause_time");
5790 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5791 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5792 pause_time, UINT16);
5793 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5794 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5795 xon_str, "send_xon");
5796 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5797 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5799 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5800 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5801 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5802 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5803 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5804 mac_ctrl_frame_fwd_mode, "on#off");
5805 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5806 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5807 autoneg_str, "autoneg");
5808 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5809 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5811 cmdline_parse_token_num_t cmd_lfc_set_portid =
5812 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5815 /* forward declaration */
5817 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5820 cmdline_parse_inst_t cmd_link_flow_control_set = {
5821 .f = cmd_link_flow_ctrl_set_parsed,
5823 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5824 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5825 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5827 (void *)&cmd_lfc_set_set,
5828 (void *)&cmd_lfc_set_flow_ctrl,
5829 (void *)&cmd_lfc_set_rx,
5830 (void *)&cmd_lfc_set_rx_mode,
5831 (void *)&cmd_lfc_set_tx,
5832 (void *)&cmd_lfc_set_tx_mode,
5833 (void *)&cmd_lfc_set_high_water,
5834 (void *)&cmd_lfc_set_low_water,
5835 (void *)&cmd_lfc_set_pause_time,
5836 (void *)&cmd_lfc_set_send_xon,
5837 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5838 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5839 (void *)&cmd_lfc_set_autoneg_str,
5840 (void *)&cmd_lfc_set_autoneg,
5841 (void *)&cmd_lfc_set_portid,
5846 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5847 .f = cmd_link_flow_ctrl_set_parsed,
5848 .data = (void *)&cmd_link_flow_control_set_rx,
5849 .help_str = "set flow_ctrl rx on|off <port_id>: "
5850 "Change rx flow control parameter",
5852 (void *)&cmd_lfc_set_set,
5853 (void *)&cmd_lfc_set_flow_ctrl,
5854 (void *)&cmd_lfc_set_rx,
5855 (void *)&cmd_lfc_set_rx_mode,
5856 (void *)&cmd_lfc_set_portid,
5861 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5862 .f = cmd_link_flow_ctrl_set_parsed,
5863 .data = (void *)&cmd_link_flow_control_set_tx,
5864 .help_str = "set flow_ctrl tx on|off <port_id>: "
5865 "Change tx flow control parameter",
5867 (void *)&cmd_lfc_set_set,
5868 (void *)&cmd_lfc_set_flow_ctrl,
5869 (void *)&cmd_lfc_set_tx,
5870 (void *)&cmd_lfc_set_tx_mode,
5871 (void *)&cmd_lfc_set_portid,
5876 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5877 .f = cmd_link_flow_ctrl_set_parsed,
5878 .data = (void *)&cmd_link_flow_control_set_hw,
5879 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5880 "Change high water flow control parameter",
5882 (void *)&cmd_lfc_set_set,
5883 (void *)&cmd_lfc_set_flow_ctrl,
5884 (void *)&cmd_lfc_set_high_water_str,
5885 (void *)&cmd_lfc_set_high_water,
5886 (void *)&cmd_lfc_set_portid,
5891 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5892 .f = cmd_link_flow_ctrl_set_parsed,
5893 .data = (void *)&cmd_link_flow_control_set_lw,
5894 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5895 "Change low water flow control parameter",
5897 (void *)&cmd_lfc_set_set,
5898 (void *)&cmd_lfc_set_flow_ctrl,
5899 (void *)&cmd_lfc_set_low_water_str,
5900 (void *)&cmd_lfc_set_low_water,
5901 (void *)&cmd_lfc_set_portid,
5906 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5907 .f = cmd_link_flow_ctrl_set_parsed,
5908 .data = (void *)&cmd_link_flow_control_set_pt,
5909 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5910 "Change pause time flow control parameter",
5912 (void *)&cmd_lfc_set_set,
5913 (void *)&cmd_lfc_set_flow_ctrl,
5914 (void *)&cmd_lfc_set_pause_time_str,
5915 (void *)&cmd_lfc_set_pause_time,
5916 (void *)&cmd_lfc_set_portid,
5921 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5922 .f = cmd_link_flow_ctrl_set_parsed,
5923 .data = (void *)&cmd_link_flow_control_set_xon,
5924 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5925 "Change send_xon flow control parameter",
5927 (void *)&cmd_lfc_set_set,
5928 (void *)&cmd_lfc_set_flow_ctrl,
5929 (void *)&cmd_lfc_set_send_xon_str,
5930 (void *)&cmd_lfc_set_send_xon,
5931 (void *)&cmd_lfc_set_portid,
5936 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5937 .f = cmd_link_flow_ctrl_set_parsed,
5938 .data = (void *)&cmd_link_flow_control_set_macfwd,
5939 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5940 "Change mac ctrl fwd flow control parameter",
5942 (void *)&cmd_lfc_set_set,
5943 (void *)&cmd_lfc_set_flow_ctrl,
5944 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5945 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5946 (void *)&cmd_lfc_set_portid,
5951 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5952 .f = cmd_link_flow_ctrl_set_parsed,
5953 .data = (void *)&cmd_link_flow_control_set_autoneg,
5954 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5955 "Change autoneg flow control parameter",
5957 (void *)&cmd_lfc_set_set,
5958 (void *)&cmd_lfc_set_flow_ctrl,
5959 (void *)&cmd_lfc_set_autoneg_str,
5960 (void *)&cmd_lfc_set_autoneg,
5961 (void *)&cmd_lfc_set_portid,
5967 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5968 __attribute__((unused)) struct cmdline *cl,
5971 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5972 cmdline_parse_inst_t *cmd = data;
5973 struct rte_eth_fc_conf fc_conf;
5979 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5980 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5981 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5982 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5984 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5985 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5988 /* Partial command line, retrieve current configuration */
5990 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5992 printf("cannot get current flow ctrl parameters, return"
5993 "code = %d\n", ret);
5997 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5998 (fc_conf.mode == RTE_FC_FULL))
6000 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6001 (fc_conf.mode == RTE_FC_FULL))
6005 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6006 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6008 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6009 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6011 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6013 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6014 fc_conf.high_water = res->high_water;
6016 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6017 fc_conf.low_water = res->low_water;
6019 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6020 fc_conf.pause_time = res->pause_time;
6022 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6023 fc_conf.send_xon = res->send_xon;
6025 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6026 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6027 fc_conf.mac_ctrl_frame_fwd = 1;
6029 fc_conf.mac_ctrl_frame_fwd = 0;
6032 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6033 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6035 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6037 printf("bad flow contrl parameter, return code = %d \n", ret);
6040 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6041 struct cmd_priority_flow_ctrl_set_result {
6042 cmdline_fixed_string_t set;
6043 cmdline_fixed_string_t pfc_ctrl;
6044 cmdline_fixed_string_t rx;
6045 cmdline_fixed_string_t rx_pfc_mode;
6046 cmdline_fixed_string_t tx;
6047 cmdline_fixed_string_t tx_pfc_mode;
6048 uint32_t high_water;
6050 uint16_t pause_time;
6056 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6057 __attribute__((unused)) struct cmdline *cl,
6058 __attribute__((unused)) void *data)
6060 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6061 struct rte_eth_pfc_conf pfc_conf;
6062 int rx_fc_enable, tx_fc_enable;
6066 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6067 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6068 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6069 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6071 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6072 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6075 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6076 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6077 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6078 pfc_conf.fc.high_water = res->high_water;
6079 pfc_conf.fc.low_water = res->low_water;
6080 pfc_conf.fc.pause_time = res->pause_time;
6081 pfc_conf.priority = res->priority;
6083 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6085 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6088 cmdline_parse_token_string_t cmd_pfc_set_set =
6089 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6091 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6092 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6093 pfc_ctrl, "pfc_ctrl");
6094 cmdline_parse_token_string_t cmd_pfc_set_rx =
6095 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6097 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6098 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6099 rx_pfc_mode, "on#off");
6100 cmdline_parse_token_string_t cmd_pfc_set_tx =
6101 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6103 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6104 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6105 tx_pfc_mode, "on#off");
6106 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6107 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6108 high_water, UINT32);
6109 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6110 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6112 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6113 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6114 pause_time, UINT16);
6115 cmdline_parse_token_num_t cmd_pfc_set_priority =
6116 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6118 cmdline_parse_token_num_t cmd_pfc_set_portid =
6119 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6122 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6123 .f = cmd_priority_flow_ctrl_set_parsed,
6125 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6126 "<pause_time> <priority> <port_id>: "
6127 "Configure the Ethernet priority flow control",
6129 (void *)&cmd_pfc_set_set,
6130 (void *)&cmd_pfc_set_flow_ctrl,
6131 (void *)&cmd_pfc_set_rx,
6132 (void *)&cmd_pfc_set_rx_mode,
6133 (void *)&cmd_pfc_set_tx,
6134 (void *)&cmd_pfc_set_tx_mode,
6135 (void *)&cmd_pfc_set_high_water,
6136 (void *)&cmd_pfc_set_low_water,
6137 (void *)&cmd_pfc_set_pause_time,
6138 (void *)&cmd_pfc_set_priority,
6139 (void *)&cmd_pfc_set_portid,
6144 /* *** RESET CONFIGURATION *** */
6145 struct cmd_reset_result {
6146 cmdline_fixed_string_t reset;
6147 cmdline_fixed_string_t def;
6150 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6152 __attribute__((unused)) void *data)
6154 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6155 set_def_fwd_config();
6158 cmdline_parse_token_string_t cmd_reset_set =
6159 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6160 cmdline_parse_token_string_t cmd_reset_def =
6161 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6164 cmdline_parse_inst_t cmd_reset = {
6165 .f = cmd_reset_parsed,
6167 .help_str = "set default: Reset default forwarding configuration",
6169 (void *)&cmd_reset_set,
6170 (void *)&cmd_reset_def,
6175 /* *** START FORWARDING *** */
6176 struct cmd_start_result {
6177 cmdline_fixed_string_t start;
6180 cmdline_parse_token_string_t cmd_start_start =
6181 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6183 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6184 __attribute__((unused)) struct cmdline *cl,
6185 __attribute__((unused)) void *data)
6187 start_packet_forwarding(0);
6190 cmdline_parse_inst_t cmd_start = {
6191 .f = cmd_start_parsed,
6193 .help_str = "start: Start packet forwarding",
6195 (void *)&cmd_start_start,
6200 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6201 struct cmd_start_tx_first_result {
6202 cmdline_fixed_string_t start;
6203 cmdline_fixed_string_t tx_first;
6207 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6208 __attribute__((unused)) struct cmdline *cl,
6209 __attribute__((unused)) void *data)
6211 start_packet_forwarding(1);
6214 cmdline_parse_token_string_t cmd_start_tx_first_start =
6215 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6217 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6218 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6219 tx_first, "tx_first");
6221 cmdline_parse_inst_t cmd_start_tx_first = {
6222 .f = cmd_start_tx_first_parsed,
6224 .help_str = "start tx_first: Start packet forwarding, "
6225 "after sending 1 burst of packets",
6227 (void *)&cmd_start_tx_first_start,
6228 (void *)&cmd_start_tx_first_tx_first,
6233 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6234 struct cmd_start_tx_first_n_result {
6235 cmdline_fixed_string_t start;
6236 cmdline_fixed_string_t tx_first;
6241 cmd_start_tx_first_n_parsed(void *parsed_result,
6242 __attribute__((unused)) struct cmdline *cl,
6243 __attribute__((unused)) void *data)
6245 struct cmd_start_tx_first_n_result *res = parsed_result;
6247 start_packet_forwarding(res->tx_num);
6250 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6251 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6253 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6254 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6255 tx_first, "tx_first");
6256 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6257 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6260 cmdline_parse_inst_t cmd_start_tx_first_n = {
6261 .f = cmd_start_tx_first_n_parsed,
6263 .help_str = "start tx_first <num>: "
6264 "packet forwarding, after sending <num> bursts of packets",
6266 (void *)&cmd_start_tx_first_n_start,
6267 (void *)&cmd_start_tx_first_n_tx_first,
6268 (void *)&cmd_start_tx_first_n_tx_num,
6273 /* *** SET LINK UP *** */
6274 struct cmd_set_link_up_result {
6275 cmdline_fixed_string_t set;
6276 cmdline_fixed_string_t link_up;
6277 cmdline_fixed_string_t port;
6281 cmdline_parse_token_string_t cmd_set_link_up_set =
6282 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6283 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6284 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6286 cmdline_parse_token_string_t cmd_set_link_up_port =
6287 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6288 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6289 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
6291 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6292 __attribute__((unused)) struct cmdline *cl,
6293 __attribute__((unused)) void *data)
6295 struct cmd_set_link_up_result *res = parsed_result;
6296 dev_set_link_up(res->port_id);
6299 cmdline_parse_inst_t cmd_set_link_up = {
6300 .f = cmd_set_link_up_parsed,
6302 .help_str = "set link-up port <port id>",
6304 (void *)&cmd_set_link_up_set,
6305 (void *)&cmd_set_link_up_link_up,
6306 (void *)&cmd_set_link_up_port,
6307 (void *)&cmd_set_link_up_port_id,
6312 /* *** SET LINK DOWN *** */
6313 struct cmd_set_link_down_result {
6314 cmdline_fixed_string_t set;
6315 cmdline_fixed_string_t link_down;
6316 cmdline_fixed_string_t port;
6320 cmdline_parse_token_string_t cmd_set_link_down_set =
6321 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6322 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6323 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6325 cmdline_parse_token_string_t cmd_set_link_down_port =
6326 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6327 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6328 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
6330 static void cmd_set_link_down_parsed(
6331 __attribute__((unused)) void *parsed_result,
6332 __attribute__((unused)) struct cmdline *cl,
6333 __attribute__((unused)) void *data)
6335 struct cmd_set_link_down_result *res = parsed_result;
6336 dev_set_link_down(res->port_id);
6339 cmdline_parse_inst_t cmd_set_link_down = {
6340 .f = cmd_set_link_down_parsed,
6342 .help_str = "set link-down port <port id>",
6344 (void *)&cmd_set_link_down_set,
6345 (void *)&cmd_set_link_down_link_down,
6346 (void *)&cmd_set_link_down_port,
6347 (void *)&cmd_set_link_down_port_id,
6352 /* *** SHOW CFG *** */
6353 struct cmd_showcfg_result {
6354 cmdline_fixed_string_t show;
6355 cmdline_fixed_string_t cfg;
6356 cmdline_fixed_string_t what;
6359 static void cmd_showcfg_parsed(void *parsed_result,
6360 __attribute__((unused)) struct cmdline *cl,
6361 __attribute__((unused)) void *data)
6363 struct cmd_showcfg_result *res = parsed_result;
6364 if (!strcmp(res->what, "rxtx"))
6365 rxtx_config_display();
6366 else if (!strcmp(res->what, "cores"))
6367 fwd_lcores_config_display();
6368 else if (!strcmp(res->what, "fwd"))
6369 pkt_fwd_config_display(&cur_fwd_config);
6370 else if (!strcmp(res->what, "txpkts"))
6371 show_tx_pkt_segments();
6374 cmdline_parse_token_string_t cmd_showcfg_show =
6375 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6376 cmdline_parse_token_string_t cmd_showcfg_port =
6377 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6378 cmdline_parse_token_string_t cmd_showcfg_what =
6379 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6380 "rxtx#cores#fwd#txpkts");
6382 cmdline_parse_inst_t cmd_showcfg = {
6383 .f = cmd_showcfg_parsed,
6385 .help_str = "show config rxtx|cores|fwd|txpkts",
6387 (void *)&cmd_showcfg_show,
6388 (void *)&cmd_showcfg_port,
6389 (void *)&cmd_showcfg_what,
6394 /* *** SHOW ALL PORT INFO *** */
6395 struct cmd_showportall_result {
6396 cmdline_fixed_string_t show;
6397 cmdline_fixed_string_t port;
6398 cmdline_fixed_string_t what;
6399 cmdline_fixed_string_t all;
6402 static void cmd_showportall_parsed(void *parsed_result,
6403 __attribute__((unused)) struct cmdline *cl,
6404 __attribute__((unused)) void *data)
6408 struct cmd_showportall_result *res = parsed_result;
6409 if (!strcmp(res->show, "clear")) {
6410 if (!strcmp(res->what, "stats"))
6411 RTE_ETH_FOREACH_DEV(i)
6413 else if (!strcmp(res->what, "xstats"))
6414 RTE_ETH_FOREACH_DEV(i)
6415 nic_xstats_clear(i);
6416 } else if (!strcmp(res->what, "info"))
6417 RTE_ETH_FOREACH_DEV(i)
6418 port_infos_display(i);
6419 else if (!strcmp(res->what, "stats"))
6420 RTE_ETH_FOREACH_DEV(i)
6421 nic_stats_display(i);
6422 else if (!strcmp(res->what, "xstats"))
6423 RTE_ETH_FOREACH_DEV(i)
6424 nic_xstats_display(i);
6425 else if (!strcmp(res->what, "fdir"))
6426 RTE_ETH_FOREACH_DEV(i)
6428 else if (!strcmp(res->what, "stat_qmap"))
6429 RTE_ETH_FOREACH_DEV(i)
6430 nic_stats_mapping_display(i);
6431 else if (!strcmp(res->what, "dcb_tc"))
6432 RTE_ETH_FOREACH_DEV(i)
6433 port_dcb_info_display(i);
6434 else if (!strcmp(res->what, "cap"))
6435 RTE_ETH_FOREACH_DEV(i)
6436 port_offload_cap_display(i);
6439 cmdline_parse_token_string_t cmd_showportall_show =
6440 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6442 cmdline_parse_token_string_t cmd_showportall_port =
6443 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6444 cmdline_parse_token_string_t cmd_showportall_what =
6445 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6446 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6447 cmdline_parse_token_string_t cmd_showportall_all =
6448 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6449 cmdline_parse_inst_t cmd_showportall = {
6450 .f = cmd_showportall_parsed,
6452 .help_str = "show|clear port "
6453 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6455 (void *)&cmd_showportall_show,
6456 (void *)&cmd_showportall_port,
6457 (void *)&cmd_showportall_what,
6458 (void *)&cmd_showportall_all,
6463 /* *** SHOW PORT INFO *** */
6464 struct cmd_showport_result {
6465 cmdline_fixed_string_t show;
6466 cmdline_fixed_string_t port;
6467 cmdline_fixed_string_t what;
6471 static void cmd_showport_parsed(void *parsed_result,
6472 __attribute__((unused)) struct cmdline *cl,
6473 __attribute__((unused)) void *data)
6475 struct cmd_showport_result *res = parsed_result;
6476 if (!strcmp(res->show, "clear")) {
6477 if (!strcmp(res->what, "stats"))
6478 nic_stats_clear(res->portnum);
6479 else if (!strcmp(res->what, "xstats"))
6480 nic_xstats_clear(res->portnum);
6481 } else if (!strcmp(res->what, "info"))
6482 port_infos_display(res->portnum);
6483 else if (!strcmp(res->what, "stats"))
6484 nic_stats_display(res->portnum);
6485 else if (!strcmp(res->what, "xstats"))
6486 nic_xstats_display(res->portnum);
6487 else if (!strcmp(res->what, "fdir"))
6488 fdir_get_infos(res->portnum);
6489 else if (!strcmp(res->what, "stat_qmap"))
6490 nic_stats_mapping_display(res->portnum);
6491 else if (!strcmp(res->what, "dcb_tc"))
6492 port_dcb_info_display(res->portnum);
6493 else if (!strcmp(res->what, "cap"))
6494 port_offload_cap_display(res->portnum);
6497 cmdline_parse_token_string_t cmd_showport_show =
6498 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6500 cmdline_parse_token_string_t cmd_showport_port =
6501 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6502 cmdline_parse_token_string_t cmd_showport_what =
6503 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6504 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6505 cmdline_parse_token_num_t cmd_showport_portnum =
6506 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
6508 cmdline_parse_inst_t cmd_showport = {
6509 .f = cmd_showport_parsed,
6511 .help_str = "show|clear port "
6512 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6515 (void *)&cmd_showport_show,
6516 (void *)&cmd_showport_port,
6517 (void *)&cmd_showport_what,
6518 (void *)&cmd_showport_portnum,
6523 /* *** SHOW QUEUE INFO *** */
6524 struct cmd_showqueue_result {
6525 cmdline_fixed_string_t show;
6526 cmdline_fixed_string_t type;
6527 cmdline_fixed_string_t what;
6533 cmd_showqueue_parsed(void *parsed_result,
6534 __attribute__((unused)) struct cmdline *cl,
6535 __attribute__((unused)) void *data)
6537 struct cmd_showqueue_result *res = parsed_result;
6539 if (!strcmp(res->type, "rxq"))
6540 rx_queue_infos_display(res->portnum, res->queuenum);
6541 else if (!strcmp(res->type, "txq"))
6542 tx_queue_infos_display(res->portnum, res->queuenum);
6545 cmdline_parse_token_string_t cmd_showqueue_show =
6546 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6547 cmdline_parse_token_string_t cmd_showqueue_type =
6548 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6549 cmdline_parse_token_string_t cmd_showqueue_what =
6550 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6551 cmdline_parse_token_num_t cmd_showqueue_portnum =
6552 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6553 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6554 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6556 cmdline_parse_inst_t cmd_showqueue = {
6557 .f = cmd_showqueue_parsed,
6559 .help_str = "show rxq|txq info <port_id> <queue_id>",
6561 (void *)&cmd_showqueue_show,
6562 (void *)&cmd_showqueue_type,
6563 (void *)&cmd_showqueue_what,
6564 (void *)&cmd_showqueue_portnum,
6565 (void *)&cmd_showqueue_queuenum,
6570 /* *** READ PORT REGISTER *** */
6571 struct cmd_read_reg_result {
6572 cmdline_fixed_string_t read;
6573 cmdline_fixed_string_t reg;
6579 cmd_read_reg_parsed(void *parsed_result,
6580 __attribute__((unused)) struct cmdline *cl,
6581 __attribute__((unused)) void *data)
6583 struct cmd_read_reg_result *res = parsed_result;
6584 port_reg_display(res->port_id, res->reg_off);
6587 cmdline_parse_token_string_t cmd_read_reg_read =
6588 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6589 cmdline_parse_token_string_t cmd_read_reg_reg =
6590 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6591 cmdline_parse_token_num_t cmd_read_reg_port_id =
6592 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6593 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6594 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6596 cmdline_parse_inst_t cmd_read_reg = {
6597 .f = cmd_read_reg_parsed,
6599 .help_str = "read reg <port_id> <reg_off>",
6601 (void *)&cmd_read_reg_read,
6602 (void *)&cmd_read_reg_reg,
6603 (void *)&cmd_read_reg_port_id,
6604 (void *)&cmd_read_reg_reg_off,
6609 /* *** READ PORT REGISTER BIT FIELD *** */
6610 struct cmd_read_reg_bit_field_result {
6611 cmdline_fixed_string_t read;
6612 cmdline_fixed_string_t regfield;
6620 cmd_read_reg_bit_field_parsed(void *parsed_result,
6621 __attribute__((unused)) struct cmdline *cl,
6622 __attribute__((unused)) void *data)
6624 struct cmd_read_reg_bit_field_result *res = parsed_result;
6625 port_reg_bit_field_display(res->port_id, res->reg_off,
6626 res->bit1_pos, res->bit2_pos);
6629 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6630 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6632 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6633 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6634 regfield, "regfield");
6635 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6636 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6638 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6639 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6641 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6642 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6644 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6645 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6648 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6649 .f = cmd_read_reg_bit_field_parsed,
6651 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6652 "Read register bit field between bit_x and bit_y included",
6654 (void *)&cmd_read_reg_bit_field_read,
6655 (void *)&cmd_read_reg_bit_field_regfield,
6656 (void *)&cmd_read_reg_bit_field_port_id,
6657 (void *)&cmd_read_reg_bit_field_reg_off,
6658 (void *)&cmd_read_reg_bit_field_bit1_pos,
6659 (void *)&cmd_read_reg_bit_field_bit2_pos,
6664 /* *** READ PORT REGISTER BIT *** */
6665 struct cmd_read_reg_bit_result {
6666 cmdline_fixed_string_t read;
6667 cmdline_fixed_string_t regbit;
6674 cmd_read_reg_bit_parsed(void *parsed_result,
6675 __attribute__((unused)) struct cmdline *cl,
6676 __attribute__((unused)) void *data)
6678 struct cmd_read_reg_bit_result *res = parsed_result;
6679 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6682 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6683 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6684 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6685 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6687 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6688 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6689 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6690 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6691 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6692 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6694 cmdline_parse_inst_t cmd_read_reg_bit = {
6695 .f = cmd_read_reg_bit_parsed,
6697 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6699 (void *)&cmd_read_reg_bit_read,
6700 (void *)&cmd_read_reg_bit_regbit,
6701 (void *)&cmd_read_reg_bit_port_id,
6702 (void *)&cmd_read_reg_bit_reg_off,
6703 (void *)&cmd_read_reg_bit_bit_pos,
6708 /* *** WRITE PORT REGISTER *** */
6709 struct cmd_write_reg_result {
6710 cmdline_fixed_string_t write;
6711 cmdline_fixed_string_t reg;
6718 cmd_write_reg_parsed(void *parsed_result,
6719 __attribute__((unused)) struct cmdline *cl,
6720 __attribute__((unused)) void *data)
6722 struct cmd_write_reg_result *res = parsed_result;
6723 port_reg_set(res->port_id, res->reg_off, res->value);
6726 cmdline_parse_token_string_t cmd_write_reg_write =
6727 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6728 cmdline_parse_token_string_t cmd_write_reg_reg =
6729 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6730 cmdline_parse_token_num_t cmd_write_reg_port_id =
6731 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6732 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6733 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6734 cmdline_parse_token_num_t cmd_write_reg_value =
6735 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6737 cmdline_parse_inst_t cmd_write_reg = {
6738 .f = cmd_write_reg_parsed,
6740 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6742 (void *)&cmd_write_reg_write,
6743 (void *)&cmd_write_reg_reg,
6744 (void *)&cmd_write_reg_port_id,
6745 (void *)&cmd_write_reg_reg_off,
6746 (void *)&cmd_write_reg_value,
6751 /* *** WRITE PORT REGISTER BIT FIELD *** */
6752 struct cmd_write_reg_bit_field_result {
6753 cmdline_fixed_string_t write;
6754 cmdline_fixed_string_t regfield;
6763 cmd_write_reg_bit_field_parsed(void *parsed_result,
6764 __attribute__((unused)) struct cmdline *cl,
6765 __attribute__((unused)) void *data)
6767 struct cmd_write_reg_bit_field_result *res = parsed_result;
6768 port_reg_bit_field_set(res->port_id, res->reg_off,
6769 res->bit1_pos, res->bit2_pos, res->value);
6772 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6773 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6775 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6776 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6777 regfield, "regfield");
6778 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6779 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6781 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6782 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6784 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6785 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6787 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6788 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6790 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6791 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6794 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6795 .f = cmd_write_reg_bit_field_parsed,
6797 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6799 "Set register bit field between bit_x and bit_y included",
6801 (void *)&cmd_write_reg_bit_field_write,
6802 (void *)&cmd_write_reg_bit_field_regfield,
6803 (void *)&cmd_write_reg_bit_field_port_id,
6804 (void *)&cmd_write_reg_bit_field_reg_off,
6805 (void *)&cmd_write_reg_bit_field_bit1_pos,
6806 (void *)&cmd_write_reg_bit_field_bit2_pos,
6807 (void *)&cmd_write_reg_bit_field_value,
6812 /* *** WRITE PORT REGISTER BIT *** */
6813 struct cmd_write_reg_bit_result {
6814 cmdline_fixed_string_t write;
6815 cmdline_fixed_string_t regbit;
6823 cmd_write_reg_bit_parsed(void *parsed_result,
6824 __attribute__((unused)) struct cmdline *cl,
6825 __attribute__((unused)) void *data)
6827 struct cmd_write_reg_bit_result *res = parsed_result;
6828 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6831 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6832 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6834 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6835 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6837 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6838 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6839 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6840 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6841 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6842 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6843 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6844 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6846 cmdline_parse_inst_t cmd_write_reg_bit = {
6847 .f = cmd_write_reg_bit_parsed,
6849 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6852 (void *)&cmd_write_reg_bit_write,
6853 (void *)&cmd_write_reg_bit_regbit,
6854 (void *)&cmd_write_reg_bit_port_id,
6855 (void *)&cmd_write_reg_bit_reg_off,
6856 (void *)&cmd_write_reg_bit_bit_pos,
6857 (void *)&cmd_write_reg_bit_value,
6862 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6863 struct cmd_read_rxd_txd_result {
6864 cmdline_fixed_string_t read;
6865 cmdline_fixed_string_t rxd_txd;
6872 cmd_read_rxd_txd_parsed(void *parsed_result,
6873 __attribute__((unused)) struct cmdline *cl,
6874 __attribute__((unused)) void *data)
6876 struct cmd_read_rxd_txd_result *res = parsed_result;
6878 if (!strcmp(res->rxd_txd, "rxd"))
6879 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6880 else if (!strcmp(res->rxd_txd, "txd"))
6881 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6884 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6885 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6886 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6887 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6889 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6890 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6891 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6892 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6893 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6894 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6896 cmdline_parse_inst_t cmd_read_rxd_txd = {
6897 .f = cmd_read_rxd_txd_parsed,
6899 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6901 (void *)&cmd_read_rxd_txd_read,
6902 (void *)&cmd_read_rxd_txd_rxd_txd,
6903 (void *)&cmd_read_rxd_txd_port_id,
6904 (void *)&cmd_read_rxd_txd_queue_id,
6905 (void *)&cmd_read_rxd_txd_desc_id,
6911 struct cmd_quit_result {
6912 cmdline_fixed_string_t quit;
6915 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6917 __attribute__((unused)) void *data)
6923 cmdline_parse_token_string_t cmd_quit_quit =
6924 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6926 cmdline_parse_inst_t cmd_quit = {
6927 .f = cmd_quit_parsed,
6929 .help_str = "quit: Exit application",
6931 (void *)&cmd_quit_quit,
6936 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6937 struct cmd_mac_addr_result {
6938 cmdline_fixed_string_t mac_addr_cmd;
6939 cmdline_fixed_string_t what;
6941 struct ether_addr address;
6944 static void cmd_mac_addr_parsed(void *parsed_result,
6945 __attribute__((unused)) struct cmdline *cl,
6946 __attribute__((unused)) void *data)
6948 struct cmd_mac_addr_result *res = parsed_result;
6951 if (strcmp(res->what, "add") == 0)
6952 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6953 else if (strcmp(res->what, "set") == 0)
6954 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6957 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6959 /* check the return value and print it if is < 0 */
6961 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6965 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6966 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6968 cmdline_parse_token_string_t cmd_mac_addr_what =
6969 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6971 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6972 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6973 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6974 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6976 cmdline_parse_inst_t cmd_mac_addr = {
6977 .f = cmd_mac_addr_parsed,
6979 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6980 "Add/Remove/Set MAC address on port_id",
6982 (void *)&cmd_mac_addr_cmd,
6983 (void *)&cmd_mac_addr_what,
6984 (void *)&cmd_mac_addr_portnum,
6985 (void *)&cmd_mac_addr_addr,
6991 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6992 struct cmd_set_qmap_result {
6993 cmdline_fixed_string_t set;
6994 cmdline_fixed_string_t qmap;
6995 cmdline_fixed_string_t what;
7002 cmd_set_qmap_parsed(void *parsed_result,
7003 __attribute__((unused)) struct cmdline *cl,
7004 __attribute__((unused)) void *data)
7006 struct cmd_set_qmap_result *res = parsed_result;
7007 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7009 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7012 cmdline_parse_token_string_t cmd_setqmap_set =
7013 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7015 cmdline_parse_token_string_t cmd_setqmap_qmap =
7016 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7018 cmdline_parse_token_string_t cmd_setqmap_what =
7019 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7021 cmdline_parse_token_num_t cmd_setqmap_portid =
7022 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7024 cmdline_parse_token_num_t cmd_setqmap_queueid =
7025 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7027 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7028 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7031 cmdline_parse_inst_t cmd_set_qmap = {
7032 .f = cmd_set_qmap_parsed,
7034 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7035 "Set statistics mapping value on tx|rx queue_id of port_id",
7037 (void *)&cmd_setqmap_set,
7038 (void *)&cmd_setqmap_qmap,
7039 (void *)&cmd_setqmap_what,
7040 (void *)&cmd_setqmap_portid,
7041 (void *)&cmd_setqmap_queueid,
7042 (void *)&cmd_setqmap_mapvalue,
7047 /* *** CONFIGURE UNICAST HASH TABLE *** */
7048 struct cmd_set_uc_hash_table {
7049 cmdline_fixed_string_t set;
7050 cmdline_fixed_string_t port;
7052 cmdline_fixed_string_t what;
7053 struct ether_addr address;
7054 cmdline_fixed_string_t mode;
7058 cmd_set_uc_hash_parsed(void *parsed_result,
7059 __attribute__((unused)) struct cmdline *cl,
7060 __attribute__((unused)) void *data)
7063 struct cmd_set_uc_hash_table *res = parsed_result;
7065 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7067 if (strcmp(res->what, "uta") == 0)
7068 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7069 &res->address,(uint8_t)is_on);
7071 printf("bad unicast hash table parameter, return code = %d \n", ret);
7075 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7076 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7078 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7079 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7081 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7082 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7084 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7085 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7087 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7088 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7090 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7091 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7094 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7095 .f = cmd_set_uc_hash_parsed,
7097 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7099 (void *)&cmd_set_uc_hash_set,
7100 (void *)&cmd_set_uc_hash_port,
7101 (void *)&cmd_set_uc_hash_portid,
7102 (void *)&cmd_set_uc_hash_what,
7103 (void *)&cmd_set_uc_hash_mac,
7104 (void *)&cmd_set_uc_hash_mode,
7109 struct cmd_set_uc_all_hash_table {
7110 cmdline_fixed_string_t set;
7111 cmdline_fixed_string_t port;
7113 cmdline_fixed_string_t what;
7114 cmdline_fixed_string_t value;
7115 cmdline_fixed_string_t mode;
7119 cmd_set_uc_all_hash_parsed(void *parsed_result,
7120 __attribute__((unused)) struct cmdline *cl,
7121 __attribute__((unused)) void *data)
7124 struct cmd_set_uc_all_hash_table *res = parsed_result;
7126 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7128 if ((strcmp(res->what, "uta") == 0) &&
7129 (strcmp(res->value, "all") == 0))
7130 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7132 printf("bad unicast hash table parameter,"
7133 "return code = %d \n", ret);
7136 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7137 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7139 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7140 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7142 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7143 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7145 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7146 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7148 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7149 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7151 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7152 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7155 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7156 .f = cmd_set_uc_all_hash_parsed,
7158 .help_str = "set port <port_id> uta all on|off",
7160 (void *)&cmd_set_uc_all_hash_set,
7161 (void *)&cmd_set_uc_all_hash_port,
7162 (void *)&cmd_set_uc_all_hash_portid,
7163 (void *)&cmd_set_uc_all_hash_what,
7164 (void *)&cmd_set_uc_all_hash_value,
7165 (void *)&cmd_set_uc_all_hash_mode,
7170 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7171 struct cmd_set_vf_macvlan_filter {
7172 cmdline_fixed_string_t set;
7173 cmdline_fixed_string_t port;
7175 cmdline_fixed_string_t vf;
7177 struct ether_addr address;
7178 cmdline_fixed_string_t filter_type;
7179 cmdline_fixed_string_t mode;
7183 cmd_set_vf_macvlan_parsed(void *parsed_result,
7184 __attribute__((unused)) struct cmdline *cl,
7185 __attribute__((unused)) void *data)
7188 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7189 struct rte_eth_mac_filter filter;
7191 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7193 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7195 /* set VF MAC filter */
7199 filter.dst_id = res->vf_id;
7201 if (!strcmp(res->filter_type, "exact-mac"))
7202 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7203 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7204 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7205 else if (!strcmp(res->filter_type, "hashmac"))
7206 filter.filter_type = RTE_MAC_HASH_MATCH;
7207 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7208 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7210 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7213 ret = rte_eth_dev_filter_ctrl(res->port_id,
7214 RTE_ETH_FILTER_MACVLAN,
7218 ret = rte_eth_dev_filter_ctrl(res->port_id,
7219 RTE_ETH_FILTER_MACVLAN,
7220 RTE_ETH_FILTER_DELETE,
7224 printf("bad set MAC hash parameter, return code = %d\n", ret);
7228 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7229 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7231 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7232 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7234 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7235 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7237 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7238 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7240 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7241 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7243 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7244 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7246 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7247 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7248 filter_type, "exact-mac#exact-mac-vlan"
7249 "#hashmac#hashmac-vlan");
7250 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7251 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7254 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7255 .f = cmd_set_vf_macvlan_parsed,
7257 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7258 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7259 "Exact match rule: exact match of MAC or MAC and VLAN; "
7260 "hash match rule: hash match of MAC and exact match of VLAN",
7262 (void *)&cmd_set_vf_macvlan_set,
7263 (void *)&cmd_set_vf_macvlan_port,
7264 (void *)&cmd_set_vf_macvlan_portid,
7265 (void *)&cmd_set_vf_macvlan_vf,
7266 (void *)&cmd_set_vf_macvlan_vf_id,
7267 (void *)&cmd_set_vf_macvlan_mac,
7268 (void *)&cmd_set_vf_macvlan_filter_type,
7269 (void *)&cmd_set_vf_macvlan_mode,
7274 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7275 struct cmd_set_vf_traffic {
7276 cmdline_fixed_string_t set;
7277 cmdline_fixed_string_t port;
7279 cmdline_fixed_string_t vf;
7281 cmdline_fixed_string_t what;
7282 cmdline_fixed_string_t mode;
7286 cmd_set_vf_traffic_parsed(void *parsed_result,
7287 __attribute__((unused)) struct cmdline *cl,
7288 __attribute__((unused)) void *data)
7290 struct cmd_set_vf_traffic *res = parsed_result;
7291 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7292 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7294 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7297 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7298 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7300 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7301 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7303 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7304 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7306 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7307 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7309 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7310 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7312 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7313 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7315 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7316 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7319 cmdline_parse_inst_t cmd_set_vf_traffic = {
7320 .f = cmd_set_vf_traffic_parsed,
7322 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7324 (void *)&cmd_setvf_traffic_set,
7325 (void *)&cmd_setvf_traffic_port,
7326 (void *)&cmd_setvf_traffic_portid,
7327 (void *)&cmd_setvf_traffic_vf,
7328 (void *)&cmd_setvf_traffic_vfid,
7329 (void *)&cmd_setvf_traffic_what,
7330 (void *)&cmd_setvf_traffic_mode,
7335 /* *** CONFIGURE VF RECEIVE MODE *** */
7336 struct cmd_set_vf_rxmode {
7337 cmdline_fixed_string_t set;
7338 cmdline_fixed_string_t port;
7340 cmdline_fixed_string_t vf;
7342 cmdline_fixed_string_t what;
7343 cmdline_fixed_string_t mode;
7344 cmdline_fixed_string_t on;
7348 cmd_set_vf_rxmode_parsed(void *parsed_result,
7349 __attribute__((unused)) struct cmdline *cl,
7350 __attribute__((unused)) void *data)
7353 uint16_t rx_mode = 0;
7354 struct cmd_set_vf_rxmode *res = parsed_result;
7356 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7357 if (!strcmp(res->what,"rxmode")) {
7358 if (!strcmp(res->mode, "AUPE"))
7359 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7360 else if (!strcmp(res->mode, "ROPE"))
7361 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7362 else if (!strcmp(res->mode, "BAM"))
7363 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7364 else if (!strncmp(res->mode, "MPE",3))
7365 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7368 #ifdef RTE_LIBRTE_IXGBE_PMD
7369 if (ret == -ENOTSUP)
7370 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7371 rx_mode, (uint8_t)is_on);
7373 #ifdef RTE_LIBRTE_BNXT_PMD
7374 if (ret == -ENOTSUP)
7375 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7376 rx_mode, (uint8_t)is_on);
7379 printf("bad VF receive mode parameter, return code = %d \n",
7383 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7384 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7386 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7387 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7389 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7390 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7392 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7393 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7395 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7396 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7398 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7399 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7401 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7402 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7403 mode, "AUPE#ROPE#BAM#MPE");
7404 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7405 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7408 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7409 .f = cmd_set_vf_rxmode_parsed,
7411 .help_str = "set port <port_id> vf <vf_id> rxmode "
7412 "AUPE|ROPE|BAM|MPE on|off",
7414 (void *)&cmd_set_vf_rxmode_set,
7415 (void *)&cmd_set_vf_rxmode_port,
7416 (void *)&cmd_set_vf_rxmode_portid,
7417 (void *)&cmd_set_vf_rxmode_vf,
7418 (void *)&cmd_set_vf_rxmode_vfid,
7419 (void *)&cmd_set_vf_rxmode_what,
7420 (void *)&cmd_set_vf_rxmode_mode,
7421 (void *)&cmd_set_vf_rxmode_on,
7426 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7427 struct cmd_vf_mac_addr_result {
7428 cmdline_fixed_string_t mac_addr_cmd;
7429 cmdline_fixed_string_t what;
7430 cmdline_fixed_string_t port;
7432 cmdline_fixed_string_t vf;
7434 struct ether_addr address;
7437 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7438 __attribute__((unused)) struct cmdline *cl,
7439 __attribute__((unused)) void *data)
7441 struct cmd_vf_mac_addr_result *res = parsed_result;
7444 if (strcmp(res->what, "add") != 0)
7447 #ifdef RTE_LIBRTE_I40E_PMD
7448 if (ret == -ENOTSUP)
7449 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7452 #ifdef RTE_LIBRTE_BNXT_PMD
7453 if (ret == -ENOTSUP)
7454 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7459 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7463 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7464 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7465 mac_addr_cmd,"mac_addr");
7466 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7467 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7469 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7470 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7472 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7473 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7475 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7476 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7478 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7479 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7481 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7482 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7485 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7486 .f = cmd_vf_mac_addr_parsed,
7488 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7489 "Add MAC address filtering for a VF on port_id",
7491 (void *)&cmd_vf_mac_addr_cmd,
7492 (void *)&cmd_vf_mac_addr_what,
7493 (void *)&cmd_vf_mac_addr_port,
7494 (void *)&cmd_vf_mac_addr_portnum,
7495 (void *)&cmd_vf_mac_addr_vf,
7496 (void *)&cmd_vf_mac_addr_vfnum,
7497 (void *)&cmd_vf_mac_addr_addr,
7502 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7503 struct cmd_vf_rx_vlan_filter {
7504 cmdline_fixed_string_t rx_vlan;
7505 cmdline_fixed_string_t what;
7507 cmdline_fixed_string_t port;
7509 cmdline_fixed_string_t vf;
7514 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7515 __attribute__((unused)) struct cmdline *cl,
7516 __attribute__((unused)) void *data)
7518 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7521 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7523 #ifdef RTE_LIBRTE_IXGBE_PMD
7524 if (ret == -ENOTSUP)
7525 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7526 res->vlan_id, res->vf_mask, is_add);
7528 #ifdef RTE_LIBRTE_I40E_PMD
7529 if (ret == -ENOTSUP)
7530 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7531 res->vlan_id, res->vf_mask, is_add);
7533 #ifdef RTE_LIBRTE_BNXT_PMD
7534 if (ret == -ENOTSUP)
7535 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7536 res->vlan_id, res->vf_mask, is_add);
7543 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7544 res->vlan_id, res->vf_mask);
7547 printf("invalid port_id %d\n", res->port_id);
7550 printf("function not implemented or supported\n");
7553 printf("programming error: (%s)\n", strerror(-ret));
7557 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7558 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7559 rx_vlan, "rx_vlan");
7560 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7561 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7563 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7564 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7566 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7567 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7569 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7570 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7572 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7573 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7575 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7576 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7579 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7580 .f = cmd_vf_rx_vlan_filter_parsed,
7582 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7583 "(vf_mask = hexadecimal VF mask)",
7585 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7586 (void *)&cmd_vf_rx_vlan_filter_what,
7587 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7588 (void *)&cmd_vf_rx_vlan_filter_port,
7589 (void *)&cmd_vf_rx_vlan_filter_portid,
7590 (void *)&cmd_vf_rx_vlan_filter_vf,
7591 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7596 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7597 struct cmd_queue_rate_limit_result {
7598 cmdline_fixed_string_t set;
7599 cmdline_fixed_string_t port;
7601 cmdline_fixed_string_t queue;
7603 cmdline_fixed_string_t rate;
7607 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7608 __attribute__((unused)) struct cmdline *cl,
7609 __attribute__((unused)) void *data)
7611 struct cmd_queue_rate_limit_result *res = parsed_result;
7614 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7615 && (strcmp(res->queue, "queue") == 0)
7616 && (strcmp(res->rate, "rate") == 0))
7617 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7620 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7624 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7625 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7627 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7628 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7630 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7631 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7633 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7634 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7636 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7637 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7639 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7640 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7642 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7643 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7646 cmdline_parse_inst_t cmd_queue_rate_limit = {
7647 .f = cmd_queue_rate_limit_parsed,
7649 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7650 "Set rate limit for a queue on port_id",
7652 (void *)&cmd_queue_rate_limit_set,
7653 (void *)&cmd_queue_rate_limit_port,
7654 (void *)&cmd_queue_rate_limit_portnum,
7655 (void *)&cmd_queue_rate_limit_queue,
7656 (void *)&cmd_queue_rate_limit_queuenum,
7657 (void *)&cmd_queue_rate_limit_rate,
7658 (void *)&cmd_queue_rate_limit_ratenum,
7663 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7664 struct cmd_vf_rate_limit_result {
7665 cmdline_fixed_string_t set;
7666 cmdline_fixed_string_t port;
7668 cmdline_fixed_string_t vf;
7670 cmdline_fixed_string_t rate;
7672 cmdline_fixed_string_t q_msk;
7676 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7677 __attribute__((unused)) struct cmdline *cl,
7678 __attribute__((unused)) void *data)
7680 struct cmd_vf_rate_limit_result *res = parsed_result;
7683 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7684 && (strcmp(res->vf, "vf") == 0)
7685 && (strcmp(res->rate, "rate") == 0)
7686 && (strcmp(res->q_msk, "queue_mask") == 0))
7687 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7688 res->rate_num, res->q_msk_val);
7690 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7694 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7695 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7697 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7698 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7700 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7701 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7703 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7704 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7706 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7707 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7709 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7710 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7712 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7713 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7715 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7716 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7717 q_msk, "queue_mask");
7718 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7719 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7722 cmdline_parse_inst_t cmd_vf_rate_limit = {
7723 .f = cmd_vf_rate_limit_parsed,
7725 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7726 "queue_mask <queue_mask_value>: "
7727 "Set rate limit for queues of VF on port_id",
7729 (void *)&cmd_vf_rate_limit_set,
7730 (void *)&cmd_vf_rate_limit_port,
7731 (void *)&cmd_vf_rate_limit_portnum,
7732 (void *)&cmd_vf_rate_limit_vf,
7733 (void *)&cmd_vf_rate_limit_vfnum,
7734 (void *)&cmd_vf_rate_limit_rate,
7735 (void *)&cmd_vf_rate_limit_ratenum,
7736 (void *)&cmd_vf_rate_limit_q_msk,
7737 (void *)&cmd_vf_rate_limit_q_msk_val,
7742 /* *** ADD TUNNEL FILTER OF A PORT *** */
7743 struct cmd_tunnel_filter_result {
7744 cmdline_fixed_string_t cmd;
7745 cmdline_fixed_string_t what;
7747 struct ether_addr outer_mac;
7748 struct ether_addr inner_mac;
7749 cmdline_ipaddr_t ip_value;
7750 uint16_t inner_vlan;
7751 cmdline_fixed_string_t tunnel_type;
7752 cmdline_fixed_string_t filter_type;
7758 cmd_tunnel_filter_parsed(void *parsed_result,
7759 __attribute__((unused)) struct cmdline *cl,
7760 __attribute__((unused)) void *data)
7762 struct cmd_tunnel_filter_result *res = parsed_result;
7763 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7766 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7768 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7769 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7770 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7772 if (res->ip_value.family == AF_INET) {
7773 tunnel_filter_conf.ip_addr.ipv4_addr =
7774 res->ip_value.addr.ipv4.s_addr;
7775 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7777 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7778 &(res->ip_value.addr.ipv6),
7779 sizeof(struct in6_addr));
7780 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7783 if (!strcmp(res->filter_type, "imac-ivlan"))
7784 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7785 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7786 tunnel_filter_conf.filter_type =
7787 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7788 else if (!strcmp(res->filter_type, "imac-tenid"))
7789 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7790 else if (!strcmp(res->filter_type, "imac"))
7791 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7792 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7793 tunnel_filter_conf.filter_type =
7794 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7795 else if (!strcmp(res->filter_type, "oip"))
7796 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7797 else if (!strcmp(res->filter_type, "iip"))
7798 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7800 printf("The filter type is not supported");
7804 if (!strcmp(res->tunnel_type, "vxlan"))
7805 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7806 else if (!strcmp(res->tunnel_type, "nvgre"))
7807 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7808 else if (!strcmp(res->tunnel_type, "ipingre"))
7809 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7811 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7815 tunnel_filter_conf.tenant_id = res->tenant_id;
7816 tunnel_filter_conf.queue_id = res->queue_num;
7817 if (!strcmp(res->what, "add"))
7818 ret = rte_eth_dev_filter_ctrl(res->port_id,
7819 RTE_ETH_FILTER_TUNNEL,
7821 &tunnel_filter_conf);
7823 ret = rte_eth_dev_filter_ctrl(res->port_id,
7824 RTE_ETH_FILTER_TUNNEL,
7825 RTE_ETH_FILTER_DELETE,
7826 &tunnel_filter_conf);
7828 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7832 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7833 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7834 cmd, "tunnel_filter");
7835 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7836 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7838 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7839 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7841 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7842 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7844 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7845 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7847 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7848 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7849 inner_vlan, UINT16);
7850 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7851 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7853 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7854 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7855 tunnel_type, "vxlan#nvgre#ipingre");
7857 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7858 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7859 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7860 "imac#omac-imac-tenid");
7861 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7862 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7864 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7865 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7868 cmdline_parse_inst_t cmd_tunnel_filter = {
7869 .f = cmd_tunnel_filter_parsed,
7871 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7872 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7873 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7874 "<queue_id>: Add/Rm tunnel filter of a port",
7876 (void *)&cmd_tunnel_filter_cmd,
7877 (void *)&cmd_tunnel_filter_what,
7878 (void *)&cmd_tunnel_filter_port_id,
7879 (void *)&cmd_tunnel_filter_outer_mac,
7880 (void *)&cmd_tunnel_filter_inner_mac,
7881 (void *)&cmd_tunnel_filter_ip_value,
7882 (void *)&cmd_tunnel_filter_innner_vlan,
7883 (void *)&cmd_tunnel_filter_tunnel_type,
7884 (void *)&cmd_tunnel_filter_filter_type,
7885 (void *)&cmd_tunnel_filter_tenant_id,
7886 (void *)&cmd_tunnel_filter_queue_num,
7891 /* *** CONFIGURE TUNNEL UDP PORT *** */
7892 struct cmd_tunnel_udp_config {
7893 cmdline_fixed_string_t cmd;
7894 cmdline_fixed_string_t what;
7900 cmd_tunnel_udp_config_parsed(void *parsed_result,
7901 __attribute__((unused)) struct cmdline *cl,
7902 __attribute__((unused)) void *data)
7904 struct cmd_tunnel_udp_config *res = parsed_result;
7905 struct rte_eth_udp_tunnel tunnel_udp;
7908 tunnel_udp.udp_port = res->udp_port;
7910 if (!strcmp(res->cmd, "rx_vxlan_port"))
7911 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7913 if (!strcmp(res->what, "add"))
7914 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7917 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7921 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7924 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7925 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7926 cmd, "rx_vxlan_port");
7927 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7928 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7930 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7931 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7933 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7934 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7937 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7938 .f = cmd_tunnel_udp_config_parsed,
7940 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7941 "Add/Remove a tunneling UDP port filter",
7943 (void *)&cmd_tunnel_udp_config_cmd,
7944 (void *)&cmd_tunnel_udp_config_what,
7945 (void *)&cmd_tunnel_udp_config_udp_port,
7946 (void *)&cmd_tunnel_udp_config_port_id,
7951 /* *** GLOBAL CONFIG *** */
7952 struct cmd_global_config_result {
7953 cmdline_fixed_string_t cmd;
7955 cmdline_fixed_string_t cfg_type;
7960 cmd_global_config_parsed(void *parsed_result,
7961 __attribute__((unused)) struct cmdline *cl,
7962 __attribute__((unused)) void *data)
7964 struct cmd_global_config_result *res = parsed_result;
7965 struct rte_eth_global_cfg conf;
7968 memset(&conf, 0, sizeof(conf));
7969 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7970 conf.cfg.gre_key_len = res->len;
7971 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7972 RTE_ETH_FILTER_SET, &conf);
7974 printf("Global config error\n");
7977 cmdline_parse_token_string_t cmd_global_config_cmd =
7978 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7980 cmdline_parse_token_num_t cmd_global_config_port_id =
7981 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7982 cmdline_parse_token_string_t cmd_global_config_type =
7983 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7984 cfg_type, "gre-key-len");
7985 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7986 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7989 cmdline_parse_inst_t cmd_global_config = {
7990 .f = cmd_global_config_parsed,
7991 .data = (void *)NULL,
7992 .help_str = "global_config <port_id> gre-key-len <key_len>",
7994 (void *)&cmd_global_config_cmd,
7995 (void *)&cmd_global_config_port_id,
7996 (void *)&cmd_global_config_type,
7997 (void *)&cmd_global_config_gre_key_len,
8002 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8003 struct cmd_set_mirror_mask_result {
8004 cmdline_fixed_string_t set;
8005 cmdline_fixed_string_t port;
8007 cmdline_fixed_string_t mirror;
8009 cmdline_fixed_string_t what;
8010 cmdline_fixed_string_t value;
8011 cmdline_fixed_string_t dstpool;
8013 cmdline_fixed_string_t on;
8016 cmdline_parse_token_string_t cmd_mirror_mask_set =
8017 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8019 cmdline_parse_token_string_t cmd_mirror_mask_port =
8020 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8022 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8023 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8025 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8026 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8027 mirror, "mirror-rule");
8028 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8029 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8031 cmdline_parse_token_string_t cmd_mirror_mask_what =
8032 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8033 what, "pool-mirror-up#pool-mirror-down"
8035 cmdline_parse_token_string_t cmd_mirror_mask_value =
8036 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8038 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8039 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8040 dstpool, "dst-pool");
8041 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8042 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8044 cmdline_parse_token_string_t cmd_mirror_mask_on =
8045 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8049 cmd_set_mirror_mask_parsed(void *parsed_result,
8050 __attribute__((unused)) struct cmdline *cl,
8051 __attribute__((unused)) void *data)
8054 struct cmd_set_mirror_mask_result *res = parsed_result;
8055 struct rte_eth_mirror_conf mr_conf;
8057 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8059 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8061 mr_conf.dst_pool = res->dstpool_id;
8063 if (!strcmp(res->what, "pool-mirror-up")) {
8064 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8065 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8066 } else if (!strcmp(res->what, "pool-mirror-down")) {
8067 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8068 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8069 } else if (!strcmp(res->what, "vlan-mirror")) {
8070 mr_conf.rule_type = ETH_MIRROR_VLAN;
8071 nb_item = parse_item_list(res->value, "vlan",
8072 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8076 for (i = 0; i < nb_item; i++) {
8077 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8078 printf("Invalid vlan_id: must be < 4096\n");
8082 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8083 mr_conf.vlan.vlan_mask |= 1ULL << i;
8087 if (!strcmp(res->on, "on"))
8088 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8091 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8094 printf("mirror rule add error: (%s)\n", strerror(-ret));
8097 cmdline_parse_inst_t cmd_set_mirror_mask = {
8098 .f = cmd_set_mirror_mask_parsed,
8100 .help_str = "set port <port_id> mirror-rule <rule_id> "
8101 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8102 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8104 (void *)&cmd_mirror_mask_set,
8105 (void *)&cmd_mirror_mask_port,
8106 (void *)&cmd_mirror_mask_portid,
8107 (void *)&cmd_mirror_mask_mirror,
8108 (void *)&cmd_mirror_mask_ruleid,
8109 (void *)&cmd_mirror_mask_what,
8110 (void *)&cmd_mirror_mask_value,
8111 (void *)&cmd_mirror_mask_dstpool,
8112 (void *)&cmd_mirror_mask_poolid,
8113 (void *)&cmd_mirror_mask_on,
8118 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8119 struct cmd_set_mirror_link_result {
8120 cmdline_fixed_string_t set;
8121 cmdline_fixed_string_t port;
8123 cmdline_fixed_string_t mirror;
8125 cmdline_fixed_string_t what;
8126 cmdline_fixed_string_t dstpool;
8128 cmdline_fixed_string_t on;
8131 cmdline_parse_token_string_t cmd_mirror_link_set =
8132 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8134 cmdline_parse_token_string_t cmd_mirror_link_port =
8135 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8137 cmdline_parse_token_num_t cmd_mirror_link_portid =
8138 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8140 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8141 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8142 mirror, "mirror-rule");
8143 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8144 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8146 cmdline_parse_token_string_t cmd_mirror_link_what =
8147 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8148 what, "uplink-mirror#downlink-mirror");
8149 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8150 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8151 dstpool, "dst-pool");
8152 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8153 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8155 cmdline_parse_token_string_t cmd_mirror_link_on =
8156 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8160 cmd_set_mirror_link_parsed(void *parsed_result,
8161 __attribute__((unused)) struct cmdline *cl,
8162 __attribute__((unused)) void *data)
8165 struct cmd_set_mirror_link_result *res = parsed_result;
8166 struct rte_eth_mirror_conf mr_conf;
8168 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8169 if (!strcmp(res->what, "uplink-mirror"))
8170 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8172 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8174 mr_conf.dst_pool = res->dstpool_id;
8176 if (!strcmp(res->on, "on"))
8177 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8180 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8183 /* check the return value and print it if is < 0 */
8185 printf("mirror rule add error: (%s)\n", strerror(-ret));
8189 cmdline_parse_inst_t cmd_set_mirror_link = {
8190 .f = cmd_set_mirror_link_parsed,
8192 .help_str = "set port <port_id> mirror-rule <rule_id> "
8193 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8195 (void *)&cmd_mirror_link_set,
8196 (void *)&cmd_mirror_link_port,
8197 (void *)&cmd_mirror_link_portid,
8198 (void *)&cmd_mirror_link_mirror,
8199 (void *)&cmd_mirror_link_ruleid,
8200 (void *)&cmd_mirror_link_what,
8201 (void *)&cmd_mirror_link_dstpool,
8202 (void *)&cmd_mirror_link_poolid,
8203 (void *)&cmd_mirror_link_on,
8208 /* *** RESET VM MIRROR RULE *** */
8209 struct cmd_rm_mirror_rule_result {
8210 cmdline_fixed_string_t reset;
8211 cmdline_fixed_string_t port;
8213 cmdline_fixed_string_t mirror;
8217 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8218 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8220 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8221 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8223 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8224 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8226 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8227 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8228 mirror, "mirror-rule");
8229 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8230 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8234 cmd_reset_mirror_rule_parsed(void *parsed_result,
8235 __attribute__((unused)) struct cmdline *cl,
8236 __attribute__((unused)) void *data)
8239 struct cmd_set_mirror_link_result *res = parsed_result;
8241 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8243 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8246 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8247 .f = cmd_reset_mirror_rule_parsed,
8249 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8251 (void *)&cmd_rm_mirror_rule_reset,
8252 (void *)&cmd_rm_mirror_rule_port,
8253 (void *)&cmd_rm_mirror_rule_portid,
8254 (void *)&cmd_rm_mirror_rule_mirror,
8255 (void *)&cmd_rm_mirror_rule_ruleid,
8260 /* ******************************************************************************** */
8262 struct cmd_dump_result {
8263 cmdline_fixed_string_t dump;
8267 dump_struct_sizes(void)
8269 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8270 DUMP_SIZE(struct rte_mbuf);
8271 DUMP_SIZE(struct rte_mempool);
8272 DUMP_SIZE(struct rte_ring);
8276 static void cmd_dump_parsed(void *parsed_result,
8277 __attribute__((unused)) struct cmdline *cl,
8278 __attribute__((unused)) void *data)
8280 struct cmd_dump_result *res = parsed_result;
8282 if (!strcmp(res->dump, "dump_physmem"))
8283 rte_dump_physmem_layout(stdout);
8284 else if (!strcmp(res->dump, "dump_memzone"))
8285 rte_memzone_dump(stdout);
8286 else if (!strcmp(res->dump, "dump_struct_sizes"))
8287 dump_struct_sizes();
8288 else if (!strcmp(res->dump, "dump_ring"))
8289 rte_ring_list_dump(stdout);
8290 else if (!strcmp(res->dump, "dump_mempool"))
8291 rte_mempool_list_dump(stdout);
8292 else if (!strcmp(res->dump, "dump_devargs"))
8293 rte_eal_devargs_dump(stdout);
8294 else if (!strcmp(res->dump, "dump_log_types"))
8295 rte_log_dump(stdout);
8298 cmdline_parse_token_string_t cmd_dump_dump =
8299 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8302 "dump_struct_sizes#"
8308 cmdline_parse_inst_t cmd_dump = {
8309 .f = cmd_dump_parsed, /* function to call */
8310 .data = NULL, /* 2nd arg of func */
8311 .help_str = "Dump status",
8312 .tokens = { /* token list, NULL terminated */
8313 (void *)&cmd_dump_dump,
8318 /* ******************************************************************************** */
8320 struct cmd_dump_one_result {
8321 cmdline_fixed_string_t dump;
8322 cmdline_fixed_string_t name;
8325 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8326 __attribute__((unused)) void *data)
8328 struct cmd_dump_one_result *res = parsed_result;
8330 if (!strcmp(res->dump, "dump_ring")) {
8332 r = rte_ring_lookup(res->name);
8334 cmdline_printf(cl, "Cannot find ring\n");
8337 rte_ring_dump(stdout, r);
8338 } else if (!strcmp(res->dump, "dump_mempool")) {
8339 struct rte_mempool *mp;
8340 mp = rte_mempool_lookup(res->name);
8342 cmdline_printf(cl, "Cannot find mempool\n");
8345 rte_mempool_dump(stdout, mp);
8349 cmdline_parse_token_string_t cmd_dump_one_dump =
8350 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8351 "dump_ring#dump_mempool");
8353 cmdline_parse_token_string_t cmd_dump_one_name =
8354 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8356 cmdline_parse_inst_t cmd_dump_one = {
8357 .f = cmd_dump_one_parsed, /* function to call */
8358 .data = NULL, /* 2nd arg of func */
8359 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8360 .tokens = { /* token list, NULL terminated */
8361 (void *)&cmd_dump_one_dump,
8362 (void *)&cmd_dump_one_name,
8367 /* *** Add/Del syn filter *** */
8368 struct cmd_syn_filter_result {
8369 cmdline_fixed_string_t filter;
8371 cmdline_fixed_string_t ops;
8372 cmdline_fixed_string_t priority;
8373 cmdline_fixed_string_t high;
8374 cmdline_fixed_string_t queue;
8379 cmd_syn_filter_parsed(void *parsed_result,
8380 __attribute__((unused)) struct cmdline *cl,
8381 __attribute__((unused)) void *data)
8383 struct cmd_syn_filter_result *res = parsed_result;
8384 struct rte_eth_syn_filter syn_filter;
8387 ret = rte_eth_dev_filter_supported(res->port_id,
8388 RTE_ETH_FILTER_SYN);
8390 printf("syn filter is not supported on port %u.\n",
8395 memset(&syn_filter, 0, sizeof(syn_filter));
8397 if (!strcmp(res->ops, "add")) {
8398 if (!strcmp(res->high, "high"))
8399 syn_filter.hig_pri = 1;
8401 syn_filter.hig_pri = 0;
8403 syn_filter.queue = res->queue_id;
8404 ret = rte_eth_dev_filter_ctrl(res->port_id,
8409 ret = rte_eth_dev_filter_ctrl(res->port_id,
8411 RTE_ETH_FILTER_DELETE,
8415 printf("syn filter programming error: (%s)\n",
8419 cmdline_parse_token_string_t cmd_syn_filter_filter =
8420 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8421 filter, "syn_filter");
8422 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8423 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8425 cmdline_parse_token_string_t cmd_syn_filter_ops =
8426 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8428 cmdline_parse_token_string_t cmd_syn_filter_priority =
8429 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8430 priority, "priority");
8431 cmdline_parse_token_string_t cmd_syn_filter_high =
8432 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8434 cmdline_parse_token_string_t cmd_syn_filter_queue =
8435 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8437 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8438 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8441 cmdline_parse_inst_t cmd_syn_filter = {
8442 .f = cmd_syn_filter_parsed,
8444 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8445 "<queue_id>: Add/Delete syn filter",
8447 (void *)&cmd_syn_filter_filter,
8448 (void *)&cmd_syn_filter_port_id,
8449 (void *)&cmd_syn_filter_ops,
8450 (void *)&cmd_syn_filter_priority,
8451 (void *)&cmd_syn_filter_high,
8452 (void *)&cmd_syn_filter_queue,
8453 (void *)&cmd_syn_filter_queue_id,
8458 /* *** ADD/REMOVE A 2tuple FILTER *** */
8459 struct cmd_2tuple_filter_result {
8460 cmdline_fixed_string_t filter;
8462 cmdline_fixed_string_t ops;
8463 cmdline_fixed_string_t dst_port;
8464 uint16_t dst_port_value;
8465 cmdline_fixed_string_t protocol;
8466 uint8_t protocol_value;
8467 cmdline_fixed_string_t mask;
8469 cmdline_fixed_string_t tcp_flags;
8470 uint8_t tcp_flags_value;
8471 cmdline_fixed_string_t priority;
8472 uint8_t priority_value;
8473 cmdline_fixed_string_t queue;
8478 cmd_2tuple_filter_parsed(void *parsed_result,
8479 __attribute__((unused)) struct cmdline *cl,
8480 __attribute__((unused)) void *data)
8482 struct rte_eth_ntuple_filter filter;
8483 struct cmd_2tuple_filter_result *res = parsed_result;
8486 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8488 printf("ntuple filter is not supported on port %u.\n",
8493 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8495 filter.flags = RTE_2TUPLE_FLAGS;
8496 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8497 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8498 filter.proto = res->protocol_value;
8499 filter.priority = res->priority_value;
8500 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8501 printf("nonzero tcp_flags is only meaningful"
8502 " when protocol is TCP.\n");
8505 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8506 printf("invalid TCP flags.\n");
8510 if (res->tcp_flags_value != 0) {
8511 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8512 filter.tcp_flags = res->tcp_flags_value;
8515 /* need convert to big endian. */
8516 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8517 filter.queue = res->queue_id;
8519 if (!strcmp(res->ops, "add"))
8520 ret = rte_eth_dev_filter_ctrl(res->port_id,
8521 RTE_ETH_FILTER_NTUPLE,
8525 ret = rte_eth_dev_filter_ctrl(res->port_id,
8526 RTE_ETH_FILTER_NTUPLE,
8527 RTE_ETH_FILTER_DELETE,
8530 printf("2tuple filter programming error: (%s)\n",
8535 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
8536 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8537 filter, "2tuple_filter");
8538 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
8539 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8541 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
8542 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8544 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
8545 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8546 dst_port, "dst_port");
8547 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
8548 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8549 dst_port_value, UINT16);
8550 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
8551 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8552 protocol, "protocol");
8553 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
8554 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8555 protocol_value, UINT8);
8556 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8557 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8559 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8560 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8562 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8563 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8564 tcp_flags, "tcp_flags");
8565 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8566 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8567 tcp_flags_value, UINT8);
8568 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8569 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8570 priority, "priority");
8571 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8572 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8573 priority_value, UINT8);
8574 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8575 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8577 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8578 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8581 cmdline_parse_inst_t cmd_2tuple_filter = {
8582 .f = cmd_2tuple_filter_parsed,
8584 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8585 "<value> mask <value> tcp_flags <value> priority <value> queue "
8586 "<queue_id>: Add a 2tuple filter",
8588 (void *)&cmd_2tuple_filter_filter,
8589 (void *)&cmd_2tuple_filter_port_id,
8590 (void *)&cmd_2tuple_filter_ops,
8591 (void *)&cmd_2tuple_filter_dst_port,
8592 (void *)&cmd_2tuple_filter_dst_port_value,
8593 (void *)&cmd_2tuple_filter_protocol,
8594 (void *)&cmd_2tuple_filter_protocol_value,
8595 (void *)&cmd_2tuple_filter_mask,
8596 (void *)&cmd_2tuple_filter_mask_value,
8597 (void *)&cmd_2tuple_filter_tcp_flags,
8598 (void *)&cmd_2tuple_filter_tcp_flags_value,
8599 (void *)&cmd_2tuple_filter_priority,
8600 (void *)&cmd_2tuple_filter_priority_value,
8601 (void *)&cmd_2tuple_filter_queue,
8602 (void *)&cmd_2tuple_filter_queue_id,
8607 /* *** ADD/REMOVE A 5tuple FILTER *** */
8608 struct cmd_5tuple_filter_result {
8609 cmdline_fixed_string_t filter;
8611 cmdline_fixed_string_t ops;
8612 cmdline_fixed_string_t dst_ip;
8613 cmdline_ipaddr_t dst_ip_value;
8614 cmdline_fixed_string_t src_ip;
8615 cmdline_ipaddr_t src_ip_value;
8616 cmdline_fixed_string_t dst_port;
8617 uint16_t dst_port_value;
8618 cmdline_fixed_string_t src_port;
8619 uint16_t src_port_value;
8620 cmdline_fixed_string_t protocol;
8621 uint8_t protocol_value;
8622 cmdline_fixed_string_t mask;
8624 cmdline_fixed_string_t tcp_flags;
8625 uint8_t tcp_flags_value;
8626 cmdline_fixed_string_t priority;
8627 uint8_t priority_value;
8628 cmdline_fixed_string_t queue;
8633 cmd_5tuple_filter_parsed(void *parsed_result,
8634 __attribute__((unused)) struct cmdline *cl,
8635 __attribute__((unused)) void *data)
8637 struct rte_eth_ntuple_filter filter;
8638 struct cmd_5tuple_filter_result *res = parsed_result;
8641 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8643 printf("ntuple filter is not supported on port %u.\n",
8648 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8650 filter.flags = RTE_5TUPLE_FLAGS;
8651 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8652 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8653 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8654 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8655 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8656 filter.proto = res->protocol_value;
8657 filter.priority = res->priority_value;
8658 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8659 printf("nonzero tcp_flags is only meaningful"
8660 " when protocol is TCP.\n");
8663 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8664 printf("invalid TCP flags.\n");
8668 if (res->tcp_flags_value != 0) {
8669 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8670 filter.tcp_flags = res->tcp_flags_value;
8673 if (res->dst_ip_value.family == AF_INET)
8674 /* no need to convert, already big endian. */
8675 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8677 if (filter.dst_ip_mask == 0) {
8678 printf("can not support ipv6 involved compare.\n");
8684 if (res->src_ip_value.family == AF_INET)
8685 /* no need to convert, already big endian. */
8686 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8688 if (filter.src_ip_mask == 0) {
8689 printf("can not support ipv6 involved compare.\n");
8694 /* need convert to big endian. */
8695 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8696 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8697 filter.queue = res->queue_id;
8699 if (!strcmp(res->ops, "add"))
8700 ret = rte_eth_dev_filter_ctrl(res->port_id,
8701 RTE_ETH_FILTER_NTUPLE,
8705 ret = rte_eth_dev_filter_ctrl(res->port_id,
8706 RTE_ETH_FILTER_NTUPLE,
8707 RTE_ETH_FILTER_DELETE,
8710 printf("5tuple filter programming error: (%s)\n",
8714 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8715 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8716 filter, "5tuple_filter");
8717 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8718 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8720 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8721 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8723 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8724 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8726 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8727 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8729 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8730 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8732 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8733 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8735 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8736 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8737 dst_port, "dst_port");
8738 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8739 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8740 dst_port_value, UINT16);
8741 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8742 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8743 src_port, "src_port");
8744 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8745 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8746 src_port_value, UINT16);
8747 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8748 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8749 protocol, "protocol");
8750 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8751 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8752 protocol_value, UINT8);
8753 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8754 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8756 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8757 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8759 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8760 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8761 tcp_flags, "tcp_flags");
8762 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8763 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8764 tcp_flags_value, UINT8);
8765 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8766 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8767 priority, "priority");
8768 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8769 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8770 priority_value, UINT8);
8771 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8772 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8774 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8775 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8778 cmdline_parse_inst_t cmd_5tuple_filter = {
8779 .f = cmd_5tuple_filter_parsed,
8781 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8782 "src_ip <value> dst_port <value> src_port <value> "
8783 "protocol <value> mask <value> tcp_flags <value> "
8784 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8786 (void *)&cmd_5tuple_filter_filter,
8787 (void *)&cmd_5tuple_filter_port_id,
8788 (void *)&cmd_5tuple_filter_ops,
8789 (void *)&cmd_5tuple_filter_dst_ip,
8790 (void *)&cmd_5tuple_filter_dst_ip_value,
8791 (void *)&cmd_5tuple_filter_src_ip,
8792 (void *)&cmd_5tuple_filter_src_ip_value,
8793 (void *)&cmd_5tuple_filter_dst_port,
8794 (void *)&cmd_5tuple_filter_dst_port_value,
8795 (void *)&cmd_5tuple_filter_src_port,
8796 (void *)&cmd_5tuple_filter_src_port_value,
8797 (void *)&cmd_5tuple_filter_protocol,
8798 (void *)&cmd_5tuple_filter_protocol_value,
8799 (void *)&cmd_5tuple_filter_mask,
8800 (void *)&cmd_5tuple_filter_mask_value,
8801 (void *)&cmd_5tuple_filter_tcp_flags,
8802 (void *)&cmd_5tuple_filter_tcp_flags_value,
8803 (void *)&cmd_5tuple_filter_priority,
8804 (void *)&cmd_5tuple_filter_priority_value,
8805 (void *)&cmd_5tuple_filter_queue,
8806 (void *)&cmd_5tuple_filter_queue_id,
8811 /* *** ADD/REMOVE A flex FILTER *** */
8812 struct cmd_flex_filter_result {
8813 cmdline_fixed_string_t filter;
8814 cmdline_fixed_string_t ops;
8816 cmdline_fixed_string_t len;
8818 cmdline_fixed_string_t bytes;
8819 cmdline_fixed_string_t bytes_value;
8820 cmdline_fixed_string_t mask;
8821 cmdline_fixed_string_t mask_value;
8822 cmdline_fixed_string_t priority;
8823 uint8_t priority_value;
8824 cmdline_fixed_string_t queue;
8828 static int xdigit2val(unsigned char c)
8833 else if (isupper(c))
8841 cmd_flex_filter_parsed(void *parsed_result,
8842 __attribute__((unused)) struct cmdline *cl,
8843 __attribute__((unused)) void *data)
8846 struct rte_eth_flex_filter filter;
8847 struct cmd_flex_filter_result *res = parsed_result;
8848 char *bytes_ptr, *mask_ptr;
8849 uint16_t len, i, j = 0;
8854 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8855 printf("the len exceed the max length 128\n");
8858 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8859 filter.len = res->len_value;
8860 filter.priority = res->priority_value;
8861 filter.queue = res->queue_id;
8862 bytes_ptr = res->bytes_value;
8863 mask_ptr = res->mask_value;
8865 /* translate bytes string to array. */
8866 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8867 (bytes_ptr[1] == 'X')))
8869 len = strnlen(bytes_ptr, res->len_value * 2);
8870 if (len == 0 || (len % 8 != 0)) {
8871 printf("please check len and bytes input\n");
8874 for (i = 0; i < len; i++) {
8876 if (isxdigit(c) == 0) {
8877 /* invalid characters. */
8878 printf("invalid input\n");
8881 val = xdigit2val(c);
8884 filter.bytes[j] = byte;
8885 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8892 /* translate mask string to uint8_t array. */
8893 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8894 (mask_ptr[1] == 'X')))
8896 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8898 printf("invalid input\n");
8903 for (i = 0; i < len; i++) {
8905 if (isxdigit(c) == 0) {
8906 /* invalid characters. */
8907 printf("invalid input\n");
8910 val = xdigit2val(c);
8913 filter.mask[j] = byte;
8914 printf("mask[%d]:%02x ", j, filter.mask[j]);
8922 if (!strcmp(res->ops, "add"))
8923 ret = rte_eth_dev_filter_ctrl(res->port_id,
8924 RTE_ETH_FILTER_FLEXIBLE,
8928 ret = rte_eth_dev_filter_ctrl(res->port_id,
8929 RTE_ETH_FILTER_FLEXIBLE,
8930 RTE_ETH_FILTER_DELETE,
8934 printf("flex filter setting error: (%s)\n", strerror(-ret));
8937 cmdline_parse_token_string_t cmd_flex_filter_filter =
8938 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8939 filter, "flex_filter");
8940 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8941 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8943 cmdline_parse_token_string_t cmd_flex_filter_ops =
8944 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8946 cmdline_parse_token_string_t cmd_flex_filter_len =
8947 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8949 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8950 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8952 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8953 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8955 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8956 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8958 cmdline_parse_token_string_t cmd_flex_filter_mask =
8959 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8961 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8962 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8964 cmdline_parse_token_string_t cmd_flex_filter_priority =
8965 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8966 priority, "priority");
8967 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8968 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8969 priority_value, UINT8);
8970 cmdline_parse_token_string_t cmd_flex_filter_queue =
8971 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8973 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8974 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8976 cmdline_parse_inst_t cmd_flex_filter = {
8977 .f = cmd_flex_filter_parsed,
8979 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8980 "<value> mask <value> priority <value> queue <queue_id>: "
8981 "Add/Del a flex filter",
8983 (void *)&cmd_flex_filter_filter,
8984 (void *)&cmd_flex_filter_port_id,
8985 (void *)&cmd_flex_filter_ops,
8986 (void *)&cmd_flex_filter_len,
8987 (void *)&cmd_flex_filter_len_value,
8988 (void *)&cmd_flex_filter_bytes,
8989 (void *)&cmd_flex_filter_bytes_value,
8990 (void *)&cmd_flex_filter_mask,
8991 (void *)&cmd_flex_filter_mask_value,
8992 (void *)&cmd_flex_filter_priority,
8993 (void *)&cmd_flex_filter_priority_value,
8994 (void *)&cmd_flex_filter_queue,
8995 (void *)&cmd_flex_filter_queue_id,
9000 /* *** Filters Control *** */
9002 /* *** deal with ethertype filter *** */
9003 struct cmd_ethertype_filter_result {
9004 cmdline_fixed_string_t filter;
9006 cmdline_fixed_string_t ops;
9007 cmdline_fixed_string_t mac;
9008 struct ether_addr mac_addr;
9009 cmdline_fixed_string_t ethertype;
9010 uint16_t ethertype_value;
9011 cmdline_fixed_string_t drop;
9012 cmdline_fixed_string_t queue;
9016 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9017 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9018 filter, "ethertype_filter");
9019 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9020 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9022 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9023 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9025 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9026 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9027 mac, "mac_addr#mac_ignr");
9028 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9029 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9031 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9032 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9033 ethertype, "ethertype");
9034 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9035 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9036 ethertype_value, UINT16);
9037 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9038 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9040 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9041 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9043 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9044 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9048 cmd_ethertype_filter_parsed(void *parsed_result,
9049 __attribute__((unused)) struct cmdline *cl,
9050 __attribute__((unused)) void *data)
9052 struct cmd_ethertype_filter_result *res = parsed_result;
9053 struct rte_eth_ethertype_filter filter;
9056 ret = rte_eth_dev_filter_supported(res->port_id,
9057 RTE_ETH_FILTER_ETHERTYPE);
9059 printf("ethertype filter is not supported on port %u.\n",
9064 memset(&filter, 0, sizeof(filter));
9065 if (!strcmp(res->mac, "mac_addr")) {
9066 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9067 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9068 sizeof(struct ether_addr));
9070 if (!strcmp(res->drop, "drop"))
9071 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9072 filter.ether_type = res->ethertype_value;
9073 filter.queue = res->queue_id;
9075 if (!strcmp(res->ops, "add"))
9076 ret = rte_eth_dev_filter_ctrl(res->port_id,
9077 RTE_ETH_FILTER_ETHERTYPE,
9081 ret = rte_eth_dev_filter_ctrl(res->port_id,
9082 RTE_ETH_FILTER_ETHERTYPE,
9083 RTE_ETH_FILTER_DELETE,
9086 printf("ethertype filter programming error: (%s)\n",
9090 cmdline_parse_inst_t cmd_ethertype_filter = {
9091 .f = cmd_ethertype_filter_parsed,
9093 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9094 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9095 "Add or delete an ethertype filter entry",
9097 (void *)&cmd_ethertype_filter_filter,
9098 (void *)&cmd_ethertype_filter_port_id,
9099 (void *)&cmd_ethertype_filter_ops,
9100 (void *)&cmd_ethertype_filter_mac,
9101 (void *)&cmd_ethertype_filter_mac_addr,
9102 (void *)&cmd_ethertype_filter_ethertype,
9103 (void *)&cmd_ethertype_filter_ethertype_value,
9104 (void *)&cmd_ethertype_filter_drop,
9105 (void *)&cmd_ethertype_filter_queue,
9106 (void *)&cmd_ethertype_filter_queue_id,
9111 /* *** deal with flow director filter *** */
9112 struct cmd_flow_director_result {
9113 cmdline_fixed_string_t flow_director_filter;
9115 cmdline_fixed_string_t mode;
9116 cmdline_fixed_string_t mode_value;
9117 cmdline_fixed_string_t ops;
9118 cmdline_fixed_string_t flow;
9119 cmdline_fixed_string_t flow_type;
9120 cmdline_fixed_string_t ether;
9121 uint16_t ether_type;
9122 cmdline_fixed_string_t src;
9123 cmdline_ipaddr_t ip_src;
9125 cmdline_fixed_string_t dst;
9126 cmdline_ipaddr_t ip_dst;
9128 cmdline_fixed_string_t verify_tag;
9129 uint32_t verify_tag_value;
9130 cmdline_ipaddr_t tos;
9132 cmdline_ipaddr_t proto;
9133 uint8_t proto_value;
9134 cmdline_ipaddr_t ttl;
9136 cmdline_fixed_string_t vlan;
9137 uint16_t vlan_value;
9138 cmdline_fixed_string_t flexbytes;
9139 cmdline_fixed_string_t flexbytes_value;
9140 cmdline_fixed_string_t pf_vf;
9141 cmdline_fixed_string_t drop;
9142 cmdline_fixed_string_t queue;
9144 cmdline_fixed_string_t fd_id;
9145 uint32_t fd_id_value;
9146 cmdline_fixed_string_t mac;
9147 struct ether_addr mac_addr;
9148 cmdline_fixed_string_t tunnel;
9149 cmdline_fixed_string_t tunnel_type;
9150 cmdline_fixed_string_t tunnel_id;
9151 uint32_t tunnel_id_value;
9155 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9158 const char *p, *p0 = q_arg;
9160 unsigned long int_fld;
9161 char *str_fld[max_num];
9166 p = strchr(p0, '(');
9170 p0 = strchr(p, ')');
9175 if (size >= sizeof(s))
9178 snprintf(s, sizeof(s), "%.*s", size, p);
9179 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9180 if (ret < 0 || ret > max_num)
9182 for (i = 0; i < ret; i++) {
9184 int_fld = strtoul(str_fld[i], &end, 0);
9185 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9187 flexbytes[i] = (uint8_t)int_fld;
9193 str2flowtype(char *string)
9196 static const struct {
9199 } flowtype_str[] = {
9200 {"raw", RTE_ETH_FLOW_RAW},
9201 {"ipv4", RTE_ETH_FLOW_IPV4},
9202 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9203 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9204 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9205 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9206 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9207 {"ipv6", RTE_ETH_FLOW_IPV6},
9208 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9209 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9210 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9211 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9212 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9213 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9216 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9217 if (!strcmp(flowtype_str[i].str, string))
9218 return flowtype_str[i].type;
9221 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9222 return (uint16_t)atoi(string);
9224 return RTE_ETH_FLOW_UNKNOWN;
9227 static enum rte_eth_fdir_tunnel_type
9228 str2fdir_tunneltype(char *string)
9232 static const struct {
9234 enum rte_eth_fdir_tunnel_type type;
9235 } tunneltype_str[] = {
9236 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9237 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9240 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9241 if (!strcmp(tunneltype_str[i].str, string))
9242 return tunneltype_str[i].type;
9244 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9247 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9249 if ((ip_addr).family == AF_INET) \
9250 (ip) = (ip_addr).addr.ipv4.s_addr; \
9252 printf("invalid parameter.\n"); \
9257 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9259 if ((ip_addr).family == AF_INET6) \
9261 &((ip_addr).addr.ipv6), \
9262 sizeof(struct in6_addr)); \
9264 printf("invalid parameter.\n"); \
9270 cmd_flow_director_filter_parsed(void *parsed_result,
9271 __attribute__((unused)) struct cmdline *cl,
9272 __attribute__((unused)) void *data)
9274 struct cmd_flow_director_result *res = parsed_result;
9275 struct rte_eth_fdir_filter entry;
9276 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9278 unsigned long vf_id;
9281 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9283 printf("flow director is not supported on port %u.\n",
9287 memset(flexbytes, 0, sizeof(flexbytes));
9288 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9290 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9291 if (strcmp(res->mode_value, "MAC-VLAN")) {
9292 printf("Please set mode to MAC-VLAN.\n");
9295 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9296 if (strcmp(res->mode_value, "Tunnel")) {
9297 printf("Please set mode to Tunnel.\n");
9301 if (strcmp(res->mode_value, "IP")) {
9302 printf("Please set mode to IP.\n");
9305 entry.input.flow_type = str2flowtype(res->flow_type);
9308 ret = parse_flexbytes(res->flexbytes_value,
9310 RTE_ETH_FDIR_MAX_FLEXLEN);
9312 printf("error: Cannot parse flexbytes input.\n");
9316 switch (entry.input.flow_type) {
9317 case RTE_ETH_FLOW_FRAG_IPV4:
9318 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9319 entry.input.flow.ip4_flow.proto = res->proto_value;
9321 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9322 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9323 IPV4_ADDR_TO_UINT(res->ip_dst,
9324 entry.input.flow.ip4_flow.dst_ip);
9325 IPV4_ADDR_TO_UINT(res->ip_src,
9326 entry.input.flow.ip4_flow.src_ip);
9327 entry.input.flow.ip4_flow.tos = res->tos_value;
9328 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9329 /* need convert to big endian. */
9330 entry.input.flow.udp4_flow.dst_port =
9331 rte_cpu_to_be_16(res->port_dst);
9332 entry.input.flow.udp4_flow.src_port =
9333 rte_cpu_to_be_16(res->port_src);
9335 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9336 IPV4_ADDR_TO_UINT(res->ip_dst,
9337 entry.input.flow.sctp4_flow.ip.dst_ip);
9338 IPV4_ADDR_TO_UINT(res->ip_src,
9339 entry.input.flow.sctp4_flow.ip.src_ip);
9340 entry.input.flow.ip4_flow.tos = res->tos_value;
9341 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9342 /* need convert to big endian. */
9343 entry.input.flow.sctp4_flow.dst_port =
9344 rte_cpu_to_be_16(res->port_dst);
9345 entry.input.flow.sctp4_flow.src_port =
9346 rte_cpu_to_be_16(res->port_src);
9347 entry.input.flow.sctp4_flow.verify_tag =
9348 rte_cpu_to_be_32(res->verify_tag_value);
9350 case RTE_ETH_FLOW_FRAG_IPV6:
9351 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9352 entry.input.flow.ipv6_flow.proto = res->proto_value;
9354 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9355 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9356 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9357 entry.input.flow.ipv6_flow.dst_ip);
9358 IPV6_ADDR_TO_ARRAY(res->ip_src,
9359 entry.input.flow.ipv6_flow.src_ip);
9360 entry.input.flow.ipv6_flow.tc = res->tos_value;
9361 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9362 /* need convert to big endian. */
9363 entry.input.flow.udp6_flow.dst_port =
9364 rte_cpu_to_be_16(res->port_dst);
9365 entry.input.flow.udp6_flow.src_port =
9366 rte_cpu_to_be_16(res->port_src);
9368 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9369 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9370 entry.input.flow.sctp6_flow.ip.dst_ip);
9371 IPV6_ADDR_TO_ARRAY(res->ip_src,
9372 entry.input.flow.sctp6_flow.ip.src_ip);
9373 entry.input.flow.ipv6_flow.tc = res->tos_value;
9374 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9375 /* need convert to big endian. */
9376 entry.input.flow.sctp6_flow.dst_port =
9377 rte_cpu_to_be_16(res->port_dst);
9378 entry.input.flow.sctp6_flow.src_port =
9379 rte_cpu_to_be_16(res->port_src);
9380 entry.input.flow.sctp6_flow.verify_tag =
9381 rte_cpu_to_be_32(res->verify_tag_value);
9383 case RTE_ETH_FLOW_L2_PAYLOAD:
9384 entry.input.flow.l2_flow.ether_type =
9385 rte_cpu_to_be_16(res->ether_type);
9391 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
9392 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
9394 sizeof(struct ether_addr));
9396 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9397 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
9399 sizeof(struct ether_addr));
9400 entry.input.flow.tunnel_flow.tunnel_type =
9401 str2fdir_tunneltype(res->tunnel_type);
9402 entry.input.flow.tunnel_flow.tunnel_id =
9403 rte_cpu_to_be_32(res->tunnel_id_value);
9406 rte_memcpy(entry.input.flow_ext.flexbytes,
9408 RTE_ETH_FDIR_MAX_FLEXLEN);
9410 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
9412 entry.action.flex_off = 0; /*use 0 by default */
9413 if (!strcmp(res->drop, "drop"))
9414 entry.action.behavior = RTE_ETH_FDIR_REJECT;
9416 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
9418 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
9419 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
9420 if (!strcmp(res->pf_vf, "pf"))
9421 entry.input.flow_ext.is_vf = 0;
9422 else if (!strncmp(res->pf_vf, "vf", 2)) {
9423 struct rte_eth_dev_info dev_info;
9425 memset(&dev_info, 0, sizeof(dev_info));
9426 rte_eth_dev_info_get(res->port_id, &dev_info);
9428 vf_id = strtoul(res->pf_vf + 2, &end, 10);
9429 if (errno != 0 || *end != '\0' ||
9430 vf_id >= dev_info.max_vfs) {
9431 printf("invalid parameter %s.\n", res->pf_vf);
9434 entry.input.flow_ext.is_vf = 1;
9435 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
9437 printf("invalid parameter %s.\n", res->pf_vf);
9442 /* set to report FD ID by default */
9443 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
9444 entry.action.rx_queue = res->queue_id;
9445 entry.soft_id = res->fd_id_value;
9446 if (!strcmp(res->ops, "add"))
9447 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9448 RTE_ETH_FILTER_ADD, &entry);
9449 else if (!strcmp(res->ops, "del"))
9450 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9451 RTE_ETH_FILTER_DELETE, &entry);
9453 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9454 RTE_ETH_FILTER_UPDATE, &entry);
9456 printf("flow director programming error: (%s)\n",
9460 cmdline_parse_token_string_t cmd_flow_director_filter =
9461 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9462 flow_director_filter, "flow_director_filter");
9463 cmdline_parse_token_num_t cmd_flow_director_port_id =
9464 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9466 cmdline_parse_token_string_t cmd_flow_director_ops =
9467 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9468 ops, "add#del#update");
9469 cmdline_parse_token_string_t cmd_flow_director_flow =
9470 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9472 cmdline_parse_token_string_t cmd_flow_director_flow_type =
9473 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9474 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9475 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
9476 cmdline_parse_token_string_t cmd_flow_director_ether =
9477 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9479 cmdline_parse_token_num_t cmd_flow_director_ether_type =
9480 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9481 ether_type, UINT16);
9482 cmdline_parse_token_string_t cmd_flow_director_src =
9483 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9485 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
9486 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9488 cmdline_parse_token_num_t cmd_flow_director_port_src =
9489 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9491 cmdline_parse_token_string_t cmd_flow_director_dst =
9492 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9494 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
9495 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9497 cmdline_parse_token_num_t cmd_flow_director_port_dst =
9498 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9500 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
9501 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9502 verify_tag, "verify_tag");
9503 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
9504 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9505 verify_tag_value, UINT32);
9506 cmdline_parse_token_string_t cmd_flow_director_tos =
9507 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9509 cmdline_parse_token_num_t cmd_flow_director_tos_value =
9510 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9512 cmdline_parse_token_string_t cmd_flow_director_proto =
9513 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9515 cmdline_parse_token_num_t cmd_flow_director_proto_value =
9516 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9517 proto_value, UINT8);
9518 cmdline_parse_token_string_t cmd_flow_director_ttl =
9519 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9521 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
9522 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9524 cmdline_parse_token_string_t cmd_flow_director_vlan =
9525 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9527 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
9528 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9529 vlan_value, UINT16);
9530 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
9531 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9532 flexbytes, "flexbytes");
9533 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
9534 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9535 flexbytes_value, NULL);
9536 cmdline_parse_token_string_t cmd_flow_director_drop =
9537 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9539 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
9540 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9542 cmdline_parse_token_string_t cmd_flow_director_queue =
9543 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9545 cmdline_parse_token_num_t cmd_flow_director_queue_id =
9546 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9548 cmdline_parse_token_string_t cmd_flow_director_fd_id =
9549 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9551 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
9552 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9553 fd_id_value, UINT32);
9555 cmdline_parse_token_string_t cmd_flow_director_mode =
9556 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9558 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
9559 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9561 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9562 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9563 mode_value, "MAC-VLAN");
9564 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9565 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9566 mode_value, "Tunnel");
9567 cmdline_parse_token_string_t cmd_flow_director_mac =
9568 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9570 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9571 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9573 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9574 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9576 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9577 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9578 tunnel_type, "NVGRE#VxLAN");
9579 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9580 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9581 tunnel_id, "tunnel-id");
9582 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9583 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9584 tunnel_id_value, UINT32);
9586 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9587 .f = cmd_flow_director_filter_parsed,
9589 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9590 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9591 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9592 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9593 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9594 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9595 "fd_id <fd_id_value>: "
9596 "Add or delete an ip flow director entry on NIC",
9598 (void *)&cmd_flow_director_filter,
9599 (void *)&cmd_flow_director_port_id,
9600 (void *)&cmd_flow_director_mode,
9601 (void *)&cmd_flow_director_mode_ip,
9602 (void *)&cmd_flow_director_ops,
9603 (void *)&cmd_flow_director_flow,
9604 (void *)&cmd_flow_director_flow_type,
9605 (void *)&cmd_flow_director_src,
9606 (void *)&cmd_flow_director_ip_src,
9607 (void *)&cmd_flow_director_dst,
9608 (void *)&cmd_flow_director_ip_dst,
9609 (void *)&cmd_flow_director_tos,
9610 (void *)&cmd_flow_director_tos_value,
9611 (void *)&cmd_flow_director_proto,
9612 (void *)&cmd_flow_director_proto_value,
9613 (void *)&cmd_flow_director_ttl,
9614 (void *)&cmd_flow_director_ttl_value,
9615 (void *)&cmd_flow_director_vlan,
9616 (void *)&cmd_flow_director_vlan_value,
9617 (void *)&cmd_flow_director_flexbytes,
9618 (void *)&cmd_flow_director_flexbytes_value,
9619 (void *)&cmd_flow_director_drop,
9620 (void *)&cmd_flow_director_pf_vf,
9621 (void *)&cmd_flow_director_queue,
9622 (void *)&cmd_flow_director_queue_id,
9623 (void *)&cmd_flow_director_fd_id,
9624 (void *)&cmd_flow_director_fd_id_value,
9629 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9630 .f = cmd_flow_director_filter_parsed,
9632 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9633 "director entry on NIC",
9635 (void *)&cmd_flow_director_filter,
9636 (void *)&cmd_flow_director_port_id,
9637 (void *)&cmd_flow_director_mode,
9638 (void *)&cmd_flow_director_mode_ip,
9639 (void *)&cmd_flow_director_ops,
9640 (void *)&cmd_flow_director_flow,
9641 (void *)&cmd_flow_director_flow_type,
9642 (void *)&cmd_flow_director_src,
9643 (void *)&cmd_flow_director_ip_src,
9644 (void *)&cmd_flow_director_port_src,
9645 (void *)&cmd_flow_director_dst,
9646 (void *)&cmd_flow_director_ip_dst,
9647 (void *)&cmd_flow_director_port_dst,
9648 (void *)&cmd_flow_director_tos,
9649 (void *)&cmd_flow_director_tos_value,
9650 (void *)&cmd_flow_director_ttl,
9651 (void *)&cmd_flow_director_ttl_value,
9652 (void *)&cmd_flow_director_vlan,
9653 (void *)&cmd_flow_director_vlan_value,
9654 (void *)&cmd_flow_director_flexbytes,
9655 (void *)&cmd_flow_director_flexbytes_value,
9656 (void *)&cmd_flow_director_drop,
9657 (void *)&cmd_flow_director_pf_vf,
9658 (void *)&cmd_flow_director_queue,
9659 (void *)&cmd_flow_director_queue_id,
9660 (void *)&cmd_flow_director_fd_id,
9661 (void *)&cmd_flow_director_fd_id_value,
9666 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9667 .f = cmd_flow_director_filter_parsed,
9669 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9670 "director entry on NIC",
9672 (void *)&cmd_flow_director_filter,
9673 (void *)&cmd_flow_director_port_id,
9674 (void *)&cmd_flow_director_mode,
9675 (void *)&cmd_flow_director_mode_ip,
9676 (void *)&cmd_flow_director_ops,
9677 (void *)&cmd_flow_director_flow,
9678 (void *)&cmd_flow_director_flow_type,
9679 (void *)&cmd_flow_director_src,
9680 (void *)&cmd_flow_director_ip_src,
9681 (void *)&cmd_flow_director_port_dst,
9682 (void *)&cmd_flow_director_dst,
9683 (void *)&cmd_flow_director_ip_dst,
9684 (void *)&cmd_flow_director_port_dst,
9685 (void *)&cmd_flow_director_verify_tag,
9686 (void *)&cmd_flow_director_verify_tag_value,
9687 (void *)&cmd_flow_director_tos,
9688 (void *)&cmd_flow_director_tos_value,
9689 (void *)&cmd_flow_director_ttl,
9690 (void *)&cmd_flow_director_ttl_value,
9691 (void *)&cmd_flow_director_vlan,
9692 (void *)&cmd_flow_director_vlan_value,
9693 (void *)&cmd_flow_director_flexbytes,
9694 (void *)&cmd_flow_director_flexbytes_value,
9695 (void *)&cmd_flow_director_drop,
9696 (void *)&cmd_flow_director_pf_vf,
9697 (void *)&cmd_flow_director_queue,
9698 (void *)&cmd_flow_director_queue_id,
9699 (void *)&cmd_flow_director_fd_id,
9700 (void *)&cmd_flow_director_fd_id_value,
9705 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9706 .f = cmd_flow_director_filter_parsed,
9708 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9709 "director entry on NIC",
9711 (void *)&cmd_flow_director_filter,
9712 (void *)&cmd_flow_director_port_id,
9713 (void *)&cmd_flow_director_mode,
9714 (void *)&cmd_flow_director_mode_ip,
9715 (void *)&cmd_flow_director_ops,
9716 (void *)&cmd_flow_director_flow,
9717 (void *)&cmd_flow_director_flow_type,
9718 (void *)&cmd_flow_director_ether,
9719 (void *)&cmd_flow_director_ether_type,
9720 (void *)&cmd_flow_director_flexbytes,
9721 (void *)&cmd_flow_director_flexbytes_value,
9722 (void *)&cmd_flow_director_drop,
9723 (void *)&cmd_flow_director_pf_vf,
9724 (void *)&cmd_flow_director_queue,
9725 (void *)&cmd_flow_director_queue_id,
9726 (void *)&cmd_flow_director_fd_id,
9727 (void *)&cmd_flow_director_fd_id_value,
9732 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9733 .f = cmd_flow_director_filter_parsed,
9735 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9736 "director entry on NIC",
9738 (void *)&cmd_flow_director_filter,
9739 (void *)&cmd_flow_director_port_id,
9740 (void *)&cmd_flow_director_mode,
9741 (void *)&cmd_flow_director_mode_mac_vlan,
9742 (void *)&cmd_flow_director_ops,
9743 (void *)&cmd_flow_director_mac,
9744 (void *)&cmd_flow_director_mac_addr,
9745 (void *)&cmd_flow_director_vlan,
9746 (void *)&cmd_flow_director_vlan_value,
9747 (void *)&cmd_flow_director_flexbytes,
9748 (void *)&cmd_flow_director_flexbytes_value,
9749 (void *)&cmd_flow_director_drop,
9750 (void *)&cmd_flow_director_queue,
9751 (void *)&cmd_flow_director_queue_id,
9752 (void *)&cmd_flow_director_fd_id,
9753 (void *)&cmd_flow_director_fd_id_value,
9758 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9759 .f = cmd_flow_director_filter_parsed,
9761 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9762 "director entry on NIC",
9764 (void *)&cmd_flow_director_filter,
9765 (void *)&cmd_flow_director_port_id,
9766 (void *)&cmd_flow_director_mode,
9767 (void *)&cmd_flow_director_mode_tunnel,
9768 (void *)&cmd_flow_director_ops,
9769 (void *)&cmd_flow_director_mac,
9770 (void *)&cmd_flow_director_mac_addr,
9771 (void *)&cmd_flow_director_vlan,
9772 (void *)&cmd_flow_director_vlan_value,
9773 (void *)&cmd_flow_director_tunnel,
9774 (void *)&cmd_flow_director_tunnel_type,
9775 (void *)&cmd_flow_director_tunnel_id,
9776 (void *)&cmd_flow_director_tunnel_id_value,
9777 (void *)&cmd_flow_director_flexbytes,
9778 (void *)&cmd_flow_director_flexbytes_value,
9779 (void *)&cmd_flow_director_drop,
9780 (void *)&cmd_flow_director_queue,
9781 (void *)&cmd_flow_director_queue_id,
9782 (void *)&cmd_flow_director_fd_id,
9783 (void *)&cmd_flow_director_fd_id_value,
9788 struct cmd_flush_flow_director_result {
9789 cmdline_fixed_string_t flush_flow_director;
9793 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9794 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9795 flush_flow_director, "flush_flow_director");
9796 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9797 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9801 cmd_flush_flow_director_parsed(void *parsed_result,
9802 __attribute__((unused)) struct cmdline *cl,
9803 __attribute__((unused)) void *data)
9805 struct cmd_flow_director_result *res = parsed_result;
9808 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9810 printf("flow director is not supported on port %u.\n",
9815 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9816 RTE_ETH_FILTER_FLUSH, NULL);
9818 printf("flow director table flushing error: (%s)\n",
9822 cmdline_parse_inst_t cmd_flush_flow_director = {
9823 .f = cmd_flush_flow_director_parsed,
9825 .help_str = "flush_flow_director <port_id>: "
9826 "Flush all flow director entries of a device on NIC",
9828 (void *)&cmd_flush_flow_director_flush,
9829 (void *)&cmd_flush_flow_director_port_id,
9834 /* *** deal with flow director mask *** */
9835 struct cmd_flow_director_mask_result {
9836 cmdline_fixed_string_t flow_director_mask;
9838 cmdline_fixed_string_t mode;
9839 cmdline_fixed_string_t mode_value;
9840 cmdline_fixed_string_t vlan;
9842 cmdline_fixed_string_t src_mask;
9843 cmdline_ipaddr_t ipv4_src;
9844 cmdline_ipaddr_t ipv6_src;
9846 cmdline_fixed_string_t dst_mask;
9847 cmdline_ipaddr_t ipv4_dst;
9848 cmdline_ipaddr_t ipv6_dst;
9850 cmdline_fixed_string_t mac;
9851 uint8_t mac_addr_byte_mask;
9852 cmdline_fixed_string_t tunnel_id;
9853 uint32_t tunnel_id_mask;
9854 cmdline_fixed_string_t tunnel_type;
9855 uint8_t tunnel_type_mask;
9859 cmd_flow_director_mask_parsed(void *parsed_result,
9860 __attribute__((unused)) struct cmdline *cl,
9861 __attribute__((unused)) void *data)
9863 struct cmd_flow_director_mask_result *res = parsed_result;
9864 struct rte_eth_fdir_masks *mask;
9865 struct rte_port *port;
9867 if (res->port_id > nb_ports) {
9868 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9872 port = &ports[res->port_id];
9873 /** Check if the port is not started **/
9874 if (port->port_status != RTE_PORT_STOPPED) {
9875 printf("Please stop port %d first\n", res->port_id);
9879 mask = &port->dev_conf.fdir_conf.mask;
9881 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9882 if (strcmp(res->mode_value, "MAC-VLAN")) {
9883 printf("Please set mode to MAC-VLAN.\n");
9887 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9888 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9889 if (strcmp(res->mode_value, "Tunnel")) {
9890 printf("Please set mode to Tunnel.\n");
9894 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9895 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9896 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9897 mask->tunnel_type_mask = res->tunnel_type_mask;
9899 if (strcmp(res->mode_value, "IP")) {
9900 printf("Please set mode to IP.\n");
9904 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9905 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9906 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9907 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9908 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9909 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9910 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9913 cmd_reconfig_device_queue(res->port_id, 1, 1);
9916 cmdline_parse_token_string_t cmd_flow_director_mask =
9917 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9918 flow_director_mask, "flow_director_mask");
9919 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9920 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9922 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9923 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9925 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9926 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9928 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9929 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9930 src_mask, "src_mask");
9931 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9932 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9934 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9935 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9937 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9938 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9940 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9941 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9942 dst_mask, "dst_mask");
9943 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9944 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9946 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9947 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9949 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9950 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9953 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9954 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9956 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9957 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9959 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9960 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9961 mode_value, "MAC-VLAN");
9962 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9963 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9964 mode_value, "Tunnel");
9965 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9966 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9968 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9969 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9970 mac_addr_byte_mask, UINT8);
9971 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9972 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9973 tunnel_type, "tunnel-type");
9974 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9975 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9976 tunnel_type_mask, UINT8);
9977 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9978 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9979 tunnel_id, "tunnel-id");
9980 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9981 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9982 tunnel_id_mask, UINT32);
9984 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9985 .f = cmd_flow_director_mask_parsed,
9987 .help_str = "flow_director_mask ... : "
9988 "Set IP mode flow director's mask on NIC",
9990 (void *)&cmd_flow_director_mask,
9991 (void *)&cmd_flow_director_mask_port_id,
9992 (void *)&cmd_flow_director_mask_mode,
9993 (void *)&cmd_flow_director_mask_mode_ip,
9994 (void *)&cmd_flow_director_mask_vlan,
9995 (void *)&cmd_flow_director_mask_vlan_value,
9996 (void *)&cmd_flow_director_mask_src,
9997 (void *)&cmd_flow_director_mask_ipv4_src,
9998 (void *)&cmd_flow_director_mask_ipv6_src,
9999 (void *)&cmd_flow_director_mask_port_src,
10000 (void *)&cmd_flow_director_mask_dst,
10001 (void *)&cmd_flow_director_mask_ipv4_dst,
10002 (void *)&cmd_flow_director_mask_ipv6_dst,
10003 (void *)&cmd_flow_director_mask_port_dst,
10008 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10009 .f = cmd_flow_director_mask_parsed,
10011 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10012 "flow director's mask on NIC",
10014 (void *)&cmd_flow_director_mask,
10015 (void *)&cmd_flow_director_mask_port_id,
10016 (void *)&cmd_flow_director_mask_mode,
10017 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10018 (void *)&cmd_flow_director_mask_vlan,
10019 (void *)&cmd_flow_director_mask_vlan_value,
10024 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10025 .f = cmd_flow_director_mask_parsed,
10027 .help_str = "flow_director_mask ... : Set tunnel mode "
10028 "flow director's mask on NIC",
10030 (void *)&cmd_flow_director_mask,
10031 (void *)&cmd_flow_director_mask_port_id,
10032 (void *)&cmd_flow_director_mask_mode,
10033 (void *)&cmd_flow_director_mask_mode_tunnel,
10034 (void *)&cmd_flow_director_mask_vlan,
10035 (void *)&cmd_flow_director_mask_vlan_value,
10036 (void *)&cmd_flow_director_mask_mac,
10037 (void *)&cmd_flow_director_mask_mac_value,
10038 (void *)&cmd_flow_director_mask_tunnel_type,
10039 (void *)&cmd_flow_director_mask_tunnel_type_value,
10040 (void *)&cmd_flow_director_mask_tunnel_id,
10041 (void *)&cmd_flow_director_mask_tunnel_id_value,
10046 /* *** deal with flow director mask on flexible payload *** */
10047 struct cmd_flow_director_flex_mask_result {
10048 cmdline_fixed_string_t flow_director_flexmask;
10050 cmdline_fixed_string_t flow;
10051 cmdline_fixed_string_t flow_type;
10052 cmdline_fixed_string_t mask;
10056 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10057 __attribute__((unused)) struct cmdline *cl,
10058 __attribute__((unused)) void *data)
10060 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10061 struct rte_eth_fdir_info fdir_info;
10062 struct rte_eth_fdir_flex_mask flex_mask;
10063 struct rte_port *port;
10064 uint32_t flow_type_mask;
10068 if (res->port_id > nb_ports) {
10069 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10073 port = &ports[res->port_id];
10074 /** Check if the port is not started **/
10075 if (port->port_status != RTE_PORT_STOPPED) {
10076 printf("Please stop port %d first\n", res->port_id);
10080 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10081 ret = parse_flexbytes(res->mask,
10083 RTE_ETH_FDIR_MAX_FLEXLEN);
10085 printf("error: Cannot parse mask input.\n");
10089 memset(&fdir_info, 0, sizeof(fdir_info));
10090 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10091 RTE_ETH_FILTER_INFO, &fdir_info);
10093 printf("Cannot get FDir filter info\n");
10097 if (!strcmp(res->flow_type, "none")) {
10098 /* means don't specify the flow type */
10099 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10100 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10101 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10102 0, sizeof(struct rte_eth_fdir_flex_mask));
10103 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10104 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10106 sizeof(struct rte_eth_fdir_flex_mask));
10107 cmd_reconfig_device_queue(res->port_id, 1, 1);
10110 flow_type_mask = fdir_info.flow_types_mask[0];
10111 if (!strcmp(res->flow_type, "all")) {
10112 if (!flow_type_mask) {
10113 printf("No flow type supported\n");
10116 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10117 if (flow_type_mask & (1 << i)) {
10118 flex_mask.flow_type = i;
10119 fdir_set_flex_mask(res->port_id, &flex_mask);
10122 cmd_reconfig_device_queue(res->port_id, 1, 1);
10125 flex_mask.flow_type = str2flowtype(res->flow_type);
10126 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10127 printf("Flow type %s not supported on port %d\n",
10128 res->flow_type, res->port_id);
10131 fdir_set_flex_mask(res->port_id, &flex_mask);
10132 cmd_reconfig_device_queue(res->port_id, 1, 1);
10135 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10136 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10137 flow_director_flexmask,
10138 "flow_director_flex_mask");
10139 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10140 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10142 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10143 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10145 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10146 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10147 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10148 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10149 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10150 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10153 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10154 .f = cmd_flow_director_flex_mask_parsed,
10156 .help_str = "flow_director_flex_mask ... : "
10157 "Set flow director's flex mask on NIC",
10159 (void *)&cmd_flow_director_flexmask,
10160 (void *)&cmd_flow_director_flexmask_port_id,
10161 (void *)&cmd_flow_director_flexmask_flow,
10162 (void *)&cmd_flow_director_flexmask_flow_type,
10163 (void *)&cmd_flow_director_flexmask_mask,
10168 /* *** deal with flow director flexible payload configuration *** */
10169 struct cmd_flow_director_flexpayload_result {
10170 cmdline_fixed_string_t flow_director_flexpayload;
10172 cmdline_fixed_string_t payload_layer;
10173 cmdline_fixed_string_t payload_cfg;
10177 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10180 const char *p, *p0 = q_arg;
10182 unsigned long int_fld;
10183 char *str_fld[max_num];
10188 p = strchr(p0, '(');
10192 p0 = strchr(p, ')');
10197 if (size >= sizeof(s))
10200 snprintf(s, sizeof(s), "%.*s", size, p);
10201 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10202 if (ret < 0 || ret > max_num)
10204 for (i = 0; i < ret; i++) {
10206 int_fld = strtoul(str_fld[i], &end, 0);
10207 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10209 offsets[i] = (uint16_t)int_fld;
10215 cmd_flow_director_flxpld_parsed(void *parsed_result,
10216 __attribute__((unused)) struct cmdline *cl,
10217 __attribute__((unused)) void *data)
10219 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10220 struct rte_eth_flex_payload_cfg flex_cfg;
10221 struct rte_port *port;
10224 if (res->port_id > nb_ports) {
10225 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10229 port = &ports[res->port_id];
10230 /** Check if the port is not started **/
10231 if (port->port_status != RTE_PORT_STOPPED) {
10232 printf("Please stop port %d first\n", res->port_id);
10236 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10238 if (!strcmp(res->payload_layer, "raw"))
10239 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10240 else if (!strcmp(res->payload_layer, "l2"))
10241 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10242 else if (!strcmp(res->payload_layer, "l3"))
10243 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10244 else if (!strcmp(res->payload_layer, "l4"))
10245 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10247 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10248 RTE_ETH_FDIR_MAX_FLEXLEN);
10250 printf("error: Cannot parse flex payload input.\n");
10254 fdir_set_flex_payload(res->port_id, &flex_cfg);
10255 cmd_reconfig_device_queue(res->port_id, 1, 1);
10258 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10259 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10260 flow_director_flexpayload,
10261 "flow_director_flex_payload");
10262 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10263 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10265 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10266 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10267 payload_layer, "raw#l2#l3#l4");
10268 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10269 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10270 payload_cfg, NULL);
10272 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10273 .f = cmd_flow_director_flxpld_parsed,
10275 .help_str = "flow_director_flexpayload ... : "
10276 "Set flow director's flex payload on NIC",
10278 (void *)&cmd_flow_director_flexpayload,
10279 (void *)&cmd_flow_director_flexpayload_port_id,
10280 (void *)&cmd_flow_director_flexpayload_payload_layer,
10281 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10286 /* Generic flow interface command. */
10287 extern cmdline_parse_inst_t cmd_flow;
10289 /* *** Classification Filters Control *** */
10290 /* *** Get symmetric hash enable per port *** */
10291 struct cmd_get_sym_hash_ena_per_port_result {
10292 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10297 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10298 __rte_unused struct cmdline *cl,
10299 __rte_unused void *data)
10301 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10302 struct rte_eth_hash_filter_info info;
10305 if (rte_eth_dev_filter_supported(res->port_id,
10306 RTE_ETH_FILTER_HASH) < 0) {
10307 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10312 memset(&info, 0, sizeof(info));
10313 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10314 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10315 RTE_ETH_FILTER_GET, &info);
10318 printf("Cannot get symmetric hash enable per port "
10319 "on port %u\n", res->port_id);
10323 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10324 "enabled" : "disabled", res->port_id);
10327 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10328 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10329 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10330 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10331 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10334 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10335 .f = cmd_get_sym_hash_per_port_parsed,
10337 .help_str = "get_sym_hash_ena_per_port <port_id>",
10339 (void *)&cmd_get_sym_hash_ena_per_port_all,
10340 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10345 /* *** Set symmetric hash enable per port *** */
10346 struct cmd_set_sym_hash_ena_per_port_result {
10347 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10348 cmdline_fixed_string_t enable;
10353 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10354 __rte_unused struct cmdline *cl,
10355 __rte_unused void *data)
10357 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10358 struct rte_eth_hash_filter_info info;
10361 if (rte_eth_dev_filter_supported(res->port_id,
10362 RTE_ETH_FILTER_HASH) < 0) {
10363 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10368 memset(&info, 0, sizeof(info));
10369 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10370 if (!strcmp(res->enable, "enable"))
10371 info.info.enable = 1;
10372 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10373 RTE_ETH_FILTER_SET, &info);
10375 printf("Cannot set symmetric hash enable per port on "
10376 "port %u\n", res->port_id);
10379 printf("Symmetric hash has been set to %s on port %u\n",
10380 res->enable, res->port_id);
10383 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
10384 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10385 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
10386 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
10387 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10389 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
10390 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10391 enable, "enable#disable");
10393 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
10394 .f = cmd_set_sym_hash_per_port_parsed,
10396 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
10398 (void *)&cmd_set_sym_hash_ena_per_port_all,
10399 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
10400 (void *)&cmd_set_sym_hash_ena_per_port_enable,
10405 /* Get global config of hash function */
10406 struct cmd_get_hash_global_config_result {
10407 cmdline_fixed_string_t get_hash_global_config;
10412 flowtype_to_str(uint16_t ftype)
10418 } ftype_table[] = {
10419 {"ipv4", RTE_ETH_FLOW_IPV4},
10420 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10421 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10422 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10423 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10424 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10425 {"ipv6", RTE_ETH_FLOW_IPV6},
10426 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10427 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10428 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10429 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10430 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10431 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10432 {"port", RTE_ETH_FLOW_PORT},
10433 {"vxlan", RTE_ETH_FLOW_VXLAN},
10434 {"geneve", RTE_ETH_FLOW_GENEVE},
10435 {"nvgre", RTE_ETH_FLOW_NVGRE},
10438 for (i = 0; i < RTE_DIM(ftype_table); i++) {
10439 if (ftype_table[i].ftype == ftype)
10440 return ftype_table[i].str;
10447 cmd_get_hash_global_config_parsed(void *parsed_result,
10448 __rte_unused struct cmdline *cl,
10449 __rte_unused void *data)
10451 struct cmd_get_hash_global_config_result *res = parsed_result;
10452 struct rte_eth_hash_filter_info info;
10453 uint32_t idx, offset;
10458 if (rte_eth_dev_filter_supported(res->port_id,
10459 RTE_ETH_FILTER_HASH) < 0) {
10460 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10465 memset(&info, 0, sizeof(info));
10466 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10467 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10468 RTE_ETH_FILTER_GET, &info);
10470 printf("Cannot get hash global configurations by port %d\n",
10475 switch (info.info.global_conf.hash_func) {
10476 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
10477 printf("Hash function is Toeplitz\n");
10479 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
10480 printf("Hash function is Simple XOR\n");
10483 printf("Unknown hash function\n");
10487 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
10488 idx = i / UINT32_BIT;
10489 offset = i % UINT32_BIT;
10490 if (!(info.info.global_conf.valid_bit_mask[idx] &
10493 str = flowtype_to_str(i);
10496 printf("Symmetric hash is %s globally for flow type %s "
10498 ((info.info.global_conf.sym_hash_enable_mask[idx] &
10499 (1UL << offset)) ? "enabled" : "disabled"), str,
10504 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
10505 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
10506 get_hash_global_config, "get_hash_global_config");
10507 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
10508 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
10511 cmdline_parse_inst_t cmd_get_hash_global_config = {
10512 .f = cmd_get_hash_global_config_parsed,
10514 .help_str = "get_hash_global_config <port_id>",
10516 (void *)&cmd_get_hash_global_config_all,
10517 (void *)&cmd_get_hash_global_config_port_id,
10522 /* Set global config of hash function */
10523 struct cmd_set_hash_global_config_result {
10524 cmdline_fixed_string_t set_hash_global_config;
10526 cmdline_fixed_string_t hash_func;
10527 cmdline_fixed_string_t flow_type;
10528 cmdline_fixed_string_t enable;
10532 cmd_set_hash_global_config_parsed(void *parsed_result,
10533 __rte_unused struct cmdline *cl,
10534 __rte_unused void *data)
10536 struct cmd_set_hash_global_config_result *res = parsed_result;
10537 struct rte_eth_hash_filter_info info;
10538 uint32_t ftype, idx, offset;
10541 if (rte_eth_dev_filter_supported(res->port_id,
10542 RTE_ETH_FILTER_HASH) < 0) {
10543 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10547 memset(&info, 0, sizeof(info));
10548 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10549 if (!strcmp(res->hash_func, "toeplitz"))
10550 info.info.global_conf.hash_func =
10551 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
10552 else if (!strcmp(res->hash_func, "simple_xor"))
10553 info.info.global_conf.hash_func =
10554 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
10555 else if (!strcmp(res->hash_func, "default"))
10556 info.info.global_conf.hash_func =
10557 RTE_ETH_HASH_FUNCTION_DEFAULT;
10559 ftype = str2flowtype(res->flow_type);
10560 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10561 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10562 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10563 if (!strcmp(res->enable, "enable"))
10564 info.info.global_conf.sym_hash_enable_mask[idx] |=
10566 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10567 RTE_ETH_FILTER_SET, &info);
10569 printf("Cannot set global hash configurations by port %d\n",
10572 printf("Global hash configurations have been set "
10573 "succcessfully by port %d\n", res->port_id);
10576 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10577 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10578 set_hash_global_config, "set_hash_global_config");
10579 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10580 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10582 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10583 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10584 hash_func, "toeplitz#simple_xor#default");
10585 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10586 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10588 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10589 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10590 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10591 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10592 enable, "enable#disable");
10594 cmdline_parse_inst_t cmd_set_hash_global_config = {
10595 .f = cmd_set_hash_global_config_parsed,
10597 .help_str = "set_hash_global_config <port_id> "
10598 "toeplitz|simple_xor|default "
10599 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10600 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10601 "l2_payload enable|disable",
10603 (void *)&cmd_set_hash_global_config_all,
10604 (void *)&cmd_set_hash_global_config_port_id,
10605 (void *)&cmd_set_hash_global_config_hash_func,
10606 (void *)&cmd_set_hash_global_config_flow_type,
10607 (void *)&cmd_set_hash_global_config_enable,
10612 /* Set hash input set */
10613 struct cmd_set_hash_input_set_result {
10614 cmdline_fixed_string_t set_hash_input_set;
10616 cmdline_fixed_string_t flow_type;
10617 cmdline_fixed_string_t inset_field;
10618 cmdline_fixed_string_t select;
10621 static enum rte_eth_input_set_field
10622 str2inset(char *string)
10626 static const struct {
10628 enum rte_eth_input_set_field inset;
10629 } inset_table[] = {
10630 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10631 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10632 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10633 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10634 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10635 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10636 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10637 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10638 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10639 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10640 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10641 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10642 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10643 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10644 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10645 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10646 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10647 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10648 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10649 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10650 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10651 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10652 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10653 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10654 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10655 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10656 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10657 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10658 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10659 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10660 {"none", RTE_ETH_INPUT_SET_NONE},
10663 for (i = 0; i < RTE_DIM(inset_table); i++) {
10664 if (!strcmp(string, inset_table[i].str))
10665 return inset_table[i].inset;
10668 return RTE_ETH_INPUT_SET_UNKNOWN;
10672 cmd_set_hash_input_set_parsed(void *parsed_result,
10673 __rte_unused struct cmdline *cl,
10674 __rte_unused void *data)
10676 struct cmd_set_hash_input_set_result *res = parsed_result;
10677 struct rte_eth_hash_filter_info info;
10679 memset(&info, 0, sizeof(info));
10680 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10681 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10682 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10683 info.info.input_set_conf.inset_size = 1;
10684 if (!strcmp(res->select, "select"))
10685 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10686 else if (!strcmp(res->select, "add"))
10687 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10688 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10689 RTE_ETH_FILTER_SET, &info);
10692 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10693 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10694 set_hash_input_set, "set_hash_input_set");
10695 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10696 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10698 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10699 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10701 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10702 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10704 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10705 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10706 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10707 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10708 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10710 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10711 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10712 select, "select#add");
10714 cmdline_parse_inst_t cmd_set_hash_input_set = {
10715 .f = cmd_set_hash_input_set_parsed,
10717 .help_str = "set_hash_input_set <port_id> "
10718 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10719 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
10720 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10721 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10722 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10723 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10724 "fld-7th|fld-8th|none select|add",
10726 (void *)&cmd_set_hash_input_set_cmd,
10727 (void *)&cmd_set_hash_input_set_port_id,
10728 (void *)&cmd_set_hash_input_set_flow_type,
10729 (void *)&cmd_set_hash_input_set_field,
10730 (void *)&cmd_set_hash_input_set_select,
10735 /* Set flow director input set */
10736 struct cmd_set_fdir_input_set_result {
10737 cmdline_fixed_string_t set_fdir_input_set;
10739 cmdline_fixed_string_t flow_type;
10740 cmdline_fixed_string_t inset_field;
10741 cmdline_fixed_string_t select;
10745 cmd_set_fdir_input_set_parsed(void *parsed_result,
10746 __rte_unused struct cmdline *cl,
10747 __rte_unused void *data)
10749 struct cmd_set_fdir_input_set_result *res = parsed_result;
10750 struct rte_eth_fdir_filter_info info;
10752 memset(&info, 0, sizeof(info));
10753 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10754 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10755 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10756 info.info.input_set_conf.inset_size = 1;
10757 if (!strcmp(res->select, "select"))
10758 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10759 else if (!strcmp(res->select, "add"))
10760 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10761 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10762 RTE_ETH_FILTER_SET, &info);
10765 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10766 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10767 set_fdir_input_set, "set_fdir_input_set");
10768 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10769 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10771 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10772 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10774 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10775 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10776 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10777 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10779 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10780 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10781 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10782 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10783 "sctp-veri-tag#none");
10784 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10785 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10786 select, "select#add");
10788 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10789 .f = cmd_set_fdir_input_set_parsed,
10791 .help_str = "set_fdir_input_set <port_id> "
10792 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10793 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10794 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10795 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10796 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10797 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10798 "sctp-veri-tag|none select|add",
10800 (void *)&cmd_set_fdir_input_set_cmd,
10801 (void *)&cmd_set_fdir_input_set_port_id,
10802 (void *)&cmd_set_fdir_input_set_flow_type,
10803 (void *)&cmd_set_fdir_input_set_field,
10804 (void *)&cmd_set_fdir_input_set_select,
10809 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10810 struct cmd_mcast_addr_result {
10811 cmdline_fixed_string_t mcast_addr_cmd;
10812 cmdline_fixed_string_t what;
10814 struct ether_addr mc_addr;
10817 static void cmd_mcast_addr_parsed(void *parsed_result,
10818 __attribute__((unused)) struct cmdline *cl,
10819 __attribute__((unused)) void *data)
10821 struct cmd_mcast_addr_result *res = parsed_result;
10823 if (!is_multicast_ether_addr(&res->mc_addr)) {
10824 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10825 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10826 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10827 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10830 if (strcmp(res->what, "add") == 0)
10831 mcast_addr_add(res->port_num, &res->mc_addr);
10833 mcast_addr_remove(res->port_num, &res->mc_addr);
10836 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10837 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10838 mcast_addr_cmd, "mcast_addr");
10839 cmdline_parse_token_string_t cmd_mcast_addr_what =
10840 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10842 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10843 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10844 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10845 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10847 cmdline_parse_inst_t cmd_mcast_addr = {
10848 .f = cmd_mcast_addr_parsed,
10850 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10851 "Add/Remove multicast MAC address on port_id",
10853 (void *)&cmd_mcast_addr_cmd,
10854 (void *)&cmd_mcast_addr_what,
10855 (void *)&cmd_mcast_addr_portnum,
10856 (void *)&cmd_mcast_addr_addr,
10861 /* l2 tunnel config
10862 * only support E-tag now.
10865 /* Ether type config */
10866 struct cmd_config_l2_tunnel_eth_type_result {
10867 cmdline_fixed_string_t port;
10868 cmdline_fixed_string_t config;
10869 cmdline_fixed_string_t all;
10871 cmdline_fixed_string_t l2_tunnel;
10872 cmdline_fixed_string_t l2_tunnel_type;
10873 cmdline_fixed_string_t eth_type;
10874 uint16_t eth_type_val;
10877 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10878 TOKEN_STRING_INITIALIZER
10879 (struct cmd_config_l2_tunnel_eth_type_result,
10881 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10882 TOKEN_STRING_INITIALIZER
10883 (struct cmd_config_l2_tunnel_eth_type_result,
10885 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10886 TOKEN_STRING_INITIALIZER
10887 (struct cmd_config_l2_tunnel_eth_type_result,
10889 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10890 TOKEN_NUM_INITIALIZER
10891 (struct cmd_config_l2_tunnel_eth_type_result,
10893 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10894 TOKEN_STRING_INITIALIZER
10895 (struct cmd_config_l2_tunnel_eth_type_result,
10896 l2_tunnel, "l2-tunnel");
10897 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10898 TOKEN_STRING_INITIALIZER
10899 (struct cmd_config_l2_tunnel_eth_type_result,
10900 l2_tunnel_type, "E-tag");
10901 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10902 TOKEN_STRING_INITIALIZER
10903 (struct cmd_config_l2_tunnel_eth_type_result,
10904 eth_type, "ether-type");
10905 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10906 TOKEN_NUM_INITIALIZER
10907 (struct cmd_config_l2_tunnel_eth_type_result,
10908 eth_type_val, UINT16);
10910 static enum rte_eth_tunnel_type
10911 str2fdir_l2_tunnel_type(char *string)
10915 static const struct {
10917 enum rte_eth_tunnel_type type;
10918 } l2_tunnel_type_str[] = {
10919 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10922 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10923 if (!strcmp(l2_tunnel_type_str[i].str, string))
10924 return l2_tunnel_type_str[i].type;
10926 return RTE_TUNNEL_TYPE_NONE;
10929 /* ether type config for all ports */
10931 cmd_config_l2_tunnel_eth_type_all_parsed
10932 (void *parsed_result,
10933 __attribute__((unused)) struct cmdline *cl,
10934 __attribute__((unused)) void *data)
10936 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10937 struct rte_eth_l2_tunnel_conf entry;
10940 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10941 entry.ether_type = res->eth_type_val;
10943 RTE_ETH_FOREACH_DEV(pid) {
10944 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10948 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10949 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10951 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10953 (void *)&cmd_config_l2_tunnel_eth_type_port,
10954 (void *)&cmd_config_l2_tunnel_eth_type_config,
10955 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10956 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10957 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10958 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10959 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10964 /* ether type config for a specific port */
10966 cmd_config_l2_tunnel_eth_type_specific_parsed(
10967 void *parsed_result,
10968 __attribute__((unused)) struct cmdline *cl,
10969 __attribute__((unused)) void *data)
10971 struct cmd_config_l2_tunnel_eth_type_result *res =
10973 struct rte_eth_l2_tunnel_conf entry;
10975 if (port_id_is_invalid(res->id, ENABLED_WARN))
10978 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10979 entry.ether_type = res->eth_type_val;
10981 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10984 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10985 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10987 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10989 (void *)&cmd_config_l2_tunnel_eth_type_port,
10990 (void *)&cmd_config_l2_tunnel_eth_type_config,
10991 (void *)&cmd_config_l2_tunnel_eth_type_id,
10992 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10993 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10994 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10995 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11000 /* Enable/disable l2 tunnel */
11001 struct cmd_config_l2_tunnel_en_dis_result {
11002 cmdline_fixed_string_t port;
11003 cmdline_fixed_string_t config;
11004 cmdline_fixed_string_t all;
11006 cmdline_fixed_string_t l2_tunnel;
11007 cmdline_fixed_string_t l2_tunnel_type;
11008 cmdline_fixed_string_t en_dis;
11011 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11012 TOKEN_STRING_INITIALIZER
11013 (struct cmd_config_l2_tunnel_en_dis_result,
11015 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11016 TOKEN_STRING_INITIALIZER
11017 (struct cmd_config_l2_tunnel_en_dis_result,
11019 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11020 TOKEN_STRING_INITIALIZER
11021 (struct cmd_config_l2_tunnel_en_dis_result,
11023 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11024 TOKEN_NUM_INITIALIZER
11025 (struct cmd_config_l2_tunnel_en_dis_result,
11027 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11028 TOKEN_STRING_INITIALIZER
11029 (struct cmd_config_l2_tunnel_en_dis_result,
11030 l2_tunnel, "l2-tunnel");
11031 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11032 TOKEN_STRING_INITIALIZER
11033 (struct cmd_config_l2_tunnel_en_dis_result,
11034 l2_tunnel_type, "E-tag");
11035 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11036 TOKEN_STRING_INITIALIZER
11037 (struct cmd_config_l2_tunnel_en_dis_result,
11038 en_dis, "enable#disable");
11040 /* enable/disable l2 tunnel for all ports */
11042 cmd_config_l2_tunnel_en_dis_all_parsed(
11043 void *parsed_result,
11044 __attribute__((unused)) struct cmdline *cl,
11045 __attribute__((unused)) void *data)
11047 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11048 struct rte_eth_l2_tunnel_conf entry;
11052 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11054 if (!strcmp("enable", res->en_dis))
11059 RTE_ETH_FOREACH_DEV(pid) {
11060 rte_eth_dev_l2_tunnel_offload_set(pid,
11062 ETH_L2_TUNNEL_ENABLE_MASK,
11067 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11068 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11070 .help_str = "port config all l2-tunnel E-tag enable|disable",
11072 (void *)&cmd_config_l2_tunnel_en_dis_port,
11073 (void *)&cmd_config_l2_tunnel_en_dis_config,
11074 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11075 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11076 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11077 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11082 /* enable/disable l2 tunnel for a port */
11084 cmd_config_l2_tunnel_en_dis_specific_parsed(
11085 void *parsed_result,
11086 __attribute__((unused)) struct cmdline *cl,
11087 __attribute__((unused)) void *data)
11089 struct cmd_config_l2_tunnel_en_dis_result *res =
11091 struct rte_eth_l2_tunnel_conf entry;
11093 if (port_id_is_invalid(res->id, ENABLED_WARN))
11096 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11098 if (!strcmp("enable", res->en_dis))
11099 rte_eth_dev_l2_tunnel_offload_set(res->id,
11101 ETH_L2_TUNNEL_ENABLE_MASK,
11104 rte_eth_dev_l2_tunnel_offload_set(res->id,
11106 ETH_L2_TUNNEL_ENABLE_MASK,
11110 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11111 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11113 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11115 (void *)&cmd_config_l2_tunnel_en_dis_port,
11116 (void *)&cmd_config_l2_tunnel_en_dis_config,
11117 (void *)&cmd_config_l2_tunnel_en_dis_id,
11118 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11119 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11120 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11125 /* E-tag configuration */
11127 /* Common result structure for all E-tag configuration */
11128 struct cmd_config_e_tag_result {
11129 cmdline_fixed_string_t e_tag;
11130 cmdline_fixed_string_t set;
11131 cmdline_fixed_string_t insertion;
11132 cmdline_fixed_string_t stripping;
11133 cmdline_fixed_string_t forwarding;
11134 cmdline_fixed_string_t filter;
11135 cmdline_fixed_string_t add;
11136 cmdline_fixed_string_t del;
11137 cmdline_fixed_string_t on;
11138 cmdline_fixed_string_t off;
11139 cmdline_fixed_string_t on_off;
11140 cmdline_fixed_string_t port_tag_id;
11141 uint32_t port_tag_id_val;
11142 cmdline_fixed_string_t e_tag_id;
11143 uint16_t e_tag_id_val;
11144 cmdline_fixed_string_t dst_pool;
11145 uint8_t dst_pool_val;
11146 cmdline_fixed_string_t port;
11148 cmdline_fixed_string_t vf;
11152 /* Common CLI fields for all E-tag configuration */
11153 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11154 TOKEN_STRING_INITIALIZER
11155 (struct cmd_config_e_tag_result,
11157 cmdline_parse_token_string_t cmd_config_e_tag_set =
11158 TOKEN_STRING_INITIALIZER
11159 (struct cmd_config_e_tag_result,
11161 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11162 TOKEN_STRING_INITIALIZER
11163 (struct cmd_config_e_tag_result,
11164 insertion, "insertion");
11165 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11166 TOKEN_STRING_INITIALIZER
11167 (struct cmd_config_e_tag_result,
11168 stripping, "stripping");
11169 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11170 TOKEN_STRING_INITIALIZER
11171 (struct cmd_config_e_tag_result,
11172 forwarding, "forwarding");
11173 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11174 TOKEN_STRING_INITIALIZER
11175 (struct cmd_config_e_tag_result,
11177 cmdline_parse_token_string_t cmd_config_e_tag_add =
11178 TOKEN_STRING_INITIALIZER
11179 (struct cmd_config_e_tag_result,
11181 cmdline_parse_token_string_t cmd_config_e_tag_del =
11182 TOKEN_STRING_INITIALIZER
11183 (struct cmd_config_e_tag_result,
11185 cmdline_parse_token_string_t cmd_config_e_tag_on =
11186 TOKEN_STRING_INITIALIZER
11187 (struct cmd_config_e_tag_result,
11189 cmdline_parse_token_string_t cmd_config_e_tag_off =
11190 TOKEN_STRING_INITIALIZER
11191 (struct cmd_config_e_tag_result,
11193 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11194 TOKEN_STRING_INITIALIZER
11195 (struct cmd_config_e_tag_result,
11197 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11198 TOKEN_STRING_INITIALIZER
11199 (struct cmd_config_e_tag_result,
11200 port_tag_id, "port-tag-id");
11201 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11202 TOKEN_NUM_INITIALIZER
11203 (struct cmd_config_e_tag_result,
11204 port_tag_id_val, UINT32);
11205 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11206 TOKEN_STRING_INITIALIZER
11207 (struct cmd_config_e_tag_result,
11208 e_tag_id, "e-tag-id");
11209 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11210 TOKEN_NUM_INITIALIZER
11211 (struct cmd_config_e_tag_result,
11212 e_tag_id_val, UINT16);
11213 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11214 TOKEN_STRING_INITIALIZER
11215 (struct cmd_config_e_tag_result,
11216 dst_pool, "dst-pool");
11217 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11218 TOKEN_NUM_INITIALIZER
11219 (struct cmd_config_e_tag_result,
11220 dst_pool_val, UINT8);
11221 cmdline_parse_token_string_t cmd_config_e_tag_port =
11222 TOKEN_STRING_INITIALIZER
11223 (struct cmd_config_e_tag_result,
11225 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11226 TOKEN_NUM_INITIALIZER
11227 (struct cmd_config_e_tag_result,
11229 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11230 TOKEN_STRING_INITIALIZER
11231 (struct cmd_config_e_tag_result,
11233 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11234 TOKEN_NUM_INITIALIZER
11235 (struct cmd_config_e_tag_result,
11238 /* E-tag insertion configuration */
11240 cmd_config_e_tag_insertion_en_parsed(
11241 void *parsed_result,
11242 __attribute__((unused)) struct cmdline *cl,
11243 __attribute__((unused)) void *data)
11245 struct cmd_config_e_tag_result *res =
11247 struct rte_eth_l2_tunnel_conf entry;
11249 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11252 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11253 entry.tunnel_id = res->port_tag_id_val;
11254 entry.vf_id = res->vf_id;
11255 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11257 ETH_L2_TUNNEL_INSERTION_MASK,
11262 cmd_config_e_tag_insertion_dis_parsed(
11263 void *parsed_result,
11264 __attribute__((unused)) struct cmdline *cl,
11265 __attribute__((unused)) void *data)
11267 struct cmd_config_e_tag_result *res =
11269 struct rte_eth_l2_tunnel_conf entry;
11271 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11274 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11275 entry.vf_id = res->vf_id;
11277 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11279 ETH_L2_TUNNEL_INSERTION_MASK,
11283 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11284 .f = cmd_config_e_tag_insertion_en_parsed,
11286 .help_str = "E-tag ... : E-tag insertion enable",
11288 (void *)&cmd_config_e_tag_e_tag,
11289 (void *)&cmd_config_e_tag_set,
11290 (void *)&cmd_config_e_tag_insertion,
11291 (void *)&cmd_config_e_tag_on,
11292 (void *)&cmd_config_e_tag_port_tag_id,
11293 (void *)&cmd_config_e_tag_port_tag_id_val,
11294 (void *)&cmd_config_e_tag_port,
11295 (void *)&cmd_config_e_tag_port_id,
11296 (void *)&cmd_config_e_tag_vf,
11297 (void *)&cmd_config_e_tag_vf_id,
11302 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11303 .f = cmd_config_e_tag_insertion_dis_parsed,
11305 .help_str = "E-tag ... : E-tag insertion disable",
11307 (void *)&cmd_config_e_tag_e_tag,
11308 (void *)&cmd_config_e_tag_set,
11309 (void *)&cmd_config_e_tag_insertion,
11310 (void *)&cmd_config_e_tag_off,
11311 (void *)&cmd_config_e_tag_port,
11312 (void *)&cmd_config_e_tag_port_id,
11313 (void *)&cmd_config_e_tag_vf,
11314 (void *)&cmd_config_e_tag_vf_id,
11319 /* E-tag stripping configuration */
11321 cmd_config_e_tag_stripping_parsed(
11322 void *parsed_result,
11323 __attribute__((unused)) struct cmdline *cl,
11324 __attribute__((unused)) void *data)
11326 struct cmd_config_e_tag_result *res =
11328 struct rte_eth_l2_tunnel_conf entry;
11330 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11333 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11335 if (!strcmp(res->on_off, "on"))
11336 rte_eth_dev_l2_tunnel_offload_set
11339 ETH_L2_TUNNEL_STRIPPING_MASK,
11342 rte_eth_dev_l2_tunnel_offload_set
11345 ETH_L2_TUNNEL_STRIPPING_MASK,
11349 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11350 .f = cmd_config_e_tag_stripping_parsed,
11352 .help_str = "E-tag ... : E-tag stripping enable/disable",
11354 (void *)&cmd_config_e_tag_e_tag,
11355 (void *)&cmd_config_e_tag_set,
11356 (void *)&cmd_config_e_tag_stripping,
11357 (void *)&cmd_config_e_tag_on_off,
11358 (void *)&cmd_config_e_tag_port,
11359 (void *)&cmd_config_e_tag_port_id,
11364 /* E-tag forwarding configuration */
11366 cmd_config_e_tag_forwarding_parsed(
11367 void *parsed_result,
11368 __attribute__((unused)) struct cmdline *cl,
11369 __attribute__((unused)) void *data)
11371 struct cmd_config_e_tag_result *res = parsed_result;
11372 struct rte_eth_l2_tunnel_conf entry;
11374 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11377 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11379 if (!strcmp(res->on_off, "on"))
11380 rte_eth_dev_l2_tunnel_offload_set
11383 ETH_L2_TUNNEL_FORWARDING_MASK,
11386 rte_eth_dev_l2_tunnel_offload_set
11389 ETH_L2_TUNNEL_FORWARDING_MASK,
11393 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11394 .f = cmd_config_e_tag_forwarding_parsed,
11396 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11398 (void *)&cmd_config_e_tag_e_tag,
11399 (void *)&cmd_config_e_tag_set,
11400 (void *)&cmd_config_e_tag_forwarding,
11401 (void *)&cmd_config_e_tag_on_off,
11402 (void *)&cmd_config_e_tag_port,
11403 (void *)&cmd_config_e_tag_port_id,
11408 /* E-tag filter configuration */
11410 cmd_config_e_tag_filter_add_parsed(
11411 void *parsed_result,
11412 __attribute__((unused)) struct cmdline *cl,
11413 __attribute__((unused)) void *data)
11415 struct cmd_config_e_tag_result *res = parsed_result;
11416 struct rte_eth_l2_tunnel_conf entry;
11419 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11422 if (res->e_tag_id_val > 0x3fff) {
11423 printf("e-tag-id must be equal or less than 0x3fff.\n");
11427 ret = rte_eth_dev_filter_supported(res->port_id,
11428 RTE_ETH_FILTER_L2_TUNNEL);
11430 printf("E-tag filter is not supported on port %u.\n",
11435 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11436 entry.tunnel_id = res->e_tag_id_val;
11437 entry.pool = res->dst_pool_val;
11439 ret = rte_eth_dev_filter_ctrl(res->port_id,
11440 RTE_ETH_FILTER_L2_TUNNEL,
11441 RTE_ETH_FILTER_ADD,
11444 printf("E-tag filter programming error: (%s)\n",
11448 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
11449 .f = cmd_config_e_tag_filter_add_parsed,
11451 .help_str = "E-tag ... : E-tag filter add",
11453 (void *)&cmd_config_e_tag_e_tag,
11454 (void *)&cmd_config_e_tag_set,
11455 (void *)&cmd_config_e_tag_filter,
11456 (void *)&cmd_config_e_tag_add,
11457 (void *)&cmd_config_e_tag_e_tag_id,
11458 (void *)&cmd_config_e_tag_e_tag_id_val,
11459 (void *)&cmd_config_e_tag_dst_pool,
11460 (void *)&cmd_config_e_tag_dst_pool_val,
11461 (void *)&cmd_config_e_tag_port,
11462 (void *)&cmd_config_e_tag_port_id,
11468 cmd_config_e_tag_filter_del_parsed(
11469 void *parsed_result,
11470 __attribute__((unused)) struct cmdline *cl,
11471 __attribute__((unused)) void *data)
11473 struct cmd_config_e_tag_result *res = parsed_result;
11474 struct rte_eth_l2_tunnel_conf entry;
11477 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11480 if (res->e_tag_id_val > 0x3fff) {
11481 printf("e-tag-id must be less than 0x3fff.\n");
11485 ret = rte_eth_dev_filter_supported(res->port_id,
11486 RTE_ETH_FILTER_L2_TUNNEL);
11488 printf("E-tag filter is not supported on port %u.\n",
11493 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11494 entry.tunnel_id = res->e_tag_id_val;
11496 ret = rte_eth_dev_filter_ctrl(res->port_id,
11497 RTE_ETH_FILTER_L2_TUNNEL,
11498 RTE_ETH_FILTER_DELETE,
11501 printf("E-tag filter programming error: (%s)\n",
11505 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
11506 .f = cmd_config_e_tag_filter_del_parsed,
11508 .help_str = "E-tag ... : E-tag filter delete",
11510 (void *)&cmd_config_e_tag_e_tag,
11511 (void *)&cmd_config_e_tag_set,
11512 (void *)&cmd_config_e_tag_filter,
11513 (void *)&cmd_config_e_tag_del,
11514 (void *)&cmd_config_e_tag_e_tag_id,
11515 (void *)&cmd_config_e_tag_e_tag_id_val,
11516 (void *)&cmd_config_e_tag_port,
11517 (void *)&cmd_config_e_tag_port_id,
11522 /* vf vlan anti spoof configuration */
11524 /* Common result structure for vf vlan anti spoof */
11525 struct cmd_vf_vlan_anti_spoof_result {
11526 cmdline_fixed_string_t set;
11527 cmdline_fixed_string_t vf;
11528 cmdline_fixed_string_t vlan;
11529 cmdline_fixed_string_t antispoof;
11532 cmdline_fixed_string_t on_off;
11535 /* Common CLI fields for vf vlan anti spoof enable disable */
11536 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11537 TOKEN_STRING_INITIALIZER
11538 (struct cmd_vf_vlan_anti_spoof_result,
11540 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11541 TOKEN_STRING_INITIALIZER
11542 (struct cmd_vf_vlan_anti_spoof_result,
11544 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11545 TOKEN_STRING_INITIALIZER
11546 (struct cmd_vf_vlan_anti_spoof_result,
11548 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11549 TOKEN_STRING_INITIALIZER
11550 (struct cmd_vf_vlan_anti_spoof_result,
11551 antispoof, "antispoof");
11552 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11553 TOKEN_NUM_INITIALIZER
11554 (struct cmd_vf_vlan_anti_spoof_result,
11556 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11557 TOKEN_NUM_INITIALIZER
11558 (struct cmd_vf_vlan_anti_spoof_result,
11560 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11561 TOKEN_STRING_INITIALIZER
11562 (struct cmd_vf_vlan_anti_spoof_result,
11566 cmd_set_vf_vlan_anti_spoof_parsed(
11567 void *parsed_result,
11568 __attribute__((unused)) struct cmdline *cl,
11569 __attribute__((unused)) void *data)
11571 struct cmd_vf_vlan_anti_spoof_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_anti_spoof(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_anti_spoof(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_anti_spoof(res->port_id,
11592 res->vf_id, is_on);
11599 printf("invalid vf_id %d\n", res->vf_id);
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_anti_spoof = {
11613 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11615 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11617 (void *)&cmd_vf_vlan_anti_spoof_set,
11618 (void *)&cmd_vf_vlan_anti_spoof_vf,
11619 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11620 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11621 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11622 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11623 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11628 /* vf mac anti spoof configuration */
11630 /* Common result structure for vf mac anti spoof */
11631 struct cmd_vf_mac_anti_spoof_result {
11632 cmdline_fixed_string_t set;
11633 cmdline_fixed_string_t vf;
11634 cmdline_fixed_string_t mac;
11635 cmdline_fixed_string_t antispoof;
11638 cmdline_fixed_string_t on_off;
11641 /* Common CLI fields for vf mac anti spoof enable disable */
11642 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11643 TOKEN_STRING_INITIALIZER
11644 (struct cmd_vf_mac_anti_spoof_result,
11646 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11647 TOKEN_STRING_INITIALIZER
11648 (struct cmd_vf_mac_anti_spoof_result,
11650 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11651 TOKEN_STRING_INITIALIZER
11652 (struct cmd_vf_mac_anti_spoof_result,
11654 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11655 TOKEN_STRING_INITIALIZER
11656 (struct cmd_vf_mac_anti_spoof_result,
11657 antispoof, "antispoof");
11658 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11659 TOKEN_NUM_INITIALIZER
11660 (struct cmd_vf_mac_anti_spoof_result,
11662 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11663 TOKEN_NUM_INITIALIZER
11664 (struct cmd_vf_mac_anti_spoof_result,
11666 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11667 TOKEN_STRING_INITIALIZER
11668 (struct cmd_vf_mac_anti_spoof_result,
11672 cmd_set_vf_mac_anti_spoof_parsed(
11673 void *parsed_result,
11674 __attribute__((unused)) struct cmdline *cl,
11675 __attribute__((unused)) void *data)
11677 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11678 int ret = -ENOTSUP;
11680 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11682 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11685 #ifdef RTE_LIBRTE_IXGBE_PMD
11686 if (ret == -ENOTSUP)
11687 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11688 res->vf_id, is_on);
11690 #ifdef RTE_LIBRTE_I40E_PMD
11691 if (ret == -ENOTSUP)
11692 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11693 res->vf_id, is_on);
11695 #ifdef RTE_LIBRTE_BNXT_PMD
11696 if (ret == -ENOTSUP)
11697 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11698 res->vf_id, is_on);
11705 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11708 printf("invalid port_id %d\n", res->port_id);
11711 printf("function not implemented\n");
11714 printf("programming error: (%s)\n", strerror(-ret));
11718 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11719 .f = cmd_set_vf_mac_anti_spoof_parsed,
11721 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11723 (void *)&cmd_vf_mac_anti_spoof_set,
11724 (void *)&cmd_vf_mac_anti_spoof_vf,
11725 (void *)&cmd_vf_mac_anti_spoof_mac,
11726 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11727 (void *)&cmd_vf_mac_anti_spoof_port_id,
11728 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11729 (void *)&cmd_vf_mac_anti_spoof_on_off,
11734 /* vf vlan strip queue configuration */
11736 /* Common result structure for vf mac anti spoof */
11737 struct cmd_vf_vlan_stripq_result {
11738 cmdline_fixed_string_t set;
11739 cmdline_fixed_string_t vf;
11740 cmdline_fixed_string_t vlan;
11741 cmdline_fixed_string_t stripq;
11744 cmdline_fixed_string_t on_off;
11747 /* Common CLI fields for vf vlan strip enable disable */
11748 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11749 TOKEN_STRING_INITIALIZER
11750 (struct cmd_vf_vlan_stripq_result,
11752 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11753 TOKEN_STRING_INITIALIZER
11754 (struct cmd_vf_vlan_stripq_result,
11756 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11757 TOKEN_STRING_INITIALIZER
11758 (struct cmd_vf_vlan_stripq_result,
11760 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11761 TOKEN_STRING_INITIALIZER
11762 (struct cmd_vf_vlan_stripq_result,
11764 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11765 TOKEN_NUM_INITIALIZER
11766 (struct cmd_vf_vlan_stripq_result,
11768 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11769 TOKEN_NUM_INITIALIZER
11770 (struct cmd_vf_vlan_stripq_result,
11772 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11773 TOKEN_STRING_INITIALIZER
11774 (struct cmd_vf_vlan_stripq_result,
11778 cmd_set_vf_vlan_stripq_parsed(
11779 void *parsed_result,
11780 __attribute__((unused)) struct cmdline *cl,
11781 __attribute__((unused)) void *data)
11783 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11784 int ret = -ENOTSUP;
11786 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11788 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11791 #ifdef RTE_LIBRTE_IXGBE_PMD
11792 if (ret == -ENOTSUP)
11793 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11794 res->vf_id, is_on);
11796 #ifdef RTE_LIBRTE_I40E_PMD
11797 if (ret == -ENOTSUP)
11798 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11799 res->vf_id, is_on);
11801 #ifdef RTE_LIBRTE_BNXT_PMD
11802 if (ret == -ENOTSUP)
11803 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11804 res->vf_id, is_on);
11811 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11814 printf("invalid port_id %d\n", res->port_id);
11817 printf("function not implemented\n");
11820 printf("programming error: (%s)\n", strerror(-ret));
11824 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11825 .f = cmd_set_vf_vlan_stripq_parsed,
11827 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11829 (void *)&cmd_vf_vlan_stripq_set,
11830 (void *)&cmd_vf_vlan_stripq_vf,
11831 (void *)&cmd_vf_vlan_stripq_vlan,
11832 (void *)&cmd_vf_vlan_stripq_stripq,
11833 (void *)&cmd_vf_vlan_stripq_port_id,
11834 (void *)&cmd_vf_vlan_stripq_vf_id,
11835 (void *)&cmd_vf_vlan_stripq_on_off,
11840 /* vf vlan insert configuration */
11842 /* Common result structure for vf vlan insert */
11843 struct cmd_vf_vlan_insert_result {
11844 cmdline_fixed_string_t set;
11845 cmdline_fixed_string_t vf;
11846 cmdline_fixed_string_t vlan;
11847 cmdline_fixed_string_t insert;
11853 /* Common CLI fields for vf vlan insert enable disable */
11854 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11855 TOKEN_STRING_INITIALIZER
11856 (struct cmd_vf_vlan_insert_result,
11858 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11859 TOKEN_STRING_INITIALIZER
11860 (struct cmd_vf_vlan_insert_result,
11862 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11863 TOKEN_STRING_INITIALIZER
11864 (struct cmd_vf_vlan_insert_result,
11866 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11867 TOKEN_STRING_INITIALIZER
11868 (struct cmd_vf_vlan_insert_result,
11870 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11871 TOKEN_NUM_INITIALIZER
11872 (struct cmd_vf_vlan_insert_result,
11874 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11875 TOKEN_NUM_INITIALIZER
11876 (struct cmd_vf_vlan_insert_result,
11878 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11879 TOKEN_NUM_INITIALIZER
11880 (struct cmd_vf_vlan_insert_result,
11884 cmd_set_vf_vlan_insert_parsed(
11885 void *parsed_result,
11886 __attribute__((unused)) struct cmdline *cl,
11887 __attribute__((unused)) void *data)
11889 struct cmd_vf_vlan_insert_result *res = parsed_result;
11890 int ret = -ENOTSUP;
11892 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11895 #ifdef RTE_LIBRTE_IXGBE_PMD
11896 if (ret == -ENOTSUP)
11897 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11900 #ifdef RTE_LIBRTE_I40E_PMD
11901 if (ret == -ENOTSUP)
11902 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11905 #ifdef RTE_LIBRTE_BNXT_PMD
11906 if (ret == -ENOTSUP)
11907 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11915 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11918 printf("invalid port_id %d\n", res->port_id);
11921 printf("function not implemented\n");
11924 printf("programming error: (%s)\n", strerror(-ret));
11928 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11929 .f = cmd_set_vf_vlan_insert_parsed,
11931 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11933 (void *)&cmd_vf_vlan_insert_set,
11934 (void *)&cmd_vf_vlan_insert_vf,
11935 (void *)&cmd_vf_vlan_insert_vlan,
11936 (void *)&cmd_vf_vlan_insert_insert,
11937 (void *)&cmd_vf_vlan_insert_port_id,
11938 (void *)&cmd_vf_vlan_insert_vf_id,
11939 (void *)&cmd_vf_vlan_insert_vlan_id,
11944 /* tx loopback configuration */
11946 /* Common result structure for tx loopback */
11947 struct cmd_tx_loopback_result {
11948 cmdline_fixed_string_t set;
11949 cmdline_fixed_string_t tx;
11950 cmdline_fixed_string_t loopback;
11952 cmdline_fixed_string_t on_off;
11955 /* Common CLI fields for tx loopback enable disable */
11956 cmdline_parse_token_string_t cmd_tx_loopback_set =
11957 TOKEN_STRING_INITIALIZER
11958 (struct cmd_tx_loopback_result,
11960 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11961 TOKEN_STRING_INITIALIZER
11962 (struct cmd_tx_loopback_result,
11964 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11965 TOKEN_STRING_INITIALIZER
11966 (struct cmd_tx_loopback_result,
11967 loopback, "loopback");
11968 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11969 TOKEN_NUM_INITIALIZER
11970 (struct cmd_tx_loopback_result,
11972 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11973 TOKEN_STRING_INITIALIZER
11974 (struct cmd_tx_loopback_result,
11978 cmd_set_tx_loopback_parsed(
11979 void *parsed_result,
11980 __attribute__((unused)) struct cmdline *cl,
11981 __attribute__((unused)) void *data)
11983 struct cmd_tx_loopback_result *res = parsed_result;
11984 int ret = -ENOTSUP;
11986 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11988 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11991 #ifdef RTE_LIBRTE_IXGBE_PMD
11992 if (ret == -ENOTSUP)
11993 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11995 #ifdef RTE_LIBRTE_I40E_PMD
11996 if (ret == -ENOTSUP)
11997 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11999 #ifdef RTE_LIBRTE_BNXT_PMD
12000 if (ret == -ENOTSUP)
12001 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12008 printf("invalid is_on %d\n", is_on);
12011 printf("invalid port_id %d\n", res->port_id);
12014 printf("function not implemented\n");
12017 printf("programming error: (%s)\n", strerror(-ret));
12021 cmdline_parse_inst_t cmd_set_tx_loopback = {
12022 .f = cmd_set_tx_loopback_parsed,
12024 .help_str = "set tx loopback <port_id> on|off",
12026 (void *)&cmd_tx_loopback_set,
12027 (void *)&cmd_tx_loopback_tx,
12028 (void *)&cmd_tx_loopback_loopback,
12029 (void *)&cmd_tx_loopback_port_id,
12030 (void *)&cmd_tx_loopback_on_off,
12035 /* all queues drop enable configuration */
12037 /* Common result structure for all queues drop enable */
12038 struct cmd_all_queues_drop_en_result {
12039 cmdline_fixed_string_t set;
12040 cmdline_fixed_string_t all;
12041 cmdline_fixed_string_t queues;
12042 cmdline_fixed_string_t drop;
12044 cmdline_fixed_string_t on_off;
12047 /* Common CLI fields for tx loopback enable disable */
12048 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12049 TOKEN_STRING_INITIALIZER
12050 (struct cmd_all_queues_drop_en_result,
12052 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12053 TOKEN_STRING_INITIALIZER
12054 (struct cmd_all_queues_drop_en_result,
12056 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12057 TOKEN_STRING_INITIALIZER
12058 (struct cmd_all_queues_drop_en_result,
12060 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12061 TOKEN_STRING_INITIALIZER
12062 (struct cmd_all_queues_drop_en_result,
12064 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12065 TOKEN_NUM_INITIALIZER
12066 (struct cmd_all_queues_drop_en_result,
12068 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12069 TOKEN_STRING_INITIALIZER
12070 (struct cmd_all_queues_drop_en_result,
12074 cmd_set_all_queues_drop_en_parsed(
12075 void *parsed_result,
12076 __attribute__((unused)) struct cmdline *cl,
12077 __attribute__((unused)) void *data)
12079 struct cmd_all_queues_drop_en_result *res = parsed_result;
12080 int ret = -ENOTSUP;
12081 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12083 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12086 #ifdef RTE_LIBRTE_IXGBE_PMD
12087 if (ret == -ENOTSUP)
12088 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12090 #ifdef RTE_LIBRTE_BNXT_PMD
12091 if (ret == -ENOTSUP)
12092 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12098 printf("invalid is_on %d\n", is_on);
12101 printf("invalid port_id %d\n", res->port_id);
12104 printf("function not implemented\n");
12107 printf("programming error: (%s)\n", strerror(-ret));
12111 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12112 .f = cmd_set_all_queues_drop_en_parsed,
12114 .help_str = "set all queues drop <port_id> on|off",
12116 (void *)&cmd_all_queues_drop_en_set,
12117 (void *)&cmd_all_queues_drop_en_all,
12118 (void *)&cmd_all_queues_drop_en_queues,
12119 (void *)&cmd_all_queues_drop_en_drop,
12120 (void *)&cmd_all_queues_drop_en_port_id,
12121 (void *)&cmd_all_queues_drop_en_on_off,
12126 /* vf split drop enable configuration */
12128 /* Common result structure for vf split drop enable */
12129 struct cmd_vf_split_drop_en_result {
12130 cmdline_fixed_string_t set;
12131 cmdline_fixed_string_t vf;
12132 cmdline_fixed_string_t split;
12133 cmdline_fixed_string_t drop;
12136 cmdline_fixed_string_t on_off;
12139 /* Common CLI fields for vf split drop enable disable */
12140 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12141 TOKEN_STRING_INITIALIZER
12142 (struct cmd_vf_split_drop_en_result,
12144 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12145 TOKEN_STRING_INITIALIZER
12146 (struct cmd_vf_split_drop_en_result,
12148 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12149 TOKEN_STRING_INITIALIZER
12150 (struct cmd_vf_split_drop_en_result,
12152 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12153 TOKEN_STRING_INITIALIZER
12154 (struct cmd_vf_split_drop_en_result,
12156 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12157 TOKEN_NUM_INITIALIZER
12158 (struct cmd_vf_split_drop_en_result,
12160 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12161 TOKEN_NUM_INITIALIZER
12162 (struct cmd_vf_split_drop_en_result,
12164 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12165 TOKEN_STRING_INITIALIZER
12166 (struct cmd_vf_split_drop_en_result,
12170 cmd_set_vf_split_drop_en_parsed(
12171 void *parsed_result,
12172 __attribute__((unused)) struct cmdline *cl,
12173 __attribute__((unused)) void *data)
12175 struct cmd_vf_split_drop_en_result *res = parsed_result;
12176 int ret = -ENOTSUP;
12177 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12179 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12182 #ifdef RTE_LIBRTE_IXGBE_PMD
12183 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12190 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12193 printf("invalid port_id %d\n", res->port_id);
12196 printf("not supported on port %d\n", res->port_id);
12199 printf("programming error: (%s)\n", strerror(-ret));
12203 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12204 .f = cmd_set_vf_split_drop_en_parsed,
12206 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12208 (void *)&cmd_vf_split_drop_en_set,
12209 (void *)&cmd_vf_split_drop_en_vf,
12210 (void *)&cmd_vf_split_drop_en_split,
12211 (void *)&cmd_vf_split_drop_en_drop,
12212 (void *)&cmd_vf_split_drop_en_port_id,
12213 (void *)&cmd_vf_split_drop_en_vf_id,
12214 (void *)&cmd_vf_split_drop_en_on_off,
12219 /* vf mac address configuration */
12221 /* Common result structure for vf mac address */
12222 struct cmd_set_vf_mac_addr_result {
12223 cmdline_fixed_string_t set;
12224 cmdline_fixed_string_t vf;
12225 cmdline_fixed_string_t mac;
12226 cmdline_fixed_string_t addr;
12229 struct ether_addr mac_addr;
12233 /* Common CLI fields for vf split drop enable disable */
12234 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12235 TOKEN_STRING_INITIALIZER
12236 (struct cmd_set_vf_mac_addr_result,
12238 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12239 TOKEN_STRING_INITIALIZER
12240 (struct cmd_set_vf_mac_addr_result,
12242 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12243 TOKEN_STRING_INITIALIZER
12244 (struct cmd_set_vf_mac_addr_result,
12246 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12247 TOKEN_STRING_INITIALIZER
12248 (struct cmd_set_vf_mac_addr_result,
12250 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12251 TOKEN_NUM_INITIALIZER
12252 (struct cmd_set_vf_mac_addr_result,
12254 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12255 TOKEN_NUM_INITIALIZER
12256 (struct cmd_set_vf_mac_addr_result,
12258 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12259 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12263 cmd_set_vf_mac_addr_parsed(
12264 void *parsed_result,
12265 __attribute__((unused)) struct cmdline *cl,
12266 __attribute__((unused)) void *data)
12268 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12269 int ret = -ENOTSUP;
12271 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12274 #ifdef RTE_LIBRTE_IXGBE_PMD
12275 if (ret == -ENOTSUP)
12276 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12279 #ifdef RTE_LIBRTE_I40E_PMD
12280 if (ret == -ENOTSUP)
12281 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12284 #ifdef RTE_LIBRTE_BNXT_PMD
12285 if (ret == -ENOTSUP)
12286 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12294 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12297 printf("invalid port_id %d\n", res->port_id);
12300 printf("function not implemented\n");
12303 printf("programming error: (%s)\n", strerror(-ret));
12307 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12308 .f = cmd_set_vf_mac_addr_parsed,
12310 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12312 (void *)&cmd_set_vf_mac_addr_set,
12313 (void *)&cmd_set_vf_mac_addr_vf,
12314 (void *)&cmd_set_vf_mac_addr_mac,
12315 (void *)&cmd_set_vf_mac_addr_addr,
12316 (void *)&cmd_set_vf_mac_addr_port_id,
12317 (void *)&cmd_set_vf_mac_addr_vf_id,
12318 (void *)&cmd_set_vf_mac_addr_mac_addr,
12323 /* MACsec configuration */
12325 /* Common result structure for MACsec offload enable */
12326 struct cmd_macsec_offload_on_result {
12327 cmdline_fixed_string_t set;
12328 cmdline_fixed_string_t macsec;
12329 cmdline_fixed_string_t offload;
12331 cmdline_fixed_string_t on;
12332 cmdline_fixed_string_t encrypt;
12333 cmdline_fixed_string_t en_on_off;
12334 cmdline_fixed_string_t replay_protect;
12335 cmdline_fixed_string_t rp_on_off;
12338 /* Common CLI fields for MACsec offload disable */
12339 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12340 TOKEN_STRING_INITIALIZER
12341 (struct cmd_macsec_offload_on_result,
12343 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12344 TOKEN_STRING_INITIALIZER
12345 (struct cmd_macsec_offload_on_result,
12347 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12348 TOKEN_STRING_INITIALIZER
12349 (struct cmd_macsec_offload_on_result,
12350 offload, "offload");
12351 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12352 TOKEN_NUM_INITIALIZER
12353 (struct cmd_macsec_offload_on_result,
12355 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12356 TOKEN_STRING_INITIALIZER
12357 (struct cmd_macsec_offload_on_result,
12359 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12360 TOKEN_STRING_INITIALIZER
12361 (struct cmd_macsec_offload_on_result,
12362 encrypt, "encrypt");
12363 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12364 TOKEN_STRING_INITIALIZER
12365 (struct cmd_macsec_offload_on_result,
12366 en_on_off, "on#off");
12367 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12368 TOKEN_STRING_INITIALIZER
12369 (struct cmd_macsec_offload_on_result,
12370 replay_protect, "replay-protect");
12371 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12372 TOKEN_STRING_INITIALIZER
12373 (struct cmd_macsec_offload_on_result,
12374 rp_on_off, "on#off");
12377 cmd_set_macsec_offload_on_parsed(
12378 void *parsed_result,
12379 __attribute__((unused)) struct cmdline *cl,
12380 __attribute__((unused)) void *data)
12382 struct cmd_macsec_offload_on_result *res = parsed_result;
12383 int ret = -ENOTSUP;
12384 portid_t port_id = res->port_id;
12385 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12386 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12388 if (port_id_is_invalid(port_id, ENABLED_WARN))
12391 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
12392 #ifdef RTE_LIBRTE_IXGBE_PMD
12393 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12402 printf("invalid port_id %d\n", port_id);
12405 printf("not supported on port %d\n", port_id);
12408 printf("programming error: (%s)\n", strerror(-ret));
12412 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12413 .f = cmd_set_macsec_offload_on_parsed,
12415 .help_str = "set macsec offload <port_id> on "
12416 "encrypt on|off replay-protect on|off",
12418 (void *)&cmd_macsec_offload_on_set,
12419 (void *)&cmd_macsec_offload_on_macsec,
12420 (void *)&cmd_macsec_offload_on_offload,
12421 (void *)&cmd_macsec_offload_on_port_id,
12422 (void *)&cmd_macsec_offload_on_on,
12423 (void *)&cmd_macsec_offload_on_encrypt,
12424 (void *)&cmd_macsec_offload_on_en_on_off,
12425 (void *)&cmd_macsec_offload_on_replay_protect,
12426 (void *)&cmd_macsec_offload_on_rp_on_off,
12431 /* Common result structure for MACsec offload disable */
12432 struct cmd_macsec_offload_off_result {
12433 cmdline_fixed_string_t set;
12434 cmdline_fixed_string_t macsec;
12435 cmdline_fixed_string_t offload;
12437 cmdline_fixed_string_t off;
12440 /* Common CLI fields for MACsec offload disable */
12441 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12442 TOKEN_STRING_INITIALIZER
12443 (struct cmd_macsec_offload_off_result,
12445 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12446 TOKEN_STRING_INITIALIZER
12447 (struct cmd_macsec_offload_off_result,
12449 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12450 TOKEN_STRING_INITIALIZER
12451 (struct cmd_macsec_offload_off_result,
12452 offload, "offload");
12453 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12454 TOKEN_NUM_INITIALIZER
12455 (struct cmd_macsec_offload_off_result,
12457 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12458 TOKEN_STRING_INITIALIZER
12459 (struct cmd_macsec_offload_off_result,
12463 cmd_set_macsec_offload_off_parsed(
12464 void *parsed_result,
12465 __attribute__((unused)) struct cmdline *cl,
12466 __attribute__((unused)) void *data)
12468 struct cmd_macsec_offload_off_result *res = parsed_result;
12469 int ret = -ENOTSUP;
12470 portid_t port_id = res->port_id;
12472 if (port_id_is_invalid(port_id, ENABLED_WARN))
12475 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
12476 #ifdef RTE_LIBRTE_IXGBE_PMD
12477 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12484 printf("invalid port_id %d\n", port_id);
12487 printf("not supported on port %d\n", port_id);
12490 printf("programming error: (%s)\n", strerror(-ret));
12494 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12495 .f = cmd_set_macsec_offload_off_parsed,
12497 .help_str = "set macsec offload <port_id> off",
12499 (void *)&cmd_macsec_offload_off_set,
12500 (void *)&cmd_macsec_offload_off_macsec,
12501 (void *)&cmd_macsec_offload_off_offload,
12502 (void *)&cmd_macsec_offload_off_port_id,
12503 (void *)&cmd_macsec_offload_off_off,
12508 /* Common result structure for MACsec secure connection configure */
12509 struct cmd_macsec_sc_result {
12510 cmdline_fixed_string_t set;
12511 cmdline_fixed_string_t macsec;
12512 cmdline_fixed_string_t sc;
12513 cmdline_fixed_string_t tx_rx;
12515 struct ether_addr mac;
12519 /* Common CLI fields for MACsec secure connection configure */
12520 cmdline_parse_token_string_t cmd_macsec_sc_set =
12521 TOKEN_STRING_INITIALIZER
12522 (struct cmd_macsec_sc_result,
12524 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12525 TOKEN_STRING_INITIALIZER
12526 (struct cmd_macsec_sc_result,
12528 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12529 TOKEN_STRING_INITIALIZER
12530 (struct cmd_macsec_sc_result,
12532 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12533 TOKEN_STRING_INITIALIZER
12534 (struct cmd_macsec_sc_result,
12536 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12537 TOKEN_NUM_INITIALIZER
12538 (struct cmd_macsec_sc_result,
12540 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12541 TOKEN_ETHERADDR_INITIALIZER
12542 (struct cmd_macsec_sc_result,
12544 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12545 TOKEN_NUM_INITIALIZER
12546 (struct cmd_macsec_sc_result,
12550 cmd_set_macsec_sc_parsed(
12551 void *parsed_result,
12552 __attribute__((unused)) struct cmdline *cl,
12553 __attribute__((unused)) void *data)
12555 struct cmd_macsec_sc_result *res = parsed_result;
12556 int ret = -ENOTSUP;
12557 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12559 #ifdef RTE_LIBRTE_IXGBE_PMD
12561 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12562 res->mac.addr_bytes) :
12563 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12564 res->mac.addr_bytes, res->pi);
12566 RTE_SET_USED(is_tx);
12572 printf("invalid port_id %d\n", res->port_id);
12575 printf("not supported on port %d\n", res->port_id);
12578 printf("programming error: (%s)\n", strerror(-ret));
12582 cmdline_parse_inst_t cmd_set_macsec_sc = {
12583 .f = cmd_set_macsec_sc_parsed,
12585 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12587 (void *)&cmd_macsec_sc_set,
12588 (void *)&cmd_macsec_sc_macsec,
12589 (void *)&cmd_macsec_sc_sc,
12590 (void *)&cmd_macsec_sc_tx_rx,
12591 (void *)&cmd_macsec_sc_port_id,
12592 (void *)&cmd_macsec_sc_mac,
12593 (void *)&cmd_macsec_sc_pi,
12598 /* Common result structure for MACsec secure connection configure */
12599 struct cmd_macsec_sa_result {
12600 cmdline_fixed_string_t set;
12601 cmdline_fixed_string_t macsec;
12602 cmdline_fixed_string_t sa;
12603 cmdline_fixed_string_t tx_rx;
12608 cmdline_fixed_string_t key;
12611 /* Common CLI fields for MACsec secure connection configure */
12612 cmdline_parse_token_string_t cmd_macsec_sa_set =
12613 TOKEN_STRING_INITIALIZER
12614 (struct cmd_macsec_sa_result,
12616 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12617 TOKEN_STRING_INITIALIZER
12618 (struct cmd_macsec_sa_result,
12620 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12621 TOKEN_STRING_INITIALIZER
12622 (struct cmd_macsec_sa_result,
12624 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12625 TOKEN_STRING_INITIALIZER
12626 (struct cmd_macsec_sa_result,
12628 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12629 TOKEN_NUM_INITIALIZER
12630 (struct cmd_macsec_sa_result,
12632 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12633 TOKEN_NUM_INITIALIZER
12634 (struct cmd_macsec_sa_result,
12636 cmdline_parse_token_num_t cmd_macsec_sa_an =
12637 TOKEN_NUM_INITIALIZER
12638 (struct cmd_macsec_sa_result,
12640 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12641 TOKEN_NUM_INITIALIZER
12642 (struct cmd_macsec_sa_result,
12644 cmdline_parse_token_string_t cmd_macsec_sa_key =
12645 TOKEN_STRING_INITIALIZER
12646 (struct cmd_macsec_sa_result,
12650 cmd_set_macsec_sa_parsed(
12651 void *parsed_result,
12652 __attribute__((unused)) struct cmdline *cl,
12653 __attribute__((unused)) void *data)
12655 struct cmd_macsec_sa_result *res = parsed_result;
12656 int ret = -ENOTSUP;
12657 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12658 uint8_t key[16] = { 0 };
12664 key_len = strlen(res->key) / 2;
12668 for (i = 0; i < key_len; i++) {
12669 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12672 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12675 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12678 #ifdef RTE_LIBRTE_IXGBE_PMD
12680 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12681 res->idx, res->an, res->pn, key) :
12682 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12683 res->idx, res->an, res->pn, key);
12685 RTE_SET_USED(is_tx);
12692 printf("invalid idx %d or an %d\n", res->idx, res->an);
12695 printf("invalid port_id %d\n", res->port_id);
12698 printf("not supported on port %d\n", res->port_id);
12701 printf("programming error: (%s)\n", strerror(-ret));
12705 cmdline_parse_inst_t cmd_set_macsec_sa = {
12706 .f = cmd_set_macsec_sa_parsed,
12708 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12710 (void *)&cmd_macsec_sa_set,
12711 (void *)&cmd_macsec_sa_macsec,
12712 (void *)&cmd_macsec_sa_sa,
12713 (void *)&cmd_macsec_sa_tx_rx,
12714 (void *)&cmd_macsec_sa_port_id,
12715 (void *)&cmd_macsec_sa_idx,
12716 (void *)&cmd_macsec_sa_an,
12717 (void *)&cmd_macsec_sa_pn,
12718 (void *)&cmd_macsec_sa_key,
12723 /* VF unicast promiscuous mode configuration */
12725 /* Common result structure for VF unicast promiscuous mode */
12726 struct cmd_vf_promisc_result {
12727 cmdline_fixed_string_t set;
12728 cmdline_fixed_string_t vf;
12729 cmdline_fixed_string_t promisc;
12732 cmdline_fixed_string_t on_off;
12735 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12736 cmdline_parse_token_string_t cmd_vf_promisc_set =
12737 TOKEN_STRING_INITIALIZER
12738 (struct cmd_vf_promisc_result,
12740 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12741 TOKEN_STRING_INITIALIZER
12742 (struct cmd_vf_promisc_result,
12744 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12745 TOKEN_STRING_INITIALIZER
12746 (struct cmd_vf_promisc_result,
12747 promisc, "promisc");
12748 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12749 TOKEN_NUM_INITIALIZER
12750 (struct cmd_vf_promisc_result,
12752 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12753 TOKEN_NUM_INITIALIZER
12754 (struct cmd_vf_promisc_result,
12756 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12757 TOKEN_STRING_INITIALIZER
12758 (struct cmd_vf_promisc_result,
12762 cmd_set_vf_promisc_parsed(
12763 void *parsed_result,
12764 __attribute__((unused)) struct cmdline *cl,
12765 __attribute__((unused)) void *data)
12767 struct cmd_vf_promisc_result *res = parsed_result;
12768 int ret = -ENOTSUP;
12770 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12772 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12775 #ifdef RTE_LIBRTE_I40E_PMD
12776 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12777 res->vf_id, is_on);
12784 printf("invalid vf_id %d\n", res->vf_id);
12787 printf("invalid port_id %d\n", res->port_id);
12790 printf("function not implemented\n");
12793 printf("programming error: (%s)\n", strerror(-ret));
12797 cmdline_parse_inst_t cmd_set_vf_promisc = {
12798 .f = cmd_set_vf_promisc_parsed,
12800 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12801 "Set unicast promiscuous mode for a VF from the PF",
12803 (void *)&cmd_vf_promisc_set,
12804 (void *)&cmd_vf_promisc_vf,
12805 (void *)&cmd_vf_promisc_promisc,
12806 (void *)&cmd_vf_promisc_port_id,
12807 (void *)&cmd_vf_promisc_vf_id,
12808 (void *)&cmd_vf_promisc_on_off,
12813 /* VF multicast promiscuous mode configuration */
12815 /* Common result structure for VF multicast promiscuous mode */
12816 struct cmd_vf_allmulti_result {
12817 cmdline_fixed_string_t set;
12818 cmdline_fixed_string_t vf;
12819 cmdline_fixed_string_t allmulti;
12822 cmdline_fixed_string_t on_off;
12825 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12826 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12827 TOKEN_STRING_INITIALIZER
12828 (struct cmd_vf_allmulti_result,
12830 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12831 TOKEN_STRING_INITIALIZER
12832 (struct cmd_vf_allmulti_result,
12834 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12835 TOKEN_STRING_INITIALIZER
12836 (struct cmd_vf_allmulti_result,
12837 allmulti, "allmulti");
12838 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12839 TOKEN_NUM_INITIALIZER
12840 (struct cmd_vf_allmulti_result,
12842 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12843 TOKEN_NUM_INITIALIZER
12844 (struct cmd_vf_allmulti_result,
12846 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12847 TOKEN_STRING_INITIALIZER
12848 (struct cmd_vf_allmulti_result,
12852 cmd_set_vf_allmulti_parsed(
12853 void *parsed_result,
12854 __attribute__((unused)) struct cmdline *cl,
12855 __attribute__((unused)) void *data)
12857 struct cmd_vf_allmulti_result *res = parsed_result;
12858 int ret = -ENOTSUP;
12860 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12862 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12865 #ifdef RTE_LIBRTE_I40E_PMD
12866 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12867 res->vf_id, is_on);
12874 printf("invalid vf_id %d\n", res->vf_id);
12877 printf("invalid port_id %d\n", res->port_id);
12880 printf("function not implemented\n");
12883 printf("programming error: (%s)\n", strerror(-ret));
12887 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12888 .f = cmd_set_vf_allmulti_parsed,
12890 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12891 "Set multicast promiscuous mode for a VF from the PF",
12893 (void *)&cmd_vf_allmulti_set,
12894 (void *)&cmd_vf_allmulti_vf,
12895 (void *)&cmd_vf_allmulti_allmulti,
12896 (void *)&cmd_vf_allmulti_port_id,
12897 (void *)&cmd_vf_allmulti_vf_id,
12898 (void *)&cmd_vf_allmulti_on_off,
12903 /* vf broadcast mode configuration */
12905 /* Common result structure for vf broadcast */
12906 struct cmd_set_vf_broadcast_result {
12907 cmdline_fixed_string_t set;
12908 cmdline_fixed_string_t vf;
12909 cmdline_fixed_string_t broadcast;
12912 cmdline_fixed_string_t on_off;
12915 /* Common CLI fields for vf broadcast enable disable */
12916 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12917 TOKEN_STRING_INITIALIZER
12918 (struct cmd_set_vf_broadcast_result,
12920 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12921 TOKEN_STRING_INITIALIZER
12922 (struct cmd_set_vf_broadcast_result,
12924 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12925 TOKEN_STRING_INITIALIZER
12926 (struct cmd_set_vf_broadcast_result,
12927 broadcast, "broadcast");
12928 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12929 TOKEN_NUM_INITIALIZER
12930 (struct cmd_set_vf_broadcast_result,
12932 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12933 TOKEN_NUM_INITIALIZER
12934 (struct cmd_set_vf_broadcast_result,
12936 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12937 TOKEN_STRING_INITIALIZER
12938 (struct cmd_set_vf_broadcast_result,
12942 cmd_set_vf_broadcast_parsed(
12943 void *parsed_result,
12944 __attribute__((unused)) struct cmdline *cl,
12945 __attribute__((unused)) void *data)
12947 struct cmd_set_vf_broadcast_result *res = parsed_result;
12948 int ret = -ENOTSUP;
12950 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12952 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12955 #ifdef RTE_LIBRTE_I40E_PMD
12956 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12957 res->vf_id, is_on);
12964 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12967 printf("invalid port_id %d\n", res->port_id);
12970 printf("function not implemented\n");
12973 printf("programming error: (%s)\n", strerror(-ret));
12977 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12978 .f = cmd_set_vf_broadcast_parsed,
12980 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12982 (void *)&cmd_set_vf_broadcast_set,
12983 (void *)&cmd_set_vf_broadcast_vf,
12984 (void *)&cmd_set_vf_broadcast_broadcast,
12985 (void *)&cmd_set_vf_broadcast_port_id,
12986 (void *)&cmd_set_vf_broadcast_vf_id,
12987 (void *)&cmd_set_vf_broadcast_on_off,
12992 /* vf vlan tag configuration */
12994 /* Common result structure for vf vlan tag */
12995 struct cmd_set_vf_vlan_tag_result {
12996 cmdline_fixed_string_t set;
12997 cmdline_fixed_string_t vf;
12998 cmdline_fixed_string_t vlan;
12999 cmdline_fixed_string_t tag;
13002 cmdline_fixed_string_t on_off;
13005 /* Common CLI fields for vf vlan tag enable disable */
13006 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13007 TOKEN_STRING_INITIALIZER
13008 (struct cmd_set_vf_vlan_tag_result,
13010 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13011 TOKEN_STRING_INITIALIZER
13012 (struct cmd_set_vf_vlan_tag_result,
13014 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13015 TOKEN_STRING_INITIALIZER
13016 (struct cmd_set_vf_vlan_tag_result,
13018 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13019 TOKEN_STRING_INITIALIZER
13020 (struct cmd_set_vf_vlan_tag_result,
13022 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13023 TOKEN_NUM_INITIALIZER
13024 (struct cmd_set_vf_vlan_tag_result,
13026 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13027 TOKEN_NUM_INITIALIZER
13028 (struct cmd_set_vf_vlan_tag_result,
13030 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13031 TOKEN_STRING_INITIALIZER
13032 (struct cmd_set_vf_vlan_tag_result,
13036 cmd_set_vf_vlan_tag_parsed(
13037 void *parsed_result,
13038 __attribute__((unused)) struct cmdline *cl,
13039 __attribute__((unused)) void *data)
13041 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13042 int ret = -ENOTSUP;
13044 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13046 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13049 #ifdef RTE_LIBRTE_I40E_PMD
13050 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13051 res->vf_id, is_on);
13058 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13061 printf("invalid port_id %d\n", res->port_id);
13064 printf("function not implemented\n");
13067 printf("programming error: (%s)\n", strerror(-ret));
13071 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13072 .f = cmd_set_vf_vlan_tag_parsed,
13074 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13076 (void *)&cmd_set_vf_vlan_tag_set,
13077 (void *)&cmd_set_vf_vlan_tag_vf,
13078 (void *)&cmd_set_vf_vlan_tag_vlan,
13079 (void *)&cmd_set_vf_vlan_tag_tag,
13080 (void *)&cmd_set_vf_vlan_tag_port_id,
13081 (void *)&cmd_set_vf_vlan_tag_vf_id,
13082 (void *)&cmd_set_vf_vlan_tag_on_off,
13087 /* Common definition of VF and TC TX bandwidth configuration */
13088 struct cmd_vf_tc_bw_result {
13089 cmdline_fixed_string_t set;
13090 cmdline_fixed_string_t vf;
13091 cmdline_fixed_string_t tc;
13092 cmdline_fixed_string_t tx;
13093 cmdline_fixed_string_t min_bw;
13094 cmdline_fixed_string_t max_bw;
13095 cmdline_fixed_string_t strict_link_prio;
13100 cmdline_fixed_string_t bw_list;
13104 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13105 TOKEN_STRING_INITIALIZER
13106 (struct cmd_vf_tc_bw_result,
13108 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13109 TOKEN_STRING_INITIALIZER
13110 (struct cmd_vf_tc_bw_result,
13112 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13113 TOKEN_STRING_INITIALIZER
13114 (struct cmd_vf_tc_bw_result,
13116 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13117 TOKEN_STRING_INITIALIZER
13118 (struct cmd_vf_tc_bw_result,
13120 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13121 TOKEN_STRING_INITIALIZER
13122 (struct cmd_vf_tc_bw_result,
13123 strict_link_prio, "strict-link-priority");
13124 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13125 TOKEN_STRING_INITIALIZER
13126 (struct cmd_vf_tc_bw_result,
13127 min_bw, "min-bandwidth");
13128 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13129 TOKEN_STRING_INITIALIZER
13130 (struct cmd_vf_tc_bw_result,
13131 max_bw, "max-bandwidth");
13132 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13133 TOKEN_NUM_INITIALIZER
13134 (struct cmd_vf_tc_bw_result,
13136 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13137 TOKEN_NUM_INITIALIZER
13138 (struct cmd_vf_tc_bw_result,
13140 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13141 TOKEN_NUM_INITIALIZER
13142 (struct cmd_vf_tc_bw_result,
13144 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13145 TOKEN_NUM_INITIALIZER
13146 (struct cmd_vf_tc_bw_result,
13148 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13149 TOKEN_STRING_INITIALIZER
13150 (struct cmd_vf_tc_bw_result,
13152 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13153 TOKEN_NUM_INITIALIZER
13154 (struct cmd_vf_tc_bw_result,
13157 /* VF max bandwidth setting */
13159 cmd_vf_max_bw_parsed(
13160 void *parsed_result,
13161 __attribute__((unused)) struct cmdline *cl,
13162 __attribute__((unused)) void *data)
13164 struct cmd_vf_tc_bw_result *res = parsed_result;
13165 int ret = -ENOTSUP;
13167 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13170 #ifdef RTE_LIBRTE_I40E_PMD
13171 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13172 res->vf_id, res->bw);
13179 printf("invalid vf_id %d or bandwidth %d\n",
13180 res->vf_id, res->bw);
13183 printf("invalid port_id %d\n", res->port_id);
13186 printf("function not implemented\n");
13189 printf("programming error: (%s)\n", strerror(-ret));
13193 cmdline_parse_inst_t cmd_vf_max_bw = {
13194 .f = cmd_vf_max_bw_parsed,
13196 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13198 (void *)&cmd_vf_tc_bw_set,
13199 (void *)&cmd_vf_tc_bw_vf,
13200 (void *)&cmd_vf_tc_bw_tx,
13201 (void *)&cmd_vf_tc_bw_max_bw,
13202 (void *)&cmd_vf_tc_bw_port_id,
13203 (void *)&cmd_vf_tc_bw_vf_id,
13204 (void *)&cmd_vf_tc_bw_bw,
13210 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13215 const char *p, *p0 = str;
13222 p = strchr(p0, '(');
13224 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13228 p0 = strchr(p, ')');
13230 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13234 if (size >= sizeof(s)) {
13235 printf("The string size exceeds the internal buffer size\n");
13238 snprintf(s, sizeof(s), "%.*s", size, p);
13239 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13241 printf("Failed to get the bandwidth list. ");
13245 for (i = 0; i < ret; i++)
13246 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13251 /* TC min bandwidth setting */
13253 cmd_vf_tc_min_bw_parsed(
13254 void *parsed_result,
13255 __attribute__((unused)) struct cmdline *cl,
13256 __attribute__((unused)) void *data)
13258 struct cmd_vf_tc_bw_result *res = parsed_result;
13261 int ret = -ENOTSUP;
13263 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13266 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13270 #ifdef RTE_LIBRTE_I40E_PMD
13271 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13279 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13282 printf("invalid port_id %d\n", res->port_id);
13285 printf("function not implemented\n");
13288 printf("programming error: (%s)\n", strerror(-ret));
13292 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13293 .f = cmd_vf_tc_min_bw_parsed,
13295 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13296 " <bw1, bw2, ...>",
13298 (void *)&cmd_vf_tc_bw_set,
13299 (void *)&cmd_vf_tc_bw_vf,
13300 (void *)&cmd_vf_tc_bw_tc,
13301 (void *)&cmd_vf_tc_bw_tx,
13302 (void *)&cmd_vf_tc_bw_min_bw,
13303 (void *)&cmd_vf_tc_bw_port_id,
13304 (void *)&cmd_vf_tc_bw_vf_id,
13305 (void *)&cmd_vf_tc_bw_bw_list,
13311 cmd_tc_min_bw_parsed(
13312 void *parsed_result,
13313 __attribute__((unused)) struct cmdline *cl,
13314 __attribute__((unused)) void *data)
13316 struct cmd_vf_tc_bw_result *res = parsed_result;
13317 struct rte_port *port;
13320 int ret = -ENOTSUP;
13322 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13325 port = &ports[res->port_id];
13326 /** Check if the port is not started **/
13327 if (port->port_status != RTE_PORT_STOPPED) {
13328 printf("Please stop port %d first\n", res->port_id);
13332 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13336 #ifdef RTE_LIBRTE_IXGBE_PMD
13337 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13344 printf("invalid bandwidth\n");
13347 printf("invalid port_id %d\n", res->port_id);
13350 printf("function not implemented\n");
13353 printf("programming error: (%s)\n", strerror(-ret));
13357 cmdline_parse_inst_t cmd_tc_min_bw = {
13358 .f = cmd_tc_min_bw_parsed,
13360 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13362 (void *)&cmd_vf_tc_bw_set,
13363 (void *)&cmd_vf_tc_bw_tc,
13364 (void *)&cmd_vf_tc_bw_tx,
13365 (void *)&cmd_vf_tc_bw_min_bw,
13366 (void *)&cmd_vf_tc_bw_port_id,
13367 (void *)&cmd_vf_tc_bw_bw_list,
13372 /* TC max bandwidth setting */
13374 cmd_vf_tc_max_bw_parsed(
13375 void *parsed_result,
13376 __attribute__((unused)) struct cmdline *cl,
13377 __attribute__((unused)) void *data)
13379 struct cmd_vf_tc_bw_result *res = parsed_result;
13380 int ret = -ENOTSUP;
13382 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13385 #ifdef RTE_LIBRTE_I40E_PMD
13386 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13387 res->tc_no, res->bw);
13394 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13395 res->vf_id, res->tc_no, res->bw);
13398 printf("invalid port_id %d\n", res->port_id);
13401 printf("function not implemented\n");
13404 printf("programming error: (%s)\n", strerror(-ret));
13408 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13409 .f = cmd_vf_tc_max_bw_parsed,
13411 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13414 (void *)&cmd_vf_tc_bw_set,
13415 (void *)&cmd_vf_tc_bw_vf,
13416 (void *)&cmd_vf_tc_bw_tc,
13417 (void *)&cmd_vf_tc_bw_tx,
13418 (void *)&cmd_vf_tc_bw_max_bw,
13419 (void *)&cmd_vf_tc_bw_port_id,
13420 (void *)&cmd_vf_tc_bw_vf_id,
13421 (void *)&cmd_vf_tc_bw_tc_no,
13422 (void *)&cmd_vf_tc_bw_bw,
13427 /* Strict link priority scheduling mode setting */
13429 cmd_strict_link_prio_parsed(
13430 void *parsed_result,
13431 __attribute__((unused)) struct cmdline *cl,
13432 __attribute__((unused)) void *data)
13434 struct cmd_vf_tc_bw_result *res = parsed_result;
13435 int ret = -ENOTSUP;
13437 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13440 #ifdef RTE_LIBRTE_I40E_PMD
13441 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13448 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13451 printf("invalid port_id %d\n", res->port_id);
13454 printf("function not implemented\n");
13457 printf("programming error: (%s)\n", strerror(-ret));
13461 cmdline_parse_inst_t cmd_strict_link_prio = {
13462 .f = cmd_strict_link_prio_parsed,
13464 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13466 (void *)&cmd_vf_tc_bw_set,
13467 (void *)&cmd_vf_tc_bw_tx,
13468 (void *)&cmd_vf_tc_bw_strict_link_prio,
13469 (void *)&cmd_vf_tc_bw_port_id,
13470 (void *)&cmd_vf_tc_bw_tc_map,
13475 /* Load dynamic device personalization*/
13476 struct cmd_ddp_add_result {
13477 cmdline_fixed_string_t ddp;
13478 cmdline_fixed_string_t add;
13483 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13484 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13485 cmdline_parse_token_string_t cmd_ddp_add_add =
13486 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13487 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13488 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
13489 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13490 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13493 cmd_ddp_add_parsed(
13494 void *parsed_result,
13495 __attribute__((unused)) struct cmdline *cl,
13496 __attribute__((unused)) void *data)
13498 struct cmd_ddp_add_result *res = parsed_result;
13504 int ret = -ENOTSUP;
13506 if (res->port_id > nb_ports) {
13507 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13511 if (!all_ports_stopped()) {
13512 printf("Please stop all ports first\n");
13516 filepath = strdup(res->filepath);
13517 if (filepath == NULL) {
13518 printf("Failed to allocate memory\n");
13521 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13523 buff = open_ddp_package_file(file_fld[0], &size);
13525 free((void *)filepath);
13529 #ifdef RTE_LIBRTE_I40E_PMD
13530 if (ret == -ENOTSUP)
13531 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13533 RTE_PMD_I40E_PKG_OP_WR_ADD);
13536 if (ret == -EEXIST)
13537 printf("Profile has already existed.\n");
13539 printf("Failed to load profile.\n");
13540 else if (file_num == 2)
13541 save_ddp_package_file(file_fld[1], buff, size);
13543 close_ddp_package_file(buff);
13544 free((void *)filepath);
13547 cmdline_parse_inst_t cmd_ddp_add = {
13548 .f = cmd_ddp_add_parsed,
13550 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
13552 (void *)&cmd_ddp_add_ddp,
13553 (void *)&cmd_ddp_add_add,
13554 (void *)&cmd_ddp_add_port_id,
13555 (void *)&cmd_ddp_add_filepath,
13560 /* Delete dynamic device personalization*/
13561 struct cmd_ddp_del_result {
13562 cmdline_fixed_string_t ddp;
13563 cmdline_fixed_string_t del;
13568 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13569 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13570 cmdline_parse_token_string_t cmd_ddp_del_del =
13571 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13572 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13573 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT8);
13574 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13575 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13578 cmd_ddp_del_parsed(
13579 void *parsed_result,
13580 __attribute__((unused)) struct cmdline *cl,
13581 __attribute__((unused)) void *data)
13583 struct cmd_ddp_del_result *res = parsed_result;
13586 int ret = -ENOTSUP;
13588 if (res->port_id > nb_ports) {
13589 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13593 if (!all_ports_stopped()) {
13594 printf("Please stop all ports first\n");
13598 buff = open_ddp_package_file(res->filepath, &size);
13602 #ifdef RTE_LIBRTE_I40E_PMD
13603 if (ret == -ENOTSUP)
13604 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13606 RTE_PMD_I40E_PKG_OP_WR_DEL);
13609 if (ret == -EACCES)
13610 printf("Profile does not exist.\n");
13612 printf("Failed to delete profile.\n");
13614 close_ddp_package_file(buff);
13617 cmdline_parse_inst_t cmd_ddp_del = {
13618 .f = cmd_ddp_del_parsed,
13620 .help_str = "ddp del <port_id> <profile_path>",
13622 (void *)&cmd_ddp_del_ddp,
13623 (void *)&cmd_ddp_del_del,
13624 (void *)&cmd_ddp_del_port_id,
13625 (void *)&cmd_ddp_del_filepath,
13630 /* Get dynamic device personalization profile info */
13631 struct cmd_ddp_info_result {
13632 cmdline_fixed_string_t ddp;
13633 cmdline_fixed_string_t get;
13634 cmdline_fixed_string_t info;
13638 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13639 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13640 cmdline_parse_token_string_t cmd_ddp_info_get =
13641 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13642 cmdline_parse_token_string_t cmd_ddp_info_info =
13643 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13644 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13645 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13648 cmd_ddp_info_parsed(
13649 void *parsed_result,
13650 __attribute__((unused)) struct cmdline *cl,
13651 __attribute__((unused)) void *data)
13653 struct cmd_ddp_info_result *res = parsed_result;
13656 int ret = -ENOTSUP;
13657 #ifdef RTE_LIBRTE_I40E_PMD
13660 uint32_t buff_size = 0;
13661 struct rte_pmd_i40e_profile_info info;
13662 uint32_t dev_num = 0;
13663 struct rte_pmd_i40e_ddp_device_id *devs;
13664 uint32_t proto_num = 0;
13665 struct rte_pmd_i40e_proto_info *proto;
13666 uint32_t pctype_num = 0;
13667 struct rte_pmd_i40e_ptype_info *pctype;
13668 uint32_t ptype_num = 0;
13669 struct rte_pmd_i40e_ptype_info *ptype;
13674 pkg = open_ddp_package_file(res->filepath, &pkg_size);
13678 #ifdef RTE_LIBRTE_I40E_PMD
13679 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13680 (uint8_t *)&info, sizeof(info),
13681 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13683 printf("Global Track id: 0x%x\n", info.track_id);
13684 printf("Global Version: %d.%d.%d.%d\n",
13685 info.version.major,
13686 info.version.minor,
13687 info.version.update,
13688 info.version.draft);
13689 printf("Global Package name: %s\n\n", info.name);
13692 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13693 (uint8_t *)&info, sizeof(info),
13694 RTE_PMD_I40E_PKG_INFO_HEADER);
13696 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13697 printf("i40e Profile Version: %d.%d.%d.%d\n",
13698 info.version.major,
13699 info.version.minor,
13700 info.version.update,
13701 info.version.draft);
13702 printf("i40e Profile name: %s\n\n", info.name);
13705 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13706 (uint8_t *)&buff_size, sizeof(buff_size),
13707 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13708 if (!ret && buff_size) {
13709 buff = (uint8_t *)malloc(buff_size);
13711 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13713 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13715 printf("Package Notes:\n%s\n\n", buff);
13720 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13721 (uint8_t *)&dev_num, sizeof(dev_num),
13722 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13723 if (!ret && dev_num) {
13724 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
13725 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
13727 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13728 (uint8_t *)devs, buff_size,
13729 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13731 printf("List of supported devices:\n");
13732 for (i = 0; i < dev_num; i++) {
13733 printf(" %04X:%04X %04X:%04X\n",
13734 devs[i].vendor_dev_id >> 16,
13735 devs[i].vendor_dev_id & 0xFFFF,
13736 devs[i].sub_vendor_dev_id >> 16,
13737 devs[i].sub_vendor_dev_id & 0xFFFF);
13745 /* get information about protocols and packet types */
13746 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13747 (uint8_t *)&proto_num, sizeof(proto_num),
13748 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
13749 if (ret || !proto_num)
13750 goto no_print_return;
13752 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
13753 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
13755 goto no_print_return;
13757 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
13759 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
13761 printf("List of used protocols:\n");
13762 for (i = 0; i < proto_num; i++)
13763 printf(" %2u: %s\n", proto[i].proto_id,
13767 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13768 (uint8_t *)&pctype_num, sizeof(pctype_num),
13769 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
13770 if (ret || !pctype_num)
13771 goto no_print_pctypes;
13773 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13774 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13776 goto no_print_pctypes;
13778 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
13780 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
13783 goto no_print_pctypes;
13786 printf("List of defined packet classification types:\n");
13787 for (i = 0; i < pctype_num; i++) {
13788 printf(" %2u:", pctype[i].ptype_id);
13789 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13790 proto_id = pctype[i].protocols[j];
13791 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13792 for (n = 0; n < proto_num; n++) {
13793 if (proto[n].proto_id == proto_id) {
13794 printf(" %s", proto[n].name);
13807 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
13809 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
13810 if (ret || !ptype_num)
13811 goto no_print_return;
13813 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13814 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13816 goto no_print_return;
13818 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
13820 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
13823 goto no_print_return;
13825 printf("List of defined packet types:\n");
13826 for (i = 0; i < ptype_num; i++) {
13827 printf(" %2u:", ptype[i].ptype_id);
13828 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13829 proto_id = ptype[i].protocols[j];
13830 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13831 for (n = 0; n < proto_num; n++) {
13832 if (proto[n].proto_id == proto_id) {
13833 printf(" %s", proto[n].name);
13848 if (ret == -ENOTSUP)
13849 printf("Function not supported in PMD driver\n");
13850 close_ddp_package_file(pkg);
13853 cmdline_parse_inst_t cmd_ddp_get_info = {
13854 .f = cmd_ddp_info_parsed,
13856 .help_str = "ddp get info <profile_path>",
13858 (void *)&cmd_ddp_info_ddp,
13859 (void *)&cmd_ddp_info_get,
13860 (void *)&cmd_ddp_info_info,
13861 (void *)&cmd_ddp_info_filepath,
13866 /* Get dynamic device personalization profile info list*/
13867 #define PROFILE_INFO_SIZE 48
13868 #define MAX_PROFILE_NUM 16
13870 struct cmd_ddp_get_list_result {
13871 cmdline_fixed_string_t ddp;
13872 cmdline_fixed_string_t get;
13873 cmdline_fixed_string_t list;
13877 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
13878 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
13879 cmdline_parse_token_string_t cmd_ddp_get_list_get =
13880 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
13881 cmdline_parse_token_string_t cmd_ddp_get_list_list =
13882 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
13883 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
13884 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
13887 cmd_ddp_get_list_parsed(
13888 void *parsed_result,
13889 __attribute__((unused)) struct cmdline *cl,
13890 __attribute__((unused)) void *data)
13892 struct cmd_ddp_get_list_result *res = parsed_result;
13893 #ifdef RTE_LIBRTE_I40E_PMD
13894 struct rte_pmd_i40e_profile_list *p_list;
13895 struct rte_pmd_i40e_profile_info *p_info;
13900 int ret = -ENOTSUP;
13902 if (res->port_id > nb_ports) {
13903 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13907 #ifdef RTE_LIBRTE_I40E_PMD
13908 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
13909 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
13911 printf("%s: Failed to malloc buffer\n", __func__);
13913 if (ret == -ENOTSUP)
13914 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
13915 (uint8_t *)p_list, size);
13918 p_num = p_list->p_count;
13919 printf("Profile number is: %d\n\n", p_num);
13921 for (i = 0; i < p_num; i++) {
13922 p_info = &p_list->p_info[i];
13923 printf("Profile %d:\n", i);
13924 printf("Track id: 0x%x\n", p_info->track_id);
13925 printf("Version: %d.%d.%d.%d\n",
13926 p_info->version.major,
13927 p_info->version.minor,
13928 p_info->version.update,
13929 p_info->version.draft);
13930 printf("Profile name: %s\n\n", p_info->name);
13938 printf("Failed to get ddp list\n");
13941 cmdline_parse_inst_t cmd_ddp_get_list = {
13942 .f = cmd_ddp_get_list_parsed,
13944 .help_str = "ddp get list <port_id>",
13946 (void *)&cmd_ddp_get_list_ddp,
13947 (void *)&cmd_ddp_get_list_get,
13948 (void *)&cmd_ddp_get_list_list,
13949 (void *)&cmd_ddp_get_list_port_id,
13954 /* show vf stats */
13956 /* Common result structure for show vf stats */
13957 struct cmd_show_vf_stats_result {
13958 cmdline_fixed_string_t show;
13959 cmdline_fixed_string_t vf;
13960 cmdline_fixed_string_t stats;
13965 /* Common CLI fields show vf stats*/
13966 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13967 TOKEN_STRING_INITIALIZER
13968 (struct cmd_show_vf_stats_result,
13970 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13971 TOKEN_STRING_INITIALIZER
13972 (struct cmd_show_vf_stats_result,
13974 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13975 TOKEN_STRING_INITIALIZER
13976 (struct cmd_show_vf_stats_result,
13978 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13979 TOKEN_NUM_INITIALIZER
13980 (struct cmd_show_vf_stats_result,
13982 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13983 TOKEN_NUM_INITIALIZER
13984 (struct cmd_show_vf_stats_result,
13988 cmd_show_vf_stats_parsed(
13989 void *parsed_result,
13990 __attribute__((unused)) struct cmdline *cl,
13991 __attribute__((unused)) void *data)
13993 struct cmd_show_vf_stats_result *res = parsed_result;
13994 struct rte_eth_stats stats;
13995 int ret = -ENOTSUP;
13996 static const char *nic_stats_border = "########################";
13998 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14001 memset(&stats, 0, sizeof(stats));
14003 #ifdef RTE_LIBRTE_I40E_PMD
14004 if (ret == -ENOTSUP)
14005 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14009 #ifdef RTE_LIBRTE_BNXT_PMD
14010 if (ret == -ENOTSUP)
14011 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14020 printf("invalid vf_id %d\n", res->vf_id);
14023 printf("invalid port_id %d\n", res->port_id);
14026 printf("function not implemented\n");
14029 printf("programming error: (%s)\n", strerror(-ret));
14032 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14033 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14035 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14037 stats.ipackets, stats.imissed, stats.ibytes);
14038 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14039 printf(" RX-nombuf: %-10"PRIu64"\n",
14041 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14043 stats.opackets, stats.oerrors, stats.obytes);
14045 printf(" %s############################%s\n",
14046 nic_stats_border, nic_stats_border);
14049 cmdline_parse_inst_t cmd_show_vf_stats = {
14050 .f = cmd_show_vf_stats_parsed,
14052 .help_str = "show vf stats <port_id> <vf_id>",
14054 (void *)&cmd_show_vf_stats_show,
14055 (void *)&cmd_show_vf_stats_vf,
14056 (void *)&cmd_show_vf_stats_stats,
14057 (void *)&cmd_show_vf_stats_port_id,
14058 (void *)&cmd_show_vf_stats_vf_id,
14063 /* clear vf stats */
14065 /* Common result structure for clear vf stats */
14066 struct cmd_clear_vf_stats_result {
14067 cmdline_fixed_string_t clear;
14068 cmdline_fixed_string_t vf;
14069 cmdline_fixed_string_t stats;
14074 /* Common CLI fields clear vf stats*/
14075 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14076 TOKEN_STRING_INITIALIZER
14077 (struct cmd_clear_vf_stats_result,
14079 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14080 TOKEN_STRING_INITIALIZER
14081 (struct cmd_clear_vf_stats_result,
14083 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14084 TOKEN_STRING_INITIALIZER
14085 (struct cmd_clear_vf_stats_result,
14087 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14088 TOKEN_NUM_INITIALIZER
14089 (struct cmd_clear_vf_stats_result,
14091 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14092 TOKEN_NUM_INITIALIZER
14093 (struct cmd_clear_vf_stats_result,
14097 cmd_clear_vf_stats_parsed(
14098 void *parsed_result,
14099 __attribute__((unused)) struct cmdline *cl,
14100 __attribute__((unused)) void *data)
14102 struct cmd_clear_vf_stats_result *res = parsed_result;
14103 int ret = -ENOTSUP;
14105 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14108 #ifdef RTE_LIBRTE_I40E_PMD
14109 if (ret == -ENOTSUP)
14110 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14113 #ifdef RTE_LIBRTE_BNXT_PMD
14114 if (ret == -ENOTSUP)
14115 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14123 printf("invalid vf_id %d\n", res->vf_id);
14126 printf("invalid port_id %d\n", res->port_id);
14129 printf("function not implemented\n");
14132 printf("programming error: (%s)\n", strerror(-ret));
14136 cmdline_parse_inst_t cmd_clear_vf_stats = {
14137 .f = cmd_clear_vf_stats_parsed,
14139 .help_str = "clear vf stats <port_id> <vf_id>",
14141 (void *)&cmd_clear_vf_stats_clear,
14142 (void *)&cmd_clear_vf_stats_vf,
14143 (void *)&cmd_clear_vf_stats_stats,
14144 (void *)&cmd_clear_vf_stats_port_id,
14145 (void *)&cmd_clear_vf_stats_vf_id,
14150 /* port config pctype mapping reset */
14152 /* Common result structure for port config pctype mapping reset */
14153 struct cmd_pctype_mapping_reset_result {
14154 cmdline_fixed_string_t port;
14155 cmdline_fixed_string_t config;
14157 cmdline_fixed_string_t pctype;
14158 cmdline_fixed_string_t mapping;
14159 cmdline_fixed_string_t reset;
14162 /* Common CLI fields for port config pctype mapping reset*/
14163 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14164 TOKEN_STRING_INITIALIZER
14165 (struct cmd_pctype_mapping_reset_result,
14167 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14168 TOKEN_STRING_INITIALIZER
14169 (struct cmd_pctype_mapping_reset_result,
14171 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14172 TOKEN_NUM_INITIALIZER
14173 (struct cmd_pctype_mapping_reset_result,
14175 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14176 TOKEN_STRING_INITIALIZER
14177 (struct cmd_pctype_mapping_reset_result,
14179 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14180 TOKEN_STRING_INITIALIZER
14181 (struct cmd_pctype_mapping_reset_result,
14182 mapping, "mapping");
14183 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14184 TOKEN_STRING_INITIALIZER
14185 (struct cmd_pctype_mapping_reset_result,
14189 cmd_pctype_mapping_reset_parsed(
14190 void *parsed_result,
14191 __attribute__((unused)) struct cmdline *cl,
14192 __attribute__((unused)) void *data)
14194 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14195 int ret = -ENOTSUP;
14197 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14200 #ifdef RTE_LIBRTE_I40E_PMD
14201 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
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_reset = {
14219 .f = cmd_pctype_mapping_reset_parsed,
14221 .help_str = "port config <port_id> pctype mapping reset",
14223 (void *)&cmd_pctype_mapping_reset_port,
14224 (void *)&cmd_pctype_mapping_reset_config,
14225 (void *)&cmd_pctype_mapping_reset_port_id,
14226 (void *)&cmd_pctype_mapping_reset_pctype,
14227 (void *)&cmd_pctype_mapping_reset_mapping,
14228 (void *)&cmd_pctype_mapping_reset_reset,
14233 /* show port pctype mapping */
14235 /* Common result structure for show port pctype mapping */
14236 struct cmd_pctype_mapping_get_result {
14237 cmdline_fixed_string_t show;
14238 cmdline_fixed_string_t port;
14240 cmdline_fixed_string_t pctype;
14241 cmdline_fixed_string_t mapping;
14244 /* Common CLI fields for pctype mapping get */
14245 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14246 TOKEN_STRING_INITIALIZER
14247 (struct cmd_pctype_mapping_get_result,
14249 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14250 TOKEN_STRING_INITIALIZER
14251 (struct cmd_pctype_mapping_get_result,
14253 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14254 TOKEN_NUM_INITIALIZER
14255 (struct cmd_pctype_mapping_get_result,
14257 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14258 TOKEN_STRING_INITIALIZER
14259 (struct cmd_pctype_mapping_get_result,
14261 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14262 TOKEN_STRING_INITIALIZER
14263 (struct cmd_pctype_mapping_get_result,
14264 mapping, "mapping");
14267 cmd_pctype_mapping_get_parsed(
14268 void *parsed_result,
14269 __attribute__((unused)) struct cmdline *cl,
14270 __attribute__((unused)) void *data)
14272 struct cmd_pctype_mapping_get_result *res = parsed_result;
14273 int ret = -ENOTSUP;
14274 #ifdef RTE_LIBRTE_I40E_PMD
14275 struct rte_pmd_i40e_flow_type_mapping
14276 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14277 int i, j, first_pctype;
14280 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14283 #ifdef RTE_LIBRTE_I40E_PMD
14284 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14291 printf("invalid port_id %d\n", res->port_id);
14294 printf("function not implemented\n");
14297 printf("programming error: (%s)\n", strerror(-ret));
14301 #ifdef RTE_LIBRTE_I40E_PMD
14302 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14303 if (mapping[i].pctype != 0ULL) {
14306 printf("pctype: ");
14307 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14308 if (mapping[i].pctype & (1ULL << j)) {
14309 printf(first_pctype ?
14310 "%02d" : ",%02d", j);
14314 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14320 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14321 .f = cmd_pctype_mapping_get_parsed,
14323 .help_str = "show port <port_id> pctype mapping",
14325 (void *)&cmd_pctype_mapping_get_show,
14326 (void *)&cmd_pctype_mapping_get_port,
14327 (void *)&cmd_pctype_mapping_get_port_id,
14328 (void *)&cmd_pctype_mapping_get_pctype,
14329 (void *)&cmd_pctype_mapping_get_mapping,
14334 /* port config pctype mapping update */
14336 /* Common result structure for port config pctype mapping update */
14337 struct cmd_pctype_mapping_update_result {
14338 cmdline_fixed_string_t port;
14339 cmdline_fixed_string_t config;
14341 cmdline_fixed_string_t pctype;
14342 cmdline_fixed_string_t mapping;
14343 cmdline_fixed_string_t update;
14344 cmdline_fixed_string_t pctype_list;
14345 uint16_t flow_type;
14348 /* Common CLI fields for pctype mapping update*/
14349 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14350 TOKEN_STRING_INITIALIZER
14351 (struct cmd_pctype_mapping_update_result,
14353 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14354 TOKEN_STRING_INITIALIZER
14355 (struct cmd_pctype_mapping_update_result,
14357 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14358 TOKEN_NUM_INITIALIZER
14359 (struct cmd_pctype_mapping_update_result,
14361 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14362 TOKEN_STRING_INITIALIZER
14363 (struct cmd_pctype_mapping_update_result,
14365 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14366 TOKEN_STRING_INITIALIZER
14367 (struct cmd_pctype_mapping_update_result,
14368 mapping, "mapping");
14369 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
14370 TOKEN_STRING_INITIALIZER
14371 (struct cmd_pctype_mapping_update_result,
14373 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
14374 TOKEN_STRING_INITIALIZER
14375 (struct cmd_pctype_mapping_update_result,
14376 pctype_list, NULL);
14377 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
14378 TOKEN_NUM_INITIALIZER
14379 (struct cmd_pctype_mapping_update_result,
14380 flow_type, UINT16);
14383 cmd_pctype_mapping_update_parsed(
14384 void *parsed_result,
14385 __attribute__((unused)) struct cmdline *cl,
14386 __attribute__((unused)) void *data)
14388 struct cmd_pctype_mapping_update_result *res = parsed_result;
14389 int ret = -ENOTSUP;
14390 #ifdef RTE_LIBRTE_I40E_PMD
14391 struct rte_pmd_i40e_flow_type_mapping mapping;
14393 unsigned int nb_item;
14394 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
14397 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14400 #ifdef RTE_LIBRTE_I40E_PMD
14401 nb_item = parse_item_list(res->pctype_list, "pctypes",
14402 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
14403 mapping.flow_type = res->flow_type;
14404 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
14405 mapping.pctype |= (1ULL << pctype_list[i]);
14406 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
14416 printf("invalid pctype or flow type\n");
14419 printf("invalid port_id %d\n", res->port_id);
14422 printf("function not implemented\n");
14425 printf("programming error: (%s)\n", strerror(-ret));
14429 cmdline_parse_inst_t cmd_pctype_mapping_update = {
14430 .f = cmd_pctype_mapping_update_parsed,
14432 .help_str = "port config <port_id> pctype mapping update"
14433 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
14435 (void *)&cmd_pctype_mapping_update_port,
14436 (void *)&cmd_pctype_mapping_update_config,
14437 (void *)&cmd_pctype_mapping_update_port_id,
14438 (void *)&cmd_pctype_mapping_update_pctype,
14439 (void *)&cmd_pctype_mapping_update_mapping,
14440 (void *)&cmd_pctype_mapping_update_update,
14441 (void *)&cmd_pctype_mapping_update_pc_type,
14442 (void *)&cmd_pctype_mapping_update_flow_type,
14447 /* ptype mapping get */
14449 /* Common result structure for ptype mapping get */
14450 struct cmd_ptype_mapping_get_result {
14451 cmdline_fixed_string_t ptype;
14452 cmdline_fixed_string_t mapping;
14453 cmdline_fixed_string_t get;
14455 uint8_t valid_only;
14458 /* Common CLI fields for ptype mapping get */
14459 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
14460 TOKEN_STRING_INITIALIZER
14461 (struct cmd_ptype_mapping_get_result,
14463 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
14464 TOKEN_STRING_INITIALIZER
14465 (struct cmd_ptype_mapping_get_result,
14466 mapping, "mapping");
14467 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
14468 TOKEN_STRING_INITIALIZER
14469 (struct cmd_ptype_mapping_get_result,
14471 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
14472 TOKEN_NUM_INITIALIZER
14473 (struct cmd_ptype_mapping_get_result,
14475 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
14476 TOKEN_NUM_INITIALIZER
14477 (struct cmd_ptype_mapping_get_result,
14478 valid_only, UINT8);
14481 cmd_ptype_mapping_get_parsed(
14482 void *parsed_result,
14483 __attribute__((unused)) struct cmdline *cl,
14484 __attribute__((unused)) void *data)
14486 struct cmd_ptype_mapping_get_result *res = parsed_result;
14487 int ret = -ENOTSUP;
14488 #ifdef RTE_LIBRTE_I40E_PMD
14489 int max_ptype_num = 256;
14490 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
14495 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14498 #ifdef RTE_LIBRTE_I40E_PMD
14499 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
14510 printf("invalid port_id %d\n", res->port_id);
14513 printf("function not implemented\n");
14516 printf("programming error: (%s)\n", strerror(-ret));
14519 #ifdef RTE_LIBRTE_I40E_PMD
14521 for (i = 0; i < count; i++)
14522 printf("%3d\t0x%08x\n",
14523 mapping[i].hw_ptype, mapping[i].sw_ptype);
14528 cmdline_parse_inst_t cmd_ptype_mapping_get = {
14529 .f = cmd_ptype_mapping_get_parsed,
14531 .help_str = "ptype mapping get <port_id> <valid_only>",
14533 (void *)&cmd_ptype_mapping_get_ptype,
14534 (void *)&cmd_ptype_mapping_get_mapping,
14535 (void *)&cmd_ptype_mapping_get_get,
14536 (void *)&cmd_ptype_mapping_get_port_id,
14537 (void *)&cmd_ptype_mapping_get_valid_only,
14542 /* ptype mapping replace */
14544 /* Common result structure for ptype mapping replace */
14545 struct cmd_ptype_mapping_replace_result {
14546 cmdline_fixed_string_t ptype;
14547 cmdline_fixed_string_t mapping;
14548 cmdline_fixed_string_t replace;
14555 /* Common CLI fields for ptype mapping replace */
14556 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
14557 TOKEN_STRING_INITIALIZER
14558 (struct cmd_ptype_mapping_replace_result,
14560 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
14561 TOKEN_STRING_INITIALIZER
14562 (struct cmd_ptype_mapping_replace_result,
14563 mapping, "mapping");
14564 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
14565 TOKEN_STRING_INITIALIZER
14566 (struct cmd_ptype_mapping_replace_result,
14567 replace, "replace");
14568 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
14569 TOKEN_NUM_INITIALIZER
14570 (struct cmd_ptype_mapping_replace_result,
14572 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
14573 TOKEN_NUM_INITIALIZER
14574 (struct cmd_ptype_mapping_replace_result,
14576 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
14577 TOKEN_NUM_INITIALIZER
14578 (struct cmd_ptype_mapping_replace_result,
14580 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
14581 TOKEN_NUM_INITIALIZER
14582 (struct cmd_ptype_mapping_replace_result,
14586 cmd_ptype_mapping_replace_parsed(
14587 void *parsed_result,
14588 __attribute__((unused)) struct cmdline *cl,
14589 __attribute__((unused)) void *data)
14591 struct cmd_ptype_mapping_replace_result *res = parsed_result;
14592 int ret = -ENOTSUP;
14594 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14597 #ifdef RTE_LIBRTE_I40E_PMD
14598 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
14608 printf("invalid ptype 0x%8x or 0x%8x\n",
14609 res->target, res->pkt_type);
14612 printf("invalid port_id %d\n", res->port_id);
14615 printf("function not implemented\n");
14618 printf("programming error: (%s)\n", strerror(-ret));
14622 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
14623 .f = cmd_ptype_mapping_replace_parsed,
14626 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
14628 (void *)&cmd_ptype_mapping_replace_ptype,
14629 (void *)&cmd_ptype_mapping_replace_mapping,
14630 (void *)&cmd_ptype_mapping_replace_replace,
14631 (void *)&cmd_ptype_mapping_replace_port_id,
14632 (void *)&cmd_ptype_mapping_replace_target,
14633 (void *)&cmd_ptype_mapping_replace_mask,
14634 (void *)&cmd_ptype_mapping_replace_pkt_type,
14639 /* ptype mapping reset */
14641 /* Common result structure for ptype mapping reset */
14642 struct cmd_ptype_mapping_reset_result {
14643 cmdline_fixed_string_t ptype;
14644 cmdline_fixed_string_t mapping;
14645 cmdline_fixed_string_t reset;
14649 /* Common CLI fields for ptype mapping reset*/
14650 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
14651 TOKEN_STRING_INITIALIZER
14652 (struct cmd_ptype_mapping_reset_result,
14654 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
14655 TOKEN_STRING_INITIALIZER
14656 (struct cmd_ptype_mapping_reset_result,
14657 mapping, "mapping");
14658 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
14659 TOKEN_STRING_INITIALIZER
14660 (struct cmd_ptype_mapping_reset_result,
14662 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
14663 TOKEN_NUM_INITIALIZER
14664 (struct cmd_ptype_mapping_reset_result,
14668 cmd_ptype_mapping_reset_parsed(
14669 void *parsed_result,
14670 __attribute__((unused)) struct cmdline *cl,
14671 __attribute__((unused)) void *data)
14673 struct cmd_ptype_mapping_reset_result *res = parsed_result;
14674 int ret = -ENOTSUP;
14676 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14679 #ifdef RTE_LIBRTE_I40E_PMD
14680 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
14687 printf("invalid port_id %d\n", res->port_id);
14690 printf("function not implemented\n");
14693 printf("programming error: (%s)\n", strerror(-ret));
14697 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
14698 .f = cmd_ptype_mapping_reset_parsed,
14700 .help_str = "ptype mapping reset <port_id>",
14702 (void *)&cmd_ptype_mapping_reset_ptype,
14703 (void *)&cmd_ptype_mapping_reset_mapping,
14704 (void *)&cmd_ptype_mapping_reset_reset,
14705 (void *)&cmd_ptype_mapping_reset_port_id,
14710 /* ptype mapping update */
14712 /* Common result structure for ptype mapping update */
14713 struct cmd_ptype_mapping_update_result {
14714 cmdline_fixed_string_t ptype;
14715 cmdline_fixed_string_t mapping;
14716 cmdline_fixed_string_t reset;
14722 /* Common CLI fields for ptype mapping update*/
14723 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
14724 TOKEN_STRING_INITIALIZER
14725 (struct cmd_ptype_mapping_update_result,
14727 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
14728 TOKEN_STRING_INITIALIZER
14729 (struct cmd_ptype_mapping_update_result,
14730 mapping, "mapping");
14731 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
14732 TOKEN_STRING_INITIALIZER
14733 (struct cmd_ptype_mapping_update_result,
14735 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
14736 TOKEN_NUM_INITIALIZER
14737 (struct cmd_ptype_mapping_update_result,
14739 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
14740 TOKEN_NUM_INITIALIZER
14741 (struct cmd_ptype_mapping_update_result,
14743 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
14744 TOKEN_NUM_INITIALIZER
14745 (struct cmd_ptype_mapping_update_result,
14749 cmd_ptype_mapping_update_parsed(
14750 void *parsed_result,
14751 __attribute__((unused)) struct cmdline *cl,
14752 __attribute__((unused)) void *data)
14754 struct cmd_ptype_mapping_update_result *res = parsed_result;
14755 int ret = -ENOTSUP;
14756 #ifdef RTE_LIBRTE_I40E_PMD
14757 struct rte_pmd_i40e_ptype_mapping mapping;
14759 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14762 #ifdef RTE_LIBRTE_I40E_PMD
14763 mapping.hw_ptype = res->hw_ptype;
14764 mapping.sw_ptype = res->sw_ptype;
14765 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
14775 printf("invalid ptype 0x%8x\n", res->sw_ptype);
14778 printf("invalid port_id %d\n", res->port_id);
14781 printf("function not implemented\n");
14784 printf("programming error: (%s)\n", strerror(-ret));
14788 cmdline_parse_inst_t cmd_ptype_mapping_update = {
14789 .f = cmd_ptype_mapping_update_parsed,
14791 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
14793 (void *)&cmd_ptype_mapping_update_ptype,
14794 (void *)&cmd_ptype_mapping_update_mapping,
14795 (void *)&cmd_ptype_mapping_update_update,
14796 (void *)&cmd_ptype_mapping_update_port_id,
14797 (void *)&cmd_ptype_mapping_update_hw_ptype,
14798 (void *)&cmd_ptype_mapping_update_sw_ptype,
14803 /* Common result structure for file commands */
14804 struct cmd_cmdfile_result {
14805 cmdline_fixed_string_t load;
14806 cmdline_fixed_string_t filename;
14809 /* Common CLI fields for file commands */
14810 cmdline_parse_token_string_t cmd_load_cmdfile =
14811 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
14812 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
14813 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
14816 cmd_load_from_file_parsed(
14817 void *parsed_result,
14818 __attribute__((unused)) struct cmdline *cl,
14819 __attribute__((unused)) void *data)
14821 struct cmd_cmdfile_result *res = parsed_result;
14823 cmdline_read_from_file(res->filename);
14826 cmdline_parse_inst_t cmd_load_from_file = {
14827 .f = cmd_load_from_file_parsed,
14829 .help_str = "load <filename>",
14831 (void *)&cmd_load_cmdfile,
14832 (void *)&cmd_load_cmdfile_filename,
14837 /* ******************************************************************************** */
14839 /* list of instructions */
14840 cmdline_parse_ctx_t main_ctx[] = {
14841 (cmdline_parse_inst_t *)&cmd_help_brief,
14842 (cmdline_parse_inst_t *)&cmd_help_long,
14843 (cmdline_parse_inst_t *)&cmd_quit,
14844 (cmdline_parse_inst_t *)&cmd_load_from_file,
14845 (cmdline_parse_inst_t *)&cmd_showport,
14846 (cmdline_parse_inst_t *)&cmd_showqueue,
14847 (cmdline_parse_inst_t *)&cmd_showportall,
14848 (cmdline_parse_inst_t *)&cmd_showcfg,
14849 (cmdline_parse_inst_t *)&cmd_start,
14850 (cmdline_parse_inst_t *)&cmd_start_tx_first,
14851 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
14852 (cmdline_parse_inst_t *)&cmd_set_link_up,
14853 (cmdline_parse_inst_t *)&cmd_set_link_down,
14854 (cmdline_parse_inst_t *)&cmd_reset,
14855 (cmdline_parse_inst_t *)&cmd_set_numbers,
14856 (cmdline_parse_inst_t *)&cmd_set_txpkts,
14857 (cmdline_parse_inst_t *)&cmd_set_txsplit,
14858 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
14859 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
14860 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
14861 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
14862 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
14863 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
14864 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
14865 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
14866 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
14867 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
14868 (cmdline_parse_inst_t *)&cmd_set_link_check,
14869 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
14870 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
14871 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
14872 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
14873 #ifdef RTE_LIBRTE_PMD_BOND
14874 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
14875 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
14876 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
14877 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
14878 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
14879 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
14880 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
14881 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
14882 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
14883 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
14884 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
14886 (cmdline_parse_inst_t *)&cmd_vlan_offload,
14887 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
14888 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
14889 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
14890 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
14891 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
14892 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
14893 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
14894 (cmdline_parse_inst_t *)&cmd_csum_set,
14895 (cmdline_parse_inst_t *)&cmd_csum_show,
14896 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
14897 (cmdline_parse_inst_t *)&cmd_tso_set,
14898 (cmdline_parse_inst_t *)&cmd_tso_show,
14899 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
14900 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
14901 (cmdline_parse_inst_t *)&cmd_gro_enable,
14902 (cmdline_parse_inst_t *)&cmd_gro_flush,
14903 (cmdline_parse_inst_t *)&cmd_gro_show,
14904 (cmdline_parse_inst_t *)&cmd_gso_enable,
14905 (cmdline_parse_inst_t *)&cmd_gso_size,
14906 (cmdline_parse_inst_t *)&cmd_gso_show,
14907 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
14908 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
14909 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
14910 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
14911 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
14912 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
14913 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
14914 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
14915 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
14916 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
14917 (cmdline_parse_inst_t *)&cmd_config_dcb,
14918 (cmdline_parse_inst_t *)&cmd_read_reg,
14919 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
14920 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
14921 (cmdline_parse_inst_t *)&cmd_write_reg,
14922 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
14923 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
14924 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
14925 (cmdline_parse_inst_t *)&cmd_stop,
14926 (cmdline_parse_inst_t *)&cmd_mac_addr,
14927 (cmdline_parse_inst_t *)&cmd_set_qmap,
14928 (cmdline_parse_inst_t *)&cmd_operate_port,
14929 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
14930 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
14931 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
14932 (cmdline_parse_inst_t *)&cmd_config_speed_all,
14933 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
14934 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
14935 (cmdline_parse_inst_t *)&cmd_config_mtu,
14936 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
14937 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
14938 (cmdline_parse_inst_t *)&cmd_config_rss,
14939 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
14940 (cmdline_parse_inst_t *)&cmd_config_txqflags,
14941 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
14942 (cmdline_parse_inst_t *)&cmd_showport_reta,
14943 (cmdline_parse_inst_t *)&cmd_config_burst,
14944 (cmdline_parse_inst_t *)&cmd_config_thresh,
14945 (cmdline_parse_inst_t *)&cmd_config_threshold,
14946 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
14947 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
14948 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
14949 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
14950 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
14951 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
14952 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
14953 (cmdline_parse_inst_t *)&cmd_global_config,
14954 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
14955 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
14956 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
14957 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
14958 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
14959 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
14960 (cmdline_parse_inst_t *)&cmd_dump,
14961 (cmdline_parse_inst_t *)&cmd_dump_one,
14962 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
14963 (cmdline_parse_inst_t *)&cmd_syn_filter,
14964 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
14965 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
14966 (cmdline_parse_inst_t *)&cmd_flex_filter,
14967 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
14968 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
14969 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
14970 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
14971 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
14972 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
14973 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
14974 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
14975 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
14976 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
14977 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
14978 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
14979 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
14980 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
14981 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
14982 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
14983 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
14984 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
14985 (cmdline_parse_inst_t *)&cmd_flow,
14986 (cmdline_parse_inst_t *)&cmd_mcast_addr,
14987 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
14988 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
14989 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
14990 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
14991 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
14992 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
14993 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
14994 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
14995 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
14996 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
14997 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
14998 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
14999 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15000 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15001 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15002 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15003 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15004 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15005 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15006 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15007 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15008 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15009 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15010 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15011 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15012 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15013 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15014 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15015 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15016 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15017 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15018 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15019 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15020 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15021 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15022 (cmdline_parse_inst_t *)&cmd_ddp_add,
15023 (cmdline_parse_inst_t *)&cmd_ddp_del,
15024 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15025 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15026 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15027 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15028 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15029 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15030 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15031 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15033 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15034 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15035 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15039 /* read cmdline commands from file */
15041 cmdline_read_from_file(const char *filename)
15043 struct cmdline *cl;
15045 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15047 printf("Failed to create file based cmdline context: %s\n",
15052 cmdline_interact(cl);
15057 printf("Read CLI commands from %s\n", filename);
15060 /* prompt function, called from main on MASTER lcore */
15064 /* initialize non-constant commands */
15065 cmd_set_fwd_mode_init();
15066 cmd_set_fwd_retry_mode_init();
15068 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15069 if (testpmd_cl == NULL)
15071 cmdline_interact(testpmd_cl);
15072 cmdline_stdin_exit(testpmd_cl);
15078 if (testpmd_cl != NULL)
15079 cmdline_quit(testpmd_cl);
15083 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15085 if (id == (portid_t)RTE_PORT_ALL) {
15088 RTE_ETH_FOREACH_DEV(pid) {
15089 /* check if need_reconfig has been set to 1 */
15090 if (ports[pid].need_reconfig == 0)
15091 ports[pid].need_reconfig = dev;
15092 /* check if need_reconfig_queues has been set to 1 */
15093 if (ports[pid].need_reconfig_queues == 0)
15094 ports[pid].need_reconfig_queues = queue;
15096 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15097 /* check if need_reconfig has been set to 1 */
15098 if (ports[id].need_reconfig == 0)
15099 ports[id].need_reconfig = dev;
15100 /* check if need_reconfig_queues has been set to 1 */
15101 if (ports[id].need_reconfig_queues == 0)
15102 ports[id].need_reconfig_queues = queue;