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"
236 if (show_all || !strcmp(res->section, "config")) {
242 "Configuration changes only become active when"
243 " forwarding is started/restarted.\n\n"
246 " Reset forwarding to the default configuration.\n\n"
248 "set verbose (level)\n"
249 " Set the debug verbosity level X.\n\n"
252 " Set number of ports.\n\n"
255 " Set number of cores.\n\n"
257 "set coremask (mask)\n"
258 " Set the forwarding cores hexadecimal mask.\n\n"
260 "set portmask (mask)\n"
261 " Set the forwarding ports hexadecimal mask.\n\n"
264 " Set number of packets per burst.\n\n"
266 "set burst tx delay (microseconds) retry (num)\n"
267 " Set the transmit delay time and number of retries,"
268 " effective when retry is enabled.\n\n"
270 "set txpkts (x[,y]*)\n"
271 " Set the length of each segment of TXONLY"
272 " and optionally CSUM packets.\n\n"
274 "set txsplit (off|on|rand)\n"
275 " Set the split policy for the TX packets."
276 " Right now only applicable for CSUM and TXONLY"
279 "set corelist (x[,y]*)\n"
280 " Set the list of forwarding cores.\n\n"
282 "set portlist (x[,y]*)\n"
283 " Set the list of forwarding ports.\n\n"
285 "set tx loopback (port_id) (on|off)\n"
286 " Enable or disable tx loopback.\n\n"
288 "set all queues drop (port_id) (on|off)\n"
289 " Set drop enable bit for all queues.\n\n"
291 "set vf split drop (port_id) (vf_id) (on|off)\n"
292 " Set split drop enable bit for a VF from the PF.\n\n"
294 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
295 " Set MAC antispoof for a VF from the PF.\n\n"
297 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
298 " Enable MACsec offload.\n\n"
300 "set macsec offload (port_id) off\n"
301 " Disable MACsec offload.\n\n"
303 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
304 " Configure MACsec secure connection (SC).\n\n"
306 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
307 " Configure MACsec secure association (SA).\n\n"
309 "set vf broadcast (port_id) (vf_id) (on|off)\n"
310 " Set VF broadcast for a VF from the PF.\n\n"
312 "vlan set strip (on|off) (port_id)\n"
313 " Set the VLAN strip on a port.\n\n"
315 "vlan set stripq (on|off) (port_id,queue_id)\n"
316 " Set the VLAN strip for a queue on a port.\n\n"
318 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
319 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
321 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
322 " Set VLAN insert for a VF from the PF.\n\n"
324 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
325 " Set VLAN antispoof for a VF from the PF.\n\n"
327 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
328 " Set VLAN tag for a VF from the PF.\n\n"
330 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
331 " Set a VF's max bandwidth(Mbps).\n\n"
333 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
334 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
336 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
337 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
339 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
340 " Set some TCs' strict link priority mode on a physical port.\n\n"
342 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
343 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
345 "vlan set filter (on|off) (port_id)\n"
346 " Set the VLAN filter on a port.\n\n"
348 "vlan set qinq (on|off) (port_id)\n"
349 " Set the VLAN QinQ (extended queue in queue)"
352 "vlan set (inner|outer) tpid (value) (port_id)\n"
353 " Set the VLAN TPID for Packet Filtering on"
356 "rx_vlan add (vlan_id|all) (port_id)\n"
357 " Add a vlan_id, or all identifiers, to the set"
358 " of VLAN identifiers filtered by port_id.\n\n"
360 "rx_vlan rm (vlan_id|all) (port_id)\n"
361 " Remove a vlan_id, or all identifiers, from the set"
362 " of VLAN identifiers filtered by port_id.\n\n"
364 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
365 " Add a vlan_id, to the set of VLAN identifiers"
366 "filtered for VF(s) from port_id.\n\n"
368 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
369 " Remove a vlan_id, to the set of VLAN identifiers"
370 "filtered for VF(s) from port_id.\n\n"
372 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
373 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
374 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
375 " add a tunnel filter of a port.\n\n"
377 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
378 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
379 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
380 " remove a tunnel filter of a port.\n\n"
382 "rx_vxlan_port add (udp_port) (port_id)\n"
383 " Add an UDP port for VXLAN packet filter on a port\n\n"
385 "rx_vxlan_port rm (udp_port) (port_id)\n"
386 " Remove an UDP port for VXLAN packet filter on a port\n\n"
388 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
389 " Set hardware insertion of VLAN IDs (single or double VLAN "
390 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
392 "tx_vlan set pvid port_id vlan_id (on|off)\n"
393 " Set port based TX VLAN insertion.\n\n"
395 "tx_vlan reset (port_id)\n"
396 " Disable hardware insertion of a VLAN header in"
397 " packets sent on a port.\n\n"
399 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
400 " Select hardware or software calculation of the"
401 " checksum when transmitting a packet using the"
402 " csum forward engine.\n"
403 " ip|udp|tcp|sctp always concern the inner layer.\n"
404 " outer-ip concerns the outer IP layer in"
405 " case the packet is recognized as a tunnel packet by"
406 " the forward engine (vxlan, gre and ipip are supported)\n"
407 " Please check the NIC datasheet for HW limits.\n\n"
409 "csum parse-tunnel (on|off) (tx_port_id)\n"
410 " If disabled, treat tunnel packets as non-tunneled"
411 " packets (treat inner headers as payload). The port\n"
412 " argument is the port used for TX in csum forward"
415 "csum show (port_id)\n"
416 " Display tx checksum offload configuration\n\n"
418 "tso set (segsize) (portid)\n"
419 " Enable TCP Segmentation Offload in csum forward"
421 " Please check the NIC datasheet for HW limits.\n\n"
424 " Display the status of TCP Segmentation Offload.\n\n"
426 "gro (on|off) (port_id)"
427 " Enable or disable Generic Receive Offload in io"
428 " forward engine.\n\n"
430 "gro set (max_flow_num) (max_item_num_per_flow) (port_id)\n"
431 " Set max flow number and max packet number per-flow"
435 " Set packet forwarding mode.\n\n"
437 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
438 " Add a MAC address on port_id.\n\n"
440 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
441 " Remove a MAC address from port_id.\n\n"
443 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
444 " Set the default MAC address for port_id.\n\n"
446 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
447 " Add a MAC address for a VF on the port.\n\n"
449 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
450 " Set the MAC address for a VF from the PF.\n\n"
452 "set port (port_id) uta (mac_address|all) (on|off)\n"
453 " Add/Remove a or all unicast hash filter(s)"
456 "set promisc (port_id|all) (on|off)\n"
457 " Set the promiscuous mode on port_id, or all.\n\n"
459 "set allmulti (port_id|all) (on|off)\n"
460 " Set the allmulti mode on port_id, or all.\n\n"
462 "set vf promisc (port_id) (vf_id) (on|off)\n"
463 " Set unicast promiscuous mode for a VF from the PF.\n\n"
465 "set vf allmulti (port_id) (vf_id) (on|off)\n"
466 " Set multicast promiscuous mode for a VF from the PF.\n\n"
468 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
469 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
470 " (on|off) autoneg (on|off) (port_id)\n"
471 "set flow_ctrl rx (on|off) (portid)\n"
472 "set flow_ctrl tx (on|off) (portid)\n"
473 "set flow_ctrl high_water (high_water) (portid)\n"
474 "set flow_ctrl low_water (low_water) (portid)\n"
475 "set flow_ctrl pause_time (pause_time) (portid)\n"
476 "set flow_ctrl send_xon (send_xon) (portid)\n"
477 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
478 "set flow_ctrl autoneg (on|off) (port_id)\n"
479 " Set the link flow control parameter on a port.\n\n"
481 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
482 " (low_water) (pause_time) (priority) (port_id)\n"
483 " Set the priority flow control parameter on a"
486 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
487 " Set statistics mapping (qmapping 0..15) for RX/TX"
489 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
490 " on port 0 to mapping 5.\n\n"
492 "set port (port_id) vf (vf_id) rx|tx on|off\n"
493 " Enable/Disable a VF receive/tranmit from a port\n\n"
495 "set port (port_id) vf (vf_id) (mac_addr)"
496 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
497 " Add/Remove unicast or multicast MAC addr filter"
500 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
502 " AUPE:accepts untagged VLAN;"
503 "ROPE:accept unicast hash\n\n"
504 " BAM:accepts broadcast packets;"
505 "MPE:accepts all multicast packets\n\n"
506 " Enable/Disable a VF receive mode of a port\n\n"
508 "set port (port_id) queue (queue_id) rate (rate_num)\n"
509 " Set rate limit for a queue of a port\n\n"
511 "set port (port_id) vf (vf_id) rate (rate_num) "
512 "queue_mask (queue_mask_value)\n"
513 " Set rate limit for queues in VF of a port\n\n"
515 "set port (port_id) mirror-rule (rule_id)"
516 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
517 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
518 " Set pool or vlan type mirror rule on a port.\n"
519 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
520 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
523 "set port (port_id) mirror-rule (rule_id)"
524 " (uplink-mirror|downlink-mirror) dst-pool"
525 " (pool_id) (on|off)\n"
526 " Set uplink or downlink type mirror rule on a port.\n"
527 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
528 " 0 on' enable mirror income traffic to pool 0.\n\n"
530 "reset port (port_id) mirror-rule (rule_id)\n"
531 " Reset a mirror rule.\n\n"
533 "set flush_rx (on|off)\n"
534 " Flush (default) or don't flush RX streams before"
535 " forwarding. Mainly used with PCAP drivers.\n\n"
537 "set bypass mode (normal|bypass|isolate) (port_id)\n"
538 " Set the bypass mode for the lowest port on bypass enabled"
541 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
542 "mode (normal|bypass|isolate) (port_id)\n"
543 " Set the event required to initiate specified bypass mode for"
544 " the lowest port on a bypass enabled NIC where:\n"
545 " timeout = enable bypass after watchdog timeout.\n"
546 " os_on = enable bypass when OS/board is powered on.\n"
547 " os_off = enable bypass when OS/board is powered off.\n"
548 " power_on = enable bypass when power supply is turned on.\n"
549 " power_off = enable bypass when power supply is turned off."
552 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
553 " Set the bypass watchdog timeout to 'n' seconds"
554 " where 0 = instant.\n\n"
556 "show bypass config (port_id)\n"
557 " Show the bypass configuration for a bypass enabled NIC"
558 " using the lowest port on the NIC.\n\n"
560 #ifdef RTE_LIBRTE_PMD_BOND
561 "create bonded device (mode) (socket)\n"
562 " Create a new bonded device with specific bonding mode and socket.\n\n"
564 "add bonding slave (slave_id) (port_id)\n"
565 " Add a slave device to a bonded device.\n\n"
567 "remove bonding slave (slave_id) (port_id)\n"
568 " Remove a slave device from a bonded device.\n\n"
570 "set bonding mode (value) (port_id)\n"
571 " Set the bonding mode on a bonded device.\n\n"
573 "set bonding primary (slave_id) (port_id)\n"
574 " Set the primary slave for a bonded device.\n\n"
576 "show bonding config (port_id)\n"
577 " Show the bonding config for port_id.\n\n"
579 "set bonding mac_addr (port_id) (address)\n"
580 " Set the MAC address of a bonded device.\n\n"
582 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
583 " Set Aggregation mode for IEEE802.3AD (mode 4)"
585 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
586 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
588 "set bonding mon_period (port_id) (value)\n"
589 " Set the bonding link status monitoring polling period in ms.\n\n"
591 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
592 " Enable/disable dedicated queues for LACP control traffic.\n\n"
595 "set link-up port (port_id)\n"
596 " Set link up for a port.\n\n"
598 "set link-down port (port_id)\n"
599 " Set link down for a port.\n\n"
601 "E-tag set insertion on port-tag-id (value)"
602 " port (port_id) vf (vf_id)\n"
603 " Enable E-tag insertion for a VF on a port\n\n"
605 "E-tag set insertion off port (port_id) vf (vf_id)\n"
606 " Disable E-tag insertion for a VF on a port\n\n"
608 "E-tag set stripping (on|off) port (port_id)\n"
609 " Enable/disable E-tag stripping on a port\n\n"
611 "E-tag set forwarding (on|off) port (port_id)\n"
612 " Enable/disable E-tag based forwarding"
615 "E-tag set filter add e-tag-id (value) dst-pool"
616 " (pool_id) port (port_id)\n"
617 " Add an E-tag forwarding filter on a port\n\n"
619 "E-tag set filter del e-tag-id (value) port (port_id)\n"
620 " Delete an E-tag forwarding filter on a port\n\n"
622 "ddp add (port_id) (profile_path[,output_path])\n"
623 " Load a profile package on a port\n\n"
625 "ddp del (port_id) (profile_path)\n"
626 " Delete a profile package from a port\n\n"
628 "ptype mapping get (port_id) (valid_only)\n"
629 " Get ptype mapping on a port\n\n"
631 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
632 " Replace target with the pkt_type in ptype mapping\n\n"
634 "ptype mapping reset (port_id)\n"
635 " Reset ptype mapping on a port\n\n"
637 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
638 " Update a ptype mapping item on a port\n\n"
640 , list_pkt_forwarding_modes()
644 if (show_all || !strcmp(res->section, "ports")) {
650 "----------------\n\n"
652 "port start (port_id|all)\n"
653 " Start all ports or port_id.\n\n"
655 "port stop (port_id|all)\n"
656 " Stop all ports or port_id.\n\n"
658 "port close (port_id|all)\n"
659 " Close all ports or port_id.\n\n"
661 "port attach (ident)\n"
662 " Attach physical or virtual dev by pci address or virtual device name\n\n"
664 "port detach (port_id)\n"
665 " Detach physical or virtual dev by port_id\n\n"
667 "port config (port_id|all)"
668 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
669 " duplex (half|full|auto)\n"
670 " Set speed and duplex for all ports or port_id\n\n"
672 "port config all (rxq|txq|rxd|txd) (value)\n"
673 " Set number for rxq/txq/rxd/txd.\n\n"
675 "port config all max-pkt-len (value)\n"
676 " Set the max packet length.\n\n"
678 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
679 "hw-vlan-strip|hw-vlan-extend|drop-en)"
681 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
684 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
685 " Set the RSS mode.\n\n"
687 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
688 " Set the RSS redirection table.\n\n"
690 "port config (port_id) dcb vt (on|off) (traffic_class)"
692 " Set the DCB mode.\n\n"
694 "port config all burst (value)\n"
695 " Set the number of packets per burst.\n\n"
697 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
699 " Set the ring prefetch/host/writeback threshold"
700 " for tx/rx queue.\n\n"
702 "port config all (txfreet|txrst|rxfreet) (value)\n"
703 " Set free threshold for rx/tx, or set"
704 " tx rs bit threshold.\n\n"
705 "port config mtu X value\n"
706 " Set the MTU of port X to a given value\n\n"
708 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
709 " Start/stop a rx/tx queue of port X. Only take effect"
710 " when port X is started\n\n"
712 "port config (port_id|all) l2-tunnel E-tag ether-type"
714 " Set the value of E-tag ether-type.\n\n"
716 "port config (port_id|all) l2-tunnel E-tag"
717 " (enable|disable)\n"
718 " Enable/disable the E-tag support.\n\n"
722 if (show_all || !strcmp(res->section, "registers")) {
730 "read reg (port_id) (address)\n"
731 " Display value of a port register.\n\n"
733 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
734 " Display a port register bit field.\n\n"
736 "read regbit (port_id) (address) (bit_x)\n"
737 " Display a single port register bit.\n\n"
739 "write reg (port_id) (address) (value)\n"
740 " Set value of a port register.\n\n"
742 "write regfield (port_id) (address) (bit_x) (bit_y)"
744 " Set bit field of a port register.\n\n"
746 "write regbit (port_id) (address) (bit_x) (value)\n"
747 " Set single bit value of a port register.\n\n"
750 if (show_all || !strcmp(res->section, "filters")) {
758 "ethertype_filter (port_id) (add|del)"
759 " (mac_addr|mac_ignr) (mac_address) ethertype"
760 " (ether_type) (drop|fwd) queue (queue_id)\n"
761 " Add/Del an ethertype filter.\n\n"
763 "2tuple_filter (port_id) (add|del)"
764 " dst_port (dst_port_value) protocol (protocol_value)"
765 " mask (mask_value) tcp_flags (tcp_flags_value)"
766 " priority (prio_value) queue (queue_id)\n"
767 " Add/Del a 2tuple filter.\n\n"
769 "5tuple_filter (port_id) (add|del)"
770 " dst_ip (dst_address) src_ip (src_address)"
771 " dst_port (dst_port_value) src_port (src_port_value)"
772 " protocol (protocol_value)"
773 " mask (mask_value) tcp_flags (tcp_flags_value)"
774 " priority (prio_value) queue (queue_id)\n"
775 " Add/Del a 5tuple filter.\n\n"
777 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
778 " Add/Del syn filter.\n\n"
780 "flex_filter (port_id) (add|del) len (len_value)"
781 " bytes (bytes_value) mask (mask_value)"
782 " priority (prio_value) queue (queue_id)\n"
783 " Add/Del a flex filter.\n\n"
785 "flow_director_filter (port_id) mode IP (add|del|update)"
786 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
787 " src (src_ip_address) dst (dst_ip_address)"
788 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
789 " vlan (vlan_value) flexbytes (flexbytes_value)"
790 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
791 " fd_id (fd_id_value)\n"
792 " Add/Del an IP type flow director filter.\n\n"
794 "flow_director_filter (port_id) mode IP (add|del|update)"
795 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
796 " src (src_ip_address) (src_port)"
797 " dst (dst_ip_address) (dst_port)"
798 " tos (tos_value) ttl (ttl_value)"
799 " vlan (vlan_value) flexbytes (flexbytes_value)"
800 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
801 " fd_id (fd_id_value)\n"
802 " Add/Del an UDP/TCP type flow director filter.\n\n"
804 "flow_director_filter (port_id) mode IP (add|del|update)"
805 " flow (ipv4-sctp|ipv6-sctp)"
806 " src (src_ip_address) (src_port)"
807 " dst (dst_ip_address) (dst_port)"
808 " tag (verification_tag) "
809 " tos (tos_value) ttl (ttl_value)"
811 " flexbytes (flexbytes_value) (drop|fwd)"
812 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
813 " Add/Del a SCTP type flow director filter.\n\n"
815 "flow_director_filter (port_id) mode IP (add|del|update)"
816 " flow l2_payload ether (ethertype)"
817 " flexbytes (flexbytes_value) (drop|fwd)"
818 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
819 " Add/Del a l2 payload type flow director filter.\n\n"
821 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
822 " mac (mac_address) vlan (vlan_value)"
823 " flexbytes (flexbytes_value) (drop|fwd)"
824 " queue (queue_id) fd_id (fd_id_value)\n"
825 " Add/Del a MAC-VLAN flow director filter.\n\n"
827 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
828 " mac (mac_address) vlan (vlan_value)"
829 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
830 " flexbytes (flexbytes_value) (drop|fwd)"
831 " queue (queue_id) fd_id (fd_id_value)\n"
832 " Add/Del a Tunnel flow director filter.\n\n"
834 "flush_flow_director (port_id)\n"
835 " Flush all flow director entries of a device.\n\n"
837 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
838 " src_mask (ipv4_src) (ipv6_src) (src_port)"
839 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
840 " Set flow director IP mask.\n\n"
842 "flow_director_mask (port_id) mode MAC-VLAN"
843 " vlan (vlan_value)\n"
844 " Set flow director MAC-VLAN mask.\n\n"
846 "flow_director_mask (port_id) mode Tunnel"
847 " vlan (vlan_value) mac (mac_value)"
848 " tunnel-type (tunnel_type_value)"
849 " tunnel-id (tunnel_id_value)\n"
850 " Set flow director Tunnel mask.\n\n"
852 "flow_director_flex_mask (port_id)"
853 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
854 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
856 " Configure mask of flex payload.\n\n"
858 "flow_director_flex_payload (port_id)"
859 " (raw|l2|l3|l4) (config)\n"
860 " Configure flex payload selection.\n\n"
862 "get_sym_hash_ena_per_port (port_id)\n"
863 " get symmetric hash enable configuration per port.\n\n"
865 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
866 " set symmetric hash enable configuration per port"
867 " to enable or disable.\n\n"
869 "get_hash_global_config (port_id)\n"
870 " Get the global configurations of hash filters.\n\n"
872 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
873 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
874 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
875 " (enable|disable)\n"
876 " Set the global configurations of hash filters.\n\n"
878 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
879 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
880 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
881 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
882 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
883 "ipv6-next-header|udp-src-port|udp-dst-port|"
884 "tcp-src-port|tcp-dst-port|sctp-src-port|"
885 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
886 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
887 "fld-8th|none) (select|add)\n"
888 " Set the input set for hash.\n\n"
890 "set_fdir_input_set (port_id) "
891 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
892 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
893 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
894 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
895 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
896 "udp-dst-port|tcp-src-port|tcp-dst-port|"
897 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
899 " Set the input set for FDir.\n\n"
901 "flow validate {port_id}"
902 " [group {group_id}] [priority {level}]"
903 " [ingress] [egress]"
904 " pattern {item} [/ {item} [...]] / end"
905 " actions {action} [/ {action} [...]] / end\n"
906 " Check whether a flow rule can be created.\n\n"
908 "flow create {port_id}"
909 " [group {group_id}] [priority {level}]"
910 " [ingress] [egress]"
911 " pattern {item} [/ {item} [...]] / end"
912 " actions {action} [/ {action} [...]] / end\n"
913 " Create a flow rule.\n\n"
915 "flow destroy {port_id} rule {rule_id} [...]\n"
916 " Destroy specific flow rules.\n\n"
918 "flow flush {port_id}\n"
919 " Destroy all flow rules.\n\n"
921 "flow query {port_id} {rule_id} {action}\n"
922 " Query an existing flow rule.\n\n"
924 "flow list {port_id} [group {group_id}] [...]\n"
925 " List existing flow rules sorted by priority,"
926 " filtered by group identifiers.\n\n"
928 "flow isolate {port_id} {boolean}\n"
929 " Restrict ingress traffic to the defined"
935 cmdline_parse_token_string_t cmd_help_long_help =
936 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
938 cmdline_parse_token_string_t cmd_help_long_section =
939 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
940 "all#control#display#config#"
941 "ports#registers#filters");
943 cmdline_parse_inst_t cmd_help_long = {
944 .f = cmd_help_long_parsed,
946 .help_str = "help all|control|display|config|ports|register|filters: "
949 (void *)&cmd_help_long_help,
950 (void *)&cmd_help_long_section,
956 /* *** start/stop/close all ports *** */
957 struct cmd_operate_port_result {
958 cmdline_fixed_string_t keyword;
959 cmdline_fixed_string_t name;
960 cmdline_fixed_string_t value;
963 static void cmd_operate_port_parsed(void *parsed_result,
964 __attribute__((unused)) struct cmdline *cl,
965 __attribute__((unused)) void *data)
967 struct cmd_operate_port_result *res = parsed_result;
969 if (!strcmp(res->name, "start"))
970 start_port(RTE_PORT_ALL);
971 else if (!strcmp(res->name, "stop"))
972 stop_port(RTE_PORT_ALL);
973 else if (!strcmp(res->name, "close"))
974 close_port(RTE_PORT_ALL);
976 printf("Unknown parameter\n");
979 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
980 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
982 cmdline_parse_token_string_t cmd_operate_port_all_port =
983 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
985 cmdline_parse_token_string_t cmd_operate_port_all_all =
986 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
988 cmdline_parse_inst_t cmd_operate_port = {
989 .f = cmd_operate_port_parsed,
991 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
993 (void *)&cmd_operate_port_all_cmd,
994 (void *)&cmd_operate_port_all_port,
995 (void *)&cmd_operate_port_all_all,
1000 /* *** start/stop/close specific port *** */
1001 struct cmd_operate_specific_port_result {
1002 cmdline_fixed_string_t keyword;
1003 cmdline_fixed_string_t name;
1007 static void cmd_operate_specific_port_parsed(void *parsed_result,
1008 __attribute__((unused)) struct cmdline *cl,
1009 __attribute__((unused)) void *data)
1011 struct cmd_operate_specific_port_result *res = parsed_result;
1013 if (!strcmp(res->name, "start"))
1014 start_port(res->value);
1015 else if (!strcmp(res->name, "stop"))
1016 stop_port(res->value);
1017 else if (!strcmp(res->name, "close"))
1018 close_port(res->value);
1020 printf("Unknown parameter\n");
1023 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1024 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1026 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1027 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1028 name, "start#stop#close");
1029 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1030 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1033 cmdline_parse_inst_t cmd_operate_specific_port = {
1034 .f = cmd_operate_specific_port_parsed,
1036 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
1038 (void *)&cmd_operate_specific_port_cmd,
1039 (void *)&cmd_operate_specific_port_port,
1040 (void *)&cmd_operate_specific_port_id,
1045 /* *** attach a specified port *** */
1046 struct cmd_operate_attach_port_result {
1047 cmdline_fixed_string_t port;
1048 cmdline_fixed_string_t keyword;
1049 cmdline_fixed_string_t identifier;
1052 static void cmd_operate_attach_port_parsed(void *parsed_result,
1053 __attribute__((unused)) struct cmdline *cl,
1054 __attribute__((unused)) void *data)
1056 struct cmd_operate_attach_port_result *res = parsed_result;
1058 if (!strcmp(res->keyword, "attach"))
1059 attach_port(res->identifier);
1061 printf("Unknown parameter\n");
1064 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1065 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1067 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1068 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1070 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1071 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1074 cmdline_parse_inst_t cmd_operate_attach_port = {
1075 .f = cmd_operate_attach_port_parsed,
1077 .help_str = "port attach <identifier>: "
1078 "(identifier: pci address or virtual dev name)",
1080 (void *)&cmd_operate_attach_port_port,
1081 (void *)&cmd_operate_attach_port_keyword,
1082 (void *)&cmd_operate_attach_port_identifier,
1087 /* *** detach a specified port *** */
1088 struct cmd_operate_detach_port_result {
1089 cmdline_fixed_string_t port;
1090 cmdline_fixed_string_t keyword;
1094 static void cmd_operate_detach_port_parsed(void *parsed_result,
1095 __attribute__((unused)) struct cmdline *cl,
1096 __attribute__((unused)) void *data)
1098 struct cmd_operate_detach_port_result *res = parsed_result;
1100 if (!strcmp(res->keyword, "detach"))
1101 detach_port(res->port_id);
1103 printf("Unknown parameter\n");
1106 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1107 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1109 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1110 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1112 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1113 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1116 cmdline_parse_inst_t cmd_operate_detach_port = {
1117 .f = cmd_operate_detach_port_parsed,
1119 .help_str = "port detach <port_id>",
1121 (void *)&cmd_operate_detach_port_port,
1122 (void *)&cmd_operate_detach_port_keyword,
1123 (void *)&cmd_operate_detach_port_port_id,
1128 /* *** configure speed for all ports *** */
1129 struct cmd_config_speed_all {
1130 cmdline_fixed_string_t port;
1131 cmdline_fixed_string_t keyword;
1132 cmdline_fixed_string_t all;
1133 cmdline_fixed_string_t item1;
1134 cmdline_fixed_string_t item2;
1135 cmdline_fixed_string_t value1;
1136 cmdline_fixed_string_t value2;
1140 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1145 if (!strcmp(duplexstr, "half")) {
1146 duplex = ETH_LINK_HALF_DUPLEX;
1147 } else if (!strcmp(duplexstr, "full")) {
1148 duplex = ETH_LINK_FULL_DUPLEX;
1149 } else if (!strcmp(duplexstr, "auto")) {
1150 duplex = ETH_LINK_FULL_DUPLEX;
1152 printf("Unknown duplex parameter\n");
1156 if (!strcmp(speedstr, "10")) {
1157 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1158 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1159 } else if (!strcmp(speedstr, "100")) {
1160 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1161 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1163 if (duplex != ETH_LINK_FULL_DUPLEX) {
1164 printf("Invalid speed/duplex parameters\n");
1167 if (!strcmp(speedstr, "1000")) {
1168 *speed = ETH_LINK_SPEED_1G;
1169 } else if (!strcmp(speedstr, "10000")) {
1170 *speed = ETH_LINK_SPEED_10G;
1171 } else if (!strcmp(speedstr, "25000")) {
1172 *speed = ETH_LINK_SPEED_25G;
1173 } else if (!strcmp(speedstr, "40000")) {
1174 *speed = ETH_LINK_SPEED_40G;
1175 } else if (!strcmp(speedstr, "50000")) {
1176 *speed = ETH_LINK_SPEED_50G;
1177 } else if (!strcmp(speedstr, "100000")) {
1178 *speed = ETH_LINK_SPEED_100G;
1179 } else if (!strcmp(speedstr, "auto")) {
1180 *speed = ETH_LINK_SPEED_AUTONEG;
1182 printf("Unknown speed parameter\n");
1191 cmd_config_speed_all_parsed(void *parsed_result,
1192 __attribute__((unused)) struct cmdline *cl,
1193 __attribute__((unused)) void *data)
1195 struct cmd_config_speed_all *res = parsed_result;
1196 uint32_t link_speed;
1199 if (!all_ports_stopped()) {
1200 printf("Please stop all ports first\n");
1204 if (parse_and_check_speed_duplex(res->value1, res->value2,
1208 RTE_ETH_FOREACH_DEV(pid) {
1209 ports[pid].dev_conf.link_speeds = link_speed;
1212 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1215 cmdline_parse_token_string_t cmd_config_speed_all_port =
1216 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1217 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1218 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1220 cmdline_parse_token_string_t cmd_config_speed_all_all =
1221 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1222 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1223 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1224 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1225 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1226 "10#100#1000#10000#25000#40000#50000#100000#auto");
1227 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1228 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1229 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1230 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1233 cmdline_parse_inst_t cmd_config_speed_all = {
1234 .f = cmd_config_speed_all_parsed,
1236 .help_str = "port config all speed "
1237 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1240 (void *)&cmd_config_speed_all_port,
1241 (void *)&cmd_config_speed_all_keyword,
1242 (void *)&cmd_config_speed_all_all,
1243 (void *)&cmd_config_speed_all_item1,
1244 (void *)&cmd_config_speed_all_value1,
1245 (void *)&cmd_config_speed_all_item2,
1246 (void *)&cmd_config_speed_all_value2,
1251 /* *** configure speed for specific port *** */
1252 struct cmd_config_speed_specific {
1253 cmdline_fixed_string_t port;
1254 cmdline_fixed_string_t keyword;
1256 cmdline_fixed_string_t item1;
1257 cmdline_fixed_string_t item2;
1258 cmdline_fixed_string_t value1;
1259 cmdline_fixed_string_t value2;
1263 cmd_config_speed_specific_parsed(void *parsed_result,
1264 __attribute__((unused)) struct cmdline *cl,
1265 __attribute__((unused)) void *data)
1267 struct cmd_config_speed_specific *res = parsed_result;
1268 uint32_t link_speed;
1270 if (!all_ports_stopped()) {
1271 printf("Please stop all ports first\n");
1275 if (port_id_is_invalid(res->id, ENABLED_WARN))
1278 if (parse_and_check_speed_duplex(res->value1, res->value2,
1282 ports[res->id].dev_conf.link_speeds = link_speed;
1284 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1288 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1289 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1291 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1292 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1294 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1295 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1296 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1297 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1299 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1300 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1301 "10#100#1000#10000#25000#40000#50000#100000#auto");
1302 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1303 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1305 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1306 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1309 cmdline_parse_inst_t cmd_config_speed_specific = {
1310 .f = cmd_config_speed_specific_parsed,
1312 .help_str = "port config <port_id> speed "
1313 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1316 (void *)&cmd_config_speed_specific_port,
1317 (void *)&cmd_config_speed_specific_keyword,
1318 (void *)&cmd_config_speed_specific_id,
1319 (void *)&cmd_config_speed_specific_item1,
1320 (void *)&cmd_config_speed_specific_value1,
1321 (void *)&cmd_config_speed_specific_item2,
1322 (void *)&cmd_config_speed_specific_value2,
1327 /* *** configure txq/rxq, txd/rxd *** */
1328 struct cmd_config_rx_tx {
1329 cmdline_fixed_string_t port;
1330 cmdline_fixed_string_t keyword;
1331 cmdline_fixed_string_t all;
1332 cmdline_fixed_string_t name;
1337 cmd_config_rx_tx_parsed(void *parsed_result,
1338 __attribute__((unused)) struct cmdline *cl,
1339 __attribute__((unused)) void *data)
1341 struct cmd_config_rx_tx *res = parsed_result;
1343 if (!all_ports_stopped()) {
1344 printf("Please stop all ports first\n");
1347 if (!strcmp(res->name, "rxq")) {
1348 if (!res->value && !nb_txq) {
1349 printf("Warning: Either rx or tx queues should be non zero\n");
1352 nb_rxq = res->value;
1354 else if (!strcmp(res->name, "txq")) {
1355 if (!res->value && !nb_rxq) {
1356 printf("Warning: Either rx or tx queues should be non zero\n");
1359 nb_txq = res->value;
1361 else if (!strcmp(res->name, "rxd")) {
1362 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1363 printf("rxd %d invalid - must be > 0 && <= %d\n",
1364 res->value, RTE_TEST_RX_DESC_MAX);
1367 nb_rxd = res->value;
1368 } else if (!strcmp(res->name, "txd")) {
1369 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1370 printf("txd %d invalid - must be > 0 && <= %d\n",
1371 res->value, RTE_TEST_TX_DESC_MAX);
1374 nb_txd = res->value;
1376 printf("Unknown parameter\n");
1384 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1387 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1388 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1389 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1390 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1391 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1393 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1396 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1397 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1399 cmdline_parse_inst_t cmd_config_rx_tx = {
1400 .f = cmd_config_rx_tx_parsed,
1402 .help_str = "port config all rxq|txq|rxd|txd <value>",
1404 (void *)&cmd_config_rx_tx_port,
1405 (void *)&cmd_config_rx_tx_keyword,
1406 (void *)&cmd_config_rx_tx_all,
1407 (void *)&cmd_config_rx_tx_name,
1408 (void *)&cmd_config_rx_tx_value,
1413 /* *** config max packet length *** */
1414 struct cmd_config_max_pkt_len_result {
1415 cmdline_fixed_string_t port;
1416 cmdline_fixed_string_t keyword;
1417 cmdline_fixed_string_t all;
1418 cmdline_fixed_string_t name;
1423 cmd_config_max_pkt_len_parsed(void *parsed_result,
1424 __attribute__((unused)) struct cmdline *cl,
1425 __attribute__((unused)) void *data)
1427 struct cmd_config_max_pkt_len_result *res = parsed_result;
1429 if (!all_ports_stopped()) {
1430 printf("Please stop all ports first\n");
1434 if (!strcmp(res->name, "max-pkt-len")) {
1435 if (res->value < ETHER_MIN_LEN) {
1436 printf("max-pkt-len can not be less than %d\n",
1440 if (res->value == rx_mode.max_rx_pkt_len)
1443 rx_mode.max_rx_pkt_len = res->value;
1444 if (res->value > ETHER_MAX_LEN)
1445 rx_mode.jumbo_frame = 1;
1447 rx_mode.jumbo_frame = 0;
1449 printf("Unknown parameter\n");
1455 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1458 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1459 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1461 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1462 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1464 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1465 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1467 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1468 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1470 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1471 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1474 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1475 .f = cmd_config_max_pkt_len_parsed,
1477 .help_str = "port config all max-pkt-len <value>",
1479 (void *)&cmd_config_max_pkt_len_port,
1480 (void *)&cmd_config_max_pkt_len_keyword,
1481 (void *)&cmd_config_max_pkt_len_all,
1482 (void *)&cmd_config_max_pkt_len_name,
1483 (void *)&cmd_config_max_pkt_len_value,
1488 /* *** configure port MTU *** */
1489 struct cmd_config_mtu_result {
1490 cmdline_fixed_string_t port;
1491 cmdline_fixed_string_t keyword;
1492 cmdline_fixed_string_t mtu;
1498 cmd_config_mtu_parsed(void *parsed_result,
1499 __attribute__((unused)) struct cmdline *cl,
1500 __attribute__((unused)) void *data)
1502 struct cmd_config_mtu_result *res = parsed_result;
1504 if (res->value < ETHER_MIN_LEN) {
1505 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1508 port_mtu_set(res->port_id, res->value);
1511 cmdline_parse_token_string_t cmd_config_mtu_port =
1512 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1514 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1515 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1517 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1518 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1520 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1521 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1522 cmdline_parse_token_num_t cmd_config_mtu_value =
1523 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1525 cmdline_parse_inst_t cmd_config_mtu = {
1526 .f = cmd_config_mtu_parsed,
1528 .help_str = "port config mtu <port_id> <value>",
1530 (void *)&cmd_config_mtu_port,
1531 (void *)&cmd_config_mtu_keyword,
1532 (void *)&cmd_config_mtu_mtu,
1533 (void *)&cmd_config_mtu_port_id,
1534 (void *)&cmd_config_mtu_value,
1539 /* *** configure rx mode *** */
1540 struct cmd_config_rx_mode_flag {
1541 cmdline_fixed_string_t port;
1542 cmdline_fixed_string_t keyword;
1543 cmdline_fixed_string_t all;
1544 cmdline_fixed_string_t name;
1545 cmdline_fixed_string_t value;
1549 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1550 __attribute__((unused)) struct cmdline *cl,
1551 __attribute__((unused)) void *data)
1553 struct cmd_config_rx_mode_flag *res = parsed_result;
1555 if (!all_ports_stopped()) {
1556 printf("Please stop all ports first\n");
1560 if (!strcmp(res->name, "crc-strip")) {
1561 if (!strcmp(res->value, "on"))
1562 rx_mode.hw_strip_crc = 1;
1563 else if (!strcmp(res->value, "off"))
1564 rx_mode.hw_strip_crc = 0;
1566 printf("Unknown parameter\n");
1569 } else if (!strcmp(res->name, "scatter")) {
1570 if (!strcmp(res->value, "on"))
1571 rx_mode.enable_scatter = 1;
1572 else if (!strcmp(res->value, "off"))
1573 rx_mode.enable_scatter = 0;
1575 printf("Unknown parameter\n");
1578 } else if (!strcmp(res->name, "rx-cksum")) {
1579 if (!strcmp(res->value, "on"))
1580 rx_mode.hw_ip_checksum = 1;
1581 else if (!strcmp(res->value, "off"))
1582 rx_mode.hw_ip_checksum = 0;
1584 printf("Unknown parameter\n");
1587 } else if (!strcmp(res->name, "hw-vlan")) {
1588 if (!strcmp(res->value, "on")) {
1589 rx_mode.hw_vlan_filter = 1;
1590 rx_mode.hw_vlan_strip = 1;
1592 else if (!strcmp(res->value, "off")) {
1593 rx_mode.hw_vlan_filter = 0;
1594 rx_mode.hw_vlan_strip = 0;
1597 printf("Unknown parameter\n");
1600 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1601 if (!strcmp(res->value, "on"))
1602 rx_mode.hw_vlan_filter = 1;
1603 else if (!strcmp(res->value, "off"))
1604 rx_mode.hw_vlan_filter = 0;
1606 printf("Unknown parameter\n");
1609 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1610 if (!strcmp(res->value, "on"))
1611 rx_mode.hw_vlan_strip = 1;
1612 else if (!strcmp(res->value, "off"))
1613 rx_mode.hw_vlan_strip = 0;
1615 printf("Unknown parameter\n");
1618 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1619 if (!strcmp(res->value, "on"))
1620 rx_mode.hw_vlan_extend = 1;
1621 else if (!strcmp(res->value, "off"))
1622 rx_mode.hw_vlan_extend = 0;
1624 printf("Unknown parameter\n");
1627 } else if (!strcmp(res->name, "drop-en")) {
1628 if (!strcmp(res->value, "on"))
1630 else if (!strcmp(res->value, "off"))
1633 printf("Unknown parameter\n");
1637 printf("Unknown parameter\n");
1643 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1646 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1647 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1648 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1649 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1651 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1652 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1653 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1654 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1655 "crc-strip#scatter#rx-cksum#hw-vlan#"
1656 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1657 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1661 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1662 .f = cmd_config_rx_mode_flag_parsed,
1664 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1665 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1667 (void *)&cmd_config_rx_mode_flag_port,
1668 (void *)&cmd_config_rx_mode_flag_keyword,
1669 (void *)&cmd_config_rx_mode_flag_all,
1670 (void *)&cmd_config_rx_mode_flag_name,
1671 (void *)&cmd_config_rx_mode_flag_value,
1676 /* *** configure rss *** */
1677 struct cmd_config_rss {
1678 cmdline_fixed_string_t port;
1679 cmdline_fixed_string_t keyword;
1680 cmdline_fixed_string_t all;
1681 cmdline_fixed_string_t name;
1682 cmdline_fixed_string_t value;
1686 cmd_config_rss_parsed(void *parsed_result,
1687 __attribute__((unused)) struct cmdline *cl,
1688 __attribute__((unused)) void *data)
1690 struct cmd_config_rss *res = parsed_result;
1691 struct rte_eth_rss_conf rss_conf;
1695 if (!strcmp(res->value, "all"))
1696 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1697 ETH_RSS_UDP | ETH_RSS_SCTP |
1699 else if (!strcmp(res->value, "ip"))
1700 rss_conf.rss_hf = ETH_RSS_IP;
1701 else if (!strcmp(res->value, "udp"))
1702 rss_conf.rss_hf = ETH_RSS_UDP;
1703 else if (!strcmp(res->value, "tcp"))
1704 rss_conf.rss_hf = ETH_RSS_TCP;
1705 else if (!strcmp(res->value, "sctp"))
1706 rss_conf.rss_hf = ETH_RSS_SCTP;
1707 else if (!strcmp(res->value, "ether"))
1708 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1709 else if (!strcmp(res->value, "port"))
1710 rss_conf.rss_hf = ETH_RSS_PORT;
1711 else if (!strcmp(res->value, "vxlan"))
1712 rss_conf.rss_hf = ETH_RSS_VXLAN;
1713 else if (!strcmp(res->value, "geneve"))
1714 rss_conf.rss_hf = ETH_RSS_GENEVE;
1715 else if (!strcmp(res->value, "nvgre"))
1716 rss_conf.rss_hf = ETH_RSS_NVGRE;
1717 else if (!strcmp(res->value, "none"))
1718 rss_conf.rss_hf = 0;
1720 printf("Unknown parameter\n");
1723 rss_conf.rss_key = NULL;
1724 for (i = 0; i < rte_eth_dev_count(); i++) {
1725 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1727 printf("Configuration of RSS hash at ethernet port %d "
1728 "failed with error (%d): %s.\n",
1729 i, -diag, strerror(-diag));
1733 cmdline_parse_token_string_t cmd_config_rss_port =
1734 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1735 cmdline_parse_token_string_t cmd_config_rss_keyword =
1736 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1737 cmdline_parse_token_string_t cmd_config_rss_all =
1738 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1739 cmdline_parse_token_string_t cmd_config_rss_name =
1740 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1741 cmdline_parse_token_string_t cmd_config_rss_value =
1742 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1743 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1745 cmdline_parse_inst_t cmd_config_rss = {
1746 .f = cmd_config_rss_parsed,
1748 .help_str = "port config all rss "
1749 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1751 (void *)&cmd_config_rss_port,
1752 (void *)&cmd_config_rss_keyword,
1753 (void *)&cmd_config_rss_all,
1754 (void *)&cmd_config_rss_name,
1755 (void *)&cmd_config_rss_value,
1760 /* *** configure rss hash key *** */
1761 struct cmd_config_rss_hash_key {
1762 cmdline_fixed_string_t port;
1763 cmdline_fixed_string_t config;
1765 cmdline_fixed_string_t rss_hash_key;
1766 cmdline_fixed_string_t rss_type;
1767 cmdline_fixed_string_t key;
1771 hexa_digit_to_value(char hexa_digit)
1773 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1774 return (uint8_t) (hexa_digit - '0');
1775 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1776 return (uint8_t) ((hexa_digit - 'a') + 10);
1777 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1778 return (uint8_t) ((hexa_digit - 'A') + 10);
1779 /* Invalid hexa digit */
1784 parse_and_check_key_hexa_digit(char *key, int idx)
1788 hexa_v = hexa_digit_to_value(key[idx]);
1790 printf("invalid key: character %c at position %d is not a "
1791 "valid hexa digit\n", key[idx], idx);
1796 cmd_config_rss_hash_key_parsed(void *parsed_result,
1797 __attribute__((unused)) struct cmdline *cl,
1798 __attribute__((unused)) void *data)
1800 struct cmd_config_rss_hash_key *res = parsed_result;
1801 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1805 struct rte_eth_dev_info dev_info;
1806 uint8_t hash_key_size;
1809 memset(&dev_info, 0, sizeof(dev_info));
1810 rte_eth_dev_info_get(res->port_id, &dev_info);
1811 if (dev_info.hash_key_size > 0 &&
1812 dev_info.hash_key_size <= sizeof(hash_key))
1813 hash_key_size = dev_info.hash_key_size;
1815 printf("dev_info did not provide a valid hash key size\n");
1818 /* Check the length of the RSS hash key */
1819 key_len = strlen(res->key);
1820 if (key_len != (hash_key_size * 2)) {
1821 printf("key length: %d invalid - key must be a string of %d"
1822 " hexa-decimal numbers\n",
1823 (int) key_len, hash_key_size * 2);
1826 /* Translate RSS hash key into binary representation */
1827 for (i = 0; i < hash_key_size; i++) {
1828 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1831 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1834 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1836 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1840 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1841 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1842 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1843 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1845 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1846 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1847 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1848 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1849 rss_hash_key, "rss-hash-key");
1850 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1851 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1852 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1853 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1854 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1855 "ipv6-tcp-ex#ipv6-udp-ex");
1856 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1857 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1859 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1860 .f = cmd_config_rss_hash_key_parsed,
1862 .help_str = "port config <port_id> rss-hash-key "
1863 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1864 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1865 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1866 "<string of hex digits (variable length, NIC dependent)>",
1868 (void *)&cmd_config_rss_hash_key_port,
1869 (void *)&cmd_config_rss_hash_key_config,
1870 (void *)&cmd_config_rss_hash_key_port_id,
1871 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1872 (void *)&cmd_config_rss_hash_key_rss_type,
1873 (void *)&cmd_config_rss_hash_key_value,
1878 /* *** configure port rxq/txq start/stop *** */
1879 struct cmd_config_rxtx_queue {
1880 cmdline_fixed_string_t port;
1882 cmdline_fixed_string_t rxtxq;
1884 cmdline_fixed_string_t opname;
1888 cmd_config_rxtx_queue_parsed(void *parsed_result,
1889 __attribute__((unused)) struct cmdline *cl,
1890 __attribute__((unused)) void *data)
1892 struct cmd_config_rxtx_queue *res = parsed_result;
1897 if (test_done == 0) {
1898 printf("Please stop forwarding first\n");
1902 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1905 if (port_is_started(res->portid) != 1) {
1906 printf("Please start port %u first\n", res->portid);
1910 if (!strcmp(res->rxtxq, "rxq"))
1912 else if (!strcmp(res->rxtxq, "txq"))
1915 printf("Unknown parameter\n");
1919 if (isrx && rx_queue_id_is_invalid(res->qid))
1921 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1924 if (!strcmp(res->opname, "start"))
1926 else if (!strcmp(res->opname, "stop"))
1929 printf("Unknown parameter\n");
1933 if (isstart && isrx)
1934 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1935 else if (!isstart && isrx)
1936 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1937 else if (isstart && !isrx)
1938 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1940 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1942 if (ret == -ENOTSUP)
1943 printf("Function not supported in PMD driver\n");
1946 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1947 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1948 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1949 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1950 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1951 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1952 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1953 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1954 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1955 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1958 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1959 .f = cmd_config_rxtx_queue_parsed,
1961 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1963 (void *)&cmd_config_speed_all_port,
1964 (void *)&cmd_config_rxtx_queue_portid,
1965 (void *)&cmd_config_rxtx_queue_rxtxq,
1966 (void *)&cmd_config_rxtx_queue_qid,
1967 (void *)&cmd_config_rxtx_queue_opname,
1972 /* *** Configure RSS RETA *** */
1973 struct cmd_config_rss_reta {
1974 cmdline_fixed_string_t port;
1975 cmdline_fixed_string_t keyword;
1977 cmdline_fixed_string_t name;
1978 cmdline_fixed_string_t list_name;
1979 cmdline_fixed_string_t list_of_items;
1983 parse_reta_config(const char *str,
1984 struct rte_eth_rss_reta_entry64 *reta_conf,
1985 uint16_t nb_entries)
1989 uint16_t hash_index, idx, shift;
1992 const char *p, *p0 = str;
1999 unsigned long int_fld[_NUM_FLD];
2000 char *str_fld[_NUM_FLD];
2002 while ((p = strchr(p0,'(')) != NULL) {
2004 if((p0 = strchr(p,')')) == NULL)
2008 if(size >= sizeof(s))
2011 snprintf(s, sizeof(s), "%.*s", size, p);
2012 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2014 for (i = 0; i < _NUM_FLD; i++) {
2016 int_fld[i] = strtoul(str_fld[i], &end, 0);
2017 if (errno != 0 || end == str_fld[i] ||
2022 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2023 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2025 if (hash_index >= nb_entries) {
2026 printf("Invalid RETA hash index=%d\n", hash_index);
2030 idx = hash_index / RTE_RETA_GROUP_SIZE;
2031 shift = hash_index % RTE_RETA_GROUP_SIZE;
2032 reta_conf[idx].mask |= (1ULL << shift);
2033 reta_conf[idx].reta[shift] = nb_queue;
2040 cmd_set_rss_reta_parsed(void *parsed_result,
2041 __attribute__((unused)) struct cmdline *cl,
2042 __attribute__((unused)) void *data)
2045 struct rte_eth_dev_info dev_info;
2046 struct rte_eth_rss_reta_entry64 reta_conf[8];
2047 struct cmd_config_rss_reta *res = parsed_result;
2049 memset(&dev_info, 0, sizeof(dev_info));
2050 rte_eth_dev_info_get(res->port_id, &dev_info);
2051 if (dev_info.reta_size == 0) {
2052 printf("Redirection table size is 0 which is "
2053 "invalid for RSS\n");
2056 printf("The reta size of port %d is %u\n",
2057 res->port_id, dev_info.reta_size);
2058 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2059 printf("Currently do not support more than %u entries of "
2060 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2064 memset(reta_conf, 0, sizeof(reta_conf));
2065 if (!strcmp(res->list_name, "reta")) {
2066 if (parse_reta_config(res->list_of_items, reta_conf,
2067 dev_info.reta_size)) {
2068 printf("Invalid RSS Redirection Table "
2069 "config entered\n");
2072 ret = rte_eth_dev_rss_reta_update(res->port_id,
2073 reta_conf, dev_info.reta_size);
2075 printf("Bad redirection table parameter, "
2076 "return code = %d \n", ret);
2080 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2081 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2082 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2083 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2084 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2085 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2086 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2087 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2088 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2089 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2090 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2091 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2093 cmdline_parse_inst_t cmd_config_rss_reta = {
2094 .f = cmd_set_rss_reta_parsed,
2096 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2098 (void *)&cmd_config_rss_reta_port,
2099 (void *)&cmd_config_rss_reta_keyword,
2100 (void *)&cmd_config_rss_reta_port_id,
2101 (void *)&cmd_config_rss_reta_name,
2102 (void *)&cmd_config_rss_reta_list_name,
2103 (void *)&cmd_config_rss_reta_list_of_items,
2108 /* *** SHOW PORT RETA INFO *** */
2109 struct cmd_showport_reta {
2110 cmdline_fixed_string_t show;
2111 cmdline_fixed_string_t port;
2113 cmdline_fixed_string_t rss;
2114 cmdline_fixed_string_t reta;
2116 cmdline_fixed_string_t list_of_items;
2120 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2121 uint16_t nb_entries,
2125 const char *p, *p0 = str;
2130 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2131 RTE_RETA_GROUP_SIZE;
2134 p = strchr(p0, '(');
2138 p0 = strchr(p, ')');
2142 if (size >= sizeof(s)) {
2143 printf("The string size exceeds the internal buffer size\n");
2146 snprintf(s, sizeof(s), "%.*s", size, p);
2147 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2148 if (ret <= 0 || ret != num) {
2149 printf("The bits of masks do not match the number of "
2150 "reta entries: %u\n", num);
2153 for (i = 0; i < ret; i++)
2154 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2160 cmd_showport_reta_parsed(void *parsed_result,
2161 __attribute__((unused)) struct cmdline *cl,
2162 __attribute__((unused)) void *data)
2164 struct cmd_showport_reta *res = parsed_result;
2165 struct rte_eth_rss_reta_entry64 reta_conf[8];
2166 struct rte_eth_dev_info dev_info;
2168 memset(&dev_info, 0, sizeof(dev_info));
2169 rte_eth_dev_info_get(res->port_id, &dev_info);
2170 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2171 res->size > ETH_RSS_RETA_SIZE_512) {
2172 printf("Invalid redirection table size: %u\n", res->size);
2176 memset(reta_conf, 0, sizeof(reta_conf));
2177 if (showport_parse_reta_config(reta_conf, res->size,
2178 res->list_of_items) < 0) {
2179 printf("Invalid string: %s for reta masks\n",
2180 res->list_of_items);
2183 port_rss_reta_info(res->port_id, reta_conf, res->size);
2186 cmdline_parse_token_string_t cmd_showport_reta_show =
2187 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2188 cmdline_parse_token_string_t cmd_showport_reta_port =
2189 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2190 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2191 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2192 cmdline_parse_token_string_t cmd_showport_reta_rss =
2193 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2194 cmdline_parse_token_string_t cmd_showport_reta_reta =
2195 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2196 cmdline_parse_token_num_t cmd_showport_reta_size =
2197 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2198 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2199 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2200 list_of_items, NULL);
2202 cmdline_parse_inst_t cmd_showport_reta = {
2203 .f = cmd_showport_reta_parsed,
2205 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2207 (void *)&cmd_showport_reta_show,
2208 (void *)&cmd_showport_reta_port,
2209 (void *)&cmd_showport_reta_port_id,
2210 (void *)&cmd_showport_reta_rss,
2211 (void *)&cmd_showport_reta_reta,
2212 (void *)&cmd_showport_reta_size,
2213 (void *)&cmd_showport_reta_list_of_items,
2218 /* *** Show RSS hash configuration *** */
2219 struct cmd_showport_rss_hash {
2220 cmdline_fixed_string_t show;
2221 cmdline_fixed_string_t port;
2223 cmdline_fixed_string_t rss_hash;
2224 cmdline_fixed_string_t rss_type;
2225 cmdline_fixed_string_t key; /* optional argument */
2228 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2229 __attribute__((unused)) struct cmdline *cl,
2232 struct cmd_showport_rss_hash *res = parsed_result;
2234 port_rss_hash_conf_show(res->port_id, res->rss_type,
2235 show_rss_key != NULL);
2238 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2239 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2240 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2241 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2242 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2243 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2244 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2245 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2247 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2248 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2249 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2250 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2251 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2252 "ipv6-tcp-ex#ipv6-udp-ex");
2253 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2254 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2256 cmdline_parse_inst_t cmd_showport_rss_hash = {
2257 .f = cmd_showport_rss_hash_parsed,
2259 .help_str = "show port <port_id> rss-hash "
2260 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2261 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2262 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2264 (void *)&cmd_showport_rss_hash_show,
2265 (void *)&cmd_showport_rss_hash_port,
2266 (void *)&cmd_showport_rss_hash_port_id,
2267 (void *)&cmd_showport_rss_hash_rss_hash,
2268 (void *)&cmd_showport_rss_hash_rss_hash_info,
2273 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2274 .f = cmd_showport_rss_hash_parsed,
2276 .help_str = "show port <port_id> rss-hash "
2277 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2278 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2279 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2281 (void *)&cmd_showport_rss_hash_show,
2282 (void *)&cmd_showport_rss_hash_port,
2283 (void *)&cmd_showport_rss_hash_port_id,
2284 (void *)&cmd_showport_rss_hash_rss_hash,
2285 (void *)&cmd_showport_rss_hash_rss_hash_info,
2286 (void *)&cmd_showport_rss_hash_rss_key,
2291 /* *** Configure DCB *** */
2292 struct cmd_config_dcb {
2293 cmdline_fixed_string_t port;
2294 cmdline_fixed_string_t config;
2296 cmdline_fixed_string_t dcb;
2297 cmdline_fixed_string_t vt;
2298 cmdline_fixed_string_t vt_en;
2300 cmdline_fixed_string_t pfc;
2301 cmdline_fixed_string_t pfc_en;
2305 cmd_config_dcb_parsed(void *parsed_result,
2306 __attribute__((unused)) struct cmdline *cl,
2307 __attribute__((unused)) void *data)
2309 struct cmd_config_dcb *res = parsed_result;
2310 portid_t port_id = res->port_id;
2311 struct rte_port *port;
2315 port = &ports[port_id];
2316 /** Check if the port is not started **/
2317 if (port->port_status != RTE_PORT_STOPPED) {
2318 printf("Please stop port %d first\n", port_id);
2322 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2323 printf("The invalid number of traffic class,"
2324 " only 4 or 8 allowed.\n");
2328 if (nb_fwd_lcores < res->num_tcs) {
2329 printf("nb_cores shouldn't be less than number of TCs.\n");
2332 if (!strncmp(res->pfc_en, "on", 2))
2337 /* DCB in VT mode */
2338 if (!strncmp(res->vt_en, "on", 2))
2339 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2340 (enum rte_eth_nb_tcs)res->num_tcs,
2343 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2344 (enum rte_eth_nb_tcs)res->num_tcs,
2349 printf("Cannot initialize network ports.\n");
2353 cmd_reconfig_device_queue(port_id, 1, 1);
2356 cmdline_parse_token_string_t cmd_config_dcb_port =
2357 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2358 cmdline_parse_token_string_t cmd_config_dcb_config =
2359 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2360 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2361 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2362 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2363 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2364 cmdline_parse_token_string_t cmd_config_dcb_vt =
2365 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2366 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2367 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2368 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2369 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2370 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2371 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2372 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2373 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2375 cmdline_parse_inst_t cmd_config_dcb = {
2376 .f = cmd_config_dcb_parsed,
2378 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2380 (void *)&cmd_config_dcb_port,
2381 (void *)&cmd_config_dcb_config,
2382 (void *)&cmd_config_dcb_port_id,
2383 (void *)&cmd_config_dcb_dcb,
2384 (void *)&cmd_config_dcb_vt,
2385 (void *)&cmd_config_dcb_vt_en,
2386 (void *)&cmd_config_dcb_num_tcs,
2387 (void *)&cmd_config_dcb_pfc,
2388 (void *)&cmd_config_dcb_pfc_en,
2393 /* *** configure number of packets per burst *** */
2394 struct cmd_config_burst {
2395 cmdline_fixed_string_t port;
2396 cmdline_fixed_string_t keyword;
2397 cmdline_fixed_string_t all;
2398 cmdline_fixed_string_t name;
2403 cmd_config_burst_parsed(void *parsed_result,
2404 __attribute__((unused)) struct cmdline *cl,
2405 __attribute__((unused)) void *data)
2407 struct cmd_config_burst *res = parsed_result;
2409 if (!all_ports_stopped()) {
2410 printf("Please stop all ports first\n");
2414 if (!strcmp(res->name, "burst")) {
2415 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2416 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2419 nb_pkt_per_burst = res->value;
2421 printf("Unknown parameter\n");
2427 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2430 cmdline_parse_token_string_t cmd_config_burst_port =
2431 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2432 cmdline_parse_token_string_t cmd_config_burst_keyword =
2433 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2434 cmdline_parse_token_string_t cmd_config_burst_all =
2435 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2436 cmdline_parse_token_string_t cmd_config_burst_name =
2437 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2438 cmdline_parse_token_num_t cmd_config_burst_value =
2439 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2441 cmdline_parse_inst_t cmd_config_burst = {
2442 .f = cmd_config_burst_parsed,
2444 .help_str = "port config all burst <value>",
2446 (void *)&cmd_config_burst_port,
2447 (void *)&cmd_config_burst_keyword,
2448 (void *)&cmd_config_burst_all,
2449 (void *)&cmd_config_burst_name,
2450 (void *)&cmd_config_burst_value,
2455 /* *** configure rx/tx queues *** */
2456 struct cmd_config_thresh {
2457 cmdline_fixed_string_t port;
2458 cmdline_fixed_string_t keyword;
2459 cmdline_fixed_string_t all;
2460 cmdline_fixed_string_t name;
2465 cmd_config_thresh_parsed(void *parsed_result,
2466 __attribute__((unused)) struct cmdline *cl,
2467 __attribute__((unused)) void *data)
2469 struct cmd_config_thresh *res = parsed_result;
2471 if (!all_ports_stopped()) {
2472 printf("Please stop all ports first\n");
2476 if (!strcmp(res->name, "txpt"))
2477 tx_pthresh = res->value;
2478 else if(!strcmp(res->name, "txht"))
2479 tx_hthresh = res->value;
2480 else if(!strcmp(res->name, "txwt"))
2481 tx_wthresh = res->value;
2482 else if(!strcmp(res->name, "rxpt"))
2483 rx_pthresh = res->value;
2484 else if(!strcmp(res->name, "rxht"))
2485 rx_hthresh = res->value;
2486 else if(!strcmp(res->name, "rxwt"))
2487 rx_wthresh = res->value;
2489 printf("Unknown parameter\n");
2495 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2498 cmdline_parse_token_string_t cmd_config_thresh_port =
2499 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2500 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2501 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2502 cmdline_parse_token_string_t cmd_config_thresh_all =
2503 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2504 cmdline_parse_token_string_t cmd_config_thresh_name =
2505 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2506 "txpt#txht#txwt#rxpt#rxht#rxwt");
2507 cmdline_parse_token_num_t cmd_config_thresh_value =
2508 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2510 cmdline_parse_inst_t cmd_config_thresh = {
2511 .f = cmd_config_thresh_parsed,
2513 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2515 (void *)&cmd_config_thresh_port,
2516 (void *)&cmd_config_thresh_keyword,
2517 (void *)&cmd_config_thresh_all,
2518 (void *)&cmd_config_thresh_name,
2519 (void *)&cmd_config_thresh_value,
2524 /* *** configure free/rs threshold *** */
2525 struct cmd_config_threshold {
2526 cmdline_fixed_string_t port;
2527 cmdline_fixed_string_t keyword;
2528 cmdline_fixed_string_t all;
2529 cmdline_fixed_string_t name;
2534 cmd_config_threshold_parsed(void *parsed_result,
2535 __attribute__((unused)) struct cmdline *cl,
2536 __attribute__((unused)) void *data)
2538 struct cmd_config_threshold *res = parsed_result;
2540 if (!all_ports_stopped()) {
2541 printf("Please stop all ports first\n");
2545 if (!strcmp(res->name, "txfreet"))
2546 tx_free_thresh = res->value;
2547 else if (!strcmp(res->name, "txrst"))
2548 tx_rs_thresh = res->value;
2549 else if (!strcmp(res->name, "rxfreet"))
2550 rx_free_thresh = res->value;
2552 printf("Unknown parameter\n");
2558 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2561 cmdline_parse_token_string_t cmd_config_threshold_port =
2562 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2563 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2564 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2566 cmdline_parse_token_string_t cmd_config_threshold_all =
2567 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2568 cmdline_parse_token_string_t cmd_config_threshold_name =
2569 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2570 "txfreet#txrst#rxfreet");
2571 cmdline_parse_token_num_t cmd_config_threshold_value =
2572 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2574 cmdline_parse_inst_t cmd_config_threshold = {
2575 .f = cmd_config_threshold_parsed,
2577 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2579 (void *)&cmd_config_threshold_port,
2580 (void *)&cmd_config_threshold_keyword,
2581 (void *)&cmd_config_threshold_all,
2582 (void *)&cmd_config_threshold_name,
2583 (void *)&cmd_config_threshold_value,
2589 struct cmd_stop_result {
2590 cmdline_fixed_string_t stop;
2593 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2594 __attribute__((unused)) struct cmdline *cl,
2595 __attribute__((unused)) void *data)
2597 stop_packet_forwarding();
2600 cmdline_parse_token_string_t cmd_stop_stop =
2601 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2603 cmdline_parse_inst_t cmd_stop = {
2604 .f = cmd_stop_parsed,
2606 .help_str = "stop: Stop packet forwarding",
2608 (void *)&cmd_stop_stop,
2613 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2616 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2617 unsigned int *parsed_items, int check_unique_values)
2619 unsigned int nb_item;
2627 * First parse all items in the list and store their value.
2632 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2634 if ((c >= '0') && (c <= '9')) {
2635 value = (unsigned int) (value * 10 + (c - '0'));
2640 printf("character %c is not a decimal digit\n", c);
2644 printf("No valid value before comma\n");
2647 if (nb_item < max_items) {
2648 parsed_items[nb_item] = value;
2654 if (nb_item >= max_items) {
2655 printf("Number of %s = %u > %u (maximum items)\n",
2656 item_name, nb_item + 1, max_items);
2659 parsed_items[nb_item++] = value;
2660 if (! check_unique_values)
2664 * Then, check that all values in the list are differents.
2665 * No optimization here...
2667 for (i = 0; i < nb_item; i++) {
2668 for (j = i + 1; j < nb_item; j++) {
2669 if (parsed_items[j] == parsed_items[i]) {
2670 printf("duplicated %s %u at index %u and %u\n",
2671 item_name, parsed_items[i], i, j);
2679 struct cmd_set_list_result {
2680 cmdline_fixed_string_t cmd_keyword;
2681 cmdline_fixed_string_t list_name;
2682 cmdline_fixed_string_t list_of_items;
2685 static void cmd_set_list_parsed(void *parsed_result,
2686 __attribute__((unused)) struct cmdline *cl,
2687 __attribute__((unused)) void *data)
2689 struct cmd_set_list_result *res;
2691 unsigned int lcorelist[RTE_MAX_LCORE];
2692 unsigned int portlist[RTE_MAX_ETHPORTS];
2694 unsigned int nb_item;
2696 if (test_done == 0) {
2697 printf("Please stop forwarding first\n");
2701 res = parsed_result;
2702 if (!strcmp(res->list_name, "corelist")) {
2703 nb_item = parse_item_list(res->list_of_items, "core",
2705 parsed_items.lcorelist, 1);
2707 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2712 if (!strcmp(res->list_name, "portlist")) {
2713 nb_item = parse_item_list(res->list_of_items, "port",
2715 parsed_items.portlist, 1);
2717 set_fwd_ports_list(parsed_items.portlist, nb_item);
2723 cmdline_parse_token_string_t cmd_set_list_keyword =
2724 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2726 cmdline_parse_token_string_t cmd_set_list_name =
2727 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2728 "corelist#portlist");
2729 cmdline_parse_token_string_t cmd_set_list_of_items =
2730 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2733 cmdline_parse_inst_t cmd_set_fwd_list = {
2734 .f = cmd_set_list_parsed,
2736 .help_str = "set corelist|portlist <list0[,list1]*>",
2738 (void *)&cmd_set_list_keyword,
2739 (void *)&cmd_set_list_name,
2740 (void *)&cmd_set_list_of_items,
2745 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2747 struct cmd_setmask_result {
2748 cmdline_fixed_string_t set;
2749 cmdline_fixed_string_t mask;
2753 static void cmd_set_mask_parsed(void *parsed_result,
2754 __attribute__((unused)) struct cmdline *cl,
2755 __attribute__((unused)) void *data)
2757 struct cmd_setmask_result *res = parsed_result;
2759 if (test_done == 0) {
2760 printf("Please stop forwarding first\n");
2763 if (!strcmp(res->mask, "coremask")) {
2764 set_fwd_lcores_mask(res->hexavalue);
2766 } else if (!strcmp(res->mask, "portmask")) {
2767 set_fwd_ports_mask(res->hexavalue);
2772 cmdline_parse_token_string_t cmd_setmask_set =
2773 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2774 cmdline_parse_token_string_t cmd_setmask_mask =
2775 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2776 "coremask#portmask");
2777 cmdline_parse_token_num_t cmd_setmask_value =
2778 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2780 cmdline_parse_inst_t cmd_set_fwd_mask = {
2781 .f = cmd_set_mask_parsed,
2783 .help_str = "set coremask|portmask <hexadecimal value>",
2785 (void *)&cmd_setmask_set,
2786 (void *)&cmd_setmask_mask,
2787 (void *)&cmd_setmask_value,
2793 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2795 struct cmd_set_result {
2796 cmdline_fixed_string_t set;
2797 cmdline_fixed_string_t what;
2801 static void cmd_set_parsed(void *parsed_result,
2802 __attribute__((unused)) struct cmdline *cl,
2803 __attribute__((unused)) void *data)
2805 struct cmd_set_result *res = parsed_result;
2806 if (!strcmp(res->what, "nbport")) {
2807 set_fwd_ports_number(res->value);
2809 } else if (!strcmp(res->what, "nbcore")) {
2810 set_fwd_lcores_number(res->value);
2812 } else if (!strcmp(res->what, "burst"))
2813 set_nb_pkt_per_burst(res->value);
2814 else if (!strcmp(res->what, "verbose"))
2815 set_verbose_level(res->value);
2818 cmdline_parse_token_string_t cmd_set_set =
2819 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2820 cmdline_parse_token_string_t cmd_set_what =
2821 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2822 "nbport#nbcore#burst#verbose");
2823 cmdline_parse_token_num_t cmd_set_value =
2824 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2826 cmdline_parse_inst_t cmd_set_numbers = {
2827 .f = cmd_set_parsed,
2829 .help_str = "set nbport|nbcore|burst|verbose <value>",
2831 (void *)&cmd_set_set,
2832 (void *)&cmd_set_what,
2833 (void *)&cmd_set_value,
2838 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2840 struct cmd_set_txpkts_result {
2841 cmdline_fixed_string_t cmd_keyword;
2842 cmdline_fixed_string_t txpkts;
2843 cmdline_fixed_string_t seg_lengths;
2847 cmd_set_txpkts_parsed(void *parsed_result,
2848 __attribute__((unused)) struct cmdline *cl,
2849 __attribute__((unused)) void *data)
2851 struct cmd_set_txpkts_result *res;
2852 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2853 unsigned int nb_segs;
2855 res = parsed_result;
2856 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2857 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2859 set_tx_pkt_segments(seg_lengths, nb_segs);
2862 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2863 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2864 cmd_keyword, "set");
2865 cmdline_parse_token_string_t cmd_set_txpkts_name =
2866 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2868 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2869 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2872 cmdline_parse_inst_t cmd_set_txpkts = {
2873 .f = cmd_set_txpkts_parsed,
2875 .help_str = "set txpkts <len0[,len1]*>",
2877 (void *)&cmd_set_txpkts_keyword,
2878 (void *)&cmd_set_txpkts_name,
2879 (void *)&cmd_set_txpkts_lengths,
2884 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2886 struct cmd_set_txsplit_result {
2887 cmdline_fixed_string_t cmd_keyword;
2888 cmdline_fixed_string_t txsplit;
2889 cmdline_fixed_string_t mode;
2893 cmd_set_txsplit_parsed(void *parsed_result,
2894 __attribute__((unused)) struct cmdline *cl,
2895 __attribute__((unused)) void *data)
2897 struct cmd_set_txsplit_result *res;
2899 res = parsed_result;
2900 set_tx_pkt_split(res->mode);
2903 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2904 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2905 cmd_keyword, "set");
2906 cmdline_parse_token_string_t cmd_set_txsplit_name =
2907 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2908 txsplit, "txsplit");
2909 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2910 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2913 cmdline_parse_inst_t cmd_set_txsplit = {
2914 .f = cmd_set_txsplit_parsed,
2916 .help_str = "set txsplit on|off|rand",
2918 (void *)&cmd_set_txsplit_keyword,
2919 (void *)&cmd_set_txsplit_name,
2920 (void *)&cmd_set_txsplit_mode,
2925 /* *** CONFIG TX QUEUE FLAGS *** */
2927 struct cmd_config_txqflags_result {
2928 cmdline_fixed_string_t port;
2929 cmdline_fixed_string_t config;
2930 cmdline_fixed_string_t all;
2931 cmdline_fixed_string_t what;
2935 static void cmd_config_txqflags_parsed(void *parsed_result,
2936 __attribute__((unused)) struct cmdline *cl,
2937 __attribute__((unused)) void *data)
2939 struct cmd_config_txqflags_result *res = parsed_result;
2941 if (!all_ports_stopped()) {
2942 printf("Please stop all ports first\n");
2946 if (strcmp(res->what, "txqflags")) {
2947 printf("Unknown parameter\n");
2951 if (res->hexvalue >= 0) {
2952 txq_flags = res->hexvalue;
2954 printf("txqflags must be >= 0\n");
2960 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2963 cmdline_parse_token_string_t cmd_config_txqflags_port =
2964 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2966 cmdline_parse_token_string_t cmd_config_txqflags_config =
2967 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2969 cmdline_parse_token_string_t cmd_config_txqflags_all =
2970 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2972 cmdline_parse_token_string_t cmd_config_txqflags_what =
2973 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2975 cmdline_parse_token_num_t cmd_config_txqflags_value =
2976 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2979 cmdline_parse_inst_t cmd_config_txqflags = {
2980 .f = cmd_config_txqflags_parsed,
2982 .help_str = "port config all txqflags <value>",
2984 (void *)&cmd_config_txqflags_port,
2985 (void *)&cmd_config_txqflags_config,
2986 (void *)&cmd_config_txqflags_all,
2987 (void *)&cmd_config_txqflags_what,
2988 (void *)&cmd_config_txqflags_value,
2993 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2994 struct cmd_rx_vlan_filter_all_result {
2995 cmdline_fixed_string_t rx_vlan;
2996 cmdline_fixed_string_t what;
2997 cmdline_fixed_string_t all;
3002 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3003 __attribute__((unused)) struct cmdline *cl,
3004 __attribute__((unused)) void *data)
3006 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3008 if (!strcmp(res->what, "add"))
3009 rx_vlan_all_filter_set(res->port_id, 1);
3011 rx_vlan_all_filter_set(res->port_id, 0);
3014 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3015 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3016 rx_vlan, "rx_vlan");
3017 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3018 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3020 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3021 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3023 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3024 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3027 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3028 .f = cmd_rx_vlan_filter_all_parsed,
3030 .help_str = "rx_vlan add|rm all <port_id>: "
3031 "Add/Remove all identifiers to/from the set of VLAN "
3032 "identifiers filtered by a port",
3034 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3035 (void *)&cmd_rx_vlan_filter_all_what,
3036 (void *)&cmd_rx_vlan_filter_all_all,
3037 (void *)&cmd_rx_vlan_filter_all_portid,
3042 /* *** VLAN OFFLOAD SET ON A PORT *** */
3043 struct cmd_vlan_offload_result {
3044 cmdline_fixed_string_t vlan;
3045 cmdline_fixed_string_t set;
3046 cmdline_fixed_string_t vlan_type;
3047 cmdline_fixed_string_t what;
3048 cmdline_fixed_string_t on;
3049 cmdline_fixed_string_t port_id;
3053 cmd_vlan_offload_parsed(void *parsed_result,
3054 __attribute__((unused)) struct cmdline *cl,
3055 __attribute__((unused)) void *data)
3058 struct cmd_vlan_offload_result *res = parsed_result;
3061 portid_t port_id = 0;
3065 len = strnlen(str, STR_TOKEN_SIZE);
3067 /* Get port_id first */
3075 tmp = strtoul(str, NULL, 0);
3076 /* If port_id greater that what portid_t can represent, return */
3077 if(tmp >= RTE_MAX_ETHPORTS)
3079 port_id = (portid_t)tmp;
3081 if (!strcmp(res->on, "on"))
3086 if (!strcmp(res->what, "strip"))
3087 rx_vlan_strip_set(port_id, on);
3088 else if(!strcmp(res->what, "stripq")){
3089 uint16_t queue_id = 0;
3091 /* No queue_id, return */
3093 printf("must specify (port,queue_id)\n");
3096 tmp = strtoul(str + i + 1, NULL, 0);
3097 /* If queue_id greater that what 16-bits can represent, return */
3101 queue_id = (uint16_t)tmp;
3102 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3104 else if (!strcmp(res->what, "filter"))
3105 rx_vlan_filter_set(port_id, on);
3107 vlan_extend_set(port_id, on);
3112 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3113 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3115 cmdline_parse_token_string_t cmd_vlan_offload_set =
3116 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3118 cmdline_parse_token_string_t cmd_vlan_offload_what =
3119 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3120 what, "strip#filter#qinq#stripq");
3121 cmdline_parse_token_string_t cmd_vlan_offload_on =
3122 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3124 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3125 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3128 cmdline_parse_inst_t cmd_vlan_offload = {
3129 .f = cmd_vlan_offload_parsed,
3131 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3132 "<port_id[,queue_id]>: "
3133 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3135 (void *)&cmd_vlan_offload_vlan,
3136 (void *)&cmd_vlan_offload_set,
3137 (void *)&cmd_vlan_offload_what,
3138 (void *)&cmd_vlan_offload_on,
3139 (void *)&cmd_vlan_offload_portid,
3144 /* *** VLAN TPID SET ON A PORT *** */
3145 struct cmd_vlan_tpid_result {
3146 cmdline_fixed_string_t vlan;
3147 cmdline_fixed_string_t set;
3148 cmdline_fixed_string_t vlan_type;
3149 cmdline_fixed_string_t what;
3155 cmd_vlan_tpid_parsed(void *parsed_result,
3156 __attribute__((unused)) struct cmdline *cl,
3157 __attribute__((unused)) void *data)
3159 struct cmd_vlan_tpid_result *res = parsed_result;
3160 enum rte_vlan_type vlan_type;
3162 if (!strcmp(res->vlan_type, "inner"))
3163 vlan_type = ETH_VLAN_TYPE_INNER;
3164 else if (!strcmp(res->vlan_type, "outer"))
3165 vlan_type = ETH_VLAN_TYPE_OUTER;
3167 printf("Unknown vlan type\n");
3170 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3173 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3174 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3176 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3177 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3179 cmdline_parse_token_string_t cmd_vlan_type =
3180 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3181 vlan_type, "inner#outer");
3182 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3183 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3185 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3186 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3188 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3189 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3192 cmdline_parse_inst_t cmd_vlan_tpid = {
3193 .f = cmd_vlan_tpid_parsed,
3195 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3196 "Set the VLAN Ether type",
3198 (void *)&cmd_vlan_tpid_vlan,
3199 (void *)&cmd_vlan_tpid_set,
3200 (void *)&cmd_vlan_type,
3201 (void *)&cmd_vlan_tpid_what,
3202 (void *)&cmd_vlan_tpid_tpid,
3203 (void *)&cmd_vlan_tpid_portid,
3208 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3209 struct cmd_rx_vlan_filter_result {
3210 cmdline_fixed_string_t rx_vlan;
3211 cmdline_fixed_string_t what;
3217 cmd_rx_vlan_filter_parsed(void *parsed_result,
3218 __attribute__((unused)) struct cmdline *cl,
3219 __attribute__((unused)) void *data)
3221 struct cmd_rx_vlan_filter_result *res = parsed_result;
3223 if (!strcmp(res->what, "add"))
3224 rx_vft_set(res->port_id, res->vlan_id, 1);
3226 rx_vft_set(res->port_id, res->vlan_id, 0);
3229 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3230 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3231 rx_vlan, "rx_vlan");
3232 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3233 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3235 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3236 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3238 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3239 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3242 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3243 .f = cmd_rx_vlan_filter_parsed,
3245 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3246 "Add/Remove a VLAN identifier to/from the set of VLAN "
3247 "identifiers filtered by a port",
3249 (void *)&cmd_rx_vlan_filter_rx_vlan,
3250 (void *)&cmd_rx_vlan_filter_what,
3251 (void *)&cmd_rx_vlan_filter_vlanid,
3252 (void *)&cmd_rx_vlan_filter_portid,
3257 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3258 struct cmd_tx_vlan_set_result {
3259 cmdline_fixed_string_t tx_vlan;
3260 cmdline_fixed_string_t set;
3266 cmd_tx_vlan_set_parsed(void *parsed_result,
3267 __attribute__((unused)) struct cmdline *cl,
3268 __attribute__((unused)) void *data)
3270 struct cmd_tx_vlan_set_result *res = parsed_result;
3272 tx_vlan_set(res->port_id, res->vlan_id);
3275 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3276 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3277 tx_vlan, "tx_vlan");
3278 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3279 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3281 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3282 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3284 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3285 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3288 cmdline_parse_inst_t cmd_tx_vlan_set = {
3289 .f = cmd_tx_vlan_set_parsed,
3291 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3292 "Enable hardware insertion of a single VLAN header "
3293 "with a given TAG Identifier in packets sent on a port",
3295 (void *)&cmd_tx_vlan_set_tx_vlan,
3296 (void *)&cmd_tx_vlan_set_set,
3297 (void *)&cmd_tx_vlan_set_portid,
3298 (void *)&cmd_tx_vlan_set_vlanid,
3303 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3304 struct cmd_tx_vlan_set_qinq_result {
3305 cmdline_fixed_string_t tx_vlan;
3306 cmdline_fixed_string_t set;
3309 uint16_t vlan_id_outer;
3313 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3314 __attribute__((unused)) struct cmdline *cl,
3315 __attribute__((unused)) void *data)
3317 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3319 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3322 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3323 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3324 tx_vlan, "tx_vlan");
3325 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3326 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3328 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3329 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3331 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3332 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3334 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3335 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3336 vlan_id_outer, UINT16);
3338 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3339 .f = cmd_tx_vlan_set_qinq_parsed,
3341 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3342 "Enable hardware insertion of double VLAN header "
3343 "with given TAG Identifiers in packets sent on a port",
3345 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3346 (void *)&cmd_tx_vlan_set_qinq_set,
3347 (void *)&cmd_tx_vlan_set_qinq_portid,
3348 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3349 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3354 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3355 struct cmd_tx_vlan_set_pvid_result {
3356 cmdline_fixed_string_t tx_vlan;
3357 cmdline_fixed_string_t set;
3358 cmdline_fixed_string_t pvid;
3361 cmdline_fixed_string_t mode;
3365 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3366 __attribute__((unused)) struct cmdline *cl,
3367 __attribute__((unused)) void *data)
3369 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3371 if (strcmp(res->mode, "on") == 0)
3372 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3374 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3377 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3378 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3379 tx_vlan, "tx_vlan");
3380 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3381 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3383 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3384 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3386 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3387 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3389 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3390 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3392 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3393 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3396 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3397 .f = cmd_tx_vlan_set_pvid_parsed,
3399 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3401 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3402 (void *)&cmd_tx_vlan_set_pvid_set,
3403 (void *)&cmd_tx_vlan_set_pvid_pvid,
3404 (void *)&cmd_tx_vlan_set_pvid_port_id,
3405 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3406 (void *)&cmd_tx_vlan_set_pvid_mode,
3411 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3412 struct cmd_tx_vlan_reset_result {
3413 cmdline_fixed_string_t tx_vlan;
3414 cmdline_fixed_string_t reset;
3419 cmd_tx_vlan_reset_parsed(void *parsed_result,
3420 __attribute__((unused)) struct cmdline *cl,
3421 __attribute__((unused)) void *data)
3423 struct cmd_tx_vlan_reset_result *res = parsed_result;
3425 tx_vlan_reset(res->port_id);
3428 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3429 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3430 tx_vlan, "tx_vlan");
3431 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3432 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3434 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3435 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3438 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3439 .f = cmd_tx_vlan_reset_parsed,
3441 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3442 "VLAN header in packets sent on a port",
3444 (void *)&cmd_tx_vlan_reset_tx_vlan,
3445 (void *)&cmd_tx_vlan_reset_reset,
3446 (void *)&cmd_tx_vlan_reset_portid,
3452 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3453 struct cmd_csum_result {
3454 cmdline_fixed_string_t csum;
3455 cmdline_fixed_string_t mode;
3456 cmdline_fixed_string_t proto;
3457 cmdline_fixed_string_t hwsw;
3462 csum_show(int port_id)
3464 struct rte_eth_dev_info dev_info;
3467 ol_flags = ports[port_id].tx_ol_flags;
3468 printf("Parse tunnel is %s\n",
3469 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3470 printf("IP checksum offload is %s\n",
3471 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3472 printf("UDP checksum offload is %s\n",
3473 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3474 printf("TCP checksum offload is %s\n",
3475 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3476 printf("SCTP checksum offload is %s\n",
3477 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3478 printf("Outer-Ip checksum offload is %s\n",
3479 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3481 /* display warnings if configuration is not supported by the NIC */
3482 rte_eth_dev_info_get(port_id, &dev_info);
3483 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3484 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3485 printf("Warning: hardware IP checksum enabled but not "
3486 "supported by port %d\n", port_id);
3488 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3489 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3490 printf("Warning: hardware UDP checksum enabled but not "
3491 "supported by port %d\n", port_id);
3493 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3494 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3495 printf("Warning: hardware TCP checksum enabled but not "
3496 "supported by port %d\n", port_id);
3498 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3499 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3500 printf("Warning: hardware SCTP checksum enabled but not "
3501 "supported by port %d\n", port_id);
3503 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3504 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3505 printf("Warning: hardware outer IP checksum enabled but not "
3506 "supported by port %d\n", port_id);
3511 cmd_csum_parsed(void *parsed_result,
3512 __attribute__((unused)) struct cmdline *cl,
3513 __attribute__((unused)) void *data)
3515 struct cmd_csum_result *res = parsed_result;
3519 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3520 printf("invalid port %d\n", res->port_id);
3524 if (!strcmp(res->mode, "set")) {
3526 if (!strcmp(res->hwsw, "hw"))
3529 if (!strcmp(res->proto, "ip")) {
3530 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3531 } else if (!strcmp(res->proto, "udp")) {
3532 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3533 } else if (!strcmp(res->proto, "tcp")) {
3534 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3535 } else if (!strcmp(res->proto, "sctp")) {
3536 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3537 } else if (!strcmp(res->proto, "outer-ip")) {
3538 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3542 ports[res->port_id].tx_ol_flags |= mask;
3544 ports[res->port_id].tx_ol_flags &= (~mask);
3546 csum_show(res->port_id);
3549 cmdline_parse_token_string_t cmd_csum_csum =
3550 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3552 cmdline_parse_token_string_t cmd_csum_mode =
3553 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3555 cmdline_parse_token_string_t cmd_csum_proto =
3556 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3557 proto, "ip#tcp#udp#sctp#outer-ip");
3558 cmdline_parse_token_string_t cmd_csum_hwsw =
3559 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3561 cmdline_parse_token_num_t cmd_csum_portid =
3562 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3565 cmdline_parse_inst_t cmd_csum_set = {
3566 .f = cmd_csum_parsed,
3568 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3569 "Enable/Disable hardware calculation of L3/L4 checksum when "
3570 "using csum forward engine",
3572 (void *)&cmd_csum_csum,
3573 (void *)&cmd_csum_mode,
3574 (void *)&cmd_csum_proto,
3575 (void *)&cmd_csum_hwsw,
3576 (void *)&cmd_csum_portid,
3581 cmdline_parse_token_string_t cmd_csum_mode_show =
3582 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3585 cmdline_parse_inst_t cmd_csum_show = {
3586 .f = cmd_csum_parsed,
3588 .help_str = "csum show <port_id>: Show checksum offload configuration",
3590 (void *)&cmd_csum_csum,
3591 (void *)&cmd_csum_mode_show,
3592 (void *)&cmd_csum_portid,
3597 /* Enable/disable tunnel parsing */
3598 struct cmd_csum_tunnel_result {
3599 cmdline_fixed_string_t csum;
3600 cmdline_fixed_string_t parse;
3601 cmdline_fixed_string_t onoff;
3606 cmd_csum_tunnel_parsed(void *parsed_result,
3607 __attribute__((unused)) struct cmdline *cl,
3608 __attribute__((unused)) void *data)
3610 struct cmd_csum_tunnel_result *res = parsed_result;
3612 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3615 if (!strcmp(res->onoff, "on"))
3616 ports[res->port_id].tx_ol_flags |=
3617 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3619 ports[res->port_id].tx_ol_flags &=
3620 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3622 csum_show(res->port_id);
3625 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3626 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3628 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3629 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3630 parse, "parse_tunnel");
3631 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3632 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3634 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3635 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3638 cmdline_parse_inst_t cmd_csum_tunnel = {
3639 .f = cmd_csum_tunnel_parsed,
3641 .help_str = "csum parse_tunnel on|off <port_id>: "
3642 "Enable/Disable parsing of tunnels for csum engine",
3644 (void *)&cmd_csum_tunnel_csum,
3645 (void *)&cmd_csum_tunnel_parse,
3646 (void *)&cmd_csum_tunnel_onoff,
3647 (void *)&cmd_csum_tunnel_portid,
3652 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3653 struct cmd_tso_set_result {
3654 cmdline_fixed_string_t tso;
3655 cmdline_fixed_string_t mode;
3661 cmd_tso_set_parsed(void *parsed_result,
3662 __attribute__((unused)) struct cmdline *cl,
3663 __attribute__((unused)) void *data)
3665 struct cmd_tso_set_result *res = parsed_result;
3666 struct rte_eth_dev_info dev_info;
3668 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3671 if (!strcmp(res->mode, "set"))
3672 ports[res->port_id].tso_segsz = res->tso_segsz;
3674 if (ports[res->port_id].tso_segsz == 0)
3675 printf("TSO for non-tunneled packets is disabled\n");
3677 printf("TSO segment size for non-tunneled packets is %d\n",
3678 ports[res->port_id].tso_segsz);
3680 /* display warnings if configuration is not supported by the NIC */
3681 rte_eth_dev_info_get(res->port_id, &dev_info);
3682 if ((ports[res->port_id].tso_segsz != 0) &&
3683 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3684 printf("Warning: TSO enabled but not "
3685 "supported by port %d\n", res->port_id);
3689 cmdline_parse_token_string_t cmd_tso_set_tso =
3690 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3692 cmdline_parse_token_string_t cmd_tso_set_mode =
3693 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3695 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3696 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3698 cmdline_parse_token_num_t cmd_tso_set_portid =
3699 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3702 cmdline_parse_inst_t cmd_tso_set = {
3703 .f = cmd_tso_set_parsed,
3705 .help_str = "tso set <tso_segsz> <port_id>: "
3706 "Set TSO segment size of non-tunneled packets for csum engine "
3709 (void *)&cmd_tso_set_tso,
3710 (void *)&cmd_tso_set_mode,
3711 (void *)&cmd_tso_set_tso_segsz,
3712 (void *)&cmd_tso_set_portid,
3717 cmdline_parse_token_string_t cmd_tso_show_mode =
3718 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3722 cmdline_parse_inst_t cmd_tso_show = {
3723 .f = cmd_tso_set_parsed,
3725 .help_str = "tso show <port_id>: "
3726 "Show TSO segment size of non-tunneled packets for csum engine",
3728 (void *)&cmd_tso_set_tso,
3729 (void *)&cmd_tso_show_mode,
3730 (void *)&cmd_tso_set_portid,
3735 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3736 struct cmd_tunnel_tso_set_result {
3737 cmdline_fixed_string_t tso;
3738 cmdline_fixed_string_t mode;
3744 check_tunnel_tso_nic_support(uint8_t port_id)
3746 struct rte_eth_dev_info dev_info;
3748 rte_eth_dev_info_get(port_id, &dev_info);
3749 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3750 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3751 "supported by port %d\n", port_id);
3752 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3753 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3754 "supported by port %d\n", port_id);
3755 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3756 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3757 "supported by port %d\n", port_id);
3758 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3759 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3760 "supported by port %d\n", port_id);
3764 cmd_tunnel_tso_set_parsed(void *parsed_result,
3765 __attribute__((unused)) struct cmdline *cl,
3766 __attribute__((unused)) void *data)
3768 struct cmd_tunnel_tso_set_result *res = parsed_result;
3770 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3773 if (!strcmp(res->mode, "set"))
3774 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3776 if (ports[res->port_id].tunnel_tso_segsz == 0)
3777 printf("TSO for tunneled packets is disabled\n");
3779 printf("TSO segment size for tunneled packets is %d\n",
3780 ports[res->port_id].tunnel_tso_segsz);
3782 /* Below conditions are needed to make it work:
3783 * (1) tunnel TSO is supported by the NIC;
3784 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3786 * (3) for tunneled pkts with outer L3 of IPv4,
3787 * "csum set outer-ip" must be set to hw, because after tso,
3788 * total_len of outer IP header is changed, and the checksum
3789 * of outer IP header calculated by sw should be wrong; that
3790 * is not necessary for IPv6 tunneled pkts because there's no
3791 * checksum in IP header anymore.
3793 check_tunnel_tso_nic_support(res->port_id);
3795 if (!(ports[res->port_id].tx_ol_flags &
3796 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3797 printf("Warning: csum parse_tunnel must be set "
3798 "so that tunneled packets are recognized\n");
3799 if (!(ports[res->port_id].tx_ol_flags &
3800 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3801 printf("Warning: csum set outer-ip must be set to hw "
3802 "if outer L3 is IPv4; not necessary for IPv6\n");
3806 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3807 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3809 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3810 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3812 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3813 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3815 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3816 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3819 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3820 .f = cmd_tunnel_tso_set_parsed,
3822 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3823 "Set TSO segment size of tunneled packets for csum engine "
3826 (void *)&cmd_tunnel_tso_set_tso,
3827 (void *)&cmd_tunnel_tso_set_mode,
3828 (void *)&cmd_tunnel_tso_set_tso_segsz,
3829 (void *)&cmd_tunnel_tso_set_portid,
3834 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3835 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3839 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3840 .f = cmd_tunnel_tso_set_parsed,
3842 .help_str = "tunnel_tso show <port_id> "
3843 "Show TSO segment size of tunneled packets for csum engine",
3845 (void *)&cmd_tunnel_tso_set_tso,
3846 (void *)&cmd_tunnel_tso_show_mode,
3847 (void *)&cmd_tunnel_tso_set_portid,
3852 /* *** SET GRO FOR A PORT *** */
3853 struct cmd_gro_result {
3854 cmdline_fixed_string_t cmd_keyword;
3855 cmdline_fixed_string_t mode;
3860 cmd_enable_gro_parsed(void *parsed_result,
3861 __attribute__((unused)) struct cmdline *cl,
3862 __attribute__((unused)) void *data)
3864 struct cmd_gro_result *res;
3866 res = parsed_result;
3867 setup_gro(res->mode, res->port_id);
3870 cmdline_parse_token_string_t cmd_gro_keyword =
3871 TOKEN_STRING_INITIALIZER(struct cmd_gro_result,
3872 cmd_keyword, "gro");
3873 cmdline_parse_token_string_t cmd_gro_mode =
3874 TOKEN_STRING_INITIALIZER(struct cmd_gro_result,
3876 cmdline_parse_token_num_t cmd_gro_pid =
3877 TOKEN_NUM_INITIALIZER(struct cmd_gro_result,
3880 cmdline_parse_inst_t cmd_enable_gro = {
3881 .f = cmd_enable_gro_parsed,
3883 .help_str = "gro (on|off) (port_id)",
3885 (void *)&cmd_gro_keyword,
3886 (void *)&cmd_gro_mode,
3887 (void *)&cmd_gro_pid,
3892 /* *** SET MAX FLOW NUMBER AND ITEM NUM PER FLOW FOR GRO *** */
3893 struct cmd_gro_set_result {
3894 cmdline_fixed_string_t gro;
3895 cmdline_fixed_string_t mode;
3897 uint16_t item_num_per_flow;
3902 cmd_gro_set_parsed(void *parsed_result,
3903 __attribute__((unused)) struct cmdline *cl,
3904 __attribute__((unused)) void *data)
3906 struct cmd_gro_set_result *res = parsed_result;
3908 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3910 if (test_done == 0) {
3911 printf("Before set GRO flow_num and item_num_per_flow,"
3912 " please stop forwarding first\n");
3916 if (!strcmp(res->mode, "set")) {
3917 if (res->flow_num == 0)
3918 printf("Invalid flow number. Revert to default value:"
3919 " %u.\n", GRO_DEFAULT_FLOW_NUM);
3921 gro_ports[res->port_id].param.max_flow_num =
3924 if (res->item_num_per_flow == 0)
3925 printf("Invalid item number per-flow. Revert"
3926 " to default value:%u.\n",
3927 GRO_DEFAULT_ITEM_NUM_PER_FLOW);
3929 gro_ports[res->port_id].param.max_item_per_flow =
3930 res->item_num_per_flow;
3934 cmdline_parse_token_string_t cmd_gro_set_gro =
3935 TOKEN_STRING_INITIALIZER(struct cmd_gro_set_result,
3937 cmdline_parse_token_string_t cmd_gro_set_mode =
3938 TOKEN_STRING_INITIALIZER(struct cmd_gro_set_result,
3940 cmdline_parse_token_num_t cmd_gro_set_flow_num =
3941 TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result,
3943 cmdline_parse_token_num_t cmd_gro_set_item_num_per_flow =
3944 TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result,
3945 item_num_per_flow, UINT16);
3946 cmdline_parse_token_num_t cmd_gro_set_portid =
3947 TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result,
3950 cmdline_parse_inst_t cmd_gro_set = {
3951 .f = cmd_gro_set_parsed,
3953 .help_str = "gro set <max_flow_num> <max_item_num_per_flow> "
3954 "<port_id>: set max flow number and max packet number per-flow "
3957 (void *)&cmd_gro_set_gro,
3958 (void *)&cmd_gro_set_mode,
3959 (void *)&cmd_gro_set_flow_num,
3960 (void *)&cmd_gro_set_item_num_per_flow,
3961 (void *)&cmd_gro_set_portid,
3966 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3967 struct cmd_set_flush_rx {
3968 cmdline_fixed_string_t set;
3969 cmdline_fixed_string_t flush_rx;
3970 cmdline_fixed_string_t mode;
3974 cmd_set_flush_rx_parsed(void *parsed_result,
3975 __attribute__((unused)) struct cmdline *cl,
3976 __attribute__((unused)) void *data)
3978 struct cmd_set_flush_rx *res = parsed_result;
3979 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3982 cmdline_parse_token_string_t cmd_setflushrx_set =
3983 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3985 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3986 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3987 flush_rx, "flush_rx");
3988 cmdline_parse_token_string_t cmd_setflushrx_mode =
3989 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3993 cmdline_parse_inst_t cmd_set_flush_rx = {
3994 .f = cmd_set_flush_rx_parsed,
3995 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3998 (void *)&cmd_setflushrx_set,
3999 (void *)&cmd_setflushrx_flush_rx,
4000 (void *)&cmd_setflushrx_mode,
4005 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4006 struct cmd_set_link_check {
4007 cmdline_fixed_string_t set;
4008 cmdline_fixed_string_t link_check;
4009 cmdline_fixed_string_t mode;
4013 cmd_set_link_check_parsed(void *parsed_result,
4014 __attribute__((unused)) struct cmdline *cl,
4015 __attribute__((unused)) void *data)
4017 struct cmd_set_link_check *res = parsed_result;
4018 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4021 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4022 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4024 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4025 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4026 link_check, "link_check");
4027 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4028 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4032 cmdline_parse_inst_t cmd_set_link_check = {
4033 .f = cmd_set_link_check_parsed,
4034 .help_str = "set link_check on|off: Enable/Disable link status check "
4035 "when starting/stopping a port",
4038 (void *)&cmd_setlinkcheck_set,
4039 (void *)&cmd_setlinkcheck_link_check,
4040 (void *)&cmd_setlinkcheck_mode,
4045 /* *** SET NIC BYPASS MODE *** */
4046 struct cmd_set_bypass_mode_result {
4047 cmdline_fixed_string_t set;
4048 cmdline_fixed_string_t bypass;
4049 cmdline_fixed_string_t mode;
4050 cmdline_fixed_string_t value;
4055 cmd_set_bypass_mode_parsed(void *parsed_result,
4056 __attribute__((unused)) struct cmdline *cl,
4057 __attribute__((unused)) void *data)
4059 struct cmd_set_bypass_mode_result *res = parsed_result;
4060 portid_t port_id = res->port_id;
4061 int32_t rc = -EINVAL;
4063 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4064 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4066 if (!strcmp(res->value, "bypass"))
4067 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4068 else if (!strcmp(res->value, "isolate"))
4069 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4071 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4073 /* Set the bypass mode for the relevant port. */
4074 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4077 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4080 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4081 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4083 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4084 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4086 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4087 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4089 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4090 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4091 value, "normal#bypass#isolate");
4092 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4093 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4096 cmdline_parse_inst_t cmd_set_bypass_mode = {
4097 .f = cmd_set_bypass_mode_parsed,
4098 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4099 "Set the NIC bypass mode for port_id",
4102 (void *)&cmd_setbypass_mode_set,
4103 (void *)&cmd_setbypass_mode_bypass,
4104 (void *)&cmd_setbypass_mode_mode,
4105 (void *)&cmd_setbypass_mode_value,
4106 (void *)&cmd_setbypass_mode_port,
4111 /* *** SET NIC BYPASS EVENT *** */
4112 struct cmd_set_bypass_event_result {
4113 cmdline_fixed_string_t set;
4114 cmdline_fixed_string_t bypass;
4115 cmdline_fixed_string_t event;
4116 cmdline_fixed_string_t event_value;
4117 cmdline_fixed_string_t mode;
4118 cmdline_fixed_string_t mode_value;
4123 cmd_set_bypass_event_parsed(void *parsed_result,
4124 __attribute__((unused)) struct cmdline *cl,
4125 __attribute__((unused)) void *data)
4127 int32_t rc = -EINVAL;
4128 struct cmd_set_bypass_event_result *res = parsed_result;
4129 portid_t port_id = res->port_id;
4131 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4132 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4133 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4135 if (!strcmp(res->event_value, "timeout"))
4136 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4137 else if (!strcmp(res->event_value, "os_on"))
4138 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4139 else if (!strcmp(res->event_value, "os_off"))
4140 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4141 else if (!strcmp(res->event_value, "power_on"))
4142 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4143 else if (!strcmp(res->event_value, "power_off"))
4144 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4146 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4148 if (!strcmp(res->mode_value, "bypass"))
4149 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4150 else if (!strcmp(res->mode_value, "isolate"))
4151 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4153 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4155 /* Set the watchdog timeout. */
4156 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4159 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4160 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4164 printf("Failed to set timeout value %u "
4165 "for port %d, errto code: %d.\n",
4166 bypass_timeout, port_id, rc);
4170 /* Set the bypass event to transition to bypass mode. */
4171 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4176 printf("\t Failed to set bypass event for port = %d.\n",
4180 cmdline_parse_token_string_t cmd_setbypass_event_set =
4181 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4183 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4184 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4186 cmdline_parse_token_string_t cmd_setbypass_event_event =
4187 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4189 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4190 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4191 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4192 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4193 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4195 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4196 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4197 mode_value, "normal#bypass#isolate");
4198 cmdline_parse_token_num_t cmd_setbypass_event_port =
4199 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4202 cmdline_parse_inst_t cmd_set_bypass_event = {
4203 .f = cmd_set_bypass_event_parsed,
4204 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4205 "power_off mode normal|bypass|isolate <port_id>: "
4206 "Set the NIC bypass event mode for port_id",
4209 (void *)&cmd_setbypass_event_set,
4210 (void *)&cmd_setbypass_event_bypass,
4211 (void *)&cmd_setbypass_event_event,
4212 (void *)&cmd_setbypass_event_event_value,
4213 (void *)&cmd_setbypass_event_mode,
4214 (void *)&cmd_setbypass_event_mode_value,
4215 (void *)&cmd_setbypass_event_port,
4221 /* *** SET NIC BYPASS TIMEOUT *** */
4222 struct cmd_set_bypass_timeout_result {
4223 cmdline_fixed_string_t set;
4224 cmdline_fixed_string_t bypass;
4225 cmdline_fixed_string_t timeout;
4226 cmdline_fixed_string_t value;
4230 cmd_set_bypass_timeout_parsed(void *parsed_result,
4231 __attribute__((unused)) struct cmdline *cl,
4232 __attribute__((unused)) void *data)
4234 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4236 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4237 if (!strcmp(res->value, "1.5"))
4238 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4239 else if (!strcmp(res->value, "2"))
4240 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4241 else if (!strcmp(res->value, "3"))
4242 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4243 else if (!strcmp(res->value, "4"))
4244 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4245 else if (!strcmp(res->value, "8"))
4246 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4247 else if (!strcmp(res->value, "16"))
4248 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4249 else if (!strcmp(res->value, "32"))
4250 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4252 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4256 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4257 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4259 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4260 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4262 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4263 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4264 timeout, "timeout");
4265 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4266 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4267 value, "0#1.5#2#3#4#8#16#32");
4269 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4270 .f = cmd_set_bypass_timeout_parsed,
4271 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4272 "Set the NIC bypass watchdog timeout in seconds",
4275 (void *)&cmd_setbypass_timeout_set,
4276 (void *)&cmd_setbypass_timeout_bypass,
4277 (void *)&cmd_setbypass_timeout_timeout,
4278 (void *)&cmd_setbypass_timeout_value,
4283 /* *** SHOW NIC BYPASS MODE *** */
4284 struct cmd_show_bypass_config_result {
4285 cmdline_fixed_string_t show;
4286 cmdline_fixed_string_t bypass;
4287 cmdline_fixed_string_t config;
4292 cmd_show_bypass_config_parsed(void *parsed_result,
4293 __attribute__((unused)) struct cmdline *cl,
4294 __attribute__((unused)) void *data)
4296 struct cmd_show_bypass_config_result *res = parsed_result;
4297 portid_t port_id = res->port_id;
4299 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4300 uint32_t event_mode;
4301 uint32_t bypass_mode;
4302 uint32_t timeout = bypass_timeout;
4305 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4306 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4307 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4308 {"UNKNOWN", "normal", "bypass", "isolate"};
4309 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4316 int num_events = (sizeof events) / (sizeof events[0]);
4318 /* Display the bypass mode.*/
4319 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4320 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4324 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4325 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4327 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4330 /* Display the bypass timeout.*/
4331 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4332 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4334 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4336 /* Display the bypass events and associated modes. */
4337 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4339 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4340 printf("\tFailed to get bypass mode for event = %s\n",
4343 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4344 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4346 printf("\tbypass event: %-16s = %s\n", events[i],
4352 printf("\tFailed to get bypass configuration for port = %d\n",
4356 cmdline_parse_token_string_t cmd_showbypass_config_show =
4357 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4359 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4360 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4362 cmdline_parse_token_string_t cmd_showbypass_config_config =
4363 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4365 cmdline_parse_token_num_t cmd_showbypass_config_port =
4366 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4369 cmdline_parse_inst_t cmd_show_bypass_config = {
4370 .f = cmd_show_bypass_config_parsed,
4371 .help_str = "show bypass config <port_id>: "
4372 "Show the NIC bypass config for port_id",
4375 (void *)&cmd_showbypass_config_show,
4376 (void *)&cmd_showbypass_config_bypass,
4377 (void *)&cmd_showbypass_config_config,
4378 (void *)&cmd_showbypass_config_port,
4383 #ifdef RTE_LIBRTE_PMD_BOND
4384 /* *** SET BONDING MODE *** */
4385 struct cmd_set_bonding_mode_result {
4386 cmdline_fixed_string_t set;
4387 cmdline_fixed_string_t bonding;
4388 cmdline_fixed_string_t mode;
4393 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4394 __attribute__((unused)) struct cmdline *cl,
4395 __attribute__((unused)) void *data)
4397 struct cmd_set_bonding_mode_result *res = parsed_result;
4398 portid_t port_id = res->port_id;
4400 /* Set the bonding mode for the relevant port. */
4401 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4402 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4405 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4406 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4408 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4409 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4410 bonding, "bonding");
4411 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4412 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4414 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4415 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4417 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4418 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4421 cmdline_parse_inst_t cmd_set_bonding_mode = {
4422 .f = cmd_set_bonding_mode_parsed,
4423 .help_str = "set bonding mode <mode_value> <port_id>: "
4424 "Set the bonding mode for port_id",
4427 (void *) &cmd_setbonding_mode_set,
4428 (void *) &cmd_setbonding_mode_bonding,
4429 (void *) &cmd_setbonding_mode_mode,
4430 (void *) &cmd_setbonding_mode_value,
4431 (void *) &cmd_setbonding_mode_port,
4436 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4437 struct cmd_set_bonding_lacp_dedicated_queues_result {
4438 cmdline_fixed_string_t set;
4439 cmdline_fixed_string_t bonding;
4440 cmdline_fixed_string_t lacp;
4441 cmdline_fixed_string_t dedicated_queues;
4443 cmdline_fixed_string_t mode;
4446 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4447 __attribute__((unused)) struct cmdline *cl,
4448 __attribute__((unused)) void *data)
4450 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4451 portid_t port_id = res->port_id;
4452 struct rte_port *port;
4454 port = &ports[port_id];
4456 /** Check if the port is not started **/
4457 if (port->port_status != RTE_PORT_STOPPED) {
4458 printf("Please stop port %d first\n", port_id);
4462 if (!strcmp(res->mode, "enable")) {
4463 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4464 printf("Dedicate queues for LACP control packets"
4467 printf("Enabling dedicate queues for LACP control "
4468 "packets on port %d failed\n", port_id);
4469 } else if (!strcmp(res->mode, "disable")) {
4470 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4471 printf("Dedicated queues for LACP control packets "
4474 printf("Disabling dedicated queues for LACP control "
4475 "traffic on port %d failed\n", port_id);
4479 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4480 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4482 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4483 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4484 bonding, "bonding");
4485 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4486 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4488 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4489 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4490 dedicated_queues, "dedicated_queues");
4491 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4492 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4494 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4495 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4496 mode, "enable#disable");
4498 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4499 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4500 .help_str = "set bonding lacp dedicated_queues <port_id> "
4502 "Enable/disable dedicated queues for LACP control traffic for port_id",
4505 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4506 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4507 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4508 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4509 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4510 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4515 /* *** SET BALANCE XMIT POLICY *** */
4516 struct cmd_set_bonding_balance_xmit_policy_result {
4517 cmdline_fixed_string_t set;
4518 cmdline_fixed_string_t bonding;
4519 cmdline_fixed_string_t balance_xmit_policy;
4521 cmdline_fixed_string_t policy;
4524 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4525 __attribute__((unused)) struct cmdline *cl,
4526 __attribute__((unused)) void *data)
4528 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4529 portid_t port_id = res->port_id;
4532 if (!strcmp(res->policy, "l2")) {
4533 policy = BALANCE_XMIT_POLICY_LAYER2;
4534 } else if (!strcmp(res->policy, "l23")) {
4535 policy = BALANCE_XMIT_POLICY_LAYER23;
4536 } else if (!strcmp(res->policy, "l34")) {
4537 policy = BALANCE_XMIT_POLICY_LAYER34;
4539 printf("\t Invalid xmit policy selection");
4543 /* Set the bonding mode for the relevant port. */
4544 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4545 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4550 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4551 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4553 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4554 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4555 bonding, "bonding");
4556 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4557 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4558 balance_xmit_policy, "balance_xmit_policy");
4559 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4560 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4562 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4563 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4564 policy, "l2#l23#l34");
4566 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4567 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4568 .help_str = "set bonding balance_xmit_policy <port_id> "
4570 "Set the bonding balance_xmit_policy for port_id",
4573 (void *)&cmd_setbonding_balance_xmit_policy_set,
4574 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4575 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4576 (void *)&cmd_setbonding_balance_xmit_policy_port,
4577 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4582 /* *** SHOW NIC BONDING CONFIGURATION *** */
4583 struct cmd_show_bonding_config_result {
4584 cmdline_fixed_string_t show;
4585 cmdline_fixed_string_t bonding;
4586 cmdline_fixed_string_t config;
4590 static void cmd_show_bonding_config_parsed(void *parsed_result,
4591 __attribute__((unused)) struct cmdline *cl,
4592 __attribute__((unused)) void *data)
4594 struct cmd_show_bonding_config_result *res = parsed_result;
4595 int bonding_mode, agg_mode;
4596 uint8_t slaves[RTE_MAX_ETHPORTS];
4597 int num_slaves, num_active_slaves;
4600 portid_t port_id = res->port_id;
4602 /* Display the bonding mode.*/
4603 bonding_mode = rte_eth_bond_mode_get(port_id);
4604 if (bonding_mode < 0) {
4605 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4608 printf("\tBonding mode: %d\n", bonding_mode);
4610 if (bonding_mode == BONDING_MODE_BALANCE) {
4611 int balance_xmit_policy;
4613 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4614 if (balance_xmit_policy < 0) {
4615 printf("\tFailed to get balance xmit policy for port = %d\n",
4619 printf("\tBalance Xmit Policy: ");
4621 switch (balance_xmit_policy) {
4622 case BALANCE_XMIT_POLICY_LAYER2:
4623 printf("BALANCE_XMIT_POLICY_LAYER2");
4625 case BALANCE_XMIT_POLICY_LAYER23:
4626 printf("BALANCE_XMIT_POLICY_LAYER23");
4628 case BALANCE_XMIT_POLICY_LAYER34:
4629 printf("BALANCE_XMIT_POLICY_LAYER34");
4636 if (bonding_mode == BONDING_MODE_8023AD) {
4637 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
4638 printf("\tIEEE802.3AD Aggregator Mode: ");
4641 printf("bandwidth");
4653 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4655 if (num_slaves < 0) {
4656 printf("\tFailed to get slave list for port = %d\n", port_id);
4659 if (num_slaves > 0) {
4660 printf("\tSlaves (%d): [", num_slaves);
4661 for (i = 0; i < num_slaves - 1; i++)
4662 printf("%d ", slaves[i]);
4664 printf("%d]\n", slaves[num_slaves - 1]);
4666 printf("\tSlaves: []\n");
4670 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4673 if (num_active_slaves < 0) {
4674 printf("\tFailed to get active slave list for port = %d\n", port_id);
4677 if (num_active_slaves > 0) {
4678 printf("\tActive Slaves (%d): [", num_active_slaves);
4679 for (i = 0; i < num_active_slaves - 1; i++)
4680 printf("%d ", slaves[i]);
4682 printf("%d]\n", slaves[num_active_slaves - 1]);
4685 printf("\tActive Slaves: []\n");
4689 primary_id = rte_eth_bond_primary_get(port_id);
4690 if (primary_id < 0) {
4691 printf("\tFailed to get primary slave for port = %d\n", port_id);
4694 printf("\tPrimary: [%d]\n", primary_id);
4698 cmdline_parse_token_string_t cmd_showbonding_config_show =
4699 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4701 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4702 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4703 bonding, "bonding");
4704 cmdline_parse_token_string_t cmd_showbonding_config_config =
4705 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4707 cmdline_parse_token_num_t cmd_showbonding_config_port =
4708 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4711 cmdline_parse_inst_t cmd_show_bonding_config = {
4712 .f = cmd_show_bonding_config_parsed,
4713 .help_str = "show bonding config <port_id>: "
4714 "Show the bonding config for port_id",
4717 (void *)&cmd_showbonding_config_show,
4718 (void *)&cmd_showbonding_config_bonding,
4719 (void *)&cmd_showbonding_config_config,
4720 (void *)&cmd_showbonding_config_port,
4725 /* *** SET BONDING PRIMARY *** */
4726 struct cmd_set_bonding_primary_result {
4727 cmdline_fixed_string_t set;
4728 cmdline_fixed_string_t bonding;
4729 cmdline_fixed_string_t primary;
4734 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4735 __attribute__((unused)) struct cmdline *cl,
4736 __attribute__((unused)) void *data)
4738 struct cmd_set_bonding_primary_result *res = parsed_result;
4739 portid_t master_port_id = res->port_id;
4740 portid_t slave_port_id = res->slave_id;
4742 /* Set the primary slave for a bonded device. */
4743 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4744 printf("\t Failed to set primary slave for port = %d.\n",
4751 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4752 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4754 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4755 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4756 bonding, "bonding");
4757 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4758 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4759 primary, "primary");
4760 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4761 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4763 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4764 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4767 cmdline_parse_inst_t cmd_set_bonding_primary = {
4768 .f = cmd_set_bonding_primary_parsed,
4769 .help_str = "set bonding primary <slave_id> <port_id>: "
4770 "Set the primary slave for port_id",
4773 (void *)&cmd_setbonding_primary_set,
4774 (void *)&cmd_setbonding_primary_bonding,
4775 (void *)&cmd_setbonding_primary_primary,
4776 (void *)&cmd_setbonding_primary_slave,
4777 (void *)&cmd_setbonding_primary_port,
4782 /* *** ADD SLAVE *** */
4783 struct cmd_add_bonding_slave_result {
4784 cmdline_fixed_string_t add;
4785 cmdline_fixed_string_t bonding;
4786 cmdline_fixed_string_t slave;
4791 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4792 __attribute__((unused)) struct cmdline *cl,
4793 __attribute__((unused)) void *data)
4795 struct cmd_add_bonding_slave_result *res = parsed_result;
4796 portid_t master_port_id = res->port_id;
4797 portid_t slave_port_id = res->slave_id;
4799 /* add the slave for a bonded device. */
4800 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4801 printf("\t Failed to add slave %d to master port = %d.\n",
4802 slave_port_id, master_port_id);
4806 set_port_slave_flag(slave_port_id);
4809 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4810 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4812 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4813 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4814 bonding, "bonding");
4815 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4816 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4818 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4819 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4821 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4822 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4825 cmdline_parse_inst_t cmd_add_bonding_slave = {
4826 .f = cmd_add_bonding_slave_parsed,
4827 .help_str = "add bonding slave <slave_id> <port_id>: "
4828 "Add a slave device to a bonded device",
4831 (void *)&cmd_addbonding_slave_add,
4832 (void *)&cmd_addbonding_slave_bonding,
4833 (void *)&cmd_addbonding_slave_slave,
4834 (void *)&cmd_addbonding_slave_slaveid,
4835 (void *)&cmd_addbonding_slave_port,
4840 /* *** REMOVE SLAVE *** */
4841 struct cmd_remove_bonding_slave_result {
4842 cmdline_fixed_string_t remove;
4843 cmdline_fixed_string_t bonding;
4844 cmdline_fixed_string_t slave;
4849 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4850 __attribute__((unused)) struct cmdline *cl,
4851 __attribute__((unused)) void *data)
4853 struct cmd_remove_bonding_slave_result *res = parsed_result;
4854 portid_t master_port_id = res->port_id;
4855 portid_t slave_port_id = res->slave_id;
4857 /* remove the slave from a bonded device. */
4858 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4859 printf("\t Failed to remove slave %d from master port = %d.\n",
4860 slave_port_id, master_port_id);
4864 clear_port_slave_flag(slave_port_id);
4867 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4868 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4870 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4871 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4872 bonding, "bonding");
4873 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4874 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4876 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4877 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4879 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4880 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4883 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4884 .f = cmd_remove_bonding_slave_parsed,
4885 .help_str = "remove bonding slave <slave_id> <port_id>: "
4886 "Remove a slave device from a bonded device",
4889 (void *)&cmd_removebonding_slave_remove,
4890 (void *)&cmd_removebonding_slave_bonding,
4891 (void *)&cmd_removebonding_slave_slave,
4892 (void *)&cmd_removebonding_slave_slaveid,
4893 (void *)&cmd_removebonding_slave_port,
4898 /* *** CREATE BONDED DEVICE *** */
4899 struct cmd_create_bonded_device_result {
4900 cmdline_fixed_string_t create;
4901 cmdline_fixed_string_t bonded;
4902 cmdline_fixed_string_t device;
4907 static int bond_dev_num = 0;
4909 static void cmd_create_bonded_device_parsed(void *parsed_result,
4910 __attribute__((unused)) struct cmdline *cl,
4911 __attribute__((unused)) void *data)
4913 struct cmd_create_bonded_device_result *res = parsed_result;
4914 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4917 if (test_done == 0) {
4918 printf("Please stop forwarding first\n");
4922 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
4925 /* Create a new bonded device. */
4926 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4928 printf("\t Failed to create bonded device.\n");
4931 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4934 /* Update number of ports */
4935 nb_ports = rte_eth_dev_count();
4936 reconfig(port_id, res->socket);
4937 rte_eth_promiscuous_enable(port_id);
4942 cmdline_parse_token_string_t cmd_createbonded_device_create =
4943 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4945 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4946 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4948 cmdline_parse_token_string_t cmd_createbonded_device_device =
4949 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4951 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4952 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4954 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4955 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4958 cmdline_parse_inst_t cmd_create_bonded_device = {
4959 .f = cmd_create_bonded_device_parsed,
4960 .help_str = "create bonded device <mode> <socket>: "
4961 "Create a new bonded device with specific bonding mode and socket",
4964 (void *)&cmd_createbonded_device_create,
4965 (void *)&cmd_createbonded_device_bonded,
4966 (void *)&cmd_createbonded_device_device,
4967 (void *)&cmd_createbonded_device_mode,
4968 (void *)&cmd_createbonded_device_socket,
4973 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4974 struct cmd_set_bond_mac_addr_result {
4975 cmdline_fixed_string_t set;
4976 cmdline_fixed_string_t bonding;
4977 cmdline_fixed_string_t mac_addr;
4979 struct ether_addr address;
4982 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4983 __attribute__((unused)) struct cmdline *cl,
4984 __attribute__((unused)) void *data)
4986 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4989 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4992 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4994 /* check the return value and print it if is < 0 */
4996 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4999 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5000 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5001 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5002 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5004 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5005 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5007 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5008 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
5009 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5010 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5012 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5013 .f = cmd_set_bond_mac_addr_parsed,
5015 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5017 (void *)&cmd_set_bond_mac_addr_set,
5018 (void *)&cmd_set_bond_mac_addr_bonding,
5019 (void *)&cmd_set_bond_mac_addr_mac,
5020 (void *)&cmd_set_bond_mac_addr_portnum,
5021 (void *)&cmd_set_bond_mac_addr_addr,
5027 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5028 struct cmd_set_bond_mon_period_result {
5029 cmdline_fixed_string_t set;
5030 cmdline_fixed_string_t bonding;
5031 cmdline_fixed_string_t mon_period;
5036 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5037 __attribute__((unused)) struct cmdline *cl,
5038 __attribute__((unused)) void *data)
5040 struct cmd_set_bond_mon_period_result *res = parsed_result;
5043 if (res->port_num >= nb_ports) {
5044 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5048 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5050 /* check the return value and print it if is < 0 */
5052 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5055 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5056 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5058 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5059 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5060 bonding, "bonding");
5061 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5062 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5063 mon_period, "mon_period");
5064 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5065 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5067 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5068 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5071 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5072 .f = cmd_set_bond_mon_period_parsed,
5074 .help_str = "set bonding mon_period <port_id> <period_ms>",
5076 (void *)&cmd_set_bond_mon_period_set,
5077 (void *)&cmd_set_bond_mon_period_bonding,
5078 (void *)&cmd_set_bond_mon_period_mon_period,
5079 (void *)&cmd_set_bond_mon_period_portnum,
5080 (void *)&cmd_set_bond_mon_period_period_ms,
5087 struct cmd_set_bonding_agg_mode_policy_result {
5088 cmdline_fixed_string_t set;
5089 cmdline_fixed_string_t bonding;
5090 cmdline_fixed_string_t agg_mode;
5092 cmdline_fixed_string_t policy;
5097 cmd_set_bonding_agg_mode(void *parsed_result,
5098 __attribute__((unused)) struct cmdline *cl,
5099 __attribute__((unused)) void *data)
5101 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5102 uint8_t policy = AGG_BANDWIDTH;
5104 if (res->port_num >= nb_ports) {
5105 printf("Port id %d must be less than %d\n",
5106 res->port_num, nb_ports);
5110 if (!strcmp(res->policy, "bandwidth"))
5111 policy = AGG_BANDWIDTH;
5112 else if (!strcmp(res->policy, "stable"))
5113 policy = AGG_STABLE;
5114 else if (!strcmp(res->policy, "count"))
5117 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5121 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5122 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5124 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5125 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5126 bonding, "bonding");
5128 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5129 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5130 agg_mode, "agg_mode");
5132 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5133 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5136 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5137 TOKEN_STRING_INITIALIZER(
5138 struct cmd_set_bonding_balance_xmit_policy_result,
5139 policy, "stable#bandwidth#count");
5141 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5142 .f = cmd_set_bonding_agg_mode,
5144 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5146 (void *)&cmd_set_bonding_agg_mode_set,
5147 (void *)&cmd_set_bonding_agg_mode_bonding,
5148 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5149 (void *)&cmd_set_bonding_agg_mode_portnum,
5150 (void *)&cmd_set_bonding_agg_mode_policy_string,
5156 #endif /* RTE_LIBRTE_PMD_BOND */
5158 /* *** SET FORWARDING MODE *** */
5159 struct cmd_set_fwd_mode_result {
5160 cmdline_fixed_string_t set;
5161 cmdline_fixed_string_t fwd;
5162 cmdline_fixed_string_t mode;
5165 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5166 __attribute__((unused)) struct cmdline *cl,
5167 __attribute__((unused)) void *data)
5169 struct cmd_set_fwd_mode_result *res = parsed_result;
5172 set_pkt_forwarding_mode(res->mode);
5175 cmdline_parse_token_string_t cmd_setfwd_set =
5176 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5177 cmdline_parse_token_string_t cmd_setfwd_fwd =
5178 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5179 cmdline_parse_token_string_t cmd_setfwd_mode =
5180 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5181 "" /* defined at init */);
5183 cmdline_parse_inst_t cmd_set_fwd_mode = {
5184 .f = cmd_set_fwd_mode_parsed,
5186 .help_str = NULL, /* defined at init */
5188 (void *)&cmd_setfwd_set,
5189 (void *)&cmd_setfwd_fwd,
5190 (void *)&cmd_setfwd_mode,
5195 static void cmd_set_fwd_mode_init(void)
5198 static char token[128];
5199 static char help[256];
5200 cmdline_parse_token_string_t *token_struct;
5202 modes = list_pkt_forwarding_modes();
5203 snprintf(help, sizeof(help), "set fwd %s: "
5204 "Set packet forwarding mode", modes);
5205 cmd_set_fwd_mode.help_str = help;
5207 /* string token separator is # */
5208 for (c = token; *modes != '\0'; modes++)
5213 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5214 token_struct->string_data.str = token;
5217 /* *** SET RETRY FORWARDING MODE *** */
5218 struct cmd_set_fwd_retry_mode_result {
5219 cmdline_fixed_string_t set;
5220 cmdline_fixed_string_t fwd;
5221 cmdline_fixed_string_t mode;
5222 cmdline_fixed_string_t retry;
5225 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5226 __attribute__((unused)) struct cmdline *cl,
5227 __attribute__((unused)) void *data)
5229 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5232 set_pkt_forwarding_mode(res->mode);
5235 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5236 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5238 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5239 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5241 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5242 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5244 "" /* defined at init */);
5245 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5246 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5249 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5250 .f = cmd_set_fwd_retry_mode_parsed,
5252 .help_str = NULL, /* defined at init */
5254 (void *)&cmd_setfwd_retry_set,
5255 (void *)&cmd_setfwd_retry_fwd,
5256 (void *)&cmd_setfwd_retry_mode,
5257 (void *)&cmd_setfwd_retry_retry,
5262 static void cmd_set_fwd_retry_mode_init(void)
5265 static char token[128];
5266 static char help[256];
5267 cmdline_parse_token_string_t *token_struct;
5269 modes = list_pkt_forwarding_retry_modes();
5270 snprintf(help, sizeof(help), "set fwd %s retry: "
5271 "Set packet forwarding mode with retry", modes);
5272 cmd_set_fwd_retry_mode.help_str = help;
5274 /* string token separator is # */
5275 for (c = token; *modes != '\0'; modes++)
5280 token_struct = (cmdline_parse_token_string_t *)
5281 cmd_set_fwd_retry_mode.tokens[2];
5282 token_struct->string_data.str = token;
5285 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5286 struct cmd_set_burst_tx_retry_result {
5287 cmdline_fixed_string_t set;
5288 cmdline_fixed_string_t burst;
5289 cmdline_fixed_string_t tx;
5290 cmdline_fixed_string_t delay;
5292 cmdline_fixed_string_t retry;
5296 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5297 __attribute__((unused)) struct cmdline *cl,
5298 __attribute__((unused)) void *data)
5300 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5302 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5303 && !strcmp(res->tx, "tx")) {
5304 if (!strcmp(res->delay, "delay"))
5305 burst_tx_delay_time = res->time;
5306 if (!strcmp(res->retry, "retry"))
5307 burst_tx_retry_num = res->retry_num;
5312 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5313 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5314 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5315 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5317 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5318 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5319 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5320 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5321 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5322 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5323 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5324 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5325 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5326 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5328 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5329 .f = cmd_set_burst_tx_retry_parsed,
5330 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5332 (void *)&cmd_set_burst_tx_retry_set,
5333 (void *)&cmd_set_burst_tx_retry_burst,
5334 (void *)&cmd_set_burst_tx_retry_tx,
5335 (void *)&cmd_set_burst_tx_retry_delay,
5336 (void *)&cmd_set_burst_tx_retry_time,
5337 (void *)&cmd_set_burst_tx_retry_retry,
5338 (void *)&cmd_set_burst_tx_retry_retry_num,
5343 /* *** SET PROMISC MODE *** */
5344 struct cmd_set_promisc_mode_result {
5345 cmdline_fixed_string_t set;
5346 cmdline_fixed_string_t promisc;
5347 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5348 uint8_t port_num; /* valid if "allports" argument == 0 */
5349 cmdline_fixed_string_t mode;
5352 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5353 __attribute__((unused)) struct cmdline *cl,
5356 struct cmd_set_promisc_mode_result *res = parsed_result;
5360 if (!strcmp(res->mode, "on"))
5367 RTE_ETH_FOREACH_DEV(i) {
5369 rte_eth_promiscuous_enable(i);
5371 rte_eth_promiscuous_disable(i);
5376 rte_eth_promiscuous_enable(res->port_num);
5378 rte_eth_promiscuous_disable(res->port_num);
5382 cmdline_parse_token_string_t cmd_setpromisc_set =
5383 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5384 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5385 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5387 cmdline_parse_token_string_t cmd_setpromisc_portall =
5388 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5390 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5391 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5393 cmdline_parse_token_string_t cmd_setpromisc_mode =
5394 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5397 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5398 .f = cmd_set_promisc_mode_parsed,
5400 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5402 (void *)&cmd_setpromisc_set,
5403 (void *)&cmd_setpromisc_promisc,
5404 (void *)&cmd_setpromisc_portall,
5405 (void *)&cmd_setpromisc_mode,
5410 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5411 .f = cmd_set_promisc_mode_parsed,
5413 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5415 (void *)&cmd_setpromisc_set,
5416 (void *)&cmd_setpromisc_promisc,
5417 (void *)&cmd_setpromisc_portnum,
5418 (void *)&cmd_setpromisc_mode,
5423 /* *** SET ALLMULTI MODE *** */
5424 struct cmd_set_allmulti_mode_result {
5425 cmdline_fixed_string_t set;
5426 cmdline_fixed_string_t allmulti;
5427 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5428 uint8_t port_num; /* valid if "allports" argument == 0 */
5429 cmdline_fixed_string_t mode;
5432 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5433 __attribute__((unused)) struct cmdline *cl,
5436 struct cmd_set_allmulti_mode_result *res = parsed_result;
5440 if (!strcmp(res->mode, "on"))
5447 RTE_ETH_FOREACH_DEV(i) {
5449 rte_eth_allmulticast_enable(i);
5451 rte_eth_allmulticast_disable(i);
5456 rte_eth_allmulticast_enable(res->port_num);
5458 rte_eth_allmulticast_disable(res->port_num);
5462 cmdline_parse_token_string_t cmd_setallmulti_set =
5463 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5464 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5465 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5467 cmdline_parse_token_string_t cmd_setallmulti_portall =
5468 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5470 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5471 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5473 cmdline_parse_token_string_t cmd_setallmulti_mode =
5474 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5477 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5478 .f = cmd_set_allmulti_mode_parsed,
5480 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5482 (void *)&cmd_setallmulti_set,
5483 (void *)&cmd_setallmulti_allmulti,
5484 (void *)&cmd_setallmulti_portall,
5485 (void *)&cmd_setallmulti_mode,
5490 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5491 .f = cmd_set_allmulti_mode_parsed,
5493 .help_str = "set allmulti <port_id> on|off: "
5494 "Set allmulti mode on port_id",
5496 (void *)&cmd_setallmulti_set,
5497 (void *)&cmd_setallmulti_allmulti,
5498 (void *)&cmd_setallmulti_portnum,
5499 (void *)&cmd_setallmulti_mode,
5504 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5505 struct cmd_link_flow_ctrl_set_result {
5506 cmdline_fixed_string_t set;
5507 cmdline_fixed_string_t flow_ctrl;
5508 cmdline_fixed_string_t rx;
5509 cmdline_fixed_string_t rx_lfc_mode;
5510 cmdline_fixed_string_t tx;
5511 cmdline_fixed_string_t tx_lfc_mode;
5512 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5513 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5514 cmdline_fixed_string_t autoneg_str;
5515 cmdline_fixed_string_t autoneg;
5516 cmdline_fixed_string_t hw_str;
5517 uint32_t high_water;
5518 cmdline_fixed_string_t lw_str;
5520 cmdline_fixed_string_t pt_str;
5521 uint16_t pause_time;
5522 cmdline_fixed_string_t xon_str;
5527 cmdline_parse_token_string_t cmd_lfc_set_set =
5528 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5530 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5531 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5532 flow_ctrl, "flow_ctrl");
5533 cmdline_parse_token_string_t cmd_lfc_set_rx =
5534 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5536 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5537 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5538 rx_lfc_mode, "on#off");
5539 cmdline_parse_token_string_t cmd_lfc_set_tx =
5540 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5542 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5543 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5544 tx_lfc_mode, "on#off");
5545 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5546 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5547 hw_str, "high_water");
5548 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5549 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5550 high_water, UINT32);
5551 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5552 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5553 lw_str, "low_water");
5554 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5555 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5557 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5558 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5559 pt_str, "pause_time");
5560 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5561 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5562 pause_time, UINT16);
5563 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5564 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5565 xon_str, "send_xon");
5566 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5567 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5569 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5570 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5571 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5572 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5573 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5574 mac_ctrl_frame_fwd_mode, "on#off");
5575 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5576 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5577 autoneg_str, "autoneg");
5578 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5579 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5581 cmdline_parse_token_num_t cmd_lfc_set_portid =
5582 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5585 /* forward declaration */
5587 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5590 cmdline_parse_inst_t cmd_link_flow_control_set = {
5591 .f = cmd_link_flow_ctrl_set_parsed,
5593 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5594 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5595 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5597 (void *)&cmd_lfc_set_set,
5598 (void *)&cmd_lfc_set_flow_ctrl,
5599 (void *)&cmd_lfc_set_rx,
5600 (void *)&cmd_lfc_set_rx_mode,
5601 (void *)&cmd_lfc_set_tx,
5602 (void *)&cmd_lfc_set_tx_mode,
5603 (void *)&cmd_lfc_set_high_water,
5604 (void *)&cmd_lfc_set_low_water,
5605 (void *)&cmd_lfc_set_pause_time,
5606 (void *)&cmd_lfc_set_send_xon,
5607 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5608 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5609 (void *)&cmd_lfc_set_autoneg_str,
5610 (void *)&cmd_lfc_set_autoneg,
5611 (void *)&cmd_lfc_set_portid,
5616 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5617 .f = cmd_link_flow_ctrl_set_parsed,
5618 .data = (void *)&cmd_link_flow_control_set_rx,
5619 .help_str = "set flow_ctrl rx on|off <port_id>: "
5620 "Change rx flow control parameter",
5622 (void *)&cmd_lfc_set_set,
5623 (void *)&cmd_lfc_set_flow_ctrl,
5624 (void *)&cmd_lfc_set_rx,
5625 (void *)&cmd_lfc_set_rx_mode,
5626 (void *)&cmd_lfc_set_portid,
5631 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5632 .f = cmd_link_flow_ctrl_set_parsed,
5633 .data = (void *)&cmd_link_flow_control_set_tx,
5634 .help_str = "set flow_ctrl tx on|off <port_id>: "
5635 "Change tx flow control parameter",
5637 (void *)&cmd_lfc_set_set,
5638 (void *)&cmd_lfc_set_flow_ctrl,
5639 (void *)&cmd_lfc_set_tx,
5640 (void *)&cmd_lfc_set_tx_mode,
5641 (void *)&cmd_lfc_set_portid,
5646 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5647 .f = cmd_link_flow_ctrl_set_parsed,
5648 .data = (void *)&cmd_link_flow_control_set_hw,
5649 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5650 "Change high water flow control parameter",
5652 (void *)&cmd_lfc_set_set,
5653 (void *)&cmd_lfc_set_flow_ctrl,
5654 (void *)&cmd_lfc_set_high_water_str,
5655 (void *)&cmd_lfc_set_high_water,
5656 (void *)&cmd_lfc_set_portid,
5661 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5662 .f = cmd_link_flow_ctrl_set_parsed,
5663 .data = (void *)&cmd_link_flow_control_set_lw,
5664 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5665 "Change low water flow control parameter",
5667 (void *)&cmd_lfc_set_set,
5668 (void *)&cmd_lfc_set_flow_ctrl,
5669 (void *)&cmd_lfc_set_low_water_str,
5670 (void *)&cmd_lfc_set_low_water,
5671 (void *)&cmd_lfc_set_portid,
5676 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5677 .f = cmd_link_flow_ctrl_set_parsed,
5678 .data = (void *)&cmd_link_flow_control_set_pt,
5679 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5680 "Change pause time flow control parameter",
5682 (void *)&cmd_lfc_set_set,
5683 (void *)&cmd_lfc_set_flow_ctrl,
5684 (void *)&cmd_lfc_set_pause_time_str,
5685 (void *)&cmd_lfc_set_pause_time,
5686 (void *)&cmd_lfc_set_portid,
5691 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5692 .f = cmd_link_flow_ctrl_set_parsed,
5693 .data = (void *)&cmd_link_flow_control_set_xon,
5694 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5695 "Change send_xon flow control parameter",
5697 (void *)&cmd_lfc_set_set,
5698 (void *)&cmd_lfc_set_flow_ctrl,
5699 (void *)&cmd_lfc_set_send_xon_str,
5700 (void *)&cmd_lfc_set_send_xon,
5701 (void *)&cmd_lfc_set_portid,
5706 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5707 .f = cmd_link_flow_ctrl_set_parsed,
5708 .data = (void *)&cmd_link_flow_control_set_macfwd,
5709 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5710 "Change mac ctrl fwd flow control parameter",
5712 (void *)&cmd_lfc_set_set,
5713 (void *)&cmd_lfc_set_flow_ctrl,
5714 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5715 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5716 (void *)&cmd_lfc_set_portid,
5721 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5722 .f = cmd_link_flow_ctrl_set_parsed,
5723 .data = (void *)&cmd_link_flow_control_set_autoneg,
5724 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5725 "Change autoneg flow control parameter",
5727 (void *)&cmd_lfc_set_set,
5728 (void *)&cmd_lfc_set_flow_ctrl,
5729 (void *)&cmd_lfc_set_autoneg_str,
5730 (void *)&cmd_lfc_set_autoneg,
5731 (void *)&cmd_lfc_set_portid,
5737 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5738 __attribute__((unused)) struct cmdline *cl,
5741 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5742 cmdline_parse_inst_t *cmd = data;
5743 struct rte_eth_fc_conf fc_conf;
5749 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5750 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5751 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5752 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5754 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5755 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5758 /* Partial command line, retrieve current configuration */
5760 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5762 printf("cannot get current flow ctrl parameters, return"
5763 "code = %d\n", ret);
5767 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5768 (fc_conf.mode == RTE_FC_FULL))
5770 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5771 (fc_conf.mode == RTE_FC_FULL))
5775 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5776 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5778 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5779 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5781 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5783 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5784 fc_conf.high_water = res->high_water;
5786 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5787 fc_conf.low_water = res->low_water;
5789 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5790 fc_conf.pause_time = res->pause_time;
5792 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5793 fc_conf.send_xon = res->send_xon;
5795 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5796 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5797 fc_conf.mac_ctrl_frame_fwd = 1;
5799 fc_conf.mac_ctrl_frame_fwd = 0;
5802 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5803 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5805 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5807 printf("bad flow contrl parameter, return code = %d \n", ret);
5810 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5811 struct cmd_priority_flow_ctrl_set_result {
5812 cmdline_fixed_string_t set;
5813 cmdline_fixed_string_t pfc_ctrl;
5814 cmdline_fixed_string_t rx;
5815 cmdline_fixed_string_t rx_pfc_mode;
5816 cmdline_fixed_string_t tx;
5817 cmdline_fixed_string_t tx_pfc_mode;
5818 uint32_t high_water;
5820 uint16_t pause_time;
5826 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5827 __attribute__((unused)) struct cmdline *cl,
5828 __attribute__((unused)) void *data)
5830 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5831 struct rte_eth_pfc_conf pfc_conf;
5832 int rx_fc_enable, tx_fc_enable;
5836 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5837 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5838 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5839 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5841 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5842 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5845 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5846 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5847 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5848 pfc_conf.fc.high_water = res->high_water;
5849 pfc_conf.fc.low_water = res->low_water;
5850 pfc_conf.fc.pause_time = res->pause_time;
5851 pfc_conf.priority = res->priority;
5853 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5855 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5858 cmdline_parse_token_string_t cmd_pfc_set_set =
5859 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5861 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5862 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5863 pfc_ctrl, "pfc_ctrl");
5864 cmdline_parse_token_string_t cmd_pfc_set_rx =
5865 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5867 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5868 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5869 rx_pfc_mode, "on#off");
5870 cmdline_parse_token_string_t cmd_pfc_set_tx =
5871 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5873 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5874 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5875 tx_pfc_mode, "on#off");
5876 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5877 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5878 high_water, UINT32);
5879 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5880 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5882 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5883 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5884 pause_time, UINT16);
5885 cmdline_parse_token_num_t cmd_pfc_set_priority =
5886 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5888 cmdline_parse_token_num_t cmd_pfc_set_portid =
5889 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5892 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5893 .f = cmd_priority_flow_ctrl_set_parsed,
5895 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5896 "<pause_time> <priority> <port_id>: "
5897 "Configure the Ethernet priority flow control",
5899 (void *)&cmd_pfc_set_set,
5900 (void *)&cmd_pfc_set_flow_ctrl,
5901 (void *)&cmd_pfc_set_rx,
5902 (void *)&cmd_pfc_set_rx_mode,
5903 (void *)&cmd_pfc_set_tx,
5904 (void *)&cmd_pfc_set_tx_mode,
5905 (void *)&cmd_pfc_set_high_water,
5906 (void *)&cmd_pfc_set_low_water,
5907 (void *)&cmd_pfc_set_pause_time,
5908 (void *)&cmd_pfc_set_priority,
5909 (void *)&cmd_pfc_set_portid,
5914 /* *** RESET CONFIGURATION *** */
5915 struct cmd_reset_result {
5916 cmdline_fixed_string_t reset;
5917 cmdline_fixed_string_t def;
5920 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5922 __attribute__((unused)) void *data)
5924 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5925 set_def_fwd_config();
5928 cmdline_parse_token_string_t cmd_reset_set =
5929 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5930 cmdline_parse_token_string_t cmd_reset_def =
5931 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5934 cmdline_parse_inst_t cmd_reset = {
5935 .f = cmd_reset_parsed,
5937 .help_str = "set default: Reset default forwarding configuration",
5939 (void *)&cmd_reset_set,
5940 (void *)&cmd_reset_def,
5945 /* *** START FORWARDING *** */
5946 struct cmd_start_result {
5947 cmdline_fixed_string_t start;
5950 cmdline_parse_token_string_t cmd_start_start =
5951 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5953 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5954 __attribute__((unused)) struct cmdline *cl,
5955 __attribute__((unused)) void *data)
5957 start_packet_forwarding(0);
5960 cmdline_parse_inst_t cmd_start = {
5961 .f = cmd_start_parsed,
5963 .help_str = "start: Start packet forwarding",
5965 (void *)&cmd_start_start,
5970 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5971 struct cmd_start_tx_first_result {
5972 cmdline_fixed_string_t start;
5973 cmdline_fixed_string_t tx_first;
5977 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5978 __attribute__((unused)) struct cmdline *cl,
5979 __attribute__((unused)) void *data)
5981 start_packet_forwarding(1);
5984 cmdline_parse_token_string_t cmd_start_tx_first_start =
5985 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5987 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5988 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5989 tx_first, "tx_first");
5991 cmdline_parse_inst_t cmd_start_tx_first = {
5992 .f = cmd_start_tx_first_parsed,
5994 .help_str = "start tx_first: Start packet forwarding, "
5995 "after sending 1 burst of packets",
5997 (void *)&cmd_start_tx_first_start,
5998 (void *)&cmd_start_tx_first_tx_first,
6003 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6004 struct cmd_start_tx_first_n_result {
6005 cmdline_fixed_string_t start;
6006 cmdline_fixed_string_t tx_first;
6011 cmd_start_tx_first_n_parsed(void *parsed_result,
6012 __attribute__((unused)) struct cmdline *cl,
6013 __attribute__((unused)) void *data)
6015 struct cmd_start_tx_first_n_result *res = parsed_result;
6017 start_packet_forwarding(res->tx_num);
6020 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6021 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6023 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6024 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6025 tx_first, "tx_first");
6026 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6027 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6030 cmdline_parse_inst_t cmd_start_tx_first_n = {
6031 .f = cmd_start_tx_first_n_parsed,
6033 .help_str = "start tx_first <num>: "
6034 "packet forwarding, after sending <num> bursts of packets",
6036 (void *)&cmd_start_tx_first_n_start,
6037 (void *)&cmd_start_tx_first_n_tx_first,
6038 (void *)&cmd_start_tx_first_n_tx_num,
6043 /* *** SET LINK UP *** */
6044 struct cmd_set_link_up_result {
6045 cmdline_fixed_string_t set;
6046 cmdline_fixed_string_t link_up;
6047 cmdline_fixed_string_t port;
6051 cmdline_parse_token_string_t cmd_set_link_up_set =
6052 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6053 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6054 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6056 cmdline_parse_token_string_t cmd_set_link_up_port =
6057 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6058 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6059 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
6061 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6062 __attribute__((unused)) struct cmdline *cl,
6063 __attribute__((unused)) void *data)
6065 struct cmd_set_link_up_result *res = parsed_result;
6066 dev_set_link_up(res->port_id);
6069 cmdline_parse_inst_t cmd_set_link_up = {
6070 .f = cmd_set_link_up_parsed,
6072 .help_str = "set link-up port <port id>",
6074 (void *)&cmd_set_link_up_set,
6075 (void *)&cmd_set_link_up_link_up,
6076 (void *)&cmd_set_link_up_port,
6077 (void *)&cmd_set_link_up_port_id,
6082 /* *** SET LINK DOWN *** */
6083 struct cmd_set_link_down_result {
6084 cmdline_fixed_string_t set;
6085 cmdline_fixed_string_t link_down;
6086 cmdline_fixed_string_t port;
6090 cmdline_parse_token_string_t cmd_set_link_down_set =
6091 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6092 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6093 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6095 cmdline_parse_token_string_t cmd_set_link_down_port =
6096 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6097 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6098 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
6100 static void cmd_set_link_down_parsed(
6101 __attribute__((unused)) void *parsed_result,
6102 __attribute__((unused)) struct cmdline *cl,
6103 __attribute__((unused)) void *data)
6105 struct cmd_set_link_down_result *res = parsed_result;
6106 dev_set_link_down(res->port_id);
6109 cmdline_parse_inst_t cmd_set_link_down = {
6110 .f = cmd_set_link_down_parsed,
6112 .help_str = "set link-down port <port id>",
6114 (void *)&cmd_set_link_down_set,
6115 (void *)&cmd_set_link_down_link_down,
6116 (void *)&cmd_set_link_down_port,
6117 (void *)&cmd_set_link_down_port_id,
6122 /* *** SHOW CFG *** */
6123 struct cmd_showcfg_result {
6124 cmdline_fixed_string_t show;
6125 cmdline_fixed_string_t cfg;
6126 cmdline_fixed_string_t what;
6129 static void cmd_showcfg_parsed(void *parsed_result,
6130 __attribute__((unused)) struct cmdline *cl,
6131 __attribute__((unused)) void *data)
6133 struct cmd_showcfg_result *res = parsed_result;
6134 if (!strcmp(res->what, "rxtx"))
6135 rxtx_config_display();
6136 else if (!strcmp(res->what, "cores"))
6137 fwd_lcores_config_display();
6138 else if (!strcmp(res->what, "fwd"))
6139 pkt_fwd_config_display(&cur_fwd_config);
6140 else if (!strcmp(res->what, "txpkts"))
6141 show_tx_pkt_segments();
6144 cmdline_parse_token_string_t cmd_showcfg_show =
6145 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6146 cmdline_parse_token_string_t cmd_showcfg_port =
6147 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6148 cmdline_parse_token_string_t cmd_showcfg_what =
6149 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6150 "rxtx#cores#fwd#txpkts");
6152 cmdline_parse_inst_t cmd_showcfg = {
6153 .f = cmd_showcfg_parsed,
6155 .help_str = "show config rxtx|cores|fwd|txpkts",
6157 (void *)&cmd_showcfg_show,
6158 (void *)&cmd_showcfg_port,
6159 (void *)&cmd_showcfg_what,
6164 /* *** SHOW ALL PORT INFO *** */
6165 struct cmd_showportall_result {
6166 cmdline_fixed_string_t show;
6167 cmdline_fixed_string_t port;
6168 cmdline_fixed_string_t what;
6169 cmdline_fixed_string_t all;
6172 static void cmd_showportall_parsed(void *parsed_result,
6173 __attribute__((unused)) struct cmdline *cl,
6174 __attribute__((unused)) void *data)
6178 struct cmd_showportall_result *res = parsed_result;
6179 if (!strcmp(res->show, "clear")) {
6180 if (!strcmp(res->what, "stats"))
6181 RTE_ETH_FOREACH_DEV(i)
6183 else if (!strcmp(res->what, "xstats"))
6184 RTE_ETH_FOREACH_DEV(i)
6185 nic_xstats_clear(i);
6186 } else if (!strcmp(res->what, "info"))
6187 RTE_ETH_FOREACH_DEV(i)
6188 port_infos_display(i);
6189 else if (!strcmp(res->what, "stats"))
6190 RTE_ETH_FOREACH_DEV(i)
6191 nic_stats_display(i);
6192 else if (!strcmp(res->what, "xstats"))
6193 RTE_ETH_FOREACH_DEV(i)
6194 nic_xstats_display(i);
6195 else if (!strcmp(res->what, "fdir"))
6196 RTE_ETH_FOREACH_DEV(i)
6198 else if (!strcmp(res->what, "stat_qmap"))
6199 RTE_ETH_FOREACH_DEV(i)
6200 nic_stats_mapping_display(i);
6201 else if (!strcmp(res->what, "dcb_tc"))
6202 RTE_ETH_FOREACH_DEV(i)
6203 port_dcb_info_display(i);
6204 else if (!strcmp(res->what, "cap"))
6205 RTE_ETH_FOREACH_DEV(i)
6206 port_offload_cap_display(i);
6209 cmdline_parse_token_string_t cmd_showportall_show =
6210 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6212 cmdline_parse_token_string_t cmd_showportall_port =
6213 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6214 cmdline_parse_token_string_t cmd_showportall_what =
6215 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6216 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6217 cmdline_parse_token_string_t cmd_showportall_all =
6218 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6219 cmdline_parse_inst_t cmd_showportall = {
6220 .f = cmd_showportall_parsed,
6222 .help_str = "show|clear port "
6223 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6225 (void *)&cmd_showportall_show,
6226 (void *)&cmd_showportall_port,
6227 (void *)&cmd_showportall_what,
6228 (void *)&cmd_showportall_all,
6233 /* *** SHOW PORT INFO *** */
6234 struct cmd_showport_result {
6235 cmdline_fixed_string_t show;
6236 cmdline_fixed_string_t port;
6237 cmdline_fixed_string_t what;
6241 static void cmd_showport_parsed(void *parsed_result,
6242 __attribute__((unused)) struct cmdline *cl,
6243 __attribute__((unused)) void *data)
6245 struct cmd_showport_result *res = parsed_result;
6246 if (!strcmp(res->show, "clear")) {
6247 if (!strcmp(res->what, "stats"))
6248 nic_stats_clear(res->portnum);
6249 else if (!strcmp(res->what, "xstats"))
6250 nic_xstats_clear(res->portnum);
6251 } else if (!strcmp(res->what, "info"))
6252 port_infos_display(res->portnum);
6253 else if (!strcmp(res->what, "stats"))
6254 nic_stats_display(res->portnum);
6255 else if (!strcmp(res->what, "xstats"))
6256 nic_xstats_display(res->portnum);
6257 else if (!strcmp(res->what, "fdir"))
6258 fdir_get_infos(res->portnum);
6259 else if (!strcmp(res->what, "stat_qmap"))
6260 nic_stats_mapping_display(res->portnum);
6261 else if (!strcmp(res->what, "dcb_tc"))
6262 port_dcb_info_display(res->portnum);
6263 else if (!strcmp(res->what, "cap"))
6264 port_offload_cap_display(res->portnum);
6267 cmdline_parse_token_string_t cmd_showport_show =
6268 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6270 cmdline_parse_token_string_t cmd_showport_port =
6271 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6272 cmdline_parse_token_string_t cmd_showport_what =
6273 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6274 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6275 cmdline_parse_token_num_t cmd_showport_portnum =
6276 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
6278 cmdline_parse_inst_t cmd_showport = {
6279 .f = cmd_showport_parsed,
6281 .help_str = "show|clear port "
6282 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6285 (void *)&cmd_showport_show,
6286 (void *)&cmd_showport_port,
6287 (void *)&cmd_showport_what,
6288 (void *)&cmd_showport_portnum,
6293 /* *** SHOW QUEUE INFO *** */
6294 struct cmd_showqueue_result {
6295 cmdline_fixed_string_t show;
6296 cmdline_fixed_string_t type;
6297 cmdline_fixed_string_t what;
6303 cmd_showqueue_parsed(void *parsed_result,
6304 __attribute__((unused)) struct cmdline *cl,
6305 __attribute__((unused)) void *data)
6307 struct cmd_showqueue_result *res = parsed_result;
6309 if (!strcmp(res->type, "rxq"))
6310 rx_queue_infos_display(res->portnum, res->queuenum);
6311 else if (!strcmp(res->type, "txq"))
6312 tx_queue_infos_display(res->portnum, res->queuenum);
6315 cmdline_parse_token_string_t cmd_showqueue_show =
6316 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6317 cmdline_parse_token_string_t cmd_showqueue_type =
6318 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6319 cmdline_parse_token_string_t cmd_showqueue_what =
6320 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6321 cmdline_parse_token_num_t cmd_showqueue_portnum =
6322 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6323 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6324 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6326 cmdline_parse_inst_t cmd_showqueue = {
6327 .f = cmd_showqueue_parsed,
6329 .help_str = "show rxq|txq info <port_id> <queue_id>",
6331 (void *)&cmd_showqueue_show,
6332 (void *)&cmd_showqueue_type,
6333 (void *)&cmd_showqueue_what,
6334 (void *)&cmd_showqueue_portnum,
6335 (void *)&cmd_showqueue_queuenum,
6340 /* *** READ PORT REGISTER *** */
6341 struct cmd_read_reg_result {
6342 cmdline_fixed_string_t read;
6343 cmdline_fixed_string_t reg;
6349 cmd_read_reg_parsed(void *parsed_result,
6350 __attribute__((unused)) struct cmdline *cl,
6351 __attribute__((unused)) void *data)
6353 struct cmd_read_reg_result *res = parsed_result;
6354 port_reg_display(res->port_id, res->reg_off);
6357 cmdline_parse_token_string_t cmd_read_reg_read =
6358 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6359 cmdline_parse_token_string_t cmd_read_reg_reg =
6360 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6361 cmdline_parse_token_num_t cmd_read_reg_port_id =
6362 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6363 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6364 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6366 cmdline_parse_inst_t cmd_read_reg = {
6367 .f = cmd_read_reg_parsed,
6369 .help_str = "read reg <port_id> <reg_off>",
6371 (void *)&cmd_read_reg_read,
6372 (void *)&cmd_read_reg_reg,
6373 (void *)&cmd_read_reg_port_id,
6374 (void *)&cmd_read_reg_reg_off,
6379 /* *** READ PORT REGISTER BIT FIELD *** */
6380 struct cmd_read_reg_bit_field_result {
6381 cmdline_fixed_string_t read;
6382 cmdline_fixed_string_t regfield;
6390 cmd_read_reg_bit_field_parsed(void *parsed_result,
6391 __attribute__((unused)) struct cmdline *cl,
6392 __attribute__((unused)) void *data)
6394 struct cmd_read_reg_bit_field_result *res = parsed_result;
6395 port_reg_bit_field_display(res->port_id, res->reg_off,
6396 res->bit1_pos, res->bit2_pos);
6399 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6400 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6402 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6403 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6404 regfield, "regfield");
6405 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6406 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6408 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6409 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6411 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6412 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6414 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6415 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6418 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6419 .f = cmd_read_reg_bit_field_parsed,
6421 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6422 "Read register bit field between bit_x and bit_y included",
6424 (void *)&cmd_read_reg_bit_field_read,
6425 (void *)&cmd_read_reg_bit_field_regfield,
6426 (void *)&cmd_read_reg_bit_field_port_id,
6427 (void *)&cmd_read_reg_bit_field_reg_off,
6428 (void *)&cmd_read_reg_bit_field_bit1_pos,
6429 (void *)&cmd_read_reg_bit_field_bit2_pos,
6434 /* *** READ PORT REGISTER BIT *** */
6435 struct cmd_read_reg_bit_result {
6436 cmdline_fixed_string_t read;
6437 cmdline_fixed_string_t regbit;
6444 cmd_read_reg_bit_parsed(void *parsed_result,
6445 __attribute__((unused)) struct cmdline *cl,
6446 __attribute__((unused)) void *data)
6448 struct cmd_read_reg_bit_result *res = parsed_result;
6449 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6452 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6453 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6454 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6455 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6457 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6458 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6459 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6460 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6461 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6462 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6464 cmdline_parse_inst_t cmd_read_reg_bit = {
6465 .f = cmd_read_reg_bit_parsed,
6467 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6469 (void *)&cmd_read_reg_bit_read,
6470 (void *)&cmd_read_reg_bit_regbit,
6471 (void *)&cmd_read_reg_bit_port_id,
6472 (void *)&cmd_read_reg_bit_reg_off,
6473 (void *)&cmd_read_reg_bit_bit_pos,
6478 /* *** WRITE PORT REGISTER *** */
6479 struct cmd_write_reg_result {
6480 cmdline_fixed_string_t write;
6481 cmdline_fixed_string_t reg;
6488 cmd_write_reg_parsed(void *parsed_result,
6489 __attribute__((unused)) struct cmdline *cl,
6490 __attribute__((unused)) void *data)
6492 struct cmd_write_reg_result *res = parsed_result;
6493 port_reg_set(res->port_id, res->reg_off, res->value);
6496 cmdline_parse_token_string_t cmd_write_reg_write =
6497 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6498 cmdline_parse_token_string_t cmd_write_reg_reg =
6499 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6500 cmdline_parse_token_num_t cmd_write_reg_port_id =
6501 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6502 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6503 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6504 cmdline_parse_token_num_t cmd_write_reg_value =
6505 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6507 cmdline_parse_inst_t cmd_write_reg = {
6508 .f = cmd_write_reg_parsed,
6510 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6512 (void *)&cmd_write_reg_write,
6513 (void *)&cmd_write_reg_reg,
6514 (void *)&cmd_write_reg_port_id,
6515 (void *)&cmd_write_reg_reg_off,
6516 (void *)&cmd_write_reg_value,
6521 /* *** WRITE PORT REGISTER BIT FIELD *** */
6522 struct cmd_write_reg_bit_field_result {
6523 cmdline_fixed_string_t write;
6524 cmdline_fixed_string_t regfield;
6533 cmd_write_reg_bit_field_parsed(void *parsed_result,
6534 __attribute__((unused)) struct cmdline *cl,
6535 __attribute__((unused)) void *data)
6537 struct cmd_write_reg_bit_field_result *res = parsed_result;
6538 port_reg_bit_field_set(res->port_id, res->reg_off,
6539 res->bit1_pos, res->bit2_pos, res->value);
6542 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6543 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6545 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6546 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6547 regfield, "regfield");
6548 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6549 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6551 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6552 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6554 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6555 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6557 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6558 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6560 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6561 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6564 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6565 .f = cmd_write_reg_bit_field_parsed,
6567 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6569 "Set register bit field between bit_x and bit_y included",
6571 (void *)&cmd_write_reg_bit_field_write,
6572 (void *)&cmd_write_reg_bit_field_regfield,
6573 (void *)&cmd_write_reg_bit_field_port_id,
6574 (void *)&cmd_write_reg_bit_field_reg_off,
6575 (void *)&cmd_write_reg_bit_field_bit1_pos,
6576 (void *)&cmd_write_reg_bit_field_bit2_pos,
6577 (void *)&cmd_write_reg_bit_field_value,
6582 /* *** WRITE PORT REGISTER BIT *** */
6583 struct cmd_write_reg_bit_result {
6584 cmdline_fixed_string_t write;
6585 cmdline_fixed_string_t regbit;
6593 cmd_write_reg_bit_parsed(void *parsed_result,
6594 __attribute__((unused)) struct cmdline *cl,
6595 __attribute__((unused)) void *data)
6597 struct cmd_write_reg_bit_result *res = parsed_result;
6598 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6601 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6602 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6604 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6605 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6607 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6608 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6609 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6610 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6611 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6612 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6613 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6614 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6616 cmdline_parse_inst_t cmd_write_reg_bit = {
6617 .f = cmd_write_reg_bit_parsed,
6619 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6622 (void *)&cmd_write_reg_bit_write,
6623 (void *)&cmd_write_reg_bit_regbit,
6624 (void *)&cmd_write_reg_bit_port_id,
6625 (void *)&cmd_write_reg_bit_reg_off,
6626 (void *)&cmd_write_reg_bit_bit_pos,
6627 (void *)&cmd_write_reg_bit_value,
6632 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6633 struct cmd_read_rxd_txd_result {
6634 cmdline_fixed_string_t read;
6635 cmdline_fixed_string_t rxd_txd;
6642 cmd_read_rxd_txd_parsed(void *parsed_result,
6643 __attribute__((unused)) struct cmdline *cl,
6644 __attribute__((unused)) void *data)
6646 struct cmd_read_rxd_txd_result *res = parsed_result;
6648 if (!strcmp(res->rxd_txd, "rxd"))
6649 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6650 else if (!strcmp(res->rxd_txd, "txd"))
6651 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6654 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6655 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6656 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6657 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6659 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6660 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6661 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6662 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6663 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6664 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6666 cmdline_parse_inst_t cmd_read_rxd_txd = {
6667 .f = cmd_read_rxd_txd_parsed,
6669 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6671 (void *)&cmd_read_rxd_txd_read,
6672 (void *)&cmd_read_rxd_txd_rxd_txd,
6673 (void *)&cmd_read_rxd_txd_port_id,
6674 (void *)&cmd_read_rxd_txd_queue_id,
6675 (void *)&cmd_read_rxd_txd_desc_id,
6681 struct cmd_quit_result {
6682 cmdline_fixed_string_t quit;
6685 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6687 __attribute__((unused)) void *data)
6693 cmdline_parse_token_string_t cmd_quit_quit =
6694 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6696 cmdline_parse_inst_t cmd_quit = {
6697 .f = cmd_quit_parsed,
6699 .help_str = "quit: Exit application",
6701 (void *)&cmd_quit_quit,
6706 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6707 struct cmd_mac_addr_result {
6708 cmdline_fixed_string_t mac_addr_cmd;
6709 cmdline_fixed_string_t what;
6711 struct ether_addr address;
6714 static void cmd_mac_addr_parsed(void *parsed_result,
6715 __attribute__((unused)) struct cmdline *cl,
6716 __attribute__((unused)) void *data)
6718 struct cmd_mac_addr_result *res = parsed_result;
6721 if (strcmp(res->what, "add") == 0)
6722 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6723 else if (strcmp(res->what, "set") == 0)
6724 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6727 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6729 /* check the return value and print it if is < 0 */
6731 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6735 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6736 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6738 cmdline_parse_token_string_t cmd_mac_addr_what =
6739 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6741 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6742 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6743 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6744 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6746 cmdline_parse_inst_t cmd_mac_addr = {
6747 .f = cmd_mac_addr_parsed,
6749 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6750 "Add/Remove/Set MAC address on port_id",
6752 (void *)&cmd_mac_addr_cmd,
6753 (void *)&cmd_mac_addr_what,
6754 (void *)&cmd_mac_addr_portnum,
6755 (void *)&cmd_mac_addr_addr,
6761 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6762 struct cmd_set_qmap_result {
6763 cmdline_fixed_string_t set;
6764 cmdline_fixed_string_t qmap;
6765 cmdline_fixed_string_t what;
6772 cmd_set_qmap_parsed(void *parsed_result,
6773 __attribute__((unused)) struct cmdline *cl,
6774 __attribute__((unused)) void *data)
6776 struct cmd_set_qmap_result *res = parsed_result;
6777 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6779 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6782 cmdline_parse_token_string_t cmd_setqmap_set =
6783 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6785 cmdline_parse_token_string_t cmd_setqmap_qmap =
6786 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6788 cmdline_parse_token_string_t cmd_setqmap_what =
6789 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6791 cmdline_parse_token_num_t cmd_setqmap_portid =
6792 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6794 cmdline_parse_token_num_t cmd_setqmap_queueid =
6795 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6797 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6798 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6801 cmdline_parse_inst_t cmd_set_qmap = {
6802 .f = cmd_set_qmap_parsed,
6804 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6805 "Set statistics mapping value on tx|rx queue_id of port_id",
6807 (void *)&cmd_setqmap_set,
6808 (void *)&cmd_setqmap_qmap,
6809 (void *)&cmd_setqmap_what,
6810 (void *)&cmd_setqmap_portid,
6811 (void *)&cmd_setqmap_queueid,
6812 (void *)&cmd_setqmap_mapvalue,
6817 /* *** CONFIGURE UNICAST HASH TABLE *** */
6818 struct cmd_set_uc_hash_table {
6819 cmdline_fixed_string_t set;
6820 cmdline_fixed_string_t port;
6822 cmdline_fixed_string_t what;
6823 struct ether_addr address;
6824 cmdline_fixed_string_t mode;
6828 cmd_set_uc_hash_parsed(void *parsed_result,
6829 __attribute__((unused)) struct cmdline *cl,
6830 __attribute__((unused)) void *data)
6833 struct cmd_set_uc_hash_table *res = parsed_result;
6835 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6837 if (strcmp(res->what, "uta") == 0)
6838 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6839 &res->address,(uint8_t)is_on);
6841 printf("bad unicast hash table parameter, return code = %d \n", ret);
6845 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6846 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6848 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6849 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6851 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6852 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6854 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6855 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6857 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6858 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6860 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6861 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6864 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6865 .f = cmd_set_uc_hash_parsed,
6867 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6869 (void *)&cmd_set_uc_hash_set,
6870 (void *)&cmd_set_uc_hash_port,
6871 (void *)&cmd_set_uc_hash_portid,
6872 (void *)&cmd_set_uc_hash_what,
6873 (void *)&cmd_set_uc_hash_mac,
6874 (void *)&cmd_set_uc_hash_mode,
6879 struct cmd_set_uc_all_hash_table {
6880 cmdline_fixed_string_t set;
6881 cmdline_fixed_string_t port;
6883 cmdline_fixed_string_t what;
6884 cmdline_fixed_string_t value;
6885 cmdline_fixed_string_t mode;
6889 cmd_set_uc_all_hash_parsed(void *parsed_result,
6890 __attribute__((unused)) struct cmdline *cl,
6891 __attribute__((unused)) void *data)
6894 struct cmd_set_uc_all_hash_table *res = parsed_result;
6896 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6898 if ((strcmp(res->what, "uta") == 0) &&
6899 (strcmp(res->value, "all") == 0))
6900 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6902 printf("bad unicast hash table parameter,"
6903 "return code = %d \n", ret);
6906 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6907 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6909 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6910 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6912 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6913 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6915 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6916 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6918 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6919 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6921 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6922 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6925 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6926 .f = cmd_set_uc_all_hash_parsed,
6928 .help_str = "set port <port_id> uta all on|off",
6930 (void *)&cmd_set_uc_all_hash_set,
6931 (void *)&cmd_set_uc_all_hash_port,
6932 (void *)&cmd_set_uc_all_hash_portid,
6933 (void *)&cmd_set_uc_all_hash_what,
6934 (void *)&cmd_set_uc_all_hash_value,
6935 (void *)&cmd_set_uc_all_hash_mode,
6940 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6941 struct cmd_set_vf_macvlan_filter {
6942 cmdline_fixed_string_t set;
6943 cmdline_fixed_string_t port;
6945 cmdline_fixed_string_t vf;
6947 struct ether_addr address;
6948 cmdline_fixed_string_t filter_type;
6949 cmdline_fixed_string_t mode;
6953 cmd_set_vf_macvlan_parsed(void *parsed_result,
6954 __attribute__((unused)) struct cmdline *cl,
6955 __attribute__((unused)) void *data)
6958 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6959 struct rte_eth_mac_filter filter;
6961 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6963 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6965 /* set VF MAC filter */
6969 filter.dst_id = res->vf_id;
6971 if (!strcmp(res->filter_type, "exact-mac"))
6972 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6973 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6974 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6975 else if (!strcmp(res->filter_type, "hashmac"))
6976 filter.filter_type = RTE_MAC_HASH_MATCH;
6977 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6978 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6980 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6983 ret = rte_eth_dev_filter_ctrl(res->port_id,
6984 RTE_ETH_FILTER_MACVLAN,
6988 ret = rte_eth_dev_filter_ctrl(res->port_id,
6989 RTE_ETH_FILTER_MACVLAN,
6990 RTE_ETH_FILTER_DELETE,
6994 printf("bad set MAC hash parameter, return code = %d\n", ret);
6998 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6999 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7001 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7002 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7004 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7005 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7007 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7008 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7010 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7011 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7013 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7014 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7016 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7017 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7018 filter_type, "exact-mac#exact-mac-vlan"
7019 "#hashmac#hashmac-vlan");
7020 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7021 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7024 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7025 .f = cmd_set_vf_macvlan_parsed,
7027 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7028 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7029 "Exact match rule: exact match of MAC or MAC and VLAN; "
7030 "hash match rule: hash match of MAC and exact match of VLAN",
7032 (void *)&cmd_set_vf_macvlan_set,
7033 (void *)&cmd_set_vf_macvlan_port,
7034 (void *)&cmd_set_vf_macvlan_portid,
7035 (void *)&cmd_set_vf_macvlan_vf,
7036 (void *)&cmd_set_vf_macvlan_vf_id,
7037 (void *)&cmd_set_vf_macvlan_mac,
7038 (void *)&cmd_set_vf_macvlan_filter_type,
7039 (void *)&cmd_set_vf_macvlan_mode,
7044 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7045 struct cmd_set_vf_traffic {
7046 cmdline_fixed_string_t set;
7047 cmdline_fixed_string_t port;
7049 cmdline_fixed_string_t vf;
7051 cmdline_fixed_string_t what;
7052 cmdline_fixed_string_t mode;
7056 cmd_set_vf_traffic_parsed(void *parsed_result,
7057 __attribute__((unused)) struct cmdline *cl,
7058 __attribute__((unused)) void *data)
7060 struct cmd_set_vf_traffic *res = parsed_result;
7061 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7062 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7064 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7067 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7068 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7070 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7071 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7073 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7074 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7076 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7077 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7079 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7080 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7082 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7083 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7085 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7086 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7089 cmdline_parse_inst_t cmd_set_vf_traffic = {
7090 .f = cmd_set_vf_traffic_parsed,
7092 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7094 (void *)&cmd_setvf_traffic_set,
7095 (void *)&cmd_setvf_traffic_port,
7096 (void *)&cmd_setvf_traffic_portid,
7097 (void *)&cmd_setvf_traffic_vf,
7098 (void *)&cmd_setvf_traffic_vfid,
7099 (void *)&cmd_setvf_traffic_what,
7100 (void *)&cmd_setvf_traffic_mode,
7105 /* *** CONFIGURE VF RECEIVE MODE *** */
7106 struct cmd_set_vf_rxmode {
7107 cmdline_fixed_string_t set;
7108 cmdline_fixed_string_t port;
7110 cmdline_fixed_string_t vf;
7112 cmdline_fixed_string_t what;
7113 cmdline_fixed_string_t mode;
7114 cmdline_fixed_string_t on;
7118 cmd_set_vf_rxmode_parsed(void *parsed_result,
7119 __attribute__((unused)) struct cmdline *cl,
7120 __attribute__((unused)) void *data)
7123 uint16_t rx_mode = 0;
7124 struct cmd_set_vf_rxmode *res = parsed_result;
7126 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7127 if (!strcmp(res->what,"rxmode")) {
7128 if (!strcmp(res->mode, "AUPE"))
7129 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7130 else if (!strcmp(res->mode, "ROPE"))
7131 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7132 else if (!strcmp(res->mode, "BAM"))
7133 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7134 else if (!strncmp(res->mode, "MPE",3))
7135 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7138 #ifdef RTE_LIBRTE_IXGBE_PMD
7139 if (ret == -ENOTSUP)
7140 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7141 rx_mode, (uint8_t)is_on);
7143 #ifdef RTE_LIBRTE_BNXT_PMD
7144 if (ret == -ENOTSUP)
7145 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7146 rx_mode, (uint8_t)is_on);
7149 printf("bad VF receive mode parameter, return code = %d \n",
7153 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7154 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7156 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7157 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7159 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7160 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7162 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7163 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7165 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7166 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7168 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7169 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7171 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7172 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7173 mode, "AUPE#ROPE#BAM#MPE");
7174 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7175 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7178 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7179 .f = cmd_set_vf_rxmode_parsed,
7181 .help_str = "set port <port_id> vf <vf_id> rxmode "
7182 "AUPE|ROPE|BAM|MPE on|off",
7184 (void *)&cmd_set_vf_rxmode_set,
7185 (void *)&cmd_set_vf_rxmode_port,
7186 (void *)&cmd_set_vf_rxmode_portid,
7187 (void *)&cmd_set_vf_rxmode_vf,
7188 (void *)&cmd_set_vf_rxmode_vfid,
7189 (void *)&cmd_set_vf_rxmode_what,
7190 (void *)&cmd_set_vf_rxmode_mode,
7191 (void *)&cmd_set_vf_rxmode_on,
7196 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7197 struct cmd_vf_mac_addr_result {
7198 cmdline_fixed_string_t mac_addr_cmd;
7199 cmdline_fixed_string_t what;
7200 cmdline_fixed_string_t port;
7202 cmdline_fixed_string_t vf;
7204 struct ether_addr address;
7207 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7208 __attribute__((unused)) struct cmdline *cl,
7209 __attribute__((unused)) void *data)
7211 struct cmd_vf_mac_addr_result *res = parsed_result;
7214 if (strcmp(res->what, "add") == 0)
7215 ret = rte_eth_dev_mac_addr_add(res->port_num,
7216 &res->address, res->vf_num);
7218 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7222 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7223 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7224 mac_addr_cmd,"mac_addr");
7225 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7226 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7228 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7229 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7231 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7232 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7234 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7235 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7237 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7238 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7240 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7241 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7244 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7245 .f = cmd_vf_mac_addr_parsed,
7247 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7248 "Add MAC address filtering for a VF on port_id",
7250 (void *)&cmd_vf_mac_addr_cmd,
7251 (void *)&cmd_vf_mac_addr_what,
7252 (void *)&cmd_vf_mac_addr_port,
7253 (void *)&cmd_vf_mac_addr_portnum,
7254 (void *)&cmd_vf_mac_addr_vf,
7255 (void *)&cmd_vf_mac_addr_vfnum,
7256 (void *)&cmd_vf_mac_addr_addr,
7261 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7262 struct cmd_vf_rx_vlan_filter {
7263 cmdline_fixed_string_t rx_vlan;
7264 cmdline_fixed_string_t what;
7266 cmdline_fixed_string_t port;
7268 cmdline_fixed_string_t vf;
7273 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7274 __attribute__((unused)) struct cmdline *cl,
7275 __attribute__((unused)) void *data)
7277 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7280 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7282 #ifdef RTE_LIBRTE_IXGBE_PMD
7283 if (ret == -ENOTSUP)
7284 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7285 res->vlan_id, res->vf_mask, is_add);
7287 #ifdef RTE_LIBRTE_I40E_PMD
7288 if (ret == -ENOTSUP)
7289 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7290 res->vlan_id, res->vf_mask, is_add);
7292 #ifdef RTE_LIBRTE_BNXT_PMD
7293 if (ret == -ENOTSUP)
7294 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7295 res->vlan_id, res->vf_mask, is_add);
7302 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7303 res->vlan_id, res->vf_mask);
7306 printf("invalid port_id %d\n", res->port_id);
7309 printf("function not implemented or supported\n");
7312 printf("programming error: (%s)\n", strerror(-ret));
7316 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7317 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7318 rx_vlan, "rx_vlan");
7319 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7320 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7322 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7323 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7325 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7326 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7328 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7329 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7331 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7332 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7334 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7335 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7338 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7339 .f = cmd_vf_rx_vlan_filter_parsed,
7341 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7342 "(vf_mask = hexadecimal VF mask)",
7344 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7345 (void *)&cmd_vf_rx_vlan_filter_what,
7346 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7347 (void *)&cmd_vf_rx_vlan_filter_port,
7348 (void *)&cmd_vf_rx_vlan_filter_portid,
7349 (void *)&cmd_vf_rx_vlan_filter_vf,
7350 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7355 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7356 struct cmd_queue_rate_limit_result {
7357 cmdline_fixed_string_t set;
7358 cmdline_fixed_string_t port;
7360 cmdline_fixed_string_t queue;
7362 cmdline_fixed_string_t rate;
7366 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7367 __attribute__((unused)) struct cmdline *cl,
7368 __attribute__((unused)) void *data)
7370 struct cmd_queue_rate_limit_result *res = parsed_result;
7373 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7374 && (strcmp(res->queue, "queue") == 0)
7375 && (strcmp(res->rate, "rate") == 0))
7376 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7379 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7383 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7384 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7386 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7387 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7389 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7390 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7392 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7393 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7395 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7396 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7398 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7399 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7401 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7402 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7405 cmdline_parse_inst_t cmd_queue_rate_limit = {
7406 .f = cmd_queue_rate_limit_parsed,
7408 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7409 "Set rate limit for a queue on port_id",
7411 (void *)&cmd_queue_rate_limit_set,
7412 (void *)&cmd_queue_rate_limit_port,
7413 (void *)&cmd_queue_rate_limit_portnum,
7414 (void *)&cmd_queue_rate_limit_queue,
7415 (void *)&cmd_queue_rate_limit_queuenum,
7416 (void *)&cmd_queue_rate_limit_rate,
7417 (void *)&cmd_queue_rate_limit_ratenum,
7422 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7423 struct cmd_vf_rate_limit_result {
7424 cmdline_fixed_string_t set;
7425 cmdline_fixed_string_t port;
7427 cmdline_fixed_string_t vf;
7429 cmdline_fixed_string_t rate;
7431 cmdline_fixed_string_t q_msk;
7435 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7436 __attribute__((unused)) struct cmdline *cl,
7437 __attribute__((unused)) void *data)
7439 struct cmd_vf_rate_limit_result *res = parsed_result;
7442 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7443 && (strcmp(res->vf, "vf") == 0)
7444 && (strcmp(res->rate, "rate") == 0)
7445 && (strcmp(res->q_msk, "queue_mask") == 0))
7446 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7447 res->rate_num, res->q_msk_val);
7449 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7453 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7454 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7456 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7457 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7459 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7460 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7462 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7463 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7465 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7466 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7468 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7469 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7471 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7472 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7474 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7475 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7476 q_msk, "queue_mask");
7477 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7478 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7481 cmdline_parse_inst_t cmd_vf_rate_limit = {
7482 .f = cmd_vf_rate_limit_parsed,
7484 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7485 "queue_mask <queue_mask_value>: "
7486 "Set rate limit for queues of VF on port_id",
7488 (void *)&cmd_vf_rate_limit_set,
7489 (void *)&cmd_vf_rate_limit_port,
7490 (void *)&cmd_vf_rate_limit_portnum,
7491 (void *)&cmd_vf_rate_limit_vf,
7492 (void *)&cmd_vf_rate_limit_vfnum,
7493 (void *)&cmd_vf_rate_limit_rate,
7494 (void *)&cmd_vf_rate_limit_ratenum,
7495 (void *)&cmd_vf_rate_limit_q_msk,
7496 (void *)&cmd_vf_rate_limit_q_msk_val,
7501 /* *** ADD TUNNEL FILTER OF A PORT *** */
7502 struct cmd_tunnel_filter_result {
7503 cmdline_fixed_string_t cmd;
7504 cmdline_fixed_string_t what;
7506 struct ether_addr outer_mac;
7507 struct ether_addr inner_mac;
7508 cmdline_ipaddr_t ip_value;
7509 uint16_t inner_vlan;
7510 cmdline_fixed_string_t tunnel_type;
7511 cmdline_fixed_string_t filter_type;
7517 cmd_tunnel_filter_parsed(void *parsed_result,
7518 __attribute__((unused)) struct cmdline *cl,
7519 __attribute__((unused)) void *data)
7521 struct cmd_tunnel_filter_result *res = parsed_result;
7522 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7525 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7527 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7528 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7529 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7531 if (res->ip_value.family == AF_INET) {
7532 tunnel_filter_conf.ip_addr.ipv4_addr =
7533 res->ip_value.addr.ipv4.s_addr;
7534 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7536 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7537 &(res->ip_value.addr.ipv6),
7538 sizeof(struct in6_addr));
7539 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7542 if (!strcmp(res->filter_type, "imac-ivlan"))
7543 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7544 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7545 tunnel_filter_conf.filter_type =
7546 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7547 else if (!strcmp(res->filter_type, "imac-tenid"))
7548 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7549 else if (!strcmp(res->filter_type, "imac"))
7550 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7551 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7552 tunnel_filter_conf.filter_type =
7553 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7554 else if (!strcmp(res->filter_type, "oip"))
7555 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7556 else if (!strcmp(res->filter_type, "iip"))
7557 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7559 printf("The filter type is not supported");
7563 if (!strcmp(res->tunnel_type, "vxlan"))
7564 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7565 else if (!strcmp(res->tunnel_type, "nvgre"))
7566 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7567 else if (!strcmp(res->tunnel_type, "ipingre"))
7568 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7570 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7574 tunnel_filter_conf.tenant_id = res->tenant_id;
7575 tunnel_filter_conf.queue_id = res->queue_num;
7576 if (!strcmp(res->what, "add"))
7577 ret = rte_eth_dev_filter_ctrl(res->port_id,
7578 RTE_ETH_FILTER_TUNNEL,
7580 &tunnel_filter_conf);
7582 ret = rte_eth_dev_filter_ctrl(res->port_id,
7583 RTE_ETH_FILTER_TUNNEL,
7584 RTE_ETH_FILTER_DELETE,
7585 &tunnel_filter_conf);
7587 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7591 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7592 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7593 cmd, "tunnel_filter");
7594 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7595 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7597 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7598 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7600 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7601 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7603 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7604 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7606 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7607 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7608 inner_vlan, UINT16);
7609 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7610 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7612 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7613 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7614 tunnel_type, "vxlan#nvgre#ipingre");
7616 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7617 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7618 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7619 "imac#omac-imac-tenid");
7620 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7621 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7623 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7624 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7627 cmdline_parse_inst_t cmd_tunnel_filter = {
7628 .f = cmd_tunnel_filter_parsed,
7630 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7631 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7632 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7633 "<queue_id>: Add/Rm tunnel filter of a port",
7635 (void *)&cmd_tunnel_filter_cmd,
7636 (void *)&cmd_tunnel_filter_what,
7637 (void *)&cmd_tunnel_filter_port_id,
7638 (void *)&cmd_tunnel_filter_outer_mac,
7639 (void *)&cmd_tunnel_filter_inner_mac,
7640 (void *)&cmd_tunnel_filter_ip_value,
7641 (void *)&cmd_tunnel_filter_innner_vlan,
7642 (void *)&cmd_tunnel_filter_tunnel_type,
7643 (void *)&cmd_tunnel_filter_filter_type,
7644 (void *)&cmd_tunnel_filter_tenant_id,
7645 (void *)&cmd_tunnel_filter_queue_num,
7650 /* *** CONFIGURE TUNNEL UDP PORT *** */
7651 struct cmd_tunnel_udp_config {
7652 cmdline_fixed_string_t cmd;
7653 cmdline_fixed_string_t what;
7659 cmd_tunnel_udp_config_parsed(void *parsed_result,
7660 __attribute__((unused)) struct cmdline *cl,
7661 __attribute__((unused)) void *data)
7663 struct cmd_tunnel_udp_config *res = parsed_result;
7664 struct rte_eth_udp_tunnel tunnel_udp;
7667 tunnel_udp.udp_port = res->udp_port;
7669 if (!strcmp(res->cmd, "rx_vxlan_port"))
7670 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7672 if (!strcmp(res->what, "add"))
7673 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7676 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7680 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7683 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7684 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7685 cmd, "rx_vxlan_port");
7686 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7687 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7689 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7690 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7692 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7693 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7696 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7697 .f = cmd_tunnel_udp_config_parsed,
7699 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7700 "Add/Remove a tunneling UDP port filter",
7702 (void *)&cmd_tunnel_udp_config_cmd,
7703 (void *)&cmd_tunnel_udp_config_what,
7704 (void *)&cmd_tunnel_udp_config_udp_port,
7705 (void *)&cmd_tunnel_udp_config_port_id,
7710 /* *** GLOBAL CONFIG *** */
7711 struct cmd_global_config_result {
7712 cmdline_fixed_string_t cmd;
7714 cmdline_fixed_string_t cfg_type;
7719 cmd_global_config_parsed(void *parsed_result,
7720 __attribute__((unused)) struct cmdline *cl,
7721 __attribute__((unused)) void *data)
7723 struct cmd_global_config_result *res = parsed_result;
7724 struct rte_eth_global_cfg conf;
7727 memset(&conf, 0, sizeof(conf));
7728 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7729 conf.cfg.gre_key_len = res->len;
7730 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7731 RTE_ETH_FILTER_SET, &conf);
7733 printf("Global config error\n");
7736 cmdline_parse_token_string_t cmd_global_config_cmd =
7737 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7739 cmdline_parse_token_num_t cmd_global_config_port_id =
7740 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7741 cmdline_parse_token_string_t cmd_global_config_type =
7742 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7743 cfg_type, "gre-key-len");
7744 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7745 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7748 cmdline_parse_inst_t cmd_global_config = {
7749 .f = cmd_global_config_parsed,
7750 .data = (void *)NULL,
7751 .help_str = "global_config <port_id> gre-key-len <key_len>",
7753 (void *)&cmd_global_config_cmd,
7754 (void *)&cmd_global_config_port_id,
7755 (void *)&cmd_global_config_type,
7756 (void *)&cmd_global_config_gre_key_len,
7761 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7762 struct cmd_set_mirror_mask_result {
7763 cmdline_fixed_string_t set;
7764 cmdline_fixed_string_t port;
7766 cmdline_fixed_string_t mirror;
7768 cmdline_fixed_string_t what;
7769 cmdline_fixed_string_t value;
7770 cmdline_fixed_string_t dstpool;
7772 cmdline_fixed_string_t on;
7775 cmdline_parse_token_string_t cmd_mirror_mask_set =
7776 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7778 cmdline_parse_token_string_t cmd_mirror_mask_port =
7779 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7781 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7782 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7784 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7785 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7786 mirror, "mirror-rule");
7787 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7788 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7790 cmdline_parse_token_string_t cmd_mirror_mask_what =
7791 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7792 what, "pool-mirror-up#pool-mirror-down"
7794 cmdline_parse_token_string_t cmd_mirror_mask_value =
7795 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7797 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7798 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7799 dstpool, "dst-pool");
7800 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7801 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7803 cmdline_parse_token_string_t cmd_mirror_mask_on =
7804 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7808 cmd_set_mirror_mask_parsed(void *parsed_result,
7809 __attribute__((unused)) struct cmdline *cl,
7810 __attribute__((unused)) void *data)
7813 struct cmd_set_mirror_mask_result *res = parsed_result;
7814 struct rte_eth_mirror_conf mr_conf;
7816 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7818 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7820 mr_conf.dst_pool = res->dstpool_id;
7822 if (!strcmp(res->what, "pool-mirror-up")) {
7823 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7824 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7825 } else if (!strcmp(res->what, "pool-mirror-down")) {
7826 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7827 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7828 } else if (!strcmp(res->what, "vlan-mirror")) {
7829 mr_conf.rule_type = ETH_MIRROR_VLAN;
7830 nb_item = parse_item_list(res->value, "vlan",
7831 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7835 for (i = 0; i < nb_item; i++) {
7836 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7837 printf("Invalid vlan_id: must be < 4096\n");
7841 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7842 mr_conf.vlan.vlan_mask |= 1ULL << i;
7846 if (!strcmp(res->on, "on"))
7847 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7850 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7853 printf("mirror rule add error: (%s)\n", strerror(-ret));
7856 cmdline_parse_inst_t cmd_set_mirror_mask = {
7857 .f = cmd_set_mirror_mask_parsed,
7859 .help_str = "set port <port_id> mirror-rule <rule_id> "
7860 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7861 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7863 (void *)&cmd_mirror_mask_set,
7864 (void *)&cmd_mirror_mask_port,
7865 (void *)&cmd_mirror_mask_portid,
7866 (void *)&cmd_mirror_mask_mirror,
7867 (void *)&cmd_mirror_mask_ruleid,
7868 (void *)&cmd_mirror_mask_what,
7869 (void *)&cmd_mirror_mask_value,
7870 (void *)&cmd_mirror_mask_dstpool,
7871 (void *)&cmd_mirror_mask_poolid,
7872 (void *)&cmd_mirror_mask_on,
7877 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7878 struct cmd_set_mirror_link_result {
7879 cmdline_fixed_string_t set;
7880 cmdline_fixed_string_t port;
7882 cmdline_fixed_string_t mirror;
7884 cmdline_fixed_string_t what;
7885 cmdline_fixed_string_t dstpool;
7887 cmdline_fixed_string_t on;
7890 cmdline_parse_token_string_t cmd_mirror_link_set =
7891 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7893 cmdline_parse_token_string_t cmd_mirror_link_port =
7894 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7896 cmdline_parse_token_num_t cmd_mirror_link_portid =
7897 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7899 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7900 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7901 mirror, "mirror-rule");
7902 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7903 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7905 cmdline_parse_token_string_t cmd_mirror_link_what =
7906 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7907 what, "uplink-mirror#downlink-mirror");
7908 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7909 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7910 dstpool, "dst-pool");
7911 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7912 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7914 cmdline_parse_token_string_t cmd_mirror_link_on =
7915 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7919 cmd_set_mirror_link_parsed(void *parsed_result,
7920 __attribute__((unused)) struct cmdline *cl,
7921 __attribute__((unused)) void *data)
7924 struct cmd_set_mirror_link_result *res = parsed_result;
7925 struct rte_eth_mirror_conf mr_conf;
7927 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7928 if (!strcmp(res->what, "uplink-mirror"))
7929 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7931 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7933 mr_conf.dst_pool = res->dstpool_id;
7935 if (!strcmp(res->on, "on"))
7936 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7939 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7942 /* check the return value and print it if is < 0 */
7944 printf("mirror rule add error: (%s)\n", strerror(-ret));
7948 cmdline_parse_inst_t cmd_set_mirror_link = {
7949 .f = cmd_set_mirror_link_parsed,
7951 .help_str = "set port <port_id> mirror-rule <rule_id> "
7952 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7954 (void *)&cmd_mirror_link_set,
7955 (void *)&cmd_mirror_link_port,
7956 (void *)&cmd_mirror_link_portid,
7957 (void *)&cmd_mirror_link_mirror,
7958 (void *)&cmd_mirror_link_ruleid,
7959 (void *)&cmd_mirror_link_what,
7960 (void *)&cmd_mirror_link_dstpool,
7961 (void *)&cmd_mirror_link_poolid,
7962 (void *)&cmd_mirror_link_on,
7967 /* *** RESET VM MIRROR RULE *** */
7968 struct cmd_rm_mirror_rule_result {
7969 cmdline_fixed_string_t reset;
7970 cmdline_fixed_string_t port;
7972 cmdline_fixed_string_t mirror;
7976 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7977 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7979 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7980 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7982 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7983 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7985 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7986 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7987 mirror, "mirror-rule");
7988 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7989 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7993 cmd_reset_mirror_rule_parsed(void *parsed_result,
7994 __attribute__((unused)) struct cmdline *cl,
7995 __attribute__((unused)) void *data)
7998 struct cmd_set_mirror_link_result *res = parsed_result;
8000 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8002 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8005 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8006 .f = cmd_reset_mirror_rule_parsed,
8008 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8010 (void *)&cmd_rm_mirror_rule_reset,
8011 (void *)&cmd_rm_mirror_rule_port,
8012 (void *)&cmd_rm_mirror_rule_portid,
8013 (void *)&cmd_rm_mirror_rule_mirror,
8014 (void *)&cmd_rm_mirror_rule_ruleid,
8019 /* ******************************************************************************** */
8021 struct cmd_dump_result {
8022 cmdline_fixed_string_t dump;
8026 dump_struct_sizes(void)
8028 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8029 DUMP_SIZE(struct rte_mbuf);
8030 DUMP_SIZE(struct rte_mempool);
8031 DUMP_SIZE(struct rte_ring);
8035 static void cmd_dump_parsed(void *parsed_result,
8036 __attribute__((unused)) struct cmdline *cl,
8037 __attribute__((unused)) void *data)
8039 struct cmd_dump_result *res = parsed_result;
8041 if (!strcmp(res->dump, "dump_physmem"))
8042 rte_dump_physmem_layout(stdout);
8043 else if (!strcmp(res->dump, "dump_memzone"))
8044 rte_memzone_dump(stdout);
8045 else if (!strcmp(res->dump, "dump_struct_sizes"))
8046 dump_struct_sizes();
8047 else if (!strcmp(res->dump, "dump_ring"))
8048 rte_ring_list_dump(stdout);
8049 else if (!strcmp(res->dump, "dump_mempool"))
8050 rte_mempool_list_dump(stdout);
8051 else if (!strcmp(res->dump, "dump_devargs"))
8052 rte_eal_devargs_dump(stdout);
8053 else if (!strcmp(res->dump, "dump_log_types"))
8054 rte_log_dump(stdout);
8057 cmdline_parse_token_string_t cmd_dump_dump =
8058 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8061 "dump_struct_sizes#"
8067 cmdline_parse_inst_t cmd_dump = {
8068 .f = cmd_dump_parsed, /* function to call */
8069 .data = NULL, /* 2nd arg of func */
8070 .help_str = "Dump status",
8071 .tokens = { /* token list, NULL terminated */
8072 (void *)&cmd_dump_dump,
8077 /* ******************************************************************************** */
8079 struct cmd_dump_one_result {
8080 cmdline_fixed_string_t dump;
8081 cmdline_fixed_string_t name;
8084 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8085 __attribute__((unused)) void *data)
8087 struct cmd_dump_one_result *res = parsed_result;
8089 if (!strcmp(res->dump, "dump_ring")) {
8091 r = rte_ring_lookup(res->name);
8093 cmdline_printf(cl, "Cannot find ring\n");
8096 rte_ring_dump(stdout, r);
8097 } else if (!strcmp(res->dump, "dump_mempool")) {
8098 struct rte_mempool *mp;
8099 mp = rte_mempool_lookup(res->name);
8101 cmdline_printf(cl, "Cannot find mempool\n");
8104 rte_mempool_dump(stdout, mp);
8108 cmdline_parse_token_string_t cmd_dump_one_dump =
8109 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8110 "dump_ring#dump_mempool");
8112 cmdline_parse_token_string_t cmd_dump_one_name =
8113 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8115 cmdline_parse_inst_t cmd_dump_one = {
8116 .f = cmd_dump_one_parsed, /* function to call */
8117 .data = NULL, /* 2nd arg of func */
8118 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8119 .tokens = { /* token list, NULL terminated */
8120 (void *)&cmd_dump_one_dump,
8121 (void *)&cmd_dump_one_name,
8126 /* *** Add/Del syn filter *** */
8127 struct cmd_syn_filter_result {
8128 cmdline_fixed_string_t filter;
8130 cmdline_fixed_string_t ops;
8131 cmdline_fixed_string_t priority;
8132 cmdline_fixed_string_t high;
8133 cmdline_fixed_string_t queue;
8138 cmd_syn_filter_parsed(void *parsed_result,
8139 __attribute__((unused)) struct cmdline *cl,
8140 __attribute__((unused)) void *data)
8142 struct cmd_syn_filter_result *res = parsed_result;
8143 struct rte_eth_syn_filter syn_filter;
8146 ret = rte_eth_dev_filter_supported(res->port_id,
8147 RTE_ETH_FILTER_SYN);
8149 printf("syn filter is not supported on port %u.\n",
8154 memset(&syn_filter, 0, sizeof(syn_filter));
8156 if (!strcmp(res->ops, "add")) {
8157 if (!strcmp(res->high, "high"))
8158 syn_filter.hig_pri = 1;
8160 syn_filter.hig_pri = 0;
8162 syn_filter.queue = res->queue_id;
8163 ret = rte_eth_dev_filter_ctrl(res->port_id,
8168 ret = rte_eth_dev_filter_ctrl(res->port_id,
8170 RTE_ETH_FILTER_DELETE,
8174 printf("syn filter programming error: (%s)\n",
8178 cmdline_parse_token_string_t cmd_syn_filter_filter =
8179 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8180 filter, "syn_filter");
8181 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8182 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8184 cmdline_parse_token_string_t cmd_syn_filter_ops =
8185 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8187 cmdline_parse_token_string_t cmd_syn_filter_priority =
8188 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8189 priority, "priority");
8190 cmdline_parse_token_string_t cmd_syn_filter_high =
8191 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8193 cmdline_parse_token_string_t cmd_syn_filter_queue =
8194 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8196 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8197 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8200 cmdline_parse_inst_t cmd_syn_filter = {
8201 .f = cmd_syn_filter_parsed,
8203 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8204 "<queue_id>: Add/Delete syn filter",
8206 (void *)&cmd_syn_filter_filter,
8207 (void *)&cmd_syn_filter_port_id,
8208 (void *)&cmd_syn_filter_ops,
8209 (void *)&cmd_syn_filter_priority,
8210 (void *)&cmd_syn_filter_high,
8211 (void *)&cmd_syn_filter_queue,
8212 (void *)&cmd_syn_filter_queue_id,
8217 /* *** ADD/REMOVE A 2tuple FILTER *** */
8218 struct cmd_2tuple_filter_result {
8219 cmdline_fixed_string_t filter;
8221 cmdline_fixed_string_t ops;
8222 cmdline_fixed_string_t dst_port;
8223 uint16_t dst_port_value;
8224 cmdline_fixed_string_t protocol;
8225 uint8_t protocol_value;
8226 cmdline_fixed_string_t mask;
8228 cmdline_fixed_string_t tcp_flags;
8229 uint8_t tcp_flags_value;
8230 cmdline_fixed_string_t priority;
8231 uint8_t priority_value;
8232 cmdline_fixed_string_t queue;
8237 cmd_2tuple_filter_parsed(void *parsed_result,
8238 __attribute__((unused)) struct cmdline *cl,
8239 __attribute__((unused)) void *data)
8241 struct rte_eth_ntuple_filter filter;
8242 struct cmd_2tuple_filter_result *res = parsed_result;
8245 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8247 printf("ntuple filter is not supported on port %u.\n",
8252 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8254 filter.flags = RTE_2TUPLE_FLAGS;
8255 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8256 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8257 filter.proto = res->protocol_value;
8258 filter.priority = res->priority_value;
8259 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8260 printf("nonzero tcp_flags is only meaningful"
8261 " when protocol is TCP.\n");
8264 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8265 printf("invalid TCP flags.\n");
8269 if (res->tcp_flags_value != 0) {
8270 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8271 filter.tcp_flags = res->tcp_flags_value;
8274 /* need convert to big endian. */
8275 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8276 filter.queue = res->queue_id;
8278 if (!strcmp(res->ops, "add"))
8279 ret = rte_eth_dev_filter_ctrl(res->port_id,
8280 RTE_ETH_FILTER_NTUPLE,
8284 ret = rte_eth_dev_filter_ctrl(res->port_id,
8285 RTE_ETH_FILTER_NTUPLE,
8286 RTE_ETH_FILTER_DELETE,
8289 printf("2tuple filter programming error: (%s)\n",
8294 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
8295 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8296 filter, "2tuple_filter");
8297 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
8298 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8300 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
8301 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8303 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
8304 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8305 dst_port, "dst_port");
8306 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
8307 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8308 dst_port_value, UINT16);
8309 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
8310 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8311 protocol, "protocol");
8312 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
8313 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8314 protocol_value, UINT8);
8315 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8316 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8318 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8319 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8321 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8322 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8323 tcp_flags, "tcp_flags");
8324 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8325 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8326 tcp_flags_value, UINT8);
8327 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8328 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8329 priority, "priority");
8330 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8331 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8332 priority_value, UINT8);
8333 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8334 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8336 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8337 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8340 cmdline_parse_inst_t cmd_2tuple_filter = {
8341 .f = cmd_2tuple_filter_parsed,
8343 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8344 "<value> mask <value> tcp_flags <value> priority <value> queue "
8345 "<queue_id>: Add a 2tuple filter",
8347 (void *)&cmd_2tuple_filter_filter,
8348 (void *)&cmd_2tuple_filter_port_id,
8349 (void *)&cmd_2tuple_filter_ops,
8350 (void *)&cmd_2tuple_filter_dst_port,
8351 (void *)&cmd_2tuple_filter_dst_port_value,
8352 (void *)&cmd_2tuple_filter_protocol,
8353 (void *)&cmd_2tuple_filter_protocol_value,
8354 (void *)&cmd_2tuple_filter_mask,
8355 (void *)&cmd_2tuple_filter_mask_value,
8356 (void *)&cmd_2tuple_filter_tcp_flags,
8357 (void *)&cmd_2tuple_filter_tcp_flags_value,
8358 (void *)&cmd_2tuple_filter_priority,
8359 (void *)&cmd_2tuple_filter_priority_value,
8360 (void *)&cmd_2tuple_filter_queue,
8361 (void *)&cmd_2tuple_filter_queue_id,
8366 /* *** ADD/REMOVE A 5tuple FILTER *** */
8367 struct cmd_5tuple_filter_result {
8368 cmdline_fixed_string_t filter;
8370 cmdline_fixed_string_t ops;
8371 cmdline_fixed_string_t dst_ip;
8372 cmdline_ipaddr_t dst_ip_value;
8373 cmdline_fixed_string_t src_ip;
8374 cmdline_ipaddr_t src_ip_value;
8375 cmdline_fixed_string_t dst_port;
8376 uint16_t dst_port_value;
8377 cmdline_fixed_string_t src_port;
8378 uint16_t src_port_value;
8379 cmdline_fixed_string_t protocol;
8380 uint8_t protocol_value;
8381 cmdline_fixed_string_t mask;
8383 cmdline_fixed_string_t tcp_flags;
8384 uint8_t tcp_flags_value;
8385 cmdline_fixed_string_t priority;
8386 uint8_t priority_value;
8387 cmdline_fixed_string_t queue;
8392 cmd_5tuple_filter_parsed(void *parsed_result,
8393 __attribute__((unused)) struct cmdline *cl,
8394 __attribute__((unused)) void *data)
8396 struct rte_eth_ntuple_filter filter;
8397 struct cmd_5tuple_filter_result *res = parsed_result;
8400 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8402 printf("ntuple filter is not supported on port %u.\n",
8407 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8409 filter.flags = RTE_5TUPLE_FLAGS;
8410 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8411 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8412 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8413 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8414 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8415 filter.proto = res->protocol_value;
8416 filter.priority = res->priority_value;
8417 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8418 printf("nonzero tcp_flags is only meaningful"
8419 " when protocol is TCP.\n");
8422 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8423 printf("invalid TCP flags.\n");
8427 if (res->tcp_flags_value != 0) {
8428 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8429 filter.tcp_flags = res->tcp_flags_value;
8432 if (res->dst_ip_value.family == AF_INET)
8433 /* no need to convert, already big endian. */
8434 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8436 if (filter.dst_ip_mask == 0) {
8437 printf("can not support ipv6 involved compare.\n");
8443 if (res->src_ip_value.family == AF_INET)
8444 /* no need to convert, already big endian. */
8445 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8447 if (filter.src_ip_mask == 0) {
8448 printf("can not support ipv6 involved compare.\n");
8453 /* need convert to big endian. */
8454 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8455 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8456 filter.queue = res->queue_id;
8458 if (!strcmp(res->ops, "add"))
8459 ret = rte_eth_dev_filter_ctrl(res->port_id,
8460 RTE_ETH_FILTER_NTUPLE,
8464 ret = rte_eth_dev_filter_ctrl(res->port_id,
8465 RTE_ETH_FILTER_NTUPLE,
8466 RTE_ETH_FILTER_DELETE,
8469 printf("5tuple filter programming error: (%s)\n",
8473 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8474 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8475 filter, "5tuple_filter");
8476 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8477 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8479 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8480 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8482 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8483 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8485 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8486 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8488 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8489 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8491 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8492 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8494 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8495 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8496 dst_port, "dst_port");
8497 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8498 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8499 dst_port_value, UINT16);
8500 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8501 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8502 src_port, "src_port");
8503 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8504 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8505 src_port_value, UINT16);
8506 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8507 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8508 protocol, "protocol");
8509 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8510 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8511 protocol_value, UINT8);
8512 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8513 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8515 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8516 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8518 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8519 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8520 tcp_flags, "tcp_flags");
8521 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8522 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8523 tcp_flags_value, UINT8);
8524 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8525 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8526 priority, "priority");
8527 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8528 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8529 priority_value, UINT8);
8530 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8531 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8533 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8534 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8537 cmdline_parse_inst_t cmd_5tuple_filter = {
8538 .f = cmd_5tuple_filter_parsed,
8540 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8541 "src_ip <value> dst_port <value> src_port <value> "
8542 "protocol <value> mask <value> tcp_flags <value> "
8543 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8545 (void *)&cmd_5tuple_filter_filter,
8546 (void *)&cmd_5tuple_filter_port_id,
8547 (void *)&cmd_5tuple_filter_ops,
8548 (void *)&cmd_5tuple_filter_dst_ip,
8549 (void *)&cmd_5tuple_filter_dst_ip_value,
8550 (void *)&cmd_5tuple_filter_src_ip,
8551 (void *)&cmd_5tuple_filter_src_ip_value,
8552 (void *)&cmd_5tuple_filter_dst_port,
8553 (void *)&cmd_5tuple_filter_dst_port_value,
8554 (void *)&cmd_5tuple_filter_src_port,
8555 (void *)&cmd_5tuple_filter_src_port_value,
8556 (void *)&cmd_5tuple_filter_protocol,
8557 (void *)&cmd_5tuple_filter_protocol_value,
8558 (void *)&cmd_5tuple_filter_mask,
8559 (void *)&cmd_5tuple_filter_mask_value,
8560 (void *)&cmd_5tuple_filter_tcp_flags,
8561 (void *)&cmd_5tuple_filter_tcp_flags_value,
8562 (void *)&cmd_5tuple_filter_priority,
8563 (void *)&cmd_5tuple_filter_priority_value,
8564 (void *)&cmd_5tuple_filter_queue,
8565 (void *)&cmd_5tuple_filter_queue_id,
8570 /* *** ADD/REMOVE A flex FILTER *** */
8571 struct cmd_flex_filter_result {
8572 cmdline_fixed_string_t filter;
8573 cmdline_fixed_string_t ops;
8575 cmdline_fixed_string_t len;
8577 cmdline_fixed_string_t bytes;
8578 cmdline_fixed_string_t bytes_value;
8579 cmdline_fixed_string_t mask;
8580 cmdline_fixed_string_t mask_value;
8581 cmdline_fixed_string_t priority;
8582 uint8_t priority_value;
8583 cmdline_fixed_string_t queue;
8587 static int xdigit2val(unsigned char c)
8592 else if (isupper(c))
8600 cmd_flex_filter_parsed(void *parsed_result,
8601 __attribute__((unused)) struct cmdline *cl,
8602 __attribute__((unused)) void *data)
8605 struct rte_eth_flex_filter filter;
8606 struct cmd_flex_filter_result *res = parsed_result;
8607 char *bytes_ptr, *mask_ptr;
8608 uint16_t len, i, j = 0;
8613 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8614 printf("the len exceed the max length 128\n");
8617 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8618 filter.len = res->len_value;
8619 filter.priority = res->priority_value;
8620 filter.queue = res->queue_id;
8621 bytes_ptr = res->bytes_value;
8622 mask_ptr = res->mask_value;
8624 /* translate bytes string to array. */
8625 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8626 (bytes_ptr[1] == 'X')))
8628 len = strnlen(bytes_ptr, res->len_value * 2);
8629 if (len == 0 || (len % 8 != 0)) {
8630 printf("please check len and bytes input\n");
8633 for (i = 0; i < len; i++) {
8635 if (isxdigit(c) == 0) {
8636 /* invalid characters. */
8637 printf("invalid input\n");
8640 val = xdigit2val(c);
8643 filter.bytes[j] = byte;
8644 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8651 /* translate mask string to uint8_t array. */
8652 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8653 (mask_ptr[1] == 'X')))
8655 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8657 printf("invalid input\n");
8662 for (i = 0; i < len; i++) {
8664 if (isxdigit(c) == 0) {
8665 /* invalid characters. */
8666 printf("invalid input\n");
8669 val = xdigit2val(c);
8672 filter.mask[j] = byte;
8673 printf("mask[%d]:%02x ", j, filter.mask[j]);
8681 if (!strcmp(res->ops, "add"))
8682 ret = rte_eth_dev_filter_ctrl(res->port_id,
8683 RTE_ETH_FILTER_FLEXIBLE,
8687 ret = rte_eth_dev_filter_ctrl(res->port_id,
8688 RTE_ETH_FILTER_FLEXIBLE,
8689 RTE_ETH_FILTER_DELETE,
8693 printf("flex filter setting error: (%s)\n", strerror(-ret));
8696 cmdline_parse_token_string_t cmd_flex_filter_filter =
8697 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8698 filter, "flex_filter");
8699 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8700 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8702 cmdline_parse_token_string_t cmd_flex_filter_ops =
8703 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8705 cmdline_parse_token_string_t cmd_flex_filter_len =
8706 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8708 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8709 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8711 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8712 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8714 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8715 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8717 cmdline_parse_token_string_t cmd_flex_filter_mask =
8718 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8720 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8721 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8723 cmdline_parse_token_string_t cmd_flex_filter_priority =
8724 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8725 priority, "priority");
8726 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8727 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8728 priority_value, UINT8);
8729 cmdline_parse_token_string_t cmd_flex_filter_queue =
8730 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8732 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8733 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8735 cmdline_parse_inst_t cmd_flex_filter = {
8736 .f = cmd_flex_filter_parsed,
8738 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8739 "<value> mask <value> priority <value> queue <queue_id>: "
8740 "Add/Del a flex filter",
8742 (void *)&cmd_flex_filter_filter,
8743 (void *)&cmd_flex_filter_port_id,
8744 (void *)&cmd_flex_filter_ops,
8745 (void *)&cmd_flex_filter_len,
8746 (void *)&cmd_flex_filter_len_value,
8747 (void *)&cmd_flex_filter_bytes,
8748 (void *)&cmd_flex_filter_bytes_value,
8749 (void *)&cmd_flex_filter_mask,
8750 (void *)&cmd_flex_filter_mask_value,
8751 (void *)&cmd_flex_filter_priority,
8752 (void *)&cmd_flex_filter_priority_value,
8753 (void *)&cmd_flex_filter_queue,
8754 (void *)&cmd_flex_filter_queue_id,
8759 /* *** Filters Control *** */
8761 /* *** deal with ethertype filter *** */
8762 struct cmd_ethertype_filter_result {
8763 cmdline_fixed_string_t filter;
8765 cmdline_fixed_string_t ops;
8766 cmdline_fixed_string_t mac;
8767 struct ether_addr mac_addr;
8768 cmdline_fixed_string_t ethertype;
8769 uint16_t ethertype_value;
8770 cmdline_fixed_string_t drop;
8771 cmdline_fixed_string_t queue;
8775 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8776 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8777 filter, "ethertype_filter");
8778 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8779 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8781 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8782 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8784 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8785 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8786 mac, "mac_addr#mac_ignr");
8787 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8788 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8790 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8791 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8792 ethertype, "ethertype");
8793 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8794 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8795 ethertype_value, UINT16);
8796 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8797 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8799 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8800 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8802 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8803 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8807 cmd_ethertype_filter_parsed(void *parsed_result,
8808 __attribute__((unused)) struct cmdline *cl,
8809 __attribute__((unused)) void *data)
8811 struct cmd_ethertype_filter_result *res = parsed_result;
8812 struct rte_eth_ethertype_filter filter;
8815 ret = rte_eth_dev_filter_supported(res->port_id,
8816 RTE_ETH_FILTER_ETHERTYPE);
8818 printf("ethertype filter is not supported on port %u.\n",
8823 memset(&filter, 0, sizeof(filter));
8824 if (!strcmp(res->mac, "mac_addr")) {
8825 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8826 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8827 sizeof(struct ether_addr));
8829 if (!strcmp(res->drop, "drop"))
8830 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8831 filter.ether_type = res->ethertype_value;
8832 filter.queue = res->queue_id;
8834 if (!strcmp(res->ops, "add"))
8835 ret = rte_eth_dev_filter_ctrl(res->port_id,
8836 RTE_ETH_FILTER_ETHERTYPE,
8840 ret = rte_eth_dev_filter_ctrl(res->port_id,
8841 RTE_ETH_FILTER_ETHERTYPE,
8842 RTE_ETH_FILTER_DELETE,
8845 printf("ethertype filter programming error: (%s)\n",
8849 cmdline_parse_inst_t cmd_ethertype_filter = {
8850 .f = cmd_ethertype_filter_parsed,
8852 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8853 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8854 "Add or delete an ethertype filter entry",
8856 (void *)&cmd_ethertype_filter_filter,
8857 (void *)&cmd_ethertype_filter_port_id,
8858 (void *)&cmd_ethertype_filter_ops,
8859 (void *)&cmd_ethertype_filter_mac,
8860 (void *)&cmd_ethertype_filter_mac_addr,
8861 (void *)&cmd_ethertype_filter_ethertype,
8862 (void *)&cmd_ethertype_filter_ethertype_value,
8863 (void *)&cmd_ethertype_filter_drop,
8864 (void *)&cmd_ethertype_filter_queue,
8865 (void *)&cmd_ethertype_filter_queue_id,
8870 /* *** deal with flow director filter *** */
8871 struct cmd_flow_director_result {
8872 cmdline_fixed_string_t flow_director_filter;
8874 cmdline_fixed_string_t mode;
8875 cmdline_fixed_string_t mode_value;
8876 cmdline_fixed_string_t ops;
8877 cmdline_fixed_string_t flow;
8878 cmdline_fixed_string_t flow_type;
8879 cmdline_fixed_string_t ether;
8880 uint16_t ether_type;
8881 cmdline_fixed_string_t src;
8882 cmdline_ipaddr_t ip_src;
8884 cmdline_fixed_string_t dst;
8885 cmdline_ipaddr_t ip_dst;
8887 cmdline_fixed_string_t verify_tag;
8888 uint32_t verify_tag_value;
8889 cmdline_ipaddr_t tos;
8891 cmdline_ipaddr_t proto;
8892 uint8_t proto_value;
8893 cmdline_ipaddr_t ttl;
8895 cmdline_fixed_string_t vlan;
8896 uint16_t vlan_value;
8897 cmdline_fixed_string_t flexbytes;
8898 cmdline_fixed_string_t flexbytes_value;
8899 cmdline_fixed_string_t pf_vf;
8900 cmdline_fixed_string_t drop;
8901 cmdline_fixed_string_t queue;
8903 cmdline_fixed_string_t fd_id;
8904 uint32_t fd_id_value;
8905 cmdline_fixed_string_t mac;
8906 struct ether_addr mac_addr;
8907 cmdline_fixed_string_t tunnel;
8908 cmdline_fixed_string_t tunnel_type;
8909 cmdline_fixed_string_t tunnel_id;
8910 uint32_t tunnel_id_value;
8914 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8917 const char *p, *p0 = q_arg;
8919 unsigned long int_fld;
8920 char *str_fld[max_num];
8925 p = strchr(p0, '(');
8929 p0 = strchr(p, ')');
8934 if (size >= sizeof(s))
8937 snprintf(s, sizeof(s), "%.*s", size, p);
8938 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8939 if (ret < 0 || ret > max_num)
8941 for (i = 0; i < ret; i++) {
8943 int_fld = strtoul(str_fld[i], &end, 0);
8944 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8946 flexbytes[i] = (uint8_t)int_fld;
8952 str2flowtype(char *string)
8955 static const struct {
8958 } flowtype_str[] = {
8959 {"raw", RTE_ETH_FLOW_RAW},
8960 {"ipv4", RTE_ETH_FLOW_IPV4},
8961 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8962 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8963 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8964 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8965 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8966 {"ipv6", RTE_ETH_FLOW_IPV6},
8967 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8968 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8969 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8970 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8971 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8972 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8975 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8976 if (!strcmp(flowtype_str[i].str, string))
8977 return flowtype_str[i].type;
8979 return RTE_ETH_FLOW_UNKNOWN;
8982 static enum rte_eth_fdir_tunnel_type
8983 str2fdir_tunneltype(char *string)
8987 static const struct {
8989 enum rte_eth_fdir_tunnel_type type;
8990 } tunneltype_str[] = {
8991 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8992 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8995 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8996 if (!strcmp(tunneltype_str[i].str, string))
8997 return tunneltype_str[i].type;
8999 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9002 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9004 if ((ip_addr).family == AF_INET) \
9005 (ip) = (ip_addr).addr.ipv4.s_addr; \
9007 printf("invalid parameter.\n"); \
9012 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9014 if ((ip_addr).family == AF_INET6) \
9015 (void)rte_memcpy(&(ip), \
9016 &((ip_addr).addr.ipv6), \
9017 sizeof(struct in6_addr)); \
9019 printf("invalid parameter.\n"); \
9025 cmd_flow_director_filter_parsed(void *parsed_result,
9026 __attribute__((unused)) struct cmdline *cl,
9027 __attribute__((unused)) void *data)
9029 struct cmd_flow_director_result *res = parsed_result;
9030 struct rte_eth_fdir_filter entry;
9031 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9033 unsigned long vf_id;
9036 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9038 printf("flow director is not supported on port %u.\n",
9042 memset(flexbytes, 0, sizeof(flexbytes));
9043 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9045 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9046 if (strcmp(res->mode_value, "MAC-VLAN")) {
9047 printf("Please set mode to MAC-VLAN.\n");
9050 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9051 if (strcmp(res->mode_value, "Tunnel")) {
9052 printf("Please set mode to Tunnel.\n");
9056 if (strcmp(res->mode_value, "IP")) {
9057 printf("Please set mode to IP.\n");
9060 entry.input.flow_type = str2flowtype(res->flow_type);
9063 ret = parse_flexbytes(res->flexbytes_value,
9065 RTE_ETH_FDIR_MAX_FLEXLEN);
9067 printf("error: Cannot parse flexbytes input.\n");
9071 switch (entry.input.flow_type) {
9072 case RTE_ETH_FLOW_FRAG_IPV4:
9073 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9074 entry.input.flow.ip4_flow.proto = res->proto_value;
9076 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9077 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9078 IPV4_ADDR_TO_UINT(res->ip_dst,
9079 entry.input.flow.ip4_flow.dst_ip);
9080 IPV4_ADDR_TO_UINT(res->ip_src,
9081 entry.input.flow.ip4_flow.src_ip);
9082 entry.input.flow.ip4_flow.tos = res->tos_value;
9083 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9084 /* need convert to big endian. */
9085 entry.input.flow.udp4_flow.dst_port =
9086 rte_cpu_to_be_16(res->port_dst);
9087 entry.input.flow.udp4_flow.src_port =
9088 rte_cpu_to_be_16(res->port_src);
9090 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9091 IPV4_ADDR_TO_UINT(res->ip_dst,
9092 entry.input.flow.sctp4_flow.ip.dst_ip);
9093 IPV4_ADDR_TO_UINT(res->ip_src,
9094 entry.input.flow.sctp4_flow.ip.src_ip);
9095 entry.input.flow.ip4_flow.tos = res->tos_value;
9096 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9097 /* need convert to big endian. */
9098 entry.input.flow.sctp4_flow.dst_port =
9099 rte_cpu_to_be_16(res->port_dst);
9100 entry.input.flow.sctp4_flow.src_port =
9101 rte_cpu_to_be_16(res->port_src);
9102 entry.input.flow.sctp4_flow.verify_tag =
9103 rte_cpu_to_be_32(res->verify_tag_value);
9105 case RTE_ETH_FLOW_FRAG_IPV6:
9106 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9107 entry.input.flow.ipv6_flow.proto = res->proto_value;
9109 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9110 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9111 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9112 entry.input.flow.ipv6_flow.dst_ip);
9113 IPV6_ADDR_TO_ARRAY(res->ip_src,
9114 entry.input.flow.ipv6_flow.src_ip);
9115 entry.input.flow.ipv6_flow.tc = res->tos_value;
9116 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9117 /* need convert to big endian. */
9118 entry.input.flow.udp6_flow.dst_port =
9119 rte_cpu_to_be_16(res->port_dst);
9120 entry.input.flow.udp6_flow.src_port =
9121 rte_cpu_to_be_16(res->port_src);
9123 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9124 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9125 entry.input.flow.sctp6_flow.ip.dst_ip);
9126 IPV6_ADDR_TO_ARRAY(res->ip_src,
9127 entry.input.flow.sctp6_flow.ip.src_ip);
9128 entry.input.flow.ipv6_flow.tc = res->tos_value;
9129 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9130 /* need convert to big endian. */
9131 entry.input.flow.sctp6_flow.dst_port =
9132 rte_cpu_to_be_16(res->port_dst);
9133 entry.input.flow.sctp6_flow.src_port =
9134 rte_cpu_to_be_16(res->port_src);
9135 entry.input.flow.sctp6_flow.verify_tag =
9136 rte_cpu_to_be_32(res->verify_tag_value);
9138 case RTE_ETH_FLOW_L2_PAYLOAD:
9139 entry.input.flow.l2_flow.ether_type =
9140 rte_cpu_to_be_16(res->ether_type);
9146 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
9147 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
9149 sizeof(struct ether_addr));
9151 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9152 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
9154 sizeof(struct ether_addr));
9155 entry.input.flow.tunnel_flow.tunnel_type =
9156 str2fdir_tunneltype(res->tunnel_type);
9157 entry.input.flow.tunnel_flow.tunnel_id =
9158 rte_cpu_to_be_32(res->tunnel_id_value);
9161 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
9163 RTE_ETH_FDIR_MAX_FLEXLEN);
9165 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
9167 entry.action.flex_off = 0; /*use 0 by default */
9168 if (!strcmp(res->drop, "drop"))
9169 entry.action.behavior = RTE_ETH_FDIR_REJECT;
9171 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
9173 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
9174 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
9175 if (!strcmp(res->pf_vf, "pf"))
9176 entry.input.flow_ext.is_vf = 0;
9177 else if (!strncmp(res->pf_vf, "vf", 2)) {
9178 struct rte_eth_dev_info dev_info;
9180 memset(&dev_info, 0, sizeof(dev_info));
9181 rte_eth_dev_info_get(res->port_id, &dev_info);
9183 vf_id = strtoul(res->pf_vf + 2, &end, 10);
9184 if (errno != 0 || *end != '\0' ||
9185 vf_id >= dev_info.max_vfs) {
9186 printf("invalid parameter %s.\n", res->pf_vf);
9189 entry.input.flow_ext.is_vf = 1;
9190 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
9192 printf("invalid parameter %s.\n", res->pf_vf);
9197 /* set to report FD ID by default */
9198 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
9199 entry.action.rx_queue = res->queue_id;
9200 entry.soft_id = res->fd_id_value;
9201 if (!strcmp(res->ops, "add"))
9202 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9203 RTE_ETH_FILTER_ADD, &entry);
9204 else if (!strcmp(res->ops, "del"))
9205 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9206 RTE_ETH_FILTER_DELETE, &entry);
9208 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9209 RTE_ETH_FILTER_UPDATE, &entry);
9211 printf("flow director programming error: (%s)\n",
9215 cmdline_parse_token_string_t cmd_flow_director_filter =
9216 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9217 flow_director_filter, "flow_director_filter");
9218 cmdline_parse_token_num_t cmd_flow_director_port_id =
9219 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9221 cmdline_parse_token_string_t cmd_flow_director_ops =
9222 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9223 ops, "add#del#update");
9224 cmdline_parse_token_string_t cmd_flow_director_flow =
9225 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9227 cmdline_parse_token_string_t cmd_flow_director_flow_type =
9228 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9229 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9230 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
9231 cmdline_parse_token_string_t cmd_flow_director_ether =
9232 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9234 cmdline_parse_token_num_t cmd_flow_director_ether_type =
9235 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9236 ether_type, UINT16);
9237 cmdline_parse_token_string_t cmd_flow_director_src =
9238 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9240 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
9241 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9243 cmdline_parse_token_num_t cmd_flow_director_port_src =
9244 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9246 cmdline_parse_token_string_t cmd_flow_director_dst =
9247 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9249 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
9250 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9252 cmdline_parse_token_num_t cmd_flow_director_port_dst =
9253 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9255 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
9256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9257 verify_tag, "verify_tag");
9258 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
9259 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9260 verify_tag_value, UINT32);
9261 cmdline_parse_token_string_t cmd_flow_director_tos =
9262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9264 cmdline_parse_token_num_t cmd_flow_director_tos_value =
9265 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9267 cmdline_parse_token_string_t cmd_flow_director_proto =
9268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9270 cmdline_parse_token_num_t cmd_flow_director_proto_value =
9271 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9272 proto_value, UINT8);
9273 cmdline_parse_token_string_t cmd_flow_director_ttl =
9274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9276 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
9277 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9279 cmdline_parse_token_string_t cmd_flow_director_vlan =
9280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9282 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
9283 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9284 vlan_value, UINT16);
9285 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
9286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9287 flexbytes, "flexbytes");
9288 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
9289 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9290 flexbytes_value, NULL);
9291 cmdline_parse_token_string_t cmd_flow_director_drop =
9292 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9294 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
9295 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9297 cmdline_parse_token_string_t cmd_flow_director_queue =
9298 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9300 cmdline_parse_token_num_t cmd_flow_director_queue_id =
9301 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9303 cmdline_parse_token_string_t cmd_flow_director_fd_id =
9304 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9306 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
9307 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9308 fd_id_value, UINT32);
9310 cmdline_parse_token_string_t cmd_flow_director_mode =
9311 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9313 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
9314 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9316 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9317 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9318 mode_value, "MAC-VLAN");
9319 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9320 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9321 mode_value, "Tunnel");
9322 cmdline_parse_token_string_t cmd_flow_director_mac =
9323 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9325 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9326 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9328 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9329 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9331 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9332 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9333 tunnel_type, "NVGRE#VxLAN");
9334 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9335 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9336 tunnel_id, "tunnel-id");
9337 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9338 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9339 tunnel_id_value, UINT32);
9341 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9342 .f = cmd_flow_director_filter_parsed,
9344 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9345 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9346 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9347 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9348 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9349 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9350 "fd_id <fd_id_value>: "
9351 "Add or delete an ip flow director entry on NIC",
9353 (void *)&cmd_flow_director_filter,
9354 (void *)&cmd_flow_director_port_id,
9355 (void *)&cmd_flow_director_mode,
9356 (void *)&cmd_flow_director_mode_ip,
9357 (void *)&cmd_flow_director_ops,
9358 (void *)&cmd_flow_director_flow,
9359 (void *)&cmd_flow_director_flow_type,
9360 (void *)&cmd_flow_director_src,
9361 (void *)&cmd_flow_director_ip_src,
9362 (void *)&cmd_flow_director_dst,
9363 (void *)&cmd_flow_director_ip_dst,
9364 (void *)&cmd_flow_director_tos,
9365 (void *)&cmd_flow_director_tos_value,
9366 (void *)&cmd_flow_director_proto,
9367 (void *)&cmd_flow_director_proto_value,
9368 (void *)&cmd_flow_director_ttl,
9369 (void *)&cmd_flow_director_ttl_value,
9370 (void *)&cmd_flow_director_vlan,
9371 (void *)&cmd_flow_director_vlan_value,
9372 (void *)&cmd_flow_director_flexbytes,
9373 (void *)&cmd_flow_director_flexbytes_value,
9374 (void *)&cmd_flow_director_drop,
9375 (void *)&cmd_flow_director_pf_vf,
9376 (void *)&cmd_flow_director_queue,
9377 (void *)&cmd_flow_director_queue_id,
9378 (void *)&cmd_flow_director_fd_id,
9379 (void *)&cmd_flow_director_fd_id_value,
9384 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9385 .f = cmd_flow_director_filter_parsed,
9387 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9388 "director entry on NIC",
9390 (void *)&cmd_flow_director_filter,
9391 (void *)&cmd_flow_director_port_id,
9392 (void *)&cmd_flow_director_mode,
9393 (void *)&cmd_flow_director_mode_ip,
9394 (void *)&cmd_flow_director_ops,
9395 (void *)&cmd_flow_director_flow,
9396 (void *)&cmd_flow_director_flow_type,
9397 (void *)&cmd_flow_director_src,
9398 (void *)&cmd_flow_director_ip_src,
9399 (void *)&cmd_flow_director_port_src,
9400 (void *)&cmd_flow_director_dst,
9401 (void *)&cmd_flow_director_ip_dst,
9402 (void *)&cmd_flow_director_port_dst,
9403 (void *)&cmd_flow_director_tos,
9404 (void *)&cmd_flow_director_tos_value,
9405 (void *)&cmd_flow_director_ttl,
9406 (void *)&cmd_flow_director_ttl_value,
9407 (void *)&cmd_flow_director_vlan,
9408 (void *)&cmd_flow_director_vlan_value,
9409 (void *)&cmd_flow_director_flexbytes,
9410 (void *)&cmd_flow_director_flexbytes_value,
9411 (void *)&cmd_flow_director_drop,
9412 (void *)&cmd_flow_director_pf_vf,
9413 (void *)&cmd_flow_director_queue,
9414 (void *)&cmd_flow_director_queue_id,
9415 (void *)&cmd_flow_director_fd_id,
9416 (void *)&cmd_flow_director_fd_id_value,
9421 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9422 .f = cmd_flow_director_filter_parsed,
9424 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9425 "director entry on NIC",
9427 (void *)&cmd_flow_director_filter,
9428 (void *)&cmd_flow_director_port_id,
9429 (void *)&cmd_flow_director_mode,
9430 (void *)&cmd_flow_director_mode_ip,
9431 (void *)&cmd_flow_director_ops,
9432 (void *)&cmd_flow_director_flow,
9433 (void *)&cmd_flow_director_flow_type,
9434 (void *)&cmd_flow_director_src,
9435 (void *)&cmd_flow_director_ip_src,
9436 (void *)&cmd_flow_director_port_dst,
9437 (void *)&cmd_flow_director_dst,
9438 (void *)&cmd_flow_director_ip_dst,
9439 (void *)&cmd_flow_director_port_dst,
9440 (void *)&cmd_flow_director_verify_tag,
9441 (void *)&cmd_flow_director_verify_tag_value,
9442 (void *)&cmd_flow_director_tos,
9443 (void *)&cmd_flow_director_tos_value,
9444 (void *)&cmd_flow_director_ttl,
9445 (void *)&cmd_flow_director_ttl_value,
9446 (void *)&cmd_flow_director_vlan,
9447 (void *)&cmd_flow_director_vlan_value,
9448 (void *)&cmd_flow_director_flexbytes,
9449 (void *)&cmd_flow_director_flexbytes_value,
9450 (void *)&cmd_flow_director_drop,
9451 (void *)&cmd_flow_director_pf_vf,
9452 (void *)&cmd_flow_director_queue,
9453 (void *)&cmd_flow_director_queue_id,
9454 (void *)&cmd_flow_director_fd_id,
9455 (void *)&cmd_flow_director_fd_id_value,
9460 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9461 .f = cmd_flow_director_filter_parsed,
9463 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9464 "director entry on NIC",
9466 (void *)&cmd_flow_director_filter,
9467 (void *)&cmd_flow_director_port_id,
9468 (void *)&cmd_flow_director_mode,
9469 (void *)&cmd_flow_director_mode_ip,
9470 (void *)&cmd_flow_director_ops,
9471 (void *)&cmd_flow_director_flow,
9472 (void *)&cmd_flow_director_flow_type,
9473 (void *)&cmd_flow_director_ether,
9474 (void *)&cmd_flow_director_ether_type,
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_mac_vlan_flow_director = {
9488 .f = cmd_flow_director_filter_parsed,
9490 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN 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_mac_vlan,
9497 (void *)&cmd_flow_director_ops,
9498 (void *)&cmd_flow_director_mac,
9499 (void *)&cmd_flow_director_mac_addr,
9500 (void *)&cmd_flow_director_vlan,
9501 (void *)&cmd_flow_director_vlan_value,
9502 (void *)&cmd_flow_director_flexbytes,
9503 (void *)&cmd_flow_director_flexbytes_value,
9504 (void *)&cmd_flow_director_drop,
9505 (void *)&cmd_flow_director_queue,
9506 (void *)&cmd_flow_director_queue_id,
9507 (void *)&cmd_flow_director_fd_id,
9508 (void *)&cmd_flow_director_fd_id_value,
9513 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9514 .f = cmd_flow_director_filter_parsed,
9516 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9517 "director entry on NIC",
9519 (void *)&cmd_flow_director_filter,
9520 (void *)&cmd_flow_director_port_id,
9521 (void *)&cmd_flow_director_mode,
9522 (void *)&cmd_flow_director_mode_tunnel,
9523 (void *)&cmd_flow_director_ops,
9524 (void *)&cmd_flow_director_mac,
9525 (void *)&cmd_flow_director_mac_addr,
9526 (void *)&cmd_flow_director_vlan,
9527 (void *)&cmd_flow_director_vlan_value,
9528 (void *)&cmd_flow_director_tunnel,
9529 (void *)&cmd_flow_director_tunnel_type,
9530 (void *)&cmd_flow_director_tunnel_id,
9531 (void *)&cmd_flow_director_tunnel_id_value,
9532 (void *)&cmd_flow_director_flexbytes,
9533 (void *)&cmd_flow_director_flexbytes_value,
9534 (void *)&cmd_flow_director_drop,
9535 (void *)&cmd_flow_director_queue,
9536 (void *)&cmd_flow_director_queue_id,
9537 (void *)&cmd_flow_director_fd_id,
9538 (void *)&cmd_flow_director_fd_id_value,
9543 struct cmd_flush_flow_director_result {
9544 cmdline_fixed_string_t flush_flow_director;
9548 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9549 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9550 flush_flow_director, "flush_flow_director");
9551 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9552 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9556 cmd_flush_flow_director_parsed(void *parsed_result,
9557 __attribute__((unused)) struct cmdline *cl,
9558 __attribute__((unused)) void *data)
9560 struct cmd_flow_director_result *res = parsed_result;
9563 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9565 printf("flow director is not supported on port %u.\n",
9570 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9571 RTE_ETH_FILTER_FLUSH, NULL);
9573 printf("flow director table flushing error: (%s)\n",
9577 cmdline_parse_inst_t cmd_flush_flow_director = {
9578 .f = cmd_flush_flow_director_parsed,
9580 .help_str = "flush_flow_director <port_id>: "
9581 "Flush all flow director entries of a device on NIC",
9583 (void *)&cmd_flush_flow_director_flush,
9584 (void *)&cmd_flush_flow_director_port_id,
9589 /* *** deal with flow director mask *** */
9590 struct cmd_flow_director_mask_result {
9591 cmdline_fixed_string_t flow_director_mask;
9593 cmdline_fixed_string_t mode;
9594 cmdline_fixed_string_t mode_value;
9595 cmdline_fixed_string_t vlan;
9597 cmdline_fixed_string_t src_mask;
9598 cmdline_ipaddr_t ipv4_src;
9599 cmdline_ipaddr_t ipv6_src;
9601 cmdline_fixed_string_t dst_mask;
9602 cmdline_ipaddr_t ipv4_dst;
9603 cmdline_ipaddr_t ipv6_dst;
9605 cmdline_fixed_string_t mac;
9606 uint8_t mac_addr_byte_mask;
9607 cmdline_fixed_string_t tunnel_id;
9608 uint32_t tunnel_id_mask;
9609 cmdline_fixed_string_t tunnel_type;
9610 uint8_t tunnel_type_mask;
9614 cmd_flow_director_mask_parsed(void *parsed_result,
9615 __attribute__((unused)) struct cmdline *cl,
9616 __attribute__((unused)) void *data)
9618 struct cmd_flow_director_mask_result *res = parsed_result;
9619 struct rte_eth_fdir_masks *mask;
9620 struct rte_port *port;
9622 if (res->port_id > nb_ports) {
9623 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9627 port = &ports[res->port_id];
9628 /** Check if the port is not started **/
9629 if (port->port_status != RTE_PORT_STOPPED) {
9630 printf("Please stop port %d first\n", res->port_id);
9634 mask = &port->dev_conf.fdir_conf.mask;
9636 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9637 if (strcmp(res->mode_value, "MAC-VLAN")) {
9638 printf("Please set mode to MAC-VLAN.\n");
9642 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9643 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9644 if (strcmp(res->mode_value, "Tunnel")) {
9645 printf("Please set mode to Tunnel.\n");
9649 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9650 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9651 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9652 mask->tunnel_type_mask = res->tunnel_type_mask;
9654 if (strcmp(res->mode_value, "IP")) {
9655 printf("Please set mode to IP.\n");
9659 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9660 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9661 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9662 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9663 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9664 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9665 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9668 cmd_reconfig_device_queue(res->port_id, 1, 1);
9671 cmdline_parse_token_string_t cmd_flow_director_mask =
9672 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9673 flow_director_mask, "flow_director_mask");
9674 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9675 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9677 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9678 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9680 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9681 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9683 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9684 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9685 src_mask, "src_mask");
9686 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9687 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9689 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9690 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9692 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9693 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9695 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9696 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9697 dst_mask, "dst_mask");
9698 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9699 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9701 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9702 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9704 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9705 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9708 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9709 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9711 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9712 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9714 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9715 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9716 mode_value, "MAC-VLAN");
9717 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9718 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9719 mode_value, "Tunnel");
9720 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9721 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9723 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9724 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9725 mac_addr_byte_mask, UINT8);
9726 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9727 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9728 tunnel_type, "tunnel-type");
9729 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9730 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9731 tunnel_type_mask, UINT8);
9732 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9733 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9734 tunnel_id, "tunnel-id");
9735 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9736 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9737 tunnel_id_mask, UINT32);
9739 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9740 .f = cmd_flow_director_mask_parsed,
9742 .help_str = "flow_director_mask ... : "
9743 "Set IP mode flow director's mask on NIC",
9745 (void *)&cmd_flow_director_mask,
9746 (void *)&cmd_flow_director_mask_port_id,
9747 (void *)&cmd_flow_director_mask_mode,
9748 (void *)&cmd_flow_director_mask_mode_ip,
9749 (void *)&cmd_flow_director_mask_vlan,
9750 (void *)&cmd_flow_director_mask_vlan_value,
9751 (void *)&cmd_flow_director_mask_src,
9752 (void *)&cmd_flow_director_mask_ipv4_src,
9753 (void *)&cmd_flow_director_mask_ipv6_src,
9754 (void *)&cmd_flow_director_mask_port_src,
9755 (void *)&cmd_flow_director_mask_dst,
9756 (void *)&cmd_flow_director_mask_ipv4_dst,
9757 (void *)&cmd_flow_director_mask_ipv6_dst,
9758 (void *)&cmd_flow_director_mask_port_dst,
9763 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9764 .f = cmd_flow_director_mask_parsed,
9766 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9767 "flow director's mask on NIC",
9769 (void *)&cmd_flow_director_mask,
9770 (void *)&cmd_flow_director_mask_port_id,
9771 (void *)&cmd_flow_director_mask_mode,
9772 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9773 (void *)&cmd_flow_director_mask_vlan,
9774 (void *)&cmd_flow_director_mask_vlan_value,
9779 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9780 .f = cmd_flow_director_mask_parsed,
9782 .help_str = "flow_director_mask ... : Set tunnel mode "
9783 "flow director's mask on NIC",
9785 (void *)&cmd_flow_director_mask,
9786 (void *)&cmd_flow_director_mask_port_id,
9787 (void *)&cmd_flow_director_mask_mode,
9788 (void *)&cmd_flow_director_mask_mode_tunnel,
9789 (void *)&cmd_flow_director_mask_vlan,
9790 (void *)&cmd_flow_director_mask_vlan_value,
9791 (void *)&cmd_flow_director_mask_mac,
9792 (void *)&cmd_flow_director_mask_mac_value,
9793 (void *)&cmd_flow_director_mask_tunnel_type,
9794 (void *)&cmd_flow_director_mask_tunnel_type_value,
9795 (void *)&cmd_flow_director_mask_tunnel_id,
9796 (void *)&cmd_flow_director_mask_tunnel_id_value,
9801 /* *** deal with flow director mask on flexible payload *** */
9802 struct cmd_flow_director_flex_mask_result {
9803 cmdline_fixed_string_t flow_director_flexmask;
9805 cmdline_fixed_string_t flow;
9806 cmdline_fixed_string_t flow_type;
9807 cmdline_fixed_string_t mask;
9811 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9812 __attribute__((unused)) struct cmdline *cl,
9813 __attribute__((unused)) void *data)
9815 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9816 struct rte_eth_fdir_info fdir_info;
9817 struct rte_eth_fdir_flex_mask flex_mask;
9818 struct rte_port *port;
9819 uint32_t flow_type_mask;
9823 if (res->port_id > nb_ports) {
9824 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9828 port = &ports[res->port_id];
9829 /** Check if the port is not started **/
9830 if (port->port_status != RTE_PORT_STOPPED) {
9831 printf("Please stop port %d first\n", res->port_id);
9835 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9836 ret = parse_flexbytes(res->mask,
9838 RTE_ETH_FDIR_MAX_FLEXLEN);
9840 printf("error: Cannot parse mask input.\n");
9844 memset(&fdir_info, 0, sizeof(fdir_info));
9845 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9846 RTE_ETH_FILTER_INFO, &fdir_info);
9848 printf("Cannot get FDir filter info\n");
9852 if (!strcmp(res->flow_type, "none")) {
9853 /* means don't specify the flow type */
9854 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9855 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9856 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9857 0, sizeof(struct rte_eth_fdir_flex_mask));
9858 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9859 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9861 sizeof(struct rte_eth_fdir_flex_mask));
9862 cmd_reconfig_device_queue(res->port_id, 1, 1);
9865 flow_type_mask = fdir_info.flow_types_mask[0];
9866 if (!strcmp(res->flow_type, "all")) {
9867 if (!flow_type_mask) {
9868 printf("No flow type supported\n");
9871 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9872 if (flow_type_mask & (1 << i)) {
9873 flex_mask.flow_type = i;
9874 fdir_set_flex_mask(res->port_id, &flex_mask);
9877 cmd_reconfig_device_queue(res->port_id, 1, 1);
9880 flex_mask.flow_type = str2flowtype(res->flow_type);
9881 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9882 printf("Flow type %s not supported on port %d\n",
9883 res->flow_type, res->port_id);
9886 fdir_set_flex_mask(res->port_id, &flex_mask);
9887 cmd_reconfig_device_queue(res->port_id, 1, 1);
9890 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9891 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9892 flow_director_flexmask,
9893 "flow_director_flex_mask");
9894 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9895 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9897 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9900 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9902 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9903 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9904 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9905 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9908 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9909 .f = cmd_flow_director_flex_mask_parsed,
9911 .help_str = "flow_director_flex_mask ... : "
9912 "Set flow director's flex mask on NIC",
9914 (void *)&cmd_flow_director_flexmask,
9915 (void *)&cmd_flow_director_flexmask_port_id,
9916 (void *)&cmd_flow_director_flexmask_flow,
9917 (void *)&cmd_flow_director_flexmask_flow_type,
9918 (void *)&cmd_flow_director_flexmask_mask,
9923 /* *** deal with flow director flexible payload configuration *** */
9924 struct cmd_flow_director_flexpayload_result {
9925 cmdline_fixed_string_t flow_director_flexpayload;
9927 cmdline_fixed_string_t payload_layer;
9928 cmdline_fixed_string_t payload_cfg;
9932 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9935 const char *p, *p0 = q_arg;
9937 unsigned long int_fld;
9938 char *str_fld[max_num];
9943 p = strchr(p0, '(');
9947 p0 = strchr(p, ')');
9952 if (size >= sizeof(s))
9955 snprintf(s, sizeof(s), "%.*s", size, p);
9956 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9957 if (ret < 0 || ret > max_num)
9959 for (i = 0; i < ret; i++) {
9961 int_fld = strtoul(str_fld[i], &end, 0);
9962 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9964 offsets[i] = (uint16_t)int_fld;
9970 cmd_flow_director_flxpld_parsed(void *parsed_result,
9971 __attribute__((unused)) struct cmdline *cl,
9972 __attribute__((unused)) void *data)
9974 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9975 struct rte_eth_flex_payload_cfg flex_cfg;
9976 struct rte_port *port;
9979 if (res->port_id > nb_ports) {
9980 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9984 port = &ports[res->port_id];
9985 /** Check if the port is not started **/
9986 if (port->port_status != RTE_PORT_STOPPED) {
9987 printf("Please stop port %d first\n", res->port_id);
9991 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9993 if (!strcmp(res->payload_layer, "raw"))
9994 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9995 else if (!strcmp(res->payload_layer, "l2"))
9996 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9997 else if (!strcmp(res->payload_layer, "l3"))
9998 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9999 else if (!strcmp(res->payload_layer, "l4"))
10000 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10002 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10003 RTE_ETH_FDIR_MAX_FLEXLEN);
10005 printf("error: Cannot parse flex payload input.\n");
10009 fdir_set_flex_payload(res->port_id, &flex_cfg);
10010 cmd_reconfig_device_queue(res->port_id, 1, 1);
10013 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10014 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10015 flow_director_flexpayload,
10016 "flow_director_flex_payload");
10017 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10018 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10020 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10021 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10022 payload_layer, "raw#l2#l3#l4");
10023 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10024 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10025 payload_cfg, NULL);
10027 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10028 .f = cmd_flow_director_flxpld_parsed,
10030 .help_str = "flow_director_flexpayload ... : "
10031 "Set flow director's flex payload on NIC",
10033 (void *)&cmd_flow_director_flexpayload,
10034 (void *)&cmd_flow_director_flexpayload_port_id,
10035 (void *)&cmd_flow_director_flexpayload_payload_layer,
10036 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10041 /* Generic flow interface command. */
10042 extern cmdline_parse_inst_t cmd_flow;
10044 /* *** Classification Filters Control *** */
10045 /* *** Get symmetric hash enable per port *** */
10046 struct cmd_get_sym_hash_ena_per_port_result {
10047 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10052 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10053 __rte_unused struct cmdline *cl,
10054 __rte_unused void *data)
10056 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10057 struct rte_eth_hash_filter_info info;
10060 if (rte_eth_dev_filter_supported(res->port_id,
10061 RTE_ETH_FILTER_HASH) < 0) {
10062 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10067 memset(&info, 0, sizeof(info));
10068 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10069 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10070 RTE_ETH_FILTER_GET, &info);
10073 printf("Cannot get symmetric hash enable per port "
10074 "on port %u\n", res->port_id);
10078 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10079 "enabled" : "disabled", res->port_id);
10082 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10083 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10084 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10085 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10086 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10089 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10090 .f = cmd_get_sym_hash_per_port_parsed,
10092 .help_str = "get_sym_hash_ena_per_port <port_id>",
10094 (void *)&cmd_get_sym_hash_ena_per_port_all,
10095 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10100 /* *** Set symmetric hash enable per port *** */
10101 struct cmd_set_sym_hash_ena_per_port_result {
10102 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10103 cmdline_fixed_string_t enable;
10108 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10109 __rte_unused struct cmdline *cl,
10110 __rte_unused void *data)
10112 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10113 struct rte_eth_hash_filter_info info;
10116 if (rte_eth_dev_filter_supported(res->port_id,
10117 RTE_ETH_FILTER_HASH) < 0) {
10118 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10123 memset(&info, 0, sizeof(info));
10124 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10125 if (!strcmp(res->enable, "enable"))
10126 info.info.enable = 1;
10127 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10128 RTE_ETH_FILTER_SET, &info);
10130 printf("Cannot set symmetric hash enable per port on "
10131 "port %u\n", res->port_id);
10134 printf("Symmetric hash has been set to %s on port %u\n",
10135 res->enable, res->port_id);
10138 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
10139 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10140 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
10141 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
10142 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10144 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
10145 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10146 enable, "enable#disable");
10148 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
10149 .f = cmd_set_sym_hash_per_port_parsed,
10151 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
10153 (void *)&cmd_set_sym_hash_ena_per_port_all,
10154 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
10155 (void *)&cmd_set_sym_hash_ena_per_port_enable,
10160 /* Get global config of hash function */
10161 struct cmd_get_hash_global_config_result {
10162 cmdline_fixed_string_t get_hash_global_config;
10167 flowtype_to_str(uint16_t ftype)
10173 } ftype_table[] = {
10174 {"ipv4", RTE_ETH_FLOW_IPV4},
10175 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10176 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10177 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10178 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10179 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10180 {"ipv6", RTE_ETH_FLOW_IPV6},
10181 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10182 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10183 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10184 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10185 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10186 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10187 {"port", RTE_ETH_FLOW_PORT},
10188 {"vxlan", RTE_ETH_FLOW_VXLAN},
10189 {"geneve", RTE_ETH_FLOW_GENEVE},
10190 {"nvgre", RTE_ETH_FLOW_NVGRE},
10193 for (i = 0; i < RTE_DIM(ftype_table); i++) {
10194 if (ftype_table[i].ftype == ftype)
10195 return ftype_table[i].str;
10202 cmd_get_hash_global_config_parsed(void *parsed_result,
10203 __rte_unused struct cmdline *cl,
10204 __rte_unused void *data)
10206 struct cmd_get_hash_global_config_result *res = parsed_result;
10207 struct rte_eth_hash_filter_info info;
10208 uint32_t idx, offset;
10213 if (rte_eth_dev_filter_supported(res->port_id,
10214 RTE_ETH_FILTER_HASH) < 0) {
10215 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10220 memset(&info, 0, sizeof(info));
10221 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10222 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10223 RTE_ETH_FILTER_GET, &info);
10225 printf("Cannot get hash global configurations by port %d\n",
10230 switch (info.info.global_conf.hash_func) {
10231 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
10232 printf("Hash function is Toeplitz\n");
10234 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
10235 printf("Hash function is Simple XOR\n");
10238 printf("Unknown hash function\n");
10242 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
10243 idx = i / UINT32_BIT;
10244 offset = i % UINT32_BIT;
10245 if (!(info.info.global_conf.valid_bit_mask[idx] &
10248 str = flowtype_to_str(i);
10251 printf("Symmetric hash is %s globally for flow type %s "
10253 ((info.info.global_conf.sym_hash_enable_mask[idx] &
10254 (1UL << offset)) ? "enabled" : "disabled"), str,
10259 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
10260 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
10261 get_hash_global_config, "get_hash_global_config");
10262 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
10263 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
10266 cmdline_parse_inst_t cmd_get_hash_global_config = {
10267 .f = cmd_get_hash_global_config_parsed,
10269 .help_str = "get_hash_global_config <port_id>",
10271 (void *)&cmd_get_hash_global_config_all,
10272 (void *)&cmd_get_hash_global_config_port_id,
10277 /* Set global config of hash function */
10278 struct cmd_set_hash_global_config_result {
10279 cmdline_fixed_string_t set_hash_global_config;
10281 cmdline_fixed_string_t hash_func;
10282 cmdline_fixed_string_t flow_type;
10283 cmdline_fixed_string_t enable;
10287 cmd_set_hash_global_config_parsed(void *parsed_result,
10288 __rte_unused struct cmdline *cl,
10289 __rte_unused void *data)
10291 struct cmd_set_hash_global_config_result *res = parsed_result;
10292 struct rte_eth_hash_filter_info info;
10293 uint32_t ftype, idx, offset;
10296 if (rte_eth_dev_filter_supported(res->port_id,
10297 RTE_ETH_FILTER_HASH) < 0) {
10298 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10302 memset(&info, 0, sizeof(info));
10303 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10304 if (!strcmp(res->hash_func, "toeplitz"))
10305 info.info.global_conf.hash_func =
10306 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
10307 else if (!strcmp(res->hash_func, "simple_xor"))
10308 info.info.global_conf.hash_func =
10309 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
10310 else if (!strcmp(res->hash_func, "default"))
10311 info.info.global_conf.hash_func =
10312 RTE_ETH_HASH_FUNCTION_DEFAULT;
10314 ftype = str2flowtype(res->flow_type);
10315 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10316 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10317 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10318 if (!strcmp(res->enable, "enable"))
10319 info.info.global_conf.sym_hash_enable_mask[idx] |=
10321 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10322 RTE_ETH_FILTER_SET, &info);
10324 printf("Cannot set global hash configurations by port %d\n",
10327 printf("Global hash configurations have been set "
10328 "succcessfully by port %d\n", res->port_id);
10331 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10332 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10333 set_hash_global_config, "set_hash_global_config");
10334 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10335 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10337 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10338 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10339 hash_func, "toeplitz#simple_xor#default");
10340 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10341 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10343 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10344 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10345 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10346 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10347 enable, "enable#disable");
10349 cmdline_parse_inst_t cmd_set_hash_global_config = {
10350 .f = cmd_set_hash_global_config_parsed,
10352 .help_str = "set_hash_global_config <port_id> "
10353 "toeplitz|simple_xor|default "
10354 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10355 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10356 "l2_payload enable|disable",
10358 (void *)&cmd_set_hash_global_config_all,
10359 (void *)&cmd_set_hash_global_config_port_id,
10360 (void *)&cmd_set_hash_global_config_hash_func,
10361 (void *)&cmd_set_hash_global_config_flow_type,
10362 (void *)&cmd_set_hash_global_config_enable,
10367 /* Set hash input set */
10368 struct cmd_set_hash_input_set_result {
10369 cmdline_fixed_string_t set_hash_input_set;
10371 cmdline_fixed_string_t flow_type;
10372 cmdline_fixed_string_t inset_field;
10373 cmdline_fixed_string_t select;
10376 static enum rte_eth_input_set_field
10377 str2inset(char *string)
10381 static const struct {
10383 enum rte_eth_input_set_field inset;
10384 } inset_table[] = {
10385 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10386 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10387 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10388 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10389 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10390 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10391 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10392 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10393 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10394 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10395 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10396 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10397 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10398 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10399 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10400 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10401 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10402 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10403 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10404 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10405 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10406 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10407 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10408 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10409 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10410 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10411 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10412 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10413 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10414 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10415 {"none", RTE_ETH_INPUT_SET_NONE},
10418 for (i = 0; i < RTE_DIM(inset_table); i++) {
10419 if (!strcmp(string, inset_table[i].str))
10420 return inset_table[i].inset;
10423 return RTE_ETH_INPUT_SET_UNKNOWN;
10427 cmd_set_hash_input_set_parsed(void *parsed_result,
10428 __rte_unused struct cmdline *cl,
10429 __rte_unused void *data)
10431 struct cmd_set_hash_input_set_result *res = parsed_result;
10432 struct rte_eth_hash_filter_info info;
10434 memset(&info, 0, sizeof(info));
10435 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10436 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10437 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10438 info.info.input_set_conf.inset_size = 1;
10439 if (!strcmp(res->select, "select"))
10440 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10441 else if (!strcmp(res->select, "add"))
10442 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10443 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10444 RTE_ETH_FILTER_SET, &info);
10447 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10448 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10449 set_hash_input_set, "set_hash_input_set");
10450 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10451 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10453 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10454 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10456 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10457 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10458 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10459 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10461 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10462 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10463 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10464 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10465 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10467 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10468 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10469 select, "select#add");
10471 cmdline_parse_inst_t cmd_set_hash_input_set = {
10472 .f = cmd_set_hash_input_set_parsed,
10474 .help_str = "set_hash_input_set <port_id> "
10475 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10476 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10477 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10478 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10479 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10480 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10481 "fld-7th|fld-8th|none select|add",
10483 (void *)&cmd_set_hash_input_set_cmd,
10484 (void *)&cmd_set_hash_input_set_port_id,
10485 (void *)&cmd_set_hash_input_set_flow_type,
10486 (void *)&cmd_set_hash_input_set_field,
10487 (void *)&cmd_set_hash_input_set_select,
10492 /* Set flow director input set */
10493 struct cmd_set_fdir_input_set_result {
10494 cmdline_fixed_string_t set_fdir_input_set;
10496 cmdline_fixed_string_t flow_type;
10497 cmdline_fixed_string_t inset_field;
10498 cmdline_fixed_string_t select;
10502 cmd_set_fdir_input_set_parsed(void *parsed_result,
10503 __rte_unused struct cmdline *cl,
10504 __rte_unused void *data)
10506 struct cmd_set_fdir_input_set_result *res = parsed_result;
10507 struct rte_eth_fdir_filter_info info;
10509 memset(&info, 0, sizeof(info));
10510 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10511 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10512 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10513 info.info.input_set_conf.inset_size = 1;
10514 if (!strcmp(res->select, "select"))
10515 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10516 else if (!strcmp(res->select, "add"))
10517 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10518 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10519 RTE_ETH_FILTER_SET, &info);
10522 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10523 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10524 set_fdir_input_set, "set_fdir_input_set");
10525 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10526 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10528 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10529 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10531 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10532 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10533 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10534 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10536 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10537 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10538 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10539 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10540 "sctp-veri-tag#none");
10541 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10542 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10543 select, "select#add");
10545 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10546 .f = cmd_set_fdir_input_set_parsed,
10548 .help_str = "set_fdir_input_set <port_id> "
10549 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10550 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10551 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10552 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10553 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10554 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10555 "sctp-veri-tag|none select|add",
10557 (void *)&cmd_set_fdir_input_set_cmd,
10558 (void *)&cmd_set_fdir_input_set_port_id,
10559 (void *)&cmd_set_fdir_input_set_flow_type,
10560 (void *)&cmd_set_fdir_input_set_field,
10561 (void *)&cmd_set_fdir_input_set_select,
10566 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10567 struct cmd_mcast_addr_result {
10568 cmdline_fixed_string_t mcast_addr_cmd;
10569 cmdline_fixed_string_t what;
10571 struct ether_addr mc_addr;
10574 static void cmd_mcast_addr_parsed(void *parsed_result,
10575 __attribute__((unused)) struct cmdline *cl,
10576 __attribute__((unused)) void *data)
10578 struct cmd_mcast_addr_result *res = parsed_result;
10580 if (!is_multicast_ether_addr(&res->mc_addr)) {
10581 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10582 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10583 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10584 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10587 if (strcmp(res->what, "add") == 0)
10588 mcast_addr_add(res->port_num, &res->mc_addr);
10590 mcast_addr_remove(res->port_num, &res->mc_addr);
10593 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10594 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10595 mcast_addr_cmd, "mcast_addr");
10596 cmdline_parse_token_string_t cmd_mcast_addr_what =
10597 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10599 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10600 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10601 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10602 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10604 cmdline_parse_inst_t cmd_mcast_addr = {
10605 .f = cmd_mcast_addr_parsed,
10607 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10608 "Add/Remove multicast MAC address on port_id",
10610 (void *)&cmd_mcast_addr_cmd,
10611 (void *)&cmd_mcast_addr_what,
10612 (void *)&cmd_mcast_addr_portnum,
10613 (void *)&cmd_mcast_addr_addr,
10618 /* l2 tunnel config
10619 * only support E-tag now.
10622 /* Ether type config */
10623 struct cmd_config_l2_tunnel_eth_type_result {
10624 cmdline_fixed_string_t port;
10625 cmdline_fixed_string_t config;
10626 cmdline_fixed_string_t all;
10628 cmdline_fixed_string_t l2_tunnel;
10629 cmdline_fixed_string_t l2_tunnel_type;
10630 cmdline_fixed_string_t eth_type;
10631 uint16_t eth_type_val;
10634 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10635 TOKEN_STRING_INITIALIZER
10636 (struct cmd_config_l2_tunnel_eth_type_result,
10638 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10639 TOKEN_STRING_INITIALIZER
10640 (struct cmd_config_l2_tunnel_eth_type_result,
10642 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10643 TOKEN_STRING_INITIALIZER
10644 (struct cmd_config_l2_tunnel_eth_type_result,
10646 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10647 TOKEN_NUM_INITIALIZER
10648 (struct cmd_config_l2_tunnel_eth_type_result,
10650 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10651 TOKEN_STRING_INITIALIZER
10652 (struct cmd_config_l2_tunnel_eth_type_result,
10653 l2_tunnel, "l2-tunnel");
10654 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10655 TOKEN_STRING_INITIALIZER
10656 (struct cmd_config_l2_tunnel_eth_type_result,
10657 l2_tunnel_type, "E-tag");
10658 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10659 TOKEN_STRING_INITIALIZER
10660 (struct cmd_config_l2_tunnel_eth_type_result,
10661 eth_type, "ether-type");
10662 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10663 TOKEN_NUM_INITIALIZER
10664 (struct cmd_config_l2_tunnel_eth_type_result,
10665 eth_type_val, UINT16);
10667 static enum rte_eth_tunnel_type
10668 str2fdir_l2_tunnel_type(char *string)
10672 static const struct {
10674 enum rte_eth_tunnel_type type;
10675 } l2_tunnel_type_str[] = {
10676 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10679 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10680 if (!strcmp(l2_tunnel_type_str[i].str, string))
10681 return l2_tunnel_type_str[i].type;
10683 return RTE_TUNNEL_TYPE_NONE;
10686 /* ether type config for all ports */
10688 cmd_config_l2_tunnel_eth_type_all_parsed
10689 (void *parsed_result,
10690 __attribute__((unused)) struct cmdline *cl,
10691 __attribute__((unused)) void *data)
10693 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10694 struct rte_eth_l2_tunnel_conf entry;
10697 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10698 entry.ether_type = res->eth_type_val;
10700 RTE_ETH_FOREACH_DEV(pid) {
10701 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10705 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10706 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10708 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10710 (void *)&cmd_config_l2_tunnel_eth_type_port,
10711 (void *)&cmd_config_l2_tunnel_eth_type_config,
10712 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10713 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10714 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10715 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10716 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10721 /* ether type config for a specific port */
10723 cmd_config_l2_tunnel_eth_type_specific_parsed(
10724 void *parsed_result,
10725 __attribute__((unused)) struct cmdline *cl,
10726 __attribute__((unused)) void *data)
10728 struct cmd_config_l2_tunnel_eth_type_result *res =
10730 struct rte_eth_l2_tunnel_conf entry;
10732 if (port_id_is_invalid(res->id, ENABLED_WARN))
10735 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10736 entry.ether_type = res->eth_type_val;
10738 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10741 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10742 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10744 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10746 (void *)&cmd_config_l2_tunnel_eth_type_port,
10747 (void *)&cmd_config_l2_tunnel_eth_type_config,
10748 (void *)&cmd_config_l2_tunnel_eth_type_id,
10749 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10750 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10751 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10752 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10757 /* Enable/disable l2 tunnel */
10758 struct cmd_config_l2_tunnel_en_dis_result {
10759 cmdline_fixed_string_t port;
10760 cmdline_fixed_string_t config;
10761 cmdline_fixed_string_t all;
10763 cmdline_fixed_string_t l2_tunnel;
10764 cmdline_fixed_string_t l2_tunnel_type;
10765 cmdline_fixed_string_t en_dis;
10768 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10769 TOKEN_STRING_INITIALIZER
10770 (struct cmd_config_l2_tunnel_en_dis_result,
10772 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10773 TOKEN_STRING_INITIALIZER
10774 (struct cmd_config_l2_tunnel_en_dis_result,
10776 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10777 TOKEN_STRING_INITIALIZER
10778 (struct cmd_config_l2_tunnel_en_dis_result,
10780 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10781 TOKEN_NUM_INITIALIZER
10782 (struct cmd_config_l2_tunnel_en_dis_result,
10784 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10785 TOKEN_STRING_INITIALIZER
10786 (struct cmd_config_l2_tunnel_en_dis_result,
10787 l2_tunnel, "l2-tunnel");
10788 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10789 TOKEN_STRING_INITIALIZER
10790 (struct cmd_config_l2_tunnel_en_dis_result,
10791 l2_tunnel_type, "E-tag");
10792 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10793 TOKEN_STRING_INITIALIZER
10794 (struct cmd_config_l2_tunnel_en_dis_result,
10795 en_dis, "enable#disable");
10797 /* enable/disable l2 tunnel for all ports */
10799 cmd_config_l2_tunnel_en_dis_all_parsed(
10800 void *parsed_result,
10801 __attribute__((unused)) struct cmdline *cl,
10802 __attribute__((unused)) void *data)
10804 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10805 struct rte_eth_l2_tunnel_conf entry;
10809 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10811 if (!strcmp("enable", res->en_dis))
10816 RTE_ETH_FOREACH_DEV(pid) {
10817 rte_eth_dev_l2_tunnel_offload_set(pid,
10819 ETH_L2_TUNNEL_ENABLE_MASK,
10824 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10825 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10827 .help_str = "port config all l2-tunnel E-tag enable|disable",
10829 (void *)&cmd_config_l2_tunnel_en_dis_port,
10830 (void *)&cmd_config_l2_tunnel_en_dis_config,
10831 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10832 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10833 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10834 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10839 /* enable/disable l2 tunnel for a port */
10841 cmd_config_l2_tunnel_en_dis_specific_parsed(
10842 void *parsed_result,
10843 __attribute__((unused)) struct cmdline *cl,
10844 __attribute__((unused)) void *data)
10846 struct cmd_config_l2_tunnel_en_dis_result *res =
10848 struct rte_eth_l2_tunnel_conf entry;
10850 if (port_id_is_invalid(res->id, ENABLED_WARN))
10853 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10855 if (!strcmp("enable", res->en_dis))
10856 rte_eth_dev_l2_tunnel_offload_set(res->id,
10858 ETH_L2_TUNNEL_ENABLE_MASK,
10861 rte_eth_dev_l2_tunnel_offload_set(res->id,
10863 ETH_L2_TUNNEL_ENABLE_MASK,
10867 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10868 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10870 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10872 (void *)&cmd_config_l2_tunnel_en_dis_port,
10873 (void *)&cmd_config_l2_tunnel_en_dis_config,
10874 (void *)&cmd_config_l2_tunnel_en_dis_id,
10875 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10876 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10877 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10882 /* E-tag configuration */
10884 /* Common result structure for all E-tag configuration */
10885 struct cmd_config_e_tag_result {
10886 cmdline_fixed_string_t e_tag;
10887 cmdline_fixed_string_t set;
10888 cmdline_fixed_string_t insertion;
10889 cmdline_fixed_string_t stripping;
10890 cmdline_fixed_string_t forwarding;
10891 cmdline_fixed_string_t filter;
10892 cmdline_fixed_string_t add;
10893 cmdline_fixed_string_t del;
10894 cmdline_fixed_string_t on;
10895 cmdline_fixed_string_t off;
10896 cmdline_fixed_string_t on_off;
10897 cmdline_fixed_string_t port_tag_id;
10898 uint32_t port_tag_id_val;
10899 cmdline_fixed_string_t e_tag_id;
10900 uint16_t e_tag_id_val;
10901 cmdline_fixed_string_t dst_pool;
10902 uint8_t dst_pool_val;
10903 cmdline_fixed_string_t port;
10905 cmdline_fixed_string_t vf;
10909 /* Common CLI fields for all E-tag configuration */
10910 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10911 TOKEN_STRING_INITIALIZER
10912 (struct cmd_config_e_tag_result,
10914 cmdline_parse_token_string_t cmd_config_e_tag_set =
10915 TOKEN_STRING_INITIALIZER
10916 (struct cmd_config_e_tag_result,
10918 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10919 TOKEN_STRING_INITIALIZER
10920 (struct cmd_config_e_tag_result,
10921 insertion, "insertion");
10922 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10923 TOKEN_STRING_INITIALIZER
10924 (struct cmd_config_e_tag_result,
10925 stripping, "stripping");
10926 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10927 TOKEN_STRING_INITIALIZER
10928 (struct cmd_config_e_tag_result,
10929 forwarding, "forwarding");
10930 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10931 TOKEN_STRING_INITIALIZER
10932 (struct cmd_config_e_tag_result,
10934 cmdline_parse_token_string_t cmd_config_e_tag_add =
10935 TOKEN_STRING_INITIALIZER
10936 (struct cmd_config_e_tag_result,
10938 cmdline_parse_token_string_t cmd_config_e_tag_del =
10939 TOKEN_STRING_INITIALIZER
10940 (struct cmd_config_e_tag_result,
10942 cmdline_parse_token_string_t cmd_config_e_tag_on =
10943 TOKEN_STRING_INITIALIZER
10944 (struct cmd_config_e_tag_result,
10946 cmdline_parse_token_string_t cmd_config_e_tag_off =
10947 TOKEN_STRING_INITIALIZER
10948 (struct cmd_config_e_tag_result,
10950 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10951 TOKEN_STRING_INITIALIZER
10952 (struct cmd_config_e_tag_result,
10954 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10955 TOKEN_STRING_INITIALIZER
10956 (struct cmd_config_e_tag_result,
10957 port_tag_id, "port-tag-id");
10958 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10959 TOKEN_NUM_INITIALIZER
10960 (struct cmd_config_e_tag_result,
10961 port_tag_id_val, UINT32);
10962 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10963 TOKEN_STRING_INITIALIZER
10964 (struct cmd_config_e_tag_result,
10965 e_tag_id, "e-tag-id");
10966 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10967 TOKEN_NUM_INITIALIZER
10968 (struct cmd_config_e_tag_result,
10969 e_tag_id_val, UINT16);
10970 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10971 TOKEN_STRING_INITIALIZER
10972 (struct cmd_config_e_tag_result,
10973 dst_pool, "dst-pool");
10974 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10975 TOKEN_NUM_INITIALIZER
10976 (struct cmd_config_e_tag_result,
10977 dst_pool_val, UINT8);
10978 cmdline_parse_token_string_t cmd_config_e_tag_port =
10979 TOKEN_STRING_INITIALIZER
10980 (struct cmd_config_e_tag_result,
10982 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10983 TOKEN_NUM_INITIALIZER
10984 (struct cmd_config_e_tag_result,
10986 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10987 TOKEN_STRING_INITIALIZER
10988 (struct cmd_config_e_tag_result,
10990 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10991 TOKEN_NUM_INITIALIZER
10992 (struct cmd_config_e_tag_result,
10995 /* E-tag insertion configuration */
10997 cmd_config_e_tag_insertion_en_parsed(
10998 void *parsed_result,
10999 __attribute__((unused)) struct cmdline *cl,
11000 __attribute__((unused)) void *data)
11002 struct cmd_config_e_tag_result *res =
11004 struct rte_eth_l2_tunnel_conf entry;
11006 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11009 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11010 entry.tunnel_id = res->port_tag_id_val;
11011 entry.vf_id = res->vf_id;
11012 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11014 ETH_L2_TUNNEL_INSERTION_MASK,
11019 cmd_config_e_tag_insertion_dis_parsed(
11020 void *parsed_result,
11021 __attribute__((unused)) struct cmdline *cl,
11022 __attribute__((unused)) void *data)
11024 struct cmd_config_e_tag_result *res =
11026 struct rte_eth_l2_tunnel_conf entry;
11028 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11031 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11032 entry.vf_id = res->vf_id;
11034 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11036 ETH_L2_TUNNEL_INSERTION_MASK,
11040 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11041 .f = cmd_config_e_tag_insertion_en_parsed,
11043 .help_str = "E-tag ... : E-tag insertion enable",
11045 (void *)&cmd_config_e_tag_e_tag,
11046 (void *)&cmd_config_e_tag_set,
11047 (void *)&cmd_config_e_tag_insertion,
11048 (void *)&cmd_config_e_tag_on,
11049 (void *)&cmd_config_e_tag_port_tag_id,
11050 (void *)&cmd_config_e_tag_port_tag_id_val,
11051 (void *)&cmd_config_e_tag_port,
11052 (void *)&cmd_config_e_tag_port_id,
11053 (void *)&cmd_config_e_tag_vf,
11054 (void *)&cmd_config_e_tag_vf_id,
11059 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11060 .f = cmd_config_e_tag_insertion_dis_parsed,
11062 .help_str = "E-tag ... : E-tag insertion disable",
11064 (void *)&cmd_config_e_tag_e_tag,
11065 (void *)&cmd_config_e_tag_set,
11066 (void *)&cmd_config_e_tag_insertion,
11067 (void *)&cmd_config_e_tag_off,
11068 (void *)&cmd_config_e_tag_port,
11069 (void *)&cmd_config_e_tag_port_id,
11070 (void *)&cmd_config_e_tag_vf,
11071 (void *)&cmd_config_e_tag_vf_id,
11076 /* E-tag stripping configuration */
11078 cmd_config_e_tag_stripping_parsed(
11079 void *parsed_result,
11080 __attribute__((unused)) struct cmdline *cl,
11081 __attribute__((unused)) void *data)
11083 struct cmd_config_e_tag_result *res =
11085 struct rte_eth_l2_tunnel_conf entry;
11087 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11090 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11092 if (!strcmp(res->on_off, "on"))
11093 rte_eth_dev_l2_tunnel_offload_set
11096 ETH_L2_TUNNEL_STRIPPING_MASK,
11099 rte_eth_dev_l2_tunnel_offload_set
11102 ETH_L2_TUNNEL_STRIPPING_MASK,
11106 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11107 .f = cmd_config_e_tag_stripping_parsed,
11109 .help_str = "E-tag ... : E-tag stripping enable/disable",
11111 (void *)&cmd_config_e_tag_e_tag,
11112 (void *)&cmd_config_e_tag_set,
11113 (void *)&cmd_config_e_tag_stripping,
11114 (void *)&cmd_config_e_tag_on_off,
11115 (void *)&cmd_config_e_tag_port,
11116 (void *)&cmd_config_e_tag_port_id,
11121 /* E-tag forwarding configuration */
11123 cmd_config_e_tag_forwarding_parsed(
11124 void *parsed_result,
11125 __attribute__((unused)) struct cmdline *cl,
11126 __attribute__((unused)) void *data)
11128 struct cmd_config_e_tag_result *res = parsed_result;
11129 struct rte_eth_l2_tunnel_conf entry;
11131 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11134 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11136 if (!strcmp(res->on_off, "on"))
11137 rte_eth_dev_l2_tunnel_offload_set
11140 ETH_L2_TUNNEL_FORWARDING_MASK,
11143 rte_eth_dev_l2_tunnel_offload_set
11146 ETH_L2_TUNNEL_FORWARDING_MASK,
11150 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11151 .f = cmd_config_e_tag_forwarding_parsed,
11153 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11155 (void *)&cmd_config_e_tag_e_tag,
11156 (void *)&cmd_config_e_tag_set,
11157 (void *)&cmd_config_e_tag_forwarding,
11158 (void *)&cmd_config_e_tag_on_off,
11159 (void *)&cmd_config_e_tag_port,
11160 (void *)&cmd_config_e_tag_port_id,
11165 /* E-tag filter configuration */
11167 cmd_config_e_tag_filter_add_parsed(
11168 void *parsed_result,
11169 __attribute__((unused)) struct cmdline *cl,
11170 __attribute__((unused)) void *data)
11172 struct cmd_config_e_tag_result *res = parsed_result;
11173 struct rte_eth_l2_tunnel_conf entry;
11176 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11179 if (res->e_tag_id_val > 0x3fff) {
11180 printf("e-tag-id must be equal or less than 0x3fff.\n");
11184 ret = rte_eth_dev_filter_supported(res->port_id,
11185 RTE_ETH_FILTER_L2_TUNNEL);
11187 printf("E-tag filter is not supported on port %u.\n",
11192 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11193 entry.tunnel_id = res->e_tag_id_val;
11194 entry.pool = res->dst_pool_val;
11196 ret = rte_eth_dev_filter_ctrl(res->port_id,
11197 RTE_ETH_FILTER_L2_TUNNEL,
11198 RTE_ETH_FILTER_ADD,
11201 printf("E-tag filter programming error: (%s)\n",
11205 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
11206 .f = cmd_config_e_tag_filter_add_parsed,
11208 .help_str = "E-tag ... : E-tag filter add",
11210 (void *)&cmd_config_e_tag_e_tag,
11211 (void *)&cmd_config_e_tag_set,
11212 (void *)&cmd_config_e_tag_filter,
11213 (void *)&cmd_config_e_tag_add,
11214 (void *)&cmd_config_e_tag_e_tag_id,
11215 (void *)&cmd_config_e_tag_e_tag_id_val,
11216 (void *)&cmd_config_e_tag_dst_pool,
11217 (void *)&cmd_config_e_tag_dst_pool_val,
11218 (void *)&cmd_config_e_tag_port,
11219 (void *)&cmd_config_e_tag_port_id,
11225 cmd_config_e_tag_filter_del_parsed(
11226 void *parsed_result,
11227 __attribute__((unused)) struct cmdline *cl,
11228 __attribute__((unused)) void *data)
11230 struct cmd_config_e_tag_result *res = parsed_result;
11231 struct rte_eth_l2_tunnel_conf entry;
11234 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11237 if (res->e_tag_id_val > 0x3fff) {
11238 printf("e-tag-id must be less than 0x3fff.\n");
11242 ret = rte_eth_dev_filter_supported(res->port_id,
11243 RTE_ETH_FILTER_L2_TUNNEL);
11245 printf("E-tag filter is not supported on port %u.\n",
11250 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11251 entry.tunnel_id = res->e_tag_id_val;
11253 ret = rte_eth_dev_filter_ctrl(res->port_id,
11254 RTE_ETH_FILTER_L2_TUNNEL,
11255 RTE_ETH_FILTER_DELETE,
11258 printf("E-tag filter programming error: (%s)\n",
11262 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
11263 .f = cmd_config_e_tag_filter_del_parsed,
11265 .help_str = "E-tag ... : E-tag filter delete",
11267 (void *)&cmd_config_e_tag_e_tag,
11268 (void *)&cmd_config_e_tag_set,
11269 (void *)&cmd_config_e_tag_filter,
11270 (void *)&cmd_config_e_tag_del,
11271 (void *)&cmd_config_e_tag_e_tag_id,
11272 (void *)&cmd_config_e_tag_e_tag_id_val,
11273 (void *)&cmd_config_e_tag_port,
11274 (void *)&cmd_config_e_tag_port_id,
11279 /* vf vlan anti spoof configuration */
11281 /* Common result structure for vf vlan anti spoof */
11282 struct cmd_vf_vlan_anti_spoof_result {
11283 cmdline_fixed_string_t set;
11284 cmdline_fixed_string_t vf;
11285 cmdline_fixed_string_t vlan;
11286 cmdline_fixed_string_t antispoof;
11289 cmdline_fixed_string_t on_off;
11292 /* Common CLI fields for vf vlan anti spoof enable disable */
11293 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11294 TOKEN_STRING_INITIALIZER
11295 (struct cmd_vf_vlan_anti_spoof_result,
11297 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11298 TOKEN_STRING_INITIALIZER
11299 (struct cmd_vf_vlan_anti_spoof_result,
11301 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11302 TOKEN_STRING_INITIALIZER
11303 (struct cmd_vf_vlan_anti_spoof_result,
11305 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11306 TOKEN_STRING_INITIALIZER
11307 (struct cmd_vf_vlan_anti_spoof_result,
11308 antispoof, "antispoof");
11309 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11310 TOKEN_NUM_INITIALIZER
11311 (struct cmd_vf_vlan_anti_spoof_result,
11313 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11314 TOKEN_NUM_INITIALIZER
11315 (struct cmd_vf_vlan_anti_spoof_result,
11317 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11318 TOKEN_STRING_INITIALIZER
11319 (struct cmd_vf_vlan_anti_spoof_result,
11323 cmd_set_vf_vlan_anti_spoof_parsed(
11324 void *parsed_result,
11325 __attribute__((unused)) struct cmdline *cl,
11326 __attribute__((unused)) void *data)
11328 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11329 int ret = -ENOTSUP;
11331 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11333 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11336 #ifdef RTE_LIBRTE_IXGBE_PMD
11337 if (ret == -ENOTSUP)
11338 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11339 res->vf_id, is_on);
11341 #ifdef RTE_LIBRTE_I40E_PMD
11342 if (ret == -ENOTSUP)
11343 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11344 res->vf_id, is_on);
11346 #ifdef RTE_LIBRTE_BNXT_PMD
11347 if (ret == -ENOTSUP)
11348 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11349 res->vf_id, is_on);
11356 printf("invalid vf_id %d\n", res->vf_id);
11359 printf("invalid port_id %d\n", res->port_id);
11362 printf("function not implemented\n");
11365 printf("programming error: (%s)\n", strerror(-ret));
11369 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11370 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11372 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11374 (void *)&cmd_vf_vlan_anti_spoof_set,
11375 (void *)&cmd_vf_vlan_anti_spoof_vf,
11376 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11377 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11378 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11379 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11380 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11385 /* vf mac anti spoof configuration */
11387 /* Common result structure for vf mac anti spoof */
11388 struct cmd_vf_mac_anti_spoof_result {
11389 cmdline_fixed_string_t set;
11390 cmdline_fixed_string_t vf;
11391 cmdline_fixed_string_t mac;
11392 cmdline_fixed_string_t antispoof;
11395 cmdline_fixed_string_t on_off;
11398 /* Common CLI fields for vf mac anti spoof enable disable */
11399 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11400 TOKEN_STRING_INITIALIZER
11401 (struct cmd_vf_mac_anti_spoof_result,
11403 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11404 TOKEN_STRING_INITIALIZER
11405 (struct cmd_vf_mac_anti_spoof_result,
11407 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11408 TOKEN_STRING_INITIALIZER
11409 (struct cmd_vf_mac_anti_spoof_result,
11411 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11412 TOKEN_STRING_INITIALIZER
11413 (struct cmd_vf_mac_anti_spoof_result,
11414 antispoof, "antispoof");
11415 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11416 TOKEN_NUM_INITIALIZER
11417 (struct cmd_vf_mac_anti_spoof_result,
11419 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11420 TOKEN_NUM_INITIALIZER
11421 (struct cmd_vf_mac_anti_spoof_result,
11423 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11424 TOKEN_STRING_INITIALIZER
11425 (struct cmd_vf_mac_anti_spoof_result,
11429 cmd_set_vf_mac_anti_spoof_parsed(
11430 void *parsed_result,
11431 __attribute__((unused)) struct cmdline *cl,
11432 __attribute__((unused)) void *data)
11434 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11435 int ret = -ENOTSUP;
11437 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11439 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11442 #ifdef RTE_LIBRTE_IXGBE_PMD
11443 if (ret == -ENOTSUP)
11444 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11445 res->vf_id, is_on);
11447 #ifdef RTE_LIBRTE_I40E_PMD
11448 if (ret == -ENOTSUP)
11449 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11450 res->vf_id, is_on);
11452 #ifdef RTE_LIBRTE_BNXT_PMD
11453 if (ret == -ENOTSUP)
11454 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11455 res->vf_id, is_on);
11462 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11465 printf("invalid port_id %d\n", res->port_id);
11468 printf("function not implemented\n");
11471 printf("programming error: (%s)\n", strerror(-ret));
11475 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11476 .f = cmd_set_vf_mac_anti_spoof_parsed,
11478 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11480 (void *)&cmd_vf_mac_anti_spoof_set,
11481 (void *)&cmd_vf_mac_anti_spoof_vf,
11482 (void *)&cmd_vf_mac_anti_spoof_mac,
11483 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11484 (void *)&cmd_vf_mac_anti_spoof_port_id,
11485 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11486 (void *)&cmd_vf_mac_anti_spoof_on_off,
11491 /* vf vlan strip queue configuration */
11493 /* Common result structure for vf mac anti spoof */
11494 struct cmd_vf_vlan_stripq_result {
11495 cmdline_fixed_string_t set;
11496 cmdline_fixed_string_t vf;
11497 cmdline_fixed_string_t vlan;
11498 cmdline_fixed_string_t stripq;
11501 cmdline_fixed_string_t on_off;
11504 /* Common CLI fields for vf vlan strip enable disable */
11505 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11506 TOKEN_STRING_INITIALIZER
11507 (struct cmd_vf_vlan_stripq_result,
11509 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11510 TOKEN_STRING_INITIALIZER
11511 (struct cmd_vf_vlan_stripq_result,
11513 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11514 TOKEN_STRING_INITIALIZER
11515 (struct cmd_vf_vlan_stripq_result,
11517 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11518 TOKEN_STRING_INITIALIZER
11519 (struct cmd_vf_vlan_stripq_result,
11521 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11522 TOKEN_NUM_INITIALIZER
11523 (struct cmd_vf_vlan_stripq_result,
11525 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11526 TOKEN_NUM_INITIALIZER
11527 (struct cmd_vf_vlan_stripq_result,
11529 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11530 TOKEN_STRING_INITIALIZER
11531 (struct cmd_vf_vlan_stripq_result,
11535 cmd_set_vf_vlan_stripq_parsed(
11536 void *parsed_result,
11537 __attribute__((unused)) struct cmdline *cl,
11538 __attribute__((unused)) void *data)
11540 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11541 int ret = -ENOTSUP;
11543 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11545 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11548 #ifdef RTE_LIBRTE_IXGBE_PMD
11549 if (ret == -ENOTSUP)
11550 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11551 res->vf_id, is_on);
11553 #ifdef RTE_LIBRTE_I40E_PMD
11554 if (ret == -ENOTSUP)
11555 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11556 res->vf_id, is_on);
11558 #ifdef RTE_LIBRTE_BNXT_PMD
11559 if (ret == -ENOTSUP)
11560 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11561 res->vf_id, is_on);
11568 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11571 printf("invalid port_id %d\n", res->port_id);
11574 printf("function not implemented\n");
11577 printf("programming error: (%s)\n", strerror(-ret));
11581 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11582 .f = cmd_set_vf_vlan_stripq_parsed,
11584 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11586 (void *)&cmd_vf_vlan_stripq_set,
11587 (void *)&cmd_vf_vlan_stripq_vf,
11588 (void *)&cmd_vf_vlan_stripq_vlan,
11589 (void *)&cmd_vf_vlan_stripq_stripq,
11590 (void *)&cmd_vf_vlan_stripq_port_id,
11591 (void *)&cmd_vf_vlan_stripq_vf_id,
11592 (void *)&cmd_vf_vlan_stripq_on_off,
11597 /* vf vlan insert configuration */
11599 /* Common result structure for vf vlan insert */
11600 struct cmd_vf_vlan_insert_result {
11601 cmdline_fixed_string_t set;
11602 cmdline_fixed_string_t vf;
11603 cmdline_fixed_string_t vlan;
11604 cmdline_fixed_string_t insert;
11610 /* Common CLI fields for vf vlan insert enable disable */
11611 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11612 TOKEN_STRING_INITIALIZER
11613 (struct cmd_vf_vlan_insert_result,
11615 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11616 TOKEN_STRING_INITIALIZER
11617 (struct cmd_vf_vlan_insert_result,
11619 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11620 TOKEN_STRING_INITIALIZER
11621 (struct cmd_vf_vlan_insert_result,
11623 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11624 TOKEN_STRING_INITIALIZER
11625 (struct cmd_vf_vlan_insert_result,
11627 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11628 TOKEN_NUM_INITIALIZER
11629 (struct cmd_vf_vlan_insert_result,
11631 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11632 TOKEN_NUM_INITIALIZER
11633 (struct cmd_vf_vlan_insert_result,
11635 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11636 TOKEN_NUM_INITIALIZER
11637 (struct cmd_vf_vlan_insert_result,
11641 cmd_set_vf_vlan_insert_parsed(
11642 void *parsed_result,
11643 __attribute__((unused)) struct cmdline *cl,
11644 __attribute__((unused)) void *data)
11646 struct cmd_vf_vlan_insert_result *res = parsed_result;
11647 int ret = -ENOTSUP;
11649 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11652 #ifdef RTE_LIBRTE_IXGBE_PMD
11653 if (ret == -ENOTSUP)
11654 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11657 #ifdef RTE_LIBRTE_I40E_PMD
11658 if (ret == -ENOTSUP)
11659 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11662 #ifdef RTE_LIBRTE_BNXT_PMD
11663 if (ret == -ENOTSUP)
11664 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11672 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11675 printf("invalid port_id %d\n", res->port_id);
11678 printf("function not implemented\n");
11681 printf("programming error: (%s)\n", strerror(-ret));
11685 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11686 .f = cmd_set_vf_vlan_insert_parsed,
11688 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11690 (void *)&cmd_vf_vlan_insert_set,
11691 (void *)&cmd_vf_vlan_insert_vf,
11692 (void *)&cmd_vf_vlan_insert_vlan,
11693 (void *)&cmd_vf_vlan_insert_insert,
11694 (void *)&cmd_vf_vlan_insert_port_id,
11695 (void *)&cmd_vf_vlan_insert_vf_id,
11696 (void *)&cmd_vf_vlan_insert_vlan_id,
11701 /* tx loopback configuration */
11703 /* Common result structure for tx loopback */
11704 struct cmd_tx_loopback_result {
11705 cmdline_fixed_string_t set;
11706 cmdline_fixed_string_t tx;
11707 cmdline_fixed_string_t loopback;
11709 cmdline_fixed_string_t on_off;
11712 /* Common CLI fields for tx loopback enable disable */
11713 cmdline_parse_token_string_t cmd_tx_loopback_set =
11714 TOKEN_STRING_INITIALIZER
11715 (struct cmd_tx_loopback_result,
11717 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11718 TOKEN_STRING_INITIALIZER
11719 (struct cmd_tx_loopback_result,
11721 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11722 TOKEN_STRING_INITIALIZER
11723 (struct cmd_tx_loopback_result,
11724 loopback, "loopback");
11725 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11726 TOKEN_NUM_INITIALIZER
11727 (struct cmd_tx_loopback_result,
11729 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11730 TOKEN_STRING_INITIALIZER
11731 (struct cmd_tx_loopback_result,
11735 cmd_set_tx_loopback_parsed(
11736 void *parsed_result,
11737 __attribute__((unused)) struct cmdline *cl,
11738 __attribute__((unused)) void *data)
11740 struct cmd_tx_loopback_result *res = parsed_result;
11741 int ret = -ENOTSUP;
11743 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11745 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11748 #ifdef RTE_LIBRTE_IXGBE_PMD
11749 if (ret == -ENOTSUP)
11750 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11752 #ifdef RTE_LIBRTE_I40E_PMD
11753 if (ret == -ENOTSUP)
11754 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11756 #ifdef RTE_LIBRTE_BNXT_PMD
11757 if (ret == -ENOTSUP)
11758 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11765 printf("invalid is_on %d\n", is_on);
11768 printf("invalid port_id %d\n", res->port_id);
11771 printf("function not implemented\n");
11774 printf("programming error: (%s)\n", strerror(-ret));
11778 cmdline_parse_inst_t cmd_set_tx_loopback = {
11779 .f = cmd_set_tx_loopback_parsed,
11781 .help_str = "set tx loopback <port_id> on|off",
11783 (void *)&cmd_tx_loopback_set,
11784 (void *)&cmd_tx_loopback_tx,
11785 (void *)&cmd_tx_loopback_loopback,
11786 (void *)&cmd_tx_loopback_port_id,
11787 (void *)&cmd_tx_loopback_on_off,
11792 /* all queues drop enable configuration */
11794 /* Common result structure for all queues drop enable */
11795 struct cmd_all_queues_drop_en_result {
11796 cmdline_fixed_string_t set;
11797 cmdline_fixed_string_t all;
11798 cmdline_fixed_string_t queues;
11799 cmdline_fixed_string_t drop;
11801 cmdline_fixed_string_t on_off;
11804 /* Common CLI fields for tx loopback enable disable */
11805 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11806 TOKEN_STRING_INITIALIZER
11807 (struct cmd_all_queues_drop_en_result,
11809 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11810 TOKEN_STRING_INITIALIZER
11811 (struct cmd_all_queues_drop_en_result,
11813 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11814 TOKEN_STRING_INITIALIZER
11815 (struct cmd_all_queues_drop_en_result,
11817 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11818 TOKEN_STRING_INITIALIZER
11819 (struct cmd_all_queues_drop_en_result,
11821 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11822 TOKEN_NUM_INITIALIZER
11823 (struct cmd_all_queues_drop_en_result,
11825 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11826 TOKEN_STRING_INITIALIZER
11827 (struct cmd_all_queues_drop_en_result,
11831 cmd_set_all_queues_drop_en_parsed(
11832 void *parsed_result,
11833 __attribute__((unused)) struct cmdline *cl,
11834 __attribute__((unused)) void *data)
11836 struct cmd_all_queues_drop_en_result *res = parsed_result;
11837 int ret = -ENOTSUP;
11838 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11840 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11843 #ifdef RTE_LIBRTE_IXGBE_PMD
11844 if (ret == -ENOTSUP)
11845 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11847 #ifdef RTE_LIBRTE_BNXT_PMD
11848 if (ret == -ENOTSUP)
11849 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11855 printf("invalid is_on %d\n", is_on);
11858 printf("invalid port_id %d\n", res->port_id);
11861 printf("function not implemented\n");
11864 printf("programming error: (%s)\n", strerror(-ret));
11868 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11869 .f = cmd_set_all_queues_drop_en_parsed,
11871 .help_str = "set all queues drop <port_id> on|off",
11873 (void *)&cmd_all_queues_drop_en_set,
11874 (void *)&cmd_all_queues_drop_en_all,
11875 (void *)&cmd_all_queues_drop_en_queues,
11876 (void *)&cmd_all_queues_drop_en_drop,
11877 (void *)&cmd_all_queues_drop_en_port_id,
11878 (void *)&cmd_all_queues_drop_en_on_off,
11883 /* vf split drop enable configuration */
11885 /* Common result structure for vf split drop enable */
11886 struct cmd_vf_split_drop_en_result {
11887 cmdline_fixed_string_t set;
11888 cmdline_fixed_string_t vf;
11889 cmdline_fixed_string_t split;
11890 cmdline_fixed_string_t drop;
11893 cmdline_fixed_string_t on_off;
11896 /* Common CLI fields for vf split drop enable disable */
11897 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11898 TOKEN_STRING_INITIALIZER
11899 (struct cmd_vf_split_drop_en_result,
11901 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11902 TOKEN_STRING_INITIALIZER
11903 (struct cmd_vf_split_drop_en_result,
11905 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11906 TOKEN_STRING_INITIALIZER
11907 (struct cmd_vf_split_drop_en_result,
11909 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11910 TOKEN_STRING_INITIALIZER
11911 (struct cmd_vf_split_drop_en_result,
11913 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11914 TOKEN_NUM_INITIALIZER
11915 (struct cmd_vf_split_drop_en_result,
11917 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11918 TOKEN_NUM_INITIALIZER
11919 (struct cmd_vf_split_drop_en_result,
11921 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11922 TOKEN_STRING_INITIALIZER
11923 (struct cmd_vf_split_drop_en_result,
11927 cmd_set_vf_split_drop_en_parsed(
11928 void *parsed_result,
11929 __attribute__((unused)) struct cmdline *cl,
11930 __attribute__((unused)) void *data)
11932 struct cmd_vf_split_drop_en_result *res = parsed_result;
11933 int ret = -ENOTSUP;
11934 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11936 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11939 #ifdef RTE_LIBRTE_IXGBE_PMD
11940 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11947 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11950 printf("invalid port_id %d\n", res->port_id);
11953 printf("not supported on port %d\n", res->port_id);
11956 printf("programming error: (%s)\n", strerror(-ret));
11960 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11961 .f = cmd_set_vf_split_drop_en_parsed,
11963 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11965 (void *)&cmd_vf_split_drop_en_set,
11966 (void *)&cmd_vf_split_drop_en_vf,
11967 (void *)&cmd_vf_split_drop_en_split,
11968 (void *)&cmd_vf_split_drop_en_drop,
11969 (void *)&cmd_vf_split_drop_en_port_id,
11970 (void *)&cmd_vf_split_drop_en_vf_id,
11971 (void *)&cmd_vf_split_drop_en_on_off,
11976 /* vf mac address configuration */
11978 /* Common result structure for vf mac address */
11979 struct cmd_set_vf_mac_addr_result {
11980 cmdline_fixed_string_t set;
11981 cmdline_fixed_string_t vf;
11982 cmdline_fixed_string_t mac;
11983 cmdline_fixed_string_t addr;
11986 struct ether_addr mac_addr;
11990 /* Common CLI fields for vf split drop enable disable */
11991 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11992 TOKEN_STRING_INITIALIZER
11993 (struct cmd_set_vf_mac_addr_result,
11995 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11996 TOKEN_STRING_INITIALIZER
11997 (struct cmd_set_vf_mac_addr_result,
11999 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12000 TOKEN_STRING_INITIALIZER
12001 (struct cmd_set_vf_mac_addr_result,
12003 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12004 TOKEN_STRING_INITIALIZER
12005 (struct cmd_set_vf_mac_addr_result,
12007 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12008 TOKEN_NUM_INITIALIZER
12009 (struct cmd_set_vf_mac_addr_result,
12011 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12012 TOKEN_NUM_INITIALIZER
12013 (struct cmd_set_vf_mac_addr_result,
12015 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12016 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12020 cmd_set_vf_mac_addr_parsed(
12021 void *parsed_result,
12022 __attribute__((unused)) struct cmdline *cl,
12023 __attribute__((unused)) void *data)
12025 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12026 int ret = -ENOTSUP;
12028 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12031 #ifdef RTE_LIBRTE_IXGBE_PMD
12032 if (ret == -ENOTSUP)
12033 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12036 #ifdef RTE_LIBRTE_I40E_PMD
12037 if (ret == -ENOTSUP)
12038 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12041 #ifdef RTE_LIBRTE_BNXT_PMD
12042 if (ret == -ENOTSUP)
12043 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12051 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12054 printf("invalid port_id %d\n", res->port_id);
12057 printf("function not implemented\n");
12060 printf("programming error: (%s)\n", strerror(-ret));
12064 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12065 .f = cmd_set_vf_mac_addr_parsed,
12067 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12069 (void *)&cmd_set_vf_mac_addr_set,
12070 (void *)&cmd_set_vf_mac_addr_vf,
12071 (void *)&cmd_set_vf_mac_addr_mac,
12072 (void *)&cmd_set_vf_mac_addr_addr,
12073 (void *)&cmd_set_vf_mac_addr_port_id,
12074 (void *)&cmd_set_vf_mac_addr_vf_id,
12075 (void *)&cmd_set_vf_mac_addr_mac_addr,
12080 /* MACsec configuration */
12082 /* Common result structure for MACsec offload enable */
12083 struct cmd_macsec_offload_on_result {
12084 cmdline_fixed_string_t set;
12085 cmdline_fixed_string_t macsec;
12086 cmdline_fixed_string_t offload;
12088 cmdline_fixed_string_t on;
12089 cmdline_fixed_string_t encrypt;
12090 cmdline_fixed_string_t en_on_off;
12091 cmdline_fixed_string_t replay_protect;
12092 cmdline_fixed_string_t rp_on_off;
12095 /* Common CLI fields for MACsec offload disable */
12096 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12097 TOKEN_STRING_INITIALIZER
12098 (struct cmd_macsec_offload_on_result,
12100 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12101 TOKEN_STRING_INITIALIZER
12102 (struct cmd_macsec_offload_on_result,
12104 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12105 TOKEN_STRING_INITIALIZER
12106 (struct cmd_macsec_offload_on_result,
12107 offload, "offload");
12108 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12109 TOKEN_NUM_INITIALIZER
12110 (struct cmd_macsec_offload_on_result,
12112 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12113 TOKEN_STRING_INITIALIZER
12114 (struct cmd_macsec_offload_on_result,
12116 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12117 TOKEN_STRING_INITIALIZER
12118 (struct cmd_macsec_offload_on_result,
12119 encrypt, "encrypt");
12120 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12121 TOKEN_STRING_INITIALIZER
12122 (struct cmd_macsec_offload_on_result,
12123 en_on_off, "on#off");
12124 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12125 TOKEN_STRING_INITIALIZER
12126 (struct cmd_macsec_offload_on_result,
12127 replay_protect, "replay-protect");
12128 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12129 TOKEN_STRING_INITIALIZER
12130 (struct cmd_macsec_offload_on_result,
12131 rp_on_off, "on#off");
12134 cmd_set_macsec_offload_on_parsed(
12135 void *parsed_result,
12136 __attribute__((unused)) struct cmdline *cl,
12137 __attribute__((unused)) void *data)
12139 struct cmd_macsec_offload_on_result *res = parsed_result;
12140 int ret = -ENOTSUP;
12141 portid_t port_id = res->port_id;
12142 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12143 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12145 if (port_id_is_invalid(port_id, ENABLED_WARN))
12148 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
12149 #ifdef RTE_LIBRTE_IXGBE_PMD
12150 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12159 printf("invalid port_id %d\n", port_id);
12162 printf("not supported on port %d\n", port_id);
12165 printf("programming error: (%s)\n", strerror(-ret));
12169 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12170 .f = cmd_set_macsec_offload_on_parsed,
12172 .help_str = "set macsec offload <port_id> on "
12173 "encrypt on|off replay-protect on|off",
12175 (void *)&cmd_macsec_offload_on_set,
12176 (void *)&cmd_macsec_offload_on_macsec,
12177 (void *)&cmd_macsec_offload_on_offload,
12178 (void *)&cmd_macsec_offload_on_port_id,
12179 (void *)&cmd_macsec_offload_on_on,
12180 (void *)&cmd_macsec_offload_on_encrypt,
12181 (void *)&cmd_macsec_offload_on_en_on_off,
12182 (void *)&cmd_macsec_offload_on_replay_protect,
12183 (void *)&cmd_macsec_offload_on_rp_on_off,
12188 /* Common result structure for MACsec offload disable */
12189 struct cmd_macsec_offload_off_result {
12190 cmdline_fixed_string_t set;
12191 cmdline_fixed_string_t macsec;
12192 cmdline_fixed_string_t offload;
12194 cmdline_fixed_string_t off;
12197 /* Common CLI fields for MACsec offload disable */
12198 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12199 TOKEN_STRING_INITIALIZER
12200 (struct cmd_macsec_offload_off_result,
12202 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12203 TOKEN_STRING_INITIALIZER
12204 (struct cmd_macsec_offload_off_result,
12206 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12207 TOKEN_STRING_INITIALIZER
12208 (struct cmd_macsec_offload_off_result,
12209 offload, "offload");
12210 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12211 TOKEN_NUM_INITIALIZER
12212 (struct cmd_macsec_offload_off_result,
12214 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12215 TOKEN_STRING_INITIALIZER
12216 (struct cmd_macsec_offload_off_result,
12220 cmd_set_macsec_offload_off_parsed(
12221 void *parsed_result,
12222 __attribute__((unused)) struct cmdline *cl,
12223 __attribute__((unused)) void *data)
12225 struct cmd_macsec_offload_off_result *res = parsed_result;
12226 int ret = -ENOTSUP;
12227 portid_t port_id = res->port_id;
12229 if (port_id_is_invalid(port_id, ENABLED_WARN))
12232 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
12233 #ifdef RTE_LIBRTE_IXGBE_PMD
12234 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12241 printf("invalid port_id %d\n", port_id);
12244 printf("not supported on port %d\n", port_id);
12247 printf("programming error: (%s)\n", strerror(-ret));
12251 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12252 .f = cmd_set_macsec_offload_off_parsed,
12254 .help_str = "set macsec offload <port_id> off",
12256 (void *)&cmd_macsec_offload_off_set,
12257 (void *)&cmd_macsec_offload_off_macsec,
12258 (void *)&cmd_macsec_offload_off_offload,
12259 (void *)&cmd_macsec_offload_off_port_id,
12260 (void *)&cmd_macsec_offload_off_off,
12265 /* Common result structure for MACsec secure connection configure */
12266 struct cmd_macsec_sc_result {
12267 cmdline_fixed_string_t set;
12268 cmdline_fixed_string_t macsec;
12269 cmdline_fixed_string_t sc;
12270 cmdline_fixed_string_t tx_rx;
12272 struct ether_addr mac;
12276 /* Common CLI fields for MACsec secure connection configure */
12277 cmdline_parse_token_string_t cmd_macsec_sc_set =
12278 TOKEN_STRING_INITIALIZER
12279 (struct cmd_macsec_sc_result,
12281 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12282 TOKEN_STRING_INITIALIZER
12283 (struct cmd_macsec_sc_result,
12285 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12286 TOKEN_STRING_INITIALIZER
12287 (struct cmd_macsec_sc_result,
12289 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12290 TOKEN_STRING_INITIALIZER
12291 (struct cmd_macsec_sc_result,
12293 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12294 TOKEN_NUM_INITIALIZER
12295 (struct cmd_macsec_sc_result,
12297 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12298 TOKEN_ETHERADDR_INITIALIZER
12299 (struct cmd_macsec_sc_result,
12301 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12302 TOKEN_NUM_INITIALIZER
12303 (struct cmd_macsec_sc_result,
12307 cmd_set_macsec_sc_parsed(
12308 void *parsed_result,
12309 __attribute__((unused)) struct cmdline *cl,
12310 __attribute__((unused)) void *data)
12312 struct cmd_macsec_sc_result *res = parsed_result;
12313 int ret = -ENOTSUP;
12314 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12316 #ifdef RTE_LIBRTE_IXGBE_PMD
12318 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12319 res->mac.addr_bytes) :
12320 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12321 res->mac.addr_bytes, res->pi);
12323 RTE_SET_USED(is_tx);
12329 printf("invalid port_id %d\n", res->port_id);
12332 printf("not supported on port %d\n", res->port_id);
12335 printf("programming error: (%s)\n", strerror(-ret));
12339 cmdline_parse_inst_t cmd_set_macsec_sc = {
12340 .f = cmd_set_macsec_sc_parsed,
12342 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12344 (void *)&cmd_macsec_sc_set,
12345 (void *)&cmd_macsec_sc_macsec,
12346 (void *)&cmd_macsec_sc_sc,
12347 (void *)&cmd_macsec_sc_tx_rx,
12348 (void *)&cmd_macsec_sc_port_id,
12349 (void *)&cmd_macsec_sc_mac,
12350 (void *)&cmd_macsec_sc_pi,
12355 /* Common result structure for MACsec secure connection configure */
12356 struct cmd_macsec_sa_result {
12357 cmdline_fixed_string_t set;
12358 cmdline_fixed_string_t macsec;
12359 cmdline_fixed_string_t sa;
12360 cmdline_fixed_string_t tx_rx;
12365 cmdline_fixed_string_t key;
12368 /* Common CLI fields for MACsec secure connection configure */
12369 cmdline_parse_token_string_t cmd_macsec_sa_set =
12370 TOKEN_STRING_INITIALIZER
12371 (struct cmd_macsec_sa_result,
12373 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12374 TOKEN_STRING_INITIALIZER
12375 (struct cmd_macsec_sa_result,
12377 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12378 TOKEN_STRING_INITIALIZER
12379 (struct cmd_macsec_sa_result,
12381 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12382 TOKEN_STRING_INITIALIZER
12383 (struct cmd_macsec_sa_result,
12385 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12386 TOKEN_NUM_INITIALIZER
12387 (struct cmd_macsec_sa_result,
12389 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12390 TOKEN_NUM_INITIALIZER
12391 (struct cmd_macsec_sa_result,
12393 cmdline_parse_token_num_t cmd_macsec_sa_an =
12394 TOKEN_NUM_INITIALIZER
12395 (struct cmd_macsec_sa_result,
12397 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12398 TOKEN_NUM_INITIALIZER
12399 (struct cmd_macsec_sa_result,
12401 cmdline_parse_token_string_t cmd_macsec_sa_key =
12402 TOKEN_STRING_INITIALIZER
12403 (struct cmd_macsec_sa_result,
12407 cmd_set_macsec_sa_parsed(
12408 void *parsed_result,
12409 __attribute__((unused)) struct cmdline *cl,
12410 __attribute__((unused)) void *data)
12412 struct cmd_macsec_sa_result *res = parsed_result;
12413 int ret = -ENOTSUP;
12414 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12415 uint8_t key[16] = { 0 };
12421 key_len = strlen(res->key) / 2;
12425 for (i = 0; i < key_len; i++) {
12426 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12429 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12432 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12435 #ifdef RTE_LIBRTE_IXGBE_PMD
12437 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12438 res->idx, res->an, res->pn, key) :
12439 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12440 res->idx, res->an, res->pn, key);
12442 RTE_SET_USED(is_tx);
12449 printf("invalid idx %d or an %d\n", res->idx, res->an);
12452 printf("invalid port_id %d\n", res->port_id);
12455 printf("not supported on port %d\n", res->port_id);
12458 printf("programming error: (%s)\n", strerror(-ret));
12462 cmdline_parse_inst_t cmd_set_macsec_sa = {
12463 .f = cmd_set_macsec_sa_parsed,
12465 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12467 (void *)&cmd_macsec_sa_set,
12468 (void *)&cmd_macsec_sa_macsec,
12469 (void *)&cmd_macsec_sa_sa,
12470 (void *)&cmd_macsec_sa_tx_rx,
12471 (void *)&cmd_macsec_sa_port_id,
12472 (void *)&cmd_macsec_sa_idx,
12473 (void *)&cmd_macsec_sa_an,
12474 (void *)&cmd_macsec_sa_pn,
12475 (void *)&cmd_macsec_sa_key,
12480 /* VF unicast promiscuous mode configuration */
12482 /* Common result structure for VF unicast promiscuous mode */
12483 struct cmd_vf_promisc_result {
12484 cmdline_fixed_string_t set;
12485 cmdline_fixed_string_t vf;
12486 cmdline_fixed_string_t promisc;
12489 cmdline_fixed_string_t on_off;
12492 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12493 cmdline_parse_token_string_t cmd_vf_promisc_set =
12494 TOKEN_STRING_INITIALIZER
12495 (struct cmd_vf_promisc_result,
12497 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12498 TOKEN_STRING_INITIALIZER
12499 (struct cmd_vf_promisc_result,
12501 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12502 TOKEN_STRING_INITIALIZER
12503 (struct cmd_vf_promisc_result,
12504 promisc, "promisc");
12505 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12506 TOKEN_NUM_INITIALIZER
12507 (struct cmd_vf_promisc_result,
12509 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12510 TOKEN_NUM_INITIALIZER
12511 (struct cmd_vf_promisc_result,
12513 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12514 TOKEN_STRING_INITIALIZER
12515 (struct cmd_vf_promisc_result,
12519 cmd_set_vf_promisc_parsed(
12520 void *parsed_result,
12521 __attribute__((unused)) struct cmdline *cl,
12522 __attribute__((unused)) void *data)
12524 struct cmd_vf_promisc_result *res = parsed_result;
12525 int ret = -ENOTSUP;
12527 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12529 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12532 #ifdef RTE_LIBRTE_I40E_PMD
12533 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12534 res->vf_id, is_on);
12541 printf("invalid vf_id %d\n", res->vf_id);
12544 printf("invalid port_id %d\n", res->port_id);
12547 printf("function not implemented\n");
12550 printf("programming error: (%s)\n", strerror(-ret));
12554 cmdline_parse_inst_t cmd_set_vf_promisc = {
12555 .f = cmd_set_vf_promisc_parsed,
12557 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12558 "Set unicast promiscuous mode for a VF from the PF",
12560 (void *)&cmd_vf_promisc_set,
12561 (void *)&cmd_vf_promisc_vf,
12562 (void *)&cmd_vf_promisc_promisc,
12563 (void *)&cmd_vf_promisc_port_id,
12564 (void *)&cmd_vf_promisc_vf_id,
12565 (void *)&cmd_vf_promisc_on_off,
12570 /* VF multicast promiscuous mode configuration */
12572 /* Common result structure for VF multicast promiscuous mode */
12573 struct cmd_vf_allmulti_result {
12574 cmdline_fixed_string_t set;
12575 cmdline_fixed_string_t vf;
12576 cmdline_fixed_string_t allmulti;
12579 cmdline_fixed_string_t on_off;
12582 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12583 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12584 TOKEN_STRING_INITIALIZER
12585 (struct cmd_vf_allmulti_result,
12587 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12588 TOKEN_STRING_INITIALIZER
12589 (struct cmd_vf_allmulti_result,
12591 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12592 TOKEN_STRING_INITIALIZER
12593 (struct cmd_vf_allmulti_result,
12594 allmulti, "allmulti");
12595 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12596 TOKEN_NUM_INITIALIZER
12597 (struct cmd_vf_allmulti_result,
12599 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12600 TOKEN_NUM_INITIALIZER
12601 (struct cmd_vf_allmulti_result,
12603 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12604 TOKEN_STRING_INITIALIZER
12605 (struct cmd_vf_allmulti_result,
12609 cmd_set_vf_allmulti_parsed(
12610 void *parsed_result,
12611 __attribute__((unused)) struct cmdline *cl,
12612 __attribute__((unused)) void *data)
12614 struct cmd_vf_allmulti_result *res = parsed_result;
12615 int ret = -ENOTSUP;
12617 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12619 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12622 #ifdef RTE_LIBRTE_I40E_PMD
12623 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12624 res->vf_id, is_on);
12631 printf("invalid vf_id %d\n", res->vf_id);
12634 printf("invalid port_id %d\n", res->port_id);
12637 printf("function not implemented\n");
12640 printf("programming error: (%s)\n", strerror(-ret));
12644 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12645 .f = cmd_set_vf_allmulti_parsed,
12647 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12648 "Set multicast promiscuous mode for a VF from the PF",
12650 (void *)&cmd_vf_allmulti_set,
12651 (void *)&cmd_vf_allmulti_vf,
12652 (void *)&cmd_vf_allmulti_allmulti,
12653 (void *)&cmd_vf_allmulti_port_id,
12654 (void *)&cmd_vf_allmulti_vf_id,
12655 (void *)&cmd_vf_allmulti_on_off,
12660 /* vf broadcast mode configuration */
12662 /* Common result structure for vf broadcast */
12663 struct cmd_set_vf_broadcast_result {
12664 cmdline_fixed_string_t set;
12665 cmdline_fixed_string_t vf;
12666 cmdline_fixed_string_t broadcast;
12669 cmdline_fixed_string_t on_off;
12672 /* Common CLI fields for vf broadcast enable disable */
12673 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12674 TOKEN_STRING_INITIALIZER
12675 (struct cmd_set_vf_broadcast_result,
12677 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12678 TOKEN_STRING_INITIALIZER
12679 (struct cmd_set_vf_broadcast_result,
12681 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12682 TOKEN_STRING_INITIALIZER
12683 (struct cmd_set_vf_broadcast_result,
12684 broadcast, "broadcast");
12685 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12686 TOKEN_NUM_INITIALIZER
12687 (struct cmd_set_vf_broadcast_result,
12689 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12690 TOKEN_NUM_INITIALIZER
12691 (struct cmd_set_vf_broadcast_result,
12693 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12694 TOKEN_STRING_INITIALIZER
12695 (struct cmd_set_vf_broadcast_result,
12699 cmd_set_vf_broadcast_parsed(
12700 void *parsed_result,
12701 __attribute__((unused)) struct cmdline *cl,
12702 __attribute__((unused)) void *data)
12704 struct cmd_set_vf_broadcast_result *res = parsed_result;
12705 int ret = -ENOTSUP;
12707 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12709 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12712 #ifdef RTE_LIBRTE_I40E_PMD
12713 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12714 res->vf_id, is_on);
12721 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12724 printf("invalid port_id %d\n", res->port_id);
12727 printf("function not implemented\n");
12730 printf("programming error: (%s)\n", strerror(-ret));
12734 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12735 .f = cmd_set_vf_broadcast_parsed,
12737 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12739 (void *)&cmd_set_vf_broadcast_set,
12740 (void *)&cmd_set_vf_broadcast_vf,
12741 (void *)&cmd_set_vf_broadcast_broadcast,
12742 (void *)&cmd_set_vf_broadcast_port_id,
12743 (void *)&cmd_set_vf_broadcast_vf_id,
12744 (void *)&cmd_set_vf_broadcast_on_off,
12749 /* vf vlan tag configuration */
12751 /* Common result structure for vf vlan tag */
12752 struct cmd_set_vf_vlan_tag_result {
12753 cmdline_fixed_string_t set;
12754 cmdline_fixed_string_t vf;
12755 cmdline_fixed_string_t vlan;
12756 cmdline_fixed_string_t tag;
12759 cmdline_fixed_string_t on_off;
12762 /* Common CLI fields for vf vlan tag enable disable */
12763 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12764 TOKEN_STRING_INITIALIZER
12765 (struct cmd_set_vf_vlan_tag_result,
12767 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12768 TOKEN_STRING_INITIALIZER
12769 (struct cmd_set_vf_vlan_tag_result,
12771 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12772 TOKEN_STRING_INITIALIZER
12773 (struct cmd_set_vf_vlan_tag_result,
12775 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12776 TOKEN_STRING_INITIALIZER
12777 (struct cmd_set_vf_vlan_tag_result,
12779 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12780 TOKEN_NUM_INITIALIZER
12781 (struct cmd_set_vf_vlan_tag_result,
12783 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12784 TOKEN_NUM_INITIALIZER
12785 (struct cmd_set_vf_vlan_tag_result,
12787 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12788 TOKEN_STRING_INITIALIZER
12789 (struct cmd_set_vf_vlan_tag_result,
12793 cmd_set_vf_vlan_tag_parsed(
12794 void *parsed_result,
12795 __attribute__((unused)) struct cmdline *cl,
12796 __attribute__((unused)) void *data)
12798 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12799 int ret = -ENOTSUP;
12801 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12803 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12806 #ifdef RTE_LIBRTE_I40E_PMD
12807 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12808 res->vf_id, is_on);
12815 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12818 printf("invalid port_id %d\n", res->port_id);
12821 printf("function not implemented\n");
12824 printf("programming error: (%s)\n", strerror(-ret));
12828 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12829 .f = cmd_set_vf_vlan_tag_parsed,
12831 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12833 (void *)&cmd_set_vf_vlan_tag_set,
12834 (void *)&cmd_set_vf_vlan_tag_vf,
12835 (void *)&cmd_set_vf_vlan_tag_vlan,
12836 (void *)&cmd_set_vf_vlan_tag_tag,
12837 (void *)&cmd_set_vf_vlan_tag_port_id,
12838 (void *)&cmd_set_vf_vlan_tag_vf_id,
12839 (void *)&cmd_set_vf_vlan_tag_on_off,
12844 /* Common definition of VF and TC TX bandwidth configuration */
12845 struct cmd_vf_tc_bw_result {
12846 cmdline_fixed_string_t set;
12847 cmdline_fixed_string_t vf;
12848 cmdline_fixed_string_t tc;
12849 cmdline_fixed_string_t tx;
12850 cmdline_fixed_string_t min_bw;
12851 cmdline_fixed_string_t max_bw;
12852 cmdline_fixed_string_t strict_link_prio;
12857 cmdline_fixed_string_t bw_list;
12861 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12862 TOKEN_STRING_INITIALIZER
12863 (struct cmd_vf_tc_bw_result,
12865 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12866 TOKEN_STRING_INITIALIZER
12867 (struct cmd_vf_tc_bw_result,
12869 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12870 TOKEN_STRING_INITIALIZER
12871 (struct cmd_vf_tc_bw_result,
12873 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12874 TOKEN_STRING_INITIALIZER
12875 (struct cmd_vf_tc_bw_result,
12877 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12878 TOKEN_STRING_INITIALIZER
12879 (struct cmd_vf_tc_bw_result,
12880 strict_link_prio, "strict-link-priority");
12881 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12882 TOKEN_STRING_INITIALIZER
12883 (struct cmd_vf_tc_bw_result,
12884 min_bw, "min-bandwidth");
12885 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12886 TOKEN_STRING_INITIALIZER
12887 (struct cmd_vf_tc_bw_result,
12888 max_bw, "max-bandwidth");
12889 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12890 TOKEN_NUM_INITIALIZER
12891 (struct cmd_vf_tc_bw_result,
12893 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12894 TOKEN_NUM_INITIALIZER
12895 (struct cmd_vf_tc_bw_result,
12897 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12898 TOKEN_NUM_INITIALIZER
12899 (struct cmd_vf_tc_bw_result,
12901 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12902 TOKEN_NUM_INITIALIZER
12903 (struct cmd_vf_tc_bw_result,
12905 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12906 TOKEN_STRING_INITIALIZER
12907 (struct cmd_vf_tc_bw_result,
12909 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12910 TOKEN_NUM_INITIALIZER
12911 (struct cmd_vf_tc_bw_result,
12914 /* VF max bandwidth setting */
12916 cmd_vf_max_bw_parsed(
12917 void *parsed_result,
12918 __attribute__((unused)) struct cmdline *cl,
12919 __attribute__((unused)) void *data)
12921 struct cmd_vf_tc_bw_result *res = parsed_result;
12922 int ret = -ENOTSUP;
12924 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12927 #ifdef RTE_LIBRTE_I40E_PMD
12928 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12929 res->vf_id, res->bw);
12936 printf("invalid vf_id %d or bandwidth %d\n",
12937 res->vf_id, res->bw);
12940 printf("invalid port_id %d\n", res->port_id);
12943 printf("function not implemented\n");
12946 printf("programming error: (%s)\n", strerror(-ret));
12950 cmdline_parse_inst_t cmd_vf_max_bw = {
12951 .f = cmd_vf_max_bw_parsed,
12953 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12955 (void *)&cmd_vf_tc_bw_set,
12956 (void *)&cmd_vf_tc_bw_vf,
12957 (void *)&cmd_vf_tc_bw_tx,
12958 (void *)&cmd_vf_tc_bw_max_bw,
12959 (void *)&cmd_vf_tc_bw_port_id,
12960 (void *)&cmd_vf_tc_bw_vf_id,
12961 (void *)&cmd_vf_tc_bw_bw,
12967 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12972 const char *p, *p0 = str;
12979 p = strchr(p0, '(');
12981 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12985 p0 = strchr(p, ')');
12987 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12991 if (size >= sizeof(s)) {
12992 printf("The string size exceeds the internal buffer size\n");
12995 snprintf(s, sizeof(s), "%.*s", size, p);
12996 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12998 printf("Failed to get the bandwidth list. ");
13002 for (i = 0; i < ret; i++)
13003 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13008 /* TC min bandwidth setting */
13010 cmd_vf_tc_min_bw_parsed(
13011 void *parsed_result,
13012 __attribute__((unused)) struct cmdline *cl,
13013 __attribute__((unused)) void *data)
13015 struct cmd_vf_tc_bw_result *res = parsed_result;
13018 int ret = -ENOTSUP;
13020 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13023 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13027 #ifdef RTE_LIBRTE_I40E_PMD
13028 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13036 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13039 printf("invalid port_id %d\n", res->port_id);
13042 printf("function not implemented\n");
13045 printf("programming error: (%s)\n", strerror(-ret));
13049 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13050 .f = cmd_vf_tc_min_bw_parsed,
13052 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13053 " <bw1, bw2, ...>",
13055 (void *)&cmd_vf_tc_bw_set,
13056 (void *)&cmd_vf_tc_bw_vf,
13057 (void *)&cmd_vf_tc_bw_tc,
13058 (void *)&cmd_vf_tc_bw_tx,
13059 (void *)&cmd_vf_tc_bw_min_bw,
13060 (void *)&cmd_vf_tc_bw_port_id,
13061 (void *)&cmd_vf_tc_bw_vf_id,
13062 (void *)&cmd_vf_tc_bw_bw_list,
13068 cmd_tc_min_bw_parsed(
13069 void *parsed_result,
13070 __attribute__((unused)) struct cmdline *cl,
13071 __attribute__((unused)) void *data)
13073 struct cmd_vf_tc_bw_result *res = parsed_result;
13074 struct rte_port *port;
13077 int ret = -ENOTSUP;
13079 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13082 port = &ports[res->port_id];
13083 /** Check if the port is not started **/
13084 if (port->port_status != RTE_PORT_STOPPED) {
13085 printf("Please stop port %d first\n", res->port_id);
13089 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13093 #ifdef RTE_LIBRTE_IXGBE_PMD
13094 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13101 printf("invalid bandwidth\n");
13104 printf("invalid port_id %d\n", res->port_id);
13107 printf("function not implemented\n");
13110 printf("programming error: (%s)\n", strerror(-ret));
13114 cmdline_parse_inst_t cmd_tc_min_bw = {
13115 .f = cmd_tc_min_bw_parsed,
13117 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13119 (void *)&cmd_vf_tc_bw_set,
13120 (void *)&cmd_vf_tc_bw_tc,
13121 (void *)&cmd_vf_tc_bw_tx,
13122 (void *)&cmd_vf_tc_bw_min_bw,
13123 (void *)&cmd_vf_tc_bw_port_id,
13124 (void *)&cmd_vf_tc_bw_bw_list,
13129 /* TC max bandwidth setting */
13131 cmd_vf_tc_max_bw_parsed(
13132 void *parsed_result,
13133 __attribute__((unused)) struct cmdline *cl,
13134 __attribute__((unused)) void *data)
13136 struct cmd_vf_tc_bw_result *res = parsed_result;
13137 int ret = -ENOTSUP;
13139 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13142 #ifdef RTE_LIBRTE_I40E_PMD
13143 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13144 res->tc_no, res->bw);
13151 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13152 res->vf_id, res->tc_no, res->bw);
13155 printf("invalid port_id %d\n", res->port_id);
13158 printf("function not implemented\n");
13161 printf("programming error: (%s)\n", strerror(-ret));
13165 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13166 .f = cmd_vf_tc_max_bw_parsed,
13168 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13171 (void *)&cmd_vf_tc_bw_set,
13172 (void *)&cmd_vf_tc_bw_vf,
13173 (void *)&cmd_vf_tc_bw_tc,
13174 (void *)&cmd_vf_tc_bw_tx,
13175 (void *)&cmd_vf_tc_bw_max_bw,
13176 (void *)&cmd_vf_tc_bw_port_id,
13177 (void *)&cmd_vf_tc_bw_vf_id,
13178 (void *)&cmd_vf_tc_bw_tc_no,
13179 (void *)&cmd_vf_tc_bw_bw,
13184 /* Strict link priority scheduling mode setting */
13186 cmd_strict_link_prio_parsed(
13187 void *parsed_result,
13188 __attribute__((unused)) struct cmdline *cl,
13189 __attribute__((unused)) void *data)
13191 struct cmd_vf_tc_bw_result *res = parsed_result;
13192 int ret = -ENOTSUP;
13194 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13197 #ifdef RTE_LIBRTE_I40E_PMD
13198 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13205 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13208 printf("invalid port_id %d\n", res->port_id);
13211 printf("function not implemented\n");
13214 printf("programming error: (%s)\n", strerror(-ret));
13218 cmdline_parse_inst_t cmd_strict_link_prio = {
13219 .f = cmd_strict_link_prio_parsed,
13221 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13223 (void *)&cmd_vf_tc_bw_set,
13224 (void *)&cmd_vf_tc_bw_tx,
13225 (void *)&cmd_vf_tc_bw_strict_link_prio,
13226 (void *)&cmd_vf_tc_bw_port_id,
13227 (void *)&cmd_vf_tc_bw_tc_map,
13232 /* Load dynamic device personalization*/
13233 struct cmd_ddp_add_result {
13234 cmdline_fixed_string_t ddp;
13235 cmdline_fixed_string_t add;
13240 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13241 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13242 cmdline_parse_token_string_t cmd_ddp_add_add =
13243 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13244 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13245 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
13246 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13247 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13250 cmd_ddp_add_parsed(
13251 void *parsed_result,
13252 __attribute__((unused)) struct cmdline *cl,
13253 __attribute__((unused)) void *data)
13255 struct cmd_ddp_add_result *res = parsed_result;
13261 int ret = -ENOTSUP;
13263 if (res->port_id > nb_ports) {
13264 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13268 if (!all_ports_stopped()) {
13269 printf("Please stop all ports first\n");
13273 filepath = strdup(res->filepath);
13274 if (filepath == NULL) {
13275 printf("Failed to allocate memory\n");
13278 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13280 buff = open_ddp_package_file(file_fld[0], &size);
13282 free((void *)filepath);
13286 #ifdef RTE_LIBRTE_I40E_PMD
13287 if (ret == -ENOTSUP)
13288 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13290 RTE_PMD_I40E_PKG_OP_WR_ADD);
13293 if (ret == -EEXIST)
13294 printf("Profile has already existed.\n");
13296 printf("Failed to load profile.\n");
13297 else if (file_num == 2)
13298 save_ddp_package_file(file_fld[1], buff, size);
13300 close_ddp_package_file(buff);
13301 free((void *)filepath);
13304 cmdline_parse_inst_t cmd_ddp_add = {
13305 .f = cmd_ddp_add_parsed,
13307 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
13309 (void *)&cmd_ddp_add_ddp,
13310 (void *)&cmd_ddp_add_add,
13311 (void *)&cmd_ddp_add_port_id,
13312 (void *)&cmd_ddp_add_filepath,
13317 /* Delete dynamic device personalization*/
13318 struct cmd_ddp_del_result {
13319 cmdline_fixed_string_t ddp;
13320 cmdline_fixed_string_t del;
13325 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13326 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13327 cmdline_parse_token_string_t cmd_ddp_del_del =
13328 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13329 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13330 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT8);
13331 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13332 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13335 cmd_ddp_del_parsed(
13336 void *parsed_result,
13337 __attribute__((unused)) struct cmdline *cl,
13338 __attribute__((unused)) void *data)
13340 struct cmd_ddp_del_result *res = parsed_result;
13343 int ret = -ENOTSUP;
13345 if (res->port_id > nb_ports) {
13346 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13350 if (!all_ports_stopped()) {
13351 printf("Please stop all ports first\n");
13355 buff = open_ddp_package_file(res->filepath, &size);
13359 #ifdef RTE_LIBRTE_I40E_PMD
13360 if (ret == -ENOTSUP)
13361 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13363 RTE_PMD_I40E_PKG_OP_WR_DEL);
13366 if (ret == -EACCES)
13367 printf("Profile does not exist.\n");
13369 printf("Failed to delete profile.\n");
13371 close_ddp_package_file(buff);
13374 cmdline_parse_inst_t cmd_ddp_del = {
13375 .f = cmd_ddp_del_parsed,
13377 .help_str = "ddp del <port_id> <profile_path>",
13379 (void *)&cmd_ddp_del_ddp,
13380 (void *)&cmd_ddp_del_del,
13381 (void *)&cmd_ddp_del_port_id,
13382 (void *)&cmd_ddp_del_filepath,
13387 /* Get dynamic device personalization profile info */
13388 struct cmd_ddp_info_result {
13389 cmdline_fixed_string_t ddp;
13390 cmdline_fixed_string_t get;
13391 cmdline_fixed_string_t info;
13395 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13396 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13397 cmdline_parse_token_string_t cmd_ddp_info_get =
13398 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13399 cmdline_parse_token_string_t cmd_ddp_info_info =
13400 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13401 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13402 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13405 cmd_ddp_info_parsed(
13406 void *parsed_result,
13407 __attribute__((unused)) struct cmdline *cl,
13408 __attribute__((unused)) void *data)
13410 struct cmd_ddp_info_result *res = parsed_result;
13413 int ret = -ENOTSUP;
13414 #ifdef RTE_LIBRTE_I40E_PMD
13417 uint32_t buff_size;
13418 struct rte_pmd_i40e_profile_info info;
13420 struct rte_pmd_i40e_ddp_device_id *devs;
13423 pkg = open_ddp_package_file(res->filepath, &pkg_size);
13427 #ifdef RTE_LIBRTE_I40E_PMD
13428 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13429 (uint8_t *)&info, sizeof(info),
13430 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13432 printf("Global Track id: 0x%x\n", info.track_id);
13433 printf("Global Version: %d.%d.%d.%d\n",
13434 info.version.major,
13435 info.version.minor,
13436 info.version.update,
13437 info.version.draft);
13438 printf("Global Package name: %s\n\n", info.name);
13441 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13442 (uint8_t *)&info, sizeof(info),
13443 RTE_PMD_I40E_PKG_INFO_HEADER);
13445 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13446 printf("i40e Profile Version: %d.%d.%d.%d\n",
13447 info.version.major,
13448 info.version.minor,
13449 info.version.update,
13450 info.version.draft);
13451 printf("i40e Profile name: %s\n\n", info.name);
13454 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13455 (uint8_t *)&buff_size, sizeof(buff_size),
13456 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13457 if (!ret && buff_size) {
13458 buff = (uint8_t *)malloc(buff_size);
13460 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13462 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13464 printf("Package Notes:\n%s\n\n", buff);
13469 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13470 (uint8_t *)&dev_num, sizeof(dev_num),
13471 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13472 if (!ret && dev_num) {
13473 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(dev_num *
13474 sizeof(struct rte_pmd_i40e_ddp_device_id));
13476 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13477 (uint8_t *)devs, dev_num *
13478 sizeof(struct rte_pmd_i40e_ddp_device_id),
13479 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13481 printf("List of supported devices:\n");
13482 for (i = 0; i < dev_num; i++) {
13483 printf(" %04X:%04X %04X:%04X\n",
13484 devs[i].vendor_dev_id >> 16,
13485 devs[i].vendor_dev_id & 0xFFFF,
13486 devs[i].sub_vendor_dev_id >> 16,
13487 devs[i].sub_vendor_dev_id & 0xFFFF);
13496 if (ret == -ENOTSUP)
13497 printf("Function not supported in PMD driver\n");
13498 close_ddp_package_file(pkg);
13501 cmdline_parse_inst_t cmd_ddp_get_info = {
13502 .f = cmd_ddp_info_parsed,
13504 .help_str = "ddp get info <profile_path>",
13506 (void *)&cmd_ddp_info_ddp,
13507 (void *)&cmd_ddp_info_get,
13508 (void *)&cmd_ddp_info_info,
13509 (void *)&cmd_ddp_info_filepath,
13514 /* Get dynamic device personalization profile info list*/
13515 #define PROFILE_INFO_SIZE 48
13516 #define MAX_PROFILE_NUM 16
13518 struct cmd_ddp_get_list_result {
13519 cmdline_fixed_string_t ddp;
13520 cmdline_fixed_string_t get;
13521 cmdline_fixed_string_t list;
13525 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
13526 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
13527 cmdline_parse_token_string_t cmd_ddp_get_list_get =
13528 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
13529 cmdline_parse_token_string_t cmd_ddp_get_list_list =
13530 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
13531 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
13532 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
13535 cmd_ddp_get_list_parsed(
13536 void *parsed_result,
13537 __attribute__((unused)) struct cmdline *cl,
13538 __attribute__((unused)) void *data)
13540 struct cmd_ddp_get_list_result *res = parsed_result;
13541 #ifdef RTE_LIBRTE_I40E_PMD
13542 struct rte_pmd_i40e_profile_list *p_list;
13543 struct rte_pmd_i40e_profile_info *p_info;
13548 int ret = -ENOTSUP;
13550 if (res->port_id > nb_ports) {
13551 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13555 #ifdef RTE_LIBRTE_I40E_PMD
13556 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
13557 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
13559 printf("%s: Failed to malloc buffer\n", __func__);
13561 if (ret == -ENOTSUP)
13562 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
13563 (uint8_t *)p_list, size);
13566 p_num = p_list->p_count;
13567 printf("Profile number is: %d\n\n", p_num);
13569 for (i = 0; i < p_num; i++) {
13570 p_info = &p_list->p_info[i];
13571 printf("Profile %d:\n", i);
13572 printf("Track id: 0x%x\n", p_info->track_id);
13573 printf("Version: %d.%d.%d.%d\n",
13574 p_info->version.major,
13575 p_info->version.minor,
13576 p_info->version.update,
13577 p_info->version.draft);
13578 printf("Profile name: %s\n\n", p_info->name);
13586 printf("Failed to get ddp list\n");
13589 cmdline_parse_inst_t cmd_ddp_get_list = {
13590 .f = cmd_ddp_get_list_parsed,
13592 .help_str = "ddp get list <port_id>",
13594 (void *)&cmd_ddp_get_list_ddp,
13595 (void *)&cmd_ddp_get_list_get,
13596 (void *)&cmd_ddp_get_list_list,
13597 (void *)&cmd_ddp_get_list_port_id,
13602 /* show vf stats */
13604 /* Common result structure for show vf stats */
13605 struct cmd_show_vf_stats_result {
13606 cmdline_fixed_string_t show;
13607 cmdline_fixed_string_t vf;
13608 cmdline_fixed_string_t stats;
13613 /* Common CLI fields show vf stats*/
13614 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13615 TOKEN_STRING_INITIALIZER
13616 (struct cmd_show_vf_stats_result,
13618 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13619 TOKEN_STRING_INITIALIZER
13620 (struct cmd_show_vf_stats_result,
13622 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13623 TOKEN_STRING_INITIALIZER
13624 (struct cmd_show_vf_stats_result,
13626 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13627 TOKEN_NUM_INITIALIZER
13628 (struct cmd_show_vf_stats_result,
13630 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13631 TOKEN_NUM_INITIALIZER
13632 (struct cmd_show_vf_stats_result,
13636 cmd_show_vf_stats_parsed(
13637 void *parsed_result,
13638 __attribute__((unused)) struct cmdline *cl,
13639 __attribute__((unused)) void *data)
13641 struct cmd_show_vf_stats_result *res = parsed_result;
13642 struct rte_eth_stats stats;
13643 int ret = -ENOTSUP;
13644 static const char *nic_stats_border = "########################";
13646 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13649 memset(&stats, 0, sizeof(stats));
13651 #ifdef RTE_LIBRTE_I40E_PMD
13652 if (ret == -ENOTSUP)
13653 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13657 #ifdef RTE_LIBRTE_BNXT_PMD
13658 if (ret == -ENOTSUP)
13659 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
13668 printf("invalid vf_id %d\n", res->vf_id);
13671 printf("invalid port_id %d\n", res->port_id);
13674 printf("function not implemented\n");
13677 printf("programming error: (%s)\n", strerror(-ret));
13680 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13681 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13683 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13685 stats.ipackets, stats.imissed, stats.ibytes);
13686 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13687 printf(" RX-nombuf: %-10"PRIu64"\n",
13689 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13691 stats.opackets, stats.oerrors, stats.obytes);
13693 printf(" %s############################%s\n",
13694 nic_stats_border, nic_stats_border);
13697 cmdline_parse_inst_t cmd_show_vf_stats = {
13698 .f = cmd_show_vf_stats_parsed,
13700 .help_str = "show vf stats <port_id> <vf_id>",
13702 (void *)&cmd_show_vf_stats_show,
13703 (void *)&cmd_show_vf_stats_vf,
13704 (void *)&cmd_show_vf_stats_stats,
13705 (void *)&cmd_show_vf_stats_port_id,
13706 (void *)&cmd_show_vf_stats_vf_id,
13711 /* clear vf stats */
13713 /* Common result structure for clear vf stats */
13714 struct cmd_clear_vf_stats_result {
13715 cmdline_fixed_string_t clear;
13716 cmdline_fixed_string_t vf;
13717 cmdline_fixed_string_t stats;
13722 /* Common CLI fields clear vf stats*/
13723 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13724 TOKEN_STRING_INITIALIZER
13725 (struct cmd_clear_vf_stats_result,
13727 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13728 TOKEN_STRING_INITIALIZER
13729 (struct cmd_clear_vf_stats_result,
13731 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13732 TOKEN_STRING_INITIALIZER
13733 (struct cmd_clear_vf_stats_result,
13735 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13736 TOKEN_NUM_INITIALIZER
13737 (struct cmd_clear_vf_stats_result,
13739 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13740 TOKEN_NUM_INITIALIZER
13741 (struct cmd_clear_vf_stats_result,
13745 cmd_clear_vf_stats_parsed(
13746 void *parsed_result,
13747 __attribute__((unused)) struct cmdline *cl,
13748 __attribute__((unused)) void *data)
13750 struct cmd_clear_vf_stats_result *res = parsed_result;
13751 int ret = -ENOTSUP;
13753 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13756 #ifdef RTE_LIBRTE_I40E_PMD
13757 if (ret == -ENOTSUP)
13758 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13761 #ifdef RTE_LIBRTE_BNXT_PMD
13762 if (ret == -ENOTSUP)
13763 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
13771 printf("invalid vf_id %d\n", res->vf_id);
13774 printf("invalid port_id %d\n", res->port_id);
13777 printf("function not implemented\n");
13780 printf("programming error: (%s)\n", strerror(-ret));
13784 cmdline_parse_inst_t cmd_clear_vf_stats = {
13785 .f = cmd_clear_vf_stats_parsed,
13787 .help_str = "clear vf stats <port_id> <vf_id>",
13789 (void *)&cmd_clear_vf_stats_clear,
13790 (void *)&cmd_clear_vf_stats_vf,
13791 (void *)&cmd_clear_vf_stats_stats,
13792 (void *)&cmd_clear_vf_stats_port_id,
13793 (void *)&cmd_clear_vf_stats_vf_id,
13798 /* ptype mapping get */
13800 /* Common result structure for ptype mapping get */
13801 struct cmd_ptype_mapping_get_result {
13802 cmdline_fixed_string_t ptype;
13803 cmdline_fixed_string_t mapping;
13804 cmdline_fixed_string_t get;
13806 uint8_t valid_only;
13809 /* Common CLI fields for ptype mapping get */
13810 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
13811 TOKEN_STRING_INITIALIZER
13812 (struct cmd_ptype_mapping_get_result,
13814 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
13815 TOKEN_STRING_INITIALIZER
13816 (struct cmd_ptype_mapping_get_result,
13817 mapping, "mapping");
13818 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
13819 TOKEN_STRING_INITIALIZER
13820 (struct cmd_ptype_mapping_get_result,
13822 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
13823 TOKEN_NUM_INITIALIZER
13824 (struct cmd_ptype_mapping_get_result,
13826 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
13827 TOKEN_NUM_INITIALIZER
13828 (struct cmd_ptype_mapping_get_result,
13829 valid_only, UINT8);
13832 cmd_ptype_mapping_get_parsed(
13833 void *parsed_result,
13834 __attribute__((unused)) struct cmdline *cl,
13835 __attribute__((unused)) void *data)
13837 struct cmd_ptype_mapping_get_result *res = parsed_result;
13838 int ret = -ENOTSUP;
13839 #ifdef RTE_LIBRTE_I40E_PMD
13840 int max_ptype_num = 256;
13841 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
13846 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13849 #ifdef RTE_LIBRTE_I40E_PMD
13850 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
13861 printf("invalid port_id %d\n", res->port_id);
13864 printf("function not implemented\n");
13867 printf("programming error: (%s)\n", strerror(-ret));
13870 #ifdef RTE_LIBRTE_I40E_PMD
13872 for (i = 0; i < count; i++)
13873 printf("%3d\t0x%08x\n",
13874 mapping[i].hw_ptype, mapping[i].sw_ptype);
13879 cmdline_parse_inst_t cmd_ptype_mapping_get = {
13880 .f = cmd_ptype_mapping_get_parsed,
13882 .help_str = "ptype mapping get <port_id> <valid_only>",
13884 (void *)&cmd_ptype_mapping_get_ptype,
13885 (void *)&cmd_ptype_mapping_get_mapping,
13886 (void *)&cmd_ptype_mapping_get_get,
13887 (void *)&cmd_ptype_mapping_get_port_id,
13888 (void *)&cmd_ptype_mapping_get_valid_only,
13893 /* ptype mapping replace */
13895 /* Common result structure for ptype mapping replace */
13896 struct cmd_ptype_mapping_replace_result {
13897 cmdline_fixed_string_t ptype;
13898 cmdline_fixed_string_t mapping;
13899 cmdline_fixed_string_t replace;
13906 /* Common CLI fields for ptype mapping replace */
13907 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
13908 TOKEN_STRING_INITIALIZER
13909 (struct cmd_ptype_mapping_replace_result,
13911 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
13912 TOKEN_STRING_INITIALIZER
13913 (struct cmd_ptype_mapping_replace_result,
13914 mapping, "mapping");
13915 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
13916 TOKEN_STRING_INITIALIZER
13917 (struct cmd_ptype_mapping_replace_result,
13918 replace, "replace");
13919 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
13920 TOKEN_NUM_INITIALIZER
13921 (struct cmd_ptype_mapping_replace_result,
13923 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
13924 TOKEN_NUM_INITIALIZER
13925 (struct cmd_ptype_mapping_replace_result,
13927 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
13928 TOKEN_NUM_INITIALIZER
13929 (struct cmd_ptype_mapping_replace_result,
13931 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
13932 TOKEN_NUM_INITIALIZER
13933 (struct cmd_ptype_mapping_replace_result,
13937 cmd_ptype_mapping_replace_parsed(
13938 void *parsed_result,
13939 __attribute__((unused)) struct cmdline *cl,
13940 __attribute__((unused)) void *data)
13942 struct cmd_ptype_mapping_replace_result *res = parsed_result;
13943 int ret = -ENOTSUP;
13945 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13948 #ifdef RTE_LIBRTE_I40E_PMD
13949 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
13959 printf("invalid ptype 0x%8x or 0x%8x\n",
13960 res->target, res->pkt_type);
13963 printf("invalid port_id %d\n", res->port_id);
13966 printf("function not implemented\n");
13969 printf("programming error: (%s)\n", strerror(-ret));
13973 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
13974 .f = cmd_ptype_mapping_replace_parsed,
13977 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
13979 (void *)&cmd_ptype_mapping_replace_ptype,
13980 (void *)&cmd_ptype_mapping_replace_mapping,
13981 (void *)&cmd_ptype_mapping_replace_replace,
13982 (void *)&cmd_ptype_mapping_replace_port_id,
13983 (void *)&cmd_ptype_mapping_replace_target,
13984 (void *)&cmd_ptype_mapping_replace_mask,
13985 (void *)&cmd_ptype_mapping_replace_pkt_type,
13990 /* ptype mapping reset */
13992 /* Common result structure for ptype mapping reset */
13993 struct cmd_ptype_mapping_reset_result {
13994 cmdline_fixed_string_t ptype;
13995 cmdline_fixed_string_t mapping;
13996 cmdline_fixed_string_t reset;
14000 /* Common CLI fields for ptype mapping reset*/
14001 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
14002 TOKEN_STRING_INITIALIZER
14003 (struct cmd_ptype_mapping_reset_result,
14005 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
14006 TOKEN_STRING_INITIALIZER
14007 (struct cmd_ptype_mapping_reset_result,
14008 mapping, "mapping");
14009 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
14010 TOKEN_STRING_INITIALIZER
14011 (struct cmd_ptype_mapping_reset_result,
14013 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
14014 TOKEN_NUM_INITIALIZER
14015 (struct cmd_ptype_mapping_reset_result,
14019 cmd_ptype_mapping_reset_parsed(
14020 void *parsed_result,
14021 __attribute__((unused)) struct cmdline *cl,
14022 __attribute__((unused)) void *data)
14024 struct cmd_ptype_mapping_reset_result *res = parsed_result;
14025 int ret = -ENOTSUP;
14027 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14030 #ifdef RTE_LIBRTE_I40E_PMD
14031 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
14038 printf("invalid port_id %d\n", res->port_id);
14041 printf("function not implemented\n");
14044 printf("programming error: (%s)\n", strerror(-ret));
14048 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
14049 .f = cmd_ptype_mapping_reset_parsed,
14051 .help_str = "ptype mapping reset <port_id>",
14053 (void *)&cmd_ptype_mapping_reset_ptype,
14054 (void *)&cmd_ptype_mapping_reset_mapping,
14055 (void *)&cmd_ptype_mapping_reset_reset,
14056 (void *)&cmd_ptype_mapping_reset_port_id,
14061 /* ptype mapping update */
14063 /* Common result structure for ptype mapping update */
14064 struct cmd_ptype_mapping_update_result {
14065 cmdline_fixed_string_t ptype;
14066 cmdline_fixed_string_t mapping;
14067 cmdline_fixed_string_t reset;
14073 /* Common CLI fields for ptype mapping update*/
14074 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
14075 TOKEN_STRING_INITIALIZER
14076 (struct cmd_ptype_mapping_update_result,
14078 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
14079 TOKEN_STRING_INITIALIZER
14080 (struct cmd_ptype_mapping_update_result,
14081 mapping, "mapping");
14082 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
14083 TOKEN_STRING_INITIALIZER
14084 (struct cmd_ptype_mapping_update_result,
14086 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
14087 TOKEN_NUM_INITIALIZER
14088 (struct cmd_ptype_mapping_update_result,
14090 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
14091 TOKEN_NUM_INITIALIZER
14092 (struct cmd_ptype_mapping_update_result,
14094 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
14095 TOKEN_NUM_INITIALIZER
14096 (struct cmd_ptype_mapping_update_result,
14100 cmd_ptype_mapping_update_parsed(
14101 void *parsed_result,
14102 __attribute__((unused)) struct cmdline *cl,
14103 __attribute__((unused)) void *data)
14105 struct cmd_ptype_mapping_update_result *res = parsed_result;
14106 int ret = -ENOTSUP;
14107 #ifdef RTE_LIBRTE_I40E_PMD
14108 struct rte_pmd_i40e_ptype_mapping mapping;
14110 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14113 #ifdef RTE_LIBRTE_I40E_PMD
14114 mapping.hw_ptype = res->hw_ptype;
14115 mapping.sw_ptype = res->sw_ptype;
14116 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
14126 printf("invalid ptype 0x%8x\n", res->sw_ptype);
14129 printf("invalid port_id %d\n", res->port_id);
14132 printf("function not implemented\n");
14135 printf("programming error: (%s)\n", strerror(-ret));
14139 cmdline_parse_inst_t cmd_ptype_mapping_update = {
14140 .f = cmd_ptype_mapping_update_parsed,
14142 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
14144 (void *)&cmd_ptype_mapping_update_ptype,
14145 (void *)&cmd_ptype_mapping_update_mapping,
14146 (void *)&cmd_ptype_mapping_update_update,
14147 (void *)&cmd_ptype_mapping_update_port_id,
14148 (void *)&cmd_ptype_mapping_update_hw_ptype,
14149 (void *)&cmd_ptype_mapping_update_sw_ptype,
14154 /* Common result structure for file commands */
14155 struct cmd_cmdfile_result {
14156 cmdline_fixed_string_t load;
14157 cmdline_fixed_string_t filename;
14160 /* Common CLI fields for file commands */
14161 cmdline_parse_token_string_t cmd_load_cmdfile =
14162 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
14163 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
14164 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
14167 cmd_load_from_file_parsed(
14168 void *parsed_result,
14169 __attribute__((unused)) struct cmdline *cl,
14170 __attribute__((unused)) void *data)
14172 struct cmd_cmdfile_result *res = parsed_result;
14174 cmdline_read_from_file(res->filename);
14177 cmdline_parse_inst_t cmd_load_from_file = {
14178 .f = cmd_load_from_file_parsed,
14180 .help_str = "load <filename>",
14182 (void *)&cmd_load_cmdfile,
14183 (void *)&cmd_load_cmdfile_filename,
14188 /* ******************************************************************************** */
14190 /* list of instructions */
14191 cmdline_parse_ctx_t main_ctx[] = {
14192 (cmdline_parse_inst_t *)&cmd_help_brief,
14193 (cmdline_parse_inst_t *)&cmd_help_long,
14194 (cmdline_parse_inst_t *)&cmd_quit,
14195 (cmdline_parse_inst_t *)&cmd_load_from_file,
14196 (cmdline_parse_inst_t *)&cmd_showport,
14197 (cmdline_parse_inst_t *)&cmd_showqueue,
14198 (cmdline_parse_inst_t *)&cmd_showportall,
14199 (cmdline_parse_inst_t *)&cmd_showcfg,
14200 (cmdline_parse_inst_t *)&cmd_start,
14201 (cmdline_parse_inst_t *)&cmd_start_tx_first,
14202 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
14203 (cmdline_parse_inst_t *)&cmd_set_link_up,
14204 (cmdline_parse_inst_t *)&cmd_set_link_down,
14205 (cmdline_parse_inst_t *)&cmd_reset,
14206 (cmdline_parse_inst_t *)&cmd_set_numbers,
14207 (cmdline_parse_inst_t *)&cmd_set_txpkts,
14208 (cmdline_parse_inst_t *)&cmd_set_txsplit,
14209 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
14210 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
14211 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
14212 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
14213 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
14214 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
14215 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
14216 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
14217 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
14218 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
14219 (cmdline_parse_inst_t *)&cmd_set_link_check,
14220 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
14221 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
14222 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
14223 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
14224 #ifdef RTE_LIBRTE_PMD_BOND
14225 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
14226 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
14227 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
14228 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
14229 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
14230 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
14231 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
14232 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
14233 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
14234 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
14235 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
14237 (cmdline_parse_inst_t *)&cmd_vlan_offload,
14238 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
14239 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
14240 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
14241 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
14242 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
14243 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
14244 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
14245 (cmdline_parse_inst_t *)&cmd_csum_set,
14246 (cmdline_parse_inst_t *)&cmd_csum_show,
14247 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
14248 (cmdline_parse_inst_t *)&cmd_tso_set,
14249 (cmdline_parse_inst_t *)&cmd_tso_show,
14250 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
14251 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
14252 (cmdline_parse_inst_t *)&cmd_enable_gro,
14253 (cmdline_parse_inst_t *)&cmd_gro_set,
14254 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
14255 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
14256 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
14257 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
14258 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
14259 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
14260 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
14261 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
14262 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
14263 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
14264 (cmdline_parse_inst_t *)&cmd_config_dcb,
14265 (cmdline_parse_inst_t *)&cmd_read_reg,
14266 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
14267 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
14268 (cmdline_parse_inst_t *)&cmd_write_reg,
14269 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
14270 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
14271 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
14272 (cmdline_parse_inst_t *)&cmd_stop,
14273 (cmdline_parse_inst_t *)&cmd_mac_addr,
14274 (cmdline_parse_inst_t *)&cmd_set_qmap,
14275 (cmdline_parse_inst_t *)&cmd_operate_port,
14276 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
14277 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
14278 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
14279 (cmdline_parse_inst_t *)&cmd_config_speed_all,
14280 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
14281 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
14282 (cmdline_parse_inst_t *)&cmd_config_mtu,
14283 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
14284 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
14285 (cmdline_parse_inst_t *)&cmd_config_rss,
14286 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
14287 (cmdline_parse_inst_t *)&cmd_config_txqflags,
14288 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
14289 (cmdline_parse_inst_t *)&cmd_showport_reta,
14290 (cmdline_parse_inst_t *)&cmd_config_burst,
14291 (cmdline_parse_inst_t *)&cmd_config_thresh,
14292 (cmdline_parse_inst_t *)&cmd_config_threshold,
14293 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
14294 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
14295 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
14296 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
14297 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
14298 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
14299 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
14300 (cmdline_parse_inst_t *)&cmd_global_config,
14301 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
14302 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
14303 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
14304 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
14305 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
14306 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
14307 (cmdline_parse_inst_t *)&cmd_dump,
14308 (cmdline_parse_inst_t *)&cmd_dump_one,
14309 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
14310 (cmdline_parse_inst_t *)&cmd_syn_filter,
14311 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
14312 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
14313 (cmdline_parse_inst_t *)&cmd_flex_filter,
14314 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
14315 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
14316 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
14317 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
14318 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
14319 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
14320 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
14321 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
14322 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
14323 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
14324 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
14325 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
14326 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
14327 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
14328 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
14329 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
14330 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
14331 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
14332 (cmdline_parse_inst_t *)&cmd_flow,
14333 (cmdline_parse_inst_t *)&cmd_mcast_addr,
14334 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
14335 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
14336 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
14337 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
14338 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
14339 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
14340 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
14341 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
14342 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
14343 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
14344 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
14345 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
14346 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
14347 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
14348 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
14349 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
14350 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
14351 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
14352 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
14353 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
14354 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
14355 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
14356 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
14357 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
14358 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
14359 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
14360 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
14361 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
14362 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
14363 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
14364 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
14365 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
14366 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
14367 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
14368 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
14369 (cmdline_parse_inst_t *)&cmd_ddp_add,
14370 (cmdline_parse_inst_t *)&cmd_ddp_del,
14371 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
14372 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
14373 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
14374 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
14375 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
14376 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
14377 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
14378 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
14382 /* read cmdline commands from file */
14384 cmdline_read_from_file(const char *filename)
14386 struct cmdline *cl;
14388 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14390 printf("Failed to create file based cmdline context: %s\n",
14395 cmdline_interact(cl);
14400 printf("Read CLI commands from %s\n", filename);
14403 /* prompt function, called from main on MASTER lcore */
14407 /* initialize non-constant commands */
14408 cmd_set_fwd_mode_init();
14409 cmd_set_fwd_retry_mode_init();
14411 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14412 if (testpmd_cl == NULL)
14414 cmdline_interact(testpmd_cl);
14415 cmdline_stdin_exit(testpmd_cl);
14421 if (testpmd_cl != NULL)
14422 cmdline_quit(testpmd_cl);
14426 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14428 if (id == (portid_t)RTE_PORT_ALL) {
14431 RTE_ETH_FOREACH_DEV(pid) {
14432 /* check if need_reconfig has been set to 1 */
14433 if (ports[pid].need_reconfig == 0)
14434 ports[pid].need_reconfig = dev;
14435 /* check if need_reconfig_queues has been set to 1 */
14436 if (ports[pid].need_reconfig_queues == 0)
14437 ports[pid].need_reconfig_queues = queue;
14439 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14440 /* check if need_reconfig has been set to 1 */
14441 if (ports[id].need_reconfig == 0)
14442 ports[id].need_reconfig = dev;
14443 /* check if need_reconfig_queues has been set to 1 */
14444 if (ports[id].need_reconfig_queues == 0)
14445 ports[id].need_reconfig_queues = queue;