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)
7219 ret = rte_eth_dev_mac_addr_add(res->port_num,
7220 &res->address, res->vf_num);
7222 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7226 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7227 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7228 mac_addr_cmd,"mac_addr");
7229 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7230 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7232 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7233 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7235 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7236 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7238 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7239 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7241 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7242 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7244 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7245 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7248 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7249 .f = cmd_vf_mac_addr_parsed,
7251 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7252 "Add MAC address filtering for a VF on port_id",
7254 (void *)&cmd_vf_mac_addr_cmd,
7255 (void *)&cmd_vf_mac_addr_what,
7256 (void *)&cmd_vf_mac_addr_port,
7257 (void *)&cmd_vf_mac_addr_portnum,
7258 (void *)&cmd_vf_mac_addr_vf,
7259 (void *)&cmd_vf_mac_addr_vfnum,
7260 (void *)&cmd_vf_mac_addr_addr,
7265 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7266 struct cmd_vf_rx_vlan_filter {
7267 cmdline_fixed_string_t rx_vlan;
7268 cmdline_fixed_string_t what;
7270 cmdline_fixed_string_t port;
7272 cmdline_fixed_string_t vf;
7277 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7278 __attribute__((unused)) struct cmdline *cl,
7279 __attribute__((unused)) void *data)
7281 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7284 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7286 #ifdef RTE_LIBRTE_IXGBE_PMD
7287 if (ret == -ENOTSUP)
7288 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7289 res->vlan_id, res->vf_mask, is_add);
7291 #ifdef RTE_LIBRTE_I40E_PMD
7292 if (ret == -ENOTSUP)
7293 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7294 res->vlan_id, res->vf_mask, is_add);
7296 #ifdef RTE_LIBRTE_BNXT_PMD
7297 if (ret == -ENOTSUP)
7298 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7299 res->vlan_id, res->vf_mask, is_add);
7306 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7307 res->vlan_id, res->vf_mask);
7310 printf("invalid port_id %d\n", res->port_id);
7313 printf("function not implemented or supported\n");
7316 printf("programming error: (%s)\n", strerror(-ret));
7320 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7321 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7322 rx_vlan, "rx_vlan");
7323 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7324 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7326 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7327 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7329 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7330 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7332 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7333 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7335 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7336 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7338 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7339 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7342 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7343 .f = cmd_vf_rx_vlan_filter_parsed,
7345 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7346 "(vf_mask = hexadecimal VF mask)",
7348 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7349 (void *)&cmd_vf_rx_vlan_filter_what,
7350 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7351 (void *)&cmd_vf_rx_vlan_filter_port,
7352 (void *)&cmd_vf_rx_vlan_filter_portid,
7353 (void *)&cmd_vf_rx_vlan_filter_vf,
7354 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7359 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7360 struct cmd_queue_rate_limit_result {
7361 cmdline_fixed_string_t set;
7362 cmdline_fixed_string_t port;
7364 cmdline_fixed_string_t queue;
7366 cmdline_fixed_string_t rate;
7370 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7371 __attribute__((unused)) struct cmdline *cl,
7372 __attribute__((unused)) void *data)
7374 struct cmd_queue_rate_limit_result *res = parsed_result;
7377 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7378 && (strcmp(res->queue, "queue") == 0)
7379 && (strcmp(res->rate, "rate") == 0))
7380 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7383 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7387 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7388 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7390 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7391 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7393 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7394 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7396 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7397 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7399 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7400 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7402 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7403 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7405 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7406 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7409 cmdline_parse_inst_t cmd_queue_rate_limit = {
7410 .f = cmd_queue_rate_limit_parsed,
7412 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7413 "Set rate limit for a queue on port_id",
7415 (void *)&cmd_queue_rate_limit_set,
7416 (void *)&cmd_queue_rate_limit_port,
7417 (void *)&cmd_queue_rate_limit_portnum,
7418 (void *)&cmd_queue_rate_limit_queue,
7419 (void *)&cmd_queue_rate_limit_queuenum,
7420 (void *)&cmd_queue_rate_limit_rate,
7421 (void *)&cmd_queue_rate_limit_ratenum,
7426 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7427 struct cmd_vf_rate_limit_result {
7428 cmdline_fixed_string_t set;
7429 cmdline_fixed_string_t port;
7431 cmdline_fixed_string_t vf;
7433 cmdline_fixed_string_t rate;
7435 cmdline_fixed_string_t q_msk;
7439 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7440 __attribute__((unused)) struct cmdline *cl,
7441 __attribute__((unused)) void *data)
7443 struct cmd_vf_rate_limit_result *res = parsed_result;
7446 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7447 && (strcmp(res->vf, "vf") == 0)
7448 && (strcmp(res->rate, "rate") == 0)
7449 && (strcmp(res->q_msk, "queue_mask") == 0))
7450 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7451 res->rate_num, res->q_msk_val);
7453 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7457 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7458 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7460 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7461 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7463 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7464 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7466 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7467 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7469 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7470 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7472 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7473 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7475 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7476 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7478 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7479 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7480 q_msk, "queue_mask");
7481 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7482 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7485 cmdline_parse_inst_t cmd_vf_rate_limit = {
7486 .f = cmd_vf_rate_limit_parsed,
7488 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7489 "queue_mask <queue_mask_value>: "
7490 "Set rate limit for queues of VF on port_id",
7492 (void *)&cmd_vf_rate_limit_set,
7493 (void *)&cmd_vf_rate_limit_port,
7494 (void *)&cmd_vf_rate_limit_portnum,
7495 (void *)&cmd_vf_rate_limit_vf,
7496 (void *)&cmd_vf_rate_limit_vfnum,
7497 (void *)&cmd_vf_rate_limit_rate,
7498 (void *)&cmd_vf_rate_limit_ratenum,
7499 (void *)&cmd_vf_rate_limit_q_msk,
7500 (void *)&cmd_vf_rate_limit_q_msk_val,
7505 /* *** ADD TUNNEL FILTER OF A PORT *** */
7506 struct cmd_tunnel_filter_result {
7507 cmdline_fixed_string_t cmd;
7508 cmdline_fixed_string_t what;
7510 struct ether_addr outer_mac;
7511 struct ether_addr inner_mac;
7512 cmdline_ipaddr_t ip_value;
7513 uint16_t inner_vlan;
7514 cmdline_fixed_string_t tunnel_type;
7515 cmdline_fixed_string_t filter_type;
7521 cmd_tunnel_filter_parsed(void *parsed_result,
7522 __attribute__((unused)) struct cmdline *cl,
7523 __attribute__((unused)) void *data)
7525 struct cmd_tunnel_filter_result *res = parsed_result;
7526 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7529 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7531 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7532 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7533 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7535 if (res->ip_value.family == AF_INET) {
7536 tunnel_filter_conf.ip_addr.ipv4_addr =
7537 res->ip_value.addr.ipv4.s_addr;
7538 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7540 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7541 &(res->ip_value.addr.ipv6),
7542 sizeof(struct in6_addr));
7543 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7546 if (!strcmp(res->filter_type, "imac-ivlan"))
7547 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7548 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7549 tunnel_filter_conf.filter_type =
7550 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7551 else if (!strcmp(res->filter_type, "imac-tenid"))
7552 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7553 else if (!strcmp(res->filter_type, "imac"))
7554 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7555 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7556 tunnel_filter_conf.filter_type =
7557 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7558 else if (!strcmp(res->filter_type, "oip"))
7559 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7560 else if (!strcmp(res->filter_type, "iip"))
7561 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7563 printf("The filter type is not supported");
7567 if (!strcmp(res->tunnel_type, "vxlan"))
7568 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7569 else if (!strcmp(res->tunnel_type, "nvgre"))
7570 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7571 else if (!strcmp(res->tunnel_type, "ipingre"))
7572 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7574 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7578 tunnel_filter_conf.tenant_id = res->tenant_id;
7579 tunnel_filter_conf.queue_id = res->queue_num;
7580 if (!strcmp(res->what, "add"))
7581 ret = rte_eth_dev_filter_ctrl(res->port_id,
7582 RTE_ETH_FILTER_TUNNEL,
7584 &tunnel_filter_conf);
7586 ret = rte_eth_dev_filter_ctrl(res->port_id,
7587 RTE_ETH_FILTER_TUNNEL,
7588 RTE_ETH_FILTER_DELETE,
7589 &tunnel_filter_conf);
7591 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7595 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7596 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7597 cmd, "tunnel_filter");
7598 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7599 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7601 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7602 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7604 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7605 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7607 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7608 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7610 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7611 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7612 inner_vlan, UINT16);
7613 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7614 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7616 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7617 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7618 tunnel_type, "vxlan#nvgre#ipingre");
7620 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7621 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7622 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7623 "imac#omac-imac-tenid");
7624 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7625 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7627 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7628 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7631 cmdline_parse_inst_t cmd_tunnel_filter = {
7632 .f = cmd_tunnel_filter_parsed,
7634 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7635 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7636 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7637 "<queue_id>: Add/Rm tunnel filter of a port",
7639 (void *)&cmd_tunnel_filter_cmd,
7640 (void *)&cmd_tunnel_filter_what,
7641 (void *)&cmd_tunnel_filter_port_id,
7642 (void *)&cmd_tunnel_filter_outer_mac,
7643 (void *)&cmd_tunnel_filter_inner_mac,
7644 (void *)&cmd_tunnel_filter_ip_value,
7645 (void *)&cmd_tunnel_filter_innner_vlan,
7646 (void *)&cmd_tunnel_filter_tunnel_type,
7647 (void *)&cmd_tunnel_filter_filter_type,
7648 (void *)&cmd_tunnel_filter_tenant_id,
7649 (void *)&cmd_tunnel_filter_queue_num,
7654 /* *** CONFIGURE TUNNEL UDP PORT *** */
7655 struct cmd_tunnel_udp_config {
7656 cmdline_fixed_string_t cmd;
7657 cmdline_fixed_string_t what;
7663 cmd_tunnel_udp_config_parsed(void *parsed_result,
7664 __attribute__((unused)) struct cmdline *cl,
7665 __attribute__((unused)) void *data)
7667 struct cmd_tunnel_udp_config *res = parsed_result;
7668 struct rte_eth_udp_tunnel tunnel_udp;
7671 tunnel_udp.udp_port = res->udp_port;
7673 if (!strcmp(res->cmd, "rx_vxlan_port"))
7674 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7676 if (!strcmp(res->what, "add"))
7677 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7680 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7684 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7687 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7688 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7689 cmd, "rx_vxlan_port");
7690 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7691 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7693 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7694 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7696 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7697 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7700 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7701 .f = cmd_tunnel_udp_config_parsed,
7703 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7704 "Add/Remove a tunneling UDP port filter",
7706 (void *)&cmd_tunnel_udp_config_cmd,
7707 (void *)&cmd_tunnel_udp_config_what,
7708 (void *)&cmd_tunnel_udp_config_udp_port,
7709 (void *)&cmd_tunnel_udp_config_port_id,
7714 /* *** GLOBAL CONFIG *** */
7715 struct cmd_global_config_result {
7716 cmdline_fixed_string_t cmd;
7718 cmdline_fixed_string_t cfg_type;
7723 cmd_global_config_parsed(void *parsed_result,
7724 __attribute__((unused)) struct cmdline *cl,
7725 __attribute__((unused)) void *data)
7727 struct cmd_global_config_result *res = parsed_result;
7728 struct rte_eth_global_cfg conf;
7731 memset(&conf, 0, sizeof(conf));
7732 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7733 conf.cfg.gre_key_len = res->len;
7734 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7735 RTE_ETH_FILTER_SET, &conf);
7737 printf("Global config error\n");
7740 cmdline_parse_token_string_t cmd_global_config_cmd =
7741 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7743 cmdline_parse_token_num_t cmd_global_config_port_id =
7744 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7745 cmdline_parse_token_string_t cmd_global_config_type =
7746 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7747 cfg_type, "gre-key-len");
7748 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7749 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7752 cmdline_parse_inst_t cmd_global_config = {
7753 .f = cmd_global_config_parsed,
7754 .data = (void *)NULL,
7755 .help_str = "global_config <port_id> gre-key-len <key_len>",
7757 (void *)&cmd_global_config_cmd,
7758 (void *)&cmd_global_config_port_id,
7759 (void *)&cmd_global_config_type,
7760 (void *)&cmd_global_config_gre_key_len,
7765 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7766 struct cmd_set_mirror_mask_result {
7767 cmdline_fixed_string_t set;
7768 cmdline_fixed_string_t port;
7770 cmdline_fixed_string_t mirror;
7772 cmdline_fixed_string_t what;
7773 cmdline_fixed_string_t value;
7774 cmdline_fixed_string_t dstpool;
7776 cmdline_fixed_string_t on;
7779 cmdline_parse_token_string_t cmd_mirror_mask_set =
7780 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7782 cmdline_parse_token_string_t cmd_mirror_mask_port =
7783 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7785 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7786 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7788 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7789 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7790 mirror, "mirror-rule");
7791 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7792 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7794 cmdline_parse_token_string_t cmd_mirror_mask_what =
7795 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7796 what, "pool-mirror-up#pool-mirror-down"
7798 cmdline_parse_token_string_t cmd_mirror_mask_value =
7799 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7801 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7802 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7803 dstpool, "dst-pool");
7804 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7805 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7807 cmdline_parse_token_string_t cmd_mirror_mask_on =
7808 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7812 cmd_set_mirror_mask_parsed(void *parsed_result,
7813 __attribute__((unused)) struct cmdline *cl,
7814 __attribute__((unused)) void *data)
7817 struct cmd_set_mirror_mask_result *res = parsed_result;
7818 struct rte_eth_mirror_conf mr_conf;
7820 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7822 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7824 mr_conf.dst_pool = res->dstpool_id;
7826 if (!strcmp(res->what, "pool-mirror-up")) {
7827 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7828 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7829 } else if (!strcmp(res->what, "pool-mirror-down")) {
7830 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7831 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7832 } else if (!strcmp(res->what, "vlan-mirror")) {
7833 mr_conf.rule_type = ETH_MIRROR_VLAN;
7834 nb_item = parse_item_list(res->value, "vlan",
7835 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7839 for (i = 0; i < nb_item; i++) {
7840 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7841 printf("Invalid vlan_id: must be < 4096\n");
7845 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7846 mr_conf.vlan.vlan_mask |= 1ULL << i;
7850 if (!strcmp(res->on, "on"))
7851 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7854 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7857 printf("mirror rule add error: (%s)\n", strerror(-ret));
7860 cmdline_parse_inst_t cmd_set_mirror_mask = {
7861 .f = cmd_set_mirror_mask_parsed,
7863 .help_str = "set port <port_id> mirror-rule <rule_id> "
7864 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7865 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7867 (void *)&cmd_mirror_mask_set,
7868 (void *)&cmd_mirror_mask_port,
7869 (void *)&cmd_mirror_mask_portid,
7870 (void *)&cmd_mirror_mask_mirror,
7871 (void *)&cmd_mirror_mask_ruleid,
7872 (void *)&cmd_mirror_mask_what,
7873 (void *)&cmd_mirror_mask_value,
7874 (void *)&cmd_mirror_mask_dstpool,
7875 (void *)&cmd_mirror_mask_poolid,
7876 (void *)&cmd_mirror_mask_on,
7881 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7882 struct cmd_set_mirror_link_result {
7883 cmdline_fixed_string_t set;
7884 cmdline_fixed_string_t port;
7886 cmdline_fixed_string_t mirror;
7888 cmdline_fixed_string_t what;
7889 cmdline_fixed_string_t dstpool;
7891 cmdline_fixed_string_t on;
7894 cmdline_parse_token_string_t cmd_mirror_link_set =
7895 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7897 cmdline_parse_token_string_t cmd_mirror_link_port =
7898 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7900 cmdline_parse_token_num_t cmd_mirror_link_portid =
7901 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7903 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7904 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7905 mirror, "mirror-rule");
7906 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7907 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7909 cmdline_parse_token_string_t cmd_mirror_link_what =
7910 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7911 what, "uplink-mirror#downlink-mirror");
7912 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7913 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7914 dstpool, "dst-pool");
7915 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7916 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7918 cmdline_parse_token_string_t cmd_mirror_link_on =
7919 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7923 cmd_set_mirror_link_parsed(void *parsed_result,
7924 __attribute__((unused)) struct cmdline *cl,
7925 __attribute__((unused)) void *data)
7928 struct cmd_set_mirror_link_result *res = parsed_result;
7929 struct rte_eth_mirror_conf mr_conf;
7931 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7932 if (!strcmp(res->what, "uplink-mirror"))
7933 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7935 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7937 mr_conf.dst_pool = res->dstpool_id;
7939 if (!strcmp(res->on, "on"))
7940 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7943 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7946 /* check the return value and print it if is < 0 */
7948 printf("mirror rule add error: (%s)\n", strerror(-ret));
7952 cmdline_parse_inst_t cmd_set_mirror_link = {
7953 .f = cmd_set_mirror_link_parsed,
7955 .help_str = "set port <port_id> mirror-rule <rule_id> "
7956 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7958 (void *)&cmd_mirror_link_set,
7959 (void *)&cmd_mirror_link_port,
7960 (void *)&cmd_mirror_link_portid,
7961 (void *)&cmd_mirror_link_mirror,
7962 (void *)&cmd_mirror_link_ruleid,
7963 (void *)&cmd_mirror_link_what,
7964 (void *)&cmd_mirror_link_dstpool,
7965 (void *)&cmd_mirror_link_poolid,
7966 (void *)&cmd_mirror_link_on,
7971 /* *** RESET VM MIRROR RULE *** */
7972 struct cmd_rm_mirror_rule_result {
7973 cmdline_fixed_string_t reset;
7974 cmdline_fixed_string_t port;
7976 cmdline_fixed_string_t mirror;
7980 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7981 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7983 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7984 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7986 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7987 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7989 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7990 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7991 mirror, "mirror-rule");
7992 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7993 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7997 cmd_reset_mirror_rule_parsed(void *parsed_result,
7998 __attribute__((unused)) struct cmdline *cl,
7999 __attribute__((unused)) void *data)
8002 struct cmd_set_mirror_link_result *res = parsed_result;
8004 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8006 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8009 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8010 .f = cmd_reset_mirror_rule_parsed,
8012 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8014 (void *)&cmd_rm_mirror_rule_reset,
8015 (void *)&cmd_rm_mirror_rule_port,
8016 (void *)&cmd_rm_mirror_rule_portid,
8017 (void *)&cmd_rm_mirror_rule_mirror,
8018 (void *)&cmd_rm_mirror_rule_ruleid,
8023 /* ******************************************************************************** */
8025 struct cmd_dump_result {
8026 cmdline_fixed_string_t dump;
8030 dump_struct_sizes(void)
8032 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8033 DUMP_SIZE(struct rte_mbuf);
8034 DUMP_SIZE(struct rte_mempool);
8035 DUMP_SIZE(struct rte_ring);
8039 static void cmd_dump_parsed(void *parsed_result,
8040 __attribute__((unused)) struct cmdline *cl,
8041 __attribute__((unused)) void *data)
8043 struct cmd_dump_result *res = parsed_result;
8045 if (!strcmp(res->dump, "dump_physmem"))
8046 rte_dump_physmem_layout(stdout);
8047 else if (!strcmp(res->dump, "dump_memzone"))
8048 rte_memzone_dump(stdout);
8049 else if (!strcmp(res->dump, "dump_struct_sizes"))
8050 dump_struct_sizes();
8051 else if (!strcmp(res->dump, "dump_ring"))
8052 rte_ring_list_dump(stdout);
8053 else if (!strcmp(res->dump, "dump_mempool"))
8054 rte_mempool_list_dump(stdout);
8055 else if (!strcmp(res->dump, "dump_devargs"))
8056 rte_eal_devargs_dump(stdout);
8057 else if (!strcmp(res->dump, "dump_log_types"))
8058 rte_log_dump(stdout);
8061 cmdline_parse_token_string_t cmd_dump_dump =
8062 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8065 "dump_struct_sizes#"
8071 cmdline_parse_inst_t cmd_dump = {
8072 .f = cmd_dump_parsed, /* function to call */
8073 .data = NULL, /* 2nd arg of func */
8074 .help_str = "Dump status",
8075 .tokens = { /* token list, NULL terminated */
8076 (void *)&cmd_dump_dump,
8081 /* ******************************************************************************** */
8083 struct cmd_dump_one_result {
8084 cmdline_fixed_string_t dump;
8085 cmdline_fixed_string_t name;
8088 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8089 __attribute__((unused)) void *data)
8091 struct cmd_dump_one_result *res = parsed_result;
8093 if (!strcmp(res->dump, "dump_ring")) {
8095 r = rte_ring_lookup(res->name);
8097 cmdline_printf(cl, "Cannot find ring\n");
8100 rte_ring_dump(stdout, r);
8101 } else if (!strcmp(res->dump, "dump_mempool")) {
8102 struct rte_mempool *mp;
8103 mp = rte_mempool_lookup(res->name);
8105 cmdline_printf(cl, "Cannot find mempool\n");
8108 rte_mempool_dump(stdout, mp);
8112 cmdline_parse_token_string_t cmd_dump_one_dump =
8113 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8114 "dump_ring#dump_mempool");
8116 cmdline_parse_token_string_t cmd_dump_one_name =
8117 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8119 cmdline_parse_inst_t cmd_dump_one = {
8120 .f = cmd_dump_one_parsed, /* function to call */
8121 .data = NULL, /* 2nd arg of func */
8122 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8123 .tokens = { /* token list, NULL terminated */
8124 (void *)&cmd_dump_one_dump,
8125 (void *)&cmd_dump_one_name,
8130 /* *** Add/Del syn filter *** */
8131 struct cmd_syn_filter_result {
8132 cmdline_fixed_string_t filter;
8134 cmdline_fixed_string_t ops;
8135 cmdline_fixed_string_t priority;
8136 cmdline_fixed_string_t high;
8137 cmdline_fixed_string_t queue;
8142 cmd_syn_filter_parsed(void *parsed_result,
8143 __attribute__((unused)) struct cmdline *cl,
8144 __attribute__((unused)) void *data)
8146 struct cmd_syn_filter_result *res = parsed_result;
8147 struct rte_eth_syn_filter syn_filter;
8150 ret = rte_eth_dev_filter_supported(res->port_id,
8151 RTE_ETH_FILTER_SYN);
8153 printf("syn filter is not supported on port %u.\n",
8158 memset(&syn_filter, 0, sizeof(syn_filter));
8160 if (!strcmp(res->ops, "add")) {
8161 if (!strcmp(res->high, "high"))
8162 syn_filter.hig_pri = 1;
8164 syn_filter.hig_pri = 0;
8166 syn_filter.queue = res->queue_id;
8167 ret = rte_eth_dev_filter_ctrl(res->port_id,
8172 ret = rte_eth_dev_filter_ctrl(res->port_id,
8174 RTE_ETH_FILTER_DELETE,
8178 printf("syn filter programming error: (%s)\n",
8182 cmdline_parse_token_string_t cmd_syn_filter_filter =
8183 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8184 filter, "syn_filter");
8185 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8186 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8188 cmdline_parse_token_string_t cmd_syn_filter_ops =
8189 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8191 cmdline_parse_token_string_t cmd_syn_filter_priority =
8192 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8193 priority, "priority");
8194 cmdline_parse_token_string_t cmd_syn_filter_high =
8195 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8197 cmdline_parse_token_string_t cmd_syn_filter_queue =
8198 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8200 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8201 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8204 cmdline_parse_inst_t cmd_syn_filter = {
8205 .f = cmd_syn_filter_parsed,
8207 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8208 "<queue_id>: Add/Delete syn filter",
8210 (void *)&cmd_syn_filter_filter,
8211 (void *)&cmd_syn_filter_port_id,
8212 (void *)&cmd_syn_filter_ops,
8213 (void *)&cmd_syn_filter_priority,
8214 (void *)&cmd_syn_filter_high,
8215 (void *)&cmd_syn_filter_queue,
8216 (void *)&cmd_syn_filter_queue_id,
8221 /* *** ADD/REMOVE A 2tuple FILTER *** */
8222 struct cmd_2tuple_filter_result {
8223 cmdline_fixed_string_t filter;
8225 cmdline_fixed_string_t ops;
8226 cmdline_fixed_string_t dst_port;
8227 uint16_t dst_port_value;
8228 cmdline_fixed_string_t protocol;
8229 uint8_t protocol_value;
8230 cmdline_fixed_string_t mask;
8232 cmdline_fixed_string_t tcp_flags;
8233 uint8_t tcp_flags_value;
8234 cmdline_fixed_string_t priority;
8235 uint8_t priority_value;
8236 cmdline_fixed_string_t queue;
8241 cmd_2tuple_filter_parsed(void *parsed_result,
8242 __attribute__((unused)) struct cmdline *cl,
8243 __attribute__((unused)) void *data)
8245 struct rte_eth_ntuple_filter filter;
8246 struct cmd_2tuple_filter_result *res = parsed_result;
8249 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8251 printf("ntuple filter is not supported on port %u.\n",
8256 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8258 filter.flags = RTE_2TUPLE_FLAGS;
8259 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8260 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8261 filter.proto = res->protocol_value;
8262 filter.priority = res->priority_value;
8263 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8264 printf("nonzero tcp_flags is only meaningful"
8265 " when protocol is TCP.\n");
8268 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8269 printf("invalid TCP flags.\n");
8273 if (res->tcp_flags_value != 0) {
8274 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8275 filter.tcp_flags = res->tcp_flags_value;
8278 /* need convert to big endian. */
8279 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8280 filter.queue = res->queue_id;
8282 if (!strcmp(res->ops, "add"))
8283 ret = rte_eth_dev_filter_ctrl(res->port_id,
8284 RTE_ETH_FILTER_NTUPLE,
8288 ret = rte_eth_dev_filter_ctrl(res->port_id,
8289 RTE_ETH_FILTER_NTUPLE,
8290 RTE_ETH_FILTER_DELETE,
8293 printf("2tuple filter programming error: (%s)\n",
8298 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
8299 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8300 filter, "2tuple_filter");
8301 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
8302 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8304 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
8305 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8307 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
8308 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8309 dst_port, "dst_port");
8310 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
8311 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8312 dst_port_value, UINT16);
8313 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
8314 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8315 protocol, "protocol");
8316 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
8317 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8318 protocol_value, UINT8);
8319 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
8320 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8322 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
8323 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8325 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
8326 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8327 tcp_flags, "tcp_flags");
8328 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
8329 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8330 tcp_flags_value, UINT8);
8331 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
8332 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8333 priority, "priority");
8334 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
8335 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8336 priority_value, UINT8);
8337 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
8338 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
8340 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
8341 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
8344 cmdline_parse_inst_t cmd_2tuple_filter = {
8345 .f = cmd_2tuple_filter_parsed,
8347 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
8348 "<value> mask <value> tcp_flags <value> priority <value> queue "
8349 "<queue_id>: Add a 2tuple filter",
8351 (void *)&cmd_2tuple_filter_filter,
8352 (void *)&cmd_2tuple_filter_port_id,
8353 (void *)&cmd_2tuple_filter_ops,
8354 (void *)&cmd_2tuple_filter_dst_port,
8355 (void *)&cmd_2tuple_filter_dst_port_value,
8356 (void *)&cmd_2tuple_filter_protocol,
8357 (void *)&cmd_2tuple_filter_protocol_value,
8358 (void *)&cmd_2tuple_filter_mask,
8359 (void *)&cmd_2tuple_filter_mask_value,
8360 (void *)&cmd_2tuple_filter_tcp_flags,
8361 (void *)&cmd_2tuple_filter_tcp_flags_value,
8362 (void *)&cmd_2tuple_filter_priority,
8363 (void *)&cmd_2tuple_filter_priority_value,
8364 (void *)&cmd_2tuple_filter_queue,
8365 (void *)&cmd_2tuple_filter_queue_id,
8370 /* *** ADD/REMOVE A 5tuple FILTER *** */
8371 struct cmd_5tuple_filter_result {
8372 cmdline_fixed_string_t filter;
8374 cmdline_fixed_string_t ops;
8375 cmdline_fixed_string_t dst_ip;
8376 cmdline_ipaddr_t dst_ip_value;
8377 cmdline_fixed_string_t src_ip;
8378 cmdline_ipaddr_t src_ip_value;
8379 cmdline_fixed_string_t dst_port;
8380 uint16_t dst_port_value;
8381 cmdline_fixed_string_t src_port;
8382 uint16_t src_port_value;
8383 cmdline_fixed_string_t protocol;
8384 uint8_t protocol_value;
8385 cmdline_fixed_string_t mask;
8387 cmdline_fixed_string_t tcp_flags;
8388 uint8_t tcp_flags_value;
8389 cmdline_fixed_string_t priority;
8390 uint8_t priority_value;
8391 cmdline_fixed_string_t queue;
8396 cmd_5tuple_filter_parsed(void *parsed_result,
8397 __attribute__((unused)) struct cmdline *cl,
8398 __attribute__((unused)) void *data)
8400 struct rte_eth_ntuple_filter filter;
8401 struct cmd_5tuple_filter_result *res = parsed_result;
8404 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8406 printf("ntuple filter is not supported on port %u.\n",
8411 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8413 filter.flags = RTE_5TUPLE_FLAGS;
8414 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8415 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8416 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8417 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8418 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8419 filter.proto = res->protocol_value;
8420 filter.priority = res->priority_value;
8421 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8422 printf("nonzero tcp_flags is only meaningful"
8423 " when protocol is TCP.\n");
8426 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8427 printf("invalid TCP flags.\n");
8431 if (res->tcp_flags_value != 0) {
8432 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8433 filter.tcp_flags = res->tcp_flags_value;
8436 if (res->dst_ip_value.family == AF_INET)
8437 /* no need to convert, already big endian. */
8438 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8440 if (filter.dst_ip_mask == 0) {
8441 printf("can not support ipv6 involved compare.\n");
8447 if (res->src_ip_value.family == AF_INET)
8448 /* no need to convert, already big endian. */
8449 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8451 if (filter.src_ip_mask == 0) {
8452 printf("can not support ipv6 involved compare.\n");
8457 /* need convert to big endian. */
8458 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8459 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8460 filter.queue = res->queue_id;
8462 if (!strcmp(res->ops, "add"))
8463 ret = rte_eth_dev_filter_ctrl(res->port_id,
8464 RTE_ETH_FILTER_NTUPLE,
8468 ret = rte_eth_dev_filter_ctrl(res->port_id,
8469 RTE_ETH_FILTER_NTUPLE,
8470 RTE_ETH_FILTER_DELETE,
8473 printf("5tuple filter programming error: (%s)\n",
8477 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8478 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8479 filter, "5tuple_filter");
8480 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8481 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8483 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8484 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8486 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8487 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8489 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8490 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8492 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8493 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8495 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8496 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8498 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8499 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8500 dst_port, "dst_port");
8501 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8502 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8503 dst_port_value, UINT16);
8504 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8505 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8506 src_port, "src_port");
8507 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8508 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8509 src_port_value, UINT16);
8510 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8511 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8512 protocol, "protocol");
8513 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8514 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8515 protocol_value, UINT8);
8516 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8517 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8519 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8520 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8522 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8523 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8524 tcp_flags, "tcp_flags");
8525 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8526 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8527 tcp_flags_value, UINT8);
8528 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8529 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8530 priority, "priority");
8531 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8532 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8533 priority_value, UINT8);
8534 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8535 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8537 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8538 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8541 cmdline_parse_inst_t cmd_5tuple_filter = {
8542 .f = cmd_5tuple_filter_parsed,
8544 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8545 "src_ip <value> dst_port <value> src_port <value> "
8546 "protocol <value> mask <value> tcp_flags <value> "
8547 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8549 (void *)&cmd_5tuple_filter_filter,
8550 (void *)&cmd_5tuple_filter_port_id,
8551 (void *)&cmd_5tuple_filter_ops,
8552 (void *)&cmd_5tuple_filter_dst_ip,
8553 (void *)&cmd_5tuple_filter_dst_ip_value,
8554 (void *)&cmd_5tuple_filter_src_ip,
8555 (void *)&cmd_5tuple_filter_src_ip_value,
8556 (void *)&cmd_5tuple_filter_dst_port,
8557 (void *)&cmd_5tuple_filter_dst_port_value,
8558 (void *)&cmd_5tuple_filter_src_port,
8559 (void *)&cmd_5tuple_filter_src_port_value,
8560 (void *)&cmd_5tuple_filter_protocol,
8561 (void *)&cmd_5tuple_filter_protocol_value,
8562 (void *)&cmd_5tuple_filter_mask,
8563 (void *)&cmd_5tuple_filter_mask_value,
8564 (void *)&cmd_5tuple_filter_tcp_flags,
8565 (void *)&cmd_5tuple_filter_tcp_flags_value,
8566 (void *)&cmd_5tuple_filter_priority,
8567 (void *)&cmd_5tuple_filter_priority_value,
8568 (void *)&cmd_5tuple_filter_queue,
8569 (void *)&cmd_5tuple_filter_queue_id,
8574 /* *** ADD/REMOVE A flex FILTER *** */
8575 struct cmd_flex_filter_result {
8576 cmdline_fixed_string_t filter;
8577 cmdline_fixed_string_t ops;
8579 cmdline_fixed_string_t len;
8581 cmdline_fixed_string_t bytes;
8582 cmdline_fixed_string_t bytes_value;
8583 cmdline_fixed_string_t mask;
8584 cmdline_fixed_string_t mask_value;
8585 cmdline_fixed_string_t priority;
8586 uint8_t priority_value;
8587 cmdline_fixed_string_t queue;
8591 static int xdigit2val(unsigned char c)
8596 else if (isupper(c))
8604 cmd_flex_filter_parsed(void *parsed_result,
8605 __attribute__((unused)) struct cmdline *cl,
8606 __attribute__((unused)) void *data)
8609 struct rte_eth_flex_filter filter;
8610 struct cmd_flex_filter_result *res = parsed_result;
8611 char *bytes_ptr, *mask_ptr;
8612 uint16_t len, i, j = 0;
8617 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8618 printf("the len exceed the max length 128\n");
8621 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8622 filter.len = res->len_value;
8623 filter.priority = res->priority_value;
8624 filter.queue = res->queue_id;
8625 bytes_ptr = res->bytes_value;
8626 mask_ptr = res->mask_value;
8628 /* translate bytes string to array. */
8629 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8630 (bytes_ptr[1] == 'X')))
8632 len = strnlen(bytes_ptr, res->len_value * 2);
8633 if (len == 0 || (len % 8 != 0)) {
8634 printf("please check len and bytes input\n");
8637 for (i = 0; i < len; i++) {
8639 if (isxdigit(c) == 0) {
8640 /* invalid characters. */
8641 printf("invalid input\n");
8644 val = xdigit2val(c);
8647 filter.bytes[j] = byte;
8648 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8655 /* translate mask string to uint8_t array. */
8656 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8657 (mask_ptr[1] == 'X')))
8659 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8661 printf("invalid input\n");
8666 for (i = 0; i < len; i++) {
8668 if (isxdigit(c) == 0) {
8669 /* invalid characters. */
8670 printf("invalid input\n");
8673 val = xdigit2val(c);
8676 filter.mask[j] = byte;
8677 printf("mask[%d]:%02x ", j, filter.mask[j]);
8685 if (!strcmp(res->ops, "add"))
8686 ret = rte_eth_dev_filter_ctrl(res->port_id,
8687 RTE_ETH_FILTER_FLEXIBLE,
8691 ret = rte_eth_dev_filter_ctrl(res->port_id,
8692 RTE_ETH_FILTER_FLEXIBLE,
8693 RTE_ETH_FILTER_DELETE,
8697 printf("flex filter setting error: (%s)\n", strerror(-ret));
8700 cmdline_parse_token_string_t cmd_flex_filter_filter =
8701 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8702 filter, "flex_filter");
8703 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8704 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8706 cmdline_parse_token_string_t cmd_flex_filter_ops =
8707 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8709 cmdline_parse_token_string_t cmd_flex_filter_len =
8710 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8712 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8713 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8715 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8716 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8718 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8719 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8721 cmdline_parse_token_string_t cmd_flex_filter_mask =
8722 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8724 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8725 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8727 cmdline_parse_token_string_t cmd_flex_filter_priority =
8728 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8729 priority, "priority");
8730 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8731 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8732 priority_value, UINT8);
8733 cmdline_parse_token_string_t cmd_flex_filter_queue =
8734 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8736 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8737 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8739 cmdline_parse_inst_t cmd_flex_filter = {
8740 .f = cmd_flex_filter_parsed,
8742 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8743 "<value> mask <value> priority <value> queue <queue_id>: "
8744 "Add/Del a flex filter",
8746 (void *)&cmd_flex_filter_filter,
8747 (void *)&cmd_flex_filter_port_id,
8748 (void *)&cmd_flex_filter_ops,
8749 (void *)&cmd_flex_filter_len,
8750 (void *)&cmd_flex_filter_len_value,
8751 (void *)&cmd_flex_filter_bytes,
8752 (void *)&cmd_flex_filter_bytes_value,
8753 (void *)&cmd_flex_filter_mask,
8754 (void *)&cmd_flex_filter_mask_value,
8755 (void *)&cmd_flex_filter_priority,
8756 (void *)&cmd_flex_filter_priority_value,
8757 (void *)&cmd_flex_filter_queue,
8758 (void *)&cmd_flex_filter_queue_id,
8763 /* *** Filters Control *** */
8765 /* *** deal with ethertype filter *** */
8766 struct cmd_ethertype_filter_result {
8767 cmdline_fixed_string_t filter;
8769 cmdline_fixed_string_t ops;
8770 cmdline_fixed_string_t mac;
8771 struct ether_addr mac_addr;
8772 cmdline_fixed_string_t ethertype;
8773 uint16_t ethertype_value;
8774 cmdline_fixed_string_t drop;
8775 cmdline_fixed_string_t queue;
8779 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8780 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8781 filter, "ethertype_filter");
8782 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8783 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8785 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8786 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8788 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8789 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8790 mac, "mac_addr#mac_ignr");
8791 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8792 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8794 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8795 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8796 ethertype, "ethertype");
8797 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8798 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8799 ethertype_value, UINT16);
8800 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8801 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8803 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8804 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8806 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8807 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8811 cmd_ethertype_filter_parsed(void *parsed_result,
8812 __attribute__((unused)) struct cmdline *cl,
8813 __attribute__((unused)) void *data)
8815 struct cmd_ethertype_filter_result *res = parsed_result;
8816 struct rte_eth_ethertype_filter filter;
8819 ret = rte_eth_dev_filter_supported(res->port_id,
8820 RTE_ETH_FILTER_ETHERTYPE);
8822 printf("ethertype filter is not supported on port %u.\n",
8827 memset(&filter, 0, sizeof(filter));
8828 if (!strcmp(res->mac, "mac_addr")) {
8829 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8830 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8831 sizeof(struct ether_addr));
8833 if (!strcmp(res->drop, "drop"))
8834 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8835 filter.ether_type = res->ethertype_value;
8836 filter.queue = res->queue_id;
8838 if (!strcmp(res->ops, "add"))
8839 ret = rte_eth_dev_filter_ctrl(res->port_id,
8840 RTE_ETH_FILTER_ETHERTYPE,
8844 ret = rte_eth_dev_filter_ctrl(res->port_id,
8845 RTE_ETH_FILTER_ETHERTYPE,
8846 RTE_ETH_FILTER_DELETE,
8849 printf("ethertype filter programming error: (%s)\n",
8853 cmdline_parse_inst_t cmd_ethertype_filter = {
8854 .f = cmd_ethertype_filter_parsed,
8856 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8857 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8858 "Add or delete an ethertype filter entry",
8860 (void *)&cmd_ethertype_filter_filter,
8861 (void *)&cmd_ethertype_filter_port_id,
8862 (void *)&cmd_ethertype_filter_ops,
8863 (void *)&cmd_ethertype_filter_mac,
8864 (void *)&cmd_ethertype_filter_mac_addr,
8865 (void *)&cmd_ethertype_filter_ethertype,
8866 (void *)&cmd_ethertype_filter_ethertype_value,
8867 (void *)&cmd_ethertype_filter_drop,
8868 (void *)&cmd_ethertype_filter_queue,
8869 (void *)&cmd_ethertype_filter_queue_id,
8874 /* *** deal with flow director filter *** */
8875 struct cmd_flow_director_result {
8876 cmdline_fixed_string_t flow_director_filter;
8878 cmdline_fixed_string_t mode;
8879 cmdline_fixed_string_t mode_value;
8880 cmdline_fixed_string_t ops;
8881 cmdline_fixed_string_t flow;
8882 cmdline_fixed_string_t flow_type;
8883 cmdline_fixed_string_t ether;
8884 uint16_t ether_type;
8885 cmdline_fixed_string_t src;
8886 cmdline_ipaddr_t ip_src;
8888 cmdline_fixed_string_t dst;
8889 cmdline_ipaddr_t ip_dst;
8891 cmdline_fixed_string_t verify_tag;
8892 uint32_t verify_tag_value;
8893 cmdline_ipaddr_t tos;
8895 cmdline_ipaddr_t proto;
8896 uint8_t proto_value;
8897 cmdline_ipaddr_t ttl;
8899 cmdline_fixed_string_t vlan;
8900 uint16_t vlan_value;
8901 cmdline_fixed_string_t flexbytes;
8902 cmdline_fixed_string_t flexbytes_value;
8903 cmdline_fixed_string_t pf_vf;
8904 cmdline_fixed_string_t drop;
8905 cmdline_fixed_string_t queue;
8907 cmdline_fixed_string_t fd_id;
8908 uint32_t fd_id_value;
8909 cmdline_fixed_string_t mac;
8910 struct ether_addr mac_addr;
8911 cmdline_fixed_string_t tunnel;
8912 cmdline_fixed_string_t tunnel_type;
8913 cmdline_fixed_string_t tunnel_id;
8914 uint32_t tunnel_id_value;
8918 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8921 const char *p, *p0 = q_arg;
8923 unsigned long int_fld;
8924 char *str_fld[max_num];
8929 p = strchr(p0, '(');
8933 p0 = strchr(p, ')');
8938 if (size >= sizeof(s))
8941 snprintf(s, sizeof(s), "%.*s", size, p);
8942 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8943 if (ret < 0 || ret > max_num)
8945 for (i = 0; i < ret; i++) {
8947 int_fld = strtoul(str_fld[i], &end, 0);
8948 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8950 flexbytes[i] = (uint8_t)int_fld;
8956 str2flowtype(char *string)
8959 static const struct {
8962 } flowtype_str[] = {
8963 {"raw", RTE_ETH_FLOW_RAW},
8964 {"ipv4", RTE_ETH_FLOW_IPV4},
8965 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8966 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8967 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8968 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8969 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8970 {"ipv6", RTE_ETH_FLOW_IPV6},
8971 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8972 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8973 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8974 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8975 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8976 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8979 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8980 if (!strcmp(flowtype_str[i].str, string))
8981 return flowtype_str[i].type;
8983 return RTE_ETH_FLOW_UNKNOWN;
8986 static enum rte_eth_fdir_tunnel_type
8987 str2fdir_tunneltype(char *string)
8991 static const struct {
8993 enum rte_eth_fdir_tunnel_type type;
8994 } tunneltype_str[] = {
8995 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8996 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8999 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9000 if (!strcmp(tunneltype_str[i].str, string))
9001 return tunneltype_str[i].type;
9003 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9006 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9008 if ((ip_addr).family == AF_INET) \
9009 (ip) = (ip_addr).addr.ipv4.s_addr; \
9011 printf("invalid parameter.\n"); \
9016 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9018 if ((ip_addr).family == AF_INET6) \
9019 (void)rte_memcpy(&(ip), \
9020 &((ip_addr).addr.ipv6), \
9021 sizeof(struct in6_addr)); \
9023 printf("invalid parameter.\n"); \
9029 cmd_flow_director_filter_parsed(void *parsed_result,
9030 __attribute__((unused)) struct cmdline *cl,
9031 __attribute__((unused)) void *data)
9033 struct cmd_flow_director_result *res = parsed_result;
9034 struct rte_eth_fdir_filter entry;
9035 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9037 unsigned long vf_id;
9040 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9042 printf("flow director is not supported on port %u.\n",
9046 memset(flexbytes, 0, sizeof(flexbytes));
9047 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9049 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9050 if (strcmp(res->mode_value, "MAC-VLAN")) {
9051 printf("Please set mode to MAC-VLAN.\n");
9054 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9055 if (strcmp(res->mode_value, "Tunnel")) {
9056 printf("Please set mode to Tunnel.\n");
9060 if (strcmp(res->mode_value, "IP")) {
9061 printf("Please set mode to IP.\n");
9064 entry.input.flow_type = str2flowtype(res->flow_type);
9067 ret = parse_flexbytes(res->flexbytes_value,
9069 RTE_ETH_FDIR_MAX_FLEXLEN);
9071 printf("error: Cannot parse flexbytes input.\n");
9075 switch (entry.input.flow_type) {
9076 case RTE_ETH_FLOW_FRAG_IPV4:
9077 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9078 entry.input.flow.ip4_flow.proto = res->proto_value;
9080 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9081 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9082 IPV4_ADDR_TO_UINT(res->ip_dst,
9083 entry.input.flow.ip4_flow.dst_ip);
9084 IPV4_ADDR_TO_UINT(res->ip_src,
9085 entry.input.flow.ip4_flow.src_ip);
9086 entry.input.flow.ip4_flow.tos = res->tos_value;
9087 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9088 /* need convert to big endian. */
9089 entry.input.flow.udp4_flow.dst_port =
9090 rte_cpu_to_be_16(res->port_dst);
9091 entry.input.flow.udp4_flow.src_port =
9092 rte_cpu_to_be_16(res->port_src);
9094 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9095 IPV4_ADDR_TO_UINT(res->ip_dst,
9096 entry.input.flow.sctp4_flow.ip.dst_ip);
9097 IPV4_ADDR_TO_UINT(res->ip_src,
9098 entry.input.flow.sctp4_flow.ip.src_ip);
9099 entry.input.flow.ip4_flow.tos = res->tos_value;
9100 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9101 /* need convert to big endian. */
9102 entry.input.flow.sctp4_flow.dst_port =
9103 rte_cpu_to_be_16(res->port_dst);
9104 entry.input.flow.sctp4_flow.src_port =
9105 rte_cpu_to_be_16(res->port_src);
9106 entry.input.flow.sctp4_flow.verify_tag =
9107 rte_cpu_to_be_32(res->verify_tag_value);
9109 case RTE_ETH_FLOW_FRAG_IPV6:
9110 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9111 entry.input.flow.ipv6_flow.proto = res->proto_value;
9113 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9114 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9115 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9116 entry.input.flow.ipv6_flow.dst_ip);
9117 IPV6_ADDR_TO_ARRAY(res->ip_src,
9118 entry.input.flow.ipv6_flow.src_ip);
9119 entry.input.flow.ipv6_flow.tc = res->tos_value;
9120 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9121 /* need convert to big endian. */
9122 entry.input.flow.udp6_flow.dst_port =
9123 rte_cpu_to_be_16(res->port_dst);
9124 entry.input.flow.udp6_flow.src_port =
9125 rte_cpu_to_be_16(res->port_src);
9127 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9128 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9129 entry.input.flow.sctp6_flow.ip.dst_ip);
9130 IPV6_ADDR_TO_ARRAY(res->ip_src,
9131 entry.input.flow.sctp6_flow.ip.src_ip);
9132 entry.input.flow.ipv6_flow.tc = res->tos_value;
9133 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9134 /* need convert to big endian. */
9135 entry.input.flow.sctp6_flow.dst_port =
9136 rte_cpu_to_be_16(res->port_dst);
9137 entry.input.flow.sctp6_flow.src_port =
9138 rte_cpu_to_be_16(res->port_src);
9139 entry.input.flow.sctp6_flow.verify_tag =
9140 rte_cpu_to_be_32(res->verify_tag_value);
9142 case RTE_ETH_FLOW_L2_PAYLOAD:
9143 entry.input.flow.l2_flow.ether_type =
9144 rte_cpu_to_be_16(res->ether_type);
9150 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
9151 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
9153 sizeof(struct ether_addr));
9155 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9156 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
9158 sizeof(struct ether_addr));
9159 entry.input.flow.tunnel_flow.tunnel_type =
9160 str2fdir_tunneltype(res->tunnel_type);
9161 entry.input.flow.tunnel_flow.tunnel_id =
9162 rte_cpu_to_be_32(res->tunnel_id_value);
9165 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
9167 RTE_ETH_FDIR_MAX_FLEXLEN);
9169 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
9171 entry.action.flex_off = 0; /*use 0 by default */
9172 if (!strcmp(res->drop, "drop"))
9173 entry.action.behavior = RTE_ETH_FDIR_REJECT;
9175 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
9177 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
9178 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
9179 if (!strcmp(res->pf_vf, "pf"))
9180 entry.input.flow_ext.is_vf = 0;
9181 else if (!strncmp(res->pf_vf, "vf", 2)) {
9182 struct rte_eth_dev_info dev_info;
9184 memset(&dev_info, 0, sizeof(dev_info));
9185 rte_eth_dev_info_get(res->port_id, &dev_info);
9187 vf_id = strtoul(res->pf_vf + 2, &end, 10);
9188 if (errno != 0 || *end != '\0' ||
9189 vf_id >= dev_info.max_vfs) {
9190 printf("invalid parameter %s.\n", res->pf_vf);
9193 entry.input.flow_ext.is_vf = 1;
9194 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
9196 printf("invalid parameter %s.\n", res->pf_vf);
9201 /* set to report FD ID by default */
9202 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
9203 entry.action.rx_queue = res->queue_id;
9204 entry.soft_id = res->fd_id_value;
9205 if (!strcmp(res->ops, "add"))
9206 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9207 RTE_ETH_FILTER_ADD, &entry);
9208 else if (!strcmp(res->ops, "del"))
9209 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9210 RTE_ETH_FILTER_DELETE, &entry);
9212 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9213 RTE_ETH_FILTER_UPDATE, &entry);
9215 printf("flow director programming error: (%s)\n",
9219 cmdline_parse_token_string_t cmd_flow_director_filter =
9220 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9221 flow_director_filter, "flow_director_filter");
9222 cmdline_parse_token_num_t cmd_flow_director_port_id =
9223 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9225 cmdline_parse_token_string_t cmd_flow_director_ops =
9226 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9227 ops, "add#del#update");
9228 cmdline_parse_token_string_t cmd_flow_director_flow =
9229 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9231 cmdline_parse_token_string_t cmd_flow_director_flow_type =
9232 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9233 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9234 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
9235 cmdline_parse_token_string_t cmd_flow_director_ether =
9236 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9238 cmdline_parse_token_num_t cmd_flow_director_ether_type =
9239 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9240 ether_type, UINT16);
9241 cmdline_parse_token_string_t cmd_flow_director_src =
9242 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9244 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
9245 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9247 cmdline_parse_token_num_t cmd_flow_director_port_src =
9248 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9250 cmdline_parse_token_string_t cmd_flow_director_dst =
9251 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9253 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
9254 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
9256 cmdline_parse_token_num_t cmd_flow_director_port_dst =
9257 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9259 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
9260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9261 verify_tag, "verify_tag");
9262 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
9263 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9264 verify_tag_value, UINT32);
9265 cmdline_parse_token_string_t cmd_flow_director_tos =
9266 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9268 cmdline_parse_token_num_t cmd_flow_director_tos_value =
9269 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9271 cmdline_parse_token_string_t cmd_flow_director_proto =
9272 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9274 cmdline_parse_token_num_t cmd_flow_director_proto_value =
9275 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9276 proto_value, UINT8);
9277 cmdline_parse_token_string_t cmd_flow_director_ttl =
9278 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9280 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
9281 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9283 cmdline_parse_token_string_t cmd_flow_director_vlan =
9284 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9286 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
9287 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9288 vlan_value, UINT16);
9289 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
9290 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9291 flexbytes, "flexbytes");
9292 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
9293 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9294 flexbytes_value, NULL);
9295 cmdline_parse_token_string_t cmd_flow_director_drop =
9296 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9298 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
9299 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9301 cmdline_parse_token_string_t cmd_flow_director_queue =
9302 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9304 cmdline_parse_token_num_t cmd_flow_director_queue_id =
9305 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9307 cmdline_parse_token_string_t cmd_flow_director_fd_id =
9308 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9310 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
9311 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9312 fd_id_value, UINT32);
9314 cmdline_parse_token_string_t cmd_flow_director_mode =
9315 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9317 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
9318 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9320 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
9321 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9322 mode_value, "MAC-VLAN");
9323 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
9324 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9325 mode_value, "Tunnel");
9326 cmdline_parse_token_string_t cmd_flow_director_mac =
9327 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9329 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
9330 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
9332 cmdline_parse_token_string_t cmd_flow_director_tunnel =
9333 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9335 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
9336 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9337 tunnel_type, "NVGRE#VxLAN");
9338 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
9339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9340 tunnel_id, "tunnel-id");
9341 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
9342 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9343 tunnel_id_value, UINT32);
9345 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
9346 .f = cmd_flow_director_filter_parsed,
9348 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
9349 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
9350 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
9351 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
9352 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
9353 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9354 "fd_id <fd_id_value>: "
9355 "Add or delete an ip flow director entry on NIC",
9357 (void *)&cmd_flow_director_filter,
9358 (void *)&cmd_flow_director_port_id,
9359 (void *)&cmd_flow_director_mode,
9360 (void *)&cmd_flow_director_mode_ip,
9361 (void *)&cmd_flow_director_ops,
9362 (void *)&cmd_flow_director_flow,
9363 (void *)&cmd_flow_director_flow_type,
9364 (void *)&cmd_flow_director_src,
9365 (void *)&cmd_flow_director_ip_src,
9366 (void *)&cmd_flow_director_dst,
9367 (void *)&cmd_flow_director_ip_dst,
9368 (void *)&cmd_flow_director_tos,
9369 (void *)&cmd_flow_director_tos_value,
9370 (void *)&cmd_flow_director_proto,
9371 (void *)&cmd_flow_director_proto_value,
9372 (void *)&cmd_flow_director_ttl,
9373 (void *)&cmd_flow_director_ttl_value,
9374 (void *)&cmd_flow_director_vlan,
9375 (void *)&cmd_flow_director_vlan_value,
9376 (void *)&cmd_flow_director_flexbytes,
9377 (void *)&cmd_flow_director_flexbytes_value,
9378 (void *)&cmd_flow_director_drop,
9379 (void *)&cmd_flow_director_pf_vf,
9380 (void *)&cmd_flow_director_queue,
9381 (void *)&cmd_flow_director_queue_id,
9382 (void *)&cmd_flow_director_fd_id,
9383 (void *)&cmd_flow_director_fd_id_value,
9388 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9389 .f = cmd_flow_director_filter_parsed,
9391 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9392 "director entry on NIC",
9394 (void *)&cmd_flow_director_filter,
9395 (void *)&cmd_flow_director_port_id,
9396 (void *)&cmd_flow_director_mode,
9397 (void *)&cmd_flow_director_mode_ip,
9398 (void *)&cmd_flow_director_ops,
9399 (void *)&cmd_flow_director_flow,
9400 (void *)&cmd_flow_director_flow_type,
9401 (void *)&cmd_flow_director_src,
9402 (void *)&cmd_flow_director_ip_src,
9403 (void *)&cmd_flow_director_port_src,
9404 (void *)&cmd_flow_director_dst,
9405 (void *)&cmd_flow_director_ip_dst,
9406 (void *)&cmd_flow_director_port_dst,
9407 (void *)&cmd_flow_director_tos,
9408 (void *)&cmd_flow_director_tos_value,
9409 (void *)&cmd_flow_director_ttl,
9410 (void *)&cmd_flow_director_ttl_value,
9411 (void *)&cmd_flow_director_vlan,
9412 (void *)&cmd_flow_director_vlan_value,
9413 (void *)&cmd_flow_director_flexbytes,
9414 (void *)&cmd_flow_director_flexbytes_value,
9415 (void *)&cmd_flow_director_drop,
9416 (void *)&cmd_flow_director_pf_vf,
9417 (void *)&cmd_flow_director_queue,
9418 (void *)&cmd_flow_director_queue_id,
9419 (void *)&cmd_flow_director_fd_id,
9420 (void *)&cmd_flow_director_fd_id_value,
9425 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9426 .f = cmd_flow_director_filter_parsed,
9428 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9429 "director entry on NIC",
9431 (void *)&cmd_flow_director_filter,
9432 (void *)&cmd_flow_director_port_id,
9433 (void *)&cmd_flow_director_mode,
9434 (void *)&cmd_flow_director_mode_ip,
9435 (void *)&cmd_flow_director_ops,
9436 (void *)&cmd_flow_director_flow,
9437 (void *)&cmd_flow_director_flow_type,
9438 (void *)&cmd_flow_director_src,
9439 (void *)&cmd_flow_director_ip_src,
9440 (void *)&cmd_flow_director_port_dst,
9441 (void *)&cmd_flow_director_dst,
9442 (void *)&cmd_flow_director_ip_dst,
9443 (void *)&cmd_flow_director_port_dst,
9444 (void *)&cmd_flow_director_verify_tag,
9445 (void *)&cmd_flow_director_verify_tag_value,
9446 (void *)&cmd_flow_director_tos,
9447 (void *)&cmd_flow_director_tos_value,
9448 (void *)&cmd_flow_director_ttl,
9449 (void *)&cmd_flow_director_ttl_value,
9450 (void *)&cmd_flow_director_vlan,
9451 (void *)&cmd_flow_director_vlan_value,
9452 (void *)&cmd_flow_director_flexbytes,
9453 (void *)&cmd_flow_director_flexbytes_value,
9454 (void *)&cmd_flow_director_drop,
9455 (void *)&cmd_flow_director_pf_vf,
9456 (void *)&cmd_flow_director_queue,
9457 (void *)&cmd_flow_director_queue_id,
9458 (void *)&cmd_flow_director_fd_id,
9459 (void *)&cmd_flow_director_fd_id_value,
9464 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9465 .f = cmd_flow_director_filter_parsed,
9467 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9468 "director entry on NIC",
9470 (void *)&cmd_flow_director_filter,
9471 (void *)&cmd_flow_director_port_id,
9472 (void *)&cmd_flow_director_mode,
9473 (void *)&cmd_flow_director_mode_ip,
9474 (void *)&cmd_flow_director_ops,
9475 (void *)&cmd_flow_director_flow,
9476 (void *)&cmd_flow_director_flow_type,
9477 (void *)&cmd_flow_director_ether,
9478 (void *)&cmd_flow_director_ether_type,
9479 (void *)&cmd_flow_director_flexbytes,
9480 (void *)&cmd_flow_director_flexbytes_value,
9481 (void *)&cmd_flow_director_drop,
9482 (void *)&cmd_flow_director_pf_vf,
9483 (void *)&cmd_flow_director_queue,
9484 (void *)&cmd_flow_director_queue_id,
9485 (void *)&cmd_flow_director_fd_id,
9486 (void *)&cmd_flow_director_fd_id_value,
9491 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9492 .f = cmd_flow_director_filter_parsed,
9494 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9495 "director entry on NIC",
9497 (void *)&cmd_flow_director_filter,
9498 (void *)&cmd_flow_director_port_id,
9499 (void *)&cmd_flow_director_mode,
9500 (void *)&cmd_flow_director_mode_mac_vlan,
9501 (void *)&cmd_flow_director_ops,
9502 (void *)&cmd_flow_director_mac,
9503 (void *)&cmd_flow_director_mac_addr,
9504 (void *)&cmd_flow_director_vlan,
9505 (void *)&cmd_flow_director_vlan_value,
9506 (void *)&cmd_flow_director_flexbytes,
9507 (void *)&cmd_flow_director_flexbytes_value,
9508 (void *)&cmd_flow_director_drop,
9509 (void *)&cmd_flow_director_queue,
9510 (void *)&cmd_flow_director_queue_id,
9511 (void *)&cmd_flow_director_fd_id,
9512 (void *)&cmd_flow_director_fd_id_value,
9517 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9518 .f = cmd_flow_director_filter_parsed,
9520 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9521 "director entry on NIC",
9523 (void *)&cmd_flow_director_filter,
9524 (void *)&cmd_flow_director_port_id,
9525 (void *)&cmd_flow_director_mode,
9526 (void *)&cmd_flow_director_mode_tunnel,
9527 (void *)&cmd_flow_director_ops,
9528 (void *)&cmd_flow_director_mac,
9529 (void *)&cmd_flow_director_mac_addr,
9530 (void *)&cmd_flow_director_vlan,
9531 (void *)&cmd_flow_director_vlan_value,
9532 (void *)&cmd_flow_director_tunnel,
9533 (void *)&cmd_flow_director_tunnel_type,
9534 (void *)&cmd_flow_director_tunnel_id,
9535 (void *)&cmd_flow_director_tunnel_id_value,
9536 (void *)&cmd_flow_director_flexbytes,
9537 (void *)&cmd_flow_director_flexbytes_value,
9538 (void *)&cmd_flow_director_drop,
9539 (void *)&cmd_flow_director_queue,
9540 (void *)&cmd_flow_director_queue_id,
9541 (void *)&cmd_flow_director_fd_id,
9542 (void *)&cmd_flow_director_fd_id_value,
9547 struct cmd_flush_flow_director_result {
9548 cmdline_fixed_string_t flush_flow_director;
9552 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9553 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9554 flush_flow_director, "flush_flow_director");
9555 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9556 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9560 cmd_flush_flow_director_parsed(void *parsed_result,
9561 __attribute__((unused)) struct cmdline *cl,
9562 __attribute__((unused)) void *data)
9564 struct cmd_flow_director_result *res = parsed_result;
9567 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9569 printf("flow director is not supported on port %u.\n",
9574 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9575 RTE_ETH_FILTER_FLUSH, NULL);
9577 printf("flow director table flushing error: (%s)\n",
9581 cmdline_parse_inst_t cmd_flush_flow_director = {
9582 .f = cmd_flush_flow_director_parsed,
9584 .help_str = "flush_flow_director <port_id>: "
9585 "Flush all flow director entries of a device on NIC",
9587 (void *)&cmd_flush_flow_director_flush,
9588 (void *)&cmd_flush_flow_director_port_id,
9593 /* *** deal with flow director mask *** */
9594 struct cmd_flow_director_mask_result {
9595 cmdline_fixed_string_t flow_director_mask;
9597 cmdline_fixed_string_t mode;
9598 cmdline_fixed_string_t mode_value;
9599 cmdline_fixed_string_t vlan;
9601 cmdline_fixed_string_t src_mask;
9602 cmdline_ipaddr_t ipv4_src;
9603 cmdline_ipaddr_t ipv6_src;
9605 cmdline_fixed_string_t dst_mask;
9606 cmdline_ipaddr_t ipv4_dst;
9607 cmdline_ipaddr_t ipv6_dst;
9609 cmdline_fixed_string_t mac;
9610 uint8_t mac_addr_byte_mask;
9611 cmdline_fixed_string_t tunnel_id;
9612 uint32_t tunnel_id_mask;
9613 cmdline_fixed_string_t tunnel_type;
9614 uint8_t tunnel_type_mask;
9618 cmd_flow_director_mask_parsed(void *parsed_result,
9619 __attribute__((unused)) struct cmdline *cl,
9620 __attribute__((unused)) void *data)
9622 struct cmd_flow_director_mask_result *res = parsed_result;
9623 struct rte_eth_fdir_masks *mask;
9624 struct rte_port *port;
9626 if (res->port_id > nb_ports) {
9627 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9631 port = &ports[res->port_id];
9632 /** Check if the port is not started **/
9633 if (port->port_status != RTE_PORT_STOPPED) {
9634 printf("Please stop port %d first\n", res->port_id);
9638 mask = &port->dev_conf.fdir_conf.mask;
9640 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9641 if (strcmp(res->mode_value, "MAC-VLAN")) {
9642 printf("Please set mode to MAC-VLAN.\n");
9646 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9647 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9648 if (strcmp(res->mode_value, "Tunnel")) {
9649 printf("Please set mode to Tunnel.\n");
9653 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9654 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9655 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9656 mask->tunnel_type_mask = res->tunnel_type_mask;
9658 if (strcmp(res->mode_value, "IP")) {
9659 printf("Please set mode to IP.\n");
9663 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9664 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9665 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9666 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9667 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9668 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9669 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9672 cmd_reconfig_device_queue(res->port_id, 1, 1);
9675 cmdline_parse_token_string_t cmd_flow_director_mask =
9676 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9677 flow_director_mask, "flow_director_mask");
9678 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9679 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9681 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9682 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9684 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9685 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9687 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9688 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9689 src_mask, "src_mask");
9690 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9691 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9693 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9694 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9696 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9697 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9699 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9700 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9701 dst_mask, "dst_mask");
9702 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9703 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9705 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9706 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9708 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9709 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9712 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9713 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9715 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9716 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9718 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9719 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9720 mode_value, "MAC-VLAN");
9721 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9722 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9723 mode_value, "Tunnel");
9724 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9725 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9727 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9728 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9729 mac_addr_byte_mask, UINT8);
9730 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9731 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9732 tunnel_type, "tunnel-type");
9733 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9734 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9735 tunnel_type_mask, UINT8);
9736 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9737 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9738 tunnel_id, "tunnel-id");
9739 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9740 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9741 tunnel_id_mask, UINT32);
9743 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9744 .f = cmd_flow_director_mask_parsed,
9746 .help_str = "flow_director_mask ... : "
9747 "Set IP mode flow director's mask on NIC",
9749 (void *)&cmd_flow_director_mask,
9750 (void *)&cmd_flow_director_mask_port_id,
9751 (void *)&cmd_flow_director_mask_mode,
9752 (void *)&cmd_flow_director_mask_mode_ip,
9753 (void *)&cmd_flow_director_mask_vlan,
9754 (void *)&cmd_flow_director_mask_vlan_value,
9755 (void *)&cmd_flow_director_mask_src,
9756 (void *)&cmd_flow_director_mask_ipv4_src,
9757 (void *)&cmd_flow_director_mask_ipv6_src,
9758 (void *)&cmd_flow_director_mask_port_src,
9759 (void *)&cmd_flow_director_mask_dst,
9760 (void *)&cmd_flow_director_mask_ipv4_dst,
9761 (void *)&cmd_flow_director_mask_ipv6_dst,
9762 (void *)&cmd_flow_director_mask_port_dst,
9767 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9768 .f = cmd_flow_director_mask_parsed,
9770 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9771 "flow director's mask on NIC",
9773 (void *)&cmd_flow_director_mask,
9774 (void *)&cmd_flow_director_mask_port_id,
9775 (void *)&cmd_flow_director_mask_mode,
9776 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9777 (void *)&cmd_flow_director_mask_vlan,
9778 (void *)&cmd_flow_director_mask_vlan_value,
9783 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9784 .f = cmd_flow_director_mask_parsed,
9786 .help_str = "flow_director_mask ... : Set tunnel mode "
9787 "flow director's mask on NIC",
9789 (void *)&cmd_flow_director_mask,
9790 (void *)&cmd_flow_director_mask_port_id,
9791 (void *)&cmd_flow_director_mask_mode,
9792 (void *)&cmd_flow_director_mask_mode_tunnel,
9793 (void *)&cmd_flow_director_mask_vlan,
9794 (void *)&cmd_flow_director_mask_vlan_value,
9795 (void *)&cmd_flow_director_mask_mac,
9796 (void *)&cmd_flow_director_mask_mac_value,
9797 (void *)&cmd_flow_director_mask_tunnel_type,
9798 (void *)&cmd_flow_director_mask_tunnel_type_value,
9799 (void *)&cmd_flow_director_mask_tunnel_id,
9800 (void *)&cmd_flow_director_mask_tunnel_id_value,
9805 /* *** deal with flow director mask on flexible payload *** */
9806 struct cmd_flow_director_flex_mask_result {
9807 cmdline_fixed_string_t flow_director_flexmask;
9809 cmdline_fixed_string_t flow;
9810 cmdline_fixed_string_t flow_type;
9811 cmdline_fixed_string_t mask;
9815 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9816 __attribute__((unused)) struct cmdline *cl,
9817 __attribute__((unused)) void *data)
9819 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9820 struct rte_eth_fdir_info fdir_info;
9821 struct rte_eth_fdir_flex_mask flex_mask;
9822 struct rte_port *port;
9823 uint32_t flow_type_mask;
9827 if (res->port_id > nb_ports) {
9828 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9832 port = &ports[res->port_id];
9833 /** Check if the port is not started **/
9834 if (port->port_status != RTE_PORT_STOPPED) {
9835 printf("Please stop port %d first\n", res->port_id);
9839 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9840 ret = parse_flexbytes(res->mask,
9842 RTE_ETH_FDIR_MAX_FLEXLEN);
9844 printf("error: Cannot parse mask input.\n");
9848 memset(&fdir_info, 0, sizeof(fdir_info));
9849 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9850 RTE_ETH_FILTER_INFO, &fdir_info);
9852 printf("Cannot get FDir filter info\n");
9856 if (!strcmp(res->flow_type, "none")) {
9857 /* means don't specify the flow type */
9858 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9859 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9860 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9861 0, sizeof(struct rte_eth_fdir_flex_mask));
9862 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9863 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9865 sizeof(struct rte_eth_fdir_flex_mask));
9866 cmd_reconfig_device_queue(res->port_id, 1, 1);
9869 flow_type_mask = fdir_info.flow_types_mask[0];
9870 if (!strcmp(res->flow_type, "all")) {
9871 if (!flow_type_mask) {
9872 printf("No flow type supported\n");
9875 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9876 if (flow_type_mask & (1 << i)) {
9877 flex_mask.flow_type = i;
9878 fdir_set_flex_mask(res->port_id, &flex_mask);
9881 cmd_reconfig_device_queue(res->port_id, 1, 1);
9884 flex_mask.flow_type = str2flowtype(res->flow_type);
9885 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9886 printf("Flow type %s not supported on port %d\n",
9887 res->flow_type, res->port_id);
9890 fdir_set_flex_mask(res->port_id, &flex_mask);
9891 cmd_reconfig_device_queue(res->port_id, 1, 1);
9894 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9896 flow_director_flexmask,
9897 "flow_director_flex_mask");
9898 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9899 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9901 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9902 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9904 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9905 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9906 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9907 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9908 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9909 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9912 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9913 .f = cmd_flow_director_flex_mask_parsed,
9915 .help_str = "flow_director_flex_mask ... : "
9916 "Set flow director's flex mask on NIC",
9918 (void *)&cmd_flow_director_flexmask,
9919 (void *)&cmd_flow_director_flexmask_port_id,
9920 (void *)&cmd_flow_director_flexmask_flow,
9921 (void *)&cmd_flow_director_flexmask_flow_type,
9922 (void *)&cmd_flow_director_flexmask_mask,
9927 /* *** deal with flow director flexible payload configuration *** */
9928 struct cmd_flow_director_flexpayload_result {
9929 cmdline_fixed_string_t flow_director_flexpayload;
9931 cmdline_fixed_string_t payload_layer;
9932 cmdline_fixed_string_t payload_cfg;
9936 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9939 const char *p, *p0 = q_arg;
9941 unsigned long int_fld;
9942 char *str_fld[max_num];
9947 p = strchr(p0, '(');
9951 p0 = strchr(p, ')');
9956 if (size >= sizeof(s))
9959 snprintf(s, sizeof(s), "%.*s", size, p);
9960 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9961 if (ret < 0 || ret > max_num)
9963 for (i = 0; i < ret; i++) {
9965 int_fld = strtoul(str_fld[i], &end, 0);
9966 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9968 offsets[i] = (uint16_t)int_fld;
9974 cmd_flow_director_flxpld_parsed(void *parsed_result,
9975 __attribute__((unused)) struct cmdline *cl,
9976 __attribute__((unused)) void *data)
9978 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9979 struct rte_eth_flex_payload_cfg flex_cfg;
9980 struct rte_port *port;
9983 if (res->port_id > nb_ports) {
9984 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9988 port = &ports[res->port_id];
9989 /** Check if the port is not started **/
9990 if (port->port_status != RTE_PORT_STOPPED) {
9991 printf("Please stop port %d first\n", res->port_id);
9995 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9997 if (!strcmp(res->payload_layer, "raw"))
9998 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9999 else if (!strcmp(res->payload_layer, "l2"))
10000 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10001 else if (!strcmp(res->payload_layer, "l3"))
10002 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10003 else if (!strcmp(res->payload_layer, "l4"))
10004 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10006 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10007 RTE_ETH_FDIR_MAX_FLEXLEN);
10009 printf("error: Cannot parse flex payload input.\n");
10013 fdir_set_flex_payload(res->port_id, &flex_cfg);
10014 cmd_reconfig_device_queue(res->port_id, 1, 1);
10017 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10018 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10019 flow_director_flexpayload,
10020 "flow_director_flex_payload");
10021 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10022 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10024 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10025 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10026 payload_layer, "raw#l2#l3#l4");
10027 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10028 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10029 payload_cfg, NULL);
10031 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10032 .f = cmd_flow_director_flxpld_parsed,
10034 .help_str = "flow_director_flexpayload ... : "
10035 "Set flow director's flex payload on NIC",
10037 (void *)&cmd_flow_director_flexpayload,
10038 (void *)&cmd_flow_director_flexpayload_port_id,
10039 (void *)&cmd_flow_director_flexpayload_payload_layer,
10040 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10045 /* Generic flow interface command. */
10046 extern cmdline_parse_inst_t cmd_flow;
10048 /* *** Classification Filters Control *** */
10049 /* *** Get symmetric hash enable per port *** */
10050 struct cmd_get_sym_hash_ena_per_port_result {
10051 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10056 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10057 __rte_unused struct cmdline *cl,
10058 __rte_unused void *data)
10060 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10061 struct rte_eth_hash_filter_info info;
10064 if (rte_eth_dev_filter_supported(res->port_id,
10065 RTE_ETH_FILTER_HASH) < 0) {
10066 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10071 memset(&info, 0, sizeof(info));
10072 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10073 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10074 RTE_ETH_FILTER_GET, &info);
10077 printf("Cannot get symmetric hash enable per port "
10078 "on port %u\n", res->port_id);
10082 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10083 "enabled" : "disabled", res->port_id);
10086 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10087 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10088 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10089 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10090 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10093 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10094 .f = cmd_get_sym_hash_per_port_parsed,
10096 .help_str = "get_sym_hash_ena_per_port <port_id>",
10098 (void *)&cmd_get_sym_hash_ena_per_port_all,
10099 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10104 /* *** Set symmetric hash enable per port *** */
10105 struct cmd_set_sym_hash_ena_per_port_result {
10106 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10107 cmdline_fixed_string_t enable;
10112 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10113 __rte_unused struct cmdline *cl,
10114 __rte_unused void *data)
10116 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10117 struct rte_eth_hash_filter_info info;
10120 if (rte_eth_dev_filter_supported(res->port_id,
10121 RTE_ETH_FILTER_HASH) < 0) {
10122 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10127 memset(&info, 0, sizeof(info));
10128 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10129 if (!strcmp(res->enable, "enable"))
10130 info.info.enable = 1;
10131 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10132 RTE_ETH_FILTER_SET, &info);
10134 printf("Cannot set symmetric hash enable per port on "
10135 "port %u\n", res->port_id);
10138 printf("Symmetric hash has been set to %s on port %u\n",
10139 res->enable, res->port_id);
10142 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
10143 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10144 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
10145 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
10146 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10148 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
10149 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10150 enable, "enable#disable");
10152 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
10153 .f = cmd_set_sym_hash_per_port_parsed,
10155 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
10157 (void *)&cmd_set_sym_hash_ena_per_port_all,
10158 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
10159 (void *)&cmd_set_sym_hash_ena_per_port_enable,
10164 /* Get global config of hash function */
10165 struct cmd_get_hash_global_config_result {
10166 cmdline_fixed_string_t get_hash_global_config;
10171 flowtype_to_str(uint16_t ftype)
10177 } ftype_table[] = {
10178 {"ipv4", RTE_ETH_FLOW_IPV4},
10179 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10180 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10181 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10182 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10183 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10184 {"ipv6", RTE_ETH_FLOW_IPV6},
10185 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10186 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10187 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10188 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10189 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10190 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10191 {"port", RTE_ETH_FLOW_PORT},
10192 {"vxlan", RTE_ETH_FLOW_VXLAN},
10193 {"geneve", RTE_ETH_FLOW_GENEVE},
10194 {"nvgre", RTE_ETH_FLOW_NVGRE},
10197 for (i = 0; i < RTE_DIM(ftype_table); i++) {
10198 if (ftype_table[i].ftype == ftype)
10199 return ftype_table[i].str;
10206 cmd_get_hash_global_config_parsed(void *parsed_result,
10207 __rte_unused struct cmdline *cl,
10208 __rte_unused void *data)
10210 struct cmd_get_hash_global_config_result *res = parsed_result;
10211 struct rte_eth_hash_filter_info info;
10212 uint32_t idx, offset;
10217 if (rte_eth_dev_filter_supported(res->port_id,
10218 RTE_ETH_FILTER_HASH) < 0) {
10219 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10224 memset(&info, 0, sizeof(info));
10225 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10226 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10227 RTE_ETH_FILTER_GET, &info);
10229 printf("Cannot get hash global configurations by port %d\n",
10234 switch (info.info.global_conf.hash_func) {
10235 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
10236 printf("Hash function is Toeplitz\n");
10238 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
10239 printf("Hash function is Simple XOR\n");
10242 printf("Unknown hash function\n");
10246 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
10247 idx = i / UINT32_BIT;
10248 offset = i % UINT32_BIT;
10249 if (!(info.info.global_conf.valid_bit_mask[idx] &
10252 str = flowtype_to_str(i);
10255 printf("Symmetric hash is %s globally for flow type %s "
10257 ((info.info.global_conf.sym_hash_enable_mask[idx] &
10258 (1UL << offset)) ? "enabled" : "disabled"), str,
10263 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
10264 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
10265 get_hash_global_config, "get_hash_global_config");
10266 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
10267 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
10270 cmdline_parse_inst_t cmd_get_hash_global_config = {
10271 .f = cmd_get_hash_global_config_parsed,
10273 .help_str = "get_hash_global_config <port_id>",
10275 (void *)&cmd_get_hash_global_config_all,
10276 (void *)&cmd_get_hash_global_config_port_id,
10281 /* Set global config of hash function */
10282 struct cmd_set_hash_global_config_result {
10283 cmdline_fixed_string_t set_hash_global_config;
10285 cmdline_fixed_string_t hash_func;
10286 cmdline_fixed_string_t flow_type;
10287 cmdline_fixed_string_t enable;
10291 cmd_set_hash_global_config_parsed(void *parsed_result,
10292 __rte_unused struct cmdline *cl,
10293 __rte_unused void *data)
10295 struct cmd_set_hash_global_config_result *res = parsed_result;
10296 struct rte_eth_hash_filter_info info;
10297 uint32_t ftype, idx, offset;
10300 if (rte_eth_dev_filter_supported(res->port_id,
10301 RTE_ETH_FILTER_HASH) < 0) {
10302 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10306 memset(&info, 0, sizeof(info));
10307 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10308 if (!strcmp(res->hash_func, "toeplitz"))
10309 info.info.global_conf.hash_func =
10310 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
10311 else if (!strcmp(res->hash_func, "simple_xor"))
10312 info.info.global_conf.hash_func =
10313 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
10314 else if (!strcmp(res->hash_func, "default"))
10315 info.info.global_conf.hash_func =
10316 RTE_ETH_HASH_FUNCTION_DEFAULT;
10318 ftype = str2flowtype(res->flow_type);
10319 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
10320 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
10321 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
10322 if (!strcmp(res->enable, "enable"))
10323 info.info.global_conf.sym_hash_enable_mask[idx] |=
10325 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10326 RTE_ETH_FILTER_SET, &info);
10328 printf("Cannot set global hash configurations by port %d\n",
10331 printf("Global hash configurations have been set "
10332 "succcessfully by port %d\n", res->port_id);
10335 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
10336 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10337 set_hash_global_config, "set_hash_global_config");
10338 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
10339 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
10341 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
10342 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10343 hash_func, "toeplitz#simple_xor#default");
10344 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
10345 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10347 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
10348 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10349 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
10350 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
10351 enable, "enable#disable");
10353 cmdline_parse_inst_t cmd_set_hash_global_config = {
10354 .f = cmd_set_hash_global_config_parsed,
10356 .help_str = "set_hash_global_config <port_id> "
10357 "toeplitz|simple_xor|default "
10358 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10359 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10360 "l2_payload enable|disable",
10362 (void *)&cmd_set_hash_global_config_all,
10363 (void *)&cmd_set_hash_global_config_port_id,
10364 (void *)&cmd_set_hash_global_config_hash_func,
10365 (void *)&cmd_set_hash_global_config_flow_type,
10366 (void *)&cmd_set_hash_global_config_enable,
10371 /* Set hash input set */
10372 struct cmd_set_hash_input_set_result {
10373 cmdline_fixed_string_t set_hash_input_set;
10375 cmdline_fixed_string_t flow_type;
10376 cmdline_fixed_string_t inset_field;
10377 cmdline_fixed_string_t select;
10380 static enum rte_eth_input_set_field
10381 str2inset(char *string)
10385 static const struct {
10387 enum rte_eth_input_set_field inset;
10388 } inset_table[] = {
10389 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10390 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10391 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10392 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10393 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10394 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10395 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10396 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10397 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10398 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10399 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10400 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10401 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10402 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10403 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10404 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10405 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10406 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10407 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10408 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10409 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10410 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10411 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10412 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10413 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10414 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10415 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10416 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10417 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10418 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10419 {"none", RTE_ETH_INPUT_SET_NONE},
10422 for (i = 0; i < RTE_DIM(inset_table); i++) {
10423 if (!strcmp(string, inset_table[i].str))
10424 return inset_table[i].inset;
10427 return RTE_ETH_INPUT_SET_UNKNOWN;
10431 cmd_set_hash_input_set_parsed(void *parsed_result,
10432 __rte_unused struct cmdline *cl,
10433 __rte_unused void *data)
10435 struct cmd_set_hash_input_set_result *res = parsed_result;
10436 struct rte_eth_hash_filter_info info;
10438 memset(&info, 0, sizeof(info));
10439 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10440 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10441 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10442 info.info.input_set_conf.inset_size = 1;
10443 if (!strcmp(res->select, "select"))
10444 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10445 else if (!strcmp(res->select, "add"))
10446 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10447 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10448 RTE_ETH_FILTER_SET, &info);
10451 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10452 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10453 set_hash_input_set, "set_hash_input_set");
10454 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10455 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10457 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10458 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10460 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10461 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10462 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10463 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10465 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10466 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10467 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10468 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10469 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10471 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10472 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10473 select, "select#add");
10475 cmdline_parse_inst_t cmd_set_hash_input_set = {
10476 .f = cmd_set_hash_input_set_parsed,
10478 .help_str = "set_hash_input_set <port_id> "
10479 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10480 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10481 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10482 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10483 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10484 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10485 "fld-7th|fld-8th|none select|add",
10487 (void *)&cmd_set_hash_input_set_cmd,
10488 (void *)&cmd_set_hash_input_set_port_id,
10489 (void *)&cmd_set_hash_input_set_flow_type,
10490 (void *)&cmd_set_hash_input_set_field,
10491 (void *)&cmd_set_hash_input_set_select,
10496 /* Set flow director input set */
10497 struct cmd_set_fdir_input_set_result {
10498 cmdline_fixed_string_t set_fdir_input_set;
10500 cmdline_fixed_string_t flow_type;
10501 cmdline_fixed_string_t inset_field;
10502 cmdline_fixed_string_t select;
10506 cmd_set_fdir_input_set_parsed(void *parsed_result,
10507 __rte_unused struct cmdline *cl,
10508 __rte_unused void *data)
10510 struct cmd_set_fdir_input_set_result *res = parsed_result;
10511 struct rte_eth_fdir_filter_info info;
10513 memset(&info, 0, sizeof(info));
10514 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10515 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10516 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10517 info.info.input_set_conf.inset_size = 1;
10518 if (!strcmp(res->select, "select"))
10519 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10520 else if (!strcmp(res->select, "add"))
10521 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10522 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10523 RTE_ETH_FILTER_SET, &info);
10526 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10527 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10528 set_fdir_input_set, "set_fdir_input_set");
10529 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10530 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10532 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10533 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10535 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10536 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10537 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10538 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10540 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10541 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10542 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10543 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10544 "sctp-veri-tag#none");
10545 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10546 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10547 select, "select#add");
10549 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10550 .f = cmd_set_fdir_input_set_parsed,
10552 .help_str = "set_fdir_input_set <port_id> "
10553 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10554 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10555 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10556 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10557 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10558 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10559 "sctp-veri-tag|none select|add",
10561 (void *)&cmd_set_fdir_input_set_cmd,
10562 (void *)&cmd_set_fdir_input_set_port_id,
10563 (void *)&cmd_set_fdir_input_set_flow_type,
10564 (void *)&cmd_set_fdir_input_set_field,
10565 (void *)&cmd_set_fdir_input_set_select,
10570 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10571 struct cmd_mcast_addr_result {
10572 cmdline_fixed_string_t mcast_addr_cmd;
10573 cmdline_fixed_string_t what;
10575 struct ether_addr mc_addr;
10578 static void cmd_mcast_addr_parsed(void *parsed_result,
10579 __attribute__((unused)) struct cmdline *cl,
10580 __attribute__((unused)) void *data)
10582 struct cmd_mcast_addr_result *res = parsed_result;
10584 if (!is_multicast_ether_addr(&res->mc_addr)) {
10585 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10586 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10587 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10588 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10591 if (strcmp(res->what, "add") == 0)
10592 mcast_addr_add(res->port_num, &res->mc_addr);
10594 mcast_addr_remove(res->port_num, &res->mc_addr);
10597 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10598 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10599 mcast_addr_cmd, "mcast_addr");
10600 cmdline_parse_token_string_t cmd_mcast_addr_what =
10601 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10603 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10604 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10605 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10606 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10608 cmdline_parse_inst_t cmd_mcast_addr = {
10609 .f = cmd_mcast_addr_parsed,
10611 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10612 "Add/Remove multicast MAC address on port_id",
10614 (void *)&cmd_mcast_addr_cmd,
10615 (void *)&cmd_mcast_addr_what,
10616 (void *)&cmd_mcast_addr_portnum,
10617 (void *)&cmd_mcast_addr_addr,
10622 /* l2 tunnel config
10623 * only support E-tag now.
10626 /* Ether type config */
10627 struct cmd_config_l2_tunnel_eth_type_result {
10628 cmdline_fixed_string_t port;
10629 cmdline_fixed_string_t config;
10630 cmdline_fixed_string_t all;
10632 cmdline_fixed_string_t l2_tunnel;
10633 cmdline_fixed_string_t l2_tunnel_type;
10634 cmdline_fixed_string_t eth_type;
10635 uint16_t eth_type_val;
10638 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10639 TOKEN_STRING_INITIALIZER
10640 (struct cmd_config_l2_tunnel_eth_type_result,
10642 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10643 TOKEN_STRING_INITIALIZER
10644 (struct cmd_config_l2_tunnel_eth_type_result,
10646 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10647 TOKEN_STRING_INITIALIZER
10648 (struct cmd_config_l2_tunnel_eth_type_result,
10650 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10651 TOKEN_NUM_INITIALIZER
10652 (struct cmd_config_l2_tunnel_eth_type_result,
10654 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10655 TOKEN_STRING_INITIALIZER
10656 (struct cmd_config_l2_tunnel_eth_type_result,
10657 l2_tunnel, "l2-tunnel");
10658 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10659 TOKEN_STRING_INITIALIZER
10660 (struct cmd_config_l2_tunnel_eth_type_result,
10661 l2_tunnel_type, "E-tag");
10662 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10663 TOKEN_STRING_INITIALIZER
10664 (struct cmd_config_l2_tunnel_eth_type_result,
10665 eth_type, "ether-type");
10666 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10667 TOKEN_NUM_INITIALIZER
10668 (struct cmd_config_l2_tunnel_eth_type_result,
10669 eth_type_val, UINT16);
10671 static enum rte_eth_tunnel_type
10672 str2fdir_l2_tunnel_type(char *string)
10676 static const struct {
10678 enum rte_eth_tunnel_type type;
10679 } l2_tunnel_type_str[] = {
10680 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10683 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10684 if (!strcmp(l2_tunnel_type_str[i].str, string))
10685 return l2_tunnel_type_str[i].type;
10687 return RTE_TUNNEL_TYPE_NONE;
10690 /* ether type config for all ports */
10692 cmd_config_l2_tunnel_eth_type_all_parsed
10693 (void *parsed_result,
10694 __attribute__((unused)) struct cmdline *cl,
10695 __attribute__((unused)) void *data)
10697 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10698 struct rte_eth_l2_tunnel_conf entry;
10701 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10702 entry.ether_type = res->eth_type_val;
10704 RTE_ETH_FOREACH_DEV(pid) {
10705 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10709 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10710 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10712 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10714 (void *)&cmd_config_l2_tunnel_eth_type_port,
10715 (void *)&cmd_config_l2_tunnel_eth_type_config,
10716 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10717 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10718 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10719 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10720 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10725 /* ether type config for a specific port */
10727 cmd_config_l2_tunnel_eth_type_specific_parsed(
10728 void *parsed_result,
10729 __attribute__((unused)) struct cmdline *cl,
10730 __attribute__((unused)) void *data)
10732 struct cmd_config_l2_tunnel_eth_type_result *res =
10734 struct rte_eth_l2_tunnel_conf entry;
10736 if (port_id_is_invalid(res->id, ENABLED_WARN))
10739 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10740 entry.ether_type = res->eth_type_val;
10742 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10745 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10746 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10748 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10750 (void *)&cmd_config_l2_tunnel_eth_type_port,
10751 (void *)&cmd_config_l2_tunnel_eth_type_config,
10752 (void *)&cmd_config_l2_tunnel_eth_type_id,
10753 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10754 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10755 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10756 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10761 /* Enable/disable l2 tunnel */
10762 struct cmd_config_l2_tunnel_en_dis_result {
10763 cmdline_fixed_string_t port;
10764 cmdline_fixed_string_t config;
10765 cmdline_fixed_string_t all;
10767 cmdline_fixed_string_t l2_tunnel;
10768 cmdline_fixed_string_t l2_tunnel_type;
10769 cmdline_fixed_string_t en_dis;
10772 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10773 TOKEN_STRING_INITIALIZER
10774 (struct cmd_config_l2_tunnel_en_dis_result,
10776 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10777 TOKEN_STRING_INITIALIZER
10778 (struct cmd_config_l2_tunnel_en_dis_result,
10780 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10781 TOKEN_STRING_INITIALIZER
10782 (struct cmd_config_l2_tunnel_en_dis_result,
10784 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10785 TOKEN_NUM_INITIALIZER
10786 (struct cmd_config_l2_tunnel_en_dis_result,
10788 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10789 TOKEN_STRING_INITIALIZER
10790 (struct cmd_config_l2_tunnel_en_dis_result,
10791 l2_tunnel, "l2-tunnel");
10792 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10793 TOKEN_STRING_INITIALIZER
10794 (struct cmd_config_l2_tunnel_en_dis_result,
10795 l2_tunnel_type, "E-tag");
10796 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10797 TOKEN_STRING_INITIALIZER
10798 (struct cmd_config_l2_tunnel_en_dis_result,
10799 en_dis, "enable#disable");
10801 /* enable/disable l2 tunnel for all ports */
10803 cmd_config_l2_tunnel_en_dis_all_parsed(
10804 void *parsed_result,
10805 __attribute__((unused)) struct cmdline *cl,
10806 __attribute__((unused)) void *data)
10808 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10809 struct rte_eth_l2_tunnel_conf entry;
10813 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10815 if (!strcmp("enable", res->en_dis))
10820 RTE_ETH_FOREACH_DEV(pid) {
10821 rte_eth_dev_l2_tunnel_offload_set(pid,
10823 ETH_L2_TUNNEL_ENABLE_MASK,
10828 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10829 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10831 .help_str = "port config all l2-tunnel E-tag enable|disable",
10833 (void *)&cmd_config_l2_tunnel_en_dis_port,
10834 (void *)&cmd_config_l2_tunnel_en_dis_config,
10835 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10836 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10837 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10838 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10843 /* enable/disable l2 tunnel for a port */
10845 cmd_config_l2_tunnel_en_dis_specific_parsed(
10846 void *parsed_result,
10847 __attribute__((unused)) struct cmdline *cl,
10848 __attribute__((unused)) void *data)
10850 struct cmd_config_l2_tunnel_en_dis_result *res =
10852 struct rte_eth_l2_tunnel_conf entry;
10854 if (port_id_is_invalid(res->id, ENABLED_WARN))
10857 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10859 if (!strcmp("enable", res->en_dis))
10860 rte_eth_dev_l2_tunnel_offload_set(res->id,
10862 ETH_L2_TUNNEL_ENABLE_MASK,
10865 rte_eth_dev_l2_tunnel_offload_set(res->id,
10867 ETH_L2_TUNNEL_ENABLE_MASK,
10871 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10872 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10874 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10876 (void *)&cmd_config_l2_tunnel_en_dis_port,
10877 (void *)&cmd_config_l2_tunnel_en_dis_config,
10878 (void *)&cmd_config_l2_tunnel_en_dis_id,
10879 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10880 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10881 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10886 /* E-tag configuration */
10888 /* Common result structure for all E-tag configuration */
10889 struct cmd_config_e_tag_result {
10890 cmdline_fixed_string_t e_tag;
10891 cmdline_fixed_string_t set;
10892 cmdline_fixed_string_t insertion;
10893 cmdline_fixed_string_t stripping;
10894 cmdline_fixed_string_t forwarding;
10895 cmdline_fixed_string_t filter;
10896 cmdline_fixed_string_t add;
10897 cmdline_fixed_string_t del;
10898 cmdline_fixed_string_t on;
10899 cmdline_fixed_string_t off;
10900 cmdline_fixed_string_t on_off;
10901 cmdline_fixed_string_t port_tag_id;
10902 uint32_t port_tag_id_val;
10903 cmdline_fixed_string_t e_tag_id;
10904 uint16_t e_tag_id_val;
10905 cmdline_fixed_string_t dst_pool;
10906 uint8_t dst_pool_val;
10907 cmdline_fixed_string_t port;
10909 cmdline_fixed_string_t vf;
10913 /* Common CLI fields for all E-tag configuration */
10914 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10915 TOKEN_STRING_INITIALIZER
10916 (struct cmd_config_e_tag_result,
10918 cmdline_parse_token_string_t cmd_config_e_tag_set =
10919 TOKEN_STRING_INITIALIZER
10920 (struct cmd_config_e_tag_result,
10922 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10923 TOKEN_STRING_INITIALIZER
10924 (struct cmd_config_e_tag_result,
10925 insertion, "insertion");
10926 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10927 TOKEN_STRING_INITIALIZER
10928 (struct cmd_config_e_tag_result,
10929 stripping, "stripping");
10930 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10931 TOKEN_STRING_INITIALIZER
10932 (struct cmd_config_e_tag_result,
10933 forwarding, "forwarding");
10934 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10935 TOKEN_STRING_INITIALIZER
10936 (struct cmd_config_e_tag_result,
10938 cmdline_parse_token_string_t cmd_config_e_tag_add =
10939 TOKEN_STRING_INITIALIZER
10940 (struct cmd_config_e_tag_result,
10942 cmdline_parse_token_string_t cmd_config_e_tag_del =
10943 TOKEN_STRING_INITIALIZER
10944 (struct cmd_config_e_tag_result,
10946 cmdline_parse_token_string_t cmd_config_e_tag_on =
10947 TOKEN_STRING_INITIALIZER
10948 (struct cmd_config_e_tag_result,
10950 cmdline_parse_token_string_t cmd_config_e_tag_off =
10951 TOKEN_STRING_INITIALIZER
10952 (struct cmd_config_e_tag_result,
10954 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10955 TOKEN_STRING_INITIALIZER
10956 (struct cmd_config_e_tag_result,
10958 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10959 TOKEN_STRING_INITIALIZER
10960 (struct cmd_config_e_tag_result,
10961 port_tag_id, "port-tag-id");
10962 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10963 TOKEN_NUM_INITIALIZER
10964 (struct cmd_config_e_tag_result,
10965 port_tag_id_val, UINT32);
10966 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10967 TOKEN_STRING_INITIALIZER
10968 (struct cmd_config_e_tag_result,
10969 e_tag_id, "e-tag-id");
10970 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10971 TOKEN_NUM_INITIALIZER
10972 (struct cmd_config_e_tag_result,
10973 e_tag_id_val, UINT16);
10974 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10975 TOKEN_STRING_INITIALIZER
10976 (struct cmd_config_e_tag_result,
10977 dst_pool, "dst-pool");
10978 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10979 TOKEN_NUM_INITIALIZER
10980 (struct cmd_config_e_tag_result,
10981 dst_pool_val, UINT8);
10982 cmdline_parse_token_string_t cmd_config_e_tag_port =
10983 TOKEN_STRING_INITIALIZER
10984 (struct cmd_config_e_tag_result,
10986 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10987 TOKEN_NUM_INITIALIZER
10988 (struct cmd_config_e_tag_result,
10990 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10991 TOKEN_STRING_INITIALIZER
10992 (struct cmd_config_e_tag_result,
10994 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10995 TOKEN_NUM_INITIALIZER
10996 (struct cmd_config_e_tag_result,
10999 /* E-tag insertion configuration */
11001 cmd_config_e_tag_insertion_en_parsed(
11002 void *parsed_result,
11003 __attribute__((unused)) struct cmdline *cl,
11004 __attribute__((unused)) void *data)
11006 struct cmd_config_e_tag_result *res =
11008 struct rte_eth_l2_tunnel_conf entry;
11010 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11013 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11014 entry.tunnel_id = res->port_tag_id_val;
11015 entry.vf_id = res->vf_id;
11016 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11018 ETH_L2_TUNNEL_INSERTION_MASK,
11023 cmd_config_e_tag_insertion_dis_parsed(
11024 void *parsed_result,
11025 __attribute__((unused)) struct cmdline *cl,
11026 __attribute__((unused)) void *data)
11028 struct cmd_config_e_tag_result *res =
11030 struct rte_eth_l2_tunnel_conf entry;
11032 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11035 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11036 entry.vf_id = res->vf_id;
11038 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11040 ETH_L2_TUNNEL_INSERTION_MASK,
11044 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11045 .f = cmd_config_e_tag_insertion_en_parsed,
11047 .help_str = "E-tag ... : E-tag insertion enable",
11049 (void *)&cmd_config_e_tag_e_tag,
11050 (void *)&cmd_config_e_tag_set,
11051 (void *)&cmd_config_e_tag_insertion,
11052 (void *)&cmd_config_e_tag_on,
11053 (void *)&cmd_config_e_tag_port_tag_id,
11054 (void *)&cmd_config_e_tag_port_tag_id_val,
11055 (void *)&cmd_config_e_tag_port,
11056 (void *)&cmd_config_e_tag_port_id,
11057 (void *)&cmd_config_e_tag_vf,
11058 (void *)&cmd_config_e_tag_vf_id,
11063 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11064 .f = cmd_config_e_tag_insertion_dis_parsed,
11066 .help_str = "E-tag ... : E-tag insertion disable",
11068 (void *)&cmd_config_e_tag_e_tag,
11069 (void *)&cmd_config_e_tag_set,
11070 (void *)&cmd_config_e_tag_insertion,
11071 (void *)&cmd_config_e_tag_off,
11072 (void *)&cmd_config_e_tag_port,
11073 (void *)&cmd_config_e_tag_port_id,
11074 (void *)&cmd_config_e_tag_vf,
11075 (void *)&cmd_config_e_tag_vf_id,
11080 /* E-tag stripping configuration */
11082 cmd_config_e_tag_stripping_parsed(
11083 void *parsed_result,
11084 __attribute__((unused)) struct cmdline *cl,
11085 __attribute__((unused)) void *data)
11087 struct cmd_config_e_tag_result *res =
11089 struct rte_eth_l2_tunnel_conf entry;
11091 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11094 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11096 if (!strcmp(res->on_off, "on"))
11097 rte_eth_dev_l2_tunnel_offload_set
11100 ETH_L2_TUNNEL_STRIPPING_MASK,
11103 rte_eth_dev_l2_tunnel_offload_set
11106 ETH_L2_TUNNEL_STRIPPING_MASK,
11110 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11111 .f = cmd_config_e_tag_stripping_parsed,
11113 .help_str = "E-tag ... : E-tag stripping enable/disable",
11115 (void *)&cmd_config_e_tag_e_tag,
11116 (void *)&cmd_config_e_tag_set,
11117 (void *)&cmd_config_e_tag_stripping,
11118 (void *)&cmd_config_e_tag_on_off,
11119 (void *)&cmd_config_e_tag_port,
11120 (void *)&cmd_config_e_tag_port_id,
11125 /* E-tag forwarding configuration */
11127 cmd_config_e_tag_forwarding_parsed(
11128 void *parsed_result,
11129 __attribute__((unused)) struct cmdline *cl,
11130 __attribute__((unused)) void *data)
11132 struct cmd_config_e_tag_result *res = parsed_result;
11133 struct rte_eth_l2_tunnel_conf entry;
11135 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11138 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11140 if (!strcmp(res->on_off, "on"))
11141 rte_eth_dev_l2_tunnel_offload_set
11144 ETH_L2_TUNNEL_FORWARDING_MASK,
11147 rte_eth_dev_l2_tunnel_offload_set
11150 ETH_L2_TUNNEL_FORWARDING_MASK,
11154 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11155 .f = cmd_config_e_tag_forwarding_parsed,
11157 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11159 (void *)&cmd_config_e_tag_e_tag,
11160 (void *)&cmd_config_e_tag_set,
11161 (void *)&cmd_config_e_tag_forwarding,
11162 (void *)&cmd_config_e_tag_on_off,
11163 (void *)&cmd_config_e_tag_port,
11164 (void *)&cmd_config_e_tag_port_id,
11169 /* E-tag filter configuration */
11171 cmd_config_e_tag_filter_add_parsed(
11172 void *parsed_result,
11173 __attribute__((unused)) struct cmdline *cl,
11174 __attribute__((unused)) void *data)
11176 struct cmd_config_e_tag_result *res = parsed_result;
11177 struct rte_eth_l2_tunnel_conf entry;
11180 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11183 if (res->e_tag_id_val > 0x3fff) {
11184 printf("e-tag-id must be equal or less than 0x3fff.\n");
11188 ret = rte_eth_dev_filter_supported(res->port_id,
11189 RTE_ETH_FILTER_L2_TUNNEL);
11191 printf("E-tag filter is not supported on port %u.\n",
11196 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11197 entry.tunnel_id = res->e_tag_id_val;
11198 entry.pool = res->dst_pool_val;
11200 ret = rte_eth_dev_filter_ctrl(res->port_id,
11201 RTE_ETH_FILTER_L2_TUNNEL,
11202 RTE_ETH_FILTER_ADD,
11205 printf("E-tag filter programming error: (%s)\n",
11209 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
11210 .f = cmd_config_e_tag_filter_add_parsed,
11212 .help_str = "E-tag ... : E-tag filter add",
11214 (void *)&cmd_config_e_tag_e_tag,
11215 (void *)&cmd_config_e_tag_set,
11216 (void *)&cmd_config_e_tag_filter,
11217 (void *)&cmd_config_e_tag_add,
11218 (void *)&cmd_config_e_tag_e_tag_id,
11219 (void *)&cmd_config_e_tag_e_tag_id_val,
11220 (void *)&cmd_config_e_tag_dst_pool,
11221 (void *)&cmd_config_e_tag_dst_pool_val,
11222 (void *)&cmd_config_e_tag_port,
11223 (void *)&cmd_config_e_tag_port_id,
11229 cmd_config_e_tag_filter_del_parsed(
11230 void *parsed_result,
11231 __attribute__((unused)) struct cmdline *cl,
11232 __attribute__((unused)) void *data)
11234 struct cmd_config_e_tag_result *res = parsed_result;
11235 struct rte_eth_l2_tunnel_conf entry;
11238 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11241 if (res->e_tag_id_val > 0x3fff) {
11242 printf("e-tag-id must be less than 0x3fff.\n");
11246 ret = rte_eth_dev_filter_supported(res->port_id,
11247 RTE_ETH_FILTER_L2_TUNNEL);
11249 printf("E-tag filter is not supported on port %u.\n",
11254 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11255 entry.tunnel_id = res->e_tag_id_val;
11257 ret = rte_eth_dev_filter_ctrl(res->port_id,
11258 RTE_ETH_FILTER_L2_TUNNEL,
11259 RTE_ETH_FILTER_DELETE,
11262 printf("E-tag filter programming error: (%s)\n",
11266 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
11267 .f = cmd_config_e_tag_filter_del_parsed,
11269 .help_str = "E-tag ... : E-tag filter delete",
11271 (void *)&cmd_config_e_tag_e_tag,
11272 (void *)&cmd_config_e_tag_set,
11273 (void *)&cmd_config_e_tag_filter,
11274 (void *)&cmd_config_e_tag_del,
11275 (void *)&cmd_config_e_tag_e_tag_id,
11276 (void *)&cmd_config_e_tag_e_tag_id_val,
11277 (void *)&cmd_config_e_tag_port,
11278 (void *)&cmd_config_e_tag_port_id,
11283 /* vf vlan anti spoof configuration */
11285 /* Common result structure for vf vlan anti spoof */
11286 struct cmd_vf_vlan_anti_spoof_result {
11287 cmdline_fixed_string_t set;
11288 cmdline_fixed_string_t vf;
11289 cmdline_fixed_string_t vlan;
11290 cmdline_fixed_string_t antispoof;
11293 cmdline_fixed_string_t on_off;
11296 /* Common CLI fields for vf vlan anti spoof enable disable */
11297 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11298 TOKEN_STRING_INITIALIZER
11299 (struct cmd_vf_vlan_anti_spoof_result,
11301 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11302 TOKEN_STRING_INITIALIZER
11303 (struct cmd_vf_vlan_anti_spoof_result,
11305 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11306 TOKEN_STRING_INITIALIZER
11307 (struct cmd_vf_vlan_anti_spoof_result,
11309 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11310 TOKEN_STRING_INITIALIZER
11311 (struct cmd_vf_vlan_anti_spoof_result,
11312 antispoof, "antispoof");
11313 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11314 TOKEN_NUM_INITIALIZER
11315 (struct cmd_vf_vlan_anti_spoof_result,
11317 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11318 TOKEN_NUM_INITIALIZER
11319 (struct cmd_vf_vlan_anti_spoof_result,
11321 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11322 TOKEN_STRING_INITIALIZER
11323 (struct cmd_vf_vlan_anti_spoof_result,
11327 cmd_set_vf_vlan_anti_spoof_parsed(
11328 void *parsed_result,
11329 __attribute__((unused)) struct cmdline *cl,
11330 __attribute__((unused)) void *data)
11332 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11333 int ret = -ENOTSUP;
11335 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11337 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11340 #ifdef RTE_LIBRTE_IXGBE_PMD
11341 if (ret == -ENOTSUP)
11342 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11343 res->vf_id, is_on);
11345 #ifdef RTE_LIBRTE_I40E_PMD
11346 if (ret == -ENOTSUP)
11347 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11348 res->vf_id, is_on);
11350 #ifdef RTE_LIBRTE_BNXT_PMD
11351 if (ret == -ENOTSUP)
11352 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11353 res->vf_id, is_on);
11360 printf("invalid vf_id %d\n", res->vf_id);
11363 printf("invalid port_id %d\n", res->port_id);
11366 printf("function not implemented\n");
11369 printf("programming error: (%s)\n", strerror(-ret));
11373 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11374 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11376 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11378 (void *)&cmd_vf_vlan_anti_spoof_set,
11379 (void *)&cmd_vf_vlan_anti_spoof_vf,
11380 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11381 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11382 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11383 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11384 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11389 /* vf mac anti spoof configuration */
11391 /* Common result structure for vf mac anti spoof */
11392 struct cmd_vf_mac_anti_spoof_result {
11393 cmdline_fixed_string_t set;
11394 cmdline_fixed_string_t vf;
11395 cmdline_fixed_string_t mac;
11396 cmdline_fixed_string_t antispoof;
11399 cmdline_fixed_string_t on_off;
11402 /* Common CLI fields for vf mac anti spoof enable disable */
11403 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11404 TOKEN_STRING_INITIALIZER
11405 (struct cmd_vf_mac_anti_spoof_result,
11407 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11408 TOKEN_STRING_INITIALIZER
11409 (struct cmd_vf_mac_anti_spoof_result,
11411 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11412 TOKEN_STRING_INITIALIZER
11413 (struct cmd_vf_mac_anti_spoof_result,
11415 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11416 TOKEN_STRING_INITIALIZER
11417 (struct cmd_vf_mac_anti_spoof_result,
11418 antispoof, "antispoof");
11419 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11420 TOKEN_NUM_INITIALIZER
11421 (struct cmd_vf_mac_anti_spoof_result,
11423 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11424 TOKEN_NUM_INITIALIZER
11425 (struct cmd_vf_mac_anti_spoof_result,
11427 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11428 TOKEN_STRING_INITIALIZER
11429 (struct cmd_vf_mac_anti_spoof_result,
11433 cmd_set_vf_mac_anti_spoof_parsed(
11434 void *parsed_result,
11435 __attribute__((unused)) struct cmdline *cl,
11436 __attribute__((unused)) void *data)
11438 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11439 int ret = -ENOTSUP;
11441 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11443 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11446 #ifdef RTE_LIBRTE_IXGBE_PMD
11447 if (ret == -ENOTSUP)
11448 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11449 res->vf_id, is_on);
11451 #ifdef RTE_LIBRTE_I40E_PMD
11452 if (ret == -ENOTSUP)
11453 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11454 res->vf_id, is_on);
11456 #ifdef RTE_LIBRTE_BNXT_PMD
11457 if (ret == -ENOTSUP)
11458 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11459 res->vf_id, is_on);
11466 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11469 printf("invalid port_id %d\n", res->port_id);
11472 printf("function not implemented\n");
11475 printf("programming error: (%s)\n", strerror(-ret));
11479 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11480 .f = cmd_set_vf_mac_anti_spoof_parsed,
11482 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11484 (void *)&cmd_vf_mac_anti_spoof_set,
11485 (void *)&cmd_vf_mac_anti_spoof_vf,
11486 (void *)&cmd_vf_mac_anti_spoof_mac,
11487 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11488 (void *)&cmd_vf_mac_anti_spoof_port_id,
11489 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11490 (void *)&cmd_vf_mac_anti_spoof_on_off,
11495 /* vf vlan strip queue configuration */
11497 /* Common result structure for vf mac anti spoof */
11498 struct cmd_vf_vlan_stripq_result {
11499 cmdline_fixed_string_t set;
11500 cmdline_fixed_string_t vf;
11501 cmdline_fixed_string_t vlan;
11502 cmdline_fixed_string_t stripq;
11505 cmdline_fixed_string_t on_off;
11508 /* Common CLI fields for vf vlan strip enable disable */
11509 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11510 TOKEN_STRING_INITIALIZER
11511 (struct cmd_vf_vlan_stripq_result,
11513 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11514 TOKEN_STRING_INITIALIZER
11515 (struct cmd_vf_vlan_stripq_result,
11517 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11518 TOKEN_STRING_INITIALIZER
11519 (struct cmd_vf_vlan_stripq_result,
11521 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11522 TOKEN_STRING_INITIALIZER
11523 (struct cmd_vf_vlan_stripq_result,
11525 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11526 TOKEN_NUM_INITIALIZER
11527 (struct cmd_vf_vlan_stripq_result,
11529 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11530 TOKEN_NUM_INITIALIZER
11531 (struct cmd_vf_vlan_stripq_result,
11533 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11534 TOKEN_STRING_INITIALIZER
11535 (struct cmd_vf_vlan_stripq_result,
11539 cmd_set_vf_vlan_stripq_parsed(
11540 void *parsed_result,
11541 __attribute__((unused)) struct cmdline *cl,
11542 __attribute__((unused)) void *data)
11544 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11545 int ret = -ENOTSUP;
11547 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11549 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11552 #ifdef RTE_LIBRTE_IXGBE_PMD
11553 if (ret == -ENOTSUP)
11554 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11555 res->vf_id, is_on);
11557 #ifdef RTE_LIBRTE_I40E_PMD
11558 if (ret == -ENOTSUP)
11559 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11560 res->vf_id, is_on);
11562 #ifdef RTE_LIBRTE_BNXT_PMD
11563 if (ret == -ENOTSUP)
11564 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11565 res->vf_id, is_on);
11572 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11575 printf("invalid port_id %d\n", res->port_id);
11578 printf("function not implemented\n");
11581 printf("programming error: (%s)\n", strerror(-ret));
11585 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11586 .f = cmd_set_vf_vlan_stripq_parsed,
11588 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11590 (void *)&cmd_vf_vlan_stripq_set,
11591 (void *)&cmd_vf_vlan_stripq_vf,
11592 (void *)&cmd_vf_vlan_stripq_vlan,
11593 (void *)&cmd_vf_vlan_stripq_stripq,
11594 (void *)&cmd_vf_vlan_stripq_port_id,
11595 (void *)&cmd_vf_vlan_stripq_vf_id,
11596 (void *)&cmd_vf_vlan_stripq_on_off,
11601 /* vf vlan insert configuration */
11603 /* Common result structure for vf vlan insert */
11604 struct cmd_vf_vlan_insert_result {
11605 cmdline_fixed_string_t set;
11606 cmdline_fixed_string_t vf;
11607 cmdline_fixed_string_t vlan;
11608 cmdline_fixed_string_t insert;
11614 /* Common CLI fields for vf vlan insert enable disable */
11615 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11616 TOKEN_STRING_INITIALIZER
11617 (struct cmd_vf_vlan_insert_result,
11619 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11620 TOKEN_STRING_INITIALIZER
11621 (struct cmd_vf_vlan_insert_result,
11623 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11624 TOKEN_STRING_INITIALIZER
11625 (struct cmd_vf_vlan_insert_result,
11627 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11628 TOKEN_STRING_INITIALIZER
11629 (struct cmd_vf_vlan_insert_result,
11631 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11632 TOKEN_NUM_INITIALIZER
11633 (struct cmd_vf_vlan_insert_result,
11635 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11636 TOKEN_NUM_INITIALIZER
11637 (struct cmd_vf_vlan_insert_result,
11639 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11640 TOKEN_NUM_INITIALIZER
11641 (struct cmd_vf_vlan_insert_result,
11645 cmd_set_vf_vlan_insert_parsed(
11646 void *parsed_result,
11647 __attribute__((unused)) struct cmdline *cl,
11648 __attribute__((unused)) void *data)
11650 struct cmd_vf_vlan_insert_result *res = parsed_result;
11651 int ret = -ENOTSUP;
11653 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11656 #ifdef RTE_LIBRTE_IXGBE_PMD
11657 if (ret == -ENOTSUP)
11658 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11661 #ifdef RTE_LIBRTE_I40E_PMD
11662 if (ret == -ENOTSUP)
11663 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11666 #ifdef RTE_LIBRTE_BNXT_PMD
11667 if (ret == -ENOTSUP)
11668 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11676 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11679 printf("invalid port_id %d\n", res->port_id);
11682 printf("function not implemented\n");
11685 printf("programming error: (%s)\n", strerror(-ret));
11689 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11690 .f = cmd_set_vf_vlan_insert_parsed,
11692 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11694 (void *)&cmd_vf_vlan_insert_set,
11695 (void *)&cmd_vf_vlan_insert_vf,
11696 (void *)&cmd_vf_vlan_insert_vlan,
11697 (void *)&cmd_vf_vlan_insert_insert,
11698 (void *)&cmd_vf_vlan_insert_port_id,
11699 (void *)&cmd_vf_vlan_insert_vf_id,
11700 (void *)&cmd_vf_vlan_insert_vlan_id,
11705 /* tx loopback configuration */
11707 /* Common result structure for tx loopback */
11708 struct cmd_tx_loopback_result {
11709 cmdline_fixed_string_t set;
11710 cmdline_fixed_string_t tx;
11711 cmdline_fixed_string_t loopback;
11713 cmdline_fixed_string_t on_off;
11716 /* Common CLI fields for tx loopback enable disable */
11717 cmdline_parse_token_string_t cmd_tx_loopback_set =
11718 TOKEN_STRING_INITIALIZER
11719 (struct cmd_tx_loopback_result,
11721 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11722 TOKEN_STRING_INITIALIZER
11723 (struct cmd_tx_loopback_result,
11725 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11726 TOKEN_STRING_INITIALIZER
11727 (struct cmd_tx_loopback_result,
11728 loopback, "loopback");
11729 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11730 TOKEN_NUM_INITIALIZER
11731 (struct cmd_tx_loopback_result,
11733 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11734 TOKEN_STRING_INITIALIZER
11735 (struct cmd_tx_loopback_result,
11739 cmd_set_tx_loopback_parsed(
11740 void *parsed_result,
11741 __attribute__((unused)) struct cmdline *cl,
11742 __attribute__((unused)) void *data)
11744 struct cmd_tx_loopback_result *res = parsed_result;
11745 int ret = -ENOTSUP;
11747 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11749 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11752 #ifdef RTE_LIBRTE_IXGBE_PMD
11753 if (ret == -ENOTSUP)
11754 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11756 #ifdef RTE_LIBRTE_I40E_PMD
11757 if (ret == -ENOTSUP)
11758 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11760 #ifdef RTE_LIBRTE_BNXT_PMD
11761 if (ret == -ENOTSUP)
11762 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11769 printf("invalid is_on %d\n", is_on);
11772 printf("invalid port_id %d\n", res->port_id);
11775 printf("function not implemented\n");
11778 printf("programming error: (%s)\n", strerror(-ret));
11782 cmdline_parse_inst_t cmd_set_tx_loopback = {
11783 .f = cmd_set_tx_loopback_parsed,
11785 .help_str = "set tx loopback <port_id> on|off",
11787 (void *)&cmd_tx_loopback_set,
11788 (void *)&cmd_tx_loopback_tx,
11789 (void *)&cmd_tx_loopback_loopback,
11790 (void *)&cmd_tx_loopback_port_id,
11791 (void *)&cmd_tx_loopback_on_off,
11796 /* all queues drop enable configuration */
11798 /* Common result structure for all queues drop enable */
11799 struct cmd_all_queues_drop_en_result {
11800 cmdline_fixed_string_t set;
11801 cmdline_fixed_string_t all;
11802 cmdline_fixed_string_t queues;
11803 cmdline_fixed_string_t drop;
11805 cmdline_fixed_string_t on_off;
11808 /* Common CLI fields for tx loopback enable disable */
11809 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11810 TOKEN_STRING_INITIALIZER
11811 (struct cmd_all_queues_drop_en_result,
11813 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11814 TOKEN_STRING_INITIALIZER
11815 (struct cmd_all_queues_drop_en_result,
11817 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11818 TOKEN_STRING_INITIALIZER
11819 (struct cmd_all_queues_drop_en_result,
11821 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11822 TOKEN_STRING_INITIALIZER
11823 (struct cmd_all_queues_drop_en_result,
11825 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11826 TOKEN_NUM_INITIALIZER
11827 (struct cmd_all_queues_drop_en_result,
11829 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11830 TOKEN_STRING_INITIALIZER
11831 (struct cmd_all_queues_drop_en_result,
11835 cmd_set_all_queues_drop_en_parsed(
11836 void *parsed_result,
11837 __attribute__((unused)) struct cmdline *cl,
11838 __attribute__((unused)) void *data)
11840 struct cmd_all_queues_drop_en_result *res = parsed_result;
11841 int ret = -ENOTSUP;
11842 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11844 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11847 #ifdef RTE_LIBRTE_IXGBE_PMD
11848 if (ret == -ENOTSUP)
11849 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11851 #ifdef RTE_LIBRTE_BNXT_PMD
11852 if (ret == -ENOTSUP)
11853 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11859 printf("invalid is_on %d\n", is_on);
11862 printf("invalid port_id %d\n", res->port_id);
11865 printf("function not implemented\n");
11868 printf("programming error: (%s)\n", strerror(-ret));
11872 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11873 .f = cmd_set_all_queues_drop_en_parsed,
11875 .help_str = "set all queues drop <port_id> on|off",
11877 (void *)&cmd_all_queues_drop_en_set,
11878 (void *)&cmd_all_queues_drop_en_all,
11879 (void *)&cmd_all_queues_drop_en_queues,
11880 (void *)&cmd_all_queues_drop_en_drop,
11881 (void *)&cmd_all_queues_drop_en_port_id,
11882 (void *)&cmd_all_queues_drop_en_on_off,
11887 /* vf split drop enable configuration */
11889 /* Common result structure for vf split drop enable */
11890 struct cmd_vf_split_drop_en_result {
11891 cmdline_fixed_string_t set;
11892 cmdline_fixed_string_t vf;
11893 cmdline_fixed_string_t split;
11894 cmdline_fixed_string_t drop;
11897 cmdline_fixed_string_t on_off;
11900 /* Common CLI fields for vf split drop enable disable */
11901 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11902 TOKEN_STRING_INITIALIZER
11903 (struct cmd_vf_split_drop_en_result,
11905 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11906 TOKEN_STRING_INITIALIZER
11907 (struct cmd_vf_split_drop_en_result,
11909 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11910 TOKEN_STRING_INITIALIZER
11911 (struct cmd_vf_split_drop_en_result,
11913 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11914 TOKEN_STRING_INITIALIZER
11915 (struct cmd_vf_split_drop_en_result,
11917 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11918 TOKEN_NUM_INITIALIZER
11919 (struct cmd_vf_split_drop_en_result,
11921 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11922 TOKEN_NUM_INITIALIZER
11923 (struct cmd_vf_split_drop_en_result,
11925 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11926 TOKEN_STRING_INITIALIZER
11927 (struct cmd_vf_split_drop_en_result,
11931 cmd_set_vf_split_drop_en_parsed(
11932 void *parsed_result,
11933 __attribute__((unused)) struct cmdline *cl,
11934 __attribute__((unused)) void *data)
11936 struct cmd_vf_split_drop_en_result *res = parsed_result;
11937 int ret = -ENOTSUP;
11938 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11940 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11943 #ifdef RTE_LIBRTE_IXGBE_PMD
11944 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11951 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11954 printf("invalid port_id %d\n", res->port_id);
11957 printf("not supported on port %d\n", res->port_id);
11960 printf("programming error: (%s)\n", strerror(-ret));
11964 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11965 .f = cmd_set_vf_split_drop_en_parsed,
11967 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11969 (void *)&cmd_vf_split_drop_en_set,
11970 (void *)&cmd_vf_split_drop_en_vf,
11971 (void *)&cmd_vf_split_drop_en_split,
11972 (void *)&cmd_vf_split_drop_en_drop,
11973 (void *)&cmd_vf_split_drop_en_port_id,
11974 (void *)&cmd_vf_split_drop_en_vf_id,
11975 (void *)&cmd_vf_split_drop_en_on_off,
11980 /* vf mac address configuration */
11982 /* Common result structure for vf mac address */
11983 struct cmd_set_vf_mac_addr_result {
11984 cmdline_fixed_string_t set;
11985 cmdline_fixed_string_t vf;
11986 cmdline_fixed_string_t mac;
11987 cmdline_fixed_string_t addr;
11990 struct ether_addr mac_addr;
11994 /* Common CLI fields for vf split drop enable disable */
11995 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11996 TOKEN_STRING_INITIALIZER
11997 (struct cmd_set_vf_mac_addr_result,
11999 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12000 TOKEN_STRING_INITIALIZER
12001 (struct cmd_set_vf_mac_addr_result,
12003 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12004 TOKEN_STRING_INITIALIZER
12005 (struct cmd_set_vf_mac_addr_result,
12007 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12008 TOKEN_STRING_INITIALIZER
12009 (struct cmd_set_vf_mac_addr_result,
12011 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12012 TOKEN_NUM_INITIALIZER
12013 (struct cmd_set_vf_mac_addr_result,
12015 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12016 TOKEN_NUM_INITIALIZER
12017 (struct cmd_set_vf_mac_addr_result,
12019 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12020 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12024 cmd_set_vf_mac_addr_parsed(
12025 void *parsed_result,
12026 __attribute__((unused)) struct cmdline *cl,
12027 __attribute__((unused)) void *data)
12029 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12030 int ret = -ENOTSUP;
12032 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12035 #ifdef RTE_LIBRTE_IXGBE_PMD
12036 if (ret == -ENOTSUP)
12037 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12040 #ifdef RTE_LIBRTE_I40E_PMD
12041 if (ret == -ENOTSUP)
12042 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12045 #ifdef RTE_LIBRTE_BNXT_PMD
12046 if (ret == -ENOTSUP)
12047 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12055 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12058 printf("invalid port_id %d\n", res->port_id);
12061 printf("function not implemented\n");
12064 printf("programming error: (%s)\n", strerror(-ret));
12068 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12069 .f = cmd_set_vf_mac_addr_parsed,
12071 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12073 (void *)&cmd_set_vf_mac_addr_set,
12074 (void *)&cmd_set_vf_mac_addr_vf,
12075 (void *)&cmd_set_vf_mac_addr_mac,
12076 (void *)&cmd_set_vf_mac_addr_addr,
12077 (void *)&cmd_set_vf_mac_addr_port_id,
12078 (void *)&cmd_set_vf_mac_addr_vf_id,
12079 (void *)&cmd_set_vf_mac_addr_mac_addr,
12084 /* MACsec configuration */
12086 /* Common result structure for MACsec offload enable */
12087 struct cmd_macsec_offload_on_result {
12088 cmdline_fixed_string_t set;
12089 cmdline_fixed_string_t macsec;
12090 cmdline_fixed_string_t offload;
12092 cmdline_fixed_string_t on;
12093 cmdline_fixed_string_t encrypt;
12094 cmdline_fixed_string_t en_on_off;
12095 cmdline_fixed_string_t replay_protect;
12096 cmdline_fixed_string_t rp_on_off;
12099 /* Common CLI fields for MACsec offload disable */
12100 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12101 TOKEN_STRING_INITIALIZER
12102 (struct cmd_macsec_offload_on_result,
12104 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12105 TOKEN_STRING_INITIALIZER
12106 (struct cmd_macsec_offload_on_result,
12108 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12109 TOKEN_STRING_INITIALIZER
12110 (struct cmd_macsec_offload_on_result,
12111 offload, "offload");
12112 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12113 TOKEN_NUM_INITIALIZER
12114 (struct cmd_macsec_offload_on_result,
12116 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12117 TOKEN_STRING_INITIALIZER
12118 (struct cmd_macsec_offload_on_result,
12120 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12121 TOKEN_STRING_INITIALIZER
12122 (struct cmd_macsec_offload_on_result,
12123 encrypt, "encrypt");
12124 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12125 TOKEN_STRING_INITIALIZER
12126 (struct cmd_macsec_offload_on_result,
12127 en_on_off, "on#off");
12128 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12129 TOKEN_STRING_INITIALIZER
12130 (struct cmd_macsec_offload_on_result,
12131 replay_protect, "replay-protect");
12132 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12133 TOKEN_STRING_INITIALIZER
12134 (struct cmd_macsec_offload_on_result,
12135 rp_on_off, "on#off");
12138 cmd_set_macsec_offload_on_parsed(
12139 void *parsed_result,
12140 __attribute__((unused)) struct cmdline *cl,
12141 __attribute__((unused)) void *data)
12143 struct cmd_macsec_offload_on_result *res = parsed_result;
12144 int ret = -ENOTSUP;
12145 portid_t port_id = res->port_id;
12146 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12147 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12149 if (port_id_is_invalid(port_id, ENABLED_WARN))
12152 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
12153 #ifdef RTE_LIBRTE_IXGBE_PMD
12154 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12163 printf("invalid port_id %d\n", port_id);
12166 printf("not supported on port %d\n", port_id);
12169 printf("programming error: (%s)\n", strerror(-ret));
12173 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12174 .f = cmd_set_macsec_offload_on_parsed,
12176 .help_str = "set macsec offload <port_id> on "
12177 "encrypt on|off replay-protect on|off",
12179 (void *)&cmd_macsec_offload_on_set,
12180 (void *)&cmd_macsec_offload_on_macsec,
12181 (void *)&cmd_macsec_offload_on_offload,
12182 (void *)&cmd_macsec_offload_on_port_id,
12183 (void *)&cmd_macsec_offload_on_on,
12184 (void *)&cmd_macsec_offload_on_encrypt,
12185 (void *)&cmd_macsec_offload_on_en_on_off,
12186 (void *)&cmd_macsec_offload_on_replay_protect,
12187 (void *)&cmd_macsec_offload_on_rp_on_off,
12192 /* Common result structure for MACsec offload disable */
12193 struct cmd_macsec_offload_off_result {
12194 cmdline_fixed_string_t set;
12195 cmdline_fixed_string_t macsec;
12196 cmdline_fixed_string_t offload;
12198 cmdline_fixed_string_t off;
12201 /* Common CLI fields for MACsec offload disable */
12202 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12203 TOKEN_STRING_INITIALIZER
12204 (struct cmd_macsec_offload_off_result,
12206 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12207 TOKEN_STRING_INITIALIZER
12208 (struct cmd_macsec_offload_off_result,
12210 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12211 TOKEN_STRING_INITIALIZER
12212 (struct cmd_macsec_offload_off_result,
12213 offload, "offload");
12214 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12215 TOKEN_NUM_INITIALIZER
12216 (struct cmd_macsec_offload_off_result,
12218 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12219 TOKEN_STRING_INITIALIZER
12220 (struct cmd_macsec_offload_off_result,
12224 cmd_set_macsec_offload_off_parsed(
12225 void *parsed_result,
12226 __attribute__((unused)) struct cmdline *cl,
12227 __attribute__((unused)) void *data)
12229 struct cmd_macsec_offload_off_result *res = parsed_result;
12230 int ret = -ENOTSUP;
12231 portid_t port_id = res->port_id;
12233 if (port_id_is_invalid(port_id, ENABLED_WARN))
12236 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
12237 #ifdef RTE_LIBRTE_IXGBE_PMD
12238 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12245 printf("invalid port_id %d\n", port_id);
12248 printf("not supported on port %d\n", port_id);
12251 printf("programming error: (%s)\n", strerror(-ret));
12255 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12256 .f = cmd_set_macsec_offload_off_parsed,
12258 .help_str = "set macsec offload <port_id> off",
12260 (void *)&cmd_macsec_offload_off_set,
12261 (void *)&cmd_macsec_offload_off_macsec,
12262 (void *)&cmd_macsec_offload_off_offload,
12263 (void *)&cmd_macsec_offload_off_port_id,
12264 (void *)&cmd_macsec_offload_off_off,
12269 /* Common result structure for MACsec secure connection configure */
12270 struct cmd_macsec_sc_result {
12271 cmdline_fixed_string_t set;
12272 cmdline_fixed_string_t macsec;
12273 cmdline_fixed_string_t sc;
12274 cmdline_fixed_string_t tx_rx;
12276 struct ether_addr mac;
12280 /* Common CLI fields for MACsec secure connection configure */
12281 cmdline_parse_token_string_t cmd_macsec_sc_set =
12282 TOKEN_STRING_INITIALIZER
12283 (struct cmd_macsec_sc_result,
12285 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12286 TOKEN_STRING_INITIALIZER
12287 (struct cmd_macsec_sc_result,
12289 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12290 TOKEN_STRING_INITIALIZER
12291 (struct cmd_macsec_sc_result,
12293 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12294 TOKEN_STRING_INITIALIZER
12295 (struct cmd_macsec_sc_result,
12297 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12298 TOKEN_NUM_INITIALIZER
12299 (struct cmd_macsec_sc_result,
12301 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12302 TOKEN_ETHERADDR_INITIALIZER
12303 (struct cmd_macsec_sc_result,
12305 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12306 TOKEN_NUM_INITIALIZER
12307 (struct cmd_macsec_sc_result,
12311 cmd_set_macsec_sc_parsed(
12312 void *parsed_result,
12313 __attribute__((unused)) struct cmdline *cl,
12314 __attribute__((unused)) void *data)
12316 struct cmd_macsec_sc_result *res = parsed_result;
12317 int ret = -ENOTSUP;
12318 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12320 #ifdef RTE_LIBRTE_IXGBE_PMD
12322 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12323 res->mac.addr_bytes) :
12324 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12325 res->mac.addr_bytes, res->pi);
12327 RTE_SET_USED(is_tx);
12333 printf("invalid port_id %d\n", res->port_id);
12336 printf("not supported on port %d\n", res->port_id);
12339 printf("programming error: (%s)\n", strerror(-ret));
12343 cmdline_parse_inst_t cmd_set_macsec_sc = {
12344 .f = cmd_set_macsec_sc_parsed,
12346 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12348 (void *)&cmd_macsec_sc_set,
12349 (void *)&cmd_macsec_sc_macsec,
12350 (void *)&cmd_macsec_sc_sc,
12351 (void *)&cmd_macsec_sc_tx_rx,
12352 (void *)&cmd_macsec_sc_port_id,
12353 (void *)&cmd_macsec_sc_mac,
12354 (void *)&cmd_macsec_sc_pi,
12359 /* Common result structure for MACsec secure connection configure */
12360 struct cmd_macsec_sa_result {
12361 cmdline_fixed_string_t set;
12362 cmdline_fixed_string_t macsec;
12363 cmdline_fixed_string_t sa;
12364 cmdline_fixed_string_t tx_rx;
12369 cmdline_fixed_string_t key;
12372 /* Common CLI fields for MACsec secure connection configure */
12373 cmdline_parse_token_string_t cmd_macsec_sa_set =
12374 TOKEN_STRING_INITIALIZER
12375 (struct cmd_macsec_sa_result,
12377 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12378 TOKEN_STRING_INITIALIZER
12379 (struct cmd_macsec_sa_result,
12381 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12382 TOKEN_STRING_INITIALIZER
12383 (struct cmd_macsec_sa_result,
12385 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12386 TOKEN_STRING_INITIALIZER
12387 (struct cmd_macsec_sa_result,
12389 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12390 TOKEN_NUM_INITIALIZER
12391 (struct cmd_macsec_sa_result,
12393 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12394 TOKEN_NUM_INITIALIZER
12395 (struct cmd_macsec_sa_result,
12397 cmdline_parse_token_num_t cmd_macsec_sa_an =
12398 TOKEN_NUM_INITIALIZER
12399 (struct cmd_macsec_sa_result,
12401 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12402 TOKEN_NUM_INITIALIZER
12403 (struct cmd_macsec_sa_result,
12405 cmdline_parse_token_string_t cmd_macsec_sa_key =
12406 TOKEN_STRING_INITIALIZER
12407 (struct cmd_macsec_sa_result,
12411 cmd_set_macsec_sa_parsed(
12412 void *parsed_result,
12413 __attribute__((unused)) struct cmdline *cl,
12414 __attribute__((unused)) void *data)
12416 struct cmd_macsec_sa_result *res = parsed_result;
12417 int ret = -ENOTSUP;
12418 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12419 uint8_t key[16] = { 0 };
12425 key_len = strlen(res->key) / 2;
12429 for (i = 0; i < key_len; i++) {
12430 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12433 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12436 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12439 #ifdef RTE_LIBRTE_IXGBE_PMD
12441 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12442 res->idx, res->an, res->pn, key) :
12443 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12444 res->idx, res->an, res->pn, key);
12446 RTE_SET_USED(is_tx);
12453 printf("invalid idx %d or an %d\n", res->idx, res->an);
12456 printf("invalid port_id %d\n", res->port_id);
12459 printf("not supported on port %d\n", res->port_id);
12462 printf("programming error: (%s)\n", strerror(-ret));
12466 cmdline_parse_inst_t cmd_set_macsec_sa = {
12467 .f = cmd_set_macsec_sa_parsed,
12469 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12471 (void *)&cmd_macsec_sa_set,
12472 (void *)&cmd_macsec_sa_macsec,
12473 (void *)&cmd_macsec_sa_sa,
12474 (void *)&cmd_macsec_sa_tx_rx,
12475 (void *)&cmd_macsec_sa_port_id,
12476 (void *)&cmd_macsec_sa_idx,
12477 (void *)&cmd_macsec_sa_an,
12478 (void *)&cmd_macsec_sa_pn,
12479 (void *)&cmd_macsec_sa_key,
12484 /* VF unicast promiscuous mode configuration */
12486 /* Common result structure for VF unicast promiscuous mode */
12487 struct cmd_vf_promisc_result {
12488 cmdline_fixed_string_t set;
12489 cmdline_fixed_string_t vf;
12490 cmdline_fixed_string_t promisc;
12493 cmdline_fixed_string_t on_off;
12496 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12497 cmdline_parse_token_string_t cmd_vf_promisc_set =
12498 TOKEN_STRING_INITIALIZER
12499 (struct cmd_vf_promisc_result,
12501 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12502 TOKEN_STRING_INITIALIZER
12503 (struct cmd_vf_promisc_result,
12505 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12506 TOKEN_STRING_INITIALIZER
12507 (struct cmd_vf_promisc_result,
12508 promisc, "promisc");
12509 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12510 TOKEN_NUM_INITIALIZER
12511 (struct cmd_vf_promisc_result,
12513 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12514 TOKEN_NUM_INITIALIZER
12515 (struct cmd_vf_promisc_result,
12517 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12518 TOKEN_STRING_INITIALIZER
12519 (struct cmd_vf_promisc_result,
12523 cmd_set_vf_promisc_parsed(
12524 void *parsed_result,
12525 __attribute__((unused)) struct cmdline *cl,
12526 __attribute__((unused)) void *data)
12528 struct cmd_vf_promisc_result *res = parsed_result;
12529 int ret = -ENOTSUP;
12531 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12533 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12536 #ifdef RTE_LIBRTE_I40E_PMD
12537 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12538 res->vf_id, is_on);
12545 printf("invalid vf_id %d\n", res->vf_id);
12548 printf("invalid port_id %d\n", res->port_id);
12551 printf("function not implemented\n");
12554 printf("programming error: (%s)\n", strerror(-ret));
12558 cmdline_parse_inst_t cmd_set_vf_promisc = {
12559 .f = cmd_set_vf_promisc_parsed,
12561 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12562 "Set unicast promiscuous mode for a VF from the PF",
12564 (void *)&cmd_vf_promisc_set,
12565 (void *)&cmd_vf_promisc_vf,
12566 (void *)&cmd_vf_promisc_promisc,
12567 (void *)&cmd_vf_promisc_port_id,
12568 (void *)&cmd_vf_promisc_vf_id,
12569 (void *)&cmd_vf_promisc_on_off,
12574 /* VF multicast promiscuous mode configuration */
12576 /* Common result structure for VF multicast promiscuous mode */
12577 struct cmd_vf_allmulti_result {
12578 cmdline_fixed_string_t set;
12579 cmdline_fixed_string_t vf;
12580 cmdline_fixed_string_t allmulti;
12583 cmdline_fixed_string_t on_off;
12586 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12587 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12588 TOKEN_STRING_INITIALIZER
12589 (struct cmd_vf_allmulti_result,
12591 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12592 TOKEN_STRING_INITIALIZER
12593 (struct cmd_vf_allmulti_result,
12595 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12596 TOKEN_STRING_INITIALIZER
12597 (struct cmd_vf_allmulti_result,
12598 allmulti, "allmulti");
12599 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12600 TOKEN_NUM_INITIALIZER
12601 (struct cmd_vf_allmulti_result,
12603 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12604 TOKEN_NUM_INITIALIZER
12605 (struct cmd_vf_allmulti_result,
12607 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12608 TOKEN_STRING_INITIALIZER
12609 (struct cmd_vf_allmulti_result,
12613 cmd_set_vf_allmulti_parsed(
12614 void *parsed_result,
12615 __attribute__((unused)) struct cmdline *cl,
12616 __attribute__((unused)) void *data)
12618 struct cmd_vf_allmulti_result *res = parsed_result;
12619 int ret = -ENOTSUP;
12621 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12623 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12626 #ifdef RTE_LIBRTE_I40E_PMD
12627 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12628 res->vf_id, is_on);
12635 printf("invalid vf_id %d\n", res->vf_id);
12638 printf("invalid port_id %d\n", res->port_id);
12641 printf("function not implemented\n");
12644 printf("programming error: (%s)\n", strerror(-ret));
12648 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12649 .f = cmd_set_vf_allmulti_parsed,
12651 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12652 "Set multicast promiscuous mode for a VF from the PF",
12654 (void *)&cmd_vf_allmulti_set,
12655 (void *)&cmd_vf_allmulti_vf,
12656 (void *)&cmd_vf_allmulti_allmulti,
12657 (void *)&cmd_vf_allmulti_port_id,
12658 (void *)&cmd_vf_allmulti_vf_id,
12659 (void *)&cmd_vf_allmulti_on_off,
12664 /* vf broadcast mode configuration */
12666 /* Common result structure for vf broadcast */
12667 struct cmd_set_vf_broadcast_result {
12668 cmdline_fixed_string_t set;
12669 cmdline_fixed_string_t vf;
12670 cmdline_fixed_string_t broadcast;
12673 cmdline_fixed_string_t on_off;
12676 /* Common CLI fields for vf broadcast enable disable */
12677 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12678 TOKEN_STRING_INITIALIZER
12679 (struct cmd_set_vf_broadcast_result,
12681 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12682 TOKEN_STRING_INITIALIZER
12683 (struct cmd_set_vf_broadcast_result,
12685 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12686 TOKEN_STRING_INITIALIZER
12687 (struct cmd_set_vf_broadcast_result,
12688 broadcast, "broadcast");
12689 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12690 TOKEN_NUM_INITIALIZER
12691 (struct cmd_set_vf_broadcast_result,
12693 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12694 TOKEN_NUM_INITIALIZER
12695 (struct cmd_set_vf_broadcast_result,
12697 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12698 TOKEN_STRING_INITIALIZER
12699 (struct cmd_set_vf_broadcast_result,
12703 cmd_set_vf_broadcast_parsed(
12704 void *parsed_result,
12705 __attribute__((unused)) struct cmdline *cl,
12706 __attribute__((unused)) void *data)
12708 struct cmd_set_vf_broadcast_result *res = parsed_result;
12709 int ret = -ENOTSUP;
12711 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12713 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12716 #ifdef RTE_LIBRTE_I40E_PMD
12717 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12718 res->vf_id, is_on);
12725 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12728 printf("invalid port_id %d\n", res->port_id);
12731 printf("function not implemented\n");
12734 printf("programming error: (%s)\n", strerror(-ret));
12738 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12739 .f = cmd_set_vf_broadcast_parsed,
12741 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12743 (void *)&cmd_set_vf_broadcast_set,
12744 (void *)&cmd_set_vf_broadcast_vf,
12745 (void *)&cmd_set_vf_broadcast_broadcast,
12746 (void *)&cmd_set_vf_broadcast_port_id,
12747 (void *)&cmd_set_vf_broadcast_vf_id,
12748 (void *)&cmd_set_vf_broadcast_on_off,
12753 /* vf vlan tag configuration */
12755 /* Common result structure for vf vlan tag */
12756 struct cmd_set_vf_vlan_tag_result {
12757 cmdline_fixed_string_t set;
12758 cmdline_fixed_string_t vf;
12759 cmdline_fixed_string_t vlan;
12760 cmdline_fixed_string_t tag;
12763 cmdline_fixed_string_t on_off;
12766 /* Common CLI fields for vf vlan tag enable disable */
12767 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12768 TOKEN_STRING_INITIALIZER
12769 (struct cmd_set_vf_vlan_tag_result,
12771 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12772 TOKEN_STRING_INITIALIZER
12773 (struct cmd_set_vf_vlan_tag_result,
12775 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12776 TOKEN_STRING_INITIALIZER
12777 (struct cmd_set_vf_vlan_tag_result,
12779 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12780 TOKEN_STRING_INITIALIZER
12781 (struct cmd_set_vf_vlan_tag_result,
12783 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12784 TOKEN_NUM_INITIALIZER
12785 (struct cmd_set_vf_vlan_tag_result,
12787 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12788 TOKEN_NUM_INITIALIZER
12789 (struct cmd_set_vf_vlan_tag_result,
12791 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12792 TOKEN_STRING_INITIALIZER
12793 (struct cmd_set_vf_vlan_tag_result,
12797 cmd_set_vf_vlan_tag_parsed(
12798 void *parsed_result,
12799 __attribute__((unused)) struct cmdline *cl,
12800 __attribute__((unused)) void *data)
12802 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12803 int ret = -ENOTSUP;
12805 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12807 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12810 #ifdef RTE_LIBRTE_I40E_PMD
12811 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12812 res->vf_id, is_on);
12819 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12822 printf("invalid port_id %d\n", res->port_id);
12825 printf("function not implemented\n");
12828 printf("programming error: (%s)\n", strerror(-ret));
12832 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12833 .f = cmd_set_vf_vlan_tag_parsed,
12835 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12837 (void *)&cmd_set_vf_vlan_tag_set,
12838 (void *)&cmd_set_vf_vlan_tag_vf,
12839 (void *)&cmd_set_vf_vlan_tag_vlan,
12840 (void *)&cmd_set_vf_vlan_tag_tag,
12841 (void *)&cmd_set_vf_vlan_tag_port_id,
12842 (void *)&cmd_set_vf_vlan_tag_vf_id,
12843 (void *)&cmd_set_vf_vlan_tag_on_off,
12848 /* Common definition of VF and TC TX bandwidth configuration */
12849 struct cmd_vf_tc_bw_result {
12850 cmdline_fixed_string_t set;
12851 cmdline_fixed_string_t vf;
12852 cmdline_fixed_string_t tc;
12853 cmdline_fixed_string_t tx;
12854 cmdline_fixed_string_t min_bw;
12855 cmdline_fixed_string_t max_bw;
12856 cmdline_fixed_string_t strict_link_prio;
12861 cmdline_fixed_string_t bw_list;
12865 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12866 TOKEN_STRING_INITIALIZER
12867 (struct cmd_vf_tc_bw_result,
12869 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12870 TOKEN_STRING_INITIALIZER
12871 (struct cmd_vf_tc_bw_result,
12873 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12874 TOKEN_STRING_INITIALIZER
12875 (struct cmd_vf_tc_bw_result,
12877 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12878 TOKEN_STRING_INITIALIZER
12879 (struct cmd_vf_tc_bw_result,
12881 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12882 TOKEN_STRING_INITIALIZER
12883 (struct cmd_vf_tc_bw_result,
12884 strict_link_prio, "strict-link-priority");
12885 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12886 TOKEN_STRING_INITIALIZER
12887 (struct cmd_vf_tc_bw_result,
12888 min_bw, "min-bandwidth");
12889 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12890 TOKEN_STRING_INITIALIZER
12891 (struct cmd_vf_tc_bw_result,
12892 max_bw, "max-bandwidth");
12893 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12894 TOKEN_NUM_INITIALIZER
12895 (struct cmd_vf_tc_bw_result,
12897 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12898 TOKEN_NUM_INITIALIZER
12899 (struct cmd_vf_tc_bw_result,
12901 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12902 TOKEN_NUM_INITIALIZER
12903 (struct cmd_vf_tc_bw_result,
12905 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12906 TOKEN_NUM_INITIALIZER
12907 (struct cmd_vf_tc_bw_result,
12909 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12910 TOKEN_STRING_INITIALIZER
12911 (struct cmd_vf_tc_bw_result,
12913 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12914 TOKEN_NUM_INITIALIZER
12915 (struct cmd_vf_tc_bw_result,
12918 /* VF max bandwidth setting */
12920 cmd_vf_max_bw_parsed(
12921 void *parsed_result,
12922 __attribute__((unused)) struct cmdline *cl,
12923 __attribute__((unused)) void *data)
12925 struct cmd_vf_tc_bw_result *res = parsed_result;
12926 int ret = -ENOTSUP;
12928 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12931 #ifdef RTE_LIBRTE_I40E_PMD
12932 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12933 res->vf_id, res->bw);
12940 printf("invalid vf_id %d or bandwidth %d\n",
12941 res->vf_id, res->bw);
12944 printf("invalid port_id %d\n", res->port_id);
12947 printf("function not implemented\n");
12950 printf("programming error: (%s)\n", strerror(-ret));
12954 cmdline_parse_inst_t cmd_vf_max_bw = {
12955 .f = cmd_vf_max_bw_parsed,
12957 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12959 (void *)&cmd_vf_tc_bw_set,
12960 (void *)&cmd_vf_tc_bw_vf,
12961 (void *)&cmd_vf_tc_bw_tx,
12962 (void *)&cmd_vf_tc_bw_max_bw,
12963 (void *)&cmd_vf_tc_bw_port_id,
12964 (void *)&cmd_vf_tc_bw_vf_id,
12965 (void *)&cmd_vf_tc_bw_bw,
12971 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12976 const char *p, *p0 = str;
12983 p = strchr(p0, '(');
12985 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12989 p0 = strchr(p, ')');
12991 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12995 if (size >= sizeof(s)) {
12996 printf("The string size exceeds the internal buffer size\n");
12999 snprintf(s, sizeof(s), "%.*s", size, p);
13000 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13002 printf("Failed to get the bandwidth list. ");
13006 for (i = 0; i < ret; i++)
13007 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13012 /* TC min bandwidth setting */
13014 cmd_vf_tc_min_bw_parsed(
13015 void *parsed_result,
13016 __attribute__((unused)) struct cmdline *cl,
13017 __attribute__((unused)) void *data)
13019 struct cmd_vf_tc_bw_result *res = parsed_result;
13022 int ret = -ENOTSUP;
13024 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13027 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13031 #ifdef RTE_LIBRTE_I40E_PMD
13032 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13040 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13043 printf("invalid port_id %d\n", res->port_id);
13046 printf("function not implemented\n");
13049 printf("programming error: (%s)\n", strerror(-ret));
13053 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13054 .f = cmd_vf_tc_min_bw_parsed,
13056 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13057 " <bw1, bw2, ...>",
13059 (void *)&cmd_vf_tc_bw_set,
13060 (void *)&cmd_vf_tc_bw_vf,
13061 (void *)&cmd_vf_tc_bw_tc,
13062 (void *)&cmd_vf_tc_bw_tx,
13063 (void *)&cmd_vf_tc_bw_min_bw,
13064 (void *)&cmd_vf_tc_bw_port_id,
13065 (void *)&cmd_vf_tc_bw_vf_id,
13066 (void *)&cmd_vf_tc_bw_bw_list,
13072 cmd_tc_min_bw_parsed(
13073 void *parsed_result,
13074 __attribute__((unused)) struct cmdline *cl,
13075 __attribute__((unused)) void *data)
13077 struct cmd_vf_tc_bw_result *res = parsed_result;
13078 struct rte_port *port;
13081 int ret = -ENOTSUP;
13083 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13086 port = &ports[res->port_id];
13087 /** Check if the port is not started **/
13088 if (port->port_status != RTE_PORT_STOPPED) {
13089 printf("Please stop port %d first\n", res->port_id);
13093 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13097 #ifdef RTE_LIBRTE_IXGBE_PMD
13098 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13105 printf("invalid bandwidth\n");
13108 printf("invalid port_id %d\n", res->port_id);
13111 printf("function not implemented\n");
13114 printf("programming error: (%s)\n", strerror(-ret));
13118 cmdline_parse_inst_t cmd_tc_min_bw = {
13119 .f = cmd_tc_min_bw_parsed,
13121 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13123 (void *)&cmd_vf_tc_bw_set,
13124 (void *)&cmd_vf_tc_bw_tc,
13125 (void *)&cmd_vf_tc_bw_tx,
13126 (void *)&cmd_vf_tc_bw_min_bw,
13127 (void *)&cmd_vf_tc_bw_port_id,
13128 (void *)&cmd_vf_tc_bw_bw_list,
13133 /* TC max bandwidth setting */
13135 cmd_vf_tc_max_bw_parsed(
13136 void *parsed_result,
13137 __attribute__((unused)) struct cmdline *cl,
13138 __attribute__((unused)) void *data)
13140 struct cmd_vf_tc_bw_result *res = parsed_result;
13141 int ret = -ENOTSUP;
13143 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13146 #ifdef RTE_LIBRTE_I40E_PMD
13147 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13148 res->tc_no, res->bw);
13155 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13156 res->vf_id, res->tc_no, res->bw);
13159 printf("invalid port_id %d\n", res->port_id);
13162 printf("function not implemented\n");
13165 printf("programming error: (%s)\n", strerror(-ret));
13169 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13170 .f = cmd_vf_tc_max_bw_parsed,
13172 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13175 (void *)&cmd_vf_tc_bw_set,
13176 (void *)&cmd_vf_tc_bw_vf,
13177 (void *)&cmd_vf_tc_bw_tc,
13178 (void *)&cmd_vf_tc_bw_tx,
13179 (void *)&cmd_vf_tc_bw_max_bw,
13180 (void *)&cmd_vf_tc_bw_port_id,
13181 (void *)&cmd_vf_tc_bw_vf_id,
13182 (void *)&cmd_vf_tc_bw_tc_no,
13183 (void *)&cmd_vf_tc_bw_bw,
13188 /* Strict link priority scheduling mode setting */
13190 cmd_strict_link_prio_parsed(
13191 void *parsed_result,
13192 __attribute__((unused)) struct cmdline *cl,
13193 __attribute__((unused)) void *data)
13195 struct cmd_vf_tc_bw_result *res = parsed_result;
13196 int ret = -ENOTSUP;
13198 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13201 #ifdef RTE_LIBRTE_I40E_PMD
13202 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13209 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13212 printf("invalid port_id %d\n", res->port_id);
13215 printf("function not implemented\n");
13218 printf("programming error: (%s)\n", strerror(-ret));
13222 cmdline_parse_inst_t cmd_strict_link_prio = {
13223 .f = cmd_strict_link_prio_parsed,
13225 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13227 (void *)&cmd_vf_tc_bw_set,
13228 (void *)&cmd_vf_tc_bw_tx,
13229 (void *)&cmd_vf_tc_bw_strict_link_prio,
13230 (void *)&cmd_vf_tc_bw_port_id,
13231 (void *)&cmd_vf_tc_bw_tc_map,
13236 /* Load dynamic device personalization*/
13237 struct cmd_ddp_add_result {
13238 cmdline_fixed_string_t ddp;
13239 cmdline_fixed_string_t add;
13244 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13245 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13246 cmdline_parse_token_string_t cmd_ddp_add_add =
13247 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13248 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13249 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
13250 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13251 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13254 cmd_ddp_add_parsed(
13255 void *parsed_result,
13256 __attribute__((unused)) struct cmdline *cl,
13257 __attribute__((unused)) void *data)
13259 struct cmd_ddp_add_result *res = parsed_result;
13265 int ret = -ENOTSUP;
13267 if (res->port_id > nb_ports) {
13268 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13272 if (!all_ports_stopped()) {
13273 printf("Please stop all ports first\n");
13277 filepath = strdup(res->filepath);
13278 if (filepath == NULL) {
13279 printf("Failed to allocate memory\n");
13282 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13284 buff = open_ddp_package_file(file_fld[0], &size);
13286 free((void *)filepath);
13290 #ifdef RTE_LIBRTE_I40E_PMD
13291 if (ret == -ENOTSUP)
13292 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13294 RTE_PMD_I40E_PKG_OP_WR_ADD);
13297 if (ret == -EEXIST)
13298 printf("Profile has already existed.\n");
13300 printf("Failed to load profile.\n");
13301 else if (file_num == 2)
13302 save_ddp_package_file(file_fld[1], buff, size);
13304 close_ddp_package_file(buff);
13305 free((void *)filepath);
13308 cmdline_parse_inst_t cmd_ddp_add = {
13309 .f = cmd_ddp_add_parsed,
13311 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
13313 (void *)&cmd_ddp_add_ddp,
13314 (void *)&cmd_ddp_add_add,
13315 (void *)&cmd_ddp_add_port_id,
13316 (void *)&cmd_ddp_add_filepath,
13321 /* Delete dynamic device personalization*/
13322 struct cmd_ddp_del_result {
13323 cmdline_fixed_string_t ddp;
13324 cmdline_fixed_string_t del;
13329 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13330 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13331 cmdline_parse_token_string_t cmd_ddp_del_del =
13332 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13333 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13334 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT8);
13335 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13336 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13339 cmd_ddp_del_parsed(
13340 void *parsed_result,
13341 __attribute__((unused)) struct cmdline *cl,
13342 __attribute__((unused)) void *data)
13344 struct cmd_ddp_del_result *res = parsed_result;
13347 int ret = -ENOTSUP;
13349 if (res->port_id > nb_ports) {
13350 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13354 if (!all_ports_stopped()) {
13355 printf("Please stop all ports first\n");
13359 buff = open_ddp_package_file(res->filepath, &size);
13363 #ifdef RTE_LIBRTE_I40E_PMD
13364 if (ret == -ENOTSUP)
13365 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13367 RTE_PMD_I40E_PKG_OP_WR_DEL);
13370 if (ret == -EACCES)
13371 printf("Profile does not exist.\n");
13373 printf("Failed to delete profile.\n");
13375 close_ddp_package_file(buff);
13378 cmdline_parse_inst_t cmd_ddp_del = {
13379 .f = cmd_ddp_del_parsed,
13381 .help_str = "ddp del <port_id> <profile_path>",
13383 (void *)&cmd_ddp_del_ddp,
13384 (void *)&cmd_ddp_del_del,
13385 (void *)&cmd_ddp_del_port_id,
13386 (void *)&cmd_ddp_del_filepath,
13391 /* Get dynamic device personalization profile info */
13392 struct cmd_ddp_info_result {
13393 cmdline_fixed_string_t ddp;
13394 cmdline_fixed_string_t get;
13395 cmdline_fixed_string_t info;
13399 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13400 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13401 cmdline_parse_token_string_t cmd_ddp_info_get =
13402 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13403 cmdline_parse_token_string_t cmd_ddp_info_info =
13404 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13405 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13406 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13409 cmd_ddp_info_parsed(
13410 void *parsed_result,
13411 __attribute__((unused)) struct cmdline *cl,
13412 __attribute__((unused)) void *data)
13414 struct cmd_ddp_info_result *res = parsed_result;
13417 int ret = -ENOTSUP;
13418 #ifdef RTE_LIBRTE_I40E_PMD
13421 uint32_t buff_size;
13422 struct rte_pmd_i40e_profile_info info;
13424 struct rte_pmd_i40e_ddp_device_id *devs;
13427 pkg = open_ddp_package_file(res->filepath, &pkg_size);
13431 #ifdef RTE_LIBRTE_I40E_PMD
13432 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13433 (uint8_t *)&info, sizeof(info),
13434 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13436 printf("Global Track id: 0x%x\n", info.track_id);
13437 printf("Global Version: %d.%d.%d.%d\n",
13438 info.version.major,
13439 info.version.minor,
13440 info.version.update,
13441 info.version.draft);
13442 printf("Global Package name: %s\n\n", info.name);
13445 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13446 (uint8_t *)&info, sizeof(info),
13447 RTE_PMD_I40E_PKG_INFO_HEADER);
13449 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13450 printf("i40e Profile Version: %d.%d.%d.%d\n",
13451 info.version.major,
13452 info.version.minor,
13453 info.version.update,
13454 info.version.draft);
13455 printf("i40e Profile name: %s\n\n", info.name);
13458 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13459 (uint8_t *)&buff_size, sizeof(buff_size),
13460 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13461 if (!ret && buff_size) {
13462 buff = (uint8_t *)malloc(buff_size);
13464 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13466 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13468 printf("Package Notes:\n%s\n\n", buff);
13473 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13474 (uint8_t *)&dev_num, sizeof(dev_num),
13475 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13476 if (!ret && dev_num) {
13477 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(dev_num *
13478 sizeof(struct rte_pmd_i40e_ddp_device_id));
13480 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13481 (uint8_t *)devs, dev_num *
13482 sizeof(struct rte_pmd_i40e_ddp_device_id),
13483 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13485 printf("List of supported devices:\n");
13486 for (i = 0; i < dev_num; i++) {
13487 printf(" %04X:%04X %04X:%04X\n",
13488 devs[i].vendor_dev_id >> 16,
13489 devs[i].vendor_dev_id & 0xFFFF,
13490 devs[i].sub_vendor_dev_id >> 16,
13491 devs[i].sub_vendor_dev_id & 0xFFFF);
13500 if (ret == -ENOTSUP)
13501 printf("Function not supported in PMD driver\n");
13502 close_ddp_package_file(pkg);
13505 cmdline_parse_inst_t cmd_ddp_get_info = {
13506 .f = cmd_ddp_info_parsed,
13508 .help_str = "ddp get info <profile_path>",
13510 (void *)&cmd_ddp_info_ddp,
13511 (void *)&cmd_ddp_info_get,
13512 (void *)&cmd_ddp_info_info,
13513 (void *)&cmd_ddp_info_filepath,
13518 /* Get dynamic device personalization profile info list*/
13519 #define PROFILE_INFO_SIZE 48
13520 #define MAX_PROFILE_NUM 16
13522 struct cmd_ddp_get_list_result {
13523 cmdline_fixed_string_t ddp;
13524 cmdline_fixed_string_t get;
13525 cmdline_fixed_string_t list;
13529 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
13530 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
13531 cmdline_parse_token_string_t cmd_ddp_get_list_get =
13532 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
13533 cmdline_parse_token_string_t cmd_ddp_get_list_list =
13534 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
13535 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
13536 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
13539 cmd_ddp_get_list_parsed(
13540 void *parsed_result,
13541 __attribute__((unused)) struct cmdline *cl,
13542 __attribute__((unused)) void *data)
13544 struct cmd_ddp_get_list_result *res = parsed_result;
13545 #ifdef RTE_LIBRTE_I40E_PMD
13546 struct rte_pmd_i40e_profile_list *p_list;
13547 struct rte_pmd_i40e_profile_info *p_info;
13552 int ret = -ENOTSUP;
13554 if (res->port_id > nb_ports) {
13555 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
13559 #ifdef RTE_LIBRTE_I40E_PMD
13560 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
13561 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
13563 printf("%s: Failed to malloc buffer\n", __func__);
13565 if (ret == -ENOTSUP)
13566 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
13567 (uint8_t *)p_list, size);
13570 p_num = p_list->p_count;
13571 printf("Profile number is: %d\n\n", p_num);
13573 for (i = 0; i < p_num; i++) {
13574 p_info = &p_list->p_info[i];
13575 printf("Profile %d:\n", i);
13576 printf("Track id: 0x%x\n", p_info->track_id);
13577 printf("Version: %d.%d.%d.%d\n",
13578 p_info->version.major,
13579 p_info->version.minor,
13580 p_info->version.update,
13581 p_info->version.draft);
13582 printf("Profile name: %s\n\n", p_info->name);
13590 printf("Failed to get ddp list\n");
13593 cmdline_parse_inst_t cmd_ddp_get_list = {
13594 .f = cmd_ddp_get_list_parsed,
13596 .help_str = "ddp get list <port_id>",
13598 (void *)&cmd_ddp_get_list_ddp,
13599 (void *)&cmd_ddp_get_list_get,
13600 (void *)&cmd_ddp_get_list_list,
13601 (void *)&cmd_ddp_get_list_port_id,
13606 /* show vf stats */
13608 /* Common result structure for show vf stats */
13609 struct cmd_show_vf_stats_result {
13610 cmdline_fixed_string_t show;
13611 cmdline_fixed_string_t vf;
13612 cmdline_fixed_string_t stats;
13617 /* Common CLI fields show vf stats*/
13618 cmdline_parse_token_string_t cmd_show_vf_stats_show =
13619 TOKEN_STRING_INITIALIZER
13620 (struct cmd_show_vf_stats_result,
13622 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
13623 TOKEN_STRING_INITIALIZER
13624 (struct cmd_show_vf_stats_result,
13626 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
13627 TOKEN_STRING_INITIALIZER
13628 (struct cmd_show_vf_stats_result,
13630 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
13631 TOKEN_NUM_INITIALIZER
13632 (struct cmd_show_vf_stats_result,
13634 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
13635 TOKEN_NUM_INITIALIZER
13636 (struct cmd_show_vf_stats_result,
13640 cmd_show_vf_stats_parsed(
13641 void *parsed_result,
13642 __attribute__((unused)) struct cmdline *cl,
13643 __attribute__((unused)) void *data)
13645 struct cmd_show_vf_stats_result *res = parsed_result;
13646 struct rte_eth_stats stats;
13647 int ret = -ENOTSUP;
13648 static const char *nic_stats_border = "########################";
13650 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13653 memset(&stats, 0, sizeof(stats));
13655 #ifdef RTE_LIBRTE_I40E_PMD
13656 if (ret == -ENOTSUP)
13657 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
13661 #ifdef RTE_LIBRTE_BNXT_PMD
13662 if (ret == -ENOTSUP)
13663 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
13672 printf("invalid vf_id %d\n", res->vf_id);
13675 printf("invalid port_id %d\n", res->port_id);
13678 printf("function not implemented\n");
13681 printf("programming error: (%s)\n", strerror(-ret));
13684 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
13685 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
13687 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
13689 stats.ipackets, stats.imissed, stats.ibytes);
13690 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
13691 printf(" RX-nombuf: %-10"PRIu64"\n",
13693 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
13695 stats.opackets, stats.oerrors, stats.obytes);
13697 printf(" %s############################%s\n",
13698 nic_stats_border, nic_stats_border);
13701 cmdline_parse_inst_t cmd_show_vf_stats = {
13702 .f = cmd_show_vf_stats_parsed,
13704 .help_str = "show vf stats <port_id> <vf_id>",
13706 (void *)&cmd_show_vf_stats_show,
13707 (void *)&cmd_show_vf_stats_vf,
13708 (void *)&cmd_show_vf_stats_stats,
13709 (void *)&cmd_show_vf_stats_port_id,
13710 (void *)&cmd_show_vf_stats_vf_id,
13715 /* clear vf stats */
13717 /* Common result structure for clear vf stats */
13718 struct cmd_clear_vf_stats_result {
13719 cmdline_fixed_string_t clear;
13720 cmdline_fixed_string_t vf;
13721 cmdline_fixed_string_t stats;
13726 /* Common CLI fields clear vf stats*/
13727 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
13728 TOKEN_STRING_INITIALIZER
13729 (struct cmd_clear_vf_stats_result,
13731 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
13732 TOKEN_STRING_INITIALIZER
13733 (struct cmd_clear_vf_stats_result,
13735 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
13736 TOKEN_STRING_INITIALIZER
13737 (struct cmd_clear_vf_stats_result,
13739 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
13740 TOKEN_NUM_INITIALIZER
13741 (struct cmd_clear_vf_stats_result,
13743 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
13744 TOKEN_NUM_INITIALIZER
13745 (struct cmd_clear_vf_stats_result,
13749 cmd_clear_vf_stats_parsed(
13750 void *parsed_result,
13751 __attribute__((unused)) struct cmdline *cl,
13752 __attribute__((unused)) void *data)
13754 struct cmd_clear_vf_stats_result *res = parsed_result;
13755 int ret = -ENOTSUP;
13757 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13760 #ifdef RTE_LIBRTE_I40E_PMD
13761 if (ret == -ENOTSUP)
13762 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
13765 #ifdef RTE_LIBRTE_BNXT_PMD
13766 if (ret == -ENOTSUP)
13767 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
13775 printf("invalid vf_id %d\n", res->vf_id);
13778 printf("invalid port_id %d\n", res->port_id);
13781 printf("function not implemented\n");
13784 printf("programming error: (%s)\n", strerror(-ret));
13788 cmdline_parse_inst_t cmd_clear_vf_stats = {
13789 .f = cmd_clear_vf_stats_parsed,
13791 .help_str = "clear vf stats <port_id> <vf_id>",
13793 (void *)&cmd_clear_vf_stats_clear,
13794 (void *)&cmd_clear_vf_stats_vf,
13795 (void *)&cmd_clear_vf_stats_stats,
13796 (void *)&cmd_clear_vf_stats_port_id,
13797 (void *)&cmd_clear_vf_stats_vf_id,
13802 /* ptype mapping get */
13804 /* Common result structure for ptype mapping get */
13805 struct cmd_ptype_mapping_get_result {
13806 cmdline_fixed_string_t ptype;
13807 cmdline_fixed_string_t mapping;
13808 cmdline_fixed_string_t get;
13810 uint8_t valid_only;
13813 /* Common CLI fields for ptype mapping get */
13814 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
13815 TOKEN_STRING_INITIALIZER
13816 (struct cmd_ptype_mapping_get_result,
13818 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
13819 TOKEN_STRING_INITIALIZER
13820 (struct cmd_ptype_mapping_get_result,
13821 mapping, "mapping");
13822 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
13823 TOKEN_STRING_INITIALIZER
13824 (struct cmd_ptype_mapping_get_result,
13826 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
13827 TOKEN_NUM_INITIALIZER
13828 (struct cmd_ptype_mapping_get_result,
13830 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
13831 TOKEN_NUM_INITIALIZER
13832 (struct cmd_ptype_mapping_get_result,
13833 valid_only, UINT8);
13836 cmd_ptype_mapping_get_parsed(
13837 void *parsed_result,
13838 __attribute__((unused)) struct cmdline *cl,
13839 __attribute__((unused)) void *data)
13841 struct cmd_ptype_mapping_get_result *res = parsed_result;
13842 int ret = -ENOTSUP;
13843 #ifdef RTE_LIBRTE_I40E_PMD
13844 int max_ptype_num = 256;
13845 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
13850 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13853 #ifdef RTE_LIBRTE_I40E_PMD
13854 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
13865 printf("invalid port_id %d\n", res->port_id);
13868 printf("function not implemented\n");
13871 printf("programming error: (%s)\n", strerror(-ret));
13874 #ifdef RTE_LIBRTE_I40E_PMD
13876 for (i = 0; i < count; i++)
13877 printf("%3d\t0x%08x\n",
13878 mapping[i].hw_ptype, mapping[i].sw_ptype);
13883 cmdline_parse_inst_t cmd_ptype_mapping_get = {
13884 .f = cmd_ptype_mapping_get_parsed,
13886 .help_str = "ptype mapping get <port_id> <valid_only>",
13888 (void *)&cmd_ptype_mapping_get_ptype,
13889 (void *)&cmd_ptype_mapping_get_mapping,
13890 (void *)&cmd_ptype_mapping_get_get,
13891 (void *)&cmd_ptype_mapping_get_port_id,
13892 (void *)&cmd_ptype_mapping_get_valid_only,
13897 /* ptype mapping replace */
13899 /* Common result structure for ptype mapping replace */
13900 struct cmd_ptype_mapping_replace_result {
13901 cmdline_fixed_string_t ptype;
13902 cmdline_fixed_string_t mapping;
13903 cmdline_fixed_string_t replace;
13910 /* Common CLI fields for ptype mapping replace */
13911 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
13912 TOKEN_STRING_INITIALIZER
13913 (struct cmd_ptype_mapping_replace_result,
13915 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
13916 TOKEN_STRING_INITIALIZER
13917 (struct cmd_ptype_mapping_replace_result,
13918 mapping, "mapping");
13919 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
13920 TOKEN_STRING_INITIALIZER
13921 (struct cmd_ptype_mapping_replace_result,
13922 replace, "replace");
13923 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
13924 TOKEN_NUM_INITIALIZER
13925 (struct cmd_ptype_mapping_replace_result,
13927 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
13928 TOKEN_NUM_INITIALIZER
13929 (struct cmd_ptype_mapping_replace_result,
13931 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
13932 TOKEN_NUM_INITIALIZER
13933 (struct cmd_ptype_mapping_replace_result,
13935 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
13936 TOKEN_NUM_INITIALIZER
13937 (struct cmd_ptype_mapping_replace_result,
13941 cmd_ptype_mapping_replace_parsed(
13942 void *parsed_result,
13943 __attribute__((unused)) struct cmdline *cl,
13944 __attribute__((unused)) void *data)
13946 struct cmd_ptype_mapping_replace_result *res = parsed_result;
13947 int ret = -ENOTSUP;
13949 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13952 #ifdef RTE_LIBRTE_I40E_PMD
13953 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
13963 printf("invalid ptype 0x%8x or 0x%8x\n",
13964 res->target, res->pkt_type);
13967 printf("invalid port_id %d\n", res->port_id);
13970 printf("function not implemented\n");
13973 printf("programming error: (%s)\n", strerror(-ret));
13977 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
13978 .f = cmd_ptype_mapping_replace_parsed,
13981 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
13983 (void *)&cmd_ptype_mapping_replace_ptype,
13984 (void *)&cmd_ptype_mapping_replace_mapping,
13985 (void *)&cmd_ptype_mapping_replace_replace,
13986 (void *)&cmd_ptype_mapping_replace_port_id,
13987 (void *)&cmd_ptype_mapping_replace_target,
13988 (void *)&cmd_ptype_mapping_replace_mask,
13989 (void *)&cmd_ptype_mapping_replace_pkt_type,
13994 /* ptype mapping reset */
13996 /* Common result structure for ptype mapping reset */
13997 struct cmd_ptype_mapping_reset_result {
13998 cmdline_fixed_string_t ptype;
13999 cmdline_fixed_string_t mapping;
14000 cmdline_fixed_string_t reset;
14004 /* Common CLI fields for ptype mapping reset*/
14005 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
14006 TOKEN_STRING_INITIALIZER
14007 (struct cmd_ptype_mapping_reset_result,
14009 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
14010 TOKEN_STRING_INITIALIZER
14011 (struct cmd_ptype_mapping_reset_result,
14012 mapping, "mapping");
14013 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
14014 TOKEN_STRING_INITIALIZER
14015 (struct cmd_ptype_mapping_reset_result,
14017 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
14018 TOKEN_NUM_INITIALIZER
14019 (struct cmd_ptype_mapping_reset_result,
14023 cmd_ptype_mapping_reset_parsed(
14024 void *parsed_result,
14025 __attribute__((unused)) struct cmdline *cl,
14026 __attribute__((unused)) void *data)
14028 struct cmd_ptype_mapping_reset_result *res = parsed_result;
14029 int ret = -ENOTSUP;
14031 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14034 #ifdef RTE_LIBRTE_I40E_PMD
14035 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
14042 printf("invalid port_id %d\n", res->port_id);
14045 printf("function not implemented\n");
14048 printf("programming error: (%s)\n", strerror(-ret));
14052 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
14053 .f = cmd_ptype_mapping_reset_parsed,
14055 .help_str = "ptype mapping reset <port_id>",
14057 (void *)&cmd_ptype_mapping_reset_ptype,
14058 (void *)&cmd_ptype_mapping_reset_mapping,
14059 (void *)&cmd_ptype_mapping_reset_reset,
14060 (void *)&cmd_ptype_mapping_reset_port_id,
14065 /* ptype mapping update */
14067 /* Common result structure for ptype mapping update */
14068 struct cmd_ptype_mapping_update_result {
14069 cmdline_fixed_string_t ptype;
14070 cmdline_fixed_string_t mapping;
14071 cmdline_fixed_string_t reset;
14077 /* Common CLI fields for ptype mapping update*/
14078 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
14079 TOKEN_STRING_INITIALIZER
14080 (struct cmd_ptype_mapping_update_result,
14082 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
14083 TOKEN_STRING_INITIALIZER
14084 (struct cmd_ptype_mapping_update_result,
14085 mapping, "mapping");
14086 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
14087 TOKEN_STRING_INITIALIZER
14088 (struct cmd_ptype_mapping_update_result,
14090 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
14091 TOKEN_NUM_INITIALIZER
14092 (struct cmd_ptype_mapping_update_result,
14094 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
14095 TOKEN_NUM_INITIALIZER
14096 (struct cmd_ptype_mapping_update_result,
14098 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
14099 TOKEN_NUM_INITIALIZER
14100 (struct cmd_ptype_mapping_update_result,
14104 cmd_ptype_mapping_update_parsed(
14105 void *parsed_result,
14106 __attribute__((unused)) struct cmdline *cl,
14107 __attribute__((unused)) void *data)
14109 struct cmd_ptype_mapping_update_result *res = parsed_result;
14110 int ret = -ENOTSUP;
14111 #ifdef RTE_LIBRTE_I40E_PMD
14112 struct rte_pmd_i40e_ptype_mapping mapping;
14114 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14117 #ifdef RTE_LIBRTE_I40E_PMD
14118 mapping.hw_ptype = res->hw_ptype;
14119 mapping.sw_ptype = res->sw_ptype;
14120 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
14130 printf("invalid ptype 0x%8x\n", res->sw_ptype);
14133 printf("invalid port_id %d\n", res->port_id);
14136 printf("function not implemented\n");
14139 printf("programming error: (%s)\n", strerror(-ret));
14143 cmdline_parse_inst_t cmd_ptype_mapping_update = {
14144 .f = cmd_ptype_mapping_update_parsed,
14146 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
14148 (void *)&cmd_ptype_mapping_update_ptype,
14149 (void *)&cmd_ptype_mapping_update_mapping,
14150 (void *)&cmd_ptype_mapping_update_update,
14151 (void *)&cmd_ptype_mapping_update_port_id,
14152 (void *)&cmd_ptype_mapping_update_hw_ptype,
14153 (void *)&cmd_ptype_mapping_update_sw_ptype,
14158 /* Common result structure for file commands */
14159 struct cmd_cmdfile_result {
14160 cmdline_fixed_string_t load;
14161 cmdline_fixed_string_t filename;
14164 /* Common CLI fields for file commands */
14165 cmdline_parse_token_string_t cmd_load_cmdfile =
14166 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
14167 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
14168 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
14171 cmd_load_from_file_parsed(
14172 void *parsed_result,
14173 __attribute__((unused)) struct cmdline *cl,
14174 __attribute__((unused)) void *data)
14176 struct cmd_cmdfile_result *res = parsed_result;
14178 cmdline_read_from_file(res->filename);
14181 cmdline_parse_inst_t cmd_load_from_file = {
14182 .f = cmd_load_from_file_parsed,
14184 .help_str = "load <filename>",
14186 (void *)&cmd_load_cmdfile,
14187 (void *)&cmd_load_cmdfile_filename,
14192 /* ******************************************************************************** */
14194 /* list of instructions */
14195 cmdline_parse_ctx_t main_ctx[] = {
14196 (cmdline_parse_inst_t *)&cmd_help_brief,
14197 (cmdline_parse_inst_t *)&cmd_help_long,
14198 (cmdline_parse_inst_t *)&cmd_quit,
14199 (cmdline_parse_inst_t *)&cmd_load_from_file,
14200 (cmdline_parse_inst_t *)&cmd_showport,
14201 (cmdline_parse_inst_t *)&cmd_showqueue,
14202 (cmdline_parse_inst_t *)&cmd_showportall,
14203 (cmdline_parse_inst_t *)&cmd_showcfg,
14204 (cmdline_parse_inst_t *)&cmd_start,
14205 (cmdline_parse_inst_t *)&cmd_start_tx_first,
14206 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
14207 (cmdline_parse_inst_t *)&cmd_set_link_up,
14208 (cmdline_parse_inst_t *)&cmd_set_link_down,
14209 (cmdline_parse_inst_t *)&cmd_reset,
14210 (cmdline_parse_inst_t *)&cmd_set_numbers,
14211 (cmdline_parse_inst_t *)&cmd_set_txpkts,
14212 (cmdline_parse_inst_t *)&cmd_set_txsplit,
14213 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
14214 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
14215 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
14216 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
14217 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
14218 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
14219 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
14220 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
14221 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
14222 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
14223 (cmdline_parse_inst_t *)&cmd_set_link_check,
14224 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
14225 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
14226 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
14227 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
14228 #ifdef RTE_LIBRTE_PMD_BOND
14229 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
14230 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
14231 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
14232 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
14233 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
14234 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
14235 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
14236 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
14237 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
14238 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
14239 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
14241 (cmdline_parse_inst_t *)&cmd_vlan_offload,
14242 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
14243 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
14244 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
14245 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
14246 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
14247 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
14248 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
14249 (cmdline_parse_inst_t *)&cmd_csum_set,
14250 (cmdline_parse_inst_t *)&cmd_csum_show,
14251 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
14252 (cmdline_parse_inst_t *)&cmd_tso_set,
14253 (cmdline_parse_inst_t *)&cmd_tso_show,
14254 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
14255 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
14256 (cmdline_parse_inst_t *)&cmd_enable_gro,
14257 (cmdline_parse_inst_t *)&cmd_gro_set,
14258 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
14259 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
14260 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
14261 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
14262 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
14263 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
14264 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
14265 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
14266 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
14267 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
14268 (cmdline_parse_inst_t *)&cmd_config_dcb,
14269 (cmdline_parse_inst_t *)&cmd_read_reg,
14270 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
14271 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
14272 (cmdline_parse_inst_t *)&cmd_write_reg,
14273 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
14274 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
14275 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
14276 (cmdline_parse_inst_t *)&cmd_stop,
14277 (cmdline_parse_inst_t *)&cmd_mac_addr,
14278 (cmdline_parse_inst_t *)&cmd_set_qmap,
14279 (cmdline_parse_inst_t *)&cmd_operate_port,
14280 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
14281 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
14282 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
14283 (cmdline_parse_inst_t *)&cmd_config_speed_all,
14284 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
14285 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
14286 (cmdline_parse_inst_t *)&cmd_config_mtu,
14287 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
14288 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
14289 (cmdline_parse_inst_t *)&cmd_config_rss,
14290 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
14291 (cmdline_parse_inst_t *)&cmd_config_txqflags,
14292 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
14293 (cmdline_parse_inst_t *)&cmd_showport_reta,
14294 (cmdline_parse_inst_t *)&cmd_config_burst,
14295 (cmdline_parse_inst_t *)&cmd_config_thresh,
14296 (cmdline_parse_inst_t *)&cmd_config_threshold,
14297 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
14298 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
14299 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
14300 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
14301 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
14302 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
14303 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
14304 (cmdline_parse_inst_t *)&cmd_global_config,
14305 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
14306 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
14307 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
14308 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
14309 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
14310 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
14311 (cmdline_parse_inst_t *)&cmd_dump,
14312 (cmdline_parse_inst_t *)&cmd_dump_one,
14313 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
14314 (cmdline_parse_inst_t *)&cmd_syn_filter,
14315 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
14316 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
14317 (cmdline_parse_inst_t *)&cmd_flex_filter,
14318 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
14319 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
14320 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
14321 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
14322 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
14323 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
14324 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
14325 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
14326 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
14327 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
14328 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
14329 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
14330 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
14331 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
14332 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
14333 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
14334 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
14335 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
14336 (cmdline_parse_inst_t *)&cmd_flow,
14337 (cmdline_parse_inst_t *)&cmd_mcast_addr,
14338 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
14339 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
14340 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
14341 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
14342 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
14343 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
14344 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
14345 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
14346 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
14347 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
14348 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
14349 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
14350 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
14351 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
14352 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
14353 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
14354 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
14355 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
14356 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
14357 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
14358 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
14359 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
14360 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
14361 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
14362 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
14363 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
14364 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
14365 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
14366 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
14367 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
14368 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
14369 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
14370 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
14371 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
14372 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
14373 (cmdline_parse_inst_t *)&cmd_ddp_add,
14374 (cmdline_parse_inst_t *)&cmd_ddp_del,
14375 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
14376 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
14377 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
14378 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
14379 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
14380 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
14381 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
14382 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
14386 /* read cmdline commands from file */
14388 cmdline_read_from_file(const char *filename)
14390 struct cmdline *cl;
14392 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14394 printf("Failed to create file based cmdline context: %s\n",
14399 cmdline_interact(cl);
14404 printf("Read CLI commands from %s\n", filename);
14407 /* prompt function, called from main on MASTER lcore */
14411 /* initialize non-constant commands */
14412 cmd_set_fwd_mode_init();
14413 cmd_set_fwd_retry_mode_init();
14415 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14416 if (testpmd_cl == NULL)
14418 cmdline_interact(testpmd_cl);
14419 cmdline_stdin_exit(testpmd_cl);
14425 if (testpmd_cl != NULL)
14426 cmdline_quit(testpmd_cl);
14430 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14432 if (id == (portid_t)RTE_PORT_ALL) {
14435 RTE_ETH_FOREACH_DEV(pid) {
14436 /* check if need_reconfig has been set to 1 */
14437 if (ports[pid].need_reconfig == 0)
14438 ports[pid].need_reconfig = dev;
14439 /* check if need_reconfig_queues has been set to 1 */
14440 if (ports[pid].need_reconfig_queues == 0)
14441 ports[pid].need_reconfig_queues = queue;
14443 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14444 /* check if need_reconfig has been set to 1 */
14445 if (ports[id].need_reconfig == 0)
14446 ports[id].need_reconfig = dev;
14447 /* check if need_reconfig_queues has been set to 1 */
14448 if (ports[id].need_reconfig_queues == 0)
14449 ports[id].need_reconfig_queues = queue;