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"
442 " Set packet forwarding mode.\n\n"
444 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
445 " Add a MAC address on port_id.\n\n"
447 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
448 " Remove a MAC address from port_id.\n\n"
450 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
451 " Set the default MAC address for port_id.\n\n"
453 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
454 " Add a MAC address for a VF on the port.\n\n"
456 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
457 " Set the MAC address for a VF from the PF.\n\n"
459 "set port (port_id) uta (mac_address|all) (on|off)\n"
460 " Add/Remove a or all unicast hash filter(s)"
463 "set promisc (port_id|all) (on|off)\n"
464 " Set the promiscuous mode on port_id, or all.\n\n"
466 "set allmulti (port_id|all) (on|off)\n"
467 " Set the allmulti mode on port_id, or all.\n\n"
469 "set vf promisc (port_id) (vf_id) (on|off)\n"
470 " Set unicast promiscuous mode for a VF from the PF.\n\n"
472 "set vf allmulti (port_id) (vf_id) (on|off)\n"
473 " Set multicast promiscuous mode for a VF from the PF.\n\n"
475 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
476 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
477 " (on|off) autoneg (on|off) (port_id)\n"
478 "set flow_ctrl rx (on|off) (portid)\n"
479 "set flow_ctrl tx (on|off) (portid)\n"
480 "set flow_ctrl high_water (high_water) (portid)\n"
481 "set flow_ctrl low_water (low_water) (portid)\n"
482 "set flow_ctrl pause_time (pause_time) (portid)\n"
483 "set flow_ctrl send_xon (send_xon) (portid)\n"
484 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
485 "set flow_ctrl autoneg (on|off) (port_id)\n"
486 " Set the link flow control parameter on a port.\n\n"
488 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
489 " (low_water) (pause_time) (priority) (port_id)\n"
490 " Set the priority flow control parameter on a"
493 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
494 " Set statistics mapping (qmapping 0..15) for RX/TX"
496 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
497 " on port 0 to mapping 5.\n\n"
499 "set port (port_id) vf (vf_id) rx|tx on|off\n"
500 " Enable/Disable a VF receive/tranmit from a port\n\n"
502 "set port (port_id) vf (vf_id) (mac_addr)"
503 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
504 " Add/Remove unicast or multicast MAC addr filter"
507 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
509 " AUPE:accepts untagged VLAN;"
510 "ROPE:accept unicast hash\n\n"
511 " BAM:accepts broadcast packets;"
512 "MPE:accepts all multicast packets\n\n"
513 " Enable/Disable a VF receive mode of a port\n\n"
515 "set port (port_id) queue (queue_id) rate (rate_num)\n"
516 " Set rate limit for a queue of a port\n\n"
518 "set port (port_id) vf (vf_id) rate (rate_num) "
519 "queue_mask (queue_mask_value)\n"
520 " Set rate limit for queues in VF of a port\n\n"
522 "set port (port_id) mirror-rule (rule_id)"
523 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
524 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
525 " Set pool or vlan type mirror rule on a port.\n"
526 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
527 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
530 "set port (port_id) mirror-rule (rule_id)"
531 " (uplink-mirror|downlink-mirror) dst-pool"
532 " (pool_id) (on|off)\n"
533 " Set uplink or downlink type mirror rule on a port.\n"
534 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
535 " 0 on' enable mirror income traffic to pool 0.\n\n"
537 "reset port (port_id) mirror-rule (rule_id)\n"
538 " Reset a mirror rule.\n\n"
540 "set flush_rx (on|off)\n"
541 " Flush (default) or don't flush RX streams before"
542 " forwarding. Mainly used with PCAP drivers.\n\n"
544 "set bypass mode (normal|bypass|isolate) (port_id)\n"
545 " Set the bypass mode for the lowest port on bypass enabled"
548 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
549 "mode (normal|bypass|isolate) (port_id)\n"
550 " Set the event required to initiate specified bypass mode for"
551 " the lowest port on a bypass enabled NIC where:\n"
552 " timeout = enable bypass after watchdog timeout.\n"
553 " os_on = enable bypass when OS/board is powered on.\n"
554 " os_off = enable bypass when OS/board is powered off.\n"
555 " power_on = enable bypass when power supply is turned on.\n"
556 " power_off = enable bypass when power supply is turned off."
559 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
560 " Set the bypass watchdog timeout to 'n' seconds"
561 " where 0 = instant.\n\n"
563 "show bypass config (port_id)\n"
564 " Show the bypass configuration for a bypass enabled NIC"
565 " using the lowest port on the NIC.\n\n"
567 #ifdef RTE_LIBRTE_PMD_BOND
568 "create bonded device (mode) (socket)\n"
569 " Create a new bonded device with specific bonding mode and socket.\n\n"
571 "add bonding slave (slave_id) (port_id)\n"
572 " Add a slave device to a bonded device.\n\n"
574 "remove bonding slave (slave_id) (port_id)\n"
575 " Remove a slave device from a bonded device.\n\n"
577 "set bonding mode (value) (port_id)\n"
578 " Set the bonding mode on a bonded device.\n\n"
580 "set bonding primary (slave_id) (port_id)\n"
581 " Set the primary slave for a bonded device.\n\n"
583 "show bonding config (port_id)\n"
584 " Show the bonding config for port_id.\n\n"
586 "set bonding mac_addr (port_id) (address)\n"
587 " Set the MAC address of a bonded device.\n\n"
589 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
590 " Set Aggregation mode for IEEE802.3AD (mode 4)"
592 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
593 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
595 "set bonding mon_period (port_id) (value)\n"
596 " Set the bonding link status monitoring polling period in ms.\n\n"
598 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
599 " Enable/disable dedicated queues for LACP control traffic.\n\n"
602 "set link-up port (port_id)\n"
603 " Set link up for a port.\n\n"
605 "set link-down port (port_id)\n"
606 " Set link down for a port.\n\n"
608 "E-tag set insertion on port-tag-id (value)"
609 " port (port_id) vf (vf_id)\n"
610 " Enable E-tag insertion for a VF on a port\n\n"
612 "E-tag set insertion off port (port_id) vf (vf_id)\n"
613 " Disable E-tag insertion for a VF on a port\n\n"
615 "E-tag set stripping (on|off) port (port_id)\n"
616 " Enable/disable E-tag stripping on a port\n\n"
618 "E-tag set forwarding (on|off) port (port_id)\n"
619 " Enable/disable E-tag based forwarding"
622 "E-tag set filter add e-tag-id (value) dst-pool"
623 " (pool_id) port (port_id)\n"
624 " Add an E-tag forwarding filter on a port\n\n"
626 "E-tag set filter del e-tag-id (value) port (port_id)\n"
627 " Delete an E-tag forwarding filter on a port\n\n"
629 "ddp add (port_id) (profile_path[,output_path])\n"
630 " Load a profile package on a port\n\n"
632 "ddp del (port_id) (profile_path)\n"
633 " Delete a profile package from a port\n\n"
635 "ptype mapping get (port_id) (valid_only)\n"
636 " Get ptype mapping on a port\n\n"
638 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
639 " Replace target with the pkt_type in ptype mapping\n\n"
641 "ptype mapping reset (port_id)\n"
642 " Reset ptype mapping on a port\n\n"
644 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
645 " Update a ptype mapping item on a port\n\n"
647 , list_pkt_forwarding_modes()
651 if (show_all || !strcmp(res->section, "ports")) {
657 "----------------\n\n"
659 "port start (port_id|all)\n"
660 " Start all ports or port_id.\n\n"
662 "port stop (port_id|all)\n"
663 " Stop all ports or port_id.\n\n"
665 "port close (port_id|all)\n"
666 " Close all ports or port_id.\n\n"
668 "port attach (ident)\n"
669 " Attach physical or virtual dev by pci address or virtual device name\n\n"
671 "port detach (port_id)\n"
672 " Detach physical or virtual dev by port_id\n\n"
674 "port config (port_id|all)"
675 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
676 " duplex (half|full|auto)\n"
677 " Set speed and duplex for all ports or port_id\n\n"
679 "port config all (rxq|txq|rxd|txd) (value)\n"
680 " Set number for rxq/txq/rxd/txd.\n\n"
682 "port config all max-pkt-len (value)\n"
683 " Set the max packet length.\n\n"
685 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
686 "hw-vlan-strip|hw-vlan-extend|drop-en)"
688 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
691 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
692 "geneve|nvgre|none|<flowtype_id>)\n"
693 " Set the RSS mode.\n\n"
695 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
696 " Set the RSS redirection table.\n\n"
698 "port config (port_id) dcb vt (on|off) (traffic_class)"
700 " Set the DCB mode.\n\n"
702 "port config all burst (value)\n"
703 " Set the number of packets per burst.\n\n"
705 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
707 " Set the ring prefetch/host/writeback threshold"
708 " for tx/rx queue.\n\n"
710 "port config all (txfreet|txrst|rxfreet) (value)\n"
711 " Set free threshold for rx/tx, or set"
712 " tx rs bit threshold.\n\n"
713 "port config mtu X value\n"
714 " Set the MTU of port X to a given value\n\n"
716 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
717 " Start/stop a rx/tx queue of port X. Only take effect"
718 " when port X is started\n\n"
720 "port config (port_id|all) l2-tunnel E-tag ether-type"
722 " Set the value of E-tag ether-type.\n\n"
724 "port config (port_id|all) l2-tunnel E-tag"
725 " (enable|disable)\n"
726 " Enable/disable the E-tag support.\n\n"
728 "port config (port_id) pctype mapping reset\n"
729 " Reset flow type to pctype mapping on a port\n\n"
731 "port config (port_id) pctype mapping update"
732 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
733 " Update a flow type to pctype mapping item on a port\n\n"
737 if (show_all || !strcmp(res->section, "registers")) {
745 "read reg (port_id) (address)\n"
746 " Display value of a port register.\n\n"
748 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
749 " Display a port register bit field.\n\n"
751 "read regbit (port_id) (address) (bit_x)\n"
752 " Display a single port register bit.\n\n"
754 "write reg (port_id) (address) (value)\n"
755 " Set value of a port register.\n\n"
757 "write regfield (port_id) (address) (bit_x) (bit_y)"
759 " Set bit field of a port register.\n\n"
761 "write regbit (port_id) (address) (bit_x) (value)\n"
762 " Set single bit value of a port register.\n\n"
765 if (show_all || !strcmp(res->section, "filters")) {
773 "ethertype_filter (port_id) (add|del)"
774 " (mac_addr|mac_ignr) (mac_address) ethertype"
775 " (ether_type) (drop|fwd) queue (queue_id)\n"
776 " Add/Del an ethertype filter.\n\n"
778 "2tuple_filter (port_id) (add|del)"
779 " dst_port (dst_port_value) protocol (protocol_value)"
780 " mask (mask_value) tcp_flags (tcp_flags_value)"
781 " priority (prio_value) queue (queue_id)\n"
782 " Add/Del a 2tuple filter.\n\n"
784 "5tuple_filter (port_id) (add|del)"
785 " dst_ip (dst_address) src_ip (src_address)"
786 " dst_port (dst_port_value) src_port (src_port_value)"
787 " protocol (protocol_value)"
788 " mask (mask_value) tcp_flags (tcp_flags_value)"
789 " priority (prio_value) queue (queue_id)\n"
790 " Add/Del a 5tuple filter.\n\n"
792 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
793 " Add/Del syn filter.\n\n"
795 "flex_filter (port_id) (add|del) len (len_value)"
796 " bytes (bytes_value) mask (mask_value)"
797 " priority (prio_value) queue (queue_id)\n"
798 " Add/Del a flex filter.\n\n"
800 "flow_director_filter (port_id) mode IP (add|del|update)"
801 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
802 " src (src_ip_address) dst (dst_ip_address)"
803 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
804 " vlan (vlan_value) flexbytes (flexbytes_value)"
805 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
806 " fd_id (fd_id_value)\n"
807 " Add/Del an IP type flow director filter.\n\n"
809 "flow_director_filter (port_id) mode IP (add|del|update)"
810 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
811 " src (src_ip_address) (src_port)"
812 " dst (dst_ip_address) (dst_port)"
813 " tos (tos_value) ttl (ttl_value)"
814 " vlan (vlan_value) flexbytes (flexbytes_value)"
815 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
816 " fd_id (fd_id_value)\n"
817 " Add/Del an UDP/TCP type flow director filter.\n\n"
819 "flow_director_filter (port_id) mode IP (add|del|update)"
820 " flow (ipv4-sctp|ipv6-sctp)"
821 " src (src_ip_address) (src_port)"
822 " dst (dst_ip_address) (dst_port)"
823 " tag (verification_tag) "
824 " tos (tos_value) ttl (ttl_value)"
826 " flexbytes (flexbytes_value) (drop|fwd)"
827 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
828 " Add/Del a SCTP type flow director filter.\n\n"
830 "flow_director_filter (port_id) mode IP (add|del|update)"
831 " flow l2_payload ether (ethertype)"
832 " flexbytes (flexbytes_value) (drop|fwd)"
833 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
834 " Add/Del a l2 payload type flow director filter.\n\n"
836 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
837 " mac (mac_address) vlan (vlan_value)"
838 " flexbytes (flexbytes_value) (drop|fwd)"
839 " queue (queue_id) fd_id (fd_id_value)\n"
840 " Add/Del a MAC-VLAN flow director filter.\n\n"
842 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
843 " mac (mac_address) vlan (vlan_value)"
844 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
845 " flexbytes (flexbytes_value) (drop|fwd)"
846 " queue (queue_id) fd_id (fd_id_value)\n"
847 " Add/Del a Tunnel flow director filter.\n\n"
849 "flush_flow_director (port_id)\n"
850 " Flush all flow director entries of a device.\n\n"
852 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
853 " src_mask (ipv4_src) (ipv6_src) (src_port)"
854 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
855 " Set flow director IP mask.\n\n"
857 "flow_director_mask (port_id) mode MAC-VLAN"
858 " vlan (vlan_value)\n"
859 " Set flow director MAC-VLAN mask.\n\n"
861 "flow_director_mask (port_id) mode Tunnel"
862 " vlan (vlan_value) mac (mac_value)"
863 " tunnel-type (tunnel_type_value)"
864 " tunnel-id (tunnel_id_value)\n"
865 " Set flow director Tunnel mask.\n\n"
867 "flow_director_flex_mask (port_id)"
868 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
869 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
871 " Configure mask of flex payload.\n\n"
873 "flow_director_flex_payload (port_id)"
874 " (raw|l2|l3|l4) (config)\n"
875 " Configure flex payload selection.\n\n"
877 "get_sym_hash_ena_per_port (port_id)\n"
878 " get symmetric hash enable configuration per port.\n\n"
880 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
881 " set symmetric hash enable configuration per port"
882 " to enable or disable.\n\n"
884 "get_hash_global_config (port_id)\n"
885 " Get the global configurations of hash filters.\n\n"
887 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
888 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
889 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
890 " (enable|disable)\n"
891 " Set the global configurations of hash filters.\n\n"
893 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
894 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
895 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
896 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
897 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
898 "ipv6-next-header|udp-src-port|udp-dst-port|"
899 "tcp-src-port|tcp-dst-port|sctp-src-port|"
900 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
901 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
902 "fld-8th|none) (select|add)\n"
903 " Set the input set for hash.\n\n"
905 "set_fdir_input_set (port_id) "
906 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
907 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
908 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
909 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
910 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
911 "udp-dst-port|tcp-src-port|tcp-dst-port|"
912 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
914 " Set the input set for FDir.\n\n"
916 "flow validate {port_id}"
917 " [group {group_id}] [priority {level}]"
918 " [ingress] [egress]"
919 " pattern {item} [/ {item} [...]] / end"
920 " actions {action} [/ {action} [...]] / end\n"
921 " Check whether a flow rule can be created.\n\n"
923 "flow create {port_id}"
924 " [group {group_id}] [priority {level}]"
925 " [ingress] [egress]"
926 " pattern {item} [/ {item} [...]] / end"
927 " actions {action} [/ {action} [...]] / end\n"
928 " Create a flow rule.\n\n"
930 "flow destroy {port_id} rule {rule_id} [...]\n"
931 " Destroy specific flow rules.\n\n"
933 "flow flush {port_id}\n"
934 " Destroy all flow rules.\n\n"
936 "flow query {port_id} {rule_id} {action}\n"
937 " Query an existing flow rule.\n\n"
939 "flow list {port_id} [group {group_id}] [...]\n"
940 " List existing flow rules sorted by priority,"
941 " filtered by group identifiers.\n\n"
943 "flow isolate {port_id} {boolean}\n"
944 " Restrict ingress traffic to the defined"
950 cmdline_parse_token_string_t cmd_help_long_help =
951 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
953 cmdline_parse_token_string_t cmd_help_long_section =
954 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
955 "all#control#display#config#"
956 "ports#registers#filters");
958 cmdline_parse_inst_t cmd_help_long = {
959 .f = cmd_help_long_parsed,
961 .help_str = "help all|control|display|config|ports|register|filters: "
964 (void *)&cmd_help_long_help,
965 (void *)&cmd_help_long_section,
971 /* *** start/stop/close all ports *** */
972 struct cmd_operate_port_result {
973 cmdline_fixed_string_t keyword;
974 cmdline_fixed_string_t name;
975 cmdline_fixed_string_t value;
978 static void cmd_operate_port_parsed(void *parsed_result,
979 __attribute__((unused)) struct cmdline *cl,
980 __attribute__((unused)) void *data)
982 struct cmd_operate_port_result *res = parsed_result;
984 if (!strcmp(res->name, "start"))
985 start_port(RTE_PORT_ALL);
986 else if (!strcmp(res->name, "stop"))
987 stop_port(RTE_PORT_ALL);
988 else if (!strcmp(res->name, "close"))
989 close_port(RTE_PORT_ALL);
990 else if (!strcmp(res->name, "reset"))
991 reset_port(RTE_PORT_ALL);
993 printf("Unknown parameter\n");
996 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
997 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
999 cmdline_parse_token_string_t cmd_operate_port_all_port =
1000 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1001 "start#stop#close#reset");
1002 cmdline_parse_token_string_t cmd_operate_port_all_all =
1003 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1005 cmdline_parse_inst_t cmd_operate_port = {
1006 .f = cmd_operate_port_parsed,
1008 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1010 (void *)&cmd_operate_port_all_cmd,
1011 (void *)&cmd_operate_port_all_port,
1012 (void *)&cmd_operate_port_all_all,
1017 /* *** start/stop/close specific port *** */
1018 struct cmd_operate_specific_port_result {
1019 cmdline_fixed_string_t keyword;
1020 cmdline_fixed_string_t name;
1024 static void cmd_operate_specific_port_parsed(void *parsed_result,
1025 __attribute__((unused)) struct cmdline *cl,
1026 __attribute__((unused)) void *data)
1028 struct cmd_operate_specific_port_result *res = parsed_result;
1030 if (!strcmp(res->name, "start"))
1031 start_port(res->value);
1032 else if (!strcmp(res->name, "stop"))
1033 stop_port(res->value);
1034 else if (!strcmp(res->name, "close"))
1035 close_port(res->value);
1036 else if (!strcmp(res->name, "reset"))
1037 reset_port(res->value);
1039 printf("Unknown parameter\n");
1042 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1043 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1045 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1046 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1047 name, "start#stop#close#reset");
1048 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1049 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1052 cmdline_parse_inst_t cmd_operate_specific_port = {
1053 .f = cmd_operate_specific_port_parsed,
1055 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1057 (void *)&cmd_operate_specific_port_cmd,
1058 (void *)&cmd_operate_specific_port_port,
1059 (void *)&cmd_operate_specific_port_id,
1064 /* *** attach a specified port *** */
1065 struct cmd_operate_attach_port_result {
1066 cmdline_fixed_string_t port;
1067 cmdline_fixed_string_t keyword;
1068 cmdline_fixed_string_t identifier;
1071 static void cmd_operate_attach_port_parsed(void *parsed_result,
1072 __attribute__((unused)) struct cmdline *cl,
1073 __attribute__((unused)) void *data)
1075 struct cmd_operate_attach_port_result *res = parsed_result;
1077 if (!strcmp(res->keyword, "attach"))
1078 attach_port(res->identifier);
1080 printf("Unknown parameter\n");
1083 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1084 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1086 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1087 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1089 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1090 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1093 cmdline_parse_inst_t cmd_operate_attach_port = {
1094 .f = cmd_operate_attach_port_parsed,
1096 .help_str = "port attach <identifier>: "
1097 "(identifier: pci address or virtual dev name)",
1099 (void *)&cmd_operate_attach_port_port,
1100 (void *)&cmd_operate_attach_port_keyword,
1101 (void *)&cmd_operate_attach_port_identifier,
1106 /* *** detach a specified port *** */
1107 struct cmd_operate_detach_port_result {
1108 cmdline_fixed_string_t port;
1109 cmdline_fixed_string_t keyword;
1113 static void cmd_operate_detach_port_parsed(void *parsed_result,
1114 __attribute__((unused)) struct cmdline *cl,
1115 __attribute__((unused)) void *data)
1117 struct cmd_operate_detach_port_result *res = parsed_result;
1119 if (!strcmp(res->keyword, "detach"))
1120 detach_port(res->port_id);
1122 printf("Unknown parameter\n");
1125 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1126 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1128 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1129 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1131 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1132 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1135 cmdline_parse_inst_t cmd_operate_detach_port = {
1136 .f = cmd_operate_detach_port_parsed,
1138 .help_str = "port detach <port_id>",
1140 (void *)&cmd_operate_detach_port_port,
1141 (void *)&cmd_operate_detach_port_keyword,
1142 (void *)&cmd_operate_detach_port_port_id,
1147 /* *** configure speed for all ports *** */
1148 struct cmd_config_speed_all {
1149 cmdline_fixed_string_t port;
1150 cmdline_fixed_string_t keyword;
1151 cmdline_fixed_string_t all;
1152 cmdline_fixed_string_t item1;
1153 cmdline_fixed_string_t item2;
1154 cmdline_fixed_string_t value1;
1155 cmdline_fixed_string_t value2;
1159 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1164 if (!strcmp(duplexstr, "half")) {
1165 duplex = ETH_LINK_HALF_DUPLEX;
1166 } else if (!strcmp(duplexstr, "full")) {
1167 duplex = ETH_LINK_FULL_DUPLEX;
1168 } else if (!strcmp(duplexstr, "auto")) {
1169 duplex = ETH_LINK_FULL_DUPLEX;
1171 printf("Unknown duplex parameter\n");
1175 if (!strcmp(speedstr, "10")) {
1176 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1177 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1178 } else if (!strcmp(speedstr, "100")) {
1179 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1180 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1182 if (duplex != ETH_LINK_FULL_DUPLEX) {
1183 printf("Invalid speed/duplex parameters\n");
1186 if (!strcmp(speedstr, "1000")) {
1187 *speed = ETH_LINK_SPEED_1G;
1188 } else if (!strcmp(speedstr, "10000")) {
1189 *speed = ETH_LINK_SPEED_10G;
1190 } else if (!strcmp(speedstr, "25000")) {
1191 *speed = ETH_LINK_SPEED_25G;
1192 } else if (!strcmp(speedstr, "40000")) {
1193 *speed = ETH_LINK_SPEED_40G;
1194 } else if (!strcmp(speedstr, "50000")) {
1195 *speed = ETH_LINK_SPEED_50G;
1196 } else if (!strcmp(speedstr, "100000")) {
1197 *speed = ETH_LINK_SPEED_100G;
1198 } else if (!strcmp(speedstr, "auto")) {
1199 *speed = ETH_LINK_SPEED_AUTONEG;
1201 printf("Unknown speed parameter\n");
1210 cmd_config_speed_all_parsed(void *parsed_result,
1211 __attribute__((unused)) struct cmdline *cl,
1212 __attribute__((unused)) void *data)
1214 struct cmd_config_speed_all *res = parsed_result;
1215 uint32_t link_speed;
1218 if (!all_ports_stopped()) {
1219 printf("Please stop all ports first\n");
1223 if (parse_and_check_speed_duplex(res->value1, res->value2,
1227 RTE_ETH_FOREACH_DEV(pid) {
1228 ports[pid].dev_conf.link_speeds = link_speed;
1231 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1234 cmdline_parse_token_string_t cmd_config_speed_all_port =
1235 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1236 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1237 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1239 cmdline_parse_token_string_t cmd_config_speed_all_all =
1240 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1241 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1242 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1243 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1244 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1245 "10#100#1000#10000#25000#40000#50000#100000#auto");
1246 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1247 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1248 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1249 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1252 cmdline_parse_inst_t cmd_config_speed_all = {
1253 .f = cmd_config_speed_all_parsed,
1255 .help_str = "port config all speed "
1256 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1259 (void *)&cmd_config_speed_all_port,
1260 (void *)&cmd_config_speed_all_keyword,
1261 (void *)&cmd_config_speed_all_all,
1262 (void *)&cmd_config_speed_all_item1,
1263 (void *)&cmd_config_speed_all_value1,
1264 (void *)&cmd_config_speed_all_item2,
1265 (void *)&cmd_config_speed_all_value2,
1270 /* *** configure speed for specific port *** */
1271 struct cmd_config_speed_specific {
1272 cmdline_fixed_string_t port;
1273 cmdline_fixed_string_t keyword;
1275 cmdline_fixed_string_t item1;
1276 cmdline_fixed_string_t item2;
1277 cmdline_fixed_string_t value1;
1278 cmdline_fixed_string_t value2;
1282 cmd_config_speed_specific_parsed(void *parsed_result,
1283 __attribute__((unused)) struct cmdline *cl,
1284 __attribute__((unused)) void *data)
1286 struct cmd_config_speed_specific *res = parsed_result;
1287 uint32_t link_speed;
1289 if (!all_ports_stopped()) {
1290 printf("Please stop all ports first\n");
1294 if (port_id_is_invalid(res->id, ENABLED_WARN))
1297 if (parse_and_check_speed_duplex(res->value1, res->value2,
1301 ports[res->id].dev_conf.link_speeds = link_speed;
1303 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1307 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1308 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1310 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1311 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1313 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1314 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1315 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1316 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1318 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1319 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1320 "10#100#1000#10000#25000#40000#50000#100000#auto");
1321 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1322 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1324 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1325 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1328 cmdline_parse_inst_t cmd_config_speed_specific = {
1329 .f = cmd_config_speed_specific_parsed,
1331 .help_str = "port config <port_id> speed "
1332 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1335 (void *)&cmd_config_speed_specific_port,
1336 (void *)&cmd_config_speed_specific_keyword,
1337 (void *)&cmd_config_speed_specific_id,
1338 (void *)&cmd_config_speed_specific_item1,
1339 (void *)&cmd_config_speed_specific_value1,
1340 (void *)&cmd_config_speed_specific_item2,
1341 (void *)&cmd_config_speed_specific_value2,
1346 /* *** configure txq/rxq, txd/rxd *** */
1347 struct cmd_config_rx_tx {
1348 cmdline_fixed_string_t port;
1349 cmdline_fixed_string_t keyword;
1350 cmdline_fixed_string_t all;
1351 cmdline_fixed_string_t name;
1356 cmd_config_rx_tx_parsed(void *parsed_result,
1357 __attribute__((unused)) struct cmdline *cl,
1358 __attribute__((unused)) void *data)
1360 struct cmd_config_rx_tx *res = parsed_result;
1362 if (!all_ports_stopped()) {
1363 printf("Please stop all ports first\n");
1366 if (!strcmp(res->name, "rxq")) {
1367 if (!res->value && !nb_txq) {
1368 printf("Warning: Either rx or tx queues should be non zero\n");
1371 nb_rxq = res->value;
1373 else if (!strcmp(res->name, "txq")) {
1374 if (!res->value && !nb_rxq) {
1375 printf("Warning: Either rx or tx queues should be non zero\n");
1378 nb_txq = res->value;
1380 else if (!strcmp(res->name, "rxd")) {
1381 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1382 printf("rxd %d invalid - must be > 0 && <= %d\n",
1383 res->value, RTE_TEST_RX_DESC_MAX);
1386 nb_rxd = res->value;
1387 } else if (!strcmp(res->name, "txd")) {
1388 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1389 printf("txd %d invalid - must be > 0 && <= %d\n",
1390 res->value, RTE_TEST_TX_DESC_MAX);
1393 nb_txd = res->value;
1395 printf("Unknown parameter\n");
1403 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1406 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1407 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1408 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1409 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1410 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1411 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1412 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1413 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1415 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1416 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1418 cmdline_parse_inst_t cmd_config_rx_tx = {
1419 .f = cmd_config_rx_tx_parsed,
1421 .help_str = "port config all rxq|txq|rxd|txd <value>",
1423 (void *)&cmd_config_rx_tx_port,
1424 (void *)&cmd_config_rx_tx_keyword,
1425 (void *)&cmd_config_rx_tx_all,
1426 (void *)&cmd_config_rx_tx_name,
1427 (void *)&cmd_config_rx_tx_value,
1432 /* *** config max packet length *** */
1433 struct cmd_config_max_pkt_len_result {
1434 cmdline_fixed_string_t port;
1435 cmdline_fixed_string_t keyword;
1436 cmdline_fixed_string_t all;
1437 cmdline_fixed_string_t name;
1442 cmd_config_max_pkt_len_parsed(void *parsed_result,
1443 __attribute__((unused)) struct cmdline *cl,
1444 __attribute__((unused)) void *data)
1446 struct cmd_config_max_pkt_len_result *res = parsed_result;
1448 if (!all_ports_stopped()) {
1449 printf("Please stop all ports first\n");
1453 if (!strcmp(res->name, "max-pkt-len")) {
1454 if (res->value < ETHER_MIN_LEN) {
1455 printf("max-pkt-len can not be less than %d\n",
1459 if (res->value == rx_mode.max_rx_pkt_len)
1462 rx_mode.max_rx_pkt_len = res->value;
1463 if (res->value > ETHER_MAX_LEN)
1464 rx_mode.jumbo_frame = 1;
1466 rx_mode.jumbo_frame = 0;
1468 printf("Unknown parameter\n");
1474 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1477 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1478 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1480 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1481 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1483 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1484 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1486 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1487 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1489 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1490 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1493 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1494 .f = cmd_config_max_pkt_len_parsed,
1496 .help_str = "port config all max-pkt-len <value>",
1498 (void *)&cmd_config_max_pkt_len_port,
1499 (void *)&cmd_config_max_pkt_len_keyword,
1500 (void *)&cmd_config_max_pkt_len_all,
1501 (void *)&cmd_config_max_pkt_len_name,
1502 (void *)&cmd_config_max_pkt_len_value,
1507 /* *** configure port MTU *** */
1508 struct cmd_config_mtu_result {
1509 cmdline_fixed_string_t port;
1510 cmdline_fixed_string_t keyword;
1511 cmdline_fixed_string_t mtu;
1517 cmd_config_mtu_parsed(void *parsed_result,
1518 __attribute__((unused)) struct cmdline *cl,
1519 __attribute__((unused)) void *data)
1521 struct cmd_config_mtu_result *res = parsed_result;
1523 if (res->value < ETHER_MIN_LEN) {
1524 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1527 port_mtu_set(res->port_id, res->value);
1530 cmdline_parse_token_string_t cmd_config_mtu_port =
1531 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1533 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1534 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1536 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1537 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1539 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1540 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1541 cmdline_parse_token_num_t cmd_config_mtu_value =
1542 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1544 cmdline_parse_inst_t cmd_config_mtu = {
1545 .f = cmd_config_mtu_parsed,
1547 .help_str = "port config mtu <port_id> <value>",
1549 (void *)&cmd_config_mtu_port,
1550 (void *)&cmd_config_mtu_keyword,
1551 (void *)&cmd_config_mtu_mtu,
1552 (void *)&cmd_config_mtu_port_id,
1553 (void *)&cmd_config_mtu_value,
1558 /* *** configure rx mode *** */
1559 struct cmd_config_rx_mode_flag {
1560 cmdline_fixed_string_t port;
1561 cmdline_fixed_string_t keyword;
1562 cmdline_fixed_string_t all;
1563 cmdline_fixed_string_t name;
1564 cmdline_fixed_string_t value;
1568 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1569 __attribute__((unused)) struct cmdline *cl,
1570 __attribute__((unused)) void *data)
1572 struct cmd_config_rx_mode_flag *res = parsed_result;
1574 if (!all_ports_stopped()) {
1575 printf("Please stop all ports first\n");
1579 if (!strcmp(res->name, "crc-strip")) {
1580 if (!strcmp(res->value, "on"))
1581 rx_mode.hw_strip_crc = 1;
1582 else if (!strcmp(res->value, "off"))
1583 rx_mode.hw_strip_crc = 0;
1585 printf("Unknown parameter\n");
1588 } else if (!strcmp(res->name, "scatter")) {
1589 if (!strcmp(res->value, "on"))
1590 rx_mode.enable_scatter = 1;
1591 else if (!strcmp(res->value, "off"))
1592 rx_mode.enable_scatter = 0;
1594 printf("Unknown parameter\n");
1597 } else if (!strcmp(res->name, "rx-cksum")) {
1598 if (!strcmp(res->value, "on"))
1599 rx_mode.hw_ip_checksum = 1;
1600 else if (!strcmp(res->value, "off"))
1601 rx_mode.hw_ip_checksum = 0;
1603 printf("Unknown parameter\n");
1606 } else if (!strcmp(res->name, "hw-vlan")) {
1607 if (!strcmp(res->value, "on")) {
1608 rx_mode.hw_vlan_filter = 1;
1609 rx_mode.hw_vlan_strip = 1;
1611 else if (!strcmp(res->value, "off")) {
1612 rx_mode.hw_vlan_filter = 0;
1613 rx_mode.hw_vlan_strip = 0;
1616 printf("Unknown parameter\n");
1619 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1620 if (!strcmp(res->value, "on"))
1621 rx_mode.hw_vlan_filter = 1;
1622 else if (!strcmp(res->value, "off"))
1623 rx_mode.hw_vlan_filter = 0;
1625 printf("Unknown parameter\n");
1628 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1629 if (!strcmp(res->value, "on"))
1630 rx_mode.hw_vlan_strip = 1;
1631 else if (!strcmp(res->value, "off"))
1632 rx_mode.hw_vlan_strip = 0;
1634 printf("Unknown parameter\n");
1637 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1638 if (!strcmp(res->value, "on"))
1639 rx_mode.hw_vlan_extend = 1;
1640 else if (!strcmp(res->value, "off"))
1641 rx_mode.hw_vlan_extend = 0;
1643 printf("Unknown parameter\n");
1646 } else if (!strcmp(res->name, "drop-en")) {
1647 if (!strcmp(res->value, "on"))
1649 else if (!strcmp(res->value, "off"))
1652 printf("Unknown parameter\n");
1656 printf("Unknown parameter\n");
1662 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1665 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1667 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1668 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1670 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1671 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1672 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1673 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1674 "crc-strip#scatter#rx-cksum#hw-vlan#"
1675 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1676 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1677 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1680 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1681 .f = cmd_config_rx_mode_flag_parsed,
1683 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1684 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1686 (void *)&cmd_config_rx_mode_flag_port,
1687 (void *)&cmd_config_rx_mode_flag_keyword,
1688 (void *)&cmd_config_rx_mode_flag_all,
1689 (void *)&cmd_config_rx_mode_flag_name,
1690 (void *)&cmd_config_rx_mode_flag_value,
1695 /* *** configure rss *** */
1696 struct cmd_config_rss {
1697 cmdline_fixed_string_t port;
1698 cmdline_fixed_string_t keyword;
1699 cmdline_fixed_string_t all;
1700 cmdline_fixed_string_t name;
1701 cmdline_fixed_string_t value;
1705 cmd_config_rss_parsed(void *parsed_result,
1706 __attribute__((unused)) struct cmdline *cl,
1707 __attribute__((unused)) void *data)
1709 struct cmd_config_rss *res = parsed_result;
1710 struct rte_eth_rss_conf rss_conf;
1714 if (!strcmp(res->value, "all"))
1715 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1716 ETH_RSS_UDP | ETH_RSS_SCTP |
1718 else if (!strcmp(res->value, "ip"))
1719 rss_conf.rss_hf = ETH_RSS_IP;
1720 else if (!strcmp(res->value, "udp"))
1721 rss_conf.rss_hf = ETH_RSS_UDP;
1722 else if (!strcmp(res->value, "tcp"))
1723 rss_conf.rss_hf = ETH_RSS_TCP;
1724 else if (!strcmp(res->value, "sctp"))
1725 rss_conf.rss_hf = ETH_RSS_SCTP;
1726 else if (!strcmp(res->value, "ether"))
1727 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1728 else if (!strcmp(res->value, "port"))
1729 rss_conf.rss_hf = ETH_RSS_PORT;
1730 else if (!strcmp(res->value, "vxlan"))
1731 rss_conf.rss_hf = ETH_RSS_VXLAN;
1732 else if (!strcmp(res->value, "geneve"))
1733 rss_conf.rss_hf = ETH_RSS_GENEVE;
1734 else if (!strcmp(res->value, "nvgre"))
1735 rss_conf.rss_hf = ETH_RSS_NVGRE;
1736 else if (!strcmp(res->value, "none"))
1737 rss_conf.rss_hf = 0;
1738 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1739 atoi(res->value) < 64)
1740 rss_conf.rss_hf = 1ULL << atoi(res->value);
1742 printf("Unknown parameter\n");
1745 rss_conf.rss_key = NULL;
1746 for (i = 0; i < rte_eth_dev_count(); i++) {
1747 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1749 printf("Configuration of RSS hash at ethernet port %d "
1750 "failed with error (%d): %s.\n",
1751 i, -diag, strerror(-diag));
1755 cmdline_parse_token_string_t cmd_config_rss_port =
1756 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1757 cmdline_parse_token_string_t cmd_config_rss_keyword =
1758 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1759 cmdline_parse_token_string_t cmd_config_rss_all =
1760 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1761 cmdline_parse_token_string_t cmd_config_rss_name =
1762 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1763 cmdline_parse_token_string_t cmd_config_rss_value =
1764 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1766 cmdline_parse_inst_t cmd_config_rss = {
1767 .f = cmd_config_rss_parsed,
1769 .help_str = "port config all rss "
1770 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1772 (void *)&cmd_config_rss_port,
1773 (void *)&cmd_config_rss_keyword,
1774 (void *)&cmd_config_rss_all,
1775 (void *)&cmd_config_rss_name,
1776 (void *)&cmd_config_rss_value,
1781 /* *** configure rss hash key *** */
1782 struct cmd_config_rss_hash_key {
1783 cmdline_fixed_string_t port;
1784 cmdline_fixed_string_t config;
1786 cmdline_fixed_string_t rss_hash_key;
1787 cmdline_fixed_string_t rss_type;
1788 cmdline_fixed_string_t key;
1792 hexa_digit_to_value(char hexa_digit)
1794 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1795 return (uint8_t) (hexa_digit - '0');
1796 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1797 return (uint8_t) ((hexa_digit - 'a') + 10);
1798 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1799 return (uint8_t) ((hexa_digit - 'A') + 10);
1800 /* Invalid hexa digit */
1805 parse_and_check_key_hexa_digit(char *key, int idx)
1809 hexa_v = hexa_digit_to_value(key[idx]);
1811 printf("invalid key: character %c at position %d is not a "
1812 "valid hexa digit\n", key[idx], idx);
1817 cmd_config_rss_hash_key_parsed(void *parsed_result,
1818 __attribute__((unused)) struct cmdline *cl,
1819 __attribute__((unused)) void *data)
1821 struct cmd_config_rss_hash_key *res = parsed_result;
1822 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1826 struct rte_eth_dev_info dev_info;
1827 uint8_t hash_key_size;
1830 memset(&dev_info, 0, sizeof(dev_info));
1831 rte_eth_dev_info_get(res->port_id, &dev_info);
1832 if (dev_info.hash_key_size > 0 &&
1833 dev_info.hash_key_size <= sizeof(hash_key))
1834 hash_key_size = dev_info.hash_key_size;
1836 printf("dev_info did not provide a valid hash key size\n");
1839 /* Check the length of the RSS hash key */
1840 key_len = strlen(res->key);
1841 if (key_len != (hash_key_size * 2)) {
1842 printf("key length: %d invalid - key must be a string of %d"
1843 " hexa-decimal numbers\n",
1844 (int) key_len, hash_key_size * 2);
1847 /* Translate RSS hash key into binary representation */
1848 for (i = 0; i < hash_key_size; i++) {
1849 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1852 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1855 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1857 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1861 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1862 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1863 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1864 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1866 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1867 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1868 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1869 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1870 rss_hash_key, "rss-hash-key");
1871 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1872 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1873 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1874 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1875 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1876 "ipv6-tcp-ex#ipv6-udp-ex");
1877 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1878 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1880 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1881 .f = cmd_config_rss_hash_key_parsed,
1883 .help_str = "port config <port_id> rss-hash-key "
1884 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1885 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1886 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1887 "<string of hex digits (variable length, NIC dependent)>",
1889 (void *)&cmd_config_rss_hash_key_port,
1890 (void *)&cmd_config_rss_hash_key_config,
1891 (void *)&cmd_config_rss_hash_key_port_id,
1892 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1893 (void *)&cmd_config_rss_hash_key_rss_type,
1894 (void *)&cmd_config_rss_hash_key_value,
1899 /* *** configure port rxq/txq start/stop *** */
1900 struct cmd_config_rxtx_queue {
1901 cmdline_fixed_string_t port;
1903 cmdline_fixed_string_t rxtxq;
1905 cmdline_fixed_string_t opname;
1909 cmd_config_rxtx_queue_parsed(void *parsed_result,
1910 __attribute__((unused)) struct cmdline *cl,
1911 __attribute__((unused)) void *data)
1913 struct cmd_config_rxtx_queue *res = parsed_result;
1918 if (test_done == 0) {
1919 printf("Please stop forwarding first\n");
1923 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1926 if (port_is_started(res->portid) != 1) {
1927 printf("Please start port %u first\n", res->portid);
1931 if (!strcmp(res->rxtxq, "rxq"))
1933 else if (!strcmp(res->rxtxq, "txq"))
1936 printf("Unknown parameter\n");
1940 if (isrx && rx_queue_id_is_invalid(res->qid))
1942 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1945 if (!strcmp(res->opname, "start"))
1947 else if (!strcmp(res->opname, "stop"))
1950 printf("Unknown parameter\n");
1954 if (isstart && isrx)
1955 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1956 else if (!isstart && isrx)
1957 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1958 else if (isstart && !isrx)
1959 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1961 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1963 if (ret == -ENOTSUP)
1964 printf("Function not supported in PMD driver\n");
1967 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1968 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1969 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1970 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1971 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1972 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1973 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1974 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1975 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1976 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1979 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1980 .f = cmd_config_rxtx_queue_parsed,
1982 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1984 (void *)&cmd_config_speed_all_port,
1985 (void *)&cmd_config_rxtx_queue_portid,
1986 (void *)&cmd_config_rxtx_queue_rxtxq,
1987 (void *)&cmd_config_rxtx_queue_qid,
1988 (void *)&cmd_config_rxtx_queue_opname,
1993 /* *** Configure RSS RETA *** */
1994 struct cmd_config_rss_reta {
1995 cmdline_fixed_string_t port;
1996 cmdline_fixed_string_t keyword;
1998 cmdline_fixed_string_t name;
1999 cmdline_fixed_string_t list_name;
2000 cmdline_fixed_string_t list_of_items;
2004 parse_reta_config(const char *str,
2005 struct rte_eth_rss_reta_entry64 *reta_conf,
2006 uint16_t nb_entries)
2010 uint16_t hash_index, idx, shift;
2013 const char *p, *p0 = str;
2020 unsigned long int_fld[_NUM_FLD];
2021 char *str_fld[_NUM_FLD];
2023 while ((p = strchr(p0,'(')) != NULL) {
2025 if((p0 = strchr(p,')')) == NULL)
2029 if(size >= sizeof(s))
2032 snprintf(s, sizeof(s), "%.*s", size, p);
2033 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2035 for (i = 0; i < _NUM_FLD; i++) {
2037 int_fld[i] = strtoul(str_fld[i], &end, 0);
2038 if (errno != 0 || end == str_fld[i] ||
2043 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2044 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2046 if (hash_index >= nb_entries) {
2047 printf("Invalid RETA hash index=%d\n", hash_index);
2051 idx = hash_index / RTE_RETA_GROUP_SIZE;
2052 shift = hash_index % RTE_RETA_GROUP_SIZE;
2053 reta_conf[idx].mask |= (1ULL << shift);
2054 reta_conf[idx].reta[shift] = nb_queue;
2061 cmd_set_rss_reta_parsed(void *parsed_result,
2062 __attribute__((unused)) struct cmdline *cl,
2063 __attribute__((unused)) void *data)
2066 struct rte_eth_dev_info dev_info;
2067 struct rte_eth_rss_reta_entry64 reta_conf[8];
2068 struct cmd_config_rss_reta *res = parsed_result;
2070 memset(&dev_info, 0, sizeof(dev_info));
2071 rte_eth_dev_info_get(res->port_id, &dev_info);
2072 if (dev_info.reta_size == 0) {
2073 printf("Redirection table size is 0 which is "
2074 "invalid for RSS\n");
2077 printf("The reta size of port %d is %u\n",
2078 res->port_id, dev_info.reta_size);
2079 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2080 printf("Currently do not support more than %u entries of "
2081 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2085 memset(reta_conf, 0, sizeof(reta_conf));
2086 if (!strcmp(res->list_name, "reta")) {
2087 if (parse_reta_config(res->list_of_items, reta_conf,
2088 dev_info.reta_size)) {
2089 printf("Invalid RSS Redirection Table "
2090 "config entered\n");
2093 ret = rte_eth_dev_rss_reta_update(res->port_id,
2094 reta_conf, dev_info.reta_size);
2096 printf("Bad redirection table parameter, "
2097 "return code = %d \n", ret);
2101 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2102 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2103 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2104 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2105 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2106 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2107 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2108 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2109 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2110 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2111 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2112 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2114 cmdline_parse_inst_t cmd_config_rss_reta = {
2115 .f = cmd_set_rss_reta_parsed,
2117 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2119 (void *)&cmd_config_rss_reta_port,
2120 (void *)&cmd_config_rss_reta_keyword,
2121 (void *)&cmd_config_rss_reta_port_id,
2122 (void *)&cmd_config_rss_reta_name,
2123 (void *)&cmd_config_rss_reta_list_name,
2124 (void *)&cmd_config_rss_reta_list_of_items,
2129 /* *** SHOW PORT RETA INFO *** */
2130 struct cmd_showport_reta {
2131 cmdline_fixed_string_t show;
2132 cmdline_fixed_string_t port;
2134 cmdline_fixed_string_t rss;
2135 cmdline_fixed_string_t reta;
2137 cmdline_fixed_string_t list_of_items;
2141 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2142 uint16_t nb_entries,
2146 const char *p, *p0 = str;
2151 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2152 RTE_RETA_GROUP_SIZE;
2155 p = strchr(p0, '(');
2159 p0 = strchr(p, ')');
2163 if (size >= sizeof(s)) {
2164 printf("The string size exceeds the internal buffer size\n");
2167 snprintf(s, sizeof(s), "%.*s", size, p);
2168 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2169 if (ret <= 0 || ret != num) {
2170 printf("The bits of masks do not match the number of "
2171 "reta entries: %u\n", num);
2174 for (i = 0; i < ret; i++)
2175 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2181 cmd_showport_reta_parsed(void *parsed_result,
2182 __attribute__((unused)) struct cmdline *cl,
2183 __attribute__((unused)) void *data)
2185 struct cmd_showport_reta *res = parsed_result;
2186 struct rte_eth_rss_reta_entry64 reta_conf[8];
2187 struct rte_eth_dev_info dev_info;
2189 memset(&dev_info, 0, sizeof(dev_info));
2190 rte_eth_dev_info_get(res->port_id, &dev_info);
2191 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2192 res->size > ETH_RSS_RETA_SIZE_512) {
2193 printf("Invalid redirection table size: %u\n", res->size);
2197 memset(reta_conf, 0, sizeof(reta_conf));
2198 if (showport_parse_reta_config(reta_conf, res->size,
2199 res->list_of_items) < 0) {
2200 printf("Invalid string: %s for reta masks\n",
2201 res->list_of_items);
2204 port_rss_reta_info(res->port_id, reta_conf, res->size);
2207 cmdline_parse_token_string_t cmd_showport_reta_show =
2208 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2209 cmdline_parse_token_string_t cmd_showport_reta_port =
2210 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2211 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2212 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2213 cmdline_parse_token_string_t cmd_showport_reta_rss =
2214 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2215 cmdline_parse_token_string_t cmd_showport_reta_reta =
2216 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2217 cmdline_parse_token_num_t cmd_showport_reta_size =
2218 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2219 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2220 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2221 list_of_items, NULL);
2223 cmdline_parse_inst_t cmd_showport_reta = {
2224 .f = cmd_showport_reta_parsed,
2226 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2228 (void *)&cmd_showport_reta_show,
2229 (void *)&cmd_showport_reta_port,
2230 (void *)&cmd_showport_reta_port_id,
2231 (void *)&cmd_showport_reta_rss,
2232 (void *)&cmd_showport_reta_reta,
2233 (void *)&cmd_showport_reta_size,
2234 (void *)&cmd_showport_reta_list_of_items,
2239 /* *** Show RSS hash configuration *** */
2240 struct cmd_showport_rss_hash {
2241 cmdline_fixed_string_t show;
2242 cmdline_fixed_string_t port;
2244 cmdline_fixed_string_t rss_hash;
2245 cmdline_fixed_string_t rss_type;
2246 cmdline_fixed_string_t key; /* optional argument */
2249 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2250 __attribute__((unused)) struct cmdline *cl,
2253 struct cmd_showport_rss_hash *res = parsed_result;
2255 port_rss_hash_conf_show(res->port_id, res->rss_type,
2256 show_rss_key != NULL);
2259 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2260 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2261 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2262 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2263 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2264 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2265 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2266 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2268 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2269 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2270 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2271 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2272 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2273 "ipv6-tcp-ex#ipv6-udp-ex");
2274 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2275 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2277 cmdline_parse_inst_t cmd_showport_rss_hash = {
2278 .f = cmd_showport_rss_hash_parsed,
2280 .help_str = "show port <port_id> rss-hash "
2281 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2282 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2283 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2285 (void *)&cmd_showport_rss_hash_show,
2286 (void *)&cmd_showport_rss_hash_port,
2287 (void *)&cmd_showport_rss_hash_port_id,
2288 (void *)&cmd_showport_rss_hash_rss_hash,
2289 (void *)&cmd_showport_rss_hash_rss_hash_info,
2294 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2295 .f = cmd_showport_rss_hash_parsed,
2297 .help_str = "show port <port_id> rss-hash "
2298 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2299 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2300 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2302 (void *)&cmd_showport_rss_hash_show,
2303 (void *)&cmd_showport_rss_hash_port,
2304 (void *)&cmd_showport_rss_hash_port_id,
2305 (void *)&cmd_showport_rss_hash_rss_hash,
2306 (void *)&cmd_showport_rss_hash_rss_hash_info,
2307 (void *)&cmd_showport_rss_hash_rss_key,
2312 /* *** Configure DCB *** */
2313 struct cmd_config_dcb {
2314 cmdline_fixed_string_t port;
2315 cmdline_fixed_string_t config;
2317 cmdline_fixed_string_t dcb;
2318 cmdline_fixed_string_t vt;
2319 cmdline_fixed_string_t vt_en;
2321 cmdline_fixed_string_t pfc;
2322 cmdline_fixed_string_t pfc_en;
2326 cmd_config_dcb_parsed(void *parsed_result,
2327 __attribute__((unused)) struct cmdline *cl,
2328 __attribute__((unused)) void *data)
2330 struct cmd_config_dcb *res = parsed_result;
2331 portid_t port_id = res->port_id;
2332 struct rte_port *port;
2336 port = &ports[port_id];
2337 /** Check if the port is not started **/
2338 if (port->port_status != RTE_PORT_STOPPED) {
2339 printf("Please stop port %d first\n", port_id);
2343 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2344 printf("The invalid number of traffic class,"
2345 " only 4 or 8 allowed.\n");
2349 if (nb_fwd_lcores < res->num_tcs) {
2350 printf("nb_cores shouldn't be less than number of TCs.\n");
2353 if (!strncmp(res->pfc_en, "on", 2))
2358 /* DCB in VT mode */
2359 if (!strncmp(res->vt_en, "on", 2))
2360 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2361 (enum rte_eth_nb_tcs)res->num_tcs,
2364 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2365 (enum rte_eth_nb_tcs)res->num_tcs,
2370 printf("Cannot initialize network ports.\n");
2374 cmd_reconfig_device_queue(port_id, 1, 1);
2377 cmdline_parse_token_string_t cmd_config_dcb_port =
2378 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2379 cmdline_parse_token_string_t cmd_config_dcb_config =
2380 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2381 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2382 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2383 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2384 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2385 cmdline_parse_token_string_t cmd_config_dcb_vt =
2386 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2387 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2388 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2389 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2390 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2391 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2392 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2393 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2394 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2396 cmdline_parse_inst_t cmd_config_dcb = {
2397 .f = cmd_config_dcb_parsed,
2399 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2401 (void *)&cmd_config_dcb_port,
2402 (void *)&cmd_config_dcb_config,
2403 (void *)&cmd_config_dcb_port_id,
2404 (void *)&cmd_config_dcb_dcb,
2405 (void *)&cmd_config_dcb_vt,
2406 (void *)&cmd_config_dcb_vt_en,
2407 (void *)&cmd_config_dcb_num_tcs,
2408 (void *)&cmd_config_dcb_pfc,
2409 (void *)&cmd_config_dcb_pfc_en,
2414 /* *** configure number of packets per burst *** */
2415 struct cmd_config_burst {
2416 cmdline_fixed_string_t port;
2417 cmdline_fixed_string_t keyword;
2418 cmdline_fixed_string_t all;
2419 cmdline_fixed_string_t name;
2424 cmd_config_burst_parsed(void *parsed_result,
2425 __attribute__((unused)) struct cmdline *cl,
2426 __attribute__((unused)) void *data)
2428 struct cmd_config_burst *res = parsed_result;
2430 if (!all_ports_stopped()) {
2431 printf("Please stop all ports first\n");
2435 if (!strcmp(res->name, "burst")) {
2436 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2437 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2440 nb_pkt_per_burst = res->value;
2442 printf("Unknown parameter\n");
2448 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2451 cmdline_parse_token_string_t cmd_config_burst_port =
2452 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2453 cmdline_parse_token_string_t cmd_config_burst_keyword =
2454 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2455 cmdline_parse_token_string_t cmd_config_burst_all =
2456 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2457 cmdline_parse_token_string_t cmd_config_burst_name =
2458 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2459 cmdline_parse_token_num_t cmd_config_burst_value =
2460 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2462 cmdline_parse_inst_t cmd_config_burst = {
2463 .f = cmd_config_burst_parsed,
2465 .help_str = "port config all burst <value>",
2467 (void *)&cmd_config_burst_port,
2468 (void *)&cmd_config_burst_keyword,
2469 (void *)&cmd_config_burst_all,
2470 (void *)&cmd_config_burst_name,
2471 (void *)&cmd_config_burst_value,
2476 /* *** configure rx/tx queues *** */
2477 struct cmd_config_thresh {
2478 cmdline_fixed_string_t port;
2479 cmdline_fixed_string_t keyword;
2480 cmdline_fixed_string_t all;
2481 cmdline_fixed_string_t name;
2486 cmd_config_thresh_parsed(void *parsed_result,
2487 __attribute__((unused)) struct cmdline *cl,
2488 __attribute__((unused)) void *data)
2490 struct cmd_config_thresh *res = parsed_result;
2492 if (!all_ports_stopped()) {
2493 printf("Please stop all ports first\n");
2497 if (!strcmp(res->name, "txpt"))
2498 tx_pthresh = res->value;
2499 else if(!strcmp(res->name, "txht"))
2500 tx_hthresh = res->value;
2501 else if(!strcmp(res->name, "txwt"))
2502 tx_wthresh = res->value;
2503 else if(!strcmp(res->name, "rxpt"))
2504 rx_pthresh = res->value;
2505 else if(!strcmp(res->name, "rxht"))
2506 rx_hthresh = res->value;
2507 else if(!strcmp(res->name, "rxwt"))
2508 rx_wthresh = res->value;
2510 printf("Unknown parameter\n");
2516 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2519 cmdline_parse_token_string_t cmd_config_thresh_port =
2520 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2521 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2522 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2523 cmdline_parse_token_string_t cmd_config_thresh_all =
2524 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2525 cmdline_parse_token_string_t cmd_config_thresh_name =
2526 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2527 "txpt#txht#txwt#rxpt#rxht#rxwt");
2528 cmdline_parse_token_num_t cmd_config_thresh_value =
2529 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2531 cmdline_parse_inst_t cmd_config_thresh = {
2532 .f = cmd_config_thresh_parsed,
2534 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2536 (void *)&cmd_config_thresh_port,
2537 (void *)&cmd_config_thresh_keyword,
2538 (void *)&cmd_config_thresh_all,
2539 (void *)&cmd_config_thresh_name,
2540 (void *)&cmd_config_thresh_value,
2545 /* *** configure free/rs threshold *** */
2546 struct cmd_config_threshold {
2547 cmdline_fixed_string_t port;
2548 cmdline_fixed_string_t keyword;
2549 cmdline_fixed_string_t all;
2550 cmdline_fixed_string_t name;
2555 cmd_config_threshold_parsed(void *parsed_result,
2556 __attribute__((unused)) struct cmdline *cl,
2557 __attribute__((unused)) void *data)
2559 struct cmd_config_threshold *res = parsed_result;
2561 if (!all_ports_stopped()) {
2562 printf("Please stop all ports first\n");
2566 if (!strcmp(res->name, "txfreet"))
2567 tx_free_thresh = res->value;
2568 else if (!strcmp(res->name, "txrst"))
2569 tx_rs_thresh = res->value;
2570 else if (!strcmp(res->name, "rxfreet"))
2571 rx_free_thresh = res->value;
2573 printf("Unknown parameter\n");
2579 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2582 cmdline_parse_token_string_t cmd_config_threshold_port =
2583 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2584 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2585 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2587 cmdline_parse_token_string_t cmd_config_threshold_all =
2588 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2589 cmdline_parse_token_string_t cmd_config_threshold_name =
2590 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2591 "txfreet#txrst#rxfreet");
2592 cmdline_parse_token_num_t cmd_config_threshold_value =
2593 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2595 cmdline_parse_inst_t cmd_config_threshold = {
2596 .f = cmd_config_threshold_parsed,
2598 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2600 (void *)&cmd_config_threshold_port,
2601 (void *)&cmd_config_threshold_keyword,
2602 (void *)&cmd_config_threshold_all,
2603 (void *)&cmd_config_threshold_name,
2604 (void *)&cmd_config_threshold_value,
2610 struct cmd_stop_result {
2611 cmdline_fixed_string_t stop;
2614 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2615 __attribute__((unused)) struct cmdline *cl,
2616 __attribute__((unused)) void *data)
2618 stop_packet_forwarding();
2621 cmdline_parse_token_string_t cmd_stop_stop =
2622 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2624 cmdline_parse_inst_t cmd_stop = {
2625 .f = cmd_stop_parsed,
2627 .help_str = "stop: Stop packet forwarding",
2629 (void *)&cmd_stop_stop,
2634 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2637 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2638 unsigned int *parsed_items, int check_unique_values)
2640 unsigned int nb_item;
2648 * First parse all items in the list and store their value.
2653 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2655 if ((c >= '0') && (c <= '9')) {
2656 value = (unsigned int) (value * 10 + (c - '0'));
2661 printf("character %c is not a decimal digit\n", c);
2665 printf("No valid value before comma\n");
2668 if (nb_item < max_items) {
2669 parsed_items[nb_item] = value;
2675 if (nb_item >= max_items) {
2676 printf("Number of %s = %u > %u (maximum items)\n",
2677 item_name, nb_item + 1, max_items);
2680 parsed_items[nb_item++] = value;
2681 if (! check_unique_values)
2685 * Then, check that all values in the list are differents.
2686 * No optimization here...
2688 for (i = 0; i < nb_item; i++) {
2689 for (j = i + 1; j < nb_item; j++) {
2690 if (parsed_items[j] == parsed_items[i]) {
2691 printf("duplicated %s %u at index %u and %u\n",
2692 item_name, parsed_items[i], i, j);
2700 struct cmd_set_list_result {
2701 cmdline_fixed_string_t cmd_keyword;
2702 cmdline_fixed_string_t list_name;
2703 cmdline_fixed_string_t list_of_items;
2706 static void cmd_set_list_parsed(void *parsed_result,
2707 __attribute__((unused)) struct cmdline *cl,
2708 __attribute__((unused)) void *data)
2710 struct cmd_set_list_result *res;
2712 unsigned int lcorelist[RTE_MAX_LCORE];
2713 unsigned int portlist[RTE_MAX_ETHPORTS];
2715 unsigned int nb_item;
2717 if (test_done == 0) {
2718 printf("Please stop forwarding first\n");
2722 res = parsed_result;
2723 if (!strcmp(res->list_name, "corelist")) {
2724 nb_item = parse_item_list(res->list_of_items, "core",
2726 parsed_items.lcorelist, 1);
2728 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2733 if (!strcmp(res->list_name, "portlist")) {
2734 nb_item = parse_item_list(res->list_of_items, "port",
2736 parsed_items.portlist, 1);
2738 set_fwd_ports_list(parsed_items.portlist, nb_item);
2744 cmdline_parse_token_string_t cmd_set_list_keyword =
2745 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2747 cmdline_parse_token_string_t cmd_set_list_name =
2748 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2749 "corelist#portlist");
2750 cmdline_parse_token_string_t cmd_set_list_of_items =
2751 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2754 cmdline_parse_inst_t cmd_set_fwd_list = {
2755 .f = cmd_set_list_parsed,
2757 .help_str = "set corelist|portlist <list0[,list1]*>",
2759 (void *)&cmd_set_list_keyword,
2760 (void *)&cmd_set_list_name,
2761 (void *)&cmd_set_list_of_items,
2766 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2768 struct cmd_setmask_result {
2769 cmdline_fixed_string_t set;
2770 cmdline_fixed_string_t mask;
2774 static void cmd_set_mask_parsed(void *parsed_result,
2775 __attribute__((unused)) struct cmdline *cl,
2776 __attribute__((unused)) void *data)
2778 struct cmd_setmask_result *res = parsed_result;
2780 if (test_done == 0) {
2781 printf("Please stop forwarding first\n");
2784 if (!strcmp(res->mask, "coremask")) {
2785 set_fwd_lcores_mask(res->hexavalue);
2787 } else if (!strcmp(res->mask, "portmask")) {
2788 set_fwd_ports_mask(res->hexavalue);
2793 cmdline_parse_token_string_t cmd_setmask_set =
2794 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2795 cmdline_parse_token_string_t cmd_setmask_mask =
2796 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2797 "coremask#portmask");
2798 cmdline_parse_token_num_t cmd_setmask_value =
2799 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2801 cmdline_parse_inst_t cmd_set_fwd_mask = {
2802 .f = cmd_set_mask_parsed,
2804 .help_str = "set coremask|portmask <hexadecimal value>",
2806 (void *)&cmd_setmask_set,
2807 (void *)&cmd_setmask_mask,
2808 (void *)&cmd_setmask_value,
2814 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2816 struct cmd_set_result {
2817 cmdline_fixed_string_t set;
2818 cmdline_fixed_string_t what;
2822 static void cmd_set_parsed(void *parsed_result,
2823 __attribute__((unused)) struct cmdline *cl,
2824 __attribute__((unused)) void *data)
2826 struct cmd_set_result *res = parsed_result;
2827 if (!strcmp(res->what, "nbport")) {
2828 set_fwd_ports_number(res->value);
2830 } else if (!strcmp(res->what, "nbcore")) {
2831 set_fwd_lcores_number(res->value);
2833 } else if (!strcmp(res->what, "burst"))
2834 set_nb_pkt_per_burst(res->value);
2835 else if (!strcmp(res->what, "verbose"))
2836 set_verbose_level(res->value);
2839 cmdline_parse_token_string_t cmd_set_set =
2840 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2841 cmdline_parse_token_string_t cmd_set_what =
2842 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2843 "nbport#nbcore#burst#verbose");
2844 cmdline_parse_token_num_t cmd_set_value =
2845 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2847 cmdline_parse_inst_t cmd_set_numbers = {
2848 .f = cmd_set_parsed,
2850 .help_str = "set nbport|nbcore|burst|verbose <value>",
2852 (void *)&cmd_set_set,
2853 (void *)&cmd_set_what,
2854 (void *)&cmd_set_value,
2859 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2861 struct cmd_set_txpkts_result {
2862 cmdline_fixed_string_t cmd_keyword;
2863 cmdline_fixed_string_t txpkts;
2864 cmdline_fixed_string_t seg_lengths;
2868 cmd_set_txpkts_parsed(void *parsed_result,
2869 __attribute__((unused)) struct cmdline *cl,
2870 __attribute__((unused)) void *data)
2872 struct cmd_set_txpkts_result *res;
2873 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2874 unsigned int nb_segs;
2876 res = parsed_result;
2877 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2878 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2880 set_tx_pkt_segments(seg_lengths, nb_segs);
2883 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2884 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2885 cmd_keyword, "set");
2886 cmdline_parse_token_string_t cmd_set_txpkts_name =
2887 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2889 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2890 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2893 cmdline_parse_inst_t cmd_set_txpkts = {
2894 .f = cmd_set_txpkts_parsed,
2896 .help_str = "set txpkts <len0[,len1]*>",
2898 (void *)&cmd_set_txpkts_keyword,
2899 (void *)&cmd_set_txpkts_name,
2900 (void *)&cmd_set_txpkts_lengths,
2905 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2907 struct cmd_set_txsplit_result {
2908 cmdline_fixed_string_t cmd_keyword;
2909 cmdline_fixed_string_t txsplit;
2910 cmdline_fixed_string_t mode;
2914 cmd_set_txsplit_parsed(void *parsed_result,
2915 __attribute__((unused)) struct cmdline *cl,
2916 __attribute__((unused)) void *data)
2918 struct cmd_set_txsplit_result *res;
2920 res = parsed_result;
2921 set_tx_pkt_split(res->mode);
2924 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2925 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2926 cmd_keyword, "set");
2927 cmdline_parse_token_string_t cmd_set_txsplit_name =
2928 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2929 txsplit, "txsplit");
2930 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2931 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2934 cmdline_parse_inst_t cmd_set_txsplit = {
2935 .f = cmd_set_txsplit_parsed,
2937 .help_str = "set txsplit on|off|rand",
2939 (void *)&cmd_set_txsplit_keyword,
2940 (void *)&cmd_set_txsplit_name,
2941 (void *)&cmd_set_txsplit_mode,
2946 /* *** CONFIG TX QUEUE FLAGS *** */
2948 struct cmd_config_txqflags_result {
2949 cmdline_fixed_string_t port;
2950 cmdline_fixed_string_t config;
2951 cmdline_fixed_string_t all;
2952 cmdline_fixed_string_t what;
2956 static void cmd_config_txqflags_parsed(void *parsed_result,
2957 __attribute__((unused)) struct cmdline *cl,
2958 __attribute__((unused)) void *data)
2960 struct cmd_config_txqflags_result *res = parsed_result;
2962 if (!all_ports_stopped()) {
2963 printf("Please stop all ports first\n");
2967 if (strcmp(res->what, "txqflags")) {
2968 printf("Unknown parameter\n");
2972 if (res->hexvalue >= 0) {
2973 txq_flags = res->hexvalue;
2975 printf("txqflags must be >= 0\n");
2981 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2984 cmdline_parse_token_string_t cmd_config_txqflags_port =
2985 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2987 cmdline_parse_token_string_t cmd_config_txqflags_config =
2988 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2990 cmdline_parse_token_string_t cmd_config_txqflags_all =
2991 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2993 cmdline_parse_token_string_t cmd_config_txqflags_what =
2994 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2996 cmdline_parse_token_num_t cmd_config_txqflags_value =
2997 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
3000 cmdline_parse_inst_t cmd_config_txqflags = {
3001 .f = cmd_config_txqflags_parsed,
3003 .help_str = "port config all txqflags <value>",
3005 (void *)&cmd_config_txqflags_port,
3006 (void *)&cmd_config_txqflags_config,
3007 (void *)&cmd_config_txqflags_all,
3008 (void *)&cmd_config_txqflags_what,
3009 (void *)&cmd_config_txqflags_value,
3014 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3015 struct cmd_rx_vlan_filter_all_result {
3016 cmdline_fixed_string_t rx_vlan;
3017 cmdline_fixed_string_t what;
3018 cmdline_fixed_string_t all;
3023 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3024 __attribute__((unused)) struct cmdline *cl,
3025 __attribute__((unused)) void *data)
3027 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3029 if (!strcmp(res->what, "add"))
3030 rx_vlan_all_filter_set(res->port_id, 1);
3032 rx_vlan_all_filter_set(res->port_id, 0);
3035 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3036 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3037 rx_vlan, "rx_vlan");
3038 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3039 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3041 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3042 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3044 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3045 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3048 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3049 .f = cmd_rx_vlan_filter_all_parsed,
3051 .help_str = "rx_vlan add|rm all <port_id>: "
3052 "Add/Remove all identifiers to/from the set of VLAN "
3053 "identifiers filtered by a port",
3055 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3056 (void *)&cmd_rx_vlan_filter_all_what,
3057 (void *)&cmd_rx_vlan_filter_all_all,
3058 (void *)&cmd_rx_vlan_filter_all_portid,
3063 /* *** VLAN OFFLOAD SET ON A PORT *** */
3064 struct cmd_vlan_offload_result {
3065 cmdline_fixed_string_t vlan;
3066 cmdline_fixed_string_t set;
3067 cmdline_fixed_string_t vlan_type;
3068 cmdline_fixed_string_t what;
3069 cmdline_fixed_string_t on;
3070 cmdline_fixed_string_t port_id;
3074 cmd_vlan_offload_parsed(void *parsed_result,
3075 __attribute__((unused)) struct cmdline *cl,
3076 __attribute__((unused)) void *data)
3079 struct cmd_vlan_offload_result *res = parsed_result;
3082 portid_t port_id = 0;
3086 len = strnlen(str, STR_TOKEN_SIZE);
3088 /* Get port_id first */
3096 tmp = strtoul(str, NULL, 0);
3097 /* If port_id greater that what portid_t can represent, return */
3098 if(tmp >= RTE_MAX_ETHPORTS)
3100 port_id = (portid_t)tmp;
3102 if (!strcmp(res->on, "on"))
3107 if (!strcmp(res->what, "strip"))
3108 rx_vlan_strip_set(port_id, on);
3109 else if(!strcmp(res->what, "stripq")){
3110 uint16_t queue_id = 0;
3112 /* No queue_id, return */
3114 printf("must specify (port,queue_id)\n");
3117 tmp = strtoul(str + i + 1, NULL, 0);
3118 /* If queue_id greater that what 16-bits can represent, return */
3122 queue_id = (uint16_t)tmp;
3123 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3125 else if (!strcmp(res->what, "filter"))
3126 rx_vlan_filter_set(port_id, on);
3128 vlan_extend_set(port_id, on);
3133 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3134 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3136 cmdline_parse_token_string_t cmd_vlan_offload_set =
3137 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3139 cmdline_parse_token_string_t cmd_vlan_offload_what =
3140 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3141 what, "strip#filter#qinq#stripq");
3142 cmdline_parse_token_string_t cmd_vlan_offload_on =
3143 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3145 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3146 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3149 cmdline_parse_inst_t cmd_vlan_offload = {
3150 .f = cmd_vlan_offload_parsed,
3152 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3153 "<port_id[,queue_id]>: "
3154 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3156 (void *)&cmd_vlan_offload_vlan,
3157 (void *)&cmd_vlan_offload_set,
3158 (void *)&cmd_vlan_offload_what,
3159 (void *)&cmd_vlan_offload_on,
3160 (void *)&cmd_vlan_offload_portid,
3165 /* *** VLAN TPID SET ON A PORT *** */
3166 struct cmd_vlan_tpid_result {
3167 cmdline_fixed_string_t vlan;
3168 cmdline_fixed_string_t set;
3169 cmdline_fixed_string_t vlan_type;
3170 cmdline_fixed_string_t what;
3176 cmd_vlan_tpid_parsed(void *parsed_result,
3177 __attribute__((unused)) struct cmdline *cl,
3178 __attribute__((unused)) void *data)
3180 struct cmd_vlan_tpid_result *res = parsed_result;
3181 enum rte_vlan_type vlan_type;
3183 if (!strcmp(res->vlan_type, "inner"))
3184 vlan_type = ETH_VLAN_TYPE_INNER;
3185 else if (!strcmp(res->vlan_type, "outer"))
3186 vlan_type = ETH_VLAN_TYPE_OUTER;
3188 printf("Unknown vlan type\n");
3191 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3194 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3195 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3197 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3198 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3200 cmdline_parse_token_string_t cmd_vlan_type =
3201 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3202 vlan_type, "inner#outer");
3203 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3204 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3206 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3207 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3209 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3210 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3213 cmdline_parse_inst_t cmd_vlan_tpid = {
3214 .f = cmd_vlan_tpid_parsed,
3216 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3217 "Set the VLAN Ether type",
3219 (void *)&cmd_vlan_tpid_vlan,
3220 (void *)&cmd_vlan_tpid_set,
3221 (void *)&cmd_vlan_type,
3222 (void *)&cmd_vlan_tpid_what,
3223 (void *)&cmd_vlan_tpid_tpid,
3224 (void *)&cmd_vlan_tpid_portid,
3229 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3230 struct cmd_rx_vlan_filter_result {
3231 cmdline_fixed_string_t rx_vlan;
3232 cmdline_fixed_string_t what;
3238 cmd_rx_vlan_filter_parsed(void *parsed_result,
3239 __attribute__((unused)) struct cmdline *cl,
3240 __attribute__((unused)) void *data)
3242 struct cmd_rx_vlan_filter_result *res = parsed_result;
3244 if (!strcmp(res->what, "add"))
3245 rx_vft_set(res->port_id, res->vlan_id, 1);
3247 rx_vft_set(res->port_id, res->vlan_id, 0);
3250 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3251 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3252 rx_vlan, "rx_vlan");
3253 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3254 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3256 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3257 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3259 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3260 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3263 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3264 .f = cmd_rx_vlan_filter_parsed,
3266 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3267 "Add/Remove a VLAN identifier to/from the set of VLAN "
3268 "identifiers filtered by a port",
3270 (void *)&cmd_rx_vlan_filter_rx_vlan,
3271 (void *)&cmd_rx_vlan_filter_what,
3272 (void *)&cmd_rx_vlan_filter_vlanid,
3273 (void *)&cmd_rx_vlan_filter_portid,
3278 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3279 struct cmd_tx_vlan_set_result {
3280 cmdline_fixed_string_t tx_vlan;
3281 cmdline_fixed_string_t set;
3287 cmd_tx_vlan_set_parsed(void *parsed_result,
3288 __attribute__((unused)) struct cmdline *cl,
3289 __attribute__((unused)) void *data)
3291 struct cmd_tx_vlan_set_result *res = parsed_result;
3293 tx_vlan_set(res->port_id, res->vlan_id);
3296 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3297 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3298 tx_vlan, "tx_vlan");
3299 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3300 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3302 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3303 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3305 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3306 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3309 cmdline_parse_inst_t cmd_tx_vlan_set = {
3310 .f = cmd_tx_vlan_set_parsed,
3312 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3313 "Enable hardware insertion of a single VLAN header "
3314 "with a given TAG Identifier in packets sent on a port",
3316 (void *)&cmd_tx_vlan_set_tx_vlan,
3317 (void *)&cmd_tx_vlan_set_set,
3318 (void *)&cmd_tx_vlan_set_portid,
3319 (void *)&cmd_tx_vlan_set_vlanid,
3324 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3325 struct cmd_tx_vlan_set_qinq_result {
3326 cmdline_fixed_string_t tx_vlan;
3327 cmdline_fixed_string_t set;
3330 uint16_t vlan_id_outer;
3334 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3335 __attribute__((unused)) struct cmdline *cl,
3336 __attribute__((unused)) void *data)
3338 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3340 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3343 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3344 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3345 tx_vlan, "tx_vlan");
3346 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3347 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3349 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3350 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3352 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3353 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3355 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3356 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3357 vlan_id_outer, UINT16);
3359 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3360 .f = cmd_tx_vlan_set_qinq_parsed,
3362 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3363 "Enable hardware insertion of double VLAN header "
3364 "with given TAG Identifiers in packets sent on a port",
3366 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3367 (void *)&cmd_tx_vlan_set_qinq_set,
3368 (void *)&cmd_tx_vlan_set_qinq_portid,
3369 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3370 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3375 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3376 struct cmd_tx_vlan_set_pvid_result {
3377 cmdline_fixed_string_t tx_vlan;
3378 cmdline_fixed_string_t set;
3379 cmdline_fixed_string_t pvid;
3382 cmdline_fixed_string_t mode;
3386 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3387 __attribute__((unused)) struct cmdline *cl,
3388 __attribute__((unused)) void *data)
3390 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3392 if (strcmp(res->mode, "on") == 0)
3393 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3395 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3398 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3399 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3400 tx_vlan, "tx_vlan");
3401 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3402 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3404 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3405 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3407 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3408 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3410 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3411 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3413 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3414 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3417 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3418 .f = cmd_tx_vlan_set_pvid_parsed,
3420 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3422 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3423 (void *)&cmd_tx_vlan_set_pvid_set,
3424 (void *)&cmd_tx_vlan_set_pvid_pvid,
3425 (void *)&cmd_tx_vlan_set_pvid_port_id,
3426 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3427 (void *)&cmd_tx_vlan_set_pvid_mode,
3432 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3433 struct cmd_tx_vlan_reset_result {
3434 cmdline_fixed_string_t tx_vlan;
3435 cmdline_fixed_string_t reset;
3440 cmd_tx_vlan_reset_parsed(void *parsed_result,
3441 __attribute__((unused)) struct cmdline *cl,
3442 __attribute__((unused)) void *data)
3444 struct cmd_tx_vlan_reset_result *res = parsed_result;
3446 tx_vlan_reset(res->port_id);
3449 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3450 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3451 tx_vlan, "tx_vlan");
3452 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3453 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3455 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3456 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3459 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3460 .f = cmd_tx_vlan_reset_parsed,
3462 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3463 "VLAN header in packets sent on a port",
3465 (void *)&cmd_tx_vlan_reset_tx_vlan,
3466 (void *)&cmd_tx_vlan_reset_reset,
3467 (void *)&cmd_tx_vlan_reset_portid,
3473 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3474 struct cmd_csum_result {
3475 cmdline_fixed_string_t csum;
3476 cmdline_fixed_string_t mode;
3477 cmdline_fixed_string_t proto;
3478 cmdline_fixed_string_t hwsw;
3483 csum_show(int port_id)
3485 struct rte_eth_dev_info dev_info;
3488 ol_flags = ports[port_id].tx_ol_flags;
3489 printf("Parse tunnel is %s\n",
3490 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3491 printf("IP checksum offload is %s\n",
3492 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3493 printf("UDP checksum offload is %s\n",
3494 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3495 printf("TCP checksum offload is %s\n",
3496 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3497 printf("SCTP checksum offload is %s\n",
3498 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3499 printf("Outer-Ip checksum offload is %s\n",
3500 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3502 /* display warnings if configuration is not supported by the NIC */
3503 rte_eth_dev_info_get(port_id, &dev_info);
3504 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3505 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3506 printf("Warning: hardware IP checksum enabled but not "
3507 "supported by port %d\n", port_id);
3509 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3510 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3511 printf("Warning: hardware UDP checksum enabled but not "
3512 "supported by port %d\n", port_id);
3514 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3515 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3516 printf("Warning: hardware TCP checksum enabled but not "
3517 "supported by port %d\n", port_id);
3519 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3520 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3521 printf("Warning: hardware SCTP checksum enabled but not "
3522 "supported by port %d\n", port_id);
3524 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3525 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3526 printf("Warning: hardware outer IP checksum enabled but not "
3527 "supported by port %d\n", port_id);
3532 cmd_csum_parsed(void *parsed_result,
3533 __attribute__((unused)) struct cmdline *cl,
3534 __attribute__((unused)) void *data)
3536 struct cmd_csum_result *res = parsed_result;
3540 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3541 printf("invalid port %d\n", res->port_id);
3545 if (!strcmp(res->mode, "set")) {
3547 if (!strcmp(res->hwsw, "hw"))
3550 if (!strcmp(res->proto, "ip")) {
3551 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3552 } else if (!strcmp(res->proto, "udp")) {
3553 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3554 } else if (!strcmp(res->proto, "tcp")) {
3555 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3556 } else if (!strcmp(res->proto, "sctp")) {
3557 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3558 } else if (!strcmp(res->proto, "outer-ip")) {
3559 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3563 ports[res->port_id].tx_ol_flags |= mask;
3565 ports[res->port_id].tx_ol_flags &= (~mask);
3567 csum_show(res->port_id);
3570 cmdline_parse_token_string_t cmd_csum_csum =
3571 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3573 cmdline_parse_token_string_t cmd_csum_mode =
3574 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3576 cmdline_parse_token_string_t cmd_csum_proto =
3577 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3578 proto, "ip#tcp#udp#sctp#outer-ip");
3579 cmdline_parse_token_string_t cmd_csum_hwsw =
3580 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3582 cmdline_parse_token_num_t cmd_csum_portid =
3583 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3586 cmdline_parse_inst_t cmd_csum_set = {
3587 .f = cmd_csum_parsed,
3589 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3590 "Enable/Disable hardware calculation of L3/L4 checksum when "
3591 "using csum forward engine",
3593 (void *)&cmd_csum_csum,
3594 (void *)&cmd_csum_mode,
3595 (void *)&cmd_csum_proto,
3596 (void *)&cmd_csum_hwsw,
3597 (void *)&cmd_csum_portid,
3602 cmdline_parse_token_string_t cmd_csum_mode_show =
3603 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3606 cmdline_parse_inst_t cmd_csum_show = {
3607 .f = cmd_csum_parsed,
3609 .help_str = "csum show <port_id>: Show checksum offload configuration",
3611 (void *)&cmd_csum_csum,
3612 (void *)&cmd_csum_mode_show,
3613 (void *)&cmd_csum_portid,
3618 /* Enable/disable tunnel parsing */
3619 struct cmd_csum_tunnel_result {
3620 cmdline_fixed_string_t csum;
3621 cmdline_fixed_string_t parse;
3622 cmdline_fixed_string_t onoff;
3627 cmd_csum_tunnel_parsed(void *parsed_result,
3628 __attribute__((unused)) struct cmdline *cl,
3629 __attribute__((unused)) void *data)
3631 struct cmd_csum_tunnel_result *res = parsed_result;
3633 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3636 if (!strcmp(res->onoff, "on"))
3637 ports[res->port_id].tx_ol_flags |=
3638 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3640 ports[res->port_id].tx_ol_flags &=
3641 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3643 csum_show(res->port_id);
3646 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3647 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3649 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3650 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3651 parse, "parse_tunnel");
3652 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3653 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3655 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3656 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3659 cmdline_parse_inst_t cmd_csum_tunnel = {
3660 .f = cmd_csum_tunnel_parsed,
3662 .help_str = "csum parse_tunnel on|off <port_id>: "
3663 "Enable/Disable parsing of tunnels for csum engine",
3665 (void *)&cmd_csum_tunnel_csum,
3666 (void *)&cmd_csum_tunnel_parse,
3667 (void *)&cmd_csum_tunnel_onoff,
3668 (void *)&cmd_csum_tunnel_portid,
3673 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3674 struct cmd_tso_set_result {
3675 cmdline_fixed_string_t tso;
3676 cmdline_fixed_string_t mode;
3682 cmd_tso_set_parsed(void *parsed_result,
3683 __attribute__((unused)) struct cmdline *cl,
3684 __attribute__((unused)) void *data)
3686 struct cmd_tso_set_result *res = parsed_result;
3687 struct rte_eth_dev_info dev_info;
3689 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3692 if (!strcmp(res->mode, "set"))
3693 ports[res->port_id].tso_segsz = res->tso_segsz;
3695 if (ports[res->port_id].tso_segsz == 0)
3696 printf("TSO for non-tunneled packets is disabled\n");
3698 printf("TSO segment size for non-tunneled packets is %d\n",
3699 ports[res->port_id].tso_segsz);
3701 /* display warnings if configuration is not supported by the NIC */
3702 rte_eth_dev_info_get(res->port_id, &dev_info);
3703 if ((ports[res->port_id].tso_segsz != 0) &&
3704 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3705 printf("Warning: TSO enabled but not "
3706 "supported by port %d\n", res->port_id);
3710 cmdline_parse_token_string_t cmd_tso_set_tso =
3711 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3713 cmdline_parse_token_string_t cmd_tso_set_mode =
3714 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3716 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3717 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3719 cmdline_parse_token_num_t cmd_tso_set_portid =
3720 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3723 cmdline_parse_inst_t cmd_tso_set = {
3724 .f = cmd_tso_set_parsed,
3726 .help_str = "tso set <tso_segsz> <port_id>: "
3727 "Set TSO segment size of non-tunneled packets for csum engine "
3730 (void *)&cmd_tso_set_tso,
3731 (void *)&cmd_tso_set_mode,
3732 (void *)&cmd_tso_set_tso_segsz,
3733 (void *)&cmd_tso_set_portid,
3738 cmdline_parse_token_string_t cmd_tso_show_mode =
3739 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3743 cmdline_parse_inst_t cmd_tso_show = {
3744 .f = cmd_tso_set_parsed,
3746 .help_str = "tso show <port_id>: "
3747 "Show TSO segment size of non-tunneled packets for csum engine",
3749 (void *)&cmd_tso_set_tso,
3750 (void *)&cmd_tso_show_mode,
3751 (void *)&cmd_tso_set_portid,
3756 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3757 struct cmd_tunnel_tso_set_result {
3758 cmdline_fixed_string_t tso;
3759 cmdline_fixed_string_t mode;
3765 check_tunnel_tso_nic_support(uint8_t port_id)
3767 struct rte_eth_dev_info dev_info;
3769 rte_eth_dev_info_get(port_id, &dev_info);
3770 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3771 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3772 "supported by port %d\n", port_id);
3773 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3774 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3775 "supported by port %d\n", port_id);
3776 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3777 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3778 "supported by port %d\n", port_id);
3779 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3780 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3781 "supported by port %d\n", port_id);
3785 cmd_tunnel_tso_set_parsed(void *parsed_result,
3786 __attribute__((unused)) struct cmdline *cl,
3787 __attribute__((unused)) void *data)
3789 struct cmd_tunnel_tso_set_result *res = parsed_result;
3791 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3794 if (!strcmp(res->mode, "set"))
3795 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3797 if (ports[res->port_id].tunnel_tso_segsz == 0)
3798 printf("TSO for tunneled packets is disabled\n");
3800 printf("TSO segment size for tunneled packets is %d\n",
3801 ports[res->port_id].tunnel_tso_segsz);
3803 /* Below conditions are needed to make it work:
3804 * (1) tunnel TSO is supported by the NIC;
3805 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3807 * (3) for tunneled pkts with outer L3 of IPv4,
3808 * "csum set outer-ip" must be set to hw, because after tso,
3809 * total_len of outer IP header is changed, and the checksum
3810 * of outer IP header calculated by sw should be wrong; that
3811 * is not necessary for IPv6 tunneled pkts because there's no
3812 * checksum in IP header anymore.
3814 check_tunnel_tso_nic_support(res->port_id);
3816 if (!(ports[res->port_id].tx_ol_flags &
3817 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3818 printf("Warning: csum parse_tunnel must be set "
3819 "so that tunneled packets are recognized\n");
3820 if (!(ports[res->port_id].tx_ol_flags &
3821 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3822 printf("Warning: csum set outer-ip must be set to hw "
3823 "if outer L3 is IPv4; not necessary for IPv6\n");
3827 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3828 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3830 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3831 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3833 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3834 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3836 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3837 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3840 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3841 .f = cmd_tunnel_tso_set_parsed,
3843 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3844 "Set TSO segment size of tunneled packets for csum engine "
3847 (void *)&cmd_tunnel_tso_set_tso,
3848 (void *)&cmd_tunnel_tso_set_mode,
3849 (void *)&cmd_tunnel_tso_set_tso_segsz,
3850 (void *)&cmd_tunnel_tso_set_portid,
3855 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3856 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3860 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3861 .f = cmd_tunnel_tso_set_parsed,
3863 .help_str = "tunnel_tso show <port_id> "
3864 "Show TSO segment size of tunneled packets for csum engine",
3866 (void *)&cmd_tunnel_tso_set_tso,
3867 (void *)&cmd_tunnel_tso_show_mode,
3868 (void *)&cmd_tunnel_tso_set_portid,
3873 /* *** SET GRO FOR A PORT *** */
3874 struct cmd_gro_enable_result {
3875 cmdline_fixed_string_t cmd_set;
3876 cmdline_fixed_string_t cmd_port;
3877 cmdline_fixed_string_t cmd_keyword;
3878 cmdline_fixed_string_t cmd_onoff;
3883 cmd_gro_enable_parsed(void *parsed_result,
3884 __attribute__((unused)) struct cmdline *cl,
3885 __attribute__((unused)) void *data)
3887 struct cmd_gro_enable_result *res;
3889 res = parsed_result;
3890 if (!strcmp(res->cmd_keyword, "gro"))
3891 setup_gro(res->cmd_onoff, res->cmd_pid);
3894 cmdline_parse_token_string_t cmd_gro_enable_set =
3895 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3897 cmdline_parse_token_string_t cmd_gro_enable_port =
3898 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3899 cmd_keyword, "port");
3900 cmdline_parse_token_num_t cmd_gro_enable_pid =
3901 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
3903 cmdline_parse_token_string_t cmd_gro_enable_keyword =
3904 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3905 cmd_keyword, "gro");
3906 cmdline_parse_token_string_t cmd_gro_enable_onoff =
3907 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3908 cmd_onoff, "on#off");
3910 cmdline_parse_inst_t cmd_gro_enable = {
3911 .f = cmd_gro_enable_parsed,
3913 .help_str = "set port <port_id> gro on|off",
3915 (void *)&cmd_gro_enable_set,
3916 (void *)&cmd_gro_enable_port,
3917 (void *)&cmd_gro_enable_pid,
3918 (void *)&cmd_gro_enable_keyword,
3919 (void *)&cmd_gro_enable_onoff,
3924 /* *** DISPLAY GRO CONFIGURATION *** */
3925 struct cmd_gro_show_result {
3926 cmdline_fixed_string_t cmd_show;
3927 cmdline_fixed_string_t cmd_port;
3928 cmdline_fixed_string_t cmd_keyword;
3933 cmd_gro_show_parsed(void *parsed_result,
3934 __attribute__((unused)) struct cmdline *cl,
3935 __attribute__((unused)) void *data)
3937 struct cmd_gro_show_result *res;
3939 res = parsed_result;
3940 if (!strcmp(res->cmd_keyword, "gro"))
3941 show_gro(res->cmd_pid);
3944 cmdline_parse_token_string_t cmd_gro_show_show =
3945 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
3947 cmdline_parse_token_string_t cmd_gro_show_port =
3948 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
3950 cmdline_parse_token_num_t cmd_gro_show_pid =
3951 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
3953 cmdline_parse_token_string_t cmd_gro_show_keyword =
3954 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
3955 cmd_keyword, "gro");
3957 cmdline_parse_inst_t cmd_gro_show = {
3958 .f = cmd_gro_show_parsed,
3960 .help_str = "show port <port_id> gro",
3962 (void *)&cmd_gro_show_show,
3963 (void *)&cmd_gro_show_port,
3964 (void *)&cmd_gro_show_pid,
3965 (void *)&cmd_gro_show_keyword,
3970 /* *** SET FLUSH CYCLES FOR GRO *** */
3971 struct cmd_gro_flush_result {
3972 cmdline_fixed_string_t cmd_set;
3973 cmdline_fixed_string_t cmd_keyword;
3974 cmdline_fixed_string_t cmd_flush;
3979 cmd_gro_flush_parsed(void *parsed_result,
3980 __attribute__((unused)) struct cmdline *cl,
3981 __attribute__((unused)) void *data)
3983 struct cmd_gro_flush_result *res;
3985 res = parsed_result;
3986 if ((!strcmp(res->cmd_keyword, "gro")) &&
3987 (!strcmp(res->cmd_flush, "flush")))
3988 setup_gro_flush_cycles(res->cmd_cycles);
3991 cmdline_parse_token_string_t cmd_gro_flush_set =
3992 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
3994 cmdline_parse_token_string_t cmd_gro_flush_keyword =
3995 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
3996 cmd_keyword, "gro");
3997 cmdline_parse_token_string_t cmd_gro_flush_flush =
3998 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
3999 cmd_flush, "flush");
4000 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4001 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4004 cmdline_parse_inst_t cmd_gro_flush = {
4005 .f = cmd_gro_flush_parsed,
4007 .help_str = "set gro flush <cycles>",
4009 (void *)&cmd_gro_flush_set,
4010 (void *)&cmd_gro_flush_keyword,
4011 (void *)&cmd_gro_flush_flush,
4012 (void *)&cmd_gro_flush_cycles,
4017 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4018 struct cmd_set_flush_rx {
4019 cmdline_fixed_string_t set;
4020 cmdline_fixed_string_t flush_rx;
4021 cmdline_fixed_string_t mode;
4025 cmd_set_flush_rx_parsed(void *parsed_result,
4026 __attribute__((unused)) struct cmdline *cl,
4027 __attribute__((unused)) void *data)
4029 struct cmd_set_flush_rx *res = parsed_result;
4030 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4033 cmdline_parse_token_string_t cmd_setflushrx_set =
4034 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4036 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4037 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4038 flush_rx, "flush_rx");
4039 cmdline_parse_token_string_t cmd_setflushrx_mode =
4040 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4044 cmdline_parse_inst_t cmd_set_flush_rx = {
4045 .f = cmd_set_flush_rx_parsed,
4046 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4049 (void *)&cmd_setflushrx_set,
4050 (void *)&cmd_setflushrx_flush_rx,
4051 (void *)&cmd_setflushrx_mode,
4056 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4057 struct cmd_set_link_check {
4058 cmdline_fixed_string_t set;
4059 cmdline_fixed_string_t link_check;
4060 cmdline_fixed_string_t mode;
4064 cmd_set_link_check_parsed(void *parsed_result,
4065 __attribute__((unused)) struct cmdline *cl,
4066 __attribute__((unused)) void *data)
4068 struct cmd_set_link_check *res = parsed_result;
4069 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4072 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4073 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4075 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4076 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4077 link_check, "link_check");
4078 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4079 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4083 cmdline_parse_inst_t cmd_set_link_check = {
4084 .f = cmd_set_link_check_parsed,
4085 .help_str = "set link_check on|off: Enable/Disable link status check "
4086 "when starting/stopping a port",
4089 (void *)&cmd_setlinkcheck_set,
4090 (void *)&cmd_setlinkcheck_link_check,
4091 (void *)&cmd_setlinkcheck_mode,
4096 /* *** SET NIC BYPASS MODE *** */
4097 struct cmd_set_bypass_mode_result {
4098 cmdline_fixed_string_t set;
4099 cmdline_fixed_string_t bypass;
4100 cmdline_fixed_string_t mode;
4101 cmdline_fixed_string_t value;
4106 cmd_set_bypass_mode_parsed(void *parsed_result,
4107 __attribute__((unused)) struct cmdline *cl,
4108 __attribute__((unused)) void *data)
4110 struct cmd_set_bypass_mode_result *res = parsed_result;
4111 portid_t port_id = res->port_id;
4112 int32_t rc = -EINVAL;
4114 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4115 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4117 if (!strcmp(res->value, "bypass"))
4118 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4119 else if (!strcmp(res->value, "isolate"))
4120 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4122 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4124 /* Set the bypass mode for the relevant port. */
4125 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4128 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4131 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4132 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4134 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4135 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4137 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4138 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4140 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4141 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4142 value, "normal#bypass#isolate");
4143 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4144 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4147 cmdline_parse_inst_t cmd_set_bypass_mode = {
4148 .f = cmd_set_bypass_mode_parsed,
4149 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4150 "Set the NIC bypass mode for port_id",
4153 (void *)&cmd_setbypass_mode_set,
4154 (void *)&cmd_setbypass_mode_bypass,
4155 (void *)&cmd_setbypass_mode_mode,
4156 (void *)&cmd_setbypass_mode_value,
4157 (void *)&cmd_setbypass_mode_port,
4162 /* *** SET NIC BYPASS EVENT *** */
4163 struct cmd_set_bypass_event_result {
4164 cmdline_fixed_string_t set;
4165 cmdline_fixed_string_t bypass;
4166 cmdline_fixed_string_t event;
4167 cmdline_fixed_string_t event_value;
4168 cmdline_fixed_string_t mode;
4169 cmdline_fixed_string_t mode_value;
4174 cmd_set_bypass_event_parsed(void *parsed_result,
4175 __attribute__((unused)) struct cmdline *cl,
4176 __attribute__((unused)) void *data)
4178 int32_t rc = -EINVAL;
4179 struct cmd_set_bypass_event_result *res = parsed_result;
4180 portid_t port_id = res->port_id;
4182 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4183 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4184 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4186 if (!strcmp(res->event_value, "timeout"))
4187 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4188 else if (!strcmp(res->event_value, "os_on"))
4189 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4190 else if (!strcmp(res->event_value, "os_off"))
4191 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4192 else if (!strcmp(res->event_value, "power_on"))
4193 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4194 else if (!strcmp(res->event_value, "power_off"))
4195 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4197 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4199 if (!strcmp(res->mode_value, "bypass"))
4200 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4201 else if (!strcmp(res->mode_value, "isolate"))
4202 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4204 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4206 /* Set the watchdog timeout. */
4207 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4210 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4211 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4215 printf("Failed to set timeout value %u "
4216 "for port %d, errto code: %d.\n",
4217 bypass_timeout, port_id, rc);
4221 /* Set the bypass event to transition to bypass mode. */
4222 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4227 printf("\t Failed to set bypass event for port = %d.\n",
4231 cmdline_parse_token_string_t cmd_setbypass_event_set =
4232 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4234 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4235 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4237 cmdline_parse_token_string_t cmd_setbypass_event_event =
4238 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4240 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4241 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4242 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4243 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4244 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4246 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4247 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4248 mode_value, "normal#bypass#isolate");
4249 cmdline_parse_token_num_t cmd_setbypass_event_port =
4250 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4253 cmdline_parse_inst_t cmd_set_bypass_event = {
4254 .f = cmd_set_bypass_event_parsed,
4255 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4256 "power_off mode normal|bypass|isolate <port_id>: "
4257 "Set the NIC bypass event mode for port_id",
4260 (void *)&cmd_setbypass_event_set,
4261 (void *)&cmd_setbypass_event_bypass,
4262 (void *)&cmd_setbypass_event_event,
4263 (void *)&cmd_setbypass_event_event_value,
4264 (void *)&cmd_setbypass_event_mode,
4265 (void *)&cmd_setbypass_event_mode_value,
4266 (void *)&cmd_setbypass_event_port,
4272 /* *** SET NIC BYPASS TIMEOUT *** */
4273 struct cmd_set_bypass_timeout_result {
4274 cmdline_fixed_string_t set;
4275 cmdline_fixed_string_t bypass;
4276 cmdline_fixed_string_t timeout;
4277 cmdline_fixed_string_t value;
4281 cmd_set_bypass_timeout_parsed(void *parsed_result,
4282 __attribute__((unused)) struct cmdline *cl,
4283 __attribute__((unused)) void *data)
4285 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4287 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4288 if (!strcmp(res->value, "1.5"))
4289 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4290 else if (!strcmp(res->value, "2"))
4291 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4292 else if (!strcmp(res->value, "3"))
4293 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4294 else if (!strcmp(res->value, "4"))
4295 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4296 else if (!strcmp(res->value, "8"))
4297 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4298 else if (!strcmp(res->value, "16"))
4299 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4300 else if (!strcmp(res->value, "32"))
4301 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4303 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4307 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4308 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4310 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4311 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4313 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4314 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4315 timeout, "timeout");
4316 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4317 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4318 value, "0#1.5#2#3#4#8#16#32");
4320 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4321 .f = cmd_set_bypass_timeout_parsed,
4322 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4323 "Set the NIC bypass watchdog timeout in seconds",
4326 (void *)&cmd_setbypass_timeout_set,
4327 (void *)&cmd_setbypass_timeout_bypass,
4328 (void *)&cmd_setbypass_timeout_timeout,
4329 (void *)&cmd_setbypass_timeout_value,
4334 /* *** SHOW NIC BYPASS MODE *** */
4335 struct cmd_show_bypass_config_result {
4336 cmdline_fixed_string_t show;
4337 cmdline_fixed_string_t bypass;
4338 cmdline_fixed_string_t config;
4343 cmd_show_bypass_config_parsed(void *parsed_result,
4344 __attribute__((unused)) struct cmdline *cl,
4345 __attribute__((unused)) void *data)
4347 struct cmd_show_bypass_config_result *res = parsed_result;
4348 portid_t port_id = res->port_id;
4350 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4351 uint32_t event_mode;
4352 uint32_t bypass_mode;
4353 uint32_t timeout = bypass_timeout;
4356 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4357 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4358 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4359 {"UNKNOWN", "normal", "bypass", "isolate"};
4360 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4367 int num_events = (sizeof events) / (sizeof events[0]);
4369 /* Display the bypass mode.*/
4370 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4371 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4375 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4376 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4378 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4381 /* Display the bypass timeout.*/
4382 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4383 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4385 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4387 /* Display the bypass events and associated modes. */
4388 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4390 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4391 printf("\tFailed to get bypass mode for event = %s\n",
4394 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4395 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4397 printf("\tbypass event: %-16s = %s\n", events[i],
4403 printf("\tFailed to get bypass configuration for port = %d\n",
4407 cmdline_parse_token_string_t cmd_showbypass_config_show =
4408 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4410 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4411 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4413 cmdline_parse_token_string_t cmd_showbypass_config_config =
4414 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4416 cmdline_parse_token_num_t cmd_showbypass_config_port =
4417 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4420 cmdline_parse_inst_t cmd_show_bypass_config = {
4421 .f = cmd_show_bypass_config_parsed,
4422 .help_str = "show bypass config <port_id>: "
4423 "Show the NIC bypass config for port_id",
4426 (void *)&cmd_showbypass_config_show,
4427 (void *)&cmd_showbypass_config_bypass,
4428 (void *)&cmd_showbypass_config_config,
4429 (void *)&cmd_showbypass_config_port,
4434 #ifdef RTE_LIBRTE_PMD_BOND
4435 /* *** SET BONDING MODE *** */
4436 struct cmd_set_bonding_mode_result {
4437 cmdline_fixed_string_t set;
4438 cmdline_fixed_string_t bonding;
4439 cmdline_fixed_string_t mode;
4444 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4445 __attribute__((unused)) struct cmdline *cl,
4446 __attribute__((unused)) void *data)
4448 struct cmd_set_bonding_mode_result *res = parsed_result;
4449 portid_t port_id = res->port_id;
4451 /* Set the bonding mode for the relevant port. */
4452 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4453 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4456 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4457 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4459 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4460 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4461 bonding, "bonding");
4462 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4463 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4465 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4466 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4468 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4469 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4472 cmdline_parse_inst_t cmd_set_bonding_mode = {
4473 .f = cmd_set_bonding_mode_parsed,
4474 .help_str = "set bonding mode <mode_value> <port_id>: "
4475 "Set the bonding mode for port_id",
4478 (void *) &cmd_setbonding_mode_set,
4479 (void *) &cmd_setbonding_mode_bonding,
4480 (void *) &cmd_setbonding_mode_mode,
4481 (void *) &cmd_setbonding_mode_value,
4482 (void *) &cmd_setbonding_mode_port,
4487 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4488 struct cmd_set_bonding_lacp_dedicated_queues_result {
4489 cmdline_fixed_string_t set;
4490 cmdline_fixed_string_t bonding;
4491 cmdline_fixed_string_t lacp;
4492 cmdline_fixed_string_t dedicated_queues;
4494 cmdline_fixed_string_t mode;
4497 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4498 __attribute__((unused)) struct cmdline *cl,
4499 __attribute__((unused)) void *data)
4501 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4502 portid_t port_id = res->port_id;
4503 struct rte_port *port;
4505 port = &ports[port_id];
4507 /** Check if the port is not started **/
4508 if (port->port_status != RTE_PORT_STOPPED) {
4509 printf("Please stop port %d first\n", port_id);
4513 if (!strcmp(res->mode, "enable")) {
4514 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4515 printf("Dedicate queues for LACP control packets"
4518 printf("Enabling dedicate queues for LACP control "
4519 "packets on port %d failed\n", port_id);
4520 } else if (!strcmp(res->mode, "disable")) {
4521 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4522 printf("Dedicated queues for LACP control packets "
4525 printf("Disabling dedicated queues for LACP control "
4526 "traffic on port %d failed\n", port_id);
4530 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4531 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4533 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4534 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4535 bonding, "bonding");
4536 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4537 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4539 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4540 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4541 dedicated_queues, "dedicated_queues");
4542 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4543 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4545 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4546 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4547 mode, "enable#disable");
4549 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4550 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4551 .help_str = "set bonding lacp dedicated_queues <port_id> "
4553 "Enable/disable dedicated queues for LACP control traffic for port_id",
4556 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4557 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4558 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4559 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4560 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4561 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4566 /* *** SET BALANCE XMIT POLICY *** */
4567 struct cmd_set_bonding_balance_xmit_policy_result {
4568 cmdline_fixed_string_t set;
4569 cmdline_fixed_string_t bonding;
4570 cmdline_fixed_string_t balance_xmit_policy;
4572 cmdline_fixed_string_t policy;
4575 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4576 __attribute__((unused)) struct cmdline *cl,
4577 __attribute__((unused)) void *data)
4579 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4580 portid_t port_id = res->port_id;
4583 if (!strcmp(res->policy, "l2")) {
4584 policy = BALANCE_XMIT_POLICY_LAYER2;
4585 } else if (!strcmp(res->policy, "l23")) {
4586 policy = BALANCE_XMIT_POLICY_LAYER23;
4587 } else if (!strcmp(res->policy, "l34")) {
4588 policy = BALANCE_XMIT_POLICY_LAYER34;
4590 printf("\t Invalid xmit policy selection");
4594 /* Set the bonding mode for the relevant port. */
4595 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4596 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4601 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4602 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4604 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4605 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4606 bonding, "bonding");
4607 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4608 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4609 balance_xmit_policy, "balance_xmit_policy");
4610 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4611 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4613 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4614 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4615 policy, "l2#l23#l34");
4617 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4618 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4619 .help_str = "set bonding balance_xmit_policy <port_id> "
4621 "Set the bonding balance_xmit_policy for port_id",
4624 (void *)&cmd_setbonding_balance_xmit_policy_set,
4625 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4626 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4627 (void *)&cmd_setbonding_balance_xmit_policy_port,
4628 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4633 /* *** SHOW NIC BONDING CONFIGURATION *** */
4634 struct cmd_show_bonding_config_result {
4635 cmdline_fixed_string_t show;
4636 cmdline_fixed_string_t bonding;
4637 cmdline_fixed_string_t config;
4641 static void cmd_show_bonding_config_parsed(void *parsed_result,
4642 __attribute__((unused)) struct cmdline *cl,
4643 __attribute__((unused)) void *data)
4645 struct cmd_show_bonding_config_result *res = parsed_result;
4646 int bonding_mode, agg_mode;
4647 portid_t slaves[RTE_MAX_ETHPORTS];
4648 int num_slaves, num_active_slaves;
4651 portid_t port_id = res->port_id;
4653 /* Display the bonding mode.*/
4654 bonding_mode = rte_eth_bond_mode_get(port_id);
4655 if (bonding_mode < 0) {
4656 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4659 printf("\tBonding mode: %d\n", bonding_mode);
4661 if (bonding_mode == BONDING_MODE_BALANCE) {
4662 int balance_xmit_policy;
4664 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4665 if (balance_xmit_policy < 0) {
4666 printf("\tFailed to get balance xmit policy for port = %d\n",
4670 printf("\tBalance Xmit Policy: ");
4672 switch (balance_xmit_policy) {
4673 case BALANCE_XMIT_POLICY_LAYER2:
4674 printf("BALANCE_XMIT_POLICY_LAYER2");
4676 case BALANCE_XMIT_POLICY_LAYER23:
4677 printf("BALANCE_XMIT_POLICY_LAYER23");
4679 case BALANCE_XMIT_POLICY_LAYER34:
4680 printf("BALANCE_XMIT_POLICY_LAYER34");
4687 if (bonding_mode == BONDING_MODE_8023AD) {
4688 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
4689 printf("\tIEEE802.3AD Aggregator Mode: ");
4692 printf("bandwidth");
4704 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4706 if (num_slaves < 0) {
4707 printf("\tFailed to get slave list for port = %d\n", port_id);
4710 if (num_slaves > 0) {
4711 printf("\tSlaves (%d): [", num_slaves);
4712 for (i = 0; i < num_slaves - 1; i++)
4713 printf("%d ", slaves[i]);
4715 printf("%d]\n", slaves[num_slaves - 1]);
4717 printf("\tSlaves: []\n");
4721 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4724 if (num_active_slaves < 0) {
4725 printf("\tFailed to get active slave list for port = %d\n", port_id);
4728 if (num_active_slaves > 0) {
4729 printf("\tActive Slaves (%d): [", num_active_slaves);
4730 for (i = 0; i < num_active_slaves - 1; i++)
4731 printf("%d ", slaves[i]);
4733 printf("%d]\n", slaves[num_active_slaves - 1]);
4736 printf("\tActive Slaves: []\n");
4740 primary_id = rte_eth_bond_primary_get(port_id);
4741 if (primary_id < 0) {
4742 printf("\tFailed to get primary slave for port = %d\n", port_id);
4745 printf("\tPrimary: [%d]\n", primary_id);
4749 cmdline_parse_token_string_t cmd_showbonding_config_show =
4750 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4752 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4753 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4754 bonding, "bonding");
4755 cmdline_parse_token_string_t cmd_showbonding_config_config =
4756 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4758 cmdline_parse_token_num_t cmd_showbonding_config_port =
4759 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4762 cmdline_parse_inst_t cmd_show_bonding_config = {
4763 .f = cmd_show_bonding_config_parsed,
4764 .help_str = "show bonding config <port_id>: "
4765 "Show the bonding config for port_id",
4768 (void *)&cmd_showbonding_config_show,
4769 (void *)&cmd_showbonding_config_bonding,
4770 (void *)&cmd_showbonding_config_config,
4771 (void *)&cmd_showbonding_config_port,
4776 /* *** SET BONDING PRIMARY *** */
4777 struct cmd_set_bonding_primary_result {
4778 cmdline_fixed_string_t set;
4779 cmdline_fixed_string_t bonding;
4780 cmdline_fixed_string_t primary;
4785 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4786 __attribute__((unused)) struct cmdline *cl,
4787 __attribute__((unused)) void *data)
4789 struct cmd_set_bonding_primary_result *res = parsed_result;
4790 portid_t master_port_id = res->port_id;
4791 portid_t slave_port_id = res->slave_id;
4793 /* Set the primary slave for a bonded device. */
4794 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4795 printf("\t Failed to set primary slave for port = %d.\n",
4802 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4803 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4805 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4806 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4807 bonding, "bonding");
4808 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4809 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4810 primary, "primary");
4811 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4812 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4814 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4815 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4818 cmdline_parse_inst_t cmd_set_bonding_primary = {
4819 .f = cmd_set_bonding_primary_parsed,
4820 .help_str = "set bonding primary <slave_id> <port_id>: "
4821 "Set the primary slave for port_id",
4824 (void *)&cmd_setbonding_primary_set,
4825 (void *)&cmd_setbonding_primary_bonding,
4826 (void *)&cmd_setbonding_primary_primary,
4827 (void *)&cmd_setbonding_primary_slave,
4828 (void *)&cmd_setbonding_primary_port,
4833 /* *** ADD SLAVE *** */
4834 struct cmd_add_bonding_slave_result {
4835 cmdline_fixed_string_t add;
4836 cmdline_fixed_string_t bonding;
4837 cmdline_fixed_string_t slave;
4842 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4843 __attribute__((unused)) struct cmdline *cl,
4844 __attribute__((unused)) void *data)
4846 struct cmd_add_bonding_slave_result *res = parsed_result;
4847 portid_t master_port_id = res->port_id;
4848 portid_t slave_port_id = res->slave_id;
4850 /* add the slave for a bonded device. */
4851 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4852 printf("\t Failed to add slave %d to master port = %d.\n",
4853 slave_port_id, master_port_id);
4857 set_port_slave_flag(slave_port_id);
4860 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4861 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4863 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4864 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4865 bonding, "bonding");
4866 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4867 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4869 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4870 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4872 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4873 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4876 cmdline_parse_inst_t cmd_add_bonding_slave = {
4877 .f = cmd_add_bonding_slave_parsed,
4878 .help_str = "add bonding slave <slave_id> <port_id>: "
4879 "Add a slave device to a bonded device",
4882 (void *)&cmd_addbonding_slave_add,
4883 (void *)&cmd_addbonding_slave_bonding,
4884 (void *)&cmd_addbonding_slave_slave,
4885 (void *)&cmd_addbonding_slave_slaveid,
4886 (void *)&cmd_addbonding_slave_port,
4891 /* *** REMOVE SLAVE *** */
4892 struct cmd_remove_bonding_slave_result {
4893 cmdline_fixed_string_t remove;
4894 cmdline_fixed_string_t bonding;
4895 cmdline_fixed_string_t slave;
4900 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4901 __attribute__((unused)) struct cmdline *cl,
4902 __attribute__((unused)) void *data)
4904 struct cmd_remove_bonding_slave_result *res = parsed_result;
4905 portid_t master_port_id = res->port_id;
4906 portid_t slave_port_id = res->slave_id;
4908 /* remove the slave from a bonded device. */
4909 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4910 printf("\t Failed to remove slave %d from master port = %d.\n",
4911 slave_port_id, master_port_id);
4915 clear_port_slave_flag(slave_port_id);
4918 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4919 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4921 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4922 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4923 bonding, "bonding");
4924 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4925 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4927 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4928 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4930 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4931 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4934 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4935 .f = cmd_remove_bonding_slave_parsed,
4936 .help_str = "remove bonding slave <slave_id> <port_id>: "
4937 "Remove a slave device from a bonded device",
4940 (void *)&cmd_removebonding_slave_remove,
4941 (void *)&cmd_removebonding_slave_bonding,
4942 (void *)&cmd_removebonding_slave_slave,
4943 (void *)&cmd_removebonding_slave_slaveid,
4944 (void *)&cmd_removebonding_slave_port,
4949 /* *** CREATE BONDED DEVICE *** */
4950 struct cmd_create_bonded_device_result {
4951 cmdline_fixed_string_t create;
4952 cmdline_fixed_string_t bonded;
4953 cmdline_fixed_string_t device;
4958 static int bond_dev_num = 0;
4960 static void cmd_create_bonded_device_parsed(void *parsed_result,
4961 __attribute__((unused)) struct cmdline *cl,
4962 __attribute__((unused)) void *data)
4964 struct cmd_create_bonded_device_result *res = parsed_result;
4965 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4968 if (test_done == 0) {
4969 printf("Please stop forwarding first\n");
4973 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
4976 /* Create a new bonded device. */
4977 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4979 printf("\t Failed to create bonded device.\n");
4982 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4985 /* Update number of ports */
4986 nb_ports = rte_eth_dev_count();
4987 reconfig(port_id, res->socket);
4988 rte_eth_promiscuous_enable(port_id);
4993 cmdline_parse_token_string_t cmd_createbonded_device_create =
4994 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4996 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4997 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4999 cmdline_parse_token_string_t cmd_createbonded_device_device =
5000 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5002 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5003 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5005 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5006 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5009 cmdline_parse_inst_t cmd_create_bonded_device = {
5010 .f = cmd_create_bonded_device_parsed,
5011 .help_str = "create bonded device <mode> <socket>: "
5012 "Create a new bonded device with specific bonding mode and socket",
5015 (void *)&cmd_createbonded_device_create,
5016 (void *)&cmd_createbonded_device_bonded,
5017 (void *)&cmd_createbonded_device_device,
5018 (void *)&cmd_createbonded_device_mode,
5019 (void *)&cmd_createbonded_device_socket,
5024 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5025 struct cmd_set_bond_mac_addr_result {
5026 cmdline_fixed_string_t set;
5027 cmdline_fixed_string_t bonding;
5028 cmdline_fixed_string_t mac_addr;
5030 struct ether_addr address;
5033 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5034 __attribute__((unused)) struct cmdline *cl,
5035 __attribute__((unused)) void *data)
5037 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5040 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5043 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5045 /* check the return value and print it if is < 0 */
5047 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5050 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5051 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5052 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5053 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5055 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5056 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5058 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5059 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
5060 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5061 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5063 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5064 .f = cmd_set_bond_mac_addr_parsed,
5066 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5068 (void *)&cmd_set_bond_mac_addr_set,
5069 (void *)&cmd_set_bond_mac_addr_bonding,
5070 (void *)&cmd_set_bond_mac_addr_mac,
5071 (void *)&cmd_set_bond_mac_addr_portnum,
5072 (void *)&cmd_set_bond_mac_addr_addr,
5078 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5079 struct cmd_set_bond_mon_period_result {
5080 cmdline_fixed_string_t set;
5081 cmdline_fixed_string_t bonding;
5082 cmdline_fixed_string_t mon_period;
5087 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5088 __attribute__((unused)) struct cmdline *cl,
5089 __attribute__((unused)) void *data)
5091 struct cmd_set_bond_mon_period_result *res = parsed_result;
5094 if (res->port_num >= nb_ports) {
5095 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5099 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5101 /* check the return value and print it if is < 0 */
5103 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5106 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5107 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5109 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5110 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5111 bonding, "bonding");
5112 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5113 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5114 mon_period, "mon_period");
5115 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5116 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5118 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5119 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5122 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5123 .f = cmd_set_bond_mon_period_parsed,
5125 .help_str = "set bonding mon_period <port_id> <period_ms>",
5127 (void *)&cmd_set_bond_mon_period_set,
5128 (void *)&cmd_set_bond_mon_period_bonding,
5129 (void *)&cmd_set_bond_mon_period_mon_period,
5130 (void *)&cmd_set_bond_mon_period_portnum,
5131 (void *)&cmd_set_bond_mon_period_period_ms,
5138 struct cmd_set_bonding_agg_mode_policy_result {
5139 cmdline_fixed_string_t set;
5140 cmdline_fixed_string_t bonding;
5141 cmdline_fixed_string_t agg_mode;
5143 cmdline_fixed_string_t policy;
5148 cmd_set_bonding_agg_mode(void *parsed_result,
5149 __attribute__((unused)) struct cmdline *cl,
5150 __attribute__((unused)) void *data)
5152 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5153 uint8_t policy = AGG_BANDWIDTH;
5155 if (res->port_num >= nb_ports) {
5156 printf("Port id %d must be less than %d\n",
5157 res->port_num, nb_ports);
5161 if (!strcmp(res->policy, "bandwidth"))
5162 policy = AGG_BANDWIDTH;
5163 else if (!strcmp(res->policy, "stable"))
5164 policy = AGG_STABLE;
5165 else if (!strcmp(res->policy, "count"))
5168 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5172 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5173 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5175 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5176 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5177 bonding, "bonding");
5179 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5180 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5181 agg_mode, "agg_mode");
5183 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5184 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5187 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5188 TOKEN_STRING_INITIALIZER(
5189 struct cmd_set_bonding_balance_xmit_policy_result,
5190 policy, "stable#bandwidth#count");
5192 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5193 .f = cmd_set_bonding_agg_mode,
5195 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5197 (void *)&cmd_set_bonding_agg_mode_set,
5198 (void *)&cmd_set_bonding_agg_mode_bonding,
5199 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5200 (void *)&cmd_set_bonding_agg_mode_portnum,
5201 (void *)&cmd_set_bonding_agg_mode_policy_string,
5207 #endif /* RTE_LIBRTE_PMD_BOND */
5209 /* *** SET FORWARDING MODE *** */
5210 struct cmd_set_fwd_mode_result {
5211 cmdline_fixed_string_t set;
5212 cmdline_fixed_string_t fwd;
5213 cmdline_fixed_string_t mode;
5216 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5217 __attribute__((unused)) struct cmdline *cl,
5218 __attribute__((unused)) void *data)
5220 struct cmd_set_fwd_mode_result *res = parsed_result;
5223 set_pkt_forwarding_mode(res->mode);
5226 cmdline_parse_token_string_t cmd_setfwd_set =
5227 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5228 cmdline_parse_token_string_t cmd_setfwd_fwd =
5229 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5230 cmdline_parse_token_string_t cmd_setfwd_mode =
5231 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5232 "" /* defined at init */);
5234 cmdline_parse_inst_t cmd_set_fwd_mode = {
5235 .f = cmd_set_fwd_mode_parsed,
5237 .help_str = NULL, /* defined at init */
5239 (void *)&cmd_setfwd_set,
5240 (void *)&cmd_setfwd_fwd,
5241 (void *)&cmd_setfwd_mode,
5246 static void cmd_set_fwd_mode_init(void)
5249 static char token[128];
5250 static char help[256];
5251 cmdline_parse_token_string_t *token_struct;
5253 modes = list_pkt_forwarding_modes();
5254 snprintf(help, sizeof(help), "set fwd %s: "
5255 "Set packet forwarding mode", modes);
5256 cmd_set_fwd_mode.help_str = help;
5258 /* string token separator is # */
5259 for (c = token; *modes != '\0'; modes++)
5264 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5265 token_struct->string_data.str = token;
5268 /* *** SET RETRY FORWARDING MODE *** */
5269 struct cmd_set_fwd_retry_mode_result {
5270 cmdline_fixed_string_t set;
5271 cmdline_fixed_string_t fwd;
5272 cmdline_fixed_string_t mode;
5273 cmdline_fixed_string_t retry;
5276 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5277 __attribute__((unused)) struct cmdline *cl,
5278 __attribute__((unused)) void *data)
5280 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5283 set_pkt_forwarding_mode(res->mode);
5286 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5287 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5289 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5290 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5292 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5293 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5295 "" /* defined at init */);
5296 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5297 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5300 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5301 .f = cmd_set_fwd_retry_mode_parsed,
5303 .help_str = NULL, /* defined at init */
5305 (void *)&cmd_setfwd_retry_set,
5306 (void *)&cmd_setfwd_retry_fwd,
5307 (void *)&cmd_setfwd_retry_mode,
5308 (void *)&cmd_setfwd_retry_retry,
5313 static void cmd_set_fwd_retry_mode_init(void)
5316 static char token[128];
5317 static char help[256];
5318 cmdline_parse_token_string_t *token_struct;
5320 modes = list_pkt_forwarding_retry_modes();
5321 snprintf(help, sizeof(help), "set fwd %s retry: "
5322 "Set packet forwarding mode with retry", modes);
5323 cmd_set_fwd_retry_mode.help_str = help;
5325 /* string token separator is # */
5326 for (c = token; *modes != '\0'; modes++)
5331 token_struct = (cmdline_parse_token_string_t *)
5332 cmd_set_fwd_retry_mode.tokens[2];
5333 token_struct->string_data.str = token;
5336 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5337 struct cmd_set_burst_tx_retry_result {
5338 cmdline_fixed_string_t set;
5339 cmdline_fixed_string_t burst;
5340 cmdline_fixed_string_t tx;
5341 cmdline_fixed_string_t delay;
5343 cmdline_fixed_string_t retry;
5347 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5348 __attribute__((unused)) struct cmdline *cl,
5349 __attribute__((unused)) void *data)
5351 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5353 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5354 && !strcmp(res->tx, "tx")) {
5355 if (!strcmp(res->delay, "delay"))
5356 burst_tx_delay_time = res->time;
5357 if (!strcmp(res->retry, "retry"))
5358 burst_tx_retry_num = res->retry_num;
5363 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5364 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5365 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5366 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5368 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5369 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5370 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5371 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5372 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5373 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5374 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5375 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5376 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5377 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5379 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5380 .f = cmd_set_burst_tx_retry_parsed,
5381 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5383 (void *)&cmd_set_burst_tx_retry_set,
5384 (void *)&cmd_set_burst_tx_retry_burst,
5385 (void *)&cmd_set_burst_tx_retry_tx,
5386 (void *)&cmd_set_burst_tx_retry_delay,
5387 (void *)&cmd_set_burst_tx_retry_time,
5388 (void *)&cmd_set_burst_tx_retry_retry,
5389 (void *)&cmd_set_burst_tx_retry_retry_num,
5394 /* *** SET PROMISC MODE *** */
5395 struct cmd_set_promisc_mode_result {
5396 cmdline_fixed_string_t set;
5397 cmdline_fixed_string_t promisc;
5398 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5399 uint8_t port_num; /* valid if "allports" argument == 0 */
5400 cmdline_fixed_string_t mode;
5403 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5404 __attribute__((unused)) struct cmdline *cl,
5407 struct cmd_set_promisc_mode_result *res = parsed_result;
5411 if (!strcmp(res->mode, "on"))
5418 RTE_ETH_FOREACH_DEV(i) {
5420 rte_eth_promiscuous_enable(i);
5422 rte_eth_promiscuous_disable(i);
5427 rte_eth_promiscuous_enable(res->port_num);
5429 rte_eth_promiscuous_disable(res->port_num);
5433 cmdline_parse_token_string_t cmd_setpromisc_set =
5434 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5435 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5436 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5438 cmdline_parse_token_string_t cmd_setpromisc_portall =
5439 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5441 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5442 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5444 cmdline_parse_token_string_t cmd_setpromisc_mode =
5445 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5448 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5449 .f = cmd_set_promisc_mode_parsed,
5451 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5453 (void *)&cmd_setpromisc_set,
5454 (void *)&cmd_setpromisc_promisc,
5455 (void *)&cmd_setpromisc_portall,
5456 (void *)&cmd_setpromisc_mode,
5461 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5462 .f = cmd_set_promisc_mode_parsed,
5464 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5466 (void *)&cmd_setpromisc_set,
5467 (void *)&cmd_setpromisc_promisc,
5468 (void *)&cmd_setpromisc_portnum,
5469 (void *)&cmd_setpromisc_mode,
5474 /* *** SET ALLMULTI MODE *** */
5475 struct cmd_set_allmulti_mode_result {
5476 cmdline_fixed_string_t set;
5477 cmdline_fixed_string_t allmulti;
5478 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5479 uint8_t port_num; /* valid if "allports" argument == 0 */
5480 cmdline_fixed_string_t mode;
5483 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5484 __attribute__((unused)) struct cmdline *cl,
5487 struct cmd_set_allmulti_mode_result *res = parsed_result;
5491 if (!strcmp(res->mode, "on"))
5498 RTE_ETH_FOREACH_DEV(i) {
5500 rte_eth_allmulticast_enable(i);
5502 rte_eth_allmulticast_disable(i);
5507 rte_eth_allmulticast_enable(res->port_num);
5509 rte_eth_allmulticast_disable(res->port_num);
5513 cmdline_parse_token_string_t cmd_setallmulti_set =
5514 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5515 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5516 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5518 cmdline_parse_token_string_t cmd_setallmulti_portall =
5519 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5521 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5522 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5524 cmdline_parse_token_string_t cmd_setallmulti_mode =
5525 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5528 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5529 .f = cmd_set_allmulti_mode_parsed,
5531 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5533 (void *)&cmd_setallmulti_set,
5534 (void *)&cmd_setallmulti_allmulti,
5535 (void *)&cmd_setallmulti_portall,
5536 (void *)&cmd_setallmulti_mode,
5541 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5542 .f = cmd_set_allmulti_mode_parsed,
5544 .help_str = "set allmulti <port_id> on|off: "
5545 "Set allmulti mode on port_id",
5547 (void *)&cmd_setallmulti_set,
5548 (void *)&cmd_setallmulti_allmulti,
5549 (void *)&cmd_setallmulti_portnum,
5550 (void *)&cmd_setallmulti_mode,
5555 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5556 struct cmd_link_flow_ctrl_set_result {
5557 cmdline_fixed_string_t set;
5558 cmdline_fixed_string_t flow_ctrl;
5559 cmdline_fixed_string_t rx;
5560 cmdline_fixed_string_t rx_lfc_mode;
5561 cmdline_fixed_string_t tx;
5562 cmdline_fixed_string_t tx_lfc_mode;
5563 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5564 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5565 cmdline_fixed_string_t autoneg_str;
5566 cmdline_fixed_string_t autoneg;
5567 cmdline_fixed_string_t hw_str;
5568 uint32_t high_water;
5569 cmdline_fixed_string_t lw_str;
5571 cmdline_fixed_string_t pt_str;
5572 uint16_t pause_time;
5573 cmdline_fixed_string_t xon_str;
5578 cmdline_parse_token_string_t cmd_lfc_set_set =
5579 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5581 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5582 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5583 flow_ctrl, "flow_ctrl");
5584 cmdline_parse_token_string_t cmd_lfc_set_rx =
5585 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5587 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5588 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5589 rx_lfc_mode, "on#off");
5590 cmdline_parse_token_string_t cmd_lfc_set_tx =
5591 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5593 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5594 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5595 tx_lfc_mode, "on#off");
5596 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5597 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5598 hw_str, "high_water");
5599 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5600 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5601 high_water, UINT32);
5602 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5603 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5604 lw_str, "low_water");
5605 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5606 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5608 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5609 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5610 pt_str, "pause_time");
5611 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5612 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5613 pause_time, UINT16);
5614 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5615 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5616 xon_str, "send_xon");
5617 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5618 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5620 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5621 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5622 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5623 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5624 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5625 mac_ctrl_frame_fwd_mode, "on#off");
5626 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5627 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5628 autoneg_str, "autoneg");
5629 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5630 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5632 cmdline_parse_token_num_t cmd_lfc_set_portid =
5633 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5636 /* forward declaration */
5638 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5641 cmdline_parse_inst_t cmd_link_flow_control_set = {
5642 .f = cmd_link_flow_ctrl_set_parsed,
5644 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5645 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5646 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5648 (void *)&cmd_lfc_set_set,
5649 (void *)&cmd_lfc_set_flow_ctrl,
5650 (void *)&cmd_lfc_set_rx,
5651 (void *)&cmd_lfc_set_rx_mode,
5652 (void *)&cmd_lfc_set_tx,
5653 (void *)&cmd_lfc_set_tx_mode,
5654 (void *)&cmd_lfc_set_high_water,
5655 (void *)&cmd_lfc_set_low_water,
5656 (void *)&cmd_lfc_set_pause_time,
5657 (void *)&cmd_lfc_set_send_xon,
5658 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5659 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5660 (void *)&cmd_lfc_set_autoneg_str,
5661 (void *)&cmd_lfc_set_autoneg,
5662 (void *)&cmd_lfc_set_portid,
5667 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5668 .f = cmd_link_flow_ctrl_set_parsed,
5669 .data = (void *)&cmd_link_flow_control_set_rx,
5670 .help_str = "set flow_ctrl rx on|off <port_id>: "
5671 "Change rx flow control parameter",
5673 (void *)&cmd_lfc_set_set,
5674 (void *)&cmd_lfc_set_flow_ctrl,
5675 (void *)&cmd_lfc_set_rx,
5676 (void *)&cmd_lfc_set_rx_mode,
5677 (void *)&cmd_lfc_set_portid,
5682 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5683 .f = cmd_link_flow_ctrl_set_parsed,
5684 .data = (void *)&cmd_link_flow_control_set_tx,
5685 .help_str = "set flow_ctrl tx on|off <port_id>: "
5686 "Change tx flow control parameter",
5688 (void *)&cmd_lfc_set_set,
5689 (void *)&cmd_lfc_set_flow_ctrl,
5690 (void *)&cmd_lfc_set_tx,
5691 (void *)&cmd_lfc_set_tx_mode,
5692 (void *)&cmd_lfc_set_portid,
5697 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5698 .f = cmd_link_flow_ctrl_set_parsed,
5699 .data = (void *)&cmd_link_flow_control_set_hw,
5700 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5701 "Change high water flow control parameter",
5703 (void *)&cmd_lfc_set_set,
5704 (void *)&cmd_lfc_set_flow_ctrl,
5705 (void *)&cmd_lfc_set_high_water_str,
5706 (void *)&cmd_lfc_set_high_water,
5707 (void *)&cmd_lfc_set_portid,
5712 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5713 .f = cmd_link_flow_ctrl_set_parsed,
5714 .data = (void *)&cmd_link_flow_control_set_lw,
5715 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5716 "Change low water flow control parameter",
5718 (void *)&cmd_lfc_set_set,
5719 (void *)&cmd_lfc_set_flow_ctrl,
5720 (void *)&cmd_lfc_set_low_water_str,
5721 (void *)&cmd_lfc_set_low_water,
5722 (void *)&cmd_lfc_set_portid,
5727 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5728 .f = cmd_link_flow_ctrl_set_parsed,
5729 .data = (void *)&cmd_link_flow_control_set_pt,
5730 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5731 "Change pause time flow control parameter",
5733 (void *)&cmd_lfc_set_set,
5734 (void *)&cmd_lfc_set_flow_ctrl,
5735 (void *)&cmd_lfc_set_pause_time_str,
5736 (void *)&cmd_lfc_set_pause_time,
5737 (void *)&cmd_lfc_set_portid,
5742 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5743 .f = cmd_link_flow_ctrl_set_parsed,
5744 .data = (void *)&cmd_link_flow_control_set_xon,
5745 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5746 "Change send_xon flow control parameter",
5748 (void *)&cmd_lfc_set_set,
5749 (void *)&cmd_lfc_set_flow_ctrl,
5750 (void *)&cmd_lfc_set_send_xon_str,
5751 (void *)&cmd_lfc_set_send_xon,
5752 (void *)&cmd_lfc_set_portid,
5757 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5758 .f = cmd_link_flow_ctrl_set_parsed,
5759 .data = (void *)&cmd_link_flow_control_set_macfwd,
5760 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5761 "Change mac ctrl fwd flow control parameter",
5763 (void *)&cmd_lfc_set_set,
5764 (void *)&cmd_lfc_set_flow_ctrl,
5765 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5766 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5767 (void *)&cmd_lfc_set_portid,
5772 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5773 .f = cmd_link_flow_ctrl_set_parsed,
5774 .data = (void *)&cmd_link_flow_control_set_autoneg,
5775 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5776 "Change autoneg flow control parameter",
5778 (void *)&cmd_lfc_set_set,
5779 (void *)&cmd_lfc_set_flow_ctrl,
5780 (void *)&cmd_lfc_set_autoneg_str,
5781 (void *)&cmd_lfc_set_autoneg,
5782 (void *)&cmd_lfc_set_portid,
5788 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5789 __attribute__((unused)) struct cmdline *cl,
5792 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5793 cmdline_parse_inst_t *cmd = data;
5794 struct rte_eth_fc_conf fc_conf;
5800 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5801 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5802 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5803 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5805 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5806 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5809 /* Partial command line, retrieve current configuration */
5811 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5813 printf("cannot get current flow ctrl parameters, return"
5814 "code = %d\n", ret);
5818 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5819 (fc_conf.mode == RTE_FC_FULL))
5821 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5822 (fc_conf.mode == RTE_FC_FULL))
5826 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5827 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5829 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5830 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5832 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5834 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5835 fc_conf.high_water = res->high_water;
5837 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5838 fc_conf.low_water = res->low_water;
5840 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5841 fc_conf.pause_time = res->pause_time;
5843 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5844 fc_conf.send_xon = res->send_xon;
5846 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5847 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5848 fc_conf.mac_ctrl_frame_fwd = 1;
5850 fc_conf.mac_ctrl_frame_fwd = 0;
5853 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5854 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5856 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5858 printf("bad flow contrl parameter, return code = %d \n", ret);
5861 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5862 struct cmd_priority_flow_ctrl_set_result {
5863 cmdline_fixed_string_t set;
5864 cmdline_fixed_string_t pfc_ctrl;
5865 cmdline_fixed_string_t rx;
5866 cmdline_fixed_string_t rx_pfc_mode;
5867 cmdline_fixed_string_t tx;
5868 cmdline_fixed_string_t tx_pfc_mode;
5869 uint32_t high_water;
5871 uint16_t pause_time;
5877 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5878 __attribute__((unused)) struct cmdline *cl,
5879 __attribute__((unused)) void *data)
5881 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5882 struct rte_eth_pfc_conf pfc_conf;
5883 int rx_fc_enable, tx_fc_enable;
5887 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5888 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5889 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5890 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5892 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5893 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5896 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5897 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5898 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5899 pfc_conf.fc.high_water = res->high_water;
5900 pfc_conf.fc.low_water = res->low_water;
5901 pfc_conf.fc.pause_time = res->pause_time;
5902 pfc_conf.priority = res->priority;
5904 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5906 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5909 cmdline_parse_token_string_t cmd_pfc_set_set =
5910 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5912 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5913 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5914 pfc_ctrl, "pfc_ctrl");
5915 cmdline_parse_token_string_t cmd_pfc_set_rx =
5916 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5918 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5919 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5920 rx_pfc_mode, "on#off");
5921 cmdline_parse_token_string_t cmd_pfc_set_tx =
5922 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5924 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5925 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5926 tx_pfc_mode, "on#off");
5927 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5928 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5929 high_water, UINT32);
5930 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5931 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5933 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5934 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5935 pause_time, UINT16);
5936 cmdline_parse_token_num_t cmd_pfc_set_priority =
5937 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5939 cmdline_parse_token_num_t cmd_pfc_set_portid =
5940 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5943 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5944 .f = cmd_priority_flow_ctrl_set_parsed,
5946 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5947 "<pause_time> <priority> <port_id>: "
5948 "Configure the Ethernet priority flow control",
5950 (void *)&cmd_pfc_set_set,
5951 (void *)&cmd_pfc_set_flow_ctrl,
5952 (void *)&cmd_pfc_set_rx,
5953 (void *)&cmd_pfc_set_rx_mode,
5954 (void *)&cmd_pfc_set_tx,
5955 (void *)&cmd_pfc_set_tx_mode,
5956 (void *)&cmd_pfc_set_high_water,
5957 (void *)&cmd_pfc_set_low_water,
5958 (void *)&cmd_pfc_set_pause_time,
5959 (void *)&cmd_pfc_set_priority,
5960 (void *)&cmd_pfc_set_portid,
5965 /* *** RESET CONFIGURATION *** */
5966 struct cmd_reset_result {
5967 cmdline_fixed_string_t reset;
5968 cmdline_fixed_string_t def;
5971 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5973 __attribute__((unused)) void *data)
5975 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5976 set_def_fwd_config();
5979 cmdline_parse_token_string_t cmd_reset_set =
5980 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5981 cmdline_parse_token_string_t cmd_reset_def =
5982 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5985 cmdline_parse_inst_t cmd_reset = {
5986 .f = cmd_reset_parsed,
5988 .help_str = "set default: Reset default forwarding configuration",
5990 (void *)&cmd_reset_set,
5991 (void *)&cmd_reset_def,
5996 /* *** START FORWARDING *** */
5997 struct cmd_start_result {
5998 cmdline_fixed_string_t start;
6001 cmdline_parse_token_string_t cmd_start_start =
6002 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6004 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6005 __attribute__((unused)) struct cmdline *cl,
6006 __attribute__((unused)) void *data)
6008 start_packet_forwarding(0);
6011 cmdline_parse_inst_t cmd_start = {
6012 .f = cmd_start_parsed,
6014 .help_str = "start: Start packet forwarding",
6016 (void *)&cmd_start_start,
6021 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6022 struct cmd_start_tx_first_result {
6023 cmdline_fixed_string_t start;
6024 cmdline_fixed_string_t tx_first;
6028 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6029 __attribute__((unused)) struct cmdline *cl,
6030 __attribute__((unused)) void *data)
6032 start_packet_forwarding(1);
6035 cmdline_parse_token_string_t cmd_start_tx_first_start =
6036 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6038 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6039 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6040 tx_first, "tx_first");
6042 cmdline_parse_inst_t cmd_start_tx_first = {
6043 .f = cmd_start_tx_first_parsed,
6045 .help_str = "start tx_first: Start packet forwarding, "
6046 "after sending 1 burst of packets",
6048 (void *)&cmd_start_tx_first_start,
6049 (void *)&cmd_start_tx_first_tx_first,
6054 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6055 struct cmd_start_tx_first_n_result {
6056 cmdline_fixed_string_t start;
6057 cmdline_fixed_string_t tx_first;
6062 cmd_start_tx_first_n_parsed(void *parsed_result,
6063 __attribute__((unused)) struct cmdline *cl,
6064 __attribute__((unused)) void *data)
6066 struct cmd_start_tx_first_n_result *res = parsed_result;
6068 start_packet_forwarding(res->tx_num);
6071 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6072 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6074 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6075 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6076 tx_first, "tx_first");
6077 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6078 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6081 cmdline_parse_inst_t cmd_start_tx_first_n = {
6082 .f = cmd_start_tx_first_n_parsed,
6084 .help_str = "start tx_first <num>: "
6085 "packet forwarding, after sending <num> bursts of packets",
6087 (void *)&cmd_start_tx_first_n_start,
6088 (void *)&cmd_start_tx_first_n_tx_first,
6089 (void *)&cmd_start_tx_first_n_tx_num,
6094 /* *** SET LINK UP *** */
6095 struct cmd_set_link_up_result {
6096 cmdline_fixed_string_t set;
6097 cmdline_fixed_string_t link_up;
6098 cmdline_fixed_string_t port;
6102 cmdline_parse_token_string_t cmd_set_link_up_set =
6103 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6104 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6105 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6107 cmdline_parse_token_string_t cmd_set_link_up_port =
6108 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6109 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6110 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
6112 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6113 __attribute__((unused)) struct cmdline *cl,
6114 __attribute__((unused)) void *data)
6116 struct cmd_set_link_up_result *res = parsed_result;
6117 dev_set_link_up(res->port_id);
6120 cmdline_parse_inst_t cmd_set_link_up = {
6121 .f = cmd_set_link_up_parsed,
6123 .help_str = "set link-up port <port id>",
6125 (void *)&cmd_set_link_up_set,
6126 (void *)&cmd_set_link_up_link_up,
6127 (void *)&cmd_set_link_up_port,
6128 (void *)&cmd_set_link_up_port_id,
6133 /* *** SET LINK DOWN *** */
6134 struct cmd_set_link_down_result {
6135 cmdline_fixed_string_t set;
6136 cmdline_fixed_string_t link_down;
6137 cmdline_fixed_string_t port;
6141 cmdline_parse_token_string_t cmd_set_link_down_set =
6142 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6143 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6144 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6146 cmdline_parse_token_string_t cmd_set_link_down_port =
6147 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6148 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6149 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
6151 static void cmd_set_link_down_parsed(
6152 __attribute__((unused)) void *parsed_result,
6153 __attribute__((unused)) struct cmdline *cl,
6154 __attribute__((unused)) void *data)
6156 struct cmd_set_link_down_result *res = parsed_result;
6157 dev_set_link_down(res->port_id);
6160 cmdline_parse_inst_t cmd_set_link_down = {
6161 .f = cmd_set_link_down_parsed,
6163 .help_str = "set link-down port <port id>",
6165 (void *)&cmd_set_link_down_set,
6166 (void *)&cmd_set_link_down_link_down,
6167 (void *)&cmd_set_link_down_port,
6168 (void *)&cmd_set_link_down_port_id,
6173 /* *** SHOW CFG *** */
6174 struct cmd_showcfg_result {
6175 cmdline_fixed_string_t show;
6176 cmdline_fixed_string_t cfg;
6177 cmdline_fixed_string_t what;
6180 static void cmd_showcfg_parsed(void *parsed_result,
6181 __attribute__((unused)) struct cmdline *cl,
6182 __attribute__((unused)) void *data)
6184 struct cmd_showcfg_result *res = parsed_result;
6185 if (!strcmp(res->what, "rxtx"))
6186 rxtx_config_display();
6187 else if (!strcmp(res->what, "cores"))
6188 fwd_lcores_config_display();
6189 else if (!strcmp(res->what, "fwd"))
6190 pkt_fwd_config_display(&cur_fwd_config);
6191 else if (!strcmp(res->what, "txpkts"))
6192 show_tx_pkt_segments();
6195 cmdline_parse_token_string_t cmd_showcfg_show =
6196 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6197 cmdline_parse_token_string_t cmd_showcfg_port =
6198 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6199 cmdline_parse_token_string_t cmd_showcfg_what =
6200 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6201 "rxtx#cores#fwd#txpkts");
6203 cmdline_parse_inst_t cmd_showcfg = {
6204 .f = cmd_showcfg_parsed,
6206 .help_str = "show config rxtx|cores|fwd|txpkts",
6208 (void *)&cmd_showcfg_show,
6209 (void *)&cmd_showcfg_port,
6210 (void *)&cmd_showcfg_what,
6215 /* *** SHOW ALL PORT INFO *** */
6216 struct cmd_showportall_result {
6217 cmdline_fixed_string_t show;
6218 cmdline_fixed_string_t port;
6219 cmdline_fixed_string_t what;
6220 cmdline_fixed_string_t all;
6223 static void cmd_showportall_parsed(void *parsed_result,
6224 __attribute__((unused)) struct cmdline *cl,
6225 __attribute__((unused)) void *data)
6229 struct cmd_showportall_result *res = parsed_result;
6230 if (!strcmp(res->show, "clear")) {
6231 if (!strcmp(res->what, "stats"))
6232 RTE_ETH_FOREACH_DEV(i)
6234 else if (!strcmp(res->what, "xstats"))
6235 RTE_ETH_FOREACH_DEV(i)
6236 nic_xstats_clear(i);
6237 } else if (!strcmp(res->what, "info"))
6238 RTE_ETH_FOREACH_DEV(i)
6239 port_infos_display(i);
6240 else if (!strcmp(res->what, "stats"))
6241 RTE_ETH_FOREACH_DEV(i)
6242 nic_stats_display(i);
6243 else if (!strcmp(res->what, "xstats"))
6244 RTE_ETH_FOREACH_DEV(i)
6245 nic_xstats_display(i);
6246 else if (!strcmp(res->what, "fdir"))
6247 RTE_ETH_FOREACH_DEV(i)
6249 else if (!strcmp(res->what, "stat_qmap"))
6250 RTE_ETH_FOREACH_DEV(i)
6251 nic_stats_mapping_display(i);
6252 else if (!strcmp(res->what, "dcb_tc"))
6253 RTE_ETH_FOREACH_DEV(i)
6254 port_dcb_info_display(i);
6255 else if (!strcmp(res->what, "cap"))
6256 RTE_ETH_FOREACH_DEV(i)
6257 port_offload_cap_display(i);
6260 cmdline_parse_token_string_t cmd_showportall_show =
6261 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6263 cmdline_parse_token_string_t cmd_showportall_port =
6264 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6265 cmdline_parse_token_string_t cmd_showportall_what =
6266 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6267 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6268 cmdline_parse_token_string_t cmd_showportall_all =
6269 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6270 cmdline_parse_inst_t cmd_showportall = {
6271 .f = cmd_showportall_parsed,
6273 .help_str = "show|clear port "
6274 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6276 (void *)&cmd_showportall_show,
6277 (void *)&cmd_showportall_port,
6278 (void *)&cmd_showportall_what,
6279 (void *)&cmd_showportall_all,
6284 /* *** SHOW PORT INFO *** */
6285 struct cmd_showport_result {
6286 cmdline_fixed_string_t show;
6287 cmdline_fixed_string_t port;
6288 cmdline_fixed_string_t what;
6292 static void cmd_showport_parsed(void *parsed_result,
6293 __attribute__((unused)) struct cmdline *cl,
6294 __attribute__((unused)) void *data)
6296 struct cmd_showport_result *res = parsed_result;
6297 if (!strcmp(res->show, "clear")) {
6298 if (!strcmp(res->what, "stats"))
6299 nic_stats_clear(res->portnum);
6300 else if (!strcmp(res->what, "xstats"))
6301 nic_xstats_clear(res->portnum);
6302 } else if (!strcmp(res->what, "info"))
6303 port_infos_display(res->portnum);
6304 else if (!strcmp(res->what, "stats"))
6305 nic_stats_display(res->portnum);
6306 else if (!strcmp(res->what, "xstats"))
6307 nic_xstats_display(res->portnum);
6308 else if (!strcmp(res->what, "fdir"))
6309 fdir_get_infos(res->portnum);
6310 else if (!strcmp(res->what, "stat_qmap"))
6311 nic_stats_mapping_display(res->portnum);
6312 else if (!strcmp(res->what, "dcb_tc"))
6313 port_dcb_info_display(res->portnum);
6314 else if (!strcmp(res->what, "cap"))
6315 port_offload_cap_display(res->portnum);
6318 cmdline_parse_token_string_t cmd_showport_show =
6319 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6321 cmdline_parse_token_string_t cmd_showport_port =
6322 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6323 cmdline_parse_token_string_t cmd_showport_what =
6324 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6325 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6326 cmdline_parse_token_num_t cmd_showport_portnum =
6327 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
6329 cmdline_parse_inst_t cmd_showport = {
6330 .f = cmd_showport_parsed,
6332 .help_str = "show|clear port "
6333 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6336 (void *)&cmd_showport_show,
6337 (void *)&cmd_showport_port,
6338 (void *)&cmd_showport_what,
6339 (void *)&cmd_showport_portnum,
6344 /* *** SHOW QUEUE INFO *** */
6345 struct cmd_showqueue_result {
6346 cmdline_fixed_string_t show;
6347 cmdline_fixed_string_t type;
6348 cmdline_fixed_string_t what;
6354 cmd_showqueue_parsed(void *parsed_result,
6355 __attribute__((unused)) struct cmdline *cl,
6356 __attribute__((unused)) void *data)
6358 struct cmd_showqueue_result *res = parsed_result;
6360 if (!strcmp(res->type, "rxq"))
6361 rx_queue_infos_display(res->portnum, res->queuenum);
6362 else if (!strcmp(res->type, "txq"))
6363 tx_queue_infos_display(res->portnum, res->queuenum);
6366 cmdline_parse_token_string_t cmd_showqueue_show =
6367 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6368 cmdline_parse_token_string_t cmd_showqueue_type =
6369 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6370 cmdline_parse_token_string_t cmd_showqueue_what =
6371 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6372 cmdline_parse_token_num_t cmd_showqueue_portnum =
6373 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6374 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6375 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6377 cmdline_parse_inst_t cmd_showqueue = {
6378 .f = cmd_showqueue_parsed,
6380 .help_str = "show rxq|txq info <port_id> <queue_id>",
6382 (void *)&cmd_showqueue_show,
6383 (void *)&cmd_showqueue_type,
6384 (void *)&cmd_showqueue_what,
6385 (void *)&cmd_showqueue_portnum,
6386 (void *)&cmd_showqueue_queuenum,
6391 /* *** READ PORT REGISTER *** */
6392 struct cmd_read_reg_result {
6393 cmdline_fixed_string_t read;
6394 cmdline_fixed_string_t reg;
6400 cmd_read_reg_parsed(void *parsed_result,
6401 __attribute__((unused)) struct cmdline *cl,
6402 __attribute__((unused)) void *data)
6404 struct cmd_read_reg_result *res = parsed_result;
6405 port_reg_display(res->port_id, res->reg_off);
6408 cmdline_parse_token_string_t cmd_read_reg_read =
6409 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6410 cmdline_parse_token_string_t cmd_read_reg_reg =
6411 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6412 cmdline_parse_token_num_t cmd_read_reg_port_id =
6413 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6414 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6415 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6417 cmdline_parse_inst_t cmd_read_reg = {
6418 .f = cmd_read_reg_parsed,
6420 .help_str = "read reg <port_id> <reg_off>",
6422 (void *)&cmd_read_reg_read,
6423 (void *)&cmd_read_reg_reg,
6424 (void *)&cmd_read_reg_port_id,
6425 (void *)&cmd_read_reg_reg_off,
6430 /* *** READ PORT REGISTER BIT FIELD *** */
6431 struct cmd_read_reg_bit_field_result {
6432 cmdline_fixed_string_t read;
6433 cmdline_fixed_string_t regfield;
6441 cmd_read_reg_bit_field_parsed(void *parsed_result,
6442 __attribute__((unused)) struct cmdline *cl,
6443 __attribute__((unused)) void *data)
6445 struct cmd_read_reg_bit_field_result *res = parsed_result;
6446 port_reg_bit_field_display(res->port_id, res->reg_off,
6447 res->bit1_pos, res->bit2_pos);
6450 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6451 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6453 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6454 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6455 regfield, "regfield");
6456 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6457 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6459 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6460 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6462 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6463 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6465 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6466 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6469 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6470 .f = cmd_read_reg_bit_field_parsed,
6472 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6473 "Read register bit field between bit_x and bit_y included",
6475 (void *)&cmd_read_reg_bit_field_read,
6476 (void *)&cmd_read_reg_bit_field_regfield,
6477 (void *)&cmd_read_reg_bit_field_port_id,
6478 (void *)&cmd_read_reg_bit_field_reg_off,
6479 (void *)&cmd_read_reg_bit_field_bit1_pos,
6480 (void *)&cmd_read_reg_bit_field_bit2_pos,
6485 /* *** READ PORT REGISTER BIT *** */
6486 struct cmd_read_reg_bit_result {
6487 cmdline_fixed_string_t read;
6488 cmdline_fixed_string_t regbit;
6495 cmd_read_reg_bit_parsed(void *parsed_result,
6496 __attribute__((unused)) struct cmdline *cl,
6497 __attribute__((unused)) void *data)
6499 struct cmd_read_reg_bit_result *res = parsed_result;
6500 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6503 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6504 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6505 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6506 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6508 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6509 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6510 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6511 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6512 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6513 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6515 cmdline_parse_inst_t cmd_read_reg_bit = {
6516 .f = cmd_read_reg_bit_parsed,
6518 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6520 (void *)&cmd_read_reg_bit_read,
6521 (void *)&cmd_read_reg_bit_regbit,
6522 (void *)&cmd_read_reg_bit_port_id,
6523 (void *)&cmd_read_reg_bit_reg_off,
6524 (void *)&cmd_read_reg_bit_bit_pos,
6529 /* *** WRITE PORT REGISTER *** */
6530 struct cmd_write_reg_result {
6531 cmdline_fixed_string_t write;
6532 cmdline_fixed_string_t reg;
6539 cmd_write_reg_parsed(void *parsed_result,
6540 __attribute__((unused)) struct cmdline *cl,
6541 __attribute__((unused)) void *data)
6543 struct cmd_write_reg_result *res = parsed_result;
6544 port_reg_set(res->port_id, res->reg_off, res->value);
6547 cmdline_parse_token_string_t cmd_write_reg_write =
6548 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6549 cmdline_parse_token_string_t cmd_write_reg_reg =
6550 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6551 cmdline_parse_token_num_t cmd_write_reg_port_id =
6552 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6553 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6554 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6555 cmdline_parse_token_num_t cmd_write_reg_value =
6556 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6558 cmdline_parse_inst_t cmd_write_reg = {
6559 .f = cmd_write_reg_parsed,
6561 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6563 (void *)&cmd_write_reg_write,
6564 (void *)&cmd_write_reg_reg,
6565 (void *)&cmd_write_reg_port_id,
6566 (void *)&cmd_write_reg_reg_off,
6567 (void *)&cmd_write_reg_value,
6572 /* *** WRITE PORT REGISTER BIT FIELD *** */
6573 struct cmd_write_reg_bit_field_result {
6574 cmdline_fixed_string_t write;
6575 cmdline_fixed_string_t regfield;
6584 cmd_write_reg_bit_field_parsed(void *parsed_result,
6585 __attribute__((unused)) struct cmdline *cl,
6586 __attribute__((unused)) void *data)
6588 struct cmd_write_reg_bit_field_result *res = parsed_result;
6589 port_reg_bit_field_set(res->port_id, res->reg_off,
6590 res->bit1_pos, res->bit2_pos, res->value);
6593 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6594 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6596 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6597 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6598 regfield, "regfield");
6599 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6600 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6602 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6603 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6605 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6606 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6608 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6609 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6611 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6612 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6615 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6616 .f = cmd_write_reg_bit_field_parsed,
6618 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6620 "Set register bit field between bit_x and bit_y included",
6622 (void *)&cmd_write_reg_bit_field_write,
6623 (void *)&cmd_write_reg_bit_field_regfield,
6624 (void *)&cmd_write_reg_bit_field_port_id,
6625 (void *)&cmd_write_reg_bit_field_reg_off,
6626 (void *)&cmd_write_reg_bit_field_bit1_pos,
6627 (void *)&cmd_write_reg_bit_field_bit2_pos,
6628 (void *)&cmd_write_reg_bit_field_value,
6633 /* *** WRITE PORT REGISTER BIT *** */
6634 struct cmd_write_reg_bit_result {
6635 cmdline_fixed_string_t write;
6636 cmdline_fixed_string_t regbit;
6644 cmd_write_reg_bit_parsed(void *parsed_result,
6645 __attribute__((unused)) struct cmdline *cl,
6646 __attribute__((unused)) void *data)
6648 struct cmd_write_reg_bit_result *res = parsed_result;
6649 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6652 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6653 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6655 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6656 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6658 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6659 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6660 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6661 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6662 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6663 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6664 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6665 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6667 cmdline_parse_inst_t cmd_write_reg_bit = {
6668 .f = cmd_write_reg_bit_parsed,
6670 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6673 (void *)&cmd_write_reg_bit_write,
6674 (void *)&cmd_write_reg_bit_regbit,
6675 (void *)&cmd_write_reg_bit_port_id,
6676 (void *)&cmd_write_reg_bit_reg_off,
6677 (void *)&cmd_write_reg_bit_bit_pos,
6678 (void *)&cmd_write_reg_bit_value,
6683 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6684 struct cmd_read_rxd_txd_result {
6685 cmdline_fixed_string_t read;
6686 cmdline_fixed_string_t rxd_txd;
6693 cmd_read_rxd_txd_parsed(void *parsed_result,
6694 __attribute__((unused)) struct cmdline *cl,
6695 __attribute__((unused)) void *data)
6697 struct cmd_read_rxd_txd_result *res = parsed_result;
6699 if (!strcmp(res->rxd_txd, "rxd"))
6700 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6701 else if (!strcmp(res->rxd_txd, "txd"))
6702 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6705 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6706 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6707 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6708 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6710 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6711 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6712 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6713 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6714 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6715 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6717 cmdline_parse_inst_t cmd_read_rxd_txd = {
6718 .f = cmd_read_rxd_txd_parsed,
6720 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6722 (void *)&cmd_read_rxd_txd_read,
6723 (void *)&cmd_read_rxd_txd_rxd_txd,
6724 (void *)&cmd_read_rxd_txd_port_id,
6725 (void *)&cmd_read_rxd_txd_queue_id,
6726 (void *)&cmd_read_rxd_txd_desc_id,
6732 struct cmd_quit_result {
6733 cmdline_fixed_string_t quit;
6736 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6738 __attribute__((unused)) void *data)
6744 cmdline_parse_token_string_t cmd_quit_quit =
6745 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6747 cmdline_parse_inst_t cmd_quit = {
6748 .f = cmd_quit_parsed,
6750 .help_str = "quit: Exit application",
6752 (void *)&cmd_quit_quit,
6757 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6758 struct cmd_mac_addr_result {
6759 cmdline_fixed_string_t mac_addr_cmd;
6760 cmdline_fixed_string_t what;
6762 struct ether_addr address;
6765 static void cmd_mac_addr_parsed(void *parsed_result,
6766 __attribute__((unused)) struct cmdline *cl,
6767 __attribute__((unused)) void *data)
6769 struct cmd_mac_addr_result *res = parsed_result;
6772 if (strcmp(res->what, "add") == 0)
6773 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6774 else if (strcmp(res->what, "set") == 0)
6775 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6778 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6780 /* check the return value and print it if is < 0 */
6782 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6786 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6787 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6789 cmdline_parse_token_string_t cmd_mac_addr_what =
6790 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6792 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6793 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6794 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6795 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6797 cmdline_parse_inst_t cmd_mac_addr = {
6798 .f = cmd_mac_addr_parsed,
6800 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6801 "Add/Remove/Set MAC address on port_id",
6803 (void *)&cmd_mac_addr_cmd,
6804 (void *)&cmd_mac_addr_what,
6805 (void *)&cmd_mac_addr_portnum,
6806 (void *)&cmd_mac_addr_addr,
6812 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6813 struct cmd_set_qmap_result {
6814 cmdline_fixed_string_t set;
6815 cmdline_fixed_string_t qmap;
6816 cmdline_fixed_string_t what;
6823 cmd_set_qmap_parsed(void *parsed_result,
6824 __attribute__((unused)) struct cmdline *cl,
6825 __attribute__((unused)) void *data)
6827 struct cmd_set_qmap_result *res = parsed_result;
6828 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6830 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6833 cmdline_parse_token_string_t cmd_setqmap_set =
6834 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6836 cmdline_parse_token_string_t cmd_setqmap_qmap =
6837 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6839 cmdline_parse_token_string_t cmd_setqmap_what =
6840 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6842 cmdline_parse_token_num_t cmd_setqmap_portid =
6843 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6845 cmdline_parse_token_num_t cmd_setqmap_queueid =
6846 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6848 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6849 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6852 cmdline_parse_inst_t cmd_set_qmap = {
6853 .f = cmd_set_qmap_parsed,
6855 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6856 "Set statistics mapping value on tx|rx queue_id of port_id",
6858 (void *)&cmd_setqmap_set,
6859 (void *)&cmd_setqmap_qmap,
6860 (void *)&cmd_setqmap_what,
6861 (void *)&cmd_setqmap_portid,
6862 (void *)&cmd_setqmap_queueid,
6863 (void *)&cmd_setqmap_mapvalue,
6868 /* *** CONFIGURE UNICAST HASH TABLE *** */
6869 struct cmd_set_uc_hash_table {
6870 cmdline_fixed_string_t set;
6871 cmdline_fixed_string_t port;
6873 cmdline_fixed_string_t what;
6874 struct ether_addr address;
6875 cmdline_fixed_string_t mode;
6879 cmd_set_uc_hash_parsed(void *parsed_result,
6880 __attribute__((unused)) struct cmdline *cl,
6881 __attribute__((unused)) void *data)
6884 struct cmd_set_uc_hash_table *res = parsed_result;
6886 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6888 if (strcmp(res->what, "uta") == 0)
6889 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6890 &res->address,(uint8_t)is_on);
6892 printf("bad unicast hash table parameter, return code = %d \n", ret);
6896 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6897 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6899 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6900 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6902 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6903 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6905 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6906 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6908 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6909 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6911 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6912 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6915 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6916 .f = cmd_set_uc_hash_parsed,
6918 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6920 (void *)&cmd_set_uc_hash_set,
6921 (void *)&cmd_set_uc_hash_port,
6922 (void *)&cmd_set_uc_hash_portid,
6923 (void *)&cmd_set_uc_hash_what,
6924 (void *)&cmd_set_uc_hash_mac,
6925 (void *)&cmd_set_uc_hash_mode,
6930 struct cmd_set_uc_all_hash_table {
6931 cmdline_fixed_string_t set;
6932 cmdline_fixed_string_t port;
6934 cmdline_fixed_string_t what;
6935 cmdline_fixed_string_t value;
6936 cmdline_fixed_string_t mode;
6940 cmd_set_uc_all_hash_parsed(void *parsed_result,
6941 __attribute__((unused)) struct cmdline *cl,
6942 __attribute__((unused)) void *data)
6945 struct cmd_set_uc_all_hash_table *res = parsed_result;
6947 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6949 if ((strcmp(res->what, "uta") == 0) &&
6950 (strcmp(res->value, "all") == 0))
6951 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6953 printf("bad unicast hash table parameter,"
6954 "return code = %d \n", ret);
6957 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6958 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6960 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6961 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6963 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6964 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6966 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6967 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6969 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6970 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6972 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6973 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6976 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6977 .f = cmd_set_uc_all_hash_parsed,
6979 .help_str = "set port <port_id> uta all on|off",
6981 (void *)&cmd_set_uc_all_hash_set,
6982 (void *)&cmd_set_uc_all_hash_port,
6983 (void *)&cmd_set_uc_all_hash_portid,
6984 (void *)&cmd_set_uc_all_hash_what,
6985 (void *)&cmd_set_uc_all_hash_value,
6986 (void *)&cmd_set_uc_all_hash_mode,
6991 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6992 struct cmd_set_vf_macvlan_filter {
6993 cmdline_fixed_string_t set;
6994 cmdline_fixed_string_t port;
6996 cmdline_fixed_string_t vf;
6998 struct ether_addr address;
6999 cmdline_fixed_string_t filter_type;
7000 cmdline_fixed_string_t mode;
7004 cmd_set_vf_macvlan_parsed(void *parsed_result,
7005 __attribute__((unused)) struct cmdline *cl,
7006 __attribute__((unused)) void *data)
7009 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7010 struct rte_eth_mac_filter filter;
7012 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7014 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7016 /* set VF MAC filter */
7020 filter.dst_id = res->vf_id;
7022 if (!strcmp(res->filter_type, "exact-mac"))
7023 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7024 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7025 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7026 else if (!strcmp(res->filter_type, "hashmac"))
7027 filter.filter_type = RTE_MAC_HASH_MATCH;
7028 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7029 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7031 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7034 ret = rte_eth_dev_filter_ctrl(res->port_id,
7035 RTE_ETH_FILTER_MACVLAN,
7039 ret = rte_eth_dev_filter_ctrl(res->port_id,
7040 RTE_ETH_FILTER_MACVLAN,
7041 RTE_ETH_FILTER_DELETE,
7045 printf("bad set MAC hash parameter, return code = %d\n", ret);
7049 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7050 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7052 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7053 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7055 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7056 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7058 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7059 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7061 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7062 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7064 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7065 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7067 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7068 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7069 filter_type, "exact-mac#exact-mac-vlan"
7070 "#hashmac#hashmac-vlan");
7071 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7072 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7075 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7076 .f = cmd_set_vf_macvlan_parsed,
7078 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7079 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7080 "Exact match rule: exact match of MAC or MAC and VLAN; "
7081 "hash match rule: hash match of MAC and exact match of VLAN",
7083 (void *)&cmd_set_vf_macvlan_set,
7084 (void *)&cmd_set_vf_macvlan_port,
7085 (void *)&cmd_set_vf_macvlan_portid,
7086 (void *)&cmd_set_vf_macvlan_vf,
7087 (void *)&cmd_set_vf_macvlan_vf_id,
7088 (void *)&cmd_set_vf_macvlan_mac,
7089 (void *)&cmd_set_vf_macvlan_filter_type,
7090 (void *)&cmd_set_vf_macvlan_mode,
7095 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7096 struct cmd_set_vf_traffic {
7097 cmdline_fixed_string_t set;
7098 cmdline_fixed_string_t port;
7100 cmdline_fixed_string_t vf;
7102 cmdline_fixed_string_t what;
7103 cmdline_fixed_string_t mode;
7107 cmd_set_vf_traffic_parsed(void *parsed_result,
7108 __attribute__((unused)) struct cmdline *cl,
7109 __attribute__((unused)) void *data)
7111 struct cmd_set_vf_traffic *res = parsed_result;
7112 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7113 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7115 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7118 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7119 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7121 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7122 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7124 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7125 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7127 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7128 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7130 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7131 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7133 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7134 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7136 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7137 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7140 cmdline_parse_inst_t cmd_set_vf_traffic = {
7141 .f = cmd_set_vf_traffic_parsed,
7143 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7145 (void *)&cmd_setvf_traffic_set,
7146 (void *)&cmd_setvf_traffic_port,
7147 (void *)&cmd_setvf_traffic_portid,
7148 (void *)&cmd_setvf_traffic_vf,
7149 (void *)&cmd_setvf_traffic_vfid,
7150 (void *)&cmd_setvf_traffic_what,
7151 (void *)&cmd_setvf_traffic_mode,
7156 /* *** CONFIGURE VF RECEIVE MODE *** */
7157 struct cmd_set_vf_rxmode {
7158 cmdline_fixed_string_t set;
7159 cmdline_fixed_string_t port;
7161 cmdline_fixed_string_t vf;
7163 cmdline_fixed_string_t what;
7164 cmdline_fixed_string_t mode;
7165 cmdline_fixed_string_t on;
7169 cmd_set_vf_rxmode_parsed(void *parsed_result,
7170 __attribute__((unused)) struct cmdline *cl,
7171 __attribute__((unused)) void *data)
7174 uint16_t rx_mode = 0;
7175 struct cmd_set_vf_rxmode *res = parsed_result;
7177 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7178 if (!strcmp(res->what,"rxmode")) {
7179 if (!strcmp(res->mode, "AUPE"))
7180 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7181 else if (!strcmp(res->mode, "ROPE"))
7182 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7183 else if (!strcmp(res->mode, "BAM"))
7184 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7185 else if (!strncmp(res->mode, "MPE",3))
7186 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7189 #ifdef RTE_LIBRTE_IXGBE_PMD
7190 if (ret == -ENOTSUP)
7191 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7192 rx_mode, (uint8_t)is_on);
7194 #ifdef RTE_LIBRTE_BNXT_PMD
7195 if (ret == -ENOTSUP)
7196 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7197 rx_mode, (uint8_t)is_on);
7200 printf("bad VF receive mode parameter, return code = %d \n",
7204 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7205 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7207 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7208 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7210 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7211 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7213 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7214 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7216 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7217 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7219 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7220 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7222 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7223 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7224 mode, "AUPE#ROPE#BAM#MPE");
7225 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7226 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7229 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7230 .f = cmd_set_vf_rxmode_parsed,
7232 .help_str = "set port <port_id> vf <vf_id> rxmode "
7233 "AUPE|ROPE|BAM|MPE on|off",
7235 (void *)&cmd_set_vf_rxmode_set,
7236 (void *)&cmd_set_vf_rxmode_port,
7237 (void *)&cmd_set_vf_rxmode_portid,
7238 (void *)&cmd_set_vf_rxmode_vf,
7239 (void *)&cmd_set_vf_rxmode_vfid,
7240 (void *)&cmd_set_vf_rxmode_what,
7241 (void *)&cmd_set_vf_rxmode_mode,
7242 (void *)&cmd_set_vf_rxmode_on,
7247 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7248 struct cmd_vf_mac_addr_result {
7249 cmdline_fixed_string_t mac_addr_cmd;
7250 cmdline_fixed_string_t what;
7251 cmdline_fixed_string_t port;
7253 cmdline_fixed_string_t vf;
7255 struct ether_addr address;
7258 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7259 __attribute__((unused)) struct cmdline *cl,
7260 __attribute__((unused)) void *data)
7262 struct cmd_vf_mac_addr_result *res = parsed_result;
7265 if (strcmp(res->what, "add") != 0)
7268 #ifdef RTE_LIBRTE_I40E_PMD
7269 if (ret == -ENOTSUP)
7270 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7273 #ifdef RTE_LIBRTE_BNXT_PMD
7274 if (ret == -ENOTSUP)
7275 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7280 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7284 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7285 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7286 mac_addr_cmd,"mac_addr");
7287 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7288 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7290 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7291 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7293 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7294 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7296 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7297 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7299 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7300 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7302 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7303 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7306 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7307 .f = cmd_vf_mac_addr_parsed,
7309 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7310 "Add MAC address filtering for a VF on port_id",
7312 (void *)&cmd_vf_mac_addr_cmd,
7313 (void *)&cmd_vf_mac_addr_what,
7314 (void *)&cmd_vf_mac_addr_port,
7315 (void *)&cmd_vf_mac_addr_portnum,
7316 (void *)&cmd_vf_mac_addr_vf,
7317 (void *)&cmd_vf_mac_addr_vfnum,
7318 (void *)&cmd_vf_mac_addr_addr,
7323 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7324 struct cmd_vf_rx_vlan_filter {
7325 cmdline_fixed_string_t rx_vlan;
7326 cmdline_fixed_string_t what;
7328 cmdline_fixed_string_t port;
7330 cmdline_fixed_string_t vf;
7335 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7336 __attribute__((unused)) struct cmdline *cl,
7337 __attribute__((unused)) void *data)
7339 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7342 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7344 #ifdef RTE_LIBRTE_IXGBE_PMD
7345 if (ret == -ENOTSUP)
7346 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7347 res->vlan_id, res->vf_mask, is_add);
7349 #ifdef RTE_LIBRTE_I40E_PMD
7350 if (ret == -ENOTSUP)
7351 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7352 res->vlan_id, res->vf_mask, is_add);
7354 #ifdef RTE_LIBRTE_BNXT_PMD
7355 if (ret == -ENOTSUP)
7356 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7357 res->vlan_id, res->vf_mask, is_add);
7364 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7365 res->vlan_id, res->vf_mask);
7368 printf("invalid port_id %d\n", res->port_id);
7371 printf("function not implemented or supported\n");
7374 printf("programming error: (%s)\n", strerror(-ret));
7378 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7379 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7380 rx_vlan, "rx_vlan");
7381 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7382 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7384 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7385 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7387 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7388 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7390 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7391 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7393 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7394 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7396 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7397 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7400 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7401 .f = cmd_vf_rx_vlan_filter_parsed,
7403 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7404 "(vf_mask = hexadecimal VF mask)",
7406 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7407 (void *)&cmd_vf_rx_vlan_filter_what,
7408 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7409 (void *)&cmd_vf_rx_vlan_filter_port,
7410 (void *)&cmd_vf_rx_vlan_filter_portid,
7411 (void *)&cmd_vf_rx_vlan_filter_vf,
7412 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7417 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7418 struct cmd_queue_rate_limit_result {
7419 cmdline_fixed_string_t set;
7420 cmdline_fixed_string_t port;
7422 cmdline_fixed_string_t queue;
7424 cmdline_fixed_string_t rate;
7428 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7429 __attribute__((unused)) struct cmdline *cl,
7430 __attribute__((unused)) void *data)
7432 struct cmd_queue_rate_limit_result *res = parsed_result;
7435 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7436 && (strcmp(res->queue, "queue") == 0)
7437 && (strcmp(res->rate, "rate") == 0))
7438 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7441 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7445 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7446 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7448 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7449 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7451 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7452 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7454 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7455 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7457 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7458 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7460 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7461 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7463 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7464 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7467 cmdline_parse_inst_t cmd_queue_rate_limit = {
7468 .f = cmd_queue_rate_limit_parsed,
7470 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7471 "Set rate limit for a queue on port_id",
7473 (void *)&cmd_queue_rate_limit_set,
7474 (void *)&cmd_queue_rate_limit_port,
7475 (void *)&cmd_queue_rate_limit_portnum,
7476 (void *)&cmd_queue_rate_limit_queue,
7477 (void *)&cmd_queue_rate_limit_queuenum,
7478 (void *)&cmd_queue_rate_limit_rate,
7479 (void *)&cmd_queue_rate_limit_ratenum,
7484 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7485 struct cmd_vf_rate_limit_result {
7486 cmdline_fixed_string_t set;
7487 cmdline_fixed_string_t port;
7489 cmdline_fixed_string_t vf;
7491 cmdline_fixed_string_t rate;
7493 cmdline_fixed_string_t q_msk;
7497 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7498 __attribute__((unused)) struct cmdline *cl,
7499 __attribute__((unused)) void *data)
7501 struct cmd_vf_rate_limit_result *res = parsed_result;
7504 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7505 && (strcmp(res->vf, "vf") == 0)
7506 && (strcmp(res->rate, "rate") == 0)
7507 && (strcmp(res->q_msk, "queue_mask") == 0))
7508 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7509 res->rate_num, res->q_msk_val);
7511 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7515 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7516 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7518 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7519 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7521 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7522 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7524 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7525 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7527 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7528 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7530 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7531 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7533 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7534 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7536 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7537 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7538 q_msk, "queue_mask");
7539 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7540 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7543 cmdline_parse_inst_t cmd_vf_rate_limit = {
7544 .f = cmd_vf_rate_limit_parsed,
7546 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7547 "queue_mask <queue_mask_value>: "
7548 "Set rate limit for queues of VF on port_id",
7550 (void *)&cmd_vf_rate_limit_set,
7551 (void *)&cmd_vf_rate_limit_port,
7552 (void *)&cmd_vf_rate_limit_portnum,
7553 (void *)&cmd_vf_rate_limit_vf,
7554 (void *)&cmd_vf_rate_limit_vfnum,
7555 (void *)&cmd_vf_rate_limit_rate,
7556 (void *)&cmd_vf_rate_limit_ratenum,
7557 (void *)&cmd_vf_rate_limit_q_msk,
7558 (void *)&cmd_vf_rate_limit_q_msk_val,
7563 /* *** ADD TUNNEL FILTER OF A PORT *** */
7564 struct cmd_tunnel_filter_result {
7565 cmdline_fixed_string_t cmd;
7566 cmdline_fixed_string_t what;
7568 struct ether_addr outer_mac;
7569 struct ether_addr inner_mac;
7570 cmdline_ipaddr_t ip_value;
7571 uint16_t inner_vlan;
7572 cmdline_fixed_string_t tunnel_type;
7573 cmdline_fixed_string_t filter_type;
7579 cmd_tunnel_filter_parsed(void *parsed_result,
7580 __attribute__((unused)) struct cmdline *cl,
7581 __attribute__((unused)) void *data)
7583 struct cmd_tunnel_filter_result *res = parsed_result;
7584 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7587 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7589 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7590 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7591 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7593 if (res->ip_value.family == AF_INET) {
7594 tunnel_filter_conf.ip_addr.ipv4_addr =
7595 res->ip_value.addr.ipv4.s_addr;
7596 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7598 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7599 &(res->ip_value.addr.ipv6),
7600 sizeof(struct in6_addr));
7601 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7604 if (!strcmp(res->filter_type, "imac-ivlan"))
7605 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7606 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7607 tunnel_filter_conf.filter_type =
7608 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7609 else if (!strcmp(res->filter_type, "imac-tenid"))
7610 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7611 else if (!strcmp(res->filter_type, "imac"))
7612 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7613 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7614 tunnel_filter_conf.filter_type =
7615 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7616 else if (!strcmp(res->filter_type, "oip"))
7617 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7618 else if (!strcmp(res->filter_type, "iip"))
7619 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7621 printf("The filter type is not supported");
7625 if (!strcmp(res->tunnel_type, "vxlan"))
7626 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7627 else if (!strcmp(res->tunnel_type, "nvgre"))
7628 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7629 else if (!strcmp(res->tunnel_type, "ipingre"))
7630 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7632 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7636 tunnel_filter_conf.tenant_id = res->tenant_id;
7637 tunnel_filter_conf.queue_id = res->queue_num;
7638 if (!strcmp(res->what, "add"))
7639 ret = rte_eth_dev_filter_ctrl(res->port_id,
7640 RTE_ETH_FILTER_TUNNEL,
7642 &tunnel_filter_conf);
7644 ret = rte_eth_dev_filter_ctrl(res->port_id,
7645 RTE_ETH_FILTER_TUNNEL,
7646 RTE_ETH_FILTER_DELETE,
7647 &tunnel_filter_conf);
7649 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7653 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7654 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7655 cmd, "tunnel_filter");
7656 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7657 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7659 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7660 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7662 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7663 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7665 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7666 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7668 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7669 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7670 inner_vlan, UINT16);
7671 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7672 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7674 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7675 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7676 tunnel_type, "vxlan#nvgre#ipingre");
7678 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7679 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7680 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7681 "imac#omac-imac-tenid");
7682 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7683 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7685 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7686 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7689 cmdline_parse_inst_t cmd_tunnel_filter = {
7690 .f = cmd_tunnel_filter_parsed,
7692 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7693 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7694 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7695 "<queue_id>: Add/Rm tunnel filter of a port",
7697 (void *)&cmd_tunnel_filter_cmd,
7698 (void *)&cmd_tunnel_filter_what,
7699 (void *)&cmd_tunnel_filter_port_id,
7700 (void *)&cmd_tunnel_filter_outer_mac,
7701 (void *)&cmd_tunnel_filter_inner_mac,
7702 (void *)&cmd_tunnel_filter_ip_value,
7703 (void *)&cmd_tunnel_filter_innner_vlan,
7704 (void *)&cmd_tunnel_filter_tunnel_type,
7705 (void *)&cmd_tunnel_filter_filter_type,
7706 (void *)&cmd_tunnel_filter_tenant_id,
7707 (void *)&cmd_tunnel_filter_queue_num,
7712 /* *** CONFIGURE TUNNEL UDP PORT *** */
7713 struct cmd_tunnel_udp_config {
7714 cmdline_fixed_string_t cmd;
7715 cmdline_fixed_string_t what;
7721 cmd_tunnel_udp_config_parsed(void *parsed_result,
7722 __attribute__((unused)) struct cmdline *cl,
7723 __attribute__((unused)) void *data)
7725 struct cmd_tunnel_udp_config *res = parsed_result;
7726 struct rte_eth_udp_tunnel tunnel_udp;
7729 tunnel_udp.udp_port = res->udp_port;
7731 if (!strcmp(res->cmd, "rx_vxlan_port"))
7732 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7734 if (!strcmp(res->what, "add"))
7735 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7738 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7742 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7745 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7746 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7747 cmd, "rx_vxlan_port");
7748 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7749 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7751 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7752 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7754 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7755 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7758 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7759 .f = cmd_tunnel_udp_config_parsed,
7761 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7762 "Add/Remove a tunneling UDP port filter",
7764 (void *)&cmd_tunnel_udp_config_cmd,
7765 (void *)&cmd_tunnel_udp_config_what,
7766 (void *)&cmd_tunnel_udp_config_udp_port,
7767 (void *)&cmd_tunnel_udp_config_port_id,
7772 /* *** GLOBAL CONFIG *** */
7773 struct cmd_global_config_result {
7774 cmdline_fixed_string_t cmd;
7776 cmdline_fixed_string_t cfg_type;
7781 cmd_global_config_parsed(void *parsed_result,
7782 __attribute__((unused)) struct cmdline *cl,
7783 __attribute__((unused)) void *data)
7785 struct cmd_global_config_result *res = parsed_result;
7786 struct rte_eth_global_cfg conf;
7789 memset(&conf, 0, sizeof(conf));
7790 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7791 conf.cfg.gre_key_len = res->len;
7792 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7793 RTE_ETH_FILTER_SET, &conf);
7795 printf("Global config error\n");
7798 cmdline_parse_token_string_t cmd_global_config_cmd =
7799 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7801 cmdline_parse_token_num_t cmd_global_config_port_id =
7802 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7803 cmdline_parse_token_string_t cmd_global_config_type =
7804 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7805 cfg_type, "gre-key-len");
7806 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7807 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7810 cmdline_parse_inst_t cmd_global_config = {
7811 .f = cmd_global_config_parsed,
7812 .data = (void *)NULL,
7813 .help_str = "global_config <port_id> gre-key-len <key_len>",
7815 (void *)&cmd_global_config_cmd,
7816 (void *)&cmd_global_config_port_id,
7817 (void *)&cmd_global_config_type,
7818 (void *)&cmd_global_config_gre_key_len,
7823 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7824 struct cmd_set_mirror_mask_result {
7825 cmdline_fixed_string_t set;
7826 cmdline_fixed_string_t port;
7828 cmdline_fixed_string_t mirror;
7830 cmdline_fixed_string_t what;
7831 cmdline_fixed_string_t value;
7832 cmdline_fixed_string_t dstpool;
7834 cmdline_fixed_string_t on;
7837 cmdline_parse_token_string_t cmd_mirror_mask_set =
7838 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7840 cmdline_parse_token_string_t cmd_mirror_mask_port =
7841 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7843 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7844 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7846 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7847 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7848 mirror, "mirror-rule");
7849 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7850 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7852 cmdline_parse_token_string_t cmd_mirror_mask_what =
7853 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7854 what, "pool-mirror-up#pool-mirror-down"
7856 cmdline_parse_token_string_t cmd_mirror_mask_value =
7857 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7859 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7860 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7861 dstpool, "dst-pool");
7862 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7863 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7865 cmdline_parse_token_string_t cmd_mirror_mask_on =
7866 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7870 cmd_set_mirror_mask_parsed(void *parsed_result,
7871 __attribute__((unused)) struct cmdline *cl,
7872 __attribute__((unused)) void *data)
7875 struct cmd_set_mirror_mask_result *res = parsed_result;
7876 struct rte_eth_mirror_conf mr_conf;
7878 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7880 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7882 mr_conf.dst_pool = res->dstpool_id;
7884 if (!strcmp(res->what, "pool-mirror-up")) {
7885 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7886 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7887 } else if (!strcmp(res->what, "pool-mirror-down")) {
7888 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7889 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7890 } else if (!strcmp(res->what, "vlan-mirror")) {
7891 mr_conf.rule_type = ETH_MIRROR_VLAN;
7892 nb_item = parse_item_list(res->value, "vlan",
7893 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7897 for (i = 0; i < nb_item; i++) {
7898 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7899 printf("Invalid vlan_id: must be < 4096\n");
7903 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7904 mr_conf.vlan.vlan_mask |= 1ULL << i;
7908 if (!strcmp(res->on, "on"))
7909 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7912 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7915 printf("mirror rule add error: (%s)\n", strerror(-ret));
7918 cmdline_parse_inst_t cmd_set_mirror_mask = {
7919 .f = cmd_set_mirror_mask_parsed,
7921 .help_str = "set port <port_id> mirror-rule <rule_id> "
7922 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7923 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7925 (void *)&cmd_mirror_mask_set,
7926 (void *)&cmd_mirror_mask_port,
7927 (void *)&cmd_mirror_mask_portid,
7928 (void *)&cmd_mirror_mask_mirror,
7929 (void *)&cmd_mirror_mask_ruleid,
7930 (void *)&cmd_mirror_mask_what,
7931 (void *)&cmd_mirror_mask_value,
7932 (void *)&cmd_mirror_mask_dstpool,
7933 (void *)&cmd_mirror_mask_poolid,
7934 (void *)&cmd_mirror_mask_on,
7939 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7940 struct cmd_set_mirror_link_result {
7941 cmdline_fixed_string_t set;
7942 cmdline_fixed_string_t port;
7944 cmdline_fixed_string_t mirror;
7946 cmdline_fixed_string_t what;
7947 cmdline_fixed_string_t dstpool;
7949 cmdline_fixed_string_t on;
7952 cmdline_parse_token_string_t cmd_mirror_link_set =
7953 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7955 cmdline_parse_token_string_t cmd_mirror_link_port =
7956 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7958 cmdline_parse_token_num_t cmd_mirror_link_portid =
7959 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7961 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7962 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7963 mirror, "mirror-rule");
7964 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7965 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7967 cmdline_parse_token_string_t cmd_mirror_link_what =
7968 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7969 what, "uplink-mirror#downlink-mirror");
7970 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7971 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7972 dstpool, "dst-pool");
7973 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7974 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7976 cmdline_parse_token_string_t cmd_mirror_link_on =
7977 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7981 cmd_set_mirror_link_parsed(void *parsed_result,
7982 __attribute__((unused)) struct cmdline *cl,
7983 __attribute__((unused)) void *data)
7986 struct cmd_set_mirror_link_result *res = parsed_result;
7987 struct rte_eth_mirror_conf mr_conf;
7989 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7990 if (!strcmp(res->what, "uplink-mirror"))
7991 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7993 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7995 mr_conf.dst_pool = res->dstpool_id;
7997 if (!strcmp(res->on, "on"))
7998 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8001 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8004 /* check the return value and print it if is < 0 */
8006 printf("mirror rule add error: (%s)\n", strerror(-ret));
8010 cmdline_parse_inst_t cmd_set_mirror_link = {
8011 .f = cmd_set_mirror_link_parsed,
8013 .help_str = "set port <port_id> mirror-rule <rule_id> "
8014 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8016 (void *)&cmd_mirror_link_set,
8017 (void *)&cmd_mirror_link_port,
8018 (void *)&cmd_mirror_link_portid,
8019 (void *)&cmd_mirror_link_mirror,
8020 (void *)&cmd_mirror_link_ruleid,
8021 (void *)&cmd_mirror_link_what,
8022 (void *)&cmd_mirror_link_dstpool,
8023 (void *)&cmd_mirror_link_poolid,
8024 (void *)&cmd_mirror_link_on,
8029 /* *** RESET VM MIRROR RULE *** */
8030 struct cmd_rm_mirror_rule_result {
8031 cmdline_fixed_string_t reset;
8032 cmdline_fixed_string_t port;
8034 cmdline_fixed_string_t mirror;
8038 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8039 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8041 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8042 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8044 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8045 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8047 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8048 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8049 mirror, "mirror-rule");
8050 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8051 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8055 cmd_reset_mirror_rule_parsed(void *parsed_result,
8056 __attribute__((unused)) struct cmdline *cl,
8057 __attribute__((unused)) void *data)
8060 struct cmd_set_mirror_link_result *res = parsed_result;
8062 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8064 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8067 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8068 .f = cmd_reset_mirror_rule_parsed,
8070 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8072 (void *)&cmd_rm_mirror_rule_reset,
8073 (void *)&cmd_rm_mirror_rule_port,
8074 (void *)&cmd_rm_mirror_rule_portid,
8075 (void *)&cmd_rm_mirror_rule_mirror,
8076 (void *)&cmd_rm_mirror_rule_ruleid,
8081 /* ******************************************************************************** */
8083 struct cmd_dump_result {
8084 cmdline_fixed_string_t dump;
8088 dump_struct_sizes(void)
8090 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8091 DUMP_SIZE(struct rte_mbuf);
8092 DUMP_SIZE(struct rte_mempool);
8093 DUMP_SIZE(struct rte_ring);
8097 static void cmd_dump_parsed(void *parsed_result,
8098 __attribute__((unused)) struct cmdline *cl,
8099 __attribute__((unused)) void *data)
8101 struct cmd_dump_result *res = parsed_result;
8103 if (!strcmp(res->dump, "dump_physmem"))
8104 rte_dump_physmem_layout(stdout);
8105 else if (!strcmp(res->dump, "dump_memzone"))
8106 rte_memzone_dump(stdout);
8107 else if (!strcmp(res->dump, "dump_struct_sizes"))
8108 dump_struct_sizes();
8109 else if (!strcmp(res->dump, "dump_ring"))
8110 rte_ring_list_dump(stdout);
8111 else if (!strcmp(res->dump, "dump_mempool"))
8112 rte_mempool_list_dump(stdout);
8113 else if (!strcmp(res->dump, "dump_devargs"))
8114 rte_eal_devargs_dump(stdout);
8115 else if (!strcmp(res->dump, "dump_log_types"))
8116 rte_log_dump(stdout);
8119 cmdline_parse_token_string_t cmd_dump_dump =
8120 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8123 "dump_struct_sizes#"
8129 cmdline_parse_inst_t cmd_dump = {
8130 .f = cmd_dump_parsed, /* function to call */
8131 .data = NULL, /* 2nd arg of func */
8132 .help_str = "Dump status",
8133 .tokens = { /* token list, NULL terminated */
8134 (void *)&cmd_dump_dump,
8139 /* ******************************************************************************** */
8141 struct cmd_dump_one_result {
8142 cmdline_fixed_string_t dump;
8143 cmdline_fixed_string_t name;
8146 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8147 __attribute__((unused)) void *data)
8149 struct cmd_dump_one_result *res = parsed_result;
8151 if (!strcmp(res->dump, "dump_ring")) {
8153 r = rte_ring_lookup(res->name);
8155 cmdline_printf(cl, "Cannot find ring\n");
8158 rte_ring_dump(stdout, r);
8159 } else if (!strcmp(res->dump, "dump_mempool")) {
8160 struct rte_mempool *mp;
8161 mp = rte_mempool_lookup(res->name);
8163 cmdline_printf(cl, "Cannot find mempool\n");
8166 rte_mempool_dump(stdout, mp);
8170 cmdline_parse_token_string_t cmd_dump_one_dump =
8171 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8172 "dump_ring#dump_mempool");
8174 cmdline_parse_token_string_t cmd_dump_one_name =
8175 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8177 cmdline_parse_inst_t cmd_dump_one = {
8178 .f = cmd_dump_one_parsed, /* function to call */
8179 .data = NULL, /* 2nd arg of func */
8180 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8181 .tokens = { /* token list, NULL terminated */
8182 (void *)&cmd_dump_one_dump,
8183 (void *)&cmd_dump_one_name,
8188 /* *** Add/Del syn filter *** */
8189 struct cmd_syn_filter_result {
8190 cmdline_fixed_string_t filter;
8192 cmdline_fixed_string_t ops;
8193 cmdline_fixed_string_t priority;
8194 cmdline_fixed_string_t high;
8195 cmdline_fixed_string_t queue;
8200 cmd_syn_filter_parsed(void *parsed_result,
8201 __attribute__((unused)) struct cmdline *cl,
8202 __attribute__((unused)) void *data)
8204 struct cmd_syn_filter_result *res = parsed_result;
8205 struct rte_eth_syn_filter syn_filter;
8208 ret = rte_eth_dev_filter_supported(res->port_id,
8209 RTE_ETH_FILTER_SYN);
8211 printf("syn filter is not supported on port %u.\n",
8216 memset(&syn_filter, 0, sizeof(syn_filter));
8218 if (!strcmp(res->ops, "add")) {
8219 if (!strcmp(res->high, "high"))
8220 syn_filter.hig_pri = 1;
8222 syn_filter.hig_pri = 0;
8224 syn_filter.queue = res->queue_id;
8225 ret = rte_eth_dev_filter_ctrl(res->port_id,
8230 ret = rte_eth_dev_filter_ctrl(res->port_id,
8232 RTE_ETH_FILTER_DELETE,
8236 printf("syn filter programming error: (%s)\n",
8240 cmdline_parse_token_string_t cmd_syn_filter_filter =
8241 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8242 filter, "syn_filter");
8243 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8244 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8246 cmdline_parse_token_string_t cmd_syn_filter_ops =
8247 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8249 cmdline_parse_token_string_t cmd_syn_filter_priority =
8250 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8251 priority, "priority");
8252 cmdline_parse_token_string_t cmd_syn_filter_high =
8253 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8255 cmdline_parse_token_string_t cmd_syn_filter_queue =
8256 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8258 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8259 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8262 cmdline_parse_inst_t cmd_syn_filter = {
8263 .f = cmd_syn_filter_parsed,
8265 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8266 "<queue_id>: Add/Delete syn filter",
8268 (void *)&cmd_syn_filter_filter,
8269 (void *)&cmd_syn_filter_port_id,
8270 (void *)&cmd_syn_filter_ops,
8271 (void *)&cmd_syn_filter_priority,
8272 (void *)&cmd_syn_filter_high,
8273 (void *)&cmd_syn_filter_queue,
8274 (void *)&cmd_syn_filter_queue_id,
8279 /* *** ADD/REMOVE A 2tuple FILTER *** */
8280 struct cmd_2tuple_filter_result {
8281 cmdline_fixed_string_t filter;
8283 cmdline_fixed_string_t ops;
8284 cmdline_fixed_string_t dst_port;
8285 uint16_t dst_port_value;
8286 cmdline_fixed_string_t protocol;
8287 uint8_t protocol_value;
8288 cmdline_fixed_string_t mask;
8290 cmdline_fixed_string_t tcp_flags;
8291 uint8_t tcp_flags_value;
8292 cmdline_fixed_string_t priority;
8293 uint8_t priority_value;
8294 cmdline_fixed_string_t queue;
8299 cmd_2tuple_filter_parsed(void *parsed_result,
8300 __attribute__((unused)) struct cmdline *cl,
8301 __attribute__((unused)) void *data)
8303 struct rte_eth_ntuple_filter filter;
8304 struct cmd_2tuple_filter_result *res = parsed_result;
8307 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8309 printf("ntuple filter is not supported on port %u.\n",
8314 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8316 filter.flags = RTE_2TUPLE_FLAGS;
8317 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8318 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8319 filter.proto = res->protocol_value;
8320 filter.priority = res->priority_value;
8321 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8322 printf("nonzero tcp_flags is only meaningful"
8323 " when protocol is TCP.\n");
8326 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8327 printf("invalid TCP flags.\n");
8331 if (res->tcp_flags_value != 0) {
8332 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8333 filter.tcp_flags = res->tcp_flags_value;
8336 /* need convert to big endian. */
8337 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8338 filter.queue = res->queue_id;
8340 if (!strcmp(res->ops, "add"))
8341 ret = rte_eth_dev_filter_ctrl(res->port_id,
8342 RTE_ETH_FILTER_NTUPLE,
8346 ret = rte_eth_dev_filter_ctrl(res->port_id,
8347 RTE_ETH_FILTER_NTUPLE,
8348 RTE_ETH_FILTER_DELETE,
8351 printf("2tuple filter programming error: (%s)\n",
8356 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
8357 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8358 filter, "2tuple_filter");
8359 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
8360 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8362 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
8363 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8365 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
8366 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8367 dst_port, "dst_port");
8368 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
8369 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8370 dst_port_value, UINT16);
8371 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
8372 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8373 protocol, "protocol");
8374 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
8375 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8376 protocol_value, UINT8);
8377 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8378 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8380 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8381 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8383 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8384 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8385 tcp_flags, "tcp_flags");
8386 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8387 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8388 tcp_flags_value, UINT8);
8389 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8390 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8391 priority, "priority");
8392 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8393 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8394 priority_value, UINT8);
8395 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8396 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8398 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8399 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8402 cmdline_parse_inst_t cmd_2tuple_filter = {
8403 .f = cmd_2tuple_filter_parsed,
8405 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8406 "<value> mask <value> tcp_flags <value> priority <value> queue "
8407 "<queue_id>: Add a 2tuple filter",
8409 (void *)&cmd_2tuple_filter_filter,
8410 (void *)&cmd_2tuple_filter_port_id,
8411 (void *)&cmd_2tuple_filter_ops,
8412 (void *)&cmd_2tuple_filter_dst_port,
8413 (void *)&cmd_2tuple_filter_dst_port_value,
8414 (void *)&cmd_2tuple_filter_protocol,
8415 (void *)&cmd_2tuple_filter_protocol_value,
8416 (void *)&cmd_2tuple_filter_mask,
8417 (void *)&cmd_2tuple_filter_mask_value,
8418 (void *)&cmd_2tuple_filter_tcp_flags,
8419 (void *)&cmd_2tuple_filter_tcp_flags_value,
8420 (void *)&cmd_2tuple_filter_priority,
8421 (void *)&cmd_2tuple_filter_priority_value,
8422 (void *)&cmd_2tuple_filter_queue,
8423 (void *)&cmd_2tuple_filter_queue_id,
8428 /* *** ADD/REMOVE A 5tuple FILTER *** */
8429 struct cmd_5tuple_filter_result {
8430 cmdline_fixed_string_t filter;
8432 cmdline_fixed_string_t ops;
8433 cmdline_fixed_string_t dst_ip;
8434 cmdline_ipaddr_t dst_ip_value;
8435 cmdline_fixed_string_t src_ip;
8436 cmdline_ipaddr_t src_ip_value;
8437 cmdline_fixed_string_t dst_port;
8438 uint16_t dst_port_value;
8439 cmdline_fixed_string_t src_port;
8440 uint16_t src_port_value;
8441 cmdline_fixed_string_t protocol;
8442 uint8_t protocol_value;
8443 cmdline_fixed_string_t mask;
8445 cmdline_fixed_string_t tcp_flags;
8446 uint8_t tcp_flags_value;
8447 cmdline_fixed_string_t priority;
8448 uint8_t priority_value;
8449 cmdline_fixed_string_t queue;
8454 cmd_5tuple_filter_parsed(void *parsed_result,
8455 __attribute__((unused)) struct cmdline *cl,
8456 __attribute__((unused)) void *data)
8458 struct rte_eth_ntuple_filter filter;
8459 struct cmd_5tuple_filter_result *res = parsed_result;
8462 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8464 printf("ntuple filter is not supported on port %u.\n",
8469 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8471 filter.flags = RTE_5TUPLE_FLAGS;
8472 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8473 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8474 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8475 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8476 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8477 filter.proto = res->protocol_value;
8478 filter.priority = res->priority_value;
8479 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8480 printf("nonzero tcp_flags is only meaningful"
8481 " when protocol is TCP.\n");
8484 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8485 printf("invalid TCP flags.\n");
8489 if (res->tcp_flags_value != 0) {
8490 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8491 filter.tcp_flags = res->tcp_flags_value;
8494 if (res->dst_ip_value.family == AF_INET)
8495 /* no need to convert, already big endian. */
8496 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8498 if (filter.dst_ip_mask == 0) {
8499 printf("can not support ipv6 involved compare.\n");
8505 if (res->src_ip_value.family == AF_INET)
8506 /* no need to convert, already big endian. */
8507 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8509 if (filter.src_ip_mask == 0) {
8510 printf("can not support ipv6 involved compare.\n");
8515 /* need convert to big endian. */
8516 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8517 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8518 filter.queue = res->queue_id;
8520 if (!strcmp(res->ops, "add"))
8521 ret = rte_eth_dev_filter_ctrl(res->port_id,
8522 RTE_ETH_FILTER_NTUPLE,
8526 ret = rte_eth_dev_filter_ctrl(res->port_id,
8527 RTE_ETH_FILTER_NTUPLE,
8528 RTE_ETH_FILTER_DELETE,
8531 printf("5tuple filter programming error: (%s)\n",
8535 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8536 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8537 filter, "5tuple_filter");
8538 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8539 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8541 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8542 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8544 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8545 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8547 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8548 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8550 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8551 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8553 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8554 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8556 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8557 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8558 dst_port, "dst_port");
8559 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8560 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8561 dst_port_value, UINT16);
8562 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8563 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8564 src_port, "src_port");
8565 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8566 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8567 src_port_value, UINT16);
8568 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8569 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8570 protocol, "protocol");
8571 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8572 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8573 protocol_value, UINT8);
8574 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8575 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8577 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8578 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8580 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8581 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8582 tcp_flags, "tcp_flags");
8583 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8584 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8585 tcp_flags_value, UINT8);
8586 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8587 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8588 priority, "priority");
8589 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8590 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8591 priority_value, UINT8);
8592 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8593 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8595 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8596 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8599 cmdline_parse_inst_t cmd_5tuple_filter = {
8600 .f = cmd_5tuple_filter_parsed,
8602 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8603 "src_ip <value> dst_port <value> src_port <value> "
8604 "protocol <value> mask <value> tcp_flags <value> "
8605 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8607 (void *)&cmd_5tuple_filter_filter,
8608 (void *)&cmd_5tuple_filter_port_id,
8609 (void *)&cmd_5tuple_filter_ops,
8610 (void *)&cmd_5tuple_filter_dst_ip,
8611 (void *)&cmd_5tuple_filter_dst_ip_value,
8612 (void *)&cmd_5tuple_filter_src_ip,
8613 (void *)&cmd_5tuple_filter_src_ip_value,
8614 (void *)&cmd_5tuple_filter_dst_port,
8615 (void *)&cmd_5tuple_filter_dst_port_value,
8616 (void *)&cmd_5tuple_filter_src_port,
8617 (void *)&cmd_5tuple_filter_src_port_value,
8618 (void *)&cmd_5tuple_filter_protocol,
8619 (void *)&cmd_5tuple_filter_protocol_value,
8620 (void *)&cmd_5tuple_filter_mask,
8621 (void *)&cmd_5tuple_filter_mask_value,
8622 (void *)&cmd_5tuple_filter_tcp_flags,
8623 (void *)&cmd_5tuple_filter_tcp_flags_value,
8624 (void *)&cmd_5tuple_filter_priority,
8625 (void *)&cmd_5tuple_filter_priority_value,
8626 (void *)&cmd_5tuple_filter_queue,
8627 (void *)&cmd_5tuple_filter_queue_id,
8632 /* *** ADD/REMOVE A flex FILTER *** */
8633 struct cmd_flex_filter_result {
8634 cmdline_fixed_string_t filter;
8635 cmdline_fixed_string_t ops;
8637 cmdline_fixed_string_t len;
8639 cmdline_fixed_string_t bytes;
8640 cmdline_fixed_string_t bytes_value;
8641 cmdline_fixed_string_t mask;
8642 cmdline_fixed_string_t mask_value;
8643 cmdline_fixed_string_t priority;
8644 uint8_t priority_value;
8645 cmdline_fixed_string_t queue;
8649 static int xdigit2val(unsigned char c)
8654 else if (isupper(c))
8662 cmd_flex_filter_parsed(void *parsed_result,
8663 __attribute__((unused)) struct cmdline *cl,
8664 __attribute__((unused)) void *data)
8667 struct rte_eth_flex_filter filter;
8668 struct cmd_flex_filter_result *res = parsed_result;
8669 char *bytes_ptr, *mask_ptr;
8670 uint16_t len, i, j = 0;
8675 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8676 printf("the len exceed the max length 128\n");
8679 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8680 filter.len = res->len_value;
8681 filter.priority = res->priority_value;
8682 filter.queue = res->queue_id;
8683 bytes_ptr = res->bytes_value;
8684 mask_ptr = res->mask_value;
8686 /* translate bytes string to array. */
8687 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8688 (bytes_ptr[1] == 'X')))
8690 len = strnlen(bytes_ptr, res->len_value * 2);
8691 if (len == 0 || (len % 8 != 0)) {
8692 printf("please check len and bytes input\n");
8695 for (i = 0; i < len; i++) {
8697 if (isxdigit(c) == 0) {
8698 /* invalid characters. */
8699 printf("invalid input\n");
8702 val = xdigit2val(c);
8705 filter.bytes[j] = byte;
8706 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8713 /* translate mask string to uint8_t array. */
8714 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8715 (mask_ptr[1] == 'X')))
8717 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8719 printf("invalid input\n");
8724 for (i = 0; i < len; i++) {
8726 if (isxdigit(c) == 0) {
8727 /* invalid characters. */
8728 printf("invalid input\n");
8731 val = xdigit2val(c);
8734 filter.mask[j] = byte;
8735 printf("mask[%d]:%02x ", j, filter.mask[j]);
8743 if (!strcmp(res->ops, "add"))
8744 ret = rte_eth_dev_filter_ctrl(res->port_id,
8745 RTE_ETH_FILTER_FLEXIBLE,
8749 ret = rte_eth_dev_filter_ctrl(res->port_id,
8750 RTE_ETH_FILTER_FLEXIBLE,
8751 RTE_ETH_FILTER_DELETE,
8755 printf("flex filter setting error: (%s)\n", strerror(-ret));
8758 cmdline_parse_token_string_t cmd_flex_filter_filter =
8759 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8760 filter, "flex_filter");
8761 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8762 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8764 cmdline_parse_token_string_t cmd_flex_filter_ops =
8765 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8767 cmdline_parse_token_string_t cmd_flex_filter_len =
8768 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8770 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8771 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8773 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8774 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8776 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8777 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8779 cmdline_parse_token_string_t cmd_flex_filter_mask =
8780 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8782 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8783 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8785 cmdline_parse_token_string_t cmd_flex_filter_priority =
8786 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8787 priority, "priority");
8788 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8789 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8790 priority_value, UINT8);
8791 cmdline_parse_token_string_t cmd_flex_filter_queue =
8792 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8794 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8795 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8797 cmdline_parse_inst_t cmd_flex_filter = {
8798 .f = cmd_flex_filter_parsed,
8800 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8801 "<value> mask <value> priority <value> queue <queue_id>: "
8802 "Add/Del a flex filter",
8804 (void *)&cmd_flex_filter_filter,
8805 (void *)&cmd_flex_filter_port_id,
8806 (void *)&cmd_flex_filter_ops,
8807 (void *)&cmd_flex_filter_len,
8808 (void *)&cmd_flex_filter_len_value,
8809 (void *)&cmd_flex_filter_bytes,
8810 (void *)&cmd_flex_filter_bytes_value,
8811 (void *)&cmd_flex_filter_mask,
8812 (void *)&cmd_flex_filter_mask_value,
8813 (void *)&cmd_flex_filter_priority,
8814 (void *)&cmd_flex_filter_priority_value,
8815 (void *)&cmd_flex_filter_queue,
8816 (void *)&cmd_flex_filter_queue_id,
8821 /* *** Filters Control *** */
8823 /* *** deal with ethertype filter *** */
8824 struct cmd_ethertype_filter_result {
8825 cmdline_fixed_string_t filter;
8827 cmdline_fixed_string_t ops;
8828 cmdline_fixed_string_t mac;
8829 struct ether_addr mac_addr;
8830 cmdline_fixed_string_t ethertype;
8831 uint16_t ethertype_value;
8832 cmdline_fixed_string_t drop;
8833 cmdline_fixed_string_t queue;
8837 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8838 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8839 filter, "ethertype_filter");
8840 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8841 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8843 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8844 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8846 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8847 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8848 mac, "mac_addr#mac_ignr");
8849 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8850 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8852 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8853 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8854 ethertype, "ethertype");
8855 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8856 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8857 ethertype_value, UINT16);
8858 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8859 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8861 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8862 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8864 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8865 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8869 cmd_ethertype_filter_parsed(void *parsed_result,
8870 __attribute__((unused)) struct cmdline *cl,
8871 __attribute__((unused)) void *data)
8873 struct cmd_ethertype_filter_result *res = parsed_result;
8874 struct rte_eth_ethertype_filter filter;
8877 ret = rte_eth_dev_filter_supported(res->port_id,
8878 RTE_ETH_FILTER_ETHERTYPE);
8880 printf("ethertype filter is not supported on port %u.\n",
8885 memset(&filter, 0, sizeof(filter));
8886 if (!strcmp(res->mac, "mac_addr")) {
8887 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8888 rte_memcpy(&filter.mac_addr, &res->mac_addr,
8889 sizeof(struct ether_addr));
8891 if (!strcmp(res->drop, "drop"))
8892 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8893 filter.ether_type = res->ethertype_value;
8894 filter.queue = res->queue_id;
8896 if (!strcmp(res->ops, "add"))
8897 ret = rte_eth_dev_filter_ctrl(res->port_id,
8898 RTE_ETH_FILTER_ETHERTYPE,
8902 ret = rte_eth_dev_filter_ctrl(res->port_id,
8903 RTE_ETH_FILTER_ETHERTYPE,
8904 RTE_ETH_FILTER_DELETE,
8907 printf("ethertype filter programming error: (%s)\n",
8911 cmdline_parse_inst_t cmd_ethertype_filter = {
8912 .f = cmd_ethertype_filter_parsed,
8914 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8915 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8916 "Add or delete an ethertype filter entry",
8918 (void *)&cmd_ethertype_filter_filter,
8919 (void *)&cmd_ethertype_filter_port_id,
8920 (void *)&cmd_ethertype_filter_ops,
8921 (void *)&cmd_ethertype_filter_mac,
8922 (void *)&cmd_ethertype_filter_mac_addr,
8923 (void *)&cmd_ethertype_filter_ethertype,
8924 (void *)&cmd_ethertype_filter_ethertype_value,
8925 (void *)&cmd_ethertype_filter_drop,
8926 (void *)&cmd_ethertype_filter_queue,
8927 (void *)&cmd_ethertype_filter_queue_id,
8932 /* *** deal with flow director filter *** */
8933 struct cmd_flow_director_result {
8934 cmdline_fixed_string_t flow_director_filter;
8936 cmdline_fixed_string_t mode;
8937 cmdline_fixed_string_t mode_value;
8938 cmdline_fixed_string_t ops;
8939 cmdline_fixed_string_t flow;
8940 cmdline_fixed_string_t flow_type;
8941 cmdline_fixed_string_t ether;
8942 uint16_t ether_type;
8943 cmdline_fixed_string_t src;
8944 cmdline_ipaddr_t ip_src;
8946 cmdline_fixed_string_t dst;
8947 cmdline_ipaddr_t ip_dst;
8949 cmdline_fixed_string_t verify_tag;
8950 uint32_t verify_tag_value;
8951 cmdline_ipaddr_t tos;
8953 cmdline_ipaddr_t proto;
8954 uint8_t proto_value;
8955 cmdline_ipaddr_t ttl;
8957 cmdline_fixed_string_t vlan;
8958 uint16_t vlan_value;
8959 cmdline_fixed_string_t flexbytes;
8960 cmdline_fixed_string_t flexbytes_value;
8961 cmdline_fixed_string_t pf_vf;
8962 cmdline_fixed_string_t drop;
8963 cmdline_fixed_string_t queue;
8965 cmdline_fixed_string_t fd_id;
8966 uint32_t fd_id_value;
8967 cmdline_fixed_string_t mac;
8968 struct ether_addr mac_addr;
8969 cmdline_fixed_string_t tunnel;
8970 cmdline_fixed_string_t tunnel_type;
8971 cmdline_fixed_string_t tunnel_id;
8972 uint32_t tunnel_id_value;
8976 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8979 const char *p, *p0 = q_arg;
8981 unsigned long int_fld;
8982 char *str_fld[max_num];
8987 p = strchr(p0, '(');
8991 p0 = strchr(p, ')');
8996 if (size >= sizeof(s))
8999 snprintf(s, sizeof(s), "%.*s", size, p);
9000 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9001 if (ret < 0 || ret > max_num)
9003 for (i = 0; i < ret; i++) {
9005 int_fld = strtoul(str_fld[i], &end, 0);
9006 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9008 flexbytes[i] = (uint8_t)int_fld;
9014 str2flowtype(char *string)
9017 static const struct {
9020 } flowtype_str[] = {
9021 {"raw", RTE_ETH_FLOW_RAW},
9022 {"ipv4", RTE_ETH_FLOW_IPV4},
9023 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9024 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9025 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9026 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9027 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9028 {"ipv6", RTE_ETH_FLOW_IPV6},
9029 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9030 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9031 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9032 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9033 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9034 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9037 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9038 if (!strcmp(flowtype_str[i].str, string))
9039 return flowtype_str[i].type;
9042 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9043 return (uint16_t)atoi(string);
9045 return RTE_ETH_FLOW_UNKNOWN;
9048 static enum rte_eth_fdir_tunnel_type
9049 str2fdir_tunneltype(char *string)
9053 static const struct {
9055 enum rte_eth_fdir_tunnel_type type;
9056 } tunneltype_str[] = {
9057 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9058 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9061 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9062 if (!strcmp(tunneltype_str[i].str, string))
9063 return tunneltype_str[i].type;
9065 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9068 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9070 if ((ip_addr).family == AF_INET) \
9071 (ip) = (ip_addr).addr.ipv4.s_addr; \
9073 printf("invalid parameter.\n"); \
9078 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9080 if ((ip_addr).family == AF_INET6) \
9082 &((ip_addr).addr.ipv6), \
9083 sizeof(struct in6_addr)); \
9085 printf("invalid parameter.\n"); \
9091 cmd_flow_director_filter_parsed(void *parsed_result,
9092 __attribute__((unused)) struct cmdline *cl,
9093 __attribute__((unused)) void *data)
9095 struct cmd_flow_director_result *res = parsed_result;
9096 struct rte_eth_fdir_filter entry;
9097 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9099 unsigned long vf_id;
9102 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9104 printf("flow director is not supported on port %u.\n",
9108 memset(flexbytes, 0, sizeof(flexbytes));
9109 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9111 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9112 if (strcmp(res->mode_value, "MAC-VLAN")) {
9113 printf("Please set mode to MAC-VLAN.\n");
9116 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9117 if (strcmp(res->mode_value, "Tunnel")) {
9118 printf("Please set mode to Tunnel.\n");
9122 if (strcmp(res->mode_value, "IP")) {
9123 printf("Please set mode to IP.\n");
9126 entry.input.flow_type = str2flowtype(res->flow_type);
9129 ret = parse_flexbytes(res->flexbytes_value,
9131 RTE_ETH_FDIR_MAX_FLEXLEN);
9133 printf("error: Cannot parse flexbytes input.\n");
9137 switch (entry.input.flow_type) {
9138 case RTE_ETH_FLOW_FRAG_IPV4:
9139 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9140 entry.input.flow.ip4_flow.proto = res->proto_value;
9142 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9143 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9144 IPV4_ADDR_TO_UINT(res->ip_dst,
9145 entry.input.flow.ip4_flow.dst_ip);
9146 IPV4_ADDR_TO_UINT(res->ip_src,
9147 entry.input.flow.ip4_flow.src_ip);
9148 entry.input.flow.ip4_flow.tos = res->tos_value;
9149 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9150 /* need convert to big endian. */
9151 entry.input.flow.udp4_flow.dst_port =
9152 rte_cpu_to_be_16(res->port_dst);
9153 entry.input.flow.udp4_flow.src_port =
9154 rte_cpu_to_be_16(res->port_src);
9156 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9157 IPV4_ADDR_TO_UINT(res->ip_dst,
9158 entry.input.flow.sctp4_flow.ip.dst_ip);
9159 IPV4_ADDR_TO_UINT(res->ip_src,
9160 entry.input.flow.sctp4_flow.ip.src_ip);
9161 entry.input.flow.ip4_flow.tos = res->tos_value;
9162 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9163 /* need convert to big endian. */
9164 entry.input.flow.sctp4_flow.dst_port =
9165 rte_cpu_to_be_16(res->port_dst);
9166 entry.input.flow.sctp4_flow.src_port =
9167 rte_cpu_to_be_16(res->port_src);
9168 entry.input.flow.sctp4_flow.verify_tag =
9169 rte_cpu_to_be_32(res->verify_tag_value);
9171 case RTE_ETH_FLOW_FRAG_IPV6:
9172 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9173 entry.input.flow.ipv6_flow.proto = res->proto_value;
9175 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9176 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9177 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9178 entry.input.flow.ipv6_flow.dst_ip);
9179 IPV6_ADDR_TO_ARRAY(res->ip_src,
9180 entry.input.flow.ipv6_flow.src_ip);
9181 entry.input.flow.ipv6_flow.tc = res->tos_value;
9182 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9183 /* need convert to big endian. */
9184 entry.input.flow.udp6_flow.dst_port =
9185 rte_cpu_to_be_16(res->port_dst);
9186 entry.input.flow.udp6_flow.src_port =
9187 rte_cpu_to_be_16(res->port_src);
9189 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9190 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9191 entry.input.flow.sctp6_flow.ip.dst_ip);
9192 IPV6_ADDR_TO_ARRAY(res->ip_src,
9193 entry.input.flow.sctp6_flow.ip.src_ip);
9194 entry.input.flow.ipv6_flow.tc = res->tos_value;
9195 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9196 /* need convert to big endian. */
9197 entry.input.flow.sctp6_flow.dst_port =
9198 rte_cpu_to_be_16(res->port_dst);
9199 entry.input.flow.sctp6_flow.src_port =
9200 rte_cpu_to_be_16(res->port_src);
9201 entry.input.flow.sctp6_flow.verify_tag =
9202 rte_cpu_to_be_32(res->verify_tag_value);
9204 case RTE_ETH_FLOW_L2_PAYLOAD:
9205 entry.input.flow.l2_flow.ether_type =
9206 rte_cpu_to_be_16(res->ether_type);
9212 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
9213 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
9215 sizeof(struct ether_addr));
9217 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9218 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
9220 sizeof(struct ether_addr));
9221 entry.input.flow.tunnel_flow.tunnel_type =
9222 str2fdir_tunneltype(res->tunnel_type);
9223 entry.input.flow.tunnel_flow.tunnel_id =
9224 rte_cpu_to_be_32(res->tunnel_id_value);
9227 rte_memcpy(entry.input.flow_ext.flexbytes,
9229 RTE_ETH_FDIR_MAX_FLEXLEN);
9231 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
9233 entry.action.flex_off = 0; /*use 0 by default */
9234 if (!strcmp(res->drop, "drop"))
9235 entry.action.behavior = RTE_ETH_FDIR_REJECT;
9237 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
9239 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
9240 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
9241 if (!strcmp(res->pf_vf, "pf"))
9242 entry.input.flow_ext.is_vf = 0;
9243 else if (!strncmp(res->pf_vf, "vf", 2)) {
9244 struct rte_eth_dev_info dev_info;
9246 memset(&dev_info, 0, sizeof(dev_info));
9247 rte_eth_dev_info_get(res->port_id, &dev_info);
9249 vf_id = strtoul(res->pf_vf + 2, &end, 10);
9250 if (errno != 0 || *end != '\0' ||
9251 vf_id >= dev_info.max_vfs) {
9252 printf("invalid parameter %s.\n", res->pf_vf);
9255 entry.input.flow_ext.is_vf = 1;
9256 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
9258 printf("invalid parameter %s.\n", res->pf_vf);
9263 /* set to report FD ID by default */
9264 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
9265 entry.action.rx_queue = res->queue_id;
9266 entry.soft_id = res->fd_id_value;
9267 if (!strcmp(res->ops, "add"))
9268 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9269 RTE_ETH_FILTER_ADD, &entry);
9270 else if (!strcmp(res->ops, "del"))
9271 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9272 RTE_ETH_FILTER_DELETE, &entry);
9274 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9275 RTE_ETH_FILTER_UPDATE, &entry);
9277 printf("flow director programming error: (%s)\n",
9281 cmdline_parse_token_string_t cmd_flow_director_filter =
9282 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9283 flow_director_filter, "flow_director_filter");
9284 cmdline_parse_token_num_t cmd_flow_director_port_id =
9285 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9287 cmdline_parse_token_string_t cmd_flow_director_ops =
9288 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9289 ops, "add#del#update");
9290 cmdline_parse_token_string_t cmd_flow_director_flow =
9291 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9293 cmdline_parse_token_string_t cmd_flow_director_flow_type =
9294 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9295 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9296 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
9297 cmdline_parse_token_string_t cmd_flow_director_ether =
9298 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9300 cmdline_parse_token_num_t cmd_flow_director_ether_type =
9301 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9302 ether_type, UINT16);
9303 cmdline_parse_token_string_t cmd_flow_director_src =
9304 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9306 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
9307 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9309 cmdline_parse_token_num_t cmd_flow_director_port_src =
9310 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9312 cmdline_parse_token_string_t cmd_flow_director_dst =
9313 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9315 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
9316 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9318 cmdline_parse_token_num_t cmd_flow_director_port_dst =
9319 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9321 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
9322 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9323 verify_tag, "verify_tag");
9324 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
9325 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9326 verify_tag_value, UINT32);
9327 cmdline_parse_token_string_t cmd_flow_director_tos =
9328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9330 cmdline_parse_token_num_t cmd_flow_director_tos_value =
9331 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9333 cmdline_parse_token_string_t cmd_flow_director_proto =
9334 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9336 cmdline_parse_token_num_t cmd_flow_director_proto_value =
9337 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9338 proto_value, UINT8);
9339 cmdline_parse_token_string_t cmd_flow_director_ttl =
9340 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9342 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
9343 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9345 cmdline_parse_token_string_t cmd_flow_director_vlan =
9346 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9348 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
9349 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9350 vlan_value, UINT16);
9351 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
9352 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9353 flexbytes, "flexbytes");
9354 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
9355 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9356 flexbytes_value, NULL);
9357 cmdline_parse_token_string_t cmd_flow_director_drop =
9358 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9360 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
9361 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9363 cmdline_parse_token_string_t cmd_flow_director_queue =
9364 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9366 cmdline_parse_token_num_t cmd_flow_director_queue_id =
9367 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9369 cmdline_parse_token_string_t cmd_flow_director_fd_id =
9370 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9372 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
9373 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9374 fd_id_value, UINT32);
9376 cmdline_parse_token_string_t cmd_flow_director_mode =
9377 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9379 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
9380 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9382 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9383 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9384 mode_value, "MAC-VLAN");
9385 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9386 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9387 mode_value, "Tunnel");
9388 cmdline_parse_token_string_t cmd_flow_director_mac =
9389 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9391 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9392 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9394 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9395 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9397 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9398 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9399 tunnel_type, "NVGRE#VxLAN");
9400 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9401 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9402 tunnel_id, "tunnel-id");
9403 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9404 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9405 tunnel_id_value, UINT32);
9407 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9408 .f = cmd_flow_director_filter_parsed,
9410 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9411 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9412 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9413 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9414 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9415 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9416 "fd_id <fd_id_value>: "
9417 "Add or delete an ip flow director entry on NIC",
9419 (void *)&cmd_flow_director_filter,
9420 (void *)&cmd_flow_director_port_id,
9421 (void *)&cmd_flow_director_mode,
9422 (void *)&cmd_flow_director_mode_ip,
9423 (void *)&cmd_flow_director_ops,
9424 (void *)&cmd_flow_director_flow,
9425 (void *)&cmd_flow_director_flow_type,
9426 (void *)&cmd_flow_director_src,
9427 (void *)&cmd_flow_director_ip_src,
9428 (void *)&cmd_flow_director_dst,
9429 (void *)&cmd_flow_director_ip_dst,
9430 (void *)&cmd_flow_director_tos,
9431 (void *)&cmd_flow_director_tos_value,
9432 (void *)&cmd_flow_director_proto,
9433 (void *)&cmd_flow_director_proto_value,
9434 (void *)&cmd_flow_director_ttl,
9435 (void *)&cmd_flow_director_ttl_value,
9436 (void *)&cmd_flow_director_vlan,
9437 (void *)&cmd_flow_director_vlan_value,
9438 (void *)&cmd_flow_director_flexbytes,
9439 (void *)&cmd_flow_director_flexbytes_value,
9440 (void *)&cmd_flow_director_drop,
9441 (void *)&cmd_flow_director_pf_vf,
9442 (void *)&cmd_flow_director_queue,
9443 (void *)&cmd_flow_director_queue_id,
9444 (void *)&cmd_flow_director_fd_id,
9445 (void *)&cmd_flow_director_fd_id_value,
9450 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9451 .f = cmd_flow_director_filter_parsed,
9453 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9454 "director entry on NIC",
9456 (void *)&cmd_flow_director_filter,
9457 (void *)&cmd_flow_director_port_id,
9458 (void *)&cmd_flow_director_mode,
9459 (void *)&cmd_flow_director_mode_ip,
9460 (void *)&cmd_flow_director_ops,
9461 (void *)&cmd_flow_director_flow,
9462 (void *)&cmd_flow_director_flow_type,
9463 (void *)&cmd_flow_director_src,
9464 (void *)&cmd_flow_director_ip_src,
9465 (void *)&cmd_flow_director_port_src,
9466 (void *)&cmd_flow_director_dst,
9467 (void *)&cmd_flow_director_ip_dst,
9468 (void *)&cmd_flow_director_port_dst,
9469 (void *)&cmd_flow_director_tos,
9470 (void *)&cmd_flow_director_tos_value,
9471 (void *)&cmd_flow_director_ttl,
9472 (void *)&cmd_flow_director_ttl_value,
9473 (void *)&cmd_flow_director_vlan,
9474 (void *)&cmd_flow_director_vlan_value,
9475 (void *)&cmd_flow_director_flexbytes,
9476 (void *)&cmd_flow_director_flexbytes_value,
9477 (void *)&cmd_flow_director_drop,
9478 (void *)&cmd_flow_director_pf_vf,
9479 (void *)&cmd_flow_director_queue,
9480 (void *)&cmd_flow_director_queue_id,
9481 (void *)&cmd_flow_director_fd_id,
9482 (void *)&cmd_flow_director_fd_id_value,
9487 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9488 .f = cmd_flow_director_filter_parsed,
9490 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9491 "director entry on NIC",
9493 (void *)&cmd_flow_director_filter,
9494 (void *)&cmd_flow_director_port_id,
9495 (void *)&cmd_flow_director_mode,
9496 (void *)&cmd_flow_director_mode_ip,
9497 (void *)&cmd_flow_director_ops,
9498 (void *)&cmd_flow_director_flow,
9499 (void *)&cmd_flow_director_flow_type,
9500 (void *)&cmd_flow_director_src,
9501 (void *)&cmd_flow_director_ip_src,
9502 (void *)&cmd_flow_director_port_dst,
9503 (void *)&cmd_flow_director_dst,
9504 (void *)&cmd_flow_director_ip_dst,
9505 (void *)&cmd_flow_director_port_dst,
9506 (void *)&cmd_flow_director_verify_tag,
9507 (void *)&cmd_flow_director_verify_tag_value,
9508 (void *)&cmd_flow_director_tos,
9509 (void *)&cmd_flow_director_tos_value,
9510 (void *)&cmd_flow_director_ttl,
9511 (void *)&cmd_flow_director_ttl_value,
9512 (void *)&cmd_flow_director_vlan,
9513 (void *)&cmd_flow_director_vlan_value,
9514 (void *)&cmd_flow_director_flexbytes,
9515 (void *)&cmd_flow_director_flexbytes_value,
9516 (void *)&cmd_flow_director_drop,
9517 (void *)&cmd_flow_director_pf_vf,
9518 (void *)&cmd_flow_director_queue,
9519 (void *)&cmd_flow_director_queue_id,
9520 (void *)&cmd_flow_director_fd_id,
9521 (void *)&cmd_flow_director_fd_id_value,
9526 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9527 .f = cmd_flow_director_filter_parsed,
9529 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9530 "director entry on NIC",
9532 (void *)&cmd_flow_director_filter,
9533 (void *)&cmd_flow_director_port_id,
9534 (void *)&cmd_flow_director_mode,
9535 (void *)&cmd_flow_director_mode_ip,
9536 (void *)&cmd_flow_director_ops,
9537 (void *)&cmd_flow_director_flow,
9538 (void *)&cmd_flow_director_flow_type,
9539 (void *)&cmd_flow_director_ether,
9540 (void *)&cmd_flow_director_ether_type,
9541 (void *)&cmd_flow_director_flexbytes,
9542 (void *)&cmd_flow_director_flexbytes_value,
9543 (void *)&cmd_flow_director_drop,
9544 (void *)&cmd_flow_director_pf_vf,
9545 (void *)&cmd_flow_director_queue,
9546 (void *)&cmd_flow_director_queue_id,
9547 (void *)&cmd_flow_director_fd_id,
9548 (void *)&cmd_flow_director_fd_id_value,
9553 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9554 .f = cmd_flow_director_filter_parsed,
9556 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9557 "director entry on NIC",
9559 (void *)&cmd_flow_director_filter,
9560 (void *)&cmd_flow_director_port_id,
9561 (void *)&cmd_flow_director_mode,
9562 (void *)&cmd_flow_director_mode_mac_vlan,
9563 (void *)&cmd_flow_director_ops,
9564 (void *)&cmd_flow_director_mac,
9565 (void *)&cmd_flow_director_mac_addr,
9566 (void *)&cmd_flow_director_vlan,
9567 (void *)&cmd_flow_director_vlan_value,
9568 (void *)&cmd_flow_director_flexbytes,
9569 (void *)&cmd_flow_director_flexbytes_value,
9570 (void *)&cmd_flow_director_drop,
9571 (void *)&cmd_flow_director_queue,
9572 (void *)&cmd_flow_director_queue_id,
9573 (void *)&cmd_flow_director_fd_id,
9574 (void *)&cmd_flow_director_fd_id_value,
9579 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9580 .f = cmd_flow_director_filter_parsed,
9582 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9583 "director entry on NIC",
9585 (void *)&cmd_flow_director_filter,
9586 (void *)&cmd_flow_director_port_id,
9587 (void *)&cmd_flow_director_mode,
9588 (void *)&cmd_flow_director_mode_tunnel,
9589 (void *)&cmd_flow_director_ops,
9590 (void *)&cmd_flow_director_mac,
9591 (void *)&cmd_flow_director_mac_addr,
9592 (void *)&cmd_flow_director_vlan,
9593 (void *)&cmd_flow_director_vlan_value,
9594 (void *)&cmd_flow_director_tunnel,
9595 (void *)&cmd_flow_director_tunnel_type,
9596 (void *)&cmd_flow_director_tunnel_id,
9597 (void *)&cmd_flow_director_tunnel_id_value,
9598 (void *)&cmd_flow_director_flexbytes,
9599 (void *)&cmd_flow_director_flexbytes_value,
9600 (void *)&cmd_flow_director_drop,
9601 (void *)&cmd_flow_director_queue,
9602 (void *)&cmd_flow_director_queue_id,
9603 (void *)&cmd_flow_director_fd_id,
9604 (void *)&cmd_flow_director_fd_id_value,
9609 struct cmd_flush_flow_director_result {
9610 cmdline_fixed_string_t flush_flow_director;
9614 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9615 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9616 flush_flow_director, "flush_flow_director");
9617 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9618 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9622 cmd_flush_flow_director_parsed(void *parsed_result,
9623 __attribute__((unused)) struct cmdline *cl,
9624 __attribute__((unused)) void *data)
9626 struct cmd_flow_director_result *res = parsed_result;
9629 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9631 printf("flow director is not supported on port %u.\n",
9636 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9637 RTE_ETH_FILTER_FLUSH, NULL);
9639 printf("flow director table flushing error: (%s)\n",
9643 cmdline_parse_inst_t cmd_flush_flow_director = {
9644 .f = cmd_flush_flow_director_parsed,
9646 .help_str = "flush_flow_director <port_id>: "
9647 "Flush all flow director entries of a device on NIC",
9649 (void *)&cmd_flush_flow_director_flush,
9650 (void *)&cmd_flush_flow_director_port_id,
9655 /* *** deal with flow director mask *** */
9656 struct cmd_flow_director_mask_result {
9657 cmdline_fixed_string_t flow_director_mask;
9659 cmdline_fixed_string_t mode;
9660 cmdline_fixed_string_t mode_value;
9661 cmdline_fixed_string_t vlan;
9663 cmdline_fixed_string_t src_mask;
9664 cmdline_ipaddr_t ipv4_src;
9665 cmdline_ipaddr_t ipv6_src;
9667 cmdline_fixed_string_t dst_mask;
9668 cmdline_ipaddr_t ipv4_dst;
9669 cmdline_ipaddr_t ipv6_dst;
9671 cmdline_fixed_string_t mac;
9672 uint8_t mac_addr_byte_mask;
9673 cmdline_fixed_string_t tunnel_id;
9674 uint32_t tunnel_id_mask;
9675 cmdline_fixed_string_t tunnel_type;
9676 uint8_t tunnel_type_mask;
9680 cmd_flow_director_mask_parsed(void *parsed_result,
9681 __attribute__((unused)) struct cmdline *cl,
9682 __attribute__((unused)) void *data)
9684 struct cmd_flow_director_mask_result *res = parsed_result;
9685 struct rte_eth_fdir_masks *mask;
9686 struct rte_port *port;
9688 if (res->port_id > nb_ports) {
9689 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9693 port = &ports[res->port_id];
9694 /** Check if the port is not started **/
9695 if (port->port_status != RTE_PORT_STOPPED) {
9696 printf("Please stop port %d first\n", res->port_id);
9700 mask = &port->dev_conf.fdir_conf.mask;
9702 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9703 if (strcmp(res->mode_value, "MAC-VLAN")) {
9704 printf("Please set mode to MAC-VLAN.\n");
9708 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9709 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9710 if (strcmp(res->mode_value, "Tunnel")) {
9711 printf("Please set mode to Tunnel.\n");
9715 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9716 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9717 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9718 mask->tunnel_type_mask = res->tunnel_type_mask;
9720 if (strcmp(res->mode_value, "IP")) {
9721 printf("Please set mode to IP.\n");
9725 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9726 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9727 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9728 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9729 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9730 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9731 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9734 cmd_reconfig_device_queue(res->port_id, 1, 1);
9737 cmdline_parse_token_string_t cmd_flow_director_mask =
9738 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9739 flow_director_mask, "flow_director_mask");
9740 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9741 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9743 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9744 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9746 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9747 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9749 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9750 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9751 src_mask, "src_mask");
9752 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9753 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9755 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9756 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9758 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9759 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9761 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9762 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9763 dst_mask, "dst_mask");
9764 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9765 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9767 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9768 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9770 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9771 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9774 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9777 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9780 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9781 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9782 mode_value, "MAC-VLAN");
9783 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9784 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9785 mode_value, "Tunnel");
9786 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9787 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9789 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9790 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9791 mac_addr_byte_mask, UINT8);
9792 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9793 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9794 tunnel_type, "tunnel-type");
9795 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9796 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9797 tunnel_type_mask, UINT8);
9798 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9799 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9800 tunnel_id, "tunnel-id");
9801 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9802 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9803 tunnel_id_mask, UINT32);
9805 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9806 .f = cmd_flow_director_mask_parsed,
9808 .help_str = "flow_director_mask ... : "
9809 "Set IP mode flow director's mask on NIC",
9811 (void *)&cmd_flow_director_mask,
9812 (void *)&cmd_flow_director_mask_port_id,
9813 (void *)&cmd_flow_director_mask_mode,
9814 (void *)&cmd_flow_director_mask_mode_ip,
9815 (void *)&cmd_flow_director_mask_vlan,
9816 (void *)&cmd_flow_director_mask_vlan_value,
9817 (void *)&cmd_flow_director_mask_src,
9818 (void *)&cmd_flow_director_mask_ipv4_src,
9819 (void *)&cmd_flow_director_mask_ipv6_src,
9820 (void *)&cmd_flow_director_mask_port_src,
9821 (void *)&cmd_flow_director_mask_dst,
9822 (void *)&cmd_flow_director_mask_ipv4_dst,
9823 (void *)&cmd_flow_director_mask_ipv6_dst,
9824 (void *)&cmd_flow_director_mask_port_dst,
9829 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9830 .f = cmd_flow_director_mask_parsed,
9832 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9833 "flow director's mask on NIC",
9835 (void *)&cmd_flow_director_mask,
9836 (void *)&cmd_flow_director_mask_port_id,
9837 (void *)&cmd_flow_director_mask_mode,
9838 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9839 (void *)&cmd_flow_director_mask_vlan,
9840 (void *)&cmd_flow_director_mask_vlan_value,
9845 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9846 .f = cmd_flow_director_mask_parsed,
9848 .help_str = "flow_director_mask ... : Set tunnel mode "
9849 "flow director's mask on NIC",
9851 (void *)&cmd_flow_director_mask,
9852 (void *)&cmd_flow_director_mask_port_id,
9853 (void *)&cmd_flow_director_mask_mode,
9854 (void *)&cmd_flow_director_mask_mode_tunnel,
9855 (void *)&cmd_flow_director_mask_vlan,
9856 (void *)&cmd_flow_director_mask_vlan_value,
9857 (void *)&cmd_flow_director_mask_mac,
9858 (void *)&cmd_flow_director_mask_mac_value,
9859 (void *)&cmd_flow_director_mask_tunnel_type,
9860 (void *)&cmd_flow_director_mask_tunnel_type_value,
9861 (void *)&cmd_flow_director_mask_tunnel_id,
9862 (void *)&cmd_flow_director_mask_tunnel_id_value,
9867 /* *** deal with flow director mask on flexible payload *** */
9868 struct cmd_flow_director_flex_mask_result {
9869 cmdline_fixed_string_t flow_director_flexmask;
9871 cmdline_fixed_string_t flow;
9872 cmdline_fixed_string_t flow_type;
9873 cmdline_fixed_string_t mask;
9877 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9878 __attribute__((unused)) struct cmdline *cl,
9879 __attribute__((unused)) void *data)
9881 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9882 struct rte_eth_fdir_info fdir_info;
9883 struct rte_eth_fdir_flex_mask flex_mask;
9884 struct rte_port *port;
9885 uint32_t flow_type_mask;
9889 if (res->port_id > nb_ports) {
9890 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9894 port = &ports[res->port_id];
9895 /** Check if the port is not started **/
9896 if (port->port_status != RTE_PORT_STOPPED) {
9897 printf("Please stop port %d first\n", res->port_id);
9901 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9902 ret = parse_flexbytes(res->mask,
9904 RTE_ETH_FDIR_MAX_FLEXLEN);
9906 printf("error: Cannot parse mask input.\n");
9910 memset(&fdir_info, 0, sizeof(fdir_info));
9911 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9912 RTE_ETH_FILTER_INFO, &fdir_info);
9914 printf("Cannot get FDir filter info\n");
9918 if (!strcmp(res->flow_type, "none")) {
9919 /* means don't specify the flow type */
9920 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9921 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9922 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9923 0, sizeof(struct rte_eth_fdir_flex_mask));
9924 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9925 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9927 sizeof(struct rte_eth_fdir_flex_mask));
9928 cmd_reconfig_device_queue(res->port_id, 1, 1);
9931 flow_type_mask = fdir_info.flow_types_mask[0];
9932 if (!strcmp(res->flow_type, "all")) {
9933 if (!flow_type_mask) {
9934 printf("No flow type supported\n");
9937 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9938 if (flow_type_mask & (1 << i)) {
9939 flex_mask.flow_type = i;
9940 fdir_set_flex_mask(res->port_id, &flex_mask);
9943 cmd_reconfig_device_queue(res->port_id, 1, 1);
9946 flex_mask.flow_type = str2flowtype(res->flow_type);
9947 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9948 printf("Flow type %s not supported on port %d\n",
9949 res->flow_type, res->port_id);
9952 fdir_set_flex_mask(res->port_id, &flex_mask);
9953 cmd_reconfig_device_queue(res->port_id, 1, 1);
9956 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9957 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9958 flow_director_flexmask,
9959 "flow_director_flex_mask");
9960 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9961 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9963 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9964 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9966 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9967 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9968 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9969 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9970 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9974 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9975 .f = cmd_flow_director_flex_mask_parsed,
9977 .help_str = "flow_director_flex_mask ... : "
9978 "Set flow director's flex mask on NIC",
9980 (void *)&cmd_flow_director_flexmask,
9981 (void *)&cmd_flow_director_flexmask_port_id,
9982 (void *)&cmd_flow_director_flexmask_flow,
9983 (void *)&cmd_flow_director_flexmask_flow_type,
9984 (void *)&cmd_flow_director_flexmask_mask,
9989 /* *** deal with flow director flexible payload configuration *** */
9990 struct cmd_flow_director_flexpayload_result {
9991 cmdline_fixed_string_t flow_director_flexpayload;
9993 cmdline_fixed_string_t payload_layer;
9994 cmdline_fixed_string_t payload_cfg;
9998 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10001 const char *p, *p0 = q_arg;
10003 unsigned long int_fld;
10004 char *str_fld[max_num];
10009 p = strchr(p0, '(');
10013 p0 = strchr(p, ')');
10018 if (size >= sizeof(s))
10021 snprintf(s, sizeof(s), "%.*s", size, p);
10022 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10023 if (ret < 0 || ret > max_num)
10025 for (i = 0; i < ret; i++) {
10027 int_fld = strtoul(str_fld[i], &end, 0);
10028 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10030 offsets[i] = (uint16_t)int_fld;
10036 cmd_flow_director_flxpld_parsed(void *parsed_result,
10037 __attribute__((unused)) struct cmdline *cl,
10038 __attribute__((unused)) void *data)
10040 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10041 struct rte_eth_flex_payload_cfg flex_cfg;
10042 struct rte_port *port;
10045 if (res->port_id > nb_ports) {
10046 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10050 port = &ports[res->port_id];
10051 /** Check if the port is not started **/
10052 if (port->port_status != RTE_PORT_STOPPED) {
10053 printf("Please stop port %d first\n", res->port_id);
10057 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10059 if (!strcmp(res->payload_layer, "raw"))
10060 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10061 else if (!strcmp(res->payload_layer, "l2"))
10062 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10063 else if (!strcmp(res->payload_layer, "l3"))
10064 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10065 else if (!strcmp(res->payload_layer, "l4"))
10066 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10068 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10069 RTE_ETH_FDIR_MAX_FLEXLEN);
10071 printf("error: Cannot parse flex payload input.\n");
10075 fdir_set_flex_payload(res->port_id, &flex_cfg);
10076 cmd_reconfig_device_queue(res->port_id, 1, 1);
10079 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10080 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10081 flow_director_flexpayload,
10082 "flow_director_flex_payload");
10083 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10084 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10086 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10087 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10088 payload_layer, "raw#l2#l3#l4");
10089 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10090 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10091 payload_cfg, NULL);
10093 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10094 .f = cmd_flow_director_flxpld_parsed,
10096 .help_str = "flow_director_flexpayload ... : "
10097 "Set flow director's flex payload on NIC",
10099 (void *)&cmd_flow_director_flexpayload,
10100 (void *)&cmd_flow_director_flexpayload_port_id,
10101 (void *)&cmd_flow_director_flexpayload_payload_layer,
10102 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10107 /* Generic flow interface command. */
10108 extern cmdline_parse_inst_t cmd_flow;
10110 /* *** Classification Filters Control *** */
10111 /* *** Get symmetric hash enable per port *** */
10112 struct cmd_get_sym_hash_ena_per_port_result {
10113 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10118 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10119 __rte_unused struct cmdline *cl,
10120 __rte_unused void *data)
10122 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10123 struct rte_eth_hash_filter_info info;
10126 if (rte_eth_dev_filter_supported(res->port_id,
10127 RTE_ETH_FILTER_HASH) < 0) {
10128 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10133 memset(&info, 0, sizeof(info));
10134 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10135 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10136 RTE_ETH_FILTER_GET, &info);
10139 printf("Cannot get symmetric hash enable per port "
10140 "on port %u\n", res->port_id);
10144 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10145 "enabled" : "disabled", res->port_id);
10148 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10149 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10150 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10151 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10152 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10155 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10156 .f = cmd_get_sym_hash_per_port_parsed,
10158 .help_str = "get_sym_hash_ena_per_port <port_id>",
10160 (void *)&cmd_get_sym_hash_ena_per_port_all,
10161 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10166 /* *** Set symmetric hash enable per port *** */
10167 struct cmd_set_sym_hash_ena_per_port_result {
10168 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10169 cmdline_fixed_string_t enable;
10174 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10175 __rte_unused struct cmdline *cl,
10176 __rte_unused void *data)
10178 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10179 struct rte_eth_hash_filter_info info;
10182 if (rte_eth_dev_filter_supported(res->port_id,
10183 RTE_ETH_FILTER_HASH) < 0) {
10184 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10189 memset(&info, 0, sizeof(info));
10190 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10191 if (!strcmp(res->enable, "enable"))
10192 info.info.enable = 1;
10193 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10194 RTE_ETH_FILTER_SET, &info);
10196 printf("Cannot set symmetric hash enable per port on "
10197 "port %u\n", res->port_id);
10200 printf("Symmetric hash has been set to %s on port %u\n",
10201 res->enable, res->port_id);
10204 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
10205 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10206 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
10207 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
10208 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10210 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
10211 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10212 enable, "enable#disable");
10214 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
10215 .f = cmd_set_sym_hash_per_port_parsed,
10217 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
10219 (void *)&cmd_set_sym_hash_ena_per_port_all,
10220 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
10221 (void *)&cmd_set_sym_hash_ena_per_port_enable,
10226 /* Get global config of hash function */
10227 struct cmd_get_hash_global_config_result {
10228 cmdline_fixed_string_t get_hash_global_config;
10233 flowtype_to_str(uint16_t ftype)
10239 } ftype_table[] = {
10240 {"ipv4", RTE_ETH_FLOW_IPV4},
10241 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10242 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10243 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10244 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10245 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10246 {"ipv6", RTE_ETH_FLOW_IPV6},
10247 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10248 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10249 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10250 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10251 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10252 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10253 {"port", RTE_ETH_FLOW_PORT},
10254 {"vxlan", RTE_ETH_FLOW_VXLAN},
10255 {"geneve", RTE_ETH_FLOW_GENEVE},
10256 {"nvgre", RTE_ETH_FLOW_NVGRE},
10259 for (i = 0; i < RTE_DIM(ftype_table); i++) {
10260 if (ftype_table[i].ftype == ftype)
10261 return ftype_table[i].str;
10268 cmd_get_hash_global_config_parsed(void *parsed_result,
10269 __rte_unused struct cmdline *cl,
10270 __rte_unused void *data)
10272 struct cmd_get_hash_global_config_result *res = parsed_result;
10273 struct rte_eth_hash_filter_info info;
10274 uint32_t idx, offset;
10279 if (rte_eth_dev_filter_supported(res->port_id,
10280 RTE_ETH_FILTER_HASH) < 0) {
10281 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10286 memset(&info, 0, sizeof(info));
10287 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10288 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10289 RTE_ETH_FILTER_GET, &info);
10291 printf("Cannot get hash global configurations by port %d\n",
10296 switch (info.info.global_conf.hash_func) {
10297 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
10298 printf("Hash function is Toeplitz\n");
10300 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
10301 printf("Hash function is Simple XOR\n");
10304 printf("Unknown hash function\n");
10308 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
10309 idx = i / UINT32_BIT;
10310 offset = i % UINT32_BIT;
10311 if (!(info.info.global_conf.valid_bit_mask[idx] &
10314 str = flowtype_to_str(i);
10317 printf("Symmetric hash is %s globally for flow type %s "
10319 ((info.info.global_conf.sym_hash_enable_mask[idx] &
10320 (1UL << offset)) ? "enabled" : "disabled"), str,
10325 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
10326 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
10327 get_hash_global_config, "get_hash_global_config");
10328 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
10329 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
10332 cmdline_parse_inst_t cmd_get_hash_global_config = {
10333 .f = cmd_get_hash_global_config_parsed,
10335 .help_str = "get_hash_global_config <port_id>",
10337 (void *)&cmd_get_hash_global_config_all,
10338 (void *)&cmd_get_hash_global_config_port_id,
10343 /* Set global config of hash function */
10344 struct cmd_set_hash_global_config_result {
10345 cmdline_fixed_string_t set_hash_global_config;
10347 cmdline_fixed_string_t hash_func;
10348 cmdline_fixed_string_t flow_type;
10349 cmdline_fixed_string_t enable;
10353 cmd_set_hash_global_config_parsed(void *parsed_result,
10354 __rte_unused struct cmdline *cl,
10355 __rte_unused void *data)
10357 struct cmd_set_hash_global_config_result *res = parsed_result;
10358 struct rte_eth_hash_filter_info info;
10359 uint32_t ftype, idx, offset;
10362 if (rte_eth_dev_filter_supported(res->port_id,
10363 RTE_ETH_FILTER_HASH) < 0) {
10364 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10368 memset(&info, 0, sizeof(info));
10369 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10370 if (!strcmp(res->hash_func, "toeplitz"))
10371 info.info.global_conf.hash_func =
10372 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
10373 else if (!strcmp(res->hash_func, "simple_xor"))
10374 info.info.global_conf.hash_func =
10375 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
10376 else if (!strcmp(res->hash_func, "default"))
10377 info.info.global_conf.hash_func =
10378 RTE_ETH_HASH_FUNCTION_DEFAULT;
10380 ftype = str2flowtype(res->flow_type);
10381 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10382 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10383 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10384 if (!strcmp(res->enable, "enable"))
10385 info.info.global_conf.sym_hash_enable_mask[idx] |=
10387 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10388 RTE_ETH_FILTER_SET, &info);
10390 printf("Cannot set global hash configurations by port %d\n",
10393 printf("Global hash configurations have been set "
10394 "succcessfully by port %d\n", res->port_id);
10397 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10398 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10399 set_hash_global_config, "set_hash_global_config");
10400 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10401 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10403 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10404 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10405 hash_func, "toeplitz#simple_xor#default");
10406 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10407 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10409 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10410 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10411 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10412 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10413 enable, "enable#disable");
10415 cmdline_parse_inst_t cmd_set_hash_global_config = {
10416 .f = cmd_set_hash_global_config_parsed,
10418 .help_str = "set_hash_global_config <port_id> "
10419 "toeplitz|simple_xor|default "
10420 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10421 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10422 "l2_payload enable|disable",
10424 (void *)&cmd_set_hash_global_config_all,
10425 (void *)&cmd_set_hash_global_config_port_id,
10426 (void *)&cmd_set_hash_global_config_hash_func,
10427 (void *)&cmd_set_hash_global_config_flow_type,
10428 (void *)&cmd_set_hash_global_config_enable,
10433 /* Set hash input set */
10434 struct cmd_set_hash_input_set_result {
10435 cmdline_fixed_string_t set_hash_input_set;
10437 cmdline_fixed_string_t flow_type;
10438 cmdline_fixed_string_t inset_field;
10439 cmdline_fixed_string_t select;
10442 static enum rte_eth_input_set_field
10443 str2inset(char *string)
10447 static const struct {
10449 enum rte_eth_input_set_field inset;
10450 } inset_table[] = {
10451 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10452 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10453 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10454 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10455 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10456 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10457 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10458 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10459 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10460 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10461 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10462 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10463 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10464 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10465 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10466 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10467 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10468 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10469 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10470 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10471 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10472 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10473 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10474 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10475 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10476 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10477 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10478 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10479 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10480 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10481 {"none", RTE_ETH_INPUT_SET_NONE},
10484 for (i = 0; i < RTE_DIM(inset_table); i++) {
10485 if (!strcmp(string, inset_table[i].str))
10486 return inset_table[i].inset;
10489 return RTE_ETH_INPUT_SET_UNKNOWN;
10493 cmd_set_hash_input_set_parsed(void *parsed_result,
10494 __rte_unused struct cmdline *cl,
10495 __rte_unused void *data)
10497 struct cmd_set_hash_input_set_result *res = parsed_result;
10498 struct rte_eth_hash_filter_info info;
10500 memset(&info, 0, sizeof(info));
10501 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10502 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10503 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10504 info.info.input_set_conf.inset_size = 1;
10505 if (!strcmp(res->select, "select"))
10506 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10507 else if (!strcmp(res->select, "add"))
10508 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10509 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10510 RTE_ETH_FILTER_SET, &info);
10513 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10514 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10515 set_hash_input_set, "set_hash_input_set");
10516 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10517 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10519 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10520 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10522 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10523 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10525 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10526 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10527 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10528 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10529 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10531 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10532 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10533 select, "select#add");
10535 cmdline_parse_inst_t cmd_set_hash_input_set = {
10536 .f = cmd_set_hash_input_set_parsed,
10538 .help_str = "set_hash_input_set <port_id> "
10539 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10540 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
10541 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10542 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10543 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10544 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10545 "fld-7th|fld-8th|none select|add",
10547 (void *)&cmd_set_hash_input_set_cmd,
10548 (void *)&cmd_set_hash_input_set_port_id,
10549 (void *)&cmd_set_hash_input_set_flow_type,
10550 (void *)&cmd_set_hash_input_set_field,
10551 (void *)&cmd_set_hash_input_set_select,
10556 /* Set flow director input set */
10557 struct cmd_set_fdir_input_set_result {
10558 cmdline_fixed_string_t set_fdir_input_set;
10560 cmdline_fixed_string_t flow_type;
10561 cmdline_fixed_string_t inset_field;
10562 cmdline_fixed_string_t select;
10566 cmd_set_fdir_input_set_parsed(void *parsed_result,
10567 __rte_unused struct cmdline *cl,
10568 __rte_unused void *data)
10570 struct cmd_set_fdir_input_set_result *res = parsed_result;
10571 struct rte_eth_fdir_filter_info info;
10573 memset(&info, 0, sizeof(info));
10574 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10575 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10576 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10577 info.info.input_set_conf.inset_size = 1;
10578 if (!strcmp(res->select, "select"))
10579 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10580 else if (!strcmp(res->select, "add"))
10581 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10582 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10583 RTE_ETH_FILTER_SET, &info);
10586 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10587 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10588 set_fdir_input_set, "set_fdir_input_set");
10589 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10590 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10592 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10593 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10595 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10596 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10597 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10598 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10600 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10601 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10602 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10603 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10604 "sctp-veri-tag#none");
10605 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10606 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10607 select, "select#add");
10609 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10610 .f = cmd_set_fdir_input_set_parsed,
10612 .help_str = "set_fdir_input_set <port_id> "
10613 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10614 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10615 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10616 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10617 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10618 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10619 "sctp-veri-tag|none select|add",
10621 (void *)&cmd_set_fdir_input_set_cmd,
10622 (void *)&cmd_set_fdir_input_set_port_id,
10623 (void *)&cmd_set_fdir_input_set_flow_type,
10624 (void *)&cmd_set_fdir_input_set_field,
10625 (void *)&cmd_set_fdir_input_set_select,
10630 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10631 struct cmd_mcast_addr_result {
10632 cmdline_fixed_string_t mcast_addr_cmd;
10633 cmdline_fixed_string_t what;
10635 struct ether_addr mc_addr;
10638 static void cmd_mcast_addr_parsed(void *parsed_result,
10639 __attribute__((unused)) struct cmdline *cl,
10640 __attribute__((unused)) void *data)
10642 struct cmd_mcast_addr_result *res = parsed_result;
10644 if (!is_multicast_ether_addr(&res->mc_addr)) {
10645 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10646 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10647 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10648 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10651 if (strcmp(res->what, "add") == 0)
10652 mcast_addr_add(res->port_num, &res->mc_addr);
10654 mcast_addr_remove(res->port_num, &res->mc_addr);
10657 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10658 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10659 mcast_addr_cmd, "mcast_addr");
10660 cmdline_parse_token_string_t cmd_mcast_addr_what =
10661 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10663 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10664 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10665 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10666 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10668 cmdline_parse_inst_t cmd_mcast_addr = {
10669 .f = cmd_mcast_addr_parsed,
10671 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10672 "Add/Remove multicast MAC address on port_id",
10674 (void *)&cmd_mcast_addr_cmd,
10675 (void *)&cmd_mcast_addr_what,
10676 (void *)&cmd_mcast_addr_portnum,
10677 (void *)&cmd_mcast_addr_addr,
10682 /* l2 tunnel config
10683 * only support E-tag now.
10686 /* Ether type config */
10687 struct cmd_config_l2_tunnel_eth_type_result {
10688 cmdline_fixed_string_t port;
10689 cmdline_fixed_string_t config;
10690 cmdline_fixed_string_t all;
10692 cmdline_fixed_string_t l2_tunnel;
10693 cmdline_fixed_string_t l2_tunnel_type;
10694 cmdline_fixed_string_t eth_type;
10695 uint16_t eth_type_val;
10698 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10699 TOKEN_STRING_INITIALIZER
10700 (struct cmd_config_l2_tunnel_eth_type_result,
10702 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10703 TOKEN_STRING_INITIALIZER
10704 (struct cmd_config_l2_tunnel_eth_type_result,
10706 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10707 TOKEN_STRING_INITIALIZER
10708 (struct cmd_config_l2_tunnel_eth_type_result,
10710 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10711 TOKEN_NUM_INITIALIZER
10712 (struct cmd_config_l2_tunnel_eth_type_result,
10714 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10715 TOKEN_STRING_INITIALIZER
10716 (struct cmd_config_l2_tunnel_eth_type_result,
10717 l2_tunnel, "l2-tunnel");
10718 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10719 TOKEN_STRING_INITIALIZER
10720 (struct cmd_config_l2_tunnel_eth_type_result,
10721 l2_tunnel_type, "E-tag");
10722 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10723 TOKEN_STRING_INITIALIZER
10724 (struct cmd_config_l2_tunnel_eth_type_result,
10725 eth_type, "ether-type");
10726 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10727 TOKEN_NUM_INITIALIZER
10728 (struct cmd_config_l2_tunnel_eth_type_result,
10729 eth_type_val, UINT16);
10731 static enum rte_eth_tunnel_type
10732 str2fdir_l2_tunnel_type(char *string)
10736 static const struct {
10738 enum rte_eth_tunnel_type type;
10739 } l2_tunnel_type_str[] = {
10740 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10743 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10744 if (!strcmp(l2_tunnel_type_str[i].str, string))
10745 return l2_tunnel_type_str[i].type;
10747 return RTE_TUNNEL_TYPE_NONE;
10750 /* ether type config for all ports */
10752 cmd_config_l2_tunnel_eth_type_all_parsed
10753 (void *parsed_result,
10754 __attribute__((unused)) struct cmdline *cl,
10755 __attribute__((unused)) void *data)
10757 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10758 struct rte_eth_l2_tunnel_conf entry;
10761 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10762 entry.ether_type = res->eth_type_val;
10764 RTE_ETH_FOREACH_DEV(pid) {
10765 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10769 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10770 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10772 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10774 (void *)&cmd_config_l2_tunnel_eth_type_port,
10775 (void *)&cmd_config_l2_tunnel_eth_type_config,
10776 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10777 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10778 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10779 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10780 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10785 /* ether type config for a specific port */
10787 cmd_config_l2_tunnel_eth_type_specific_parsed(
10788 void *parsed_result,
10789 __attribute__((unused)) struct cmdline *cl,
10790 __attribute__((unused)) void *data)
10792 struct cmd_config_l2_tunnel_eth_type_result *res =
10794 struct rte_eth_l2_tunnel_conf entry;
10796 if (port_id_is_invalid(res->id, ENABLED_WARN))
10799 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10800 entry.ether_type = res->eth_type_val;
10802 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10805 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10806 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10808 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10810 (void *)&cmd_config_l2_tunnel_eth_type_port,
10811 (void *)&cmd_config_l2_tunnel_eth_type_config,
10812 (void *)&cmd_config_l2_tunnel_eth_type_id,
10813 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10814 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10815 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10816 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10821 /* Enable/disable l2 tunnel */
10822 struct cmd_config_l2_tunnel_en_dis_result {
10823 cmdline_fixed_string_t port;
10824 cmdline_fixed_string_t config;
10825 cmdline_fixed_string_t all;
10827 cmdline_fixed_string_t l2_tunnel;
10828 cmdline_fixed_string_t l2_tunnel_type;
10829 cmdline_fixed_string_t en_dis;
10832 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10833 TOKEN_STRING_INITIALIZER
10834 (struct cmd_config_l2_tunnel_en_dis_result,
10836 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10837 TOKEN_STRING_INITIALIZER
10838 (struct cmd_config_l2_tunnel_en_dis_result,
10840 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10841 TOKEN_STRING_INITIALIZER
10842 (struct cmd_config_l2_tunnel_en_dis_result,
10844 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10845 TOKEN_NUM_INITIALIZER
10846 (struct cmd_config_l2_tunnel_en_dis_result,
10848 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10849 TOKEN_STRING_INITIALIZER
10850 (struct cmd_config_l2_tunnel_en_dis_result,
10851 l2_tunnel, "l2-tunnel");
10852 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10853 TOKEN_STRING_INITIALIZER
10854 (struct cmd_config_l2_tunnel_en_dis_result,
10855 l2_tunnel_type, "E-tag");
10856 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10857 TOKEN_STRING_INITIALIZER
10858 (struct cmd_config_l2_tunnel_en_dis_result,
10859 en_dis, "enable#disable");
10861 /* enable/disable l2 tunnel for all ports */
10863 cmd_config_l2_tunnel_en_dis_all_parsed(
10864 void *parsed_result,
10865 __attribute__((unused)) struct cmdline *cl,
10866 __attribute__((unused)) void *data)
10868 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10869 struct rte_eth_l2_tunnel_conf entry;
10873 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10875 if (!strcmp("enable", res->en_dis))
10880 RTE_ETH_FOREACH_DEV(pid) {
10881 rte_eth_dev_l2_tunnel_offload_set(pid,
10883 ETH_L2_TUNNEL_ENABLE_MASK,
10888 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10889 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10891 .help_str = "port config all l2-tunnel E-tag enable|disable",
10893 (void *)&cmd_config_l2_tunnel_en_dis_port,
10894 (void *)&cmd_config_l2_tunnel_en_dis_config,
10895 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10896 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10897 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10898 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10903 /* enable/disable l2 tunnel for a port */
10905 cmd_config_l2_tunnel_en_dis_specific_parsed(
10906 void *parsed_result,
10907 __attribute__((unused)) struct cmdline *cl,
10908 __attribute__((unused)) void *data)
10910 struct cmd_config_l2_tunnel_en_dis_result *res =
10912 struct rte_eth_l2_tunnel_conf entry;
10914 if (port_id_is_invalid(res->id, ENABLED_WARN))
10917 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10919 if (!strcmp("enable", res->en_dis))
10920 rte_eth_dev_l2_tunnel_offload_set(res->id,
10922 ETH_L2_TUNNEL_ENABLE_MASK,
10925 rte_eth_dev_l2_tunnel_offload_set(res->id,
10927 ETH_L2_TUNNEL_ENABLE_MASK,
10931 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10932 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10934 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10936 (void *)&cmd_config_l2_tunnel_en_dis_port,
10937 (void *)&cmd_config_l2_tunnel_en_dis_config,
10938 (void *)&cmd_config_l2_tunnel_en_dis_id,
10939 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10940 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10941 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10946 /* E-tag configuration */
10948 /* Common result structure for all E-tag configuration */
10949 struct cmd_config_e_tag_result {
10950 cmdline_fixed_string_t e_tag;
10951 cmdline_fixed_string_t set;
10952 cmdline_fixed_string_t insertion;
10953 cmdline_fixed_string_t stripping;
10954 cmdline_fixed_string_t forwarding;
10955 cmdline_fixed_string_t filter;
10956 cmdline_fixed_string_t add;
10957 cmdline_fixed_string_t del;
10958 cmdline_fixed_string_t on;
10959 cmdline_fixed_string_t off;
10960 cmdline_fixed_string_t on_off;
10961 cmdline_fixed_string_t port_tag_id;
10962 uint32_t port_tag_id_val;
10963 cmdline_fixed_string_t e_tag_id;
10964 uint16_t e_tag_id_val;
10965 cmdline_fixed_string_t dst_pool;
10966 uint8_t dst_pool_val;
10967 cmdline_fixed_string_t port;
10969 cmdline_fixed_string_t vf;
10973 /* Common CLI fields for all E-tag configuration */
10974 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10975 TOKEN_STRING_INITIALIZER
10976 (struct cmd_config_e_tag_result,
10978 cmdline_parse_token_string_t cmd_config_e_tag_set =
10979 TOKEN_STRING_INITIALIZER
10980 (struct cmd_config_e_tag_result,
10982 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10983 TOKEN_STRING_INITIALIZER
10984 (struct cmd_config_e_tag_result,
10985 insertion, "insertion");
10986 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10987 TOKEN_STRING_INITIALIZER
10988 (struct cmd_config_e_tag_result,
10989 stripping, "stripping");
10990 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10991 TOKEN_STRING_INITIALIZER
10992 (struct cmd_config_e_tag_result,
10993 forwarding, "forwarding");
10994 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10995 TOKEN_STRING_INITIALIZER
10996 (struct cmd_config_e_tag_result,
10998 cmdline_parse_token_string_t cmd_config_e_tag_add =
10999 TOKEN_STRING_INITIALIZER
11000 (struct cmd_config_e_tag_result,
11002 cmdline_parse_token_string_t cmd_config_e_tag_del =
11003 TOKEN_STRING_INITIALIZER
11004 (struct cmd_config_e_tag_result,
11006 cmdline_parse_token_string_t cmd_config_e_tag_on =
11007 TOKEN_STRING_INITIALIZER
11008 (struct cmd_config_e_tag_result,
11010 cmdline_parse_token_string_t cmd_config_e_tag_off =
11011 TOKEN_STRING_INITIALIZER
11012 (struct cmd_config_e_tag_result,
11014 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11015 TOKEN_STRING_INITIALIZER
11016 (struct cmd_config_e_tag_result,
11018 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11019 TOKEN_STRING_INITIALIZER
11020 (struct cmd_config_e_tag_result,
11021 port_tag_id, "port-tag-id");
11022 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11023 TOKEN_NUM_INITIALIZER
11024 (struct cmd_config_e_tag_result,
11025 port_tag_id_val, UINT32);
11026 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11027 TOKEN_STRING_INITIALIZER
11028 (struct cmd_config_e_tag_result,
11029 e_tag_id, "e-tag-id");
11030 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11031 TOKEN_NUM_INITIALIZER
11032 (struct cmd_config_e_tag_result,
11033 e_tag_id_val, UINT16);
11034 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11035 TOKEN_STRING_INITIALIZER
11036 (struct cmd_config_e_tag_result,
11037 dst_pool, "dst-pool");
11038 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11039 TOKEN_NUM_INITIALIZER
11040 (struct cmd_config_e_tag_result,
11041 dst_pool_val, UINT8);
11042 cmdline_parse_token_string_t cmd_config_e_tag_port =
11043 TOKEN_STRING_INITIALIZER
11044 (struct cmd_config_e_tag_result,
11046 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11047 TOKEN_NUM_INITIALIZER
11048 (struct cmd_config_e_tag_result,
11050 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11051 TOKEN_STRING_INITIALIZER
11052 (struct cmd_config_e_tag_result,
11054 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11055 TOKEN_NUM_INITIALIZER
11056 (struct cmd_config_e_tag_result,
11059 /* E-tag insertion configuration */
11061 cmd_config_e_tag_insertion_en_parsed(
11062 void *parsed_result,
11063 __attribute__((unused)) struct cmdline *cl,
11064 __attribute__((unused)) void *data)
11066 struct cmd_config_e_tag_result *res =
11068 struct rte_eth_l2_tunnel_conf entry;
11070 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11073 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11074 entry.tunnel_id = res->port_tag_id_val;
11075 entry.vf_id = res->vf_id;
11076 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11078 ETH_L2_TUNNEL_INSERTION_MASK,
11083 cmd_config_e_tag_insertion_dis_parsed(
11084 void *parsed_result,
11085 __attribute__((unused)) struct cmdline *cl,
11086 __attribute__((unused)) void *data)
11088 struct cmd_config_e_tag_result *res =
11090 struct rte_eth_l2_tunnel_conf entry;
11092 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11095 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11096 entry.vf_id = res->vf_id;
11098 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11100 ETH_L2_TUNNEL_INSERTION_MASK,
11104 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11105 .f = cmd_config_e_tag_insertion_en_parsed,
11107 .help_str = "E-tag ... : E-tag insertion enable",
11109 (void *)&cmd_config_e_tag_e_tag,
11110 (void *)&cmd_config_e_tag_set,
11111 (void *)&cmd_config_e_tag_insertion,
11112 (void *)&cmd_config_e_tag_on,
11113 (void *)&cmd_config_e_tag_port_tag_id,
11114 (void *)&cmd_config_e_tag_port_tag_id_val,
11115 (void *)&cmd_config_e_tag_port,
11116 (void *)&cmd_config_e_tag_port_id,
11117 (void *)&cmd_config_e_tag_vf,
11118 (void *)&cmd_config_e_tag_vf_id,
11123 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11124 .f = cmd_config_e_tag_insertion_dis_parsed,
11126 .help_str = "E-tag ... : E-tag insertion disable",
11128 (void *)&cmd_config_e_tag_e_tag,
11129 (void *)&cmd_config_e_tag_set,
11130 (void *)&cmd_config_e_tag_insertion,
11131 (void *)&cmd_config_e_tag_off,
11132 (void *)&cmd_config_e_tag_port,
11133 (void *)&cmd_config_e_tag_port_id,
11134 (void *)&cmd_config_e_tag_vf,
11135 (void *)&cmd_config_e_tag_vf_id,
11140 /* E-tag stripping configuration */
11142 cmd_config_e_tag_stripping_parsed(
11143 void *parsed_result,
11144 __attribute__((unused)) struct cmdline *cl,
11145 __attribute__((unused)) void *data)
11147 struct cmd_config_e_tag_result *res =
11149 struct rte_eth_l2_tunnel_conf entry;
11151 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11154 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11156 if (!strcmp(res->on_off, "on"))
11157 rte_eth_dev_l2_tunnel_offload_set
11160 ETH_L2_TUNNEL_STRIPPING_MASK,
11163 rte_eth_dev_l2_tunnel_offload_set
11166 ETH_L2_TUNNEL_STRIPPING_MASK,
11170 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11171 .f = cmd_config_e_tag_stripping_parsed,
11173 .help_str = "E-tag ... : E-tag stripping enable/disable",
11175 (void *)&cmd_config_e_tag_e_tag,
11176 (void *)&cmd_config_e_tag_set,
11177 (void *)&cmd_config_e_tag_stripping,
11178 (void *)&cmd_config_e_tag_on_off,
11179 (void *)&cmd_config_e_tag_port,
11180 (void *)&cmd_config_e_tag_port_id,
11185 /* E-tag forwarding configuration */
11187 cmd_config_e_tag_forwarding_parsed(
11188 void *parsed_result,
11189 __attribute__((unused)) struct cmdline *cl,
11190 __attribute__((unused)) void *data)
11192 struct cmd_config_e_tag_result *res = parsed_result;
11193 struct rte_eth_l2_tunnel_conf entry;
11195 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11198 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11200 if (!strcmp(res->on_off, "on"))
11201 rte_eth_dev_l2_tunnel_offload_set
11204 ETH_L2_TUNNEL_FORWARDING_MASK,
11207 rte_eth_dev_l2_tunnel_offload_set
11210 ETH_L2_TUNNEL_FORWARDING_MASK,
11214 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11215 .f = cmd_config_e_tag_forwarding_parsed,
11217 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11219 (void *)&cmd_config_e_tag_e_tag,
11220 (void *)&cmd_config_e_tag_set,
11221 (void *)&cmd_config_e_tag_forwarding,
11222 (void *)&cmd_config_e_tag_on_off,
11223 (void *)&cmd_config_e_tag_port,
11224 (void *)&cmd_config_e_tag_port_id,
11229 /* E-tag filter configuration */
11231 cmd_config_e_tag_filter_add_parsed(
11232 void *parsed_result,
11233 __attribute__((unused)) struct cmdline *cl,
11234 __attribute__((unused)) void *data)
11236 struct cmd_config_e_tag_result *res = parsed_result;
11237 struct rte_eth_l2_tunnel_conf entry;
11240 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11243 if (res->e_tag_id_val > 0x3fff) {
11244 printf("e-tag-id must be equal or less than 0x3fff.\n");
11248 ret = rte_eth_dev_filter_supported(res->port_id,
11249 RTE_ETH_FILTER_L2_TUNNEL);
11251 printf("E-tag filter is not supported on port %u.\n",
11256 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11257 entry.tunnel_id = res->e_tag_id_val;
11258 entry.pool = res->dst_pool_val;
11260 ret = rte_eth_dev_filter_ctrl(res->port_id,
11261 RTE_ETH_FILTER_L2_TUNNEL,
11262 RTE_ETH_FILTER_ADD,
11265 printf("E-tag filter programming error: (%s)\n",
11269 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
11270 .f = cmd_config_e_tag_filter_add_parsed,
11272 .help_str = "E-tag ... : E-tag filter add",
11274 (void *)&cmd_config_e_tag_e_tag,
11275 (void *)&cmd_config_e_tag_set,
11276 (void *)&cmd_config_e_tag_filter,
11277 (void *)&cmd_config_e_tag_add,
11278 (void *)&cmd_config_e_tag_e_tag_id,
11279 (void *)&cmd_config_e_tag_e_tag_id_val,
11280 (void *)&cmd_config_e_tag_dst_pool,
11281 (void *)&cmd_config_e_tag_dst_pool_val,
11282 (void *)&cmd_config_e_tag_port,
11283 (void *)&cmd_config_e_tag_port_id,
11289 cmd_config_e_tag_filter_del_parsed(
11290 void *parsed_result,
11291 __attribute__((unused)) struct cmdline *cl,
11292 __attribute__((unused)) void *data)
11294 struct cmd_config_e_tag_result *res = parsed_result;
11295 struct rte_eth_l2_tunnel_conf entry;
11298 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11301 if (res->e_tag_id_val > 0x3fff) {
11302 printf("e-tag-id must be less than 0x3fff.\n");
11306 ret = rte_eth_dev_filter_supported(res->port_id,
11307 RTE_ETH_FILTER_L2_TUNNEL);
11309 printf("E-tag filter is not supported on port %u.\n",
11314 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11315 entry.tunnel_id = res->e_tag_id_val;
11317 ret = rte_eth_dev_filter_ctrl(res->port_id,
11318 RTE_ETH_FILTER_L2_TUNNEL,
11319 RTE_ETH_FILTER_DELETE,
11322 printf("E-tag filter programming error: (%s)\n",
11326 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
11327 .f = cmd_config_e_tag_filter_del_parsed,
11329 .help_str = "E-tag ... : E-tag filter delete",
11331 (void *)&cmd_config_e_tag_e_tag,
11332 (void *)&cmd_config_e_tag_set,
11333 (void *)&cmd_config_e_tag_filter,
11334 (void *)&cmd_config_e_tag_del,
11335 (void *)&cmd_config_e_tag_e_tag_id,
11336 (void *)&cmd_config_e_tag_e_tag_id_val,
11337 (void *)&cmd_config_e_tag_port,
11338 (void *)&cmd_config_e_tag_port_id,
11343 /* vf vlan anti spoof configuration */
11345 /* Common result structure for vf vlan anti spoof */
11346 struct cmd_vf_vlan_anti_spoof_result {
11347 cmdline_fixed_string_t set;
11348 cmdline_fixed_string_t vf;
11349 cmdline_fixed_string_t vlan;
11350 cmdline_fixed_string_t antispoof;
11353 cmdline_fixed_string_t on_off;
11356 /* Common CLI fields for vf vlan anti spoof enable disable */
11357 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11358 TOKEN_STRING_INITIALIZER
11359 (struct cmd_vf_vlan_anti_spoof_result,
11361 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11362 TOKEN_STRING_INITIALIZER
11363 (struct cmd_vf_vlan_anti_spoof_result,
11365 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11366 TOKEN_STRING_INITIALIZER
11367 (struct cmd_vf_vlan_anti_spoof_result,
11369 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11370 TOKEN_STRING_INITIALIZER
11371 (struct cmd_vf_vlan_anti_spoof_result,
11372 antispoof, "antispoof");
11373 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11374 TOKEN_NUM_INITIALIZER
11375 (struct cmd_vf_vlan_anti_spoof_result,
11377 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11378 TOKEN_NUM_INITIALIZER
11379 (struct cmd_vf_vlan_anti_spoof_result,
11381 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11382 TOKEN_STRING_INITIALIZER
11383 (struct cmd_vf_vlan_anti_spoof_result,
11387 cmd_set_vf_vlan_anti_spoof_parsed(
11388 void *parsed_result,
11389 __attribute__((unused)) struct cmdline *cl,
11390 __attribute__((unused)) void *data)
11392 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11393 int ret = -ENOTSUP;
11395 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11397 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11400 #ifdef RTE_LIBRTE_IXGBE_PMD
11401 if (ret == -ENOTSUP)
11402 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11403 res->vf_id, is_on);
11405 #ifdef RTE_LIBRTE_I40E_PMD
11406 if (ret == -ENOTSUP)
11407 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11408 res->vf_id, is_on);
11410 #ifdef RTE_LIBRTE_BNXT_PMD
11411 if (ret == -ENOTSUP)
11412 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11413 res->vf_id, is_on);
11420 printf("invalid vf_id %d\n", res->vf_id);
11423 printf("invalid port_id %d\n", res->port_id);
11426 printf("function not implemented\n");
11429 printf("programming error: (%s)\n", strerror(-ret));
11433 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11434 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11436 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11438 (void *)&cmd_vf_vlan_anti_spoof_set,
11439 (void *)&cmd_vf_vlan_anti_spoof_vf,
11440 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11441 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11442 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11443 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11444 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11449 /* vf mac anti spoof configuration */
11451 /* Common result structure for vf mac anti spoof */
11452 struct cmd_vf_mac_anti_spoof_result {
11453 cmdline_fixed_string_t set;
11454 cmdline_fixed_string_t vf;
11455 cmdline_fixed_string_t mac;
11456 cmdline_fixed_string_t antispoof;
11459 cmdline_fixed_string_t on_off;
11462 /* Common CLI fields for vf mac anti spoof enable disable */
11463 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11464 TOKEN_STRING_INITIALIZER
11465 (struct cmd_vf_mac_anti_spoof_result,
11467 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11468 TOKEN_STRING_INITIALIZER
11469 (struct cmd_vf_mac_anti_spoof_result,
11471 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11472 TOKEN_STRING_INITIALIZER
11473 (struct cmd_vf_mac_anti_spoof_result,
11475 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11476 TOKEN_STRING_INITIALIZER
11477 (struct cmd_vf_mac_anti_spoof_result,
11478 antispoof, "antispoof");
11479 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11480 TOKEN_NUM_INITIALIZER
11481 (struct cmd_vf_mac_anti_spoof_result,
11483 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11484 TOKEN_NUM_INITIALIZER
11485 (struct cmd_vf_mac_anti_spoof_result,
11487 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11488 TOKEN_STRING_INITIALIZER
11489 (struct cmd_vf_mac_anti_spoof_result,
11493 cmd_set_vf_mac_anti_spoof_parsed(
11494 void *parsed_result,
11495 __attribute__((unused)) struct cmdline *cl,
11496 __attribute__((unused)) void *data)
11498 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11499 int ret = -ENOTSUP;
11501 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11503 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11506 #ifdef RTE_LIBRTE_IXGBE_PMD
11507 if (ret == -ENOTSUP)
11508 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11509 res->vf_id, is_on);
11511 #ifdef RTE_LIBRTE_I40E_PMD
11512 if (ret == -ENOTSUP)
11513 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11514 res->vf_id, is_on);
11516 #ifdef RTE_LIBRTE_BNXT_PMD
11517 if (ret == -ENOTSUP)
11518 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11519 res->vf_id, is_on);
11526 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11529 printf("invalid port_id %d\n", res->port_id);
11532 printf("function not implemented\n");
11535 printf("programming error: (%s)\n", strerror(-ret));
11539 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11540 .f = cmd_set_vf_mac_anti_spoof_parsed,
11542 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11544 (void *)&cmd_vf_mac_anti_spoof_set,
11545 (void *)&cmd_vf_mac_anti_spoof_vf,
11546 (void *)&cmd_vf_mac_anti_spoof_mac,
11547 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11548 (void *)&cmd_vf_mac_anti_spoof_port_id,
11549 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11550 (void *)&cmd_vf_mac_anti_spoof_on_off,
11555 /* vf vlan strip queue configuration */
11557 /* Common result structure for vf mac anti spoof */
11558 struct cmd_vf_vlan_stripq_result {
11559 cmdline_fixed_string_t set;
11560 cmdline_fixed_string_t vf;
11561 cmdline_fixed_string_t vlan;
11562 cmdline_fixed_string_t stripq;
11565 cmdline_fixed_string_t on_off;
11568 /* Common CLI fields for vf vlan strip enable disable */
11569 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11570 TOKEN_STRING_INITIALIZER
11571 (struct cmd_vf_vlan_stripq_result,
11573 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11574 TOKEN_STRING_INITIALIZER
11575 (struct cmd_vf_vlan_stripq_result,
11577 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11578 TOKEN_STRING_INITIALIZER
11579 (struct cmd_vf_vlan_stripq_result,
11581 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11582 TOKEN_STRING_INITIALIZER
11583 (struct cmd_vf_vlan_stripq_result,
11585 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11586 TOKEN_NUM_INITIALIZER
11587 (struct cmd_vf_vlan_stripq_result,
11589 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11590 TOKEN_NUM_INITIALIZER
11591 (struct cmd_vf_vlan_stripq_result,
11593 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11594 TOKEN_STRING_INITIALIZER
11595 (struct cmd_vf_vlan_stripq_result,
11599 cmd_set_vf_vlan_stripq_parsed(
11600 void *parsed_result,
11601 __attribute__((unused)) struct cmdline *cl,
11602 __attribute__((unused)) void *data)
11604 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11605 int ret = -ENOTSUP;
11607 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11609 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11612 #ifdef RTE_LIBRTE_IXGBE_PMD
11613 if (ret == -ENOTSUP)
11614 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11615 res->vf_id, is_on);
11617 #ifdef RTE_LIBRTE_I40E_PMD
11618 if (ret == -ENOTSUP)
11619 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11620 res->vf_id, is_on);
11622 #ifdef RTE_LIBRTE_BNXT_PMD
11623 if (ret == -ENOTSUP)
11624 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11625 res->vf_id, is_on);
11632 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11635 printf("invalid port_id %d\n", res->port_id);
11638 printf("function not implemented\n");
11641 printf("programming error: (%s)\n", strerror(-ret));
11645 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11646 .f = cmd_set_vf_vlan_stripq_parsed,
11648 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11650 (void *)&cmd_vf_vlan_stripq_set,
11651 (void *)&cmd_vf_vlan_stripq_vf,
11652 (void *)&cmd_vf_vlan_stripq_vlan,
11653 (void *)&cmd_vf_vlan_stripq_stripq,
11654 (void *)&cmd_vf_vlan_stripq_port_id,
11655 (void *)&cmd_vf_vlan_stripq_vf_id,
11656 (void *)&cmd_vf_vlan_stripq_on_off,
11661 /* vf vlan insert configuration */
11663 /* Common result structure for vf vlan insert */
11664 struct cmd_vf_vlan_insert_result {
11665 cmdline_fixed_string_t set;
11666 cmdline_fixed_string_t vf;
11667 cmdline_fixed_string_t vlan;
11668 cmdline_fixed_string_t insert;
11674 /* Common CLI fields for vf vlan insert enable disable */
11675 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11676 TOKEN_STRING_INITIALIZER
11677 (struct cmd_vf_vlan_insert_result,
11679 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11680 TOKEN_STRING_INITIALIZER
11681 (struct cmd_vf_vlan_insert_result,
11683 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11684 TOKEN_STRING_INITIALIZER
11685 (struct cmd_vf_vlan_insert_result,
11687 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11688 TOKEN_STRING_INITIALIZER
11689 (struct cmd_vf_vlan_insert_result,
11691 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11692 TOKEN_NUM_INITIALIZER
11693 (struct cmd_vf_vlan_insert_result,
11695 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11696 TOKEN_NUM_INITIALIZER
11697 (struct cmd_vf_vlan_insert_result,
11699 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11700 TOKEN_NUM_INITIALIZER
11701 (struct cmd_vf_vlan_insert_result,
11705 cmd_set_vf_vlan_insert_parsed(
11706 void *parsed_result,
11707 __attribute__((unused)) struct cmdline *cl,
11708 __attribute__((unused)) void *data)
11710 struct cmd_vf_vlan_insert_result *res = parsed_result;
11711 int ret = -ENOTSUP;
11713 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11716 #ifdef RTE_LIBRTE_IXGBE_PMD
11717 if (ret == -ENOTSUP)
11718 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11721 #ifdef RTE_LIBRTE_I40E_PMD
11722 if (ret == -ENOTSUP)
11723 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11726 #ifdef RTE_LIBRTE_BNXT_PMD
11727 if (ret == -ENOTSUP)
11728 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11736 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11739 printf("invalid port_id %d\n", res->port_id);
11742 printf("function not implemented\n");
11745 printf("programming error: (%s)\n", strerror(-ret));
11749 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11750 .f = cmd_set_vf_vlan_insert_parsed,
11752 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11754 (void *)&cmd_vf_vlan_insert_set,
11755 (void *)&cmd_vf_vlan_insert_vf,
11756 (void *)&cmd_vf_vlan_insert_vlan,
11757 (void *)&cmd_vf_vlan_insert_insert,
11758 (void *)&cmd_vf_vlan_insert_port_id,
11759 (void *)&cmd_vf_vlan_insert_vf_id,
11760 (void *)&cmd_vf_vlan_insert_vlan_id,
11765 /* tx loopback configuration */
11767 /* Common result structure for tx loopback */
11768 struct cmd_tx_loopback_result {
11769 cmdline_fixed_string_t set;
11770 cmdline_fixed_string_t tx;
11771 cmdline_fixed_string_t loopback;
11773 cmdline_fixed_string_t on_off;
11776 /* Common CLI fields for tx loopback enable disable */
11777 cmdline_parse_token_string_t cmd_tx_loopback_set =
11778 TOKEN_STRING_INITIALIZER
11779 (struct cmd_tx_loopback_result,
11781 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11782 TOKEN_STRING_INITIALIZER
11783 (struct cmd_tx_loopback_result,
11785 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11786 TOKEN_STRING_INITIALIZER
11787 (struct cmd_tx_loopback_result,
11788 loopback, "loopback");
11789 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11790 TOKEN_NUM_INITIALIZER
11791 (struct cmd_tx_loopback_result,
11793 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11794 TOKEN_STRING_INITIALIZER
11795 (struct cmd_tx_loopback_result,
11799 cmd_set_tx_loopback_parsed(
11800 void *parsed_result,
11801 __attribute__((unused)) struct cmdline *cl,
11802 __attribute__((unused)) void *data)
11804 struct cmd_tx_loopback_result *res = parsed_result;
11805 int ret = -ENOTSUP;
11807 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11809 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11812 #ifdef RTE_LIBRTE_IXGBE_PMD
11813 if (ret == -ENOTSUP)
11814 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11816 #ifdef RTE_LIBRTE_I40E_PMD
11817 if (ret == -ENOTSUP)
11818 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11820 #ifdef RTE_LIBRTE_BNXT_PMD
11821 if (ret == -ENOTSUP)
11822 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11829 printf("invalid is_on %d\n", is_on);
11832 printf("invalid port_id %d\n", res->port_id);
11835 printf("function not implemented\n");
11838 printf("programming error: (%s)\n", strerror(-ret));
11842 cmdline_parse_inst_t cmd_set_tx_loopback = {
11843 .f = cmd_set_tx_loopback_parsed,
11845 .help_str = "set tx loopback <port_id> on|off",
11847 (void *)&cmd_tx_loopback_set,
11848 (void *)&cmd_tx_loopback_tx,
11849 (void *)&cmd_tx_loopback_loopback,
11850 (void *)&cmd_tx_loopback_port_id,
11851 (void *)&cmd_tx_loopback_on_off,
11856 /* all queues drop enable configuration */
11858 /* Common result structure for all queues drop enable */
11859 struct cmd_all_queues_drop_en_result {
11860 cmdline_fixed_string_t set;
11861 cmdline_fixed_string_t all;
11862 cmdline_fixed_string_t queues;
11863 cmdline_fixed_string_t drop;
11865 cmdline_fixed_string_t on_off;
11868 /* Common CLI fields for tx loopback enable disable */
11869 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11870 TOKEN_STRING_INITIALIZER
11871 (struct cmd_all_queues_drop_en_result,
11873 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11874 TOKEN_STRING_INITIALIZER
11875 (struct cmd_all_queues_drop_en_result,
11877 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11878 TOKEN_STRING_INITIALIZER
11879 (struct cmd_all_queues_drop_en_result,
11881 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11882 TOKEN_STRING_INITIALIZER
11883 (struct cmd_all_queues_drop_en_result,
11885 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11886 TOKEN_NUM_INITIALIZER
11887 (struct cmd_all_queues_drop_en_result,
11889 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11890 TOKEN_STRING_INITIALIZER
11891 (struct cmd_all_queues_drop_en_result,
11895 cmd_set_all_queues_drop_en_parsed(
11896 void *parsed_result,
11897 __attribute__((unused)) struct cmdline *cl,
11898 __attribute__((unused)) void *data)
11900 struct cmd_all_queues_drop_en_result *res = parsed_result;
11901 int ret = -ENOTSUP;
11902 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11904 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11907 #ifdef RTE_LIBRTE_IXGBE_PMD
11908 if (ret == -ENOTSUP)
11909 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11911 #ifdef RTE_LIBRTE_BNXT_PMD
11912 if (ret == -ENOTSUP)
11913 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11919 printf("invalid is_on %d\n", is_on);
11922 printf("invalid port_id %d\n", res->port_id);
11925 printf("function not implemented\n");
11928 printf("programming error: (%s)\n", strerror(-ret));
11932 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11933 .f = cmd_set_all_queues_drop_en_parsed,
11935 .help_str = "set all queues drop <port_id> on|off",
11937 (void *)&cmd_all_queues_drop_en_set,
11938 (void *)&cmd_all_queues_drop_en_all,
11939 (void *)&cmd_all_queues_drop_en_queues,
11940 (void *)&cmd_all_queues_drop_en_drop,
11941 (void *)&cmd_all_queues_drop_en_port_id,
11942 (void *)&cmd_all_queues_drop_en_on_off,
11947 /* vf split drop enable configuration */
11949 /* Common result structure for vf split drop enable */
11950 struct cmd_vf_split_drop_en_result {
11951 cmdline_fixed_string_t set;
11952 cmdline_fixed_string_t vf;
11953 cmdline_fixed_string_t split;
11954 cmdline_fixed_string_t drop;
11957 cmdline_fixed_string_t on_off;
11960 /* Common CLI fields for vf split drop enable disable */
11961 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11962 TOKEN_STRING_INITIALIZER
11963 (struct cmd_vf_split_drop_en_result,
11965 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11966 TOKEN_STRING_INITIALIZER
11967 (struct cmd_vf_split_drop_en_result,
11969 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11970 TOKEN_STRING_INITIALIZER
11971 (struct cmd_vf_split_drop_en_result,
11973 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11974 TOKEN_STRING_INITIALIZER
11975 (struct cmd_vf_split_drop_en_result,
11977 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11978 TOKEN_NUM_INITIALIZER
11979 (struct cmd_vf_split_drop_en_result,
11981 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11982 TOKEN_NUM_INITIALIZER
11983 (struct cmd_vf_split_drop_en_result,
11985 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11986 TOKEN_STRING_INITIALIZER
11987 (struct cmd_vf_split_drop_en_result,
11991 cmd_set_vf_split_drop_en_parsed(
11992 void *parsed_result,
11993 __attribute__((unused)) struct cmdline *cl,
11994 __attribute__((unused)) void *data)
11996 struct cmd_vf_split_drop_en_result *res = parsed_result;
11997 int ret = -ENOTSUP;
11998 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12000 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12003 #ifdef RTE_LIBRTE_IXGBE_PMD
12004 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12011 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12014 printf("invalid port_id %d\n", res->port_id);
12017 printf("not supported on port %d\n", res->port_id);
12020 printf("programming error: (%s)\n", strerror(-ret));
12024 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12025 .f = cmd_set_vf_split_drop_en_parsed,
12027 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12029 (void *)&cmd_vf_split_drop_en_set,
12030 (void *)&cmd_vf_split_drop_en_vf,
12031 (void *)&cmd_vf_split_drop_en_split,
12032 (void *)&cmd_vf_split_drop_en_drop,
12033 (void *)&cmd_vf_split_drop_en_port_id,
12034 (void *)&cmd_vf_split_drop_en_vf_id,
12035 (void *)&cmd_vf_split_drop_en_on_off,
12040 /* vf mac address configuration */
12042 /* Common result structure for vf mac address */
12043 struct cmd_set_vf_mac_addr_result {
12044 cmdline_fixed_string_t set;
12045 cmdline_fixed_string_t vf;
12046 cmdline_fixed_string_t mac;
12047 cmdline_fixed_string_t addr;
12050 struct ether_addr mac_addr;
12054 /* Common CLI fields for vf split drop enable disable */
12055 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12056 TOKEN_STRING_INITIALIZER
12057 (struct cmd_set_vf_mac_addr_result,
12059 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12060 TOKEN_STRING_INITIALIZER
12061 (struct cmd_set_vf_mac_addr_result,
12063 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12064 TOKEN_STRING_INITIALIZER
12065 (struct cmd_set_vf_mac_addr_result,
12067 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12068 TOKEN_STRING_INITIALIZER
12069 (struct cmd_set_vf_mac_addr_result,
12071 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12072 TOKEN_NUM_INITIALIZER
12073 (struct cmd_set_vf_mac_addr_result,
12075 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12076 TOKEN_NUM_INITIALIZER
12077 (struct cmd_set_vf_mac_addr_result,
12079 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12080 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12084 cmd_set_vf_mac_addr_parsed(
12085 void *parsed_result,
12086 __attribute__((unused)) struct cmdline *cl,
12087 __attribute__((unused)) void *data)
12089 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12090 int ret = -ENOTSUP;
12092 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12095 #ifdef RTE_LIBRTE_IXGBE_PMD
12096 if (ret == -ENOTSUP)
12097 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12100 #ifdef RTE_LIBRTE_I40E_PMD
12101 if (ret == -ENOTSUP)
12102 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12105 #ifdef RTE_LIBRTE_BNXT_PMD
12106 if (ret == -ENOTSUP)
12107 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12115 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12118 printf("invalid port_id %d\n", res->port_id);
12121 printf("function not implemented\n");
12124 printf("programming error: (%s)\n", strerror(-ret));
12128 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12129 .f = cmd_set_vf_mac_addr_parsed,
12131 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12133 (void *)&cmd_set_vf_mac_addr_set,
12134 (void *)&cmd_set_vf_mac_addr_vf,
12135 (void *)&cmd_set_vf_mac_addr_mac,
12136 (void *)&cmd_set_vf_mac_addr_addr,
12137 (void *)&cmd_set_vf_mac_addr_port_id,
12138 (void *)&cmd_set_vf_mac_addr_vf_id,
12139 (void *)&cmd_set_vf_mac_addr_mac_addr,
12144 /* MACsec configuration */
12146 /* Common result structure for MACsec offload enable */
12147 struct cmd_macsec_offload_on_result {
12148 cmdline_fixed_string_t set;
12149 cmdline_fixed_string_t macsec;
12150 cmdline_fixed_string_t offload;
12152 cmdline_fixed_string_t on;
12153 cmdline_fixed_string_t encrypt;
12154 cmdline_fixed_string_t en_on_off;
12155 cmdline_fixed_string_t replay_protect;
12156 cmdline_fixed_string_t rp_on_off;
12159 /* Common CLI fields for MACsec offload disable */
12160 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12161 TOKEN_STRING_INITIALIZER
12162 (struct cmd_macsec_offload_on_result,
12164 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12165 TOKEN_STRING_INITIALIZER
12166 (struct cmd_macsec_offload_on_result,
12168 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12169 TOKEN_STRING_INITIALIZER
12170 (struct cmd_macsec_offload_on_result,
12171 offload, "offload");
12172 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12173 TOKEN_NUM_INITIALIZER
12174 (struct cmd_macsec_offload_on_result,
12176 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12177 TOKEN_STRING_INITIALIZER
12178 (struct cmd_macsec_offload_on_result,
12180 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12181 TOKEN_STRING_INITIALIZER
12182 (struct cmd_macsec_offload_on_result,
12183 encrypt, "encrypt");
12184 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12185 TOKEN_STRING_INITIALIZER
12186 (struct cmd_macsec_offload_on_result,
12187 en_on_off, "on#off");
12188 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12189 TOKEN_STRING_INITIALIZER
12190 (struct cmd_macsec_offload_on_result,
12191 replay_protect, "replay-protect");
12192 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12193 TOKEN_STRING_INITIALIZER
12194 (struct cmd_macsec_offload_on_result,
12195 rp_on_off, "on#off");
12198 cmd_set_macsec_offload_on_parsed(
12199 void *parsed_result,
12200 __attribute__((unused)) struct cmdline *cl,
12201 __attribute__((unused)) void *data)
12203 struct cmd_macsec_offload_on_result *res = parsed_result;
12204 int ret = -ENOTSUP;
12205 portid_t port_id = res->port_id;
12206 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12207 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12209 if (port_id_is_invalid(port_id, ENABLED_WARN))
12212 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
12213 #ifdef RTE_LIBRTE_IXGBE_PMD
12214 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12223 printf("invalid port_id %d\n", port_id);
12226 printf("not supported on port %d\n", port_id);
12229 printf("programming error: (%s)\n", strerror(-ret));
12233 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12234 .f = cmd_set_macsec_offload_on_parsed,
12236 .help_str = "set macsec offload <port_id> on "
12237 "encrypt on|off replay-protect on|off",
12239 (void *)&cmd_macsec_offload_on_set,
12240 (void *)&cmd_macsec_offload_on_macsec,
12241 (void *)&cmd_macsec_offload_on_offload,
12242 (void *)&cmd_macsec_offload_on_port_id,
12243 (void *)&cmd_macsec_offload_on_on,
12244 (void *)&cmd_macsec_offload_on_encrypt,
12245 (void *)&cmd_macsec_offload_on_en_on_off,
12246 (void *)&cmd_macsec_offload_on_replay_protect,
12247 (void *)&cmd_macsec_offload_on_rp_on_off,
12252 /* Common result structure for MACsec offload disable */
12253 struct cmd_macsec_offload_off_result {
12254 cmdline_fixed_string_t set;
12255 cmdline_fixed_string_t macsec;
12256 cmdline_fixed_string_t offload;
12258 cmdline_fixed_string_t off;
12261 /* Common CLI fields for MACsec offload disable */
12262 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12263 TOKEN_STRING_INITIALIZER
12264 (struct cmd_macsec_offload_off_result,
12266 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12267 TOKEN_STRING_INITIALIZER
12268 (struct cmd_macsec_offload_off_result,
12270 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12271 TOKEN_STRING_INITIALIZER
12272 (struct cmd_macsec_offload_off_result,
12273 offload, "offload");
12274 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12275 TOKEN_NUM_INITIALIZER
12276 (struct cmd_macsec_offload_off_result,
12278 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12279 TOKEN_STRING_INITIALIZER
12280 (struct cmd_macsec_offload_off_result,
12284 cmd_set_macsec_offload_off_parsed(
12285 void *parsed_result,
12286 __attribute__((unused)) struct cmdline *cl,
12287 __attribute__((unused)) void *data)
12289 struct cmd_macsec_offload_off_result *res = parsed_result;
12290 int ret = -ENOTSUP;
12291 portid_t port_id = res->port_id;
12293 if (port_id_is_invalid(port_id, ENABLED_WARN))
12296 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
12297 #ifdef RTE_LIBRTE_IXGBE_PMD
12298 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12305 printf("invalid port_id %d\n", port_id);
12308 printf("not supported on port %d\n", port_id);
12311 printf("programming error: (%s)\n", strerror(-ret));
12315 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12316 .f = cmd_set_macsec_offload_off_parsed,
12318 .help_str = "set macsec offload <port_id> off",
12320 (void *)&cmd_macsec_offload_off_set,
12321 (void *)&cmd_macsec_offload_off_macsec,
12322 (void *)&cmd_macsec_offload_off_offload,
12323 (void *)&cmd_macsec_offload_off_port_id,
12324 (void *)&cmd_macsec_offload_off_off,
12329 /* Common result structure for MACsec secure connection configure */
12330 struct cmd_macsec_sc_result {
12331 cmdline_fixed_string_t set;
12332 cmdline_fixed_string_t macsec;
12333 cmdline_fixed_string_t sc;
12334 cmdline_fixed_string_t tx_rx;
12336 struct ether_addr mac;
12340 /* Common CLI fields for MACsec secure connection configure */
12341 cmdline_parse_token_string_t cmd_macsec_sc_set =
12342 TOKEN_STRING_INITIALIZER
12343 (struct cmd_macsec_sc_result,
12345 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12346 TOKEN_STRING_INITIALIZER
12347 (struct cmd_macsec_sc_result,
12349 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12350 TOKEN_STRING_INITIALIZER
12351 (struct cmd_macsec_sc_result,
12353 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12354 TOKEN_STRING_INITIALIZER
12355 (struct cmd_macsec_sc_result,
12357 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12358 TOKEN_NUM_INITIALIZER
12359 (struct cmd_macsec_sc_result,
12361 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12362 TOKEN_ETHERADDR_INITIALIZER
12363 (struct cmd_macsec_sc_result,
12365 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12366 TOKEN_NUM_INITIALIZER
12367 (struct cmd_macsec_sc_result,
12371 cmd_set_macsec_sc_parsed(
12372 void *parsed_result,
12373 __attribute__((unused)) struct cmdline *cl,
12374 __attribute__((unused)) void *data)
12376 struct cmd_macsec_sc_result *res = parsed_result;
12377 int ret = -ENOTSUP;
12378 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12380 #ifdef RTE_LIBRTE_IXGBE_PMD
12382 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12383 res->mac.addr_bytes) :
12384 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12385 res->mac.addr_bytes, res->pi);
12387 RTE_SET_USED(is_tx);
12393 printf("invalid port_id %d\n", res->port_id);
12396 printf("not supported on port %d\n", res->port_id);
12399 printf("programming error: (%s)\n", strerror(-ret));
12403 cmdline_parse_inst_t cmd_set_macsec_sc = {
12404 .f = cmd_set_macsec_sc_parsed,
12406 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12408 (void *)&cmd_macsec_sc_set,
12409 (void *)&cmd_macsec_sc_macsec,
12410 (void *)&cmd_macsec_sc_sc,
12411 (void *)&cmd_macsec_sc_tx_rx,
12412 (void *)&cmd_macsec_sc_port_id,
12413 (void *)&cmd_macsec_sc_mac,
12414 (void *)&cmd_macsec_sc_pi,
12419 /* Common result structure for MACsec secure connection configure */
12420 struct cmd_macsec_sa_result {
12421 cmdline_fixed_string_t set;
12422 cmdline_fixed_string_t macsec;
12423 cmdline_fixed_string_t sa;
12424 cmdline_fixed_string_t tx_rx;
12429 cmdline_fixed_string_t key;
12432 /* Common CLI fields for MACsec secure connection configure */
12433 cmdline_parse_token_string_t cmd_macsec_sa_set =
12434 TOKEN_STRING_INITIALIZER
12435 (struct cmd_macsec_sa_result,
12437 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12438 TOKEN_STRING_INITIALIZER
12439 (struct cmd_macsec_sa_result,
12441 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12442 TOKEN_STRING_INITIALIZER
12443 (struct cmd_macsec_sa_result,
12445 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12446 TOKEN_STRING_INITIALIZER
12447 (struct cmd_macsec_sa_result,
12449 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12450 TOKEN_NUM_INITIALIZER
12451 (struct cmd_macsec_sa_result,
12453 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12454 TOKEN_NUM_INITIALIZER
12455 (struct cmd_macsec_sa_result,
12457 cmdline_parse_token_num_t cmd_macsec_sa_an =
12458 TOKEN_NUM_INITIALIZER
12459 (struct cmd_macsec_sa_result,
12461 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12462 TOKEN_NUM_INITIALIZER
12463 (struct cmd_macsec_sa_result,
12465 cmdline_parse_token_string_t cmd_macsec_sa_key =
12466 TOKEN_STRING_INITIALIZER
12467 (struct cmd_macsec_sa_result,
12471 cmd_set_macsec_sa_parsed(
12472 void *parsed_result,
12473 __attribute__((unused)) struct cmdline *cl,
12474 __attribute__((unused)) void *data)
12476 struct cmd_macsec_sa_result *res = parsed_result;
12477 int ret = -ENOTSUP;
12478 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12479 uint8_t key[16] = { 0 };
12485 key_len = strlen(res->key) / 2;
12489 for (i = 0; i < key_len; i++) {
12490 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12493 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12496 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12499 #ifdef RTE_LIBRTE_IXGBE_PMD
12501 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12502 res->idx, res->an, res->pn, key) :
12503 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12504 res->idx, res->an, res->pn, key);
12506 RTE_SET_USED(is_tx);
12513 printf("invalid idx %d or an %d\n", res->idx, res->an);
12516 printf("invalid port_id %d\n", res->port_id);
12519 printf("not supported on port %d\n", res->port_id);
12522 printf("programming error: (%s)\n", strerror(-ret));
12526 cmdline_parse_inst_t cmd_set_macsec_sa = {
12527 .f = cmd_set_macsec_sa_parsed,
12529 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12531 (void *)&cmd_macsec_sa_set,
12532 (void *)&cmd_macsec_sa_macsec,
12533 (void *)&cmd_macsec_sa_sa,
12534 (void *)&cmd_macsec_sa_tx_rx,
12535 (void *)&cmd_macsec_sa_port_id,
12536 (void *)&cmd_macsec_sa_idx,
12537 (void *)&cmd_macsec_sa_an,
12538 (void *)&cmd_macsec_sa_pn,
12539 (void *)&cmd_macsec_sa_key,
12544 /* VF unicast promiscuous mode configuration */
12546 /* Common result structure for VF unicast promiscuous mode */
12547 struct cmd_vf_promisc_result {
12548 cmdline_fixed_string_t set;
12549 cmdline_fixed_string_t vf;
12550 cmdline_fixed_string_t promisc;
12553 cmdline_fixed_string_t on_off;
12556 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12557 cmdline_parse_token_string_t cmd_vf_promisc_set =
12558 TOKEN_STRING_INITIALIZER
12559 (struct cmd_vf_promisc_result,
12561 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12562 TOKEN_STRING_INITIALIZER
12563 (struct cmd_vf_promisc_result,
12565 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12566 TOKEN_STRING_INITIALIZER
12567 (struct cmd_vf_promisc_result,
12568 promisc, "promisc");
12569 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12570 TOKEN_NUM_INITIALIZER
12571 (struct cmd_vf_promisc_result,
12573 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12574 TOKEN_NUM_INITIALIZER
12575 (struct cmd_vf_promisc_result,
12577 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12578 TOKEN_STRING_INITIALIZER
12579 (struct cmd_vf_promisc_result,
12583 cmd_set_vf_promisc_parsed(
12584 void *parsed_result,
12585 __attribute__((unused)) struct cmdline *cl,
12586 __attribute__((unused)) void *data)
12588 struct cmd_vf_promisc_result *res = parsed_result;
12589 int ret = -ENOTSUP;
12591 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12596 #ifdef RTE_LIBRTE_I40E_PMD
12597 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12598 res->vf_id, is_on);
12605 printf("invalid vf_id %d\n", res->vf_id);
12608 printf("invalid port_id %d\n", res->port_id);
12611 printf("function not implemented\n");
12614 printf("programming error: (%s)\n", strerror(-ret));
12618 cmdline_parse_inst_t cmd_set_vf_promisc = {
12619 .f = cmd_set_vf_promisc_parsed,
12621 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12622 "Set unicast promiscuous mode for a VF from the PF",
12624 (void *)&cmd_vf_promisc_set,
12625 (void *)&cmd_vf_promisc_vf,
12626 (void *)&cmd_vf_promisc_promisc,
12627 (void *)&cmd_vf_promisc_port_id,
12628 (void *)&cmd_vf_promisc_vf_id,
12629 (void *)&cmd_vf_promisc_on_off,
12634 /* VF multicast promiscuous mode configuration */
12636 /* Common result structure for VF multicast promiscuous mode */
12637 struct cmd_vf_allmulti_result {
12638 cmdline_fixed_string_t set;
12639 cmdline_fixed_string_t vf;
12640 cmdline_fixed_string_t allmulti;
12643 cmdline_fixed_string_t on_off;
12646 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12647 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12648 TOKEN_STRING_INITIALIZER
12649 (struct cmd_vf_allmulti_result,
12651 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12652 TOKEN_STRING_INITIALIZER
12653 (struct cmd_vf_allmulti_result,
12655 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12656 TOKEN_STRING_INITIALIZER
12657 (struct cmd_vf_allmulti_result,
12658 allmulti, "allmulti");
12659 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12660 TOKEN_NUM_INITIALIZER
12661 (struct cmd_vf_allmulti_result,
12663 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12664 TOKEN_NUM_INITIALIZER
12665 (struct cmd_vf_allmulti_result,
12667 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12668 TOKEN_STRING_INITIALIZER
12669 (struct cmd_vf_allmulti_result,
12673 cmd_set_vf_allmulti_parsed(
12674 void *parsed_result,
12675 __attribute__((unused)) struct cmdline *cl,
12676 __attribute__((unused)) void *data)
12678 struct cmd_vf_allmulti_result *res = parsed_result;
12679 int ret = -ENOTSUP;
12681 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12683 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12686 #ifdef RTE_LIBRTE_I40E_PMD
12687 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12688 res->vf_id, is_on);
12695 printf("invalid vf_id %d\n", res->vf_id);
12698 printf("invalid port_id %d\n", res->port_id);
12701 printf("function not implemented\n");
12704 printf("programming error: (%s)\n", strerror(-ret));
12708 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12709 .f = cmd_set_vf_allmulti_parsed,
12711 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12712 "Set multicast promiscuous mode for a VF from the PF",
12714 (void *)&cmd_vf_allmulti_set,
12715 (void *)&cmd_vf_allmulti_vf,
12716 (void *)&cmd_vf_allmulti_allmulti,
12717 (void *)&cmd_vf_allmulti_port_id,
12718 (void *)&cmd_vf_allmulti_vf_id,
12719 (void *)&cmd_vf_allmulti_on_off,
12724 /* vf broadcast mode configuration */
12726 /* Common result structure for vf broadcast */
12727 struct cmd_set_vf_broadcast_result {
12728 cmdline_fixed_string_t set;
12729 cmdline_fixed_string_t vf;
12730 cmdline_fixed_string_t broadcast;
12733 cmdline_fixed_string_t on_off;
12736 /* Common CLI fields for vf broadcast enable disable */
12737 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12738 TOKEN_STRING_INITIALIZER
12739 (struct cmd_set_vf_broadcast_result,
12741 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12742 TOKEN_STRING_INITIALIZER
12743 (struct cmd_set_vf_broadcast_result,
12745 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12746 TOKEN_STRING_INITIALIZER
12747 (struct cmd_set_vf_broadcast_result,
12748 broadcast, "broadcast");
12749 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12750 TOKEN_NUM_INITIALIZER
12751 (struct cmd_set_vf_broadcast_result,
12753 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12754 TOKEN_NUM_INITIALIZER
12755 (struct cmd_set_vf_broadcast_result,
12757 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12758 TOKEN_STRING_INITIALIZER
12759 (struct cmd_set_vf_broadcast_result,
12763 cmd_set_vf_broadcast_parsed(
12764 void *parsed_result,
12765 __attribute__((unused)) struct cmdline *cl,
12766 __attribute__((unused)) void *data)
12768 struct cmd_set_vf_broadcast_result *res = parsed_result;
12769 int ret = -ENOTSUP;
12771 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12773 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12776 #ifdef RTE_LIBRTE_I40E_PMD
12777 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12778 res->vf_id, is_on);
12785 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12788 printf("invalid port_id %d\n", res->port_id);
12791 printf("function not implemented\n");
12794 printf("programming error: (%s)\n", strerror(-ret));
12798 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12799 .f = cmd_set_vf_broadcast_parsed,
12801 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12803 (void *)&cmd_set_vf_broadcast_set,
12804 (void *)&cmd_set_vf_broadcast_vf,
12805 (void *)&cmd_set_vf_broadcast_broadcast,
12806 (void *)&cmd_set_vf_broadcast_port_id,
12807 (void *)&cmd_set_vf_broadcast_vf_id,
12808 (void *)&cmd_set_vf_broadcast_on_off,
12813 /* vf vlan tag configuration */
12815 /* Common result structure for vf vlan tag */
12816 struct cmd_set_vf_vlan_tag_result {
12817 cmdline_fixed_string_t set;
12818 cmdline_fixed_string_t vf;
12819 cmdline_fixed_string_t vlan;
12820 cmdline_fixed_string_t tag;
12823 cmdline_fixed_string_t on_off;
12826 /* Common CLI fields for vf vlan tag enable disable */
12827 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12828 TOKEN_STRING_INITIALIZER
12829 (struct cmd_set_vf_vlan_tag_result,
12831 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12832 TOKEN_STRING_INITIALIZER
12833 (struct cmd_set_vf_vlan_tag_result,
12835 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12836 TOKEN_STRING_INITIALIZER
12837 (struct cmd_set_vf_vlan_tag_result,
12839 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12840 TOKEN_STRING_INITIALIZER
12841 (struct cmd_set_vf_vlan_tag_result,
12843 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12844 TOKEN_NUM_INITIALIZER
12845 (struct cmd_set_vf_vlan_tag_result,
12847 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12848 TOKEN_NUM_INITIALIZER
12849 (struct cmd_set_vf_vlan_tag_result,
12851 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12852 TOKEN_STRING_INITIALIZER
12853 (struct cmd_set_vf_vlan_tag_result,
12857 cmd_set_vf_vlan_tag_parsed(
12858 void *parsed_result,
12859 __attribute__((unused)) struct cmdline *cl,
12860 __attribute__((unused)) void *data)
12862 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12863 int ret = -ENOTSUP;
12865 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12867 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12870 #ifdef RTE_LIBRTE_I40E_PMD
12871 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12872 res->vf_id, is_on);
12879 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12882 printf("invalid port_id %d\n", res->port_id);
12885 printf("function not implemented\n");
12888 printf("programming error: (%s)\n", strerror(-ret));
12892 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12893 .f = cmd_set_vf_vlan_tag_parsed,
12895 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12897 (void *)&cmd_set_vf_vlan_tag_set,
12898 (void *)&cmd_set_vf_vlan_tag_vf,
12899 (void *)&cmd_set_vf_vlan_tag_vlan,
12900 (void *)&cmd_set_vf_vlan_tag_tag,
12901 (void *)&cmd_set_vf_vlan_tag_port_id,
12902 (void *)&cmd_set_vf_vlan_tag_vf_id,
12903 (void *)&cmd_set_vf_vlan_tag_on_off,
12908 /* Common definition of VF and TC TX bandwidth configuration */
12909 struct cmd_vf_tc_bw_result {
12910 cmdline_fixed_string_t set;
12911 cmdline_fixed_string_t vf;
12912 cmdline_fixed_string_t tc;
12913 cmdline_fixed_string_t tx;
12914 cmdline_fixed_string_t min_bw;
12915 cmdline_fixed_string_t max_bw;
12916 cmdline_fixed_string_t strict_link_prio;
12921 cmdline_fixed_string_t bw_list;
12925 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12926 TOKEN_STRING_INITIALIZER
12927 (struct cmd_vf_tc_bw_result,
12929 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12930 TOKEN_STRING_INITIALIZER
12931 (struct cmd_vf_tc_bw_result,
12933 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12934 TOKEN_STRING_INITIALIZER
12935 (struct cmd_vf_tc_bw_result,
12937 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12938 TOKEN_STRING_INITIALIZER
12939 (struct cmd_vf_tc_bw_result,
12941 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12942 TOKEN_STRING_INITIALIZER
12943 (struct cmd_vf_tc_bw_result,
12944 strict_link_prio, "strict-link-priority");
12945 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12946 TOKEN_STRING_INITIALIZER
12947 (struct cmd_vf_tc_bw_result,
12948 min_bw, "min-bandwidth");
12949 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12950 TOKEN_STRING_INITIALIZER
12951 (struct cmd_vf_tc_bw_result,
12952 max_bw, "max-bandwidth");
12953 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12954 TOKEN_NUM_INITIALIZER
12955 (struct cmd_vf_tc_bw_result,
12957 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12958 TOKEN_NUM_INITIALIZER
12959 (struct cmd_vf_tc_bw_result,
12961 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12962 TOKEN_NUM_INITIALIZER
12963 (struct cmd_vf_tc_bw_result,
12965 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12966 TOKEN_NUM_INITIALIZER
12967 (struct cmd_vf_tc_bw_result,
12969 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12970 TOKEN_STRING_INITIALIZER
12971 (struct cmd_vf_tc_bw_result,
12973 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12974 TOKEN_NUM_INITIALIZER
12975 (struct cmd_vf_tc_bw_result,
12978 /* VF max bandwidth setting */
12980 cmd_vf_max_bw_parsed(
12981 void *parsed_result,
12982 __attribute__((unused)) struct cmdline *cl,
12983 __attribute__((unused)) void *data)
12985 struct cmd_vf_tc_bw_result *res = parsed_result;
12986 int ret = -ENOTSUP;
12988 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12991 #ifdef RTE_LIBRTE_I40E_PMD
12992 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12993 res->vf_id, res->bw);
13000 printf("invalid vf_id %d or bandwidth %d\n",
13001 res->vf_id, res->bw);
13004 printf("invalid port_id %d\n", res->port_id);
13007 printf("function not implemented\n");
13010 printf("programming error: (%s)\n", strerror(-ret));
13014 cmdline_parse_inst_t cmd_vf_max_bw = {
13015 .f = cmd_vf_max_bw_parsed,
13017 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13019 (void *)&cmd_vf_tc_bw_set,
13020 (void *)&cmd_vf_tc_bw_vf,
13021 (void *)&cmd_vf_tc_bw_tx,
13022 (void *)&cmd_vf_tc_bw_max_bw,
13023 (void *)&cmd_vf_tc_bw_port_id,
13024 (void *)&cmd_vf_tc_bw_vf_id,
13025 (void *)&cmd_vf_tc_bw_bw,
13031 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13036 const char *p, *p0 = str;
13043 p = strchr(p0, '(');
13045 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13049 p0 = strchr(p, ')');
13051 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13055 if (size >= sizeof(s)) {
13056 printf("The string size exceeds the internal buffer size\n");
13059 snprintf(s, sizeof(s), "%.*s", size, p);
13060 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13062 printf("Failed to get the bandwidth list. ");
13066 for (i = 0; i < ret; i++)
13067 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13072 /* TC min bandwidth setting */
13074 cmd_vf_tc_min_bw_parsed(
13075 void *parsed_result,
13076 __attribute__((unused)) struct cmdline *cl,
13077 __attribute__((unused)) void *data)
13079 struct cmd_vf_tc_bw_result *res = parsed_result;
13082 int ret = -ENOTSUP;
13084 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13087 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13091 #ifdef RTE_LIBRTE_I40E_PMD
13092 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13100 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13103 printf("invalid port_id %d\n", res->port_id);
13106 printf("function not implemented\n");
13109 printf("programming error: (%s)\n", strerror(-ret));
13113 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13114 .f = cmd_vf_tc_min_bw_parsed,
13116 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13117 " <bw1, bw2, ...>",
13119 (void *)&cmd_vf_tc_bw_set,
13120 (void *)&cmd_vf_tc_bw_vf,
13121 (void *)&cmd_vf_tc_bw_tc,
13122 (void *)&cmd_vf_tc_bw_tx,
13123 (void *)&cmd_vf_tc_bw_min_bw,
13124 (void *)&cmd_vf_tc_bw_port_id,
13125 (void *)&cmd_vf_tc_bw_vf_id,
13126 (void *)&cmd_vf_tc_bw_bw_list,
13132 cmd_tc_min_bw_parsed(
13133 void *parsed_result,
13134 __attribute__((unused)) struct cmdline *cl,
13135 __attribute__((unused)) void *data)
13137 struct cmd_vf_tc_bw_result *res = parsed_result;
13138 struct rte_port *port;
13141 int ret = -ENOTSUP;
13143 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13146 port = &ports[res->port_id];
13147 /** Check if the port is not started **/
13148 if (port->port_status != RTE_PORT_STOPPED) {
13149 printf("Please stop port %d first\n", res->port_id);
13153 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13157 #ifdef RTE_LIBRTE_IXGBE_PMD
13158 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13165 printf("invalid bandwidth\n");
13168 printf("invalid port_id %d\n", res->port_id);
13171 printf("function not implemented\n");
13174 printf("programming error: (%s)\n", strerror(-ret));
13178 cmdline_parse_inst_t cmd_tc_min_bw = {
13179 .f = cmd_tc_min_bw_parsed,
13181 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13183 (void *)&cmd_vf_tc_bw_set,
13184 (void *)&cmd_vf_tc_bw_tc,
13185 (void *)&cmd_vf_tc_bw_tx,
13186 (void *)&cmd_vf_tc_bw_min_bw,
13187 (void *)&cmd_vf_tc_bw_port_id,
13188 (void *)&cmd_vf_tc_bw_bw_list,
13193 /* TC max bandwidth setting */
13195 cmd_vf_tc_max_bw_parsed(
13196 void *parsed_result,
13197 __attribute__((unused)) struct cmdline *cl,
13198 __attribute__((unused)) void *data)
13200 struct cmd_vf_tc_bw_result *res = parsed_result;
13201 int ret = -ENOTSUP;
13203 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13206 #ifdef RTE_LIBRTE_I40E_PMD
13207 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13208 res->tc_no, res->bw);
13215 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13216 res->vf_id, res->tc_no, res->bw);
13219 printf("invalid port_id %d\n", res->port_id);
13222 printf("function not implemented\n");
13225 printf("programming error: (%s)\n", strerror(-ret));
13229 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13230 .f = cmd_vf_tc_max_bw_parsed,
13232 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13235 (void *)&cmd_vf_tc_bw_set,
13236 (void *)&cmd_vf_tc_bw_vf,
13237 (void *)&cmd_vf_tc_bw_tc,
13238 (void *)&cmd_vf_tc_bw_tx,
13239 (void *)&cmd_vf_tc_bw_max_bw,
13240 (void *)&cmd_vf_tc_bw_port_id,
13241 (void *)&cmd_vf_tc_bw_vf_id,
13242 (void *)&cmd_vf_tc_bw_tc_no,
13243 (void *)&cmd_vf_tc_bw_bw,
13248 /* Strict link priority scheduling mode setting */
13250 cmd_strict_link_prio_parsed(
13251 void *parsed_result,
13252 __attribute__((unused)) struct cmdline *cl,
13253 __attribute__((unused)) void *data)
13255 struct cmd_vf_tc_bw_result *res = parsed_result;
13256 int ret = -ENOTSUP;
13258 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13261 #ifdef RTE_LIBRTE_I40E_PMD
13262 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13269 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13272 printf("invalid port_id %d\n", res->port_id);
13275 printf("function not implemented\n");
13278 printf("programming error: (%s)\n", strerror(-ret));
13282 cmdline_parse_inst_t cmd_strict_link_prio = {
13283 .f = cmd_strict_link_prio_parsed,
13285 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13287 (void *)&cmd_vf_tc_bw_set,
13288 (void *)&cmd_vf_tc_bw_tx,
13289 (void *)&cmd_vf_tc_bw_strict_link_prio,
13290 (void *)&cmd_vf_tc_bw_port_id,
13291 (void *)&cmd_vf_tc_bw_tc_map,
13296 /* Load dynamic device personalization*/
13297 struct cmd_ddp_add_result {
13298 cmdline_fixed_string_t ddp;
13299 cmdline_fixed_string_t add;
13304 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13305 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13306 cmdline_parse_token_string_t cmd_ddp_add_add =
13307 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13308 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13309 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
13310 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13311 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13314 cmd_ddp_add_parsed(
13315 void *parsed_result,
13316 __attribute__((unused)) struct cmdline *cl,
13317 __attribute__((unused)) void *data)
13319 struct cmd_ddp_add_result *res = parsed_result;
13325 int ret = -ENOTSUP;
13327 if (res->port_id > nb_ports) {
13328 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13332 if (!all_ports_stopped()) {
13333 printf("Please stop all ports first\n");
13337 filepath = strdup(res->filepath);
13338 if (filepath == NULL) {
13339 printf("Failed to allocate memory\n");
13342 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13344 buff = open_ddp_package_file(file_fld[0], &size);
13346 free((void *)filepath);
13350 #ifdef RTE_LIBRTE_I40E_PMD
13351 if (ret == -ENOTSUP)
13352 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13354 RTE_PMD_I40E_PKG_OP_WR_ADD);
13357 if (ret == -EEXIST)
13358 printf("Profile has already existed.\n");
13360 printf("Failed to load profile.\n");
13361 else if (file_num == 2)
13362 save_ddp_package_file(file_fld[1], buff, size);
13364 close_ddp_package_file(buff);
13365 free((void *)filepath);
13368 cmdline_parse_inst_t cmd_ddp_add = {
13369 .f = cmd_ddp_add_parsed,
13371 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
13373 (void *)&cmd_ddp_add_ddp,
13374 (void *)&cmd_ddp_add_add,
13375 (void *)&cmd_ddp_add_port_id,
13376 (void *)&cmd_ddp_add_filepath,
13381 /* Delete dynamic device personalization*/
13382 struct cmd_ddp_del_result {
13383 cmdline_fixed_string_t ddp;
13384 cmdline_fixed_string_t del;
13389 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13390 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13391 cmdline_parse_token_string_t cmd_ddp_del_del =
13392 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13393 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13394 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT8);
13395 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13396 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13399 cmd_ddp_del_parsed(
13400 void *parsed_result,
13401 __attribute__((unused)) struct cmdline *cl,
13402 __attribute__((unused)) void *data)
13404 struct cmd_ddp_del_result *res = parsed_result;
13407 int ret = -ENOTSUP;
13409 if (res->port_id > nb_ports) {
13410 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13414 if (!all_ports_stopped()) {
13415 printf("Please stop all ports first\n");
13419 buff = open_ddp_package_file(res->filepath, &size);
13423 #ifdef RTE_LIBRTE_I40E_PMD
13424 if (ret == -ENOTSUP)
13425 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13427 RTE_PMD_I40E_PKG_OP_WR_DEL);
13430 if (ret == -EACCES)
13431 printf("Profile does not exist.\n");
13433 printf("Failed to delete profile.\n");
13435 close_ddp_package_file(buff);
13438 cmdline_parse_inst_t cmd_ddp_del = {
13439 .f = cmd_ddp_del_parsed,
13441 .help_str = "ddp del <port_id> <profile_path>",
13443 (void *)&cmd_ddp_del_ddp,
13444 (void *)&cmd_ddp_del_del,
13445 (void *)&cmd_ddp_del_port_id,
13446 (void *)&cmd_ddp_del_filepath,
13451 /* Get dynamic device personalization profile info */
13452 struct cmd_ddp_info_result {
13453 cmdline_fixed_string_t ddp;
13454 cmdline_fixed_string_t get;
13455 cmdline_fixed_string_t info;
13459 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13460 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13461 cmdline_parse_token_string_t cmd_ddp_info_get =
13462 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13463 cmdline_parse_token_string_t cmd_ddp_info_info =
13464 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13465 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13466 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13469 cmd_ddp_info_parsed(
13470 void *parsed_result,
13471 __attribute__((unused)) struct cmdline *cl,
13472 __attribute__((unused)) void *data)
13474 struct cmd_ddp_info_result *res = parsed_result;
13477 int ret = -ENOTSUP;
13478 #ifdef RTE_LIBRTE_I40E_PMD
13481 uint32_t buff_size = 0;
13482 struct rte_pmd_i40e_profile_info info;
13483 uint32_t dev_num = 0;
13484 struct rte_pmd_i40e_ddp_device_id *devs;
13485 uint32_t proto_num = 0;
13486 struct rte_pmd_i40e_proto_info *proto;
13487 uint32_t pctype_num = 0;
13488 struct rte_pmd_i40e_ptype_info *pctype;
13489 uint32_t ptype_num = 0;
13490 struct rte_pmd_i40e_ptype_info *ptype;
13495 pkg = open_ddp_package_file(res->filepath, &pkg_size);
13499 #ifdef RTE_LIBRTE_I40E_PMD
13500 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13501 (uint8_t *)&info, sizeof(info),
13502 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13504 printf("Global Track id: 0x%x\n", info.track_id);
13505 printf("Global Version: %d.%d.%d.%d\n",
13506 info.version.major,
13507 info.version.minor,
13508 info.version.update,
13509 info.version.draft);
13510 printf("Global Package name: %s\n\n", info.name);
13513 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13514 (uint8_t *)&info, sizeof(info),
13515 RTE_PMD_I40E_PKG_INFO_HEADER);
13517 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13518 printf("i40e Profile Version: %d.%d.%d.%d\n",
13519 info.version.major,
13520 info.version.minor,
13521 info.version.update,
13522 info.version.draft);
13523 printf("i40e Profile name: %s\n\n", info.name);
13526 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13527 (uint8_t *)&buff_size, sizeof(buff_size),
13528 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13529 if (!ret && buff_size) {
13530 buff = (uint8_t *)malloc(buff_size);
13532 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13534 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13536 printf("Package Notes:\n%s\n\n", buff);
13541 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13542 (uint8_t *)&dev_num, sizeof(dev_num),
13543 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13544 if (!ret && dev_num) {
13545 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
13546 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
13548 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13549 (uint8_t *)devs, buff_size,
13550 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13552 printf("List of supported devices:\n");
13553 for (i = 0; i < dev_num; i++) {
13554 printf(" %04X:%04X %04X:%04X\n",
13555 devs[i].vendor_dev_id >> 16,
13556 devs[i].vendor_dev_id & 0xFFFF,
13557 devs[i].sub_vendor_dev_id >> 16,
13558 devs[i].sub_vendor_dev_id & 0xFFFF);
13566 /* get information about protocols and packet types */
13567 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13568 (uint8_t *)&proto_num, sizeof(proto_num),
13569 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
13570 if (ret || !proto_num)
13571 goto no_print_return;
13573 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
13574 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
13576 goto no_print_return;
13578 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
13580 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
13582 printf("List of used protocols:\n");
13583 for (i = 0; i < proto_num; i++)
13584 printf(" %2u: %s\n", proto[i].proto_id,
13588 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13589 (uint8_t *)&pctype_num, sizeof(pctype_num),
13590 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
13591 if (ret || !pctype_num)
13592 goto no_print_pctypes;
13594 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13595 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13597 goto no_print_pctypes;
13599 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
13601 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
13604 goto no_print_pctypes;
13607 printf("List of defined packet classification types:\n");
13608 for (i = 0; i < pctype_num; i++) {
13609 printf(" %2u:", pctype[i].ptype_id);
13610 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13611 proto_id = pctype[i].protocols[j];
13612 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13613 for (n = 0; n < proto_num; n++) {
13614 if (proto[n].proto_id == proto_id) {
13615 printf(" %s", proto[n].name);
13628 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
13630 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
13631 if (ret || !ptype_num)
13632 goto no_print_return;
13634 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13635 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13637 goto no_print_return;
13639 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
13641 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
13644 goto no_print_return;
13646 printf("List of defined packet types:\n");
13647 for (i = 0; i < ptype_num; i++) {
13648 printf(" %2u:", ptype[i].ptype_id);
13649 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13650 proto_id = ptype[i].protocols[j];
13651 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13652 for (n = 0; n < proto_num; n++) {
13653 if (proto[n].proto_id == proto_id) {
13654 printf(" %s", proto[n].name);
13669 if (ret == -ENOTSUP)
13670 printf("Function not supported in PMD driver\n");
13671 close_ddp_package_file(pkg);
13674 cmdline_parse_inst_t cmd_ddp_get_info = {
13675 .f = cmd_ddp_info_parsed,
13677 .help_str = "ddp get info <profile_path>",
13679 (void *)&cmd_ddp_info_ddp,
13680 (void *)&cmd_ddp_info_get,
13681 (void *)&cmd_ddp_info_info,
13682 (void *)&cmd_ddp_info_filepath,
13687 /* Get dynamic device personalization profile info list*/
13688 #define PROFILE_INFO_SIZE 48
13689 #define MAX_PROFILE_NUM 16
13691 struct cmd_ddp_get_list_result {
13692 cmdline_fixed_string_t ddp;
13693 cmdline_fixed_string_t get;
13694 cmdline_fixed_string_t list;
13698 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
13699 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
13700 cmdline_parse_token_string_t cmd_ddp_get_list_get =
13701 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
13702 cmdline_parse_token_string_t cmd_ddp_get_list_list =
13703 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
13704 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
13705 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
13708 cmd_ddp_get_list_parsed(
13709 void *parsed_result,
13710 __attribute__((unused)) struct cmdline *cl,
13711 __attribute__((unused)) void *data)
13713 struct cmd_ddp_get_list_result *res = parsed_result;
13714 #ifdef RTE_LIBRTE_I40E_PMD
13715 struct rte_pmd_i40e_profile_list *p_list;
13716 struct rte_pmd_i40e_profile_info *p_info;
13721 int ret = -ENOTSUP;
13723 if (res->port_id > nb_ports) {
13724 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13728 #ifdef RTE_LIBRTE_I40E_PMD
13729 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
13730 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
13732 printf("%s: Failed to malloc buffer\n", __func__);
13734 if (ret == -ENOTSUP)
13735 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
13736 (uint8_t *)p_list, size);
13739 p_num = p_list->p_count;
13740 printf("Profile number is: %d\n\n", p_num);
13742 for (i = 0; i < p_num; i++) {
13743 p_info = &p_list->p_info[i];
13744 printf("Profile %d:\n", i);
13745 printf("Track id: 0x%x\n", p_info->track_id);
13746 printf("Version: %d.%d.%d.%d\n",
13747 p_info->version.major,
13748 p_info->version.minor,
13749 p_info->version.update,
13750 p_info->version.draft);
13751 printf("Profile name: %s\n\n", p_info->name);
13759 printf("Failed to get ddp list\n");
13762 cmdline_parse_inst_t cmd_ddp_get_list = {
13763 .f = cmd_ddp_get_list_parsed,
13765 .help_str = "ddp get list <port_id>",
13767 (void *)&cmd_ddp_get_list_ddp,
13768 (void *)&cmd_ddp_get_list_get,
13769 (void *)&cmd_ddp_get_list_list,
13770 (void *)&cmd_ddp_get_list_port_id,
13775 /* show vf stats */
13777 /* Common result structure for show vf stats */
13778 struct cmd_show_vf_stats_result {
13779 cmdline_fixed_string_t show;
13780 cmdline_fixed_string_t vf;
13781 cmdline_fixed_string_t stats;
13786 /* Common CLI fields show vf stats*/
13787 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13788 TOKEN_STRING_INITIALIZER
13789 (struct cmd_show_vf_stats_result,
13791 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13792 TOKEN_STRING_INITIALIZER
13793 (struct cmd_show_vf_stats_result,
13795 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13796 TOKEN_STRING_INITIALIZER
13797 (struct cmd_show_vf_stats_result,
13799 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13800 TOKEN_NUM_INITIALIZER
13801 (struct cmd_show_vf_stats_result,
13803 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13804 TOKEN_NUM_INITIALIZER
13805 (struct cmd_show_vf_stats_result,
13809 cmd_show_vf_stats_parsed(
13810 void *parsed_result,
13811 __attribute__((unused)) struct cmdline *cl,
13812 __attribute__((unused)) void *data)
13814 struct cmd_show_vf_stats_result *res = parsed_result;
13815 struct rte_eth_stats stats;
13816 int ret = -ENOTSUP;
13817 static const char *nic_stats_border = "########################";
13819 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13822 memset(&stats, 0, sizeof(stats));
13824 #ifdef RTE_LIBRTE_I40E_PMD
13825 if (ret == -ENOTSUP)
13826 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13830 #ifdef RTE_LIBRTE_BNXT_PMD
13831 if (ret == -ENOTSUP)
13832 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
13841 printf("invalid vf_id %d\n", res->vf_id);
13844 printf("invalid port_id %d\n", res->port_id);
13847 printf("function not implemented\n");
13850 printf("programming error: (%s)\n", strerror(-ret));
13853 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13854 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13856 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13858 stats.ipackets, stats.imissed, stats.ibytes);
13859 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13860 printf(" RX-nombuf: %-10"PRIu64"\n",
13862 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13864 stats.opackets, stats.oerrors, stats.obytes);
13866 printf(" %s############################%s\n",
13867 nic_stats_border, nic_stats_border);
13870 cmdline_parse_inst_t cmd_show_vf_stats = {
13871 .f = cmd_show_vf_stats_parsed,
13873 .help_str = "show vf stats <port_id> <vf_id>",
13875 (void *)&cmd_show_vf_stats_show,
13876 (void *)&cmd_show_vf_stats_vf,
13877 (void *)&cmd_show_vf_stats_stats,
13878 (void *)&cmd_show_vf_stats_port_id,
13879 (void *)&cmd_show_vf_stats_vf_id,
13884 /* clear vf stats */
13886 /* Common result structure for clear vf stats */
13887 struct cmd_clear_vf_stats_result {
13888 cmdline_fixed_string_t clear;
13889 cmdline_fixed_string_t vf;
13890 cmdline_fixed_string_t stats;
13895 /* Common CLI fields clear vf stats*/
13896 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13897 TOKEN_STRING_INITIALIZER
13898 (struct cmd_clear_vf_stats_result,
13900 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13901 TOKEN_STRING_INITIALIZER
13902 (struct cmd_clear_vf_stats_result,
13904 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13905 TOKEN_STRING_INITIALIZER
13906 (struct cmd_clear_vf_stats_result,
13908 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13909 TOKEN_NUM_INITIALIZER
13910 (struct cmd_clear_vf_stats_result,
13912 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13913 TOKEN_NUM_INITIALIZER
13914 (struct cmd_clear_vf_stats_result,
13918 cmd_clear_vf_stats_parsed(
13919 void *parsed_result,
13920 __attribute__((unused)) struct cmdline *cl,
13921 __attribute__((unused)) void *data)
13923 struct cmd_clear_vf_stats_result *res = parsed_result;
13924 int ret = -ENOTSUP;
13926 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13929 #ifdef RTE_LIBRTE_I40E_PMD
13930 if (ret == -ENOTSUP)
13931 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13934 #ifdef RTE_LIBRTE_BNXT_PMD
13935 if (ret == -ENOTSUP)
13936 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
13944 printf("invalid vf_id %d\n", res->vf_id);
13947 printf("invalid port_id %d\n", res->port_id);
13950 printf("function not implemented\n");
13953 printf("programming error: (%s)\n", strerror(-ret));
13957 cmdline_parse_inst_t cmd_clear_vf_stats = {
13958 .f = cmd_clear_vf_stats_parsed,
13960 .help_str = "clear vf stats <port_id> <vf_id>",
13962 (void *)&cmd_clear_vf_stats_clear,
13963 (void *)&cmd_clear_vf_stats_vf,
13964 (void *)&cmd_clear_vf_stats_stats,
13965 (void *)&cmd_clear_vf_stats_port_id,
13966 (void *)&cmd_clear_vf_stats_vf_id,
13971 /* port config pctype mapping reset */
13973 /* Common result structure for port config pctype mapping reset */
13974 struct cmd_pctype_mapping_reset_result {
13975 cmdline_fixed_string_t port;
13976 cmdline_fixed_string_t config;
13978 cmdline_fixed_string_t pctype;
13979 cmdline_fixed_string_t mapping;
13980 cmdline_fixed_string_t reset;
13983 /* Common CLI fields for port config pctype mapping reset*/
13984 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
13985 TOKEN_STRING_INITIALIZER
13986 (struct cmd_pctype_mapping_reset_result,
13988 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
13989 TOKEN_STRING_INITIALIZER
13990 (struct cmd_pctype_mapping_reset_result,
13992 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
13993 TOKEN_NUM_INITIALIZER
13994 (struct cmd_pctype_mapping_reset_result,
13996 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
13997 TOKEN_STRING_INITIALIZER
13998 (struct cmd_pctype_mapping_reset_result,
14000 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14001 TOKEN_STRING_INITIALIZER
14002 (struct cmd_pctype_mapping_reset_result,
14003 mapping, "mapping");
14004 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14005 TOKEN_STRING_INITIALIZER
14006 (struct cmd_pctype_mapping_reset_result,
14010 cmd_pctype_mapping_reset_parsed(
14011 void *parsed_result,
14012 __attribute__((unused)) struct cmdline *cl,
14013 __attribute__((unused)) void *data)
14015 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14016 int ret = -ENOTSUP;
14018 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14021 #ifdef RTE_LIBRTE_I40E_PMD
14022 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14029 printf("invalid port_id %d\n", res->port_id);
14032 printf("function not implemented\n");
14035 printf("programming error: (%s)\n", strerror(-ret));
14039 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14040 .f = cmd_pctype_mapping_reset_parsed,
14042 .help_str = "port config <port_id> pctype mapping reset",
14044 (void *)&cmd_pctype_mapping_reset_port,
14045 (void *)&cmd_pctype_mapping_reset_config,
14046 (void *)&cmd_pctype_mapping_reset_port_id,
14047 (void *)&cmd_pctype_mapping_reset_pctype,
14048 (void *)&cmd_pctype_mapping_reset_mapping,
14049 (void *)&cmd_pctype_mapping_reset_reset,
14054 /* show port pctype mapping */
14056 /* Common result structure for show port pctype mapping */
14057 struct cmd_pctype_mapping_get_result {
14058 cmdline_fixed_string_t show;
14059 cmdline_fixed_string_t port;
14061 cmdline_fixed_string_t pctype;
14062 cmdline_fixed_string_t mapping;
14065 /* Common CLI fields for pctype mapping get */
14066 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14067 TOKEN_STRING_INITIALIZER
14068 (struct cmd_pctype_mapping_get_result,
14070 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14071 TOKEN_STRING_INITIALIZER
14072 (struct cmd_pctype_mapping_get_result,
14074 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14075 TOKEN_NUM_INITIALIZER
14076 (struct cmd_pctype_mapping_get_result,
14078 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14079 TOKEN_STRING_INITIALIZER
14080 (struct cmd_pctype_mapping_get_result,
14082 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14083 TOKEN_STRING_INITIALIZER
14084 (struct cmd_pctype_mapping_get_result,
14085 mapping, "mapping");
14088 cmd_pctype_mapping_get_parsed(
14089 void *parsed_result,
14090 __attribute__((unused)) struct cmdline *cl,
14091 __attribute__((unused)) void *data)
14093 struct cmd_pctype_mapping_get_result *res = parsed_result;
14094 int ret = -ENOTSUP;
14095 #ifdef RTE_LIBRTE_I40E_PMD
14096 struct rte_pmd_i40e_flow_type_mapping
14097 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14098 int i, j, first_pctype;
14101 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14104 #ifdef RTE_LIBRTE_I40E_PMD
14105 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14112 printf("invalid port_id %d\n", res->port_id);
14115 printf("function not implemented\n");
14118 printf("programming error: (%s)\n", strerror(-ret));
14122 #ifdef RTE_LIBRTE_I40E_PMD
14123 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14124 if (mapping[i].pctype != 0ULL) {
14127 printf("pctype: ");
14128 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14129 if (mapping[i].pctype & (1ULL << j)) {
14130 printf(first_pctype ?
14131 "%02d" : ",%02d", j);
14135 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14141 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14142 .f = cmd_pctype_mapping_get_parsed,
14144 .help_str = "show port <port_id> pctype mapping",
14146 (void *)&cmd_pctype_mapping_get_show,
14147 (void *)&cmd_pctype_mapping_get_port,
14148 (void *)&cmd_pctype_mapping_get_port_id,
14149 (void *)&cmd_pctype_mapping_get_pctype,
14150 (void *)&cmd_pctype_mapping_get_mapping,
14155 /* port config pctype mapping update */
14157 /* Common result structure for port config pctype mapping update */
14158 struct cmd_pctype_mapping_update_result {
14159 cmdline_fixed_string_t port;
14160 cmdline_fixed_string_t config;
14162 cmdline_fixed_string_t pctype;
14163 cmdline_fixed_string_t mapping;
14164 cmdline_fixed_string_t update;
14165 cmdline_fixed_string_t pctype_list;
14166 uint16_t flow_type;
14169 /* Common CLI fields for pctype mapping update*/
14170 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14171 TOKEN_STRING_INITIALIZER
14172 (struct cmd_pctype_mapping_update_result,
14174 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14175 TOKEN_STRING_INITIALIZER
14176 (struct cmd_pctype_mapping_update_result,
14178 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14179 TOKEN_NUM_INITIALIZER
14180 (struct cmd_pctype_mapping_update_result,
14182 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14183 TOKEN_STRING_INITIALIZER
14184 (struct cmd_pctype_mapping_update_result,
14186 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14187 TOKEN_STRING_INITIALIZER
14188 (struct cmd_pctype_mapping_update_result,
14189 mapping, "mapping");
14190 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
14191 TOKEN_STRING_INITIALIZER
14192 (struct cmd_pctype_mapping_update_result,
14194 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
14195 TOKEN_STRING_INITIALIZER
14196 (struct cmd_pctype_mapping_update_result,
14197 pctype_list, NULL);
14198 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
14199 TOKEN_NUM_INITIALIZER
14200 (struct cmd_pctype_mapping_update_result,
14201 flow_type, UINT16);
14204 cmd_pctype_mapping_update_parsed(
14205 void *parsed_result,
14206 __attribute__((unused)) struct cmdline *cl,
14207 __attribute__((unused)) void *data)
14209 struct cmd_pctype_mapping_update_result *res = parsed_result;
14210 int ret = -ENOTSUP;
14211 #ifdef RTE_LIBRTE_I40E_PMD
14212 struct rte_pmd_i40e_flow_type_mapping mapping;
14215 unsigned int nb_item;
14216 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
14218 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14221 nb_item = parse_item_list(res->pctype_list, "pctypes",
14222 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
14224 #ifdef RTE_LIBRTE_I40E_PMD
14225 mapping.flow_type = res->flow_type;
14226 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
14227 mapping.pctype |= (1ULL << pctype_list[i]);
14228 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
14238 printf("invalid pctype or flow type\n");
14241 printf("invalid port_id %d\n", res->port_id);
14244 printf("function not implemented\n");
14247 printf("programming error: (%s)\n", strerror(-ret));
14251 cmdline_parse_inst_t cmd_pctype_mapping_update = {
14252 .f = cmd_pctype_mapping_update_parsed,
14254 .help_str = "port config <port_id> pctype mapping update"
14255 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
14257 (void *)&cmd_pctype_mapping_update_port,
14258 (void *)&cmd_pctype_mapping_update_config,
14259 (void *)&cmd_pctype_mapping_update_port_id,
14260 (void *)&cmd_pctype_mapping_update_pctype,
14261 (void *)&cmd_pctype_mapping_update_mapping,
14262 (void *)&cmd_pctype_mapping_update_update,
14263 (void *)&cmd_pctype_mapping_update_pc_type,
14264 (void *)&cmd_pctype_mapping_update_flow_type,
14269 /* ptype mapping get */
14271 /* Common result structure for ptype mapping get */
14272 struct cmd_ptype_mapping_get_result {
14273 cmdline_fixed_string_t ptype;
14274 cmdline_fixed_string_t mapping;
14275 cmdline_fixed_string_t get;
14277 uint8_t valid_only;
14280 /* Common CLI fields for ptype mapping get */
14281 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
14282 TOKEN_STRING_INITIALIZER
14283 (struct cmd_ptype_mapping_get_result,
14285 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
14286 TOKEN_STRING_INITIALIZER
14287 (struct cmd_ptype_mapping_get_result,
14288 mapping, "mapping");
14289 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
14290 TOKEN_STRING_INITIALIZER
14291 (struct cmd_ptype_mapping_get_result,
14293 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
14294 TOKEN_NUM_INITIALIZER
14295 (struct cmd_ptype_mapping_get_result,
14297 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
14298 TOKEN_NUM_INITIALIZER
14299 (struct cmd_ptype_mapping_get_result,
14300 valid_only, UINT8);
14303 cmd_ptype_mapping_get_parsed(
14304 void *parsed_result,
14305 __attribute__((unused)) struct cmdline *cl,
14306 __attribute__((unused)) void *data)
14308 struct cmd_ptype_mapping_get_result *res = parsed_result;
14309 int ret = -ENOTSUP;
14310 #ifdef RTE_LIBRTE_I40E_PMD
14311 int max_ptype_num = 256;
14312 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
14317 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14320 #ifdef RTE_LIBRTE_I40E_PMD
14321 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
14332 printf("invalid port_id %d\n", res->port_id);
14335 printf("function not implemented\n");
14338 printf("programming error: (%s)\n", strerror(-ret));
14341 #ifdef RTE_LIBRTE_I40E_PMD
14343 for (i = 0; i < count; i++)
14344 printf("%3d\t0x%08x\n",
14345 mapping[i].hw_ptype, mapping[i].sw_ptype);
14350 cmdline_parse_inst_t cmd_ptype_mapping_get = {
14351 .f = cmd_ptype_mapping_get_parsed,
14353 .help_str = "ptype mapping get <port_id> <valid_only>",
14355 (void *)&cmd_ptype_mapping_get_ptype,
14356 (void *)&cmd_ptype_mapping_get_mapping,
14357 (void *)&cmd_ptype_mapping_get_get,
14358 (void *)&cmd_ptype_mapping_get_port_id,
14359 (void *)&cmd_ptype_mapping_get_valid_only,
14364 /* ptype mapping replace */
14366 /* Common result structure for ptype mapping replace */
14367 struct cmd_ptype_mapping_replace_result {
14368 cmdline_fixed_string_t ptype;
14369 cmdline_fixed_string_t mapping;
14370 cmdline_fixed_string_t replace;
14377 /* Common CLI fields for ptype mapping replace */
14378 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
14379 TOKEN_STRING_INITIALIZER
14380 (struct cmd_ptype_mapping_replace_result,
14382 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
14383 TOKEN_STRING_INITIALIZER
14384 (struct cmd_ptype_mapping_replace_result,
14385 mapping, "mapping");
14386 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
14387 TOKEN_STRING_INITIALIZER
14388 (struct cmd_ptype_mapping_replace_result,
14389 replace, "replace");
14390 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
14391 TOKEN_NUM_INITIALIZER
14392 (struct cmd_ptype_mapping_replace_result,
14394 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
14395 TOKEN_NUM_INITIALIZER
14396 (struct cmd_ptype_mapping_replace_result,
14398 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
14399 TOKEN_NUM_INITIALIZER
14400 (struct cmd_ptype_mapping_replace_result,
14402 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
14403 TOKEN_NUM_INITIALIZER
14404 (struct cmd_ptype_mapping_replace_result,
14408 cmd_ptype_mapping_replace_parsed(
14409 void *parsed_result,
14410 __attribute__((unused)) struct cmdline *cl,
14411 __attribute__((unused)) void *data)
14413 struct cmd_ptype_mapping_replace_result *res = parsed_result;
14414 int ret = -ENOTSUP;
14416 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14419 #ifdef RTE_LIBRTE_I40E_PMD
14420 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
14430 printf("invalid ptype 0x%8x or 0x%8x\n",
14431 res->target, res->pkt_type);
14434 printf("invalid port_id %d\n", res->port_id);
14437 printf("function not implemented\n");
14440 printf("programming error: (%s)\n", strerror(-ret));
14444 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
14445 .f = cmd_ptype_mapping_replace_parsed,
14448 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
14450 (void *)&cmd_ptype_mapping_replace_ptype,
14451 (void *)&cmd_ptype_mapping_replace_mapping,
14452 (void *)&cmd_ptype_mapping_replace_replace,
14453 (void *)&cmd_ptype_mapping_replace_port_id,
14454 (void *)&cmd_ptype_mapping_replace_target,
14455 (void *)&cmd_ptype_mapping_replace_mask,
14456 (void *)&cmd_ptype_mapping_replace_pkt_type,
14461 /* ptype mapping reset */
14463 /* Common result structure for ptype mapping reset */
14464 struct cmd_ptype_mapping_reset_result {
14465 cmdline_fixed_string_t ptype;
14466 cmdline_fixed_string_t mapping;
14467 cmdline_fixed_string_t reset;
14471 /* Common CLI fields for ptype mapping reset*/
14472 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
14473 TOKEN_STRING_INITIALIZER
14474 (struct cmd_ptype_mapping_reset_result,
14476 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
14477 TOKEN_STRING_INITIALIZER
14478 (struct cmd_ptype_mapping_reset_result,
14479 mapping, "mapping");
14480 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
14481 TOKEN_STRING_INITIALIZER
14482 (struct cmd_ptype_mapping_reset_result,
14484 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
14485 TOKEN_NUM_INITIALIZER
14486 (struct cmd_ptype_mapping_reset_result,
14490 cmd_ptype_mapping_reset_parsed(
14491 void *parsed_result,
14492 __attribute__((unused)) struct cmdline *cl,
14493 __attribute__((unused)) void *data)
14495 struct cmd_ptype_mapping_reset_result *res = parsed_result;
14496 int ret = -ENOTSUP;
14498 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14501 #ifdef RTE_LIBRTE_I40E_PMD
14502 ret = rte_pmd_i40e_ptype_mapping_reset(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));
14519 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
14520 .f = cmd_ptype_mapping_reset_parsed,
14522 .help_str = "ptype mapping reset <port_id>",
14524 (void *)&cmd_ptype_mapping_reset_ptype,
14525 (void *)&cmd_ptype_mapping_reset_mapping,
14526 (void *)&cmd_ptype_mapping_reset_reset,
14527 (void *)&cmd_ptype_mapping_reset_port_id,
14532 /* ptype mapping update */
14534 /* Common result structure for ptype mapping update */
14535 struct cmd_ptype_mapping_update_result {
14536 cmdline_fixed_string_t ptype;
14537 cmdline_fixed_string_t mapping;
14538 cmdline_fixed_string_t reset;
14544 /* Common CLI fields for ptype mapping update*/
14545 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
14546 TOKEN_STRING_INITIALIZER
14547 (struct cmd_ptype_mapping_update_result,
14549 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
14550 TOKEN_STRING_INITIALIZER
14551 (struct cmd_ptype_mapping_update_result,
14552 mapping, "mapping");
14553 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
14554 TOKEN_STRING_INITIALIZER
14555 (struct cmd_ptype_mapping_update_result,
14557 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
14558 TOKEN_NUM_INITIALIZER
14559 (struct cmd_ptype_mapping_update_result,
14561 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
14562 TOKEN_NUM_INITIALIZER
14563 (struct cmd_ptype_mapping_update_result,
14565 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
14566 TOKEN_NUM_INITIALIZER
14567 (struct cmd_ptype_mapping_update_result,
14571 cmd_ptype_mapping_update_parsed(
14572 void *parsed_result,
14573 __attribute__((unused)) struct cmdline *cl,
14574 __attribute__((unused)) void *data)
14576 struct cmd_ptype_mapping_update_result *res = parsed_result;
14577 int ret = -ENOTSUP;
14578 #ifdef RTE_LIBRTE_I40E_PMD
14579 struct rte_pmd_i40e_ptype_mapping mapping;
14581 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14584 #ifdef RTE_LIBRTE_I40E_PMD
14585 mapping.hw_ptype = res->hw_ptype;
14586 mapping.sw_ptype = res->sw_ptype;
14587 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
14597 printf("invalid ptype 0x%8x\n", res->sw_ptype);
14600 printf("invalid port_id %d\n", res->port_id);
14603 printf("function not implemented\n");
14606 printf("programming error: (%s)\n", strerror(-ret));
14610 cmdline_parse_inst_t cmd_ptype_mapping_update = {
14611 .f = cmd_ptype_mapping_update_parsed,
14613 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
14615 (void *)&cmd_ptype_mapping_update_ptype,
14616 (void *)&cmd_ptype_mapping_update_mapping,
14617 (void *)&cmd_ptype_mapping_update_update,
14618 (void *)&cmd_ptype_mapping_update_port_id,
14619 (void *)&cmd_ptype_mapping_update_hw_ptype,
14620 (void *)&cmd_ptype_mapping_update_sw_ptype,
14625 /* Common result structure for file commands */
14626 struct cmd_cmdfile_result {
14627 cmdline_fixed_string_t load;
14628 cmdline_fixed_string_t filename;
14631 /* Common CLI fields for file commands */
14632 cmdline_parse_token_string_t cmd_load_cmdfile =
14633 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
14634 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
14635 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
14638 cmd_load_from_file_parsed(
14639 void *parsed_result,
14640 __attribute__((unused)) struct cmdline *cl,
14641 __attribute__((unused)) void *data)
14643 struct cmd_cmdfile_result *res = parsed_result;
14645 cmdline_read_from_file(res->filename);
14648 cmdline_parse_inst_t cmd_load_from_file = {
14649 .f = cmd_load_from_file_parsed,
14651 .help_str = "load <filename>",
14653 (void *)&cmd_load_cmdfile,
14654 (void *)&cmd_load_cmdfile_filename,
14659 /* ******************************************************************************** */
14661 /* list of instructions */
14662 cmdline_parse_ctx_t main_ctx[] = {
14663 (cmdline_parse_inst_t *)&cmd_help_brief,
14664 (cmdline_parse_inst_t *)&cmd_help_long,
14665 (cmdline_parse_inst_t *)&cmd_quit,
14666 (cmdline_parse_inst_t *)&cmd_load_from_file,
14667 (cmdline_parse_inst_t *)&cmd_showport,
14668 (cmdline_parse_inst_t *)&cmd_showqueue,
14669 (cmdline_parse_inst_t *)&cmd_showportall,
14670 (cmdline_parse_inst_t *)&cmd_showcfg,
14671 (cmdline_parse_inst_t *)&cmd_start,
14672 (cmdline_parse_inst_t *)&cmd_start_tx_first,
14673 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
14674 (cmdline_parse_inst_t *)&cmd_set_link_up,
14675 (cmdline_parse_inst_t *)&cmd_set_link_down,
14676 (cmdline_parse_inst_t *)&cmd_reset,
14677 (cmdline_parse_inst_t *)&cmd_set_numbers,
14678 (cmdline_parse_inst_t *)&cmd_set_txpkts,
14679 (cmdline_parse_inst_t *)&cmd_set_txsplit,
14680 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
14681 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
14682 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
14683 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
14684 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
14685 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
14686 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
14687 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
14688 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
14689 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
14690 (cmdline_parse_inst_t *)&cmd_set_link_check,
14691 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
14692 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
14693 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
14694 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
14695 #ifdef RTE_LIBRTE_PMD_BOND
14696 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
14697 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
14698 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
14699 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
14700 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
14701 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
14702 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
14703 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
14704 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
14705 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
14706 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
14708 (cmdline_parse_inst_t *)&cmd_vlan_offload,
14709 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
14710 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
14711 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
14712 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
14713 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
14714 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
14715 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
14716 (cmdline_parse_inst_t *)&cmd_csum_set,
14717 (cmdline_parse_inst_t *)&cmd_csum_show,
14718 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
14719 (cmdline_parse_inst_t *)&cmd_tso_set,
14720 (cmdline_parse_inst_t *)&cmd_tso_show,
14721 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
14722 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
14723 (cmdline_parse_inst_t *)&cmd_gro_enable,
14724 (cmdline_parse_inst_t *)&cmd_gro_flush,
14725 (cmdline_parse_inst_t *)&cmd_gro_show,
14726 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
14727 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
14728 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
14729 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
14730 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
14731 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
14732 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
14733 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
14734 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
14735 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
14736 (cmdline_parse_inst_t *)&cmd_config_dcb,
14737 (cmdline_parse_inst_t *)&cmd_read_reg,
14738 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
14739 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
14740 (cmdline_parse_inst_t *)&cmd_write_reg,
14741 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
14742 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
14743 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
14744 (cmdline_parse_inst_t *)&cmd_stop,
14745 (cmdline_parse_inst_t *)&cmd_mac_addr,
14746 (cmdline_parse_inst_t *)&cmd_set_qmap,
14747 (cmdline_parse_inst_t *)&cmd_operate_port,
14748 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
14749 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
14750 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
14751 (cmdline_parse_inst_t *)&cmd_config_speed_all,
14752 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
14753 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
14754 (cmdline_parse_inst_t *)&cmd_config_mtu,
14755 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
14756 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
14757 (cmdline_parse_inst_t *)&cmd_config_rss,
14758 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
14759 (cmdline_parse_inst_t *)&cmd_config_txqflags,
14760 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
14761 (cmdline_parse_inst_t *)&cmd_showport_reta,
14762 (cmdline_parse_inst_t *)&cmd_config_burst,
14763 (cmdline_parse_inst_t *)&cmd_config_thresh,
14764 (cmdline_parse_inst_t *)&cmd_config_threshold,
14765 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
14766 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
14767 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
14768 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
14769 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
14770 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
14771 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
14772 (cmdline_parse_inst_t *)&cmd_global_config,
14773 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
14774 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
14775 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
14776 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
14777 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
14778 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
14779 (cmdline_parse_inst_t *)&cmd_dump,
14780 (cmdline_parse_inst_t *)&cmd_dump_one,
14781 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
14782 (cmdline_parse_inst_t *)&cmd_syn_filter,
14783 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
14784 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
14785 (cmdline_parse_inst_t *)&cmd_flex_filter,
14786 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
14787 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
14788 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
14789 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
14790 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
14791 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
14792 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
14793 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
14794 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
14795 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
14796 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
14797 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
14798 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
14799 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
14800 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
14801 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
14802 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
14803 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
14804 (cmdline_parse_inst_t *)&cmd_flow,
14805 (cmdline_parse_inst_t *)&cmd_mcast_addr,
14806 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
14807 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
14808 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
14809 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
14810 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
14811 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
14812 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
14813 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
14814 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
14815 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
14816 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
14817 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
14818 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
14819 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
14820 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
14821 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
14822 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
14823 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
14824 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
14825 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
14826 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
14827 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
14828 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
14829 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
14830 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
14831 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
14832 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
14833 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
14834 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
14835 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
14836 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
14837 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
14838 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
14839 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
14840 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
14841 (cmdline_parse_inst_t *)&cmd_ddp_add,
14842 (cmdline_parse_inst_t *)&cmd_ddp_del,
14843 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
14844 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
14845 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
14846 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
14847 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
14848 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
14849 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
14850 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
14852 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
14853 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
14854 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
14858 /* read cmdline commands from file */
14860 cmdline_read_from_file(const char *filename)
14862 struct cmdline *cl;
14864 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14866 printf("Failed to create file based cmdline context: %s\n",
14871 cmdline_interact(cl);
14876 printf("Read CLI commands from %s\n", filename);
14879 /* prompt function, called from main on MASTER lcore */
14883 /* initialize non-constant commands */
14884 cmd_set_fwd_mode_init();
14885 cmd_set_fwd_retry_mode_init();
14887 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14888 if (testpmd_cl == NULL)
14890 cmdline_interact(testpmd_cl);
14891 cmdline_stdin_exit(testpmd_cl);
14897 if (testpmd_cl != NULL)
14898 cmdline_quit(testpmd_cl);
14902 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14904 if (id == (portid_t)RTE_PORT_ALL) {
14907 RTE_ETH_FOREACH_DEV(pid) {
14908 /* check if need_reconfig has been set to 1 */
14909 if (ports[pid].need_reconfig == 0)
14910 ports[pid].need_reconfig = dev;
14911 /* check if need_reconfig_queues has been set to 1 */
14912 if (ports[pid].need_reconfig_queues == 0)
14913 ports[pid].need_reconfig_queues = queue;
14915 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14916 /* check if need_reconfig has been set to 1 */
14917 if (ports[id].need_reconfig == 0)
14918 ports[id].need_reconfig = dev;
14919 /* check if need_reconfig_queues has been set to 1 */
14920 if (ports[id].need_reconfig_queues == 0)
14921 ports[id].need_reconfig_queues = queue;