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;
2200 memset(&dev_info, 0, sizeof(dev_info));
2201 rte_eth_dev_info_get(res->port_id, &dev_info);
2202 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2203 res->size > ETH_RSS_RETA_SIZE_512) {
2204 printf("Invalid redirection table size: %u\n", res->size);
2208 memset(reta_conf, 0, sizeof(reta_conf));
2209 if (showport_parse_reta_config(reta_conf, res->size,
2210 res->list_of_items) < 0) {
2211 printf("Invalid string: %s for reta masks\n",
2212 res->list_of_items);
2215 port_rss_reta_info(res->port_id, reta_conf, res->size);
2218 cmdline_parse_token_string_t cmd_showport_reta_show =
2219 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2220 cmdline_parse_token_string_t cmd_showport_reta_port =
2221 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2222 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2223 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2224 cmdline_parse_token_string_t cmd_showport_reta_rss =
2225 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2226 cmdline_parse_token_string_t cmd_showport_reta_reta =
2227 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2228 cmdline_parse_token_num_t cmd_showport_reta_size =
2229 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2230 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2231 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2232 list_of_items, NULL);
2234 cmdline_parse_inst_t cmd_showport_reta = {
2235 .f = cmd_showport_reta_parsed,
2237 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2239 (void *)&cmd_showport_reta_show,
2240 (void *)&cmd_showport_reta_port,
2241 (void *)&cmd_showport_reta_port_id,
2242 (void *)&cmd_showport_reta_rss,
2243 (void *)&cmd_showport_reta_reta,
2244 (void *)&cmd_showport_reta_size,
2245 (void *)&cmd_showport_reta_list_of_items,
2250 /* *** Show RSS hash configuration *** */
2251 struct cmd_showport_rss_hash {
2252 cmdline_fixed_string_t show;
2253 cmdline_fixed_string_t port;
2255 cmdline_fixed_string_t rss_hash;
2256 cmdline_fixed_string_t rss_type;
2257 cmdline_fixed_string_t key; /* optional argument */
2260 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2261 __attribute__((unused)) struct cmdline *cl,
2264 struct cmd_showport_rss_hash *res = parsed_result;
2266 port_rss_hash_conf_show(res->port_id, res->rss_type,
2267 show_rss_key != NULL);
2270 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2271 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2272 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2273 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2274 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2275 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2276 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2277 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2279 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2280 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2281 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2282 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2283 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2284 "ipv6-tcp-ex#ipv6-udp-ex");
2285 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2286 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2288 cmdline_parse_inst_t cmd_showport_rss_hash = {
2289 .f = cmd_showport_rss_hash_parsed,
2291 .help_str = "show port <port_id> rss-hash "
2292 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2293 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2294 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2296 (void *)&cmd_showport_rss_hash_show,
2297 (void *)&cmd_showport_rss_hash_port,
2298 (void *)&cmd_showport_rss_hash_port_id,
2299 (void *)&cmd_showport_rss_hash_rss_hash,
2300 (void *)&cmd_showport_rss_hash_rss_hash_info,
2305 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2306 .f = cmd_showport_rss_hash_parsed,
2308 .help_str = "show port <port_id> rss-hash "
2309 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2310 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2311 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2313 (void *)&cmd_showport_rss_hash_show,
2314 (void *)&cmd_showport_rss_hash_port,
2315 (void *)&cmd_showport_rss_hash_port_id,
2316 (void *)&cmd_showport_rss_hash_rss_hash,
2317 (void *)&cmd_showport_rss_hash_rss_hash_info,
2318 (void *)&cmd_showport_rss_hash_rss_key,
2323 /* *** Configure DCB *** */
2324 struct cmd_config_dcb {
2325 cmdline_fixed_string_t port;
2326 cmdline_fixed_string_t config;
2328 cmdline_fixed_string_t dcb;
2329 cmdline_fixed_string_t vt;
2330 cmdline_fixed_string_t vt_en;
2332 cmdline_fixed_string_t pfc;
2333 cmdline_fixed_string_t pfc_en;
2337 cmd_config_dcb_parsed(void *parsed_result,
2338 __attribute__((unused)) struct cmdline *cl,
2339 __attribute__((unused)) void *data)
2341 struct cmd_config_dcb *res = parsed_result;
2342 portid_t port_id = res->port_id;
2343 struct rte_port *port;
2347 port = &ports[port_id];
2348 /** Check if the port is not started **/
2349 if (port->port_status != RTE_PORT_STOPPED) {
2350 printf("Please stop port %d first\n", port_id);
2354 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2355 printf("The invalid number of traffic class,"
2356 " only 4 or 8 allowed.\n");
2360 if (nb_fwd_lcores < res->num_tcs) {
2361 printf("nb_cores shouldn't be less than number of TCs.\n");
2364 if (!strncmp(res->pfc_en, "on", 2))
2369 /* DCB in VT mode */
2370 if (!strncmp(res->vt_en, "on", 2))
2371 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2372 (enum rte_eth_nb_tcs)res->num_tcs,
2375 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2376 (enum rte_eth_nb_tcs)res->num_tcs,
2381 printf("Cannot initialize network ports.\n");
2385 cmd_reconfig_device_queue(port_id, 1, 1);
2388 cmdline_parse_token_string_t cmd_config_dcb_port =
2389 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2390 cmdline_parse_token_string_t cmd_config_dcb_config =
2391 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2392 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2393 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2394 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2395 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2396 cmdline_parse_token_string_t cmd_config_dcb_vt =
2397 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2398 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2399 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2400 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2401 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2402 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2403 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2404 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2405 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2407 cmdline_parse_inst_t cmd_config_dcb = {
2408 .f = cmd_config_dcb_parsed,
2410 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2412 (void *)&cmd_config_dcb_port,
2413 (void *)&cmd_config_dcb_config,
2414 (void *)&cmd_config_dcb_port_id,
2415 (void *)&cmd_config_dcb_dcb,
2416 (void *)&cmd_config_dcb_vt,
2417 (void *)&cmd_config_dcb_vt_en,
2418 (void *)&cmd_config_dcb_num_tcs,
2419 (void *)&cmd_config_dcb_pfc,
2420 (void *)&cmd_config_dcb_pfc_en,
2425 /* *** configure number of packets per burst *** */
2426 struct cmd_config_burst {
2427 cmdline_fixed_string_t port;
2428 cmdline_fixed_string_t keyword;
2429 cmdline_fixed_string_t all;
2430 cmdline_fixed_string_t name;
2435 cmd_config_burst_parsed(void *parsed_result,
2436 __attribute__((unused)) struct cmdline *cl,
2437 __attribute__((unused)) void *data)
2439 struct cmd_config_burst *res = parsed_result;
2441 if (!all_ports_stopped()) {
2442 printf("Please stop all ports first\n");
2446 if (!strcmp(res->name, "burst")) {
2447 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2448 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2451 nb_pkt_per_burst = res->value;
2453 printf("Unknown parameter\n");
2459 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2462 cmdline_parse_token_string_t cmd_config_burst_port =
2463 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2464 cmdline_parse_token_string_t cmd_config_burst_keyword =
2465 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2466 cmdline_parse_token_string_t cmd_config_burst_all =
2467 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2468 cmdline_parse_token_string_t cmd_config_burst_name =
2469 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2470 cmdline_parse_token_num_t cmd_config_burst_value =
2471 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2473 cmdline_parse_inst_t cmd_config_burst = {
2474 .f = cmd_config_burst_parsed,
2476 .help_str = "port config all burst <value>",
2478 (void *)&cmd_config_burst_port,
2479 (void *)&cmd_config_burst_keyword,
2480 (void *)&cmd_config_burst_all,
2481 (void *)&cmd_config_burst_name,
2482 (void *)&cmd_config_burst_value,
2487 /* *** configure rx/tx queues *** */
2488 struct cmd_config_thresh {
2489 cmdline_fixed_string_t port;
2490 cmdline_fixed_string_t keyword;
2491 cmdline_fixed_string_t all;
2492 cmdline_fixed_string_t name;
2497 cmd_config_thresh_parsed(void *parsed_result,
2498 __attribute__((unused)) struct cmdline *cl,
2499 __attribute__((unused)) void *data)
2501 struct cmd_config_thresh *res = parsed_result;
2503 if (!all_ports_stopped()) {
2504 printf("Please stop all ports first\n");
2508 if (!strcmp(res->name, "txpt"))
2509 tx_pthresh = res->value;
2510 else if(!strcmp(res->name, "txht"))
2511 tx_hthresh = res->value;
2512 else if(!strcmp(res->name, "txwt"))
2513 tx_wthresh = res->value;
2514 else if(!strcmp(res->name, "rxpt"))
2515 rx_pthresh = res->value;
2516 else if(!strcmp(res->name, "rxht"))
2517 rx_hthresh = res->value;
2518 else if(!strcmp(res->name, "rxwt"))
2519 rx_wthresh = res->value;
2521 printf("Unknown parameter\n");
2527 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2530 cmdline_parse_token_string_t cmd_config_thresh_port =
2531 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2532 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2533 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2534 cmdline_parse_token_string_t cmd_config_thresh_all =
2535 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2536 cmdline_parse_token_string_t cmd_config_thresh_name =
2537 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2538 "txpt#txht#txwt#rxpt#rxht#rxwt");
2539 cmdline_parse_token_num_t cmd_config_thresh_value =
2540 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2542 cmdline_parse_inst_t cmd_config_thresh = {
2543 .f = cmd_config_thresh_parsed,
2545 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2547 (void *)&cmd_config_thresh_port,
2548 (void *)&cmd_config_thresh_keyword,
2549 (void *)&cmd_config_thresh_all,
2550 (void *)&cmd_config_thresh_name,
2551 (void *)&cmd_config_thresh_value,
2556 /* *** configure free/rs threshold *** */
2557 struct cmd_config_threshold {
2558 cmdline_fixed_string_t port;
2559 cmdline_fixed_string_t keyword;
2560 cmdline_fixed_string_t all;
2561 cmdline_fixed_string_t name;
2566 cmd_config_threshold_parsed(void *parsed_result,
2567 __attribute__((unused)) struct cmdline *cl,
2568 __attribute__((unused)) void *data)
2570 struct cmd_config_threshold *res = parsed_result;
2572 if (!all_ports_stopped()) {
2573 printf("Please stop all ports first\n");
2577 if (!strcmp(res->name, "txfreet"))
2578 tx_free_thresh = res->value;
2579 else if (!strcmp(res->name, "txrst"))
2580 tx_rs_thresh = res->value;
2581 else if (!strcmp(res->name, "rxfreet"))
2582 rx_free_thresh = res->value;
2584 printf("Unknown parameter\n");
2590 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2593 cmdline_parse_token_string_t cmd_config_threshold_port =
2594 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2595 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2596 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2598 cmdline_parse_token_string_t cmd_config_threshold_all =
2599 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2600 cmdline_parse_token_string_t cmd_config_threshold_name =
2601 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2602 "txfreet#txrst#rxfreet");
2603 cmdline_parse_token_num_t cmd_config_threshold_value =
2604 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2606 cmdline_parse_inst_t cmd_config_threshold = {
2607 .f = cmd_config_threshold_parsed,
2609 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2611 (void *)&cmd_config_threshold_port,
2612 (void *)&cmd_config_threshold_keyword,
2613 (void *)&cmd_config_threshold_all,
2614 (void *)&cmd_config_threshold_name,
2615 (void *)&cmd_config_threshold_value,
2621 struct cmd_stop_result {
2622 cmdline_fixed_string_t stop;
2625 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2626 __attribute__((unused)) struct cmdline *cl,
2627 __attribute__((unused)) void *data)
2629 stop_packet_forwarding();
2632 cmdline_parse_token_string_t cmd_stop_stop =
2633 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2635 cmdline_parse_inst_t cmd_stop = {
2636 .f = cmd_stop_parsed,
2638 .help_str = "stop: Stop packet forwarding",
2640 (void *)&cmd_stop_stop,
2645 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2648 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2649 unsigned int *parsed_items, int check_unique_values)
2651 unsigned int nb_item;
2659 * First parse all items in the list and store their value.
2664 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2666 if ((c >= '0') && (c <= '9')) {
2667 value = (unsigned int) (value * 10 + (c - '0'));
2672 printf("character %c is not a decimal digit\n", c);
2676 printf("No valid value before comma\n");
2679 if (nb_item < max_items) {
2680 parsed_items[nb_item] = value;
2686 if (nb_item >= max_items) {
2687 printf("Number of %s = %u > %u (maximum items)\n",
2688 item_name, nb_item + 1, max_items);
2691 parsed_items[nb_item++] = value;
2692 if (! check_unique_values)
2696 * Then, check that all values in the list are differents.
2697 * No optimization here...
2699 for (i = 0; i < nb_item; i++) {
2700 for (j = i + 1; j < nb_item; j++) {
2701 if (parsed_items[j] == parsed_items[i]) {
2702 printf("duplicated %s %u at index %u and %u\n",
2703 item_name, parsed_items[i], i, j);
2711 struct cmd_set_list_result {
2712 cmdline_fixed_string_t cmd_keyword;
2713 cmdline_fixed_string_t list_name;
2714 cmdline_fixed_string_t list_of_items;
2717 static void cmd_set_list_parsed(void *parsed_result,
2718 __attribute__((unused)) struct cmdline *cl,
2719 __attribute__((unused)) void *data)
2721 struct cmd_set_list_result *res;
2723 unsigned int lcorelist[RTE_MAX_LCORE];
2724 unsigned int portlist[RTE_MAX_ETHPORTS];
2726 unsigned int nb_item;
2728 if (test_done == 0) {
2729 printf("Please stop forwarding first\n");
2733 res = parsed_result;
2734 if (!strcmp(res->list_name, "corelist")) {
2735 nb_item = parse_item_list(res->list_of_items, "core",
2737 parsed_items.lcorelist, 1);
2739 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2744 if (!strcmp(res->list_name, "portlist")) {
2745 nb_item = parse_item_list(res->list_of_items, "port",
2747 parsed_items.portlist, 1);
2749 set_fwd_ports_list(parsed_items.portlist, nb_item);
2755 cmdline_parse_token_string_t cmd_set_list_keyword =
2756 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2758 cmdline_parse_token_string_t cmd_set_list_name =
2759 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2760 "corelist#portlist");
2761 cmdline_parse_token_string_t cmd_set_list_of_items =
2762 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2765 cmdline_parse_inst_t cmd_set_fwd_list = {
2766 .f = cmd_set_list_parsed,
2768 .help_str = "set corelist|portlist <list0[,list1]*>",
2770 (void *)&cmd_set_list_keyword,
2771 (void *)&cmd_set_list_name,
2772 (void *)&cmd_set_list_of_items,
2777 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2779 struct cmd_setmask_result {
2780 cmdline_fixed_string_t set;
2781 cmdline_fixed_string_t mask;
2785 static void cmd_set_mask_parsed(void *parsed_result,
2786 __attribute__((unused)) struct cmdline *cl,
2787 __attribute__((unused)) void *data)
2789 struct cmd_setmask_result *res = parsed_result;
2791 if (test_done == 0) {
2792 printf("Please stop forwarding first\n");
2795 if (!strcmp(res->mask, "coremask")) {
2796 set_fwd_lcores_mask(res->hexavalue);
2798 } else if (!strcmp(res->mask, "portmask")) {
2799 set_fwd_ports_mask(res->hexavalue);
2804 cmdline_parse_token_string_t cmd_setmask_set =
2805 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2806 cmdline_parse_token_string_t cmd_setmask_mask =
2807 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2808 "coremask#portmask");
2809 cmdline_parse_token_num_t cmd_setmask_value =
2810 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2812 cmdline_parse_inst_t cmd_set_fwd_mask = {
2813 .f = cmd_set_mask_parsed,
2815 .help_str = "set coremask|portmask <hexadecimal value>",
2817 (void *)&cmd_setmask_set,
2818 (void *)&cmd_setmask_mask,
2819 (void *)&cmd_setmask_value,
2825 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2827 struct cmd_set_result {
2828 cmdline_fixed_string_t set;
2829 cmdline_fixed_string_t what;
2833 static void cmd_set_parsed(void *parsed_result,
2834 __attribute__((unused)) struct cmdline *cl,
2835 __attribute__((unused)) void *data)
2837 struct cmd_set_result *res = parsed_result;
2838 if (!strcmp(res->what, "nbport")) {
2839 set_fwd_ports_number(res->value);
2841 } else if (!strcmp(res->what, "nbcore")) {
2842 set_fwd_lcores_number(res->value);
2844 } else if (!strcmp(res->what, "burst"))
2845 set_nb_pkt_per_burst(res->value);
2846 else if (!strcmp(res->what, "verbose"))
2847 set_verbose_level(res->value);
2850 cmdline_parse_token_string_t cmd_set_set =
2851 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2852 cmdline_parse_token_string_t cmd_set_what =
2853 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2854 "nbport#nbcore#burst#verbose");
2855 cmdline_parse_token_num_t cmd_set_value =
2856 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2858 cmdline_parse_inst_t cmd_set_numbers = {
2859 .f = cmd_set_parsed,
2861 .help_str = "set nbport|nbcore|burst|verbose <value>",
2863 (void *)&cmd_set_set,
2864 (void *)&cmd_set_what,
2865 (void *)&cmd_set_value,
2870 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2872 struct cmd_set_txpkts_result {
2873 cmdline_fixed_string_t cmd_keyword;
2874 cmdline_fixed_string_t txpkts;
2875 cmdline_fixed_string_t seg_lengths;
2879 cmd_set_txpkts_parsed(void *parsed_result,
2880 __attribute__((unused)) struct cmdline *cl,
2881 __attribute__((unused)) void *data)
2883 struct cmd_set_txpkts_result *res;
2884 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2885 unsigned int nb_segs;
2887 res = parsed_result;
2888 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2889 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2891 set_tx_pkt_segments(seg_lengths, nb_segs);
2894 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2895 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2896 cmd_keyword, "set");
2897 cmdline_parse_token_string_t cmd_set_txpkts_name =
2898 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2900 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2901 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2904 cmdline_parse_inst_t cmd_set_txpkts = {
2905 .f = cmd_set_txpkts_parsed,
2907 .help_str = "set txpkts <len0[,len1]*>",
2909 (void *)&cmd_set_txpkts_keyword,
2910 (void *)&cmd_set_txpkts_name,
2911 (void *)&cmd_set_txpkts_lengths,
2916 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2918 struct cmd_set_txsplit_result {
2919 cmdline_fixed_string_t cmd_keyword;
2920 cmdline_fixed_string_t txsplit;
2921 cmdline_fixed_string_t mode;
2925 cmd_set_txsplit_parsed(void *parsed_result,
2926 __attribute__((unused)) struct cmdline *cl,
2927 __attribute__((unused)) void *data)
2929 struct cmd_set_txsplit_result *res;
2931 res = parsed_result;
2932 set_tx_pkt_split(res->mode);
2935 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2936 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2937 cmd_keyword, "set");
2938 cmdline_parse_token_string_t cmd_set_txsplit_name =
2939 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2940 txsplit, "txsplit");
2941 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2942 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2945 cmdline_parse_inst_t cmd_set_txsplit = {
2946 .f = cmd_set_txsplit_parsed,
2948 .help_str = "set txsplit on|off|rand",
2950 (void *)&cmd_set_txsplit_keyword,
2951 (void *)&cmd_set_txsplit_name,
2952 (void *)&cmd_set_txsplit_mode,
2957 /* *** CONFIG TX QUEUE FLAGS *** */
2959 struct cmd_config_txqflags_result {
2960 cmdline_fixed_string_t port;
2961 cmdline_fixed_string_t config;
2962 cmdline_fixed_string_t all;
2963 cmdline_fixed_string_t what;
2967 static void cmd_config_txqflags_parsed(void *parsed_result,
2968 __attribute__((unused)) struct cmdline *cl,
2969 __attribute__((unused)) void *data)
2971 struct cmd_config_txqflags_result *res = parsed_result;
2973 if (!all_ports_stopped()) {
2974 printf("Please stop all ports first\n");
2978 if (strcmp(res->what, "txqflags")) {
2979 printf("Unknown parameter\n");
2983 if (res->hexvalue >= 0) {
2984 txq_flags = res->hexvalue;
2986 printf("txqflags must be >= 0\n");
2992 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2995 cmdline_parse_token_string_t cmd_config_txqflags_port =
2996 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2998 cmdline_parse_token_string_t cmd_config_txqflags_config =
2999 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
3001 cmdline_parse_token_string_t cmd_config_txqflags_all =
3002 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
3004 cmdline_parse_token_string_t cmd_config_txqflags_what =
3005 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
3007 cmdline_parse_token_num_t cmd_config_txqflags_value =
3008 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
3011 cmdline_parse_inst_t cmd_config_txqflags = {
3012 .f = cmd_config_txqflags_parsed,
3014 .help_str = "port config all txqflags <value>",
3016 (void *)&cmd_config_txqflags_port,
3017 (void *)&cmd_config_txqflags_config,
3018 (void *)&cmd_config_txqflags_all,
3019 (void *)&cmd_config_txqflags_what,
3020 (void *)&cmd_config_txqflags_value,
3025 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3026 struct cmd_rx_vlan_filter_all_result {
3027 cmdline_fixed_string_t rx_vlan;
3028 cmdline_fixed_string_t what;
3029 cmdline_fixed_string_t all;
3034 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3035 __attribute__((unused)) struct cmdline *cl,
3036 __attribute__((unused)) void *data)
3038 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3040 if (!strcmp(res->what, "add"))
3041 rx_vlan_all_filter_set(res->port_id, 1);
3043 rx_vlan_all_filter_set(res->port_id, 0);
3046 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3047 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3048 rx_vlan, "rx_vlan");
3049 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3050 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3052 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3053 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3055 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3056 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3059 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3060 .f = cmd_rx_vlan_filter_all_parsed,
3062 .help_str = "rx_vlan add|rm all <port_id>: "
3063 "Add/Remove all identifiers to/from the set of VLAN "
3064 "identifiers filtered by a port",
3066 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3067 (void *)&cmd_rx_vlan_filter_all_what,
3068 (void *)&cmd_rx_vlan_filter_all_all,
3069 (void *)&cmd_rx_vlan_filter_all_portid,
3074 /* *** VLAN OFFLOAD SET ON A PORT *** */
3075 struct cmd_vlan_offload_result {
3076 cmdline_fixed_string_t vlan;
3077 cmdline_fixed_string_t set;
3078 cmdline_fixed_string_t vlan_type;
3079 cmdline_fixed_string_t what;
3080 cmdline_fixed_string_t on;
3081 cmdline_fixed_string_t port_id;
3085 cmd_vlan_offload_parsed(void *parsed_result,
3086 __attribute__((unused)) struct cmdline *cl,
3087 __attribute__((unused)) void *data)
3090 struct cmd_vlan_offload_result *res = parsed_result;
3093 portid_t port_id = 0;
3097 len = strnlen(str, STR_TOKEN_SIZE);
3099 /* Get port_id first */
3107 tmp = strtoul(str, NULL, 0);
3108 /* If port_id greater that what portid_t can represent, return */
3109 if(tmp >= RTE_MAX_ETHPORTS)
3111 port_id = (portid_t)tmp;
3113 if (!strcmp(res->on, "on"))
3118 if (!strcmp(res->what, "strip"))
3119 rx_vlan_strip_set(port_id, on);
3120 else if(!strcmp(res->what, "stripq")){
3121 uint16_t queue_id = 0;
3123 /* No queue_id, return */
3125 printf("must specify (port,queue_id)\n");
3128 tmp = strtoul(str + i + 1, NULL, 0);
3129 /* If queue_id greater that what 16-bits can represent, return */
3133 queue_id = (uint16_t)tmp;
3134 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3136 else if (!strcmp(res->what, "filter"))
3137 rx_vlan_filter_set(port_id, on);
3139 vlan_extend_set(port_id, on);
3144 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3145 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3147 cmdline_parse_token_string_t cmd_vlan_offload_set =
3148 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3150 cmdline_parse_token_string_t cmd_vlan_offload_what =
3151 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3152 what, "strip#filter#qinq#stripq");
3153 cmdline_parse_token_string_t cmd_vlan_offload_on =
3154 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3156 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3157 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3160 cmdline_parse_inst_t cmd_vlan_offload = {
3161 .f = cmd_vlan_offload_parsed,
3163 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3164 "<port_id[,queue_id]>: "
3165 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3167 (void *)&cmd_vlan_offload_vlan,
3168 (void *)&cmd_vlan_offload_set,
3169 (void *)&cmd_vlan_offload_what,
3170 (void *)&cmd_vlan_offload_on,
3171 (void *)&cmd_vlan_offload_portid,
3176 /* *** VLAN TPID SET ON A PORT *** */
3177 struct cmd_vlan_tpid_result {
3178 cmdline_fixed_string_t vlan;
3179 cmdline_fixed_string_t set;
3180 cmdline_fixed_string_t vlan_type;
3181 cmdline_fixed_string_t what;
3187 cmd_vlan_tpid_parsed(void *parsed_result,
3188 __attribute__((unused)) struct cmdline *cl,
3189 __attribute__((unused)) void *data)
3191 struct cmd_vlan_tpid_result *res = parsed_result;
3192 enum rte_vlan_type vlan_type;
3194 if (!strcmp(res->vlan_type, "inner"))
3195 vlan_type = ETH_VLAN_TYPE_INNER;
3196 else if (!strcmp(res->vlan_type, "outer"))
3197 vlan_type = ETH_VLAN_TYPE_OUTER;
3199 printf("Unknown vlan type\n");
3202 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3205 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3206 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3208 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3209 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3211 cmdline_parse_token_string_t cmd_vlan_type =
3212 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3213 vlan_type, "inner#outer");
3214 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3215 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3217 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3218 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3220 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3221 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3224 cmdline_parse_inst_t cmd_vlan_tpid = {
3225 .f = cmd_vlan_tpid_parsed,
3227 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3228 "Set the VLAN Ether type",
3230 (void *)&cmd_vlan_tpid_vlan,
3231 (void *)&cmd_vlan_tpid_set,
3232 (void *)&cmd_vlan_type,
3233 (void *)&cmd_vlan_tpid_what,
3234 (void *)&cmd_vlan_tpid_tpid,
3235 (void *)&cmd_vlan_tpid_portid,
3240 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3241 struct cmd_rx_vlan_filter_result {
3242 cmdline_fixed_string_t rx_vlan;
3243 cmdline_fixed_string_t what;
3249 cmd_rx_vlan_filter_parsed(void *parsed_result,
3250 __attribute__((unused)) struct cmdline *cl,
3251 __attribute__((unused)) void *data)
3253 struct cmd_rx_vlan_filter_result *res = parsed_result;
3255 if (!strcmp(res->what, "add"))
3256 rx_vft_set(res->port_id, res->vlan_id, 1);
3258 rx_vft_set(res->port_id, res->vlan_id, 0);
3261 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3262 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3263 rx_vlan, "rx_vlan");
3264 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3265 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3267 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3268 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3270 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3271 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3274 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3275 .f = cmd_rx_vlan_filter_parsed,
3277 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3278 "Add/Remove a VLAN identifier to/from the set of VLAN "
3279 "identifiers filtered by a port",
3281 (void *)&cmd_rx_vlan_filter_rx_vlan,
3282 (void *)&cmd_rx_vlan_filter_what,
3283 (void *)&cmd_rx_vlan_filter_vlanid,
3284 (void *)&cmd_rx_vlan_filter_portid,
3289 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3290 struct cmd_tx_vlan_set_result {
3291 cmdline_fixed_string_t tx_vlan;
3292 cmdline_fixed_string_t set;
3298 cmd_tx_vlan_set_parsed(void *parsed_result,
3299 __attribute__((unused)) struct cmdline *cl,
3300 __attribute__((unused)) void *data)
3302 struct cmd_tx_vlan_set_result *res = parsed_result;
3304 tx_vlan_set(res->port_id, res->vlan_id);
3307 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3308 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3309 tx_vlan, "tx_vlan");
3310 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3311 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3313 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3314 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3316 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3317 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3320 cmdline_parse_inst_t cmd_tx_vlan_set = {
3321 .f = cmd_tx_vlan_set_parsed,
3323 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3324 "Enable hardware insertion of a single VLAN header "
3325 "with a given TAG Identifier in packets sent on a port",
3327 (void *)&cmd_tx_vlan_set_tx_vlan,
3328 (void *)&cmd_tx_vlan_set_set,
3329 (void *)&cmd_tx_vlan_set_portid,
3330 (void *)&cmd_tx_vlan_set_vlanid,
3335 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3336 struct cmd_tx_vlan_set_qinq_result {
3337 cmdline_fixed_string_t tx_vlan;
3338 cmdline_fixed_string_t set;
3341 uint16_t vlan_id_outer;
3345 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3346 __attribute__((unused)) struct cmdline *cl,
3347 __attribute__((unused)) void *data)
3349 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3351 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3354 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3355 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3356 tx_vlan, "tx_vlan");
3357 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3358 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3360 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3361 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3363 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3364 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3366 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3367 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3368 vlan_id_outer, UINT16);
3370 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3371 .f = cmd_tx_vlan_set_qinq_parsed,
3373 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3374 "Enable hardware insertion of double VLAN header "
3375 "with given TAG Identifiers in packets sent on a port",
3377 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3378 (void *)&cmd_tx_vlan_set_qinq_set,
3379 (void *)&cmd_tx_vlan_set_qinq_portid,
3380 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3381 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3386 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3387 struct cmd_tx_vlan_set_pvid_result {
3388 cmdline_fixed_string_t tx_vlan;
3389 cmdline_fixed_string_t set;
3390 cmdline_fixed_string_t pvid;
3393 cmdline_fixed_string_t mode;
3397 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3398 __attribute__((unused)) struct cmdline *cl,
3399 __attribute__((unused)) void *data)
3401 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3403 if (strcmp(res->mode, "on") == 0)
3404 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3406 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3409 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3410 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3411 tx_vlan, "tx_vlan");
3412 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3413 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3415 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3416 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3418 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3419 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3421 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3422 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3424 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3425 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3428 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3429 .f = cmd_tx_vlan_set_pvid_parsed,
3431 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3433 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3434 (void *)&cmd_tx_vlan_set_pvid_set,
3435 (void *)&cmd_tx_vlan_set_pvid_pvid,
3436 (void *)&cmd_tx_vlan_set_pvid_port_id,
3437 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3438 (void *)&cmd_tx_vlan_set_pvid_mode,
3443 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3444 struct cmd_tx_vlan_reset_result {
3445 cmdline_fixed_string_t tx_vlan;
3446 cmdline_fixed_string_t reset;
3451 cmd_tx_vlan_reset_parsed(void *parsed_result,
3452 __attribute__((unused)) struct cmdline *cl,
3453 __attribute__((unused)) void *data)
3455 struct cmd_tx_vlan_reset_result *res = parsed_result;
3457 tx_vlan_reset(res->port_id);
3460 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3461 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3462 tx_vlan, "tx_vlan");
3463 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3464 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3466 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3467 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3470 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3471 .f = cmd_tx_vlan_reset_parsed,
3473 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3474 "VLAN header in packets sent on a port",
3476 (void *)&cmd_tx_vlan_reset_tx_vlan,
3477 (void *)&cmd_tx_vlan_reset_reset,
3478 (void *)&cmd_tx_vlan_reset_portid,
3484 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3485 struct cmd_csum_result {
3486 cmdline_fixed_string_t csum;
3487 cmdline_fixed_string_t mode;
3488 cmdline_fixed_string_t proto;
3489 cmdline_fixed_string_t hwsw;
3494 csum_show(int port_id)
3496 struct rte_eth_dev_info dev_info;
3499 ol_flags = ports[port_id].tx_ol_flags;
3500 printf("Parse tunnel is %s\n",
3501 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3502 printf("IP checksum offload is %s\n",
3503 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3504 printf("UDP checksum offload is %s\n",
3505 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3506 printf("TCP checksum offload is %s\n",
3507 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3508 printf("SCTP checksum offload is %s\n",
3509 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3510 printf("Outer-Ip checksum offload is %s\n",
3511 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3513 /* display warnings if configuration is not supported by the NIC */
3514 rte_eth_dev_info_get(port_id, &dev_info);
3515 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3516 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3517 printf("Warning: hardware IP checksum enabled but not "
3518 "supported by port %d\n", port_id);
3520 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3521 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3522 printf("Warning: hardware UDP checksum enabled but not "
3523 "supported by port %d\n", port_id);
3525 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3526 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3527 printf("Warning: hardware TCP checksum enabled but not "
3528 "supported by port %d\n", port_id);
3530 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3531 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3532 printf("Warning: hardware SCTP checksum enabled but not "
3533 "supported by port %d\n", port_id);
3535 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3536 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3537 printf("Warning: hardware outer IP checksum enabled but not "
3538 "supported by port %d\n", port_id);
3543 cmd_csum_parsed(void *parsed_result,
3544 __attribute__((unused)) struct cmdline *cl,
3545 __attribute__((unused)) void *data)
3547 struct cmd_csum_result *res = parsed_result;
3551 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3552 printf("invalid port %d\n", res->port_id);
3556 if (!strcmp(res->mode, "set")) {
3558 if (!strcmp(res->hwsw, "hw"))
3561 if (!strcmp(res->proto, "ip")) {
3562 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3563 } else if (!strcmp(res->proto, "udp")) {
3564 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3565 } else if (!strcmp(res->proto, "tcp")) {
3566 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3567 } else if (!strcmp(res->proto, "sctp")) {
3568 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3569 } else if (!strcmp(res->proto, "outer-ip")) {
3570 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3574 ports[res->port_id].tx_ol_flags |= mask;
3576 ports[res->port_id].tx_ol_flags &= (~mask);
3578 csum_show(res->port_id);
3581 cmdline_parse_token_string_t cmd_csum_csum =
3582 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3584 cmdline_parse_token_string_t cmd_csum_mode =
3585 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3587 cmdline_parse_token_string_t cmd_csum_proto =
3588 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3589 proto, "ip#tcp#udp#sctp#outer-ip");
3590 cmdline_parse_token_string_t cmd_csum_hwsw =
3591 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3593 cmdline_parse_token_num_t cmd_csum_portid =
3594 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3597 cmdline_parse_inst_t cmd_csum_set = {
3598 .f = cmd_csum_parsed,
3600 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3601 "Enable/Disable hardware calculation of L3/L4 checksum when "
3602 "using csum forward engine",
3604 (void *)&cmd_csum_csum,
3605 (void *)&cmd_csum_mode,
3606 (void *)&cmd_csum_proto,
3607 (void *)&cmd_csum_hwsw,
3608 (void *)&cmd_csum_portid,
3613 cmdline_parse_token_string_t cmd_csum_mode_show =
3614 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3617 cmdline_parse_inst_t cmd_csum_show = {
3618 .f = cmd_csum_parsed,
3620 .help_str = "csum show <port_id>: Show checksum offload configuration",
3622 (void *)&cmd_csum_csum,
3623 (void *)&cmd_csum_mode_show,
3624 (void *)&cmd_csum_portid,
3629 /* Enable/disable tunnel parsing */
3630 struct cmd_csum_tunnel_result {
3631 cmdline_fixed_string_t csum;
3632 cmdline_fixed_string_t parse;
3633 cmdline_fixed_string_t onoff;
3638 cmd_csum_tunnel_parsed(void *parsed_result,
3639 __attribute__((unused)) struct cmdline *cl,
3640 __attribute__((unused)) void *data)
3642 struct cmd_csum_tunnel_result *res = parsed_result;
3644 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3647 if (!strcmp(res->onoff, "on"))
3648 ports[res->port_id].tx_ol_flags |=
3649 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3651 ports[res->port_id].tx_ol_flags &=
3652 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3654 csum_show(res->port_id);
3657 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3658 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3660 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3661 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3662 parse, "parse_tunnel");
3663 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3664 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3666 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3667 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3670 cmdline_parse_inst_t cmd_csum_tunnel = {
3671 .f = cmd_csum_tunnel_parsed,
3673 .help_str = "csum parse_tunnel on|off <port_id>: "
3674 "Enable/Disable parsing of tunnels for csum engine",
3676 (void *)&cmd_csum_tunnel_csum,
3677 (void *)&cmd_csum_tunnel_parse,
3678 (void *)&cmd_csum_tunnel_onoff,
3679 (void *)&cmd_csum_tunnel_portid,
3684 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3685 struct cmd_tso_set_result {
3686 cmdline_fixed_string_t tso;
3687 cmdline_fixed_string_t mode;
3693 cmd_tso_set_parsed(void *parsed_result,
3694 __attribute__((unused)) struct cmdline *cl,
3695 __attribute__((unused)) void *data)
3697 struct cmd_tso_set_result *res = parsed_result;
3698 struct rte_eth_dev_info dev_info;
3700 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3703 if (!strcmp(res->mode, "set"))
3704 ports[res->port_id].tso_segsz = res->tso_segsz;
3706 if (ports[res->port_id].tso_segsz == 0)
3707 printf("TSO for non-tunneled packets is disabled\n");
3709 printf("TSO segment size for non-tunneled packets is %d\n",
3710 ports[res->port_id].tso_segsz);
3712 /* display warnings if configuration is not supported by the NIC */
3713 rte_eth_dev_info_get(res->port_id, &dev_info);
3714 if ((ports[res->port_id].tso_segsz != 0) &&
3715 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3716 printf("Warning: TSO enabled but not "
3717 "supported by port %d\n", res->port_id);
3721 cmdline_parse_token_string_t cmd_tso_set_tso =
3722 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3724 cmdline_parse_token_string_t cmd_tso_set_mode =
3725 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3727 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3728 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3730 cmdline_parse_token_num_t cmd_tso_set_portid =
3731 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3734 cmdline_parse_inst_t cmd_tso_set = {
3735 .f = cmd_tso_set_parsed,
3737 .help_str = "tso set <tso_segsz> <port_id>: "
3738 "Set TSO segment size of non-tunneled packets for csum engine "
3741 (void *)&cmd_tso_set_tso,
3742 (void *)&cmd_tso_set_mode,
3743 (void *)&cmd_tso_set_tso_segsz,
3744 (void *)&cmd_tso_set_portid,
3749 cmdline_parse_token_string_t cmd_tso_show_mode =
3750 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3754 cmdline_parse_inst_t cmd_tso_show = {
3755 .f = cmd_tso_set_parsed,
3757 .help_str = "tso show <port_id>: "
3758 "Show TSO segment size of non-tunneled packets for csum engine",
3760 (void *)&cmd_tso_set_tso,
3761 (void *)&cmd_tso_show_mode,
3762 (void *)&cmd_tso_set_portid,
3767 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3768 struct cmd_tunnel_tso_set_result {
3769 cmdline_fixed_string_t tso;
3770 cmdline_fixed_string_t mode;
3776 check_tunnel_tso_nic_support(uint8_t port_id)
3778 struct rte_eth_dev_info dev_info;
3780 rte_eth_dev_info_get(port_id, &dev_info);
3781 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3782 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3783 "supported by port %d\n", port_id);
3784 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3785 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3786 "supported by port %d\n", port_id);
3787 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3788 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3789 "supported by port %d\n", port_id);
3790 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3791 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3792 "supported by port %d\n", port_id);
3796 cmd_tunnel_tso_set_parsed(void *parsed_result,
3797 __attribute__((unused)) struct cmdline *cl,
3798 __attribute__((unused)) void *data)
3800 struct cmd_tunnel_tso_set_result *res = parsed_result;
3802 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3805 if (!strcmp(res->mode, "set"))
3806 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3808 if (ports[res->port_id].tunnel_tso_segsz == 0)
3809 printf("TSO for tunneled packets is disabled\n");
3811 printf("TSO segment size for tunneled packets is %d\n",
3812 ports[res->port_id].tunnel_tso_segsz);
3814 /* Below conditions are needed to make it work:
3815 * (1) tunnel TSO is supported by the NIC;
3816 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3818 * (3) for tunneled pkts with outer L3 of IPv4,
3819 * "csum set outer-ip" must be set to hw, because after tso,
3820 * total_len of outer IP header is changed, and the checksum
3821 * of outer IP header calculated by sw should be wrong; that
3822 * is not necessary for IPv6 tunneled pkts because there's no
3823 * checksum in IP header anymore.
3825 check_tunnel_tso_nic_support(res->port_id);
3827 if (!(ports[res->port_id].tx_ol_flags &
3828 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3829 printf("Warning: csum parse_tunnel must be set "
3830 "so that tunneled packets are recognized\n");
3831 if (!(ports[res->port_id].tx_ol_flags &
3832 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3833 printf("Warning: csum set outer-ip must be set to hw "
3834 "if outer L3 is IPv4; not necessary for IPv6\n");
3838 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3839 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3841 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3842 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3844 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3845 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3847 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3848 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3851 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3852 .f = cmd_tunnel_tso_set_parsed,
3854 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3855 "Set TSO segment size of tunneled packets for csum engine "
3858 (void *)&cmd_tunnel_tso_set_tso,
3859 (void *)&cmd_tunnel_tso_set_mode,
3860 (void *)&cmd_tunnel_tso_set_tso_segsz,
3861 (void *)&cmd_tunnel_tso_set_portid,
3866 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3867 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3871 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3872 .f = cmd_tunnel_tso_set_parsed,
3874 .help_str = "tunnel_tso show <port_id> "
3875 "Show TSO segment size of tunneled packets for csum engine",
3877 (void *)&cmd_tunnel_tso_set_tso,
3878 (void *)&cmd_tunnel_tso_show_mode,
3879 (void *)&cmd_tunnel_tso_set_portid,
3884 /* *** SET GRO FOR A PORT *** */
3885 struct cmd_gro_enable_result {
3886 cmdline_fixed_string_t cmd_set;
3887 cmdline_fixed_string_t cmd_port;
3888 cmdline_fixed_string_t cmd_keyword;
3889 cmdline_fixed_string_t cmd_onoff;
3894 cmd_gro_enable_parsed(void *parsed_result,
3895 __attribute__((unused)) struct cmdline *cl,
3896 __attribute__((unused)) void *data)
3898 struct cmd_gro_enable_result *res;
3900 res = parsed_result;
3901 if (!strcmp(res->cmd_keyword, "gro"))
3902 setup_gro(res->cmd_onoff, res->cmd_pid);
3905 cmdline_parse_token_string_t cmd_gro_enable_set =
3906 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3908 cmdline_parse_token_string_t cmd_gro_enable_port =
3909 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3910 cmd_keyword, "port");
3911 cmdline_parse_token_num_t cmd_gro_enable_pid =
3912 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
3914 cmdline_parse_token_string_t cmd_gro_enable_keyword =
3915 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3916 cmd_keyword, "gro");
3917 cmdline_parse_token_string_t cmd_gro_enable_onoff =
3918 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3919 cmd_onoff, "on#off");
3921 cmdline_parse_inst_t cmd_gro_enable = {
3922 .f = cmd_gro_enable_parsed,
3924 .help_str = "set port <port_id> gro on|off",
3926 (void *)&cmd_gro_enable_set,
3927 (void *)&cmd_gro_enable_port,
3928 (void *)&cmd_gro_enable_pid,
3929 (void *)&cmd_gro_enable_keyword,
3930 (void *)&cmd_gro_enable_onoff,
3935 /* *** DISPLAY GRO CONFIGURATION *** */
3936 struct cmd_gro_show_result {
3937 cmdline_fixed_string_t cmd_show;
3938 cmdline_fixed_string_t cmd_port;
3939 cmdline_fixed_string_t cmd_keyword;
3944 cmd_gro_show_parsed(void *parsed_result,
3945 __attribute__((unused)) struct cmdline *cl,
3946 __attribute__((unused)) void *data)
3948 struct cmd_gro_show_result *res;
3950 res = parsed_result;
3951 if (!strcmp(res->cmd_keyword, "gro"))
3952 show_gro(res->cmd_pid);
3955 cmdline_parse_token_string_t cmd_gro_show_show =
3956 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
3958 cmdline_parse_token_string_t cmd_gro_show_port =
3959 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
3961 cmdline_parse_token_num_t cmd_gro_show_pid =
3962 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
3964 cmdline_parse_token_string_t cmd_gro_show_keyword =
3965 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
3966 cmd_keyword, "gro");
3968 cmdline_parse_inst_t cmd_gro_show = {
3969 .f = cmd_gro_show_parsed,
3971 .help_str = "show port <port_id> gro",
3973 (void *)&cmd_gro_show_show,
3974 (void *)&cmd_gro_show_port,
3975 (void *)&cmd_gro_show_pid,
3976 (void *)&cmd_gro_show_keyword,
3981 /* *** SET FLUSH CYCLES FOR GRO *** */
3982 struct cmd_gro_flush_result {
3983 cmdline_fixed_string_t cmd_set;
3984 cmdline_fixed_string_t cmd_keyword;
3985 cmdline_fixed_string_t cmd_flush;
3990 cmd_gro_flush_parsed(void *parsed_result,
3991 __attribute__((unused)) struct cmdline *cl,
3992 __attribute__((unused)) void *data)
3994 struct cmd_gro_flush_result *res;
3996 res = parsed_result;
3997 if ((!strcmp(res->cmd_keyword, "gro")) &&
3998 (!strcmp(res->cmd_flush, "flush")))
3999 setup_gro_flush_cycles(res->cmd_cycles);
4002 cmdline_parse_token_string_t cmd_gro_flush_set =
4003 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4005 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4006 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4007 cmd_keyword, "gro");
4008 cmdline_parse_token_string_t cmd_gro_flush_flush =
4009 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4010 cmd_flush, "flush");
4011 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4012 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4015 cmdline_parse_inst_t cmd_gro_flush = {
4016 .f = cmd_gro_flush_parsed,
4018 .help_str = "set gro flush <cycles>",
4020 (void *)&cmd_gro_flush_set,
4021 (void *)&cmd_gro_flush_keyword,
4022 (void *)&cmd_gro_flush_flush,
4023 (void *)&cmd_gro_flush_cycles,
4028 /* *** ENABLE/DISABLE GSO *** */
4029 struct cmd_gso_enable_result {
4030 cmdline_fixed_string_t cmd_set;
4031 cmdline_fixed_string_t cmd_port;
4032 cmdline_fixed_string_t cmd_keyword;
4033 cmdline_fixed_string_t cmd_mode;
4038 cmd_gso_enable_parsed(void *parsed_result,
4039 __attribute__((unused)) struct cmdline *cl,
4040 __attribute__((unused)) void *data)
4042 struct cmd_gso_enable_result *res;
4044 res = parsed_result;
4045 if (!strcmp(res->cmd_keyword, "gso"))
4046 setup_gso(res->cmd_mode, res->cmd_pid);
4049 cmdline_parse_token_string_t cmd_gso_enable_set =
4050 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4052 cmdline_parse_token_string_t cmd_gso_enable_port =
4053 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4055 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4056 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4057 cmd_keyword, "gso");
4058 cmdline_parse_token_string_t cmd_gso_enable_mode =
4059 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4060 cmd_mode, "on#off");
4061 cmdline_parse_token_num_t cmd_gso_enable_pid =
4062 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4065 cmdline_parse_inst_t cmd_gso_enable = {
4066 .f = cmd_gso_enable_parsed,
4068 .help_str = "set port <port_id> gso on|off",
4070 (void *)&cmd_gso_enable_set,
4071 (void *)&cmd_gso_enable_port,
4072 (void *)&cmd_gso_enable_pid,
4073 (void *)&cmd_gso_enable_keyword,
4074 (void *)&cmd_gso_enable_mode,
4079 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4080 struct cmd_gso_size_result {
4081 cmdline_fixed_string_t cmd_set;
4082 cmdline_fixed_string_t cmd_keyword;
4083 cmdline_fixed_string_t cmd_segsz;
4088 cmd_gso_size_parsed(void *parsed_result,
4089 __attribute__((unused)) struct cmdline *cl,
4090 __attribute__((unused)) void *data)
4092 struct cmd_gso_size_result *res = parsed_result;
4094 if (test_done == 0) {
4095 printf("Before setting GSO segsz, please first"
4096 " stop fowarding\n");
4100 if (!strcmp(res->cmd_keyword, "gso") &&
4101 !strcmp(res->cmd_segsz, "segsz")) {
4102 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4103 printf("gso_size should be larger than %zu."
4104 " Please input a legal value\n",
4105 RTE_GSO_SEG_SIZE_MIN);
4107 gso_max_segment_size = res->cmd_size;
4111 cmdline_parse_token_string_t cmd_gso_size_set =
4112 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4114 cmdline_parse_token_string_t cmd_gso_size_keyword =
4115 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4116 cmd_keyword, "gso");
4117 cmdline_parse_token_string_t cmd_gso_size_segsz =
4118 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4119 cmd_segsz, "segsz");
4120 cmdline_parse_token_num_t cmd_gso_size_size =
4121 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4124 cmdline_parse_inst_t cmd_gso_size = {
4125 .f = cmd_gso_size_parsed,
4127 .help_str = "set gso segsz <length>",
4129 (void *)&cmd_gso_size_set,
4130 (void *)&cmd_gso_size_keyword,
4131 (void *)&cmd_gso_size_segsz,
4132 (void *)&cmd_gso_size_size,
4137 /* *** SHOW GSO CONFIGURATION *** */
4138 struct cmd_gso_show_result {
4139 cmdline_fixed_string_t cmd_show;
4140 cmdline_fixed_string_t cmd_port;
4141 cmdline_fixed_string_t cmd_keyword;
4146 cmd_gso_show_parsed(void *parsed_result,
4147 __attribute__((unused)) struct cmdline *cl,
4148 __attribute__((unused)) void *data)
4150 struct cmd_gso_show_result *res = parsed_result;
4152 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4153 printf("invalid port id %u\n", res->cmd_pid);
4156 if (!strcmp(res->cmd_keyword, "gso")) {
4157 if (gso_ports[res->cmd_pid].enable) {
4158 printf("Max GSO'd packet size: %uB\n"
4159 "Supported GSO types: TCP/IPv4, "
4160 "VxLAN with inner TCP/IPv4 packet, "
4161 "GRE with inner TCP/IPv4 packet\n",
4162 gso_max_segment_size);
4164 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4168 cmdline_parse_token_string_t cmd_gso_show_show =
4169 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4171 cmdline_parse_token_string_t cmd_gso_show_port =
4172 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4174 cmdline_parse_token_string_t cmd_gso_show_keyword =
4175 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4176 cmd_keyword, "gso");
4177 cmdline_parse_token_num_t cmd_gso_show_pid =
4178 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4181 cmdline_parse_inst_t cmd_gso_show = {
4182 .f = cmd_gso_show_parsed,
4184 .help_str = "show port <port_id> gso",
4186 (void *)&cmd_gso_show_show,
4187 (void *)&cmd_gso_show_port,
4188 (void *)&cmd_gso_show_pid,
4189 (void *)&cmd_gso_show_keyword,
4194 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4195 struct cmd_set_flush_rx {
4196 cmdline_fixed_string_t set;
4197 cmdline_fixed_string_t flush_rx;
4198 cmdline_fixed_string_t mode;
4202 cmd_set_flush_rx_parsed(void *parsed_result,
4203 __attribute__((unused)) struct cmdline *cl,
4204 __attribute__((unused)) void *data)
4206 struct cmd_set_flush_rx *res = parsed_result;
4207 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4210 cmdline_parse_token_string_t cmd_setflushrx_set =
4211 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4213 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4214 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4215 flush_rx, "flush_rx");
4216 cmdline_parse_token_string_t cmd_setflushrx_mode =
4217 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4221 cmdline_parse_inst_t cmd_set_flush_rx = {
4222 .f = cmd_set_flush_rx_parsed,
4223 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4226 (void *)&cmd_setflushrx_set,
4227 (void *)&cmd_setflushrx_flush_rx,
4228 (void *)&cmd_setflushrx_mode,
4233 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4234 struct cmd_set_link_check {
4235 cmdline_fixed_string_t set;
4236 cmdline_fixed_string_t link_check;
4237 cmdline_fixed_string_t mode;
4241 cmd_set_link_check_parsed(void *parsed_result,
4242 __attribute__((unused)) struct cmdline *cl,
4243 __attribute__((unused)) void *data)
4245 struct cmd_set_link_check *res = parsed_result;
4246 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4249 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4250 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4252 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4253 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4254 link_check, "link_check");
4255 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4256 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4260 cmdline_parse_inst_t cmd_set_link_check = {
4261 .f = cmd_set_link_check_parsed,
4262 .help_str = "set link_check on|off: Enable/Disable link status check "
4263 "when starting/stopping a port",
4266 (void *)&cmd_setlinkcheck_set,
4267 (void *)&cmd_setlinkcheck_link_check,
4268 (void *)&cmd_setlinkcheck_mode,
4273 /* *** SET NIC BYPASS MODE *** */
4274 struct cmd_set_bypass_mode_result {
4275 cmdline_fixed_string_t set;
4276 cmdline_fixed_string_t bypass;
4277 cmdline_fixed_string_t mode;
4278 cmdline_fixed_string_t value;
4283 cmd_set_bypass_mode_parsed(void *parsed_result,
4284 __attribute__((unused)) struct cmdline *cl,
4285 __attribute__((unused)) void *data)
4287 struct cmd_set_bypass_mode_result *res = parsed_result;
4288 portid_t port_id = res->port_id;
4289 int32_t rc = -EINVAL;
4291 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4292 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4294 if (!strcmp(res->value, "bypass"))
4295 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4296 else if (!strcmp(res->value, "isolate"))
4297 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4299 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4301 /* Set the bypass mode for the relevant port. */
4302 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4305 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4308 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4309 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4311 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4312 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4314 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4315 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4317 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4318 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4319 value, "normal#bypass#isolate");
4320 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4321 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4324 cmdline_parse_inst_t cmd_set_bypass_mode = {
4325 .f = cmd_set_bypass_mode_parsed,
4326 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4327 "Set the NIC bypass mode for port_id",
4330 (void *)&cmd_setbypass_mode_set,
4331 (void *)&cmd_setbypass_mode_bypass,
4332 (void *)&cmd_setbypass_mode_mode,
4333 (void *)&cmd_setbypass_mode_value,
4334 (void *)&cmd_setbypass_mode_port,
4339 /* *** SET NIC BYPASS EVENT *** */
4340 struct cmd_set_bypass_event_result {
4341 cmdline_fixed_string_t set;
4342 cmdline_fixed_string_t bypass;
4343 cmdline_fixed_string_t event;
4344 cmdline_fixed_string_t event_value;
4345 cmdline_fixed_string_t mode;
4346 cmdline_fixed_string_t mode_value;
4351 cmd_set_bypass_event_parsed(void *parsed_result,
4352 __attribute__((unused)) struct cmdline *cl,
4353 __attribute__((unused)) void *data)
4355 int32_t rc = -EINVAL;
4356 struct cmd_set_bypass_event_result *res = parsed_result;
4357 portid_t port_id = res->port_id;
4359 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4360 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4361 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4363 if (!strcmp(res->event_value, "timeout"))
4364 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4365 else if (!strcmp(res->event_value, "os_on"))
4366 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4367 else if (!strcmp(res->event_value, "os_off"))
4368 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4369 else if (!strcmp(res->event_value, "power_on"))
4370 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4371 else if (!strcmp(res->event_value, "power_off"))
4372 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4374 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4376 if (!strcmp(res->mode_value, "bypass"))
4377 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4378 else if (!strcmp(res->mode_value, "isolate"))
4379 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4381 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4383 /* Set the watchdog timeout. */
4384 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4387 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4388 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4392 printf("Failed to set timeout value %u "
4393 "for port %d, errto code: %d.\n",
4394 bypass_timeout, port_id, rc);
4398 /* Set the bypass event to transition to bypass mode. */
4399 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4404 printf("\t Failed to set bypass event for port = %d.\n",
4408 cmdline_parse_token_string_t cmd_setbypass_event_set =
4409 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4411 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4412 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4414 cmdline_parse_token_string_t cmd_setbypass_event_event =
4415 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4417 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4418 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4419 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4420 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4421 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4423 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4424 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4425 mode_value, "normal#bypass#isolate");
4426 cmdline_parse_token_num_t cmd_setbypass_event_port =
4427 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4430 cmdline_parse_inst_t cmd_set_bypass_event = {
4431 .f = cmd_set_bypass_event_parsed,
4432 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4433 "power_off mode normal|bypass|isolate <port_id>: "
4434 "Set the NIC bypass event mode for port_id",
4437 (void *)&cmd_setbypass_event_set,
4438 (void *)&cmd_setbypass_event_bypass,
4439 (void *)&cmd_setbypass_event_event,
4440 (void *)&cmd_setbypass_event_event_value,
4441 (void *)&cmd_setbypass_event_mode,
4442 (void *)&cmd_setbypass_event_mode_value,
4443 (void *)&cmd_setbypass_event_port,
4449 /* *** SET NIC BYPASS TIMEOUT *** */
4450 struct cmd_set_bypass_timeout_result {
4451 cmdline_fixed_string_t set;
4452 cmdline_fixed_string_t bypass;
4453 cmdline_fixed_string_t timeout;
4454 cmdline_fixed_string_t value;
4458 cmd_set_bypass_timeout_parsed(void *parsed_result,
4459 __attribute__((unused)) struct cmdline *cl,
4460 __attribute__((unused)) void *data)
4462 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4464 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4465 if (!strcmp(res->value, "1.5"))
4466 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4467 else if (!strcmp(res->value, "2"))
4468 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4469 else if (!strcmp(res->value, "3"))
4470 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4471 else if (!strcmp(res->value, "4"))
4472 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4473 else if (!strcmp(res->value, "8"))
4474 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4475 else if (!strcmp(res->value, "16"))
4476 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4477 else if (!strcmp(res->value, "32"))
4478 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4480 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4484 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4485 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4487 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4488 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4490 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4491 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4492 timeout, "timeout");
4493 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4494 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4495 value, "0#1.5#2#3#4#8#16#32");
4497 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4498 .f = cmd_set_bypass_timeout_parsed,
4499 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4500 "Set the NIC bypass watchdog timeout in seconds",
4503 (void *)&cmd_setbypass_timeout_set,
4504 (void *)&cmd_setbypass_timeout_bypass,
4505 (void *)&cmd_setbypass_timeout_timeout,
4506 (void *)&cmd_setbypass_timeout_value,
4511 /* *** SHOW NIC BYPASS MODE *** */
4512 struct cmd_show_bypass_config_result {
4513 cmdline_fixed_string_t show;
4514 cmdline_fixed_string_t bypass;
4515 cmdline_fixed_string_t config;
4520 cmd_show_bypass_config_parsed(void *parsed_result,
4521 __attribute__((unused)) struct cmdline *cl,
4522 __attribute__((unused)) void *data)
4524 struct cmd_show_bypass_config_result *res = parsed_result;
4525 portid_t port_id = res->port_id;
4527 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4528 uint32_t event_mode;
4529 uint32_t bypass_mode;
4530 uint32_t timeout = bypass_timeout;
4533 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4534 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4535 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4536 {"UNKNOWN", "normal", "bypass", "isolate"};
4537 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4544 int num_events = (sizeof events) / (sizeof events[0]);
4546 /* Display the bypass mode.*/
4547 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4548 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4552 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4553 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4555 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4558 /* Display the bypass timeout.*/
4559 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4560 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4562 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4564 /* Display the bypass events and associated modes. */
4565 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4567 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4568 printf("\tFailed to get bypass mode for event = %s\n",
4571 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4572 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4574 printf("\tbypass event: %-16s = %s\n", events[i],
4580 printf("\tFailed to get bypass configuration for port = %d\n",
4584 cmdline_parse_token_string_t cmd_showbypass_config_show =
4585 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4587 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4588 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4590 cmdline_parse_token_string_t cmd_showbypass_config_config =
4591 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4593 cmdline_parse_token_num_t cmd_showbypass_config_port =
4594 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4597 cmdline_parse_inst_t cmd_show_bypass_config = {
4598 .f = cmd_show_bypass_config_parsed,
4599 .help_str = "show bypass config <port_id>: "
4600 "Show the NIC bypass config for port_id",
4603 (void *)&cmd_showbypass_config_show,
4604 (void *)&cmd_showbypass_config_bypass,
4605 (void *)&cmd_showbypass_config_config,
4606 (void *)&cmd_showbypass_config_port,
4611 #ifdef RTE_LIBRTE_PMD_BOND
4612 /* *** SET BONDING MODE *** */
4613 struct cmd_set_bonding_mode_result {
4614 cmdline_fixed_string_t set;
4615 cmdline_fixed_string_t bonding;
4616 cmdline_fixed_string_t mode;
4621 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4622 __attribute__((unused)) struct cmdline *cl,
4623 __attribute__((unused)) void *data)
4625 struct cmd_set_bonding_mode_result *res = parsed_result;
4626 portid_t port_id = res->port_id;
4628 /* Set the bonding mode for the relevant port. */
4629 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4630 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4633 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4634 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4636 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4637 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4638 bonding, "bonding");
4639 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4640 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4642 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4643 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4645 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4646 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4649 cmdline_parse_inst_t cmd_set_bonding_mode = {
4650 .f = cmd_set_bonding_mode_parsed,
4651 .help_str = "set bonding mode <mode_value> <port_id>: "
4652 "Set the bonding mode for port_id",
4655 (void *) &cmd_setbonding_mode_set,
4656 (void *) &cmd_setbonding_mode_bonding,
4657 (void *) &cmd_setbonding_mode_mode,
4658 (void *) &cmd_setbonding_mode_value,
4659 (void *) &cmd_setbonding_mode_port,
4664 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4665 struct cmd_set_bonding_lacp_dedicated_queues_result {
4666 cmdline_fixed_string_t set;
4667 cmdline_fixed_string_t bonding;
4668 cmdline_fixed_string_t lacp;
4669 cmdline_fixed_string_t dedicated_queues;
4671 cmdline_fixed_string_t mode;
4674 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4675 __attribute__((unused)) struct cmdline *cl,
4676 __attribute__((unused)) void *data)
4678 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4679 portid_t port_id = res->port_id;
4680 struct rte_port *port;
4682 port = &ports[port_id];
4684 /** Check if the port is not started **/
4685 if (port->port_status != RTE_PORT_STOPPED) {
4686 printf("Please stop port %d first\n", port_id);
4690 if (!strcmp(res->mode, "enable")) {
4691 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4692 printf("Dedicate queues for LACP control packets"
4695 printf("Enabling dedicate queues for LACP control "
4696 "packets on port %d failed\n", port_id);
4697 } else if (!strcmp(res->mode, "disable")) {
4698 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4699 printf("Dedicated queues for LACP control packets "
4702 printf("Disabling dedicated queues for LACP control "
4703 "traffic on port %d failed\n", port_id);
4707 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4708 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4710 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4711 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4712 bonding, "bonding");
4713 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4714 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4716 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4717 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4718 dedicated_queues, "dedicated_queues");
4719 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4720 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4722 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4723 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4724 mode, "enable#disable");
4726 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4727 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4728 .help_str = "set bonding lacp dedicated_queues <port_id> "
4730 "Enable/disable dedicated queues for LACP control traffic for port_id",
4733 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4734 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4735 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4736 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4737 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4738 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4743 /* *** SET BALANCE XMIT POLICY *** */
4744 struct cmd_set_bonding_balance_xmit_policy_result {
4745 cmdline_fixed_string_t set;
4746 cmdline_fixed_string_t bonding;
4747 cmdline_fixed_string_t balance_xmit_policy;
4749 cmdline_fixed_string_t policy;
4752 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4753 __attribute__((unused)) struct cmdline *cl,
4754 __attribute__((unused)) void *data)
4756 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4757 portid_t port_id = res->port_id;
4760 if (!strcmp(res->policy, "l2")) {
4761 policy = BALANCE_XMIT_POLICY_LAYER2;
4762 } else if (!strcmp(res->policy, "l23")) {
4763 policy = BALANCE_XMIT_POLICY_LAYER23;
4764 } else if (!strcmp(res->policy, "l34")) {
4765 policy = BALANCE_XMIT_POLICY_LAYER34;
4767 printf("\t Invalid xmit policy selection");
4771 /* Set the bonding mode for the relevant port. */
4772 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4773 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4778 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4779 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4781 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4782 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4783 bonding, "bonding");
4784 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4785 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4786 balance_xmit_policy, "balance_xmit_policy");
4787 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4788 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4790 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4791 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4792 policy, "l2#l23#l34");
4794 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4795 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4796 .help_str = "set bonding balance_xmit_policy <port_id> "
4798 "Set the bonding balance_xmit_policy for port_id",
4801 (void *)&cmd_setbonding_balance_xmit_policy_set,
4802 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4803 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4804 (void *)&cmd_setbonding_balance_xmit_policy_port,
4805 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4810 /* *** SHOW NIC BONDING CONFIGURATION *** */
4811 struct cmd_show_bonding_config_result {
4812 cmdline_fixed_string_t show;
4813 cmdline_fixed_string_t bonding;
4814 cmdline_fixed_string_t config;
4818 static void cmd_show_bonding_config_parsed(void *parsed_result,
4819 __attribute__((unused)) struct cmdline *cl,
4820 __attribute__((unused)) void *data)
4822 struct cmd_show_bonding_config_result *res = parsed_result;
4823 int bonding_mode, agg_mode;
4824 portid_t slaves[RTE_MAX_ETHPORTS];
4825 int num_slaves, num_active_slaves;
4828 portid_t port_id = res->port_id;
4830 /* Display the bonding mode.*/
4831 bonding_mode = rte_eth_bond_mode_get(port_id);
4832 if (bonding_mode < 0) {
4833 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4836 printf("\tBonding mode: %d\n", bonding_mode);
4838 if (bonding_mode == BONDING_MODE_BALANCE) {
4839 int balance_xmit_policy;
4841 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4842 if (balance_xmit_policy < 0) {
4843 printf("\tFailed to get balance xmit policy for port = %d\n",
4847 printf("\tBalance Xmit Policy: ");
4849 switch (balance_xmit_policy) {
4850 case BALANCE_XMIT_POLICY_LAYER2:
4851 printf("BALANCE_XMIT_POLICY_LAYER2");
4853 case BALANCE_XMIT_POLICY_LAYER23:
4854 printf("BALANCE_XMIT_POLICY_LAYER23");
4856 case BALANCE_XMIT_POLICY_LAYER34:
4857 printf("BALANCE_XMIT_POLICY_LAYER34");
4864 if (bonding_mode == BONDING_MODE_8023AD) {
4865 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
4866 printf("\tIEEE802.3AD Aggregator Mode: ");
4869 printf("bandwidth");
4881 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4883 if (num_slaves < 0) {
4884 printf("\tFailed to get slave list for port = %d\n", port_id);
4887 if (num_slaves > 0) {
4888 printf("\tSlaves (%d): [", num_slaves);
4889 for (i = 0; i < num_slaves - 1; i++)
4890 printf("%d ", slaves[i]);
4892 printf("%d]\n", slaves[num_slaves - 1]);
4894 printf("\tSlaves: []\n");
4898 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4901 if (num_active_slaves < 0) {
4902 printf("\tFailed to get active slave list for port = %d\n", port_id);
4905 if (num_active_slaves > 0) {
4906 printf("\tActive Slaves (%d): [", num_active_slaves);
4907 for (i = 0; i < num_active_slaves - 1; i++)
4908 printf("%d ", slaves[i]);
4910 printf("%d]\n", slaves[num_active_slaves - 1]);
4913 printf("\tActive Slaves: []\n");
4917 primary_id = rte_eth_bond_primary_get(port_id);
4918 if (primary_id < 0) {
4919 printf("\tFailed to get primary slave for port = %d\n", port_id);
4922 printf("\tPrimary: [%d]\n", primary_id);
4926 cmdline_parse_token_string_t cmd_showbonding_config_show =
4927 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4929 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4930 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4931 bonding, "bonding");
4932 cmdline_parse_token_string_t cmd_showbonding_config_config =
4933 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4935 cmdline_parse_token_num_t cmd_showbonding_config_port =
4936 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4939 cmdline_parse_inst_t cmd_show_bonding_config = {
4940 .f = cmd_show_bonding_config_parsed,
4941 .help_str = "show bonding config <port_id>: "
4942 "Show the bonding config for port_id",
4945 (void *)&cmd_showbonding_config_show,
4946 (void *)&cmd_showbonding_config_bonding,
4947 (void *)&cmd_showbonding_config_config,
4948 (void *)&cmd_showbonding_config_port,
4953 /* *** SET BONDING PRIMARY *** */
4954 struct cmd_set_bonding_primary_result {
4955 cmdline_fixed_string_t set;
4956 cmdline_fixed_string_t bonding;
4957 cmdline_fixed_string_t primary;
4962 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4963 __attribute__((unused)) struct cmdline *cl,
4964 __attribute__((unused)) void *data)
4966 struct cmd_set_bonding_primary_result *res = parsed_result;
4967 portid_t master_port_id = res->port_id;
4968 portid_t slave_port_id = res->slave_id;
4970 /* Set the primary slave for a bonded device. */
4971 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4972 printf("\t Failed to set primary slave for port = %d.\n",
4979 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4980 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4982 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4983 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4984 bonding, "bonding");
4985 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4986 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4987 primary, "primary");
4988 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4989 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4991 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4992 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4995 cmdline_parse_inst_t cmd_set_bonding_primary = {
4996 .f = cmd_set_bonding_primary_parsed,
4997 .help_str = "set bonding primary <slave_id> <port_id>: "
4998 "Set the primary slave for port_id",
5001 (void *)&cmd_setbonding_primary_set,
5002 (void *)&cmd_setbonding_primary_bonding,
5003 (void *)&cmd_setbonding_primary_primary,
5004 (void *)&cmd_setbonding_primary_slave,
5005 (void *)&cmd_setbonding_primary_port,
5010 /* *** ADD SLAVE *** */
5011 struct cmd_add_bonding_slave_result {
5012 cmdline_fixed_string_t add;
5013 cmdline_fixed_string_t bonding;
5014 cmdline_fixed_string_t slave;
5019 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5020 __attribute__((unused)) struct cmdline *cl,
5021 __attribute__((unused)) void *data)
5023 struct cmd_add_bonding_slave_result *res = parsed_result;
5024 portid_t master_port_id = res->port_id;
5025 portid_t slave_port_id = res->slave_id;
5027 /* add the slave for a bonded device. */
5028 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5029 printf("\t Failed to add slave %d to master port = %d.\n",
5030 slave_port_id, master_port_id);
5034 set_port_slave_flag(slave_port_id);
5037 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5038 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5040 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5041 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5042 bonding, "bonding");
5043 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5044 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5046 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5047 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5049 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5050 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5053 cmdline_parse_inst_t cmd_add_bonding_slave = {
5054 .f = cmd_add_bonding_slave_parsed,
5055 .help_str = "add bonding slave <slave_id> <port_id>: "
5056 "Add a slave device to a bonded device",
5059 (void *)&cmd_addbonding_slave_add,
5060 (void *)&cmd_addbonding_slave_bonding,
5061 (void *)&cmd_addbonding_slave_slave,
5062 (void *)&cmd_addbonding_slave_slaveid,
5063 (void *)&cmd_addbonding_slave_port,
5068 /* *** REMOVE SLAVE *** */
5069 struct cmd_remove_bonding_slave_result {
5070 cmdline_fixed_string_t remove;
5071 cmdline_fixed_string_t bonding;
5072 cmdline_fixed_string_t slave;
5077 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5078 __attribute__((unused)) struct cmdline *cl,
5079 __attribute__((unused)) void *data)
5081 struct cmd_remove_bonding_slave_result *res = parsed_result;
5082 portid_t master_port_id = res->port_id;
5083 portid_t slave_port_id = res->slave_id;
5085 /* remove the slave from a bonded device. */
5086 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5087 printf("\t Failed to remove slave %d from master port = %d.\n",
5088 slave_port_id, master_port_id);
5092 clear_port_slave_flag(slave_port_id);
5095 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5096 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5098 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5099 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5100 bonding, "bonding");
5101 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5102 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5104 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5105 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5107 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5108 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5111 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5112 .f = cmd_remove_bonding_slave_parsed,
5113 .help_str = "remove bonding slave <slave_id> <port_id>: "
5114 "Remove a slave device from a bonded device",
5117 (void *)&cmd_removebonding_slave_remove,
5118 (void *)&cmd_removebonding_slave_bonding,
5119 (void *)&cmd_removebonding_slave_slave,
5120 (void *)&cmd_removebonding_slave_slaveid,
5121 (void *)&cmd_removebonding_slave_port,
5126 /* *** CREATE BONDED DEVICE *** */
5127 struct cmd_create_bonded_device_result {
5128 cmdline_fixed_string_t create;
5129 cmdline_fixed_string_t bonded;
5130 cmdline_fixed_string_t device;
5135 static int bond_dev_num = 0;
5137 static void cmd_create_bonded_device_parsed(void *parsed_result,
5138 __attribute__((unused)) struct cmdline *cl,
5139 __attribute__((unused)) void *data)
5141 struct cmd_create_bonded_device_result *res = parsed_result;
5142 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5145 if (test_done == 0) {
5146 printf("Please stop forwarding first\n");
5150 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5153 /* Create a new bonded device. */
5154 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5156 printf("\t Failed to create bonded device.\n");
5159 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5162 /* Update number of ports */
5163 nb_ports = rte_eth_dev_count();
5164 reconfig(port_id, res->socket);
5165 rte_eth_promiscuous_enable(port_id);
5170 cmdline_parse_token_string_t cmd_createbonded_device_create =
5171 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5173 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5174 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5176 cmdline_parse_token_string_t cmd_createbonded_device_device =
5177 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5179 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5180 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5182 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5183 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5186 cmdline_parse_inst_t cmd_create_bonded_device = {
5187 .f = cmd_create_bonded_device_parsed,
5188 .help_str = "create bonded device <mode> <socket>: "
5189 "Create a new bonded device with specific bonding mode and socket",
5192 (void *)&cmd_createbonded_device_create,
5193 (void *)&cmd_createbonded_device_bonded,
5194 (void *)&cmd_createbonded_device_device,
5195 (void *)&cmd_createbonded_device_mode,
5196 (void *)&cmd_createbonded_device_socket,
5201 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5202 struct cmd_set_bond_mac_addr_result {
5203 cmdline_fixed_string_t set;
5204 cmdline_fixed_string_t bonding;
5205 cmdline_fixed_string_t mac_addr;
5207 struct ether_addr address;
5210 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5211 __attribute__((unused)) struct cmdline *cl,
5212 __attribute__((unused)) void *data)
5214 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5217 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5220 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5222 /* check the return value and print it if is < 0 */
5224 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5227 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5228 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5229 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5230 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5232 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5233 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5235 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5236 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
5237 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5238 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5240 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5241 .f = cmd_set_bond_mac_addr_parsed,
5243 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5245 (void *)&cmd_set_bond_mac_addr_set,
5246 (void *)&cmd_set_bond_mac_addr_bonding,
5247 (void *)&cmd_set_bond_mac_addr_mac,
5248 (void *)&cmd_set_bond_mac_addr_portnum,
5249 (void *)&cmd_set_bond_mac_addr_addr,
5255 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5256 struct cmd_set_bond_mon_period_result {
5257 cmdline_fixed_string_t set;
5258 cmdline_fixed_string_t bonding;
5259 cmdline_fixed_string_t mon_period;
5264 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5265 __attribute__((unused)) struct cmdline *cl,
5266 __attribute__((unused)) void *data)
5268 struct cmd_set_bond_mon_period_result *res = parsed_result;
5271 if (res->port_num >= nb_ports) {
5272 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5276 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5278 /* check the return value and print it if is < 0 */
5280 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5283 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5284 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5286 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5287 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5288 bonding, "bonding");
5289 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5290 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5291 mon_period, "mon_period");
5292 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5293 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5295 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5296 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5299 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5300 .f = cmd_set_bond_mon_period_parsed,
5302 .help_str = "set bonding mon_period <port_id> <period_ms>",
5304 (void *)&cmd_set_bond_mon_period_set,
5305 (void *)&cmd_set_bond_mon_period_bonding,
5306 (void *)&cmd_set_bond_mon_period_mon_period,
5307 (void *)&cmd_set_bond_mon_period_portnum,
5308 (void *)&cmd_set_bond_mon_period_period_ms,
5315 struct cmd_set_bonding_agg_mode_policy_result {
5316 cmdline_fixed_string_t set;
5317 cmdline_fixed_string_t bonding;
5318 cmdline_fixed_string_t agg_mode;
5320 cmdline_fixed_string_t policy;
5325 cmd_set_bonding_agg_mode(void *parsed_result,
5326 __attribute__((unused)) struct cmdline *cl,
5327 __attribute__((unused)) void *data)
5329 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5330 uint8_t policy = AGG_BANDWIDTH;
5332 if (res->port_num >= nb_ports) {
5333 printf("Port id %d must be less than %d\n",
5334 res->port_num, nb_ports);
5338 if (!strcmp(res->policy, "bandwidth"))
5339 policy = AGG_BANDWIDTH;
5340 else if (!strcmp(res->policy, "stable"))
5341 policy = AGG_STABLE;
5342 else if (!strcmp(res->policy, "count"))
5345 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5349 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5350 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5352 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5353 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5354 bonding, "bonding");
5356 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5357 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5358 agg_mode, "agg_mode");
5360 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5361 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5364 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5365 TOKEN_STRING_INITIALIZER(
5366 struct cmd_set_bonding_balance_xmit_policy_result,
5367 policy, "stable#bandwidth#count");
5369 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5370 .f = cmd_set_bonding_agg_mode,
5372 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5374 (void *)&cmd_set_bonding_agg_mode_set,
5375 (void *)&cmd_set_bonding_agg_mode_bonding,
5376 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5377 (void *)&cmd_set_bonding_agg_mode_portnum,
5378 (void *)&cmd_set_bonding_agg_mode_policy_string,
5384 #endif /* RTE_LIBRTE_PMD_BOND */
5386 /* *** SET FORWARDING MODE *** */
5387 struct cmd_set_fwd_mode_result {
5388 cmdline_fixed_string_t set;
5389 cmdline_fixed_string_t fwd;
5390 cmdline_fixed_string_t mode;
5393 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5394 __attribute__((unused)) struct cmdline *cl,
5395 __attribute__((unused)) void *data)
5397 struct cmd_set_fwd_mode_result *res = parsed_result;
5400 set_pkt_forwarding_mode(res->mode);
5403 cmdline_parse_token_string_t cmd_setfwd_set =
5404 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5405 cmdline_parse_token_string_t cmd_setfwd_fwd =
5406 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5407 cmdline_parse_token_string_t cmd_setfwd_mode =
5408 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5409 "" /* defined at init */);
5411 cmdline_parse_inst_t cmd_set_fwd_mode = {
5412 .f = cmd_set_fwd_mode_parsed,
5414 .help_str = NULL, /* defined at init */
5416 (void *)&cmd_setfwd_set,
5417 (void *)&cmd_setfwd_fwd,
5418 (void *)&cmd_setfwd_mode,
5423 static void cmd_set_fwd_mode_init(void)
5426 static char token[128];
5427 static char help[256];
5428 cmdline_parse_token_string_t *token_struct;
5430 modes = list_pkt_forwarding_modes();
5431 snprintf(help, sizeof(help), "set fwd %s: "
5432 "Set packet forwarding mode", modes);
5433 cmd_set_fwd_mode.help_str = help;
5435 /* string token separator is # */
5436 for (c = token; *modes != '\0'; modes++)
5441 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5442 token_struct->string_data.str = token;
5445 /* *** SET RETRY FORWARDING MODE *** */
5446 struct cmd_set_fwd_retry_mode_result {
5447 cmdline_fixed_string_t set;
5448 cmdline_fixed_string_t fwd;
5449 cmdline_fixed_string_t mode;
5450 cmdline_fixed_string_t retry;
5453 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5454 __attribute__((unused)) struct cmdline *cl,
5455 __attribute__((unused)) void *data)
5457 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5460 set_pkt_forwarding_mode(res->mode);
5463 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5464 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5466 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5467 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5469 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5470 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5472 "" /* defined at init */);
5473 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5474 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5477 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5478 .f = cmd_set_fwd_retry_mode_parsed,
5480 .help_str = NULL, /* defined at init */
5482 (void *)&cmd_setfwd_retry_set,
5483 (void *)&cmd_setfwd_retry_fwd,
5484 (void *)&cmd_setfwd_retry_mode,
5485 (void *)&cmd_setfwd_retry_retry,
5490 static void cmd_set_fwd_retry_mode_init(void)
5493 static char token[128];
5494 static char help[256];
5495 cmdline_parse_token_string_t *token_struct;
5497 modes = list_pkt_forwarding_retry_modes();
5498 snprintf(help, sizeof(help), "set fwd %s retry: "
5499 "Set packet forwarding mode with retry", modes);
5500 cmd_set_fwd_retry_mode.help_str = help;
5502 /* string token separator is # */
5503 for (c = token; *modes != '\0'; modes++)
5508 token_struct = (cmdline_parse_token_string_t *)
5509 cmd_set_fwd_retry_mode.tokens[2];
5510 token_struct->string_data.str = token;
5513 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5514 struct cmd_set_burst_tx_retry_result {
5515 cmdline_fixed_string_t set;
5516 cmdline_fixed_string_t burst;
5517 cmdline_fixed_string_t tx;
5518 cmdline_fixed_string_t delay;
5520 cmdline_fixed_string_t retry;
5524 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5525 __attribute__((unused)) struct cmdline *cl,
5526 __attribute__((unused)) void *data)
5528 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5530 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5531 && !strcmp(res->tx, "tx")) {
5532 if (!strcmp(res->delay, "delay"))
5533 burst_tx_delay_time = res->time;
5534 if (!strcmp(res->retry, "retry"))
5535 burst_tx_retry_num = res->retry_num;
5540 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5541 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5542 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5543 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5545 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5546 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5547 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5548 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5549 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5550 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5551 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5552 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5553 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5554 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5556 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5557 .f = cmd_set_burst_tx_retry_parsed,
5558 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5560 (void *)&cmd_set_burst_tx_retry_set,
5561 (void *)&cmd_set_burst_tx_retry_burst,
5562 (void *)&cmd_set_burst_tx_retry_tx,
5563 (void *)&cmd_set_burst_tx_retry_delay,
5564 (void *)&cmd_set_burst_tx_retry_time,
5565 (void *)&cmd_set_burst_tx_retry_retry,
5566 (void *)&cmd_set_burst_tx_retry_retry_num,
5571 /* *** SET PROMISC MODE *** */
5572 struct cmd_set_promisc_mode_result {
5573 cmdline_fixed_string_t set;
5574 cmdline_fixed_string_t promisc;
5575 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5576 uint8_t port_num; /* valid if "allports" argument == 0 */
5577 cmdline_fixed_string_t mode;
5580 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5581 __attribute__((unused)) struct cmdline *cl,
5584 struct cmd_set_promisc_mode_result *res = parsed_result;
5588 if (!strcmp(res->mode, "on"))
5595 RTE_ETH_FOREACH_DEV(i) {
5597 rte_eth_promiscuous_enable(i);
5599 rte_eth_promiscuous_disable(i);
5604 rte_eth_promiscuous_enable(res->port_num);
5606 rte_eth_promiscuous_disable(res->port_num);
5610 cmdline_parse_token_string_t cmd_setpromisc_set =
5611 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5612 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5613 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5615 cmdline_parse_token_string_t cmd_setpromisc_portall =
5616 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5618 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5619 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5621 cmdline_parse_token_string_t cmd_setpromisc_mode =
5622 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5625 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5626 .f = cmd_set_promisc_mode_parsed,
5628 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5630 (void *)&cmd_setpromisc_set,
5631 (void *)&cmd_setpromisc_promisc,
5632 (void *)&cmd_setpromisc_portall,
5633 (void *)&cmd_setpromisc_mode,
5638 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5639 .f = cmd_set_promisc_mode_parsed,
5641 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5643 (void *)&cmd_setpromisc_set,
5644 (void *)&cmd_setpromisc_promisc,
5645 (void *)&cmd_setpromisc_portnum,
5646 (void *)&cmd_setpromisc_mode,
5651 /* *** SET ALLMULTI MODE *** */
5652 struct cmd_set_allmulti_mode_result {
5653 cmdline_fixed_string_t set;
5654 cmdline_fixed_string_t allmulti;
5655 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5656 uint8_t port_num; /* valid if "allports" argument == 0 */
5657 cmdline_fixed_string_t mode;
5660 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5661 __attribute__((unused)) struct cmdline *cl,
5664 struct cmd_set_allmulti_mode_result *res = parsed_result;
5668 if (!strcmp(res->mode, "on"))
5675 RTE_ETH_FOREACH_DEV(i) {
5677 rte_eth_allmulticast_enable(i);
5679 rte_eth_allmulticast_disable(i);
5684 rte_eth_allmulticast_enable(res->port_num);
5686 rte_eth_allmulticast_disable(res->port_num);
5690 cmdline_parse_token_string_t cmd_setallmulti_set =
5691 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5692 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5693 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5695 cmdline_parse_token_string_t cmd_setallmulti_portall =
5696 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5698 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5699 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5701 cmdline_parse_token_string_t cmd_setallmulti_mode =
5702 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5705 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5706 .f = cmd_set_allmulti_mode_parsed,
5708 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5710 (void *)&cmd_setallmulti_set,
5711 (void *)&cmd_setallmulti_allmulti,
5712 (void *)&cmd_setallmulti_portall,
5713 (void *)&cmd_setallmulti_mode,
5718 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5719 .f = cmd_set_allmulti_mode_parsed,
5721 .help_str = "set allmulti <port_id> on|off: "
5722 "Set allmulti mode on port_id",
5724 (void *)&cmd_setallmulti_set,
5725 (void *)&cmd_setallmulti_allmulti,
5726 (void *)&cmd_setallmulti_portnum,
5727 (void *)&cmd_setallmulti_mode,
5732 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5733 struct cmd_link_flow_ctrl_set_result {
5734 cmdline_fixed_string_t set;
5735 cmdline_fixed_string_t flow_ctrl;
5736 cmdline_fixed_string_t rx;
5737 cmdline_fixed_string_t rx_lfc_mode;
5738 cmdline_fixed_string_t tx;
5739 cmdline_fixed_string_t tx_lfc_mode;
5740 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5741 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5742 cmdline_fixed_string_t autoneg_str;
5743 cmdline_fixed_string_t autoneg;
5744 cmdline_fixed_string_t hw_str;
5745 uint32_t high_water;
5746 cmdline_fixed_string_t lw_str;
5748 cmdline_fixed_string_t pt_str;
5749 uint16_t pause_time;
5750 cmdline_fixed_string_t xon_str;
5755 cmdline_parse_token_string_t cmd_lfc_set_set =
5756 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5758 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5759 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5760 flow_ctrl, "flow_ctrl");
5761 cmdline_parse_token_string_t cmd_lfc_set_rx =
5762 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5764 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5765 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5766 rx_lfc_mode, "on#off");
5767 cmdline_parse_token_string_t cmd_lfc_set_tx =
5768 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5770 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5771 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5772 tx_lfc_mode, "on#off");
5773 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5774 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5775 hw_str, "high_water");
5776 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5777 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5778 high_water, UINT32);
5779 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5780 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5781 lw_str, "low_water");
5782 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5783 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5785 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5786 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5787 pt_str, "pause_time");
5788 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5789 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5790 pause_time, UINT16);
5791 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5792 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5793 xon_str, "send_xon");
5794 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5795 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5797 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5798 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5799 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5800 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5801 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5802 mac_ctrl_frame_fwd_mode, "on#off");
5803 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5804 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5805 autoneg_str, "autoneg");
5806 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5807 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5809 cmdline_parse_token_num_t cmd_lfc_set_portid =
5810 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5813 /* forward declaration */
5815 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5818 cmdline_parse_inst_t cmd_link_flow_control_set = {
5819 .f = cmd_link_flow_ctrl_set_parsed,
5821 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5822 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5823 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5825 (void *)&cmd_lfc_set_set,
5826 (void *)&cmd_lfc_set_flow_ctrl,
5827 (void *)&cmd_lfc_set_rx,
5828 (void *)&cmd_lfc_set_rx_mode,
5829 (void *)&cmd_lfc_set_tx,
5830 (void *)&cmd_lfc_set_tx_mode,
5831 (void *)&cmd_lfc_set_high_water,
5832 (void *)&cmd_lfc_set_low_water,
5833 (void *)&cmd_lfc_set_pause_time,
5834 (void *)&cmd_lfc_set_send_xon,
5835 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5836 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5837 (void *)&cmd_lfc_set_autoneg_str,
5838 (void *)&cmd_lfc_set_autoneg,
5839 (void *)&cmd_lfc_set_portid,
5844 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5845 .f = cmd_link_flow_ctrl_set_parsed,
5846 .data = (void *)&cmd_link_flow_control_set_rx,
5847 .help_str = "set flow_ctrl rx on|off <port_id>: "
5848 "Change rx flow control parameter",
5850 (void *)&cmd_lfc_set_set,
5851 (void *)&cmd_lfc_set_flow_ctrl,
5852 (void *)&cmd_lfc_set_rx,
5853 (void *)&cmd_lfc_set_rx_mode,
5854 (void *)&cmd_lfc_set_portid,
5859 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5860 .f = cmd_link_flow_ctrl_set_parsed,
5861 .data = (void *)&cmd_link_flow_control_set_tx,
5862 .help_str = "set flow_ctrl tx on|off <port_id>: "
5863 "Change tx flow control parameter",
5865 (void *)&cmd_lfc_set_set,
5866 (void *)&cmd_lfc_set_flow_ctrl,
5867 (void *)&cmd_lfc_set_tx,
5868 (void *)&cmd_lfc_set_tx_mode,
5869 (void *)&cmd_lfc_set_portid,
5874 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5875 .f = cmd_link_flow_ctrl_set_parsed,
5876 .data = (void *)&cmd_link_flow_control_set_hw,
5877 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5878 "Change high water flow control parameter",
5880 (void *)&cmd_lfc_set_set,
5881 (void *)&cmd_lfc_set_flow_ctrl,
5882 (void *)&cmd_lfc_set_high_water_str,
5883 (void *)&cmd_lfc_set_high_water,
5884 (void *)&cmd_lfc_set_portid,
5889 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5890 .f = cmd_link_flow_ctrl_set_parsed,
5891 .data = (void *)&cmd_link_flow_control_set_lw,
5892 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5893 "Change low water flow control parameter",
5895 (void *)&cmd_lfc_set_set,
5896 (void *)&cmd_lfc_set_flow_ctrl,
5897 (void *)&cmd_lfc_set_low_water_str,
5898 (void *)&cmd_lfc_set_low_water,
5899 (void *)&cmd_lfc_set_portid,
5904 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5905 .f = cmd_link_flow_ctrl_set_parsed,
5906 .data = (void *)&cmd_link_flow_control_set_pt,
5907 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5908 "Change pause time flow control parameter",
5910 (void *)&cmd_lfc_set_set,
5911 (void *)&cmd_lfc_set_flow_ctrl,
5912 (void *)&cmd_lfc_set_pause_time_str,
5913 (void *)&cmd_lfc_set_pause_time,
5914 (void *)&cmd_lfc_set_portid,
5919 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5920 .f = cmd_link_flow_ctrl_set_parsed,
5921 .data = (void *)&cmd_link_flow_control_set_xon,
5922 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5923 "Change send_xon flow control parameter",
5925 (void *)&cmd_lfc_set_set,
5926 (void *)&cmd_lfc_set_flow_ctrl,
5927 (void *)&cmd_lfc_set_send_xon_str,
5928 (void *)&cmd_lfc_set_send_xon,
5929 (void *)&cmd_lfc_set_portid,
5934 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5935 .f = cmd_link_flow_ctrl_set_parsed,
5936 .data = (void *)&cmd_link_flow_control_set_macfwd,
5937 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5938 "Change mac ctrl fwd flow control parameter",
5940 (void *)&cmd_lfc_set_set,
5941 (void *)&cmd_lfc_set_flow_ctrl,
5942 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5943 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5944 (void *)&cmd_lfc_set_portid,
5949 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5950 .f = cmd_link_flow_ctrl_set_parsed,
5951 .data = (void *)&cmd_link_flow_control_set_autoneg,
5952 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5953 "Change autoneg flow control parameter",
5955 (void *)&cmd_lfc_set_set,
5956 (void *)&cmd_lfc_set_flow_ctrl,
5957 (void *)&cmd_lfc_set_autoneg_str,
5958 (void *)&cmd_lfc_set_autoneg,
5959 (void *)&cmd_lfc_set_portid,
5965 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5966 __attribute__((unused)) struct cmdline *cl,
5969 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5970 cmdline_parse_inst_t *cmd = data;
5971 struct rte_eth_fc_conf fc_conf;
5977 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5978 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5979 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5980 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5982 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5983 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5986 /* Partial command line, retrieve current configuration */
5988 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5990 printf("cannot get current flow ctrl parameters, return"
5991 "code = %d\n", ret);
5995 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5996 (fc_conf.mode == RTE_FC_FULL))
5998 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5999 (fc_conf.mode == RTE_FC_FULL))
6003 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6004 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6006 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6007 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6009 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6011 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6012 fc_conf.high_water = res->high_water;
6014 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6015 fc_conf.low_water = res->low_water;
6017 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6018 fc_conf.pause_time = res->pause_time;
6020 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6021 fc_conf.send_xon = res->send_xon;
6023 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6024 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6025 fc_conf.mac_ctrl_frame_fwd = 1;
6027 fc_conf.mac_ctrl_frame_fwd = 0;
6030 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6031 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6033 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6035 printf("bad flow contrl parameter, return code = %d \n", ret);
6038 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6039 struct cmd_priority_flow_ctrl_set_result {
6040 cmdline_fixed_string_t set;
6041 cmdline_fixed_string_t pfc_ctrl;
6042 cmdline_fixed_string_t rx;
6043 cmdline_fixed_string_t rx_pfc_mode;
6044 cmdline_fixed_string_t tx;
6045 cmdline_fixed_string_t tx_pfc_mode;
6046 uint32_t high_water;
6048 uint16_t pause_time;
6054 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6055 __attribute__((unused)) struct cmdline *cl,
6056 __attribute__((unused)) void *data)
6058 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6059 struct rte_eth_pfc_conf pfc_conf;
6060 int rx_fc_enable, tx_fc_enable;
6064 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6065 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6066 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6067 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6069 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6070 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6073 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6074 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6075 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6076 pfc_conf.fc.high_water = res->high_water;
6077 pfc_conf.fc.low_water = res->low_water;
6078 pfc_conf.fc.pause_time = res->pause_time;
6079 pfc_conf.priority = res->priority;
6081 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6083 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6086 cmdline_parse_token_string_t cmd_pfc_set_set =
6087 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6089 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6090 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6091 pfc_ctrl, "pfc_ctrl");
6092 cmdline_parse_token_string_t cmd_pfc_set_rx =
6093 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6095 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6096 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6097 rx_pfc_mode, "on#off");
6098 cmdline_parse_token_string_t cmd_pfc_set_tx =
6099 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6101 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6102 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6103 tx_pfc_mode, "on#off");
6104 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6105 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6106 high_water, UINT32);
6107 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6108 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6110 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6111 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6112 pause_time, UINT16);
6113 cmdline_parse_token_num_t cmd_pfc_set_priority =
6114 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6116 cmdline_parse_token_num_t cmd_pfc_set_portid =
6117 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6120 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6121 .f = cmd_priority_flow_ctrl_set_parsed,
6123 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6124 "<pause_time> <priority> <port_id>: "
6125 "Configure the Ethernet priority flow control",
6127 (void *)&cmd_pfc_set_set,
6128 (void *)&cmd_pfc_set_flow_ctrl,
6129 (void *)&cmd_pfc_set_rx,
6130 (void *)&cmd_pfc_set_rx_mode,
6131 (void *)&cmd_pfc_set_tx,
6132 (void *)&cmd_pfc_set_tx_mode,
6133 (void *)&cmd_pfc_set_high_water,
6134 (void *)&cmd_pfc_set_low_water,
6135 (void *)&cmd_pfc_set_pause_time,
6136 (void *)&cmd_pfc_set_priority,
6137 (void *)&cmd_pfc_set_portid,
6142 /* *** RESET CONFIGURATION *** */
6143 struct cmd_reset_result {
6144 cmdline_fixed_string_t reset;
6145 cmdline_fixed_string_t def;
6148 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6150 __attribute__((unused)) void *data)
6152 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6153 set_def_fwd_config();
6156 cmdline_parse_token_string_t cmd_reset_set =
6157 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6158 cmdline_parse_token_string_t cmd_reset_def =
6159 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6162 cmdline_parse_inst_t cmd_reset = {
6163 .f = cmd_reset_parsed,
6165 .help_str = "set default: Reset default forwarding configuration",
6167 (void *)&cmd_reset_set,
6168 (void *)&cmd_reset_def,
6173 /* *** START FORWARDING *** */
6174 struct cmd_start_result {
6175 cmdline_fixed_string_t start;
6178 cmdline_parse_token_string_t cmd_start_start =
6179 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6181 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6182 __attribute__((unused)) struct cmdline *cl,
6183 __attribute__((unused)) void *data)
6185 start_packet_forwarding(0);
6188 cmdline_parse_inst_t cmd_start = {
6189 .f = cmd_start_parsed,
6191 .help_str = "start: Start packet forwarding",
6193 (void *)&cmd_start_start,
6198 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6199 struct cmd_start_tx_first_result {
6200 cmdline_fixed_string_t start;
6201 cmdline_fixed_string_t tx_first;
6205 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6206 __attribute__((unused)) struct cmdline *cl,
6207 __attribute__((unused)) void *data)
6209 start_packet_forwarding(1);
6212 cmdline_parse_token_string_t cmd_start_tx_first_start =
6213 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6215 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6216 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6217 tx_first, "tx_first");
6219 cmdline_parse_inst_t cmd_start_tx_first = {
6220 .f = cmd_start_tx_first_parsed,
6222 .help_str = "start tx_first: Start packet forwarding, "
6223 "after sending 1 burst of packets",
6225 (void *)&cmd_start_tx_first_start,
6226 (void *)&cmd_start_tx_first_tx_first,
6231 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6232 struct cmd_start_tx_first_n_result {
6233 cmdline_fixed_string_t start;
6234 cmdline_fixed_string_t tx_first;
6239 cmd_start_tx_first_n_parsed(void *parsed_result,
6240 __attribute__((unused)) struct cmdline *cl,
6241 __attribute__((unused)) void *data)
6243 struct cmd_start_tx_first_n_result *res = parsed_result;
6245 start_packet_forwarding(res->tx_num);
6248 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6249 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6251 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6252 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6253 tx_first, "tx_first");
6254 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6255 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6258 cmdline_parse_inst_t cmd_start_tx_first_n = {
6259 .f = cmd_start_tx_first_n_parsed,
6261 .help_str = "start tx_first <num>: "
6262 "packet forwarding, after sending <num> bursts of packets",
6264 (void *)&cmd_start_tx_first_n_start,
6265 (void *)&cmd_start_tx_first_n_tx_first,
6266 (void *)&cmd_start_tx_first_n_tx_num,
6271 /* *** SET LINK UP *** */
6272 struct cmd_set_link_up_result {
6273 cmdline_fixed_string_t set;
6274 cmdline_fixed_string_t link_up;
6275 cmdline_fixed_string_t port;
6279 cmdline_parse_token_string_t cmd_set_link_up_set =
6280 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6281 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6282 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6284 cmdline_parse_token_string_t cmd_set_link_up_port =
6285 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6286 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6287 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
6289 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6290 __attribute__((unused)) struct cmdline *cl,
6291 __attribute__((unused)) void *data)
6293 struct cmd_set_link_up_result *res = parsed_result;
6294 dev_set_link_up(res->port_id);
6297 cmdline_parse_inst_t cmd_set_link_up = {
6298 .f = cmd_set_link_up_parsed,
6300 .help_str = "set link-up port <port id>",
6302 (void *)&cmd_set_link_up_set,
6303 (void *)&cmd_set_link_up_link_up,
6304 (void *)&cmd_set_link_up_port,
6305 (void *)&cmd_set_link_up_port_id,
6310 /* *** SET LINK DOWN *** */
6311 struct cmd_set_link_down_result {
6312 cmdline_fixed_string_t set;
6313 cmdline_fixed_string_t link_down;
6314 cmdline_fixed_string_t port;
6318 cmdline_parse_token_string_t cmd_set_link_down_set =
6319 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6320 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6321 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6323 cmdline_parse_token_string_t cmd_set_link_down_port =
6324 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6325 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6326 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
6328 static void cmd_set_link_down_parsed(
6329 __attribute__((unused)) void *parsed_result,
6330 __attribute__((unused)) struct cmdline *cl,
6331 __attribute__((unused)) void *data)
6333 struct cmd_set_link_down_result *res = parsed_result;
6334 dev_set_link_down(res->port_id);
6337 cmdline_parse_inst_t cmd_set_link_down = {
6338 .f = cmd_set_link_down_parsed,
6340 .help_str = "set link-down port <port id>",
6342 (void *)&cmd_set_link_down_set,
6343 (void *)&cmd_set_link_down_link_down,
6344 (void *)&cmd_set_link_down_port,
6345 (void *)&cmd_set_link_down_port_id,
6350 /* *** SHOW CFG *** */
6351 struct cmd_showcfg_result {
6352 cmdline_fixed_string_t show;
6353 cmdline_fixed_string_t cfg;
6354 cmdline_fixed_string_t what;
6357 static void cmd_showcfg_parsed(void *parsed_result,
6358 __attribute__((unused)) struct cmdline *cl,
6359 __attribute__((unused)) void *data)
6361 struct cmd_showcfg_result *res = parsed_result;
6362 if (!strcmp(res->what, "rxtx"))
6363 rxtx_config_display();
6364 else if (!strcmp(res->what, "cores"))
6365 fwd_lcores_config_display();
6366 else if (!strcmp(res->what, "fwd"))
6367 pkt_fwd_config_display(&cur_fwd_config);
6368 else if (!strcmp(res->what, "txpkts"))
6369 show_tx_pkt_segments();
6372 cmdline_parse_token_string_t cmd_showcfg_show =
6373 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6374 cmdline_parse_token_string_t cmd_showcfg_port =
6375 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6376 cmdline_parse_token_string_t cmd_showcfg_what =
6377 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6378 "rxtx#cores#fwd#txpkts");
6380 cmdline_parse_inst_t cmd_showcfg = {
6381 .f = cmd_showcfg_parsed,
6383 .help_str = "show config rxtx|cores|fwd|txpkts",
6385 (void *)&cmd_showcfg_show,
6386 (void *)&cmd_showcfg_port,
6387 (void *)&cmd_showcfg_what,
6392 /* *** SHOW ALL PORT INFO *** */
6393 struct cmd_showportall_result {
6394 cmdline_fixed_string_t show;
6395 cmdline_fixed_string_t port;
6396 cmdline_fixed_string_t what;
6397 cmdline_fixed_string_t all;
6400 static void cmd_showportall_parsed(void *parsed_result,
6401 __attribute__((unused)) struct cmdline *cl,
6402 __attribute__((unused)) void *data)
6406 struct cmd_showportall_result *res = parsed_result;
6407 if (!strcmp(res->show, "clear")) {
6408 if (!strcmp(res->what, "stats"))
6409 RTE_ETH_FOREACH_DEV(i)
6411 else if (!strcmp(res->what, "xstats"))
6412 RTE_ETH_FOREACH_DEV(i)
6413 nic_xstats_clear(i);
6414 } else if (!strcmp(res->what, "info"))
6415 RTE_ETH_FOREACH_DEV(i)
6416 port_infos_display(i);
6417 else if (!strcmp(res->what, "stats"))
6418 RTE_ETH_FOREACH_DEV(i)
6419 nic_stats_display(i);
6420 else if (!strcmp(res->what, "xstats"))
6421 RTE_ETH_FOREACH_DEV(i)
6422 nic_xstats_display(i);
6423 else if (!strcmp(res->what, "fdir"))
6424 RTE_ETH_FOREACH_DEV(i)
6426 else if (!strcmp(res->what, "stat_qmap"))
6427 RTE_ETH_FOREACH_DEV(i)
6428 nic_stats_mapping_display(i);
6429 else if (!strcmp(res->what, "dcb_tc"))
6430 RTE_ETH_FOREACH_DEV(i)
6431 port_dcb_info_display(i);
6432 else if (!strcmp(res->what, "cap"))
6433 RTE_ETH_FOREACH_DEV(i)
6434 port_offload_cap_display(i);
6437 cmdline_parse_token_string_t cmd_showportall_show =
6438 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6440 cmdline_parse_token_string_t cmd_showportall_port =
6441 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6442 cmdline_parse_token_string_t cmd_showportall_what =
6443 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6444 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6445 cmdline_parse_token_string_t cmd_showportall_all =
6446 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6447 cmdline_parse_inst_t cmd_showportall = {
6448 .f = cmd_showportall_parsed,
6450 .help_str = "show|clear port "
6451 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6453 (void *)&cmd_showportall_show,
6454 (void *)&cmd_showportall_port,
6455 (void *)&cmd_showportall_what,
6456 (void *)&cmd_showportall_all,
6461 /* *** SHOW PORT INFO *** */
6462 struct cmd_showport_result {
6463 cmdline_fixed_string_t show;
6464 cmdline_fixed_string_t port;
6465 cmdline_fixed_string_t what;
6469 static void cmd_showport_parsed(void *parsed_result,
6470 __attribute__((unused)) struct cmdline *cl,
6471 __attribute__((unused)) void *data)
6473 struct cmd_showport_result *res = parsed_result;
6474 if (!strcmp(res->show, "clear")) {
6475 if (!strcmp(res->what, "stats"))
6476 nic_stats_clear(res->portnum);
6477 else if (!strcmp(res->what, "xstats"))
6478 nic_xstats_clear(res->portnum);
6479 } else if (!strcmp(res->what, "info"))
6480 port_infos_display(res->portnum);
6481 else if (!strcmp(res->what, "stats"))
6482 nic_stats_display(res->portnum);
6483 else if (!strcmp(res->what, "xstats"))
6484 nic_xstats_display(res->portnum);
6485 else if (!strcmp(res->what, "fdir"))
6486 fdir_get_infos(res->portnum);
6487 else if (!strcmp(res->what, "stat_qmap"))
6488 nic_stats_mapping_display(res->portnum);
6489 else if (!strcmp(res->what, "dcb_tc"))
6490 port_dcb_info_display(res->portnum);
6491 else if (!strcmp(res->what, "cap"))
6492 port_offload_cap_display(res->portnum);
6495 cmdline_parse_token_string_t cmd_showport_show =
6496 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6498 cmdline_parse_token_string_t cmd_showport_port =
6499 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6500 cmdline_parse_token_string_t cmd_showport_what =
6501 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6502 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6503 cmdline_parse_token_num_t cmd_showport_portnum =
6504 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
6506 cmdline_parse_inst_t cmd_showport = {
6507 .f = cmd_showport_parsed,
6509 .help_str = "show|clear port "
6510 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6513 (void *)&cmd_showport_show,
6514 (void *)&cmd_showport_port,
6515 (void *)&cmd_showport_what,
6516 (void *)&cmd_showport_portnum,
6521 /* *** SHOW QUEUE INFO *** */
6522 struct cmd_showqueue_result {
6523 cmdline_fixed_string_t show;
6524 cmdline_fixed_string_t type;
6525 cmdline_fixed_string_t what;
6531 cmd_showqueue_parsed(void *parsed_result,
6532 __attribute__((unused)) struct cmdline *cl,
6533 __attribute__((unused)) void *data)
6535 struct cmd_showqueue_result *res = parsed_result;
6537 if (!strcmp(res->type, "rxq"))
6538 rx_queue_infos_display(res->portnum, res->queuenum);
6539 else if (!strcmp(res->type, "txq"))
6540 tx_queue_infos_display(res->portnum, res->queuenum);
6543 cmdline_parse_token_string_t cmd_showqueue_show =
6544 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6545 cmdline_parse_token_string_t cmd_showqueue_type =
6546 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6547 cmdline_parse_token_string_t cmd_showqueue_what =
6548 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6549 cmdline_parse_token_num_t cmd_showqueue_portnum =
6550 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6551 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6552 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6554 cmdline_parse_inst_t cmd_showqueue = {
6555 .f = cmd_showqueue_parsed,
6557 .help_str = "show rxq|txq info <port_id> <queue_id>",
6559 (void *)&cmd_showqueue_show,
6560 (void *)&cmd_showqueue_type,
6561 (void *)&cmd_showqueue_what,
6562 (void *)&cmd_showqueue_portnum,
6563 (void *)&cmd_showqueue_queuenum,
6568 /* *** READ PORT REGISTER *** */
6569 struct cmd_read_reg_result {
6570 cmdline_fixed_string_t read;
6571 cmdline_fixed_string_t reg;
6577 cmd_read_reg_parsed(void *parsed_result,
6578 __attribute__((unused)) struct cmdline *cl,
6579 __attribute__((unused)) void *data)
6581 struct cmd_read_reg_result *res = parsed_result;
6582 port_reg_display(res->port_id, res->reg_off);
6585 cmdline_parse_token_string_t cmd_read_reg_read =
6586 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6587 cmdline_parse_token_string_t cmd_read_reg_reg =
6588 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6589 cmdline_parse_token_num_t cmd_read_reg_port_id =
6590 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6591 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6592 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6594 cmdline_parse_inst_t cmd_read_reg = {
6595 .f = cmd_read_reg_parsed,
6597 .help_str = "read reg <port_id> <reg_off>",
6599 (void *)&cmd_read_reg_read,
6600 (void *)&cmd_read_reg_reg,
6601 (void *)&cmd_read_reg_port_id,
6602 (void *)&cmd_read_reg_reg_off,
6607 /* *** READ PORT REGISTER BIT FIELD *** */
6608 struct cmd_read_reg_bit_field_result {
6609 cmdline_fixed_string_t read;
6610 cmdline_fixed_string_t regfield;
6618 cmd_read_reg_bit_field_parsed(void *parsed_result,
6619 __attribute__((unused)) struct cmdline *cl,
6620 __attribute__((unused)) void *data)
6622 struct cmd_read_reg_bit_field_result *res = parsed_result;
6623 port_reg_bit_field_display(res->port_id, res->reg_off,
6624 res->bit1_pos, res->bit2_pos);
6627 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6628 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6630 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6631 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6632 regfield, "regfield");
6633 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6634 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6636 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6637 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6639 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6640 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6642 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6643 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6646 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6647 .f = cmd_read_reg_bit_field_parsed,
6649 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6650 "Read register bit field between bit_x and bit_y included",
6652 (void *)&cmd_read_reg_bit_field_read,
6653 (void *)&cmd_read_reg_bit_field_regfield,
6654 (void *)&cmd_read_reg_bit_field_port_id,
6655 (void *)&cmd_read_reg_bit_field_reg_off,
6656 (void *)&cmd_read_reg_bit_field_bit1_pos,
6657 (void *)&cmd_read_reg_bit_field_bit2_pos,
6662 /* *** READ PORT REGISTER BIT *** */
6663 struct cmd_read_reg_bit_result {
6664 cmdline_fixed_string_t read;
6665 cmdline_fixed_string_t regbit;
6672 cmd_read_reg_bit_parsed(void *parsed_result,
6673 __attribute__((unused)) struct cmdline *cl,
6674 __attribute__((unused)) void *data)
6676 struct cmd_read_reg_bit_result *res = parsed_result;
6677 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6680 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6681 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6682 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6683 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6685 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6686 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6687 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6688 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6689 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6690 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6692 cmdline_parse_inst_t cmd_read_reg_bit = {
6693 .f = cmd_read_reg_bit_parsed,
6695 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6697 (void *)&cmd_read_reg_bit_read,
6698 (void *)&cmd_read_reg_bit_regbit,
6699 (void *)&cmd_read_reg_bit_port_id,
6700 (void *)&cmd_read_reg_bit_reg_off,
6701 (void *)&cmd_read_reg_bit_bit_pos,
6706 /* *** WRITE PORT REGISTER *** */
6707 struct cmd_write_reg_result {
6708 cmdline_fixed_string_t write;
6709 cmdline_fixed_string_t reg;
6716 cmd_write_reg_parsed(void *parsed_result,
6717 __attribute__((unused)) struct cmdline *cl,
6718 __attribute__((unused)) void *data)
6720 struct cmd_write_reg_result *res = parsed_result;
6721 port_reg_set(res->port_id, res->reg_off, res->value);
6724 cmdline_parse_token_string_t cmd_write_reg_write =
6725 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6726 cmdline_parse_token_string_t cmd_write_reg_reg =
6727 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6728 cmdline_parse_token_num_t cmd_write_reg_port_id =
6729 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6730 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6731 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6732 cmdline_parse_token_num_t cmd_write_reg_value =
6733 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6735 cmdline_parse_inst_t cmd_write_reg = {
6736 .f = cmd_write_reg_parsed,
6738 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6740 (void *)&cmd_write_reg_write,
6741 (void *)&cmd_write_reg_reg,
6742 (void *)&cmd_write_reg_port_id,
6743 (void *)&cmd_write_reg_reg_off,
6744 (void *)&cmd_write_reg_value,
6749 /* *** WRITE PORT REGISTER BIT FIELD *** */
6750 struct cmd_write_reg_bit_field_result {
6751 cmdline_fixed_string_t write;
6752 cmdline_fixed_string_t regfield;
6761 cmd_write_reg_bit_field_parsed(void *parsed_result,
6762 __attribute__((unused)) struct cmdline *cl,
6763 __attribute__((unused)) void *data)
6765 struct cmd_write_reg_bit_field_result *res = parsed_result;
6766 port_reg_bit_field_set(res->port_id, res->reg_off,
6767 res->bit1_pos, res->bit2_pos, res->value);
6770 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6771 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6773 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6774 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6775 regfield, "regfield");
6776 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6777 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6779 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6780 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6782 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6783 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6785 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6786 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6788 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6789 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6792 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6793 .f = cmd_write_reg_bit_field_parsed,
6795 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6797 "Set register bit field between bit_x and bit_y included",
6799 (void *)&cmd_write_reg_bit_field_write,
6800 (void *)&cmd_write_reg_bit_field_regfield,
6801 (void *)&cmd_write_reg_bit_field_port_id,
6802 (void *)&cmd_write_reg_bit_field_reg_off,
6803 (void *)&cmd_write_reg_bit_field_bit1_pos,
6804 (void *)&cmd_write_reg_bit_field_bit2_pos,
6805 (void *)&cmd_write_reg_bit_field_value,
6810 /* *** WRITE PORT REGISTER BIT *** */
6811 struct cmd_write_reg_bit_result {
6812 cmdline_fixed_string_t write;
6813 cmdline_fixed_string_t regbit;
6821 cmd_write_reg_bit_parsed(void *parsed_result,
6822 __attribute__((unused)) struct cmdline *cl,
6823 __attribute__((unused)) void *data)
6825 struct cmd_write_reg_bit_result *res = parsed_result;
6826 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6829 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6830 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6832 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6833 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6835 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6836 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6837 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6838 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6839 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6840 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6841 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6842 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6844 cmdline_parse_inst_t cmd_write_reg_bit = {
6845 .f = cmd_write_reg_bit_parsed,
6847 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6850 (void *)&cmd_write_reg_bit_write,
6851 (void *)&cmd_write_reg_bit_regbit,
6852 (void *)&cmd_write_reg_bit_port_id,
6853 (void *)&cmd_write_reg_bit_reg_off,
6854 (void *)&cmd_write_reg_bit_bit_pos,
6855 (void *)&cmd_write_reg_bit_value,
6860 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6861 struct cmd_read_rxd_txd_result {
6862 cmdline_fixed_string_t read;
6863 cmdline_fixed_string_t rxd_txd;
6870 cmd_read_rxd_txd_parsed(void *parsed_result,
6871 __attribute__((unused)) struct cmdline *cl,
6872 __attribute__((unused)) void *data)
6874 struct cmd_read_rxd_txd_result *res = parsed_result;
6876 if (!strcmp(res->rxd_txd, "rxd"))
6877 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6878 else if (!strcmp(res->rxd_txd, "txd"))
6879 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6882 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6883 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6884 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6885 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6887 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6888 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6889 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6890 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6891 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6892 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6894 cmdline_parse_inst_t cmd_read_rxd_txd = {
6895 .f = cmd_read_rxd_txd_parsed,
6897 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6899 (void *)&cmd_read_rxd_txd_read,
6900 (void *)&cmd_read_rxd_txd_rxd_txd,
6901 (void *)&cmd_read_rxd_txd_port_id,
6902 (void *)&cmd_read_rxd_txd_queue_id,
6903 (void *)&cmd_read_rxd_txd_desc_id,
6909 struct cmd_quit_result {
6910 cmdline_fixed_string_t quit;
6913 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6915 __attribute__((unused)) void *data)
6921 cmdline_parse_token_string_t cmd_quit_quit =
6922 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6924 cmdline_parse_inst_t cmd_quit = {
6925 .f = cmd_quit_parsed,
6927 .help_str = "quit: Exit application",
6929 (void *)&cmd_quit_quit,
6934 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6935 struct cmd_mac_addr_result {
6936 cmdline_fixed_string_t mac_addr_cmd;
6937 cmdline_fixed_string_t what;
6939 struct ether_addr address;
6942 static void cmd_mac_addr_parsed(void *parsed_result,
6943 __attribute__((unused)) struct cmdline *cl,
6944 __attribute__((unused)) void *data)
6946 struct cmd_mac_addr_result *res = parsed_result;
6949 if (strcmp(res->what, "add") == 0)
6950 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6951 else if (strcmp(res->what, "set") == 0)
6952 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6955 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6957 /* check the return value and print it if is < 0 */
6959 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6963 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6964 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6966 cmdline_parse_token_string_t cmd_mac_addr_what =
6967 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6969 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6970 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6971 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6972 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6974 cmdline_parse_inst_t cmd_mac_addr = {
6975 .f = cmd_mac_addr_parsed,
6977 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6978 "Add/Remove/Set MAC address on port_id",
6980 (void *)&cmd_mac_addr_cmd,
6981 (void *)&cmd_mac_addr_what,
6982 (void *)&cmd_mac_addr_portnum,
6983 (void *)&cmd_mac_addr_addr,
6989 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6990 struct cmd_set_qmap_result {
6991 cmdline_fixed_string_t set;
6992 cmdline_fixed_string_t qmap;
6993 cmdline_fixed_string_t what;
7000 cmd_set_qmap_parsed(void *parsed_result,
7001 __attribute__((unused)) struct cmdline *cl,
7002 __attribute__((unused)) void *data)
7004 struct cmd_set_qmap_result *res = parsed_result;
7005 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7007 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7010 cmdline_parse_token_string_t cmd_setqmap_set =
7011 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7013 cmdline_parse_token_string_t cmd_setqmap_qmap =
7014 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7016 cmdline_parse_token_string_t cmd_setqmap_what =
7017 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7019 cmdline_parse_token_num_t cmd_setqmap_portid =
7020 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7022 cmdline_parse_token_num_t cmd_setqmap_queueid =
7023 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7025 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7026 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7029 cmdline_parse_inst_t cmd_set_qmap = {
7030 .f = cmd_set_qmap_parsed,
7032 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7033 "Set statistics mapping value on tx|rx queue_id of port_id",
7035 (void *)&cmd_setqmap_set,
7036 (void *)&cmd_setqmap_qmap,
7037 (void *)&cmd_setqmap_what,
7038 (void *)&cmd_setqmap_portid,
7039 (void *)&cmd_setqmap_queueid,
7040 (void *)&cmd_setqmap_mapvalue,
7045 /* *** CONFIGURE UNICAST HASH TABLE *** */
7046 struct cmd_set_uc_hash_table {
7047 cmdline_fixed_string_t set;
7048 cmdline_fixed_string_t port;
7050 cmdline_fixed_string_t what;
7051 struct ether_addr address;
7052 cmdline_fixed_string_t mode;
7056 cmd_set_uc_hash_parsed(void *parsed_result,
7057 __attribute__((unused)) struct cmdline *cl,
7058 __attribute__((unused)) void *data)
7061 struct cmd_set_uc_hash_table *res = parsed_result;
7063 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7065 if (strcmp(res->what, "uta") == 0)
7066 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7067 &res->address,(uint8_t)is_on);
7069 printf("bad unicast hash table parameter, return code = %d \n", ret);
7073 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7074 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7076 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7077 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7079 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7080 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7082 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7083 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7085 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7086 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7088 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7089 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7092 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7093 .f = cmd_set_uc_hash_parsed,
7095 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7097 (void *)&cmd_set_uc_hash_set,
7098 (void *)&cmd_set_uc_hash_port,
7099 (void *)&cmd_set_uc_hash_portid,
7100 (void *)&cmd_set_uc_hash_what,
7101 (void *)&cmd_set_uc_hash_mac,
7102 (void *)&cmd_set_uc_hash_mode,
7107 struct cmd_set_uc_all_hash_table {
7108 cmdline_fixed_string_t set;
7109 cmdline_fixed_string_t port;
7111 cmdline_fixed_string_t what;
7112 cmdline_fixed_string_t value;
7113 cmdline_fixed_string_t mode;
7117 cmd_set_uc_all_hash_parsed(void *parsed_result,
7118 __attribute__((unused)) struct cmdline *cl,
7119 __attribute__((unused)) void *data)
7122 struct cmd_set_uc_all_hash_table *res = parsed_result;
7124 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7126 if ((strcmp(res->what, "uta") == 0) &&
7127 (strcmp(res->value, "all") == 0))
7128 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7130 printf("bad unicast hash table parameter,"
7131 "return code = %d \n", ret);
7134 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7135 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7137 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7138 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7140 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7141 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7143 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7144 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7146 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7147 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7149 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7150 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7153 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7154 .f = cmd_set_uc_all_hash_parsed,
7156 .help_str = "set port <port_id> uta all on|off",
7158 (void *)&cmd_set_uc_all_hash_set,
7159 (void *)&cmd_set_uc_all_hash_port,
7160 (void *)&cmd_set_uc_all_hash_portid,
7161 (void *)&cmd_set_uc_all_hash_what,
7162 (void *)&cmd_set_uc_all_hash_value,
7163 (void *)&cmd_set_uc_all_hash_mode,
7168 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7169 struct cmd_set_vf_macvlan_filter {
7170 cmdline_fixed_string_t set;
7171 cmdline_fixed_string_t port;
7173 cmdline_fixed_string_t vf;
7175 struct ether_addr address;
7176 cmdline_fixed_string_t filter_type;
7177 cmdline_fixed_string_t mode;
7181 cmd_set_vf_macvlan_parsed(void *parsed_result,
7182 __attribute__((unused)) struct cmdline *cl,
7183 __attribute__((unused)) void *data)
7186 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7187 struct rte_eth_mac_filter filter;
7189 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7191 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7193 /* set VF MAC filter */
7197 filter.dst_id = res->vf_id;
7199 if (!strcmp(res->filter_type, "exact-mac"))
7200 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7201 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7202 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7203 else if (!strcmp(res->filter_type, "hashmac"))
7204 filter.filter_type = RTE_MAC_HASH_MATCH;
7205 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7206 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7208 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7211 ret = rte_eth_dev_filter_ctrl(res->port_id,
7212 RTE_ETH_FILTER_MACVLAN,
7216 ret = rte_eth_dev_filter_ctrl(res->port_id,
7217 RTE_ETH_FILTER_MACVLAN,
7218 RTE_ETH_FILTER_DELETE,
7222 printf("bad set MAC hash parameter, return code = %d\n", ret);
7226 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7227 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7229 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7230 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7232 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7233 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7235 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7236 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7238 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7239 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7241 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7242 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7244 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7245 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7246 filter_type, "exact-mac#exact-mac-vlan"
7247 "#hashmac#hashmac-vlan");
7248 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7249 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7252 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7253 .f = cmd_set_vf_macvlan_parsed,
7255 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7256 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7257 "Exact match rule: exact match of MAC or MAC and VLAN; "
7258 "hash match rule: hash match of MAC and exact match of VLAN",
7260 (void *)&cmd_set_vf_macvlan_set,
7261 (void *)&cmd_set_vf_macvlan_port,
7262 (void *)&cmd_set_vf_macvlan_portid,
7263 (void *)&cmd_set_vf_macvlan_vf,
7264 (void *)&cmd_set_vf_macvlan_vf_id,
7265 (void *)&cmd_set_vf_macvlan_mac,
7266 (void *)&cmd_set_vf_macvlan_filter_type,
7267 (void *)&cmd_set_vf_macvlan_mode,
7272 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7273 struct cmd_set_vf_traffic {
7274 cmdline_fixed_string_t set;
7275 cmdline_fixed_string_t port;
7277 cmdline_fixed_string_t vf;
7279 cmdline_fixed_string_t what;
7280 cmdline_fixed_string_t mode;
7284 cmd_set_vf_traffic_parsed(void *parsed_result,
7285 __attribute__((unused)) struct cmdline *cl,
7286 __attribute__((unused)) void *data)
7288 struct cmd_set_vf_traffic *res = parsed_result;
7289 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7290 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7292 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7295 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7296 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7298 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7299 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7301 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7302 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7304 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7305 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7307 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7308 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7310 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7311 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7313 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7314 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7317 cmdline_parse_inst_t cmd_set_vf_traffic = {
7318 .f = cmd_set_vf_traffic_parsed,
7320 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7322 (void *)&cmd_setvf_traffic_set,
7323 (void *)&cmd_setvf_traffic_port,
7324 (void *)&cmd_setvf_traffic_portid,
7325 (void *)&cmd_setvf_traffic_vf,
7326 (void *)&cmd_setvf_traffic_vfid,
7327 (void *)&cmd_setvf_traffic_what,
7328 (void *)&cmd_setvf_traffic_mode,
7333 /* *** CONFIGURE VF RECEIVE MODE *** */
7334 struct cmd_set_vf_rxmode {
7335 cmdline_fixed_string_t set;
7336 cmdline_fixed_string_t port;
7338 cmdline_fixed_string_t vf;
7340 cmdline_fixed_string_t what;
7341 cmdline_fixed_string_t mode;
7342 cmdline_fixed_string_t on;
7346 cmd_set_vf_rxmode_parsed(void *parsed_result,
7347 __attribute__((unused)) struct cmdline *cl,
7348 __attribute__((unused)) void *data)
7351 uint16_t rx_mode = 0;
7352 struct cmd_set_vf_rxmode *res = parsed_result;
7354 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7355 if (!strcmp(res->what,"rxmode")) {
7356 if (!strcmp(res->mode, "AUPE"))
7357 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7358 else if (!strcmp(res->mode, "ROPE"))
7359 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7360 else if (!strcmp(res->mode, "BAM"))
7361 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7362 else if (!strncmp(res->mode, "MPE",3))
7363 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7366 #ifdef RTE_LIBRTE_IXGBE_PMD
7367 if (ret == -ENOTSUP)
7368 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7369 rx_mode, (uint8_t)is_on);
7371 #ifdef RTE_LIBRTE_BNXT_PMD
7372 if (ret == -ENOTSUP)
7373 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7374 rx_mode, (uint8_t)is_on);
7377 printf("bad VF receive mode parameter, return code = %d \n",
7381 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7382 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7384 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7385 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7387 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7388 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7390 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7391 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7393 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7394 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7396 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7397 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7399 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7400 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7401 mode, "AUPE#ROPE#BAM#MPE");
7402 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7403 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7406 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7407 .f = cmd_set_vf_rxmode_parsed,
7409 .help_str = "set port <port_id> vf <vf_id> rxmode "
7410 "AUPE|ROPE|BAM|MPE on|off",
7412 (void *)&cmd_set_vf_rxmode_set,
7413 (void *)&cmd_set_vf_rxmode_port,
7414 (void *)&cmd_set_vf_rxmode_portid,
7415 (void *)&cmd_set_vf_rxmode_vf,
7416 (void *)&cmd_set_vf_rxmode_vfid,
7417 (void *)&cmd_set_vf_rxmode_what,
7418 (void *)&cmd_set_vf_rxmode_mode,
7419 (void *)&cmd_set_vf_rxmode_on,
7424 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7425 struct cmd_vf_mac_addr_result {
7426 cmdline_fixed_string_t mac_addr_cmd;
7427 cmdline_fixed_string_t what;
7428 cmdline_fixed_string_t port;
7430 cmdline_fixed_string_t vf;
7432 struct ether_addr address;
7435 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7436 __attribute__((unused)) struct cmdline *cl,
7437 __attribute__((unused)) void *data)
7439 struct cmd_vf_mac_addr_result *res = parsed_result;
7442 if (strcmp(res->what, "add") != 0)
7445 #ifdef RTE_LIBRTE_I40E_PMD
7446 if (ret == -ENOTSUP)
7447 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7450 #ifdef RTE_LIBRTE_BNXT_PMD
7451 if (ret == -ENOTSUP)
7452 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7457 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7461 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7462 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7463 mac_addr_cmd,"mac_addr");
7464 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7465 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7467 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7468 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7470 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7471 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7473 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7474 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7476 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7477 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7479 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7480 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7483 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7484 .f = cmd_vf_mac_addr_parsed,
7486 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7487 "Add MAC address filtering for a VF on port_id",
7489 (void *)&cmd_vf_mac_addr_cmd,
7490 (void *)&cmd_vf_mac_addr_what,
7491 (void *)&cmd_vf_mac_addr_port,
7492 (void *)&cmd_vf_mac_addr_portnum,
7493 (void *)&cmd_vf_mac_addr_vf,
7494 (void *)&cmd_vf_mac_addr_vfnum,
7495 (void *)&cmd_vf_mac_addr_addr,
7500 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7501 struct cmd_vf_rx_vlan_filter {
7502 cmdline_fixed_string_t rx_vlan;
7503 cmdline_fixed_string_t what;
7505 cmdline_fixed_string_t port;
7507 cmdline_fixed_string_t vf;
7512 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7513 __attribute__((unused)) struct cmdline *cl,
7514 __attribute__((unused)) void *data)
7516 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7519 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7521 #ifdef RTE_LIBRTE_IXGBE_PMD
7522 if (ret == -ENOTSUP)
7523 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7524 res->vlan_id, res->vf_mask, is_add);
7526 #ifdef RTE_LIBRTE_I40E_PMD
7527 if (ret == -ENOTSUP)
7528 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7529 res->vlan_id, res->vf_mask, is_add);
7531 #ifdef RTE_LIBRTE_BNXT_PMD
7532 if (ret == -ENOTSUP)
7533 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7534 res->vlan_id, res->vf_mask, is_add);
7541 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7542 res->vlan_id, res->vf_mask);
7545 printf("invalid port_id %d\n", res->port_id);
7548 printf("function not implemented or supported\n");
7551 printf("programming error: (%s)\n", strerror(-ret));
7555 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7556 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7557 rx_vlan, "rx_vlan");
7558 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7559 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7561 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7562 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7564 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7565 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7567 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7568 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7570 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7571 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7573 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7574 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7577 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7578 .f = cmd_vf_rx_vlan_filter_parsed,
7580 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7581 "(vf_mask = hexadecimal VF mask)",
7583 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7584 (void *)&cmd_vf_rx_vlan_filter_what,
7585 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7586 (void *)&cmd_vf_rx_vlan_filter_port,
7587 (void *)&cmd_vf_rx_vlan_filter_portid,
7588 (void *)&cmd_vf_rx_vlan_filter_vf,
7589 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7594 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7595 struct cmd_queue_rate_limit_result {
7596 cmdline_fixed_string_t set;
7597 cmdline_fixed_string_t port;
7599 cmdline_fixed_string_t queue;
7601 cmdline_fixed_string_t rate;
7605 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7606 __attribute__((unused)) struct cmdline *cl,
7607 __attribute__((unused)) void *data)
7609 struct cmd_queue_rate_limit_result *res = parsed_result;
7612 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7613 && (strcmp(res->queue, "queue") == 0)
7614 && (strcmp(res->rate, "rate") == 0))
7615 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7618 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7622 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7623 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7625 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7626 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7628 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7629 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7631 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7632 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7634 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7635 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7637 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7638 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7640 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7641 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7644 cmdline_parse_inst_t cmd_queue_rate_limit = {
7645 .f = cmd_queue_rate_limit_parsed,
7647 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7648 "Set rate limit for a queue on port_id",
7650 (void *)&cmd_queue_rate_limit_set,
7651 (void *)&cmd_queue_rate_limit_port,
7652 (void *)&cmd_queue_rate_limit_portnum,
7653 (void *)&cmd_queue_rate_limit_queue,
7654 (void *)&cmd_queue_rate_limit_queuenum,
7655 (void *)&cmd_queue_rate_limit_rate,
7656 (void *)&cmd_queue_rate_limit_ratenum,
7661 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7662 struct cmd_vf_rate_limit_result {
7663 cmdline_fixed_string_t set;
7664 cmdline_fixed_string_t port;
7666 cmdline_fixed_string_t vf;
7668 cmdline_fixed_string_t rate;
7670 cmdline_fixed_string_t q_msk;
7674 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7675 __attribute__((unused)) struct cmdline *cl,
7676 __attribute__((unused)) void *data)
7678 struct cmd_vf_rate_limit_result *res = parsed_result;
7681 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7682 && (strcmp(res->vf, "vf") == 0)
7683 && (strcmp(res->rate, "rate") == 0)
7684 && (strcmp(res->q_msk, "queue_mask") == 0))
7685 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7686 res->rate_num, res->q_msk_val);
7688 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7692 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7693 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7695 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7696 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7698 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7699 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7701 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7702 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7704 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7705 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7707 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7708 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7710 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7711 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7713 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7714 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7715 q_msk, "queue_mask");
7716 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7717 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7720 cmdline_parse_inst_t cmd_vf_rate_limit = {
7721 .f = cmd_vf_rate_limit_parsed,
7723 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7724 "queue_mask <queue_mask_value>: "
7725 "Set rate limit for queues of VF on port_id",
7727 (void *)&cmd_vf_rate_limit_set,
7728 (void *)&cmd_vf_rate_limit_port,
7729 (void *)&cmd_vf_rate_limit_portnum,
7730 (void *)&cmd_vf_rate_limit_vf,
7731 (void *)&cmd_vf_rate_limit_vfnum,
7732 (void *)&cmd_vf_rate_limit_rate,
7733 (void *)&cmd_vf_rate_limit_ratenum,
7734 (void *)&cmd_vf_rate_limit_q_msk,
7735 (void *)&cmd_vf_rate_limit_q_msk_val,
7740 /* *** ADD TUNNEL FILTER OF A PORT *** */
7741 struct cmd_tunnel_filter_result {
7742 cmdline_fixed_string_t cmd;
7743 cmdline_fixed_string_t what;
7745 struct ether_addr outer_mac;
7746 struct ether_addr inner_mac;
7747 cmdline_ipaddr_t ip_value;
7748 uint16_t inner_vlan;
7749 cmdline_fixed_string_t tunnel_type;
7750 cmdline_fixed_string_t filter_type;
7756 cmd_tunnel_filter_parsed(void *parsed_result,
7757 __attribute__((unused)) struct cmdline *cl,
7758 __attribute__((unused)) void *data)
7760 struct cmd_tunnel_filter_result *res = parsed_result;
7761 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7764 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7766 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7767 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7768 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7770 if (res->ip_value.family == AF_INET) {
7771 tunnel_filter_conf.ip_addr.ipv4_addr =
7772 res->ip_value.addr.ipv4.s_addr;
7773 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7775 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7776 &(res->ip_value.addr.ipv6),
7777 sizeof(struct in6_addr));
7778 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7781 if (!strcmp(res->filter_type, "imac-ivlan"))
7782 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7783 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7784 tunnel_filter_conf.filter_type =
7785 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7786 else if (!strcmp(res->filter_type, "imac-tenid"))
7787 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7788 else if (!strcmp(res->filter_type, "imac"))
7789 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7790 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7791 tunnel_filter_conf.filter_type =
7792 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7793 else if (!strcmp(res->filter_type, "oip"))
7794 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7795 else if (!strcmp(res->filter_type, "iip"))
7796 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7798 printf("The filter type is not supported");
7802 if (!strcmp(res->tunnel_type, "vxlan"))
7803 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7804 else if (!strcmp(res->tunnel_type, "nvgre"))
7805 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7806 else if (!strcmp(res->tunnel_type, "ipingre"))
7807 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7809 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7813 tunnel_filter_conf.tenant_id = res->tenant_id;
7814 tunnel_filter_conf.queue_id = res->queue_num;
7815 if (!strcmp(res->what, "add"))
7816 ret = rte_eth_dev_filter_ctrl(res->port_id,
7817 RTE_ETH_FILTER_TUNNEL,
7819 &tunnel_filter_conf);
7821 ret = rte_eth_dev_filter_ctrl(res->port_id,
7822 RTE_ETH_FILTER_TUNNEL,
7823 RTE_ETH_FILTER_DELETE,
7824 &tunnel_filter_conf);
7826 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7830 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7831 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7832 cmd, "tunnel_filter");
7833 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7834 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7836 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7837 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7839 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7840 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7842 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7843 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7845 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7846 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7847 inner_vlan, UINT16);
7848 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7849 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7851 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7852 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7853 tunnel_type, "vxlan#nvgre#ipingre");
7855 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7856 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7857 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7858 "imac#omac-imac-tenid");
7859 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7860 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7862 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7863 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7866 cmdline_parse_inst_t cmd_tunnel_filter = {
7867 .f = cmd_tunnel_filter_parsed,
7869 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7870 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7871 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7872 "<queue_id>: Add/Rm tunnel filter of a port",
7874 (void *)&cmd_tunnel_filter_cmd,
7875 (void *)&cmd_tunnel_filter_what,
7876 (void *)&cmd_tunnel_filter_port_id,
7877 (void *)&cmd_tunnel_filter_outer_mac,
7878 (void *)&cmd_tunnel_filter_inner_mac,
7879 (void *)&cmd_tunnel_filter_ip_value,
7880 (void *)&cmd_tunnel_filter_innner_vlan,
7881 (void *)&cmd_tunnel_filter_tunnel_type,
7882 (void *)&cmd_tunnel_filter_filter_type,
7883 (void *)&cmd_tunnel_filter_tenant_id,
7884 (void *)&cmd_tunnel_filter_queue_num,
7889 /* *** CONFIGURE TUNNEL UDP PORT *** */
7890 struct cmd_tunnel_udp_config {
7891 cmdline_fixed_string_t cmd;
7892 cmdline_fixed_string_t what;
7898 cmd_tunnel_udp_config_parsed(void *parsed_result,
7899 __attribute__((unused)) struct cmdline *cl,
7900 __attribute__((unused)) void *data)
7902 struct cmd_tunnel_udp_config *res = parsed_result;
7903 struct rte_eth_udp_tunnel tunnel_udp;
7906 tunnel_udp.udp_port = res->udp_port;
7908 if (!strcmp(res->cmd, "rx_vxlan_port"))
7909 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7911 if (!strcmp(res->what, "add"))
7912 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7915 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7919 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7922 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7923 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7924 cmd, "rx_vxlan_port");
7925 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7926 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7928 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7929 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7931 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7932 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7935 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7936 .f = cmd_tunnel_udp_config_parsed,
7938 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7939 "Add/Remove a tunneling UDP port filter",
7941 (void *)&cmd_tunnel_udp_config_cmd,
7942 (void *)&cmd_tunnel_udp_config_what,
7943 (void *)&cmd_tunnel_udp_config_udp_port,
7944 (void *)&cmd_tunnel_udp_config_port_id,
7949 /* *** GLOBAL CONFIG *** */
7950 struct cmd_global_config_result {
7951 cmdline_fixed_string_t cmd;
7953 cmdline_fixed_string_t cfg_type;
7958 cmd_global_config_parsed(void *parsed_result,
7959 __attribute__((unused)) struct cmdline *cl,
7960 __attribute__((unused)) void *data)
7962 struct cmd_global_config_result *res = parsed_result;
7963 struct rte_eth_global_cfg conf;
7966 memset(&conf, 0, sizeof(conf));
7967 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7968 conf.cfg.gre_key_len = res->len;
7969 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7970 RTE_ETH_FILTER_SET, &conf);
7972 printf("Global config error\n");
7975 cmdline_parse_token_string_t cmd_global_config_cmd =
7976 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7978 cmdline_parse_token_num_t cmd_global_config_port_id =
7979 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7980 cmdline_parse_token_string_t cmd_global_config_type =
7981 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7982 cfg_type, "gre-key-len");
7983 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7984 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7987 cmdline_parse_inst_t cmd_global_config = {
7988 .f = cmd_global_config_parsed,
7989 .data = (void *)NULL,
7990 .help_str = "global_config <port_id> gre-key-len <key_len>",
7992 (void *)&cmd_global_config_cmd,
7993 (void *)&cmd_global_config_port_id,
7994 (void *)&cmd_global_config_type,
7995 (void *)&cmd_global_config_gre_key_len,
8000 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8001 struct cmd_set_mirror_mask_result {
8002 cmdline_fixed_string_t set;
8003 cmdline_fixed_string_t port;
8005 cmdline_fixed_string_t mirror;
8007 cmdline_fixed_string_t what;
8008 cmdline_fixed_string_t value;
8009 cmdline_fixed_string_t dstpool;
8011 cmdline_fixed_string_t on;
8014 cmdline_parse_token_string_t cmd_mirror_mask_set =
8015 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8017 cmdline_parse_token_string_t cmd_mirror_mask_port =
8018 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8020 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8021 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8023 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8024 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8025 mirror, "mirror-rule");
8026 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8027 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8029 cmdline_parse_token_string_t cmd_mirror_mask_what =
8030 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8031 what, "pool-mirror-up#pool-mirror-down"
8033 cmdline_parse_token_string_t cmd_mirror_mask_value =
8034 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8036 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8037 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8038 dstpool, "dst-pool");
8039 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8040 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8042 cmdline_parse_token_string_t cmd_mirror_mask_on =
8043 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8047 cmd_set_mirror_mask_parsed(void *parsed_result,
8048 __attribute__((unused)) struct cmdline *cl,
8049 __attribute__((unused)) void *data)
8052 struct cmd_set_mirror_mask_result *res = parsed_result;
8053 struct rte_eth_mirror_conf mr_conf;
8055 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8057 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8059 mr_conf.dst_pool = res->dstpool_id;
8061 if (!strcmp(res->what, "pool-mirror-up")) {
8062 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8063 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8064 } else if (!strcmp(res->what, "pool-mirror-down")) {
8065 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8066 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8067 } else if (!strcmp(res->what, "vlan-mirror")) {
8068 mr_conf.rule_type = ETH_MIRROR_VLAN;
8069 nb_item = parse_item_list(res->value, "vlan",
8070 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8074 for (i = 0; i < nb_item; i++) {
8075 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8076 printf("Invalid vlan_id: must be < 4096\n");
8080 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8081 mr_conf.vlan.vlan_mask |= 1ULL << i;
8085 if (!strcmp(res->on, "on"))
8086 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8089 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8092 printf("mirror rule add error: (%s)\n", strerror(-ret));
8095 cmdline_parse_inst_t cmd_set_mirror_mask = {
8096 .f = cmd_set_mirror_mask_parsed,
8098 .help_str = "set port <port_id> mirror-rule <rule_id> "
8099 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8100 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8102 (void *)&cmd_mirror_mask_set,
8103 (void *)&cmd_mirror_mask_port,
8104 (void *)&cmd_mirror_mask_portid,
8105 (void *)&cmd_mirror_mask_mirror,
8106 (void *)&cmd_mirror_mask_ruleid,
8107 (void *)&cmd_mirror_mask_what,
8108 (void *)&cmd_mirror_mask_value,
8109 (void *)&cmd_mirror_mask_dstpool,
8110 (void *)&cmd_mirror_mask_poolid,
8111 (void *)&cmd_mirror_mask_on,
8116 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8117 struct cmd_set_mirror_link_result {
8118 cmdline_fixed_string_t set;
8119 cmdline_fixed_string_t port;
8121 cmdline_fixed_string_t mirror;
8123 cmdline_fixed_string_t what;
8124 cmdline_fixed_string_t dstpool;
8126 cmdline_fixed_string_t on;
8129 cmdline_parse_token_string_t cmd_mirror_link_set =
8130 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8132 cmdline_parse_token_string_t cmd_mirror_link_port =
8133 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8135 cmdline_parse_token_num_t cmd_mirror_link_portid =
8136 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8138 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8139 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8140 mirror, "mirror-rule");
8141 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8142 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8144 cmdline_parse_token_string_t cmd_mirror_link_what =
8145 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8146 what, "uplink-mirror#downlink-mirror");
8147 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8148 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8149 dstpool, "dst-pool");
8150 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8151 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8153 cmdline_parse_token_string_t cmd_mirror_link_on =
8154 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8158 cmd_set_mirror_link_parsed(void *parsed_result,
8159 __attribute__((unused)) struct cmdline *cl,
8160 __attribute__((unused)) void *data)
8163 struct cmd_set_mirror_link_result *res = parsed_result;
8164 struct rte_eth_mirror_conf mr_conf;
8166 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8167 if (!strcmp(res->what, "uplink-mirror"))
8168 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8170 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8172 mr_conf.dst_pool = res->dstpool_id;
8174 if (!strcmp(res->on, "on"))
8175 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8178 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8181 /* check the return value and print it if is < 0 */
8183 printf("mirror rule add error: (%s)\n", strerror(-ret));
8187 cmdline_parse_inst_t cmd_set_mirror_link = {
8188 .f = cmd_set_mirror_link_parsed,
8190 .help_str = "set port <port_id> mirror-rule <rule_id> "
8191 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8193 (void *)&cmd_mirror_link_set,
8194 (void *)&cmd_mirror_link_port,
8195 (void *)&cmd_mirror_link_portid,
8196 (void *)&cmd_mirror_link_mirror,
8197 (void *)&cmd_mirror_link_ruleid,
8198 (void *)&cmd_mirror_link_what,
8199 (void *)&cmd_mirror_link_dstpool,
8200 (void *)&cmd_mirror_link_poolid,
8201 (void *)&cmd_mirror_link_on,
8206 /* *** RESET VM MIRROR RULE *** */
8207 struct cmd_rm_mirror_rule_result {
8208 cmdline_fixed_string_t reset;
8209 cmdline_fixed_string_t port;
8211 cmdline_fixed_string_t mirror;
8215 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8216 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8218 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8219 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8221 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8222 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8224 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8225 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8226 mirror, "mirror-rule");
8227 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8228 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8232 cmd_reset_mirror_rule_parsed(void *parsed_result,
8233 __attribute__((unused)) struct cmdline *cl,
8234 __attribute__((unused)) void *data)
8237 struct cmd_set_mirror_link_result *res = parsed_result;
8239 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8241 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8244 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8245 .f = cmd_reset_mirror_rule_parsed,
8247 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8249 (void *)&cmd_rm_mirror_rule_reset,
8250 (void *)&cmd_rm_mirror_rule_port,
8251 (void *)&cmd_rm_mirror_rule_portid,
8252 (void *)&cmd_rm_mirror_rule_mirror,
8253 (void *)&cmd_rm_mirror_rule_ruleid,
8258 /* ******************************************************************************** */
8260 struct cmd_dump_result {
8261 cmdline_fixed_string_t dump;
8265 dump_struct_sizes(void)
8267 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8268 DUMP_SIZE(struct rte_mbuf);
8269 DUMP_SIZE(struct rte_mempool);
8270 DUMP_SIZE(struct rte_ring);
8274 static void cmd_dump_parsed(void *parsed_result,
8275 __attribute__((unused)) struct cmdline *cl,
8276 __attribute__((unused)) void *data)
8278 struct cmd_dump_result *res = parsed_result;
8280 if (!strcmp(res->dump, "dump_physmem"))
8281 rte_dump_physmem_layout(stdout);
8282 else if (!strcmp(res->dump, "dump_memzone"))
8283 rte_memzone_dump(stdout);
8284 else if (!strcmp(res->dump, "dump_struct_sizes"))
8285 dump_struct_sizes();
8286 else if (!strcmp(res->dump, "dump_ring"))
8287 rte_ring_list_dump(stdout);
8288 else if (!strcmp(res->dump, "dump_mempool"))
8289 rte_mempool_list_dump(stdout);
8290 else if (!strcmp(res->dump, "dump_devargs"))
8291 rte_eal_devargs_dump(stdout);
8292 else if (!strcmp(res->dump, "dump_log_types"))
8293 rte_log_dump(stdout);
8296 cmdline_parse_token_string_t cmd_dump_dump =
8297 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8300 "dump_struct_sizes#"
8306 cmdline_parse_inst_t cmd_dump = {
8307 .f = cmd_dump_parsed, /* function to call */
8308 .data = NULL, /* 2nd arg of func */
8309 .help_str = "Dump status",
8310 .tokens = { /* token list, NULL terminated */
8311 (void *)&cmd_dump_dump,
8316 /* ******************************************************************************** */
8318 struct cmd_dump_one_result {
8319 cmdline_fixed_string_t dump;
8320 cmdline_fixed_string_t name;
8323 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8324 __attribute__((unused)) void *data)
8326 struct cmd_dump_one_result *res = parsed_result;
8328 if (!strcmp(res->dump, "dump_ring")) {
8330 r = rte_ring_lookup(res->name);
8332 cmdline_printf(cl, "Cannot find ring\n");
8335 rte_ring_dump(stdout, r);
8336 } else if (!strcmp(res->dump, "dump_mempool")) {
8337 struct rte_mempool *mp;
8338 mp = rte_mempool_lookup(res->name);
8340 cmdline_printf(cl, "Cannot find mempool\n");
8343 rte_mempool_dump(stdout, mp);
8347 cmdline_parse_token_string_t cmd_dump_one_dump =
8348 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8349 "dump_ring#dump_mempool");
8351 cmdline_parse_token_string_t cmd_dump_one_name =
8352 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8354 cmdline_parse_inst_t cmd_dump_one = {
8355 .f = cmd_dump_one_parsed, /* function to call */
8356 .data = NULL, /* 2nd arg of func */
8357 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8358 .tokens = { /* token list, NULL terminated */
8359 (void *)&cmd_dump_one_dump,
8360 (void *)&cmd_dump_one_name,
8365 /* *** Add/Del syn filter *** */
8366 struct cmd_syn_filter_result {
8367 cmdline_fixed_string_t filter;
8369 cmdline_fixed_string_t ops;
8370 cmdline_fixed_string_t priority;
8371 cmdline_fixed_string_t high;
8372 cmdline_fixed_string_t queue;
8377 cmd_syn_filter_parsed(void *parsed_result,
8378 __attribute__((unused)) struct cmdline *cl,
8379 __attribute__((unused)) void *data)
8381 struct cmd_syn_filter_result *res = parsed_result;
8382 struct rte_eth_syn_filter syn_filter;
8385 ret = rte_eth_dev_filter_supported(res->port_id,
8386 RTE_ETH_FILTER_SYN);
8388 printf("syn filter is not supported on port %u.\n",
8393 memset(&syn_filter, 0, sizeof(syn_filter));
8395 if (!strcmp(res->ops, "add")) {
8396 if (!strcmp(res->high, "high"))
8397 syn_filter.hig_pri = 1;
8399 syn_filter.hig_pri = 0;
8401 syn_filter.queue = res->queue_id;
8402 ret = rte_eth_dev_filter_ctrl(res->port_id,
8407 ret = rte_eth_dev_filter_ctrl(res->port_id,
8409 RTE_ETH_FILTER_DELETE,
8413 printf("syn filter programming error: (%s)\n",
8417 cmdline_parse_token_string_t cmd_syn_filter_filter =
8418 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8419 filter, "syn_filter");
8420 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8421 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8423 cmdline_parse_token_string_t cmd_syn_filter_ops =
8424 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8426 cmdline_parse_token_string_t cmd_syn_filter_priority =
8427 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8428 priority, "priority");
8429 cmdline_parse_token_string_t cmd_syn_filter_high =
8430 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8432 cmdline_parse_token_string_t cmd_syn_filter_queue =
8433 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8435 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8436 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8439 cmdline_parse_inst_t cmd_syn_filter = {
8440 .f = cmd_syn_filter_parsed,
8442 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8443 "<queue_id>: Add/Delete syn filter",
8445 (void *)&cmd_syn_filter_filter,
8446 (void *)&cmd_syn_filter_port_id,
8447 (void *)&cmd_syn_filter_ops,
8448 (void *)&cmd_syn_filter_priority,
8449 (void *)&cmd_syn_filter_high,
8450 (void *)&cmd_syn_filter_queue,
8451 (void *)&cmd_syn_filter_queue_id,
8456 /* *** ADD/REMOVE A 2tuple FILTER *** */
8457 struct cmd_2tuple_filter_result {
8458 cmdline_fixed_string_t filter;
8460 cmdline_fixed_string_t ops;
8461 cmdline_fixed_string_t dst_port;
8462 uint16_t dst_port_value;
8463 cmdline_fixed_string_t protocol;
8464 uint8_t protocol_value;
8465 cmdline_fixed_string_t mask;
8467 cmdline_fixed_string_t tcp_flags;
8468 uint8_t tcp_flags_value;
8469 cmdline_fixed_string_t priority;
8470 uint8_t priority_value;
8471 cmdline_fixed_string_t queue;
8476 cmd_2tuple_filter_parsed(void *parsed_result,
8477 __attribute__((unused)) struct cmdline *cl,
8478 __attribute__((unused)) void *data)
8480 struct rte_eth_ntuple_filter filter;
8481 struct cmd_2tuple_filter_result *res = parsed_result;
8484 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8486 printf("ntuple filter is not supported on port %u.\n",
8491 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8493 filter.flags = RTE_2TUPLE_FLAGS;
8494 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8495 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8496 filter.proto = res->protocol_value;
8497 filter.priority = res->priority_value;
8498 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8499 printf("nonzero tcp_flags is only meaningful"
8500 " when protocol is TCP.\n");
8503 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8504 printf("invalid TCP flags.\n");
8508 if (res->tcp_flags_value != 0) {
8509 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8510 filter.tcp_flags = res->tcp_flags_value;
8513 /* need convert to big endian. */
8514 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8515 filter.queue = res->queue_id;
8517 if (!strcmp(res->ops, "add"))
8518 ret = rte_eth_dev_filter_ctrl(res->port_id,
8519 RTE_ETH_FILTER_NTUPLE,
8523 ret = rte_eth_dev_filter_ctrl(res->port_id,
8524 RTE_ETH_FILTER_NTUPLE,
8525 RTE_ETH_FILTER_DELETE,
8528 printf("2tuple filter programming error: (%s)\n",
8533 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
8534 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8535 filter, "2tuple_filter");
8536 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
8537 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8539 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
8540 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8542 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
8543 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8544 dst_port, "dst_port");
8545 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
8546 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8547 dst_port_value, UINT16);
8548 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
8549 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8550 protocol, "protocol");
8551 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
8552 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8553 protocol_value, UINT8);
8554 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8555 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8557 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8558 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8560 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8561 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8562 tcp_flags, "tcp_flags");
8563 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8564 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8565 tcp_flags_value, UINT8);
8566 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8567 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8568 priority, "priority");
8569 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8570 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8571 priority_value, UINT8);
8572 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8573 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8575 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8576 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8579 cmdline_parse_inst_t cmd_2tuple_filter = {
8580 .f = cmd_2tuple_filter_parsed,
8582 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8583 "<value> mask <value> tcp_flags <value> priority <value> queue "
8584 "<queue_id>: Add a 2tuple filter",
8586 (void *)&cmd_2tuple_filter_filter,
8587 (void *)&cmd_2tuple_filter_port_id,
8588 (void *)&cmd_2tuple_filter_ops,
8589 (void *)&cmd_2tuple_filter_dst_port,
8590 (void *)&cmd_2tuple_filter_dst_port_value,
8591 (void *)&cmd_2tuple_filter_protocol,
8592 (void *)&cmd_2tuple_filter_protocol_value,
8593 (void *)&cmd_2tuple_filter_mask,
8594 (void *)&cmd_2tuple_filter_mask_value,
8595 (void *)&cmd_2tuple_filter_tcp_flags,
8596 (void *)&cmd_2tuple_filter_tcp_flags_value,
8597 (void *)&cmd_2tuple_filter_priority,
8598 (void *)&cmd_2tuple_filter_priority_value,
8599 (void *)&cmd_2tuple_filter_queue,
8600 (void *)&cmd_2tuple_filter_queue_id,
8605 /* *** ADD/REMOVE A 5tuple FILTER *** */
8606 struct cmd_5tuple_filter_result {
8607 cmdline_fixed_string_t filter;
8609 cmdline_fixed_string_t ops;
8610 cmdline_fixed_string_t dst_ip;
8611 cmdline_ipaddr_t dst_ip_value;
8612 cmdline_fixed_string_t src_ip;
8613 cmdline_ipaddr_t src_ip_value;
8614 cmdline_fixed_string_t dst_port;
8615 uint16_t dst_port_value;
8616 cmdline_fixed_string_t src_port;
8617 uint16_t src_port_value;
8618 cmdline_fixed_string_t protocol;
8619 uint8_t protocol_value;
8620 cmdline_fixed_string_t mask;
8622 cmdline_fixed_string_t tcp_flags;
8623 uint8_t tcp_flags_value;
8624 cmdline_fixed_string_t priority;
8625 uint8_t priority_value;
8626 cmdline_fixed_string_t queue;
8631 cmd_5tuple_filter_parsed(void *parsed_result,
8632 __attribute__((unused)) struct cmdline *cl,
8633 __attribute__((unused)) void *data)
8635 struct rte_eth_ntuple_filter filter;
8636 struct cmd_5tuple_filter_result *res = parsed_result;
8639 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8641 printf("ntuple filter is not supported on port %u.\n",
8646 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8648 filter.flags = RTE_5TUPLE_FLAGS;
8649 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8650 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8651 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8652 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8653 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8654 filter.proto = res->protocol_value;
8655 filter.priority = res->priority_value;
8656 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8657 printf("nonzero tcp_flags is only meaningful"
8658 " when protocol is TCP.\n");
8661 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8662 printf("invalid TCP flags.\n");
8666 if (res->tcp_flags_value != 0) {
8667 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8668 filter.tcp_flags = res->tcp_flags_value;
8671 if (res->dst_ip_value.family == AF_INET)
8672 /* no need to convert, already big endian. */
8673 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8675 if (filter.dst_ip_mask == 0) {
8676 printf("can not support ipv6 involved compare.\n");
8682 if (res->src_ip_value.family == AF_INET)
8683 /* no need to convert, already big endian. */
8684 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8686 if (filter.src_ip_mask == 0) {
8687 printf("can not support ipv6 involved compare.\n");
8692 /* need convert to big endian. */
8693 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8694 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8695 filter.queue = res->queue_id;
8697 if (!strcmp(res->ops, "add"))
8698 ret = rte_eth_dev_filter_ctrl(res->port_id,
8699 RTE_ETH_FILTER_NTUPLE,
8703 ret = rte_eth_dev_filter_ctrl(res->port_id,
8704 RTE_ETH_FILTER_NTUPLE,
8705 RTE_ETH_FILTER_DELETE,
8708 printf("5tuple filter programming error: (%s)\n",
8712 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8713 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8714 filter, "5tuple_filter");
8715 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8716 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8718 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8719 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8721 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8722 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8724 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8725 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8727 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8728 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8730 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8731 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8733 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8734 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8735 dst_port, "dst_port");
8736 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8737 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8738 dst_port_value, UINT16);
8739 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8740 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8741 src_port, "src_port");
8742 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8743 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8744 src_port_value, UINT16);
8745 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8746 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8747 protocol, "protocol");
8748 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8749 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8750 protocol_value, UINT8);
8751 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8752 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8754 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8755 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8757 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8758 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8759 tcp_flags, "tcp_flags");
8760 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8761 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8762 tcp_flags_value, UINT8);
8763 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8764 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8765 priority, "priority");
8766 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8767 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8768 priority_value, UINT8);
8769 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8770 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8772 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8773 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8776 cmdline_parse_inst_t cmd_5tuple_filter = {
8777 .f = cmd_5tuple_filter_parsed,
8779 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8780 "src_ip <value> dst_port <value> src_port <value> "
8781 "protocol <value> mask <value> tcp_flags <value> "
8782 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8784 (void *)&cmd_5tuple_filter_filter,
8785 (void *)&cmd_5tuple_filter_port_id,
8786 (void *)&cmd_5tuple_filter_ops,
8787 (void *)&cmd_5tuple_filter_dst_ip,
8788 (void *)&cmd_5tuple_filter_dst_ip_value,
8789 (void *)&cmd_5tuple_filter_src_ip,
8790 (void *)&cmd_5tuple_filter_src_ip_value,
8791 (void *)&cmd_5tuple_filter_dst_port,
8792 (void *)&cmd_5tuple_filter_dst_port_value,
8793 (void *)&cmd_5tuple_filter_src_port,
8794 (void *)&cmd_5tuple_filter_src_port_value,
8795 (void *)&cmd_5tuple_filter_protocol,
8796 (void *)&cmd_5tuple_filter_protocol_value,
8797 (void *)&cmd_5tuple_filter_mask,
8798 (void *)&cmd_5tuple_filter_mask_value,
8799 (void *)&cmd_5tuple_filter_tcp_flags,
8800 (void *)&cmd_5tuple_filter_tcp_flags_value,
8801 (void *)&cmd_5tuple_filter_priority,
8802 (void *)&cmd_5tuple_filter_priority_value,
8803 (void *)&cmd_5tuple_filter_queue,
8804 (void *)&cmd_5tuple_filter_queue_id,
8809 /* *** ADD/REMOVE A flex FILTER *** */
8810 struct cmd_flex_filter_result {
8811 cmdline_fixed_string_t filter;
8812 cmdline_fixed_string_t ops;
8814 cmdline_fixed_string_t len;
8816 cmdline_fixed_string_t bytes;
8817 cmdline_fixed_string_t bytes_value;
8818 cmdline_fixed_string_t mask;
8819 cmdline_fixed_string_t mask_value;
8820 cmdline_fixed_string_t priority;
8821 uint8_t priority_value;
8822 cmdline_fixed_string_t queue;
8826 static int xdigit2val(unsigned char c)
8831 else if (isupper(c))
8839 cmd_flex_filter_parsed(void *parsed_result,
8840 __attribute__((unused)) struct cmdline *cl,
8841 __attribute__((unused)) void *data)
8844 struct rte_eth_flex_filter filter;
8845 struct cmd_flex_filter_result *res = parsed_result;
8846 char *bytes_ptr, *mask_ptr;
8847 uint16_t len, i, j = 0;
8852 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8853 printf("the len exceed the max length 128\n");
8856 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8857 filter.len = res->len_value;
8858 filter.priority = res->priority_value;
8859 filter.queue = res->queue_id;
8860 bytes_ptr = res->bytes_value;
8861 mask_ptr = res->mask_value;
8863 /* translate bytes string to array. */
8864 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8865 (bytes_ptr[1] == 'X')))
8867 len = strnlen(bytes_ptr, res->len_value * 2);
8868 if (len == 0 || (len % 8 != 0)) {
8869 printf("please check len and bytes input\n");
8872 for (i = 0; i < len; i++) {
8874 if (isxdigit(c) == 0) {
8875 /* invalid characters. */
8876 printf("invalid input\n");
8879 val = xdigit2val(c);
8882 filter.bytes[j] = byte;
8883 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8890 /* translate mask string to uint8_t array. */
8891 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8892 (mask_ptr[1] == 'X')))
8894 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8896 printf("invalid input\n");
8901 for (i = 0; i < len; i++) {
8903 if (isxdigit(c) == 0) {
8904 /* invalid characters. */
8905 printf("invalid input\n");
8908 val = xdigit2val(c);
8911 filter.mask[j] = byte;
8912 printf("mask[%d]:%02x ", j, filter.mask[j]);
8920 if (!strcmp(res->ops, "add"))
8921 ret = rte_eth_dev_filter_ctrl(res->port_id,
8922 RTE_ETH_FILTER_FLEXIBLE,
8926 ret = rte_eth_dev_filter_ctrl(res->port_id,
8927 RTE_ETH_FILTER_FLEXIBLE,
8928 RTE_ETH_FILTER_DELETE,
8932 printf("flex filter setting error: (%s)\n", strerror(-ret));
8935 cmdline_parse_token_string_t cmd_flex_filter_filter =
8936 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8937 filter, "flex_filter");
8938 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8939 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8941 cmdline_parse_token_string_t cmd_flex_filter_ops =
8942 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8944 cmdline_parse_token_string_t cmd_flex_filter_len =
8945 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8947 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8948 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8950 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8951 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8953 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8954 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8956 cmdline_parse_token_string_t cmd_flex_filter_mask =
8957 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8959 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8960 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8962 cmdline_parse_token_string_t cmd_flex_filter_priority =
8963 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8964 priority, "priority");
8965 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8966 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8967 priority_value, UINT8);
8968 cmdline_parse_token_string_t cmd_flex_filter_queue =
8969 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8971 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8972 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8974 cmdline_parse_inst_t cmd_flex_filter = {
8975 .f = cmd_flex_filter_parsed,
8977 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8978 "<value> mask <value> priority <value> queue <queue_id>: "
8979 "Add/Del a flex filter",
8981 (void *)&cmd_flex_filter_filter,
8982 (void *)&cmd_flex_filter_port_id,
8983 (void *)&cmd_flex_filter_ops,
8984 (void *)&cmd_flex_filter_len,
8985 (void *)&cmd_flex_filter_len_value,
8986 (void *)&cmd_flex_filter_bytes,
8987 (void *)&cmd_flex_filter_bytes_value,
8988 (void *)&cmd_flex_filter_mask,
8989 (void *)&cmd_flex_filter_mask_value,
8990 (void *)&cmd_flex_filter_priority,
8991 (void *)&cmd_flex_filter_priority_value,
8992 (void *)&cmd_flex_filter_queue,
8993 (void *)&cmd_flex_filter_queue_id,
8998 /* *** Filters Control *** */
9000 /* *** deal with ethertype filter *** */
9001 struct cmd_ethertype_filter_result {
9002 cmdline_fixed_string_t filter;
9004 cmdline_fixed_string_t ops;
9005 cmdline_fixed_string_t mac;
9006 struct ether_addr mac_addr;
9007 cmdline_fixed_string_t ethertype;
9008 uint16_t ethertype_value;
9009 cmdline_fixed_string_t drop;
9010 cmdline_fixed_string_t queue;
9014 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9015 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9016 filter, "ethertype_filter");
9017 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9018 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9020 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9021 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9023 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9024 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9025 mac, "mac_addr#mac_ignr");
9026 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9027 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9029 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9030 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9031 ethertype, "ethertype");
9032 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9033 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9034 ethertype_value, UINT16);
9035 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9036 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9038 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9039 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9041 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9042 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9046 cmd_ethertype_filter_parsed(void *parsed_result,
9047 __attribute__((unused)) struct cmdline *cl,
9048 __attribute__((unused)) void *data)
9050 struct cmd_ethertype_filter_result *res = parsed_result;
9051 struct rte_eth_ethertype_filter filter;
9054 ret = rte_eth_dev_filter_supported(res->port_id,
9055 RTE_ETH_FILTER_ETHERTYPE);
9057 printf("ethertype filter is not supported on port %u.\n",
9062 memset(&filter, 0, sizeof(filter));
9063 if (!strcmp(res->mac, "mac_addr")) {
9064 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9065 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9066 sizeof(struct ether_addr));
9068 if (!strcmp(res->drop, "drop"))
9069 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9070 filter.ether_type = res->ethertype_value;
9071 filter.queue = res->queue_id;
9073 if (!strcmp(res->ops, "add"))
9074 ret = rte_eth_dev_filter_ctrl(res->port_id,
9075 RTE_ETH_FILTER_ETHERTYPE,
9079 ret = rte_eth_dev_filter_ctrl(res->port_id,
9080 RTE_ETH_FILTER_ETHERTYPE,
9081 RTE_ETH_FILTER_DELETE,
9084 printf("ethertype filter programming error: (%s)\n",
9088 cmdline_parse_inst_t cmd_ethertype_filter = {
9089 .f = cmd_ethertype_filter_parsed,
9091 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9092 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9093 "Add or delete an ethertype filter entry",
9095 (void *)&cmd_ethertype_filter_filter,
9096 (void *)&cmd_ethertype_filter_port_id,
9097 (void *)&cmd_ethertype_filter_ops,
9098 (void *)&cmd_ethertype_filter_mac,
9099 (void *)&cmd_ethertype_filter_mac_addr,
9100 (void *)&cmd_ethertype_filter_ethertype,
9101 (void *)&cmd_ethertype_filter_ethertype_value,
9102 (void *)&cmd_ethertype_filter_drop,
9103 (void *)&cmd_ethertype_filter_queue,
9104 (void *)&cmd_ethertype_filter_queue_id,
9109 /* *** deal with flow director filter *** */
9110 struct cmd_flow_director_result {
9111 cmdline_fixed_string_t flow_director_filter;
9113 cmdline_fixed_string_t mode;
9114 cmdline_fixed_string_t mode_value;
9115 cmdline_fixed_string_t ops;
9116 cmdline_fixed_string_t flow;
9117 cmdline_fixed_string_t flow_type;
9118 cmdline_fixed_string_t ether;
9119 uint16_t ether_type;
9120 cmdline_fixed_string_t src;
9121 cmdline_ipaddr_t ip_src;
9123 cmdline_fixed_string_t dst;
9124 cmdline_ipaddr_t ip_dst;
9126 cmdline_fixed_string_t verify_tag;
9127 uint32_t verify_tag_value;
9128 cmdline_ipaddr_t tos;
9130 cmdline_ipaddr_t proto;
9131 uint8_t proto_value;
9132 cmdline_ipaddr_t ttl;
9134 cmdline_fixed_string_t vlan;
9135 uint16_t vlan_value;
9136 cmdline_fixed_string_t flexbytes;
9137 cmdline_fixed_string_t flexbytes_value;
9138 cmdline_fixed_string_t pf_vf;
9139 cmdline_fixed_string_t drop;
9140 cmdline_fixed_string_t queue;
9142 cmdline_fixed_string_t fd_id;
9143 uint32_t fd_id_value;
9144 cmdline_fixed_string_t mac;
9145 struct ether_addr mac_addr;
9146 cmdline_fixed_string_t tunnel;
9147 cmdline_fixed_string_t tunnel_type;
9148 cmdline_fixed_string_t tunnel_id;
9149 uint32_t tunnel_id_value;
9153 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9156 const char *p, *p0 = q_arg;
9158 unsigned long int_fld;
9159 char *str_fld[max_num];
9164 p = strchr(p0, '(');
9168 p0 = strchr(p, ')');
9173 if (size >= sizeof(s))
9176 snprintf(s, sizeof(s), "%.*s", size, p);
9177 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9178 if (ret < 0 || ret > max_num)
9180 for (i = 0; i < ret; i++) {
9182 int_fld = strtoul(str_fld[i], &end, 0);
9183 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9185 flexbytes[i] = (uint8_t)int_fld;
9191 str2flowtype(char *string)
9194 static const struct {
9197 } flowtype_str[] = {
9198 {"raw", RTE_ETH_FLOW_RAW},
9199 {"ipv4", RTE_ETH_FLOW_IPV4},
9200 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9201 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9202 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9203 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9204 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9205 {"ipv6", RTE_ETH_FLOW_IPV6},
9206 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9207 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9208 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9209 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9210 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9211 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9214 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9215 if (!strcmp(flowtype_str[i].str, string))
9216 return flowtype_str[i].type;
9219 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9220 return (uint16_t)atoi(string);
9222 return RTE_ETH_FLOW_UNKNOWN;
9225 static enum rte_eth_fdir_tunnel_type
9226 str2fdir_tunneltype(char *string)
9230 static const struct {
9232 enum rte_eth_fdir_tunnel_type type;
9233 } tunneltype_str[] = {
9234 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9235 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9238 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9239 if (!strcmp(tunneltype_str[i].str, string))
9240 return tunneltype_str[i].type;
9242 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9245 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9247 if ((ip_addr).family == AF_INET) \
9248 (ip) = (ip_addr).addr.ipv4.s_addr; \
9250 printf("invalid parameter.\n"); \
9255 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9257 if ((ip_addr).family == AF_INET6) \
9259 &((ip_addr).addr.ipv6), \
9260 sizeof(struct in6_addr)); \
9262 printf("invalid parameter.\n"); \
9268 cmd_flow_director_filter_parsed(void *parsed_result,
9269 __attribute__((unused)) struct cmdline *cl,
9270 __attribute__((unused)) void *data)
9272 struct cmd_flow_director_result *res = parsed_result;
9273 struct rte_eth_fdir_filter entry;
9274 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9276 unsigned long vf_id;
9279 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9281 printf("flow director is not supported on port %u.\n",
9285 memset(flexbytes, 0, sizeof(flexbytes));
9286 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9288 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9289 if (strcmp(res->mode_value, "MAC-VLAN")) {
9290 printf("Please set mode to MAC-VLAN.\n");
9293 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9294 if (strcmp(res->mode_value, "Tunnel")) {
9295 printf("Please set mode to Tunnel.\n");
9299 if (strcmp(res->mode_value, "IP")) {
9300 printf("Please set mode to IP.\n");
9303 entry.input.flow_type = str2flowtype(res->flow_type);
9306 ret = parse_flexbytes(res->flexbytes_value,
9308 RTE_ETH_FDIR_MAX_FLEXLEN);
9310 printf("error: Cannot parse flexbytes input.\n");
9314 switch (entry.input.flow_type) {
9315 case RTE_ETH_FLOW_FRAG_IPV4:
9316 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9317 entry.input.flow.ip4_flow.proto = res->proto_value;
9319 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9320 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9321 IPV4_ADDR_TO_UINT(res->ip_dst,
9322 entry.input.flow.ip4_flow.dst_ip);
9323 IPV4_ADDR_TO_UINT(res->ip_src,
9324 entry.input.flow.ip4_flow.src_ip);
9325 entry.input.flow.ip4_flow.tos = res->tos_value;
9326 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9327 /* need convert to big endian. */
9328 entry.input.flow.udp4_flow.dst_port =
9329 rte_cpu_to_be_16(res->port_dst);
9330 entry.input.flow.udp4_flow.src_port =
9331 rte_cpu_to_be_16(res->port_src);
9333 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9334 IPV4_ADDR_TO_UINT(res->ip_dst,
9335 entry.input.flow.sctp4_flow.ip.dst_ip);
9336 IPV4_ADDR_TO_UINT(res->ip_src,
9337 entry.input.flow.sctp4_flow.ip.src_ip);
9338 entry.input.flow.ip4_flow.tos = res->tos_value;
9339 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9340 /* need convert to big endian. */
9341 entry.input.flow.sctp4_flow.dst_port =
9342 rte_cpu_to_be_16(res->port_dst);
9343 entry.input.flow.sctp4_flow.src_port =
9344 rte_cpu_to_be_16(res->port_src);
9345 entry.input.flow.sctp4_flow.verify_tag =
9346 rte_cpu_to_be_32(res->verify_tag_value);
9348 case RTE_ETH_FLOW_FRAG_IPV6:
9349 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9350 entry.input.flow.ipv6_flow.proto = res->proto_value;
9352 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9353 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9354 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9355 entry.input.flow.ipv6_flow.dst_ip);
9356 IPV6_ADDR_TO_ARRAY(res->ip_src,
9357 entry.input.flow.ipv6_flow.src_ip);
9358 entry.input.flow.ipv6_flow.tc = res->tos_value;
9359 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9360 /* need convert to big endian. */
9361 entry.input.flow.udp6_flow.dst_port =
9362 rte_cpu_to_be_16(res->port_dst);
9363 entry.input.flow.udp6_flow.src_port =
9364 rte_cpu_to_be_16(res->port_src);
9366 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9367 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9368 entry.input.flow.sctp6_flow.ip.dst_ip);
9369 IPV6_ADDR_TO_ARRAY(res->ip_src,
9370 entry.input.flow.sctp6_flow.ip.src_ip);
9371 entry.input.flow.ipv6_flow.tc = res->tos_value;
9372 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9373 /* need convert to big endian. */
9374 entry.input.flow.sctp6_flow.dst_port =
9375 rte_cpu_to_be_16(res->port_dst);
9376 entry.input.flow.sctp6_flow.src_port =
9377 rte_cpu_to_be_16(res->port_src);
9378 entry.input.flow.sctp6_flow.verify_tag =
9379 rte_cpu_to_be_32(res->verify_tag_value);
9381 case RTE_ETH_FLOW_L2_PAYLOAD:
9382 entry.input.flow.l2_flow.ether_type =
9383 rte_cpu_to_be_16(res->ether_type);
9389 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
9390 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
9392 sizeof(struct ether_addr));
9394 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9395 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
9397 sizeof(struct ether_addr));
9398 entry.input.flow.tunnel_flow.tunnel_type =
9399 str2fdir_tunneltype(res->tunnel_type);
9400 entry.input.flow.tunnel_flow.tunnel_id =
9401 rte_cpu_to_be_32(res->tunnel_id_value);
9404 rte_memcpy(entry.input.flow_ext.flexbytes,
9406 RTE_ETH_FDIR_MAX_FLEXLEN);
9408 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
9410 entry.action.flex_off = 0; /*use 0 by default */
9411 if (!strcmp(res->drop, "drop"))
9412 entry.action.behavior = RTE_ETH_FDIR_REJECT;
9414 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
9416 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
9417 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
9418 if (!strcmp(res->pf_vf, "pf"))
9419 entry.input.flow_ext.is_vf = 0;
9420 else if (!strncmp(res->pf_vf, "vf", 2)) {
9421 struct rte_eth_dev_info dev_info;
9423 memset(&dev_info, 0, sizeof(dev_info));
9424 rte_eth_dev_info_get(res->port_id, &dev_info);
9426 vf_id = strtoul(res->pf_vf + 2, &end, 10);
9427 if (errno != 0 || *end != '\0' ||
9428 vf_id >= dev_info.max_vfs) {
9429 printf("invalid parameter %s.\n", res->pf_vf);
9432 entry.input.flow_ext.is_vf = 1;
9433 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
9435 printf("invalid parameter %s.\n", res->pf_vf);
9440 /* set to report FD ID by default */
9441 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
9442 entry.action.rx_queue = res->queue_id;
9443 entry.soft_id = res->fd_id_value;
9444 if (!strcmp(res->ops, "add"))
9445 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9446 RTE_ETH_FILTER_ADD, &entry);
9447 else if (!strcmp(res->ops, "del"))
9448 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9449 RTE_ETH_FILTER_DELETE, &entry);
9451 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9452 RTE_ETH_FILTER_UPDATE, &entry);
9454 printf("flow director programming error: (%s)\n",
9458 cmdline_parse_token_string_t cmd_flow_director_filter =
9459 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9460 flow_director_filter, "flow_director_filter");
9461 cmdline_parse_token_num_t cmd_flow_director_port_id =
9462 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9464 cmdline_parse_token_string_t cmd_flow_director_ops =
9465 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9466 ops, "add#del#update");
9467 cmdline_parse_token_string_t cmd_flow_director_flow =
9468 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9470 cmdline_parse_token_string_t cmd_flow_director_flow_type =
9471 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9472 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9473 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
9474 cmdline_parse_token_string_t cmd_flow_director_ether =
9475 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9477 cmdline_parse_token_num_t cmd_flow_director_ether_type =
9478 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9479 ether_type, UINT16);
9480 cmdline_parse_token_string_t cmd_flow_director_src =
9481 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9483 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
9484 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9486 cmdline_parse_token_num_t cmd_flow_director_port_src =
9487 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9489 cmdline_parse_token_string_t cmd_flow_director_dst =
9490 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9492 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
9493 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9495 cmdline_parse_token_num_t cmd_flow_director_port_dst =
9496 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9498 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
9499 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9500 verify_tag, "verify_tag");
9501 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
9502 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9503 verify_tag_value, UINT32);
9504 cmdline_parse_token_string_t cmd_flow_director_tos =
9505 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9507 cmdline_parse_token_num_t cmd_flow_director_tos_value =
9508 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9510 cmdline_parse_token_string_t cmd_flow_director_proto =
9511 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9513 cmdline_parse_token_num_t cmd_flow_director_proto_value =
9514 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9515 proto_value, UINT8);
9516 cmdline_parse_token_string_t cmd_flow_director_ttl =
9517 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9519 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
9520 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9522 cmdline_parse_token_string_t cmd_flow_director_vlan =
9523 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9525 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
9526 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9527 vlan_value, UINT16);
9528 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
9529 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9530 flexbytes, "flexbytes");
9531 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
9532 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9533 flexbytes_value, NULL);
9534 cmdline_parse_token_string_t cmd_flow_director_drop =
9535 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9537 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
9538 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9540 cmdline_parse_token_string_t cmd_flow_director_queue =
9541 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9543 cmdline_parse_token_num_t cmd_flow_director_queue_id =
9544 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9546 cmdline_parse_token_string_t cmd_flow_director_fd_id =
9547 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9549 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
9550 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9551 fd_id_value, UINT32);
9553 cmdline_parse_token_string_t cmd_flow_director_mode =
9554 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9556 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
9557 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9559 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9560 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9561 mode_value, "MAC-VLAN");
9562 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9564 mode_value, "Tunnel");
9565 cmdline_parse_token_string_t cmd_flow_director_mac =
9566 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9568 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9569 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9571 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9572 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9574 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9575 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9576 tunnel_type, "NVGRE#VxLAN");
9577 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9578 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9579 tunnel_id, "tunnel-id");
9580 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9581 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9582 tunnel_id_value, UINT32);
9584 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9585 .f = cmd_flow_director_filter_parsed,
9587 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9588 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9589 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9590 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9591 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9592 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9593 "fd_id <fd_id_value>: "
9594 "Add or delete an ip flow director entry on NIC",
9596 (void *)&cmd_flow_director_filter,
9597 (void *)&cmd_flow_director_port_id,
9598 (void *)&cmd_flow_director_mode,
9599 (void *)&cmd_flow_director_mode_ip,
9600 (void *)&cmd_flow_director_ops,
9601 (void *)&cmd_flow_director_flow,
9602 (void *)&cmd_flow_director_flow_type,
9603 (void *)&cmd_flow_director_src,
9604 (void *)&cmd_flow_director_ip_src,
9605 (void *)&cmd_flow_director_dst,
9606 (void *)&cmd_flow_director_ip_dst,
9607 (void *)&cmd_flow_director_tos,
9608 (void *)&cmd_flow_director_tos_value,
9609 (void *)&cmd_flow_director_proto,
9610 (void *)&cmd_flow_director_proto_value,
9611 (void *)&cmd_flow_director_ttl,
9612 (void *)&cmd_flow_director_ttl_value,
9613 (void *)&cmd_flow_director_vlan,
9614 (void *)&cmd_flow_director_vlan_value,
9615 (void *)&cmd_flow_director_flexbytes,
9616 (void *)&cmd_flow_director_flexbytes_value,
9617 (void *)&cmd_flow_director_drop,
9618 (void *)&cmd_flow_director_pf_vf,
9619 (void *)&cmd_flow_director_queue,
9620 (void *)&cmd_flow_director_queue_id,
9621 (void *)&cmd_flow_director_fd_id,
9622 (void *)&cmd_flow_director_fd_id_value,
9627 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9628 .f = cmd_flow_director_filter_parsed,
9630 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9631 "director entry on NIC",
9633 (void *)&cmd_flow_director_filter,
9634 (void *)&cmd_flow_director_port_id,
9635 (void *)&cmd_flow_director_mode,
9636 (void *)&cmd_flow_director_mode_ip,
9637 (void *)&cmd_flow_director_ops,
9638 (void *)&cmd_flow_director_flow,
9639 (void *)&cmd_flow_director_flow_type,
9640 (void *)&cmd_flow_director_src,
9641 (void *)&cmd_flow_director_ip_src,
9642 (void *)&cmd_flow_director_port_src,
9643 (void *)&cmd_flow_director_dst,
9644 (void *)&cmd_flow_director_ip_dst,
9645 (void *)&cmd_flow_director_port_dst,
9646 (void *)&cmd_flow_director_tos,
9647 (void *)&cmd_flow_director_tos_value,
9648 (void *)&cmd_flow_director_ttl,
9649 (void *)&cmd_flow_director_ttl_value,
9650 (void *)&cmd_flow_director_vlan,
9651 (void *)&cmd_flow_director_vlan_value,
9652 (void *)&cmd_flow_director_flexbytes,
9653 (void *)&cmd_flow_director_flexbytes_value,
9654 (void *)&cmd_flow_director_drop,
9655 (void *)&cmd_flow_director_pf_vf,
9656 (void *)&cmd_flow_director_queue,
9657 (void *)&cmd_flow_director_queue_id,
9658 (void *)&cmd_flow_director_fd_id,
9659 (void *)&cmd_flow_director_fd_id_value,
9664 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9665 .f = cmd_flow_director_filter_parsed,
9667 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9668 "director entry on NIC",
9670 (void *)&cmd_flow_director_filter,
9671 (void *)&cmd_flow_director_port_id,
9672 (void *)&cmd_flow_director_mode,
9673 (void *)&cmd_flow_director_mode_ip,
9674 (void *)&cmd_flow_director_ops,
9675 (void *)&cmd_flow_director_flow,
9676 (void *)&cmd_flow_director_flow_type,
9677 (void *)&cmd_flow_director_src,
9678 (void *)&cmd_flow_director_ip_src,
9679 (void *)&cmd_flow_director_port_dst,
9680 (void *)&cmd_flow_director_dst,
9681 (void *)&cmd_flow_director_ip_dst,
9682 (void *)&cmd_flow_director_port_dst,
9683 (void *)&cmd_flow_director_verify_tag,
9684 (void *)&cmd_flow_director_verify_tag_value,
9685 (void *)&cmd_flow_director_tos,
9686 (void *)&cmd_flow_director_tos_value,
9687 (void *)&cmd_flow_director_ttl,
9688 (void *)&cmd_flow_director_ttl_value,
9689 (void *)&cmd_flow_director_vlan,
9690 (void *)&cmd_flow_director_vlan_value,
9691 (void *)&cmd_flow_director_flexbytes,
9692 (void *)&cmd_flow_director_flexbytes_value,
9693 (void *)&cmd_flow_director_drop,
9694 (void *)&cmd_flow_director_pf_vf,
9695 (void *)&cmd_flow_director_queue,
9696 (void *)&cmd_flow_director_queue_id,
9697 (void *)&cmd_flow_director_fd_id,
9698 (void *)&cmd_flow_director_fd_id_value,
9703 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9704 .f = cmd_flow_director_filter_parsed,
9706 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9707 "director entry on NIC",
9709 (void *)&cmd_flow_director_filter,
9710 (void *)&cmd_flow_director_port_id,
9711 (void *)&cmd_flow_director_mode,
9712 (void *)&cmd_flow_director_mode_ip,
9713 (void *)&cmd_flow_director_ops,
9714 (void *)&cmd_flow_director_flow,
9715 (void *)&cmd_flow_director_flow_type,
9716 (void *)&cmd_flow_director_ether,
9717 (void *)&cmd_flow_director_ether_type,
9718 (void *)&cmd_flow_director_flexbytes,
9719 (void *)&cmd_flow_director_flexbytes_value,
9720 (void *)&cmd_flow_director_drop,
9721 (void *)&cmd_flow_director_pf_vf,
9722 (void *)&cmd_flow_director_queue,
9723 (void *)&cmd_flow_director_queue_id,
9724 (void *)&cmd_flow_director_fd_id,
9725 (void *)&cmd_flow_director_fd_id_value,
9730 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9731 .f = cmd_flow_director_filter_parsed,
9733 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9734 "director entry on NIC",
9736 (void *)&cmd_flow_director_filter,
9737 (void *)&cmd_flow_director_port_id,
9738 (void *)&cmd_flow_director_mode,
9739 (void *)&cmd_flow_director_mode_mac_vlan,
9740 (void *)&cmd_flow_director_ops,
9741 (void *)&cmd_flow_director_mac,
9742 (void *)&cmd_flow_director_mac_addr,
9743 (void *)&cmd_flow_director_vlan,
9744 (void *)&cmd_flow_director_vlan_value,
9745 (void *)&cmd_flow_director_flexbytes,
9746 (void *)&cmd_flow_director_flexbytes_value,
9747 (void *)&cmd_flow_director_drop,
9748 (void *)&cmd_flow_director_queue,
9749 (void *)&cmd_flow_director_queue_id,
9750 (void *)&cmd_flow_director_fd_id,
9751 (void *)&cmd_flow_director_fd_id_value,
9756 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9757 .f = cmd_flow_director_filter_parsed,
9759 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9760 "director entry on NIC",
9762 (void *)&cmd_flow_director_filter,
9763 (void *)&cmd_flow_director_port_id,
9764 (void *)&cmd_flow_director_mode,
9765 (void *)&cmd_flow_director_mode_tunnel,
9766 (void *)&cmd_flow_director_ops,
9767 (void *)&cmd_flow_director_mac,
9768 (void *)&cmd_flow_director_mac_addr,
9769 (void *)&cmd_flow_director_vlan,
9770 (void *)&cmd_flow_director_vlan_value,
9771 (void *)&cmd_flow_director_tunnel,
9772 (void *)&cmd_flow_director_tunnel_type,
9773 (void *)&cmd_flow_director_tunnel_id,
9774 (void *)&cmd_flow_director_tunnel_id_value,
9775 (void *)&cmd_flow_director_flexbytes,
9776 (void *)&cmd_flow_director_flexbytes_value,
9777 (void *)&cmd_flow_director_drop,
9778 (void *)&cmd_flow_director_queue,
9779 (void *)&cmd_flow_director_queue_id,
9780 (void *)&cmd_flow_director_fd_id,
9781 (void *)&cmd_flow_director_fd_id_value,
9786 struct cmd_flush_flow_director_result {
9787 cmdline_fixed_string_t flush_flow_director;
9791 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9792 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9793 flush_flow_director, "flush_flow_director");
9794 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9795 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9799 cmd_flush_flow_director_parsed(void *parsed_result,
9800 __attribute__((unused)) struct cmdline *cl,
9801 __attribute__((unused)) void *data)
9803 struct cmd_flow_director_result *res = parsed_result;
9806 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9808 printf("flow director is not supported on port %u.\n",
9813 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9814 RTE_ETH_FILTER_FLUSH, NULL);
9816 printf("flow director table flushing error: (%s)\n",
9820 cmdline_parse_inst_t cmd_flush_flow_director = {
9821 .f = cmd_flush_flow_director_parsed,
9823 .help_str = "flush_flow_director <port_id>: "
9824 "Flush all flow director entries of a device on NIC",
9826 (void *)&cmd_flush_flow_director_flush,
9827 (void *)&cmd_flush_flow_director_port_id,
9832 /* *** deal with flow director mask *** */
9833 struct cmd_flow_director_mask_result {
9834 cmdline_fixed_string_t flow_director_mask;
9836 cmdline_fixed_string_t mode;
9837 cmdline_fixed_string_t mode_value;
9838 cmdline_fixed_string_t vlan;
9840 cmdline_fixed_string_t src_mask;
9841 cmdline_ipaddr_t ipv4_src;
9842 cmdline_ipaddr_t ipv6_src;
9844 cmdline_fixed_string_t dst_mask;
9845 cmdline_ipaddr_t ipv4_dst;
9846 cmdline_ipaddr_t ipv6_dst;
9848 cmdline_fixed_string_t mac;
9849 uint8_t mac_addr_byte_mask;
9850 cmdline_fixed_string_t tunnel_id;
9851 uint32_t tunnel_id_mask;
9852 cmdline_fixed_string_t tunnel_type;
9853 uint8_t tunnel_type_mask;
9857 cmd_flow_director_mask_parsed(void *parsed_result,
9858 __attribute__((unused)) struct cmdline *cl,
9859 __attribute__((unused)) void *data)
9861 struct cmd_flow_director_mask_result *res = parsed_result;
9862 struct rte_eth_fdir_masks *mask;
9863 struct rte_port *port;
9865 if (res->port_id > nb_ports) {
9866 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9870 port = &ports[res->port_id];
9871 /** Check if the port is not started **/
9872 if (port->port_status != RTE_PORT_STOPPED) {
9873 printf("Please stop port %d first\n", res->port_id);
9877 mask = &port->dev_conf.fdir_conf.mask;
9879 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9880 if (strcmp(res->mode_value, "MAC-VLAN")) {
9881 printf("Please set mode to MAC-VLAN.\n");
9885 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9886 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9887 if (strcmp(res->mode_value, "Tunnel")) {
9888 printf("Please set mode to Tunnel.\n");
9892 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9893 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9894 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9895 mask->tunnel_type_mask = res->tunnel_type_mask;
9897 if (strcmp(res->mode_value, "IP")) {
9898 printf("Please set mode to IP.\n");
9902 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9903 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9904 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9905 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9906 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9907 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9908 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9911 cmd_reconfig_device_queue(res->port_id, 1, 1);
9914 cmdline_parse_token_string_t cmd_flow_director_mask =
9915 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9916 flow_director_mask, "flow_director_mask");
9917 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9918 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9920 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9921 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9923 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9924 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9926 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9927 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9928 src_mask, "src_mask");
9929 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9930 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9932 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9933 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9935 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9936 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9938 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9939 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9940 dst_mask, "dst_mask");
9941 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9942 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9944 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9945 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9947 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9948 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9951 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9952 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9954 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9955 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9957 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9958 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9959 mode_value, "MAC-VLAN");
9960 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9961 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9962 mode_value, "Tunnel");
9963 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9964 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9966 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9967 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9968 mac_addr_byte_mask, UINT8);
9969 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9970 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9971 tunnel_type, "tunnel-type");
9972 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9973 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9974 tunnel_type_mask, UINT8);
9975 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9976 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9977 tunnel_id, "tunnel-id");
9978 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9979 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9980 tunnel_id_mask, UINT32);
9982 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9983 .f = cmd_flow_director_mask_parsed,
9985 .help_str = "flow_director_mask ... : "
9986 "Set IP mode flow director's mask on NIC",
9988 (void *)&cmd_flow_director_mask,
9989 (void *)&cmd_flow_director_mask_port_id,
9990 (void *)&cmd_flow_director_mask_mode,
9991 (void *)&cmd_flow_director_mask_mode_ip,
9992 (void *)&cmd_flow_director_mask_vlan,
9993 (void *)&cmd_flow_director_mask_vlan_value,
9994 (void *)&cmd_flow_director_mask_src,
9995 (void *)&cmd_flow_director_mask_ipv4_src,
9996 (void *)&cmd_flow_director_mask_ipv6_src,
9997 (void *)&cmd_flow_director_mask_port_src,
9998 (void *)&cmd_flow_director_mask_dst,
9999 (void *)&cmd_flow_director_mask_ipv4_dst,
10000 (void *)&cmd_flow_director_mask_ipv6_dst,
10001 (void *)&cmd_flow_director_mask_port_dst,
10006 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10007 .f = cmd_flow_director_mask_parsed,
10009 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10010 "flow director's mask on NIC",
10012 (void *)&cmd_flow_director_mask,
10013 (void *)&cmd_flow_director_mask_port_id,
10014 (void *)&cmd_flow_director_mask_mode,
10015 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10016 (void *)&cmd_flow_director_mask_vlan,
10017 (void *)&cmd_flow_director_mask_vlan_value,
10022 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10023 .f = cmd_flow_director_mask_parsed,
10025 .help_str = "flow_director_mask ... : Set tunnel mode "
10026 "flow director's mask on NIC",
10028 (void *)&cmd_flow_director_mask,
10029 (void *)&cmd_flow_director_mask_port_id,
10030 (void *)&cmd_flow_director_mask_mode,
10031 (void *)&cmd_flow_director_mask_mode_tunnel,
10032 (void *)&cmd_flow_director_mask_vlan,
10033 (void *)&cmd_flow_director_mask_vlan_value,
10034 (void *)&cmd_flow_director_mask_mac,
10035 (void *)&cmd_flow_director_mask_mac_value,
10036 (void *)&cmd_flow_director_mask_tunnel_type,
10037 (void *)&cmd_flow_director_mask_tunnel_type_value,
10038 (void *)&cmd_flow_director_mask_tunnel_id,
10039 (void *)&cmd_flow_director_mask_tunnel_id_value,
10044 /* *** deal with flow director mask on flexible payload *** */
10045 struct cmd_flow_director_flex_mask_result {
10046 cmdline_fixed_string_t flow_director_flexmask;
10048 cmdline_fixed_string_t flow;
10049 cmdline_fixed_string_t flow_type;
10050 cmdline_fixed_string_t mask;
10054 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10055 __attribute__((unused)) struct cmdline *cl,
10056 __attribute__((unused)) void *data)
10058 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10059 struct rte_eth_fdir_info fdir_info;
10060 struct rte_eth_fdir_flex_mask flex_mask;
10061 struct rte_port *port;
10062 uint32_t flow_type_mask;
10066 if (res->port_id > nb_ports) {
10067 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10071 port = &ports[res->port_id];
10072 /** Check if the port is not started **/
10073 if (port->port_status != RTE_PORT_STOPPED) {
10074 printf("Please stop port %d first\n", res->port_id);
10078 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10079 ret = parse_flexbytes(res->mask,
10081 RTE_ETH_FDIR_MAX_FLEXLEN);
10083 printf("error: Cannot parse mask input.\n");
10087 memset(&fdir_info, 0, sizeof(fdir_info));
10088 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10089 RTE_ETH_FILTER_INFO, &fdir_info);
10091 printf("Cannot get FDir filter info\n");
10095 if (!strcmp(res->flow_type, "none")) {
10096 /* means don't specify the flow type */
10097 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10098 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10099 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10100 0, sizeof(struct rte_eth_fdir_flex_mask));
10101 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10102 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10104 sizeof(struct rte_eth_fdir_flex_mask));
10105 cmd_reconfig_device_queue(res->port_id, 1, 1);
10108 flow_type_mask = fdir_info.flow_types_mask[0];
10109 if (!strcmp(res->flow_type, "all")) {
10110 if (!flow_type_mask) {
10111 printf("No flow type supported\n");
10114 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10115 if (flow_type_mask & (1 << i)) {
10116 flex_mask.flow_type = i;
10117 fdir_set_flex_mask(res->port_id, &flex_mask);
10120 cmd_reconfig_device_queue(res->port_id, 1, 1);
10123 flex_mask.flow_type = str2flowtype(res->flow_type);
10124 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10125 printf("Flow type %s not supported on port %d\n",
10126 res->flow_type, res->port_id);
10129 fdir_set_flex_mask(res->port_id, &flex_mask);
10130 cmd_reconfig_device_queue(res->port_id, 1, 1);
10133 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10134 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10135 flow_director_flexmask,
10136 "flow_director_flex_mask");
10137 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10138 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10140 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10141 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10143 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10144 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10145 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10146 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10147 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10148 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10151 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10152 .f = cmd_flow_director_flex_mask_parsed,
10154 .help_str = "flow_director_flex_mask ... : "
10155 "Set flow director's flex mask on NIC",
10157 (void *)&cmd_flow_director_flexmask,
10158 (void *)&cmd_flow_director_flexmask_port_id,
10159 (void *)&cmd_flow_director_flexmask_flow,
10160 (void *)&cmd_flow_director_flexmask_flow_type,
10161 (void *)&cmd_flow_director_flexmask_mask,
10166 /* *** deal with flow director flexible payload configuration *** */
10167 struct cmd_flow_director_flexpayload_result {
10168 cmdline_fixed_string_t flow_director_flexpayload;
10170 cmdline_fixed_string_t payload_layer;
10171 cmdline_fixed_string_t payload_cfg;
10175 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10178 const char *p, *p0 = q_arg;
10180 unsigned long int_fld;
10181 char *str_fld[max_num];
10186 p = strchr(p0, '(');
10190 p0 = strchr(p, ')');
10195 if (size >= sizeof(s))
10198 snprintf(s, sizeof(s), "%.*s", size, p);
10199 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10200 if (ret < 0 || ret > max_num)
10202 for (i = 0; i < ret; i++) {
10204 int_fld = strtoul(str_fld[i], &end, 0);
10205 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10207 offsets[i] = (uint16_t)int_fld;
10213 cmd_flow_director_flxpld_parsed(void *parsed_result,
10214 __attribute__((unused)) struct cmdline *cl,
10215 __attribute__((unused)) void *data)
10217 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10218 struct rte_eth_flex_payload_cfg flex_cfg;
10219 struct rte_port *port;
10222 if (res->port_id > nb_ports) {
10223 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10227 port = &ports[res->port_id];
10228 /** Check if the port is not started **/
10229 if (port->port_status != RTE_PORT_STOPPED) {
10230 printf("Please stop port %d first\n", res->port_id);
10234 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10236 if (!strcmp(res->payload_layer, "raw"))
10237 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10238 else if (!strcmp(res->payload_layer, "l2"))
10239 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10240 else if (!strcmp(res->payload_layer, "l3"))
10241 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10242 else if (!strcmp(res->payload_layer, "l4"))
10243 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10245 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10246 RTE_ETH_FDIR_MAX_FLEXLEN);
10248 printf("error: Cannot parse flex payload input.\n");
10252 fdir_set_flex_payload(res->port_id, &flex_cfg);
10253 cmd_reconfig_device_queue(res->port_id, 1, 1);
10256 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10257 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10258 flow_director_flexpayload,
10259 "flow_director_flex_payload");
10260 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10261 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10263 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10264 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10265 payload_layer, "raw#l2#l3#l4");
10266 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10267 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10268 payload_cfg, NULL);
10270 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10271 .f = cmd_flow_director_flxpld_parsed,
10273 .help_str = "flow_director_flexpayload ... : "
10274 "Set flow director's flex payload on NIC",
10276 (void *)&cmd_flow_director_flexpayload,
10277 (void *)&cmd_flow_director_flexpayload_port_id,
10278 (void *)&cmd_flow_director_flexpayload_payload_layer,
10279 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10284 /* Generic flow interface command. */
10285 extern cmdline_parse_inst_t cmd_flow;
10287 /* *** Classification Filters Control *** */
10288 /* *** Get symmetric hash enable per port *** */
10289 struct cmd_get_sym_hash_ena_per_port_result {
10290 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10295 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10296 __rte_unused struct cmdline *cl,
10297 __rte_unused void *data)
10299 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10300 struct rte_eth_hash_filter_info info;
10303 if (rte_eth_dev_filter_supported(res->port_id,
10304 RTE_ETH_FILTER_HASH) < 0) {
10305 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10310 memset(&info, 0, sizeof(info));
10311 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10312 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10313 RTE_ETH_FILTER_GET, &info);
10316 printf("Cannot get symmetric hash enable per port "
10317 "on port %u\n", res->port_id);
10321 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10322 "enabled" : "disabled", res->port_id);
10325 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10326 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10327 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10328 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10329 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10332 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10333 .f = cmd_get_sym_hash_per_port_parsed,
10335 .help_str = "get_sym_hash_ena_per_port <port_id>",
10337 (void *)&cmd_get_sym_hash_ena_per_port_all,
10338 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10343 /* *** Set symmetric hash enable per port *** */
10344 struct cmd_set_sym_hash_ena_per_port_result {
10345 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10346 cmdline_fixed_string_t enable;
10351 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10352 __rte_unused struct cmdline *cl,
10353 __rte_unused void *data)
10355 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10356 struct rte_eth_hash_filter_info info;
10359 if (rte_eth_dev_filter_supported(res->port_id,
10360 RTE_ETH_FILTER_HASH) < 0) {
10361 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10366 memset(&info, 0, sizeof(info));
10367 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10368 if (!strcmp(res->enable, "enable"))
10369 info.info.enable = 1;
10370 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10371 RTE_ETH_FILTER_SET, &info);
10373 printf("Cannot set symmetric hash enable per port on "
10374 "port %u\n", res->port_id);
10377 printf("Symmetric hash has been set to %s on port %u\n",
10378 res->enable, res->port_id);
10381 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
10382 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10383 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
10384 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
10385 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10387 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
10388 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10389 enable, "enable#disable");
10391 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
10392 .f = cmd_set_sym_hash_per_port_parsed,
10394 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
10396 (void *)&cmd_set_sym_hash_ena_per_port_all,
10397 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
10398 (void *)&cmd_set_sym_hash_ena_per_port_enable,
10403 /* Get global config of hash function */
10404 struct cmd_get_hash_global_config_result {
10405 cmdline_fixed_string_t get_hash_global_config;
10410 flowtype_to_str(uint16_t ftype)
10416 } ftype_table[] = {
10417 {"ipv4", RTE_ETH_FLOW_IPV4},
10418 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10419 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10420 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10421 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10422 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10423 {"ipv6", RTE_ETH_FLOW_IPV6},
10424 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10425 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10426 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10427 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10428 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10429 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10430 {"port", RTE_ETH_FLOW_PORT},
10431 {"vxlan", RTE_ETH_FLOW_VXLAN},
10432 {"geneve", RTE_ETH_FLOW_GENEVE},
10433 {"nvgre", RTE_ETH_FLOW_NVGRE},
10436 for (i = 0; i < RTE_DIM(ftype_table); i++) {
10437 if (ftype_table[i].ftype == ftype)
10438 return ftype_table[i].str;
10445 cmd_get_hash_global_config_parsed(void *parsed_result,
10446 __rte_unused struct cmdline *cl,
10447 __rte_unused void *data)
10449 struct cmd_get_hash_global_config_result *res = parsed_result;
10450 struct rte_eth_hash_filter_info info;
10451 uint32_t idx, offset;
10456 if (rte_eth_dev_filter_supported(res->port_id,
10457 RTE_ETH_FILTER_HASH) < 0) {
10458 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10463 memset(&info, 0, sizeof(info));
10464 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10465 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10466 RTE_ETH_FILTER_GET, &info);
10468 printf("Cannot get hash global configurations by port %d\n",
10473 switch (info.info.global_conf.hash_func) {
10474 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
10475 printf("Hash function is Toeplitz\n");
10477 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
10478 printf("Hash function is Simple XOR\n");
10481 printf("Unknown hash function\n");
10485 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
10486 idx = i / UINT32_BIT;
10487 offset = i % UINT32_BIT;
10488 if (!(info.info.global_conf.valid_bit_mask[idx] &
10491 str = flowtype_to_str(i);
10494 printf("Symmetric hash is %s globally for flow type %s "
10496 ((info.info.global_conf.sym_hash_enable_mask[idx] &
10497 (1UL << offset)) ? "enabled" : "disabled"), str,
10502 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
10503 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
10504 get_hash_global_config, "get_hash_global_config");
10505 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
10506 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
10509 cmdline_parse_inst_t cmd_get_hash_global_config = {
10510 .f = cmd_get_hash_global_config_parsed,
10512 .help_str = "get_hash_global_config <port_id>",
10514 (void *)&cmd_get_hash_global_config_all,
10515 (void *)&cmd_get_hash_global_config_port_id,
10520 /* Set global config of hash function */
10521 struct cmd_set_hash_global_config_result {
10522 cmdline_fixed_string_t set_hash_global_config;
10524 cmdline_fixed_string_t hash_func;
10525 cmdline_fixed_string_t flow_type;
10526 cmdline_fixed_string_t enable;
10530 cmd_set_hash_global_config_parsed(void *parsed_result,
10531 __rte_unused struct cmdline *cl,
10532 __rte_unused void *data)
10534 struct cmd_set_hash_global_config_result *res = parsed_result;
10535 struct rte_eth_hash_filter_info info;
10536 uint32_t ftype, idx, offset;
10539 if (rte_eth_dev_filter_supported(res->port_id,
10540 RTE_ETH_FILTER_HASH) < 0) {
10541 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10545 memset(&info, 0, sizeof(info));
10546 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10547 if (!strcmp(res->hash_func, "toeplitz"))
10548 info.info.global_conf.hash_func =
10549 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
10550 else if (!strcmp(res->hash_func, "simple_xor"))
10551 info.info.global_conf.hash_func =
10552 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
10553 else if (!strcmp(res->hash_func, "default"))
10554 info.info.global_conf.hash_func =
10555 RTE_ETH_HASH_FUNCTION_DEFAULT;
10557 ftype = str2flowtype(res->flow_type);
10558 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10559 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10560 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10561 if (!strcmp(res->enable, "enable"))
10562 info.info.global_conf.sym_hash_enable_mask[idx] |=
10564 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10565 RTE_ETH_FILTER_SET, &info);
10567 printf("Cannot set global hash configurations by port %d\n",
10570 printf("Global hash configurations have been set "
10571 "succcessfully by port %d\n", res->port_id);
10574 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10575 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10576 set_hash_global_config, "set_hash_global_config");
10577 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10578 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10580 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10581 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10582 hash_func, "toeplitz#simple_xor#default");
10583 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10584 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10586 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10587 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10588 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10589 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10590 enable, "enable#disable");
10592 cmdline_parse_inst_t cmd_set_hash_global_config = {
10593 .f = cmd_set_hash_global_config_parsed,
10595 .help_str = "set_hash_global_config <port_id> "
10596 "toeplitz|simple_xor|default "
10597 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10598 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10599 "l2_payload enable|disable",
10601 (void *)&cmd_set_hash_global_config_all,
10602 (void *)&cmd_set_hash_global_config_port_id,
10603 (void *)&cmd_set_hash_global_config_hash_func,
10604 (void *)&cmd_set_hash_global_config_flow_type,
10605 (void *)&cmd_set_hash_global_config_enable,
10610 /* Set hash input set */
10611 struct cmd_set_hash_input_set_result {
10612 cmdline_fixed_string_t set_hash_input_set;
10614 cmdline_fixed_string_t flow_type;
10615 cmdline_fixed_string_t inset_field;
10616 cmdline_fixed_string_t select;
10619 static enum rte_eth_input_set_field
10620 str2inset(char *string)
10624 static const struct {
10626 enum rte_eth_input_set_field inset;
10627 } inset_table[] = {
10628 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10629 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10630 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10631 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10632 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10633 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10634 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10635 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10636 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10637 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10638 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10639 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10640 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10641 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10642 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10643 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10644 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10645 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10646 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10647 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10648 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10649 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10650 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10651 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10652 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10653 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10654 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10655 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10656 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10657 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10658 {"none", RTE_ETH_INPUT_SET_NONE},
10661 for (i = 0; i < RTE_DIM(inset_table); i++) {
10662 if (!strcmp(string, inset_table[i].str))
10663 return inset_table[i].inset;
10666 return RTE_ETH_INPUT_SET_UNKNOWN;
10670 cmd_set_hash_input_set_parsed(void *parsed_result,
10671 __rte_unused struct cmdline *cl,
10672 __rte_unused void *data)
10674 struct cmd_set_hash_input_set_result *res = parsed_result;
10675 struct rte_eth_hash_filter_info info;
10677 memset(&info, 0, sizeof(info));
10678 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10679 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10680 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10681 info.info.input_set_conf.inset_size = 1;
10682 if (!strcmp(res->select, "select"))
10683 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10684 else if (!strcmp(res->select, "add"))
10685 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10686 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10687 RTE_ETH_FILTER_SET, &info);
10690 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10691 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10692 set_hash_input_set, "set_hash_input_set");
10693 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10694 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10696 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10697 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10699 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10700 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10702 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10703 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10704 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10705 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10706 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10708 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10709 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10710 select, "select#add");
10712 cmdline_parse_inst_t cmd_set_hash_input_set = {
10713 .f = cmd_set_hash_input_set_parsed,
10715 .help_str = "set_hash_input_set <port_id> "
10716 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10717 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
10718 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10719 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10720 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10721 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10722 "fld-7th|fld-8th|none select|add",
10724 (void *)&cmd_set_hash_input_set_cmd,
10725 (void *)&cmd_set_hash_input_set_port_id,
10726 (void *)&cmd_set_hash_input_set_flow_type,
10727 (void *)&cmd_set_hash_input_set_field,
10728 (void *)&cmd_set_hash_input_set_select,
10733 /* Set flow director input set */
10734 struct cmd_set_fdir_input_set_result {
10735 cmdline_fixed_string_t set_fdir_input_set;
10737 cmdline_fixed_string_t flow_type;
10738 cmdline_fixed_string_t inset_field;
10739 cmdline_fixed_string_t select;
10743 cmd_set_fdir_input_set_parsed(void *parsed_result,
10744 __rte_unused struct cmdline *cl,
10745 __rte_unused void *data)
10747 struct cmd_set_fdir_input_set_result *res = parsed_result;
10748 struct rte_eth_fdir_filter_info info;
10750 memset(&info, 0, sizeof(info));
10751 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10752 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10753 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10754 info.info.input_set_conf.inset_size = 1;
10755 if (!strcmp(res->select, "select"))
10756 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10757 else if (!strcmp(res->select, "add"))
10758 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10759 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10760 RTE_ETH_FILTER_SET, &info);
10763 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10764 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10765 set_fdir_input_set, "set_fdir_input_set");
10766 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10767 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10769 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10770 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10772 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10773 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10774 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10775 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10777 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10778 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10779 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10780 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10781 "sctp-veri-tag#none");
10782 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10783 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10784 select, "select#add");
10786 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10787 .f = cmd_set_fdir_input_set_parsed,
10789 .help_str = "set_fdir_input_set <port_id> "
10790 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10791 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10792 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10793 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10794 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10795 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10796 "sctp-veri-tag|none select|add",
10798 (void *)&cmd_set_fdir_input_set_cmd,
10799 (void *)&cmd_set_fdir_input_set_port_id,
10800 (void *)&cmd_set_fdir_input_set_flow_type,
10801 (void *)&cmd_set_fdir_input_set_field,
10802 (void *)&cmd_set_fdir_input_set_select,
10807 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10808 struct cmd_mcast_addr_result {
10809 cmdline_fixed_string_t mcast_addr_cmd;
10810 cmdline_fixed_string_t what;
10812 struct ether_addr mc_addr;
10815 static void cmd_mcast_addr_parsed(void *parsed_result,
10816 __attribute__((unused)) struct cmdline *cl,
10817 __attribute__((unused)) void *data)
10819 struct cmd_mcast_addr_result *res = parsed_result;
10821 if (!is_multicast_ether_addr(&res->mc_addr)) {
10822 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10823 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10824 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10825 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10828 if (strcmp(res->what, "add") == 0)
10829 mcast_addr_add(res->port_num, &res->mc_addr);
10831 mcast_addr_remove(res->port_num, &res->mc_addr);
10834 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10835 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10836 mcast_addr_cmd, "mcast_addr");
10837 cmdline_parse_token_string_t cmd_mcast_addr_what =
10838 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10840 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10841 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10842 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10843 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10845 cmdline_parse_inst_t cmd_mcast_addr = {
10846 .f = cmd_mcast_addr_parsed,
10848 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10849 "Add/Remove multicast MAC address on port_id",
10851 (void *)&cmd_mcast_addr_cmd,
10852 (void *)&cmd_mcast_addr_what,
10853 (void *)&cmd_mcast_addr_portnum,
10854 (void *)&cmd_mcast_addr_addr,
10859 /* l2 tunnel config
10860 * only support E-tag now.
10863 /* Ether type config */
10864 struct cmd_config_l2_tunnel_eth_type_result {
10865 cmdline_fixed_string_t port;
10866 cmdline_fixed_string_t config;
10867 cmdline_fixed_string_t all;
10869 cmdline_fixed_string_t l2_tunnel;
10870 cmdline_fixed_string_t l2_tunnel_type;
10871 cmdline_fixed_string_t eth_type;
10872 uint16_t eth_type_val;
10875 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10876 TOKEN_STRING_INITIALIZER
10877 (struct cmd_config_l2_tunnel_eth_type_result,
10879 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10880 TOKEN_STRING_INITIALIZER
10881 (struct cmd_config_l2_tunnel_eth_type_result,
10883 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10884 TOKEN_STRING_INITIALIZER
10885 (struct cmd_config_l2_tunnel_eth_type_result,
10887 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10888 TOKEN_NUM_INITIALIZER
10889 (struct cmd_config_l2_tunnel_eth_type_result,
10891 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10892 TOKEN_STRING_INITIALIZER
10893 (struct cmd_config_l2_tunnel_eth_type_result,
10894 l2_tunnel, "l2-tunnel");
10895 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10896 TOKEN_STRING_INITIALIZER
10897 (struct cmd_config_l2_tunnel_eth_type_result,
10898 l2_tunnel_type, "E-tag");
10899 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10900 TOKEN_STRING_INITIALIZER
10901 (struct cmd_config_l2_tunnel_eth_type_result,
10902 eth_type, "ether-type");
10903 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10904 TOKEN_NUM_INITIALIZER
10905 (struct cmd_config_l2_tunnel_eth_type_result,
10906 eth_type_val, UINT16);
10908 static enum rte_eth_tunnel_type
10909 str2fdir_l2_tunnel_type(char *string)
10913 static const struct {
10915 enum rte_eth_tunnel_type type;
10916 } l2_tunnel_type_str[] = {
10917 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10920 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10921 if (!strcmp(l2_tunnel_type_str[i].str, string))
10922 return l2_tunnel_type_str[i].type;
10924 return RTE_TUNNEL_TYPE_NONE;
10927 /* ether type config for all ports */
10929 cmd_config_l2_tunnel_eth_type_all_parsed
10930 (void *parsed_result,
10931 __attribute__((unused)) struct cmdline *cl,
10932 __attribute__((unused)) void *data)
10934 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10935 struct rte_eth_l2_tunnel_conf entry;
10938 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10939 entry.ether_type = res->eth_type_val;
10941 RTE_ETH_FOREACH_DEV(pid) {
10942 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10946 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10947 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10949 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10951 (void *)&cmd_config_l2_tunnel_eth_type_port,
10952 (void *)&cmd_config_l2_tunnel_eth_type_config,
10953 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10954 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10955 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10956 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10957 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10962 /* ether type config for a specific port */
10964 cmd_config_l2_tunnel_eth_type_specific_parsed(
10965 void *parsed_result,
10966 __attribute__((unused)) struct cmdline *cl,
10967 __attribute__((unused)) void *data)
10969 struct cmd_config_l2_tunnel_eth_type_result *res =
10971 struct rte_eth_l2_tunnel_conf entry;
10973 if (port_id_is_invalid(res->id, ENABLED_WARN))
10976 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10977 entry.ether_type = res->eth_type_val;
10979 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10982 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10983 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10985 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10987 (void *)&cmd_config_l2_tunnel_eth_type_port,
10988 (void *)&cmd_config_l2_tunnel_eth_type_config,
10989 (void *)&cmd_config_l2_tunnel_eth_type_id,
10990 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10991 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10992 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10993 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10998 /* Enable/disable l2 tunnel */
10999 struct cmd_config_l2_tunnel_en_dis_result {
11000 cmdline_fixed_string_t port;
11001 cmdline_fixed_string_t config;
11002 cmdline_fixed_string_t all;
11004 cmdline_fixed_string_t l2_tunnel;
11005 cmdline_fixed_string_t l2_tunnel_type;
11006 cmdline_fixed_string_t en_dis;
11009 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11010 TOKEN_STRING_INITIALIZER
11011 (struct cmd_config_l2_tunnel_en_dis_result,
11013 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11014 TOKEN_STRING_INITIALIZER
11015 (struct cmd_config_l2_tunnel_en_dis_result,
11017 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11018 TOKEN_STRING_INITIALIZER
11019 (struct cmd_config_l2_tunnel_en_dis_result,
11021 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11022 TOKEN_NUM_INITIALIZER
11023 (struct cmd_config_l2_tunnel_en_dis_result,
11025 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11026 TOKEN_STRING_INITIALIZER
11027 (struct cmd_config_l2_tunnel_en_dis_result,
11028 l2_tunnel, "l2-tunnel");
11029 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11030 TOKEN_STRING_INITIALIZER
11031 (struct cmd_config_l2_tunnel_en_dis_result,
11032 l2_tunnel_type, "E-tag");
11033 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11034 TOKEN_STRING_INITIALIZER
11035 (struct cmd_config_l2_tunnel_en_dis_result,
11036 en_dis, "enable#disable");
11038 /* enable/disable l2 tunnel for all ports */
11040 cmd_config_l2_tunnel_en_dis_all_parsed(
11041 void *parsed_result,
11042 __attribute__((unused)) struct cmdline *cl,
11043 __attribute__((unused)) void *data)
11045 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11046 struct rte_eth_l2_tunnel_conf entry;
11050 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11052 if (!strcmp("enable", res->en_dis))
11057 RTE_ETH_FOREACH_DEV(pid) {
11058 rte_eth_dev_l2_tunnel_offload_set(pid,
11060 ETH_L2_TUNNEL_ENABLE_MASK,
11065 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11066 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11068 .help_str = "port config all l2-tunnel E-tag enable|disable",
11070 (void *)&cmd_config_l2_tunnel_en_dis_port,
11071 (void *)&cmd_config_l2_tunnel_en_dis_config,
11072 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11073 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11074 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11075 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11080 /* enable/disable l2 tunnel for a port */
11082 cmd_config_l2_tunnel_en_dis_specific_parsed(
11083 void *parsed_result,
11084 __attribute__((unused)) struct cmdline *cl,
11085 __attribute__((unused)) void *data)
11087 struct cmd_config_l2_tunnel_en_dis_result *res =
11089 struct rte_eth_l2_tunnel_conf entry;
11091 if (port_id_is_invalid(res->id, ENABLED_WARN))
11094 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11096 if (!strcmp("enable", res->en_dis))
11097 rte_eth_dev_l2_tunnel_offload_set(res->id,
11099 ETH_L2_TUNNEL_ENABLE_MASK,
11102 rte_eth_dev_l2_tunnel_offload_set(res->id,
11104 ETH_L2_TUNNEL_ENABLE_MASK,
11108 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11109 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11111 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11113 (void *)&cmd_config_l2_tunnel_en_dis_port,
11114 (void *)&cmd_config_l2_tunnel_en_dis_config,
11115 (void *)&cmd_config_l2_tunnel_en_dis_id,
11116 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11117 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11118 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11123 /* E-tag configuration */
11125 /* Common result structure for all E-tag configuration */
11126 struct cmd_config_e_tag_result {
11127 cmdline_fixed_string_t e_tag;
11128 cmdline_fixed_string_t set;
11129 cmdline_fixed_string_t insertion;
11130 cmdline_fixed_string_t stripping;
11131 cmdline_fixed_string_t forwarding;
11132 cmdline_fixed_string_t filter;
11133 cmdline_fixed_string_t add;
11134 cmdline_fixed_string_t del;
11135 cmdline_fixed_string_t on;
11136 cmdline_fixed_string_t off;
11137 cmdline_fixed_string_t on_off;
11138 cmdline_fixed_string_t port_tag_id;
11139 uint32_t port_tag_id_val;
11140 cmdline_fixed_string_t e_tag_id;
11141 uint16_t e_tag_id_val;
11142 cmdline_fixed_string_t dst_pool;
11143 uint8_t dst_pool_val;
11144 cmdline_fixed_string_t port;
11146 cmdline_fixed_string_t vf;
11150 /* Common CLI fields for all E-tag configuration */
11151 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11152 TOKEN_STRING_INITIALIZER
11153 (struct cmd_config_e_tag_result,
11155 cmdline_parse_token_string_t cmd_config_e_tag_set =
11156 TOKEN_STRING_INITIALIZER
11157 (struct cmd_config_e_tag_result,
11159 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11160 TOKEN_STRING_INITIALIZER
11161 (struct cmd_config_e_tag_result,
11162 insertion, "insertion");
11163 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11164 TOKEN_STRING_INITIALIZER
11165 (struct cmd_config_e_tag_result,
11166 stripping, "stripping");
11167 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11168 TOKEN_STRING_INITIALIZER
11169 (struct cmd_config_e_tag_result,
11170 forwarding, "forwarding");
11171 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11172 TOKEN_STRING_INITIALIZER
11173 (struct cmd_config_e_tag_result,
11175 cmdline_parse_token_string_t cmd_config_e_tag_add =
11176 TOKEN_STRING_INITIALIZER
11177 (struct cmd_config_e_tag_result,
11179 cmdline_parse_token_string_t cmd_config_e_tag_del =
11180 TOKEN_STRING_INITIALIZER
11181 (struct cmd_config_e_tag_result,
11183 cmdline_parse_token_string_t cmd_config_e_tag_on =
11184 TOKEN_STRING_INITIALIZER
11185 (struct cmd_config_e_tag_result,
11187 cmdline_parse_token_string_t cmd_config_e_tag_off =
11188 TOKEN_STRING_INITIALIZER
11189 (struct cmd_config_e_tag_result,
11191 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11192 TOKEN_STRING_INITIALIZER
11193 (struct cmd_config_e_tag_result,
11195 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11196 TOKEN_STRING_INITIALIZER
11197 (struct cmd_config_e_tag_result,
11198 port_tag_id, "port-tag-id");
11199 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11200 TOKEN_NUM_INITIALIZER
11201 (struct cmd_config_e_tag_result,
11202 port_tag_id_val, UINT32);
11203 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11204 TOKEN_STRING_INITIALIZER
11205 (struct cmd_config_e_tag_result,
11206 e_tag_id, "e-tag-id");
11207 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11208 TOKEN_NUM_INITIALIZER
11209 (struct cmd_config_e_tag_result,
11210 e_tag_id_val, UINT16);
11211 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11212 TOKEN_STRING_INITIALIZER
11213 (struct cmd_config_e_tag_result,
11214 dst_pool, "dst-pool");
11215 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11216 TOKEN_NUM_INITIALIZER
11217 (struct cmd_config_e_tag_result,
11218 dst_pool_val, UINT8);
11219 cmdline_parse_token_string_t cmd_config_e_tag_port =
11220 TOKEN_STRING_INITIALIZER
11221 (struct cmd_config_e_tag_result,
11223 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11224 TOKEN_NUM_INITIALIZER
11225 (struct cmd_config_e_tag_result,
11227 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11228 TOKEN_STRING_INITIALIZER
11229 (struct cmd_config_e_tag_result,
11231 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11232 TOKEN_NUM_INITIALIZER
11233 (struct cmd_config_e_tag_result,
11236 /* E-tag insertion configuration */
11238 cmd_config_e_tag_insertion_en_parsed(
11239 void *parsed_result,
11240 __attribute__((unused)) struct cmdline *cl,
11241 __attribute__((unused)) void *data)
11243 struct cmd_config_e_tag_result *res =
11245 struct rte_eth_l2_tunnel_conf entry;
11247 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11250 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11251 entry.tunnel_id = res->port_tag_id_val;
11252 entry.vf_id = res->vf_id;
11253 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11255 ETH_L2_TUNNEL_INSERTION_MASK,
11260 cmd_config_e_tag_insertion_dis_parsed(
11261 void *parsed_result,
11262 __attribute__((unused)) struct cmdline *cl,
11263 __attribute__((unused)) void *data)
11265 struct cmd_config_e_tag_result *res =
11267 struct rte_eth_l2_tunnel_conf entry;
11269 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11272 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11273 entry.vf_id = res->vf_id;
11275 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11277 ETH_L2_TUNNEL_INSERTION_MASK,
11281 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11282 .f = cmd_config_e_tag_insertion_en_parsed,
11284 .help_str = "E-tag ... : E-tag insertion enable",
11286 (void *)&cmd_config_e_tag_e_tag,
11287 (void *)&cmd_config_e_tag_set,
11288 (void *)&cmd_config_e_tag_insertion,
11289 (void *)&cmd_config_e_tag_on,
11290 (void *)&cmd_config_e_tag_port_tag_id,
11291 (void *)&cmd_config_e_tag_port_tag_id_val,
11292 (void *)&cmd_config_e_tag_port,
11293 (void *)&cmd_config_e_tag_port_id,
11294 (void *)&cmd_config_e_tag_vf,
11295 (void *)&cmd_config_e_tag_vf_id,
11300 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11301 .f = cmd_config_e_tag_insertion_dis_parsed,
11303 .help_str = "E-tag ... : E-tag insertion disable",
11305 (void *)&cmd_config_e_tag_e_tag,
11306 (void *)&cmd_config_e_tag_set,
11307 (void *)&cmd_config_e_tag_insertion,
11308 (void *)&cmd_config_e_tag_off,
11309 (void *)&cmd_config_e_tag_port,
11310 (void *)&cmd_config_e_tag_port_id,
11311 (void *)&cmd_config_e_tag_vf,
11312 (void *)&cmd_config_e_tag_vf_id,
11317 /* E-tag stripping configuration */
11319 cmd_config_e_tag_stripping_parsed(
11320 void *parsed_result,
11321 __attribute__((unused)) struct cmdline *cl,
11322 __attribute__((unused)) void *data)
11324 struct cmd_config_e_tag_result *res =
11326 struct rte_eth_l2_tunnel_conf entry;
11328 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11331 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11333 if (!strcmp(res->on_off, "on"))
11334 rte_eth_dev_l2_tunnel_offload_set
11337 ETH_L2_TUNNEL_STRIPPING_MASK,
11340 rte_eth_dev_l2_tunnel_offload_set
11343 ETH_L2_TUNNEL_STRIPPING_MASK,
11347 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11348 .f = cmd_config_e_tag_stripping_parsed,
11350 .help_str = "E-tag ... : E-tag stripping enable/disable",
11352 (void *)&cmd_config_e_tag_e_tag,
11353 (void *)&cmd_config_e_tag_set,
11354 (void *)&cmd_config_e_tag_stripping,
11355 (void *)&cmd_config_e_tag_on_off,
11356 (void *)&cmd_config_e_tag_port,
11357 (void *)&cmd_config_e_tag_port_id,
11362 /* E-tag forwarding configuration */
11364 cmd_config_e_tag_forwarding_parsed(
11365 void *parsed_result,
11366 __attribute__((unused)) struct cmdline *cl,
11367 __attribute__((unused)) void *data)
11369 struct cmd_config_e_tag_result *res = parsed_result;
11370 struct rte_eth_l2_tunnel_conf entry;
11372 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11375 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11377 if (!strcmp(res->on_off, "on"))
11378 rte_eth_dev_l2_tunnel_offload_set
11381 ETH_L2_TUNNEL_FORWARDING_MASK,
11384 rte_eth_dev_l2_tunnel_offload_set
11387 ETH_L2_TUNNEL_FORWARDING_MASK,
11391 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11392 .f = cmd_config_e_tag_forwarding_parsed,
11394 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11396 (void *)&cmd_config_e_tag_e_tag,
11397 (void *)&cmd_config_e_tag_set,
11398 (void *)&cmd_config_e_tag_forwarding,
11399 (void *)&cmd_config_e_tag_on_off,
11400 (void *)&cmd_config_e_tag_port,
11401 (void *)&cmd_config_e_tag_port_id,
11406 /* E-tag filter configuration */
11408 cmd_config_e_tag_filter_add_parsed(
11409 void *parsed_result,
11410 __attribute__((unused)) struct cmdline *cl,
11411 __attribute__((unused)) void *data)
11413 struct cmd_config_e_tag_result *res = parsed_result;
11414 struct rte_eth_l2_tunnel_conf entry;
11417 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11420 if (res->e_tag_id_val > 0x3fff) {
11421 printf("e-tag-id must be equal or less than 0x3fff.\n");
11425 ret = rte_eth_dev_filter_supported(res->port_id,
11426 RTE_ETH_FILTER_L2_TUNNEL);
11428 printf("E-tag filter is not supported on port %u.\n",
11433 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11434 entry.tunnel_id = res->e_tag_id_val;
11435 entry.pool = res->dst_pool_val;
11437 ret = rte_eth_dev_filter_ctrl(res->port_id,
11438 RTE_ETH_FILTER_L2_TUNNEL,
11439 RTE_ETH_FILTER_ADD,
11442 printf("E-tag filter programming error: (%s)\n",
11446 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
11447 .f = cmd_config_e_tag_filter_add_parsed,
11449 .help_str = "E-tag ... : E-tag filter add",
11451 (void *)&cmd_config_e_tag_e_tag,
11452 (void *)&cmd_config_e_tag_set,
11453 (void *)&cmd_config_e_tag_filter,
11454 (void *)&cmd_config_e_tag_add,
11455 (void *)&cmd_config_e_tag_e_tag_id,
11456 (void *)&cmd_config_e_tag_e_tag_id_val,
11457 (void *)&cmd_config_e_tag_dst_pool,
11458 (void *)&cmd_config_e_tag_dst_pool_val,
11459 (void *)&cmd_config_e_tag_port,
11460 (void *)&cmd_config_e_tag_port_id,
11466 cmd_config_e_tag_filter_del_parsed(
11467 void *parsed_result,
11468 __attribute__((unused)) struct cmdline *cl,
11469 __attribute__((unused)) void *data)
11471 struct cmd_config_e_tag_result *res = parsed_result;
11472 struct rte_eth_l2_tunnel_conf entry;
11475 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11478 if (res->e_tag_id_val > 0x3fff) {
11479 printf("e-tag-id must be less than 0x3fff.\n");
11483 ret = rte_eth_dev_filter_supported(res->port_id,
11484 RTE_ETH_FILTER_L2_TUNNEL);
11486 printf("E-tag filter is not supported on port %u.\n",
11491 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11492 entry.tunnel_id = res->e_tag_id_val;
11494 ret = rte_eth_dev_filter_ctrl(res->port_id,
11495 RTE_ETH_FILTER_L2_TUNNEL,
11496 RTE_ETH_FILTER_DELETE,
11499 printf("E-tag filter programming error: (%s)\n",
11503 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
11504 .f = cmd_config_e_tag_filter_del_parsed,
11506 .help_str = "E-tag ... : E-tag filter delete",
11508 (void *)&cmd_config_e_tag_e_tag,
11509 (void *)&cmd_config_e_tag_set,
11510 (void *)&cmd_config_e_tag_filter,
11511 (void *)&cmd_config_e_tag_del,
11512 (void *)&cmd_config_e_tag_e_tag_id,
11513 (void *)&cmd_config_e_tag_e_tag_id_val,
11514 (void *)&cmd_config_e_tag_port,
11515 (void *)&cmd_config_e_tag_port_id,
11520 /* vf vlan anti spoof configuration */
11522 /* Common result structure for vf vlan anti spoof */
11523 struct cmd_vf_vlan_anti_spoof_result {
11524 cmdline_fixed_string_t set;
11525 cmdline_fixed_string_t vf;
11526 cmdline_fixed_string_t vlan;
11527 cmdline_fixed_string_t antispoof;
11530 cmdline_fixed_string_t on_off;
11533 /* Common CLI fields for vf vlan anti spoof enable disable */
11534 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11535 TOKEN_STRING_INITIALIZER
11536 (struct cmd_vf_vlan_anti_spoof_result,
11538 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11539 TOKEN_STRING_INITIALIZER
11540 (struct cmd_vf_vlan_anti_spoof_result,
11542 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11543 TOKEN_STRING_INITIALIZER
11544 (struct cmd_vf_vlan_anti_spoof_result,
11546 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11547 TOKEN_STRING_INITIALIZER
11548 (struct cmd_vf_vlan_anti_spoof_result,
11549 antispoof, "antispoof");
11550 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11551 TOKEN_NUM_INITIALIZER
11552 (struct cmd_vf_vlan_anti_spoof_result,
11554 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11555 TOKEN_NUM_INITIALIZER
11556 (struct cmd_vf_vlan_anti_spoof_result,
11558 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11559 TOKEN_STRING_INITIALIZER
11560 (struct cmd_vf_vlan_anti_spoof_result,
11564 cmd_set_vf_vlan_anti_spoof_parsed(
11565 void *parsed_result,
11566 __attribute__((unused)) struct cmdline *cl,
11567 __attribute__((unused)) void *data)
11569 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11570 int ret = -ENOTSUP;
11572 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11574 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11577 #ifdef RTE_LIBRTE_IXGBE_PMD
11578 if (ret == -ENOTSUP)
11579 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11580 res->vf_id, is_on);
11582 #ifdef RTE_LIBRTE_I40E_PMD
11583 if (ret == -ENOTSUP)
11584 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11585 res->vf_id, is_on);
11587 #ifdef RTE_LIBRTE_BNXT_PMD
11588 if (ret == -ENOTSUP)
11589 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11590 res->vf_id, is_on);
11597 printf("invalid vf_id %d\n", res->vf_id);
11600 printf("invalid port_id %d\n", res->port_id);
11603 printf("function not implemented\n");
11606 printf("programming error: (%s)\n", strerror(-ret));
11610 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11611 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11613 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11615 (void *)&cmd_vf_vlan_anti_spoof_set,
11616 (void *)&cmd_vf_vlan_anti_spoof_vf,
11617 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11618 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11619 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11620 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11621 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11626 /* vf mac anti spoof configuration */
11628 /* Common result structure for vf mac anti spoof */
11629 struct cmd_vf_mac_anti_spoof_result {
11630 cmdline_fixed_string_t set;
11631 cmdline_fixed_string_t vf;
11632 cmdline_fixed_string_t mac;
11633 cmdline_fixed_string_t antispoof;
11636 cmdline_fixed_string_t on_off;
11639 /* Common CLI fields for vf mac anti spoof enable disable */
11640 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11641 TOKEN_STRING_INITIALIZER
11642 (struct cmd_vf_mac_anti_spoof_result,
11644 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11645 TOKEN_STRING_INITIALIZER
11646 (struct cmd_vf_mac_anti_spoof_result,
11648 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11649 TOKEN_STRING_INITIALIZER
11650 (struct cmd_vf_mac_anti_spoof_result,
11652 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11653 TOKEN_STRING_INITIALIZER
11654 (struct cmd_vf_mac_anti_spoof_result,
11655 antispoof, "antispoof");
11656 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11657 TOKEN_NUM_INITIALIZER
11658 (struct cmd_vf_mac_anti_spoof_result,
11660 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11661 TOKEN_NUM_INITIALIZER
11662 (struct cmd_vf_mac_anti_spoof_result,
11664 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11665 TOKEN_STRING_INITIALIZER
11666 (struct cmd_vf_mac_anti_spoof_result,
11670 cmd_set_vf_mac_anti_spoof_parsed(
11671 void *parsed_result,
11672 __attribute__((unused)) struct cmdline *cl,
11673 __attribute__((unused)) void *data)
11675 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11676 int ret = -ENOTSUP;
11678 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11680 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11683 #ifdef RTE_LIBRTE_IXGBE_PMD
11684 if (ret == -ENOTSUP)
11685 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11686 res->vf_id, is_on);
11688 #ifdef RTE_LIBRTE_I40E_PMD
11689 if (ret == -ENOTSUP)
11690 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11691 res->vf_id, is_on);
11693 #ifdef RTE_LIBRTE_BNXT_PMD
11694 if (ret == -ENOTSUP)
11695 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11696 res->vf_id, is_on);
11703 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11706 printf("invalid port_id %d\n", res->port_id);
11709 printf("function not implemented\n");
11712 printf("programming error: (%s)\n", strerror(-ret));
11716 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11717 .f = cmd_set_vf_mac_anti_spoof_parsed,
11719 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11721 (void *)&cmd_vf_mac_anti_spoof_set,
11722 (void *)&cmd_vf_mac_anti_spoof_vf,
11723 (void *)&cmd_vf_mac_anti_spoof_mac,
11724 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11725 (void *)&cmd_vf_mac_anti_spoof_port_id,
11726 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11727 (void *)&cmd_vf_mac_anti_spoof_on_off,
11732 /* vf vlan strip queue configuration */
11734 /* Common result structure for vf mac anti spoof */
11735 struct cmd_vf_vlan_stripq_result {
11736 cmdline_fixed_string_t set;
11737 cmdline_fixed_string_t vf;
11738 cmdline_fixed_string_t vlan;
11739 cmdline_fixed_string_t stripq;
11742 cmdline_fixed_string_t on_off;
11745 /* Common CLI fields for vf vlan strip enable disable */
11746 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11747 TOKEN_STRING_INITIALIZER
11748 (struct cmd_vf_vlan_stripq_result,
11750 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11751 TOKEN_STRING_INITIALIZER
11752 (struct cmd_vf_vlan_stripq_result,
11754 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11755 TOKEN_STRING_INITIALIZER
11756 (struct cmd_vf_vlan_stripq_result,
11758 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11759 TOKEN_STRING_INITIALIZER
11760 (struct cmd_vf_vlan_stripq_result,
11762 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11763 TOKEN_NUM_INITIALIZER
11764 (struct cmd_vf_vlan_stripq_result,
11766 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11767 TOKEN_NUM_INITIALIZER
11768 (struct cmd_vf_vlan_stripq_result,
11770 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11771 TOKEN_STRING_INITIALIZER
11772 (struct cmd_vf_vlan_stripq_result,
11776 cmd_set_vf_vlan_stripq_parsed(
11777 void *parsed_result,
11778 __attribute__((unused)) struct cmdline *cl,
11779 __attribute__((unused)) void *data)
11781 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11782 int ret = -ENOTSUP;
11784 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11786 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11789 #ifdef RTE_LIBRTE_IXGBE_PMD
11790 if (ret == -ENOTSUP)
11791 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11792 res->vf_id, is_on);
11794 #ifdef RTE_LIBRTE_I40E_PMD
11795 if (ret == -ENOTSUP)
11796 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11797 res->vf_id, is_on);
11799 #ifdef RTE_LIBRTE_BNXT_PMD
11800 if (ret == -ENOTSUP)
11801 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11802 res->vf_id, is_on);
11809 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11812 printf("invalid port_id %d\n", res->port_id);
11815 printf("function not implemented\n");
11818 printf("programming error: (%s)\n", strerror(-ret));
11822 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11823 .f = cmd_set_vf_vlan_stripq_parsed,
11825 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11827 (void *)&cmd_vf_vlan_stripq_set,
11828 (void *)&cmd_vf_vlan_stripq_vf,
11829 (void *)&cmd_vf_vlan_stripq_vlan,
11830 (void *)&cmd_vf_vlan_stripq_stripq,
11831 (void *)&cmd_vf_vlan_stripq_port_id,
11832 (void *)&cmd_vf_vlan_stripq_vf_id,
11833 (void *)&cmd_vf_vlan_stripq_on_off,
11838 /* vf vlan insert configuration */
11840 /* Common result structure for vf vlan insert */
11841 struct cmd_vf_vlan_insert_result {
11842 cmdline_fixed_string_t set;
11843 cmdline_fixed_string_t vf;
11844 cmdline_fixed_string_t vlan;
11845 cmdline_fixed_string_t insert;
11851 /* Common CLI fields for vf vlan insert enable disable */
11852 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11853 TOKEN_STRING_INITIALIZER
11854 (struct cmd_vf_vlan_insert_result,
11856 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11857 TOKEN_STRING_INITIALIZER
11858 (struct cmd_vf_vlan_insert_result,
11860 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11861 TOKEN_STRING_INITIALIZER
11862 (struct cmd_vf_vlan_insert_result,
11864 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11865 TOKEN_STRING_INITIALIZER
11866 (struct cmd_vf_vlan_insert_result,
11868 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11869 TOKEN_NUM_INITIALIZER
11870 (struct cmd_vf_vlan_insert_result,
11872 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11873 TOKEN_NUM_INITIALIZER
11874 (struct cmd_vf_vlan_insert_result,
11876 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11877 TOKEN_NUM_INITIALIZER
11878 (struct cmd_vf_vlan_insert_result,
11882 cmd_set_vf_vlan_insert_parsed(
11883 void *parsed_result,
11884 __attribute__((unused)) struct cmdline *cl,
11885 __attribute__((unused)) void *data)
11887 struct cmd_vf_vlan_insert_result *res = parsed_result;
11888 int ret = -ENOTSUP;
11890 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11893 #ifdef RTE_LIBRTE_IXGBE_PMD
11894 if (ret == -ENOTSUP)
11895 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11898 #ifdef RTE_LIBRTE_I40E_PMD
11899 if (ret == -ENOTSUP)
11900 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11903 #ifdef RTE_LIBRTE_BNXT_PMD
11904 if (ret == -ENOTSUP)
11905 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11913 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11916 printf("invalid port_id %d\n", res->port_id);
11919 printf("function not implemented\n");
11922 printf("programming error: (%s)\n", strerror(-ret));
11926 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11927 .f = cmd_set_vf_vlan_insert_parsed,
11929 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11931 (void *)&cmd_vf_vlan_insert_set,
11932 (void *)&cmd_vf_vlan_insert_vf,
11933 (void *)&cmd_vf_vlan_insert_vlan,
11934 (void *)&cmd_vf_vlan_insert_insert,
11935 (void *)&cmd_vf_vlan_insert_port_id,
11936 (void *)&cmd_vf_vlan_insert_vf_id,
11937 (void *)&cmd_vf_vlan_insert_vlan_id,
11942 /* tx loopback configuration */
11944 /* Common result structure for tx loopback */
11945 struct cmd_tx_loopback_result {
11946 cmdline_fixed_string_t set;
11947 cmdline_fixed_string_t tx;
11948 cmdline_fixed_string_t loopback;
11950 cmdline_fixed_string_t on_off;
11953 /* Common CLI fields for tx loopback enable disable */
11954 cmdline_parse_token_string_t cmd_tx_loopback_set =
11955 TOKEN_STRING_INITIALIZER
11956 (struct cmd_tx_loopback_result,
11958 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11959 TOKEN_STRING_INITIALIZER
11960 (struct cmd_tx_loopback_result,
11962 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11963 TOKEN_STRING_INITIALIZER
11964 (struct cmd_tx_loopback_result,
11965 loopback, "loopback");
11966 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11967 TOKEN_NUM_INITIALIZER
11968 (struct cmd_tx_loopback_result,
11970 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11971 TOKEN_STRING_INITIALIZER
11972 (struct cmd_tx_loopback_result,
11976 cmd_set_tx_loopback_parsed(
11977 void *parsed_result,
11978 __attribute__((unused)) struct cmdline *cl,
11979 __attribute__((unused)) void *data)
11981 struct cmd_tx_loopback_result *res = parsed_result;
11982 int ret = -ENOTSUP;
11984 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11986 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11989 #ifdef RTE_LIBRTE_IXGBE_PMD
11990 if (ret == -ENOTSUP)
11991 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11993 #ifdef RTE_LIBRTE_I40E_PMD
11994 if (ret == -ENOTSUP)
11995 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11997 #ifdef RTE_LIBRTE_BNXT_PMD
11998 if (ret == -ENOTSUP)
11999 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12006 printf("invalid is_on %d\n", is_on);
12009 printf("invalid port_id %d\n", res->port_id);
12012 printf("function not implemented\n");
12015 printf("programming error: (%s)\n", strerror(-ret));
12019 cmdline_parse_inst_t cmd_set_tx_loopback = {
12020 .f = cmd_set_tx_loopback_parsed,
12022 .help_str = "set tx loopback <port_id> on|off",
12024 (void *)&cmd_tx_loopback_set,
12025 (void *)&cmd_tx_loopback_tx,
12026 (void *)&cmd_tx_loopback_loopback,
12027 (void *)&cmd_tx_loopback_port_id,
12028 (void *)&cmd_tx_loopback_on_off,
12033 /* all queues drop enable configuration */
12035 /* Common result structure for all queues drop enable */
12036 struct cmd_all_queues_drop_en_result {
12037 cmdline_fixed_string_t set;
12038 cmdline_fixed_string_t all;
12039 cmdline_fixed_string_t queues;
12040 cmdline_fixed_string_t drop;
12042 cmdline_fixed_string_t on_off;
12045 /* Common CLI fields for tx loopback enable disable */
12046 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12047 TOKEN_STRING_INITIALIZER
12048 (struct cmd_all_queues_drop_en_result,
12050 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12051 TOKEN_STRING_INITIALIZER
12052 (struct cmd_all_queues_drop_en_result,
12054 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12055 TOKEN_STRING_INITIALIZER
12056 (struct cmd_all_queues_drop_en_result,
12058 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12059 TOKEN_STRING_INITIALIZER
12060 (struct cmd_all_queues_drop_en_result,
12062 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12063 TOKEN_NUM_INITIALIZER
12064 (struct cmd_all_queues_drop_en_result,
12066 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12067 TOKEN_STRING_INITIALIZER
12068 (struct cmd_all_queues_drop_en_result,
12072 cmd_set_all_queues_drop_en_parsed(
12073 void *parsed_result,
12074 __attribute__((unused)) struct cmdline *cl,
12075 __attribute__((unused)) void *data)
12077 struct cmd_all_queues_drop_en_result *res = parsed_result;
12078 int ret = -ENOTSUP;
12079 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12081 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12084 #ifdef RTE_LIBRTE_IXGBE_PMD
12085 if (ret == -ENOTSUP)
12086 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12088 #ifdef RTE_LIBRTE_BNXT_PMD
12089 if (ret == -ENOTSUP)
12090 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12096 printf("invalid is_on %d\n", is_on);
12099 printf("invalid port_id %d\n", res->port_id);
12102 printf("function not implemented\n");
12105 printf("programming error: (%s)\n", strerror(-ret));
12109 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12110 .f = cmd_set_all_queues_drop_en_parsed,
12112 .help_str = "set all queues drop <port_id> on|off",
12114 (void *)&cmd_all_queues_drop_en_set,
12115 (void *)&cmd_all_queues_drop_en_all,
12116 (void *)&cmd_all_queues_drop_en_queues,
12117 (void *)&cmd_all_queues_drop_en_drop,
12118 (void *)&cmd_all_queues_drop_en_port_id,
12119 (void *)&cmd_all_queues_drop_en_on_off,
12124 /* vf split drop enable configuration */
12126 /* Common result structure for vf split drop enable */
12127 struct cmd_vf_split_drop_en_result {
12128 cmdline_fixed_string_t set;
12129 cmdline_fixed_string_t vf;
12130 cmdline_fixed_string_t split;
12131 cmdline_fixed_string_t drop;
12134 cmdline_fixed_string_t on_off;
12137 /* Common CLI fields for vf split drop enable disable */
12138 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12139 TOKEN_STRING_INITIALIZER
12140 (struct cmd_vf_split_drop_en_result,
12142 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12143 TOKEN_STRING_INITIALIZER
12144 (struct cmd_vf_split_drop_en_result,
12146 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12147 TOKEN_STRING_INITIALIZER
12148 (struct cmd_vf_split_drop_en_result,
12150 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12151 TOKEN_STRING_INITIALIZER
12152 (struct cmd_vf_split_drop_en_result,
12154 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12155 TOKEN_NUM_INITIALIZER
12156 (struct cmd_vf_split_drop_en_result,
12158 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12159 TOKEN_NUM_INITIALIZER
12160 (struct cmd_vf_split_drop_en_result,
12162 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12163 TOKEN_STRING_INITIALIZER
12164 (struct cmd_vf_split_drop_en_result,
12168 cmd_set_vf_split_drop_en_parsed(
12169 void *parsed_result,
12170 __attribute__((unused)) struct cmdline *cl,
12171 __attribute__((unused)) void *data)
12173 struct cmd_vf_split_drop_en_result *res = parsed_result;
12174 int ret = -ENOTSUP;
12175 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12177 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12180 #ifdef RTE_LIBRTE_IXGBE_PMD
12181 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12188 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12191 printf("invalid port_id %d\n", res->port_id);
12194 printf("not supported on port %d\n", res->port_id);
12197 printf("programming error: (%s)\n", strerror(-ret));
12201 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12202 .f = cmd_set_vf_split_drop_en_parsed,
12204 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12206 (void *)&cmd_vf_split_drop_en_set,
12207 (void *)&cmd_vf_split_drop_en_vf,
12208 (void *)&cmd_vf_split_drop_en_split,
12209 (void *)&cmd_vf_split_drop_en_drop,
12210 (void *)&cmd_vf_split_drop_en_port_id,
12211 (void *)&cmd_vf_split_drop_en_vf_id,
12212 (void *)&cmd_vf_split_drop_en_on_off,
12217 /* vf mac address configuration */
12219 /* Common result structure for vf mac address */
12220 struct cmd_set_vf_mac_addr_result {
12221 cmdline_fixed_string_t set;
12222 cmdline_fixed_string_t vf;
12223 cmdline_fixed_string_t mac;
12224 cmdline_fixed_string_t addr;
12227 struct ether_addr mac_addr;
12231 /* Common CLI fields for vf split drop enable disable */
12232 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12233 TOKEN_STRING_INITIALIZER
12234 (struct cmd_set_vf_mac_addr_result,
12236 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12237 TOKEN_STRING_INITIALIZER
12238 (struct cmd_set_vf_mac_addr_result,
12240 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12241 TOKEN_STRING_INITIALIZER
12242 (struct cmd_set_vf_mac_addr_result,
12244 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12245 TOKEN_STRING_INITIALIZER
12246 (struct cmd_set_vf_mac_addr_result,
12248 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12249 TOKEN_NUM_INITIALIZER
12250 (struct cmd_set_vf_mac_addr_result,
12252 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12253 TOKEN_NUM_INITIALIZER
12254 (struct cmd_set_vf_mac_addr_result,
12256 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12257 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12261 cmd_set_vf_mac_addr_parsed(
12262 void *parsed_result,
12263 __attribute__((unused)) struct cmdline *cl,
12264 __attribute__((unused)) void *data)
12266 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12267 int ret = -ENOTSUP;
12269 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12272 #ifdef RTE_LIBRTE_IXGBE_PMD
12273 if (ret == -ENOTSUP)
12274 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12277 #ifdef RTE_LIBRTE_I40E_PMD
12278 if (ret == -ENOTSUP)
12279 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12282 #ifdef RTE_LIBRTE_BNXT_PMD
12283 if (ret == -ENOTSUP)
12284 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12292 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12295 printf("invalid port_id %d\n", res->port_id);
12298 printf("function not implemented\n");
12301 printf("programming error: (%s)\n", strerror(-ret));
12305 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12306 .f = cmd_set_vf_mac_addr_parsed,
12308 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12310 (void *)&cmd_set_vf_mac_addr_set,
12311 (void *)&cmd_set_vf_mac_addr_vf,
12312 (void *)&cmd_set_vf_mac_addr_mac,
12313 (void *)&cmd_set_vf_mac_addr_addr,
12314 (void *)&cmd_set_vf_mac_addr_port_id,
12315 (void *)&cmd_set_vf_mac_addr_vf_id,
12316 (void *)&cmd_set_vf_mac_addr_mac_addr,
12321 /* MACsec configuration */
12323 /* Common result structure for MACsec offload enable */
12324 struct cmd_macsec_offload_on_result {
12325 cmdline_fixed_string_t set;
12326 cmdline_fixed_string_t macsec;
12327 cmdline_fixed_string_t offload;
12329 cmdline_fixed_string_t on;
12330 cmdline_fixed_string_t encrypt;
12331 cmdline_fixed_string_t en_on_off;
12332 cmdline_fixed_string_t replay_protect;
12333 cmdline_fixed_string_t rp_on_off;
12336 /* Common CLI fields for MACsec offload disable */
12337 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12338 TOKEN_STRING_INITIALIZER
12339 (struct cmd_macsec_offload_on_result,
12341 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12342 TOKEN_STRING_INITIALIZER
12343 (struct cmd_macsec_offload_on_result,
12345 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12346 TOKEN_STRING_INITIALIZER
12347 (struct cmd_macsec_offload_on_result,
12348 offload, "offload");
12349 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12350 TOKEN_NUM_INITIALIZER
12351 (struct cmd_macsec_offload_on_result,
12353 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12354 TOKEN_STRING_INITIALIZER
12355 (struct cmd_macsec_offload_on_result,
12357 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12358 TOKEN_STRING_INITIALIZER
12359 (struct cmd_macsec_offload_on_result,
12360 encrypt, "encrypt");
12361 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12362 TOKEN_STRING_INITIALIZER
12363 (struct cmd_macsec_offload_on_result,
12364 en_on_off, "on#off");
12365 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12366 TOKEN_STRING_INITIALIZER
12367 (struct cmd_macsec_offload_on_result,
12368 replay_protect, "replay-protect");
12369 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12370 TOKEN_STRING_INITIALIZER
12371 (struct cmd_macsec_offload_on_result,
12372 rp_on_off, "on#off");
12375 cmd_set_macsec_offload_on_parsed(
12376 void *parsed_result,
12377 __attribute__((unused)) struct cmdline *cl,
12378 __attribute__((unused)) void *data)
12380 struct cmd_macsec_offload_on_result *res = parsed_result;
12381 int ret = -ENOTSUP;
12382 portid_t port_id = res->port_id;
12383 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12384 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12386 if (port_id_is_invalid(port_id, ENABLED_WARN))
12389 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
12390 #ifdef RTE_LIBRTE_IXGBE_PMD
12391 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12400 printf("invalid port_id %d\n", port_id);
12403 printf("not supported on port %d\n", port_id);
12406 printf("programming error: (%s)\n", strerror(-ret));
12410 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12411 .f = cmd_set_macsec_offload_on_parsed,
12413 .help_str = "set macsec offload <port_id> on "
12414 "encrypt on|off replay-protect on|off",
12416 (void *)&cmd_macsec_offload_on_set,
12417 (void *)&cmd_macsec_offload_on_macsec,
12418 (void *)&cmd_macsec_offload_on_offload,
12419 (void *)&cmd_macsec_offload_on_port_id,
12420 (void *)&cmd_macsec_offload_on_on,
12421 (void *)&cmd_macsec_offload_on_encrypt,
12422 (void *)&cmd_macsec_offload_on_en_on_off,
12423 (void *)&cmd_macsec_offload_on_replay_protect,
12424 (void *)&cmd_macsec_offload_on_rp_on_off,
12429 /* Common result structure for MACsec offload disable */
12430 struct cmd_macsec_offload_off_result {
12431 cmdline_fixed_string_t set;
12432 cmdline_fixed_string_t macsec;
12433 cmdline_fixed_string_t offload;
12435 cmdline_fixed_string_t off;
12438 /* Common CLI fields for MACsec offload disable */
12439 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12440 TOKEN_STRING_INITIALIZER
12441 (struct cmd_macsec_offload_off_result,
12443 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12444 TOKEN_STRING_INITIALIZER
12445 (struct cmd_macsec_offload_off_result,
12447 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12448 TOKEN_STRING_INITIALIZER
12449 (struct cmd_macsec_offload_off_result,
12450 offload, "offload");
12451 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12452 TOKEN_NUM_INITIALIZER
12453 (struct cmd_macsec_offload_off_result,
12455 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12456 TOKEN_STRING_INITIALIZER
12457 (struct cmd_macsec_offload_off_result,
12461 cmd_set_macsec_offload_off_parsed(
12462 void *parsed_result,
12463 __attribute__((unused)) struct cmdline *cl,
12464 __attribute__((unused)) void *data)
12466 struct cmd_macsec_offload_off_result *res = parsed_result;
12467 int ret = -ENOTSUP;
12468 portid_t port_id = res->port_id;
12470 if (port_id_is_invalid(port_id, ENABLED_WARN))
12473 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
12474 #ifdef RTE_LIBRTE_IXGBE_PMD
12475 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12482 printf("invalid port_id %d\n", port_id);
12485 printf("not supported on port %d\n", port_id);
12488 printf("programming error: (%s)\n", strerror(-ret));
12492 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12493 .f = cmd_set_macsec_offload_off_parsed,
12495 .help_str = "set macsec offload <port_id> off",
12497 (void *)&cmd_macsec_offload_off_set,
12498 (void *)&cmd_macsec_offload_off_macsec,
12499 (void *)&cmd_macsec_offload_off_offload,
12500 (void *)&cmd_macsec_offload_off_port_id,
12501 (void *)&cmd_macsec_offload_off_off,
12506 /* Common result structure for MACsec secure connection configure */
12507 struct cmd_macsec_sc_result {
12508 cmdline_fixed_string_t set;
12509 cmdline_fixed_string_t macsec;
12510 cmdline_fixed_string_t sc;
12511 cmdline_fixed_string_t tx_rx;
12513 struct ether_addr mac;
12517 /* Common CLI fields for MACsec secure connection configure */
12518 cmdline_parse_token_string_t cmd_macsec_sc_set =
12519 TOKEN_STRING_INITIALIZER
12520 (struct cmd_macsec_sc_result,
12522 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12523 TOKEN_STRING_INITIALIZER
12524 (struct cmd_macsec_sc_result,
12526 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12527 TOKEN_STRING_INITIALIZER
12528 (struct cmd_macsec_sc_result,
12530 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12531 TOKEN_STRING_INITIALIZER
12532 (struct cmd_macsec_sc_result,
12534 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12535 TOKEN_NUM_INITIALIZER
12536 (struct cmd_macsec_sc_result,
12538 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12539 TOKEN_ETHERADDR_INITIALIZER
12540 (struct cmd_macsec_sc_result,
12542 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12543 TOKEN_NUM_INITIALIZER
12544 (struct cmd_macsec_sc_result,
12548 cmd_set_macsec_sc_parsed(
12549 void *parsed_result,
12550 __attribute__((unused)) struct cmdline *cl,
12551 __attribute__((unused)) void *data)
12553 struct cmd_macsec_sc_result *res = parsed_result;
12554 int ret = -ENOTSUP;
12555 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12557 #ifdef RTE_LIBRTE_IXGBE_PMD
12559 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12560 res->mac.addr_bytes) :
12561 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12562 res->mac.addr_bytes, res->pi);
12564 RTE_SET_USED(is_tx);
12570 printf("invalid port_id %d\n", res->port_id);
12573 printf("not supported on port %d\n", res->port_id);
12576 printf("programming error: (%s)\n", strerror(-ret));
12580 cmdline_parse_inst_t cmd_set_macsec_sc = {
12581 .f = cmd_set_macsec_sc_parsed,
12583 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12585 (void *)&cmd_macsec_sc_set,
12586 (void *)&cmd_macsec_sc_macsec,
12587 (void *)&cmd_macsec_sc_sc,
12588 (void *)&cmd_macsec_sc_tx_rx,
12589 (void *)&cmd_macsec_sc_port_id,
12590 (void *)&cmd_macsec_sc_mac,
12591 (void *)&cmd_macsec_sc_pi,
12596 /* Common result structure for MACsec secure connection configure */
12597 struct cmd_macsec_sa_result {
12598 cmdline_fixed_string_t set;
12599 cmdline_fixed_string_t macsec;
12600 cmdline_fixed_string_t sa;
12601 cmdline_fixed_string_t tx_rx;
12606 cmdline_fixed_string_t key;
12609 /* Common CLI fields for MACsec secure connection configure */
12610 cmdline_parse_token_string_t cmd_macsec_sa_set =
12611 TOKEN_STRING_INITIALIZER
12612 (struct cmd_macsec_sa_result,
12614 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12615 TOKEN_STRING_INITIALIZER
12616 (struct cmd_macsec_sa_result,
12618 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12619 TOKEN_STRING_INITIALIZER
12620 (struct cmd_macsec_sa_result,
12622 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12623 TOKEN_STRING_INITIALIZER
12624 (struct cmd_macsec_sa_result,
12626 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12627 TOKEN_NUM_INITIALIZER
12628 (struct cmd_macsec_sa_result,
12630 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12631 TOKEN_NUM_INITIALIZER
12632 (struct cmd_macsec_sa_result,
12634 cmdline_parse_token_num_t cmd_macsec_sa_an =
12635 TOKEN_NUM_INITIALIZER
12636 (struct cmd_macsec_sa_result,
12638 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12639 TOKEN_NUM_INITIALIZER
12640 (struct cmd_macsec_sa_result,
12642 cmdline_parse_token_string_t cmd_macsec_sa_key =
12643 TOKEN_STRING_INITIALIZER
12644 (struct cmd_macsec_sa_result,
12648 cmd_set_macsec_sa_parsed(
12649 void *parsed_result,
12650 __attribute__((unused)) struct cmdline *cl,
12651 __attribute__((unused)) void *data)
12653 struct cmd_macsec_sa_result *res = parsed_result;
12654 int ret = -ENOTSUP;
12655 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12656 uint8_t key[16] = { 0 };
12662 key_len = strlen(res->key) / 2;
12666 for (i = 0; i < key_len; i++) {
12667 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12670 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12673 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12676 #ifdef RTE_LIBRTE_IXGBE_PMD
12678 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12679 res->idx, res->an, res->pn, key) :
12680 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12681 res->idx, res->an, res->pn, key);
12683 RTE_SET_USED(is_tx);
12690 printf("invalid idx %d or an %d\n", res->idx, res->an);
12693 printf("invalid port_id %d\n", res->port_id);
12696 printf("not supported on port %d\n", res->port_id);
12699 printf("programming error: (%s)\n", strerror(-ret));
12703 cmdline_parse_inst_t cmd_set_macsec_sa = {
12704 .f = cmd_set_macsec_sa_parsed,
12706 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12708 (void *)&cmd_macsec_sa_set,
12709 (void *)&cmd_macsec_sa_macsec,
12710 (void *)&cmd_macsec_sa_sa,
12711 (void *)&cmd_macsec_sa_tx_rx,
12712 (void *)&cmd_macsec_sa_port_id,
12713 (void *)&cmd_macsec_sa_idx,
12714 (void *)&cmd_macsec_sa_an,
12715 (void *)&cmd_macsec_sa_pn,
12716 (void *)&cmd_macsec_sa_key,
12721 /* VF unicast promiscuous mode configuration */
12723 /* Common result structure for VF unicast promiscuous mode */
12724 struct cmd_vf_promisc_result {
12725 cmdline_fixed_string_t set;
12726 cmdline_fixed_string_t vf;
12727 cmdline_fixed_string_t promisc;
12730 cmdline_fixed_string_t on_off;
12733 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12734 cmdline_parse_token_string_t cmd_vf_promisc_set =
12735 TOKEN_STRING_INITIALIZER
12736 (struct cmd_vf_promisc_result,
12738 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12739 TOKEN_STRING_INITIALIZER
12740 (struct cmd_vf_promisc_result,
12742 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12743 TOKEN_STRING_INITIALIZER
12744 (struct cmd_vf_promisc_result,
12745 promisc, "promisc");
12746 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12747 TOKEN_NUM_INITIALIZER
12748 (struct cmd_vf_promisc_result,
12750 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12751 TOKEN_NUM_INITIALIZER
12752 (struct cmd_vf_promisc_result,
12754 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12755 TOKEN_STRING_INITIALIZER
12756 (struct cmd_vf_promisc_result,
12760 cmd_set_vf_promisc_parsed(
12761 void *parsed_result,
12762 __attribute__((unused)) struct cmdline *cl,
12763 __attribute__((unused)) void *data)
12765 struct cmd_vf_promisc_result *res = parsed_result;
12766 int ret = -ENOTSUP;
12768 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12770 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12773 #ifdef RTE_LIBRTE_I40E_PMD
12774 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12775 res->vf_id, is_on);
12782 printf("invalid vf_id %d\n", res->vf_id);
12785 printf("invalid port_id %d\n", res->port_id);
12788 printf("function not implemented\n");
12791 printf("programming error: (%s)\n", strerror(-ret));
12795 cmdline_parse_inst_t cmd_set_vf_promisc = {
12796 .f = cmd_set_vf_promisc_parsed,
12798 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12799 "Set unicast promiscuous mode for a VF from the PF",
12801 (void *)&cmd_vf_promisc_set,
12802 (void *)&cmd_vf_promisc_vf,
12803 (void *)&cmd_vf_promisc_promisc,
12804 (void *)&cmd_vf_promisc_port_id,
12805 (void *)&cmd_vf_promisc_vf_id,
12806 (void *)&cmd_vf_promisc_on_off,
12811 /* VF multicast promiscuous mode configuration */
12813 /* Common result structure for VF multicast promiscuous mode */
12814 struct cmd_vf_allmulti_result {
12815 cmdline_fixed_string_t set;
12816 cmdline_fixed_string_t vf;
12817 cmdline_fixed_string_t allmulti;
12820 cmdline_fixed_string_t on_off;
12823 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12824 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12825 TOKEN_STRING_INITIALIZER
12826 (struct cmd_vf_allmulti_result,
12828 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12829 TOKEN_STRING_INITIALIZER
12830 (struct cmd_vf_allmulti_result,
12832 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12833 TOKEN_STRING_INITIALIZER
12834 (struct cmd_vf_allmulti_result,
12835 allmulti, "allmulti");
12836 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12837 TOKEN_NUM_INITIALIZER
12838 (struct cmd_vf_allmulti_result,
12840 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12841 TOKEN_NUM_INITIALIZER
12842 (struct cmd_vf_allmulti_result,
12844 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12845 TOKEN_STRING_INITIALIZER
12846 (struct cmd_vf_allmulti_result,
12850 cmd_set_vf_allmulti_parsed(
12851 void *parsed_result,
12852 __attribute__((unused)) struct cmdline *cl,
12853 __attribute__((unused)) void *data)
12855 struct cmd_vf_allmulti_result *res = parsed_result;
12856 int ret = -ENOTSUP;
12858 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12860 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12863 #ifdef RTE_LIBRTE_I40E_PMD
12864 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12865 res->vf_id, is_on);
12872 printf("invalid vf_id %d\n", res->vf_id);
12875 printf("invalid port_id %d\n", res->port_id);
12878 printf("function not implemented\n");
12881 printf("programming error: (%s)\n", strerror(-ret));
12885 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12886 .f = cmd_set_vf_allmulti_parsed,
12888 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12889 "Set multicast promiscuous mode for a VF from the PF",
12891 (void *)&cmd_vf_allmulti_set,
12892 (void *)&cmd_vf_allmulti_vf,
12893 (void *)&cmd_vf_allmulti_allmulti,
12894 (void *)&cmd_vf_allmulti_port_id,
12895 (void *)&cmd_vf_allmulti_vf_id,
12896 (void *)&cmd_vf_allmulti_on_off,
12901 /* vf broadcast mode configuration */
12903 /* Common result structure for vf broadcast */
12904 struct cmd_set_vf_broadcast_result {
12905 cmdline_fixed_string_t set;
12906 cmdline_fixed_string_t vf;
12907 cmdline_fixed_string_t broadcast;
12910 cmdline_fixed_string_t on_off;
12913 /* Common CLI fields for vf broadcast enable disable */
12914 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12915 TOKEN_STRING_INITIALIZER
12916 (struct cmd_set_vf_broadcast_result,
12918 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12919 TOKEN_STRING_INITIALIZER
12920 (struct cmd_set_vf_broadcast_result,
12922 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12923 TOKEN_STRING_INITIALIZER
12924 (struct cmd_set_vf_broadcast_result,
12925 broadcast, "broadcast");
12926 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12927 TOKEN_NUM_INITIALIZER
12928 (struct cmd_set_vf_broadcast_result,
12930 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12931 TOKEN_NUM_INITIALIZER
12932 (struct cmd_set_vf_broadcast_result,
12934 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12935 TOKEN_STRING_INITIALIZER
12936 (struct cmd_set_vf_broadcast_result,
12940 cmd_set_vf_broadcast_parsed(
12941 void *parsed_result,
12942 __attribute__((unused)) struct cmdline *cl,
12943 __attribute__((unused)) void *data)
12945 struct cmd_set_vf_broadcast_result *res = parsed_result;
12946 int ret = -ENOTSUP;
12948 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12950 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12953 #ifdef RTE_LIBRTE_I40E_PMD
12954 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12955 res->vf_id, is_on);
12962 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12965 printf("invalid port_id %d\n", res->port_id);
12968 printf("function not implemented\n");
12971 printf("programming error: (%s)\n", strerror(-ret));
12975 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12976 .f = cmd_set_vf_broadcast_parsed,
12978 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12980 (void *)&cmd_set_vf_broadcast_set,
12981 (void *)&cmd_set_vf_broadcast_vf,
12982 (void *)&cmd_set_vf_broadcast_broadcast,
12983 (void *)&cmd_set_vf_broadcast_port_id,
12984 (void *)&cmd_set_vf_broadcast_vf_id,
12985 (void *)&cmd_set_vf_broadcast_on_off,
12990 /* vf vlan tag configuration */
12992 /* Common result structure for vf vlan tag */
12993 struct cmd_set_vf_vlan_tag_result {
12994 cmdline_fixed_string_t set;
12995 cmdline_fixed_string_t vf;
12996 cmdline_fixed_string_t vlan;
12997 cmdline_fixed_string_t tag;
13000 cmdline_fixed_string_t on_off;
13003 /* Common CLI fields for vf vlan tag enable disable */
13004 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13005 TOKEN_STRING_INITIALIZER
13006 (struct cmd_set_vf_vlan_tag_result,
13008 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13009 TOKEN_STRING_INITIALIZER
13010 (struct cmd_set_vf_vlan_tag_result,
13012 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13013 TOKEN_STRING_INITIALIZER
13014 (struct cmd_set_vf_vlan_tag_result,
13016 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13017 TOKEN_STRING_INITIALIZER
13018 (struct cmd_set_vf_vlan_tag_result,
13020 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13021 TOKEN_NUM_INITIALIZER
13022 (struct cmd_set_vf_vlan_tag_result,
13024 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13025 TOKEN_NUM_INITIALIZER
13026 (struct cmd_set_vf_vlan_tag_result,
13028 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13029 TOKEN_STRING_INITIALIZER
13030 (struct cmd_set_vf_vlan_tag_result,
13034 cmd_set_vf_vlan_tag_parsed(
13035 void *parsed_result,
13036 __attribute__((unused)) struct cmdline *cl,
13037 __attribute__((unused)) void *data)
13039 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13040 int ret = -ENOTSUP;
13042 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13044 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13047 #ifdef RTE_LIBRTE_I40E_PMD
13048 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13049 res->vf_id, is_on);
13056 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13059 printf("invalid port_id %d\n", res->port_id);
13062 printf("function not implemented\n");
13065 printf("programming error: (%s)\n", strerror(-ret));
13069 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13070 .f = cmd_set_vf_vlan_tag_parsed,
13072 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13074 (void *)&cmd_set_vf_vlan_tag_set,
13075 (void *)&cmd_set_vf_vlan_tag_vf,
13076 (void *)&cmd_set_vf_vlan_tag_vlan,
13077 (void *)&cmd_set_vf_vlan_tag_tag,
13078 (void *)&cmd_set_vf_vlan_tag_port_id,
13079 (void *)&cmd_set_vf_vlan_tag_vf_id,
13080 (void *)&cmd_set_vf_vlan_tag_on_off,
13085 /* Common definition of VF and TC TX bandwidth configuration */
13086 struct cmd_vf_tc_bw_result {
13087 cmdline_fixed_string_t set;
13088 cmdline_fixed_string_t vf;
13089 cmdline_fixed_string_t tc;
13090 cmdline_fixed_string_t tx;
13091 cmdline_fixed_string_t min_bw;
13092 cmdline_fixed_string_t max_bw;
13093 cmdline_fixed_string_t strict_link_prio;
13098 cmdline_fixed_string_t bw_list;
13102 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13103 TOKEN_STRING_INITIALIZER
13104 (struct cmd_vf_tc_bw_result,
13106 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13107 TOKEN_STRING_INITIALIZER
13108 (struct cmd_vf_tc_bw_result,
13110 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13111 TOKEN_STRING_INITIALIZER
13112 (struct cmd_vf_tc_bw_result,
13114 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13115 TOKEN_STRING_INITIALIZER
13116 (struct cmd_vf_tc_bw_result,
13118 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13119 TOKEN_STRING_INITIALIZER
13120 (struct cmd_vf_tc_bw_result,
13121 strict_link_prio, "strict-link-priority");
13122 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13123 TOKEN_STRING_INITIALIZER
13124 (struct cmd_vf_tc_bw_result,
13125 min_bw, "min-bandwidth");
13126 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13127 TOKEN_STRING_INITIALIZER
13128 (struct cmd_vf_tc_bw_result,
13129 max_bw, "max-bandwidth");
13130 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13131 TOKEN_NUM_INITIALIZER
13132 (struct cmd_vf_tc_bw_result,
13134 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13135 TOKEN_NUM_INITIALIZER
13136 (struct cmd_vf_tc_bw_result,
13138 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13139 TOKEN_NUM_INITIALIZER
13140 (struct cmd_vf_tc_bw_result,
13142 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13143 TOKEN_NUM_INITIALIZER
13144 (struct cmd_vf_tc_bw_result,
13146 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13147 TOKEN_STRING_INITIALIZER
13148 (struct cmd_vf_tc_bw_result,
13150 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13151 TOKEN_NUM_INITIALIZER
13152 (struct cmd_vf_tc_bw_result,
13155 /* VF max bandwidth setting */
13157 cmd_vf_max_bw_parsed(
13158 void *parsed_result,
13159 __attribute__((unused)) struct cmdline *cl,
13160 __attribute__((unused)) void *data)
13162 struct cmd_vf_tc_bw_result *res = parsed_result;
13163 int ret = -ENOTSUP;
13165 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13168 #ifdef RTE_LIBRTE_I40E_PMD
13169 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13170 res->vf_id, res->bw);
13177 printf("invalid vf_id %d or bandwidth %d\n",
13178 res->vf_id, res->bw);
13181 printf("invalid port_id %d\n", res->port_id);
13184 printf("function not implemented\n");
13187 printf("programming error: (%s)\n", strerror(-ret));
13191 cmdline_parse_inst_t cmd_vf_max_bw = {
13192 .f = cmd_vf_max_bw_parsed,
13194 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13196 (void *)&cmd_vf_tc_bw_set,
13197 (void *)&cmd_vf_tc_bw_vf,
13198 (void *)&cmd_vf_tc_bw_tx,
13199 (void *)&cmd_vf_tc_bw_max_bw,
13200 (void *)&cmd_vf_tc_bw_port_id,
13201 (void *)&cmd_vf_tc_bw_vf_id,
13202 (void *)&cmd_vf_tc_bw_bw,
13208 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13213 const char *p, *p0 = str;
13220 p = strchr(p0, '(');
13222 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13226 p0 = strchr(p, ')');
13228 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13232 if (size >= sizeof(s)) {
13233 printf("The string size exceeds the internal buffer size\n");
13236 snprintf(s, sizeof(s), "%.*s", size, p);
13237 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13239 printf("Failed to get the bandwidth list. ");
13243 for (i = 0; i < ret; i++)
13244 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13249 /* TC min bandwidth setting */
13251 cmd_vf_tc_min_bw_parsed(
13252 void *parsed_result,
13253 __attribute__((unused)) struct cmdline *cl,
13254 __attribute__((unused)) void *data)
13256 struct cmd_vf_tc_bw_result *res = parsed_result;
13259 int ret = -ENOTSUP;
13261 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13264 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13268 #ifdef RTE_LIBRTE_I40E_PMD
13269 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13277 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13280 printf("invalid port_id %d\n", res->port_id);
13283 printf("function not implemented\n");
13286 printf("programming error: (%s)\n", strerror(-ret));
13290 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13291 .f = cmd_vf_tc_min_bw_parsed,
13293 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13294 " <bw1, bw2, ...>",
13296 (void *)&cmd_vf_tc_bw_set,
13297 (void *)&cmd_vf_tc_bw_vf,
13298 (void *)&cmd_vf_tc_bw_tc,
13299 (void *)&cmd_vf_tc_bw_tx,
13300 (void *)&cmd_vf_tc_bw_min_bw,
13301 (void *)&cmd_vf_tc_bw_port_id,
13302 (void *)&cmd_vf_tc_bw_vf_id,
13303 (void *)&cmd_vf_tc_bw_bw_list,
13309 cmd_tc_min_bw_parsed(
13310 void *parsed_result,
13311 __attribute__((unused)) struct cmdline *cl,
13312 __attribute__((unused)) void *data)
13314 struct cmd_vf_tc_bw_result *res = parsed_result;
13315 struct rte_port *port;
13318 int ret = -ENOTSUP;
13320 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13323 port = &ports[res->port_id];
13324 /** Check if the port is not started **/
13325 if (port->port_status != RTE_PORT_STOPPED) {
13326 printf("Please stop port %d first\n", res->port_id);
13330 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13334 #ifdef RTE_LIBRTE_IXGBE_PMD
13335 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13342 printf("invalid bandwidth\n");
13345 printf("invalid port_id %d\n", res->port_id);
13348 printf("function not implemented\n");
13351 printf("programming error: (%s)\n", strerror(-ret));
13355 cmdline_parse_inst_t cmd_tc_min_bw = {
13356 .f = cmd_tc_min_bw_parsed,
13358 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13360 (void *)&cmd_vf_tc_bw_set,
13361 (void *)&cmd_vf_tc_bw_tc,
13362 (void *)&cmd_vf_tc_bw_tx,
13363 (void *)&cmd_vf_tc_bw_min_bw,
13364 (void *)&cmd_vf_tc_bw_port_id,
13365 (void *)&cmd_vf_tc_bw_bw_list,
13370 /* TC max bandwidth setting */
13372 cmd_vf_tc_max_bw_parsed(
13373 void *parsed_result,
13374 __attribute__((unused)) struct cmdline *cl,
13375 __attribute__((unused)) void *data)
13377 struct cmd_vf_tc_bw_result *res = parsed_result;
13378 int ret = -ENOTSUP;
13380 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13383 #ifdef RTE_LIBRTE_I40E_PMD
13384 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13385 res->tc_no, res->bw);
13392 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13393 res->vf_id, res->tc_no, res->bw);
13396 printf("invalid port_id %d\n", res->port_id);
13399 printf("function not implemented\n");
13402 printf("programming error: (%s)\n", strerror(-ret));
13406 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13407 .f = cmd_vf_tc_max_bw_parsed,
13409 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13412 (void *)&cmd_vf_tc_bw_set,
13413 (void *)&cmd_vf_tc_bw_vf,
13414 (void *)&cmd_vf_tc_bw_tc,
13415 (void *)&cmd_vf_tc_bw_tx,
13416 (void *)&cmd_vf_tc_bw_max_bw,
13417 (void *)&cmd_vf_tc_bw_port_id,
13418 (void *)&cmd_vf_tc_bw_vf_id,
13419 (void *)&cmd_vf_tc_bw_tc_no,
13420 (void *)&cmd_vf_tc_bw_bw,
13425 /* Strict link priority scheduling mode setting */
13427 cmd_strict_link_prio_parsed(
13428 void *parsed_result,
13429 __attribute__((unused)) struct cmdline *cl,
13430 __attribute__((unused)) void *data)
13432 struct cmd_vf_tc_bw_result *res = parsed_result;
13433 int ret = -ENOTSUP;
13435 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13438 #ifdef RTE_LIBRTE_I40E_PMD
13439 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13446 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13449 printf("invalid port_id %d\n", res->port_id);
13452 printf("function not implemented\n");
13455 printf("programming error: (%s)\n", strerror(-ret));
13459 cmdline_parse_inst_t cmd_strict_link_prio = {
13460 .f = cmd_strict_link_prio_parsed,
13462 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13464 (void *)&cmd_vf_tc_bw_set,
13465 (void *)&cmd_vf_tc_bw_tx,
13466 (void *)&cmd_vf_tc_bw_strict_link_prio,
13467 (void *)&cmd_vf_tc_bw_port_id,
13468 (void *)&cmd_vf_tc_bw_tc_map,
13473 /* Load dynamic device personalization*/
13474 struct cmd_ddp_add_result {
13475 cmdline_fixed_string_t ddp;
13476 cmdline_fixed_string_t add;
13481 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13482 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13483 cmdline_parse_token_string_t cmd_ddp_add_add =
13484 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13485 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13486 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
13487 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13488 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13491 cmd_ddp_add_parsed(
13492 void *parsed_result,
13493 __attribute__((unused)) struct cmdline *cl,
13494 __attribute__((unused)) void *data)
13496 struct cmd_ddp_add_result *res = parsed_result;
13502 int ret = -ENOTSUP;
13504 if (res->port_id > nb_ports) {
13505 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13509 if (!all_ports_stopped()) {
13510 printf("Please stop all ports first\n");
13514 filepath = strdup(res->filepath);
13515 if (filepath == NULL) {
13516 printf("Failed to allocate memory\n");
13519 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13521 buff = open_ddp_package_file(file_fld[0], &size);
13523 free((void *)filepath);
13527 #ifdef RTE_LIBRTE_I40E_PMD
13528 if (ret == -ENOTSUP)
13529 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13531 RTE_PMD_I40E_PKG_OP_WR_ADD);
13534 if (ret == -EEXIST)
13535 printf("Profile has already existed.\n");
13537 printf("Failed to load profile.\n");
13538 else if (file_num == 2)
13539 save_ddp_package_file(file_fld[1], buff, size);
13541 close_ddp_package_file(buff);
13542 free((void *)filepath);
13545 cmdline_parse_inst_t cmd_ddp_add = {
13546 .f = cmd_ddp_add_parsed,
13548 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
13550 (void *)&cmd_ddp_add_ddp,
13551 (void *)&cmd_ddp_add_add,
13552 (void *)&cmd_ddp_add_port_id,
13553 (void *)&cmd_ddp_add_filepath,
13558 /* Delete dynamic device personalization*/
13559 struct cmd_ddp_del_result {
13560 cmdline_fixed_string_t ddp;
13561 cmdline_fixed_string_t del;
13566 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13567 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13568 cmdline_parse_token_string_t cmd_ddp_del_del =
13569 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13570 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13571 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT8);
13572 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13573 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13576 cmd_ddp_del_parsed(
13577 void *parsed_result,
13578 __attribute__((unused)) struct cmdline *cl,
13579 __attribute__((unused)) void *data)
13581 struct cmd_ddp_del_result *res = parsed_result;
13584 int ret = -ENOTSUP;
13586 if (res->port_id > nb_ports) {
13587 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13591 if (!all_ports_stopped()) {
13592 printf("Please stop all ports first\n");
13596 buff = open_ddp_package_file(res->filepath, &size);
13600 #ifdef RTE_LIBRTE_I40E_PMD
13601 if (ret == -ENOTSUP)
13602 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13604 RTE_PMD_I40E_PKG_OP_WR_DEL);
13607 if (ret == -EACCES)
13608 printf("Profile does not exist.\n");
13610 printf("Failed to delete profile.\n");
13612 close_ddp_package_file(buff);
13615 cmdline_parse_inst_t cmd_ddp_del = {
13616 .f = cmd_ddp_del_parsed,
13618 .help_str = "ddp del <port_id> <profile_path>",
13620 (void *)&cmd_ddp_del_ddp,
13621 (void *)&cmd_ddp_del_del,
13622 (void *)&cmd_ddp_del_port_id,
13623 (void *)&cmd_ddp_del_filepath,
13628 /* Get dynamic device personalization profile info */
13629 struct cmd_ddp_info_result {
13630 cmdline_fixed_string_t ddp;
13631 cmdline_fixed_string_t get;
13632 cmdline_fixed_string_t info;
13636 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13637 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13638 cmdline_parse_token_string_t cmd_ddp_info_get =
13639 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13640 cmdline_parse_token_string_t cmd_ddp_info_info =
13641 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13642 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13643 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13646 cmd_ddp_info_parsed(
13647 void *parsed_result,
13648 __attribute__((unused)) struct cmdline *cl,
13649 __attribute__((unused)) void *data)
13651 struct cmd_ddp_info_result *res = parsed_result;
13654 int ret = -ENOTSUP;
13655 #ifdef RTE_LIBRTE_I40E_PMD
13658 uint32_t buff_size = 0;
13659 struct rte_pmd_i40e_profile_info info;
13660 uint32_t dev_num = 0;
13661 struct rte_pmd_i40e_ddp_device_id *devs;
13662 uint32_t proto_num = 0;
13663 struct rte_pmd_i40e_proto_info *proto;
13664 uint32_t pctype_num = 0;
13665 struct rte_pmd_i40e_ptype_info *pctype;
13666 uint32_t ptype_num = 0;
13667 struct rte_pmd_i40e_ptype_info *ptype;
13672 pkg = open_ddp_package_file(res->filepath, &pkg_size);
13676 #ifdef RTE_LIBRTE_I40E_PMD
13677 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13678 (uint8_t *)&info, sizeof(info),
13679 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13681 printf("Global Track id: 0x%x\n", info.track_id);
13682 printf("Global Version: %d.%d.%d.%d\n",
13683 info.version.major,
13684 info.version.minor,
13685 info.version.update,
13686 info.version.draft);
13687 printf("Global Package name: %s\n\n", info.name);
13690 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13691 (uint8_t *)&info, sizeof(info),
13692 RTE_PMD_I40E_PKG_INFO_HEADER);
13694 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13695 printf("i40e Profile Version: %d.%d.%d.%d\n",
13696 info.version.major,
13697 info.version.minor,
13698 info.version.update,
13699 info.version.draft);
13700 printf("i40e Profile name: %s\n\n", info.name);
13703 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13704 (uint8_t *)&buff_size, sizeof(buff_size),
13705 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13706 if (!ret && buff_size) {
13707 buff = (uint8_t *)malloc(buff_size);
13709 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13711 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13713 printf("Package Notes:\n%s\n\n", buff);
13718 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13719 (uint8_t *)&dev_num, sizeof(dev_num),
13720 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13721 if (!ret && dev_num) {
13722 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
13723 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
13725 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13726 (uint8_t *)devs, buff_size,
13727 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13729 printf("List of supported devices:\n");
13730 for (i = 0; i < dev_num; i++) {
13731 printf(" %04X:%04X %04X:%04X\n",
13732 devs[i].vendor_dev_id >> 16,
13733 devs[i].vendor_dev_id & 0xFFFF,
13734 devs[i].sub_vendor_dev_id >> 16,
13735 devs[i].sub_vendor_dev_id & 0xFFFF);
13743 /* get information about protocols and packet types */
13744 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13745 (uint8_t *)&proto_num, sizeof(proto_num),
13746 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
13747 if (ret || !proto_num)
13748 goto no_print_return;
13750 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
13751 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
13753 goto no_print_return;
13755 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
13757 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
13759 printf("List of used protocols:\n");
13760 for (i = 0; i < proto_num; i++)
13761 printf(" %2u: %s\n", proto[i].proto_id,
13765 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13766 (uint8_t *)&pctype_num, sizeof(pctype_num),
13767 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
13768 if (ret || !pctype_num)
13769 goto no_print_pctypes;
13771 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13772 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13774 goto no_print_pctypes;
13776 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
13778 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
13781 goto no_print_pctypes;
13784 printf("List of defined packet classification types:\n");
13785 for (i = 0; i < pctype_num; i++) {
13786 printf(" %2u:", pctype[i].ptype_id);
13787 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13788 proto_id = pctype[i].protocols[j];
13789 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13790 for (n = 0; n < proto_num; n++) {
13791 if (proto[n].proto_id == proto_id) {
13792 printf(" %s", proto[n].name);
13805 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
13807 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
13808 if (ret || !ptype_num)
13809 goto no_print_return;
13811 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13812 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13814 goto no_print_return;
13816 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
13818 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
13821 goto no_print_return;
13823 printf("List of defined packet types:\n");
13824 for (i = 0; i < ptype_num; i++) {
13825 printf(" %2u:", ptype[i].ptype_id);
13826 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13827 proto_id = ptype[i].protocols[j];
13828 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13829 for (n = 0; n < proto_num; n++) {
13830 if (proto[n].proto_id == proto_id) {
13831 printf(" %s", proto[n].name);
13846 if (ret == -ENOTSUP)
13847 printf("Function not supported in PMD driver\n");
13848 close_ddp_package_file(pkg);
13851 cmdline_parse_inst_t cmd_ddp_get_info = {
13852 .f = cmd_ddp_info_parsed,
13854 .help_str = "ddp get info <profile_path>",
13856 (void *)&cmd_ddp_info_ddp,
13857 (void *)&cmd_ddp_info_get,
13858 (void *)&cmd_ddp_info_info,
13859 (void *)&cmd_ddp_info_filepath,
13864 /* Get dynamic device personalization profile info list*/
13865 #define PROFILE_INFO_SIZE 48
13866 #define MAX_PROFILE_NUM 16
13868 struct cmd_ddp_get_list_result {
13869 cmdline_fixed_string_t ddp;
13870 cmdline_fixed_string_t get;
13871 cmdline_fixed_string_t list;
13875 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
13876 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
13877 cmdline_parse_token_string_t cmd_ddp_get_list_get =
13878 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
13879 cmdline_parse_token_string_t cmd_ddp_get_list_list =
13880 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
13881 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
13882 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
13885 cmd_ddp_get_list_parsed(
13886 void *parsed_result,
13887 __attribute__((unused)) struct cmdline *cl,
13888 __attribute__((unused)) void *data)
13890 struct cmd_ddp_get_list_result *res = parsed_result;
13891 #ifdef RTE_LIBRTE_I40E_PMD
13892 struct rte_pmd_i40e_profile_list *p_list;
13893 struct rte_pmd_i40e_profile_info *p_info;
13898 int ret = -ENOTSUP;
13900 if (res->port_id > nb_ports) {
13901 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13905 #ifdef RTE_LIBRTE_I40E_PMD
13906 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
13907 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
13909 printf("%s: Failed to malloc buffer\n", __func__);
13911 if (ret == -ENOTSUP)
13912 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
13913 (uint8_t *)p_list, size);
13916 p_num = p_list->p_count;
13917 printf("Profile number is: %d\n\n", p_num);
13919 for (i = 0; i < p_num; i++) {
13920 p_info = &p_list->p_info[i];
13921 printf("Profile %d:\n", i);
13922 printf("Track id: 0x%x\n", p_info->track_id);
13923 printf("Version: %d.%d.%d.%d\n",
13924 p_info->version.major,
13925 p_info->version.minor,
13926 p_info->version.update,
13927 p_info->version.draft);
13928 printf("Profile name: %s\n\n", p_info->name);
13936 printf("Failed to get ddp list\n");
13939 cmdline_parse_inst_t cmd_ddp_get_list = {
13940 .f = cmd_ddp_get_list_parsed,
13942 .help_str = "ddp get list <port_id>",
13944 (void *)&cmd_ddp_get_list_ddp,
13945 (void *)&cmd_ddp_get_list_get,
13946 (void *)&cmd_ddp_get_list_list,
13947 (void *)&cmd_ddp_get_list_port_id,
13952 /* show vf stats */
13954 /* Common result structure for show vf stats */
13955 struct cmd_show_vf_stats_result {
13956 cmdline_fixed_string_t show;
13957 cmdline_fixed_string_t vf;
13958 cmdline_fixed_string_t stats;
13963 /* Common CLI fields show vf stats*/
13964 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13965 TOKEN_STRING_INITIALIZER
13966 (struct cmd_show_vf_stats_result,
13968 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13969 TOKEN_STRING_INITIALIZER
13970 (struct cmd_show_vf_stats_result,
13972 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13973 TOKEN_STRING_INITIALIZER
13974 (struct cmd_show_vf_stats_result,
13976 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13977 TOKEN_NUM_INITIALIZER
13978 (struct cmd_show_vf_stats_result,
13980 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13981 TOKEN_NUM_INITIALIZER
13982 (struct cmd_show_vf_stats_result,
13986 cmd_show_vf_stats_parsed(
13987 void *parsed_result,
13988 __attribute__((unused)) struct cmdline *cl,
13989 __attribute__((unused)) void *data)
13991 struct cmd_show_vf_stats_result *res = parsed_result;
13992 struct rte_eth_stats stats;
13993 int ret = -ENOTSUP;
13994 static const char *nic_stats_border = "########################";
13996 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13999 memset(&stats, 0, sizeof(stats));
14001 #ifdef RTE_LIBRTE_I40E_PMD
14002 if (ret == -ENOTSUP)
14003 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14007 #ifdef RTE_LIBRTE_BNXT_PMD
14008 if (ret == -ENOTSUP)
14009 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14018 printf("invalid vf_id %d\n", res->vf_id);
14021 printf("invalid port_id %d\n", res->port_id);
14024 printf("function not implemented\n");
14027 printf("programming error: (%s)\n", strerror(-ret));
14030 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14031 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14033 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14035 stats.ipackets, stats.imissed, stats.ibytes);
14036 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14037 printf(" RX-nombuf: %-10"PRIu64"\n",
14039 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14041 stats.opackets, stats.oerrors, stats.obytes);
14043 printf(" %s############################%s\n",
14044 nic_stats_border, nic_stats_border);
14047 cmdline_parse_inst_t cmd_show_vf_stats = {
14048 .f = cmd_show_vf_stats_parsed,
14050 .help_str = "show vf stats <port_id> <vf_id>",
14052 (void *)&cmd_show_vf_stats_show,
14053 (void *)&cmd_show_vf_stats_vf,
14054 (void *)&cmd_show_vf_stats_stats,
14055 (void *)&cmd_show_vf_stats_port_id,
14056 (void *)&cmd_show_vf_stats_vf_id,
14061 /* clear vf stats */
14063 /* Common result structure for clear vf stats */
14064 struct cmd_clear_vf_stats_result {
14065 cmdline_fixed_string_t clear;
14066 cmdline_fixed_string_t vf;
14067 cmdline_fixed_string_t stats;
14072 /* Common CLI fields clear vf stats*/
14073 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14074 TOKEN_STRING_INITIALIZER
14075 (struct cmd_clear_vf_stats_result,
14077 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14078 TOKEN_STRING_INITIALIZER
14079 (struct cmd_clear_vf_stats_result,
14081 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14082 TOKEN_STRING_INITIALIZER
14083 (struct cmd_clear_vf_stats_result,
14085 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14086 TOKEN_NUM_INITIALIZER
14087 (struct cmd_clear_vf_stats_result,
14089 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14090 TOKEN_NUM_INITIALIZER
14091 (struct cmd_clear_vf_stats_result,
14095 cmd_clear_vf_stats_parsed(
14096 void *parsed_result,
14097 __attribute__((unused)) struct cmdline *cl,
14098 __attribute__((unused)) void *data)
14100 struct cmd_clear_vf_stats_result *res = parsed_result;
14101 int ret = -ENOTSUP;
14103 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14106 #ifdef RTE_LIBRTE_I40E_PMD
14107 if (ret == -ENOTSUP)
14108 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14111 #ifdef RTE_LIBRTE_BNXT_PMD
14112 if (ret == -ENOTSUP)
14113 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14121 printf("invalid vf_id %d\n", res->vf_id);
14124 printf("invalid port_id %d\n", res->port_id);
14127 printf("function not implemented\n");
14130 printf("programming error: (%s)\n", strerror(-ret));
14134 cmdline_parse_inst_t cmd_clear_vf_stats = {
14135 .f = cmd_clear_vf_stats_parsed,
14137 .help_str = "clear vf stats <port_id> <vf_id>",
14139 (void *)&cmd_clear_vf_stats_clear,
14140 (void *)&cmd_clear_vf_stats_vf,
14141 (void *)&cmd_clear_vf_stats_stats,
14142 (void *)&cmd_clear_vf_stats_port_id,
14143 (void *)&cmd_clear_vf_stats_vf_id,
14148 /* port config pctype mapping reset */
14150 /* Common result structure for port config pctype mapping reset */
14151 struct cmd_pctype_mapping_reset_result {
14152 cmdline_fixed_string_t port;
14153 cmdline_fixed_string_t config;
14155 cmdline_fixed_string_t pctype;
14156 cmdline_fixed_string_t mapping;
14157 cmdline_fixed_string_t reset;
14160 /* Common CLI fields for port config pctype mapping reset*/
14161 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14162 TOKEN_STRING_INITIALIZER
14163 (struct cmd_pctype_mapping_reset_result,
14165 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14166 TOKEN_STRING_INITIALIZER
14167 (struct cmd_pctype_mapping_reset_result,
14169 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14170 TOKEN_NUM_INITIALIZER
14171 (struct cmd_pctype_mapping_reset_result,
14173 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14174 TOKEN_STRING_INITIALIZER
14175 (struct cmd_pctype_mapping_reset_result,
14177 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14178 TOKEN_STRING_INITIALIZER
14179 (struct cmd_pctype_mapping_reset_result,
14180 mapping, "mapping");
14181 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14182 TOKEN_STRING_INITIALIZER
14183 (struct cmd_pctype_mapping_reset_result,
14187 cmd_pctype_mapping_reset_parsed(
14188 void *parsed_result,
14189 __attribute__((unused)) struct cmdline *cl,
14190 __attribute__((unused)) void *data)
14192 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14193 int ret = -ENOTSUP;
14195 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14198 #ifdef RTE_LIBRTE_I40E_PMD
14199 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14206 printf("invalid port_id %d\n", res->port_id);
14209 printf("function not implemented\n");
14212 printf("programming error: (%s)\n", strerror(-ret));
14216 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14217 .f = cmd_pctype_mapping_reset_parsed,
14219 .help_str = "port config <port_id> pctype mapping reset",
14221 (void *)&cmd_pctype_mapping_reset_port,
14222 (void *)&cmd_pctype_mapping_reset_config,
14223 (void *)&cmd_pctype_mapping_reset_port_id,
14224 (void *)&cmd_pctype_mapping_reset_pctype,
14225 (void *)&cmd_pctype_mapping_reset_mapping,
14226 (void *)&cmd_pctype_mapping_reset_reset,
14231 /* show port pctype mapping */
14233 /* Common result structure for show port pctype mapping */
14234 struct cmd_pctype_mapping_get_result {
14235 cmdline_fixed_string_t show;
14236 cmdline_fixed_string_t port;
14238 cmdline_fixed_string_t pctype;
14239 cmdline_fixed_string_t mapping;
14242 /* Common CLI fields for pctype mapping get */
14243 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14244 TOKEN_STRING_INITIALIZER
14245 (struct cmd_pctype_mapping_get_result,
14247 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14248 TOKEN_STRING_INITIALIZER
14249 (struct cmd_pctype_mapping_get_result,
14251 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14252 TOKEN_NUM_INITIALIZER
14253 (struct cmd_pctype_mapping_get_result,
14255 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14256 TOKEN_STRING_INITIALIZER
14257 (struct cmd_pctype_mapping_get_result,
14259 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14260 TOKEN_STRING_INITIALIZER
14261 (struct cmd_pctype_mapping_get_result,
14262 mapping, "mapping");
14265 cmd_pctype_mapping_get_parsed(
14266 void *parsed_result,
14267 __attribute__((unused)) struct cmdline *cl,
14268 __attribute__((unused)) void *data)
14270 struct cmd_pctype_mapping_get_result *res = parsed_result;
14271 int ret = -ENOTSUP;
14272 #ifdef RTE_LIBRTE_I40E_PMD
14273 struct rte_pmd_i40e_flow_type_mapping
14274 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14275 int i, j, first_pctype;
14278 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14281 #ifdef RTE_LIBRTE_I40E_PMD
14282 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14289 printf("invalid port_id %d\n", res->port_id);
14292 printf("function not implemented\n");
14295 printf("programming error: (%s)\n", strerror(-ret));
14299 #ifdef RTE_LIBRTE_I40E_PMD
14300 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14301 if (mapping[i].pctype != 0ULL) {
14304 printf("pctype: ");
14305 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14306 if (mapping[i].pctype & (1ULL << j)) {
14307 printf(first_pctype ?
14308 "%02d" : ",%02d", j);
14312 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14318 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14319 .f = cmd_pctype_mapping_get_parsed,
14321 .help_str = "show port <port_id> pctype mapping",
14323 (void *)&cmd_pctype_mapping_get_show,
14324 (void *)&cmd_pctype_mapping_get_port,
14325 (void *)&cmd_pctype_mapping_get_port_id,
14326 (void *)&cmd_pctype_mapping_get_pctype,
14327 (void *)&cmd_pctype_mapping_get_mapping,
14332 /* port config pctype mapping update */
14334 /* Common result structure for port config pctype mapping update */
14335 struct cmd_pctype_mapping_update_result {
14336 cmdline_fixed_string_t port;
14337 cmdline_fixed_string_t config;
14339 cmdline_fixed_string_t pctype;
14340 cmdline_fixed_string_t mapping;
14341 cmdline_fixed_string_t update;
14342 cmdline_fixed_string_t pctype_list;
14343 uint16_t flow_type;
14346 /* Common CLI fields for pctype mapping update*/
14347 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14348 TOKEN_STRING_INITIALIZER
14349 (struct cmd_pctype_mapping_update_result,
14351 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14352 TOKEN_STRING_INITIALIZER
14353 (struct cmd_pctype_mapping_update_result,
14355 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14356 TOKEN_NUM_INITIALIZER
14357 (struct cmd_pctype_mapping_update_result,
14359 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14360 TOKEN_STRING_INITIALIZER
14361 (struct cmd_pctype_mapping_update_result,
14363 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14364 TOKEN_STRING_INITIALIZER
14365 (struct cmd_pctype_mapping_update_result,
14366 mapping, "mapping");
14367 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
14368 TOKEN_STRING_INITIALIZER
14369 (struct cmd_pctype_mapping_update_result,
14371 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
14372 TOKEN_STRING_INITIALIZER
14373 (struct cmd_pctype_mapping_update_result,
14374 pctype_list, NULL);
14375 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
14376 TOKEN_NUM_INITIALIZER
14377 (struct cmd_pctype_mapping_update_result,
14378 flow_type, UINT16);
14381 cmd_pctype_mapping_update_parsed(
14382 void *parsed_result,
14383 __attribute__((unused)) struct cmdline *cl,
14384 __attribute__((unused)) void *data)
14386 struct cmd_pctype_mapping_update_result *res = parsed_result;
14387 int ret = -ENOTSUP;
14388 #ifdef RTE_LIBRTE_I40E_PMD
14389 struct rte_pmd_i40e_flow_type_mapping mapping;
14392 unsigned int nb_item;
14393 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
14395 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14398 nb_item = parse_item_list(res->pctype_list, "pctypes",
14399 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
14401 #ifdef RTE_LIBRTE_I40E_PMD
14402 mapping.flow_type = res->flow_type;
14403 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
14404 mapping.pctype |= (1ULL << pctype_list[i]);
14405 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
14415 printf("invalid pctype or flow type\n");
14418 printf("invalid port_id %d\n", res->port_id);
14421 printf("function not implemented\n");
14424 printf("programming error: (%s)\n", strerror(-ret));
14428 cmdline_parse_inst_t cmd_pctype_mapping_update = {
14429 .f = cmd_pctype_mapping_update_parsed,
14431 .help_str = "port config <port_id> pctype mapping update"
14432 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
14434 (void *)&cmd_pctype_mapping_update_port,
14435 (void *)&cmd_pctype_mapping_update_config,
14436 (void *)&cmd_pctype_mapping_update_port_id,
14437 (void *)&cmd_pctype_mapping_update_pctype,
14438 (void *)&cmd_pctype_mapping_update_mapping,
14439 (void *)&cmd_pctype_mapping_update_update,
14440 (void *)&cmd_pctype_mapping_update_pc_type,
14441 (void *)&cmd_pctype_mapping_update_flow_type,
14446 /* ptype mapping get */
14448 /* Common result structure for ptype mapping get */
14449 struct cmd_ptype_mapping_get_result {
14450 cmdline_fixed_string_t ptype;
14451 cmdline_fixed_string_t mapping;
14452 cmdline_fixed_string_t get;
14454 uint8_t valid_only;
14457 /* Common CLI fields for ptype mapping get */
14458 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
14459 TOKEN_STRING_INITIALIZER
14460 (struct cmd_ptype_mapping_get_result,
14462 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
14463 TOKEN_STRING_INITIALIZER
14464 (struct cmd_ptype_mapping_get_result,
14465 mapping, "mapping");
14466 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
14467 TOKEN_STRING_INITIALIZER
14468 (struct cmd_ptype_mapping_get_result,
14470 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
14471 TOKEN_NUM_INITIALIZER
14472 (struct cmd_ptype_mapping_get_result,
14474 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
14475 TOKEN_NUM_INITIALIZER
14476 (struct cmd_ptype_mapping_get_result,
14477 valid_only, UINT8);
14480 cmd_ptype_mapping_get_parsed(
14481 void *parsed_result,
14482 __attribute__((unused)) struct cmdline *cl,
14483 __attribute__((unused)) void *data)
14485 struct cmd_ptype_mapping_get_result *res = parsed_result;
14486 int ret = -ENOTSUP;
14487 #ifdef RTE_LIBRTE_I40E_PMD
14488 int max_ptype_num = 256;
14489 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
14494 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14497 #ifdef RTE_LIBRTE_I40E_PMD
14498 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
14509 printf("invalid port_id %d\n", res->port_id);
14512 printf("function not implemented\n");
14515 printf("programming error: (%s)\n", strerror(-ret));
14518 #ifdef RTE_LIBRTE_I40E_PMD
14520 for (i = 0; i < count; i++)
14521 printf("%3d\t0x%08x\n",
14522 mapping[i].hw_ptype, mapping[i].sw_ptype);
14527 cmdline_parse_inst_t cmd_ptype_mapping_get = {
14528 .f = cmd_ptype_mapping_get_parsed,
14530 .help_str = "ptype mapping get <port_id> <valid_only>",
14532 (void *)&cmd_ptype_mapping_get_ptype,
14533 (void *)&cmd_ptype_mapping_get_mapping,
14534 (void *)&cmd_ptype_mapping_get_get,
14535 (void *)&cmd_ptype_mapping_get_port_id,
14536 (void *)&cmd_ptype_mapping_get_valid_only,
14541 /* ptype mapping replace */
14543 /* Common result structure for ptype mapping replace */
14544 struct cmd_ptype_mapping_replace_result {
14545 cmdline_fixed_string_t ptype;
14546 cmdline_fixed_string_t mapping;
14547 cmdline_fixed_string_t replace;
14554 /* Common CLI fields for ptype mapping replace */
14555 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
14556 TOKEN_STRING_INITIALIZER
14557 (struct cmd_ptype_mapping_replace_result,
14559 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
14560 TOKEN_STRING_INITIALIZER
14561 (struct cmd_ptype_mapping_replace_result,
14562 mapping, "mapping");
14563 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
14564 TOKEN_STRING_INITIALIZER
14565 (struct cmd_ptype_mapping_replace_result,
14566 replace, "replace");
14567 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
14568 TOKEN_NUM_INITIALIZER
14569 (struct cmd_ptype_mapping_replace_result,
14571 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
14572 TOKEN_NUM_INITIALIZER
14573 (struct cmd_ptype_mapping_replace_result,
14575 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
14576 TOKEN_NUM_INITIALIZER
14577 (struct cmd_ptype_mapping_replace_result,
14579 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
14580 TOKEN_NUM_INITIALIZER
14581 (struct cmd_ptype_mapping_replace_result,
14585 cmd_ptype_mapping_replace_parsed(
14586 void *parsed_result,
14587 __attribute__((unused)) struct cmdline *cl,
14588 __attribute__((unused)) void *data)
14590 struct cmd_ptype_mapping_replace_result *res = parsed_result;
14591 int ret = -ENOTSUP;
14593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14596 #ifdef RTE_LIBRTE_I40E_PMD
14597 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
14607 printf("invalid ptype 0x%8x or 0x%8x\n",
14608 res->target, res->pkt_type);
14611 printf("invalid port_id %d\n", res->port_id);
14614 printf("function not implemented\n");
14617 printf("programming error: (%s)\n", strerror(-ret));
14621 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
14622 .f = cmd_ptype_mapping_replace_parsed,
14625 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
14627 (void *)&cmd_ptype_mapping_replace_ptype,
14628 (void *)&cmd_ptype_mapping_replace_mapping,
14629 (void *)&cmd_ptype_mapping_replace_replace,
14630 (void *)&cmd_ptype_mapping_replace_port_id,
14631 (void *)&cmd_ptype_mapping_replace_target,
14632 (void *)&cmd_ptype_mapping_replace_mask,
14633 (void *)&cmd_ptype_mapping_replace_pkt_type,
14638 /* ptype mapping reset */
14640 /* Common result structure for ptype mapping reset */
14641 struct cmd_ptype_mapping_reset_result {
14642 cmdline_fixed_string_t ptype;
14643 cmdline_fixed_string_t mapping;
14644 cmdline_fixed_string_t reset;
14648 /* Common CLI fields for ptype mapping reset*/
14649 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
14650 TOKEN_STRING_INITIALIZER
14651 (struct cmd_ptype_mapping_reset_result,
14653 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
14654 TOKEN_STRING_INITIALIZER
14655 (struct cmd_ptype_mapping_reset_result,
14656 mapping, "mapping");
14657 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
14658 TOKEN_STRING_INITIALIZER
14659 (struct cmd_ptype_mapping_reset_result,
14661 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
14662 TOKEN_NUM_INITIALIZER
14663 (struct cmd_ptype_mapping_reset_result,
14667 cmd_ptype_mapping_reset_parsed(
14668 void *parsed_result,
14669 __attribute__((unused)) struct cmdline *cl,
14670 __attribute__((unused)) void *data)
14672 struct cmd_ptype_mapping_reset_result *res = parsed_result;
14673 int ret = -ENOTSUP;
14675 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14678 #ifdef RTE_LIBRTE_I40E_PMD
14679 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
14686 printf("invalid port_id %d\n", res->port_id);
14689 printf("function not implemented\n");
14692 printf("programming error: (%s)\n", strerror(-ret));
14696 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
14697 .f = cmd_ptype_mapping_reset_parsed,
14699 .help_str = "ptype mapping reset <port_id>",
14701 (void *)&cmd_ptype_mapping_reset_ptype,
14702 (void *)&cmd_ptype_mapping_reset_mapping,
14703 (void *)&cmd_ptype_mapping_reset_reset,
14704 (void *)&cmd_ptype_mapping_reset_port_id,
14709 /* ptype mapping update */
14711 /* Common result structure for ptype mapping update */
14712 struct cmd_ptype_mapping_update_result {
14713 cmdline_fixed_string_t ptype;
14714 cmdline_fixed_string_t mapping;
14715 cmdline_fixed_string_t reset;
14721 /* Common CLI fields for ptype mapping update*/
14722 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
14723 TOKEN_STRING_INITIALIZER
14724 (struct cmd_ptype_mapping_update_result,
14726 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
14727 TOKEN_STRING_INITIALIZER
14728 (struct cmd_ptype_mapping_update_result,
14729 mapping, "mapping");
14730 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
14731 TOKEN_STRING_INITIALIZER
14732 (struct cmd_ptype_mapping_update_result,
14734 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
14735 TOKEN_NUM_INITIALIZER
14736 (struct cmd_ptype_mapping_update_result,
14738 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
14739 TOKEN_NUM_INITIALIZER
14740 (struct cmd_ptype_mapping_update_result,
14742 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
14743 TOKEN_NUM_INITIALIZER
14744 (struct cmd_ptype_mapping_update_result,
14748 cmd_ptype_mapping_update_parsed(
14749 void *parsed_result,
14750 __attribute__((unused)) struct cmdline *cl,
14751 __attribute__((unused)) void *data)
14753 struct cmd_ptype_mapping_update_result *res = parsed_result;
14754 int ret = -ENOTSUP;
14755 #ifdef RTE_LIBRTE_I40E_PMD
14756 struct rte_pmd_i40e_ptype_mapping mapping;
14758 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14761 #ifdef RTE_LIBRTE_I40E_PMD
14762 mapping.hw_ptype = res->hw_ptype;
14763 mapping.sw_ptype = res->sw_ptype;
14764 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
14774 printf("invalid ptype 0x%8x\n", res->sw_ptype);
14777 printf("invalid port_id %d\n", res->port_id);
14780 printf("function not implemented\n");
14783 printf("programming error: (%s)\n", strerror(-ret));
14787 cmdline_parse_inst_t cmd_ptype_mapping_update = {
14788 .f = cmd_ptype_mapping_update_parsed,
14790 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
14792 (void *)&cmd_ptype_mapping_update_ptype,
14793 (void *)&cmd_ptype_mapping_update_mapping,
14794 (void *)&cmd_ptype_mapping_update_update,
14795 (void *)&cmd_ptype_mapping_update_port_id,
14796 (void *)&cmd_ptype_mapping_update_hw_ptype,
14797 (void *)&cmd_ptype_mapping_update_sw_ptype,
14802 /* Common result structure for file commands */
14803 struct cmd_cmdfile_result {
14804 cmdline_fixed_string_t load;
14805 cmdline_fixed_string_t filename;
14808 /* Common CLI fields for file commands */
14809 cmdline_parse_token_string_t cmd_load_cmdfile =
14810 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
14811 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
14812 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
14815 cmd_load_from_file_parsed(
14816 void *parsed_result,
14817 __attribute__((unused)) struct cmdline *cl,
14818 __attribute__((unused)) void *data)
14820 struct cmd_cmdfile_result *res = parsed_result;
14822 cmdline_read_from_file(res->filename);
14825 cmdline_parse_inst_t cmd_load_from_file = {
14826 .f = cmd_load_from_file_parsed,
14828 .help_str = "load <filename>",
14830 (void *)&cmd_load_cmdfile,
14831 (void *)&cmd_load_cmdfile_filename,
14836 /* ******************************************************************************** */
14838 /* list of instructions */
14839 cmdline_parse_ctx_t main_ctx[] = {
14840 (cmdline_parse_inst_t *)&cmd_help_brief,
14841 (cmdline_parse_inst_t *)&cmd_help_long,
14842 (cmdline_parse_inst_t *)&cmd_quit,
14843 (cmdline_parse_inst_t *)&cmd_load_from_file,
14844 (cmdline_parse_inst_t *)&cmd_showport,
14845 (cmdline_parse_inst_t *)&cmd_showqueue,
14846 (cmdline_parse_inst_t *)&cmd_showportall,
14847 (cmdline_parse_inst_t *)&cmd_showcfg,
14848 (cmdline_parse_inst_t *)&cmd_start,
14849 (cmdline_parse_inst_t *)&cmd_start_tx_first,
14850 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
14851 (cmdline_parse_inst_t *)&cmd_set_link_up,
14852 (cmdline_parse_inst_t *)&cmd_set_link_down,
14853 (cmdline_parse_inst_t *)&cmd_reset,
14854 (cmdline_parse_inst_t *)&cmd_set_numbers,
14855 (cmdline_parse_inst_t *)&cmd_set_txpkts,
14856 (cmdline_parse_inst_t *)&cmd_set_txsplit,
14857 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
14858 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
14859 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
14860 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
14861 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
14862 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
14863 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
14864 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
14865 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
14866 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
14867 (cmdline_parse_inst_t *)&cmd_set_link_check,
14868 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
14869 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
14870 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
14871 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
14872 #ifdef RTE_LIBRTE_PMD_BOND
14873 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
14874 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
14875 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
14876 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
14877 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
14878 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
14879 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
14880 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
14881 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
14882 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
14883 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
14885 (cmdline_parse_inst_t *)&cmd_vlan_offload,
14886 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
14887 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
14888 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
14889 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
14890 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
14891 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
14892 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
14893 (cmdline_parse_inst_t *)&cmd_csum_set,
14894 (cmdline_parse_inst_t *)&cmd_csum_show,
14895 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
14896 (cmdline_parse_inst_t *)&cmd_tso_set,
14897 (cmdline_parse_inst_t *)&cmd_tso_show,
14898 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
14899 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
14900 (cmdline_parse_inst_t *)&cmd_gro_enable,
14901 (cmdline_parse_inst_t *)&cmd_gro_flush,
14902 (cmdline_parse_inst_t *)&cmd_gro_show,
14903 (cmdline_parse_inst_t *)&cmd_gso_enable,
14904 (cmdline_parse_inst_t *)&cmd_gso_size,
14905 (cmdline_parse_inst_t *)&cmd_gso_show,
14906 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
14907 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
14908 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
14909 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
14910 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
14911 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
14912 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
14913 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
14914 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
14915 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
14916 (cmdline_parse_inst_t *)&cmd_config_dcb,
14917 (cmdline_parse_inst_t *)&cmd_read_reg,
14918 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
14919 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
14920 (cmdline_parse_inst_t *)&cmd_write_reg,
14921 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
14922 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
14923 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
14924 (cmdline_parse_inst_t *)&cmd_stop,
14925 (cmdline_parse_inst_t *)&cmd_mac_addr,
14926 (cmdline_parse_inst_t *)&cmd_set_qmap,
14927 (cmdline_parse_inst_t *)&cmd_operate_port,
14928 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
14929 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
14930 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
14931 (cmdline_parse_inst_t *)&cmd_config_speed_all,
14932 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
14933 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
14934 (cmdline_parse_inst_t *)&cmd_config_mtu,
14935 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
14936 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
14937 (cmdline_parse_inst_t *)&cmd_config_rss,
14938 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
14939 (cmdline_parse_inst_t *)&cmd_config_txqflags,
14940 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
14941 (cmdline_parse_inst_t *)&cmd_showport_reta,
14942 (cmdline_parse_inst_t *)&cmd_config_burst,
14943 (cmdline_parse_inst_t *)&cmd_config_thresh,
14944 (cmdline_parse_inst_t *)&cmd_config_threshold,
14945 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
14946 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
14947 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
14948 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
14949 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
14950 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
14951 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
14952 (cmdline_parse_inst_t *)&cmd_global_config,
14953 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
14954 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
14955 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
14956 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
14957 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
14958 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
14959 (cmdline_parse_inst_t *)&cmd_dump,
14960 (cmdline_parse_inst_t *)&cmd_dump_one,
14961 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
14962 (cmdline_parse_inst_t *)&cmd_syn_filter,
14963 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
14964 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
14965 (cmdline_parse_inst_t *)&cmd_flex_filter,
14966 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
14967 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
14968 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
14969 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
14970 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
14971 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
14972 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
14973 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
14974 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
14975 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
14976 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
14977 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
14978 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
14979 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
14980 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
14981 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
14982 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
14983 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
14984 (cmdline_parse_inst_t *)&cmd_flow,
14985 (cmdline_parse_inst_t *)&cmd_mcast_addr,
14986 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
14987 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
14988 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
14989 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
14990 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
14991 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
14992 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
14993 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
14994 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
14995 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
14996 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
14997 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
14998 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
14999 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15000 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15001 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15002 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15003 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15004 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15005 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15006 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15007 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15008 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15009 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15010 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15011 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15012 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15013 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15014 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15015 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15016 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15017 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15018 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15019 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15020 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15021 (cmdline_parse_inst_t *)&cmd_ddp_add,
15022 (cmdline_parse_inst_t *)&cmd_ddp_del,
15023 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15024 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15025 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15026 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15027 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15028 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15029 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15030 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15032 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15033 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15034 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15038 /* read cmdline commands from file */
15040 cmdline_read_from_file(const char *filename)
15042 struct cmdline *cl;
15044 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15046 printf("Failed to create file based cmdline context: %s\n",
15051 cmdline_interact(cl);
15056 printf("Read CLI commands from %s\n", filename);
15059 /* prompt function, called from main on MASTER lcore */
15063 /* initialize non-constant commands */
15064 cmd_set_fwd_mode_init();
15065 cmd_set_fwd_retry_mode_init();
15067 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15068 if (testpmd_cl == NULL)
15070 cmdline_interact(testpmd_cl);
15071 cmdline_stdin_exit(testpmd_cl);
15077 if (testpmd_cl != NULL)
15078 cmdline_quit(testpmd_cl);
15082 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15084 if (id == (portid_t)RTE_PORT_ALL) {
15087 RTE_ETH_FOREACH_DEV(pid) {
15088 /* check if need_reconfig has been set to 1 */
15089 if (ports[pid].need_reconfig == 0)
15090 ports[pid].need_reconfig = dev;
15091 /* check if need_reconfig_queues has been set to 1 */
15092 if (ports[pid].need_reconfig_queues == 0)
15093 ports[pid].need_reconfig_queues = queue;
15095 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15096 /* check if need_reconfig has been set to 1 */
15097 if (ports[id].need_reconfig == 0)
15098 ports[id].need_reconfig = dev;
15099 /* check if need_reconfig_queues has been set to 1 */
15100 if (ports[id].need_reconfig_queues == 0)
15101 ports[id].need_reconfig_queues = queue;