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"
428 " csum forwarding 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);
975 else if (!strcmp(res->name, "reset"))
976 reset_port(RTE_PORT_ALL);
978 printf("Unknown parameter\n");
981 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
982 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
984 cmdline_parse_token_string_t cmd_operate_port_all_port =
985 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
986 "start#stop#close#reset");
987 cmdline_parse_token_string_t cmd_operate_port_all_all =
988 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
990 cmdline_parse_inst_t cmd_operate_port = {
991 .f = cmd_operate_port_parsed,
993 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
995 (void *)&cmd_operate_port_all_cmd,
996 (void *)&cmd_operate_port_all_port,
997 (void *)&cmd_operate_port_all_all,
1002 /* *** start/stop/close specific port *** */
1003 struct cmd_operate_specific_port_result {
1004 cmdline_fixed_string_t keyword;
1005 cmdline_fixed_string_t name;
1009 static void cmd_operate_specific_port_parsed(void *parsed_result,
1010 __attribute__((unused)) struct cmdline *cl,
1011 __attribute__((unused)) void *data)
1013 struct cmd_operate_specific_port_result *res = parsed_result;
1015 if (!strcmp(res->name, "start"))
1016 start_port(res->value);
1017 else if (!strcmp(res->name, "stop"))
1018 stop_port(res->value);
1019 else if (!strcmp(res->name, "close"))
1020 close_port(res->value);
1021 else if (!strcmp(res->name, "reset"))
1022 reset_port(res->value);
1024 printf("Unknown parameter\n");
1027 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1028 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1030 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1031 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1032 name, "start#stop#close#reset");
1033 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1034 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1037 cmdline_parse_inst_t cmd_operate_specific_port = {
1038 .f = cmd_operate_specific_port_parsed,
1040 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1042 (void *)&cmd_operate_specific_port_cmd,
1043 (void *)&cmd_operate_specific_port_port,
1044 (void *)&cmd_operate_specific_port_id,
1049 /* *** attach a specified port *** */
1050 struct cmd_operate_attach_port_result {
1051 cmdline_fixed_string_t port;
1052 cmdline_fixed_string_t keyword;
1053 cmdline_fixed_string_t identifier;
1056 static void cmd_operate_attach_port_parsed(void *parsed_result,
1057 __attribute__((unused)) struct cmdline *cl,
1058 __attribute__((unused)) void *data)
1060 struct cmd_operate_attach_port_result *res = parsed_result;
1062 if (!strcmp(res->keyword, "attach"))
1063 attach_port(res->identifier);
1065 printf("Unknown parameter\n");
1068 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1069 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1071 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1072 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1074 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1075 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1078 cmdline_parse_inst_t cmd_operate_attach_port = {
1079 .f = cmd_operate_attach_port_parsed,
1081 .help_str = "port attach <identifier>: "
1082 "(identifier: pci address or virtual dev name)",
1084 (void *)&cmd_operate_attach_port_port,
1085 (void *)&cmd_operate_attach_port_keyword,
1086 (void *)&cmd_operate_attach_port_identifier,
1091 /* *** detach a specified port *** */
1092 struct cmd_operate_detach_port_result {
1093 cmdline_fixed_string_t port;
1094 cmdline_fixed_string_t keyword;
1098 static void cmd_operate_detach_port_parsed(void *parsed_result,
1099 __attribute__((unused)) struct cmdline *cl,
1100 __attribute__((unused)) void *data)
1102 struct cmd_operate_detach_port_result *res = parsed_result;
1104 if (!strcmp(res->keyword, "detach"))
1105 detach_port(res->port_id);
1107 printf("Unknown parameter\n");
1110 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1111 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1113 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1114 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1116 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1117 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1120 cmdline_parse_inst_t cmd_operate_detach_port = {
1121 .f = cmd_operate_detach_port_parsed,
1123 .help_str = "port detach <port_id>",
1125 (void *)&cmd_operate_detach_port_port,
1126 (void *)&cmd_operate_detach_port_keyword,
1127 (void *)&cmd_operate_detach_port_port_id,
1132 /* *** configure speed for all ports *** */
1133 struct cmd_config_speed_all {
1134 cmdline_fixed_string_t port;
1135 cmdline_fixed_string_t keyword;
1136 cmdline_fixed_string_t all;
1137 cmdline_fixed_string_t item1;
1138 cmdline_fixed_string_t item2;
1139 cmdline_fixed_string_t value1;
1140 cmdline_fixed_string_t value2;
1144 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1149 if (!strcmp(duplexstr, "half")) {
1150 duplex = ETH_LINK_HALF_DUPLEX;
1151 } else if (!strcmp(duplexstr, "full")) {
1152 duplex = ETH_LINK_FULL_DUPLEX;
1153 } else if (!strcmp(duplexstr, "auto")) {
1154 duplex = ETH_LINK_FULL_DUPLEX;
1156 printf("Unknown duplex parameter\n");
1160 if (!strcmp(speedstr, "10")) {
1161 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1162 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1163 } else if (!strcmp(speedstr, "100")) {
1164 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1165 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1167 if (duplex != ETH_LINK_FULL_DUPLEX) {
1168 printf("Invalid speed/duplex parameters\n");
1171 if (!strcmp(speedstr, "1000")) {
1172 *speed = ETH_LINK_SPEED_1G;
1173 } else if (!strcmp(speedstr, "10000")) {
1174 *speed = ETH_LINK_SPEED_10G;
1175 } else if (!strcmp(speedstr, "25000")) {
1176 *speed = ETH_LINK_SPEED_25G;
1177 } else if (!strcmp(speedstr, "40000")) {
1178 *speed = ETH_LINK_SPEED_40G;
1179 } else if (!strcmp(speedstr, "50000")) {
1180 *speed = ETH_LINK_SPEED_50G;
1181 } else if (!strcmp(speedstr, "100000")) {
1182 *speed = ETH_LINK_SPEED_100G;
1183 } else if (!strcmp(speedstr, "auto")) {
1184 *speed = ETH_LINK_SPEED_AUTONEG;
1186 printf("Unknown speed parameter\n");
1195 cmd_config_speed_all_parsed(void *parsed_result,
1196 __attribute__((unused)) struct cmdline *cl,
1197 __attribute__((unused)) void *data)
1199 struct cmd_config_speed_all *res = parsed_result;
1200 uint32_t link_speed;
1203 if (!all_ports_stopped()) {
1204 printf("Please stop all ports first\n");
1208 if (parse_and_check_speed_duplex(res->value1, res->value2,
1212 RTE_ETH_FOREACH_DEV(pid) {
1213 ports[pid].dev_conf.link_speeds = link_speed;
1216 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1219 cmdline_parse_token_string_t cmd_config_speed_all_port =
1220 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1221 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1222 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1224 cmdline_parse_token_string_t cmd_config_speed_all_all =
1225 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1226 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1227 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1228 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1229 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1230 "10#100#1000#10000#25000#40000#50000#100000#auto");
1231 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1232 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1233 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1234 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1237 cmdline_parse_inst_t cmd_config_speed_all = {
1238 .f = cmd_config_speed_all_parsed,
1240 .help_str = "port config all speed "
1241 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1244 (void *)&cmd_config_speed_all_port,
1245 (void *)&cmd_config_speed_all_keyword,
1246 (void *)&cmd_config_speed_all_all,
1247 (void *)&cmd_config_speed_all_item1,
1248 (void *)&cmd_config_speed_all_value1,
1249 (void *)&cmd_config_speed_all_item2,
1250 (void *)&cmd_config_speed_all_value2,
1255 /* *** configure speed for specific port *** */
1256 struct cmd_config_speed_specific {
1257 cmdline_fixed_string_t port;
1258 cmdline_fixed_string_t keyword;
1260 cmdline_fixed_string_t item1;
1261 cmdline_fixed_string_t item2;
1262 cmdline_fixed_string_t value1;
1263 cmdline_fixed_string_t value2;
1267 cmd_config_speed_specific_parsed(void *parsed_result,
1268 __attribute__((unused)) struct cmdline *cl,
1269 __attribute__((unused)) void *data)
1271 struct cmd_config_speed_specific *res = parsed_result;
1272 uint32_t link_speed;
1274 if (!all_ports_stopped()) {
1275 printf("Please stop all ports first\n");
1279 if (port_id_is_invalid(res->id, ENABLED_WARN))
1282 if (parse_and_check_speed_duplex(res->value1, res->value2,
1286 ports[res->id].dev_conf.link_speeds = link_speed;
1288 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1292 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1293 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1295 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1296 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1298 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1299 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1300 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1301 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1303 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1304 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1305 "10#100#1000#10000#25000#40000#50000#100000#auto");
1306 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1307 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1309 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1310 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1313 cmdline_parse_inst_t cmd_config_speed_specific = {
1314 .f = cmd_config_speed_specific_parsed,
1316 .help_str = "port config <port_id> speed "
1317 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1320 (void *)&cmd_config_speed_specific_port,
1321 (void *)&cmd_config_speed_specific_keyword,
1322 (void *)&cmd_config_speed_specific_id,
1323 (void *)&cmd_config_speed_specific_item1,
1324 (void *)&cmd_config_speed_specific_value1,
1325 (void *)&cmd_config_speed_specific_item2,
1326 (void *)&cmd_config_speed_specific_value2,
1331 /* *** configure txq/rxq, txd/rxd *** */
1332 struct cmd_config_rx_tx {
1333 cmdline_fixed_string_t port;
1334 cmdline_fixed_string_t keyword;
1335 cmdline_fixed_string_t all;
1336 cmdline_fixed_string_t name;
1341 cmd_config_rx_tx_parsed(void *parsed_result,
1342 __attribute__((unused)) struct cmdline *cl,
1343 __attribute__((unused)) void *data)
1345 struct cmd_config_rx_tx *res = parsed_result;
1347 if (!all_ports_stopped()) {
1348 printf("Please stop all ports first\n");
1351 if (!strcmp(res->name, "rxq")) {
1352 if (!res->value && !nb_txq) {
1353 printf("Warning: Either rx or tx queues should be non zero\n");
1356 nb_rxq = res->value;
1358 else if (!strcmp(res->name, "txq")) {
1359 if (!res->value && !nb_rxq) {
1360 printf("Warning: Either rx or tx queues should be non zero\n");
1363 nb_txq = res->value;
1365 else if (!strcmp(res->name, "rxd")) {
1366 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1367 printf("rxd %d invalid - must be > 0 && <= %d\n",
1368 res->value, RTE_TEST_RX_DESC_MAX);
1371 nb_rxd = res->value;
1372 } else if (!strcmp(res->name, "txd")) {
1373 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1374 printf("txd %d invalid - must be > 0 && <= %d\n",
1375 res->value, RTE_TEST_TX_DESC_MAX);
1378 nb_txd = res->value;
1380 printf("Unknown parameter\n");
1388 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1391 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1393 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1395 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1397 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1398 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1400 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1401 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1403 cmdline_parse_inst_t cmd_config_rx_tx = {
1404 .f = cmd_config_rx_tx_parsed,
1406 .help_str = "port config all rxq|txq|rxd|txd <value>",
1408 (void *)&cmd_config_rx_tx_port,
1409 (void *)&cmd_config_rx_tx_keyword,
1410 (void *)&cmd_config_rx_tx_all,
1411 (void *)&cmd_config_rx_tx_name,
1412 (void *)&cmd_config_rx_tx_value,
1417 /* *** config max packet length *** */
1418 struct cmd_config_max_pkt_len_result {
1419 cmdline_fixed_string_t port;
1420 cmdline_fixed_string_t keyword;
1421 cmdline_fixed_string_t all;
1422 cmdline_fixed_string_t name;
1427 cmd_config_max_pkt_len_parsed(void *parsed_result,
1428 __attribute__((unused)) struct cmdline *cl,
1429 __attribute__((unused)) void *data)
1431 struct cmd_config_max_pkt_len_result *res = parsed_result;
1433 if (!all_ports_stopped()) {
1434 printf("Please stop all ports first\n");
1438 if (!strcmp(res->name, "max-pkt-len")) {
1439 if (res->value < ETHER_MIN_LEN) {
1440 printf("max-pkt-len can not be less than %d\n",
1444 if (res->value == rx_mode.max_rx_pkt_len)
1447 rx_mode.max_rx_pkt_len = res->value;
1448 if (res->value > ETHER_MAX_LEN)
1449 rx_mode.jumbo_frame = 1;
1451 rx_mode.jumbo_frame = 0;
1453 printf("Unknown parameter\n");
1459 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1462 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1463 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1465 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1468 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1471 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1474 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1475 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1478 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1479 .f = cmd_config_max_pkt_len_parsed,
1481 .help_str = "port config all max-pkt-len <value>",
1483 (void *)&cmd_config_max_pkt_len_port,
1484 (void *)&cmd_config_max_pkt_len_keyword,
1485 (void *)&cmd_config_max_pkt_len_all,
1486 (void *)&cmd_config_max_pkt_len_name,
1487 (void *)&cmd_config_max_pkt_len_value,
1492 /* *** configure port MTU *** */
1493 struct cmd_config_mtu_result {
1494 cmdline_fixed_string_t port;
1495 cmdline_fixed_string_t keyword;
1496 cmdline_fixed_string_t mtu;
1502 cmd_config_mtu_parsed(void *parsed_result,
1503 __attribute__((unused)) struct cmdline *cl,
1504 __attribute__((unused)) void *data)
1506 struct cmd_config_mtu_result *res = parsed_result;
1508 if (res->value < ETHER_MIN_LEN) {
1509 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1512 port_mtu_set(res->port_id, res->value);
1515 cmdline_parse_token_string_t cmd_config_mtu_port =
1516 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1518 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1519 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1521 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1522 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1524 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1525 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1526 cmdline_parse_token_num_t cmd_config_mtu_value =
1527 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1529 cmdline_parse_inst_t cmd_config_mtu = {
1530 .f = cmd_config_mtu_parsed,
1532 .help_str = "port config mtu <port_id> <value>",
1534 (void *)&cmd_config_mtu_port,
1535 (void *)&cmd_config_mtu_keyword,
1536 (void *)&cmd_config_mtu_mtu,
1537 (void *)&cmd_config_mtu_port_id,
1538 (void *)&cmd_config_mtu_value,
1543 /* *** configure rx mode *** */
1544 struct cmd_config_rx_mode_flag {
1545 cmdline_fixed_string_t port;
1546 cmdline_fixed_string_t keyword;
1547 cmdline_fixed_string_t all;
1548 cmdline_fixed_string_t name;
1549 cmdline_fixed_string_t value;
1553 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1554 __attribute__((unused)) struct cmdline *cl,
1555 __attribute__((unused)) void *data)
1557 struct cmd_config_rx_mode_flag *res = parsed_result;
1559 if (!all_ports_stopped()) {
1560 printf("Please stop all ports first\n");
1564 if (!strcmp(res->name, "crc-strip")) {
1565 if (!strcmp(res->value, "on"))
1566 rx_mode.hw_strip_crc = 1;
1567 else if (!strcmp(res->value, "off"))
1568 rx_mode.hw_strip_crc = 0;
1570 printf("Unknown parameter\n");
1573 } else if (!strcmp(res->name, "scatter")) {
1574 if (!strcmp(res->value, "on"))
1575 rx_mode.enable_scatter = 1;
1576 else if (!strcmp(res->value, "off"))
1577 rx_mode.enable_scatter = 0;
1579 printf("Unknown parameter\n");
1582 } else if (!strcmp(res->name, "rx-cksum")) {
1583 if (!strcmp(res->value, "on"))
1584 rx_mode.hw_ip_checksum = 1;
1585 else if (!strcmp(res->value, "off"))
1586 rx_mode.hw_ip_checksum = 0;
1588 printf("Unknown parameter\n");
1591 } else if (!strcmp(res->name, "hw-vlan")) {
1592 if (!strcmp(res->value, "on")) {
1593 rx_mode.hw_vlan_filter = 1;
1594 rx_mode.hw_vlan_strip = 1;
1596 else if (!strcmp(res->value, "off")) {
1597 rx_mode.hw_vlan_filter = 0;
1598 rx_mode.hw_vlan_strip = 0;
1601 printf("Unknown parameter\n");
1604 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1605 if (!strcmp(res->value, "on"))
1606 rx_mode.hw_vlan_filter = 1;
1607 else if (!strcmp(res->value, "off"))
1608 rx_mode.hw_vlan_filter = 0;
1610 printf("Unknown parameter\n");
1613 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1614 if (!strcmp(res->value, "on"))
1615 rx_mode.hw_vlan_strip = 1;
1616 else if (!strcmp(res->value, "off"))
1617 rx_mode.hw_vlan_strip = 0;
1619 printf("Unknown parameter\n");
1622 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1623 if (!strcmp(res->value, "on"))
1624 rx_mode.hw_vlan_extend = 1;
1625 else if (!strcmp(res->value, "off"))
1626 rx_mode.hw_vlan_extend = 0;
1628 printf("Unknown parameter\n");
1631 } else if (!strcmp(res->name, "drop-en")) {
1632 if (!strcmp(res->value, "on"))
1634 else if (!strcmp(res->value, "off"))
1637 printf("Unknown parameter\n");
1641 printf("Unknown parameter\n");
1647 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1650 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1651 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1652 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1653 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1655 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1657 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1659 "crc-strip#scatter#rx-cksum#hw-vlan#"
1660 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1661 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1665 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1666 .f = cmd_config_rx_mode_flag_parsed,
1668 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1669 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1671 (void *)&cmd_config_rx_mode_flag_port,
1672 (void *)&cmd_config_rx_mode_flag_keyword,
1673 (void *)&cmd_config_rx_mode_flag_all,
1674 (void *)&cmd_config_rx_mode_flag_name,
1675 (void *)&cmd_config_rx_mode_flag_value,
1680 /* *** configure rss *** */
1681 struct cmd_config_rss {
1682 cmdline_fixed_string_t port;
1683 cmdline_fixed_string_t keyword;
1684 cmdline_fixed_string_t all;
1685 cmdline_fixed_string_t name;
1686 cmdline_fixed_string_t value;
1690 cmd_config_rss_parsed(void *parsed_result,
1691 __attribute__((unused)) struct cmdline *cl,
1692 __attribute__((unused)) void *data)
1694 struct cmd_config_rss *res = parsed_result;
1695 struct rte_eth_rss_conf rss_conf;
1699 if (!strcmp(res->value, "all"))
1700 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1701 ETH_RSS_UDP | ETH_RSS_SCTP |
1703 else if (!strcmp(res->value, "ip"))
1704 rss_conf.rss_hf = ETH_RSS_IP;
1705 else if (!strcmp(res->value, "udp"))
1706 rss_conf.rss_hf = ETH_RSS_UDP;
1707 else if (!strcmp(res->value, "tcp"))
1708 rss_conf.rss_hf = ETH_RSS_TCP;
1709 else if (!strcmp(res->value, "sctp"))
1710 rss_conf.rss_hf = ETH_RSS_SCTP;
1711 else if (!strcmp(res->value, "ether"))
1712 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1713 else if (!strcmp(res->value, "port"))
1714 rss_conf.rss_hf = ETH_RSS_PORT;
1715 else if (!strcmp(res->value, "vxlan"))
1716 rss_conf.rss_hf = ETH_RSS_VXLAN;
1717 else if (!strcmp(res->value, "geneve"))
1718 rss_conf.rss_hf = ETH_RSS_GENEVE;
1719 else if (!strcmp(res->value, "nvgre"))
1720 rss_conf.rss_hf = ETH_RSS_NVGRE;
1721 else if (!strcmp(res->value, "none"))
1722 rss_conf.rss_hf = 0;
1724 printf("Unknown parameter\n");
1727 rss_conf.rss_key = NULL;
1728 for (i = 0; i < rte_eth_dev_count(); i++) {
1729 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1731 printf("Configuration of RSS hash at ethernet port %d "
1732 "failed with error (%d): %s.\n",
1733 i, -diag, strerror(-diag));
1737 cmdline_parse_token_string_t cmd_config_rss_port =
1738 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1739 cmdline_parse_token_string_t cmd_config_rss_keyword =
1740 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1741 cmdline_parse_token_string_t cmd_config_rss_all =
1742 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1743 cmdline_parse_token_string_t cmd_config_rss_name =
1744 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1745 cmdline_parse_token_string_t cmd_config_rss_value =
1746 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1747 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1749 cmdline_parse_inst_t cmd_config_rss = {
1750 .f = cmd_config_rss_parsed,
1752 .help_str = "port config all rss "
1753 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1755 (void *)&cmd_config_rss_port,
1756 (void *)&cmd_config_rss_keyword,
1757 (void *)&cmd_config_rss_all,
1758 (void *)&cmd_config_rss_name,
1759 (void *)&cmd_config_rss_value,
1764 /* *** configure rss hash key *** */
1765 struct cmd_config_rss_hash_key {
1766 cmdline_fixed_string_t port;
1767 cmdline_fixed_string_t config;
1769 cmdline_fixed_string_t rss_hash_key;
1770 cmdline_fixed_string_t rss_type;
1771 cmdline_fixed_string_t key;
1775 hexa_digit_to_value(char hexa_digit)
1777 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1778 return (uint8_t) (hexa_digit - '0');
1779 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1780 return (uint8_t) ((hexa_digit - 'a') + 10);
1781 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1782 return (uint8_t) ((hexa_digit - 'A') + 10);
1783 /* Invalid hexa digit */
1788 parse_and_check_key_hexa_digit(char *key, int idx)
1792 hexa_v = hexa_digit_to_value(key[idx]);
1794 printf("invalid key: character %c at position %d is not a "
1795 "valid hexa digit\n", key[idx], idx);
1800 cmd_config_rss_hash_key_parsed(void *parsed_result,
1801 __attribute__((unused)) struct cmdline *cl,
1802 __attribute__((unused)) void *data)
1804 struct cmd_config_rss_hash_key *res = parsed_result;
1805 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1809 struct rte_eth_dev_info dev_info;
1810 uint8_t hash_key_size;
1813 memset(&dev_info, 0, sizeof(dev_info));
1814 rte_eth_dev_info_get(res->port_id, &dev_info);
1815 if (dev_info.hash_key_size > 0 &&
1816 dev_info.hash_key_size <= sizeof(hash_key))
1817 hash_key_size = dev_info.hash_key_size;
1819 printf("dev_info did not provide a valid hash key size\n");
1822 /* Check the length of the RSS hash key */
1823 key_len = strlen(res->key);
1824 if (key_len != (hash_key_size * 2)) {
1825 printf("key length: %d invalid - key must be a string of %d"
1826 " hexa-decimal numbers\n",
1827 (int) key_len, hash_key_size * 2);
1830 /* Translate RSS hash key into binary representation */
1831 for (i = 0; i < hash_key_size; i++) {
1832 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1835 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1838 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1840 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1844 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1845 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1846 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1849 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1850 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1851 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1852 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1853 rss_hash_key, "rss-hash-key");
1854 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1856 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1857 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1858 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1859 "ipv6-tcp-ex#ipv6-udp-ex");
1860 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1861 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1863 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1864 .f = cmd_config_rss_hash_key_parsed,
1866 .help_str = "port config <port_id> rss-hash-key "
1867 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1868 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1869 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1870 "<string of hex digits (variable length, NIC dependent)>",
1872 (void *)&cmd_config_rss_hash_key_port,
1873 (void *)&cmd_config_rss_hash_key_config,
1874 (void *)&cmd_config_rss_hash_key_port_id,
1875 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1876 (void *)&cmd_config_rss_hash_key_rss_type,
1877 (void *)&cmd_config_rss_hash_key_value,
1882 /* *** configure port rxq/txq start/stop *** */
1883 struct cmd_config_rxtx_queue {
1884 cmdline_fixed_string_t port;
1886 cmdline_fixed_string_t rxtxq;
1888 cmdline_fixed_string_t opname;
1892 cmd_config_rxtx_queue_parsed(void *parsed_result,
1893 __attribute__((unused)) struct cmdline *cl,
1894 __attribute__((unused)) void *data)
1896 struct cmd_config_rxtx_queue *res = parsed_result;
1901 if (test_done == 0) {
1902 printf("Please stop forwarding first\n");
1906 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1909 if (port_is_started(res->portid) != 1) {
1910 printf("Please start port %u first\n", res->portid);
1914 if (!strcmp(res->rxtxq, "rxq"))
1916 else if (!strcmp(res->rxtxq, "txq"))
1919 printf("Unknown parameter\n");
1923 if (isrx && rx_queue_id_is_invalid(res->qid))
1925 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1928 if (!strcmp(res->opname, "start"))
1930 else if (!strcmp(res->opname, "stop"))
1933 printf("Unknown parameter\n");
1937 if (isstart && isrx)
1938 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1939 else if (!isstart && isrx)
1940 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1941 else if (isstart && !isrx)
1942 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1944 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1946 if (ret == -ENOTSUP)
1947 printf("Function not supported in PMD driver\n");
1950 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1951 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1952 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1953 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1954 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1955 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1956 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1957 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1958 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1959 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1962 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1963 .f = cmd_config_rxtx_queue_parsed,
1965 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1967 (void *)&cmd_config_speed_all_port,
1968 (void *)&cmd_config_rxtx_queue_portid,
1969 (void *)&cmd_config_rxtx_queue_rxtxq,
1970 (void *)&cmd_config_rxtx_queue_qid,
1971 (void *)&cmd_config_rxtx_queue_opname,
1976 /* *** Configure RSS RETA *** */
1977 struct cmd_config_rss_reta {
1978 cmdline_fixed_string_t port;
1979 cmdline_fixed_string_t keyword;
1981 cmdline_fixed_string_t name;
1982 cmdline_fixed_string_t list_name;
1983 cmdline_fixed_string_t list_of_items;
1987 parse_reta_config(const char *str,
1988 struct rte_eth_rss_reta_entry64 *reta_conf,
1989 uint16_t nb_entries)
1993 uint16_t hash_index, idx, shift;
1996 const char *p, *p0 = str;
2003 unsigned long int_fld[_NUM_FLD];
2004 char *str_fld[_NUM_FLD];
2006 while ((p = strchr(p0,'(')) != NULL) {
2008 if((p0 = strchr(p,')')) == NULL)
2012 if(size >= sizeof(s))
2015 snprintf(s, sizeof(s), "%.*s", size, p);
2016 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2018 for (i = 0; i < _NUM_FLD; i++) {
2020 int_fld[i] = strtoul(str_fld[i], &end, 0);
2021 if (errno != 0 || end == str_fld[i] ||
2026 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2027 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2029 if (hash_index >= nb_entries) {
2030 printf("Invalid RETA hash index=%d\n", hash_index);
2034 idx = hash_index / RTE_RETA_GROUP_SIZE;
2035 shift = hash_index % RTE_RETA_GROUP_SIZE;
2036 reta_conf[idx].mask |= (1ULL << shift);
2037 reta_conf[idx].reta[shift] = nb_queue;
2044 cmd_set_rss_reta_parsed(void *parsed_result,
2045 __attribute__((unused)) struct cmdline *cl,
2046 __attribute__((unused)) void *data)
2049 struct rte_eth_dev_info dev_info;
2050 struct rte_eth_rss_reta_entry64 reta_conf[8];
2051 struct cmd_config_rss_reta *res = parsed_result;
2053 memset(&dev_info, 0, sizeof(dev_info));
2054 rte_eth_dev_info_get(res->port_id, &dev_info);
2055 if (dev_info.reta_size == 0) {
2056 printf("Redirection table size is 0 which is "
2057 "invalid for RSS\n");
2060 printf("The reta size of port %d is %u\n",
2061 res->port_id, dev_info.reta_size);
2062 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2063 printf("Currently do not support more than %u entries of "
2064 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2068 memset(reta_conf, 0, sizeof(reta_conf));
2069 if (!strcmp(res->list_name, "reta")) {
2070 if (parse_reta_config(res->list_of_items, reta_conf,
2071 dev_info.reta_size)) {
2072 printf("Invalid RSS Redirection Table "
2073 "config entered\n");
2076 ret = rte_eth_dev_rss_reta_update(res->port_id,
2077 reta_conf, dev_info.reta_size);
2079 printf("Bad redirection table parameter, "
2080 "return code = %d \n", ret);
2084 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2085 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2086 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2087 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2088 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2089 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2090 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2091 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2092 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2093 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2094 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2095 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2097 cmdline_parse_inst_t cmd_config_rss_reta = {
2098 .f = cmd_set_rss_reta_parsed,
2100 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2102 (void *)&cmd_config_rss_reta_port,
2103 (void *)&cmd_config_rss_reta_keyword,
2104 (void *)&cmd_config_rss_reta_port_id,
2105 (void *)&cmd_config_rss_reta_name,
2106 (void *)&cmd_config_rss_reta_list_name,
2107 (void *)&cmd_config_rss_reta_list_of_items,
2112 /* *** SHOW PORT RETA INFO *** */
2113 struct cmd_showport_reta {
2114 cmdline_fixed_string_t show;
2115 cmdline_fixed_string_t port;
2117 cmdline_fixed_string_t rss;
2118 cmdline_fixed_string_t reta;
2120 cmdline_fixed_string_t list_of_items;
2124 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2125 uint16_t nb_entries,
2129 const char *p, *p0 = str;
2134 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2135 RTE_RETA_GROUP_SIZE;
2138 p = strchr(p0, '(');
2142 p0 = strchr(p, ')');
2146 if (size >= sizeof(s)) {
2147 printf("The string size exceeds the internal buffer size\n");
2150 snprintf(s, sizeof(s), "%.*s", size, p);
2151 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2152 if (ret <= 0 || ret != num) {
2153 printf("The bits of masks do not match the number of "
2154 "reta entries: %u\n", num);
2157 for (i = 0; i < ret; i++)
2158 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2164 cmd_showport_reta_parsed(void *parsed_result,
2165 __attribute__((unused)) struct cmdline *cl,
2166 __attribute__((unused)) void *data)
2168 struct cmd_showport_reta *res = parsed_result;
2169 struct rte_eth_rss_reta_entry64 reta_conf[8];
2170 struct rte_eth_dev_info dev_info;
2172 memset(&dev_info, 0, sizeof(dev_info));
2173 rte_eth_dev_info_get(res->port_id, &dev_info);
2174 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2175 res->size > ETH_RSS_RETA_SIZE_512) {
2176 printf("Invalid redirection table size: %u\n", res->size);
2180 memset(reta_conf, 0, sizeof(reta_conf));
2181 if (showport_parse_reta_config(reta_conf, res->size,
2182 res->list_of_items) < 0) {
2183 printf("Invalid string: %s for reta masks\n",
2184 res->list_of_items);
2187 port_rss_reta_info(res->port_id, reta_conf, res->size);
2190 cmdline_parse_token_string_t cmd_showport_reta_show =
2191 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2192 cmdline_parse_token_string_t cmd_showport_reta_port =
2193 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2194 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2195 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2196 cmdline_parse_token_string_t cmd_showport_reta_rss =
2197 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2198 cmdline_parse_token_string_t cmd_showport_reta_reta =
2199 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2200 cmdline_parse_token_num_t cmd_showport_reta_size =
2201 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2202 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2203 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2204 list_of_items, NULL);
2206 cmdline_parse_inst_t cmd_showport_reta = {
2207 .f = cmd_showport_reta_parsed,
2209 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2211 (void *)&cmd_showport_reta_show,
2212 (void *)&cmd_showport_reta_port,
2213 (void *)&cmd_showport_reta_port_id,
2214 (void *)&cmd_showport_reta_rss,
2215 (void *)&cmd_showport_reta_reta,
2216 (void *)&cmd_showport_reta_size,
2217 (void *)&cmd_showport_reta_list_of_items,
2222 /* *** Show RSS hash configuration *** */
2223 struct cmd_showport_rss_hash {
2224 cmdline_fixed_string_t show;
2225 cmdline_fixed_string_t port;
2227 cmdline_fixed_string_t rss_hash;
2228 cmdline_fixed_string_t rss_type;
2229 cmdline_fixed_string_t key; /* optional argument */
2232 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2233 __attribute__((unused)) struct cmdline *cl,
2236 struct cmd_showport_rss_hash *res = parsed_result;
2238 port_rss_hash_conf_show(res->port_id, res->rss_type,
2239 show_rss_key != NULL);
2242 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2243 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2244 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2245 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2246 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2247 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2248 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2249 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2251 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2252 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2253 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2254 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2255 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2256 "ipv6-tcp-ex#ipv6-udp-ex");
2257 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2258 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2260 cmdline_parse_inst_t cmd_showport_rss_hash = {
2261 .f = cmd_showport_rss_hash_parsed,
2263 .help_str = "show port <port_id> rss-hash "
2264 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2265 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2266 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2268 (void *)&cmd_showport_rss_hash_show,
2269 (void *)&cmd_showport_rss_hash_port,
2270 (void *)&cmd_showport_rss_hash_port_id,
2271 (void *)&cmd_showport_rss_hash_rss_hash,
2272 (void *)&cmd_showport_rss_hash_rss_hash_info,
2277 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2278 .f = cmd_showport_rss_hash_parsed,
2280 .help_str = "show port <port_id> rss-hash "
2281 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2282 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2283 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2285 (void *)&cmd_showport_rss_hash_show,
2286 (void *)&cmd_showport_rss_hash_port,
2287 (void *)&cmd_showport_rss_hash_port_id,
2288 (void *)&cmd_showport_rss_hash_rss_hash,
2289 (void *)&cmd_showport_rss_hash_rss_hash_info,
2290 (void *)&cmd_showport_rss_hash_rss_key,
2295 /* *** Configure DCB *** */
2296 struct cmd_config_dcb {
2297 cmdline_fixed_string_t port;
2298 cmdline_fixed_string_t config;
2300 cmdline_fixed_string_t dcb;
2301 cmdline_fixed_string_t vt;
2302 cmdline_fixed_string_t vt_en;
2304 cmdline_fixed_string_t pfc;
2305 cmdline_fixed_string_t pfc_en;
2309 cmd_config_dcb_parsed(void *parsed_result,
2310 __attribute__((unused)) struct cmdline *cl,
2311 __attribute__((unused)) void *data)
2313 struct cmd_config_dcb *res = parsed_result;
2314 portid_t port_id = res->port_id;
2315 struct rte_port *port;
2319 port = &ports[port_id];
2320 /** Check if the port is not started **/
2321 if (port->port_status != RTE_PORT_STOPPED) {
2322 printf("Please stop port %d first\n", port_id);
2326 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2327 printf("The invalid number of traffic class,"
2328 " only 4 or 8 allowed.\n");
2332 if (nb_fwd_lcores < res->num_tcs) {
2333 printf("nb_cores shouldn't be less than number of TCs.\n");
2336 if (!strncmp(res->pfc_en, "on", 2))
2341 /* DCB in VT mode */
2342 if (!strncmp(res->vt_en, "on", 2))
2343 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2344 (enum rte_eth_nb_tcs)res->num_tcs,
2347 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2348 (enum rte_eth_nb_tcs)res->num_tcs,
2353 printf("Cannot initialize network ports.\n");
2357 cmd_reconfig_device_queue(port_id, 1, 1);
2360 cmdline_parse_token_string_t cmd_config_dcb_port =
2361 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2362 cmdline_parse_token_string_t cmd_config_dcb_config =
2363 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2364 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2365 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2366 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2367 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2368 cmdline_parse_token_string_t cmd_config_dcb_vt =
2369 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2370 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2371 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2372 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2373 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2374 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2375 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2376 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2377 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2379 cmdline_parse_inst_t cmd_config_dcb = {
2380 .f = cmd_config_dcb_parsed,
2382 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2384 (void *)&cmd_config_dcb_port,
2385 (void *)&cmd_config_dcb_config,
2386 (void *)&cmd_config_dcb_port_id,
2387 (void *)&cmd_config_dcb_dcb,
2388 (void *)&cmd_config_dcb_vt,
2389 (void *)&cmd_config_dcb_vt_en,
2390 (void *)&cmd_config_dcb_num_tcs,
2391 (void *)&cmd_config_dcb_pfc,
2392 (void *)&cmd_config_dcb_pfc_en,
2397 /* *** configure number of packets per burst *** */
2398 struct cmd_config_burst {
2399 cmdline_fixed_string_t port;
2400 cmdline_fixed_string_t keyword;
2401 cmdline_fixed_string_t all;
2402 cmdline_fixed_string_t name;
2407 cmd_config_burst_parsed(void *parsed_result,
2408 __attribute__((unused)) struct cmdline *cl,
2409 __attribute__((unused)) void *data)
2411 struct cmd_config_burst *res = parsed_result;
2413 if (!all_ports_stopped()) {
2414 printf("Please stop all ports first\n");
2418 if (!strcmp(res->name, "burst")) {
2419 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2420 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2423 nb_pkt_per_burst = res->value;
2425 printf("Unknown parameter\n");
2431 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2434 cmdline_parse_token_string_t cmd_config_burst_port =
2435 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2436 cmdline_parse_token_string_t cmd_config_burst_keyword =
2437 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2438 cmdline_parse_token_string_t cmd_config_burst_all =
2439 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2440 cmdline_parse_token_string_t cmd_config_burst_name =
2441 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2442 cmdline_parse_token_num_t cmd_config_burst_value =
2443 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2445 cmdline_parse_inst_t cmd_config_burst = {
2446 .f = cmd_config_burst_parsed,
2448 .help_str = "port config all burst <value>",
2450 (void *)&cmd_config_burst_port,
2451 (void *)&cmd_config_burst_keyword,
2452 (void *)&cmd_config_burst_all,
2453 (void *)&cmd_config_burst_name,
2454 (void *)&cmd_config_burst_value,
2459 /* *** configure rx/tx queues *** */
2460 struct cmd_config_thresh {
2461 cmdline_fixed_string_t port;
2462 cmdline_fixed_string_t keyword;
2463 cmdline_fixed_string_t all;
2464 cmdline_fixed_string_t name;
2469 cmd_config_thresh_parsed(void *parsed_result,
2470 __attribute__((unused)) struct cmdline *cl,
2471 __attribute__((unused)) void *data)
2473 struct cmd_config_thresh *res = parsed_result;
2475 if (!all_ports_stopped()) {
2476 printf("Please stop all ports first\n");
2480 if (!strcmp(res->name, "txpt"))
2481 tx_pthresh = res->value;
2482 else if(!strcmp(res->name, "txht"))
2483 tx_hthresh = res->value;
2484 else if(!strcmp(res->name, "txwt"))
2485 tx_wthresh = res->value;
2486 else if(!strcmp(res->name, "rxpt"))
2487 rx_pthresh = res->value;
2488 else if(!strcmp(res->name, "rxht"))
2489 rx_hthresh = res->value;
2490 else if(!strcmp(res->name, "rxwt"))
2491 rx_wthresh = res->value;
2493 printf("Unknown parameter\n");
2499 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2502 cmdline_parse_token_string_t cmd_config_thresh_port =
2503 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2504 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2505 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2506 cmdline_parse_token_string_t cmd_config_thresh_all =
2507 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2508 cmdline_parse_token_string_t cmd_config_thresh_name =
2509 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2510 "txpt#txht#txwt#rxpt#rxht#rxwt");
2511 cmdline_parse_token_num_t cmd_config_thresh_value =
2512 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2514 cmdline_parse_inst_t cmd_config_thresh = {
2515 .f = cmd_config_thresh_parsed,
2517 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2519 (void *)&cmd_config_thresh_port,
2520 (void *)&cmd_config_thresh_keyword,
2521 (void *)&cmd_config_thresh_all,
2522 (void *)&cmd_config_thresh_name,
2523 (void *)&cmd_config_thresh_value,
2528 /* *** configure free/rs threshold *** */
2529 struct cmd_config_threshold {
2530 cmdline_fixed_string_t port;
2531 cmdline_fixed_string_t keyword;
2532 cmdline_fixed_string_t all;
2533 cmdline_fixed_string_t name;
2538 cmd_config_threshold_parsed(void *parsed_result,
2539 __attribute__((unused)) struct cmdline *cl,
2540 __attribute__((unused)) void *data)
2542 struct cmd_config_threshold *res = parsed_result;
2544 if (!all_ports_stopped()) {
2545 printf("Please stop all ports first\n");
2549 if (!strcmp(res->name, "txfreet"))
2550 tx_free_thresh = res->value;
2551 else if (!strcmp(res->name, "txrst"))
2552 tx_rs_thresh = res->value;
2553 else if (!strcmp(res->name, "rxfreet"))
2554 rx_free_thresh = res->value;
2556 printf("Unknown parameter\n");
2562 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2565 cmdline_parse_token_string_t cmd_config_threshold_port =
2566 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2567 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2568 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2570 cmdline_parse_token_string_t cmd_config_threshold_all =
2571 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2572 cmdline_parse_token_string_t cmd_config_threshold_name =
2573 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2574 "txfreet#txrst#rxfreet");
2575 cmdline_parse_token_num_t cmd_config_threshold_value =
2576 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2578 cmdline_parse_inst_t cmd_config_threshold = {
2579 .f = cmd_config_threshold_parsed,
2581 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2583 (void *)&cmd_config_threshold_port,
2584 (void *)&cmd_config_threshold_keyword,
2585 (void *)&cmd_config_threshold_all,
2586 (void *)&cmd_config_threshold_name,
2587 (void *)&cmd_config_threshold_value,
2593 struct cmd_stop_result {
2594 cmdline_fixed_string_t stop;
2597 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2598 __attribute__((unused)) struct cmdline *cl,
2599 __attribute__((unused)) void *data)
2601 stop_packet_forwarding();
2604 cmdline_parse_token_string_t cmd_stop_stop =
2605 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2607 cmdline_parse_inst_t cmd_stop = {
2608 .f = cmd_stop_parsed,
2610 .help_str = "stop: Stop packet forwarding",
2612 (void *)&cmd_stop_stop,
2617 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2620 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2621 unsigned int *parsed_items, int check_unique_values)
2623 unsigned int nb_item;
2631 * First parse all items in the list and store their value.
2636 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2638 if ((c >= '0') && (c <= '9')) {
2639 value = (unsigned int) (value * 10 + (c - '0'));
2644 printf("character %c is not a decimal digit\n", c);
2648 printf("No valid value before comma\n");
2651 if (nb_item < max_items) {
2652 parsed_items[nb_item] = value;
2658 if (nb_item >= max_items) {
2659 printf("Number of %s = %u > %u (maximum items)\n",
2660 item_name, nb_item + 1, max_items);
2663 parsed_items[nb_item++] = value;
2664 if (! check_unique_values)
2668 * Then, check that all values in the list are differents.
2669 * No optimization here...
2671 for (i = 0; i < nb_item; i++) {
2672 for (j = i + 1; j < nb_item; j++) {
2673 if (parsed_items[j] == parsed_items[i]) {
2674 printf("duplicated %s %u at index %u and %u\n",
2675 item_name, parsed_items[i], i, j);
2683 struct cmd_set_list_result {
2684 cmdline_fixed_string_t cmd_keyword;
2685 cmdline_fixed_string_t list_name;
2686 cmdline_fixed_string_t list_of_items;
2689 static void cmd_set_list_parsed(void *parsed_result,
2690 __attribute__((unused)) struct cmdline *cl,
2691 __attribute__((unused)) void *data)
2693 struct cmd_set_list_result *res;
2695 unsigned int lcorelist[RTE_MAX_LCORE];
2696 unsigned int portlist[RTE_MAX_ETHPORTS];
2698 unsigned int nb_item;
2700 if (test_done == 0) {
2701 printf("Please stop forwarding first\n");
2705 res = parsed_result;
2706 if (!strcmp(res->list_name, "corelist")) {
2707 nb_item = parse_item_list(res->list_of_items, "core",
2709 parsed_items.lcorelist, 1);
2711 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2716 if (!strcmp(res->list_name, "portlist")) {
2717 nb_item = parse_item_list(res->list_of_items, "port",
2719 parsed_items.portlist, 1);
2721 set_fwd_ports_list(parsed_items.portlist, nb_item);
2727 cmdline_parse_token_string_t cmd_set_list_keyword =
2728 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2730 cmdline_parse_token_string_t cmd_set_list_name =
2731 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2732 "corelist#portlist");
2733 cmdline_parse_token_string_t cmd_set_list_of_items =
2734 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2737 cmdline_parse_inst_t cmd_set_fwd_list = {
2738 .f = cmd_set_list_parsed,
2740 .help_str = "set corelist|portlist <list0[,list1]*>",
2742 (void *)&cmd_set_list_keyword,
2743 (void *)&cmd_set_list_name,
2744 (void *)&cmd_set_list_of_items,
2749 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2751 struct cmd_setmask_result {
2752 cmdline_fixed_string_t set;
2753 cmdline_fixed_string_t mask;
2757 static void cmd_set_mask_parsed(void *parsed_result,
2758 __attribute__((unused)) struct cmdline *cl,
2759 __attribute__((unused)) void *data)
2761 struct cmd_setmask_result *res = parsed_result;
2763 if (test_done == 0) {
2764 printf("Please stop forwarding first\n");
2767 if (!strcmp(res->mask, "coremask")) {
2768 set_fwd_lcores_mask(res->hexavalue);
2770 } else if (!strcmp(res->mask, "portmask")) {
2771 set_fwd_ports_mask(res->hexavalue);
2776 cmdline_parse_token_string_t cmd_setmask_set =
2777 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2778 cmdline_parse_token_string_t cmd_setmask_mask =
2779 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2780 "coremask#portmask");
2781 cmdline_parse_token_num_t cmd_setmask_value =
2782 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2784 cmdline_parse_inst_t cmd_set_fwd_mask = {
2785 .f = cmd_set_mask_parsed,
2787 .help_str = "set coremask|portmask <hexadecimal value>",
2789 (void *)&cmd_setmask_set,
2790 (void *)&cmd_setmask_mask,
2791 (void *)&cmd_setmask_value,
2797 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2799 struct cmd_set_result {
2800 cmdline_fixed_string_t set;
2801 cmdline_fixed_string_t what;
2805 static void cmd_set_parsed(void *parsed_result,
2806 __attribute__((unused)) struct cmdline *cl,
2807 __attribute__((unused)) void *data)
2809 struct cmd_set_result *res = parsed_result;
2810 if (!strcmp(res->what, "nbport")) {
2811 set_fwd_ports_number(res->value);
2813 } else if (!strcmp(res->what, "nbcore")) {
2814 set_fwd_lcores_number(res->value);
2816 } else if (!strcmp(res->what, "burst"))
2817 set_nb_pkt_per_burst(res->value);
2818 else if (!strcmp(res->what, "verbose"))
2819 set_verbose_level(res->value);
2822 cmdline_parse_token_string_t cmd_set_set =
2823 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2824 cmdline_parse_token_string_t cmd_set_what =
2825 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2826 "nbport#nbcore#burst#verbose");
2827 cmdline_parse_token_num_t cmd_set_value =
2828 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2830 cmdline_parse_inst_t cmd_set_numbers = {
2831 .f = cmd_set_parsed,
2833 .help_str = "set nbport|nbcore|burst|verbose <value>",
2835 (void *)&cmd_set_set,
2836 (void *)&cmd_set_what,
2837 (void *)&cmd_set_value,
2842 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2844 struct cmd_set_txpkts_result {
2845 cmdline_fixed_string_t cmd_keyword;
2846 cmdline_fixed_string_t txpkts;
2847 cmdline_fixed_string_t seg_lengths;
2851 cmd_set_txpkts_parsed(void *parsed_result,
2852 __attribute__((unused)) struct cmdline *cl,
2853 __attribute__((unused)) void *data)
2855 struct cmd_set_txpkts_result *res;
2856 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2857 unsigned int nb_segs;
2859 res = parsed_result;
2860 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2861 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2863 set_tx_pkt_segments(seg_lengths, nb_segs);
2866 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2867 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2868 cmd_keyword, "set");
2869 cmdline_parse_token_string_t cmd_set_txpkts_name =
2870 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2872 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2873 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2876 cmdline_parse_inst_t cmd_set_txpkts = {
2877 .f = cmd_set_txpkts_parsed,
2879 .help_str = "set txpkts <len0[,len1]*>",
2881 (void *)&cmd_set_txpkts_keyword,
2882 (void *)&cmd_set_txpkts_name,
2883 (void *)&cmd_set_txpkts_lengths,
2888 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2890 struct cmd_set_txsplit_result {
2891 cmdline_fixed_string_t cmd_keyword;
2892 cmdline_fixed_string_t txsplit;
2893 cmdline_fixed_string_t mode;
2897 cmd_set_txsplit_parsed(void *parsed_result,
2898 __attribute__((unused)) struct cmdline *cl,
2899 __attribute__((unused)) void *data)
2901 struct cmd_set_txsplit_result *res;
2903 res = parsed_result;
2904 set_tx_pkt_split(res->mode);
2907 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2908 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2909 cmd_keyword, "set");
2910 cmdline_parse_token_string_t cmd_set_txsplit_name =
2911 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2912 txsplit, "txsplit");
2913 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2914 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2917 cmdline_parse_inst_t cmd_set_txsplit = {
2918 .f = cmd_set_txsplit_parsed,
2920 .help_str = "set txsplit on|off|rand",
2922 (void *)&cmd_set_txsplit_keyword,
2923 (void *)&cmd_set_txsplit_name,
2924 (void *)&cmd_set_txsplit_mode,
2929 /* *** CONFIG TX QUEUE FLAGS *** */
2931 struct cmd_config_txqflags_result {
2932 cmdline_fixed_string_t port;
2933 cmdline_fixed_string_t config;
2934 cmdline_fixed_string_t all;
2935 cmdline_fixed_string_t what;
2939 static void cmd_config_txqflags_parsed(void *parsed_result,
2940 __attribute__((unused)) struct cmdline *cl,
2941 __attribute__((unused)) void *data)
2943 struct cmd_config_txqflags_result *res = parsed_result;
2945 if (!all_ports_stopped()) {
2946 printf("Please stop all ports first\n");
2950 if (strcmp(res->what, "txqflags")) {
2951 printf("Unknown parameter\n");
2955 if (res->hexvalue >= 0) {
2956 txq_flags = res->hexvalue;
2958 printf("txqflags must be >= 0\n");
2964 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2967 cmdline_parse_token_string_t cmd_config_txqflags_port =
2968 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2970 cmdline_parse_token_string_t cmd_config_txqflags_config =
2971 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2973 cmdline_parse_token_string_t cmd_config_txqflags_all =
2974 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2976 cmdline_parse_token_string_t cmd_config_txqflags_what =
2977 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2979 cmdline_parse_token_num_t cmd_config_txqflags_value =
2980 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2983 cmdline_parse_inst_t cmd_config_txqflags = {
2984 .f = cmd_config_txqflags_parsed,
2986 .help_str = "port config all txqflags <value>",
2988 (void *)&cmd_config_txqflags_port,
2989 (void *)&cmd_config_txqflags_config,
2990 (void *)&cmd_config_txqflags_all,
2991 (void *)&cmd_config_txqflags_what,
2992 (void *)&cmd_config_txqflags_value,
2997 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2998 struct cmd_rx_vlan_filter_all_result {
2999 cmdline_fixed_string_t rx_vlan;
3000 cmdline_fixed_string_t what;
3001 cmdline_fixed_string_t all;
3006 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3007 __attribute__((unused)) struct cmdline *cl,
3008 __attribute__((unused)) void *data)
3010 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3012 if (!strcmp(res->what, "add"))
3013 rx_vlan_all_filter_set(res->port_id, 1);
3015 rx_vlan_all_filter_set(res->port_id, 0);
3018 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3019 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3020 rx_vlan, "rx_vlan");
3021 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3022 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3024 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3025 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3027 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3028 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3031 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3032 .f = cmd_rx_vlan_filter_all_parsed,
3034 .help_str = "rx_vlan add|rm all <port_id>: "
3035 "Add/Remove all identifiers to/from the set of VLAN "
3036 "identifiers filtered by a port",
3038 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3039 (void *)&cmd_rx_vlan_filter_all_what,
3040 (void *)&cmd_rx_vlan_filter_all_all,
3041 (void *)&cmd_rx_vlan_filter_all_portid,
3046 /* *** VLAN OFFLOAD SET ON A PORT *** */
3047 struct cmd_vlan_offload_result {
3048 cmdline_fixed_string_t vlan;
3049 cmdline_fixed_string_t set;
3050 cmdline_fixed_string_t vlan_type;
3051 cmdline_fixed_string_t what;
3052 cmdline_fixed_string_t on;
3053 cmdline_fixed_string_t port_id;
3057 cmd_vlan_offload_parsed(void *parsed_result,
3058 __attribute__((unused)) struct cmdline *cl,
3059 __attribute__((unused)) void *data)
3062 struct cmd_vlan_offload_result *res = parsed_result;
3065 portid_t port_id = 0;
3069 len = strnlen(str, STR_TOKEN_SIZE);
3071 /* Get port_id first */
3079 tmp = strtoul(str, NULL, 0);
3080 /* If port_id greater that what portid_t can represent, return */
3081 if(tmp >= RTE_MAX_ETHPORTS)
3083 port_id = (portid_t)tmp;
3085 if (!strcmp(res->on, "on"))
3090 if (!strcmp(res->what, "strip"))
3091 rx_vlan_strip_set(port_id, on);
3092 else if(!strcmp(res->what, "stripq")){
3093 uint16_t queue_id = 0;
3095 /* No queue_id, return */
3097 printf("must specify (port,queue_id)\n");
3100 tmp = strtoul(str + i + 1, NULL, 0);
3101 /* If queue_id greater that what 16-bits can represent, return */
3105 queue_id = (uint16_t)tmp;
3106 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3108 else if (!strcmp(res->what, "filter"))
3109 rx_vlan_filter_set(port_id, on);
3111 vlan_extend_set(port_id, on);
3116 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3117 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3119 cmdline_parse_token_string_t cmd_vlan_offload_set =
3120 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3122 cmdline_parse_token_string_t cmd_vlan_offload_what =
3123 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3124 what, "strip#filter#qinq#stripq");
3125 cmdline_parse_token_string_t cmd_vlan_offload_on =
3126 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3128 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3129 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3132 cmdline_parse_inst_t cmd_vlan_offload = {
3133 .f = cmd_vlan_offload_parsed,
3135 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3136 "<port_id[,queue_id]>: "
3137 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3139 (void *)&cmd_vlan_offload_vlan,
3140 (void *)&cmd_vlan_offload_set,
3141 (void *)&cmd_vlan_offload_what,
3142 (void *)&cmd_vlan_offload_on,
3143 (void *)&cmd_vlan_offload_portid,
3148 /* *** VLAN TPID SET ON A PORT *** */
3149 struct cmd_vlan_tpid_result {
3150 cmdline_fixed_string_t vlan;
3151 cmdline_fixed_string_t set;
3152 cmdline_fixed_string_t vlan_type;
3153 cmdline_fixed_string_t what;
3159 cmd_vlan_tpid_parsed(void *parsed_result,
3160 __attribute__((unused)) struct cmdline *cl,
3161 __attribute__((unused)) void *data)
3163 struct cmd_vlan_tpid_result *res = parsed_result;
3164 enum rte_vlan_type vlan_type;
3166 if (!strcmp(res->vlan_type, "inner"))
3167 vlan_type = ETH_VLAN_TYPE_INNER;
3168 else if (!strcmp(res->vlan_type, "outer"))
3169 vlan_type = ETH_VLAN_TYPE_OUTER;
3171 printf("Unknown vlan type\n");
3174 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3177 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3178 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3180 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3181 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3183 cmdline_parse_token_string_t cmd_vlan_type =
3184 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3185 vlan_type, "inner#outer");
3186 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3187 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3189 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3190 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3192 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3193 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3196 cmdline_parse_inst_t cmd_vlan_tpid = {
3197 .f = cmd_vlan_tpid_parsed,
3199 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3200 "Set the VLAN Ether type",
3202 (void *)&cmd_vlan_tpid_vlan,
3203 (void *)&cmd_vlan_tpid_set,
3204 (void *)&cmd_vlan_type,
3205 (void *)&cmd_vlan_tpid_what,
3206 (void *)&cmd_vlan_tpid_tpid,
3207 (void *)&cmd_vlan_tpid_portid,
3212 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3213 struct cmd_rx_vlan_filter_result {
3214 cmdline_fixed_string_t rx_vlan;
3215 cmdline_fixed_string_t what;
3221 cmd_rx_vlan_filter_parsed(void *parsed_result,
3222 __attribute__((unused)) struct cmdline *cl,
3223 __attribute__((unused)) void *data)
3225 struct cmd_rx_vlan_filter_result *res = parsed_result;
3227 if (!strcmp(res->what, "add"))
3228 rx_vft_set(res->port_id, res->vlan_id, 1);
3230 rx_vft_set(res->port_id, res->vlan_id, 0);
3233 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3234 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3235 rx_vlan, "rx_vlan");
3236 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3237 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3239 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3240 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3242 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3243 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3246 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3247 .f = cmd_rx_vlan_filter_parsed,
3249 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3250 "Add/Remove a VLAN identifier to/from the set of VLAN "
3251 "identifiers filtered by a port",
3253 (void *)&cmd_rx_vlan_filter_rx_vlan,
3254 (void *)&cmd_rx_vlan_filter_what,
3255 (void *)&cmd_rx_vlan_filter_vlanid,
3256 (void *)&cmd_rx_vlan_filter_portid,
3261 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3262 struct cmd_tx_vlan_set_result {
3263 cmdline_fixed_string_t tx_vlan;
3264 cmdline_fixed_string_t set;
3270 cmd_tx_vlan_set_parsed(void *parsed_result,
3271 __attribute__((unused)) struct cmdline *cl,
3272 __attribute__((unused)) void *data)
3274 struct cmd_tx_vlan_set_result *res = parsed_result;
3276 tx_vlan_set(res->port_id, res->vlan_id);
3279 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3280 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3281 tx_vlan, "tx_vlan");
3282 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3283 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3285 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3286 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3288 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3289 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3292 cmdline_parse_inst_t cmd_tx_vlan_set = {
3293 .f = cmd_tx_vlan_set_parsed,
3295 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3296 "Enable hardware insertion of a single VLAN header "
3297 "with a given TAG Identifier in packets sent on a port",
3299 (void *)&cmd_tx_vlan_set_tx_vlan,
3300 (void *)&cmd_tx_vlan_set_set,
3301 (void *)&cmd_tx_vlan_set_portid,
3302 (void *)&cmd_tx_vlan_set_vlanid,
3307 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3308 struct cmd_tx_vlan_set_qinq_result {
3309 cmdline_fixed_string_t tx_vlan;
3310 cmdline_fixed_string_t set;
3313 uint16_t vlan_id_outer;
3317 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3318 __attribute__((unused)) struct cmdline *cl,
3319 __attribute__((unused)) void *data)
3321 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3323 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3326 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3327 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3328 tx_vlan, "tx_vlan");
3329 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3330 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3332 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3333 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3335 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3336 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3338 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3339 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3340 vlan_id_outer, UINT16);
3342 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3343 .f = cmd_tx_vlan_set_qinq_parsed,
3345 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3346 "Enable hardware insertion of double VLAN header "
3347 "with given TAG Identifiers in packets sent on a port",
3349 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3350 (void *)&cmd_tx_vlan_set_qinq_set,
3351 (void *)&cmd_tx_vlan_set_qinq_portid,
3352 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3353 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3358 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3359 struct cmd_tx_vlan_set_pvid_result {
3360 cmdline_fixed_string_t tx_vlan;
3361 cmdline_fixed_string_t set;
3362 cmdline_fixed_string_t pvid;
3365 cmdline_fixed_string_t mode;
3369 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3370 __attribute__((unused)) struct cmdline *cl,
3371 __attribute__((unused)) void *data)
3373 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3375 if (strcmp(res->mode, "on") == 0)
3376 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3378 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3381 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3382 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3383 tx_vlan, "tx_vlan");
3384 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3385 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3387 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3388 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3390 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3391 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3393 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3394 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3396 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3397 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3400 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3401 .f = cmd_tx_vlan_set_pvid_parsed,
3403 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3405 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3406 (void *)&cmd_tx_vlan_set_pvid_set,
3407 (void *)&cmd_tx_vlan_set_pvid_pvid,
3408 (void *)&cmd_tx_vlan_set_pvid_port_id,
3409 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3410 (void *)&cmd_tx_vlan_set_pvid_mode,
3415 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3416 struct cmd_tx_vlan_reset_result {
3417 cmdline_fixed_string_t tx_vlan;
3418 cmdline_fixed_string_t reset;
3423 cmd_tx_vlan_reset_parsed(void *parsed_result,
3424 __attribute__((unused)) struct cmdline *cl,
3425 __attribute__((unused)) void *data)
3427 struct cmd_tx_vlan_reset_result *res = parsed_result;
3429 tx_vlan_reset(res->port_id);
3432 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3433 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3434 tx_vlan, "tx_vlan");
3435 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3436 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3438 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3439 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3442 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3443 .f = cmd_tx_vlan_reset_parsed,
3445 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3446 "VLAN header in packets sent on a port",
3448 (void *)&cmd_tx_vlan_reset_tx_vlan,
3449 (void *)&cmd_tx_vlan_reset_reset,
3450 (void *)&cmd_tx_vlan_reset_portid,
3456 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3457 struct cmd_csum_result {
3458 cmdline_fixed_string_t csum;
3459 cmdline_fixed_string_t mode;
3460 cmdline_fixed_string_t proto;
3461 cmdline_fixed_string_t hwsw;
3466 csum_show(int port_id)
3468 struct rte_eth_dev_info dev_info;
3471 ol_flags = ports[port_id].tx_ol_flags;
3472 printf("Parse tunnel is %s\n",
3473 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3474 printf("IP checksum offload is %s\n",
3475 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3476 printf("UDP checksum offload is %s\n",
3477 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3478 printf("TCP checksum offload is %s\n",
3479 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3480 printf("SCTP checksum offload is %s\n",
3481 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3482 printf("Outer-Ip checksum offload is %s\n",
3483 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3485 /* display warnings if configuration is not supported by the NIC */
3486 rte_eth_dev_info_get(port_id, &dev_info);
3487 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3488 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3489 printf("Warning: hardware IP checksum enabled but not "
3490 "supported by port %d\n", port_id);
3492 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3493 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3494 printf("Warning: hardware UDP checksum enabled but not "
3495 "supported by port %d\n", port_id);
3497 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3498 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3499 printf("Warning: hardware TCP checksum enabled but not "
3500 "supported by port %d\n", port_id);
3502 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3503 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3504 printf("Warning: hardware SCTP checksum enabled but not "
3505 "supported by port %d\n", port_id);
3507 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3508 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3509 printf("Warning: hardware outer IP checksum enabled but not "
3510 "supported by port %d\n", port_id);
3515 cmd_csum_parsed(void *parsed_result,
3516 __attribute__((unused)) struct cmdline *cl,
3517 __attribute__((unused)) void *data)
3519 struct cmd_csum_result *res = parsed_result;
3523 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3524 printf("invalid port %d\n", res->port_id);
3528 if (!strcmp(res->mode, "set")) {
3530 if (!strcmp(res->hwsw, "hw"))
3533 if (!strcmp(res->proto, "ip")) {
3534 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3535 } else if (!strcmp(res->proto, "udp")) {
3536 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3537 } else if (!strcmp(res->proto, "tcp")) {
3538 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3539 } else if (!strcmp(res->proto, "sctp")) {
3540 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3541 } else if (!strcmp(res->proto, "outer-ip")) {
3542 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3546 ports[res->port_id].tx_ol_flags |= mask;
3548 ports[res->port_id].tx_ol_flags &= (~mask);
3550 csum_show(res->port_id);
3553 cmdline_parse_token_string_t cmd_csum_csum =
3554 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3556 cmdline_parse_token_string_t cmd_csum_mode =
3557 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3559 cmdline_parse_token_string_t cmd_csum_proto =
3560 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3561 proto, "ip#tcp#udp#sctp#outer-ip");
3562 cmdline_parse_token_string_t cmd_csum_hwsw =
3563 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3565 cmdline_parse_token_num_t cmd_csum_portid =
3566 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3569 cmdline_parse_inst_t cmd_csum_set = {
3570 .f = cmd_csum_parsed,
3572 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3573 "Enable/Disable hardware calculation of L3/L4 checksum when "
3574 "using csum forward engine",
3576 (void *)&cmd_csum_csum,
3577 (void *)&cmd_csum_mode,
3578 (void *)&cmd_csum_proto,
3579 (void *)&cmd_csum_hwsw,
3580 (void *)&cmd_csum_portid,
3585 cmdline_parse_token_string_t cmd_csum_mode_show =
3586 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3589 cmdline_parse_inst_t cmd_csum_show = {
3590 .f = cmd_csum_parsed,
3592 .help_str = "csum show <port_id>: Show checksum offload configuration",
3594 (void *)&cmd_csum_csum,
3595 (void *)&cmd_csum_mode_show,
3596 (void *)&cmd_csum_portid,
3601 /* Enable/disable tunnel parsing */
3602 struct cmd_csum_tunnel_result {
3603 cmdline_fixed_string_t csum;
3604 cmdline_fixed_string_t parse;
3605 cmdline_fixed_string_t onoff;
3610 cmd_csum_tunnel_parsed(void *parsed_result,
3611 __attribute__((unused)) struct cmdline *cl,
3612 __attribute__((unused)) void *data)
3614 struct cmd_csum_tunnel_result *res = parsed_result;
3616 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3619 if (!strcmp(res->onoff, "on"))
3620 ports[res->port_id].tx_ol_flags |=
3621 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3623 ports[res->port_id].tx_ol_flags &=
3624 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3626 csum_show(res->port_id);
3629 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3630 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3632 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3633 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3634 parse, "parse_tunnel");
3635 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3636 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3638 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3639 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3642 cmdline_parse_inst_t cmd_csum_tunnel = {
3643 .f = cmd_csum_tunnel_parsed,
3645 .help_str = "csum parse_tunnel on|off <port_id>: "
3646 "Enable/Disable parsing of tunnels for csum engine",
3648 (void *)&cmd_csum_tunnel_csum,
3649 (void *)&cmd_csum_tunnel_parse,
3650 (void *)&cmd_csum_tunnel_onoff,
3651 (void *)&cmd_csum_tunnel_portid,
3656 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3657 struct cmd_tso_set_result {
3658 cmdline_fixed_string_t tso;
3659 cmdline_fixed_string_t mode;
3665 cmd_tso_set_parsed(void *parsed_result,
3666 __attribute__((unused)) struct cmdline *cl,
3667 __attribute__((unused)) void *data)
3669 struct cmd_tso_set_result *res = parsed_result;
3670 struct rte_eth_dev_info dev_info;
3672 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3675 if (!strcmp(res->mode, "set"))
3676 ports[res->port_id].tso_segsz = res->tso_segsz;
3678 if (ports[res->port_id].tso_segsz == 0)
3679 printf("TSO for non-tunneled packets is disabled\n");
3681 printf("TSO segment size for non-tunneled packets is %d\n",
3682 ports[res->port_id].tso_segsz);
3684 /* display warnings if configuration is not supported by the NIC */
3685 rte_eth_dev_info_get(res->port_id, &dev_info);
3686 if ((ports[res->port_id].tso_segsz != 0) &&
3687 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3688 printf("Warning: TSO enabled but not "
3689 "supported by port %d\n", res->port_id);
3693 cmdline_parse_token_string_t cmd_tso_set_tso =
3694 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3696 cmdline_parse_token_string_t cmd_tso_set_mode =
3697 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3699 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3700 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3702 cmdline_parse_token_num_t cmd_tso_set_portid =
3703 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3706 cmdline_parse_inst_t cmd_tso_set = {
3707 .f = cmd_tso_set_parsed,
3709 .help_str = "tso set <tso_segsz> <port_id>: "
3710 "Set TSO segment size of non-tunneled packets for csum engine "
3713 (void *)&cmd_tso_set_tso,
3714 (void *)&cmd_tso_set_mode,
3715 (void *)&cmd_tso_set_tso_segsz,
3716 (void *)&cmd_tso_set_portid,
3721 cmdline_parse_token_string_t cmd_tso_show_mode =
3722 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3726 cmdline_parse_inst_t cmd_tso_show = {
3727 .f = cmd_tso_set_parsed,
3729 .help_str = "tso show <port_id>: "
3730 "Show TSO segment size of non-tunneled packets for csum engine",
3732 (void *)&cmd_tso_set_tso,
3733 (void *)&cmd_tso_show_mode,
3734 (void *)&cmd_tso_set_portid,
3739 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3740 struct cmd_tunnel_tso_set_result {
3741 cmdline_fixed_string_t tso;
3742 cmdline_fixed_string_t mode;
3748 check_tunnel_tso_nic_support(uint8_t port_id)
3750 struct rte_eth_dev_info dev_info;
3752 rte_eth_dev_info_get(port_id, &dev_info);
3753 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3754 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3755 "supported by port %d\n", port_id);
3756 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3757 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3758 "supported by port %d\n", port_id);
3759 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3760 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3761 "supported by port %d\n", port_id);
3762 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3763 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3764 "supported by port %d\n", port_id);
3768 cmd_tunnel_tso_set_parsed(void *parsed_result,
3769 __attribute__((unused)) struct cmdline *cl,
3770 __attribute__((unused)) void *data)
3772 struct cmd_tunnel_tso_set_result *res = parsed_result;
3774 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3777 if (!strcmp(res->mode, "set"))
3778 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3780 if (ports[res->port_id].tunnel_tso_segsz == 0)
3781 printf("TSO for tunneled packets is disabled\n");
3783 printf("TSO segment size for tunneled packets is %d\n",
3784 ports[res->port_id].tunnel_tso_segsz);
3786 /* Below conditions are needed to make it work:
3787 * (1) tunnel TSO is supported by the NIC;
3788 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3790 * (3) for tunneled pkts with outer L3 of IPv4,
3791 * "csum set outer-ip" must be set to hw, because after tso,
3792 * total_len of outer IP header is changed, and the checksum
3793 * of outer IP header calculated by sw should be wrong; that
3794 * is not necessary for IPv6 tunneled pkts because there's no
3795 * checksum in IP header anymore.
3797 check_tunnel_tso_nic_support(res->port_id);
3799 if (!(ports[res->port_id].tx_ol_flags &
3800 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3801 printf("Warning: csum parse_tunnel must be set "
3802 "so that tunneled packets are recognized\n");
3803 if (!(ports[res->port_id].tx_ol_flags &
3804 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3805 printf("Warning: csum set outer-ip must be set to hw "
3806 "if outer L3 is IPv4; not necessary for IPv6\n");
3810 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3811 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3813 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3814 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3816 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3817 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3819 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3820 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3823 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3824 .f = cmd_tunnel_tso_set_parsed,
3826 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3827 "Set TSO segment size of tunneled packets for csum engine "
3830 (void *)&cmd_tunnel_tso_set_tso,
3831 (void *)&cmd_tunnel_tso_set_mode,
3832 (void *)&cmd_tunnel_tso_set_tso_segsz,
3833 (void *)&cmd_tunnel_tso_set_portid,
3838 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3839 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3843 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3844 .f = cmd_tunnel_tso_set_parsed,
3846 .help_str = "tunnel_tso show <port_id> "
3847 "Show TSO segment size of tunneled packets for csum engine",
3849 (void *)&cmd_tunnel_tso_set_tso,
3850 (void *)&cmd_tunnel_tso_show_mode,
3851 (void *)&cmd_tunnel_tso_set_portid,
3856 /* *** SET GRO FOR A PORT *** */
3857 struct cmd_gro_result {
3858 cmdline_fixed_string_t cmd_keyword;
3859 cmdline_fixed_string_t mode;
3864 cmd_enable_gro_parsed(void *parsed_result,
3865 __attribute__((unused)) struct cmdline *cl,
3866 __attribute__((unused)) void *data)
3868 struct cmd_gro_result *res;
3870 res = parsed_result;
3871 setup_gro(res->mode, res->port_id);
3874 cmdline_parse_token_string_t cmd_gro_keyword =
3875 TOKEN_STRING_INITIALIZER(struct cmd_gro_result,
3876 cmd_keyword, "gro");
3877 cmdline_parse_token_string_t cmd_gro_mode =
3878 TOKEN_STRING_INITIALIZER(struct cmd_gro_result,
3880 cmdline_parse_token_num_t cmd_gro_pid =
3881 TOKEN_NUM_INITIALIZER(struct cmd_gro_result,
3884 cmdline_parse_inst_t cmd_enable_gro = {
3885 .f = cmd_enable_gro_parsed,
3887 .help_str = "gro (on|off) (port_id)",
3889 (void *)&cmd_gro_keyword,
3890 (void *)&cmd_gro_mode,
3891 (void *)&cmd_gro_pid,
3896 /* *** SET MAX FLOW NUMBER AND ITEM NUM PER FLOW FOR GRO *** */
3897 struct cmd_gro_set_result {
3898 cmdline_fixed_string_t gro;
3899 cmdline_fixed_string_t mode;
3901 uint16_t item_num_per_flow;
3906 cmd_gro_set_parsed(void *parsed_result,
3907 __attribute__((unused)) struct cmdline *cl,
3908 __attribute__((unused)) void *data)
3910 struct cmd_gro_set_result *res = parsed_result;
3912 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3914 if (test_done == 0) {
3915 printf("Before set GRO flow_num and item_num_per_flow,"
3916 " please stop forwarding first\n");
3920 if (!strcmp(res->mode, "set")) {
3921 if (res->flow_num == 0)
3922 printf("Invalid flow number. Revert to default value:"
3923 " %u.\n", GRO_DEFAULT_FLOW_NUM);
3925 gro_ports[res->port_id].param.max_flow_num =
3928 if (res->item_num_per_flow == 0)
3929 printf("Invalid item number per-flow. Revert"
3930 " to default value:%u.\n",
3931 GRO_DEFAULT_ITEM_NUM_PER_FLOW);
3933 gro_ports[res->port_id].param.max_item_per_flow =
3934 res->item_num_per_flow;
3938 cmdline_parse_token_string_t cmd_gro_set_gro =
3939 TOKEN_STRING_INITIALIZER(struct cmd_gro_set_result,
3941 cmdline_parse_token_string_t cmd_gro_set_mode =
3942 TOKEN_STRING_INITIALIZER(struct cmd_gro_set_result,
3944 cmdline_parse_token_num_t cmd_gro_set_flow_num =
3945 TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result,
3947 cmdline_parse_token_num_t cmd_gro_set_item_num_per_flow =
3948 TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result,
3949 item_num_per_flow, UINT16);
3950 cmdline_parse_token_num_t cmd_gro_set_portid =
3951 TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result,
3954 cmdline_parse_inst_t cmd_gro_set = {
3955 .f = cmd_gro_set_parsed,
3957 .help_str = "gro set <max_flow_num> <max_item_num_per_flow> "
3958 "<port_id>: set max flow number and max packet number per-flow "
3961 (void *)&cmd_gro_set_gro,
3962 (void *)&cmd_gro_set_mode,
3963 (void *)&cmd_gro_set_flow_num,
3964 (void *)&cmd_gro_set_item_num_per_flow,
3965 (void *)&cmd_gro_set_portid,
3970 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3971 struct cmd_set_flush_rx {
3972 cmdline_fixed_string_t set;
3973 cmdline_fixed_string_t flush_rx;
3974 cmdline_fixed_string_t mode;
3978 cmd_set_flush_rx_parsed(void *parsed_result,
3979 __attribute__((unused)) struct cmdline *cl,
3980 __attribute__((unused)) void *data)
3982 struct cmd_set_flush_rx *res = parsed_result;
3983 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3986 cmdline_parse_token_string_t cmd_setflushrx_set =
3987 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3989 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3990 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3991 flush_rx, "flush_rx");
3992 cmdline_parse_token_string_t cmd_setflushrx_mode =
3993 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3997 cmdline_parse_inst_t cmd_set_flush_rx = {
3998 .f = cmd_set_flush_rx_parsed,
3999 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4002 (void *)&cmd_setflushrx_set,
4003 (void *)&cmd_setflushrx_flush_rx,
4004 (void *)&cmd_setflushrx_mode,
4009 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4010 struct cmd_set_link_check {
4011 cmdline_fixed_string_t set;
4012 cmdline_fixed_string_t link_check;
4013 cmdline_fixed_string_t mode;
4017 cmd_set_link_check_parsed(void *parsed_result,
4018 __attribute__((unused)) struct cmdline *cl,
4019 __attribute__((unused)) void *data)
4021 struct cmd_set_link_check *res = parsed_result;
4022 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4025 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4026 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4028 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4029 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4030 link_check, "link_check");
4031 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4032 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4036 cmdline_parse_inst_t cmd_set_link_check = {
4037 .f = cmd_set_link_check_parsed,
4038 .help_str = "set link_check on|off: Enable/Disable link status check "
4039 "when starting/stopping a port",
4042 (void *)&cmd_setlinkcheck_set,
4043 (void *)&cmd_setlinkcheck_link_check,
4044 (void *)&cmd_setlinkcheck_mode,
4049 /* *** SET NIC BYPASS MODE *** */
4050 struct cmd_set_bypass_mode_result {
4051 cmdline_fixed_string_t set;
4052 cmdline_fixed_string_t bypass;
4053 cmdline_fixed_string_t mode;
4054 cmdline_fixed_string_t value;
4059 cmd_set_bypass_mode_parsed(void *parsed_result,
4060 __attribute__((unused)) struct cmdline *cl,
4061 __attribute__((unused)) void *data)
4063 struct cmd_set_bypass_mode_result *res = parsed_result;
4064 portid_t port_id = res->port_id;
4065 int32_t rc = -EINVAL;
4067 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4068 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4070 if (!strcmp(res->value, "bypass"))
4071 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4072 else if (!strcmp(res->value, "isolate"))
4073 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4075 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4077 /* Set the bypass mode for the relevant port. */
4078 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4081 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4084 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4085 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4087 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4088 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4090 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4091 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4093 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4094 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4095 value, "normal#bypass#isolate");
4096 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4097 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4100 cmdline_parse_inst_t cmd_set_bypass_mode = {
4101 .f = cmd_set_bypass_mode_parsed,
4102 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4103 "Set the NIC bypass mode for port_id",
4106 (void *)&cmd_setbypass_mode_set,
4107 (void *)&cmd_setbypass_mode_bypass,
4108 (void *)&cmd_setbypass_mode_mode,
4109 (void *)&cmd_setbypass_mode_value,
4110 (void *)&cmd_setbypass_mode_port,
4115 /* *** SET NIC BYPASS EVENT *** */
4116 struct cmd_set_bypass_event_result {
4117 cmdline_fixed_string_t set;
4118 cmdline_fixed_string_t bypass;
4119 cmdline_fixed_string_t event;
4120 cmdline_fixed_string_t event_value;
4121 cmdline_fixed_string_t mode;
4122 cmdline_fixed_string_t mode_value;
4127 cmd_set_bypass_event_parsed(void *parsed_result,
4128 __attribute__((unused)) struct cmdline *cl,
4129 __attribute__((unused)) void *data)
4131 int32_t rc = -EINVAL;
4132 struct cmd_set_bypass_event_result *res = parsed_result;
4133 portid_t port_id = res->port_id;
4135 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4136 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4137 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4139 if (!strcmp(res->event_value, "timeout"))
4140 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4141 else if (!strcmp(res->event_value, "os_on"))
4142 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4143 else if (!strcmp(res->event_value, "os_off"))
4144 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4145 else if (!strcmp(res->event_value, "power_on"))
4146 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4147 else if (!strcmp(res->event_value, "power_off"))
4148 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4150 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4152 if (!strcmp(res->mode_value, "bypass"))
4153 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4154 else if (!strcmp(res->mode_value, "isolate"))
4155 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4157 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4159 /* Set the watchdog timeout. */
4160 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4163 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4164 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4168 printf("Failed to set timeout value %u "
4169 "for port %d, errto code: %d.\n",
4170 bypass_timeout, port_id, rc);
4174 /* Set the bypass event to transition to bypass mode. */
4175 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4180 printf("\t Failed to set bypass event for port = %d.\n",
4184 cmdline_parse_token_string_t cmd_setbypass_event_set =
4185 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4187 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4188 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4190 cmdline_parse_token_string_t cmd_setbypass_event_event =
4191 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4193 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4194 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4195 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4196 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4197 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4199 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4200 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4201 mode_value, "normal#bypass#isolate");
4202 cmdline_parse_token_num_t cmd_setbypass_event_port =
4203 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4206 cmdline_parse_inst_t cmd_set_bypass_event = {
4207 .f = cmd_set_bypass_event_parsed,
4208 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4209 "power_off mode normal|bypass|isolate <port_id>: "
4210 "Set the NIC bypass event mode for port_id",
4213 (void *)&cmd_setbypass_event_set,
4214 (void *)&cmd_setbypass_event_bypass,
4215 (void *)&cmd_setbypass_event_event,
4216 (void *)&cmd_setbypass_event_event_value,
4217 (void *)&cmd_setbypass_event_mode,
4218 (void *)&cmd_setbypass_event_mode_value,
4219 (void *)&cmd_setbypass_event_port,
4225 /* *** SET NIC BYPASS TIMEOUT *** */
4226 struct cmd_set_bypass_timeout_result {
4227 cmdline_fixed_string_t set;
4228 cmdline_fixed_string_t bypass;
4229 cmdline_fixed_string_t timeout;
4230 cmdline_fixed_string_t value;
4234 cmd_set_bypass_timeout_parsed(void *parsed_result,
4235 __attribute__((unused)) struct cmdline *cl,
4236 __attribute__((unused)) void *data)
4238 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4240 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4241 if (!strcmp(res->value, "1.5"))
4242 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4243 else if (!strcmp(res->value, "2"))
4244 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4245 else if (!strcmp(res->value, "3"))
4246 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4247 else if (!strcmp(res->value, "4"))
4248 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4249 else if (!strcmp(res->value, "8"))
4250 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4251 else if (!strcmp(res->value, "16"))
4252 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4253 else if (!strcmp(res->value, "32"))
4254 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4256 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4260 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4261 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4263 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4264 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4266 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4267 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4268 timeout, "timeout");
4269 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4270 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4271 value, "0#1.5#2#3#4#8#16#32");
4273 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4274 .f = cmd_set_bypass_timeout_parsed,
4275 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4276 "Set the NIC bypass watchdog timeout in seconds",
4279 (void *)&cmd_setbypass_timeout_set,
4280 (void *)&cmd_setbypass_timeout_bypass,
4281 (void *)&cmd_setbypass_timeout_timeout,
4282 (void *)&cmd_setbypass_timeout_value,
4287 /* *** SHOW NIC BYPASS MODE *** */
4288 struct cmd_show_bypass_config_result {
4289 cmdline_fixed_string_t show;
4290 cmdline_fixed_string_t bypass;
4291 cmdline_fixed_string_t config;
4296 cmd_show_bypass_config_parsed(void *parsed_result,
4297 __attribute__((unused)) struct cmdline *cl,
4298 __attribute__((unused)) void *data)
4300 struct cmd_show_bypass_config_result *res = parsed_result;
4301 portid_t port_id = res->port_id;
4303 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4304 uint32_t event_mode;
4305 uint32_t bypass_mode;
4306 uint32_t timeout = bypass_timeout;
4309 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4310 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4311 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4312 {"UNKNOWN", "normal", "bypass", "isolate"};
4313 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4320 int num_events = (sizeof events) / (sizeof events[0]);
4322 /* Display the bypass mode.*/
4323 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4324 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4328 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4329 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4331 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4334 /* Display the bypass timeout.*/
4335 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4336 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4338 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4340 /* Display the bypass events and associated modes. */
4341 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4343 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4344 printf("\tFailed to get bypass mode for event = %s\n",
4347 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4348 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4350 printf("\tbypass event: %-16s = %s\n", events[i],
4356 printf("\tFailed to get bypass configuration for port = %d\n",
4360 cmdline_parse_token_string_t cmd_showbypass_config_show =
4361 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4363 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4364 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4366 cmdline_parse_token_string_t cmd_showbypass_config_config =
4367 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4369 cmdline_parse_token_num_t cmd_showbypass_config_port =
4370 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4373 cmdline_parse_inst_t cmd_show_bypass_config = {
4374 .f = cmd_show_bypass_config_parsed,
4375 .help_str = "show bypass config <port_id>: "
4376 "Show the NIC bypass config for port_id",
4379 (void *)&cmd_showbypass_config_show,
4380 (void *)&cmd_showbypass_config_bypass,
4381 (void *)&cmd_showbypass_config_config,
4382 (void *)&cmd_showbypass_config_port,
4387 #ifdef RTE_LIBRTE_PMD_BOND
4388 /* *** SET BONDING MODE *** */
4389 struct cmd_set_bonding_mode_result {
4390 cmdline_fixed_string_t set;
4391 cmdline_fixed_string_t bonding;
4392 cmdline_fixed_string_t mode;
4397 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4398 __attribute__((unused)) struct cmdline *cl,
4399 __attribute__((unused)) void *data)
4401 struct cmd_set_bonding_mode_result *res = parsed_result;
4402 portid_t port_id = res->port_id;
4404 /* Set the bonding mode for the relevant port. */
4405 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4406 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4409 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4410 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4412 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4413 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4414 bonding, "bonding");
4415 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4416 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4418 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4419 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4421 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4422 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4425 cmdline_parse_inst_t cmd_set_bonding_mode = {
4426 .f = cmd_set_bonding_mode_parsed,
4427 .help_str = "set bonding mode <mode_value> <port_id>: "
4428 "Set the bonding mode for port_id",
4431 (void *) &cmd_setbonding_mode_set,
4432 (void *) &cmd_setbonding_mode_bonding,
4433 (void *) &cmd_setbonding_mode_mode,
4434 (void *) &cmd_setbonding_mode_value,
4435 (void *) &cmd_setbonding_mode_port,
4440 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4441 struct cmd_set_bonding_lacp_dedicated_queues_result {
4442 cmdline_fixed_string_t set;
4443 cmdline_fixed_string_t bonding;
4444 cmdline_fixed_string_t lacp;
4445 cmdline_fixed_string_t dedicated_queues;
4447 cmdline_fixed_string_t mode;
4450 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4451 __attribute__((unused)) struct cmdline *cl,
4452 __attribute__((unused)) void *data)
4454 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4455 portid_t port_id = res->port_id;
4456 struct rte_port *port;
4458 port = &ports[port_id];
4460 /** Check if the port is not started **/
4461 if (port->port_status != RTE_PORT_STOPPED) {
4462 printf("Please stop port %d first\n", port_id);
4466 if (!strcmp(res->mode, "enable")) {
4467 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4468 printf("Dedicate queues for LACP control packets"
4471 printf("Enabling dedicate queues for LACP control "
4472 "packets on port %d failed\n", port_id);
4473 } else if (!strcmp(res->mode, "disable")) {
4474 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4475 printf("Dedicated queues for LACP control packets "
4478 printf("Disabling dedicated queues for LACP control "
4479 "traffic on port %d failed\n", port_id);
4483 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4484 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4486 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4487 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4488 bonding, "bonding");
4489 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4490 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4492 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4493 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4494 dedicated_queues, "dedicated_queues");
4495 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4496 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4498 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4499 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4500 mode, "enable#disable");
4502 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4503 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4504 .help_str = "set bonding lacp dedicated_queues <port_id> "
4506 "Enable/disable dedicated queues for LACP control traffic for port_id",
4509 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4510 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4511 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4512 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4513 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4514 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4519 /* *** SET BALANCE XMIT POLICY *** */
4520 struct cmd_set_bonding_balance_xmit_policy_result {
4521 cmdline_fixed_string_t set;
4522 cmdline_fixed_string_t bonding;
4523 cmdline_fixed_string_t balance_xmit_policy;
4525 cmdline_fixed_string_t policy;
4528 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4529 __attribute__((unused)) struct cmdline *cl,
4530 __attribute__((unused)) void *data)
4532 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4533 portid_t port_id = res->port_id;
4536 if (!strcmp(res->policy, "l2")) {
4537 policy = BALANCE_XMIT_POLICY_LAYER2;
4538 } else if (!strcmp(res->policy, "l23")) {
4539 policy = BALANCE_XMIT_POLICY_LAYER23;
4540 } else if (!strcmp(res->policy, "l34")) {
4541 policy = BALANCE_XMIT_POLICY_LAYER34;
4543 printf("\t Invalid xmit policy selection");
4547 /* Set the bonding mode for the relevant port. */
4548 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4549 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4554 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4555 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4557 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4558 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4559 bonding, "bonding");
4560 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4561 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4562 balance_xmit_policy, "balance_xmit_policy");
4563 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4564 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4566 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4567 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4568 policy, "l2#l23#l34");
4570 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4571 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4572 .help_str = "set bonding balance_xmit_policy <port_id> "
4574 "Set the bonding balance_xmit_policy for port_id",
4577 (void *)&cmd_setbonding_balance_xmit_policy_set,
4578 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4579 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4580 (void *)&cmd_setbonding_balance_xmit_policy_port,
4581 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4586 /* *** SHOW NIC BONDING CONFIGURATION *** */
4587 struct cmd_show_bonding_config_result {
4588 cmdline_fixed_string_t show;
4589 cmdline_fixed_string_t bonding;
4590 cmdline_fixed_string_t config;
4594 static void cmd_show_bonding_config_parsed(void *parsed_result,
4595 __attribute__((unused)) struct cmdline *cl,
4596 __attribute__((unused)) void *data)
4598 struct cmd_show_bonding_config_result *res = parsed_result;
4599 int bonding_mode, agg_mode;
4600 uint8_t slaves[RTE_MAX_ETHPORTS];
4601 int num_slaves, num_active_slaves;
4604 portid_t port_id = res->port_id;
4606 /* Display the bonding mode.*/
4607 bonding_mode = rte_eth_bond_mode_get(port_id);
4608 if (bonding_mode < 0) {
4609 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4612 printf("\tBonding mode: %d\n", bonding_mode);
4614 if (bonding_mode == BONDING_MODE_BALANCE) {
4615 int balance_xmit_policy;
4617 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4618 if (balance_xmit_policy < 0) {
4619 printf("\tFailed to get balance xmit policy for port = %d\n",
4623 printf("\tBalance Xmit Policy: ");
4625 switch (balance_xmit_policy) {
4626 case BALANCE_XMIT_POLICY_LAYER2:
4627 printf("BALANCE_XMIT_POLICY_LAYER2");
4629 case BALANCE_XMIT_POLICY_LAYER23:
4630 printf("BALANCE_XMIT_POLICY_LAYER23");
4632 case BALANCE_XMIT_POLICY_LAYER34:
4633 printf("BALANCE_XMIT_POLICY_LAYER34");
4640 if (bonding_mode == BONDING_MODE_8023AD) {
4641 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
4642 printf("\tIEEE802.3AD Aggregator Mode: ");
4645 printf("bandwidth");
4657 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4659 if (num_slaves < 0) {
4660 printf("\tFailed to get slave list for port = %d\n", port_id);
4663 if (num_slaves > 0) {
4664 printf("\tSlaves (%d): [", num_slaves);
4665 for (i = 0; i < num_slaves - 1; i++)
4666 printf("%d ", slaves[i]);
4668 printf("%d]\n", slaves[num_slaves - 1]);
4670 printf("\tSlaves: []\n");
4674 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4677 if (num_active_slaves < 0) {
4678 printf("\tFailed to get active slave list for port = %d\n", port_id);
4681 if (num_active_slaves > 0) {
4682 printf("\tActive Slaves (%d): [", num_active_slaves);
4683 for (i = 0; i < num_active_slaves - 1; i++)
4684 printf("%d ", slaves[i]);
4686 printf("%d]\n", slaves[num_active_slaves - 1]);
4689 printf("\tActive Slaves: []\n");
4693 primary_id = rte_eth_bond_primary_get(port_id);
4694 if (primary_id < 0) {
4695 printf("\tFailed to get primary slave for port = %d\n", port_id);
4698 printf("\tPrimary: [%d]\n", primary_id);
4702 cmdline_parse_token_string_t cmd_showbonding_config_show =
4703 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4705 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4706 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4707 bonding, "bonding");
4708 cmdline_parse_token_string_t cmd_showbonding_config_config =
4709 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4711 cmdline_parse_token_num_t cmd_showbonding_config_port =
4712 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4715 cmdline_parse_inst_t cmd_show_bonding_config = {
4716 .f = cmd_show_bonding_config_parsed,
4717 .help_str = "show bonding config <port_id>: "
4718 "Show the bonding config for port_id",
4721 (void *)&cmd_showbonding_config_show,
4722 (void *)&cmd_showbonding_config_bonding,
4723 (void *)&cmd_showbonding_config_config,
4724 (void *)&cmd_showbonding_config_port,
4729 /* *** SET BONDING PRIMARY *** */
4730 struct cmd_set_bonding_primary_result {
4731 cmdline_fixed_string_t set;
4732 cmdline_fixed_string_t bonding;
4733 cmdline_fixed_string_t primary;
4738 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4739 __attribute__((unused)) struct cmdline *cl,
4740 __attribute__((unused)) void *data)
4742 struct cmd_set_bonding_primary_result *res = parsed_result;
4743 portid_t master_port_id = res->port_id;
4744 portid_t slave_port_id = res->slave_id;
4746 /* Set the primary slave for a bonded device. */
4747 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4748 printf("\t Failed to set primary slave for port = %d.\n",
4755 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4756 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4758 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4759 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4760 bonding, "bonding");
4761 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4762 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4763 primary, "primary");
4764 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4765 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4767 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4768 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4771 cmdline_parse_inst_t cmd_set_bonding_primary = {
4772 .f = cmd_set_bonding_primary_parsed,
4773 .help_str = "set bonding primary <slave_id> <port_id>: "
4774 "Set the primary slave for port_id",
4777 (void *)&cmd_setbonding_primary_set,
4778 (void *)&cmd_setbonding_primary_bonding,
4779 (void *)&cmd_setbonding_primary_primary,
4780 (void *)&cmd_setbonding_primary_slave,
4781 (void *)&cmd_setbonding_primary_port,
4786 /* *** ADD SLAVE *** */
4787 struct cmd_add_bonding_slave_result {
4788 cmdline_fixed_string_t add;
4789 cmdline_fixed_string_t bonding;
4790 cmdline_fixed_string_t slave;
4795 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4796 __attribute__((unused)) struct cmdline *cl,
4797 __attribute__((unused)) void *data)
4799 struct cmd_add_bonding_slave_result *res = parsed_result;
4800 portid_t master_port_id = res->port_id;
4801 portid_t slave_port_id = res->slave_id;
4803 /* add the slave for a bonded device. */
4804 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4805 printf("\t Failed to add slave %d to master port = %d.\n",
4806 slave_port_id, master_port_id);
4810 set_port_slave_flag(slave_port_id);
4813 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4814 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4816 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4817 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4818 bonding, "bonding");
4819 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4820 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4822 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4823 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4825 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4826 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4829 cmdline_parse_inst_t cmd_add_bonding_slave = {
4830 .f = cmd_add_bonding_slave_parsed,
4831 .help_str = "add bonding slave <slave_id> <port_id>: "
4832 "Add a slave device to a bonded device",
4835 (void *)&cmd_addbonding_slave_add,
4836 (void *)&cmd_addbonding_slave_bonding,
4837 (void *)&cmd_addbonding_slave_slave,
4838 (void *)&cmd_addbonding_slave_slaveid,
4839 (void *)&cmd_addbonding_slave_port,
4844 /* *** REMOVE SLAVE *** */
4845 struct cmd_remove_bonding_slave_result {
4846 cmdline_fixed_string_t remove;
4847 cmdline_fixed_string_t bonding;
4848 cmdline_fixed_string_t slave;
4853 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4854 __attribute__((unused)) struct cmdline *cl,
4855 __attribute__((unused)) void *data)
4857 struct cmd_remove_bonding_slave_result *res = parsed_result;
4858 portid_t master_port_id = res->port_id;
4859 portid_t slave_port_id = res->slave_id;
4861 /* remove the slave from a bonded device. */
4862 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4863 printf("\t Failed to remove slave %d from master port = %d.\n",
4864 slave_port_id, master_port_id);
4868 clear_port_slave_flag(slave_port_id);
4871 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4872 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4874 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4875 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4876 bonding, "bonding");
4877 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4878 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4880 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4881 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4883 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4884 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4887 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4888 .f = cmd_remove_bonding_slave_parsed,
4889 .help_str = "remove bonding slave <slave_id> <port_id>: "
4890 "Remove a slave device from a bonded device",
4893 (void *)&cmd_removebonding_slave_remove,
4894 (void *)&cmd_removebonding_slave_bonding,
4895 (void *)&cmd_removebonding_slave_slave,
4896 (void *)&cmd_removebonding_slave_slaveid,
4897 (void *)&cmd_removebonding_slave_port,
4902 /* *** CREATE BONDED DEVICE *** */
4903 struct cmd_create_bonded_device_result {
4904 cmdline_fixed_string_t create;
4905 cmdline_fixed_string_t bonded;
4906 cmdline_fixed_string_t device;
4911 static int bond_dev_num = 0;
4913 static void cmd_create_bonded_device_parsed(void *parsed_result,
4914 __attribute__((unused)) struct cmdline *cl,
4915 __attribute__((unused)) void *data)
4917 struct cmd_create_bonded_device_result *res = parsed_result;
4918 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4921 if (test_done == 0) {
4922 printf("Please stop forwarding first\n");
4926 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
4929 /* Create a new bonded device. */
4930 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4932 printf("\t Failed to create bonded device.\n");
4935 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4938 /* Update number of ports */
4939 nb_ports = rte_eth_dev_count();
4940 reconfig(port_id, res->socket);
4941 rte_eth_promiscuous_enable(port_id);
4946 cmdline_parse_token_string_t cmd_createbonded_device_create =
4947 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4949 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4950 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4952 cmdline_parse_token_string_t cmd_createbonded_device_device =
4953 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4955 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4956 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4958 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4959 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4962 cmdline_parse_inst_t cmd_create_bonded_device = {
4963 .f = cmd_create_bonded_device_parsed,
4964 .help_str = "create bonded device <mode> <socket>: "
4965 "Create a new bonded device with specific bonding mode and socket",
4968 (void *)&cmd_createbonded_device_create,
4969 (void *)&cmd_createbonded_device_bonded,
4970 (void *)&cmd_createbonded_device_device,
4971 (void *)&cmd_createbonded_device_mode,
4972 (void *)&cmd_createbonded_device_socket,
4977 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4978 struct cmd_set_bond_mac_addr_result {
4979 cmdline_fixed_string_t set;
4980 cmdline_fixed_string_t bonding;
4981 cmdline_fixed_string_t mac_addr;
4983 struct ether_addr address;
4986 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4987 __attribute__((unused)) struct cmdline *cl,
4988 __attribute__((unused)) void *data)
4990 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4993 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4996 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4998 /* check the return value and print it if is < 0 */
5000 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5003 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5004 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5005 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5006 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5008 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5009 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5011 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5012 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
5013 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5014 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5016 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5017 .f = cmd_set_bond_mac_addr_parsed,
5019 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5021 (void *)&cmd_set_bond_mac_addr_set,
5022 (void *)&cmd_set_bond_mac_addr_bonding,
5023 (void *)&cmd_set_bond_mac_addr_mac,
5024 (void *)&cmd_set_bond_mac_addr_portnum,
5025 (void *)&cmd_set_bond_mac_addr_addr,
5031 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5032 struct cmd_set_bond_mon_period_result {
5033 cmdline_fixed_string_t set;
5034 cmdline_fixed_string_t bonding;
5035 cmdline_fixed_string_t mon_period;
5040 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5041 __attribute__((unused)) struct cmdline *cl,
5042 __attribute__((unused)) void *data)
5044 struct cmd_set_bond_mon_period_result *res = parsed_result;
5047 if (res->port_num >= nb_ports) {
5048 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5052 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5054 /* check the return value and print it if is < 0 */
5056 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5059 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5060 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5062 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5063 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5064 bonding, "bonding");
5065 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5066 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5067 mon_period, "mon_period");
5068 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5069 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5071 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5072 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5075 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5076 .f = cmd_set_bond_mon_period_parsed,
5078 .help_str = "set bonding mon_period <port_id> <period_ms>",
5080 (void *)&cmd_set_bond_mon_period_set,
5081 (void *)&cmd_set_bond_mon_period_bonding,
5082 (void *)&cmd_set_bond_mon_period_mon_period,
5083 (void *)&cmd_set_bond_mon_period_portnum,
5084 (void *)&cmd_set_bond_mon_period_period_ms,
5091 struct cmd_set_bonding_agg_mode_policy_result {
5092 cmdline_fixed_string_t set;
5093 cmdline_fixed_string_t bonding;
5094 cmdline_fixed_string_t agg_mode;
5096 cmdline_fixed_string_t policy;
5101 cmd_set_bonding_agg_mode(void *parsed_result,
5102 __attribute__((unused)) struct cmdline *cl,
5103 __attribute__((unused)) void *data)
5105 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5106 uint8_t policy = AGG_BANDWIDTH;
5108 if (res->port_num >= nb_ports) {
5109 printf("Port id %d must be less than %d\n",
5110 res->port_num, nb_ports);
5114 if (!strcmp(res->policy, "bandwidth"))
5115 policy = AGG_BANDWIDTH;
5116 else if (!strcmp(res->policy, "stable"))
5117 policy = AGG_STABLE;
5118 else if (!strcmp(res->policy, "count"))
5121 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5125 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5126 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5128 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5129 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5130 bonding, "bonding");
5132 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5133 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5134 agg_mode, "agg_mode");
5136 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5137 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5140 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5141 TOKEN_STRING_INITIALIZER(
5142 struct cmd_set_bonding_balance_xmit_policy_result,
5143 policy, "stable#bandwidth#count");
5145 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5146 .f = cmd_set_bonding_agg_mode,
5148 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5150 (void *)&cmd_set_bonding_agg_mode_set,
5151 (void *)&cmd_set_bonding_agg_mode_bonding,
5152 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5153 (void *)&cmd_set_bonding_agg_mode_portnum,
5154 (void *)&cmd_set_bonding_agg_mode_policy_string,
5160 #endif /* RTE_LIBRTE_PMD_BOND */
5162 /* *** SET FORWARDING MODE *** */
5163 struct cmd_set_fwd_mode_result {
5164 cmdline_fixed_string_t set;
5165 cmdline_fixed_string_t fwd;
5166 cmdline_fixed_string_t mode;
5169 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5170 __attribute__((unused)) struct cmdline *cl,
5171 __attribute__((unused)) void *data)
5173 struct cmd_set_fwd_mode_result *res = parsed_result;
5176 set_pkt_forwarding_mode(res->mode);
5179 cmdline_parse_token_string_t cmd_setfwd_set =
5180 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5181 cmdline_parse_token_string_t cmd_setfwd_fwd =
5182 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5183 cmdline_parse_token_string_t cmd_setfwd_mode =
5184 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5185 "" /* defined at init */);
5187 cmdline_parse_inst_t cmd_set_fwd_mode = {
5188 .f = cmd_set_fwd_mode_parsed,
5190 .help_str = NULL, /* defined at init */
5192 (void *)&cmd_setfwd_set,
5193 (void *)&cmd_setfwd_fwd,
5194 (void *)&cmd_setfwd_mode,
5199 static void cmd_set_fwd_mode_init(void)
5202 static char token[128];
5203 static char help[256];
5204 cmdline_parse_token_string_t *token_struct;
5206 modes = list_pkt_forwarding_modes();
5207 snprintf(help, sizeof(help), "set fwd %s: "
5208 "Set packet forwarding mode", modes);
5209 cmd_set_fwd_mode.help_str = help;
5211 /* string token separator is # */
5212 for (c = token; *modes != '\0'; modes++)
5217 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5218 token_struct->string_data.str = token;
5221 /* *** SET RETRY FORWARDING MODE *** */
5222 struct cmd_set_fwd_retry_mode_result {
5223 cmdline_fixed_string_t set;
5224 cmdline_fixed_string_t fwd;
5225 cmdline_fixed_string_t mode;
5226 cmdline_fixed_string_t retry;
5229 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5230 __attribute__((unused)) struct cmdline *cl,
5231 __attribute__((unused)) void *data)
5233 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5236 set_pkt_forwarding_mode(res->mode);
5239 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5240 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5242 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5243 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5245 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5246 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5248 "" /* defined at init */);
5249 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5250 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5253 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5254 .f = cmd_set_fwd_retry_mode_parsed,
5256 .help_str = NULL, /* defined at init */
5258 (void *)&cmd_setfwd_retry_set,
5259 (void *)&cmd_setfwd_retry_fwd,
5260 (void *)&cmd_setfwd_retry_mode,
5261 (void *)&cmd_setfwd_retry_retry,
5266 static void cmd_set_fwd_retry_mode_init(void)
5269 static char token[128];
5270 static char help[256];
5271 cmdline_parse_token_string_t *token_struct;
5273 modes = list_pkt_forwarding_retry_modes();
5274 snprintf(help, sizeof(help), "set fwd %s retry: "
5275 "Set packet forwarding mode with retry", modes);
5276 cmd_set_fwd_retry_mode.help_str = help;
5278 /* string token separator is # */
5279 for (c = token; *modes != '\0'; modes++)
5284 token_struct = (cmdline_parse_token_string_t *)
5285 cmd_set_fwd_retry_mode.tokens[2];
5286 token_struct->string_data.str = token;
5289 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5290 struct cmd_set_burst_tx_retry_result {
5291 cmdline_fixed_string_t set;
5292 cmdline_fixed_string_t burst;
5293 cmdline_fixed_string_t tx;
5294 cmdline_fixed_string_t delay;
5296 cmdline_fixed_string_t retry;
5300 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5301 __attribute__((unused)) struct cmdline *cl,
5302 __attribute__((unused)) void *data)
5304 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5306 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5307 && !strcmp(res->tx, "tx")) {
5308 if (!strcmp(res->delay, "delay"))
5309 burst_tx_delay_time = res->time;
5310 if (!strcmp(res->retry, "retry"))
5311 burst_tx_retry_num = res->retry_num;
5316 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5317 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5318 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5319 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5321 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5322 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5323 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5324 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5325 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5326 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5327 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5328 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5329 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5330 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5332 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5333 .f = cmd_set_burst_tx_retry_parsed,
5334 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5336 (void *)&cmd_set_burst_tx_retry_set,
5337 (void *)&cmd_set_burst_tx_retry_burst,
5338 (void *)&cmd_set_burst_tx_retry_tx,
5339 (void *)&cmd_set_burst_tx_retry_delay,
5340 (void *)&cmd_set_burst_tx_retry_time,
5341 (void *)&cmd_set_burst_tx_retry_retry,
5342 (void *)&cmd_set_burst_tx_retry_retry_num,
5347 /* *** SET PROMISC MODE *** */
5348 struct cmd_set_promisc_mode_result {
5349 cmdline_fixed_string_t set;
5350 cmdline_fixed_string_t promisc;
5351 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5352 uint8_t port_num; /* valid if "allports" argument == 0 */
5353 cmdline_fixed_string_t mode;
5356 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5357 __attribute__((unused)) struct cmdline *cl,
5360 struct cmd_set_promisc_mode_result *res = parsed_result;
5364 if (!strcmp(res->mode, "on"))
5371 RTE_ETH_FOREACH_DEV(i) {
5373 rte_eth_promiscuous_enable(i);
5375 rte_eth_promiscuous_disable(i);
5380 rte_eth_promiscuous_enable(res->port_num);
5382 rte_eth_promiscuous_disable(res->port_num);
5386 cmdline_parse_token_string_t cmd_setpromisc_set =
5387 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5388 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5389 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5391 cmdline_parse_token_string_t cmd_setpromisc_portall =
5392 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5394 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5395 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5397 cmdline_parse_token_string_t cmd_setpromisc_mode =
5398 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5401 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5402 .f = cmd_set_promisc_mode_parsed,
5404 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5406 (void *)&cmd_setpromisc_set,
5407 (void *)&cmd_setpromisc_promisc,
5408 (void *)&cmd_setpromisc_portall,
5409 (void *)&cmd_setpromisc_mode,
5414 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5415 .f = cmd_set_promisc_mode_parsed,
5417 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5419 (void *)&cmd_setpromisc_set,
5420 (void *)&cmd_setpromisc_promisc,
5421 (void *)&cmd_setpromisc_portnum,
5422 (void *)&cmd_setpromisc_mode,
5427 /* *** SET ALLMULTI MODE *** */
5428 struct cmd_set_allmulti_mode_result {
5429 cmdline_fixed_string_t set;
5430 cmdline_fixed_string_t allmulti;
5431 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5432 uint8_t port_num; /* valid if "allports" argument == 0 */
5433 cmdline_fixed_string_t mode;
5436 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5437 __attribute__((unused)) struct cmdline *cl,
5440 struct cmd_set_allmulti_mode_result *res = parsed_result;
5444 if (!strcmp(res->mode, "on"))
5451 RTE_ETH_FOREACH_DEV(i) {
5453 rte_eth_allmulticast_enable(i);
5455 rte_eth_allmulticast_disable(i);
5460 rte_eth_allmulticast_enable(res->port_num);
5462 rte_eth_allmulticast_disable(res->port_num);
5466 cmdline_parse_token_string_t cmd_setallmulti_set =
5467 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5468 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5469 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5471 cmdline_parse_token_string_t cmd_setallmulti_portall =
5472 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5474 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5475 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5477 cmdline_parse_token_string_t cmd_setallmulti_mode =
5478 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5481 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5482 .f = cmd_set_allmulti_mode_parsed,
5484 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5486 (void *)&cmd_setallmulti_set,
5487 (void *)&cmd_setallmulti_allmulti,
5488 (void *)&cmd_setallmulti_portall,
5489 (void *)&cmd_setallmulti_mode,
5494 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5495 .f = cmd_set_allmulti_mode_parsed,
5497 .help_str = "set allmulti <port_id> on|off: "
5498 "Set allmulti mode on port_id",
5500 (void *)&cmd_setallmulti_set,
5501 (void *)&cmd_setallmulti_allmulti,
5502 (void *)&cmd_setallmulti_portnum,
5503 (void *)&cmd_setallmulti_mode,
5508 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5509 struct cmd_link_flow_ctrl_set_result {
5510 cmdline_fixed_string_t set;
5511 cmdline_fixed_string_t flow_ctrl;
5512 cmdline_fixed_string_t rx;
5513 cmdline_fixed_string_t rx_lfc_mode;
5514 cmdline_fixed_string_t tx;
5515 cmdline_fixed_string_t tx_lfc_mode;
5516 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5517 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5518 cmdline_fixed_string_t autoneg_str;
5519 cmdline_fixed_string_t autoneg;
5520 cmdline_fixed_string_t hw_str;
5521 uint32_t high_water;
5522 cmdline_fixed_string_t lw_str;
5524 cmdline_fixed_string_t pt_str;
5525 uint16_t pause_time;
5526 cmdline_fixed_string_t xon_str;
5531 cmdline_parse_token_string_t cmd_lfc_set_set =
5532 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5534 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5535 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5536 flow_ctrl, "flow_ctrl");
5537 cmdline_parse_token_string_t cmd_lfc_set_rx =
5538 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5540 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5541 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5542 rx_lfc_mode, "on#off");
5543 cmdline_parse_token_string_t cmd_lfc_set_tx =
5544 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5546 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5547 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5548 tx_lfc_mode, "on#off");
5549 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5550 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5551 hw_str, "high_water");
5552 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5553 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5554 high_water, UINT32);
5555 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5556 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5557 lw_str, "low_water");
5558 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5559 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5561 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5562 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5563 pt_str, "pause_time");
5564 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5565 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5566 pause_time, UINT16);
5567 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5568 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5569 xon_str, "send_xon");
5570 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5571 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5573 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5574 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5575 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5576 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5577 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5578 mac_ctrl_frame_fwd_mode, "on#off");
5579 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5580 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5581 autoneg_str, "autoneg");
5582 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5583 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5585 cmdline_parse_token_num_t cmd_lfc_set_portid =
5586 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5589 /* forward declaration */
5591 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5594 cmdline_parse_inst_t cmd_link_flow_control_set = {
5595 .f = cmd_link_flow_ctrl_set_parsed,
5597 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5598 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5599 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5601 (void *)&cmd_lfc_set_set,
5602 (void *)&cmd_lfc_set_flow_ctrl,
5603 (void *)&cmd_lfc_set_rx,
5604 (void *)&cmd_lfc_set_rx_mode,
5605 (void *)&cmd_lfc_set_tx,
5606 (void *)&cmd_lfc_set_tx_mode,
5607 (void *)&cmd_lfc_set_high_water,
5608 (void *)&cmd_lfc_set_low_water,
5609 (void *)&cmd_lfc_set_pause_time,
5610 (void *)&cmd_lfc_set_send_xon,
5611 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5612 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5613 (void *)&cmd_lfc_set_autoneg_str,
5614 (void *)&cmd_lfc_set_autoneg,
5615 (void *)&cmd_lfc_set_portid,
5620 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5621 .f = cmd_link_flow_ctrl_set_parsed,
5622 .data = (void *)&cmd_link_flow_control_set_rx,
5623 .help_str = "set flow_ctrl rx on|off <port_id>: "
5624 "Change rx flow control parameter",
5626 (void *)&cmd_lfc_set_set,
5627 (void *)&cmd_lfc_set_flow_ctrl,
5628 (void *)&cmd_lfc_set_rx,
5629 (void *)&cmd_lfc_set_rx_mode,
5630 (void *)&cmd_lfc_set_portid,
5635 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5636 .f = cmd_link_flow_ctrl_set_parsed,
5637 .data = (void *)&cmd_link_flow_control_set_tx,
5638 .help_str = "set flow_ctrl tx on|off <port_id>: "
5639 "Change tx flow control parameter",
5641 (void *)&cmd_lfc_set_set,
5642 (void *)&cmd_lfc_set_flow_ctrl,
5643 (void *)&cmd_lfc_set_tx,
5644 (void *)&cmd_lfc_set_tx_mode,
5645 (void *)&cmd_lfc_set_portid,
5650 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5651 .f = cmd_link_flow_ctrl_set_parsed,
5652 .data = (void *)&cmd_link_flow_control_set_hw,
5653 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5654 "Change high water flow control parameter",
5656 (void *)&cmd_lfc_set_set,
5657 (void *)&cmd_lfc_set_flow_ctrl,
5658 (void *)&cmd_lfc_set_high_water_str,
5659 (void *)&cmd_lfc_set_high_water,
5660 (void *)&cmd_lfc_set_portid,
5665 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5666 .f = cmd_link_flow_ctrl_set_parsed,
5667 .data = (void *)&cmd_link_flow_control_set_lw,
5668 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5669 "Change low water flow control parameter",
5671 (void *)&cmd_lfc_set_set,
5672 (void *)&cmd_lfc_set_flow_ctrl,
5673 (void *)&cmd_lfc_set_low_water_str,
5674 (void *)&cmd_lfc_set_low_water,
5675 (void *)&cmd_lfc_set_portid,
5680 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5681 .f = cmd_link_flow_ctrl_set_parsed,
5682 .data = (void *)&cmd_link_flow_control_set_pt,
5683 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5684 "Change pause time flow control parameter",
5686 (void *)&cmd_lfc_set_set,
5687 (void *)&cmd_lfc_set_flow_ctrl,
5688 (void *)&cmd_lfc_set_pause_time_str,
5689 (void *)&cmd_lfc_set_pause_time,
5690 (void *)&cmd_lfc_set_portid,
5695 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5696 .f = cmd_link_flow_ctrl_set_parsed,
5697 .data = (void *)&cmd_link_flow_control_set_xon,
5698 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5699 "Change send_xon flow control parameter",
5701 (void *)&cmd_lfc_set_set,
5702 (void *)&cmd_lfc_set_flow_ctrl,
5703 (void *)&cmd_lfc_set_send_xon_str,
5704 (void *)&cmd_lfc_set_send_xon,
5705 (void *)&cmd_lfc_set_portid,
5710 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5711 .f = cmd_link_flow_ctrl_set_parsed,
5712 .data = (void *)&cmd_link_flow_control_set_macfwd,
5713 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5714 "Change mac ctrl fwd flow control parameter",
5716 (void *)&cmd_lfc_set_set,
5717 (void *)&cmd_lfc_set_flow_ctrl,
5718 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5719 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5720 (void *)&cmd_lfc_set_portid,
5725 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5726 .f = cmd_link_flow_ctrl_set_parsed,
5727 .data = (void *)&cmd_link_flow_control_set_autoneg,
5728 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5729 "Change autoneg flow control parameter",
5731 (void *)&cmd_lfc_set_set,
5732 (void *)&cmd_lfc_set_flow_ctrl,
5733 (void *)&cmd_lfc_set_autoneg_str,
5734 (void *)&cmd_lfc_set_autoneg,
5735 (void *)&cmd_lfc_set_portid,
5741 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5742 __attribute__((unused)) struct cmdline *cl,
5745 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5746 cmdline_parse_inst_t *cmd = data;
5747 struct rte_eth_fc_conf fc_conf;
5753 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5754 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5755 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5756 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5758 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5759 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5762 /* Partial command line, retrieve current configuration */
5764 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5766 printf("cannot get current flow ctrl parameters, return"
5767 "code = %d\n", ret);
5771 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5772 (fc_conf.mode == RTE_FC_FULL))
5774 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5775 (fc_conf.mode == RTE_FC_FULL))
5779 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5780 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5782 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5783 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5785 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5787 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5788 fc_conf.high_water = res->high_water;
5790 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5791 fc_conf.low_water = res->low_water;
5793 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5794 fc_conf.pause_time = res->pause_time;
5796 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5797 fc_conf.send_xon = res->send_xon;
5799 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5800 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5801 fc_conf.mac_ctrl_frame_fwd = 1;
5803 fc_conf.mac_ctrl_frame_fwd = 0;
5806 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5807 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5809 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5811 printf("bad flow contrl parameter, return code = %d \n", ret);
5814 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5815 struct cmd_priority_flow_ctrl_set_result {
5816 cmdline_fixed_string_t set;
5817 cmdline_fixed_string_t pfc_ctrl;
5818 cmdline_fixed_string_t rx;
5819 cmdline_fixed_string_t rx_pfc_mode;
5820 cmdline_fixed_string_t tx;
5821 cmdline_fixed_string_t tx_pfc_mode;
5822 uint32_t high_water;
5824 uint16_t pause_time;
5830 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5831 __attribute__((unused)) struct cmdline *cl,
5832 __attribute__((unused)) void *data)
5834 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5835 struct rte_eth_pfc_conf pfc_conf;
5836 int rx_fc_enable, tx_fc_enable;
5840 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5841 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5842 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5843 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5845 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5846 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5849 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5850 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5851 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5852 pfc_conf.fc.high_water = res->high_water;
5853 pfc_conf.fc.low_water = res->low_water;
5854 pfc_conf.fc.pause_time = res->pause_time;
5855 pfc_conf.priority = res->priority;
5857 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5859 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5862 cmdline_parse_token_string_t cmd_pfc_set_set =
5863 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5865 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5866 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5867 pfc_ctrl, "pfc_ctrl");
5868 cmdline_parse_token_string_t cmd_pfc_set_rx =
5869 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5871 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5872 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5873 rx_pfc_mode, "on#off");
5874 cmdline_parse_token_string_t cmd_pfc_set_tx =
5875 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5877 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5878 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5879 tx_pfc_mode, "on#off");
5880 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5881 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5882 high_water, UINT32);
5883 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5884 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5886 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5887 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5888 pause_time, UINT16);
5889 cmdline_parse_token_num_t cmd_pfc_set_priority =
5890 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5892 cmdline_parse_token_num_t cmd_pfc_set_portid =
5893 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5896 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5897 .f = cmd_priority_flow_ctrl_set_parsed,
5899 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5900 "<pause_time> <priority> <port_id>: "
5901 "Configure the Ethernet priority flow control",
5903 (void *)&cmd_pfc_set_set,
5904 (void *)&cmd_pfc_set_flow_ctrl,
5905 (void *)&cmd_pfc_set_rx,
5906 (void *)&cmd_pfc_set_rx_mode,
5907 (void *)&cmd_pfc_set_tx,
5908 (void *)&cmd_pfc_set_tx_mode,
5909 (void *)&cmd_pfc_set_high_water,
5910 (void *)&cmd_pfc_set_low_water,
5911 (void *)&cmd_pfc_set_pause_time,
5912 (void *)&cmd_pfc_set_priority,
5913 (void *)&cmd_pfc_set_portid,
5918 /* *** RESET CONFIGURATION *** */
5919 struct cmd_reset_result {
5920 cmdline_fixed_string_t reset;
5921 cmdline_fixed_string_t def;
5924 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5926 __attribute__((unused)) void *data)
5928 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5929 set_def_fwd_config();
5932 cmdline_parse_token_string_t cmd_reset_set =
5933 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5934 cmdline_parse_token_string_t cmd_reset_def =
5935 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5938 cmdline_parse_inst_t cmd_reset = {
5939 .f = cmd_reset_parsed,
5941 .help_str = "set default: Reset default forwarding configuration",
5943 (void *)&cmd_reset_set,
5944 (void *)&cmd_reset_def,
5949 /* *** START FORWARDING *** */
5950 struct cmd_start_result {
5951 cmdline_fixed_string_t start;
5954 cmdline_parse_token_string_t cmd_start_start =
5955 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5957 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5958 __attribute__((unused)) struct cmdline *cl,
5959 __attribute__((unused)) void *data)
5961 start_packet_forwarding(0);
5964 cmdline_parse_inst_t cmd_start = {
5965 .f = cmd_start_parsed,
5967 .help_str = "start: Start packet forwarding",
5969 (void *)&cmd_start_start,
5974 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5975 struct cmd_start_tx_first_result {
5976 cmdline_fixed_string_t start;
5977 cmdline_fixed_string_t tx_first;
5981 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5982 __attribute__((unused)) struct cmdline *cl,
5983 __attribute__((unused)) void *data)
5985 start_packet_forwarding(1);
5988 cmdline_parse_token_string_t cmd_start_tx_first_start =
5989 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5991 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5992 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5993 tx_first, "tx_first");
5995 cmdline_parse_inst_t cmd_start_tx_first = {
5996 .f = cmd_start_tx_first_parsed,
5998 .help_str = "start tx_first: Start packet forwarding, "
5999 "after sending 1 burst of packets",
6001 (void *)&cmd_start_tx_first_start,
6002 (void *)&cmd_start_tx_first_tx_first,
6007 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6008 struct cmd_start_tx_first_n_result {
6009 cmdline_fixed_string_t start;
6010 cmdline_fixed_string_t tx_first;
6015 cmd_start_tx_first_n_parsed(void *parsed_result,
6016 __attribute__((unused)) struct cmdline *cl,
6017 __attribute__((unused)) void *data)
6019 struct cmd_start_tx_first_n_result *res = parsed_result;
6021 start_packet_forwarding(res->tx_num);
6024 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6025 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6027 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6028 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6029 tx_first, "tx_first");
6030 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6031 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6034 cmdline_parse_inst_t cmd_start_tx_first_n = {
6035 .f = cmd_start_tx_first_n_parsed,
6037 .help_str = "start tx_first <num>: "
6038 "packet forwarding, after sending <num> bursts of packets",
6040 (void *)&cmd_start_tx_first_n_start,
6041 (void *)&cmd_start_tx_first_n_tx_first,
6042 (void *)&cmd_start_tx_first_n_tx_num,
6047 /* *** SET LINK UP *** */
6048 struct cmd_set_link_up_result {
6049 cmdline_fixed_string_t set;
6050 cmdline_fixed_string_t link_up;
6051 cmdline_fixed_string_t port;
6055 cmdline_parse_token_string_t cmd_set_link_up_set =
6056 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6057 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6058 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6060 cmdline_parse_token_string_t cmd_set_link_up_port =
6061 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6062 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6063 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
6065 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6066 __attribute__((unused)) struct cmdline *cl,
6067 __attribute__((unused)) void *data)
6069 struct cmd_set_link_up_result *res = parsed_result;
6070 dev_set_link_up(res->port_id);
6073 cmdline_parse_inst_t cmd_set_link_up = {
6074 .f = cmd_set_link_up_parsed,
6076 .help_str = "set link-up port <port id>",
6078 (void *)&cmd_set_link_up_set,
6079 (void *)&cmd_set_link_up_link_up,
6080 (void *)&cmd_set_link_up_port,
6081 (void *)&cmd_set_link_up_port_id,
6086 /* *** SET LINK DOWN *** */
6087 struct cmd_set_link_down_result {
6088 cmdline_fixed_string_t set;
6089 cmdline_fixed_string_t link_down;
6090 cmdline_fixed_string_t port;
6094 cmdline_parse_token_string_t cmd_set_link_down_set =
6095 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6096 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6097 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6099 cmdline_parse_token_string_t cmd_set_link_down_port =
6100 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6101 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6102 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
6104 static void cmd_set_link_down_parsed(
6105 __attribute__((unused)) void *parsed_result,
6106 __attribute__((unused)) struct cmdline *cl,
6107 __attribute__((unused)) void *data)
6109 struct cmd_set_link_down_result *res = parsed_result;
6110 dev_set_link_down(res->port_id);
6113 cmdline_parse_inst_t cmd_set_link_down = {
6114 .f = cmd_set_link_down_parsed,
6116 .help_str = "set link-down port <port id>",
6118 (void *)&cmd_set_link_down_set,
6119 (void *)&cmd_set_link_down_link_down,
6120 (void *)&cmd_set_link_down_port,
6121 (void *)&cmd_set_link_down_port_id,
6126 /* *** SHOW CFG *** */
6127 struct cmd_showcfg_result {
6128 cmdline_fixed_string_t show;
6129 cmdline_fixed_string_t cfg;
6130 cmdline_fixed_string_t what;
6133 static void cmd_showcfg_parsed(void *parsed_result,
6134 __attribute__((unused)) struct cmdline *cl,
6135 __attribute__((unused)) void *data)
6137 struct cmd_showcfg_result *res = parsed_result;
6138 if (!strcmp(res->what, "rxtx"))
6139 rxtx_config_display();
6140 else if (!strcmp(res->what, "cores"))
6141 fwd_lcores_config_display();
6142 else if (!strcmp(res->what, "fwd"))
6143 pkt_fwd_config_display(&cur_fwd_config);
6144 else if (!strcmp(res->what, "txpkts"))
6145 show_tx_pkt_segments();
6148 cmdline_parse_token_string_t cmd_showcfg_show =
6149 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6150 cmdline_parse_token_string_t cmd_showcfg_port =
6151 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6152 cmdline_parse_token_string_t cmd_showcfg_what =
6153 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6154 "rxtx#cores#fwd#txpkts");
6156 cmdline_parse_inst_t cmd_showcfg = {
6157 .f = cmd_showcfg_parsed,
6159 .help_str = "show config rxtx|cores|fwd|txpkts",
6161 (void *)&cmd_showcfg_show,
6162 (void *)&cmd_showcfg_port,
6163 (void *)&cmd_showcfg_what,
6168 /* *** SHOW ALL PORT INFO *** */
6169 struct cmd_showportall_result {
6170 cmdline_fixed_string_t show;
6171 cmdline_fixed_string_t port;
6172 cmdline_fixed_string_t what;
6173 cmdline_fixed_string_t all;
6176 static void cmd_showportall_parsed(void *parsed_result,
6177 __attribute__((unused)) struct cmdline *cl,
6178 __attribute__((unused)) void *data)
6182 struct cmd_showportall_result *res = parsed_result;
6183 if (!strcmp(res->show, "clear")) {
6184 if (!strcmp(res->what, "stats"))
6185 RTE_ETH_FOREACH_DEV(i)
6187 else if (!strcmp(res->what, "xstats"))
6188 RTE_ETH_FOREACH_DEV(i)
6189 nic_xstats_clear(i);
6190 } else if (!strcmp(res->what, "info"))
6191 RTE_ETH_FOREACH_DEV(i)
6192 port_infos_display(i);
6193 else if (!strcmp(res->what, "stats"))
6194 RTE_ETH_FOREACH_DEV(i)
6195 nic_stats_display(i);
6196 else if (!strcmp(res->what, "xstats"))
6197 RTE_ETH_FOREACH_DEV(i)
6198 nic_xstats_display(i);
6199 else if (!strcmp(res->what, "fdir"))
6200 RTE_ETH_FOREACH_DEV(i)
6202 else if (!strcmp(res->what, "stat_qmap"))
6203 RTE_ETH_FOREACH_DEV(i)
6204 nic_stats_mapping_display(i);
6205 else if (!strcmp(res->what, "dcb_tc"))
6206 RTE_ETH_FOREACH_DEV(i)
6207 port_dcb_info_display(i);
6208 else if (!strcmp(res->what, "cap"))
6209 RTE_ETH_FOREACH_DEV(i)
6210 port_offload_cap_display(i);
6213 cmdline_parse_token_string_t cmd_showportall_show =
6214 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6216 cmdline_parse_token_string_t cmd_showportall_port =
6217 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6218 cmdline_parse_token_string_t cmd_showportall_what =
6219 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6220 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6221 cmdline_parse_token_string_t cmd_showportall_all =
6222 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6223 cmdline_parse_inst_t cmd_showportall = {
6224 .f = cmd_showportall_parsed,
6226 .help_str = "show|clear port "
6227 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6229 (void *)&cmd_showportall_show,
6230 (void *)&cmd_showportall_port,
6231 (void *)&cmd_showportall_what,
6232 (void *)&cmd_showportall_all,
6237 /* *** SHOW PORT INFO *** */
6238 struct cmd_showport_result {
6239 cmdline_fixed_string_t show;
6240 cmdline_fixed_string_t port;
6241 cmdline_fixed_string_t what;
6245 static void cmd_showport_parsed(void *parsed_result,
6246 __attribute__((unused)) struct cmdline *cl,
6247 __attribute__((unused)) void *data)
6249 struct cmd_showport_result *res = parsed_result;
6250 if (!strcmp(res->show, "clear")) {
6251 if (!strcmp(res->what, "stats"))
6252 nic_stats_clear(res->portnum);
6253 else if (!strcmp(res->what, "xstats"))
6254 nic_xstats_clear(res->portnum);
6255 } else if (!strcmp(res->what, "info"))
6256 port_infos_display(res->portnum);
6257 else if (!strcmp(res->what, "stats"))
6258 nic_stats_display(res->portnum);
6259 else if (!strcmp(res->what, "xstats"))
6260 nic_xstats_display(res->portnum);
6261 else if (!strcmp(res->what, "fdir"))
6262 fdir_get_infos(res->portnum);
6263 else if (!strcmp(res->what, "stat_qmap"))
6264 nic_stats_mapping_display(res->portnum);
6265 else if (!strcmp(res->what, "dcb_tc"))
6266 port_dcb_info_display(res->portnum);
6267 else if (!strcmp(res->what, "cap"))
6268 port_offload_cap_display(res->portnum);
6271 cmdline_parse_token_string_t cmd_showport_show =
6272 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6274 cmdline_parse_token_string_t cmd_showport_port =
6275 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6276 cmdline_parse_token_string_t cmd_showport_what =
6277 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6278 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6279 cmdline_parse_token_num_t cmd_showport_portnum =
6280 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
6282 cmdline_parse_inst_t cmd_showport = {
6283 .f = cmd_showport_parsed,
6285 .help_str = "show|clear port "
6286 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6289 (void *)&cmd_showport_show,
6290 (void *)&cmd_showport_port,
6291 (void *)&cmd_showport_what,
6292 (void *)&cmd_showport_portnum,
6297 /* *** SHOW QUEUE INFO *** */
6298 struct cmd_showqueue_result {
6299 cmdline_fixed_string_t show;
6300 cmdline_fixed_string_t type;
6301 cmdline_fixed_string_t what;
6307 cmd_showqueue_parsed(void *parsed_result,
6308 __attribute__((unused)) struct cmdline *cl,
6309 __attribute__((unused)) void *data)
6311 struct cmd_showqueue_result *res = parsed_result;
6313 if (!strcmp(res->type, "rxq"))
6314 rx_queue_infos_display(res->portnum, res->queuenum);
6315 else if (!strcmp(res->type, "txq"))
6316 tx_queue_infos_display(res->portnum, res->queuenum);
6319 cmdline_parse_token_string_t cmd_showqueue_show =
6320 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6321 cmdline_parse_token_string_t cmd_showqueue_type =
6322 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6323 cmdline_parse_token_string_t cmd_showqueue_what =
6324 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6325 cmdline_parse_token_num_t cmd_showqueue_portnum =
6326 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
6327 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6328 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6330 cmdline_parse_inst_t cmd_showqueue = {
6331 .f = cmd_showqueue_parsed,
6333 .help_str = "show rxq|txq info <port_id> <queue_id>",
6335 (void *)&cmd_showqueue_show,
6336 (void *)&cmd_showqueue_type,
6337 (void *)&cmd_showqueue_what,
6338 (void *)&cmd_showqueue_portnum,
6339 (void *)&cmd_showqueue_queuenum,
6344 /* *** READ PORT REGISTER *** */
6345 struct cmd_read_reg_result {
6346 cmdline_fixed_string_t read;
6347 cmdline_fixed_string_t reg;
6353 cmd_read_reg_parsed(void *parsed_result,
6354 __attribute__((unused)) struct cmdline *cl,
6355 __attribute__((unused)) void *data)
6357 struct cmd_read_reg_result *res = parsed_result;
6358 port_reg_display(res->port_id, res->reg_off);
6361 cmdline_parse_token_string_t cmd_read_reg_read =
6362 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6363 cmdline_parse_token_string_t cmd_read_reg_reg =
6364 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6365 cmdline_parse_token_num_t cmd_read_reg_port_id =
6366 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6367 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6368 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6370 cmdline_parse_inst_t cmd_read_reg = {
6371 .f = cmd_read_reg_parsed,
6373 .help_str = "read reg <port_id> <reg_off>",
6375 (void *)&cmd_read_reg_read,
6376 (void *)&cmd_read_reg_reg,
6377 (void *)&cmd_read_reg_port_id,
6378 (void *)&cmd_read_reg_reg_off,
6383 /* *** READ PORT REGISTER BIT FIELD *** */
6384 struct cmd_read_reg_bit_field_result {
6385 cmdline_fixed_string_t read;
6386 cmdline_fixed_string_t regfield;
6394 cmd_read_reg_bit_field_parsed(void *parsed_result,
6395 __attribute__((unused)) struct cmdline *cl,
6396 __attribute__((unused)) void *data)
6398 struct cmd_read_reg_bit_field_result *res = parsed_result;
6399 port_reg_bit_field_display(res->port_id, res->reg_off,
6400 res->bit1_pos, res->bit2_pos);
6403 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6404 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6406 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6407 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6408 regfield, "regfield");
6409 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6410 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6412 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6413 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6415 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6416 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6418 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6419 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6422 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6423 .f = cmd_read_reg_bit_field_parsed,
6425 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6426 "Read register bit field between bit_x and bit_y included",
6428 (void *)&cmd_read_reg_bit_field_read,
6429 (void *)&cmd_read_reg_bit_field_regfield,
6430 (void *)&cmd_read_reg_bit_field_port_id,
6431 (void *)&cmd_read_reg_bit_field_reg_off,
6432 (void *)&cmd_read_reg_bit_field_bit1_pos,
6433 (void *)&cmd_read_reg_bit_field_bit2_pos,
6438 /* *** READ PORT REGISTER BIT *** */
6439 struct cmd_read_reg_bit_result {
6440 cmdline_fixed_string_t read;
6441 cmdline_fixed_string_t regbit;
6448 cmd_read_reg_bit_parsed(void *parsed_result,
6449 __attribute__((unused)) struct cmdline *cl,
6450 __attribute__((unused)) void *data)
6452 struct cmd_read_reg_bit_result *res = parsed_result;
6453 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6456 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6457 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6458 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6459 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6461 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6462 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6463 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6464 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6465 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6466 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6468 cmdline_parse_inst_t cmd_read_reg_bit = {
6469 .f = cmd_read_reg_bit_parsed,
6471 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6473 (void *)&cmd_read_reg_bit_read,
6474 (void *)&cmd_read_reg_bit_regbit,
6475 (void *)&cmd_read_reg_bit_port_id,
6476 (void *)&cmd_read_reg_bit_reg_off,
6477 (void *)&cmd_read_reg_bit_bit_pos,
6482 /* *** WRITE PORT REGISTER *** */
6483 struct cmd_write_reg_result {
6484 cmdline_fixed_string_t write;
6485 cmdline_fixed_string_t reg;
6492 cmd_write_reg_parsed(void *parsed_result,
6493 __attribute__((unused)) struct cmdline *cl,
6494 __attribute__((unused)) void *data)
6496 struct cmd_write_reg_result *res = parsed_result;
6497 port_reg_set(res->port_id, res->reg_off, res->value);
6500 cmdline_parse_token_string_t cmd_write_reg_write =
6501 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6502 cmdline_parse_token_string_t cmd_write_reg_reg =
6503 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6504 cmdline_parse_token_num_t cmd_write_reg_port_id =
6505 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6506 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6507 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6508 cmdline_parse_token_num_t cmd_write_reg_value =
6509 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6511 cmdline_parse_inst_t cmd_write_reg = {
6512 .f = cmd_write_reg_parsed,
6514 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6516 (void *)&cmd_write_reg_write,
6517 (void *)&cmd_write_reg_reg,
6518 (void *)&cmd_write_reg_port_id,
6519 (void *)&cmd_write_reg_reg_off,
6520 (void *)&cmd_write_reg_value,
6525 /* *** WRITE PORT REGISTER BIT FIELD *** */
6526 struct cmd_write_reg_bit_field_result {
6527 cmdline_fixed_string_t write;
6528 cmdline_fixed_string_t regfield;
6537 cmd_write_reg_bit_field_parsed(void *parsed_result,
6538 __attribute__((unused)) struct cmdline *cl,
6539 __attribute__((unused)) void *data)
6541 struct cmd_write_reg_bit_field_result *res = parsed_result;
6542 port_reg_bit_field_set(res->port_id, res->reg_off,
6543 res->bit1_pos, res->bit2_pos, res->value);
6546 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6547 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6549 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6550 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6551 regfield, "regfield");
6552 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6553 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6555 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6556 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6558 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6559 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6561 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6562 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6564 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6565 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6568 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6569 .f = cmd_write_reg_bit_field_parsed,
6571 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6573 "Set register bit field between bit_x and bit_y included",
6575 (void *)&cmd_write_reg_bit_field_write,
6576 (void *)&cmd_write_reg_bit_field_regfield,
6577 (void *)&cmd_write_reg_bit_field_port_id,
6578 (void *)&cmd_write_reg_bit_field_reg_off,
6579 (void *)&cmd_write_reg_bit_field_bit1_pos,
6580 (void *)&cmd_write_reg_bit_field_bit2_pos,
6581 (void *)&cmd_write_reg_bit_field_value,
6586 /* *** WRITE PORT REGISTER BIT *** */
6587 struct cmd_write_reg_bit_result {
6588 cmdline_fixed_string_t write;
6589 cmdline_fixed_string_t regbit;
6597 cmd_write_reg_bit_parsed(void *parsed_result,
6598 __attribute__((unused)) struct cmdline *cl,
6599 __attribute__((unused)) void *data)
6601 struct cmd_write_reg_bit_result *res = parsed_result;
6602 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6605 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6606 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6608 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6609 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6611 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6612 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6613 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6614 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6615 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6616 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6617 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6618 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6620 cmdline_parse_inst_t cmd_write_reg_bit = {
6621 .f = cmd_write_reg_bit_parsed,
6623 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6626 (void *)&cmd_write_reg_bit_write,
6627 (void *)&cmd_write_reg_bit_regbit,
6628 (void *)&cmd_write_reg_bit_port_id,
6629 (void *)&cmd_write_reg_bit_reg_off,
6630 (void *)&cmd_write_reg_bit_bit_pos,
6631 (void *)&cmd_write_reg_bit_value,
6636 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6637 struct cmd_read_rxd_txd_result {
6638 cmdline_fixed_string_t read;
6639 cmdline_fixed_string_t rxd_txd;
6646 cmd_read_rxd_txd_parsed(void *parsed_result,
6647 __attribute__((unused)) struct cmdline *cl,
6648 __attribute__((unused)) void *data)
6650 struct cmd_read_rxd_txd_result *res = parsed_result;
6652 if (!strcmp(res->rxd_txd, "rxd"))
6653 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6654 else if (!strcmp(res->rxd_txd, "txd"))
6655 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6658 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6659 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6660 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6661 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6663 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6664 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6665 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6666 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6667 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6668 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6670 cmdline_parse_inst_t cmd_read_rxd_txd = {
6671 .f = cmd_read_rxd_txd_parsed,
6673 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6675 (void *)&cmd_read_rxd_txd_read,
6676 (void *)&cmd_read_rxd_txd_rxd_txd,
6677 (void *)&cmd_read_rxd_txd_port_id,
6678 (void *)&cmd_read_rxd_txd_queue_id,
6679 (void *)&cmd_read_rxd_txd_desc_id,
6685 struct cmd_quit_result {
6686 cmdline_fixed_string_t quit;
6689 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6691 __attribute__((unused)) void *data)
6697 cmdline_parse_token_string_t cmd_quit_quit =
6698 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6700 cmdline_parse_inst_t cmd_quit = {
6701 .f = cmd_quit_parsed,
6703 .help_str = "quit: Exit application",
6705 (void *)&cmd_quit_quit,
6710 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6711 struct cmd_mac_addr_result {
6712 cmdline_fixed_string_t mac_addr_cmd;
6713 cmdline_fixed_string_t what;
6715 struct ether_addr address;
6718 static void cmd_mac_addr_parsed(void *parsed_result,
6719 __attribute__((unused)) struct cmdline *cl,
6720 __attribute__((unused)) void *data)
6722 struct cmd_mac_addr_result *res = parsed_result;
6725 if (strcmp(res->what, "add") == 0)
6726 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6727 else if (strcmp(res->what, "set") == 0)
6728 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6731 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6733 /* check the return value and print it if is < 0 */
6735 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6739 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6740 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6742 cmdline_parse_token_string_t cmd_mac_addr_what =
6743 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6745 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6746 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6747 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6748 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6750 cmdline_parse_inst_t cmd_mac_addr = {
6751 .f = cmd_mac_addr_parsed,
6753 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6754 "Add/Remove/Set MAC address on port_id",
6756 (void *)&cmd_mac_addr_cmd,
6757 (void *)&cmd_mac_addr_what,
6758 (void *)&cmd_mac_addr_portnum,
6759 (void *)&cmd_mac_addr_addr,
6765 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6766 struct cmd_set_qmap_result {
6767 cmdline_fixed_string_t set;
6768 cmdline_fixed_string_t qmap;
6769 cmdline_fixed_string_t what;
6776 cmd_set_qmap_parsed(void *parsed_result,
6777 __attribute__((unused)) struct cmdline *cl,
6778 __attribute__((unused)) void *data)
6780 struct cmd_set_qmap_result *res = parsed_result;
6781 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6783 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6786 cmdline_parse_token_string_t cmd_setqmap_set =
6787 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6789 cmdline_parse_token_string_t cmd_setqmap_qmap =
6790 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6792 cmdline_parse_token_string_t cmd_setqmap_what =
6793 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6795 cmdline_parse_token_num_t cmd_setqmap_portid =
6796 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6798 cmdline_parse_token_num_t cmd_setqmap_queueid =
6799 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6801 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6802 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6805 cmdline_parse_inst_t cmd_set_qmap = {
6806 .f = cmd_set_qmap_parsed,
6808 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6809 "Set statistics mapping value on tx|rx queue_id of port_id",
6811 (void *)&cmd_setqmap_set,
6812 (void *)&cmd_setqmap_qmap,
6813 (void *)&cmd_setqmap_what,
6814 (void *)&cmd_setqmap_portid,
6815 (void *)&cmd_setqmap_queueid,
6816 (void *)&cmd_setqmap_mapvalue,
6821 /* *** CONFIGURE UNICAST HASH TABLE *** */
6822 struct cmd_set_uc_hash_table {
6823 cmdline_fixed_string_t set;
6824 cmdline_fixed_string_t port;
6826 cmdline_fixed_string_t what;
6827 struct ether_addr address;
6828 cmdline_fixed_string_t mode;
6832 cmd_set_uc_hash_parsed(void *parsed_result,
6833 __attribute__((unused)) struct cmdline *cl,
6834 __attribute__((unused)) void *data)
6837 struct cmd_set_uc_hash_table *res = parsed_result;
6839 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6841 if (strcmp(res->what, "uta") == 0)
6842 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6843 &res->address,(uint8_t)is_on);
6845 printf("bad unicast hash table parameter, return code = %d \n", ret);
6849 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6850 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6852 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6853 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6855 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6856 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6858 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6859 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6861 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6862 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6864 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6865 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6868 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6869 .f = cmd_set_uc_hash_parsed,
6871 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6873 (void *)&cmd_set_uc_hash_set,
6874 (void *)&cmd_set_uc_hash_port,
6875 (void *)&cmd_set_uc_hash_portid,
6876 (void *)&cmd_set_uc_hash_what,
6877 (void *)&cmd_set_uc_hash_mac,
6878 (void *)&cmd_set_uc_hash_mode,
6883 struct cmd_set_uc_all_hash_table {
6884 cmdline_fixed_string_t set;
6885 cmdline_fixed_string_t port;
6887 cmdline_fixed_string_t what;
6888 cmdline_fixed_string_t value;
6889 cmdline_fixed_string_t mode;
6893 cmd_set_uc_all_hash_parsed(void *parsed_result,
6894 __attribute__((unused)) struct cmdline *cl,
6895 __attribute__((unused)) void *data)
6898 struct cmd_set_uc_all_hash_table *res = parsed_result;
6900 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6902 if ((strcmp(res->what, "uta") == 0) &&
6903 (strcmp(res->value, "all") == 0))
6904 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6906 printf("bad unicast hash table parameter,"
6907 "return code = %d \n", ret);
6910 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6911 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6913 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6914 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6916 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6917 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6919 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6920 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6922 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6923 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6925 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6926 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6929 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6930 .f = cmd_set_uc_all_hash_parsed,
6932 .help_str = "set port <port_id> uta all on|off",
6934 (void *)&cmd_set_uc_all_hash_set,
6935 (void *)&cmd_set_uc_all_hash_port,
6936 (void *)&cmd_set_uc_all_hash_portid,
6937 (void *)&cmd_set_uc_all_hash_what,
6938 (void *)&cmd_set_uc_all_hash_value,
6939 (void *)&cmd_set_uc_all_hash_mode,
6944 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6945 struct cmd_set_vf_macvlan_filter {
6946 cmdline_fixed_string_t set;
6947 cmdline_fixed_string_t port;
6949 cmdline_fixed_string_t vf;
6951 struct ether_addr address;
6952 cmdline_fixed_string_t filter_type;
6953 cmdline_fixed_string_t mode;
6957 cmd_set_vf_macvlan_parsed(void *parsed_result,
6958 __attribute__((unused)) struct cmdline *cl,
6959 __attribute__((unused)) void *data)
6962 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6963 struct rte_eth_mac_filter filter;
6965 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6967 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6969 /* set VF MAC filter */
6973 filter.dst_id = res->vf_id;
6975 if (!strcmp(res->filter_type, "exact-mac"))
6976 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6977 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6978 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6979 else if (!strcmp(res->filter_type, "hashmac"))
6980 filter.filter_type = RTE_MAC_HASH_MATCH;
6981 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6982 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6984 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6987 ret = rte_eth_dev_filter_ctrl(res->port_id,
6988 RTE_ETH_FILTER_MACVLAN,
6992 ret = rte_eth_dev_filter_ctrl(res->port_id,
6993 RTE_ETH_FILTER_MACVLAN,
6994 RTE_ETH_FILTER_DELETE,
6998 printf("bad set MAC hash parameter, return code = %d\n", ret);
7002 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7003 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7005 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7006 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7008 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7009 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7011 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7012 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7014 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7015 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7017 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7018 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7020 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7021 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7022 filter_type, "exact-mac#exact-mac-vlan"
7023 "#hashmac#hashmac-vlan");
7024 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7025 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7028 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7029 .f = cmd_set_vf_macvlan_parsed,
7031 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7032 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7033 "Exact match rule: exact match of MAC or MAC and VLAN; "
7034 "hash match rule: hash match of MAC and exact match of VLAN",
7036 (void *)&cmd_set_vf_macvlan_set,
7037 (void *)&cmd_set_vf_macvlan_port,
7038 (void *)&cmd_set_vf_macvlan_portid,
7039 (void *)&cmd_set_vf_macvlan_vf,
7040 (void *)&cmd_set_vf_macvlan_vf_id,
7041 (void *)&cmd_set_vf_macvlan_mac,
7042 (void *)&cmd_set_vf_macvlan_filter_type,
7043 (void *)&cmd_set_vf_macvlan_mode,
7048 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7049 struct cmd_set_vf_traffic {
7050 cmdline_fixed_string_t set;
7051 cmdline_fixed_string_t port;
7053 cmdline_fixed_string_t vf;
7055 cmdline_fixed_string_t what;
7056 cmdline_fixed_string_t mode;
7060 cmd_set_vf_traffic_parsed(void *parsed_result,
7061 __attribute__((unused)) struct cmdline *cl,
7062 __attribute__((unused)) void *data)
7064 struct cmd_set_vf_traffic *res = parsed_result;
7065 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7066 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7068 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7071 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7072 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7074 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7075 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7077 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7078 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7080 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7081 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7083 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7084 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7086 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7087 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7089 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7090 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7093 cmdline_parse_inst_t cmd_set_vf_traffic = {
7094 .f = cmd_set_vf_traffic_parsed,
7096 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7098 (void *)&cmd_setvf_traffic_set,
7099 (void *)&cmd_setvf_traffic_port,
7100 (void *)&cmd_setvf_traffic_portid,
7101 (void *)&cmd_setvf_traffic_vf,
7102 (void *)&cmd_setvf_traffic_vfid,
7103 (void *)&cmd_setvf_traffic_what,
7104 (void *)&cmd_setvf_traffic_mode,
7109 /* *** CONFIGURE VF RECEIVE MODE *** */
7110 struct cmd_set_vf_rxmode {
7111 cmdline_fixed_string_t set;
7112 cmdline_fixed_string_t port;
7114 cmdline_fixed_string_t vf;
7116 cmdline_fixed_string_t what;
7117 cmdline_fixed_string_t mode;
7118 cmdline_fixed_string_t on;
7122 cmd_set_vf_rxmode_parsed(void *parsed_result,
7123 __attribute__((unused)) struct cmdline *cl,
7124 __attribute__((unused)) void *data)
7127 uint16_t rx_mode = 0;
7128 struct cmd_set_vf_rxmode *res = parsed_result;
7130 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7131 if (!strcmp(res->what,"rxmode")) {
7132 if (!strcmp(res->mode, "AUPE"))
7133 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7134 else if (!strcmp(res->mode, "ROPE"))
7135 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7136 else if (!strcmp(res->mode, "BAM"))
7137 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7138 else if (!strncmp(res->mode, "MPE",3))
7139 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7142 #ifdef RTE_LIBRTE_IXGBE_PMD
7143 if (ret == -ENOTSUP)
7144 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7145 rx_mode, (uint8_t)is_on);
7147 #ifdef RTE_LIBRTE_BNXT_PMD
7148 if (ret == -ENOTSUP)
7149 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7150 rx_mode, (uint8_t)is_on);
7153 printf("bad VF receive mode parameter, return code = %d \n",
7157 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7158 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7160 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7161 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7163 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7164 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7166 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7167 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7169 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7170 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7172 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7173 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7175 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7176 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7177 mode, "AUPE#ROPE#BAM#MPE");
7178 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7179 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7182 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7183 .f = cmd_set_vf_rxmode_parsed,
7185 .help_str = "set port <port_id> vf <vf_id> rxmode "
7186 "AUPE|ROPE|BAM|MPE on|off",
7188 (void *)&cmd_set_vf_rxmode_set,
7189 (void *)&cmd_set_vf_rxmode_port,
7190 (void *)&cmd_set_vf_rxmode_portid,
7191 (void *)&cmd_set_vf_rxmode_vf,
7192 (void *)&cmd_set_vf_rxmode_vfid,
7193 (void *)&cmd_set_vf_rxmode_what,
7194 (void *)&cmd_set_vf_rxmode_mode,
7195 (void *)&cmd_set_vf_rxmode_on,
7200 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7201 struct cmd_vf_mac_addr_result {
7202 cmdline_fixed_string_t mac_addr_cmd;
7203 cmdline_fixed_string_t what;
7204 cmdline_fixed_string_t port;
7206 cmdline_fixed_string_t vf;
7208 struct ether_addr address;
7211 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7212 __attribute__((unused)) struct cmdline *cl,
7213 __attribute__((unused)) void *data)
7215 struct cmd_vf_mac_addr_result *res = parsed_result;
7218 if (strcmp(res->what, "add") != 0)
7221 #ifdef RTE_LIBRTE_I40E_PMD
7222 if (ret == -ENOTSUP)
7223 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7226 #ifdef RTE_LIBRTE_BNXT_PMD
7227 if (ret == -ENOTSUP)
7228 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7233 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7237 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7238 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7239 mac_addr_cmd,"mac_addr");
7240 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7241 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7243 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7244 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7246 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7247 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7249 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7250 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7252 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7253 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7255 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7256 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7259 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7260 .f = cmd_vf_mac_addr_parsed,
7262 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7263 "Add MAC address filtering for a VF on port_id",
7265 (void *)&cmd_vf_mac_addr_cmd,
7266 (void *)&cmd_vf_mac_addr_what,
7267 (void *)&cmd_vf_mac_addr_port,
7268 (void *)&cmd_vf_mac_addr_portnum,
7269 (void *)&cmd_vf_mac_addr_vf,
7270 (void *)&cmd_vf_mac_addr_vfnum,
7271 (void *)&cmd_vf_mac_addr_addr,
7276 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7277 struct cmd_vf_rx_vlan_filter {
7278 cmdline_fixed_string_t rx_vlan;
7279 cmdline_fixed_string_t what;
7281 cmdline_fixed_string_t port;
7283 cmdline_fixed_string_t vf;
7288 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7289 __attribute__((unused)) struct cmdline *cl,
7290 __attribute__((unused)) void *data)
7292 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7295 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7297 #ifdef RTE_LIBRTE_IXGBE_PMD
7298 if (ret == -ENOTSUP)
7299 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7300 res->vlan_id, res->vf_mask, is_add);
7302 #ifdef RTE_LIBRTE_I40E_PMD
7303 if (ret == -ENOTSUP)
7304 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7305 res->vlan_id, res->vf_mask, is_add);
7307 #ifdef RTE_LIBRTE_BNXT_PMD
7308 if (ret == -ENOTSUP)
7309 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7310 res->vlan_id, res->vf_mask, is_add);
7317 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7318 res->vlan_id, res->vf_mask);
7321 printf("invalid port_id %d\n", res->port_id);
7324 printf("function not implemented or supported\n");
7327 printf("programming error: (%s)\n", strerror(-ret));
7331 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7332 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7333 rx_vlan, "rx_vlan");
7334 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7335 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7337 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7338 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7340 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7341 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7343 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7344 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7346 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7347 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7349 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7350 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7353 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7354 .f = cmd_vf_rx_vlan_filter_parsed,
7356 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7357 "(vf_mask = hexadecimal VF mask)",
7359 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7360 (void *)&cmd_vf_rx_vlan_filter_what,
7361 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7362 (void *)&cmd_vf_rx_vlan_filter_port,
7363 (void *)&cmd_vf_rx_vlan_filter_portid,
7364 (void *)&cmd_vf_rx_vlan_filter_vf,
7365 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7370 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7371 struct cmd_queue_rate_limit_result {
7372 cmdline_fixed_string_t set;
7373 cmdline_fixed_string_t port;
7375 cmdline_fixed_string_t queue;
7377 cmdline_fixed_string_t rate;
7381 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7382 __attribute__((unused)) struct cmdline *cl,
7383 __attribute__((unused)) void *data)
7385 struct cmd_queue_rate_limit_result *res = parsed_result;
7388 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7389 && (strcmp(res->queue, "queue") == 0)
7390 && (strcmp(res->rate, "rate") == 0))
7391 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7394 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7398 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7399 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7401 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7402 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7404 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7405 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7407 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7408 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7410 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7411 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7413 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7414 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7416 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7417 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7420 cmdline_parse_inst_t cmd_queue_rate_limit = {
7421 .f = cmd_queue_rate_limit_parsed,
7423 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7424 "Set rate limit for a queue on port_id",
7426 (void *)&cmd_queue_rate_limit_set,
7427 (void *)&cmd_queue_rate_limit_port,
7428 (void *)&cmd_queue_rate_limit_portnum,
7429 (void *)&cmd_queue_rate_limit_queue,
7430 (void *)&cmd_queue_rate_limit_queuenum,
7431 (void *)&cmd_queue_rate_limit_rate,
7432 (void *)&cmd_queue_rate_limit_ratenum,
7437 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7438 struct cmd_vf_rate_limit_result {
7439 cmdline_fixed_string_t set;
7440 cmdline_fixed_string_t port;
7442 cmdline_fixed_string_t vf;
7444 cmdline_fixed_string_t rate;
7446 cmdline_fixed_string_t q_msk;
7450 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7451 __attribute__((unused)) struct cmdline *cl,
7452 __attribute__((unused)) void *data)
7454 struct cmd_vf_rate_limit_result *res = parsed_result;
7457 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7458 && (strcmp(res->vf, "vf") == 0)
7459 && (strcmp(res->rate, "rate") == 0)
7460 && (strcmp(res->q_msk, "queue_mask") == 0))
7461 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7462 res->rate_num, res->q_msk_val);
7464 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7468 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7469 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7471 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7472 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7474 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7475 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7477 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7478 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7480 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7481 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7483 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7484 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7486 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7487 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7489 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7490 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7491 q_msk, "queue_mask");
7492 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7493 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7496 cmdline_parse_inst_t cmd_vf_rate_limit = {
7497 .f = cmd_vf_rate_limit_parsed,
7499 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7500 "queue_mask <queue_mask_value>: "
7501 "Set rate limit for queues of VF on port_id",
7503 (void *)&cmd_vf_rate_limit_set,
7504 (void *)&cmd_vf_rate_limit_port,
7505 (void *)&cmd_vf_rate_limit_portnum,
7506 (void *)&cmd_vf_rate_limit_vf,
7507 (void *)&cmd_vf_rate_limit_vfnum,
7508 (void *)&cmd_vf_rate_limit_rate,
7509 (void *)&cmd_vf_rate_limit_ratenum,
7510 (void *)&cmd_vf_rate_limit_q_msk,
7511 (void *)&cmd_vf_rate_limit_q_msk_val,
7516 /* *** ADD TUNNEL FILTER OF A PORT *** */
7517 struct cmd_tunnel_filter_result {
7518 cmdline_fixed_string_t cmd;
7519 cmdline_fixed_string_t what;
7521 struct ether_addr outer_mac;
7522 struct ether_addr inner_mac;
7523 cmdline_ipaddr_t ip_value;
7524 uint16_t inner_vlan;
7525 cmdline_fixed_string_t tunnel_type;
7526 cmdline_fixed_string_t filter_type;
7532 cmd_tunnel_filter_parsed(void *parsed_result,
7533 __attribute__((unused)) struct cmdline *cl,
7534 __attribute__((unused)) void *data)
7536 struct cmd_tunnel_filter_result *res = parsed_result;
7537 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7540 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7542 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7543 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7544 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7546 if (res->ip_value.family == AF_INET) {
7547 tunnel_filter_conf.ip_addr.ipv4_addr =
7548 res->ip_value.addr.ipv4.s_addr;
7549 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7551 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7552 &(res->ip_value.addr.ipv6),
7553 sizeof(struct in6_addr));
7554 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7557 if (!strcmp(res->filter_type, "imac-ivlan"))
7558 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7559 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7560 tunnel_filter_conf.filter_type =
7561 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7562 else if (!strcmp(res->filter_type, "imac-tenid"))
7563 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7564 else if (!strcmp(res->filter_type, "imac"))
7565 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7566 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7567 tunnel_filter_conf.filter_type =
7568 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7569 else if (!strcmp(res->filter_type, "oip"))
7570 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7571 else if (!strcmp(res->filter_type, "iip"))
7572 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7574 printf("The filter type is not supported");
7578 if (!strcmp(res->tunnel_type, "vxlan"))
7579 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7580 else if (!strcmp(res->tunnel_type, "nvgre"))
7581 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7582 else if (!strcmp(res->tunnel_type, "ipingre"))
7583 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7585 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7589 tunnel_filter_conf.tenant_id = res->tenant_id;
7590 tunnel_filter_conf.queue_id = res->queue_num;
7591 if (!strcmp(res->what, "add"))
7592 ret = rte_eth_dev_filter_ctrl(res->port_id,
7593 RTE_ETH_FILTER_TUNNEL,
7595 &tunnel_filter_conf);
7597 ret = rte_eth_dev_filter_ctrl(res->port_id,
7598 RTE_ETH_FILTER_TUNNEL,
7599 RTE_ETH_FILTER_DELETE,
7600 &tunnel_filter_conf);
7602 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7606 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7607 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7608 cmd, "tunnel_filter");
7609 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7610 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7612 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7613 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7615 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7616 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7618 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7619 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7621 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7622 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7623 inner_vlan, UINT16);
7624 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7625 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7627 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7628 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7629 tunnel_type, "vxlan#nvgre#ipingre");
7631 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7632 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7633 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7634 "imac#omac-imac-tenid");
7635 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7636 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7638 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7639 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7642 cmdline_parse_inst_t cmd_tunnel_filter = {
7643 .f = cmd_tunnel_filter_parsed,
7645 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7646 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7647 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7648 "<queue_id>: Add/Rm tunnel filter of a port",
7650 (void *)&cmd_tunnel_filter_cmd,
7651 (void *)&cmd_tunnel_filter_what,
7652 (void *)&cmd_tunnel_filter_port_id,
7653 (void *)&cmd_tunnel_filter_outer_mac,
7654 (void *)&cmd_tunnel_filter_inner_mac,
7655 (void *)&cmd_tunnel_filter_ip_value,
7656 (void *)&cmd_tunnel_filter_innner_vlan,
7657 (void *)&cmd_tunnel_filter_tunnel_type,
7658 (void *)&cmd_tunnel_filter_filter_type,
7659 (void *)&cmd_tunnel_filter_tenant_id,
7660 (void *)&cmd_tunnel_filter_queue_num,
7665 /* *** CONFIGURE TUNNEL UDP PORT *** */
7666 struct cmd_tunnel_udp_config {
7667 cmdline_fixed_string_t cmd;
7668 cmdline_fixed_string_t what;
7674 cmd_tunnel_udp_config_parsed(void *parsed_result,
7675 __attribute__((unused)) struct cmdline *cl,
7676 __attribute__((unused)) void *data)
7678 struct cmd_tunnel_udp_config *res = parsed_result;
7679 struct rte_eth_udp_tunnel tunnel_udp;
7682 tunnel_udp.udp_port = res->udp_port;
7684 if (!strcmp(res->cmd, "rx_vxlan_port"))
7685 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7687 if (!strcmp(res->what, "add"))
7688 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7691 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7695 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7698 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7699 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7700 cmd, "rx_vxlan_port");
7701 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7702 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7704 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7705 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7707 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7708 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7711 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7712 .f = cmd_tunnel_udp_config_parsed,
7714 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7715 "Add/Remove a tunneling UDP port filter",
7717 (void *)&cmd_tunnel_udp_config_cmd,
7718 (void *)&cmd_tunnel_udp_config_what,
7719 (void *)&cmd_tunnel_udp_config_udp_port,
7720 (void *)&cmd_tunnel_udp_config_port_id,
7725 /* *** GLOBAL CONFIG *** */
7726 struct cmd_global_config_result {
7727 cmdline_fixed_string_t cmd;
7729 cmdline_fixed_string_t cfg_type;
7734 cmd_global_config_parsed(void *parsed_result,
7735 __attribute__((unused)) struct cmdline *cl,
7736 __attribute__((unused)) void *data)
7738 struct cmd_global_config_result *res = parsed_result;
7739 struct rte_eth_global_cfg conf;
7742 memset(&conf, 0, sizeof(conf));
7743 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7744 conf.cfg.gre_key_len = res->len;
7745 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7746 RTE_ETH_FILTER_SET, &conf);
7748 printf("Global config error\n");
7751 cmdline_parse_token_string_t cmd_global_config_cmd =
7752 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7754 cmdline_parse_token_num_t cmd_global_config_port_id =
7755 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7756 cmdline_parse_token_string_t cmd_global_config_type =
7757 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7758 cfg_type, "gre-key-len");
7759 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7760 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7763 cmdline_parse_inst_t cmd_global_config = {
7764 .f = cmd_global_config_parsed,
7765 .data = (void *)NULL,
7766 .help_str = "global_config <port_id> gre-key-len <key_len>",
7768 (void *)&cmd_global_config_cmd,
7769 (void *)&cmd_global_config_port_id,
7770 (void *)&cmd_global_config_type,
7771 (void *)&cmd_global_config_gre_key_len,
7776 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7777 struct cmd_set_mirror_mask_result {
7778 cmdline_fixed_string_t set;
7779 cmdline_fixed_string_t port;
7781 cmdline_fixed_string_t mirror;
7783 cmdline_fixed_string_t what;
7784 cmdline_fixed_string_t value;
7785 cmdline_fixed_string_t dstpool;
7787 cmdline_fixed_string_t on;
7790 cmdline_parse_token_string_t cmd_mirror_mask_set =
7791 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7793 cmdline_parse_token_string_t cmd_mirror_mask_port =
7794 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7796 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7797 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7799 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7800 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7801 mirror, "mirror-rule");
7802 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7803 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7805 cmdline_parse_token_string_t cmd_mirror_mask_what =
7806 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7807 what, "pool-mirror-up#pool-mirror-down"
7809 cmdline_parse_token_string_t cmd_mirror_mask_value =
7810 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7812 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7813 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7814 dstpool, "dst-pool");
7815 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7816 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7818 cmdline_parse_token_string_t cmd_mirror_mask_on =
7819 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7823 cmd_set_mirror_mask_parsed(void *parsed_result,
7824 __attribute__((unused)) struct cmdline *cl,
7825 __attribute__((unused)) void *data)
7828 struct cmd_set_mirror_mask_result *res = parsed_result;
7829 struct rte_eth_mirror_conf mr_conf;
7831 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7833 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7835 mr_conf.dst_pool = res->dstpool_id;
7837 if (!strcmp(res->what, "pool-mirror-up")) {
7838 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7839 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7840 } else if (!strcmp(res->what, "pool-mirror-down")) {
7841 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7842 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7843 } else if (!strcmp(res->what, "vlan-mirror")) {
7844 mr_conf.rule_type = ETH_MIRROR_VLAN;
7845 nb_item = parse_item_list(res->value, "vlan",
7846 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7850 for (i = 0; i < nb_item; i++) {
7851 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7852 printf("Invalid vlan_id: must be < 4096\n");
7856 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7857 mr_conf.vlan.vlan_mask |= 1ULL << i;
7861 if (!strcmp(res->on, "on"))
7862 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7865 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7868 printf("mirror rule add error: (%s)\n", strerror(-ret));
7871 cmdline_parse_inst_t cmd_set_mirror_mask = {
7872 .f = cmd_set_mirror_mask_parsed,
7874 .help_str = "set port <port_id> mirror-rule <rule_id> "
7875 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7876 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7878 (void *)&cmd_mirror_mask_set,
7879 (void *)&cmd_mirror_mask_port,
7880 (void *)&cmd_mirror_mask_portid,
7881 (void *)&cmd_mirror_mask_mirror,
7882 (void *)&cmd_mirror_mask_ruleid,
7883 (void *)&cmd_mirror_mask_what,
7884 (void *)&cmd_mirror_mask_value,
7885 (void *)&cmd_mirror_mask_dstpool,
7886 (void *)&cmd_mirror_mask_poolid,
7887 (void *)&cmd_mirror_mask_on,
7892 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7893 struct cmd_set_mirror_link_result {
7894 cmdline_fixed_string_t set;
7895 cmdline_fixed_string_t port;
7897 cmdline_fixed_string_t mirror;
7899 cmdline_fixed_string_t what;
7900 cmdline_fixed_string_t dstpool;
7902 cmdline_fixed_string_t on;
7905 cmdline_parse_token_string_t cmd_mirror_link_set =
7906 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7908 cmdline_parse_token_string_t cmd_mirror_link_port =
7909 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7911 cmdline_parse_token_num_t cmd_mirror_link_portid =
7912 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7914 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7915 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7916 mirror, "mirror-rule");
7917 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7918 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7920 cmdline_parse_token_string_t cmd_mirror_link_what =
7921 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7922 what, "uplink-mirror#downlink-mirror");
7923 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7924 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7925 dstpool, "dst-pool");
7926 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7927 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7929 cmdline_parse_token_string_t cmd_mirror_link_on =
7930 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7934 cmd_set_mirror_link_parsed(void *parsed_result,
7935 __attribute__((unused)) struct cmdline *cl,
7936 __attribute__((unused)) void *data)
7939 struct cmd_set_mirror_link_result *res = parsed_result;
7940 struct rte_eth_mirror_conf mr_conf;
7942 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7943 if (!strcmp(res->what, "uplink-mirror"))
7944 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7946 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7948 mr_conf.dst_pool = res->dstpool_id;
7950 if (!strcmp(res->on, "on"))
7951 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7954 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7957 /* check the return value and print it if is < 0 */
7959 printf("mirror rule add error: (%s)\n", strerror(-ret));
7963 cmdline_parse_inst_t cmd_set_mirror_link = {
7964 .f = cmd_set_mirror_link_parsed,
7966 .help_str = "set port <port_id> mirror-rule <rule_id> "
7967 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7969 (void *)&cmd_mirror_link_set,
7970 (void *)&cmd_mirror_link_port,
7971 (void *)&cmd_mirror_link_portid,
7972 (void *)&cmd_mirror_link_mirror,
7973 (void *)&cmd_mirror_link_ruleid,
7974 (void *)&cmd_mirror_link_what,
7975 (void *)&cmd_mirror_link_dstpool,
7976 (void *)&cmd_mirror_link_poolid,
7977 (void *)&cmd_mirror_link_on,
7982 /* *** RESET VM MIRROR RULE *** */
7983 struct cmd_rm_mirror_rule_result {
7984 cmdline_fixed_string_t reset;
7985 cmdline_fixed_string_t port;
7987 cmdline_fixed_string_t mirror;
7991 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7992 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7994 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7995 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7997 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7998 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8000 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8001 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8002 mirror, "mirror-rule");
8003 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8004 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8008 cmd_reset_mirror_rule_parsed(void *parsed_result,
8009 __attribute__((unused)) struct cmdline *cl,
8010 __attribute__((unused)) void *data)
8013 struct cmd_set_mirror_link_result *res = parsed_result;
8015 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8017 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8020 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8021 .f = cmd_reset_mirror_rule_parsed,
8023 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8025 (void *)&cmd_rm_mirror_rule_reset,
8026 (void *)&cmd_rm_mirror_rule_port,
8027 (void *)&cmd_rm_mirror_rule_portid,
8028 (void *)&cmd_rm_mirror_rule_mirror,
8029 (void *)&cmd_rm_mirror_rule_ruleid,
8034 /* ******************************************************************************** */
8036 struct cmd_dump_result {
8037 cmdline_fixed_string_t dump;
8041 dump_struct_sizes(void)
8043 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8044 DUMP_SIZE(struct rte_mbuf);
8045 DUMP_SIZE(struct rte_mempool);
8046 DUMP_SIZE(struct rte_ring);
8050 static void cmd_dump_parsed(void *parsed_result,
8051 __attribute__((unused)) struct cmdline *cl,
8052 __attribute__((unused)) void *data)
8054 struct cmd_dump_result *res = parsed_result;
8056 if (!strcmp(res->dump, "dump_physmem"))
8057 rte_dump_physmem_layout(stdout);
8058 else if (!strcmp(res->dump, "dump_memzone"))
8059 rte_memzone_dump(stdout);
8060 else if (!strcmp(res->dump, "dump_struct_sizes"))
8061 dump_struct_sizes();
8062 else if (!strcmp(res->dump, "dump_ring"))
8063 rte_ring_list_dump(stdout);
8064 else if (!strcmp(res->dump, "dump_mempool"))
8065 rte_mempool_list_dump(stdout);
8066 else if (!strcmp(res->dump, "dump_devargs"))
8067 rte_eal_devargs_dump(stdout);
8068 else if (!strcmp(res->dump, "dump_log_types"))
8069 rte_log_dump(stdout);
8072 cmdline_parse_token_string_t cmd_dump_dump =
8073 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8076 "dump_struct_sizes#"
8082 cmdline_parse_inst_t cmd_dump = {
8083 .f = cmd_dump_parsed, /* function to call */
8084 .data = NULL, /* 2nd arg of func */
8085 .help_str = "Dump status",
8086 .tokens = { /* token list, NULL terminated */
8087 (void *)&cmd_dump_dump,
8092 /* ******************************************************************************** */
8094 struct cmd_dump_one_result {
8095 cmdline_fixed_string_t dump;
8096 cmdline_fixed_string_t name;
8099 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8100 __attribute__((unused)) void *data)
8102 struct cmd_dump_one_result *res = parsed_result;
8104 if (!strcmp(res->dump, "dump_ring")) {
8106 r = rte_ring_lookup(res->name);
8108 cmdline_printf(cl, "Cannot find ring\n");
8111 rte_ring_dump(stdout, r);
8112 } else if (!strcmp(res->dump, "dump_mempool")) {
8113 struct rte_mempool *mp;
8114 mp = rte_mempool_lookup(res->name);
8116 cmdline_printf(cl, "Cannot find mempool\n");
8119 rte_mempool_dump(stdout, mp);
8123 cmdline_parse_token_string_t cmd_dump_one_dump =
8124 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8125 "dump_ring#dump_mempool");
8127 cmdline_parse_token_string_t cmd_dump_one_name =
8128 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8130 cmdline_parse_inst_t cmd_dump_one = {
8131 .f = cmd_dump_one_parsed, /* function to call */
8132 .data = NULL, /* 2nd arg of func */
8133 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8134 .tokens = { /* token list, NULL terminated */
8135 (void *)&cmd_dump_one_dump,
8136 (void *)&cmd_dump_one_name,
8141 /* *** Add/Del syn filter *** */
8142 struct cmd_syn_filter_result {
8143 cmdline_fixed_string_t filter;
8145 cmdline_fixed_string_t ops;
8146 cmdline_fixed_string_t priority;
8147 cmdline_fixed_string_t high;
8148 cmdline_fixed_string_t queue;
8153 cmd_syn_filter_parsed(void *parsed_result,
8154 __attribute__((unused)) struct cmdline *cl,
8155 __attribute__((unused)) void *data)
8157 struct cmd_syn_filter_result *res = parsed_result;
8158 struct rte_eth_syn_filter syn_filter;
8161 ret = rte_eth_dev_filter_supported(res->port_id,
8162 RTE_ETH_FILTER_SYN);
8164 printf("syn filter is not supported on port %u.\n",
8169 memset(&syn_filter, 0, sizeof(syn_filter));
8171 if (!strcmp(res->ops, "add")) {
8172 if (!strcmp(res->high, "high"))
8173 syn_filter.hig_pri = 1;
8175 syn_filter.hig_pri = 0;
8177 syn_filter.queue = res->queue_id;
8178 ret = rte_eth_dev_filter_ctrl(res->port_id,
8183 ret = rte_eth_dev_filter_ctrl(res->port_id,
8185 RTE_ETH_FILTER_DELETE,
8189 printf("syn filter programming error: (%s)\n",
8193 cmdline_parse_token_string_t cmd_syn_filter_filter =
8194 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8195 filter, "syn_filter");
8196 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8197 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8199 cmdline_parse_token_string_t cmd_syn_filter_ops =
8200 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8202 cmdline_parse_token_string_t cmd_syn_filter_priority =
8203 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8204 priority, "priority");
8205 cmdline_parse_token_string_t cmd_syn_filter_high =
8206 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8208 cmdline_parse_token_string_t cmd_syn_filter_queue =
8209 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8211 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8212 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8215 cmdline_parse_inst_t cmd_syn_filter = {
8216 .f = cmd_syn_filter_parsed,
8218 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8219 "<queue_id>: Add/Delete syn filter",
8221 (void *)&cmd_syn_filter_filter,
8222 (void *)&cmd_syn_filter_port_id,
8223 (void *)&cmd_syn_filter_ops,
8224 (void *)&cmd_syn_filter_priority,
8225 (void *)&cmd_syn_filter_high,
8226 (void *)&cmd_syn_filter_queue,
8227 (void *)&cmd_syn_filter_queue_id,
8232 /* *** ADD/REMOVE A 2tuple FILTER *** */
8233 struct cmd_2tuple_filter_result {
8234 cmdline_fixed_string_t filter;
8236 cmdline_fixed_string_t ops;
8237 cmdline_fixed_string_t dst_port;
8238 uint16_t dst_port_value;
8239 cmdline_fixed_string_t protocol;
8240 uint8_t protocol_value;
8241 cmdline_fixed_string_t mask;
8243 cmdline_fixed_string_t tcp_flags;
8244 uint8_t tcp_flags_value;
8245 cmdline_fixed_string_t priority;
8246 uint8_t priority_value;
8247 cmdline_fixed_string_t queue;
8252 cmd_2tuple_filter_parsed(void *parsed_result,
8253 __attribute__((unused)) struct cmdline *cl,
8254 __attribute__((unused)) void *data)
8256 struct rte_eth_ntuple_filter filter;
8257 struct cmd_2tuple_filter_result *res = parsed_result;
8260 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8262 printf("ntuple filter is not supported on port %u.\n",
8267 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8269 filter.flags = RTE_2TUPLE_FLAGS;
8270 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8271 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8272 filter.proto = res->protocol_value;
8273 filter.priority = res->priority_value;
8274 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8275 printf("nonzero tcp_flags is only meaningful"
8276 " when protocol is TCP.\n");
8279 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8280 printf("invalid TCP flags.\n");
8284 if (res->tcp_flags_value != 0) {
8285 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8286 filter.tcp_flags = res->tcp_flags_value;
8289 /* need convert to big endian. */
8290 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8291 filter.queue = res->queue_id;
8293 if (!strcmp(res->ops, "add"))
8294 ret = rte_eth_dev_filter_ctrl(res->port_id,
8295 RTE_ETH_FILTER_NTUPLE,
8299 ret = rte_eth_dev_filter_ctrl(res->port_id,
8300 RTE_ETH_FILTER_NTUPLE,
8301 RTE_ETH_FILTER_DELETE,
8304 printf("2tuple filter programming error: (%s)\n",
8309 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
8310 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8311 filter, "2tuple_filter");
8312 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
8313 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8315 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
8316 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8318 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
8319 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8320 dst_port, "dst_port");
8321 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
8322 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8323 dst_port_value, UINT16);
8324 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
8325 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8326 protocol, "protocol");
8327 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
8328 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8329 protocol_value, UINT8);
8330 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8331 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8333 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8334 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8336 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8337 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8338 tcp_flags, "tcp_flags");
8339 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8340 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8341 tcp_flags_value, UINT8);
8342 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8343 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8344 priority, "priority");
8345 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8346 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8347 priority_value, UINT8);
8348 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8349 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8351 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8352 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8355 cmdline_parse_inst_t cmd_2tuple_filter = {
8356 .f = cmd_2tuple_filter_parsed,
8358 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8359 "<value> mask <value> tcp_flags <value> priority <value> queue "
8360 "<queue_id>: Add a 2tuple filter",
8362 (void *)&cmd_2tuple_filter_filter,
8363 (void *)&cmd_2tuple_filter_port_id,
8364 (void *)&cmd_2tuple_filter_ops,
8365 (void *)&cmd_2tuple_filter_dst_port,
8366 (void *)&cmd_2tuple_filter_dst_port_value,
8367 (void *)&cmd_2tuple_filter_protocol,
8368 (void *)&cmd_2tuple_filter_protocol_value,
8369 (void *)&cmd_2tuple_filter_mask,
8370 (void *)&cmd_2tuple_filter_mask_value,
8371 (void *)&cmd_2tuple_filter_tcp_flags,
8372 (void *)&cmd_2tuple_filter_tcp_flags_value,
8373 (void *)&cmd_2tuple_filter_priority,
8374 (void *)&cmd_2tuple_filter_priority_value,
8375 (void *)&cmd_2tuple_filter_queue,
8376 (void *)&cmd_2tuple_filter_queue_id,
8381 /* *** ADD/REMOVE A 5tuple FILTER *** */
8382 struct cmd_5tuple_filter_result {
8383 cmdline_fixed_string_t filter;
8385 cmdline_fixed_string_t ops;
8386 cmdline_fixed_string_t dst_ip;
8387 cmdline_ipaddr_t dst_ip_value;
8388 cmdline_fixed_string_t src_ip;
8389 cmdline_ipaddr_t src_ip_value;
8390 cmdline_fixed_string_t dst_port;
8391 uint16_t dst_port_value;
8392 cmdline_fixed_string_t src_port;
8393 uint16_t src_port_value;
8394 cmdline_fixed_string_t protocol;
8395 uint8_t protocol_value;
8396 cmdline_fixed_string_t mask;
8398 cmdline_fixed_string_t tcp_flags;
8399 uint8_t tcp_flags_value;
8400 cmdline_fixed_string_t priority;
8401 uint8_t priority_value;
8402 cmdline_fixed_string_t queue;
8407 cmd_5tuple_filter_parsed(void *parsed_result,
8408 __attribute__((unused)) struct cmdline *cl,
8409 __attribute__((unused)) void *data)
8411 struct rte_eth_ntuple_filter filter;
8412 struct cmd_5tuple_filter_result *res = parsed_result;
8415 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8417 printf("ntuple filter is not supported on port %u.\n",
8422 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8424 filter.flags = RTE_5TUPLE_FLAGS;
8425 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8426 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8427 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8428 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8429 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8430 filter.proto = res->protocol_value;
8431 filter.priority = res->priority_value;
8432 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8433 printf("nonzero tcp_flags is only meaningful"
8434 " when protocol is TCP.\n");
8437 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8438 printf("invalid TCP flags.\n");
8442 if (res->tcp_flags_value != 0) {
8443 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8444 filter.tcp_flags = res->tcp_flags_value;
8447 if (res->dst_ip_value.family == AF_INET)
8448 /* no need to convert, already big endian. */
8449 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8451 if (filter.dst_ip_mask == 0) {
8452 printf("can not support ipv6 involved compare.\n");
8458 if (res->src_ip_value.family == AF_INET)
8459 /* no need to convert, already big endian. */
8460 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8462 if (filter.src_ip_mask == 0) {
8463 printf("can not support ipv6 involved compare.\n");
8468 /* need convert to big endian. */
8469 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8470 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8471 filter.queue = res->queue_id;
8473 if (!strcmp(res->ops, "add"))
8474 ret = rte_eth_dev_filter_ctrl(res->port_id,
8475 RTE_ETH_FILTER_NTUPLE,
8479 ret = rte_eth_dev_filter_ctrl(res->port_id,
8480 RTE_ETH_FILTER_NTUPLE,
8481 RTE_ETH_FILTER_DELETE,
8484 printf("5tuple filter programming error: (%s)\n",
8488 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8489 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8490 filter, "5tuple_filter");
8491 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8492 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8494 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8495 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8497 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8498 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8500 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8501 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8503 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8504 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8506 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8507 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8509 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8510 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8511 dst_port, "dst_port");
8512 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8513 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8514 dst_port_value, UINT16);
8515 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8516 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8517 src_port, "src_port");
8518 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8519 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8520 src_port_value, UINT16);
8521 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8522 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8523 protocol, "protocol");
8524 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8525 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8526 protocol_value, UINT8);
8527 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8528 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8530 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8531 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8533 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8534 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8535 tcp_flags, "tcp_flags");
8536 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8537 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8538 tcp_flags_value, UINT8);
8539 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8540 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8541 priority, "priority");
8542 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8543 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8544 priority_value, UINT8);
8545 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8546 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8548 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8549 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8552 cmdline_parse_inst_t cmd_5tuple_filter = {
8553 .f = cmd_5tuple_filter_parsed,
8555 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8556 "src_ip <value> dst_port <value> src_port <value> "
8557 "protocol <value> mask <value> tcp_flags <value> "
8558 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8560 (void *)&cmd_5tuple_filter_filter,
8561 (void *)&cmd_5tuple_filter_port_id,
8562 (void *)&cmd_5tuple_filter_ops,
8563 (void *)&cmd_5tuple_filter_dst_ip,
8564 (void *)&cmd_5tuple_filter_dst_ip_value,
8565 (void *)&cmd_5tuple_filter_src_ip,
8566 (void *)&cmd_5tuple_filter_src_ip_value,
8567 (void *)&cmd_5tuple_filter_dst_port,
8568 (void *)&cmd_5tuple_filter_dst_port_value,
8569 (void *)&cmd_5tuple_filter_src_port,
8570 (void *)&cmd_5tuple_filter_src_port_value,
8571 (void *)&cmd_5tuple_filter_protocol,
8572 (void *)&cmd_5tuple_filter_protocol_value,
8573 (void *)&cmd_5tuple_filter_mask,
8574 (void *)&cmd_5tuple_filter_mask_value,
8575 (void *)&cmd_5tuple_filter_tcp_flags,
8576 (void *)&cmd_5tuple_filter_tcp_flags_value,
8577 (void *)&cmd_5tuple_filter_priority,
8578 (void *)&cmd_5tuple_filter_priority_value,
8579 (void *)&cmd_5tuple_filter_queue,
8580 (void *)&cmd_5tuple_filter_queue_id,
8585 /* *** ADD/REMOVE A flex FILTER *** */
8586 struct cmd_flex_filter_result {
8587 cmdline_fixed_string_t filter;
8588 cmdline_fixed_string_t ops;
8590 cmdline_fixed_string_t len;
8592 cmdline_fixed_string_t bytes;
8593 cmdline_fixed_string_t bytes_value;
8594 cmdline_fixed_string_t mask;
8595 cmdline_fixed_string_t mask_value;
8596 cmdline_fixed_string_t priority;
8597 uint8_t priority_value;
8598 cmdline_fixed_string_t queue;
8602 static int xdigit2val(unsigned char c)
8607 else if (isupper(c))
8615 cmd_flex_filter_parsed(void *parsed_result,
8616 __attribute__((unused)) struct cmdline *cl,
8617 __attribute__((unused)) void *data)
8620 struct rte_eth_flex_filter filter;
8621 struct cmd_flex_filter_result *res = parsed_result;
8622 char *bytes_ptr, *mask_ptr;
8623 uint16_t len, i, j = 0;
8628 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8629 printf("the len exceed the max length 128\n");
8632 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8633 filter.len = res->len_value;
8634 filter.priority = res->priority_value;
8635 filter.queue = res->queue_id;
8636 bytes_ptr = res->bytes_value;
8637 mask_ptr = res->mask_value;
8639 /* translate bytes string to array. */
8640 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8641 (bytes_ptr[1] == 'X')))
8643 len = strnlen(bytes_ptr, res->len_value * 2);
8644 if (len == 0 || (len % 8 != 0)) {
8645 printf("please check len and bytes input\n");
8648 for (i = 0; i < len; i++) {
8650 if (isxdigit(c) == 0) {
8651 /* invalid characters. */
8652 printf("invalid input\n");
8655 val = xdigit2val(c);
8658 filter.bytes[j] = byte;
8659 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8666 /* translate mask string to uint8_t array. */
8667 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8668 (mask_ptr[1] == 'X')))
8670 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8672 printf("invalid input\n");
8677 for (i = 0; i < len; i++) {
8679 if (isxdigit(c) == 0) {
8680 /* invalid characters. */
8681 printf("invalid input\n");
8684 val = xdigit2val(c);
8687 filter.mask[j] = byte;
8688 printf("mask[%d]:%02x ", j, filter.mask[j]);
8696 if (!strcmp(res->ops, "add"))
8697 ret = rte_eth_dev_filter_ctrl(res->port_id,
8698 RTE_ETH_FILTER_FLEXIBLE,
8702 ret = rte_eth_dev_filter_ctrl(res->port_id,
8703 RTE_ETH_FILTER_FLEXIBLE,
8704 RTE_ETH_FILTER_DELETE,
8708 printf("flex filter setting error: (%s)\n", strerror(-ret));
8711 cmdline_parse_token_string_t cmd_flex_filter_filter =
8712 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8713 filter, "flex_filter");
8714 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8715 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8717 cmdline_parse_token_string_t cmd_flex_filter_ops =
8718 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8720 cmdline_parse_token_string_t cmd_flex_filter_len =
8721 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8723 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8724 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8726 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8727 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8729 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8730 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8732 cmdline_parse_token_string_t cmd_flex_filter_mask =
8733 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8735 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8736 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8738 cmdline_parse_token_string_t cmd_flex_filter_priority =
8739 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8740 priority, "priority");
8741 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8742 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8743 priority_value, UINT8);
8744 cmdline_parse_token_string_t cmd_flex_filter_queue =
8745 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8747 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8748 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8750 cmdline_parse_inst_t cmd_flex_filter = {
8751 .f = cmd_flex_filter_parsed,
8753 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8754 "<value> mask <value> priority <value> queue <queue_id>: "
8755 "Add/Del a flex filter",
8757 (void *)&cmd_flex_filter_filter,
8758 (void *)&cmd_flex_filter_port_id,
8759 (void *)&cmd_flex_filter_ops,
8760 (void *)&cmd_flex_filter_len,
8761 (void *)&cmd_flex_filter_len_value,
8762 (void *)&cmd_flex_filter_bytes,
8763 (void *)&cmd_flex_filter_bytes_value,
8764 (void *)&cmd_flex_filter_mask,
8765 (void *)&cmd_flex_filter_mask_value,
8766 (void *)&cmd_flex_filter_priority,
8767 (void *)&cmd_flex_filter_priority_value,
8768 (void *)&cmd_flex_filter_queue,
8769 (void *)&cmd_flex_filter_queue_id,
8774 /* *** Filters Control *** */
8776 /* *** deal with ethertype filter *** */
8777 struct cmd_ethertype_filter_result {
8778 cmdline_fixed_string_t filter;
8780 cmdline_fixed_string_t ops;
8781 cmdline_fixed_string_t mac;
8782 struct ether_addr mac_addr;
8783 cmdline_fixed_string_t ethertype;
8784 uint16_t ethertype_value;
8785 cmdline_fixed_string_t drop;
8786 cmdline_fixed_string_t queue;
8790 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8791 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8792 filter, "ethertype_filter");
8793 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8794 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8796 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8797 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8799 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8800 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8801 mac, "mac_addr#mac_ignr");
8802 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8803 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8805 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8806 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8807 ethertype, "ethertype");
8808 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8809 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8810 ethertype_value, UINT16);
8811 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8812 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8814 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8815 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8817 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8818 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8822 cmd_ethertype_filter_parsed(void *parsed_result,
8823 __attribute__((unused)) struct cmdline *cl,
8824 __attribute__((unused)) void *data)
8826 struct cmd_ethertype_filter_result *res = parsed_result;
8827 struct rte_eth_ethertype_filter filter;
8830 ret = rte_eth_dev_filter_supported(res->port_id,
8831 RTE_ETH_FILTER_ETHERTYPE);
8833 printf("ethertype filter is not supported on port %u.\n",
8838 memset(&filter, 0, sizeof(filter));
8839 if (!strcmp(res->mac, "mac_addr")) {
8840 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8841 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8842 sizeof(struct ether_addr));
8844 if (!strcmp(res->drop, "drop"))
8845 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8846 filter.ether_type = res->ethertype_value;
8847 filter.queue = res->queue_id;
8849 if (!strcmp(res->ops, "add"))
8850 ret = rte_eth_dev_filter_ctrl(res->port_id,
8851 RTE_ETH_FILTER_ETHERTYPE,
8855 ret = rte_eth_dev_filter_ctrl(res->port_id,
8856 RTE_ETH_FILTER_ETHERTYPE,
8857 RTE_ETH_FILTER_DELETE,
8860 printf("ethertype filter programming error: (%s)\n",
8864 cmdline_parse_inst_t cmd_ethertype_filter = {
8865 .f = cmd_ethertype_filter_parsed,
8867 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8868 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8869 "Add or delete an ethertype filter entry",
8871 (void *)&cmd_ethertype_filter_filter,
8872 (void *)&cmd_ethertype_filter_port_id,
8873 (void *)&cmd_ethertype_filter_ops,
8874 (void *)&cmd_ethertype_filter_mac,
8875 (void *)&cmd_ethertype_filter_mac_addr,
8876 (void *)&cmd_ethertype_filter_ethertype,
8877 (void *)&cmd_ethertype_filter_ethertype_value,
8878 (void *)&cmd_ethertype_filter_drop,
8879 (void *)&cmd_ethertype_filter_queue,
8880 (void *)&cmd_ethertype_filter_queue_id,
8885 /* *** deal with flow director filter *** */
8886 struct cmd_flow_director_result {
8887 cmdline_fixed_string_t flow_director_filter;
8889 cmdline_fixed_string_t mode;
8890 cmdline_fixed_string_t mode_value;
8891 cmdline_fixed_string_t ops;
8892 cmdline_fixed_string_t flow;
8893 cmdline_fixed_string_t flow_type;
8894 cmdline_fixed_string_t ether;
8895 uint16_t ether_type;
8896 cmdline_fixed_string_t src;
8897 cmdline_ipaddr_t ip_src;
8899 cmdline_fixed_string_t dst;
8900 cmdline_ipaddr_t ip_dst;
8902 cmdline_fixed_string_t verify_tag;
8903 uint32_t verify_tag_value;
8904 cmdline_ipaddr_t tos;
8906 cmdline_ipaddr_t proto;
8907 uint8_t proto_value;
8908 cmdline_ipaddr_t ttl;
8910 cmdline_fixed_string_t vlan;
8911 uint16_t vlan_value;
8912 cmdline_fixed_string_t flexbytes;
8913 cmdline_fixed_string_t flexbytes_value;
8914 cmdline_fixed_string_t pf_vf;
8915 cmdline_fixed_string_t drop;
8916 cmdline_fixed_string_t queue;
8918 cmdline_fixed_string_t fd_id;
8919 uint32_t fd_id_value;
8920 cmdline_fixed_string_t mac;
8921 struct ether_addr mac_addr;
8922 cmdline_fixed_string_t tunnel;
8923 cmdline_fixed_string_t tunnel_type;
8924 cmdline_fixed_string_t tunnel_id;
8925 uint32_t tunnel_id_value;
8929 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8932 const char *p, *p0 = q_arg;
8934 unsigned long int_fld;
8935 char *str_fld[max_num];
8940 p = strchr(p0, '(');
8944 p0 = strchr(p, ')');
8949 if (size >= sizeof(s))
8952 snprintf(s, sizeof(s), "%.*s", size, p);
8953 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8954 if (ret < 0 || ret > max_num)
8956 for (i = 0; i < ret; i++) {
8958 int_fld = strtoul(str_fld[i], &end, 0);
8959 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8961 flexbytes[i] = (uint8_t)int_fld;
8967 str2flowtype(char *string)
8970 static const struct {
8973 } flowtype_str[] = {
8974 {"raw", RTE_ETH_FLOW_RAW},
8975 {"ipv4", RTE_ETH_FLOW_IPV4},
8976 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8977 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8978 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8979 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8980 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8981 {"ipv6", RTE_ETH_FLOW_IPV6},
8982 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8983 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8984 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8985 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8986 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8987 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8990 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8991 if (!strcmp(flowtype_str[i].str, string))
8992 return flowtype_str[i].type;
8994 return RTE_ETH_FLOW_UNKNOWN;
8997 static enum rte_eth_fdir_tunnel_type
8998 str2fdir_tunneltype(char *string)
9002 static const struct {
9004 enum rte_eth_fdir_tunnel_type type;
9005 } tunneltype_str[] = {
9006 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9007 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9010 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9011 if (!strcmp(tunneltype_str[i].str, string))
9012 return tunneltype_str[i].type;
9014 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9017 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9019 if ((ip_addr).family == AF_INET) \
9020 (ip) = (ip_addr).addr.ipv4.s_addr; \
9022 printf("invalid parameter.\n"); \
9027 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9029 if ((ip_addr).family == AF_INET6) \
9030 (void)rte_memcpy(&(ip), \
9031 &((ip_addr).addr.ipv6), \
9032 sizeof(struct in6_addr)); \
9034 printf("invalid parameter.\n"); \
9040 cmd_flow_director_filter_parsed(void *parsed_result,
9041 __attribute__((unused)) struct cmdline *cl,
9042 __attribute__((unused)) void *data)
9044 struct cmd_flow_director_result *res = parsed_result;
9045 struct rte_eth_fdir_filter entry;
9046 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9048 unsigned long vf_id;
9051 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9053 printf("flow director is not supported on port %u.\n",
9057 memset(flexbytes, 0, sizeof(flexbytes));
9058 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9060 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9061 if (strcmp(res->mode_value, "MAC-VLAN")) {
9062 printf("Please set mode to MAC-VLAN.\n");
9065 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9066 if (strcmp(res->mode_value, "Tunnel")) {
9067 printf("Please set mode to Tunnel.\n");
9071 if (strcmp(res->mode_value, "IP")) {
9072 printf("Please set mode to IP.\n");
9075 entry.input.flow_type = str2flowtype(res->flow_type);
9078 ret = parse_flexbytes(res->flexbytes_value,
9080 RTE_ETH_FDIR_MAX_FLEXLEN);
9082 printf("error: Cannot parse flexbytes input.\n");
9086 switch (entry.input.flow_type) {
9087 case RTE_ETH_FLOW_FRAG_IPV4:
9088 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9089 entry.input.flow.ip4_flow.proto = res->proto_value;
9091 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9092 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9093 IPV4_ADDR_TO_UINT(res->ip_dst,
9094 entry.input.flow.ip4_flow.dst_ip);
9095 IPV4_ADDR_TO_UINT(res->ip_src,
9096 entry.input.flow.ip4_flow.src_ip);
9097 entry.input.flow.ip4_flow.tos = res->tos_value;
9098 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9099 /* need convert to big endian. */
9100 entry.input.flow.udp4_flow.dst_port =
9101 rte_cpu_to_be_16(res->port_dst);
9102 entry.input.flow.udp4_flow.src_port =
9103 rte_cpu_to_be_16(res->port_src);
9105 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9106 IPV4_ADDR_TO_UINT(res->ip_dst,
9107 entry.input.flow.sctp4_flow.ip.dst_ip);
9108 IPV4_ADDR_TO_UINT(res->ip_src,
9109 entry.input.flow.sctp4_flow.ip.src_ip);
9110 entry.input.flow.ip4_flow.tos = res->tos_value;
9111 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9112 /* need convert to big endian. */
9113 entry.input.flow.sctp4_flow.dst_port =
9114 rte_cpu_to_be_16(res->port_dst);
9115 entry.input.flow.sctp4_flow.src_port =
9116 rte_cpu_to_be_16(res->port_src);
9117 entry.input.flow.sctp4_flow.verify_tag =
9118 rte_cpu_to_be_32(res->verify_tag_value);
9120 case RTE_ETH_FLOW_FRAG_IPV6:
9121 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9122 entry.input.flow.ipv6_flow.proto = res->proto_value;
9124 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9125 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9126 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9127 entry.input.flow.ipv6_flow.dst_ip);
9128 IPV6_ADDR_TO_ARRAY(res->ip_src,
9129 entry.input.flow.ipv6_flow.src_ip);
9130 entry.input.flow.ipv6_flow.tc = res->tos_value;
9131 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9132 /* need convert to big endian. */
9133 entry.input.flow.udp6_flow.dst_port =
9134 rte_cpu_to_be_16(res->port_dst);
9135 entry.input.flow.udp6_flow.src_port =
9136 rte_cpu_to_be_16(res->port_src);
9138 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9139 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9140 entry.input.flow.sctp6_flow.ip.dst_ip);
9141 IPV6_ADDR_TO_ARRAY(res->ip_src,
9142 entry.input.flow.sctp6_flow.ip.src_ip);
9143 entry.input.flow.ipv6_flow.tc = res->tos_value;
9144 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9145 /* need convert to big endian. */
9146 entry.input.flow.sctp6_flow.dst_port =
9147 rte_cpu_to_be_16(res->port_dst);
9148 entry.input.flow.sctp6_flow.src_port =
9149 rte_cpu_to_be_16(res->port_src);
9150 entry.input.flow.sctp6_flow.verify_tag =
9151 rte_cpu_to_be_32(res->verify_tag_value);
9153 case RTE_ETH_FLOW_L2_PAYLOAD:
9154 entry.input.flow.l2_flow.ether_type =
9155 rte_cpu_to_be_16(res->ether_type);
9161 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
9162 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
9164 sizeof(struct ether_addr));
9166 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9167 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
9169 sizeof(struct ether_addr));
9170 entry.input.flow.tunnel_flow.tunnel_type =
9171 str2fdir_tunneltype(res->tunnel_type);
9172 entry.input.flow.tunnel_flow.tunnel_id =
9173 rte_cpu_to_be_32(res->tunnel_id_value);
9176 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
9178 RTE_ETH_FDIR_MAX_FLEXLEN);
9180 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
9182 entry.action.flex_off = 0; /*use 0 by default */
9183 if (!strcmp(res->drop, "drop"))
9184 entry.action.behavior = RTE_ETH_FDIR_REJECT;
9186 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
9188 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
9189 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
9190 if (!strcmp(res->pf_vf, "pf"))
9191 entry.input.flow_ext.is_vf = 0;
9192 else if (!strncmp(res->pf_vf, "vf", 2)) {
9193 struct rte_eth_dev_info dev_info;
9195 memset(&dev_info, 0, sizeof(dev_info));
9196 rte_eth_dev_info_get(res->port_id, &dev_info);
9198 vf_id = strtoul(res->pf_vf + 2, &end, 10);
9199 if (errno != 0 || *end != '\0' ||
9200 vf_id >= dev_info.max_vfs) {
9201 printf("invalid parameter %s.\n", res->pf_vf);
9204 entry.input.flow_ext.is_vf = 1;
9205 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
9207 printf("invalid parameter %s.\n", res->pf_vf);
9212 /* set to report FD ID by default */
9213 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
9214 entry.action.rx_queue = res->queue_id;
9215 entry.soft_id = res->fd_id_value;
9216 if (!strcmp(res->ops, "add"))
9217 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9218 RTE_ETH_FILTER_ADD, &entry);
9219 else if (!strcmp(res->ops, "del"))
9220 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9221 RTE_ETH_FILTER_DELETE, &entry);
9223 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9224 RTE_ETH_FILTER_UPDATE, &entry);
9226 printf("flow director programming error: (%s)\n",
9230 cmdline_parse_token_string_t cmd_flow_director_filter =
9231 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9232 flow_director_filter, "flow_director_filter");
9233 cmdline_parse_token_num_t cmd_flow_director_port_id =
9234 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9236 cmdline_parse_token_string_t cmd_flow_director_ops =
9237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9238 ops, "add#del#update");
9239 cmdline_parse_token_string_t cmd_flow_director_flow =
9240 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9242 cmdline_parse_token_string_t cmd_flow_director_flow_type =
9243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9244 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9245 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
9246 cmdline_parse_token_string_t cmd_flow_director_ether =
9247 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9249 cmdline_parse_token_num_t cmd_flow_director_ether_type =
9250 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9251 ether_type, UINT16);
9252 cmdline_parse_token_string_t cmd_flow_director_src =
9253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9255 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
9256 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9258 cmdline_parse_token_num_t cmd_flow_director_port_src =
9259 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9261 cmdline_parse_token_string_t cmd_flow_director_dst =
9262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9264 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
9265 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9267 cmdline_parse_token_num_t cmd_flow_director_port_dst =
9268 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9270 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
9271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9272 verify_tag, "verify_tag");
9273 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
9274 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9275 verify_tag_value, UINT32);
9276 cmdline_parse_token_string_t cmd_flow_director_tos =
9277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9279 cmdline_parse_token_num_t cmd_flow_director_tos_value =
9280 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9282 cmdline_parse_token_string_t cmd_flow_director_proto =
9283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9285 cmdline_parse_token_num_t cmd_flow_director_proto_value =
9286 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9287 proto_value, UINT8);
9288 cmdline_parse_token_string_t cmd_flow_director_ttl =
9289 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9291 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
9292 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9294 cmdline_parse_token_string_t cmd_flow_director_vlan =
9295 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9297 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
9298 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9299 vlan_value, UINT16);
9300 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
9301 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9302 flexbytes, "flexbytes");
9303 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
9304 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9305 flexbytes_value, NULL);
9306 cmdline_parse_token_string_t cmd_flow_director_drop =
9307 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9309 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
9310 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9312 cmdline_parse_token_string_t cmd_flow_director_queue =
9313 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9315 cmdline_parse_token_num_t cmd_flow_director_queue_id =
9316 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9318 cmdline_parse_token_string_t cmd_flow_director_fd_id =
9319 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9321 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
9322 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9323 fd_id_value, UINT32);
9325 cmdline_parse_token_string_t cmd_flow_director_mode =
9326 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9328 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
9329 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9331 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9332 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9333 mode_value, "MAC-VLAN");
9334 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9335 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9336 mode_value, "Tunnel");
9337 cmdline_parse_token_string_t cmd_flow_director_mac =
9338 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9340 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9341 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9343 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9344 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9346 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9347 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9348 tunnel_type, "NVGRE#VxLAN");
9349 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9350 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9351 tunnel_id, "tunnel-id");
9352 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9353 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9354 tunnel_id_value, UINT32);
9356 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9357 .f = cmd_flow_director_filter_parsed,
9359 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9360 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9361 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9362 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9363 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9364 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9365 "fd_id <fd_id_value>: "
9366 "Add or delete an ip flow director entry on NIC",
9368 (void *)&cmd_flow_director_filter,
9369 (void *)&cmd_flow_director_port_id,
9370 (void *)&cmd_flow_director_mode,
9371 (void *)&cmd_flow_director_mode_ip,
9372 (void *)&cmd_flow_director_ops,
9373 (void *)&cmd_flow_director_flow,
9374 (void *)&cmd_flow_director_flow_type,
9375 (void *)&cmd_flow_director_src,
9376 (void *)&cmd_flow_director_ip_src,
9377 (void *)&cmd_flow_director_dst,
9378 (void *)&cmd_flow_director_ip_dst,
9379 (void *)&cmd_flow_director_tos,
9380 (void *)&cmd_flow_director_tos_value,
9381 (void *)&cmd_flow_director_proto,
9382 (void *)&cmd_flow_director_proto_value,
9383 (void *)&cmd_flow_director_ttl,
9384 (void *)&cmd_flow_director_ttl_value,
9385 (void *)&cmd_flow_director_vlan,
9386 (void *)&cmd_flow_director_vlan_value,
9387 (void *)&cmd_flow_director_flexbytes,
9388 (void *)&cmd_flow_director_flexbytes_value,
9389 (void *)&cmd_flow_director_drop,
9390 (void *)&cmd_flow_director_pf_vf,
9391 (void *)&cmd_flow_director_queue,
9392 (void *)&cmd_flow_director_queue_id,
9393 (void *)&cmd_flow_director_fd_id,
9394 (void *)&cmd_flow_director_fd_id_value,
9399 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9400 .f = cmd_flow_director_filter_parsed,
9402 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9403 "director entry on NIC",
9405 (void *)&cmd_flow_director_filter,
9406 (void *)&cmd_flow_director_port_id,
9407 (void *)&cmd_flow_director_mode,
9408 (void *)&cmd_flow_director_mode_ip,
9409 (void *)&cmd_flow_director_ops,
9410 (void *)&cmd_flow_director_flow,
9411 (void *)&cmd_flow_director_flow_type,
9412 (void *)&cmd_flow_director_src,
9413 (void *)&cmd_flow_director_ip_src,
9414 (void *)&cmd_flow_director_port_src,
9415 (void *)&cmd_flow_director_dst,
9416 (void *)&cmd_flow_director_ip_dst,
9417 (void *)&cmd_flow_director_port_dst,
9418 (void *)&cmd_flow_director_tos,
9419 (void *)&cmd_flow_director_tos_value,
9420 (void *)&cmd_flow_director_ttl,
9421 (void *)&cmd_flow_director_ttl_value,
9422 (void *)&cmd_flow_director_vlan,
9423 (void *)&cmd_flow_director_vlan_value,
9424 (void *)&cmd_flow_director_flexbytes,
9425 (void *)&cmd_flow_director_flexbytes_value,
9426 (void *)&cmd_flow_director_drop,
9427 (void *)&cmd_flow_director_pf_vf,
9428 (void *)&cmd_flow_director_queue,
9429 (void *)&cmd_flow_director_queue_id,
9430 (void *)&cmd_flow_director_fd_id,
9431 (void *)&cmd_flow_director_fd_id_value,
9436 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9437 .f = cmd_flow_director_filter_parsed,
9439 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9440 "director entry on NIC",
9442 (void *)&cmd_flow_director_filter,
9443 (void *)&cmd_flow_director_port_id,
9444 (void *)&cmd_flow_director_mode,
9445 (void *)&cmd_flow_director_mode_ip,
9446 (void *)&cmd_flow_director_ops,
9447 (void *)&cmd_flow_director_flow,
9448 (void *)&cmd_flow_director_flow_type,
9449 (void *)&cmd_flow_director_src,
9450 (void *)&cmd_flow_director_ip_src,
9451 (void *)&cmd_flow_director_port_dst,
9452 (void *)&cmd_flow_director_dst,
9453 (void *)&cmd_flow_director_ip_dst,
9454 (void *)&cmd_flow_director_port_dst,
9455 (void *)&cmd_flow_director_verify_tag,
9456 (void *)&cmd_flow_director_verify_tag_value,
9457 (void *)&cmd_flow_director_tos,
9458 (void *)&cmd_flow_director_tos_value,
9459 (void *)&cmd_flow_director_ttl,
9460 (void *)&cmd_flow_director_ttl_value,
9461 (void *)&cmd_flow_director_vlan,
9462 (void *)&cmd_flow_director_vlan_value,
9463 (void *)&cmd_flow_director_flexbytes,
9464 (void *)&cmd_flow_director_flexbytes_value,
9465 (void *)&cmd_flow_director_drop,
9466 (void *)&cmd_flow_director_pf_vf,
9467 (void *)&cmd_flow_director_queue,
9468 (void *)&cmd_flow_director_queue_id,
9469 (void *)&cmd_flow_director_fd_id,
9470 (void *)&cmd_flow_director_fd_id_value,
9475 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9476 .f = cmd_flow_director_filter_parsed,
9478 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9479 "director entry on NIC",
9481 (void *)&cmd_flow_director_filter,
9482 (void *)&cmd_flow_director_port_id,
9483 (void *)&cmd_flow_director_mode,
9484 (void *)&cmd_flow_director_mode_ip,
9485 (void *)&cmd_flow_director_ops,
9486 (void *)&cmd_flow_director_flow,
9487 (void *)&cmd_flow_director_flow_type,
9488 (void *)&cmd_flow_director_ether,
9489 (void *)&cmd_flow_director_ether_type,
9490 (void *)&cmd_flow_director_flexbytes,
9491 (void *)&cmd_flow_director_flexbytes_value,
9492 (void *)&cmd_flow_director_drop,
9493 (void *)&cmd_flow_director_pf_vf,
9494 (void *)&cmd_flow_director_queue,
9495 (void *)&cmd_flow_director_queue_id,
9496 (void *)&cmd_flow_director_fd_id,
9497 (void *)&cmd_flow_director_fd_id_value,
9502 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9503 .f = cmd_flow_director_filter_parsed,
9505 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9506 "director entry on NIC",
9508 (void *)&cmd_flow_director_filter,
9509 (void *)&cmd_flow_director_port_id,
9510 (void *)&cmd_flow_director_mode,
9511 (void *)&cmd_flow_director_mode_mac_vlan,
9512 (void *)&cmd_flow_director_ops,
9513 (void *)&cmd_flow_director_mac,
9514 (void *)&cmd_flow_director_mac_addr,
9515 (void *)&cmd_flow_director_vlan,
9516 (void *)&cmd_flow_director_vlan_value,
9517 (void *)&cmd_flow_director_flexbytes,
9518 (void *)&cmd_flow_director_flexbytes_value,
9519 (void *)&cmd_flow_director_drop,
9520 (void *)&cmd_flow_director_queue,
9521 (void *)&cmd_flow_director_queue_id,
9522 (void *)&cmd_flow_director_fd_id,
9523 (void *)&cmd_flow_director_fd_id_value,
9528 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9529 .f = cmd_flow_director_filter_parsed,
9531 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9532 "director entry on NIC",
9534 (void *)&cmd_flow_director_filter,
9535 (void *)&cmd_flow_director_port_id,
9536 (void *)&cmd_flow_director_mode,
9537 (void *)&cmd_flow_director_mode_tunnel,
9538 (void *)&cmd_flow_director_ops,
9539 (void *)&cmd_flow_director_mac,
9540 (void *)&cmd_flow_director_mac_addr,
9541 (void *)&cmd_flow_director_vlan,
9542 (void *)&cmd_flow_director_vlan_value,
9543 (void *)&cmd_flow_director_tunnel,
9544 (void *)&cmd_flow_director_tunnel_type,
9545 (void *)&cmd_flow_director_tunnel_id,
9546 (void *)&cmd_flow_director_tunnel_id_value,
9547 (void *)&cmd_flow_director_flexbytes,
9548 (void *)&cmd_flow_director_flexbytes_value,
9549 (void *)&cmd_flow_director_drop,
9550 (void *)&cmd_flow_director_queue,
9551 (void *)&cmd_flow_director_queue_id,
9552 (void *)&cmd_flow_director_fd_id,
9553 (void *)&cmd_flow_director_fd_id_value,
9558 struct cmd_flush_flow_director_result {
9559 cmdline_fixed_string_t flush_flow_director;
9563 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9564 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9565 flush_flow_director, "flush_flow_director");
9566 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9567 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9571 cmd_flush_flow_director_parsed(void *parsed_result,
9572 __attribute__((unused)) struct cmdline *cl,
9573 __attribute__((unused)) void *data)
9575 struct cmd_flow_director_result *res = parsed_result;
9578 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9580 printf("flow director is not supported on port %u.\n",
9585 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9586 RTE_ETH_FILTER_FLUSH, NULL);
9588 printf("flow director table flushing error: (%s)\n",
9592 cmdline_parse_inst_t cmd_flush_flow_director = {
9593 .f = cmd_flush_flow_director_parsed,
9595 .help_str = "flush_flow_director <port_id>: "
9596 "Flush all flow director entries of a device on NIC",
9598 (void *)&cmd_flush_flow_director_flush,
9599 (void *)&cmd_flush_flow_director_port_id,
9604 /* *** deal with flow director mask *** */
9605 struct cmd_flow_director_mask_result {
9606 cmdline_fixed_string_t flow_director_mask;
9608 cmdline_fixed_string_t mode;
9609 cmdline_fixed_string_t mode_value;
9610 cmdline_fixed_string_t vlan;
9612 cmdline_fixed_string_t src_mask;
9613 cmdline_ipaddr_t ipv4_src;
9614 cmdline_ipaddr_t ipv6_src;
9616 cmdline_fixed_string_t dst_mask;
9617 cmdline_ipaddr_t ipv4_dst;
9618 cmdline_ipaddr_t ipv6_dst;
9620 cmdline_fixed_string_t mac;
9621 uint8_t mac_addr_byte_mask;
9622 cmdline_fixed_string_t tunnel_id;
9623 uint32_t tunnel_id_mask;
9624 cmdline_fixed_string_t tunnel_type;
9625 uint8_t tunnel_type_mask;
9629 cmd_flow_director_mask_parsed(void *parsed_result,
9630 __attribute__((unused)) struct cmdline *cl,
9631 __attribute__((unused)) void *data)
9633 struct cmd_flow_director_mask_result *res = parsed_result;
9634 struct rte_eth_fdir_masks *mask;
9635 struct rte_port *port;
9637 if (res->port_id > nb_ports) {
9638 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9642 port = &ports[res->port_id];
9643 /** Check if the port is not started **/
9644 if (port->port_status != RTE_PORT_STOPPED) {
9645 printf("Please stop port %d first\n", res->port_id);
9649 mask = &port->dev_conf.fdir_conf.mask;
9651 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9652 if (strcmp(res->mode_value, "MAC-VLAN")) {
9653 printf("Please set mode to MAC-VLAN.\n");
9657 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9658 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9659 if (strcmp(res->mode_value, "Tunnel")) {
9660 printf("Please set mode to Tunnel.\n");
9664 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9665 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9666 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9667 mask->tunnel_type_mask = res->tunnel_type_mask;
9669 if (strcmp(res->mode_value, "IP")) {
9670 printf("Please set mode to IP.\n");
9674 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9675 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9676 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9677 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9678 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9679 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9680 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9683 cmd_reconfig_device_queue(res->port_id, 1, 1);
9686 cmdline_parse_token_string_t cmd_flow_director_mask =
9687 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9688 flow_director_mask, "flow_director_mask");
9689 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9690 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9692 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9693 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9695 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9696 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9698 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9699 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9700 src_mask, "src_mask");
9701 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9702 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9704 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9705 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9707 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9708 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9710 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9711 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9712 dst_mask, "dst_mask");
9713 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9714 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9716 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9717 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9719 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9720 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9723 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9724 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9726 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9727 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9729 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9730 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9731 mode_value, "MAC-VLAN");
9732 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9733 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9734 mode_value, "Tunnel");
9735 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9736 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9738 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9739 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9740 mac_addr_byte_mask, UINT8);
9741 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9743 tunnel_type, "tunnel-type");
9744 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9745 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9746 tunnel_type_mask, UINT8);
9747 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9748 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9749 tunnel_id, "tunnel-id");
9750 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9751 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9752 tunnel_id_mask, UINT32);
9754 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9755 .f = cmd_flow_director_mask_parsed,
9757 .help_str = "flow_director_mask ... : "
9758 "Set IP mode flow director's mask on NIC",
9760 (void *)&cmd_flow_director_mask,
9761 (void *)&cmd_flow_director_mask_port_id,
9762 (void *)&cmd_flow_director_mask_mode,
9763 (void *)&cmd_flow_director_mask_mode_ip,
9764 (void *)&cmd_flow_director_mask_vlan,
9765 (void *)&cmd_flow_director_mask_vlan_value,
9766 (void *)&cmd_flow_director_mask_src,
9767 (void *)&cmd_flow_director_mask_ipv4_src,
9768 (void *)&cmd_flow_director_mask_ipv6_src,
9769 (void *)&cmd_flow_director_mask_port_src,
9770 (void *)&cmd_flow_director_mask_dst,
9771 (void *)&cmd_flow_director_mask_ipv4_dst,
9772 (void *)&cmd_flow_director_mask_ipv6_dst,
9773 (void *)&cmd_flow_director_mask_port_dst,
9778 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9779 .f = cmd_flow_director_mask_parsed,
9781 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9782 "flow director's mask on NIC",
9784 (void *)&cmd_flow_director_mask,
9785 (void *)&cmd_flow_director_mask_port_id,
9786 (void *)&cmd_flow_director_mask_mode,
9787 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9788 (void *)&cmd_flow_director_mask_vlan,
9789 (void *)&cmd_flow_director_mask_vlan_value,
9794 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9795 .f = cmd_flow_director_mask_parsed,
9797 .help_str = "flow_director_mask ... : Set tunnel mode "
9798 "flow director's mask on NIC",
9800 (void *)&cmd_flow_director_mask,
9801 (void *)&cmd_flow_director_mask_port_id,
9802 (void *)&cmd_flow_director_mask_mode,
9803 (void *)&cmd_flow_director_mask_mode_tunnel,
9804 (void *)&cmd_flow_director_mask_vlan,
9805 (void *)&cmd_flow_director_mask_vlan_value,
9806 (void *)&cmd_flow_director_mask_mac,
9807 (void *)&cmd_flow_director_mask_mac_value,
9808 (void *)&cmd_flow_director_mask_tunnel_type,
9809 (void *)&cmd_flow_director_mask_tunnel_type_value,
9810 (void *)&cmd_flow_director_mask_tunnel_id,
9811 (void *)&cmd_flow_director_mask_tunnel_id_value,
9816 /* *** deal with flow director mask on flexible payload *** */
9817 struct cmd_flow_director_flex_mask_result {
9818 cmdline_fixed_string_t flow_director_flexmask;
9820 cmdline_fixed_string_t flow;
9821 cmdline_fixed_string_t flow_type;
9822 cmdline_fixed_string_t mask;
9826 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9827 __attribute__((unused)) struct cmdline *cl,
9828 __attribute__((unused)) void *data)
9830 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9831 struct rte_eth_fdir_info fdir_info;
9832 struct rte_eth_fdir_flex_mask flex_mask;
9833 struct rte_port *port;
9834 uint32_t flow_type_mask;
9838 if (res->port_id > nb_ports) {
9839 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9843 port = &ports[res->port_id];
9844 /** Check if the port is not started **/
9845 if (port->port_status != RTE_PORT_STOPPED) {
9846 printf("Please stop port %d first\n", res->port_id);
9850 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9851 ret = parse_flexbytes(res->mask,
9853 RTE_ETH_FDIR_MAX_FLEXLEN);
9855 printf("error: Cannot parse mask input.\n");
9859 memset(&fdir_info, 0, sizeof(fdir_info));
9860 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9861 RTE_ETH_FILTER_INFO, &fdir_info);
9863 printf("Cannot get FDir filter info\n");
9867 if (!strcmp(res->flow_type, "none")) {
9868 /* means don't specify the flow type */
9869 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9870 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9871 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9872 0, sizeof(struct rte_eth_fdir_flex_mask));
9873 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9874 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9876 sizeof(struct rte_eth_fdir_flex_mask));
9877 cmd_reconfig_device_queue(res->port_id, 1, 1);
9880 flow_type_mask = fdir_info.flow_types_mask[0];
9881 if (!strcmp(res->flow_type, "all")) {
9882 if (!flow_type_mask) {
9883 printf("No flow type supported\n");
9886 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9887 if (flow_type_mask & (1 << i)) {
9888 flex_mask.flow_type = i;
9889 fdir_set_flex_mask(res->port_id, &flex_mask);
9892 cmd_reconfig_device_queue(res->port_id, 1, 1);
9895 flex_mask.flow_type = str2flowtype(res->flow_type);
9896 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9897 printf("Flow type %s not supported on port %d\n",
9898 res->flow_type, res->port_id);
9901 fdir_set_flex_mask(res->port_id, &flex_mask);
9902 cmd_reconfig_device_queue(res->port_id, 1, 1);
9905 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9906 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9907 flow_director_flexmask,
9908 "flow_director_flex_mask");
9909 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9910 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9912 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9913 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9915 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9917 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9918 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9919 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9920 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9923 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9924 .f = cmd_flow_director_flex_mask_parsed,
9926 .help_str = "flow_director_flex_mask ... : "
9927 "Set flow director's flex mask on NIC",
9929 (void *)&cmd_flow_director_flexmask,
9930 (void *)&cmd_flow_director_flexmask_port_id,
9931 (void *)&cmd_flow_director_flexmask_flow,
9932 (void *)&cmd_flow_director_flexmask_flow_type,
9933 (void *)&cmd_flow_director_flexmask_mask,
9938 /* *** deal with flow director flexible payload configuration *** */
9939 struct cmd_flow_director_flexpayload_result {
9940 cmdline_fixed_string_t flow_director_flexpayload;
9942 cmdline_fixed_string_t payload_layer;
9943 cmdline_fixed_string_t payload_cfg;
9947 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9950 const char *p, *p0 = q_arg;
9952 unsigned long int_fld;
9953 char *str_fld[max_num];
9958 p = strchr(p0, '(');
9962 p0 = strchr(p, ')');
9967 if (size >= sizeof(s))
9970 snprintf(s, sizeof(s), "%.*s", size, p);
9971 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9972 if (ret < 0 || ret > max_num)
9974 for (i = 0; i < ret; i++) {
9976 int_fld = strtoul(str_fld[i], &end, 0);
9977 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9979 offsets[i] = (uint16_t)int_fld;
9985 cmd_flow_director_flxpld_parsed(void *parsed_result,
9986 __attribute__((unused)) struct cmdline *cl,
9987 __attribute__((unused)) void *data)
9989 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9990 struct rte_eth_flex_payload_cfg flex_cfg;
9991 struct rte_port *port;
9994 if (res->port_id > nb_ports) {
9995 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9999 port = &ports[res->port_id];
10000 /** Check if the port is not started **/
10001 if (port->port_status != RTE_PORT_STOPPED) {
10002 printf("Please stop port %d first\n", res->port_id);
10006 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10008 if (!strcmp(res->payload_layer, "raw"))
10009 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10010 else if (!strcmp(res->payload_layer, "l2"))
10011 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10012 else if (!strcmp(res->payload_layer, "l3"))
10013 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10014 else if (!strcmp(res->payload_layer, "l4"))
10015 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10017 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10018 RTE_ETH_FDIR_MAX_FLEXLEN);
10020 printf("error: Cannot parse flex payload input.\n");
10024 fdir_set_flex_payload(res->port_id, &flex_cfg);
10025 cmd_reconfig_device_queue(res->port_id, 1, 1);
10028 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10029 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10030 flow_director_flexpayload,
10031 "flow_director_flex_payload");
10032 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10033 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10035 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10036 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10037 payload_layer, "raw#l2#l3#l4");
10038 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10039 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10040 payload_cfg, NULL);
10042 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10043 .f = cmd_flow_director_flxpld_parsed,
10045 .help_str = "flow_director_flexpayload ... : "
10046 "Set flow director's flex payload on NIC",
10048 (void *)&cmd_flow_director_flexpayload,
10049 (void *)&cmd_flow_director_flexpayload_port_id,
10050 (void *)&cmd_flow_director_flexpayload_payload_layer,
10051 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10056 /* Generic flow interface command. */
10057 extern cmdline_parse_inst_t cmd_flow;
10059 /* *** Classification Filters Control *** */
10060 /* *** Get symmetric hash enable per port *** */
10061 struct cmd_get_sym_hash_ena_per_port_result {
10062 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10067 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10068 __rte_unused struct cmdline *cl,
10069 __rte_unused void *data)
10071 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10072 struct rte_eth_hash_filter_info info;
10075 if (rte_eth_dev_filter_supported(res->port_id,
10076 RTE_ETH_FILTER_HASH) < 0) {
10077 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10082 memset(&info, 0, sizeof(info));
10083 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10084 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10085 RTE_ETH_FILTER_GET, &info);
10088 printf("Cannot get symmetric hash enable per port "
10089 "on port %u\n", res->port_id);
10093 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10094 "enabled" : "disabled", res->port_id);
10097 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10098 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10099 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10100 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10101 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10104 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10105 .f = cmd_get_sym_hash_per_port_parsed,
10107 .help_str = "get_sym_hash_ena_per_port <port_id>",
10109 (void *)&cmd_get_sym_hash_ena_per_port_all,
10110 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10115 /* *** Set symmetric hash enable per port *** */
10116 struct cmd_set_sym_hash_ena_per_port_result {
10117 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10118 cmdline_fixed_string_t enable;
10123 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10124 __rte_unused struct cmdline *cl,
10125 __rte_unused void *data)
10127 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10128 struct rte_eth_hash_filter_info info;
10131 if (rte_eth_dev_filter_supported(res->port_id,
10132 RTE_ETH_FILTER_HASH) < 0) {
10133 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10138 memset(&info, 0, sizeof(info));
10139 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10140 if (!strcmp(res->enable, "enable"))
10141 info.info.enable = 1;
10142 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10143 RTE_ETH_FILTER_SET, &info);
10145 printf("Cannot set symmetric hash enable per port on "
10146 "port %u\n", res->port_id);
10149 printf("Symmetric hash has been set to %s on port %u\n",
10150 res->enable, res->port_id);
10153 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
10154 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10155 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
10156 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
10157 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10159 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
10160 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10161 enable, "enable#disable");
10163 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
10164 .f = cmd_set_sym_hash_per_port_parsed,
10166 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
10168 (void *)&cmd_set_sym_hash_ena_per_port_all,
10169 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
10170 (void *)&cmd_set_sym_hash_ena_per_port_enable,
10175 /* Get global config of hash function */
10176 struct cmd_get_hash_global_config_result {
10177 cmdline_fixed_string_t get_hash_global_config;
10182 flowtype_to_str(uint16_t ftype)
10188 } ftype_table[] = {
10189 {"ipv4", RTE_ETH_FLOW_IPV4},
10190 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10191 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10192 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10193 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10194 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10195 {"ipv6", RTE_ETH_FLOW_IPV6},
10196 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10197 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10198 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10199 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10200 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10201 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10202 {"port", RTE_ETH_FLOW_PORT},
10203 {"vxlan", RTE_ETH_FLOW_VXLAN},
10204 {"geneve", RTE_ETH_FLOW_GENEVE},
10205 {"nvgre", RTE_ETH_FLOW_NVGRE},
10208 for (i = 0; i < RTE_DIM(ftype_table); i++) {
10209 if (ftype_table[i].ftype == ftype)
10210 return ftype_table[i].str;
10217 cmd_get_hash_global_config_parsed(void *parsed_result,
10218 __rte_unused struct cmdline *cl,
10219 __rte_unused void *data)
10221 struct cmd_get_hash_global_config_result *res = parsed_result;
10222 struct rte_eth_hash_filter_info info;
10223 uint32_t idx, offset;
10228 if (rte_eth_dev_filter_supported(res->port_id,
10229 RTE_ETH_FILTER_HASH) < 0) {
10230 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10235 memset(&info, 0, sizeof(info));
10236 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10237 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10238 RTE_ETH_FILTER_GET, &info);
10240 printf("Cannot get hash global configurations by port %d\n",
10245 switch (info.info.global_conf.hash_func) {
10246 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
10247 printf("Hash function is Toeplitz\n");
10249 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
10250 printf("Hash function is Simple XOR\n");
10253 printf("Unknown hash function\n");
10257 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
10258 idx = i / UINT32_BIT;
10259 offset = i % UINT32_BIT;
10260 if (!(info.info.global_conf.valid_bit_mask[idx] &
10263 str = flowtype_to_str(i);
10266 printf("Symmetric hash is %s globally for flow type %s "
10268 ((info.info.global_conf.sym_hash_enable_mask[idx] &
10269 (1UL << offset)) ? "enabled" : "disabled"), str,
10274 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
10275 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
10276 get_hash_global_config, "get_hash_global_config");
10277 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
10278 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
10281 cmdline_parse_inst_t cmd_get_hash_global_config = {
10282 .f = cmd_get_hash_global_config_parsed,
10284 .help_str = "get_hash_global_config <port_id>",
10286 (void *)&cmd_get_hash_global_config_all,
10287 (void *)&cmd_get_hash_global_config_port_id,
10292 /* Set global config of hash function */
10293 struct cmd_set_hash_global_config_result {
10294 cmdline_fixed_string_t set_hash_global_config;
10296 cmdline_fixed_string_t hash_func;
10297 cmdline_fixed_string_t flow_type;
10298 cmdline_fixed_string_t enable;
10302 cmd_set_hash_global_config_parsed(void *parsed_result,
10303 __rte_unused struct cmdline *cl,
10304 __rte_unused void *data)
10306 struct cmd_set_hash_global_config_result *res = parsed_result;
10307 struct rte_eth_hash_filter_info info;
10308 uint32_t ftype, idx, offset;
10311 if (rte_eth_dev_filter_supported(res->port_id,
10312 RTE_ETH_FILTER_HASH) < 0) {
10313 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10317 memset(&info, 0, sizeof(info));
10318 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10319 if (!strcmp(res->hash_func, "toeplitz"))
10320 info.info.global_conf.hash_func =
10321 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
10322 else if (!strcmp(res->hash_func, "simple_xor"))
10323 info.info.global_conf.hash_func =
10324 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
10325 else if (!strcmp(res->hash_func, "default"))
10326 info.info.global_conf.hash_func =
10327 RTE_ETH_HASH_FUNCTION_DEFAULT;
10329 ftype = str2flowtype(res->flow_type);
10330 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10331 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10332 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10333 if (!strcmp(res->enable, "enable"))
10334 info.info.global_conf.sym_hash_enable_mask[idx] |=
10336 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10337 RTE_ETH_FILTER_SET, &info);
10339 printf("Cannot set global hash configurations by port %d\n",
10342 printf("Global hash configurations have been set "
10343 "succcessfully by port %d\n", res->port_id);
10346 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10347 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10348 set_hash_global_config, "set_hash_global_config");
10349 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10350 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10352 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10353 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10354 hash_func, "toeplitz#simple_xor#default");
10355 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10356 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10358 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10359 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10360 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10361 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10362 enable, "enable#disable");
10364 cmdline_parse_inst_t cmd_set_hash_global_config = {
10365 .f = cmd_set_hash_global_config_parsed,
10367 .help_str = "set_hash_global_config <port_id> "
10368 "toeplitz|simple_xor|default "
10369 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10370 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10371 "l2_payload enable|disable",
10373 (void *)&cmd_set_hash_global_config_all,
10374 (void *)&cmd_set_hash_global_config_port_id,
10375 (void *)&cmd_set_hash_global_config_hash_func,
10376 (void *)&cmd_set_hash_global_config_flow_type,
10377 (void *)&cmd_set_hash_global_config_enable,
10382 /* Set hash input set */
10383 struct cmd_set_hash_input_set_result {
10384 cmdline_fixed_string_t set_hash_input_set;
10386 cmdline_fixed_string_t flow_type;
10387 cmdline_fixed_string_t inset_field;
10388 cmdline_fixed_string_t select;
10391 static enum rte_eth_input_set_field
10392 str2inset(char *string)
10396 static const struct {
10398 enum rte_eth_input_set_field inset;
10399 } inset_table[] = {
10400 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10401 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10402 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10403 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10404 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10405 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10406 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10407 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10408 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10409 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10410 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10411 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10412 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10413 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10414 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10415 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10416 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10417 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10418 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10419 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10420 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10421 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10422 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10423 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10424 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10425 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10426 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10427 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10428 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10429 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10430 {"none", RTE_ETH_INPUT_SET_NONE},
10433 for (i = 0; i < RTE_DIM(inset_table); i++) {
10434 if (!strcmp(string, inset_table[i].str))
10435 return inset_table[i].inset;
10438 return RTE_ETH_INPUT_SET_UNKNOWN;
10442 cmd_set_hash_input_set_parsed(void *parsed_result,
10443 __rte_unused struct cmdline *cl,
10444 __rte_unused void *data)
10446 struct cmd_set_hash_input_set_result *res = parsed_result;
10447 struct rte_eth_hash_filter_info info;
10449 memset(&info, 0, sizeof(info));
10450 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10451 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10452 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10453 info.info.input_set_conf.inset_size = 1;
10454 if (!strcmp(res->select, "select"))
10455 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10456 else if (!strcmp(res->select, "add"))
10457 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10458 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10459 RTE_ETH_FILTER_SET, &info);
10462 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10463 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10464 set_hash_input_set, "set_hash_input_set");
10465 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10466 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10468 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10469 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10471 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10472 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10473 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10474 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10476 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10477 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10478 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10479 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10480 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10482 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10483 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10484 select, "select#add");
10486 cmdline_parse_inst_t cmd_set_hash_input_set = {
10487 .f = cmd_set_hash_input_set_parsed,
10489 .help_str = "set_hash_input_set <port_id> "
10490 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10491 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10492 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10493 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10494 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10495 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10496 "fld-7th|fld-8th|none select|add",
10498 (void *)&cmd_set_hash_input_set_cmd,
10499 (void *)&cmd_set_hash_input_set_port_id,
10500 (void *)&cmd_set_hash_input_set_flow_type,
10501 (void *)&cmd_set_hash_input_set_field,
10502 (void *)&cmd_set_hash_input_set_select,
10507 /* Set flow director input set */
10508 struct cmd_set_fdir_input_set_result {
10509 cmdline_fixed_string_t set_fdir_input_set;
10511 cmdline_fixed_string_t flow_type;
10512 cmdline_fixed_string_t inset_field;
10513 cmdline_fixed_string_t select;
10517 cmd_set_fdir_input_set_parsed(void *parsed_result,
10518 __rte_unused struct cmdline *cl,
10519 __rte_unused void *data)
10521 struct cmd_set_fdir_input_set_result *res = parsed_result;
10522 struct rte_eth_fdir_filter_info info;
10524 memset(&info, 0, sizeof(info));
10525 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10526 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10527 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10528 info.info.input_set_conf.inset_size = 1;
10529 if (!strcmp(res->select, "select"))
10530 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10531 else if (!strcmp(res->select, "add"))
10532 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10533 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10534 RTE_ETH_FILTER_SET, &info);
10537 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10538 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10539 set_fdir_input_set, "set_fdir_input_set");
10540 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10541 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10543 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10544 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10546 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10547 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10548 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10549 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
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");
10556 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10557 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10558 select, "select#add");
10560 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10561 .f = cmd_set_fdir_input_set_parsed,
10563 .help_str = "set_fdir_input_set <port_id> "
10564 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10565 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10566 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10567 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10568 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10569 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10570 "sctp-veri-tag|none select|add",
10572 (void *)&cmd_set_fdir_input_set_cmd,
10573 (void *)&cmd_set_fdir_input_set_port_id,
10574 (void *)&cmd_set_fdir_input_set_flow_type,
10575 (void *)&cmd_set_fdir_input_set_field,
10576 (void *)&cmd_set_fdir_input_set_select,
10581 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10582 struct cmd_mcast_addr_result {
10583 cmdline_fixed_string_t mcast_addr_cmd;
10584 cmdline_fixed_string_t what;
10586 struct ether_addr mc_addr;
10589 static void cmd_mcast_addr_parsed(void *parsed_result,
10590 __attribute__((unused)) struct cmdline *cl,
10591 __attribute__((unused)) void *data)
10593 struct cmd_mcast_addr_result *res = parsed_result;
10595 if (!is_multicast_ether_addr(&res->mc_addr)) {
10596 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10597 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10598 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10599 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10602 if (strcmp(res->what, "add") == 0)
10603 mcast_addr_add(res->port_num, &res->mc_addr);
10605 mcast_addr_remove(res->port_num, &res->mc_addr);
10608 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10609 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10610 mcast_addr_cmd, "mcast_addr");
10611 cmdline_parse_token_string_t cmd_mcast_addr_what =
10612 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10614 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10615 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10616 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10617 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10619 cmdline_parse_inst_t cmd_mcast_addr = {
10620 .f = cmd_mcast_addr_parsed,
10622 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10623 "Add/Remove multicast MAC address on port_id",
10625 (void *)&cmd_mcast_addr_cmd,
10626 (void *)&cmd_mcast_addr_what,
10627 (void *)&cmd_mcast_addr_portnum,
10628 (void *)&cmd_mcast_addr_addr,
10633 /* l2 tunnel config
10634 * only support E-tag now.
10637 /* Ether type config */
10638 struct cmd_config_l2_tunnel_eth_type_result {
10639 cmdline_fixed_string_t port;
10640 cmdline_fixed_string_t config;
10641 cmdline_fixed_string_t all;
10643 cmdline_fixed_string_t l2_tunnel;
10644 cmdline_fixed_string_t l2_tunnel_type;
10645 cmdline_fixed_string_t eth_type;
10646 uint16_t eth_type_val;
10649 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10650 TOKEN_STRING_INITIALIZER
10651 (struct cmd_config_l2_tunnel_eth_type_result,
10653 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10654 TOKEN_STRING_INITIALIZER
10655 (struct cmd_config_l2_tunnel_eth_type_result,
10657 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10658 TOKEN_STRING_INITIALIZER
10659 (struct cmd_config_l2_tunnel_eth_type_result,
10661 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10662 TOKEN_NUM_INITIALIZER
10663 (struct cmd_config_l2_tunnel_eth_type_result,
10665 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10666 TOKEN_STRING_INITIALIZER
10667 (struct cmd_config_l2_tunnel_eth_type_result,
10668 l2_tunnel, "l2-tunnel");
10669 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10670 TOKEN_STRING_INITIALIZER
10671 (struct cmd_config_l2_tunnel_eth_type_result,
10672 l2_tunnel_type, "E-tag");
10673 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10674 TOKEN_STRING_INITIALIZER
10675 (struct cmd_config_l2_tunnel_eth_type_result,
10676 eth_type, "ether-type");
10677 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10678 TOKEN_NUM_INITIALIZER
10679 (struct cmd_config_l2_tunnel_eth_type_result,
10680 eth_type_val, UINT16);
10682 static enum rte_eth_tunnel_type
10683 str2fdir_l2_tunnel_type(char *string)
10687 static const struct {
10689 enum rte_eth_tunnel_type type;
10690 } l2_tunnel_type_str[] = {
10691 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10694 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10695 if (!strcmp(l2_tunnel_type_str[i].str, string))
10696 return l2_tunnel_type_str[i].type;
10698 return RTE_TUNNEL_TYPE_NONE;
10701 /* ether type config for all ports */
10703 cmd_config_l2_tunnel_eth_type_all_parsed
10704 (void *parsed_result,
10705 __attribute__((unused)) struct cmdline *cl,
10706 __attribute__((unused)) void *data)
10708 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10709 struct rte_eth_l2_tunnel_conf entry;
10712 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10713 entry.ether_type = res->eth_type_val;
10715 RTE_ETH_FOREACH_DEV(pid) {
10716 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10720 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10721 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10723 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10725 (void *)&cmd_config_l2_tunnel_eth_type_port,
10726 (void *)&cmd_config_l2_tunnel_eth_type_config,
10727 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10728 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10729 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10730 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10731 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10736 /* ether type config for a specific port */
10738 cmd_config_l2_tunnel_eth_type_specific_parsed(
10739 void *parsed_result,
10740 __attribute__((unused)) struct cmdline *cl,
10741 __attribute__((unused)) void *data)
10743 struct cmd_config_l2_tunnel_eth_type_result *res =
10745 struct rte_eth_l2_tunnel_conf entry;
10747 if (port_id_is_invalid(res->id, ENABLED_WARN))
10750 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10751 entry.ether_type = res->eth_type_val;
10753 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10756 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10757 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10759 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10761 (void *)&cmd_config_l2_tunnel_eth_type_port,
10762 (void *)&cmd_config_l2_tunnel_eth_type_config,
10763 (void *)&cmd_config_l2_tunnel_eth_type_id,
10764 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10765 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10766 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10767 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10772 /* Enable/disable l2 tunnel */
10773 struct cmd_config_l2_tunnel_en_dis_result {
10774 cmdline_fixed_string_t port;
10775 cmdline_fixed_string_t config;
10776 cmdline_fixed_string_t all;
10778 cmdline_fixed_string_t l2_tunnel;
10779 cmdline_fixed_string_t l2_tunnel_type;
10780 cmdline_fixed_string_t en_dis;
10783 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10784 TOKEN_STRING_INITIALIZER
10785 (struct cmd_config_l2_tunnel_en_dis_result,
10787 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10788 TOKEN_STRING_INITIALIZER
10789 (struct cmd_config_l2_tunnel_en_dis_result,
10791 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10792 TOKEN_STRING_INITIALIZER
10793 (struct cmd_config_l2_tunnel_en_dis_result,
10795 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10796 TOKEN_NUM_INITIALIZER
10797 (struct cmd_config_l2_tunnel_en_dis_result,
10799 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10800 TOKEN_STRING_INITIALIZER
10801 (struct cmd_config_l2_tunnel_en_dis_result,
10802 l2_tunnel, "l2-tunnel");
10803 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10804 TOKEN_STRING_INITIALIZER
10805 (struct cmd_config_l2_tunnel_en_dis_result,
10806 l2_tunnel_type, "E-tag");
10807 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10808 TOKEN_STRING_INITIALIZER
10809 (struct cmd_config_l2_tunnel_en_dis_result,
10810 en_dis, "enable#disable");
10812 /* enable/disable l2 tunnel for all ports */
10814 cmd_config_l2_tunnel_en_dis_all_parsed(
10815 void *parsed_result,
10816 __attribute__((unused)) struct cmdline *cl,
10817 __attribute__((unused)) void *data)
10819 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10820 struct rte_eth_l2_tunnel_conf entry;
10824 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10826 if (!strcmp("enable", res->en_dis))
10831 RTE_ETH_FOREACH_DEV(pid) {
10832 rte_eth_dev_l2_tunnel_offload_set(pid,
10834 ETH_L2_TUNNEL_ENABLE_MASK,
10839 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10840 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10842 .help_str = "port config all l2-tunnel E-tag enable|disable",
10844 (void *)&cmd_config_l2_tunnel_en_dis_port,
10845 (void *)&cmd_config_l2_tunnel_en_dis_config,
10846 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10847 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10848 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10849 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10854 /* enable/disable l2 tunnel for a port */
10856 cmd_config_l2_tunnel_en_dis_specific_parsed(
10857 void *parsed_result,
10858 __attribute__((unused)) struct cmdline *cl,
10859 __attribute__((unused)) void *data)
10861 struct cmd_config_l2_tunnel_en_dis_result *res =
10863 struct rte_eth_l2_tunnel_conf entry;
10865 if (port_id_is_invalid(res->id, ENABLED_WARN))
10868 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10870 if (!strcmp("enable", res->en_dis))
10871 rte_eth_dev_l2_tunnel_offload_set(res->id,
10873 ETH_L2_TUNNEL_ENABLE_MASK,
10876 rte_eth_dev_l2_tunnel_offload_set(res->id,
10878 ETH_L2_TUNNEL_ENABLE_MASK,
10882 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10883 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10885 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10887 (void *)&cmd_config_l2_tunnel_en_dis_port,
10888 (void *)&cmd_config_l2_tunnel_en_dis_config,
10889 (void *)&cmd_config_l2_tunnel_en_dis_id,
10890 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10891 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10892 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10897 /* E-tag configuration */
10899 /* Common result structure for all E-tag configuration */
10900 struct cmd_config_e_tag_result {
10901 cmdline_fixed_string_t e_tag;
10902 cmdline_fixed_string_t set;
10903 cmdline_fixed_string_t insertion;
10904 cmdline_fixed_string_t stripping;
10905 cmdline_fixed_string_t forwarding;
10906 cmdline_fixed_string_t filter;
10907 cmdline_fixed_string_t add;
10908 cmdline_fixed_string_t del;
10909 cmdline_fixed_string_t on;
10910 cmdline_fixed_string_t off;
10911 cmdline_fixed_string_t on_off;
10912 cmdline_fixed_string_t port_tag_id;
10913 uint32_t port_tag_id_val;
10914 cmdline_fixed_string_t e_tag_id;
10915 uint16_t e_tag_id_val;
10916 cmdline_fixed_string_t dst_pool;
10917 uint8_t dst_pool_val;
10918 cmdline_fixed_string_t port;
10920 cmdline_fixed_string_t vf;
10924 /* Common CLI fields for all E-tag configuration */
10925 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10926 TOKEN_STRING_INITIALIZER
10927 (struct cmd_config_e_tag_result,
10929 cmdline_parse_token_string_t cmd_config_e_tag_set =
10930 TOKEN_STRING_INITIALIZER
10931 (struct cmd_config_e_tag_result,
10933 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10934 TOKEN_STRING_INITIALIZER
10935 (struct cmd_config_e_tag_result,
10936 insertion, "insertion");
10937 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10938 TOKEN_STRING_INITIALIZER
10939 (struct cmd_config_e_tag_result,
10940 stripping, "stripping");
10941 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10942 TOKEN_STRING_INITIALIZER
10943 (struct cmd_config_e_tag_result,
10944 forwarding, "forwarding");
10945 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10946 TOKEN_STRING_INITIALIZER
10947 (struct cmd_config_e_tag_result,
10949 cmdline_parse_token_string_t cmd_config_e_tag_add =
10950 TOKEN_STRING_INITIALIZER
10951 (struct cmd_config_e_tag_result,
10953 cmdline_parse_token_string_t cmd_config_e_tag_del =
10954 TOKEN_STRING_INITIALIZER
10955 (struct cmd_config_e_tag_result,
10957 cmdline_parse_token_string_t cmd_config_e_tag_on =
10958 TOKEN_STRING_INITIALIZER
10959 (struct cmd_config_e_tag_result,
10961 cmdline_parse_token_string_t cmd_config_e_tag_off =
10962 TOKEN_STRING_INITIALIZER
10963 (struct cmd_config_e_tag_result,
10965 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10966 TOKEN_STRING_INITIALIZER
10967 (struct cmd_config_e_tag_result,
10969 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10970 TOKEN_STRING_INITIALIZER
10971 (struct cmd_config_e_tag_result,
10972 port_tag_id, "port-tag-id");
10973 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10974 TOKEN_NUM_INITIALIZER
10975 (struct cmd_config_e_tag_result,
10976 port_tag_id_val, UINT32);
10977 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10978 TOKEN_STRING_INITIALIZER
10979 (struct cmd_config_e_tag_result,
10980 e_tag_id, "e-tag-id");
10981 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10982 TOKEN_NUM_INITIALIZER
10983 (struct cmd_config_e_tag_result,
10984 e_tag_id_val, UINT16);
10985 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10986 TOKEN_STRING_INITIALIZER
10987 (struct cmd_config_e_tag_result,
10988 dst_pool, "dst-pool");
10989 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10990 TOKEN_NUM_INITIALIZER
10991 (struct cmd_config_e_tag_result,
10992 dst_pool_val, UINT8);
10993 cmdline_parse_token_string_t cmd_config_e_tag_port =
10994 TOKEN_STRING_INITIALIZER
10995 (struct cmd_config_e_tag_result,
10997 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10998 TOKEN_NUM_INITIALIZER
10999 (struct cmd_config_e_tag_result,
11001 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11002 TOKEN_STRING_INITIALIZER
11003 (struct cmd_config_e_tag_result,
11005 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11006 TOKEN_NUM_INITIALIZER
11007 (struct cmd_config_e_tag_result,
11010 /* E-tag insertion configuration */
11012 cmd_config_e_tag_insertion_en_parsed(
11013 void *parsed_result,
11014 __attribute__((unused)) struct cmdline *cl,
11015 __attribute__((unused)) void *data)
11017 struct cmd_config_e_tag_result *res =
11019 struct rte_eth_l2_tunnel_conf entry;
11021 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11024 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11025 entry.tunnel_id = res->port_tag_id_val;
11026 entry.vf_id = res->vf_id;
11027 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11029 ETH_L2_TUNNEL_INSERTION_MASK,
11034 cmd_config_e_tag_insertion_dis_parsed(
11035 void *parsed_result,
11036 __attribute__((unused)) struct cmdline *cl,
11037 __attribute__((unused)) void *data)
11039 struct cmd_config_e_tag_result *res =
11041 struct rte_eth_l2_tunnel_conf entry;
11043 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11046 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11047 entry.vf_id = res->vf_id;
11049 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11051 ETH_L2_TUNNEL_INSERTION_MASK,
11055 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11056 .f = cmd_config_e_tag_insertion_en_parsed,
11058 .help_str = "E-tag ... : E-tag insertion enable",
11060 (void *)&cmd_config_e_tag_e_tag,
11061 (void *)&cmd_config_e_tag_set,
11062 (void *)&cmd_config_e_tag_insertion,
11063 (void *)&cmd_config_e_tag_on,
11064 (void *)&cmd_config_e_tag_port_tag_id,
11065 (void *)&cmd_config_e_tag_port_tag_id_val,
11066 (void *)&cmd_config_e_tag_port,
11067 (void *)&cmd_config_e_tag_port_id,
11068 (void *)&cmd_config_e_tag_vf,
11069 (void *)&cmd_config_e_tag_vf_id,
11074 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11075 .f = cmd_config_e_tag_insertion_dis_parsed,
11077 .help_str = "E-tag ... : E-tag insertion disable",
11079 (void *)&cmd_config_e_tag_e_tag,
11080 (void *)&cmd_config_e_tag_set,
11081 (void *)&cmd_config_e_tag_insertion,
11082 (void *)&cmd_config_e_tag_off,
11083 (void *)&cmd_config_e_tag_port,
11084 (void *)&cmd_config_e_tag_port_id,
11085 (void *)&cmd_config_e_tag_vf,
11086 (void *)&cmd_config_e_tag_vf_id,
11091 /* E-tag stripping configuration */
11093 cmd_config_e_tag_stripping_parsed(
11094 void *parsed_result,
11095 __attribute__((unused)) struct cmdline *cl,
11096 __attribute__((unused)) void *data)
11098 struct cmd_config_e_tag_result *res =
11100 struct rte_eth_l2_tunnel_conf entry;
11102 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11105 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11107 if (!strcmp(res->on_off, "on"))
11108 rte_eth_dev_l2_tunnel_offload_set
11111 ETH_L2_TUNNEL_STRIPPING_MASK,
11114 rte_eth_dev_l2_tunnel_offload_set
11117 ETH_L2_TUNNEL_STRIPPING_MASK,
11121 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11122 .f = cmd_config_e_tag_stripping_parsed,
11124 .help_str = "E-tag ... : E-tag stripping enable/disable",
11126 (void *)&cmd_config_e_tag_e_tag,
11127 (void *)&cmd_config_e_tag_set,
11128 (void *)&cmd_config_e_tag_stripping,
11129 (void *)&cmd_config_e_tag_on_off,
11130 (void *)&cmd_config_e_tag_port,
11131 (void *)&cmd_config_e_tag_port_id,
11136 /* E-tag forwarding configuration */
11138 cmd_config_e_tag_forwarding_parsed(
11139 void *parsed_result,
11140 __attribute__((unused)) struct cmdline *cl,
11141 __attribute__((unused)) void *data)
11143 struct cmd_config_e_tag_result *res = parsed_result;
11144 struct rte_eth_l2_tunnel_conf entry;
11146 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11149 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11151 if (!strcmp(res->on_off, "on"))
11152 rte_eth_dev_l2_tunnel_offload_set
11155 ETH_L2_TUNNEL_FORWARDING_MASK,
11158 rte_eth_dev_l2_tunnel_offload_set
11161 ETH_L2_TUNNEL_FORWARDING_MASK,
11165 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11166 .f = cmd_config_e_tag_forwarding_parsed,
11168 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11170 (void *)&cmd_config_e_tag_e_tag,
11171 (void *)&cmd_config_e_tag_set,
11172 (void *)&cmd_config_e_tag_forwarding,
11173 (void *)&cmd_config_e_tag_on_off,
11174 (void *)&cmd_config_e_tag_port,
11175 (void *)&cmd_config_e_tag_port_id,
11180 /* E-tag filter configuration */
11182 cmd_config_e_tag_filter_add_parsed(
11183 void *parsed_result,
11184 __attribute__((unused)) struct cmdline *cl,
11185 __attribute__((unused)) void *data)
11187 struct cmd_config_e_tag_result *res = parsed_result;
11188 struct rte_eth_l2_tunnel_conf entry;
11191 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11194 if (res->e_tag_id_val > 0x3fff) {
11195 printf("e-tag-id must be equal or less than 0x3fff.\n");
11199 ret = rte_eth_dev_filter_supported(res->port_id,
11200 RTE_ETH_FILTER_L2_TUNNEL);
11202 printf("E-tag filter is not supported on port %u.\n",
11207 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11208 entry.tunnel_id = res->e_tag_id_val;
11209 entry.pool = res->dst_pool_val;
11211 ret = rte_eth_dev_filter_ctrl(res->port_id,
11212 RTE_ETH_FILTER_L2_TUNNEL,
11213 RTE_ETH_FILTER_ADD,
11216 printf("E-tag filter programming error: (%s)\n",
11220 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
11221 .f = cmd_config_e_tag_filter_add_parsed,
11223 .help_str = "E-tag ... : E-tag filter add",
11225 (void *)&cmd_config_e_tag_e_tag,
11226 (void *)&cmd_config_e_tag_set,
11227 (void *)&cmd_config_e_tag_filter,
11228 (void *)&cmd_config_e_tag_add,
11229 (void *)&cmd_config_e_tag_e_tag_id,
11230 (void *)&cmd_config_e_tag_e_tag_id_val,
11231 (void *)&cmd_config_e_tag_dst_pool,
11232 (void *)&cmd_config_e_tag_dst_pool_val,
11233 (void *)&cmd_config_e_tag_port,
11234 (void *)&cmd_config_e_tag_port_id,
11240 cmd_config_e_tag_filter_del_parsed(
11241 void *parsed_result,
11242 __attribute__((unused)) struct cmdline *cl,
11243 __attribute__((unused)) void *data)
11245 struct cmd_config_e_tag_result *res = parsed_result;
11246 struct rte_eth_l2_tunnel_conf entry;
11249 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11252 if (res->e_tag_id_val > 0x3fff) {
11253 printf("e-tag-id must be less than 0x3fff.\n");
11257 ret = rte_eth_dev_filter_supported(res->port_id,
11258 RTE_ETH_FILTER_L2_TUNNEL);
11260 printf("E-tag filter is not supported on port %u.\n",
11265 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11266 entry.tunnel_id = res->e_tag_id_val;
11268 ret = rte_eth_dev_filter_ctrl(res->port_id,
11269 RTE_ETH_FILTER_L2_TUNNEL,
11270 RTE_ETH_FILTER_DELETE,
11273 printf("E-tag filter programming error: (%s)\n",
11277 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
11278 .f = cmd_config_e_tag_filter_del_parsed,
11280 .help_str = "E-tag ... : E-tag filter delete",
11282 (void *)&cmd_config_e_tag_e_tag,
11283 (void *)&cmd_config_e_tag_set,
11284 (void *)&cmd_config_e_tag_filter,
11285 (void *)&cmd_config_e_tag_del,
11286 (void *)&cmd_config_e_tag_e_tag_id,
11287 (void *)&cmd_config_e_tag_e_tag_id_val,
11288 (void *)&cmd_config_e_tag_port,
11289 (void *)&cmd_config_e_tag_port_id,
11294 /* vf vlan anti spoof configuration */
11296 /* Common result structure for vf vlan anti spoof */
11297 struct cmd_vf_vlan_anti_spoof_result {
11298 cmdline_fixed_string_t set;
11299 cmdline_fixed_string_t vf;
11300 cmdline_fixed_string_t vlan;
11301 cmdline_fixed_string_t antispoof;
11304 cmdline_fixed_string_t on_off;
11307 /* Common CLI fields for vf vlan anti spoof enable disable */
11308 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11309 TOKEN_STRING_INITIALIZER
11310 (struct cmd_vf_vlan_anti_spoof_result,
11312 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11313 TOKEN_STRING_INITIALIZER
11314 (struct cmd_vf_vlan_anti_spoof_result,
11316 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11317 TOKEN_STRING_INITIALIZER
11318 (struct cmd_vf_vlan_anti_spoof_result,
11320 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11321 TOKEN_STRING_INITIALIZER
11322 (struct cmd_vf_vlan_anti_spoof_result,
11323 antispoof, "antispoof");
11324 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11325 TOKEN_NUM_INITIALIZER
11326 (struct cmd_vf_vlan_anti_spoof_result,
11328 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11329 TOKEN_NUM_INITIALIZER
11330 (struct cmd_vf_vlan_anti_spoof_result,
11332 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11333 TOKEN_STRING_INITIALIZER
11334 (struct cmd_vf_vlan_anti_spoof_result,
11338 cmd_set_vf_vlan_anti_spoof_parsed(
11339 void *parsed_result,
11340 __attribute__((unused)) struct cmdline *cl,
11341 __attribute__((unused)) void *data)
11343 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11344 int ret = -ENOTSUP;
11346 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11348 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11351 #ifdef RTE_LIBRTE_IXGBE_PMD
11352 if (ret == -ENOTSUP)
11353 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11354 res->vf_id, is_on);
11356 #ifdef RTE_LIBRTE_I40E_PMD
11357 if (ret == -ENOTSUP)
11358 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11359 res->vf_id, is_on);
11361 #ifdef RTE_LIBRTE_BNXT_PMD
11362 if (ret == -ENOTSUP)
11363 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11364 res->vf_id, is_on);
11371 printf("invalid vf_id %d\n", res->vf_id);
11374 printf("invalid port_id %d\n", res->port_id);
11377 printf("function not implemented\n");
11380 printf("programming error: (%s)\n", strerror(-ret));
11384 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11385 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11387 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11389 (void *)&cmd_vf_vlan_anti_spoof_set,
11390 (void *)&cmd_vf_vlan_anti_spoof_vf,
11391 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11392 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11393 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11394 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11395 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11400 /* vf mac anti spoof configuration */
11402 /* Common result structure for vf mac anti spoof */
11403 struct cmd_vf_mac_anti_spoof_result {
11404 cmdline_fixed_string_t set;
11405 cmdline_fixed_string_t vf;
11406 cmdline_fixed_string_t mac;
11407 cmdline_fixed_string_t antispoof;
11410 cmdline_fixed_string_t on_off;
11413 /* Common CLI fields for vf mac anti spoof enable disable */
11414 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11415 TOKEN_STRING_INITIALIZER
11416 (struct cmd_vf_mac_anti_spoof_result,
11418 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11419 TOKEN_STRING_INITIALIZER
11420 (struct cmd_vf_mac_anti_spoof_result,
11422 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11423 TOKEN_STRING_INITIALIZER
11424 (struct cmd_vf_mac_anti_spoof_result,
11426 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11427 TOKEN_STRING_INITIALIZER
11428 (struct cmd_vf_mac_anti_spoof_result,
11429 antispoof, "antispoof");
11430 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11431 TOKEN_NUM_INITIALIZER
11432 (struct cmd_vf_mac_anti_spoof_result,
11434 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11435 TOKEN_NUM_INITIALIZER
11436 (struct cmd_vf_mac_anti_spoof_result,
11438 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11439 TOKEN_STRING_INITIALIZER
11440 (struct cmd_vf_mac_anti_spoof_result,
11444 cmd_set_vf_mac_anti_spoof_parsed(
11445 void *parsed_result,
11446 __attribute__((unused)) struct cmdline *cl,
11447 __attribute__((unused)) void *data)
11449 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11450 int ret = -ENOTSUP;
11452 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11454 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11457 #ifdef RTE_LIBRTE_IXGBE_PMD
11458 if (ret == -ENOTSUP)
11459 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11460 res->vf_id, is_on);
11462 #ifdef RTE_LIBRTE_I40E_PMD
11463 if (ret == -ENOTSUP)
11464 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11465 res->vf_id, is_on);
11467 #ifdef RTE_LIBRTE_BNXT_PMD
11468 if (ret == -ENOTSUP)
11469 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11470 res->vf_id, is_on);
11477 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11480 printf("invalid port_id %d\n", res->port_id);
11483 printf("function not implemented\n");
11486 printf("programming error: (%s)\n", strerror(-ret));
11490 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11491 .f = cmd_set_vf_mac_anti_spoof_parsed,
11493 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11495 (void *)&cmd_vf_mac_anti_spoof_set,
11496 (void *)&cmd_vf_mac_anti_spoof_vf,
11497 (void *)&cmd_vf_mac_anti_spoof_mac,
11498 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11499 (void *)&cmd_vf_mac_anti_spoof_port_id,
11500 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11501 (void *)&cmd_vf_mac_anti_spoof_on_off,
11506 /* vf vlan strip queue configuration */
11508 /* Common result structure for vf mac anti spoof */
11509 struct cmd_vf_vlan_stripq_result {
11510 cmdline_fixed_string_t set;
11511 cmdline_fixed_string_t vf;
11512 cmdline_fixed_string_t vlan;
11513 cmdline_fixed_string_t stripq;
11516 cmdline_fixed_string_t on_off;
11519 /* Common CLI fields for vf vlan strip enable disable */
11520 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11521 TOKEN_STRING_INITIALIZER
11522 (struct cmd_vf_vlan_stripq_result,
11524 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11525 TOKEN_STRING_INITIALIZER
11526 (struct cmd_vf_vlan_stripq_result,
11528 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11529 TOKEN_STRING_INITIALIZER
11530 (struct cmd_vf_vlan_stripq_result,
11532 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11533 TOKEN_STRING_INITIALIZER
11534 (struct cmd_vf_vlan_stripq_result,
11536 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11537 TOKEN_NUM_INITIALIZER
11538 (struct cmd_vf_vlan_stripq_result,
11540 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11541 TOKEN_NUM_INITIALIZER
11542 (struct cmd_vf_vlan_stripq_result,
11544 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11545 TOKEN_STRING_INITIALIZER
11546 (struct cmd_vf_vlan_stripq_result,
11550 cmd_set_vf_vlan_stripq_parsed(
11551 void *parsed_result,
11552 __attribute__((unused)) struct cmdline *cl,
11553 __attribute__((unused)) void *data)
11555 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11556 int ret = -ENOTSUP;
11558 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11560 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11563 #ifdef RTE_LIBRTE_IXGBE_PMD
11564 if (ret == -ENOTSUP)
11565 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11566 res->vf_id, is_on);
11568 #ifdef RTE_LIBRTE_I40E_PMD
11569 if (ret == -ENOTSUP)
11570 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11571 res->vf_id, is_on);
11573 #ifdef RTE_LIBRTE_BNXT_PMD
11574 if (ret == -ENOTSUP)
11575 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11576 res->vf_id, is_on);
11583 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11586 printf("invalid port_id %d\n", res->port_id);
11589 printf("function not implemented\n");
11592 printf("programming error: (%s)\n", strerror(-ret));
11596 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11597 .f = cmd_set_vf_vlan_stripq_parsed,
11599 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11601 (void *)&cmd_vf_vlan_stripq_set,
11602 (void *)&cmd_vf_vlan_stripq_vf,
11603 (void *)&cmd_vf_vlan_stripq_vlan,
11604 (void *)&cmd_vf_vlan_stripq_stripq,
11605 (void *)&cmd_vf_vlan_stripq_port_id,
11606 (void *)&cmd_vf_vlan_stripq_vf_id,
11607 (void *)&cmd_vf_vlan_stripq_on_off,
11612 /* vf vlan insert configuration */
11614 /* Common result structure for vf vlan insert */
11615 struct cmd_vf_vlan_insert_result {
11616 cmdline_fixed_string_t set;
11617 cmdline_fixed_string_t vf;
11618 cmdline_fixed_string_t vlan;
11619 cmdline_fixed_string_t insert;
11625 /* Common CLI fields for vf vlan insert enable disable */
11626 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11627 TOKEN_STRING_INITIALIZER
11628 (struct cmd_vf_vlan_insert_result,
11630 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11631 TOKEN_STRING_INITIALIZER
11632 (struct cmd_vf_vlan_insert_result,
11634 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11635 TOKEN_STRING_INITIALIZER
11636 (struct cmd_vf_vlan_insert_result,
11638 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11639 TOKEN_STRING_INITIALIZER
11640 (struct cmd_vf_vlan_insert_result,
11642 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11643 TOKEN_NUM_INITIALIZER
11644 (struct cmd_vf_vlan_insert_result,
11646 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11647 TOKEN_NUM_INITIALIZER
11648 (struct cmd_vf_vlan_insert_result,
11650 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11651 TOKEN_NUM_INITIALIZER
11652 (struct cmd_vf_vlan_insert_result,
11656 cmd_set_vf_vlan_insert_parsed(
11657 void *parsed_result,
11658 __attribute__((unused)) struct cmdline *cl,
11659 __attribute__((unused)) void *data)
11661 struct cmd_vf_vlan_insert_result *res = parsed_result;
11662 int ret = -ENOTSUP;
11664 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11667 #ifdef RTE_LIBRTE_IXGBE_PMD
11668 if (ret == -ENOTSUP)
11669 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11672 #ifdef RTE_LIBRTE_I40E_PMD
11673 if (ret == -ENOTSUP)
11674 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11677 #ifdef RTE_LIBRTE_BNXT_PMD
11678 if (ret == -ENOTSUP)
11679 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11687 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11690 printf("invalid port_id %d\n", res->port_id);
11693 printf("function not implemented\n");
11696 printf("programming error: (%s)\n", strerror(-ret));
11700 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11701 .f = cmd_set_vf_vlan_insert_parsed,
11703 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11705 (void *)&cmd_vf_vlan_insert_set,
11706 (void *)&cmd_vf_vlan_insert_vf,
11707 (void *)&cmd_vf_vlan_insert_vlan,
11708 (void *)&cmd_vf_vlan_insert_insert,
11709 (void *)&cmd_vf_vlan_insert_port_id,
11710 (void *)&cmd_vf_vlan_insert_vf_id,
11711 (void *)&cmd_vf_vlan_insert_vlan_id,
11716 /* tx loopback configuration */
11718 /* Common result structure for tx loopback */
11719 struct cmd_tx_loopback_result {
11720 cmdline_fixed_string_t set;
11721 cmdline_fixed_string_t tx;
11722 cmdline_fixed_string_t loopback;
11724 cmdline_fixed_string_t on_off;
11727 /* Common CLI fields for tx loopback enable disable */
11728 cmdline_parse_token_string_t cmd_tx_loopback_set =
11729 TOKEN_STRING_INITIALIZER
11730 (struct cmd_tx_loopback_result,
11732 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11733 TOKEN_STRING_INITIALIZER
11734 (struct cmd_tx_loopback_result,
11736 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11737 TOKEN_STRING_INITIALIZER
11738 (struct cmd_tx_loopback_result,
11739 loopback, "loopback");
11740 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11741 TOKEN_NUM_INITIALIZER
11742 (struct cmd_tx_loopback_result,
11744 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11745 TOKEN_STRING_INITIALIZER
11746 (struct cmd_tx_loopback_result,
11750 cmd_set_tx_loopback_parsed(
11751 void *parsed_result,
11752 __attribute__((unused)) struct cmdline *cl,
11753 __attribute__((unused)) void *data)
11755 struct cmd_tx_loopback_result *res = parsed_result;
11756 int ret = -ENOTSUP;
11758 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11760 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11763 #ifdef RTE_LIBRTE_IXGBE_PMD
11764 if (ret == -ENOTSUP)
11765 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11767 #ifdef RTE_LIBRTE_I40E_PMD
11768 if (ret == -ENOTSUP)
11769 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11771 #ifdef RTE_LIBRTE_BNXT_PMD
11772 if (ret == -ENOTSUP)
11773 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11780 printf("invalid is_on %d\n", is_on);
11783 printf("invalid port_id %d\n", res->port_id);
11786 printf("function not implemented\n");
11789 printf("programming error: (%s)\n", strerror(-ret));
11793 cmdline_parse_inst_t cmd_set_tx_loopback = {
11794 .f = cmd_set_tx_loopback_parsed,
11796 .help_str = "set tx loopback <port_id> on|off",
11798 (void *)&cmd_tx_loopback_set,
11799 (void *)&cmd_tx_loopback_tx,
11800 (void *)&cmd_tx_loopback_loopback,
11801 (void *)&cmd_tx_loopback_port_id,
11802 (void *)&cmd_tx_loopback_on_off,
11807 /* all queues drop enable configuration */
11809 /* Common result structure for all queues drop enable */
11810 struct cmd_all_queues_drop_en_result {
11811 cmdline_fixed_string_t set;
11812 cmdline_fixed_string_t all;
11813 cmdline_fixed_string_t queues;
11814 cmdline_fixed_string_t drop;
11816 cmdline_fixed_string_t on_off;
11819 /* Common CLI fields for tx loopback enable disable */
11820 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11821 TOKEN_STRING_INITIALIZER
11822 (struct cmd_all_queues_drop_en_result,
11824 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11825 TOKEN_STRING_INITIALIZER
11826 (struct cmd_all_queues_drop_en_result,
11828 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11829 TOKEN_STRING_INITIALIZER
11830 (struct cmd_all_queues_drop_en_result,
11832 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11833 TOKEN_STRING_INITIALIZER
11834 (struct cmd_all_queues_drop_en_result,
11836 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11837 TOKEN_NUM_INITIALIZER
11838 (struct cmd_all_queues_drop_en_result,
11840 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11841 TOKEN_STRING_INITIALIZER
11842 (struct cmd_all_queues_drop_en_result,
11846 cmd_set_all_queues_drop_en_parsed(
11847 void *parsed_result,
11848 __attribute__((unused)) struct cmdline *cl,
11849 __attribute__((unused)) void *data)
11851 struct cmd_all_queues_drop_en_result *res = parsed_result;
11852 int ret = -ENOTSUP;
11853 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11855 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11858 #ifdef RTE_LIBRTE_IXGBE_PMD
11859 if (ret == -ENOTSUP)
11860 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11862 #ifdef RTE_LIBRTE_BNXT_PMD
11863 if (ret == -ENOTSUP)
11864 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11870 printf("invalid is_on %d\n", is_on);
11873 printf("invalid port_id %d\n", res->port_id);
11876 printf("function not implemented\n");
11879 printf("programming error: (%s)\n", strerror(-ret));
11883 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11884 .f = cmd_set_all_queues_drop_en_parsed,
11886 .help_str = "set all queues drop <port_id> on|off",
11888 (void *)&cmd_all_queues_drop_en_set,
11889 (void *)&cmd_all_queues_drop_en_all,
11890 (void *)&cmd_all_queues_drop_en_queues,
11891 (void *)&cmd_all_queues_drop_en_drop,
11892 (void *)&cmd_all_queues_drop_en_port_id,
11893 (void *)&cmd_all_queues_drop_en_on_off,
11898 /* vf split drop enable configuration */
11900 /* Common result structure for vf split drop enable */
11901 struct cmd_vf_split_drop_en_result {
11902 cmdline_fixed_string_t set;
11903 cmdline_fixed_string_t vf;
11904 cmdline_fixed_string_t split;
11905 cmdline_fixed_string_t drop;
11908 cmdline_fixed_string_t on_off;
11911 /* Common CLI fields for vf split drop enable disable */
11912 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11913 TOKEN_STRING_INITIALIZER
11914 (struct cmd_vf_split_drop_en_result,
11916 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11917 TOKEN_STRING_INITIALIZER
11918 (struct cmd_vf_split_drop_en_result,
11920 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11921 TOKEN_STRING_INITIALIZER
11922 (struct cmd_vf_split_drop_en_result,
11924 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11925 TOKEN_STRING_INITIALIZER
11926 (struct cmd_vf_split_drop_en_result,
11928 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11929 TOKEN_NUM_INITIALIZER
11930 (struct cmd_vf_split_drop_en_result,
11932 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11933 TOKEN_NUM_INITIALIZER
11934 (struct cmd_vf_split_drop_en_result,
11936 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11937 TOKEN_STRING_INITIALIZER
11938 (struct cmd_vf_split_drop_en_result,
11942 cmd_set_vf_split_drop_en_parsed(
11943 void *parsed_result,
11944 __attribute__((unused)) struct cmdline *cl,
11945 __attribute__((unused)) void *data)
11947 struct cmd_vf_split_drop_en_result *res = parsed_result;
11948 int ret = -ENOTSUP;
11949 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11951 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11954 #ifdef RTE_LIBRTE_IXGBE_PMD
11955 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11962 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11965 printf("invalid port_id %d\n", res->port_id);
11968 printf("not supported on port %d\n", res->port_id);
11971 printf("programming error: (%s)\n", strerror(-ret));
11975 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11976 .f = cmd_set_vf_split_drop_en_parsed,
11978 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11980 (void *)&cmd_vf_split_drop_en_set,
11981 (void *)&cmd_vf_split_drop_en_vf,
11982 (void *)&cmd_vf_split_drop_en_split,
11983 (void *)&cmd_vf_split_drop_en_drop,
11984 (void *)&cmd_vf_split_drop_en_port_id,
11985 (void *)&cmd_vf_split_drop_en_vf_id,
11986 (void *)&cmd_vf_split_drop_en_on_off,
11991 /* vf mac address configuration */
11993 /* Common result structure for vf mac address */
11994 struct cmd_set_vf_mac_addr_result {
11995 cmdline_fixed_string_t set;
11996 cmdline_fixed_string_t vf;
11997 cmdline_fixed_string_t mac;
11998 cmdline_fixed_string_t addr;
12001 struct ether_addr mac_addr;
12005 /* Common CLI fields for vf split drop enable disable */
12006 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12007 TOKEN_STRING_INITIALIZER
12008 (struct cmd_set_vf_mac_addr_result,
12010 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12011 TOKEN_STRING_INITIALIZER
12012 (struct cmd_set_vf_mac_addr_result,
12014 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12015 TOKEN_STRING_INITIALIZER
12016 (struct cmd_set_vf_mac_addr_result,
12018 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12019 TOKEN_STRING_INITIALIZER
12020 (struct cmd_set_vf_mac_addr_result,
12022 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12023 TOKEN_NUM_INITIALIZER
12024 (struct cmd_set_vf_mac_addr_result,
12026 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12027 TOKEN_NUM_INITIALIZER
12028 (struct cmd_set_vf_mac_addr_result,
12030 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12031 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12035 cmd_set_vf_mac_addr_parsed(
12036 void *parsed_result,
12037 __attribute__((unused)) struct cmdline *cl,
12038 __attribute__((unused)) void *data)
12040 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12041 int ret = -ENOTSUP;
12043 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12046 #ifdef RTE_LIBRTE_IXGBE_PMD
12047 if (ret == -ENOTSUP)
12048 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12051 #ifdef RTE_LIBRTE_I40E_PMD
12052 if (ret == -ENOTSUP)
12053 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12056 #ifdef RTE_LIBRTE_BNXT_PMD
12057 if (ret == -ENOTSUP)
12058 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12066 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12069 printf("invalid port_id %d\n", res->port_id);
12072 printf("function not implemented\n");
12075 printf("programming error: (%s)\n", strerror(-ret));
12079 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12080 .f = cmd_set_vf_mac_addr_parsed,
12082 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12084 (void *)&cmd_set_vf_mac_addr_set,
12085 (void *)&cmd_set_vf_mac_addr_vf,
12086 (void *)&cmd_set_vf_mac_addr_mac,
12087 (void *)&cmd_set_vf_mac_addr_addr,
12088 (void *)&cmd_set_vf_mac_addr_port_id,
12089 (void *)&cmd_set_vf_mac_addr_vf_id,
12090 (void *)&cmd_set_vf_mac_addr_mac_addr,
12095 /* MACsec configuration */
12097 /* Common result structure for MACsec offload enable */
12098 struct cmd_macsec_offload_on_result {
12099 cmdline_fixed_string_t set;
12100 cmdline_fixed_string_t macsec;
12101 cmdline_fixed_string_t offload;
12103 cmdline_fixed_string_t on;
12104 cmdline_fixed_string_t encrypt;
12105 cmdline_fixed_string_t en_on_off;
12106 cmdline_fixed_string_t replay_protect;
12107 cmdline_fixed_string_t rp_on_off;
12110 /* Common CLI fields for MACsec offload disable */
12111 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12112 TOKEN_STRING_INITIALIZER
12113 (struct cmd_macsec_offload_on_result,
12115 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12116 TOKEN_STRING_INITIALIZER
12117 (struct cmd_macsec_offload_on_result,
12119 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12120 TOKEN_STRING_INITIALIZER
12121 (struct cmd_macsec_offload_on_result,
12122 offload, "offload");
12123 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12124 TOKEN_NUM_INITIALIZER
12125 (struct cmd_macsec_offload_on_result,
12127 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12128 TOKEN_STRING_INITIALIZER
12129 (struct cmd_macsec_offload_on_result,
12131 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12132 TOKEN_STRING_INITIALIZER
12133 (struct cmd_macsec_offload_on_result,
12134 encrypt, "encrypt");
12135 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12136 TOKEN_STRING_INITIALIZER
12137 (struct cmd_macsec_offload_on_result,
12138 en_on_off, "on#off");
12139 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12140 TOKEN_STRING_INITIALIZER
12141 (struct cmd_macsec_offload_on_result,
12142 replay_protect, "replay-protect");
12143 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12144 TOKEN_STRING_INITIALIZER
12145 (struct cmd_macsec_offload_on_result,
12146 rp_on_off, "on#off");
12149 cmd_set_macsec_offload_on_parsed(
12150 void *parsed_result,
12151 __attribute__((unused)) struct cmdline *cl,
12152 __attribute__((unused)) void *data)
12154 struct cmd_macsec_offload_on_result *res = parsed_result;
12155 int ret = -ENOTSUP;
12156 portid_t port_id = res->port_id;
12157 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12158 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12160 if (port_id_is_invalid(port_id, ENABLED_WARN))
12163 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
12164 #ifdef RTE_LIBRTE_IXGBE_PMD
12165 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12174 printf("invalid port_id %d\n", port_id);
12177 printf("not supported on port %d\n", port_id);
12180 printf("programming error: (%s)\n", strerror(-ret));
12184 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12185 .f = cmd_set_macsec_offload_on_parsed,
12187 .help_str = "set macsec offload <port_id> on "
12188 "encrypt on|off replay-protect on|off",
12190 (void *)&cmd_macsec_offload_on_set,
12191 (void *)&cmd_macsec_offload_on_macsec,
12192 (void *)&cmd_macsec_offload_on_offload,
12193 (void *)&cmd_macsec_offload_on_port_id,
12194 (void *)&cmd_macsec_offload_on_on,
12195 (void *)&cmd_macsec_offload_on_encrypt,
12196 (void *)&cmd_macsec_offload_on_en_on_off,
12197 (void *)&cmd_macsec_offload_on_replay_protect,
12198 (void *)&cmd_macsec_offload_on_rp_on_off,
12203 /* Common result structure for MACsec offload disable */
12204 struct cmd_macsec_offload_off_result {
12205 cmdline_fixed_string_t set;
12206 cmdline_fixed_string_t macsec;
12207 cmdline_fixed_string_t offload;
12209 cmdline_fixed_string_t off;
12212 /* Common CLI fields for MACsec offload disable */
12213 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12214 TOKEN_STRING_INITIALIZER
12215 (struct cmd_macsec_offload_off_result,
12217 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12218 TOKEN_STRING_INITIALIZER
12219 (struct cmd_macsec_offload_off_result,
12221 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12222 TOKEN_STRING_INITIALIZER
12223 (struct cmd_macsec_offload_off_result,
12224 offload, "offload");
12225 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12226 TOKEN_NUM_INITIALIZER
12227 (struct cmd_macsec_offload_off_result,
12229 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12230 TOKEN_STRING_INITIALIZER
12231 (struct cmd_macsec_offload_off_result,
12235 cmd_set_macsec_offload_off_parsed(
12236 void *parsed_result,
12237 __attribute__((unused)) struct cmdline *cl,
12238 __attribute__((unused)) void *data)
12240 struct cmd_macsec_offload_off_result *res = parsed_result;
12241 int ret = -ENOTSUP;
12242 portid_t port_id = res->port_id;
12244 if (port_id_is_invalid(port_id, ENABLED_WARN))
12247 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
12248 #ifdef RTE_LIBRTE_IXGBE_PMD
12249 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12256 printf("invalid port_id %d\n", port_id);
12259 printf("not supported on port %d\n", port_id);
12262 printf("programming error: (%s)\n", strerror(-ret));
12266 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12267 .f = cmd_set_macsec_offload_off_parsed,
12269 .help_str = "set macsec offload <port_id> off",
12271 (void *)&cmd_macsec_offload_off_set,
12272 (void *)&cmd_macsec_offload_off_macsec,
12273 (void *)&cmd_macsec_offload_off_offload,
12274 (void *)&cmd_macsec_offload_off_port_id,
12275 (void *)&cmd_macsec_offload_off_off,
12280 /* Common result structure for MACsec secure connection configure */
12281 struct cmd_macsec_sc_result {
12282 cmdline_fixed_string_t set;
12283 cmdline_fixed_string_t macsec;
12284 cmdline_fixed_string_t sc;
12285 cmdline_fixed_string_t tx_rx;
12287 struct ether_addr mac;
12291 /* Common CLI fields for MACsec secure connection configure */
12292 cmdline_parse_token_string_t cmd_macsec_sc_set =
12293 TOKEN_STRING_INITIALIZER
12294 (struct cmd_macsec_sc_result,
12296 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12297 TOKEN_STRING_INITIALIZER
12298 (struct cmd_macsec_sc_result,
12300 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12301 TOKEN_STRING_INITIALIZER
12302 (struct cmd_macsec_sc_result,
12304 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12305 TOKEN_STRING_INITIALIZER
12306 (struct cmd_macsec_sc_result,
12308 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12309 TOKEN_NUM_INITIALIZER
12310 (struct cmd_macsec_sc_result,
12312 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12313 TOKEN_ETHERADDR_INITIALIZER
12314 (struct cmd_macsec_sc_result,
12316 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12317 TOKEN_NUM_INITIALIZER
12318 (struct cmd_macsec_sc_result,
12322 cmd_set_macsec_sc_parsed(
12323 void *parsed_result,
12324 __attribute__((unused)) struct cmdline *cl,
12325 __attribute__((unused)) void *data)
12327 struct cmd_macsec_sc_result *res = parsed_result;
12328 int ret = -ENOTSUP;
12329 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12331 #ifdef RTE_LIBRTE_IXGBE_PMD
12333 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12334 res->mac.addr_bytes) :
12335 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12336 res->mac.addr_bytes, res->pi);
12338 RTE_SET_USED(is_tx);
12344 printf("invalid port_id %d\n", res->port_id);
12347 printf("not supported on port %d\n", res->port_id);
12350 printf("programming error: (%s)\n", strerror(-ret));
12354 cmdline_parse_inst_t cmd_set_macsec_sc = {
12355 .f = cmd_set_macsec_sc_parsed,
12357 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12359 (void *)&cmd_macsec_sc_set,
12360 (void *)&cmd_macsec_sc_macsec,
12361 (void *)&cmd_macsec_sc_sc,
12362 (void *)&cmd_macsec_sc_tx_rx,
12363 (void *)&cmd_macsec_sc_port_id,
12364 (void *)&cmd_macsec_sc_mac,
12365 (void *)&cmd_macsec_sc_pi,
12370 /* Common result structure for MACsec secure connection configure */
12371 struct cmd_macsec_sa_result {
12372 cmdline_fixed_string_t set;
12373 cmdline_fixed_string_t macsec;
12374 cmdline_fixed_string_t sa;
12375 cmdline_fixed_string_t tx_rx;
12380 cmdline_fixed_string_t key;
12383 /* Common CLI fields for MACsec secure connection configure */
12384 cmdline_parse_token_string_t cmd_macsec_sa_set =
12385 TOKEN_STRING_INITIALIZER
12386 (struct cmd_macsec_sa_result,
12388 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12389 TOKEN_STRING_INITIALIZER
12390 (struct cmd_macsec_sa_result,
12392 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12393 TOKEN_STRING_INITIALIZER
12394 (struct cmd_macsec_sa_result,
12396 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12397 TOKEN_STRING_INITIALIZER
12398 (struct cmd_macsec_sa_result,
12400 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12401 TOKEN_NUM_INITIALIZER
12402 (struct cmd_macsec_sa_result,
12404 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12405 TOKEN_NUM_INITIALIZER
12406 (struct cmd_macsec_sa_result,
12408 cmdline_parse_token_num_t cmd_macsec_sa_an =
12409 TOKEN_NUM_INITIALIZER
12410 (struct cmd_macsec_sa_result,
12412 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12413 TOKEN_NUM_INITIALIZER
12414 (struct cmd_macsec_sa_result,
12416 cmdline_parse_token_string_t cmd_macsec_sa_key =
12417 TOKEN_STRING_INITIALIZER
12418 (struct cmd_macsec_sa_result,
12422 cmd_set_macsec_sa_parsed(
12423 void *parsed_result,
12424 __attribute__((unused)) struct cmdline *cl,
12425 __attribute__((unused)) void *data)
12427 struct cmd_macsec_sa_result *res = parsed_result;
12428 int ret = -ENOTSUP;
12429 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12430 uint8_t key[16] = { 0 };
12436 key_len = strlen(res->key) / 2;
12440 for (i = 0; i < key_len; i++) {
12441 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12444 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12447 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12450 #ifdef RTE_LIBRTE_IXGBE_PMD
12452 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12453 res->idx, res->an, res->pn, key) :
12454 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12455 res->idx, res->an, res->pn, key);
12457 RTE_SET_USED(is_tx);
12464 printf("invalid idx %d or an %d\n", res->idx, res->an);
12467 printf("invalid port_id %d\n", res->port_id);
12470 printf("not supported on port %d\n", res->port_id);
12473 printf("programming error: (%s)\n", strerror(-ret));
12477 cmdline_parse_inst_t cmd_set_macsec_sa = {
12478 .f = cmd_set_macsec_sa_parsed,
12480 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12482 (void *)&cmd_macsec_sa_set,
12483 (void *)&cmd_macsec_sa_macsec,
12484 (void *)&cmd_macsec_sa_sa,
12485 (void *)&cmd_macsec_sa_tx_rx,
12486 (void *)&cmd_macsec_sa_port_id,
12487 (void *)&cmd_macsec_sa_idx,
12488 (void *)&cmd_macsec_sa_an,
12489 (void *)&cmd_macsec_sa_pn,
12490 (void *)&cmd_macsec_sa_key,
12495 /* VF unicast promiscuous mode configuration */
12497 /* Common result structure for VF unicast promiscuous mode */
12498 struct cmd_vf_promisc_result {
12499 cmdline_fixed_string_t set;
12500 cmdline_fixed_string_t vf;
12501 cmdline_fixed_string_t promisc;
12504 cmdline_fixed_string_t on_off;
12507 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12508 cmdline_parse_token_string_t cmd_vf_promisc_set =
12509 TOKEN_STRING_INITIALIZER
12510 (struct cmd_vf_promisc_result,
12512 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12513 TOKEN_STRING_INITIALIZER
12514 (struct cmd_vf_promisc_result,
12516 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12517 TOKEN_STRING_INITIALIZER
12518 (struct cmd_vf_promisc_result,
12519 promisc, "promisc");
12520 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12521 TOKEN_NUM_INITIALIZER
12522 (struct cmd_vf_promisc_result,
12524 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12525 TOKEN_NUM_INITIALIZER
12526 (struct cmd_vf_promisc_result,
12528 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12529 TOKEN_STRING_INITIALIZER
12530 (struct cmd_vf_promisc_result,
12534 cmd_set_vf_promisc_parsed(
12535 void *parsed_result,
12536 __attribute__((unused)) struct cmdline *cl,
12537 __attribute__((unused)) void *data)
12539 struct cmd_vf_promisc_result *res = parsed_result;
12540 int ret = -ENOTSUP;
12542 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12544 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12547 #ifdef RTE_LIBRTE_I40E_PMD
12548 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12549 res->vf_id, is_on);
12556 printf("invalid vf_id %d\n", res->vf_id);
12559 printf("invalid port_id %d\n", res->port_id);
12562 printf("function not implemented\n");
12565 printf("programming error: (%s)\n", strerror(-ret));
12569 cmdline_parse_inst_t cmd_set_vf_promisc = {
12570 .f = cmd_set_vf_promisc_parsed,
12572 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12573 "Set unicast promiscuous mode for a VF from the PF",
12575 (void *)&cmd_vf_promisc_set,
12576 (void *)&cmd_vf_promisc_vf,
12577 (void *)&cmd_vf_promisc_promisc,
12578 (void *)&cmd_vf_promisc_port_id,
12579 (void *)&cmd_vf_promisc_vf_id,
12580 (void *)&cmd_vf_promisc_on_off,
12585 /* VF multicast promiscuous mode configuration */
12587 /* Common result structure for VF multicast promiscuous mode */
12588 struct cmd_vf_allmulti_result {
12589 cmdline_fixed_string_t set;
12590 cmdline_fixed_string_t vf;
12591 cmdline_fixed_string_t allmulti;
12594 cmdline_fixed_string_t on_off;
12597 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12598 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12599 TOKEN_STRING_INITIALIZER
12600 (struct cmd_vf_allmulti_result,
12602 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12603 TOKEN_STRING_INITIALIZER
12604 (struct cmd_vf_allmulti_result,
12606 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12607 TOKEN_STRING_INITIALIZER
12608 (struct cmd_vf_allmulti_result,
12609 allmulti, "allmulti");
12610 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12611 TOKEN_NUM_INITIALIZER
12612 (struct cmd_vf_allmulti_result,
12614 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12615 TOKEN_NUM_INITIALIZER
12616 (struct cmd_vf_allmulti_result,
12618 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12619 TOKEN_STRING_INITIALIZER
12620 (struct cmd_vf_allmulti_result,
12624 cmd_set_vf_allmulti_parsed(
12625 void *parsed_result,
12626 __attribute__((unused)) struct cmdline *cl,
12627 __attribute__((unused)) void *data)
12629 struct cmd_vf_allmulti_result *res = parsed_result;
12630 int ret = -ENOTSUP;
12632 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12634 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12637 #ifdef RTE_LIBRTE_I40E_PMD
12638 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12639 res->vf_id, is_on);
12646 printf("invalid vf_id %d\n", res->vf_id);
12649 printf("invalid port_id %d\n", res->port_id);
12652 printf("function not implemented\n");
12655 printf("programming error: (%s)\n", strerror(-ret));
12659 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12660 .f = cmd_set_vf_allmulti_parsed,
12662 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12663 "Set multicast promiscuous mode for a VF from the PF",
12665 (void *)&cmd_vf_allmulti_set,
12666 (void *)&cmd_vf_allmulti_vf,
12667 (void *)&cmd_vf_allmulti_allmulti,
12668 (void *)&cmd_vf_allmulti_port_id,
12669 (void *)&cmd_vf_allmulti_vf_id,
12670 (void *)&cmd_vf_allmulti_on_off,
12675 /* vf broadcast mode configuration */
12677 /* Common result structure for vf broadcast */
12678 struct cmd_set_vf_broadcast_result {
12679 cmdline_fixed_string_t set;
12680 cmdline_fixed_string_t vf;
12681 cmdline_fixed_string_t broadcast;
12684 cmdline_fixed_string_t on_off;
12687 /* Common CLI fields for vf broadcast enable disable */
12688 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12689 TOKEN_STRING_INITIALIZER
12690 (struct cmd_set_vf_broadcast_result,
12692 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12693 TOKEN_STRING_INITIALIZER
12694 (struct cmd_set_vf_broadcast_result,
12696 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12697 TOKEN_STRING_INITIALIZER
12698 (struct cmd_set_vf_broadcast_result,
12699 broadcast, "broadcast");
12700 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12701 TOKEN_NUM_INITIALIZER
12702 (struct cmd_set_vf_broadcast_result,
12704 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12705 TOKEN_NUM_INITIALIZER
12706 (struct cmd_set_vf_broadcast_result,
12708 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12709 TOKEN_STRING_INITIALIZER
12710 (struct cmd_set_vf_broadcast_result,
12714 cmd_set_vf_broadcast_parsed(
12715 void *parsed_result,
12716 __attribute__((unused)) struct cmdline *cl,
12717 __attribute__((unused)) void *data)
12719 struct cmd_set_vf_broadcast_result *res = parsed_result;
12720 int ret = -ENOTSUP;
12722 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12724 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12727 #ifdef RTE_LIBRTE_I40E_PMD
12728 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12729 res->vf_id, is_on);
12736 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12739 printf("invalid port_id %d\n", res->port_id);
12742 printf("function not implemented\n");
12745 printf("programming error: (%s)\n", strerror(-ret));
12749 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12750 .f = cmd_set_vf_broadcast_parsed,
12752 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12754 (void *)&cmd_set_vf_broadcast_set,
12755 (void *)&cmd_set_vf_broadcast_vf,
12756 (void *)&cmd_set_vf_broadcast_broadcast,
12757 (void *)&cmd_set_vf_broadcast_port_id,
12758 (void *)&cmd_set_vf_broadcast_vf_id,
12759 (void *)&cmd_set_vf_broadcast_on_off,
12764 /* vf vlan tag configuration */
12766 /* Common result structure for vf vlan tag */
12767 struct cmd_set_vf_vlan_tag_result {
12768 cmdline_fixed_string_t set;
12769 cmdline_fixed_string_t vf;
12770 cmdline_fixed_string_t vlan;
12771 cmdline_fixed_string_t tag;
12774 cmdline_fixed_string_t on_off;
12777 /* Common CLI fields for vf vlan tag enable disable */
12778 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12779 TOKEN_STRING_INITIALIZER
12780 (struct cmd_set_vf_vlan_tag_result,
12782 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12783 TOKEN_STRING_INITIALIZER
12784 (struct cmd_set_vf_vlan_tag_result,
12786 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12787 TOKEN_STRING_INITIALIZER
12788 (struct cmd_set_vf_vlan_tag_result,
12790 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12791 TOKEN_STRING_INITIALIZER
12792 (struct cmd_set_vf_vlan_tag_result,
12794 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12795 TOKEN_NUM_INITIALIZER
12796 (struct cmd_set_vf_vlan_tag_result,
12798 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12799 TOKEN_NUM_INITIALIZER
12800 (struct cmd_set_vf_vlan_tag_result,
12802 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12803 TOKEN_STRING_INITIALIZER
12804 (struct cmd_set_vf_vlan_tag_result,
12808 cmd_set_vf_vlan_tag_parsed(
12809 void *parsed_result,
12810 __attribute__((unused)) struct cmdline *cl,
12811 __attribute__((unused)) void *data)
12813 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12814 int ret = -ENOTSUP;
12816 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12818 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12821 #ifdef RTE_LIBRTE_I40E_PMD
12822 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12823 res->vf_id, is_on);
12830 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12833 printf("invalid port_id %d\n", res->port_id);
12836 printf("function not implemented\n");
12839 printf("programming error: (%s)\n", strerror(-ret));
12843 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12844 .f = cmd_set_vf_vlan_tag_parsed,
12846 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12848 (void *)&cmd_set_vf_vlan_tag_set,
12849 (void *)&cmd_set_vf_vlan_tag_vf,
12850 (void *)&cmd_set_vf_vlan_tag_vlan,
12851 (void *)&cmd_set_vf_vlan_tag_tag,
12852 (void *)&cmd_set_vf_vlan_tag_port_id,
12853 (void *)&cmd_set_vf_vlan_tag_vf_id,
12854 (void *)&cmd_set_vf_vlan_tag_on_off,
12859 /* Common definition of VF and TC TX bandwidth configuration */
12860 struct cmd_vf_tc_bw_result {
12861 cmdline_fixed_string_t set;
12862 cmdline_fixed_string_t vf;
12863 cmdline_fixed_string_t tc;
12864 cmdline_fixed_string_t tx;
12865 cmdline_fixed_string_t min_bw;
12866 cmdline_fixed_string_t max_bw;
12867 cmdline_fixed_string_t strict_link_prio;
12872 cmdline_fixed_string_t bw_list;
12876 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12877 TOKEN_STRING_INITIALIZER
12878 (struct cmd_vf_tc_bw_result,
12880 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12881 TOKEN_STRING_INITIALIZER
12882 (struct cmd_vf_tc_bw_result,
12884 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12885 TOKEN_STRING_INITIALIZER
12886 (struct cmd_vf_tc_bw_result,
12888 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12889 TOKEN_STRING_INITIALIZER
12890 (struct cmd_vf_tc_bw_result,
12892 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12893 TOKEN_STRING_INITIALIZER
12894 (struct cmd_vf_tc_bw_result,
12895 strict_link_prio, "strict-link-priority");
12896 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12897 TOKEN_STRING_INITIALIZER
12898 (struct cmd_vf_tc_bw_result,
12899 min_bw, "min-bandwidth");
12900 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12901 TOKEN_STRING_INITIALIZER
12902 (struct cmd_vf_tc_bw_result,
12903 max_bw, "max-bandwidth");
12904 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12905 TOKEN_NUM_INITIALIZER
12906 (struct cmd_vf_tc_bw_result,
12908 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12909 TOKEN_NUM_INITIALIZER
12910 (struct cmd_vf_tc_bw_result,
12912 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12913 TOKEN_NUM_INITIALIZER
12914 (struct cmd_vf_tc_bw_result,
12916 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12917 TOKEN_NUM_INITIALIZER
12918 (struct cmd_vf_tc_bw_result,
12920 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12921 TOKEN_STRING_INITIALIZER
12922 (struct cmd_vf_tc_bw_result,
12924 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12925 TOKEN_NUM_INITIALIZER
12926 (struct cmd_vf_tc_bw_result,
12929 /* VF max bandwidth setting */
12931 cmd_vf_max_bw_parsed(
12932 void *parsed_result,
12933 __attribute__((unused)) struct cmdline *cl,
12934 __attribute__((unused)) void *data)
12936 struct cmd_vf_tc_bw_result *res = parsed_result;
12937 int ret = -ENOTSUP;
12939 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12942 #ifdef RTE_LIBRTE_I40E_PMD
12943 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12944 res->vf_id, res->bw);
12951 printf("invalid vf_id %d or bandwidth %d\n",
12952 res->vf_id, res->bw);
12955 printf("invalid port_id %d\n", res->port_id);
12958 printf("function not implemented\n");
12961 printf("programming error: (%s)\n", strerror(-ret));
12965 cmdline_parse_inst_t cmd_vf_max_bw = {
12966 .f = cmd_vf_max_bw_parsed,
12968 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12970 (void *)&cmd_vf_tc_bw_set,
12971 (void *)&cmd_vf_tc_bw_vf,
12972 (void *)&cmd_vf_tc_bw_tx,
12973 (void *)&cmd_vf_tc_bw_max_bw,
12974 (void *)&cmd_vf_tc_bw_port_id,
12975 (void *)&cmd_vf_tc_bw_vf_id,
12976 (void *)&cmd_vf_tc_bw_bw,
12982 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12987 const char *p, *p0 = str;
12994 p = strchr(p0, '(');
12996 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13000 p0 = strchr(p, ')');
13002 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13006 if (size >= sizeof(s)) {
13007 printf("The string size exceeds the internal buffer size\n");
13010 snprintf(s, sizeof(s), "%.*s", size, p);
13011 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13013 printf("Failed to get the bandwidth list. ");
13017 for (i = 0; i < ret; i++)
13018 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13023 /* TC min bandwidth setting */
13025 cmd_vf_tc_min_bw_parsed(
13026 void *parsed_result,
13027 __attribute__((unused)) struct cmdline *cl,
13028 __attribute__((unused)) void *data)
13030 struct cmd_vf_tc_bw_result *res = parsed_result;
13033 int ret = -ENOTSUP;
13035 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13038 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13042 #ifdef RTE_LIBRTE_I40E_PMD
13043 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13051 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13054 printf("invalid port_id %d\n", res->port_id);
13057 printf("function not implemented\n");
13060 printf("programming error: (%s)\n", strerror(-ret));
13064 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13065 .f = cmd_vf_tc_min_bw_parsed,
13067 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13068 " <bw1, bw2, ...>",
13070 (void *)&cmd_vf_tc_bw_set,
13071 (void *)&cmd_vf_tc_bw_vf,
13072 (void *)&cmd_vf_tc_bw_tc,
13073 (void *)&cmd_vf_tc_bw_tx,
13074 (void *)&cmd_vf_tc_bw_min_bw,
13075 (void *)&cmd_vf_tc_bw_port_id,
13076 (void *)&cmd_vf_tc_bw_vf_id,
13077 (void *)&cmd_vf_tc_bw_bw_list,
13083 cmd_tc_min_bw_parsed(
13084 void *parsed_result,
13085 __attribute__((unused)) struct cmdline *cl,
13086 __attribute__((unused)) void *data)
13088 struct cmd_vf_tc_bw_result *res = parsed_result;
13089 struct rte_port *port;
13092 int ret = -ENOTSUP;
13094 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13097 port = &ports[res->port_id];
13098 /** Check if the port is not started **/
13099 if (port->port_status != RTE_PORT_STOPPED) {
13100 printf("Please stop port %d first\n", res->port_id);
13104 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13108 #ifdef RTE_LIBRTE_IXGBE_PMD
13109 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13116 printf("invalid bandwidth\n");
13119 printf("invalid port_id %d\n", res->port_id);
13122 printf("function not implemented\n");
13125 printf("programming error: (%s)\n", strerror(-ret));
13129 cmdline_parse_inst_t cmd_tc_min_bw = {
13130 .f = cmd_tc_min_bw_parsed,
13132 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13134 (void *)&cmd_vf_tc_bw_set,
13135 (void *)&cmd_vf_tc_bw_tc,
13136 (void *)&cmd_vf_tc_bw_tx,
13137 (void *)&cmd_vf_tc_bw_min_bw,
13138 (void *)&cmd_vf_tc_bw_port_id,
13139 (void *)&cmd_vf_tc_bw_bw_list,
13144 /* TC max bandwidth setting */
13146 cmd_vf_tc_max_bw_parsed(
13147 void *parsed_result,
13148 __attribute__((unused)) struct cmdline *cl,
13149 __attribute__((unused)) void *data)
13151 struct cmd_vf_tc_bw_result *res = parsed_result;
13152 int ret = -ENOTSUP;
13154 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13157 #ifdef RTE_LIBRTE_I40E_PMD
13158 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13159 res->tc_no, res->bw);
13166 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13167 res->vf_id, res->tc_no, res->bw);
13170 printf("invalid port_id %d\n", res->port_id);
13173 printf("function not implemented\n");
13176 printf("programming error: (%s)\n", strerror(-ret));
13180 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13181 .f = cmd_vf_tc_max_bw_parsed,
13183 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13186 (void *)&cmd_vf_tc_bw_set,
13187 (void *)&cmd_vf_tc_bw_vf,
13188 (void *)&cmd_vf_tc_bw_tc,
13189 (void *)&cmd_vf_tc_bw_tx,
13190 (void *)&cmd_vf_tc_bw_max_bw,
13191 (void *)&cmd_vf_tc_bw_port_id,
13192 (void *)&cmd_vf_tc_bw_vf_id,
13193 (void *)&cmd_vf_tc_bw_tc_no,
13194 (void *)&cmd_vf_tc_bw_bw,
13199 /* Strict link priority scheduling mode setting */
13201 cmd_strict_link_prio_parsed(
13202 void *parsed_result,
13203 __attribute__((unused)) struct cmdline *cl,
13204 __attribute__((unused)) void *data)
13206 struct cmd_vf_tc_bw_result *res = parsed_result;
13207 int ret = -ENOTSUP;
13209 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13212 #ifdef RTE_LIBRTE_I40E_PMD
13213 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13220 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13223 printf("invalid port_id %d\n", res->port_id);
13226 printf("function not implemented\n");
13229 printf("programming error: (%s)\n", strerror(-ret));
13233 cmdline_parse_inst_t cmd_strict_link_prio = {
13234 .f = cmd_strict_link_prio_parsed,
13236 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13238 (void *)&cmd_vf_tc_bw_set,
13239 (void *)&cmd_vf_tc_bw_tx,
13240 (void *)&cmd_vf_tc_bw_strict_link_prio,
13241 (void *)&cmd_vf_tc_bw_port_id,
13242 (void *)&cmd_vf_tc_bw_tc_map,
13247 /* Load dynamic device personalization*/
13248 struct cmd_ddp_add_result {
13249 cmdline_fixed_string_t ddp;
13250 cmdline_fixed_string_t add;
13255 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13256 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13257 cmdline_parse_token_string_t cmd_ddp_add_add =
13258 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13259 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13260 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
13261 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13262 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13265 cmd_ddp_add_parsed(
13266 void *parsed_result,
13267 __attribute__((unused)) struct cmdline *cl,
13268 __attribute__((unused)) void *data)
13270 struct cmd_ddp_add_result *res = parsed_result;
13276 int ret = -ENOTSUP;
13278 if (res->port_id > nb_ports) {
13279 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13283 if (!all_ports_stopped()) {
13284 printf("Please stop all ports first\n");
13288 filepath = strdup(res->filepath);
13289 if (filepath == NULL) {
13290 printf("Failed to allocate memory\n");
13293 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13295 buff = open_ddp_package_file(file_fld[0], &size);
13297 free((void *)filepath);
13301 #ifdef RTE_LIBRTE_I40E_PMD
13302 if (ret == -ENOTSUP)
13303 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13305 RTE_PMD_I40E_PKG_OP_WR_ADD);
13308 if (ret == -EEXIST)
13309 printf("Profile has already existed.\n");
13311 printf("Failed to load profile.\n");
13312 else if (file_num == 2)
13313 save_ddp_package_file(file_fld[1], buff, size);
13315 close_ddp_package_file(buff);
13316 free((void *)filepath);
13319 cmdline_parse_inst_t cmd_ddp_add = {
13320 .f = cmd_ddp_add_parsed,
13322 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
13324 (void *)&cmd_ddp_add_ddp,
13325 (void *)&cmd_ddp_add_add,
13326 (void *)&cmd_ddp_add_port_id,
13327 (void *)&cmd_ddp_add_filepath,
13332 /* Delete dynamic device personalization*/
13333 struct cmd_ddp_del_result {
13334 cmdline_fixed_string_t ddp;
13335 cmdline_fixed_string_t del;
13340 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13341 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13342 cmdline_parse_token_string_t cmd_ddp_del_del =
13343 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13344 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13345 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT8);
13346 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13347 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13350 cmd_ddp_del_parsed(
13351 void *parsed_result,
13352 __attribute__((unused)) struct cmdline *cl,
13353 __attribute__((unused)) void *data)
13355 struct cmd_ddp_del_result *res = parsed_result;
13358 int ret = -ENOTSUP;
13360 if (res->port_id > nb_ports) {
13361 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13365 if (!all_ports_stopped()) {
13366 printf("Please stop all ports first\n");
13370 buff = open_ddp_package_file(res->filepath, &size);
13374 #ifdef RTE_LIBRTE_I40E_PMD
13375 if (ret == -ENOTSUP)
13376 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13378 RTE_PMD_I40E_PKG_OP_WR_DEL);
13381 if (ret == -EACCES)
13382 printf("Profile does not exist.\n");
13384 printf("Failed to delete profile.\n");
13386 close_ddp_package_file(buff);
13389 cmdline_parse_inst_t cmd_ddp_del = {
13390 .f = cmd_ddp_del_parsed,
13392 .help_str = "ddp del <port_id> <profile_path>",
13394 (void *)&cmd_ddp_del_ddp,
13395 (void *)&cmd_ddp_del_del,
13396 (void *)&cmd_ddp_del_port_id,
13397 (void *)&cmd_ddp_del_filepath,
13402 /* Get dynamic device personalization profile info */
13403 struct cmd_ddp_info_result {
13404 cmdline_fixed_string_t ddp;
13405 cmdline_fixed_string_t get;
13406 cmdline_fixed_string_t info;
13410 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13411 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13412 cmdline_parse_token_string_t cmd_ddp_info_get =
13413 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13414 cmdline_parse_token_string_t cmd_ddp_info_info =
13415 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13416 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13417 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13420 cmd_ddp_info_parsed(
13421 void *parsed_result,
13422 __attribute__((unused)) struct cmdline *cl,
13423 __attribute__((unused)) void *data)
13425 struct cmd_ddp_info_result *res = parsed_result;
13428 int ret = -ENOTSUP;
13429 #ifdef RTE_LIBRTE_I40E_PMD
13432 uint32_t buff_size;
13433 struct rte_pmd_i40e_profile_info info;
13435 struct rte_pmd_i40e_ddp_device_id *devs;
13438 pkg = open_ddp_package_file(res->filepath, &pkg_size);
13442 #ifdef RTE_LIBRTE_I40E_PMD
13443 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13444 (uint8_t *)&info, sizeof(info),
13445 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13447 printf("Global Track id: 0x%x\n", info.track_id);
13448 printf("Global Version: %d.%d.%d.%d\n",
13449 info.version.major,
13450 info.version.minor,
13451 info.version.update,
13452 info.version.draft);
13453 printf("Global Package name: %s\n\n", info.name);
13456 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13457 (uint8_t *)&info, sizeof(info),
13458 RTE_PMD_I40E_PKG_INFO_HEADER);
13460 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13461 printf("i40e Profile Version: %d.%d.%d.%d\n",
13462 info.version.major,
13463 info.version.minor,
13464 info.version.update,
13465 info.version.draft);
13466 printf("i40e Profile name: %s\n\n", info.name);
13469 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13470 (uint8_t *)&buff_size, sizeof(buff_size),
13471 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13472 if (!ret && buff_size) {
13473 buff = (uint8_t *)malloc(buff_size);
13475 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13477 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13479 printf("Package Notes:\n%s\n\n", buff);
13484 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13485 (uint8_t *)&dev_num, sizeof(dev_num),
13486 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13487 if (!ret && dev_num) {
13488 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(dev_num *
13489 sizeof(struct rte_pmd_i40e_ddp_device_id));
13491 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13492 (uint8_t *)devs, dev_num *
13493 sizeof(struct rte_pmd_i40e_ddp_device_id),
13494 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13496 printf("List of supported devices:\n");
13497 for (i = 0; i < dev_num; i++) {
13498 printf(" %04X:%04X %04X:%04X\n",
13499 devs[i].vendor_dev_id >> 16,
13500 devs[i].vendor_dev_id & 0xFFFF,
13501 devs[i].sub_vendor_dev_id >> 16,
13502 devs[i].sub_vendor_dev_id & 0xFFFF);
13511 if (ret == -ENOTSUP)
13512 printf("Function not supported in PMD driver\n");
13513 close_ddp_package_file(pkg);
13516 cmdline_parse_inst_t cmd_ddp_get_info = {
13517 .f = cmd_ddp_info_parsed,
13519 .help_str = "ddp get info <profile_path>",
13521 (void *)&cmd_ddp_info_ddp,
13522 (void *)&cmd_ddp_info_get,
13523 (void *)&cmd_ddp_info_info,
13524 (void *)&cmd_ddp_info_filepath,
13529 /* Get dynamic device personalization profile info list*/
13530 #define PROFILE_INFO_SIZE 48
13531 #define MAX_PROFILE_NUM 16
13533 struct cmd_ddp_get_list_result {
13534 cmdline_fixed_string_t ddp;
13535 cmdline_fixed_string_t get;
13536 cmdline_fixed_string_t list;
13540 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
13541 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
13542 cmdline_parse_token_string_t cmd_ddp_get_list_get =
13543 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
13544 cmdline_parse_token_string_t cmd_ddp_get_list_list =
13545 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
13546 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
13547 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
13550 cmd_ddp_get_list_parsed(
13551 void *parsed_result,
13552 __attribute__((unused)) struct cmdline *cl,
13553 __attribute__((unused)) void *data)
13555 struct cmd_ddp_get_list_result *res = parsed_result;
13556 #ifdef RTE_LIBRTE_I40E_PMD
13557 struct rte_pmd_i40e_profile_list *p_list;
13558 struct rte_pmd_i40e_profile_info *p_info;
13563 int ret = -ENOTSUP;
13565 if (res->port_id > nb_ports) {
13566 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13570 #ifdef RTE_LIBRTE_I40E_PMD
13571 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
13572 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
13574 printf("%s: Failed to malloc buffer\n", __func__);
13576 if (ret == -ENOTSUP)
13577 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
13578 (uint8_t *)p_list, size);
13581 p_num = p_list->p_count;
13582 printf("Profile number is: %d\n\n", p_num);
13584 for (i = 0; i < p_num; i++) {
13585 p_info = &p_list->p_info[i];
13586 printf("Profile %d:\n", i);
13587 printf("Track id: 0x%x\n", p_info->track_id);
13588 printf("Version: %d.%d.%d.%d\n",
13589 p_info->version.major,
13590 p_info->version.minor,
13591 p_info->version.update,
13592 p_info->version.draft);
13593 printf("Profile name: %s\n\n", p_info->name);
13601 printf("Failed to get ddp list\n");
13604 cmdline_parse_inst_t cmd_ddp_get_list = {
13605 .f = cmd_ddp_get_list_parsed,
13607 .help_str = "ddp get list <port_id>",
13609 (void *)&cmd_ddp_get_list_ddp,
13610 (void *)&cmd_ddp_get_list_get,
13611 (void *)&cmd_ddp_get_list_list,
13612 (void *)&cmd_ddp_get_list_port_id,
13617 /* show vf stats */
13619 /* Common result structure for show vf stats */
13620 struct cmd_show_vf_stats_result {
13621 cmdline_fixed_string_t show;
13622 cmdline_fixed_string_t vf;
13623 cmdline_fixed_string_t stats;
13628 /* Common CLI fields show vf stats*/
13629 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13630 TOKEN_STRING_INITIALIZER
13631 (struct cmd_show_vf_stats_result,
13633 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13634 TOKEN_STRING_INITIALIZER
13635 (struct cmd_show_vf_stats_result,
13637 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13638 TOKEN_STRING_INITIALIZER
13639 (struct cmd_show_vf_stats_result,
13641 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13642 TOKEN_NUM_INITIALIZER
13643 (struct cmd_show_vf_stats_result,
13645 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13646 TOKEN_NUM_INITIALIZER
13647 (struct cmd_show_vf_stats_result,
13651 cmd_show_vf_stats_parsed(
13652 void *parsed_result,
13653 __attribute__((unused)) struct cmdline *cl,
13654 __attribute__((unused)) void *data)
13656 struct cmd_show_vf_stats_result *res = parsed_result;
13657 struct rte_eth_stats stats;
13658 int ret = -ENOTSUP;
13659 static const char *nic_stats_border = "########################";
13661 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13664 memset(&stats, 0, sizeof(stats));
13666 #ifdef RTE_LIBRTE_I40E_PMD
13667 if (ret == -ENOTSUP)
13668 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13672 #ifdef RTE_LIBRTE_BNXT_PMD
13673 if (ret == -ENOTSUP)
13674 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
13683 printf("invalid vf_id %d\n", res->vf_id);
13686 printf("invalid port_id %d\n", res->port_id);
13689 printf("function not implemented\n");
13692 printf("programming error: (%s)\n", strerror(-ret));
13695 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13696 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13698 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13700 stats.ipackets, stats.imissed, stats.ibytes);
13701 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13702 printf(" RX-nombuf: %-10"PRIu64"\n",
13704 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13706 stats.opackets, stats.oerrors, stats.obytes);
13708 printf(" %s############################%s\n",
13709 nic_stats_border, nic_stats_border);
13712 cmdline_parse_inst_t cmd_show_vf_stats = {
13713 .f = cmd_show_vf_stats_parsed,
13715 .help_str = "show vf stats <port_id> <vf_id>",
13717 (void *)&cmd_show_vf_stats_show,
13718 (void *)&cmd_show_vf_stats_vf,
13719 (void *)&cmd_show_vf_stats_stats,
13720 (void *)&cmd_show_vf_stats_port_id,
13721 (void *)&cmd_show_vf_stats_vf_id,
13726 /* clear vf stats */
13728 /* Common result structure for clear vf stats */
13729 struct cmd_clear_vf_stats_result {
13730 cmdline_fixed_string_t clear;
13731 cmdline_fixed_string_t vf;
13732 cmdline_fixed_string_t stats;
13737 /* Common CLI fields clear vf stats*/
13738 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13739 TOKEN_STRING_INITIALIZER
13740 (struct cmd_clear_vf_stats_result,
13742 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13743 TOKEN_STRING_INITIALIZER
13744 (struct cmd_clear_vf_stats_result,
13746 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13747 TOKEN_STRING_INITIALIZER
13748 (struct cmd_clear_vf_stats_result,
13750 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13751 TOKEN_NUM_INITIALIZER
13752 (struct cmd_clear_vf_stats_result,
13754 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13755 TOKEN_NUM_INITIALIZER
13756 (struct cmd_clear_vf_stats_result,
13760 cmd_clear_vf_stats_parsed(
13761 void *parsed_result,
13762 __attribute__((unused)) struct cmdline *cl,
13763 __attribute__((unused)) void *data)
13765 struct cmd_clear_vf_stats_result *res = parsed_result;
13766 int ret = -ENOTSUP;
13768 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13771 #ifdef RTE_LIBRTE_I40E_PMD
13772 if (ret == -ENOTSUP)
13773 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13776 #ifdef RTE_LIBRTE_BNXT_PMD
13777 if (ret == -ENOTSUP)
13778 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
13786 printf("invalid vf_id %d\n", res->vf_id);
13789 printf("invalid port_id %d\n", res->port_id);
13792 printf("function not implemented\n");
13795 printf("programming error: (%s)\n", strerror(-ret));
13799 cmdline_parse_inst_t cmd_clear_vf_stats = {
13800 .f = cmd_clear_vf_stats_parsed,
13802 .help_str = "clear vf stats <port_id> <vf_id>",
13804 (void *)&cmd_clear_vf_stats_clear,
13805 (void *)&cmd_clear_vf_stats_vf,
13806 (void *)&cmd_clear_vf_stats_stats,
13807 (void *)&cmd_clear_vf_stats_port_id,
13808 (void *)&cmd_clear_vf_stats_vf_id,
13813 /* ptype mapping get */
13815 /* Common result structure for ptype mapping get */
13816 struct cmd_ptype_mapping_get_result {
13817 cmdline_fixed_string_t ptype;
13818 cmdline_fixed_string_t mapping;
13819 cmdline_fixed_string_t get;
13821 uint8_t valid_only;
13824 /* Common CLI fields for ptype mapping get */
13825 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
13826 TOKEN_STRING_INITIALIZER
13827 (struct cmd_ptype_mapping_get_result,
13829 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
13830 TOKEN_STRING_INITIALIZER
13831 (struct cmd_ptype_mapping_get_result,
13832 mapping, "mapping");
13833 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
13834 TOKEN_STRING_INITIALIZER
13835 (struct cmd_ptype_mapping_get_result,
13837 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
13838 TOKEN_NUM_INITIALIZER
13839 (struct cmd_ptype_mapping_get_result,
13841 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
13842 TOKEN_NUM_INITIALIZER
13843 (struct cmd_ptype_mapping_get_result,
13844 valid_only, UINT8);
13847 cmd_ptype_mapping_get_parsed(
13848 void *parsed_result,
13849 __attribute__((unused)) struct cmdline *cl,
13850 __attribute__((unused)) void *data)
13852 struct cmd_ptype_mapping_get_result *res = parsed_result;
13853 int ret = -ENOTSUP;
13854 #ifdef RTE_LIBRTE_I40E_PMD
13855 int max_ptype_num = 256;
13856 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
13861 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13864 #ifdef RTE_LIBRTE_I40E_PMD
13865 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
13876 printf("invalid port_id %d\n", res->port_id);
13879 printf("function not implemented\n");
13882 printf("programming error: (%s)\n", strerror(-ret));
13885 #ifdef RTE_LIBRTE_I40E_PMD
13887 for (i = 0; i < count; i++)
13888 printf("%3d\t0x%08x\n",
13889 mapping[i].hw_ptype, mapping[i].sw_ptype);
13894 cmdline_parse_inst_t cmd_ptype_mapping_get = {
13895 .f = cmd_ptype_mapping_get_parsed,
13897 .help_str = "ptype mapping get <port_id> <valid_only>",
13899 (void *)&cmd_ptype_mapping_get_ptype,
13900 (void *)&cmd_ptype_mapping_get_mapping,
13901 (void *)&cmd_ptype_mapping_get_get,
13902 (void *)&cmd_ptype_mapping_get_port_id,
13903 (void *)&cmd_ptype_mapping_get_valid_only,
13908 /* ptype mapping replace */
13910 /* Common result structure for ptype mapping replace */
13911 struct cmd_ptype_mapping_replace_result {
13912 cmdline_fixed_string_t ptype;
13913 cmdline_fixed_string_t mapping;
13914 cmdline_fixed_string_t replace;
13921 /* Common CLI fields for ptype mapping replace */
13922 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
13923 TOKEN_STRING_INITIALIZER
13924 (struct cmd_ptype_mapping_replace_result,
13926 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
13927 TOKEN_STRING_INITIALIZER
13928 (struct cmd_ptype_mapping_replace_result,
13929 mapping, "mapping");
13930 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
13931 TOKEN_STRING_INITIALIZER
13932 (struct cmd_ptype_mapping_replace_result,
13933 replace, "replace");
13934 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
13935 TOKEN_NUM_INITIALIZER
13936 (struct cmd_ptype_mapping_replace_result,
13938 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
13939 TOKEN_NUM_INITIALIZER
13940 (struct cmd_ptype_mapping_replace_result,
13942 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
13943 TOKEN_NUM_INITIALIZER
13944 (struct cmd_ptype_mapping_replace_result,
13946 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
13947 TOKEN_NUM_INITIALIZER
13948 (struct cmd_ptype_mapping_replace_result,
13952 cmd_ptype_mapping_replace_parsed(
13953 void *parsed_result,
13954 __attribute__((unused)) struct cmdline *cl,
13955 __attribute__((unused)) void *data)
13957 struct cmd_ptype_mapping_replace_result *res = parsed_result;
13958 int ret = -ENOTSUP;
13960 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13963 #ifdef RTE_LIBRTE_I40E_PMD
13964 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
13974 printf("invalid ptype 0x%8x or 0x%8x\n",
13975 res->target, res->pkt_type);
13978 printf("invalid port_id %d\n", res->port_id);
13981 printf("function not implemented\n");
13984 printf("programming error: (%s)\n", strerror(-ret));
13988 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
13989 .f = cmd_ptype_mapping_replace_parsed,
13992 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
13994 (void *)&cmd_ptype_mapping_replace_ptype,
13995 (void *)&cmd_ptype_mapping_replace_mapping,
13996 (void *)&cmd_ptype_mapping_replace_replace,
13997 (void *)&cmd_ptype_mapping_replace_port_id,
13998 (void *)&cmd_ptype_mapping_replace_target,
13999 (void *)&cmd_ptype_mapping_replace_mask,
14000 (void *)&cmd_ptype_mapping_replace_pkt_type,
14005 /* ptype mapping reset */
14007 /* Common result structure for ptype mapping reset */
14008 struct cmd_ptype_mapping_reset_result {
14009 cmdline_fixed_string_t ptype;
14010 cmdline_fixed_string_t mapping;
14011 cmdline_fixed_string_t reset;
14015 /* Common CLI fields for ptype mapping reset*/
14016 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
14017 TOKEN_STRING_INITIALIZER
14018 (struct cmd_ptype_mapping_reset_result,
14020 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
14021 TOKEN_STRING_INITIALIZER
14022 (struct cmd_ptype_mapping_reset_result,
14023 mapping, "mapping");
14024 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
14025 TOKEN_STRING_INITIALIZER
14026 (struct cmd_ptype_mapping_reset_result,
14028 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
14029 TOKEN_NUM_INITIALIZER
14030 (struct cmd_ptype_mapping_reset_result,
14034 cmd_ptype_mapping_reset_parsed(
14035 void *parsed_result,
14036 __attribute__((unused)) struct cmdline *cl,
14037 __attribute__((unused)) void *data)
14039 struct cmd_ptype_mapping_reset_result *res = parsed_result;
14040 int ret = -ENOTSUP;
14042 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14045 #ifdef RTE_LIBRTE_I40E_PMD
14046 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
14053 printf("invalid port_id %d\n", res->port_id);
14056 printf("function not implemented\n");
14059 printf("programming error: (%s)\n", strerror(-ret));
14063 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
14064 .f = cmd_ptype_mapping_reset_parsed,
14066 .help_str = "ptype mapping reset <port_id>",
14068 (void *)&cmd_ptype_mapping_reset_ptype,
14069 (void *)&cmd_ptype_mapping_reset_mapping,
14070 (void *)&cmd_ptype_mapping_reset_reset,
14071 (void *)&cmd_ptype_mapping_reset_port_id,
14076 /* ptype mapping update */
14078 /* Common result structure for ptype mapping update */
14079 struct cmd_ptype_mapping_update_result {
14080 cmdline_fixed_string_t ptype;
14081 cmdline_fixed_string_t mapping;
14082 cmdline_fixed_string_t reset;
14088 /* Common CLI fields for ptype mapping update*/
14089 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
14090 TOKEN_STRING_INITIALIZER
14091 (struct cmd_ptype_mapping_update_result,
14093 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
14094 TOKEN_STRING_INITIALIZER
14095 (struct cmd_ptype_mapping_update_result,
14096 mapping, "mapping");
14097 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
14098 TOKEN_STRING_INITIALIZER
14099 (struct cmd_ptype_mapping_update_result,
14101 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
14102 TOKEN_NUM_INITIALIZER
14103 (struct cmd_ptype_mapping_update_result,
14105 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
14106 TOKEN_NUM_INITIALIZER
14107 (struct cmd_ptype_mapping_update_result,
14109 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
14110 TOKEN_NUM_INITIALIZER
14111 (struct cmd_ptype_mapping_update_result,
14115 cmd_ptype_mapping_update_parsed(
14116 void *parsed_result,
14117 __attribute__((unused)) struct cmdline *cl,
14118 __attribute__((unused)) void *data)
14120 struct cmd_ptype_mapping_update_result *res = parsed_result;
14121 int ret = -ENOTSUP;
14122 #ifdef RTE_LIBRTE_I40E_PMD
14123 struct rte_pmd_i40e_ptype_mapping mapping;
14125 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14128 #ifdef RTE_LIBRTE_I40E_PMD
14129 mapping.hw_ptype = res->hw_ptype;
14130 mapping.sw_ptype = res->sw_ptype;
14131 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
14141 printf("invalid ptype 0x%8x\n", res->sw_ptype);
14144 printf("invalid port_id %d\n", res->port_id);
14147 printf("function not implemented\n");
14150 printf("programming error: (%s)\n", strerror(-ret));
14154 cmdline_parse_inst_t cmd_ptype_mapping_update = {
14155 .f = cmd_ptype_mapping_update_parsed,
14157 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
14159 (void *)&cmd_ptype_mapping_update_ptype,
14160 (void *)&cmd_ptype_mapping_update_mapping,
14161 (void *)&cmd_ptype_mapping_update_update,
14162 (void *)&cmd_ptype_mapping_update_port_id,
14163 (void *)&cmd_ptype_mapping_update_hw_ptype,
14164 (void *)&cmd_ptype_mapping_update_sw_ptype,
14169 /* Common result structure for file commands */
14170 struct cmd_cmdfile_result {
14171 cmdline_fixed_string_t load;
14172 cmdline_fixed_string_t filename;
14175 /* Common CLI fields for file commands */
14176 cmdline_parse_token_string_t cmd_load_cmdfile =
14177 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
14178 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
14179 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
14182 cmd_load_from_file_parsed(
14183 void *parsed_result,
14184 __attribute__((unused)) struct cmdline *cl,
14185 __attribute__((unused)) void *data)
14187 struct cmd_cmdfile_result *res = parsed_result;
14189 cmdline_read_from_file(res->filename);
14192 cmdline_parse_inst_t cmd_load_from_file = {
14193 .f = cmd_load_from_file_parsed,
14195 .help_str = "load <filename>",
14197 (void *)&cmd_load_cmdfile,
14198 (void *)&cmd_load_cmdfile_filename,
14203 /* ******************************************************************************** */
14205 /* list of instructions */
14206 cmdline_parse_ctx_t main_ctx[] = {
14207 (cmdline_parse_inst_t *)&cmd_help_brief,
14208 (cmdline_parse_inst_t *)&cmd_help_long,
14209 (cmdline_parse_inst_t *)&cmd_quit,
14210 (cmdline_parse_inst_t *)&cmd_load_from_file,
14211 (cmdline_parse_inst_t *)&cmd_showport,
14212 (cmdline_parse_inst_t *)&cmd_showqueue,
14213 (cmdline_parse_inst_t *)&cmd_showportall,
14214 (cmdline_parse_inst_t *)&cmd_showcfg,
14215 (cmdline_parse_inst_t *)&cmd_start,
14216 (cmdline_parse_inst_t *)&cmd_start_tx_first,
14217 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
14218 (cmdline_parse_inst_t *)&cmd_set_link_up,
14219 (cmdline_parse_inst_t *)&cmd_set_link_down,
14220 (cmdline_parse_inst_t *)&cmd_reset,
14221 (cmdline_parse_inst_t *)&cmd_set_numbers,
14222 (cmdline_parse_inst_t *)&cmd_set_txpkts,
14223 (cmdline_parse_inst_t *)&cmd_set_txsplit,
14224 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
14225 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
14226 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
14227 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
14228 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
14229 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
14230 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
14231 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
14232 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
14233 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
14234 (cmdline_parse_inst_t *)&cmd_set_link_check,
14235 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
14236 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
14237 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
14238 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
14239 #ifdef RTE_LIBRTE_PMD_BOND
14240 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
14241 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
14242 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
14243 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
14244 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
14245 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
14246 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
14247 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
14248 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
14249 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
14250 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
14252 (cmdline_parse_inst_t *)&cmd_vlan_offload,
14253 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
14254 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
14255 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
14256 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
14257 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
14258 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
14259 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
14260 (cmdline_parse_inst_t *)&cmd_csum_set,
14261 (cmdline_parse_inst_t *)&cmd_csum_show,
14262 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
14263 (cmdline_parse_inst_t *)&cmd_tso_set,
14264 (cmdline_parse_inst_t *)&cmd_tso_show,
14265 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
14266 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
14267 (cmdline_parse_inst_t *)&cmd_enable_gro,
14268 (cmdline_parse_inst_t *)&cmd_gro_set,
14269 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
14270 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
14271 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
14272 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
14273 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
14274 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
14275 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
14276 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
14277 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
14278 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
14279 (cmdline_parse_inst_t *)&cmd_config_dcb,
14280 (cmdline_parse_inst_t *)&cmd_read_reg,
14281 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
14282 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
14283 (cmdline_parse_inst_t *)&cmd_write_reg,
14284 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
14285 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
14286 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
14287 (cmdline_parse_inst_t *)&cmd_stop,
14288 (cmdline_parse_inst_t *)&cmd_mac_addr,
14289 (cmdline_parse_inst_t *)&cmd_set_qmap,
14290 (cmdline_parse_inst_t *)&cmd_operate_port,
14291 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
14292 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
14293 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
14294 (cmdline_parse_inst_t *)&cmd_config_speed_all,
14295 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
14296 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
14297 (cmdline_parse_inst_t *)&cmd_config_mtu,
14298 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
14299 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
14300 (cmdline_parse_inst_t *)&cmd_config_rss,
14301 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
14302 (cmdline_parse_inst_t *)&cmd_config_txqflags,
14303 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
14304 (cmdline_parse_inst_t *)&cmd_showport_reta,
14305 (cmdline_parse_inst_t *)&cmd_config_burst,
14306 (cmdline_parse_inst_t *)&cmd_config_thresh,
14307 (cmdline_parse_inst_t *)&cmd_config_threshold,
14308 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
14309 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
14310 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
14311 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
14312 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
14313 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
14314 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
14315 (cmdline_parse_inst_t *)&cmd_global_config,
14316 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
14317 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
14318 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
14319 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
14320 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
14321 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
14322 (cmdline_parse_inst_t *)&cmd_dump,
14323 (cmdline_parse_inst_t *)&cmd_dump_one,
14324 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
14325 (cmdline_parse_inst_t *)&cmd_syn_filter,
14326 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
14327 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
14328 (cmdline_parse_inst_t *)&cmd_flex_filter,
14329 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
14330 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
14331 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
14332 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
14333 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
14334 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
14335 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
14336 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
14337 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
14338 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
14339 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
14340 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
14341 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
14342 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
14343 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
14344 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
14345 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
14346 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
14347 (cmdline_parse_inst_t *)&cmd_flow,
14348 (cmdline_parse_inst_t *)&cmd_mcast_addr,
14349 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
14350 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
14351 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
14352 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
14353 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
14354 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
14355 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
14356 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
14357 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
14358 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
14359 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
14360 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
14361 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
14362 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
14363 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
14364 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
14365 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
14366 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
14367 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
14368 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
14369 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
14370 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
14371 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
14372 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
14373 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
14374 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
14375 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
14376 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
14377 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
14378 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
14379 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
14380 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
14381 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
14382 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
14383 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
14384 (cmdline_parse_inst_t *)&cmd_ddp_add,
14385 (cmdline_parse_inst_t *)&cmd_ddp_del,
14386 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
14387 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
14388 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
14389 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
14390 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
14391 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
14392 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
14393 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
14397 /* read cmdline commands from file */
14399 cmdline_read_from_file(const char *filename)
14401 struct cmdline *cl;
14403 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14405 printf("Failed to create file based cmdline context: %s\n",
14410 cmdline_interact(cl);
14415 printf("Read CLI commands from %s\n", filename);
14418 /* prompt function, called from main on MASTER lcore */
14422 /* initialize non-constant commands */
14423 cmd_set_fwd_mode_init();
14424 cmd_set_fwd_retry_mode_init();
14426 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14427 if (testpmd_cl == NULL)
14429 cmdline_interact(testpmd_cl);
14430 cmdline_stdin_exit(testpmd_cl);
14436 if (testpmd_cl != NULL)
14437 cmdline_quit(testpmd_cl);
14441 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14443 if (id == (portid_t)RTE_PORT_ALL) {
14446 RTE_ETH_FOREACH_DEV(pid) {
14447 /* check if need_reconfig has been set to 1 */
14448 if (ports[pid].need_reconfig == 0)
14449 ports[pid].need_reconfig = dev;
14450 /* check if need_reconfig_queues has been set to 1 */
14451 if (ports[pid].need_reconfig_queues == 0)
14452 ports[pid].need_reconfig_queues = queue;
14454 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14455 /* check if need_reconfig has been set to 1 */
14456 if (ports[id].need_reconfig == 0)
14457 ports[id].need_reconfig = dev;
14458 /* check if need_reconfig_queues has been set to 1 */
14459 if (ports[id].need_reconfig_queues == 0)
14460 ports[id].need_reconfig_queues = queue;