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.
46 #include <net/socket.h>
48 #include <sys/socket.h>
51 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include <rte_common.h>
56 #include <rte_byteorder.h>
58 #include <rte_debug.h>
59 #include <rte_cycles.h>
60 #include <rte_memory.h>
61 #include <rte_memzone.h>
62 #include <rte_malloc.h>
63 #include <rte_launch.h>
65 #include <rte_per_lcore.h>
66 #include <rte_lcore.h>
67 #include <rte_atomic.h>
68 #include <rte_branch_prediction.h>
70 #include <rte_mempool.h>
71 #include <rte_interrupts.h>
73 #include <rte_ether.h>
74 #include <rte_ethdev.h>
75 #include <rte_string_fns.h>
76 #include <rte_devargs.h>
77 #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>
91 #ifdef RTE_LIBRTE_IXGBE_PMD
92 #include <rte_pmd_ixgbe.h>
94 #ifdef RTE_LIBRTE_I40E_PMD
95 #include <rte_pmd_i40e.h>
99 static struct cmdline *testpmd_cl;
101 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
103 /* *** Help command with introduction. *** */
104 struct cmd_help_brief_result {
105 cmdline_fixed_string_t help;
108 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
110 __attribute__((unused)) void *data)
115 "Help is available for the following sections:\n\n"
116 " help control : Start and stop forwarding.\n"
117 " help display : Displaying port, stats and config "
119 " help config : Configuration information.\n"
120 " help ports : Configuring ports.\n"
121 " help registers : Reading and setting port registers.\n"
122 " help filters : Filters configuration help.\n"
123 " help all : All of the above sections.\n\n"
128 cmdline_parse_token_string_t cmd_help_brief_help =
129 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
131 cmdline_parse_inst_t cmd_help_brief = {
132 .f = cmd_help_brief_parsed,
134 .help_str = "help: Show help",
136 (void *)&cmd_help_brief_help,
141 /* *** Help command with help sections. *** */
142 struct cmd_help_long_result {
143 cmdline_fixed_string_t help;
144 cmdline_fixed_string_t section;
147 static void cmd_help_long_parsed(void *parsed_result,
149 __attribute__((unused)) void *data)
152 struct cmd_help_long_result *res = parsed_result;
154 if (!strcmp(res->section, "all"))
157 if (show_all || !strcmp(res->section, "control")) {
162 "Control forwarding:\n"
163 "-------------------\n\n"
166 " Start packet forwarding with current configuration.\n\n"
169 " Start packet forwarding with current config"
170 " after sending one burst of packets.\n\n"
173 " Stop packet forwarding, and display accumulated"
177 " Quit to prompt.\n\n"
181 if (show_all || !strcmp(res->section, "display")) {
189 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
190 " Display information for port_id, or all.\n\n"
192 "show port X rss reta (size) (mask0,mask1,...)\n"
193 " Display the rss redirection table entry indicated"
194 " by masks on port X. size is used to indicate the"
195 " hardware supported reta size\n\n"
197 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
198 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
199 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
200 " Display the RSS hash functions and RSS hash key"
203 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
204 " Clear information for port_id, or all.\n\n"
206 "show (rxq|txq) info (port_id) (queue_id)\n"
207 " Display information for configured RX/TX queue.\n\n"
209 "show config (rxtx|cores|fwd|txpkts)\n"
210 " Display the given configuration.\n\n"
212 "read rxd (port_id) (queue_id) (rxd_id)\n"
213 " Display an RX descriptor of a port RX queue.\n\n"
215 "read txd (port_id) (queue_id) (txd_id)\n"
216 " Display a TX descriptor of a port TX queue.\n\n"
218 "ddp get list (port_id)\n"
219 " Get ddp profile info list\n\n"
223 if (show_all || !strcmp(res->section, "config")) {
229 "Configuration changes only become active when"
230 " forwarding is started/restarted.\n\n"
233 " Reset forwarding to the default configuration.\n\n"
235 "set verbose (level)\n"
236 " Set the debug verbosity level X.\n\n"
239 " Set number of ports.\n\n"
242 " Set number of cores.\n\n"
244 "set coremask (mask)\n"
245 " Set the forwarding cores hexadecimal mask.\n\n"
247 "set portmask (mask)\n"
248 " Set the forwarding ports hexadecimal mask.\n\n"
251 " Set number of packets per burst.\n\n"
253 "set burst tx delay (microseconds) retry (num)\n"
254 " Set the transmit delay time and number of retries,"
255 " effective when retry is enabled.\n\n"
257 "set txpkts (x[,y]*)\n"
258 " Set the length of each segment of TXONLY"
259 " and optionally CSUM packets.\n\n"
261 "set txsplit (off|on|rand)\n"
262 " Set the split policy for the TX packets."
263 " Right now only applicable for CSUM and TXONLY"
266 "set corelist (x[,y]*)\n"
267 " Set the list of forwarding cores.\n\n"
269 "set portlist (x[,y]*)\n"
270 " Set the list of forwarding ports.\n\n"
272 "set tx loopback (port_id) (on|off)\n"
273 " Enable or disable tx loopback.\n\n"
275 #ifdef RTE_LIBRTE_IXGBE_PMD
276 "set all queues drop (port_id) (on|off)\n"
277 " Set drop enable bit for all queues.\n\n"
279 "set vf split drop (port_id) (vf_id) (on|off)\n"
280 " Set split drop enable bit for a VF from the PF.\n\n"
283 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
284 " Set MAC antispoof for a VF from the PF.\n\n"
286 #ifdef RTE_LIBRTE_IXGBE_PMD
287 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
288 " Enable MACsec offload.\n\n"
290 "set macsec offload (port_id) off\n"
291 " Disable MACsec offload.\n\n"
293 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
294 " Configure MACsec secure connection (SC).\n\n"
296 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
297 " Configure MACsec secure association (SA).\n\n"
300 "set vf broadcast (port_id) (vf_id) (on|off)\n"
301 " Set VF broadcast for a VF from the PF.\n\n"
303 "vlan set strip (on|off) (port_id)\n"
304 " Set the VLAN strip on a port.\n\n"
306 "vlan set stripq (on|off) (port_id,queue_id)\n"
307 " Set the VLAN strip for a queue on a port.\n\n"
309 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
310 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
312 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
313 " Set VLAN insert for a VF from the PF.\n\n"
315 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
316 " Set VLAN antispoof for a VF from the PF.\n\n"
318 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
319 " Set VLAN tag for a VF from the PF.\n\n"
321 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
322 " Set a VF's max bandwidth(Mbps).\n\n"
324 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
325 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
327 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
328 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
330 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
331 " Set some TCs' strict link priority mode on a physical port.\n\n"
333 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
334 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
336 "vlan set filter (on|off) (port_id)\n"
337 " Set the VLAN filter on a port.\n\n"
339 "vlan set qinq (on|off) (port_id)\n"
340 " Set the VLAN QinQ (extended queue in queue)"
343 "vlan set (inner|outer) tpid (value) (port_id)\n"
344 " Set the VLAN TPID for Packet Filtering on"
347 "rx_vlan add (vlan_id|all) (port_id)\n"
348 " Add a vlan_id, or all identifiers, to the set"
349 " of VLAN identifiers filtered by port_id.\n\n"
351 "rx_vlan rm (vlan_id|all) (port_id)\n"
352 " Remove a vlan_id, or all identifiers, from the set"
353 " of VLAN identifiers filtered by port_id.\n\n"
355 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
356 " Add a vlan_id, to the set of VLAN identifiers"
357 "filtered for VF(s) from port_id.\n\n"
359 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
360 " Remove a vlan_id, to the set of VLAN identifiers"
361 "filtered for VF(s) from port_id.\n\n"
363 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
364 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
365 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
366 " add a tunnel filter of a port.\n\n"
368 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
369 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
370 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
371 " remove a tunnel filter of a port.\n\n"
373 "rx_vxlan_port add (udp_port) (port_id)\n"
374 " Add an UDP port for VXLAN packet filter on a port\n\n"
376 "rx_vxlan_port rm (udp_port) (port_id)\n"
377 " Remove an UDP port for VXLAN packet filter on a port\n\n"
379 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
380 " Set hardware insertion of VLAN IDs (single or double VLAN "
381 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
383 "tx_vlan set pvid port_id vlan_id (on|off)\n"
384 " Set port based TX VLAN insertion.\n\n"
386 "tx_vlan reset (port_id)\n"
387 " Disable hardware insertion of a VLAN header in"
388 " packets sent on a port.\n\n"
390 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
391 " Select hardware or software calculation of the"
392 " checksum when transmitting a packet using the"
393 " csum forward engine.\n"
394 " ip|udp|tcp|sctp always concern the inner layer.\n"
395 " outer-ip concerns the outer IP layer in"
396 " case the packet is recognized as a tunnel packet by"
397 " the forward engine (vxlan, gre and ipip are supported)\n"
398 " Please check the NIC datasheet for HW limits.\n\n"
400 "csum parse-tunnel (on|off) (tx_port_id)\n"
401 " If disabled, treat tunnel packets as non-tunneled"
402 " packets (treat inner headers as payload). The port\n"
403 " argument is the port used for TX in csum forward"
406 "csum show (port_id)\n"
407 " Display tx checksum offload configuration\n\n"
409 "tso set (segsize) (portid)\n"
410 " Enable TCP Segmentation Offload in csum forward"
412 " Please check the NIC datasheet for HW limits.\n\n"
415 " Display the status of TCP Segmentation Offload.\n\n"
418 " Set packet forwarding mode.\n\n"
420 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
421 " Add a MAC address on port_id.\n\n"
423 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
424 " Remove a MAC address from port_id.\n\n"
426 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
427 " Set the default MAC address for port_id.\n\n"
429 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
430 " Add a MAC address for a VF on the port.\n\n"
432 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
433 " Set the MAC address for a VF from the PF.\n\n"
435 "set port (port_id) uta (mac_address|all) (on|off)\n"
436 " Add/Remove a or all unicast hash filter(s)"
439 "set promisc (port_id|all) (on|off)\n"
440 " Set the promiscuous mode on port_id, or all.\n\n"
442 "set allmulti (port_id|all) (on|off)\n"
443 " Set the allmulti mode on port_id, or all.\n\n"
445 "set vf promisc (port_id) (vf_id) (on|off)\n"
446 " Set unicast promiscuous mode for a VF from the PF.\n\n"
448 "set vf allmulti (port_id) (vf_id) (on|off)\n"
449 " Set multicast promiscuous mode for a VF from the PF.\n\n"
451 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
452 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
453 " (on|off) autoneg (on|off) (port_id)\n"
454 "set flow_ctrl rx (on|off) (portid)\n"
455 "set flow_ctrl tx (on|off) (portid)\n"
456 "set flow_ctrl high_water (high_water) (portid)\n"
457 "set flow_ctrl low_water (low_water) (portid)\n"
458 "set flow_ctrl pause_time (pause_time) (portid)\n"
459 "set flow_ctrl send_xon (send_xon) (portid)\n"
460 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
461 "set flow_ctrl autoneg (on|off) (port_id)\n"
462 " Set the link flow control parameter on a port.\n\n"
464 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
465 " (low_water) (pause_time) (priority) (port_id)\n"
466 " Set the priority flow control parameter on a"
469 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
470 " Set statistics mapping (qmapping 0..15) for RX/TX"
472 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
473 " on port 0 to mapping 5.\n\n"
475 "set port (port_id) vf (vf_id) rx|tx on|off\n"
476 " Enable/Disable a VF receive/tranmit from a port\n\n"
478 "set port (port_id) vf (vf_id) (mac_addr)"
479 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
480 " Add/Remove unicast or multicast MAC addr filter"
483 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
485 " AUPE:accepts untagged VLAN;"
486 "ROPE:accept unicast hash\n\n"
487 " BAM:accepts broadcast packets;"
488 "MPE:accepts all multicast packets\n\n"
489 " Enable/Disable a VF receive mode of a port\n\n"
491 "set port (port_id) queue (queue_id) rate (rate_num)\n"
492 " Set rate limit for a queue of a port\n\n"
494 "set port (port_id) vf (vf_id) rate (rate_num) "
495 "queue_mask (queue_mask_value)\n"
496 " Set rate limit for queues in VF of a port\n\n"
498 "set port (port_id) mirror-rule (rule_id)"
499 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
500 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
501 " Set pool or vlan type mirror rule on a port.\n"
502 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
503 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
506 "set port (port_id) mirror-rule (rule_id)"
507 " (uplink-mirror|downlink-mirror) dst-pool"
508 " (pool_id) (on|off)\n"
509 " Set uplink or downlink type mirror rule on a port.\n"
510 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
511 " 0 on' enable mirror income traffic to pool 0.\n\n"
513 "reset port (port_id) mirror-rule (rule_id)\n"
514 " Reset a mirror rule.\n\n"
516 "set flush_rx (on|off)\n"
517 " Flush (default) or don't flush RX streams before"
518 " forwarding. Mainly used with PCAP drivers.\n\n"
520 #ifdef RTE_NIC_BYPASS
521 "set bypass mode (normal|bypass|isolate) (port_id)\n"
522 " Set the bypass mode for the lowest port on bypass enabled"
525 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
526 "mode (normal|bypass|isolate) (port_id)\n"
527 " Set the event required to initiate specified bypass mode for"
528 " the lowest port on a bypass enabled NIC where:\n"
529 " timeout = enable bypass after watchdog timeout.\n"
530 " os_on = enable bypass when OS/board is powered on.\n"
531 " os_off = enable bypass when OS/board is powered off.\n"
532 " power_on = enable bypass when power supply is turned on.\n"
533 " power_off = enable bypass when power supply is turned off."
536 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
537 " Set the bypass watchdog timeout to 'n' seconds"
538 " where 0 = instant.\n\n"
540 "show bypass config (port_id)\n"
541 " Show the bypass configuration for a bypass enabled NIC"
542 " using the lowest port on the NIC.\n\n"
544 #ifdef RTE_LIBRTE_PMD_BOND
545 "create bonded device (mode) (socket)\n"
546 " Create a new bonded device with specific bonding mode and socket.\n\n"
548 "add bonding slave (slave_id) (port_id)\n"
549 " Add a slave device to a bonded device.\n\n"
551 "remove bonding slave (slave_id) (port_id)\n"
552 " Remove a slave device from a bonded device.\n\n"
554 "set bonding mode (value) (port_id)\n"
555 " Set the bonding mode on a bonded device.\n\n"
557 "set bonding primary (slave_id) (port_id)\n"
558 " Set the primary slave for a bonded device.\n\n"
560 "show bonding config (port_id)\n"
561 " Show the bonding config for port_id.\n\n"
563 "set bonding mac_addr (port_id) (address)\n"
564 " Set the MAC address of a bonded device.\n\n"
566 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
567 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
569 "set bonding mon_period (port_id) (value)\n"
570 " Set the bonding link status monitoring polling period in ms.\n\n"
572 "set link-up port (port_id)\n"
573 " Set link up for a port.\n\n"
575 "set link-down port (port_id)\n"
576 " Set link down for a port.\n\n"
578 "E-tag set insertion on port-tag-id (value)"
579 " port (port_id) vf (vf_id)\n"
580 " Enable E-tag insertion for a VF on a port\n\n"
582 "E-tag set insertion off port (port_id) vf (vf_id)\n"
583 " Disable E-tag insertion for a VF on a port\n\n"
585 "E-tag set stripping (on|off) port (port_id)\n"
586 " Enable/disable E-tag stripping on a port\n\n"
588 "E-tag set forwarding (on|off) port (port_id)\n"
589 " Enable/disable E-tag based forwarding"
592 "E-tag set filter add e-tag-id (value) dst-pool"
593 " (pool_id) port (port_id)\n"
594 " Add an E-tag forwarding filter on a port\n\n"
596 "E-tag set filter del e-tag-id (value) port (port_id)\n"
597 " Delete an E-tag forwarding filter on a port\n\n"
599 "ddp add (port_id) (profile_path)\n"
600 " Load a profile package on a port\n\n"
602 , list_pkt_forwarding_modes()
606 if (show_all || !strcmp(res->section, "ports")) {
612 "----------------\n\n"
614 "port start (port_id|all)\n"
615 " Start all ports or port_id.\n\n"
617 "port stop (port_id|all)\n"
618 " Stop all ports or port_id.\n\n"
620 "port close (port_id|all)\n"
621 " Close all ports or port_id.\n\n"
623 "port attach (ident)\n"
624 " Attach physical or virtual dev by pci address or virtual device name\n\n"
626 "port detach (port_id)\n"
627 " Detach physical or virtual dev by port_id\n\n"
629 "port config (port_id|all)"
630 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
631 " duplex (half|full|auto)\n"
632 " Set speed and duplex for all ports or port_id\n\n"
634 "port config all (rxq|txq|rxd|txd) (value)\n"
635 " Set number for rxq/txq/rxd/txd.\n\n"
637 "port config all max-pkt-len (value)\n"
638 " Set the max packet length.\n\n"
640 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
641 "hw-vlan-strip|hw-vlan-extend|drop-en)"
643 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
646 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
647 " Set the RSS mode.\n\n"
649 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
650 " Set the RSS redirection table.\n\n"
652 "port config (port_id) dcb vt (on|off) (traffic_class)"
654 " Set the DCB mode.\n\n"
656 "port config all burst (value)\n"
657 " Set the number of packets per burst.\n\n"
659 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
661 " Set the ring prefetch/host/writeback threshold"
662 " for tx/rx queue.\n\n"
664 "port config all (txfreet|txrst|rxfreet) (value)\n"
665 " Set free threshold for rx/tx, or set"
666 " tx rs bit threshold.\n\n"
667 "port config mtu X value\n"
668 " Set the MTU of port X to a given value\n\n"
670 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
671 " Start/stop a rx/tx queue of port X. Only take effect"
672 " when port X is started\n\n"
674 "port config (port_id|all) l2-tunnel E-tag ether-type"
676 " Set the value of E-tag ether-type.\n\n"
678 "port config (port_id|all) l2-tunnel E-tag"
679 " (enable|disable)\n"
680 " Enable/disable the E-tag support.\n\n"
684 if (show_all || !strcmp(res->section, "registers")) {
692 "read reg (port_id) (address)\n"
693 " Display value of a port register.\n\n"
695 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
696 " Display a port register bit field.\n\n"
698 "read regbit (port_id) (address) (bit_x)\n"
699 " Display a single port register bit.\n\n"
701 "write reg (port_id) (address) (value)\n"
702 " Set value of a port register.\n\n"
704 "write regfield (port_id) (address) (bit_x) (bit_y)"
706 " Set bit field of a port register.\n\n"
708 "write regbit (port_id) (address) (bit_x) (value)\n"
709 " Set single bit value of a port register.\n\n"
712 if (show_all || !strcmp(res->section, "filters")) {
720 "ethertype_filter (port_id) (add|del)"
721 " (mac_addr|mac_ignr) (mac_address) ethertype"
722 " (ether_type) (drop|fwd) queue (queue_id)\n"
723 " Add/Del an ethertype filter.\n\n"
725 "2tuple_filter (port_id) (add|del)"
726 " dst_port (dst_port_value) protocol (protocol_value)"
727 " mask (mask_value) tcp_flags (tcp_flags_value)"
728 " priority (prio_value) queue (queue_id)\n"
729 " Add/Del a 2tuple filter.\n\n"
731 "5tuple_filter (port_id) (add|del)"
732 " dst_ip (dst_address) src_ip (src_address)"
733 " dst_port (dst_port_value) src_port (src_port_value)"
734 " protocol (protocol_value)"
735 " mask (mask_value) tcp_flags (tcp_flags_value)"
736 " priority (prio_value) queue (queue_id)\n"
737 " Add/Del a 5tuple filter.\n\n"
739 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
740 " Add/Del syn filter.\n\n"
742 "flex_filter (port_id) (add|del) len (len_value)"
743 " bytes (bytes_value) mask (mask_value)"
744 " priority (prio_value) queue (queue_id)\n"
745 " Add/Del a flex filter.\n\n"
747 "flow_director_filter (port_id) mode IP (add|del|update)"
748 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
749 " src (src_ip_address) dst (dst_ip_address)"
750 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
751 " vlan (vlan_value) flexbytes (flexbytes_value)"
752 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
753 " fd_id (fd_id_value)\n"
754 " Add/Del an IP type flow director filter.\n\n"
756 "flow_director_filter (port_id) mode IP (add|del|update)"
757 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
758 " src (src_ip_address) (src_port)"
759 " dst (dst_ip_address) (dst_port)"
760 " tos (tos_value) ttl (ttl_value)"
761 " vlan (vlan_value) flexbytes (flexbytes_value)"
762 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
763 " fd_id (fd_id_value)\n"
764 " Add/Del an UDP/TCP type flow director filter.\n\n"
766 "flow_director_filter (port_id) mode IP (add|del|update)"
767 " flow (ipv4-sctp|ipv6-sctp)"
768 " src (src_ip_address) (src_port)"
769 " dst (dst_ip_address) (dst_port)"
770 " tag (verification_tag) "
771 " tos (tos_value) ttl (ttl_value)"
773 " flexbytes (flexbytes_value) (drop|fwd)"
774 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
775 " Add/Del a SCTP type flow director filter.\n\n"
777 "flow_director_filter (port_id) mode IP (add|del|update)"
778 " flow l2_payload ether (ethertype)"
779 " flexbytes (flexbytes_value) (drop|fwd)"
780 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
781 " Add/Del a l2 payload type flow director filter.\n\n"
783 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
784 " mac (mac_address) vlan (vlan_value)"
785 " flexbytes (flexbytes_value) (drop|fwd)"
786 " queue (queue_id) fd_id (fd_id_value)\n"
787 " Add/Del a MAC-VLAN flow director filter.\n\n"
789 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
790 " mac (mac_address) vlan (vlan_value)"
791 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
792 " flexbytes (flexbytes_value) (drop|fwd)"
793 " queue (queue_id) fd_id (fd_id_value)\n"
794 " Add/Del a Tunnel flow director filter.\n\n"
796 "flush_flow_director (port_id)\n"
797 " Flush all flow director entries of a device.\n\n"
799 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
800 " src_mask (ipv4_src) (ipv6_src) (src_port)"
801 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
802 " Set flow director IP mask.\n\n"
804 "flow_director_mask (port_id) mode MAC-VLAN"
805 " vlan (vlan_value)\n"
806 " Set flow director MAC-VLAN mask.\n\n"
808 "flow_director_mask (port_id) mode Tunnel"
809 " vlan (vlan_value) mac (mac_value)"
810 " tunnel-type (tunnel_type_value)"
811 " tunnel-id (tunnel_id_value)\n"
812 " Set flow director Tunnel mask.\n\n"
814 "flow_director_flex_mask (port_id)"
815 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
816 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
818 " Configure mask of flex payload.\n\n"
820 "flow_director_flex_payload (port_id)"
821 " (raw|l2|l3|l4) (config)\n"
822 " Configure flex payload selection.\n\n"
824 "get_sym_hash_ena_per_port (port_id)\n"
825 " get symmetric hash enable configuration per port.\n\n"
827 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
828 " set symmetric hash enable configuration per port"
829 " to enable or disable.\n\n"
831 "get_hash_global_config (port_id)\n"
832 " Get the global configurations of hash filters.\n\n"
834 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
835 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
836 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
837 " (enable|disable)\n"
838 " Set the global configurations of hash filters.\n\n"
840 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
841 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
842 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
843 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
844 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
845 "ipv6-next-header|udp-src-port|udp-dst-port|"
846 "tcp-src-port|tcp-dst-port|sctp-src-port|"
847 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
848 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
849 "fld-8th|none) (select|add)\n"
850 " Set the input set for hash.\n\n"
852 "set_fdir_input_set (port_id) "
853 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
854 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
855 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
856 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
857 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
858 "udp-dst-port|tcp-src-port|tcp-dst-port|"
859 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
861 " Set the input set for FDir.\n\n"
863 "flow validate {port_id}"
864 " [group {group_id}] [priority {level}]"
865 " [ingress] [egress]"
866 " pattern {item} [/ {item} [...]] / end"
867 " actions {action} [/ {action} [...]] / end\n"
868 " Check whether a flow rule can be created.\n\n"
870 "flow create {port_id}"
871 " [group {group_id}] [priority {level}]"
872 " [ingress] [egress]"
873 " pattern {item} [/ {item} [...]] / end"
874 " actions {action} [/ {action} [...]] / end\n"
875 " Create a flow rule.\n\n"
877 "flow destroy {port_id} rule {rule_id} [...]\n"
878 " Destroy specific flow rules.\n\n"
880 "flow flush {port_id}\n"
881 " Destroy all flow rules.\n\n"
883 "flow query {port_id} {rule_id} {action}\n"
884 " Query an existing flow rule.\n\n"
886 "flow list {port_id} [group {group_id}] [...]\n"
887 " List existing flow rules sorted by priority,"
888 " filtered by group identifiers.\n\n"
893 cmdline_parse_token_string_t cmd_help_long_help =
894 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
896 cmdline_parse_token_string_t cmd_help_long_section =
897 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
898 "all#control#display#config#"
899 "ports#registers#filters");
901 cmdline_parse_inst_t cmd_help_long = {
902 .f = cmd_help_long_parsed,
904 .help_str = "help all|control|display|config|ports|register|filters: "
907 (void *)&cmd_help_long_help,
908 (void *)&cmd_help_long_section,
914 /* *** start/stop/close all ports *** */
915 struct cmd_operate_port_result {
916 cmdline_fixed_string_t keyword;
917 cmdline_fixed_string_t name;
918 cmdline_fixed_string_t value;
921 static void cmd_operate_port_parsed(void *parsed_result,
922 __attribute__((unused)) struct cmdline *cl,
923 __attribute__((unused)) void *data)
925 struct cmd_operate_port_result *res = parsed_result;
927 if (!strcmp(res->name, "start"))
928 start_port(RTE_PORT_ALL);
929 else if (!strcmp(res->name, "stop"))
930 stop_port(RTE_PORT_ALL);
931 else if (!strcmp(res->name, "close"))
932 close_port(RTE_PORT_ALL);
934 printf("Unknown parameter\n");
937 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
938 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
940 cmdline_parse_token_string_t cmd_operate_port_all_port =
941 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
943 cmdline_parse_token_string_t cmd_operate_port_all_all =
944 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
946 cmdline_parse_inst_t cmd_operate_port = {
947 .f = cmd_operate_port_parsed,
949 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
951 (void *)&cmd_operate_port_all_cmd,
952 (void *)&cmd_operate_port_all_port,
953 (void *)&cmd_operate_port_all_all,
958 /* *** start/stop/close specific port *** */
959 struct cmd_operate_specific_port_result {
960 cmdline_fixed_string_t keyword;
961 cmdline_fixed_string_t name;
965 static void cmd_operate_specific_port_parsed(void *parsed_result,
966 __attribute__((unused)) struct cmdline *cl,
967 __attribute__((unused)) void *data)
969 struct cmd_operate_specific_port_result *res = parsed_result;
971 if (!strcmp(res->name, "start"))
972 start_port(res->value);
973 else if (!strcmp(res->name, "stop"))
974 stop_port(res->value);
975 else if (!strcmp(res->name, "close"))
976 close_port(res->value);
978 printf("Unknown parameter\n");
981 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
982 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
984 cmdline_parse_token_string_t cmd_operate_specific_port_port =
985 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
986 name, "start#stop#close");
987 cmdline_parse_token_num_t cmd_operate_specific_port_id =
988 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
991 cmdline_parse_inst_t cmd_operate_specific_port = {
992 .f = cmd_operate_specific_port_parsed,
994 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
996 (void *)&cmd_operate_specific_port_cmd,
997 (void *)&cmd_operate_specific_port_port,
998 (void *)&cmd_operate_specific_port_id,
1003 /* *** attach a specified port *** */
1004 struct cmd_operate_attach_port_result {
1005 cmdline_fixed_string_t port;
1006 cmdline_fixed_string_t keyword;
1007 cmdline_fixed_string_t identifier;
1010 static void cmd_operate_attach_port_parsed(void *parsed_result,
1011 __attribute__((unused)) struct cmdline *cl,
1012 __attribute__((unused)) void *data)
1014 struct cmd_operate_attach_port_result *res = parsed_result;
1016 if (!strcmp(res->keyword, "attach"))
1017 attach_port(res->identifier);
1019 printf("Unknown parameter\n");
1022 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1023 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1025 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1026 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1028 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1029 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1032 cmdline_parse_inst_t cmd_operate_attach_port = {
1033 .f = cmd_operate_attach_port_parsed,
1035 .help_str = "port attach <identifier>: "
1036 "(identifier: pci address or virtual dev name)",
1038 (void *)&cmd_operate_attach_port_port,
1039 (void *)&cmd_operate_attach_port_keyword,
1040 (void *)&cmd_operate_attach_port_identifier,
1045 /* *** detach a specified port *** */
1046 struct cmd_operate_detach_port_result {
1047 cmdline_fixed_string_t port;
1048 cmdline_fixed_string_t keyword;
1052 static void cmd_operate_detach_port_parsed(void *parsed_result,
1053 __attribute__((unused)) struct cmdline *cl,
1054 __attribute__((unused)) void *data)
1056 struct cmd_operate_detach_port_result *res = parsed_result;
1058 if (!strcmp(res->keyword, "detach"))
1059 detach_port(res->port_id);
1061 printf("Unknown parameter\n");
1064 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1065 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1067 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1068 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1070 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1071 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1074 cmdline_parse_inst_t cmd_operate_detach_port = {
1075 .f = cmd_operate_detach_port_parsed,
1077 .help_str = "port detach <port_id>",
1079 (void *)&cmd_operate_detach_port_port,
1080 (void *)&cmd_operate_detach_port_keyword,
1081 (void *)&cmd_operate_detach_port_port_id,
1086 /* *** configure speed for all ports *** */
1087 struct cmd_config_speed_all {
1088 cmdline_fixed_string_t port;
1089 cmdline_fixed_string_t keyword;
1090 cmdline_fixed_string_t all;
1091 cmdline_fixed_string_t item1;
1092 cmdline_fixed_string_t item2;
1093 cmdline_fixed_string_t value1;
1094 cmdline_fixed_string_t value2;
1098 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1103 if (!strcmp(duplexstr, "half")) {
1104 duplex = ETH_LINK_HALF_DUPLEX;
1105 } else if (!strcmp(duplexstr, "full")) {
1106 duplex = ETH_LINK_FULL_DUPLEX;
1107 } else if (!strcmp(duplexstr, "auto")) {
1108 duplex = ETH_LINK_FULL_DUPLEX;
1110 printf("Unknown duplex parameter\n");
1114 if (!strcmp(speedstr, "10")) {
1115 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1116 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1117 } else if (!strcmp(speedstr, "100")) {
1118 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1119 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1121 if (duplex != ETH_LINK_FULL_DUPLEX) {
1122 printf("Invalid speed/duplex parameters\n");
1125 if (!strcmp(speedstr, "1000")) {
1126 *speed = ETH_LINK_SPEED_1G;
1127 } else if (!strcmp(speedstr, "10000")) {
1128 *speed = ETH_LINK_SPEED_10G;
1129 } else if (!strcmp(speedstr, "25000")) {
1130 *speed = ETH_LINK_SPEED_25G;
1131 } else if (!strcmp(speedstr, "40000")) {
1132 *speed = ETH_LINK_SPEED_40G;
1133 } else if (!strcmp(speedstr, "50000")) {
1134 *speed = ETH_LINK_SPEED_50G;
1135 } else if (!strcmp(speedstr, "100000")) {
1136 *speed = ETH_LINK_SPEED_100G;
1137 } else if (!strcmp(speedstr, "auto")) {
1138 *speed = ETH_LINK_SPEED_AUTONEG;
1140 printf("Unknown speed parameter\n");
1149 cmd_config_speed_all_parsed(void *parsed_result,
1150 __attribute__((unused)) struct cmdline *cl,
1151 __attribute__((unused)) void *data)
1153 struct cmd_config_speed_all *res = parsed_result;
1154 uint32_t link_speed;
1157 if (!all_ports_stopped()) {
1158 printf("Please stop all ports first\n");
1162 if (parse_and_check_speed_duplex(res->value1, res->value2,
1166 FOREACH_PORT(pid, ports) {
1167 ports[pid].dev_conf.link_speeds = link_speed;
1170 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1173 cmdline_parse_token_string_t cmd_config_speed_all_port =
1174 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1175 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1176 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1178 cmdline_parse_token_string_t cmd_config_speed_all_all =
1179 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1180 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1181 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1182 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1183 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1184 "10#100#1000#10000#25000#40000#50000#100000#auto");
1185 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1186 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1187 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1188 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1191 cmdline_parse_inst_t cmd_config_speed_all = {
1192 .f = cmd_config_speed_all_parsed,
1194 .help_str = "port config all speed "
1195 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1198 (void *)&cmd_config_speed_all_port,
1199 (void *)&cmd_config_speed_all_keyword,
1200 (void *)&cmd_config_speed_all_all,
1201 (void *)&cmd_config_speed_all_item1,
1202 (void *)&cmd_config_speed_all_value1,
1203 (void *)&cmd_config_speed_all_item2,
1204 (void *)&cmd_config_speed_all_value2,
1209 /* *** configure speed for specific port *** */
1210 struct cmd_config_speed_specific {
1211 cmdline_fixed_string_t port;
1212 cmdline_fixed_string_t keyword;
1214 cmdline_fixed_string_t item1;
1215 cmdline_fixed_string_t item2;
1216 cmdline_fixed_string_t value1;
1217 cmdline_fixed_string_t value2;
1221 cmd_config_speed_specific_parsed(void *parsed_result,
1222 __attribute__((unused)) struct cmdline *cl,
1223 __attribute__((unused)) void *data)
1225 struct cmd_config_speed_specific *res = parsed_result;
1226 uint32_t link_speed;
1228 if (!all_ports_stopped()) {
1229 printf("Please stop all ports first\n");
1233 if (port_id_is_invalid(res->id, ENABLED_WARN))
1236 if (parse_and_check_speed_duplex(res->value1, res->value2,
1240 ports[res->id].dev_conf.link_speeds = link_speed;
1242 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1246 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1247 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1249 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1250 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1252 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1253 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1254 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1255 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1257 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1258 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1259 "10#100#1000#10000#25000#40000#50000#100000#auto");
1260 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1261 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1263 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1264 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1267 cmdline_parse_inst_t cmd_config_speed_specific = {
1268 .f = cmd_config_speed_specific_parsed,
1270 .help_str = "port config <port_id> speed "
1271 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1274 (void *)&cmd_config_speed_specific_port,
1275 (void *)&cmd_config_speed_specific_keyword,
1276 (void *)&cmd_config_speed_specific_id,
1277 (void *)&cmd_config_speed_specific_item1,
1278 (void *)&cmd_config_speed_specific_value1,
1279 (void *)&cmd_config_speed_specific_item2,
1280 (void *)&cmd_config_speed_specific_value2,
1285 /* *** configure txq/rxq, txd/rxd *** */
1286 struct cmd_config_rx_tx {
1287 cmdline_fixed_string_t port;
1288 cmdline_fixed_string_t keyword;
1289 cmdline_fixed_string_t all;
1290 cmdline_fixed_string_t name;
1295 cmd_config_rx_tx_parsed(void *parsed_result,
1296 __attribute__((unused)) struct cmdline *cl,
1297 __attribute__((unused)) void *data)
1299 struct cmd_config_rx_tx *res = parsed_result;
1301 if (!all_ports_stopped()) {
1302 printf("Please stop all ports first\n");
1305 if (!strcmp(res->name, "rxq")) {
1306 if (!res->value && !nb_txq) {
1307 printf("Warning: Either rx or tx queues should be non zero\n");
1310 nb_rxq = res->value;
1312 else if (!strcmp(res->name, "txq")) {
1313 if (!res->value && !nb_rxq) {
1314 printf("Warning: Either rx or tx queues should be non zero\n");
1317 nb_txq = res->value;
1319 else if (!strcmp(res->name, "rxd")) {
1320 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1321 printf("rxd %d invalid - must be > 0 && <= %d\n",
1322 res->value, RTE_TEST_RX_DESC_MAX);
1325 nb_rxd = res->value;
1326 } else if (!strcmp(res->name, "txd")) {
1327 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1328 printf("txd %d invalid - must be > 0 && <= %d\n",
1329 res->value, RTE_TEST_TX_DESC_MAX);
1332 nb_txd = res->value;
1334 printf("Unknown parameter\n");
1342 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1345 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1346 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1347 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1348 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1349 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1350 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1351 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1352 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1354 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1355 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1357 cmdline_parse_inst_t cmd_config_rx_tx = {
1358 .f = cmd_config_rx_tx_parsed,
1360 .help_str = "port config all rxq|txq|rxd|txd <value>",
1362 (void *)&cmd_config_rx_tx_port,
1363 (void *)&cmd_config_rx_tx_keyword,
1364 (void *)&cmd_config_rx_tx_all,
1365 (void *)&cmd_config_rx_tx_name,
1366 (void *)&cmd_config_rx_tx_value,
1371 /* *** config max packet length *** */
1372 struct cmd_config_max_pkt_len_result {
1373 cmdline_fixed_string_t port;
1374 cmdline_fixed_string_t keyword;
1375 cmdline_fixed_string_t all;
1376 cmdline_fixed_string_t name;
1381 cmd_config_max_pkt_len_parsed(void *parsed_result,
1382 __attribute__((unused)) struct cmdline *cl,
1383 __attribute__((unused)) void *data)
1385 struct cmd_config_max_pkt_len_result *res = parsed_result;
1387 if (!all_ports_stopped()) {
1388 printf("Please stop all ports first\n");
1392 if (!strcmp(res->name, "max-pkt-len")) {
1393 if (res->value < ETHER_MIN_LEN) {
1394 printf("max-pkt-len can not be less than %d\n",
1398 if (res->value == rx_mode.max_rx_pkt_len)
1401 rx_mode.max_rx_pkt_len = res->value;
1402 if (res->value > ETHER_MAX_LEN)
1403 rx_mode.jumbo_frame = 1;
1405 rx_mode.jumbo_frame = 0;
1407 printf("Unknown parameter\n");
1413 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1416 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1417 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1419 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1420 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1422 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1423 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1425 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1426 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1428 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1429 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1432 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1433 .f = cmd_config_max_pkt_len_parsed,
1435 .help_str = "port config all max-pkt-len <value>",
1437 (void *)&cmd_config_max_pkt_len_port,
1438 (void *)&cmd_config_max_pkt_len_keyword,
1439 (void *)&cmd_config_max_pkt_len_all,
1440 (void *)&cmd_config_max_pkt_len_name,
1441 (void *)&cmd_config_max_pkt_len_value,
1446 /* *** configure port MTU *** */
1447 struct cmd_config_mtu_result {
1448 cmdline_fixed_string_t port;
1449 cmdline_fixed_string_t keyword;
1450 cmdline_fixed_string_t mtu;
1456 cmd_config_mtu_parsed(void *parsed_result,
1457 __attribute__((unused)) struct cmdline *cl,
1458 __attribute__((unused)) void *data)
1460 struct cmd_config_mtu_result *res = parsed_result;
1462 if (res->value < ETHER_MIN_LEN) {
1463 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1466 port_mtu_set(res->port_id, res->value);
1469 cmdline_parse_token_string_t cmd_config_mtu_port =
1470 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1472 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1473 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1475 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1476 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1478 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1479 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1480 cmdline_parse_token_num_t cmd_config_mtu_value =
1481 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1483 cmdline_parse_inst_t cmd_config_mtu = {
1484 .f = cmd_config_mtu_parsed,
1486 .help_str = "port config mtu <port_id> <value>",
1488 (void *)&cmd_config_mtu_port,
1489 (void *)&cmd_config_mtu_keyword,
1490 (void *)&cmd_config_mtu_mtu,
1491 (void *)&cmd_config_mtu_port_id,
1492 (void *)&cmd_config_mtu_value,
1497 /* *** configure rx mode *** */
1498 struct cmd_config_rx_mode_flag {
1499 cmdline_fixed_string_t port;
1500 cmdline_fixed_string_t keyword;
1501 cmdline_fixed_string_t all;
1502 cmdline_fixed_string_t name;
1503 cmdline_fixed_string_t value;
1507 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1508 __attribute__((unused)) struct cmdline *cl,
1509 __attribute__((unused)) void *data)
1511 struct cmd_config_rx_mode_flag *res = parsed_result;
1513 if (!all_ports_stopped()) {
1514 printf("Please stop all ports first\n");
1518 if (!strcmp(res->name, "crc-strip")) {
1519 if (!strcmp(res->value, "on"))
1520 rx_mode.hw_strip_crc = 1;
1521 else if (!strcmp(res->value, "off"))
1522 rx_mode.hw_strip_crc = 0;
1524 printf("Unknown parameter\n");
1527 } else if (!strcmp(res->name, "scatter")) {
1528 if (!strcmp(res->value, "on"))
1529 rx_mode.enable_scatter = 1;
1530 else if (!strcmp(res->value, "off"))
1531 rx_mode.enable_scatter = 0;
1533 printf("Unknown parameter\n");
1536 } else if (!strcmp(res->name, "rx-cksum")) {
1537 if (!strcmp(res->value, "on"))
1538 rx_mode.hw_ip_checksum = 1;
1539 else if (!strcmp(res->value, "off"))
1540 rx_mode.hw_ip_checksum = 0;
1542 printf("Unknown parameter\n");
1545 } else if (!strcmp(res->name, "hw-vlan")) {
1546 if (!strcmp(res->value, "on")) {
1547 rx_mode.hw_vlan_filter = 1;
1548 rx_mode.hw_vlan_strip = 1;
1550 else if (!strcmp(res->value, "off")) {
1551 rx_mode.hw_vlan_filter = 0;
1552 rx_mode.hw_vlan_strip = 0;
1555 printf("Unknown parameter\n");
1558 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1559 if (!strcmp(res->value, "on"))
1560 rx_mode.hw_vlan_filter = 1;
1561 else if (!strcmp(res->value, "off"))
1562 rx_mode.hw_vlan_filter = 0;
1564 printf("Unknown parameter\n");
1567 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1568 if (!strcmp(res->value, "on"))
1569 rx_mode.hw_vlan_strip = 1;
1570 else if (!strcmp(res->value, "off"))
1571 rx_mode.hw_vlan_strip = 0;
1573 printf("Unknown parameter\n");
1576 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1577 if (!strcmp(res->value, "on"))
1578 rx_mode.hw_vlan_extend = 1;
1579 else if (!strcmp(res->value, "off"))
1580 rx_mode.hw_vlan_extend = 0;
1582 printf("Unknown parameter\n");
1585 } else if (!strcmp(res->name, "drop-en")) {
1586 if (!strcmp(res->value, "on"))
1588 else if (!strcmp(res->value, "off"))
1591 printf("Unknown parameter\n");
1595 printf("Unknown parameter\n");
1601 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1604 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1605 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1606 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1607 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1609 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1610 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1611 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1612 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1613 "crc-strip#scatter#rx-cksum#hw-vlan#"
1614 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1615 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1616 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1619 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1620 .f = cmd_config_rx_mode_flag_parsed,
1622 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1623 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1625 (void *)&cmd_config_rx_mode_flag_port,
1626 (void *)&cmd_config_rx_mode_flag_keyword,
1627 (void *)&cmd_config_rx_mode_flag_all,
1628 (void *)&cmd_config_rx_mode_flag_name,
1629 (void *)&cmd_config_rx_mode_flag_value,
1634 /* *** configure rss *** */
1635 struct cmd_config_rss {
1636 cmdline_fixed_string_t port;
1637 cmdline_fixed_string_t keyword;
1638 cmdline_fixed_string_t all;
1639 cmdline_fixed_string_t name;
1640 cmdline_fixed_string_t value;
1644 cmd_config_rss_parsed(void *parsed_result,
1645 __attribute__((unused)) struct cmdline *cl,
1646 __attribute__((unused)) void *data)
1648 struct cmd_config_rss *res = parsed_result;
1649 struct rte_eth_rss_conf rss_conf;
1653 if (!strcmp(res->value, "all"))
1654 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1655 ETH_RSS_UDP | ETH_RSS_SCTP |
1657 else if (!strcmp(res->value, "ip"))
1658 rss_conf.rss_hf = ETH_RSS_IP;
1659 else if (!strcmp(res->value, "udp"))
1660 rss_conf.rss_hf = ETH_RSS_UDP;
1661 else if (!strcmp(res->value, "tcp"))
1662 rss_conf.rss_hf = ETH_RSS_TCP;
1663 else if (!strcmp(res->value, "sctp"))
1664 rss_conf.rss_hf = ETH_RSS_SCTP;
1665 else if (!strcmp(res->value, "ether"))
1666 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1667 else if (!strcmp(res->value, "port"))
1668 rss_conf.rss_hf = ETH_RSS_PORT;
1669 else if (!strcmp(res->value, "vxlan"))
1670 rss_conf.rss_hf = ETH_RSS_VXLAN;
1671 else if (!strcmp(res->value, "geneve"))
1672 rss_conf.rss_hf = ETH_RSS_GENEVE;
1673 else if (!strcmp(res->value, "nvgre"))
1674 rss_conf.rss_hf = ETH_RSS_NVGRE;
1675 else if (!strcmp(res->value, "none"))
1676 rss_conf.rss_hf = 0;
1678 printf("Unknown parameter\n");
1681 rss_conf.rss_key = NULL;
1682 for (i = 0; i < rte_eth_dev_count(); i++) {
1683 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1685 printf("Configuration of RSS hash at ethernet port %d "
1686 "failed with error (%d): %s.\n",
1687 i, -diag, strerror(-diag));
1691 cmdline_parse_token_string_t cmd_config_rss_port =
1692 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1693 cmdline_parse_token_string_t cmd_config_rss_keyword =
1694 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1695 cmdline_parse_token_string_t cmd_config_rss_all =
1696 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1697 cmdline_parse_token_string_t cmd_config_rss_name =
1698 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1699 cmdline_parse_token_string_t cmd_config_rss_value =
1700 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1701 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1703 cmdline_parse_inst_t cmd_config_rss = {
1704 .f = cmd_config_rss_parsed,
1706 .help_str = "port config all rss "
1707 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1709 (void *)&cmd_config_rss_port,
1710 (void *)&cmd_config_rss_keyword,
1711 (void *)&cmd_config_rss_all,
1712 (void *)&cmd_config_rss_name,
1713 (void *)&cmd_config_rss_value,
1718 /* *** configure rss hash key *** */
1719 struct cmd_config_rss_hash_key {
1720 cmdline_fixed_string_t port;
1721 cmdline_fixed_string_t config;
1723 cmdline_fixed_string_t rss_hash_key;
1724 cmdline_fixed_string_t rss_type;
1725 cmdline_fixed_string_t key;
1729 hexa_digit_to_value(char hexa_digit)
1731 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1732 return (uint8_t) (hexa_digit - '0');
1733 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1734 return (uint8_t) ((hexa_digit - 'a') + 10);
1735 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1736 return (uint8_t) ((hexa_digit - 'A') + 10);
1737 /* Invalid hexa digit */
1742 parse_and_check_key_hexa_digit(char *key, int idx)
1746 hexa_v = hexa_digit_to_value(key[idx]);
1748 printf("invalid key: character %c at position %d is not a "
1749 "valid hexa digit\n", key[idx], idx);
1754 cmd_config_rss_hash_key_parsed(void *parsed_result,
1755 __attribute__((unused)) struct cmdline *cl,
1756 __attribute__((unused)) void *data)
1758 struct cmd_config_rss_hash_key *res = parsed_result;
1759 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1763 struct rte_eth_dev_info dev_info;
1764 uint8_t hash_key_size;
1767 memset(&dev_info, 0, sizeof(dev_info));
1768 rte_eth_dev_info_get(res->port_id, &dev_info);
1769 if (dev_info.hash_key_size > 0 &&
1770 dev_info.hash_key_size <= sizeof(hash_key))
1771 hash_key_size = dev_info.hash_key_size;
1773 printf("dev_info did not provide a valid hash key size\n");
1776 /* Check the length of the RSS hash key */
1777 key_len = strlen(res->key);
1778 if (key_len != (hash_key_size * 2)) {
1779 printf("key length: %d invalid - key must be a string of %d"
1780 " hexa-decimal numbers\n",
1781 (int) key_len, hash_key_size * 2);
1784 /* Translate RSS hash key into binary representation */
1785 for (i = 0; i < hash_key_size; i++) {
1786 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1789 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1792 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1794 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1798 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1799 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1800 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1801 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1803 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1804 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1805 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1806 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1807 rss_hash_key, "rss-hash-key");
1808 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1809 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1810 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1811 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1812 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1813 "ipv6-tcp-ex#ipv6-udp-ex");
1814 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1815 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1817 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1818 .f = cmd_config_rss_hash_key_parsed,
1820 .help_str = "port config <port_id> rss-hash-key "
1821 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1822 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1823 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1824 "<string of hex digits (variable length, NIC dependent)>",
1826 (void *)&cmd_config_rss_hash_key_port,
1827 (void *)&cmd_config_rss_hash_key_config,
1828 (void *)&cmd_config_rss_hash_key_port_id,
1829 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1830 (void *)&cmd_config_rss_hash_key_rss_type,
1831 (void *)&cmd_config_rss_hash_key_value,
1836 /* *** configure port rxq/txq start/stop *** */
1837 struct cmd_config_rxtx_queue {
1838 cmdline_fixed_string_t port;
1840 cmdline_fixed_string_t rxtxq;
1842 cmdline_fixed_string_t opname;
1846 cmd_config_rxtx_queue_parsed(void *parsed_result,
1847 __attribute__((unused)) struct cmdline *cl,
1848 __attribute__((unused)) void *data)
1850 struct cmd_config_rxtx_queue *res = parsed_result;
1855 if (test_done == 0) {
1856 printf("Please stop forwarding first\n");
1860 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1863 if (port_is_started(res->portid) != 1) {
1864 printf("Please start port %u first\n", res->portid);
1868 if (!strcmp(res->rxtxq, "rxq"))
1870 else if (!strcmp(res->rxtxq, "txq"))
1873 printf("Unknown parameter\n");
1877 if (isrx && rx_queue_id_is_invalid(res->qid))
1879 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1882 if (!strcmp(res->opname, "start"))
1884 else if (!strcmp(res->opname, "stop"))
1887 printf("Unknown parameter\n");
1891 if (isstart && isrx)
1892 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1893 else if (!isstart && isrx)
1894 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1895 else if (isstart && !isrx)
1896 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1898 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1900 if (ret == -ENOTSUP)
1901 printf("Function not supported in PMD driver\n");
1904 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1905 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1906 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1907 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1908 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1909 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1910 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1911 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1912 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1913 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1916 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1917 .f = cmd_config_rxtx_queue_parsed,
1919 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1921 (void *)&cmd_config_speed_all_port,
1922 (void *)&cmd_config_rxtx_queue_portid,
1923 (void *)&cmd_config_rxtx_queue_rxtxq,
1924 (void *)&cmd_config_rxtx_queue_qid,
1925 (void *)&cmd_config_rxtx_queue_opname,
1930 /* *** Configure RSS RETA *** */
1931 struct cmd_config_rss_reta {
1932 cmdline_fixed_string_t port;
1933 cmdline_fixed_string_t keyword;
1935 cmdline_fixed_string_t name;
1936 cmdline_fixed_string_t list_name;
1937 cmdline_fixed_string_t list_of_items;
1941 parse_reta_config(const char *str,
1942 struct rte_eth_rss_reta_entry64 *reta_conf,
1943 uint16_t nb_entries)
1947 uint16_t hash_index, idx, shift;
1950 const char *p, *p0 = str;
1957 unsigned long int_fld[_NUM_FLD];
1958 char *str_fld[_NUM_FLD];
1960 while ((p = strchr(p0,'(')) != NULL) {
1962 if((p0 = strchr(p,')')) == NULL)
1966 if(size >= sizeof(s))
1969 snprintf(s, sizeof(s), "%.*s", size, p);
1970 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1972 for (i = 0; i < _NUM_FLD; i++) {
1974 int_fld[i] = strtoul(str_fld[i], &end, 0);
1975 if (errno != 0 || end == str_fld[i] ||
1980 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1981 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1983 if (hash_index >= nb_entries) {
1984 printf("Invalid RETA hash index=%d\n", hash_index);
1988 idx = hash_index / RTE_RETA_GROUP_SIZE;
1989 shift = hash_index % RTE_RETA_GROUP_SIZE;
1990 reta_conf[idx].mask |= (1ULL << shift);
1991 reta_conf[idx].reta[shift] = nb_queue;
1998 cmd_set_rss_reta_parsed(void *parsed_result,
1999 __attribute__((unused)) struct cmdline *cl,
2000 __attribute__((unused)) void *data)
2003 struct rte_eth_dev_info dev_info;
2004 struct rte_eth_rss_reta_entry64 reta_conf[8];
2005 struct cmd_config_rss_reta *res = parsed_result;
2007 memset(&dev_info, 0, sizeof(dev_info));
2008 rte_eth_dev_info_get(res->port_id, &dev_info);
2009 if (dev_info.reta_size == 0) {
2010 printf("Redirection table size is 0 which is "
2011 "invalid for RSS\n");
2014 printf("The reta size of port %d is %u\n",
2015 res->port_id, dev_info.reta_size);
2016 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2017 printf("Currently do not support more than %u entries of "
2018 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2022 memset(reta_conf, 0, sizeof(reta_conf));
2023 if (!strcmp(res->list_name, "reta")) {
2024 if (parse_reta_config(res->list_of_items, reta_conf,
2025 dev_info.reta_size)) {
2026 printf("Invalid RSS Redirection Table "
2027 "config entered\n");
2030 ret = rte_eth_dev_rss_reta_update(res->port_id,
2031 reta_conf, dev_info.reta_size);
2033 printf("Bad redirection table parameter, "
2034 "return code = %d \n", ret);
2038 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2039 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2040 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2041 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2042 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2043 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2044 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2045 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2046 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2047 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2048 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2049 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2051 cmdline_parse_inst_t cmd_config_rss_reta = {
2052 .f = cmd_set_rss_reta_parsed,
2054 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2056 (void *)&cmd_config_rss_reta_port,
2057 (void *)&cmd_config_rss_reta_keyword,
2058 (void *)&cmd_config_rss_reta_port_id,
2059 (void *)&cmd_config_rss_reta_name,
2060 (void *)&cmd_config_rss_reta_list_name,
2061 (void *)&cmd_config_rss_reta_list_of_items,
2066 /* *** SHOW PORT RETA INFO *** */
2067 struct cmd_showport_reta {
2068 cmdline_fixed_string_t show;
2069 cmdline_fixed_string_t port;
2071 cmdline_fixed_string_t rss;
2072 cmdline_fixed_string_t reta;
2074 cmdline_fixed_string_t list_of_items;
2078 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2079 uint16_t nb_entries,
2083 const char *p, *p0 = str;
2088 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2089 RTE_RETA_GROUP_SIZE;
2092 p = strchr(p0, '(');
2096 p0 = strchr(p, ')');
2100 if (size >= sizeof(s)) {
2101 printf("The string size exceeds the internal buffer size\n");
2104 snprintf(s, sizeof(s), "%.*s", size, p);
2105 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2106 if (ret <= 0 || ret != num) {
2107 printf("The bits of masks do not match the number of "
2108 "reta entries: %u\n", num);
2111 for (i = 0; i < ret; i++)
2112 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2118 cmd_showport_reta_parsed(void *parsed_result,
2119 __attribute__((unused)) struct cmdline *cl,
2120 __attribute__((unused)) void *data)
2122 struct cmd_showport_reta *res = parsed_result;
2123 struct rte_eth_rss_reta_entry64 reta_conf[8];
2124 struct rte_eth_dev_info dev_info;
2126 memset(&dev_info, 0, sizeof(dev_info));
2127 rte_eth_dev_info_get(res->port_id, &dev_info);
2128 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2129 res->size > ETH_RSS_RETA_SIZE_512) {
2130 printf("Invalid redirection table size: %u\n", res->size);
2134 memset(reta_conf, 0, sizeof(reta_conf));
2135 if (showport_parse_reta_config(reta_conf, res->size,
2136 res->list_of_items) < 0) {
2137 printf("Invalid string: %s for reta masks\n",
2138 res->list_of_items);
2141 port_rss_reta_info(res->port_id, reta_conf, res->size);
2144 cmdline_parse_token_string_t cmd_showport_reta_show =
2145 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2146 cmdline_parse_token_string_t cmd_showport_reta_port =
2147 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2148 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2149 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2150 cmdline_parse_token_string_t cmd_showport_reta_rss =
2151 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2152 cmdline_parse_token_string_t cmd_showport_reta_reta =
2153 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2154 cmdline_parse_token_num_t cmd_showport_reta_size =
2155 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2156 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2157 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2158 list_of_items, NULL);
2160 cmdline_parse_inst_t cmd_showport_reta = {
2161 .f = cmd_showport_reta_parsed,
2163 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2165 (void *)&cmd_showport_reta_show,
2166 (void *)&cmd_showport_reta_port,
2167 (void *)&cmd_showport_reta_port_id,
2168 (void *)&cmd_showport_reta_rss,
2169 (void *)&cmd_showport_reta_reta,
2170 (void *)&cmd_showport_reta_size,
2171 (void *)&cmd_showport_reta_list_of_items,
2176 /* *** Show RSS hash configuration *** */
2177 struct cmd_showport_rss_hash {
2178 cmdline_fixed_string_t show;
2179 cmdline_fixed_string_t port;
2181 cmdline_fixed_string_t rss_hash;
2182 cmdline_fixed_string_t rss_type;
2183 cmdline_fixed_string_t key; /* optional argument */
2186 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2187 __attribute__((unused)) struct cmdline *cl,
2190 struct cmd_showport_rss_hash *res = parsed_result;
2192 port_rss_hash_conf_show(res->port_id, res->rss_type,
2193 show_rss_key != NULL);
2196 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2197 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2198 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2199 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2200 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2201 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2202 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2203 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2205 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2206 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2207 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2208 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2209 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2210 "ipv6-tcp-ex#ipv6-udp-ex");
2211 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2212 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2214 cmdline_parse_inst_t cmd_showport_rss_hash = {
2215 .f = cmd_showport_rss_hash_parsed,
2217 .help_str = "show port <port_id> rss-hash "
2218 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2219 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2220 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2222 (void *)&cmd_showport_rss_hash_show,
2223 (void *)&cmd_showport_rss_hash_port,
2224 (void *)&cmd_showport_rss_hash_port_id,
2225 (void *)&cmd_showport_rss_hash_rss_hash,
2226 (void *)&cmd_showport_rss_hash_rss_hash_info,
2231 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2232 .f = cmd_showport_rss_hash_parsed,
2234 .help_str = "show port <port_id> rss-hash "
2235 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2236 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2237 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2239 (void *)&cmd_showport_rss_hash_show,
2240 (void *)&cmd_showport_rss_hash_port,
2241 (void *)&cmd_showport_rss_hash_port_id,
2242 (void *)&cmd_showport_rss_hash_rss_hash,
2243 (void *)&cmd_showport_rss_hash_rss_hash_info,
2244 (void *)&cmd_showport_rss_hash_rss_key,
2249 /* *** Configure DCB *** */
2250 struct cmd_config_dcb {
2251 cmdline_fixed_string_t port;
2252 cmdline_fixed_string_t config;
2254 cmdline_fixed_string_t dcb;
2255 cmdline_fixed_string_t vt;
2256 cmdline_fixed_string_t vt_en;
2258 cmdline_fixed_string_t pfc;
2259 cmdline_fixed_string_t pfc_en;
2263 cmd_config_dcb_parsed(void *parsed_result,
2264 __attribute__((unused)) struct cmdline *cl,
2265 __attribute__((unused)) void *data)
2267 struct cmd_config_dcb *res = parsed_result;
2268 portid_t port_id = res->port_id;
2269 struct rte_port *port;
2273 port = &ports[port_id];
2274 /** Check if the port is not started **/
2275 if (port->port_status != RTE_PORT_STOPPED) {
2276 printf("Please stop port %d first\n", port_id);
2280 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2281 printf("The invalid number of traffic class,"
2282 " only 4 or 8 allowed.\n");
2286 if (nb_fwd_lcores < res->num_tcs) {
2287 printf("nb_cores shouldn't be less than number of TCs.\n");
2290 if (!strncmp(res->pfc_en, "on", 2))
2295 /* DCB in VT mode */
2296 if (!strncmp(res->vt_en, "on", 2))
2297 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2298 (enum rte_eth_nb_tcs)res->num_tcs,
2301 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2302 (enum rte_eth_nb_tcs)res->num_tcs,
2307 printf("Cannot initialize network ports.\n");
2311 cmd_reconfig_device_queue(port_id, 1, 1);
2314 cmdline_parse_token_string_t cmd_config_dcb_port =
2315 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2316 cmdline_parse_token_string_t cmd_config_dcb_config =
2317 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2318 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2319 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2320 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2321 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2322 cmdline_parse_token_string_t cmd_config_dcb_vt =
2323 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2324 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2325 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2326 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2327 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2328 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2329 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2330 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2331 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2333 cmdline_parse_inst_t cmd_config_dcb = {
2334 .f = cmd_config_dcb_parsed,
2336 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2338 (void *)&cmd_config_dcb_port,
2339 (void *)&cmd_config_dcb_config,
2340 (void *)&cmd_config_dcb_port_id,
2341 (void *)&cmd_config_dcb_dcb,
2342 (void *)&cmd_config_dcb_vt,
2343 (void *)&cmd_config_dcb_vt_en,
2344 (void *)&cmd_config_dcb_num_tcs,
2345 (void *)&cmd_config_dcb_pfc,
2346 (void *)&cmd_config_dcb_pfc_en,
2351 /* *** configure number of packets per burst *** */
2352 struct cmd_config_burst {
2353 cmdline_fixed_string_t port;
2354 cmdline_fixed_string_t keyword;
2355 cmdline_fixed_string_t all;
2356 cmdline_fixed_string_t name;
2361 cmd_config_burst_parsed(void *parsed_result,
2362 __attribute__((unused)) struct cmdline *cl,
2363 __attribute__((unused)) void *data)
2365 struct cmd_config_burst *res = parsed_result;
2367 if (!all_ports_stopped()) {
2368 printf("Please stop all ports first\n");
2372 if (!strcmp(res->name, "burst")) {
2373 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2374 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2377 nb_pkt_per_burst = res->value;
2379 printf("Unknown parameter\n");
2385 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2388 cmdline_parse_token_string_t cmd_config_burst_port =
2389 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2390 cmdline_parse_token_string_t cmd_config_burst_keyword =
2391 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2392 cmdline_parse_token_string_t cmd_config_burst_all =
2393 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2394 cmdline_parse_token_string_t cmd_config_burst_name =
2395 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2396 cmdline_parse_token_num_t cmd_config_burst_value =
2397 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2399 cmdline_parse_inst_t cmd_config_burst = {
2400 .f = cmd_config_burst_parsed,
2402 .help_str = "port config all burst <value>",
2404 (void *)&cmd_config_burst_port,
2405 (void *)&cmd_config_burst_keyword,
2406 (void *)&cmd_config_burst_all,
2407 (void *)&cmd_config_burst_name,
2408 (void *)&cmd_config_burst_value,
2413 /* *** configure rx/tx queues *** */
2414 struct cmd_config_thresh {
2415 cmdline_fixed_string_t port;
2416 cmdline_fixed_string_t keyword;
2417 cmdline_fixed_string_t all;
2418 cmdline_fixed_string_t name;
2423 cmd_config_thresh_parsed(void *parsed_result,
2424 __attribute__((unused)) struct cmdline *cl,
2425 __attribute__((unused)) void *data)
2427 struct cmd_config_thresh *res = parsed_result;
2429 if (!all_ports_stopped()) {
2430 printf("Please stop all ports first\n");
2434 if (!strcmp(res->name, "txpt"))
2435 tx_pthresh = res->value;
2436 else if(!strcmp(res->name, "txht"))
2437 tx_hthresh = res->value;
2438 else if(!strcmp(res->name, "txwt"))
2439 tx_wthresh = res->value;
2440 else if(!strcmp(res->name, "rxpt"))
2441 rx_pthresh = res->value;
2442 else if(!strcmp(res->name, "rxht"))
2443 rx_hthresh = res->value;
2444 else if(!strcmp(res->name, "rxwt"))
2445 rx_wthresh = res->value;
2447 printf("Unknown parameter\n");
2453 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2456 cmdline_parse_token_string_t cmd_config_thresh_port =
2457 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2458 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2459 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2460 cmdline_parse_token_string_t cmd_config_thresh_all =
2461 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2462 cmdline_parse_token_string_t cmd_config_thresh_name =
2463 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2464 "txpt#txht#txwt#rxpt#rxht#rxwt");
2465 cmdline_parse_token_num_t cmd_config_thresh_value =
2466 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2468 cmdline_parse_inst_t cmd_config_thresh = {
2469 .f = cmd_config_thresh_parsed,
2471 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2473 (void *)&cmd_config_thresh_port,
2474 (void *)&cmd_config_thresh_keyword,
2475 (void *)&cmd_config_thresh_all,
2476 (void *)&cmd_config_thresh_name,
2477 (void *)&cmd_config_thresh_value,
2482 /* *** configure free/rs threshold *** */
2483 struct cmd_config_threshold {
2484 cmdline_fixed_string_t port;
2485 cmdline_fixed_string_t keyword;
2486 cmdline_fixed_string_t all;
2487 cmdline_fixed_string_t name;
2492 cmd_config_threshold_parsed(void *parsed_result,
2493 __attribute__((unused)) struct cmdline *cl,
2494 __attribute__((unused)) void *data)
2496 struct cmd_config_threshold *res = parsed_result;
2498 if (!all_ports_stopped()) {
2499 printf("Please stop all ports first\n");
2503 if (!strcmp(res->name, "txfreet"))
2504 tx_free_thresh = res->value;
2505 else if (!strcmp(res->name, "txrst"))
2506 tx_rs_thresh = res->value;
2507 else if (!strcmp(res->name, "rxfreet"))
2508 rx_free_thresh = res->value;
2510 printf("Unknown parameter\n");
2516 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2519 cmdline_parse_token_string_t cmd_config_threshold_port =
2520 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2521 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2522 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2524 cmdline_parse_token_string_t cmd_config_threshold_all =
2525 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2526 cmdline_parse_token_string_t cmd_config_threshold_name =
2527 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2528 "txfreet#txrst#rxfreet");
2529 cmdline_parse_token_num_t cmd_config_threshold_value =
2530 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2532 cmdline_parse_inst_t cmd_config_threshold = {
2533 .f = cmd_config_threshold_parsed,
2535 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2537 (void *)&cmd_config_threshold_port,
2538 (void *)&cmd_config_threshold_keyword,
2539 (void *)&cmd_config_threshold_all,
2540 (void *)&cmd_config_threshold_name,
2541 (void *)&cmd_config_threshold_value,
2547 struct cmd_stop_result {
2548 cmdline_fixed_string_t stop;
2551 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2552 __attribute__((unused)) struct cmdline *cl,
2553 __attribute__((unused)) void *data)
2555 stop_packet_forwarding();
2558 cmdline_parse_token_string_t cmd_stop_stop =
2559 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2561 cmdline_parse_inst_t cmd_stop = {
2562 .f = cmd_stop_parsed,
2564 .help_str = "stop: Stop packet forwarding",
2566 (void *)&cmd_stop_stop,
2571 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2574 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2575 unsigned int *parsed_items, int check_unique_values)
2577 unsigned int nb_item;
2585 * First parse all items in the list and store their value.
2590 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2592 if ((c >= '0') && (c <= '9')) {
2593 value = (unsigned int) (value * 10 + (c - '0'));
2598 printf("character %c is not a decimal digit\n", c);
2602 printf("No valid value before comma\n");
2605 if (nb_item < max_items) {
2606 parsed_items[nb_item] = value;
2612 if (nb_item >= max_items) {
2613 printf("Number of %s = %u > %u (maximum items)\n",
2614 item_name, nb_item + 1, max_items);
2617 parsed_items[nb_item++] = value;
2618 if (! check_unique_values)
2622 * Then, check that all values in the list are differents.
2623 * No optimization here...
2625 for (i = 0; i < nb_item; i++) {
2626 for (j = i + 1; j < nb_item; j++) {
2627 if (parsed_items[j] == parsed_items[i]) {
2628 printf("duplicated %s %u at index %u and %u\n",
2629 item_name, parsed_items[i], i, j);
2637 struct cmd_set_list_result {
2638 cmdline_fixed_string_t cmd_keyword;
2639 cmdline_fixed_string_t list_name;
2640 cmdline_fixed_string_t list_of_items;
2643 static void cmd_set_list_parsed(void *parsed_result,
2644 __attribute__((unused)) struct cmdline *cl,
2645 __attribute__((unused)) void *data)
2647 struct cmd_set_list_result *res;
2649 unsigned int lcorelist[RTE_MAX_LCORE];
2650 unsigned int portlist[RTE_MAX_ETHPORTS];
2652 unsigned int nb_item;
2654 if (test_done == 0) {
2655 printf("Please stop forwarding first\n");
2659 res = parsed_result;
2660 if (!strcmp(res->list_name, "corelist")) {
2661 nb_item = parse_item_list(res->list_of_items, "core",
2663 parsed_items.lcorelist, 1);
2665 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2670 if (!strcmp(res->list_name, "portlist")) {
2671 nb_item = parse_item_list(res->list_of_items, "port",
2673 parsed_items.portlist, 1);
2675 set_fwd_ports_list(parsed_items.portlist, nb_item);
2681 cmdline_parse_token_string_t cmd_set_list_keyword =
2682 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2684 cmdline_parse_token_string_t cmd_set_list_name =
2685 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2686 "corelist#portlist");
2687 cmdline_parse_token_string_t cmd_set_list_of_items =
2688 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2691 cmdline_parse_inst_t cmd_set_fwd_list = {
2692 .f = cmd_set_list_parsed,
2694 .help_str = "set corelist|portlist <list0[,list1]*>",
2696 (void *)&cmd_set_list_keyword,
2697 (void *)&cmd_set_list_name,
2698 (void *)&cmd_set_list_of_items,
2703 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2705 struct cmd_setmask_result {
2706 cmdline_fixed_string_t set;
2707 cmdline_fixed_string_t mask;
2711 static void cmd_set_mask_parsed(void *parsed_result,
2712 __attribute__((unused)) struct cmdline *cl,
2713 __attribute__((unused)) void *data)
2715 struct cmd_setmask_result *res = parsed_result;
2717 if (test_done == 0) {
2718 printf("Please stop forwarding first\n");
2721 if (!strcmp(res->mask, "coremask")) {
2722 set_fwd_lcores_mask(res->hexavalue);
2724 } else if (!strcmp(res->mask, "portmask")) {
2725 set_fwd_ports_mask(res->hexavalue);
2730 cmdline_parse_token_string_t cmd_setmask_set =
2731 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2732 cmdline_parse_token_string_t cmd_setmask_mask =
2733 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2734 "coremask#portmask");
2735 cmdline_parse_token_num_t cmd_setmask_value =
2736 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2738 cmdline_parse_inst_t cmd_set_fwd_mask = {
2739 .f = cmd_set_mask_parsed,
2741 .help_str = "set coremask|portmask <hexadecimal value>",
2743 (void *)&cmd_setmask_set,
2744 (void *)&cmd_setmask_mask,
2745 (void *)&cmd_setmask_value,
2751 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2753 struct cmd_set_result {
2754 cmdline_fixed_string_t set;
2755 cmdline_fixed_string_t what;
2759 static void cmd_set_parsed(void *parsed_result,
2760 __attribute__((unused)) struct cmdline *cl,
2761 __attribute__((unused)) void *data)
2763 struct cmd_set_result *res = parsed_result;
2764 if (!strcmp(res->what, "nbport")) {
2765 set_fwd_ports_number(res->value);
2767 } else if (!strcmp(res->what, "nbcore")) {
2768 set_fwd_lcores_number(res->value);
2770 } else if (!strcmp(res->what, "burst"))
2771 set_nb_pkt_per_burst(res->value);
2772 else if (!strcmp(res->what, "verbose"))
2773 set_verbose_level(res->value);
2776 cmdline_parse_token_string_t cmd_set_set =
2777 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2778 cmdline_parse_token_string_t cmd_set_what =
2779 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2780 "nbport#nbcore#burst#verbose");
2781 cmdline_parse_token_num_t cmd_set_value =
2782 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2784 cmdline_parse_inst_t cmd_set_numbers = {
2785 .f = cmd_set_parsed,
2787 .help_str = "set nbport|nbcore|burst|verbose <value>",
2789 (void *)&cmd_set_set,
2790 (void *)&cmd_set_what,
2791 (void *)&cmd_set_value,
2796 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2798 struct cmd_set_txpkts_result {
2799 cmdline_fixed_string_t cmd_keyword;
2800 cmdline_fixed_string_t txpkts;
2801 cmdline_fixed_string_t seg_lengths;
2805 cmd_set_txpkts_parsed(void *parsed_result,
2806 __attribute__((unused)) struct cmdline *cl,
2807 __attribute__((unused)) void *data)
2809 struct cmd_set_txpkts_result *res;
2810 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2811 unsigned int nb_segs;
2813 res = parsed_result;
2814 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2815 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2817 set_tx_pkt_segments(seg_lengths, nb_segs);
2820 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2821 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2822 cmd_keyword, "set");
2823 cmdline_parse_token_string_t cmd_set_txpkts_name =
2824 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2826 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2827 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2830 cmdline_parse_inst_t cmd_set_txpkts = {
2831 .f = cmd_set_txpkts_parsed,
2833 .help_str = "set txpkts <len0[,len1]*>",
2835 (void *)&cmd_set_txpkts_keyword,
2836 (void *)&cmd_set_txpkts_name,
2837 (void *)&cmd_set_txpkts_lengths,
2842 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2844 struct cmd_set_txsplit_result {
2845 cmdline_fixed_string_t cmd_keyword;
2846 cmdline_fixed_string_t txsplit;
2847 cmdline_fixed_string_t mode;
2851 cmd_set_txsplit_parsed(void *parsed_result,
2852 __attribute__((unused)) struct cmdline *cl,
2853 __attribute__((unused)) void *data)
2855 struct cmd_set_txsplit_result *res;
2857 res = parsed_result;
2858 set_tx_pkt_split(res->mode);
2861 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2862 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2863 cmd_keyword, "set");
2864 cmdline_parse_token_string_t cmd_set_txsplit_name =
2865 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2866 txsplit, "txsplit");
2867 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2868 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2871 cmdline_parse_inst_t cmd_set_txsplit = {
2872 .f = cmd_set_txsplit_parsed,
2874 .help_str = "set txsplit on|off|rand",
2876 (void *)&cmd_set_txsplit_keyword,
2877 (void *)&cmd_set_txsplit_name,
2878 (void *)&cmd_set_txsplit_mode,
2883 /* *** CONFIG TX QUEUE FLAGS *** */
2885 struct cmd_config_txqflags_result {
2886 cmdline_fixed_string_t port;
2887 cmdline_fixed_string_t config;
2888 cmdline_fixed_string_t all;
2889 cmdline_fixed_string_t what;
2893 static void cmd_config_txqflags_parsed(void *parsed_result,
2894 __attribute__((unused)) struct cmdline *cl,
2895 __attribute__((unused)) void *data)
2897 struct cmd_config_txqflags_result *res = parsed_result;
2899 if (!all_ports_stopped()) {
2900 printf("Please stop all ports first\n");
2904 if (strcmp(res->what, "txqflags")) {
2905 printf("Unknown parameter\n");
2909 if (res->hexvalue >= 0) {
2910 txq_flags = res->hexvalue;
2912 printf("txqflags must be >= 0\n");
2918 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2921 cmdline_parse_token_string_t cmd_config_txqflags_port =
2922 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2924 cmdline_parse_token_string_t cmd_config_txqflags_config =
2925 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2927 cmdline_parse_token_string_t cmd_config_txqflags_all =
2928 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2930 cmdline_parse_token_string_t cmd_config_txqflags_what =
2931 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2933 cmdline_parse_token_num_t cmd_config_txqflags_value =
2934 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2937 cmdline_parse_inst_t cmd_config_txqflags = {
2938 .f = cmd_config_txqflags_parsed,
2940 .help_str = "port config all txqflags <value>",
2942 (void *)&cmd_config_txqflags_port,
2943 (void *)&cmd_config_txqflags_config,
2944 (void *)&cmd_config_txqflags_all,
2945 (void *)&cmd_config_txqflags_what,
2946 (void *)&cmd_config_txqflags_value,
2951 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2952 struct cmd_rx_vlan_filter_all_result {
2953 cmdline_fixed_string_t rx_vlan;
2954 cmdline_fixed_string_t what;
2955 cmdline_fixed_string_t all;
2960 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2961 __attribute__((unused)) struct cmdline *cl,
2962 __attribute__((unused)) void *data)
2964 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2966 if (!strcmp(res->what, "add"))
2967 rx_vlan_all_filter_set(res->port_id, 1);
2969 rx_vlan_all_filter_set(res->port_id, 0);
2972 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2973 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2974 rx_vlan, "rx_vlan");
2975 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2976 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2978 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2979 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2981 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2982 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2985 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2986 .f = cmd_rx_vlan_filter_all_parsed,
2988 .help_str = "rx_vlan add|rm all <port_id>: "
2989 "Add/Remove all identifiers to/from the set of VLAN "
2990 "identifiers filtered by a port",
2992 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2993 (void *)&cmd_rx_vlan_filter_all_what,
2994 (void *)&cmd_rx_vlan_filter_all_all,
2995 (void *)&cmd_rx_vlan_filter_all_portid,
3000 /* *** VLAN OFFLOAD SET ON A PORT *** */
3001 struct cmd_vlan_offload_result {
3002 cmdline_fixed_string_t vlan;
3003 cmdline_fixed_string_t set;
3004 cmdline_fixed_string_t vlan_type;
3005 cmdline_fixed_string_t what;
3006 cmdline_fixed_string_t on;
3007 cmdline_fixed_string_t port_id;
3011 cmd_vlan_offload_parsed(void *parsed_result,
3012 __attribute__((unused)) struct cmdline *cl,
3013 __attribute__((unused)) void *data)
3016 struct cmd_vlan_offload_result *res = parsed_result;
3019 portid_t port_id = 0;
3023 len = strnlen(str, STR_TOKEN_SIZE);
3025 /* Get port_id first */
3033 tmp = strtoul(str, NULL, 0);
3034 /* If port_id greater that what portid_t can represent, return */
3035 if(tmp >= RTE_MAX_ETHPORTS)
3037 port_id = (portid_t)tmp;
3039 if (!strcmp(res->on, "on"))
3044 if (!strcmp(res->what, "strip"))
3045 rx_vlan_strip_set(port_id, on);
3046 else if(!strcmp(res->what, "stripq")){
3047 uint16_t queue_id = 0;
3049 /* No queue_id, return */
3051 printf("must specify (port,queue_id)\n");
3054 tmp = strtoul(str + i + 1, NULL, 0);
3055 /* If queue_id greater that what 16-bits can represent, return */
3059 queue_id = (uint16_t)tmp;
3060 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3062 else if (!strcmp(res->what, "filter"))
3063 rx_vlan_filter_set(port_id, on);
3065 vlan_extend_set(port_id, on);
3070 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3071 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3073 cmdline_parse_token_string_t cmd_vlan_offload_set =
3074 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3076 cmdline_parse_token_string_t cmd_vlan_offload_what =
3077 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3078 what, "strip#filter#qinq#stripq");
3079 cmdline_parse_token_string_t cmd_vlan_offload_on =
3080 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3082 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3083 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3086 cmdline_parse_inst_t cmd_vlan_offload = {
3087 .f = cmd_vlan_offload_parsed,
3089 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3090 "<port_id[,queue_id]>: "
3091 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3093 (void *)&cmd_vlan_offload_vlan,
3094 (void *)&cmd_vlan_offload_set,
3095 (void *)&cmd_vlan_offload_what,
3096 (void *)&cmd_vlan_offload_on,
3097 (void *)&cmd_vlan_offload_portid,
3102 /* *** VLAN TPID SET ON A PORT *** */
3103 struct cmd_vlan_tpid_result {
3104 cmdline_fixed_string_t vlan;
3105 cmdline_fixed_string_t set;
3106 cmdline_fixed_string_t vlan_type;
3107 cmdline_fixed_string_t what;
3113 cmd_vlan_tpid_parsed(void *parsed_result,
3114 __attribute__((unused)) struct cmdline *cl,
3115 __attribute__((unused)) void *data)
3117 struct cmd_vlan_tpid_result *res = parsed_result;
3118 enum rte_vlan_type vlan_type;
3120 if (!strcmp(res->vlan_type, "inner"))
3121 vlan_type = ETH_VLAN_TYPE_INNER;
3122 else if (!strcmp(res->vlan_type, "outer"))
3123 vlan_type = ETH_VLAN_TYPE_OUTER;
3125 printf("Unknown vlan type\n");
3128 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3131 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3132 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3134 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3135 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3137 cmdline_parse_token_string_t cmd_vlan_type =
3138 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3139 vlan_type, "inner#outer");
3140 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3141 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3143 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3144 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3146 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3147 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3150 cmdline_parse_inst_t cmd_vlan_tpid = {
3151 .f = cmd_vlan_tpid_parsed,
3153 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3154 "Set the VLAN Ether type",
3156 (void *)&cmd_vlan_tpid_vlan,
3157 (void *)&cmd_vlan_tpid_set,
3158 (void *)&cmd_vlan_type,
3159 (void *)&cmd_vlan_tpid_what,
3160 (void *)&cmd_vlan_tpid_tpid,
3161 (void *)&cmd_vlan_tpid_portid,
3166 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3167 struct cmd_rx_vlan_filter_result {
3168 cmdline_fixed_string_t rx_vlan;
3169 cmdline_fixed_string_t what;
3175 cmd_rx_vlan_filter_parsed(void *parsed_result,
3176 __attribute__((unused)) struct cmdline *cl,
3177 __attribute__((unused)) void *data)
3179 struct cmd_rx_vlan_filter_result *res = parsed_result;
3181 if (!strcmp(res->what, "add"))
3182 rx_vft_set(res->port_id, res->vlan_id, 1);
3184 rx_vft_set(res->port_id, res->vlan_id, 0);
3187 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3188 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3189 rx_vlan, "rx_vlan");
3190 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3191 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3193 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3194 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3196 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3197 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3200 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3201 .f = cmd_rx_vlan_filter_parsed,
3203 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3204 "Add/Remove a VLAN identifier to/from the set of VLAN "
3205 "identifiers filtered by a port",
3207 (void *)&cmd_rx_vlan_filter_rx_vlan,
3208 (void *)&cmd_rx_vlan_filter_what,
3209 (void *)&cmd_rx_vlan_filter_vlanid,
3210 (void *)&cmd_rx_vlan_filter_portid,
3215 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3216 struct cmd_tx_vlan_set_result {
3217 cmdline_fixed_string_t tx_vlan;
3218 cmdline_fixed_string_t set;
3224 cmd_tx_vlan_set_parsed(void *parsed_result,
3225 __attribute__((unused)) struct cmdline *cl,
3226 __attribute__((unused)) void *data)
3228 struct cmd_tx_vlan_set_result *res = parsed_result;
3230 tx_vlan_set(res->port_id, res->vlan_id);
3233 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3234 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3235 tx_vlan, "tx_vlan");
3236 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3237 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3239 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3240 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3242 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3243 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3246 cmdline_parse_inst_t cmd_tx_vlan_set = {
3247 .f = cmd_tx_vlan_set_parsed,
3249 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3250 "Enable hardware insertion of a single VLAN header "
3251 "with a given TAG Identifier in packets sent on a port",
3253 (void *)&cmd_tx_vlan_set_tx_vlan,
3254 (void *)&cmd_tx_vlan_set_set,
3255 (void *)&cmd_tx_vlan_set_portid,
3256 (void *)&cmd_tx_vlan_set_vlanid,
3261 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3262 struct cmd_tx_vlan_set_qinq_result {
3263 cmdline_fixed_string_t tx_vlan;
3264 cmdline_fixed_string_t set;
3267 uint16_t vlan_id_outer;
3271 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3272 __attribute__((unused)) struct cmdline *cl,
3273 __attribute__((unused)) void *data)
3275 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3277 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3280 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3281 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3282 tx_vlan, "tx_vlan");
3283 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3284 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3286 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3287 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3289 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3290 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3292 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3293 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3294 vlan_id_outer, UINT16);
3296 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3297 .f = cmd_tx_vlan_set_qinq_parsed,
3299 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3300 "Enable hardware insertion of double VLAN header "
3301 "with given TAG Identifiers in packets sent on a port",
3303 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3304 (void *)&cmd_tx_vlan_set_qinq_set,
3305 (void *)&cmd_tx_vlan_set_qinq_portid,
3306 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3307 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3312 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3313 struct cmd_tx_vlan_set_pvid_result {
3314 cmdline_fixed_string_t tx_vlan;
3315 cmdline_fixed_string_t set;
3316 cmdline_fixed_string_t pvid;
3319 cmdline_fixed_string_t mode;
3323 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3324 __attribute__((unused)) struct cmdline *cl,
3325 __attribute__((unused)) void *data)
3327 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3329 if (strcmp(res->mode, "on") == 0)
3330 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3332 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3335 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3336 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3337 tx_vlan, "tx_vlan");
3338 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3339 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3341 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3342 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3344 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3345 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3347 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3348 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3350 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3351 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3354 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3355 .f = cmd_tx_vlan_set_pvid_parsed,
3357 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3359 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3360 (void *)&cmd_tx_vlan_set_pvid_set,
3361 (void *)&cmd_tx_vlan_set_pvid_pvid,
3362 (void *)&cmd_tx_vlan_set_pvid_port_id,
3363 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3364 (void *)&cmd_tx_vlan_set_pvid_mode,
3369 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3370 struct cmd_tx_vlan_reset_result {
3371 cmdline_fixed_string_t tx_vlan;
3372 cmdline_fixed_string_t reset;
3377 cmd_tx_vlan_reset_parsed(void *parsed_result,
3378 __attribute__((unused)) struct cmdline *cl,
3379 __attribute__((unused)) void *data)
3381 struct cmd_tx_vlan_reset_result *res = parsed_result;
3383 tx_vlan_reset(res->port_id);
3386 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3387 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3388 tx_vlan, "tx_vlan");
3389 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3390 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3392 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3393 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3396 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3397 .f = cmd_tx_vlan_reset_parsed,
3399 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3400 "VLAN header in packets sent on a port",
3402 (void *)&cmd_tx_vlan_reset_tx_vlan,
3403 (void *)&cmd_tx_vlan_reset_reset,
3404 (void *)&cmd_tx_vlan_reset_portid,
3410 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3411 struct cmd_csum_result {
3412 cmdline_fixed_string_t csum;
3413 cmdline_fixed_string_t mode;
3414 cmdline_fixed_string_t proto;
3415 cmdline_fixed_string_t hwsw;
3420 csum_show(int port_id)
3422 struct rte_eth_dev_info dev_info;
3425 ol_flags = ports[port_id].tx_ol_flags;
3426 printf("Parse tunnel is %s\n",
3427 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3428 printf("IP checksum offload is %s\n",
3429 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3430 printf("UDP checksum offload is %s\n",
3431 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3432 printf("TCP checksum offload is %s\n",
3433 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3434 printf("SCTP checksum offload is %s\n",
3435 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3436 printf("Outer-Ip checksum offload is %s\n",
3437 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3439 /* display warnings if configuration is not supported by the NIC */
3440 rte_eth_dev_info_get(port_id, &dev_info);
3441 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3442 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3443 printf("Warning: hardware IP checksum enabled but not "
3444 "supported by port %d\n", port_id);
3446 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3447 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3448 printf("Warning: hardware UDP checksum enabled but not "
3449 "supported by port %d\n", port_id);
3451 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3452 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3453 printf("Warning: hardware TCP checksum enabled but not "
3454 "supported by port %d\n", port_id);
3456 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3457 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3458 printf("Warning: hardware SCTP checksum enabled but not "
3459 "supported by port %d\n", port_id);
3461 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3462 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3463 printf("Warning: hardware outer IP checksum enabled but not "
3464 "supported by port %d\n", port_id);
3469 cmd_csum_parsed(void *parsed_result,
3470 __attribute__((unused)) struct cmdline *cl,
3471 __attribute__((unused)) void *data)
3473 struct cmd_csum_result *res = parsed_result;
3477 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3478 printf("invalid port %d\n", res->port_id);
3482 if (!strcmp(res->mode, "set")) {
3484 if (!strcmp(res->hwsw, "hw"))
3487 if (!strcmp(res->proto, "ip")) {
3488 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3489 } else if (!strcmp(res->proto, "udp")) {
3490 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3491 } else if (!strcmp(res->proto, "tcp")) {
3492 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3493 } else if (!strcmp(res->proto, "sctp")) {
3494 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3495 } else if (!strcmp(res->proto, "outer-ip")) {
3496 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3500 ports[res->port_id].tx_ol_flags |= mask;
3502 ports[res->port_id].tx_ol_flags &= (~mask);
3504 csum_show(res->port_id);
3507 cmdline_parse_token_string_t cmd_csum_csum =
3508 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3510 cmdline_parse_token_string_t cmd_csum_mode =
3511 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3513 cmdline_parse_token_string_t cmd_csum_proto =
3514 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3515 proto, "ip#tcp#udp#sctp#outer-ip");
3516 cmdline_parse_token_string_t cmd_csum_hwsw =
3517 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3519 cmdline_parse_token_num_t cmd_csum_portid =
3520 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3523 cmdline_parse_inst_t cmd_csum_set = {
3524 .f = cmd_csum_parsed,
3526 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3527 "Enable/Disable hardware calculation of L3/L4 checksum when "
3528 "using csum forward engine",
3530 (void *)&cmd_csum_csum,
3531 (void *)&cmd_csum_mode,
3532 (void *)&cmd_csum_proto,
3533 (void *)&cmd_csum_hwsw,
3534 (void *)&cmd_csum_portid,
3539 cmdline_parse_token_string_t cmd_csum_mode_show =
3540 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3543 cmdline_parse_inst_t cmd_csum_show = {
3544 .f = cmd_csum_parsed,
3546 .help_str = "csum show <port_id>: Show checksum offload configuration",
3548 (void *)&cmd_csum_csum,
3549 (void *)&cmd_csum_mode_show,
3550 (void *)&cmd_csum_portid,
3555 /* Enable/disable tunnel parsing */
3556 struct cmd_csum_tunnel_result {
3557 cmdline_fixed_string_t csum;
3558 cmdline_fixed_string_t parse;
3559 cmdline_fixed_string_t onoff;
3564 cmd_csum_tunnel_parsed(void *parsed_result,
3565 __attribute__((unused)) struct cmdline *cl,
3566 __attribute__((unused)) void *data)
3568 struct cmd_csum_tunnel_result *res = parsed_result;
3570 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3573 if (!strcmp(res->onoff, "on"))
3574 ports[res->port_id].tx_ol_flags |=
3575 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3577 ports[res->port_id].tx_ol_flags &=
3578 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3580 csum_show(res->port_id);
3583 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3584 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3586 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3587 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3588 parse, "parse_tunnel");
3589 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3590 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3592 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3593 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3596 cmdline_parse_inst_t cmd_csum_tunnel = {
3597 .f = cmd_csum_tunnel_parsed,
3599 .help_str = "csum parse_tunnel on|off <port_id>: "
3600 "Enable/Disable parsing of tunnels for csum engine",
3602 (void *)&cmd_csum_tunnel_csum,
3603 (void *)&cmd_csum_tunnel_parse,
3604 (void *)&cmd_csum_tunnel_onoff,
3605 (void *)&cmd_csum_tunnel_portid,
3610 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3611 struct cmd_tso_set_result {
3612 cmdline_fixed_string_t tso;
3613 cmdline_fixed_string_t mode;
3619 cmd_tso_set_parsed(void *parsed_result,
3620 __attribute__((unused)) struct cmdline *cl,
3621 __attribute__((unused)) void *data)
3623 struct cmd_tso_set_result *res = parsed_result;
3624 struct rte_eth_dev_info dev_info;
3626 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3629 if (!strcmp(res->mode, "set"))
3630 ports[res->port_id].tso_segsz = res->tso_segsz;
3632 if (ports[res->port_id].tso_segsz == 0)
3633 printf("TSO for non-tunneled packets is disabled\n");
3635 printf("TSO segment size for non-tunneled packets is %d\n",
3636 ports[res->port_id].tso_segsz);
3638 /* display warnings if configuration is not supported by the NIC */
3639 rte_eth_dev_info_get(res->port_id, &dev_info);
3640 if ((ports[res->port_id].tso_segsz != 0) &&
3641 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3642 printf("Warning: TSO enabled but not "
3643 "supported by port %d\n", res->port_id);
3647 cmdline_parse_token_string_t cmd_tso_set_tso =
3648 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3650 cmdline_parse_token_string_t cmd_tso_set_mode =
3651 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3653 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3654 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3656 cmdline_parse_token_num_t cmd_tso_set_portid =
3657 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3660 cmdline_parse_inst_t cmd_tso_set = {
3661 .f = cmd_tso_set_parsed,
3663 .help_str = "tso set <tso_segsz> <port_id>: "
3664 "Set TSO segment size of non-tunneled packets for csum engine "
3667 (void *)&cmd_tso_set_tso,
3668 (void *)&cmd_tso_set_mode,
3669 (void *)&cmd_tso_set_tso_segsz,
3670 (void *)&cmd_tso_set_portid,
3675 cmdline_parse_token_string_t cmd_tso_show_mode =
3676 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3680 cmdline_parse_inst_t cmd_tso_show = {
3681 .f = cmd_tso_set_parsed,
3683 .help_str = "tso show <port_id>: "
3684 "Show TSO segment size of non-tunneled packets for csum engine",
3686 (void *)&cmd_tso_set_tso,
3687 (void *)&cmd_tso_show_mode,
3688 (void *)&cmd_tso_set_portid,
3693 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3694 struct cmd_tunnel_tso_set_result {
3695 cmdline_fixed_string_t tso;
3696 cmdline_fixed_string_t mode;
3702 check_tunnel_tso_nic_support(uint8_t port_id)
3704 struct rte_eth_dev_info dev_info;
3706 rte_eth_dev_info_get(port_id, &dev_info);
3707 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3708 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3709 "supported by port %d\n", port_id);
3710 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3711 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3712 "supported by port %d\n", port_id);
3713 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3714 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3715 "supported by port %d\n", port_id);
3716 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3717 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3718 "supported by port %d\n", port_id);
3722 cmd_tunnel_tso_set_parsed(void *parsed_result,
3723 __attribute__((unused)) struct cmdline *cl,
3724 __attribute__((unused)) void *data)
3726 struct cmd_tunnel_tso_set_result *res = parsed_result;
3728 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3731 if (!strcmp(res->mode, "set"))
3732 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3734 if (ports[res->port_id].tunnel_tso_segsz == 0)
3735 printf("TSO for tunneled packets is disabled\n");
3737 printf("TSO segment size for tunneled packets is %d\n",
3738 ports[res->port_id].tunnel_tso_segsz);
3740 /* Below conditions are needed to make it work:
3741 * (1) tunnel TSO is supported by the NIC;
3742 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3744 * (3) for tunneled pkts with outer L3 of IPv4,
3745 * "csum set outer-ip" must be set to hw, because after tso,
3746 * total_len of outer IP header is changed, and the checksum
3747 * of outer IP header calculated by sw should be wrong; that
3748 * is not necessary for IPv6 tunneled pkts because there's no
3749 * checksum in IP header anymore.
3751 check_tunnel_tso_nic_support(res->port_id);
3753 if (!(ports[res->port_id].tx_ol_flags &
3754 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3755 printf("Warning: csum parse_tunnel must be set "
3756 "so that tunneled packets are recognized\n");
3757 if (!(ports[res->port_id].tx_ol_flags &
3758 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3759 printf("Warning: csum set outer-ip must be set to hw "
3760 "if outer L3 is IPv4; not necessary for IPv6\n");
3764 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3765 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3767 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3768 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3770 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3771 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3773 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3774 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3777 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3778 .f = cmd_tunnel_tso_set_parsed,
3780 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3781 "Set TSO segment size of tunneled packets for csum engine "
3784 (void *)&cmd_tunnel_tso_set_tso,
3785 (void *)&cmd_tunnel_tso_set_mode,
3786 (void *)&cmd_tunnel_tso_set_tso_segsz,
3787 (void *)&cmd_tunnel_tso_set_portid,
3792 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3793 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3797 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3798 .f = cmd_tunnel_tso_set_parsed,
3800 .help_str = "tunnel_tso show <port_id> "
3801 "Show TSO segment size of tunneled packets for csum engine",
3803 (void *)&cmd_tunnel_tso_set_tso,
3804 (void *)&cmd_tunnel_tso_show_mode,
3805 (void *)&cmd_tunnel_tso_set_portid,
3810 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3811 struct cmd_set_flush_rx {
3812 cmdline_fixed_string_t set;
3813 cmdline_fixed_string_t flush_rx;
3814 cmdline_fixed_string_t mode;
3818 cmd_set_flush_rx_parsed(void *parsed_result,
3819 __attribute__((unused)) struct cmdline *cl,
3820 __attribute__((unused)) void *data)
3822 struct cmd_set_flush_rx *res = parsed_result;
3823 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3826 cmdline_parse_token_string_t cmd_setflushrx_set =
3827 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3829 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3830 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3831 flush_rx, "flush_rx");
3832 cmdline_parse_token_string_t cmd_setflushrx_mode =
3833 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3837 cmdline_parse_inst_t cmd_set_flush_rx = {
3838 .f = cmd_set_flush_rx_parsed,
3839 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3842 (void *)&cmd_setflushrx_set,
3843 (void *)&cmd_setflushrx_flush_rx,
3844 (void *)&cmd_setflushrx_mode,
3849 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3850 struct cmd_set_link_check {
3851 cmdline_fixed_string_t set;
3852 cmdline_fixed_string_t link_check;
3853 cmdline_fixed_string_t mode;
3857 cmd_set_link_check_parsed(void *parsed_result,
3858 __attribute__((unused)) struct cmdline *cl,
3859 __attribute__((unused)) void *data)
3861 struct cmd_set_link_check *res = parsed_result;
3862 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3865 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3866 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3868 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3869 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3870 link_check, "link_check");
3871 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3872 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3876 cmdline_parse_inst_t cmd_set_link_check = {
3877 .f = cmd_set_link_check_parsed,
3878 .help_str = "set link_check on|off: Enable/Disable link status check "
3879 "when starting/stopping a port",
3882 (void *)&cmd_setlinkcheck_set,
3883 (void *)&cmd_setlinkcheck_link_check,
3884 (void *)&cmd_setlinkcheck_mode,
3889 #ifdef RTE_NIC_BYPASS
3890 /* *** SET NIC BYPASS MODE *** */
3891 struct cmd_set_bypass_mode_result {
3892 cmdline_fixed_string_t set;
3893 cmdline_fixed_string_t bypass;
3894 cmdline_fixed_string_t mode;
3895 cmdline_fixed_string_t value;
3900 cmd_set_bypass_mode_parsed(void *parsed_result,
3901 __attribute__((unused)) struct cmdline *cl,
3902 __attribute__((unused)) void *data)
3904 struct cmd_set_bypass_mode_result *res = parsed_result;
3905 portid_t port_id = res->port_id;
3906 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3908 if (!strcmp(res->value, "bypass"))
3909 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3910 else if (!strcmp(res->value, "isolate"))
3911 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3913 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3915 /* Set the bypass mode for the relevant port. */
3916 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3917 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3921 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3922 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3924 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3925 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3927 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3928 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3930 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3931 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3932 value, "normal#bypass#isolate");
3933 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3934 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3937 cmdline_parse_inst_t cmd_set_bypass_mode = {
3938 .f = cmd_set_bypass_mode_parsed,
3939 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3940 "Set the NIC bypass mode for port_id",
3943 (void *)&cmd_setbypass_mode_set,
3944 (void *)&cmd_setbypass_mode_bypass,
3945 (void *)&cmd_setbypass_mode_mode,
3946 (void *)&cmd_setbypass_mode_value,
3947 (void *)&cmd_setbypass_mode_port,
3952 /* *** SET NIC BYPASS EVENT *** */
3953 struct cmd_set_bypass_event_result {
3954 cmdline_fixed_string_t set;
3955 cmdline_fixed_string_t bypass;
3956 cmdline_fixed_string_t event;
3957 cmdline_fixed_string_t event_value;
3958 cmdline_fixed_string_t mode;
3959 cmdline_fixed_string_t mode_value;
3964 cmd_set_bypass_event_parsed(void *parsed_result,
3965 __attribute__((unused)) struct cmdline *cl,
3966 __attribute__((unused)) void *data)
3969 struct cmd_set_bypass_event_result *res = parsed_result;
3970 portid_t port_id = res->port_id;
3971 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3972 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3974 if (!strcmp(res->event_value, "timeout"))
3975 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3976 else if (!strcmp(res->event_value, "os_on"))
3977 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3978 else if (!strcmp(res->event_value, "os_off"))
3979 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3980 else if (!strcmp(res->event_value, "power_on"))
3981 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3982 else if (!strcmp(res->event_value, "power_off"))
3983 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3985 bypass_event = RTE_BYPASS_EVENT_NONE;
3987 if (!strcmp(res->mode_value, "bypass"))
3988 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3989 else if (!strcmp(res->mode_value, "isolate"))
3990 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3992 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3994 /* Set the watchdog timeout. */
3995 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3998 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3999 (rc = rte_eth_dev_wd_timeout_store(port_id,
4000 bypass_timeout)) != 0) {
4001 printf("Failed to set timeout value %u "
4002 "for port %d, errto code: %d.\n",
4003 bypass_timeout, port_id, rc);
4007 /* Set the bypass event to transition to bypass mode. */
4008 if (0 != rte_eth_dev_bypass_event_store(port_id,
4009 bypass_event, bypass_mode)) {
4010 printf("\t Failed to set bypass event for port = %d.\n", port_id);
4015 cmdline_parse_token_string_t cmd_setbypass_event_set =
4016 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4018 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4019 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4021 cmdline_parse_token_string_t cmd_setbypass_event_event =
4022 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4024 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4025 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4026 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4027 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4028 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4030 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4031 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4032 mode_value, "normal#bypass#isolate");
4033 cmdline_parse_token_num_t cmd_setbypass_event_port =
4034 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4037 cmdline_parse_inst_t cmd_set_bypass_event = {
4038 .f = cmd_set_bypass_event_parsed,
4039 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4040 "power_off mode normal|bypass|isolate <port_id>: "
4041 "Set the NIC bypass event mode for port_id",
4044 (void *)&cmd_setbypass_event_set,
4045 (void *)&cmd_setbypass_event_bypass,
4046 (void *)&cmd_setbypass_event_event,
4047 (void *)&cmd_setbypass_event_event_value,
4048 (void *)&cmd_setbypass_event_mode,
4049 (void *)&cmd_setbypass_event_mode_value,
4050 (void *)&cmd_setbypass_event_port,
4056 /* *** SET NIC BYPASS TIMEOUT *** */
4057 struct cmd_set_bypass_timeout_result {
4058 cmdline_fixed_string_t set;
4059 cmdline_fixed_string_t bypass;
4060 cmdline_fixed_string_t timeout;
4061 cmdline_fixed_string_t value;
4065 cmd_set_bypass_timeout_parsed(void *parsed_result,
4066 __attribute__((unused)) struct cmdline *cl,
4067 __attribute__((unused)) void *data)
4069 struct cmd_set_bypass_timeout_result *res = parsed_result;
4071 if (!strcmp(res->value, "1.5"))
4072 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4073 else if (!strcmp(res->value, "2"))
4074 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4075 else if (!strcmp(res->value, "3"))
4076 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4077 else if (!strcmp(res->value, "4"))
4078 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4079 else if (!strcmp(res->value, "8"))
4080 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4081 else if (!strcmp(res->value, "16"))
4082 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4083 else if (!strcmp(res->value, "32"))
4084 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4086 bypass_timeout = RTE_BYPASS_TMT_OFF;
4089 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4090 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4092 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4093 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4095 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4096 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4097 timeout, "timeout");
4098 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4099 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4100 value, "0#1.5#2#3#4#8#16#32");
4102 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4103 .f = cmd_set_bypass_timeout_parsed,
4104 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4105 "Set the NIC bypass watchdog timeout in seconds",
4108 (void *)&cmd_setbypass_timeout_set,
4109 (void *)&cmd_setbypass_timeout_bypass,
4110 (void *)&cmd_setbypass_timeout_timeout,
4111 (void *)&cmd_setbypass_timeout_value,
4116 /* *** SHOW NIC BYPASS MODE *** */
4117 struct cmd_show_bypass_config_result {
4118 cmdline_fixed_string_t show;
4119 cmdline_fixed_string_t bypass;
4120 cmdline_fixed_string_t config;
4125 cmd_show_bypass_config_parsed(void *parsed_result,
4126 __attribute__((unused)) struct cmdline *cl,
4127 __attribute__((unused)) void *data)
4129 struct cmd_show_bypass_config_result *res = parsed_result;
4130 uint32_t event_mode;
4131 uint32_t bypass_mode;
4132 portid_t port_id = res->port_id;
4133 uint32_t timeout = bypass_timeout;
4136 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4137 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4138 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4139 {"UNKNOWN", "normal", "bypass", "isolate"};
4140 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4147 int num_events = (sizeof events) / (sizeof events[0]);
4149 /* Display the bypass mode.*/
4150 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4151 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4155 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4156 bypass_mode = RTE_BYPASS_MODE_NONE;
4158 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4161 /* Display the bypass timeout.*/
4162 if (!RTE_BYPASS_TMT_VALID(timeout))
4163 timeout = RTE_BYPASS_TMT_OFF;
4165 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4167 /* Display the bypass events and associated modes. */
4168 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4170 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4171 printf("\tFailed to get bypass mode for event = %s\n",
4174 if (!RTE_BYPASS_MODE_VALID(event_mode))
4175 event_mode = RTE_BYPASS_MODE_NONE;
4177 printf("\tbypass event: %-16s = %s\n", events[i],
4183 cmdline_parse_token_string_t cmd_showbypass_config_show =
4184 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4186 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4187 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4189 cmdline_parse_token_string_t cmd_showbypass_config_config =
4190 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4192 cmdline_parse_token_num_t cmd_showbypass_config_port =
4193 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4196 cmdline_parse_inst_t cmd_show_bypass_config = {
4197 .f = cmd_show_bypass_config_parsed,
4198 .help_str = "show bypass config <port_id>: "
4199 "Show the NIC bypass config for port_id",
4202 (void *)&cmd_showbypass_config_show,
4203 (void *)&cmd_showbypass_config_bypass,
4204 (void *)&cmd_showbypass_config_config,
4205 (void *)&cmd_showbypass_config_port,
4211 #ifdef RTE_LIBRTE_PMD_BOND
4212 /* *** SET BONDING MODE *** */
4213 struct cmd_set_bonding_mode_result {
4214 cmdline_fixed_string_t set;
4215 cmdline_fixed_string_t bonding;
4216 cmdline_fixed_string_t mode;
4221 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4222 __attribute__((unused)) struct cmdline *cl,
4223 __attribute__((unused)) void *data)
4225 struct cmd_set_bonding_mode_result *res = parsed_result;
4226 portid_t port_id = res->port_id;
4228 /* Set the bonding mode for the relevant port. */
4229 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4230 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4233 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4234 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4236 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4237 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4238 bonding, "bonding");
4239 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4240 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4242 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4243 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4245 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4246 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4249 cmdline_parse_inst_t cmd_set_bonding_mode = {
4250 .f = cmd_set_bonding_mode_parsed,
4251 .help_str = "set bonding mode <mode_value> <port_id>: "
4252 "Set the bonding mode for port_id",
4255 (void *) &cmd_setbonding_mode_set,
4256 (void *) &cmd_setbonding_mode_bonding,
4257 (void *) &cmd_setbonding_mode_mode,
4258 (void *) &cmd_setbonding_mode_value,
4259 (void *) &cmd_setbonding_mode_port,
4264 /* *** SET BALANCE XMIT POLICY *** */
4265 struct cmd_set_bonding_balance_xmit_policy_result {
4266 cmdline_fixed_string_t set;
4267 cmdline_fixed_string_t bonding;
4268 cmdline_fixed_string_t balance_xmit_policy;
4270 cmdline_fixed_string_t policy;
4273 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4274 __attribute__((unused)) struct cmdline *cl,
4275 __attribute__((unused)) void *data)
4277 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4278 portid_t port_id = res->port_id;
4281 if (!strcmp(res->policy, "l2")) {
4282 policy = BALANCE_XMIT_POLICY_LAYER2;
4283 } else if (!strcmp(res->policy, "l23")) {
4284 policy = BALANCE_XMIT_POLICY_LAYER23;
4285 } else if (!strcmp(res->policy, "l34")) {
4286 policy = BALANCE_XMIT_POLICY_LAYER34;
4288 printf("\t Invalid xmit policy selection");
4292 /* Set the bonding mode for the relevant port. */
4293 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4294 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4299 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4300 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4302 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4303 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4304 bonding, "bonding");
4305 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4306 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4307 balance_xmit_policy, "balance_xmit_policy");
4308 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4309 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4311 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4312 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4313 policy, "l2#l23#l34");
4315 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4316 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4317 .help_str = "set bonding balance_xmit_policy <port_id> "
4319 "Set the bonding balance_xmit_policy for port_id",
4322 (void *)&cmd_setbonding_balance_xmit_policy_set,
4323 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4324 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4325 (void *)&cmd_setbonding_balance_xmit_policy_port,
4326 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4331 /* *** SHOW NIC BONDING CONFIGURATION *** */
4332 struct cmd_show_bonding_config_result {
4333 cmdline_fixed_string_t show;
4334 cmdline_fixed_string_t bonding;
4335 cmdline_fixed_string_t config;
4339 static void cmd_show_bonding_config_parsed(void *parsed_result,
4340 __attribute__((unused)) struct cmdline *cl,
4341 __attribute__((unused)) void *data)
4343 struct cmd_show_bonding_config_result *res = parsed_result;
4345 uint8_t slaves[RTE_MAX_ETHPORTS];
4346 int num_slaves, num_active_slaves;
4349 portid_t port_id = res->port_id;
4351 /* Display the bonding mode.*/
4352 bonding_mode = rte_eth_bond_mode_get(port_id);
4353 if (bonding_mode < 0) {
4354 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4357 printf("\tBonding mode: %d\n", bonding_mode);
4359 if (bonding_mode == BONDING_MODE_BALANCE) {
4360 int balance_xmit_policy;
4362 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4363 if (balance_xmit_policy < 0) {
4364 printf("\tFailed to get balance xmit policy for port = %d\n",
4368 printf("\tBalance Xmit Policy: ");
4370 switch (balance_xmit_policy) {
4371 case BALANCE_XMIT_POLICY_LAYER2:
4372 printf("BALANCE_XMIT_POLICY_LAYER2");
4374 case BALANCE_XMIT_POLICY_LAYER23:
4375 printf("BALANCE_XMIT_POLICY_LAYER23");
4377 case BALANCE_XMIT_POLICY_LAYER34:
4378 printf("BALANCE_XMIT_POLICY_LAYER34");
4385 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4387 if (num_slaves < 0) {
4388 printf("\tFailed to get slave list for port = %d\n", port_id);
4391 if (num_slaves > 0) {
4392 printf("\tSlaves (%d): [", num_slaves);
4393 for (i = 0; i < num_slaves - 1; i++)
4394 printf("%d ", slaves[i]);
4396 printf("%d]\n", slaves[num_slaves - 1]);
4398 printf("\tSlaves: []\n");
4402 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4405 if (num_active_slaves < 0) {
4406 printf("\tFailed to get active slave list for port = %d\n", port_id);
4409 if (num_active_slaves > 0) {
4410 printf("\tActive Slaves (%d): [", num_active_slaves);
4411 for (i = 0; i < num_active_slaves - 1; i++)
4412 printf("%d ", slaves[i]);
4414 printf("%d]\n", slaves[num_active_slaves - 1]);
4417 printf("\tActive Slaves: []\n");
4421 primary_id = rte_eth_bond_primary_get(port_id);
4422 if (primary_id < 0) {
4423 printf("\tFailed to get primary slave for port = %d\n", port_id);
4426 printf("\tPrimary: [%d]\n", primary_id);
4430 cmdline_parse_token_string_t cmd_showbonding_config_show =
4431 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4433 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4434 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4435 bonding, "bonding");
4436 cmdline_parse_token_string_t cmd_showbonding_config_config =
4437 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4439 cmdline_parse_token_num_t cmd_showbonding_config_port =
4440 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4443 cmdline_parse_inst_t cmd_show_bonding_config = {
4444 .f = cmd_show_bonding_config_parsed,
4445 .help_str = "show bonding config <port_id>: "
4446 "Show the bonding config for port_id",
4449 (void *)&cmd_showbonding_config_show,
4450 (void *)&cmd_showbonding_config_bonding,
4451 (void *)&cmd_showbonding_config_config,
4452 (void *)&cmd_showbonding_config_port,
4457 /* *** SET BONDING PRIMARY *** */
4458 struct cmd_set_bonding_primary_result {
4459 cmdline_fixed_string_t set;
4460 cmdline_fixed_string_t bonding;
4461 cmdline_fixed_string_t primary;
4466 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4467 __attribute__((unused)) struct cmdline *cl,
4468 __attribute__((unused)) void *data)
4470 struct cmd_set_bonding_primary_result *res = parsed_result;
4471 portid_t master_port_id = res->port_id;
4472 portid_t slave_port_id = res->slave_id;
4474 /* Set the primary slave for a bonded device. */
4475 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4476 printf("\t Failed to set primary slave for port = %d.\n",
4483 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4484 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4486 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4487 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4488 bonding, "bonding");
4489 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4490 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4491 primary, "primary");
4492 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4493 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4495 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4496 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4499 cmdline_parse_inst_t cmd_set_bonding_primary = {
4500 .f = cmd_set_bonding_primary_parsed,
4501 .help_str = "set bonding primary <slave_id> <port_id>: "
4502 "Set the primary slave for port_id",
4505 (void *)&cmd_setbonding_primary_set,
4506 (void *)&cmd_setbonding_primary_bonding,
4507 (void *)&cmd_setbonding_primary_primary,
4508 (void *)&cmd_setbonding_primary_slave,
4509 (void *)&cmd_setbonding_primary_port,
4514 /* *** ADD SLAVE *** */
4515 struct cmd_add_bonding_slave_result {
4516 cmdline_fixed_string_t add;
4517 cmdline_fixed_string_t bonding;
4518 cmdline_fixed_string_t slave;
4523 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4524 __attribute__((unused)) struct cmdline *cl,
4525 __attribute__((unused)) void *data)
4527 struct cmd_add_bonding_slave_result *res = parsed_result;
4528 portid_t master_port_id = res->port_id;
4529 portid_t slave_port_id = res->slave_id;
4531 /* Set the primary slave for a bonded device. */
4532 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4533 printf("\t Failed to add slave %d to master port = %d.\n",
4534 slave_port_id, master_port_id);
4538 set_port_slave_flag(slave_port_id);
4541 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4542 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4544 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4545 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4546 bonding, "bonding");
4547 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4548 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4550 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4551 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4553 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4554 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4557 cmdline_parse_inst_t cmd_add_bonding_slave = {
4558 .f = cmd_add_bonding_slave_parsed,
4559 .help_str = "add bonding slave <slave_id> <port_id>: "
4560 "Add a slave device to a bonded device",
4563 (void *)&cmd_addbonding_slave_add,
4564 (void *)&cmd_addbonding_slave_bonding,
4565 (void *)&cmd_addbonding_slave_slave,
4566 (void *)&cmd_addbonding_slave_slaveid,
4567 (void *)&cmd_addbonding_slave_port,
4572 /* *** REMOVE SLAVE *** */
4573 struct cmd_remove_bonding_slave_result {
4574 cmdline_fixed_string_t remove;
4575 cmdline_fixed_string_t bonding;
4576 cmdline_fixed_string_t slave;
4581 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4582 __attribute__((unused)) struct cmdline *cl,
4583 __attribute__((unused)) void *data)
4585 struct cmd_remove_bonding_slave_result *res = parsed_result;
4586 portid_t master_port_id = res->port_id;
4587 portid_t slave_port_id = res->slave_id;
4589 /* Set the primary slave for a bonded device. */
4590 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4591 printf("\t Failed to remove slave %d from master port = %d.\n",
4592 slave_port_id, master_port_id);
4596 clear_port_slave_flag(slave_port_id);
4599 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4600 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4602 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4603 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4604 bonding, "bonding");
4605 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4606 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4608 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4609 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4611 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4612 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4615 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4616 .f = cmd_remove_bonding_slave_parsed,
4617 .help_str = "remove bonding slave <slave_id> <port_id>: "
4618 "Remove a slave device from a bonded device",
4621 (void *)&cmd_removebonding_slave_remove,
4622 (void *)&cmd_removebonding_slave_bonding,
4623 (void *)&cmd_removebonding_slave_slave,
4624 (void *)&cmd_removebonding_slave_slaveid,
4625 (void *)&cmd_removebonding_slave_port,
4630 /* *** CREATE BONDED DEVICE *** */
4631 struct cmd_create_bonded_device_result {
4632 cmdline_fixed_string_t create;
4633 cmdline_fixed_string_t bonded;
4634 cmdline_fixed_string_t device;
4639 static int bond_dev_num = 0;
4641 static void cmd_create_bonded_device_parsed(void *parsed_result,
4642 __attribute__((unused)) struct cmdline *cl,
4643 __attribute__((unused)) void *data)
4645 struct cmd_create_bonded_device_result *res = parsed_result;
4646 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4649 if (test_done == 0) {
4650 printf("Please stop forwarding first\n");
4654 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4657 /* Create a new bonded device. */
4658 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4660 printf("\t Failed to create bonded device.\n");
4663 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4666 /* Update number of ports */
4667 nb_ports = rte_eth_dev_count();
4668 reconfig(port_id, res->socket);
4669 rte_eth_promiscuous_enable(port_id);
4670 ports[port_id].enabled = 1;
4675 cmdline_parse_token_string_t cmd_createbonded_device_create =
4676 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4678 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4679 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4681 cmdline_parse_token_string_t cmd_createbonded_device_device =
4682 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4684 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4685 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4687 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4688 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4691 cmdline_parse_inst_t cmd_create_bonded_device = {
4692 .f = cmd_create_bonded_device_parsed,
4693 .help_str = "create bonded device <mode> <socket>: "
4694 "Create a new bonded device with specific bonding mode and socket",
4697 (void *)&cmd_createbonded_device_create,
4698 (void *)&cmd_createbonded_device_bonded,
4699 (void *)&cmd_createbonded_device_device,
4700 (void *)&cmd_createbonded_device_mode,
4701 (void *)&cmd_createbonded_device_socket,
4706 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4707 struct cmd_set_bond_mac_addr_result {
4708 cmdline_fixed_string_t set;
4709 cmdline_fixed_string_t bonding;
4710 cmdline_fixed_string_t mac_addr;
4712 struct ether_addr address;
4715 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4716 __attribute__((unused)) struct cmdline *cl,
4717 __attribute__((unused)) void *data)
4719 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4722 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4725 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4727 /* check the return value and print it if is < 0 */
4729 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4732 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4733 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4734 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4735 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4737 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4738 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4740 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4741 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4742 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4743 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4745 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4746 .f = cmd_set_bond_mac_addr_parsed,
4748 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4750 (void *)&cmd_set_bond_mac_addr_set,
4751 (void *)&cmd_set_bond_mac_addr_bonding,
4752 (void *)&cmd_set_bond_mac_addr_mac,
4753 (void *)&cmd_set_bond_mac_addr_portnum,
4754 (void *)&cmd_set_bond_mac_addr_addr,
4760 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4761 struct cmd_set_bond_mon_period_result {
4762 cmdline_fixed_string_t set;
4763 cmdline_fixed_string_t bonding;
4764 cmdline_fixed_string_t mon_period;
4769 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4770 __attribute__((unused)) struct cmdline *cl,
4771 __attribute__((unused)) void *data)
4773 struct cmd_set_bond_mon_period_result *res = parsed_result;
4776 if (res->port_num >= nb_ports) {
4777 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4781 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4783 /* check the return value and print it if is < 0 */
4785 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4788 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4789 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4791 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4792 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4793 bonding, "bonding");
4794 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4795 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4796 mon_period, "mon_period");
4797 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4798 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4800 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4801 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4804 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4805 .f = cmd_set_bond_mon_period_parsed,
4807 .help_str = "set bonding mon_period <port_id> <period_ms>",
4809 (void *)&cmd_set_bond_mon_period_set,
4810 (void *)&cmd_set_bond_mon_period_bonding,
4811 (void *)&cmd_set_bond_mon_period_mon_period,
4812 (void *)&cmd_set_bond_mon_period_portnum,
4813 (void *)&cmd_set_bond_mon_period_period_ms,
4818 #endif /* RTE_LIBRTE_PMD_BOND */
4820 /* *** SET FORWARDING MODE *** */
4821 struct cmd_set_fwd_mode_result {
4822 cmdline_fixed_string_t set;
4823 cmdline_fixed_string_t fwd;
4824 cmdline_fixed_string_t mode;
4827 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4828 __attribute__((unused)) struct cmdline *cl,
4829 __attribute__((unused)) void *data)
4831 struct cmd_set_fwd_mode_result *res = parsed_result;
4834 set_pkt_forwarding_mode(res->mode);
4837 cmdline_parse_token_string_t cmd_setfwd_set =
4838 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4839 cmdline_parse_token_string_t cmd_setfwd_fwd =
4840 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4841 cmdline_parse_token_string_t cmd_setfwd_mode =
4842 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4843 "" /* defined at init */);
4845 cmdline_parse_inst_t cmd_set_fwd_mode = {
4846 .f = cmd_set_fwd_mode_parsed,
4848 .help_str = NULL, /* defined at init */
4850 (void *)&cmd_setfwd_set,
4851 (void *)&cmd_setfwd_fwd,
4852 (void *)&cmd_setfwd_mode,
4857 static void cmd_set_fwd_mode_init(void)
4860 static char token[128];
4861 static char help[256];
4862 cmdline_parse_token_string_t *token_struct;
4864 modes = list_pkt_forwarding_modes();
4865 snprintf(help, sizeof(help), "set fwd %s: "
4866 "Set packet forwarding mode", modes);
4867 cmd_set_fwd_mode.help_str = help;
4869 /* string token separator is # */
4870 for (c = token; *modes != '\0'; modes++)
4875 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4876 token_struct->string_data.str = token;
4879 /* *** SET RETRY FORWARDING MODE *** */
4880 struct cmd_set_fwd_retry_mode_result {
4881 cmdline_fixed_string_t set;
4882 cmdline_fixed_string_t fwd;
4883 cmdline_fixed_string_t mode;
4884 cmdline_fixed_string_t retry;
4887 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4888 __attribute__((unused)) struct cmdline *cl,
4889 __attribute__((unused)) void *data)
4891 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4894 set_pkt_forwarding_mode(res->mode);
4897 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4898 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4900 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4901 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4903 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4904 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4906 "" /* defined at init */);
4907 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4908 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4911 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4912 .f = cmd_set_fwd_retry_mode_parsed,
4914 .help_str = NULL, /* defined at init */
4916 (void *)&cmd_setfwd_retry_set,
4917 (void *)&cmd_setfwd_retry_fwd,
4918 (void *)&cmd_setfwd_retry_mode,
4919 (void *)&cmd_setfwd_retry_retry,
4924 static void cmd_set_fwd_retry_mode_init(void)
4927 static char token[128];
4928 static char help[256];
4929 cmdline_parse_token_string_t *token_struct;
4931 modes = list_pkt_forwarding_retry_modes();
4932 snprintf(help, sizeof(help), "set fwd %s retry: "
4933 "Set packet forwarding mode with retry", modes);
4934 cmd_set_fwd_retry_mode.help_str = help;
4936 /* string token separator is # */
4937 for (c = token; *modes != '\0'; modes++)
4942 token_struct = (cmdline_parse_token_string_t *)
4943 cmd_set_fwd_retry_mode.tokens[2];
4944 token_struct->string_data.str = token;
4947 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4948 struct cmd_set_burst_tx_retry_result {
4949 cmdline_fixed_string_t set;
4950 cmdline_fixed_string_t burst;
4951 cmdline_fixed_string_t tx;
4952 cmdline_fixed_string_t delay;
4954 cmdline_fixed_string_t retry;
4958 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4959 __attribute__((unused)) struct cmdline *cl,
4960 __attribute__((unused)) void *data)
4962 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4964 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4965 && !strcmp(res->tx, "tx")) {
4966 if (!strcmp(res->delay, "delay"))
4967 burst_tx_delay_time = res->time;
4968 if (!strcmp(res->retry, "retry"))
4969 burst_tx_retry_num = res->retry_num;
4974 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4975 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4976 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4977 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4979 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4980 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4981 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4982 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4983 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4984 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4985 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4986 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4987 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4988 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4990 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4991 .f = cmd_set_burst_tx_retry_parsed,
4992 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4994 (void *)&cmd_set_burst_tx_retry_set,
4995 (void *)&cmd_set_burst_tx_retry_burst,
4996 (void *)&cmd_set_burst_tx_retry_tx,
4997 (void *)&cmd_set_burst_tx_retry_delay,
4998 (void *)&cmd_set_burst_tx_retry_time,
4999 (void *)&cmd_set_burst_tx_retry_retry,
5000 (void *)&cmd_set_burst_tx_retry_retry_num,
5005 /* *** SET PROMISC MODE *** */
5006 struct cmd_set_promisc_mode_result {
5007 cmdline_fixed_string_t set;
5008 cmdline_fixed_string_t promisc;
5009 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5010 uint8_t port_num; /* valid if "allports" argument == 0 */
5011 cmdline_fixed_string_t mode;
5014 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5015 __attribute__((unused)) struct cmdline *cl,
5018 struct cmd_set_promisc_mode_result *res = parsed_result;
5022 if (!strcmp(res->mode, "on"))
5029 FOREACH_PORT(i, ports) {
5031 rte_eth_promiscuous_enable(i);
5033 rte_eth_promiscuous_disable(i);
5038 rte_eth_promiscuous_enable(res->port_num);
5040 rte_eth_promiscuous_disable(res->port_num);
5044 cmdline_parse_token_string_t cmd_setpromisc_set =
5045 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5046 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5047 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5049 cmdline_parse_token_string_t cmd_setpromisc_portall =
5050 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5052 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5053 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5055 cmdline_parse_token_string_t cmd_setpromisc_mode =
5056 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5059 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5060 .f = cmd_set_promisc_mode_parsed,
5062 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5064 (void *)&cmd_setpromisc_set,
5065 (void *)&cmd_setpromisc_promisc,
5066 (void *)&cmd_setpromisc_portall,
5067 (void *)&cmd_setpromisc_mode,
5072 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5073 .f = cmd_set_promisc_mode_parsed,
5075 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5077 (void *)&cmd_setpromisc_set,
5078 (void *)&cmd_setpromisc_promisc,
5079 (void *)&cmd_setpromisc_portnum,
5080 (void *)&cmd_setpromisc_mode,
5085 /* *** SET ALLMULTI MODE *** */
5086 struct cmd_set_allmulti_mode_result {
5087 cmdline_fixed_string_t set;
5088 cmdline_fixed_string_t allmulti;
5089 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5090 uint8_t port_num; /* valid if "allports" argument == 0 */
5091 cmdline_fixed_string_t mode;
5094 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5095 __attribute__((unused)) struct cmdline *cl,
5098 struct cmd_set_allmulti_mode_result *res = parsed_result;
5102 if (!strcmp(res->mode, "on"))
5109 FOREACH_PORT(i, ports) {
5111 rte_eth_allmulticast_enable(i);
5113 rte_eth_allmulticast_disable(i);
5118 rte_eth_allmulticast_enable(res->port_num);
5120 rte_eth_allmulticast_disable(res->port_num);
5124 cmdline_parse_token_string_t cmd_setallmulti_set =
5125 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5126 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5127 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5129 cmdline_parse_token_string_t cmd_setallmulti_portall =
5130 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5132 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5133 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5135 cmdline_parse_token_string_t cmd_setallmulti_mode =
5136 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5139 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5140 .f = cmd_set_allmulti_mode_parsed,
5142 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5144 (void *)&cmd_setallmulti_set,
5145 (void *)&cmd_setallmulti_allmulti,
5146 (void *)&cmd_setallmulti_portall,
5147 (void *)&cmd_setallmulti_mode,
5152 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5153 .f = cmd_set_allmulti_mode_parsed,
5155 .help_str = "set allmulti <port_id> on|off: "
5156 "Set allmulti mode on port_id",
5158 (void *)&cmd_setallmulti_set,
5159 (void *)&cmd_setallmulti_allmulti,
5160 (void *)&cmd_setallmulti_portnum,
5161 (void *)&cmd_setallmulti_mode,
5166 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5167 struct cmd_link_flow_ctrl_set_result {
5168 cmdline_fixed_string_t set;
5169 cmdline_fixed_string_t flow_ctrl;
5170 cmdline_fixed_string_t rx;
5171 cmdline_fixed_string_t rx_lfc_mode;
5172 cmdline_fixed_string_t tx;
5173 cmdline_fixed_string_t tx_lfc_mode;
5174 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5175 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5176 cmdline_fixed_string_t autoneg_str;
5177 cmdline_fixed_string_t autoneg;
5178 cmdline_fixed_string_t hw_str;
5179 uint32_t high_water;
5180 cmdline_fixed_string_t lw_str;
5182 cmdline_fixed_string_t pt_str;
5183 uint16_t pause_time;
5184 cmdline_fixed_string_t xon_str;
5189 cmdline_parse_token_string_t cmd_lfc_set_set =
5190 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5192 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5193 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5194 flow_ctrl, "flow_ctrl");
5195 cmdline_parse_token_string_t cmd_lfc_set_rx =
5196 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5198 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5199 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5200 rx_lfc_mode, "on#off");
5201 cmdline_parse_token_string_t cmd_lfc_set_tx =
5202 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5204 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5205 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5206 tx_lfc_mode, "on#off");
5207 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5208 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5209 hw_str, "high_water");
5210 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5211 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5212 high_water, UINT32);
5213 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5214 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5215 lw_str, "low_water");
5216 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5217 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5219 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5220 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5221 pt_str, "pause_time");
5222 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5223 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5224 pause_time, UINT16);
5225 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5226 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5227 xon_str, "send_xon");
5228 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5229 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5231 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5232 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5233 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5234 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5235 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5236 mac_ctrl_frame_fwd_mode, "on#off");
5237 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5238 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5239 autoneg_str, "autoneg");
5240 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5241 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5243 cmdline_parse_token_num_t cmd_lfc_set_portid =
5244 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5247 /* forward declaration */
5249 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5252 cmdline_parse_inst_t cmd_link_flow_control_set = {
5253 .f = cmd_link_flow_ctrl_set_parsed,
5255 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5256 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5257 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5259 (void *)&cmd_lfc_set_set,
5260 (void *)&cmd_lfc_set_flow_ctrl,
5261 (void *)&cmd_lfc_set_rx,
5262 (void *)&cmd_lfc_set_rx_mode,
5263 (void *)&cmd_lfc_set_tx,
5264 (void *)&cmd_lfc_set_tx_mode,
5265 (void *)&cmd_lfc_set_high_water,
5266 (void *)&cmd_lfc_set_low_water,
5267 (void *)&cmd_lfc_set_pause_time,
5268 (void *)&cmd_lfc_set_send_xon,
5269 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5270 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5271 (void *)&cmd_lfc_set_autoneg_str,
5272 (void *)&cmd_lfc_set_autoneg,
5273 (void *)&cmd_lfc_set_portid,
5278 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5279 .f = cmd_link_flow_ctrl_set_parsed,
5280 .data = (void *)&cmd_link_flow_control_set_rx,
5281 .help_str = "set flow_ctrl rx on|off <port_id>: "
5282 "Change rx flow control parameter",
5284 (void *)&cmd_lfc_set_set,
5285 (void *)&cmd_lfc_set_flow_ctrl,
5286 (void *)&cmd_lfc_set_rx,
5287 (void *)&cmd_lfc_set_rx_mode,
5288 (void *)&cmd_lfc_set_portid,
5293 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5294 .f = cmd_link_flow_ctrl_set_parsed,
5295 .data = (void *)&cmd_link_flow_control_set_tx,
5296 .help_str = "set flow_ctrl tx on|off <port_id>: "
5297 "Change tx flow control parameter",
5299 (void *)&cmd_lfc_set_set,
5300 (void *)&cmd_lfc_set_flow_ctrl,
5301 (void *)&cmd_lfc_set_tx,
5302 (void *)&cmd_lfc_set_tx_mode,
5303 (void *)&cmd_lfc_set_portid,
5308 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5309 .f = cmd_link_flow_ctrl_set_parsed,
5310 .data = (void *)&cmd_link_flow_control_set_hw,
5311 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5312 "Change high water flow control parameter",
5314 (void *)&cmd_lfc_set_set,
5315 (void *)&cmd_lfc_set_flow_ctrl,
5316 (void *)&cmd_lfc_set_high_water_str,
5317 (void *)&cmd_lfc_set_high_water,
5318 (void *)&cmd_lfc_set_portid,
5323 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5324 .f = cmd_link_flow_ctrl_set_parsed,
5325 .data = (void *)&cmd_link_flow_control_set_lw,
5326 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5327 "Change low water flow control parameter",
5329 (void *)&cmd_lfc_set_set,
5330 (void *)&cmd_lfc_set_flow_ctrl,
5331 (void *)&cmd_lfc_set_low_water_str,
5332 (void *)&cmd_lfc_set_low_water,
5333 (void *)&cmd_lfc_set_portid,
5338 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5339 .f = cmd_link_flow_ctrl_set_parsed,
5340 .data = (void *)&cmd_link_flow_control_set_pt,
5341 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5342 "Change pause time flow control parameter",
5344 (void *)&cmd_lfc_set_set,
5345 (void *)&cmd_lfc_set_flow_ctrl,
5346 (void *)&cmd_lfc_set_pause_time_str,
5347 (void *)&cmd_lfc_set_pause_time,
5348 (void *)&cmd_lfc_set_portid,
5353 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5354 .f = cmd_link_flow_ctrl_set_parsed,
5355 .data = (void *)&cmd_link_flow_control_set_xon,
5356 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5357 "Change send_xon flow control parameter",
5359 (void *)&cmd_lfc_set_set,
5360 (void *)&cmd_lfc_set_flow_ctrl,
5361 (void *)&cmd_lfc_set_send_xon_str,
5362 (void *)&cmd_lfc_set_send_xon,
5363 (void *)&cmd_lfc_set_portid,
5368 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5369 .f = cmd_link_flow_ctrl_set_parsed,
5370 .data = (void *)&cmd_link_flow_control_set_macfwd,
5371 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5372 "Change mac ctrl fwd flow control parameter",
5374 (void *)&cmd_lfc_set_set,
5375 (void *)&cmd_lfc_set_flow_ctrl,
5376 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5377 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5378 (void *)&cmd_lfc_set_portid,
5383 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5384 .f = cmd_link_flow_ctrl_set_parsed,
5385 .data = (void *)&cmd_link_flow_control_set_autoneg,
5386 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5387 "Change autoneg flow control parameter",
5389 (void *)&cmd_lfc_set_set,
5390 (void *)&cmd_lfc_set_flow_ctrl,
5391 (void *)&cmd_lfc_set_autoneg_str,
5392 (void *)&cmd_lfc_set_autoneg,
5393 (void *)&cmd_lfc_set_portid,
5399 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5400 __attribute__((unused)) struct cmdline *cl,
5403 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5404 cmdline_parse_inst_t *cmd = data;
5405 struct rte_eth_fc_conf fc_conf;
5411 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5412 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5413 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5414 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5416 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5417 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5420 /* Partial command line, retrieve current configuration */
5422 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5424 printf("cannot get current flow ctrl parameters, return"
5425 "code = %d\n", ret);
5429 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5430 (fc_conf.mode == RTE_FC_FULL))
5432 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5433 (fc_conf.mode == RTE_FC_FULL))
5437 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5438 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5440 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5441 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5443 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5445 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5446 fc_conf.high_water = res->high_water;
5448 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5449 fc_conf.low_water = res->low_water;
5451 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5452 fc_conf.pause_time = res->pause_time;
5454 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5455 fc_conf.send_xon = res->send_xon;
5457 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5458 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5459 fc_conf.mac_ctrl_frame_fwd = 1;
5461 fc_conf.mac_ctrl_frame_fwd = 0;
5464 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5465 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5467 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5469 printf("bad flow contrl parameter, return code = %d \n", ret);
5472 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5473 struct cmd_priority_flow_ctrl_set_result {
5474 cmdline_fixed_string_t set;
5475 cmdline_fixed_string_t pfc_ctrl;
5476 cmdline_fixed_string_t rx;
5477 cmdline_fixed_string_t rx_pfc_mode;
5478 cmdline_fixed_string_t tx;
5479 cmdline_fixed_string_t tx_pfc_mode;
5480 uint32_t high_water;
5482 uint16_t pause_time;
5488 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5489 __attribute__((unused)) struct cmdline *cl,
5490 __attribute__((unused)) void *data)
5492 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5493 struct rte_eth_pfc_conf pfc_conf;
5494 int rx_fc_enable, tx_fc_enable;
5498 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5499 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5500 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5501 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5503 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5504 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5507 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5508 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5509 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5510 pfc_conf.fc.high_water = res->high_water;
5511 pfc_conf.fc.low_water = res->low_water;
5512 pfc_conf.fc.pause_time = res->pause_time;
5513 pfc_conf.priority = res->priority;
5515 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5517 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5520 cmdline_parse_token_string_t cmd_pfc_set_set =
5521 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5523 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5524 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5525 pfc_ctrl, "pfc_ctrl");
5526 cmdline_parse_token_string_t cmd_pfc_set_rx =
5527 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5529 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5530 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5531 rx_pfc_mode, "on#off");
5532 cmdline_parse_token_string_t cmd_pfc_set_tx =
5533 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5535 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5536 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5537 tx_pfc_mode, "on#off");
5538 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5539 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5540 high_water, UINT32);
5541 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5542 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5544 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5545 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5546 pause_time, UINT16);
5547 cmdline_parse_token_num_t cmd_pfc_set_priority =
5548 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5550 cmdline_parse_token_num_t cmd_pfc_set_portid =
5551 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5554 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5555 .f = cmd_priority_flow_ctrl_set_parsed,
5557 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5558 "<pause_time> <priority> <port_id>: "
5559 "Configure the Ethernet priority flow control",
5561 (void *)&cmd_pfc_set_set,
5562 (void *)&cmd_pfc_set_flow_ctrl,
5563 (void *)&cmd_pfc_set_rx,
5564 (void *)&cmd_pfc_set_rx_mode,
5565 (void *)&cmd_pfc_set_tx,
5566 (void *)&cmd_pfc_set_tx_mode,
5567 (void *)&cmd_pfc_set_high_water,
5568 (void *)&cmd_pfc_set_low_water,
5569 (void *)&cmd_pfc_set_pause_time,
5570 (void *)&cmd_pfc_set_priority,
5571 (void *)&cmd_pfc_set_portid,
5576 /* *** RESET CONFIGURATION *** */
5577 struct cmd_reset_result {
5578 cmdline_fixed_string_t reset;
5579 cmdline_fixed_string_t def;
5582 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5584 __attribute__((unused)) void *data)
5586 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5587 set_def_fwd_config();
5590 cmdline_parse_token_string_t cmd_reset_set =
5591 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5592 cmdline_parse_token_string_t cmd_reset_def =
5593 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5596 cmdline_parse_inst_t cmd_reset = {
5597 .f = cmd_reset_parsed,
5599 .help_str = "set default: Reset default forwarding configuration",
5601 (void *)&cmd_reset_set,
5602 (void *)&cmd_reset_def,
5607 /* *** START FORWARDING *** */
5608 struct cmd_start_result {
5609 cmdline_fixed_string_t start;
5612 cmdline_parse_token_string_t cmd_start_start =
5613 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5615 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5616 __attribute__((unused)) struct cmdline *cl,
5617 __attribute__((unused)) void *data)
5619 start_packet_forwarding(0);
5622 cmdline_parse_inst_t cmd_start = {
5623 .f = cmd_start_parsed,
5625 .help_str = "start: Start packet forwarding",
5627 (void *)&cmd_start_start,
5632 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5633 struct cmd_start_tx_first_result {
5634 cmdline_fixed_string_t start;
5635 cmdline_fixed_string_t tx_first;
5639 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5640 __attribute__((unused)) struct cmdline *cl,
5641 __attribute__((unused)) void *data)
5643 start_packet_forwarding(1);
5646 cmdline_parse_token_string_t cmd_start_tx_first_start =
5647 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5649 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5650 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5651 tx_first, "tx_first");
5653 cmdline_parse_inst_t cmd_start_tx_first = {
5654 .f = cmd_start_tx_first_parsed,
5656 .help_str = "start tx_first: Start packet forwarding, "
5657 "after sending 1 burst of packets",
5659 (void *)&cmd_start_tx_first_start,
5660 (void *)&cmd_start_tx_first_tx_first,
5665 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5666 struct cmd_start_tx_first_n_result {
5667 cmdline_fixed_string_t start;
5668 cmdline_fixed_string_t tx_first;
5673 cmd_start_tx_first_n_parsed(void *parsed_result,
5674 __attribute__((unused)) struct cmdline *cl,
5675 __attribute__((unused)) void *data)
5677 struct cmd_start_tx_first_n_result *res = parsed_result;
5679 start_packet_forwarding(res->tx_num);
5682 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5683 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5685 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5686 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5687 tx_first, "tx_first");
5688 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5689 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5692 cmdline_parse_inst_t cmd_start_tx_first_n = {
5693 .f = cmd_start_tx_first_n_parsed,
5695 .help_str = "start tx_first <num>: "
5696 "packet forwarding, after sending <num> bursts of packets",
5698 (void *)&cmd_start_tx_first_n_start,
5699 (void *)&cmd_start_tx_first_n_tx_first,
5700 (void *)&cmd_start_tx_first_n_tx_num,
5705 /* *** SET LINK UP *** */
5706 struct cmd_set_link_up_result {
5707 cmdline_fixed_string_t set;
5708 cmdline_fixed_string_t link_up;
5709 cmdline_fixed_string_t port;
5713 cmdline_parse_token_string_t cmd_set_link_up_set =
5714 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5715 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5716 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5718 cmdline_parse_token_string_t cmd_set_link_up_port =
5719 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5720 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5721 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5723 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5724 __attribute__((unused)) struct cmdline *cl,
5725 __attribute__((unused)) void *data)
5727 struct cmd_set_link_up_result *res = parsed_result;
5728 dev_set_link_up(res->port_id);
5731 cmdline_parse_inst_t cmd_set_link_up = {
5732 .f = cmd_set_link_up_parsed,
5734 .help_str = "set link-up port <port id>",
5736 (void *)&cmd_set_link_up_set,
5737 (void *)&cmd_set_link_up_link_up,
5738 (void *)&cmd_set_link_up_port,
5739 (void *)&cmd_set_link_up_port_id,
5744 /* *** SET LINK DOWN *** */
5745 struct cmd_set_link_down_result {
5746 cmdline_fixed_string_t set;
5747 cmdline_fixed_string_t link_down;
5748 cmdline_fixed_string_t port;
5752 cmdline_parse_token_string_t cmd_set_link_down_set =
5753 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5754 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5755 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5757 cmdline_parse_token_string_t cmd_set_link_down_port =
5758 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5759 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5760 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5762 static void cmd_set_link_down_parsed(
5763 __attribute__((unused)) void *parsed_result,
5764 __attribute__((unused)) struct cmdline *cl,
5765 __attribute__((unused)) void *data)
5767 struct cmd_set_link_down_result *res = parsed_result;
5768 dev_set_link_down(res->port_id);
5771 cmdline_parse_inst_t cmd_set_link_down = {
5772 .f = cmd_set_link_down_parsed,
5774 .help_str = "set link-down port <port id>",
5776 (void *)&cmd_set_link_down_set,
5777 (void *)&cmd_set_link_down_link_down,
5778 (void *)&cmd_set_link_down_port,
5779 (void *)&cmd_set_link_down_port_id,
5784 /* *** SHOW CFG *** */
5785 struct cmd_showcfg_result {
5786 cmdline_fixed_string_t show;
5787 cmdline_fixed_string_t cfg;
5788 cmdline_fixed_string_t what;
5791 static void cmd_showcfg_parsed(void *parsed_result,
5792 __attribute__((unused)) struct cmdline *cl,
5793 __attribute__((unused)) void *data)
5795 struct cmd_showcfg_result *res = parsed_result;
5796 if (!strcmp(res->what, "rxtx"))
5797 rxtx_config_display();
5798 else if (!strcmp(res->what, "cores"))
5799 fwd_lcores_config_display();
5800 else if (!strcmp(res->what, "fwd"))
5801 pkt_fwd_config_display(&cur_fwd_config);
5802 else if (!strcmp(res->what, "txpkts"))
5803 show_tx_pkt_segments();
5806 cmdline_parse_token_string_t cmd_showcfg_show =
5807 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5808 cmdline_parse_token_string_t cmd_showcfg_port =
5809 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5810 cmdline_parse_token_string_t cmd_showcfg_what =
5811 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5812 "rxtx#cores#fwd#txpkts");
5814 cmdline_parse_inst_t cmd_showcfg = {
5815 .f = cmd_showcfg_parsed,
5817 .help_str = "show config rxtx|cores|fwd|txpkts",
5819 (void *)&cmd_showcfg_show,
5820 (void *)&cmd_showcfg_port,
5821 (void *)&cmd_showcfg_what,
5826 /* *** SHOW ALL PORT INFO *** */
5827 struct cmd_showportall_result {
5828 cmdline_fixed_string_t show;
5829 cmdline_fixed_string_t port;
5830 cmdline_fixed_string_t what;
5831 cmdline_fixed_string_t all;
5834 static void cmd_showportall_parsed(void *parsed_result,
5835 __attribute__((unused)) struct cmdline *cl,
5836 __attribute__((unused)) void *data)
5840 struct cmd_showportall_result *res = parsed_result;
5841 if (!strcmp(res->show, "clear")) {
5842 if (!strcmp(res->what, "stats"))
5843 FOREACH_PORT(i, ports)
5845 else if (!strcmp(res->what, "xstats"))
5846 FOREACH_PORT(i, ports)
5847 nic_xstats_clear(i);
5848 } else if (!strcmp(res->what, "info"))
5849 FOREACH_PORT(i, ports)
5850 port_infos_display(i);
5851 else if (!strcmp(res->what, "stats"))
5852 FOREACH_PORT(i, ports)
5853 nic_stats_display(i);
5854 else if (!strcmp(res->what, "xstats"))
5855 FOREACH_PORT(i, ports)
5856 nic_xstats_display(i);
5857 else if (!strcmp(res->what, "fdir"))
5858 FOREACH_PORT(i, ports)
5860 else if (!strcmp(res->what, "stat_qmap"))
5861 FOREACH_PORT(i, ports)
5862 nic_stats_mapping_display(i);
5863 else if (!strcmp(res->what, "dcb_tc"))
5864 FOREACH_PORT(i, ports)
5865 port_dcb_info_display(i);
5866 else if (!strcmp(res->what, "cap"))
5867 FOREACH_PORT(i, ports)
5868 port_offload_cap_display(i);
5871 cmdline_parse_token_string_t cmd_showportall_show =
5872 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5874 cmdline_parse_token_string_t cmd_showportall_port =
5875 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5876 cmdline_parse_token_string_t cmd_showportall_what =
5877 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5878 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5879 cmdline_parse_token_string_t cmd_showportall_all =
5880 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5881 cmdline_parse_inst_t cmd_showportall = {
5882 .f = cmd_showportall_parsed,
5884 .help_str = "show|clear port "
5885 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5887 (void *)&cmd_showportall_show,
5888 (void *)&cmd_showportall_port,
5889 (void *)&cmd_showportall_what,
5890 (void *)&cmd_showportall_all,
5895 /* *** SHOW PORT INFO *** */
5896 struct cmd_showport_result {
5897 cmdline_fixed_string_t show;
5898 cmdline_fixed_string_t port;
5899 cmdline_fixed_string_t what;
5903 static void cmd_showport_parsed(void *parsed_result,
5904 __attribute__((unused)) struct cmdline *cl,
5905 __attribute__((unused)) void *data)
5907 struct cmd_showport_result *res = parsed_result;
5908 if (!strcmp(res->show, "clear")) {
5909 if (!strcmp(res->what, "stats"))
5910 nic_stats_clear(res->portnum);
5911 else if (!strcmp(res->what, "xstats"))
5912 nic_xstats_clear(res->portnum);
5913 } else if (!strcmp(res->what, "info"))
5914 port_infos_display(res->portnum);
5915 else if (!strcmp(res->what, "stats"))
5916 nic_stats_display(res->portnum);
5917 else if (!strcmp(res->what, "xstats"))
5918 nic_xstats_display(res->portnum);
5919 else if (!strcmp(res->what, "fdir"))
5920 fdir_get_infos(res->portnum);
5921 else if (!strcmp(res->what, "stat_qmap"))
5922 nic_stats_mapping_display(res->portnum);
5923 else if (!strcmp(res->what, "dcb_tc"))
5924 port_dcb_info_display(res->portnum);
5925 else if (!strcmp(res->what, "cap"))
5926 port_offload_cap_display(res->portnum);
5929 cmdline_parse_token_string_t cmd_showport_show =
5930 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5932 cmdline_parse_token_string_t cmd_showport_port =
5933 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5934 cmdline_parse_token_string_t cmd_showport_what =
5935 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5936 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5937 cmdline_parse_token_num_t cmd_showport_portnum =
5938 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5940 cmdline_parse_inst_t cmd_showport = {
5941 .f = cmd_showport_parsed,
5943 .help_str = "show|clear port "
5944 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5947 (void *)&cmd_showport_show,
5948 (void *)&cmd_showport_port,
5949 (void *)&cmd_showport_what,
5950 (void *)&cmd_showport_portnum,
5955 /* *** SHOW QUEUE INFO *** */
5956 struct cmd_showqueue_result {
5957 cmdline_fixed_string_t show;
5958 cmdline_fixed_string_t type;
5959 cmdline_fixed_string_t what;
5965 cmd_showqueue_parsed(void *parsed_result,
5966 __attribute__((unused)) struct cmdline *cl,
5967 __attribute__((unused)) void *data)
5969 struct cmd_showqueue_result *res = parsed_result;
5971 if (!strcmp(res->type, "rxq"))
5972 rx_queue_infos_display(res->portnum, res->queuenum);
5973 else if (!strcmp(res->type, "txq"))
5974 tx_queue_infos_display(res->portnum, res->queuenum);
5977 cmdline_parse_token_string_t cmd_showqueue_show =
5978 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5979 cmdline_parse_token_string_t cmd_showqueue_type =
5980 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5981 cmdline_parse_token_string_t cmd_showqueue_what =
5982 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5983 cmdline_parse_token_num_t cmd_showqueue_portnum =
5984 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5985 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5986 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5988 cmdline_parse_inst_t cmd_showqueue = {
5989 .f = cmd_showqueue_parsed,
5991 .help_str = "show rxq|txq info <port_id> <queue_id>",
5993 (void *)&cmd_showqueue_show,
5994 (void *)&cmd_showqueue_type,
5995 (void *)&cmd_showqueue_what,
5996 (void *)&cmd_showqueue_portnum,
5997 (void *)&cmd_showqueue_queuenum,
6002 /* *** READ PORT REGISTER *** */
6003 struct cmd_read_reg_result {
6004 cmdline_fixed_string_t read;
6005 cmdline_fixed_string_t reg;
6011 cmd_read_reg_parsed(void *parsed_result,
6012 __attribute__((unused)) struct cmdline *cl,
6013 __attribute__((unused)) void *data)
6015 struct cmd_read_reg_result *res = parsed_result;
6016 port_reg_display(res->port_id, res->reg_off);
6019 cmdline_parse_token_string_t cmd_read_reg_read =
6020 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6021 cmdline_parse_token_string_t cmd_read_reg_reg =
6022 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6023 cmdline_parse_token_num_t cmd_read_reg_port_id =
6024 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6025 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6026 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6028 cmdline_parse_inst_t cmd_read_reg = {
6029 .f = cmd_read_reg_parsed,
6031 .help_str = "read reg <port_id> <reg_off>",
6033 (void *)&cmd_read_reg_read,
6034 (void *)&cmd_read_reg_reg,
6035 (void *)&cmd_read_reg_port_id,
6036 (void *)&cmd_read_reg_reg_off,
6041 /* *** READ PORT REGISTER BIT FIELD *** */
6042 struct cmd_read_reg_bit_field_result {
6043 cmdline_fixed_string_t read;
6044 cmdline_fixed_string_t regfield;
6052 cmd_read_reg_bit_field_parsed(void *parsed_result,
6053 __attribute__((unused)) struct cmdline *cl,
6054 __attribute__((unused)) void *data)
6056 struct cmd_read_reg_bit_field_result *res = parsed_result;
6057 port_reg_bit_field_display(res->port_id, res->reg_off,
6058 res->bit1_pos, res->bit2_pos);
6061 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6062 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6064 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6065 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6066 regfield, "regfield");
6067 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6068 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6070 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6071 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6073 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6074 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6076 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6077 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6080 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6081 .f = cmd_read_reg_bit_field_parsed,
6083 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6084 "Read register bit field between bit_x and bit_y included",
6086 (void *)&cmd_read_reg_bit_field_read,
6087 (void *)&cmd_read_reg_bit_field_regfield,
6088 (void *)&cmd_read_reg_bit_field_port_id,
6089 (void *)&cmd_read_reg_bit_field_reg_off,
6090 (void *)&cmd_read_reg_bit_field_bit1_pos,
6091 (void *)&cmd_read_reg_bit_field_bit2_pos,
6096 /* *** READ PORT REGISTER BIT *** */
6097 struct cmd_read_reg_bit_result {
6098 cmdline_fixed_string_t read;
6099 cmdline_fixed_string_t regbit;
6106 cmd_read_reg_bit_parsed(void *parsed_result,
6107 __attribute__((unused)) struct cmdline *cl,
6108 __attribute__((unused)) void *data)
6110 struct cmd_read_reg_bit_result *res = parsed_result;
6111 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6114 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6115 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6116 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6117 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6119 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6120 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6121 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6122 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6123 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6124 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6126 cmdline_parse_inst_t cmd_read_reg_bit = {
6127 .f = cmd_read_reg_bit_parsed,
6129 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6131 (void *)&cmd_read_reg_bit_read,
6132 (void *)&cmd_read_reg_bit_regbit,
6133 (void *)&cmd_read_reg_bit_port_id,
6134 (void *)&cmd_read_reg_bit_reg_off,
6135 (void *)&cmd_read_reg_bit_bit_pos,
6140 /* *** WRITE PORT REGISTER *** */
6141 struct cmd_write_reg_result {
6142 cmdline_fixed_string_t write;
6143 cmdline_fixed_string_t reg;
6150 cmd_write_reg_parsed(void *parsed_result,
6151 __attribute__((unused)) struct cmdline *cl,
6152 __attribute__((unused)) void *data)
6154 struct cmd_write_reg_result *res = parsed_result;
6155 port_reg_set(res->port_id, res->reg_off, res->value);
6158 cmdline_parse_token_string_t cmd_write_reg_write =
6159 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6160 cmdline_parse_token_string_t cmd_write_reg_reg =
6161 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6162 cmdline_parse_token_num_t cmd_write_reg_port_id =
6163 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6164 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6165 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6166 cmdline_parse_token_num_t cmd_write_reg_value =
6167 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6169 cmdline_parse_inst_t cmd_write_reg = {
6170 .f = cmd_write_reg_parsed,
6172 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6174 (void *)&cmd_write_reg_write,
6175 (void *)&cmd_write_reg_reg,
6176 (void *)&cmd_write_reg_port_id,
6177 (void *)&cmd_write_reg_reg_off,
6178 (void *)&cmd_write_reg_value,
6183 /* *** WRITE PORT REGISTER BIT FIELD *** */
6184 struct cmd_write_reg_bit_field_result {
6185 cmdline_fixed_string_t write;
6186 cmdline_fixed_string_t regfield;
6195 cmd_write_reg_bit_field_parsed(void *parsed_result,
6196 __attribute__((unused)) struct cmdline *cl,
6197 __attribute__((unused)) void *data)
6199 struct cmd_write_reg_bit_field_result *res = parsed_result;
6200 port_reg_bit_field_set(res->port_id, res->reg_off,
6201 res->bit1_pos, res->bit2_pos, res->value);
6204 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6205 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6207 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6208 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6209 regfield, "regfield");
6210 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6211 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6213 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6214 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6216 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6217 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6219 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6220 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6222 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6223 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6226 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6227 .f = cmd_write_reg_bit_field_parsed,
6229 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6231 "Set register bit field between bit_x and bit_y included",
6233 (void *)&cmd_write_reg_bit_field_write,
6234 (void *)&cmd_write_reg_bit_field_regfield,
6235 (void *)&cmd_write_reg_bit_field_port_id,
6236 (void *)&cmd_write_reg_bit_field_reg_off,
6237 (void *)&cmd_write_reg_bit_field_bit1_pos,
6238 (void *)&cmd_write_reg_bit_field_bit2_pos,
6239 (void *)&cmd_write_reg_bit_field_value,
6244 /* *** WRITE PORT REGISTER BIT *** */
6245 struct cmd_write_reg_bit_result {
6246 cmdline_fixed_string_t write;
6247 cmdline_fixed_string_t regbit;
6255 cmd_write_reg_bit_parsed(void *parsed_result,
6256 __attribute__((unused)) struct cmdline *cl,
6257 __attribute__((unused)) void *data)
6259 struct cmd_write_reg_bit_result *res = parsed_result;
6260 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6263 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6264 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6266 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6267 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6269 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6270 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6271 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6272 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6273 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6274 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6275 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6276 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6278 cmdline_parse_inst_t cmd_write_reg_bit = {
6279 .f = cmd_write_reg_bit_parsed,
6281 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6284 (void *)&cmd_write_reg_bit_write,
6285 (void *)&cmd_write_reg_bit_regbit,
6286 (void *)&cmd_write_reg_bit_port_id,
6287 (void *)&cmd_write_reg_bit_reg_off,
6288 (void *)&cmd_write_reg_bit_bit_pos,
6289 (void *)&cmd_write_reg_bit_value,
6294 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6295 struct cmd_read_rxd_txd_result {
6296 cmdline_fixed_string_t read;
6297 cmdline_fixed_string_t rxd_txd;
6304 cmd_read_rxd_txd_parsed(void *parsed_result,
6305 __attribute__((unused)) struct cmdline *cl,
6306 __attribute__((unused)) void *data)
6308 struct cmd_read_rxd_txd_result *res = parsed_result;
6310 if (!strcmp(res->rxd_txd, "rxd"))
6311 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6312 else if (!strcmp(res->rxd_txd, "txd"))
6313 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6316 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6317 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6318 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6319 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6321 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6322 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6323 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6324 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6325 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6326 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6328 cmdline_parse_inst_t cmd_read_rxd_txd = {
6329 .f = cmd_read_rxd_txd_parsed,
6331 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6333 (void *)&cmd_read_rxd_txd_read,
6334 (void *)&cmd_read_rxd_txd_rxd_txd,
6335 (void *)&cmd_read_rxd_txd_port_id,
6336 (void *)&cmd_read_rxd_txd_queue_id,
6337 (void *)&cmd_read_rxd_txd_desc_id,
6343 struct cmd_quit_result {
6344 cmdline_fixed_string_t quit;
6347 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6349 __attribute__((unused)) void *data)
6355 cmdline_parse_token_string_t cmd_quit_quit =
6356 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6358 cmdline_parse_inst_t cmd_quit = {
6359 .f = cmd_quit_parsed,
6361 .help_str = "quit: Exit application",
6363 (void *)&cmd_quit_quit,
6368 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6369 struct cmd_mac_addr_result {
6370 cmdline_fixed_string_t mac_addr_cmd;
6371 cmdline_fixed_string_t what;
6373 struct ether_addr address;
6376 static void cmd_mac_addr_parsed(void *parsed_result,
6377 __attribute__((unused)) struct cmdline *cl,
6378 __attribute__((unused)) void *data)
6380 struct cmd_mac_addr_result *res = parsed_result;
6383 if (strcmp(res->what, "add") == 0)
6384 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6385 else if (strcmp(res->what, "set") == 0)
6386 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6389 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6391 /* check the return value and print it if is < 0 */
6393 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6397 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6398 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6400 cmdline_parse_token_string_t cmd_mac_addr_what =
6401 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6403 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6404 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6405 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6406 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6408 cmdline_parse_inst_t cmd_mac_addr = {
6409 .f = cmd_mac_addr_parsed,
6411 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6412 "Add/Remove/Set MAC address on port_id",
6414 (void *)&cmd_mac_addr_cmd,
6415 (void *)&cmd_mac_addr_what,
6416 (void *)&cmd_mac_addr_portnum,
6417 (void *)&cmd_mac_addr_addr,
6423 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6424 struct cmd_set_qmap_result {
6425 cmdline_fixed_string_t set;
6426 cmdline_fixed_string_t qmap;
6427 cmdline_fixed_string_t what;
6434 cmd_set_qmap_parsed(void *parsed_result,
6435 __attribute__((unused)) struct cmdline *cl,
6436 __attribute__((unused)) void *data)
6438 struct cmd_set_qmap_result *res = parsed_result;
6439 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6441 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6444 cmdline_parse_token_string_t cmd_setqmap_set =
6445 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6447 cmdline_parse_token_string_t cmd_setqmap_qmap =
6448 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6450 cmdline_parse_token_string_t cmd_setqmap_what =
6451 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6453 cmdline_parse_token_num_t cmd_setqmap_portid =
6454 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6456 cmdline_parse_token_num_t cmd_setqmap_queueid =
6457 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6459 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6460 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6463 cmdline_parse_inst_t cmd_set_qmap = {
6464 .f = cmd_set_qmap_parsed,
6466 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6467 "Set statistics mapping value on tx|rx queue_id of port_id",
6469 (void *)&cmd_setqmap_set,
6470 (void *)&cmd_setqmap_qmap,
6471 (void *)&cmd_setqmap_what,
6472 (void *)&cmd_setqmap_portid,
6473 (void *)&cmd_setqmap_queueid,
6474 (void *)&cmd_setqmap_mapvalue,
6479 /* *** CONFIGURE UNICAST HASH TABLE *** */
6480 struct cmd_set_uc_hash_table {
6481 cmdline_fixed_string_t set;
6482 cmdline_fixed_string_t port;
6484 cmdline_fixed_string_t what;
6485 struct ether_addr address;
6486 cmdline_fixed_string_t mode;
6490 cmd_set_uc_hash_parsed(void *parsed_result,
6491 __attribute__((unused)) struct cmdline *cl,
6492 __attribute__((unused)) void *data)
6495 struct cmd_set_uc_hash_table *res = parsed_result;
6497 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6499 if (strcmp(res->what, "uta") == 0)
6500 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6501 &res->address,(uint8_t)is_on);
6503 printf("bad unicast hash table parameter, return code = %d \n", ret);
6507 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6508 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6510 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6511 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6513 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6514 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6516 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6517 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6519 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6520 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6522 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6523 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6526 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6527 .f = cmd_set_uc_hash_parsed,
6529 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6531 (void *)&cmd_set_uc_hash_set,
6532 (void *)&cmd_set_uc_hash_port,
6533 (void *)&cmd_set_uc_hash_portid,
6534 (void *)&cmd_set_uc_hash_what,
6535 (void *)&cmd_set_uc_hash_mac,
6536 (void *)&cmd_set_uc_hash_mode,
6541 struct cmd_set_uc_all_hash_table {
6542 cmdline_fixed_string_t set;
6543 cmdline_fixed_string_t port;
6545 cmdline_fixed_string_t what;
6546 cmdline_fixed_string_t value;
6547 cmdline_fixed_string_t mode;
6551 cmd_set_uc_all_hash_parsed(void *parsed_result,
6552 __attribute__((unused)) struct cmdline *cl,
6553 __attribute__((unused)) void *data)
6556 struct cmd_set_uc_all_hash_table *res = parsed_result;
6558 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6560 if ((strcmp(res->what, "uta") == 0) &&
6561 (strcmp(res->value, "all") == 0))
6562 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6564 printf("bad unicast hash table parameter,"
6565 "return code = %d \n", ret);
6568 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6569 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6571 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6572 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6574 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6575 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6577 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6578 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6580 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6581 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6583 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6584 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6587 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6588 .f = cmd_set_uc_all_hash_parsed,
6590 .help_str = "set port <port_id> uta all on|off",
6592 (void *)&cmd_set_uc_all_hash_set,
6593 (void *)&cmd_set_uc_all_hash_port,
6594 (void *)&cmd_set_uc_all_hash_portid,
6595 (void *)&cmd_set_uc_all_hash_what,
6596 (void *)&cmd_set_uc_all_hash_value,
6597 (void *)&cmd_set_uc_all_hash_mode,
6602 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6603 struct cmd_set_vf_macvlan_filter {
6604 cmdline_fixed_string_t set;
6605 cmdline_fixed_string_t port;
6607 cmdline_fixed_string_t vf;
6609 struct ether_addr address;
6610 cmdline_fixed_string_t filter_type;
6611 cmdline_fixed_string_t mode;
6615 cmd_set_vf_macvlan_parsed(void *parsed_result,
6616 __attribute__((unused)) struct cmdline *cl,
6617 __attribute__((unused)) void *data)
6620 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6621 struct rte_eth_mac_filter filter;
6623 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6625 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6627 /* set VF MAC filter */
6631 filter.dst_id = res->vf_id;
6633 if (!strcmp(res->filter_type, "exact-mac"))
6634 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6635 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6636 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6637 else if (!strcmp(res->filter_type, "hashmac"))
6638 filter.filter_type = RTE_MAC_HASH_MATCH;
6639 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6640 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6642 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6645 ret = rte_eth_dev_filter_ctrl(res->port_id,
6646 RTE_ETH_FILTER_MACVLAN,
6650 ret = rte_eth_dev_filter_ctrl(res->port_id,
6651 RTE_ETH_FILTER_MACVLAN,
6652 RTE_ETH_FILTER_DELETE,
6656 printf("bad set MAC hash parameter, return code = %d\n", ret);
6660 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6661 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6663 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6664 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6666 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6667 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6669 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6670 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6672 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6673 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6675 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6676 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6678 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6679 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6680 filter_type, "exact-mac#exact-mac-vlan"
6681 "#hashmac#hashmac-vlan");
6682 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6683 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6686 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6687 .f = cmd_set_vf_macvlan_parsed,
6689 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6690 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6691 "Exact match rule: exact match of MAC or MAC and VLAN; "
6692 "hash match rule: hash match of MAC and exact match of VLAN",
6694 (void *)&cmd_set_vf_macvlan_set,
6695 (void *)&cmd_set_vf_macvlan_port,
6696 (void *)&cmd_set_vf_macvlan_portid,
6697 (void *)&cmd_set_vf_macvlan_vf,
6698 (void *)&cmd_set_vf_macvlan_vf_id,
6699 (void *)&cmd_set_vf_macvlan_mac,
6700 (void *)&cmd_set_vf_macvlan_filter_type,
6701 (void *)&cmd_set_vf_macvlan_mode,
6706 #ifdef RTE_LIBRTE_IXGBE_PMD
6707 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6708 struct cmd_set_vf_traffic {
6709 cmdline_fixed_string_t set;
6710 cmdline_fixed_string_t port;
6712 cmdline_fixed_string_t vf;
6714 cmdline_fixed_string_t what;
6715 cmdline_fixed_string_t mode;
6719 cmd_set_vf_traffic_parsed(void *parsed_result,
6720 __attribute__((unused)) struct cmdline *cl,
6721 __attribute__((unused)) void *data)
6723 struct cmd_set_vf_traffic *res = parsed_result;
6724 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6725 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6727 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6730 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6731 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6733 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6734 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6736 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6737 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6739 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6740 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6742 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6743 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6745 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6746 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6748 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6749 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6752 cmdline_parse_inst_t cmd_set_vf_traffic = {
6753 .f = cmd_set_vf_traffic_parsed,
6755 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6757 (void *)&cmd_setvf_traffic_set,
6758 (void *)&cmd_setvf_traffic_port,
6759 (void *)&cmd_setvf_traffic_portid,
6760 (void *)&cmd_setvf_traffic_vf,
6761 (void *)&cmd_setvf_traffic_vfid,
6762 (void *)&cmd_setvf_traffic_what,
6763 (void *)&cmd_setvf_traffic_mode,
6768 /* *** CONFIGURE VF RECEIVE MODE *** */
6769 struct cmd_set_vf_rxmode {
6770 cmdline_fixed_string_t set;
6771 cmdline_fixed_string_t port;
6773 cmdline_fixed_string_t vf;
6775 cmdline_fixed_string_t what;
6776 cmdline_fixed_string_t mode;
6777 cmdline_fixed_string_t on;
6781 cmd_set_vf_rxmode_parsed(void *parsed_result,
6782 __attribute__((unused)) struct cmdline *cl,
6783 __attribute__((unused)) void *data)
6786 uint16_t rx_mode = 0;
6787 struct cmd_set_vf_rxmode *res = parsed_result;
6789 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6790 if (!strcmp(res->what,"rxmode")) {
6791 if (!strcmp(res->mode, "AUPE"))
6792 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6793 else if (!strcmp(res->mode, "ROPE"))
6794 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6795 else if (!strcmp(res->mode, "BAM"))
6796 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6797 else if (!strncmp(res->mode, "MPE",3))
6798 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6801 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6803 printf("bad VF receive mode parameter, return code = %d \n",
6807 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6808 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6810 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6811 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6813 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6814 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6816 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6817 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6819 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6820 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6822 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6823 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6825 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6826 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6827 mode, "AUPE#ROPE#BAM#MPE");
6828 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6829 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6832 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6833 .f = cmd_set_vf_rxmode_parsed,
6835 .help_str = "set port <port_id> vf <vf_id> rxmode "
6836 "AUPE|ROPE|BAM|MPE on|off",
6838 (void *)&cmd_set_vf_rxmode_set,
6839 (void *)&cmd_set_vf_rxmode_port,
6840 (void *)&cmd_set_vf_rxmode_portid,
6841 (void *)&cmd_set_vf_rxmode_vf,
6842 (void *)&cmd_set_vf_rxmode_vfid,
6843 (void *)&cmd_set_vf_rxmode_what,
6844 (void *)&cmd_set_vf_rxmode_mode,
6845 (void *)&cmd_set_vf_rxmode_on,
6851 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6852 struct cmd_vf_mac_addr_result {
6853 cmdline_fixed_string_t mac_addr_cmd;
6854 cmdline_fixed_string_t what;
6855 cmdline_fixed_string_t port;
6857 cmdline_fixed_string_t vf;
6859 struct ether_addr address;
6862 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6863 __attribute__((unused)) struct cmdline *cl,
6864 __attribute__((unused)) void *data)
6866 struct cmd_vf_mac_addr_result *res = parsed_result;
6869 if (strcmp(res->what, "add") == 0)
6870 ret = rte_eth_dev_mac_addr_add(res->port_num,
6871 &res->address, res->vf_num);
6873 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6877 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6878 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6879 mac_addr_cmd,"mac_addr");
6880 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6881 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6883 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6884 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6886 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6887 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6889 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6890 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6892 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6893 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6895 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6896 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6899 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6900 .f = cmd_vf_mac_addr_parsed,
6902 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6903 "Add MAC address filtering for a VF on port_id",
6905 (void *)&cmd_vf_mac_addr_cmd,
6906 (void *)&cmd_vf_mac_addr_what,
6907 (void *)&cmd_vf_mac_addr_port,
6908 (void *)&cmd_vf_mac_addr_portnum,
6909 (void *)&cmd_vf_mac_addr_vf,
6910 (void *)&cmd_vf_mac_addr_vfnum,
6911 (void *)&cmd_vf_mac_addr_addr,
6916 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6917 struct cmd_vf_rx_vlan_filter {
6918 cmdline_fixed_string_t rx_vlan;
6919 cmdline_fixed_string_t what;
6921 cmdline_fixed_string_t port;
6923 cmdline_fixed_string_t vf;
6928 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6929 __attribute__((unused)) struct cmdline *cl,
6930 __attribute__((unused)) void *data)
6932 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6935 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6937 #ifdef RTE_LIBRTE_IXGBE_PMD
6938 if (ret == -ENOTSUP)
6939 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6940 res->vlan_id, res->vf_mask, is_add);
6942 #ifdef RTE_LIBRTE_I40E_PMD
6943 if (ret == -ENOTSUP)
6944 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6945 res->vlan_id, res->vf_mask, is_add);
6952 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
6953 res->vlan_id, res->vf_mask);
6956 printf("invalid port_id %d\n", res->port_id);
6959 printf("function not implemented or supported\n");
6962 printf("programming error: (%s)\n", strerror(-ret));
6966 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6967 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6968 rx_vlan, "rx_vlan");
6969 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6970 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6972 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6973 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6975 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6976 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6978 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6979 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6981 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6982 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6984 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6985 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6988 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6989 .f = cmd_vf_rx_vlan_filter_parsed,
6991 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6992 "(vf_mask = hexadecimal VF mask)",
6994 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6995 (void *)&cmd_vf_rx_vlan_filter_what,
6996 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6997 (void *)&cmd_vf_rx_vlan_filter_port,
6998 (void *)&cmd_vf_rx_vlan_filter_portid,
6999 (void *)&cmd_vf_rx_vlan_filter_vf,
7000 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7005 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7006 struct cmd_queue_rate_limit_result {
7007 cmdline_fixed_string_t set;
7008 cmdline_fixed_string_t port;
7010 cmdline_fixed_string_t queue;
7012 cmdline_fixed_string_t rate;
7016 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7017 __attribute__((unused)) struct cmdline *cl,
7018 __attribute__((unused)) void *data)
7020 struct cmd_queue_rate_limit_result *res = parsed_result;
7023 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7024 && (strcmp(res->queue, "queue") == 0)
7025 && (strcmp(res->rate, "rate") == 0))
7026 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7029 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7033 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7034 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7036 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7037 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7039 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7040 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7042 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7043 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7045 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7046 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7048 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7049 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7051 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7052 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7055 cmdline_parse_inst_t cmd_queue_rate_limit = {
7056 .f = cmd_queue_rate_limit_parsed,
7058 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7059 "Set rate limit for a queue on port_id",
7061 (void *)&cmd_queue_rate_limit_set,
7062 (void *)&cmd_queue_rate_limit_port,
7063 (void *)&cmd_queue_rate_limit_portnum,
7064 (void *)&cmd_queue_rate_limit_queue,
7065 (void *)&cmd_queue_rate_limit_queuenum,
7066 (void *)&cmd_queue_rate_limit_rate,
7067 (void *)&cmd_queue_rate_limit_ratenum,
7072 #ifdef RTE_LIBRTE_IXGBE_PMD
7073 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7074 struct cmd_vf_rate_limit_result {
7075 cmdline_fixed_string_t set;
7076 cmdline_fixed_string_t port;
7078 cmdline_fixed_string_t vf;
7080 cmdline_fixed_string_t rate;
7082 cmdline_fixed_string_t q_msk;
7086 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7087 __attribute__((unused)) struct cmdline *cl,
7088 __attribute__((unused)) void *data)
7090 struct cmd_vf_rate_limit_result *res = parsed_result;
7093 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7094 && (strcmp(res->vf, "vf") == 0)
7095 && (strcmp(res->rate, "rate") == 0)
7096 && (strcmp(res->q_msk, "queue_mask") == 0))
7097 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7098 res->rate_num, res->q_msk_val);
7100 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7104 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7105 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7107 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7108 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7110 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7111 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7113 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7114 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7116 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7117 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7119 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7120 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7122 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7123 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7125 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7126 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7127 q_msk, "queue_mask");
7128 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7129 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7132 cmdline_parse_inst_t cmd_vf_rate_limit = {
7133 .f = cmd_vf_rate_limit_parsed,
7135 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7136 "queue_mask <queue_mask_value>: "
7137 "Set rate limit for queues of VF on port_id",
7139 (void *)&cmd_vf_rate_limit_set,
7140 (void *)&cmd_vf_rate_limit_port,
7141 (void *)&cmd_vf_rate_limit_portnum,
7142 (void *)&cmd_vf_rate_limit_vf,
7143 (void *)&cmd_vf_rate_limit_vfnum,
7144 (void *)&cmd_vf_rate_limit_rate,
7145 (void *)&cmd_vf_rate_limit_ratenum,
7146 (void *)&cmd_vf_rate_limit_q_msk,
7147 (void *)&cmd_vf_rate_limit_q_msk_val,
7153 /* *** ADD TUNNEL FILTER OF A PORT *** */
7154 struct cmd_tunnel_filter_result {
7155 cmdline_fixed_string_t cmd;
7156 cmdline_fixed_string_t what;
7158 struct ether_addr outer_mac;
7159 struct ether_addr inner_mac;
7160 cmdline_ipaddr_t ip_value;
7161 uint16_t inner_vlan;
7162 cmdline_fixed_string_t tunnel_type;
7163 cmdline_fixed_string_t filter_type;
7169 cmd_tunnel_filter_parsed(void *parsed_result,
7170 __attribute__((unused)) struct cmdline *cl,
7171 __attribute__((unused)) void *data)
7173 struct cmd_tunnel_filter_result *res = parsed_result;
7174 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7177 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7179 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7180 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7181 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7183 if (res->ip_value.family == AF_INET) {
7184 tunnel_filter_conf.ip_addr.ipv4_addr =
7185 res->ip_value.addr.ipv4.s_addr;
7186 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7188 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7189 &(res->ip_value.addr.ipv6),
7190 sizeof(struct in6_addr));
7191 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7194 if (!strcmp(res->filter_type, "imac-ivlan"))
7195 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7196 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7197 tunnel_filter_conf.filter_type =
7198 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7199 else if (!strcmp(res->filter_type, "imac-tenid"))
7200 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7201 else if (!strcmp(res->filter_type, "imac"))
7202 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7203 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7204 tunnel_filter_conf.filter_type =
7205 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7206 else if (!strcmp(res->filter_type, "oip"))
7207 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7208 else if (!strcmp(res->filter_type, "iip"))
7209 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7211 printf("The filter type is not supported");
7215 if (!strcmp(res->tunnel_type, "vxlan"))
7216 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7217 else if (!strcmp(res->tunnel_type, "nvgre"))
7218 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7219 else if (!strcmp(res->tunnel_type, "ipingre"))
7220 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7222 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7226 tunnel_filter_conf.tenant_id = res->tenant_id;
7227 tunnel_filter_conf.queue_id = res->queue_num;
7228 if (!strcmp(res->what, "add"))
7229 ret = rte_eth_dev_filter_ctrl(res->port_id,
7230 RTE_ETH_FILTER_TUNNEL,
7232 &tunnel_filter_conf);
7234 ret = rte_eth_dev_filter_ctrl(res->port_id,
7235 RTE_ETH_FILTER_TUNNEL,
7236 RTE_ETH_FILTER_DELETE,
7237 &tunnel_filter_conf);
7239 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7243 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7244 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7245 cmd, "tunnel_filter");
7246 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7247 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7249 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7250 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7252 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7253 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7255 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7256 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7258 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7259 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7260 inner_vlan, UINT16);
7261 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7262 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7264 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7265 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7266 tunnel_type, "vxlan#nvgre#ipingre");
7268 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7269 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7270 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7271 "imac#omac-imac-tenid");
7272 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7273 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7275 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7276 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7279 cmdline_parse_inst_t cmd_tunnel_filter = {
7280 .f = cmd_tunnel_filter_parsed,
7282 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7283 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7284 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7285 "<queue_id>: Add/Rm tunnel filter of a port",
7287 (void *)&cmd_tunnel_filter_cmd,
7288 (void *)&cmd_tunnel_filter_what,
7289 (void *)&cmd_tunnel_filter_port_id,
7290 (void *)&cmd_tunnel_filter_outer_mac,
7291 (void *)&cmd_tunnel_filter_inner_mac,
7292 (void *)&cmd_tunnel_filter_ip_value,
7293 (void *)&cmd_tunnel_filter_innner_vlan,
7294 (void *)&cmd_tunnel_filter_tunnel_type,
7295 (void *)&cmd_tunnel_filter_filter_type,
7296 (void *)&cmd_tunnel_filter_tenant_id,
7297 (void *)&cmd_tunnel_filter_queue_num,
7302 /* *** CONFIGURE TUNNEL UDP PORT *** */
7303 struct cmd_tunnel_udp_config {
7304 cmdline_fixed_string_t cmd;
7305 cmdline_fixed_string_t what;
7311 cmd_tunnel_udp_config_parsed(void *parsed_result,
7312 __attribute__((unused)) struct cmdline *cl,
7313 __attribute__((unused)) void *data)
7315 struct cmd_tunnel_udp_config *res = parsed_result;
7316 struct rte_eth_udp_tunnel tunnel_udp;
7319 tunnel_udp.udp_port = res->udp_port;
7321 if (!strcmp(res->cmd, "rx_vxlan_port"))
7322 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7324 if (!strcmp(res->what, "add"))
7325 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7328 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7332 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7335 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7336 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7337 cmd, "rx_vxlan_port");
7338 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7339 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7341 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7342 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7344 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7345 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7348 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7349 .f = cmd_tunnel_udp_config_parsed,
7351 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7352 "Add/Remove a tunneling UDP port filter",
7354 (void *)&cmd_tunnel_udp_config_cmd,
7355 (void *)&cmd_tunnel_udp_config_what,
7356 (void *)&cmd_tunnel_udp_config_udp_port,
7357 (void *)&cmd_tunnel_udp_config_port_id,
7362 /* *** GLOBAL CONFIG *** */
7363 struct cmd_global_config_result {
7364 cmdline_fixed_string_t cmd;
7366 cmdline_fixed_string_t cfg_type;
7371 cmd_global_config_parsed(void *parsed_result,
7372 __attribute__((unused)) struct cmdline *cl,
7373 __attribute__((unused)) void *data)
7375 struct cmd_global_config_result *res = parsed_result;
7376 struct rte_eth_global_cfg conf;
7379 memset(&conf, 0, sizeof(conf));
7380 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7381 conf.cfg.gre_key_len = res->len;
7382 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7383 RTE_ETH_FILTER_SET, &conf);
7385 printf("Global config error\n");
7388 cmdline_parse_token_string_t cmd_global_config_cmd =
7389 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7391 cmdline_parse_token_num_t cmd_global_config_port_id =
7392 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7393 cmdline_parse_token_string_t cmd_global_config_type =
7394 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7395 cfg_type, "gre-key-len");
7396 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7397 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7400 cmdline_parse_inst_t cmd_global_config = {
7401 .f = cmd_global_config_parsed,
7402 .data = (void *)NULL,
7403 .help_str = "global_config <port_id> gre-key-len <key_len>",
7405 (void *)&cmd_global_config_cmd,
7406 (void *)&cmd_global_config_port_id,
7407 (void *)&cmd_global_config_type,
7408 (void *)&cmd_global_config_gre_key_len,
7413 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7414 struct cmd_set_mirror_mask_result {
7415 cmdline_fixed_string_t set;
7416 cmdline_fixed_string_t port;
7418 cmdline_fixed_string_t mirror;
7420 cmdline_fixed_string_t what;
7421 cmdline_fixed_string_t value;
7422 cmdline_fixed_string_t dstpool;
7424 cmdline_fixed_string_t on;
7427 cmdline_parse_token_string_t cmd_mirror_mask_set =
7428 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7430 cmdline_parse_token_string_t cmd_mirror_mask_port =
7431 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7433 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7434 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7436 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7437 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7438 mirror, "mirror-rule");
7439 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7440 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7442 cmdline_parse_token_string_t cmd_mirror_mask_what =
7443 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7444 what, "pool-mirror-up#pool-mirror-down"
7446 cmdline_parse_token_string_t cmd_mirror_mask_value =
7447 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7449 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7450 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7451 dstpool, "dst-pool");
7452 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7453 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7455 cmdline_parse_token_string_t cmd_mirror_mask_on =
7456 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7460 cmd_set_mirror_mask_parsed(void *parsed_result,
7461 __attribute__((unused)) struct cmdline *cl,
7462 __attribute__((unused)) void *data)
7465 struct cmd_set_mirror_mask_result *res = parsed_result;
7466 struct rte_eth_mirror_conf mr_conf;
7468 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7470 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7472 mr_conf.dst_pool = res->dstpool_id;
7474 if (!strcmp(res->what, "pool-mirror-up")) {
7475 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7476 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7477 } else if (!strcmp(res->what, "pool-mirror-down")) {
7478 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7479 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7480 } else if (!strcmp(res->what, "vlan-mirror")) {
7481 mr_conf.rule_type = ETH_MIRROR_VLAN;
7482 nb_item = parse_item_list(res->value, "vlan",
7483 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7487 for (i = 0; i < nb_item; i++) {
7488 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7489 printf("Invalid vlan_id: must be < 4096\n");
7493 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7494 mr_conf.vlan.vlan_mask |= 1ULL << i;
7498 if (!strcmp(res->on, "on"))
7499 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7502 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7505 printf("mirror rule add error: (%s)\n", strerror(-ret));
7508 cmdline_parse_inst_t cmd_set_mirror_mask = {
7509 .f = cmd_set_mirror_mask_parsed,
7511 .help_str = "set port <port_id> mirror-rule <rule_id> "
7512 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7513 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7515 (void *)&cmd_mirror_mask_set,
7516 (void *)&cmd_mirror_mask_port,
7517 (void *)&cmd_mirror_mask_portid,
7518 (void *)&cmd_mirror_mask_mirror,
7519 (void *)&cmd_mirror_mask_ruleid,
7520 (void *)&cmd_mirror_mask_what,
7521 (void *)&cmd_mirror_mask_value,
7522 (void *)&cmd_mirror_mask_dstpool,
7523 (void *)&cmd_mirror_mask_poolid,
7524 (void *)&cmd_mirror_mask_on,
7529 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7530 struct cmd_set_mirror_link_result {
7531 cmdline_fixed_string_t set;
7532 cmdline_fixed_string_t port;
7534 cmdline_fixed_string_t mirror;
7536 cmdline_fixed_string_t what;
7537 cmdline_fixed_string_t dstpool;
7539 cmdline_fixed_string_t on;
7542 cmdline_parse_token_string_t cmd_mirror_link_set =
7543 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7545 cmdline_parse_token_string_t cmd_mirror_link_port =
7546 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7548 cmdline_parse_token_num_t cmd_mirror_link_portid =
7549 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7551 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7552 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7553 mirror, "mirror-rule");
7554 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7555 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7557 cmdline_parse_token_string_t cmd_mirror_link_what =
7558 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7559 what, "uplink-mirror#downlink-mirror");
7560 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7561 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7562 dstpool, "dst-pool");
7563 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7564 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7566 cmdline_parse_token_string_t cmd_mirror_link_on =
7567 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7571 cmd_set_mirror_link_parsed(void *parsed_result,
7572 __attribute__((unused)) struct cmdline *cl,
7573 __attribute__((unused)) void *data)
7576 struct cmd_set_mirror_link_result *res = parsed_result;
7577 struct rte_eth_mirror_conf mr_conf;
7579 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7580 if (!strcmp(res->what, "uplink-mirror"))
7581 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7583 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7585 mr_conf.dst_pool = res->dstpool_id;
7587 if (!strcmp(res->on, "on"))
7588 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7591 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7594 /* check the return value and print it if is < 0 */
7596 printf("mirror rule add error: (%s)\n", strerror(-ret));
7600 cmdline_parse_inst_t cmd_set_mirror_link = {
7601 .f = cmd_set_mirror_link_parsed,
7603 .help_str = "set port <port_id> mirror-rule <rule_id> "
7604 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7606 (void *)&cmd_mirror_link_set,
7607 (void *)&cmd_mirror_link_port,
7608 (void *)&cmd_mirror_link_portid,
7609 (void *)&cmd_mirror_link_mirror,
7610 (void *)&cmd_mirror_link_ruleid,
7611 (void *)&cmd_mirror_link_what,
7612 (void *)&cmd_mirror_link_dstpool,
7613 (void *)&cmd_mirror_link_poolid,
7614 (void *)&cmd_mirror_link_on,
7619 /* *** RESET VM MIRROR RULE *** */
7620 struct cmd_rm_mirror_rule_result {
7621 cmdline_fixed_string_t reset;
7622 cmdline_fixed_string_t port;
7624 cmdline_fixed_string_t mirror;
7628 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7629 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7631 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7632 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7634 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7635 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7637 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7638 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7639 mirror, "mirror-rule");
7640 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7641 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7645 cmd_reset_mirror_rule_parsed(void *parsed_result,
7646 __attribute__((unused)) struct cmdline *cl,
7647 __attribute__((unused)) void *data)
7650 struct cmd_set_mirror_link_result *res = parsed_result;
7652 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7654 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7657 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7658 .f = cmd_reset_mirror_rule_parsed,
7660 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7662 (void *)&cmd_rm_mirror_rule_reset,
7663 (void *)&cmd_rm_mirror_rule_port,
7664 (void *)&cmd_rm_mirror_rule_portid,
7665 (void *)&cmd_rm_mirror_rule_mirror,
7666 (void *)&cmd_rm_mirror_rule_ruleid,
7671 /* ******************************************************************************** */
7673 struct cmd_dump_result {
7674 cmdline_fixed_string_t dump;
7678 dump_struct_sizes(void)
7680 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7681 DUMP_SIZE(struct rte_mbuf);
7682 DUMP_SIZE(struct rte_mempool);
7683 DUMP_SIZE(struct rte_ring);
7687 static void cmd_dump_parsed(void *parsed_result,
7688 __attribute__((unused)) struct cmdline *cl,
7689 __attribute__((unused)) void *data)
7691 struct cmd_dump_result *res = parsed_result;
7693 if (!strcmp(res->dump, "dump_physmem"))
7694 rte_dump_physmem_layout(stdout);
7695 else if (!strcmp(res->dump, "dump_memzone"))
7696 rte_memzone_dump(stdout);
7697 else if (!strcmp(res->dump, "dump_struct_sizes"))
7698 dump_struct_sizes();
7699 else if (!strcmp(res->dump, "dump_ring"))
7700 rte_ring_list_dump(stdout);
7701 else if (!strcmp(res->dump, "dump_mempool"))
7702 rte_mempool_list_dump(stdout);
7703 else if (!strcmp(res->dump, "dump_devargs"))
7704 rte_eal_devargs_dump(stdout);
7707 cmdline_parse_token_string_t cmd_dump_dump =
7708 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7711 "dump_struct_sizes#"
7716 cmdline_parse_inst_t cmd_dump = {
7717 .f = cmd_dump_parsed, /* function to call */
7718 .data = NULL, /* 2nd arg of func */
7719 .help_str = "Dump status",
7720 .tokens = { /* token list, NULL terminated */
7721 (void *)&cmd_dump_dump,
7726 /* ******************************************************************************** */
7728 struct cmd_dump_one_result {
7729 cmdline_fixed_string_t dump;
7730 cmdline_fixed_string_t name;
7733 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7734 __attribute__((unused)) void *data)
7736 struct cmd_dump_one_result *res = parsed_result;
7738 if (!strcmp(res->dump, "dump_ring")) {
7740 r = rte_ring_lookup(res->name);
7742 cmdline_printf(cl, "Cannot find ring\n");
7745 rte_ring_dump(stdout, r);
7746 } else if (!strcmp(res->dump, "dump_mempool")) {
7747 struct rte_mempool *mp;
7748 mp = rte_mempool_lookup(res->name);
7750 cmdline_printf(cl, "Cannot find mempool\n");
7753 rte_mempool_dump(stdout, mp);
7757 cmdline_parse_token_string_t cmd_dump_one_dump =
7758 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7759 "dump_ring#dump_mempool");
7761 cmdline_parse_token_string_t cmd_dump_one_name =
7762 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7764 cmdline_parse_inst_t cmd_dump_one = {
7765 .f = cmd_dump_one_parsed, /* function to call */
7766 .data = NULL, /* 2nd arg of func */
7767 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7768 .tokens = { /* token list, NULL terminated */
7769 (void *)&cmd_dump_one_dump,
7770 (void *)&cmd_dump_one_name,
7775 /* *** Add/Del syn filter *** */
7776 struct cmd_syn_filter_result {
7777 cmdline_fixed_string_t filter;
7779 cmdline_fixed_string_t ops;
7780 cmdline_fixed_string_t priority;
7781 cmdline_fixed_string_t high;
7782 cmdline_fixed_string_t queue;
7787 cmd_syn_filter_parsed(void *parsed_result,
7788 __attribute__((unused)) struct cmdline *cl,
7789 __attribute__((unused)) void *data)
7791 struct cmd_syn_filter_result *res = parsed_result;
7792 struct rte_eth_syn_filter syn_filter;
7795 ret = rte_eth_dev_filter_supported(res->port_id,
7796 RTE_ETH_FILTER_SYN);
7798 printf("syn filter is not supported on port %u.\n",
7803 memset(&syn_filter, 0, sizeof(syn_filter));
7805 if (!strcmp(res->ops, "add")) {
7806 if (!strcmp(res->high, "high"))
7807 syn_filter.hig_pri = 1;
7809 syn_filter.hig_pri = 0;
7811 syn_filter.queue = res->queue_id;
7812 ret = rte_eth_dev_filter_ctrl(res->port_id,
7817 ret = rte_eth_dev_filter_ctrl(res->port_id,
7819 RTE_ETH_FILTER_DELETE,
7823 printf("syn filter programming error: (%s)\n",
7827 cmdline_parse_token_string_t cmd_syn_filter_filter =
7828 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7829 filter, "syn_filter");
7830 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7831 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7833 cmdline_parse_token_string_t cmd_syn_filter_ops =
7834 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7836 cmdline_parse_token_string_t cmd_syn_filter_priority =
7837 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7838 priority, "priority");
7839 cmdline_parse_token_string_t cmd_syn_filter_high =
7840 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7842 cmdline_parse_token_string_t cmd_syn_filter_queue =
7843 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7845 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7846 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7849 cmdline_parse_inst_t cmd_syn_filter = {
7850 .f = cmd_syn_filter_parsed,
7852 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7853 "<queue_id>: Add/Delete syn filter",
7855 (void *)&cmd_syn_filter_filter,
7856 (void *)&cmd_syn_filter_port_id,
7857 (void *)&cmd_syn_filter_ops,
7858 (void *)&cmd_syn_filter_priority,
7859 (void *)&cmd_syn_filter_high,
7860 (void *)&cmd_syn_filter_queue,
7861 (void *)&cmd_syn_filter_queue_id,
7866 /* *** ADD/REMOVE A 2tuple FILTER *** */
7867 struct cmd_2tuple_filter_result {
7868 cmdline_fixed_string_t filter;
7870 cmdline_fixed_string_t ops;
7871 cmdline_fixed_string_t dst_port;
7872 uint16_t dst_port_value;
7873 cmdline_fixed_string_t protocol;
7874 uint8_t protocol_value;
7875 cmdline_fixed_string_t mask;
7877 cmdline_fixed_string_t tcp_flags;
7878 uint8_t tcp_flags_value;
7879 cmdline_fixed_string_t priority;
7880 uint8_t priority_value;
7881 cmdline_fixed_string_t queue;
7886 cmd_2tuple_filter_parsed(void *parsed_result,
7887 __attribute__((unused)) struct cmdline *cl,
7888 __attribute__((unused)) void *data)
7890 struct rte_eth_ntuple_filter filter;
7891 struct cmd_2tuple_filter_result *res = parsed_result;
7894 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7896 printf("ntuple filter is not supported on port %u.\n",
7901 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7903 filter.flags = RTE_2TUPLE_FLAGS;
7904 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7905 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7906 filter.proto = res->protocol_value;
7907 filter.priority = res->priority_value;
7908 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7909 printf("nonzero tcp_flags is only meaningful"
7910 " when protocol is TCP.\n");
7913 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7914 printf("invalid TCP flags.\n");
7918 if (res->tcp_flags_value != 0) {
7919 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7920 filter.tcp_flags = res->tcp_flags_value;
7923 /* need convert to big endian. */
7924 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7925 filter.queue = res->queue_id;
7927 if (!strcmp(res->ops, "add"))
7928 ret = rte_eth_dev_filter_ctrl(res->port_id,
7929 RTE_ETH_FILTER_NTUPLE,
7933 ret = rte_eth_dev_filter_ctrl(res->port_id,
7934 RTE_ETH_FILTER_NTUPLE,
7935 RTE_ETH_FILTER_DELETE,
7938 printf("2tuple filter programming error: (%s)\n",
7943 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7944 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7945 filter, "2tuple_filter");
7946 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7947 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7949 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7950 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7952 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7953 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7954 dst_port, "dst_port");
7955 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7956 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7957 dst_port_value, UINT16);
7958 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7959 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7960 protocol, "protocol");
7961 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7962 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7963 protocol_value, UINT8);
7964 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7965 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7967 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7968 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7970 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7971 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7972 tcp_flags, "tcp_flags");
7973 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7974 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7975 tcp_flags_value, UINT8);
7976 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7977 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7978 priority, "priority");
7979 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7980 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7981 priority_value, UINT8);
7982 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7983 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7985 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7986 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7989 cmdline_parse_inst_t cmd_2tuple_filter = {
7990 .f = cmd_2tuple_filter_parsed,
7992 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7993 "<value> mask <value> tcp_flags <value> priority <value> queue "
7994 "<queue_id>: Add a 2tuple filter",
7996 (void *)&cmd_2tuple_filter_filter,
7997 (void *)&cmd_2tuple_filter_port_id,
7998 (void *)&cmd_2tuple_filter_ops,
7999 (void *)&cmd_2tuple_filter_dst_port,
8000 (void *)&cmd_2tuple_filter_dst_port_value,
8001 (void *)&cmd_2tuple_filter_protocol,
8002 (void *)&cmd_2tuple_filter_protocol_value,
8003 (void *)&cmd_2tuple_filter_mask,
8004 (void *)&cmd_2tuple_filter_mask_value,
8005 (void *)&cmd_2tuple_filter_tcp_flags,
8006 (void *)&cmd_2tuple_filter_tcp_flags_value,
8007 (void *)&cmd_2tuple_filter_priority,
8008 (void *)&cmd_2tuple_filter_priority_value,
8009 (void *)&cmd_2tuple_filter_queue,
8010 (void *)&cmd_2tuple_filter_queue_id,
8015 /* *** ADD/REMOVE A 5tuple FILTER *** */
8016 struct cmd_5tuple_filter_result {
8017 cmdline_fixed_string_t filter;
8019 cmdline_fixed_string_t ops;
8020 cmdline_fixed_string_t dst_ip;
8021 cmdline_ipaddr_t dst_ip_value;
8022 cmdline_fixed_string_t src_ip;
8023 cmdline_ipaddr_t src_ip_value;
8024 cmdline_fixed_string_t dst_port;
8025 uint16_t dst_port_value;
8026 cmdline_fixed_string_t src_port;
8027 uint16_t src_port_value;
8028 cmdline_fixed_string_t protocol;
8029 uint8_t protocol_value;
8030 cmdline_fixed_string_t mask;
8032 cmdline_fixed_string_t tcp_flags;
8033 uint8_t tcp_flags_value;
8034 cmdline_fixed_string_t priority;
8035 uint8_t priority_value;
8036 cmdline_fixed_string_t queue;
8041 cmd_5tuple_filter_parsed(void *parsed_result,
8042 __attribute__((unused)) struct cmdline *cl,
8043 __attribute__((unused)) void *data)
8045 struct rte_eth_ntuple_filter filter;
8046 struct cmd_5tuple_filter_result *res = parsed_result;
8049 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8051 printf("ntuple filter is not supported on port %u.\n",
8056 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8058 filter.flags = RTE_5TUPLE_FLAGS;
8059 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8060 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8061 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8062 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8063 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8064 filter.proto = res->protocol_value;
8065 filter.priority = res->priority_value;
8066 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8067 printf("nonzero tcp_flags is only meaningful"
8068 " when protocol is TCP.\n");
8071 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8072 printf("invalid TCP flags.\n");
8076 if (res->tcp_flags_value != 0) {
8077 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8078 filter.tcp_flags = res->tcp_flags_value;
8081 if (res->dst_ip_value.family == AF_INET)
8082 /* no need to convert, already big endian. */
8083 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8085 if (filter.dst_ip_mask == 0) {
8086 printf("can not support ipv6 involved compare.\n");
8092 if (res->src_ip_value.family == AF_INET)
8093 /* no need to convert, already big endian. */
8094 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8096 if (filter.src_ip_mask == 0) {
8097 printf("can not support ipv6 involved compare.\n");
8102 /* need convert to big endian. */
8103 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8104 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8105 filter.queue = res->queue_id;
8107 if (!strcmp(res->ops, "add"))
8108 ret = rte_eth_dev_filter_ctrl(res->port_id,
8109 RTE_ETH_FILTER_NTUPLE,
8113 ret = rte_eth_dev_filter_ctrl(res->port_id,
8114 RTE_ETH_FILTER_NTUPLE,
8115 RTE_ETH_FILTER_DELETE,
8118 printf("5tuple filter programming error: (%s)\n",
8122 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8123 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8124 filter, "5tuple_filter");
8125 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8126 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8128 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8129 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8131 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8132 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8134 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8135 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8137 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8138 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8140 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8141 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8143 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8144 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8145 dst_port, "dst_port");
8146 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8147 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8148 dst_port_value, UINT16);
8149 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8150 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8151 src_port, "src_port");
8152 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8153 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8154 src_port_value, UINT16);
8155 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8156 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8157 protocol, "protocol");
8158 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8159 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8160 protocol_value, UINT8);
8161 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8162 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8164 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8165 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8167 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8168 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8169 tcp_flags, "tcp_flags");
8170 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8171 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8172 tcp_flags_value, UINT8);
8173 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8174 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8175 priority, "priority");
8176 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8177 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8178 priority_value, UINT8);
8179 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8180 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8182 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8183 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8186 cmdline_parse_inst_t cmd_5tuple_filter = {
8187 .f = cmd_5tuple_filter_parsed,
8189 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8190 "src_ip <value> dst_port <value> src_port <value> "
8191 "protocol <value> mask <value> tcp_flags <value> "
8192 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8194 (void *)&cmd_5tuple_filter_filter,
8195 (void *)&cmd_5tuple_filter_port_id,
8196 (void *)&cmd_5tuple_filter_ops,
8197 (void *)&cmd_5tuple_filter_dst_ip,
8198 (void *)&cmd_5tuple_filter_dst_ip_value,
8199 (void *)&cmd_5tuple_filter_src_ip,
8200 (void *)&cmd_5tuple_filter_src_ip_value,
8201 (void *)&cmd_5tuple_filter_dst_port,
8202 (void *)&cmd_5tuple_filter_dst_port_value,
8203 (void *)&cmd_5tuple_filter_src_port,
8204 (void *)&cmd_5tuple_filter_src_port_value,
8205 (void *)&cmd_5tuple_filter_protocol,
8206 (void *)&cmd_5tuple_filter_protocol_value,
8207 (void *)&cmd_5tuple_filter_mask,
8208 (void *)&cmd_5tuple_filter_mask_value,
8209 (void *)&cmd_5tuple_filter_tcp_flags,
8210 (void *)&cmd_5tuple_filter_tcp_flags_value,
8211 (void *)&cmd_5tuple_filter_priority,
8212 (void *)&cmd_5tuple_filter_priority_value,
8213 (void *)&cmd_5tuple_filter_queue,
8214 (void *)&cmd_5tuple_filter_queue_id,
8219 /* *** ADD/REMOVE A flex FILTER *** */
8220 struct cmd_flex_filter_result {
8221 cmdline_fixed_string_t filter;
8222 cmdline_fixed_string_t ops;
8224 cmdline_fixed_string_t len;
8226 cmdline_fixed_string_t bytes;
8227 cmdline_fixed_string_t bytes_value;
8228 cmdline_fixed_string_t mask;
8229 cmdline_fixed_string_t mask_value;
8230 cmdline_fixed_string_t priority;
8231 uint8_t priority_value;
8232 cmdline_fixed_string_t queue;
8236 static int xdigit2val(unsigned char c)
8241 else if (isupper(c))
8249 cmd_flex_filter_parsed(void *parsed_result,
8250 __attribute__((unused)) struct cmdline *cl,
8251 __attribute__((unused)) void *data)
8254 struct rte_eth_flex_filter filter;
8255 struct cmd_flex_filter_result *res = parsed_result;
8256 char *bytes_ptr, *mask_ptr;
8257 uint16_t len, i, j = 0;
8262 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8263 printf("the len exceed the max length 128\n");
8266 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8267 filter.len = res->len_value;
8268 filter.priority = res->priority_value;
8269 filter.queue = res->queue_id;
8270 bytes_ptr = res->bytes_value;
8271 mask_ptr = res->mask_value;
8273 /* translate bytes string to array. */
8274 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8275 (bytes_ptr[1] == 'X')))
8277 len = strnlen(bytes_ptr, res->len_value * 2);
8278 if (len == 0 || (len % 8 != 0)) {
8279 printf("please check len and bytes input\n");
8282 for (i = 0; i < len; i++) {
8284 if (isxdigit(c) == 0) {
8285 /* invalid characters. */
8286 printf("invalid input\n");
8289 val = xdigit2val(c);
8292 filter.bytes[j] = byte;
8293 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8300 /* translate mask string to uint8_t array. */
8301 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8302 (mask_ptr[1] == 'X')))
8304 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8306 printf("invalid input\n");
8311 for (i = 0; i < len; i++) {
8313 if (isxdigit(c) == 0) {
8314 /* invalid characters. */
8315 printf("invalid input\n");
8318 val = xdigit2val(c);
8321 filter.mask[j] = byte;
8322 printf("mask[%d]:%02x ", j, filter.mask[j]);
8330 if (!strcmp(res->ops, "add"))
8331 ret = rte_eth_dev_filter_ctrl(res->port_id,
8332 RTE_ETH_FILTER_FLEXIBLE,
8336 ret = rte_eth_dev_filter_ctrl(res->port_id,
8337 RTE_ETH_FILTER_FLEXIBLE,
8338 RTE_ETH_FILTER_DELETE,
8342 printf("flex filter setting error: (%s)\n", strerror(-ret));
8345 cmdline_parse_token_string_t cmd_flex_filter_filter =
8346 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8347 filter, "flex_filter");
8348 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8349 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8351 cmdline_parse_token_string_t cmd_flex_filter_ops =
8352 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8354 cmdline_parse_token_string_t cmd_flex_filter_len =
8355 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8357 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8358 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8360 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8361 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8363 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8364 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8366 cmdline_parse_token_string_t cmd_flex_filter_mask =
8367 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8369 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8370 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8372 cmdline_parse_token_string_t cmd_flex_filter_priority =
8373 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8374 priority, "priority");
8375 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8376 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8377 priority_value, UINT8);
8378 cmdline_parse_token_string_t cmd_flex_filter_queue =
8379 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8381 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8382 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8384 cmdline_parse_inst_t cmd_flex_filter = {
8385 .f = cmd_flex_filter_parsed,
8387 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8388 "<value> mask <value> priority <value> queue <queue_id>: "
8389 "Add/Del a flex filter",
8391 (void *)&cmd_flex_filter_filter,
8392 (void *)&cmd_flex_filter_port_id,
8393 (void *)&cmd_flex_filter_ops,
8394 (void *)&cmd_flex_filter_len,
8395 (void *)&cmd_flex_filter_len_value,
8396 (void *)&cmd_flex_filter_bytes,
8397 (void *)&cmd_flex_filter_bytes_value,
8398 (void *)&cmd_flex_filter_mask,
8399 (void *)&cmd_flex_filter_mask_value,
8400 (void *)&cmd_flex_filter_priority,
8401 (void *)&cmd_flex_filter_priority_value,
8402 (void *)&cmd_flex_filter_queue,
8403 (void *)&cmd_flex_filter_queue_id,
8408 /* *** Filters Control *** */
8410 /* *** deal with ethertype filter *** */
8411 struct cmd_ethertype_filter_result {
8412 cmdline_fixed_string_t filter;
8414 cmdline_fixed_string_t ops;
8415 cmdline_fixed_string_t mac;
8416 struct ether_addr mac_addr;
8417 cmdline_fixed_string_t ethertype;
8418 uint16_t ethertype_value;
8419 cmdline_fixed_string_t drop;
8420 cmdline_fixed_string_t queue;
8424 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8425 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8426 filter, "ethertype_filter");
8427 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8428 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8430 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8431 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8433 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8434 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8435 mac, "mac_addr#mac_ignr");
8436 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8437 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8439 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8440 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8441 ethertype, "ethertype");
8442 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8443 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8444 ethertype_value, UINT16);
8445 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8446 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8448 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8449 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8451 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8452 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8456 cmd_ethertype_filter_parsed(void *parsed_result,
8457 __attribute__((unused)) struct cmdline *cl,
8458 __attribute__((unused)) void *data)
8460 struct cmd_ethertype_filter_result *res = parsed_result;
8461 struct rte_eth_ethertype_filter filter;
8464 ret = rte_eth_dev_filter_supported(res->port_id,
8465 RTE_ETH_FILTER_ETHERTYPE);
8467 printf("ethertype filter is not supported on port %u.\n",
8472 memset(&filter, 0, sizeof(filter));
8473 if (!strcmp(res->mac, "mac_addr")) {
8474 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8475 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8476 sizeof(struct ether_addr));
8478 if (!strcmp(res->drop, "drop"))
8479 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8480 filter.ether_type = res->ethertype_value;
8481 filter.queue = res->queue_id;
8483 if (!strcmp(res->ops, "add"))
8484 ret = rte_eth_dev_filter_ctrl(res->port_id,
8485 RTE_ETH_FILTER_ETHERTYPE,
8489 ret = rte_eth_dev_filter_ctrl(res->port_id,
8490 RTE_ETH_FILTER_ETHERTYPE,
8491 RTE_ETH_FILTER_DELETE,
8494 printf("ethertype filter programming error: (%s)\n",
8498 cmdline_parse_inst_t cmd_ethertype_filter = {
8499 .f = cmd_ethertype_filter_parsed,
8501 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8502 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8503 "Add or delete an ethertype filter entry",
8505 (void *)&cmd_ethertype_filter_filter,
8506 (void *)&cmd_ethertype_filter_port_id,
8507 (void *)&cmd_ethertype_filter_ops,
8508 (void *)&cmd_ethertype_filter_mac,
8509 (void *)&cmd_ethertype_filter_mac_addr,
8510 (void *)&cmd_ethertype_filter_ethertype,
8511 (void *)&cmd_ethertype_filter_ethertype_value,
8512 (void *)&cmd_ethertype_filter_drop,
8513 (void *)&cmd_ethertype_filter_queue,
8514 (void *)&cmd_ethertype_filter_queue_id,
8519 /* *** deal with flow director filter *** */
8520 struct cmd_flow_director_result {
8521 cmdline_fixed_string_t flow_director_filter;
8523 cmdline_fixed_string_t mode;
8524 cmdline_fixed_string_t mode_value;
8525 cmdline_fixed_string_t ops;
8526 cmdline_fixed_string_t flow;
8527 cmdline_fixed_string_t flow_type;
8528 cmdline_fixed_string_t ether;
8529 uint16_t ether_type;
8530 cmdline_fixed_string_t src;
8531 cmdline_ipaddr_t ip_src;
8533 cmdline_fixed_string_t dst;
8534 cmdline_ipaddr_t ip_dst;
8536 cmdline_fixed_string_t verify_tag;
8537 uint32_t verify_tag_value;
8538 cmdline_ipaddr_t tos;
8540 cmdline_ipaddr_t proto;
8541 uint8_t proto_value;
8542 cmdline_ipaddr_t ttl;
8544 cmdline_fixed_string_t vlan;
8545 uint16_t vlan_value;
8546 cmdline_fixed_string_t flexbytes;
8547 cmdline_fixed_string_t flexbytes_value;
8548 cmdline_fixed_string_t pf_vf;
8549 cmdline_fixed_string_t drop;
8550 cmdline_fixed_string_t queue;
8552 cmdline_fixed_string_t fd_id;
8553 uint32_t fd_id_value;
8554 cmdline_fixed_string_t mac;
8555 struct ether_addr mac_addr;
8556 cmdline_fixed_string_t tunnel;
8557 cmdline_fixed_string_t tunnel_type;
8558 cmdline_fixed_string_t tunnel_id;
8559 uint32_t tunnel_id_value;
8563 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8566 const char *p, *p0 = q_arg;
8568 unsigned long int_fld;
8569 char *str_fld[max_num];
8574 p = strchr(p0, '(');
8578 p0 = strchr(p, ')');
8583 if (size >= sizeof(s))
8586 snprintf(s, sizeof(s), "%.*s", size, p);
8587 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8588 if (ret < 0 || ret > max_num)
8590 for (i = 0; i < ret; i++) {
8592 int_fld = strtoul(str_fld[i], &end, 0);
8593 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8595 flexbytes[i] = (uint8_t)int_fld;
8601 str2flowtype(char *string)
8604 static const struct {
8607 } flowtype_str[] = {
8608 {"raw", RTE_ETH_FLOW_RAW},
8609 {"ipv4", RTE_ETH_FLOW_IPV4},
8610 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8611 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8612 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8613 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8614 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8615 {"ipv6", RTE_ETH_FLOW_IPV6},
8616 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8617 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8618 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8619 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8620 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8621 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8624 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8625 if (!strcmp(flowtype_str[i].str, string))
8626 return flowtype_str[i].type;
8628 return RTE_ETH_FLOW_UNKNOWN;
8631 static enum rte_eth_fdir_tunnel_type
8632 str2fdir_tunneltype(char *string)
8636 static const struct {
8638 enum rte_eth_fdir_tunnel_type type;
8639 } tunneltype_str[] = {
8640 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8641 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8644 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8645 if (!strcmp(tunneltype_str[i].str, string))
8646 return tunneltype_str[i].type;
8648 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8651 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8653 if ((ip_addr).family == AF_INET) \
8654 (ip) = (ip_addr).addr.ipv4.s_addr; \
8656 printf("invalid parameter.\n"); \
8661 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8663 if ((ip_addr).family == AF_INET6) \
8664 (void)rte_memcpy(&(ip), \
8665 &((ip_addr).addr.ipv6), \
8666 sizeof(struct in6_addr)); \
8668 printf("invalid parameter.\n"); \
8674 cmd_flow_director_filter_parsed(void *parsed_result,
8675 __attribute__((unused)) struct cmdline *cl,
8676 __attribute__((unused)) void *data)
8678 struct cmd_flow_director_result *res = parsed_result;
8679 struct rte_eth_fdir_filter entry;
8680 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8682 unsigned long vf_id;
8685 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8687 printf("flow director is not supported on port %u.\n",
8691 memset(flexbytes, 0, sizeof(flexbytes));
8692 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8694 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8695 if (strcmp(res->mode_value, "MAC-VLAN")) {
8696 printf("Please set mode to MAC-VLAN.\n");
8699 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8700 if (strcmp(res->mode_value, "Tunnel")) {
8701 printf("Please set mode to Tunnel.\n");
8705 if (strcmp(res->mode_value, "IP")) {
8706 printf("Please set mode to IP.\n");
8709 entry.input.flow_type = str2flowtype(res->flow_type);
8712 ret = parse_flexbytes(res->flexbytes_value,
8714 RTE_ETH_FDIR_MAX_FLEXLEN);
8716 printf("error: Cannot parse flexbytes input.\n");
8720 switch (entry.input.flow_type) {
8721 case RTE_ETH_FLOW_FRAG_IPV4:
8722 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8723 entry.input.flow.ip4_flow.proto = res->proto_value;
8724 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8725 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8726 IPV4_ADDR_TO_UINT(res->ip_dst,
8727 entry.input.flow.ip4_flow.dst_ip);
8728 IPV4_ADDR_TO_UINT(res->ip_src,
8729 entry.input.flow.ip4_flow.src_ip);
8730 entry.input.flow.ip4_flow.tos = res->tos_value;
8731 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8732 /* need convert to big endian. */
8733 entry.input.flow.udp4_flow.dst_port =
8734 rte_cpu_to_be_16(res->port_dst);
8735 entry.input.flow.udp4_flow.src_port =
8736 rte_cpu_to_be_16(res->port_src);
8738 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8739 IPV4_ADDR_TO_UINT(res->ip_dst,
8740 entry.input.flow.sctp4_flow.ip.dst_ip);
8741 IPV4_ADDR_TO_UINT(res->ip_src,
8742 entry.input.flow.sctp4_flow.ip.src_ip);
8743 entry.input.flow.ip4_flow.tos = res->tos_value;
8744 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8745 /* need convert to big endian. */
8746 entry.input.flow.sctp4_flow.dst_port =
8747 rte_cpu_to_be_16(res->port_dst);
8748 entry.input.flow.sctp4_flow.src_port =
8749 rte_cpu_to_be_16(res->port_src);
8750 entry.input.flow.sctp4_flow.verify_tag =
8751 rte_cpu_to_be_32(res->verify_tag_value);
8753 case RTE_ETH_FLOW_FRAG_IPV6:
8754 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8755 entry.input.flow.ipv6_flow.proto = res->proto_value;
8756 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8757 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8758 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8759 entry.input.flow.ipv6_flow.dst_ip);
8760 IPV6_ADDR_TO_ARRAY(res->ip_src,
8761 entry.input.flow.ipv6_flow.src_ip);
8762 entry.input.flow.ipv6_flow.tc = res->tos_value;
8763 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8764 /* need convert to big endian. */
8765 entry.input.flow.udp6_flow.dst_port =
8766 rte_cpu_to_be_16(res->port_dst);
8767 entry.input.flow.udp6_flow.src_port =
8768 rte_cpu_to_be_16(res->port_src);
8770 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8771 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8772 entry.input.flow.sctp6_flow.ip.dst_ip);
8773 IPV6_ADDR_TO_ARRAY(res->ip_src,
8774 entry.input.flow.sctp6_flow.ip.src_ip);
8775 entry.input.flow.ipv6_flow.tc = res->tos_value;
8776 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8777 /* need convert to big endian. */
8778 entry.input.flow.sctp6_flow.dst_port =
8779 rte_cpu_to_be_16(res->port_dst);
8780 entry.input.flow.sctp6_flow.src_port =
8781 rte_cpu_to_be_16(res->port_src);
8782 entry.input.flow.sctp6_flow.verify_tag =
8783 rte_cpu_to_be_32(res->verify_tag_value);
8785 case RTE_ETH_FLOW_L2_PAYLOAD:
8786 entry.input.flow.l2_flow.ether_type =
8787 rte_cpu_to_be_16(res->ether_type);
8793 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8794 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8796 sizeof(struct ether_addr));
8798 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8799 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8801 sizeof(struct ether_addr));
8802 entry.input.flow.tunnel_flow.tunnel_type =
8803 str2fdir_tunneltype(res->tunnel_type);
8804 entry.input.flow.tunnel_flow.tunnel_id =
8805 rte_cpu_to_be_32(res->tunnel_id_value);
8808 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8810 RTE_ETH_FDIR_MAX_FLEXLEN);
8812 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8814 entry.action.flex_off = 0; /*use 0 by default */
8815 if (!strcmp(res->drop, "drop"))
8816 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8818 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8820 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8821 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8822 if (!strcmp(res->pf_vf, "pf"))
8823 entry.input.flow_ext.is_vf = 0;
8824 else if (!strncmp(res->pf_vf, "vf", 2)) {
8825 struct rte_eth_dev_info dev_info;
8827 memset(&dev_info, 0, sizeof(dev_info));
8828 rte_eth_dev_info_get(res->port_id, &dev_info);
8830 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8831 if (errno != 0 || *end != '\0' ||
8832 vf_id >= dev_info.max_vfs) {
8833 printf("invalid parameter %s.\n", res->pf_vf);
8836 entry.input.flow_ext.is_vf = 1;
8837 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8839 printf("invalid parameter %s.\n", res->pf_vf);
8844 /* set to report FD ID by default */
8845 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8846 entry.action.rx_queue = res->queue_id;
8847 entry.soft_id = res->fd_id_value;
8848 if (!strcmp(res->ops, "add"))
8849 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8850 RTE_ETH_FILTER_ADD, &entry);
8851 else if (!strcmp(res->ops, "del"))
8852 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8853 RTE_ETH_FILTER_DELETE, &entry);
8855 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8856 RTE_ETH_FILTER_UPDATE, &entry);
8858 printf("flow director programming error: (%s)\n",
8862 cmdline_parse_token_string_t cmd_flow_director_filter =
8863 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8864 flow_director_filter, "flow_director_filter");
8865 cmdline_parse_token_num_t cmd_flow_director_port_id =
8866 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8868 cmdline_parse_token_string_t cmd_flow_director_ops =
8869 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8870 ops, "add#del#update");
8871 cmdline_parse_token_string_t cmd_flow_director_flow =
8872 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8874 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8875 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8876 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8877 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8878 cmdline_parse_token_string_t cmd_flow_director_ether =
8879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8881 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8882 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8883 ether_type, UINT16);
8884 cmdline_parse_token_string_t cmd_flow_director_src =
8885 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8887 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8888 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8890 cmdline_parse_token_num_t cmd_flow_director_port_src =
8891 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8893 cmdline_parse_token_string_t cmd_flow_director_dst =
8894 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8896 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8897 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8899 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8900 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8902 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8903 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8904 verify_tag, "verify_tag");
8905 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8906 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8907 verify_tag_value, UINT32);
8908 cmdline_parse_token_string_t cmd_flow_director_tos =
8909 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8911 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8912 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8914 cmdline_parse_token_string_t cmd_flow_director_proto =
8915 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8917 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8918 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8919 proto_value, UINT8);
8920 cmdline_parse_token_string_t cmd_flow_director_ttl =
8921 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8923 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8924 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8926 cmdline_parse_token_string_t cmd_flow_director_vlan =
8927 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8929 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8930 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8931 vlan_value, UINT16);
8932 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8933 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8934 flexbytes, "flexbytes");
8935 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8936 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8937 flexbytes_value, NULL);
8938 cmdline_parse_token_string_t cmd_flow_director_drop =
8939 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8941 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8942 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8944 cmdline_parse_token_string_t cmd_flow_director_queue =
8945 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8947 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8948 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8950 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8951 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8953 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8954 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8955 fd_id_value, UINT32);
8957 cmdline_parse_token_string_t cmd_flow_director_mode =
8958 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8960 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8961 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8963 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8964 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8965 mode_value, "MAC-VLAN");
8966 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8967 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8968 mode_value, "Tunnel");
8969 cmdline_parse_token_string_t cmd_flow_director_mac =
8970 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8972 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8973 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8975 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8976 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8978 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8979 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8980 tunnel_type, "NVGRE#VxLAN");
8981 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8982 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8983 tunnel_id, "tunnel-id");
8984 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8985 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8986 tunnel_id_value, UINT32);
8988 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8989 .f = cmd_flow_director_filter_parsed,
8991 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8992 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8993 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8994 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8995 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8996 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8997 "fd_id <fd_id_value>: "
8998 "Add or delete an ip flow director entry on NIC",
9000 (void *)&cmd_flow_director_filter,
9001 (void *)&cmd_flow_director_port_id,
9002 (void *)&cmd_flow_director_mode,
9003 (void *)&cmd_flow_director_mode_ip,
9004 (void *)&cmd_flow_director_ops,
9005 (void *)&cmd_flow_director_flow,
9006 (void *)&cmd_flow_director_flow_type,
9007 (void *)&cmd_flow_director_src,
9008 (void *)&cmd_flow_director_ip_src,
9009 (void *)&cmd_flow_director_dst,
9010 (void *)&cmd_flow_director_ip_dst,
9011 (void *)&cmd_flow_director_tos,
9012 (void *)&cmd_flow_director_tos_value,
9013 (void *)&cmd_flow_director_proto,
9014 (void *)&cmd_flow_director_proto_value,
9015 (void *)&cmd_flow_director_ttl,
9016 (void *)&cmd_flow_director_ttl_value,
9017 (void *)&cmd_flow_director_vlan,
9018 (void *)&cmd_flow_director_vlan_value,
9019 (void *)&cmd_flow_director_flexbytes,
9020 (void *)&cmd_flow_director_flexbytes_value,
9021 (void *)&cmd_flow_director_drop,
9022 (void *)&cmd_flow_director_pf_vf,
9023 (void *)&cmd_flow_director_queue,
9024 (void *)&cmd_flow_director_queue_id,
9025 (void *)&cmd_flow_director_fd_id,
9026 (void *)&cmd_flow_director_fd_id_value,
9031 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9032 .f = cmd_flow_director_filter_parsed,
9034 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9035 "director entry on NIC",
9037 (void *)&cmd_flow_director_filter,
9038 (void *)&cmd_flow_director_port_id,
9039 (void *)&cmd_flow_director_mode,
9040 (void *)&cmd_flow_director_mode_ip,
9041 (void *)&cmd_flow_director_ops,
9042 (void *)&cmd_flow_director_flow,
9043 (void *)&cmd_flow_director_flow_type,
9044 (void *)&cmd_flow_director_src,
9045 (void *)&cmd_flow_director_ip_src,
9046 (void *)&cmd_flow_director_port_src,
9047 (void *)&cmd_flow_director_dst,
9048 (void *)&cmd_flow_director_ip_dst,
9049 (void *)&cmd_flow_director_port_dst,
9050 (void *)&cmd_flow_director_tos,
9051 (void *)&cmd_flow_director_tos_value,
9052 (void *)&cmd_flow_director_ttl,
9053 (void *)&cmd_flow_director_ttl_value,
9054 (void *)&cmd_flow_director_vlan,
9055 (void *)&cmd_flow_director_vlan_value,
9056 (void *)&cmd_flow_director_flexbytes,
9057 (void *)&cmd_flow_director_flexbytes_value,
9058 (void *)&cmd_flow_director_drop,
9059 (void *)&cmd_flow_director_pf_vf,
9060 (void *)&cmd_flow_director_queue,
9061 (void *)&cmd_flow_director_queue_id,
9062 (void *)&cmd_flow_director_fd_id,
9063 (void *)&cmd_flow_director_fd_id_value,
9068 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9069 .f = cmd_flow_director_filter_parsed,
9071 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9072 "director entry on NIC",
9074 (void *)&cmd_flow_director_filter,
9075 (void *)&cmd_flow_director_port_id,
9076 (void *)&cmd_flow_director_mode,
9077 (void *)&cmd_flow_director_mode_ip,
9078 (void *)&cmd_flow_director_ops,
9079 (void *)&cmd_flow_director_flow,
9080 (void *)&cmd_flow_director_flow_type,
9081 (void *)&cmd_flow_director_src,
9082 (void *)&cmd_flow_director_ip_src,
9083 (void *)&cmd_flow_director_port_dst,
9084 (void *)&cmd_flow_director_dst,
9085 (void *)&cmd_flow_director_ip_dst,
9086 (void *)&cmd_flow_director_port_dst,
9087 (void *)&cmd_flow_director_verify_tag,
9088 (void *)&cmd_flow_director_verify_tag_value,
9089 (void *)&cmd_flow_director_tos,
9090 (void *)&cmd_flow_director_tos_value,
9091 (void *)&cmd_flow_director_ttl,
9092 (void *)&cmd_flow_director_ttl_value,
9093 (void *)&cmd_flow_director_vlan,
9094 (void *)&cmd_flow_director_vlan_value,
9095 (void *)&cmd_flow_director_flexbytes,
9096 (void *)&cmd_flow_director_flexbytes_value,
9097 (void *)&cmd_flow_director_drop,
9098 (void *)&cmd_flow_director_pf_vf,
9099 (void *)&cmd_flow_director_queue,
9100 (void *)&cmd_flow_director_queue_id,
9101 (void *)&cmd_flow_director_fd_id,
9102 (void *)&cmd_flow_director_fd_id_value,
9107 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9108 .f = cmd_flow_director_filter_parsed,
9110 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9111 "director entry on NIC",
9113 (void *)&cmd_flow_director_filter,
9114 (void *)&cmd_flow_director_port_id,
9115 (void *)&cmd_flow_director_mode,
9116 (void *)&cmd_flow_director_mode_ip,
9117 (void *)&cmd_flow_director_ops,
9118 (void *)&cmd_flow_director_flow,
9119 (void *)&cmd_flow_director_flow_type,
9120 (void *)&cmd_flow_director_ether,
9121 (void *)&cmd_flow_director_ether_type,
9122 (void *)&cmd_flow_director_flexbytes,
9123 (void *)&cmd_flow_director_flexbytes_value,
9124 (void *)&cmd_flow_director_drop,
9125 (void *)&cmd_flow_director_pf_vf,
9126 (void *)&cmd_flow_director_queue,
9127 (void *)&cmd_flow_director_queue_id,
9128 (void *)&cmd_flow_director_fd_id,
9129 (void *)&cmd_flow_director_fd_id_value,
9134 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9135 .f = cmd_flow_director_filter_parsed,
9137 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9138 "director entry on NIC",
9140 (void *)&cmd_flow_director_filter,
9141 (void *)&cmd_flow_director_port_id,
9142 (void *)&cmd_flow_director_mode,
9143 (void *)&cmd_flow_director_mode_mac_vlan,
9144 (void *)&cmd_flow_director_ops,
9145 (void *)&cmd_flow_director_mac,
9146 (void *)&cmd_flow_director_mac_addr,
9147 (void *)&cmd_flow_director_vlan,
9148 (void *)&cmd_flow_director_vlan_value,
9149 (void *)&cmd_flow_director_flexbytes,
9150 (void *)&cmd_flow_director_flexbytes_value,
9151 (void *)&cmd_flow_director_drop,
9152 (void *)&cmd_flow_director_queue,
9153 (void *)&cmd_flow_director_queue_id,
9154 (void *)&cmd_flow_director_fd_id,
9155 (void *)&cmd_flow_director_fd_id_value,
9160 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9161 .f = cmd_flow_director_filter_parsed,
9163 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9164 "director entry on NIC",
9166 (void *)&cmd_flow_director_filter,
9167 (void *)&cmd_flow_director_port_id,
9168 (void *)&cmd_flow_director_mode,
9169 (void *)&cmd_flow_director_mode_tunnel,
9170 (void *)&cmd_flow_director_ops,
9171 (void *)&cmd_flow_director_mac,
9172 (void *)&cmd_flow_director_mac_addr,
9173 (void *)&cmd_flow_director_vlan,
9174 (void *)&cmd_flow_director_vlan_value,
9175 (void *)&cmd_flow_director_tunnel,
9176 (void *)&cmd_flow_director_tunnel_type,
9177 (void *)&cmd_flow_director_tunnel_id,
9178 (void *)&cmd_flow_director_tunnel_id_value,
9179 (void *)&cmd_flow_director_flexbytes,
9180 (void *)&cmd_flow_director_flexbytes_value,
9181 (void *)&cmd_flow_director_drop,
9182 (void *)&cmd_flow_director_queue,
9183 (void *)&cmd_flow_director_queue_id,
9184 (void *)&cmd_flow_director_fd_id,
9185 (void *)&cmd_flow_director_fd_id_value,
9190 struct cmd_flush_flow_director_result {
9191 cmdline_fixed_string_t flush_flow_director;
9195 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9196 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9197 flush_flow_director, "flush_flow_director");
9198 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9199 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9203 cmd_flush_flow_director_parsed(void *parsed_result,
9204 __attribute__((unused)) struct cmdline *cl,
9205 __attribute__((unused)) void *data)
9207 struct cmd_flow_director_result *res = parsed_result;
9210 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9212 printf("flow director is not supported on port %u.\n",
9217 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9218 RTE_ETH_FILTER_FLUSH, NULL);
9220 printf("flow director table flushing error: (%s)\n",
9224 cmdline_parse_inst_t cmd_flush_flow_director = {
9225 .f = cmd_flush_flow_director_parsed,
9227 .help_str = "flush_flow_director <port_id>: "
9228 "Flush all flow director entries of a device on NIC",
9230 (void *)&cmd_flush_flow_director_flush,
9231 (void *)&cmd_flush_flow_director_port_id,
9236 /* *** deal with flow director mask *** */
9237 struct cmd_flow_director_mask_result {
9238 cmdline_fixed_string_t flow_director_mask;
9240 cmdline_fixed_string_t mode;
9241 cmdline_fixed_string_t mode_value;
9242 cmdline_fixed_string_t vlan;
9244 cmdline_fixed_string_t src_mask;
9245 cmdline_ipaddr_t ipv4_src;
9246 cmdline_ipaddr_t ipv6_src;
9248 cmdline_fixed_string_t dst_mask;
9249 cmdline_ipaddr_t ipv4_dst;
9250 cmdline_ipaddr_t ipv6_dst;
9252 cmdline_fixed_string_t mac;
9253 uint8_t mac_addr_byte_mask;
9254 cmdline_fixed_string_t tunnel_id;
9255 uint32_t tunnel_id_mask;
9256 cmdline_fixed_string_t tunnel_type;
9257 uint8_t tunnel_type_mask;
9261 cmd_flow_director_mask_parsed(void *parsed_result,
9262 __attribute__((unused)) struct cmdline *cl,
9263 __attribute__((unused)) void *data)
9265 struct cmd_flow_director_mask_result *res = parsed_result;
9266 struct rte_eth_fdir_masks *mask;
9267 struct rte_port *port;
9269 if (res->port_id > nb_ports) {
9270 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9274 port = &ports[res->port_id];
9275 /** Check if the port is not started **/
9276 if (port->port_status != RTE_PORT_STOPPED) {
9277 printf("Please stop port %d first\n", res->port_id);
9281 mask = &port->dev_conf.fdir_conf.mask;
9283 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9284 if (strcmp(res->mode_value, "MAC-VLAN")) {
9285 printf("Please set mode to MAC-VLAN.\n");
9289 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9290 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9291 if (strcmp(res->mode_value, "Tunnel")) {
9292 printf("Please set mode to Tunnel.\n");
9296 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9297 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9298 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9299 mask->tunnel_type_mask = res->tunnel_type_mask;
9301 if (strcmp(res->mode_value, "IP")) {
9302 printf("Please set mode to IP.\n");
9306 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9307 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9308 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9309 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9310 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9311 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9312 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9315 cmd_reconfig_device_queue(res->port_id, 1, 1);
9318 cmdline_parse_token_string_t cmd_flow_director_mask =
9319 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9320 flow_director_mask, "flow_director_mask");
9321 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9322 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9324 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9325 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9327 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9328 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9330 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9331 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9332 src_mask, "src_mask");
9333 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9334 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9336 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9337 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9339 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9340 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9342 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9343 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9344 dst_mask, "dst_mask");
9345 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9346 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9348 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9349 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9351 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9352 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9355 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9356 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9358 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9359 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9361 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9363 mode_value, "MAC-VLAN");
9364 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9366 mode_value, "Tunnel");
9367 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9368 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9370 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9371 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9372 mac_addr_byte_mask, UINT8);
9373 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9374 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9375 tunnel_type, "tunnel-type");
9376 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9377 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9378 tunnel_type_mask, UINT8);
9379 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9380 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9381 tunnel_id, "tunnel-id");
9382 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9383 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9384 tunnel_id_mask, UINT32);
9386 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9387 .f = cmd_flow_director_mask_parsed,
9389 .help_str = "flow_director_mask ... : "
9390 "Set IP mode flow director's mask on NIC",
9392 (void *)&cmd_flow_director_mask,
9393 (void *)&cmd_flow_director_mask_port_id,
9394 (void *)&cmd_flow_director_mask_mode,
9395 (void *)&cmd_flow_director_mask_mode_ip,
9396 (void *)&cmd_flow_director_mask_vlan,
9397 (void *)&cmd_flow_director_mask_vlan_value,
9398 (void *)&cmd_flow_director_mask_src,
9399 (void *)&cmd_flow_director_mask_ipv4_src,
9400 (void *)&cmd_flow_director_mask_ipv6_src,
9401 (void *)&cmd_flow_director_mask_port_src,
9402 (void *)&cmd_flow_director_mask_dst,
9403 (void *)&cmd_flow_director_mask_ipv4_dst,
9404 (void *)&cmd_flow_director_mask_ipv6_dst,
9405 (void *)&cmd_flow_director_mask_port_dst,
9410 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9411 .f = cmd_flow_director_mask_parsed,
9413 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9414 "flow director's mask on NIC",
9416 (void *)&cmd_flow_director_mask,
9417 (void *)&cmd_flow_director_mask_port_id,
9418 (void *)&cmd_flow_director_mask_mode,
9419 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9420 (void *)&cmd_flow_director_mask_vlan,
9421 (void *)&cmd_flow_director_mask_vlan_value,
9426 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9427 .f = cmd_flow_director_mask_parsed,
9429 .help_str = "flow_director_mask ... : Set tunnel mode "
9430 "flow director's mask on NIC",
9432 (void *)&cmd_flow_director_mask,
9433 (void *)&cmd_flow_director_mask_port_id,
9434 (void *)&cmd_flow_director_mask_mode,
9435 (void *)&cmd_flow_director_mask_mode_tunnel,
9436 (void *)&cmd_flow_director_mask_vlan,
9437 (void *)&cmd_flow_director_mask_vlan_value,
9438 (void *)&cmd_flow_director_mask_mac,
9439 (void *)&cmd_flow_director_mask_mac_value,
9440 (void *)&cmd_flow_director_mask_tunnel_type,
9441 (void *)&cmd_flow_director_mask_tunnel_type_value,
9442 (void *)&cmd_flow_director_mask_tunnel_id,
9443 (void *)&cmd_flow_director_mask_tunnel_id_value,
9448 /* *** deal with flow director mask on flexible payload *** */
9449 struct cmd_flow_director_flex_mask_result {
9450 cmdline_fixed_string_t flow_director_flexmask;
9452 cmdline_fixed_string_t flow;
9453 cmdline_fixed_string_t flow_type;
9454 cmdline_fixed_string_t mask;
9458 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9459 __attribute__((unused)) struct cmdline *cl,
9460 __attribute__((unused)) void *data)
9462 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9463 struct rte_eth_fdir_info fdir_info;
9464 struct rte_eth_fdir_flex_mask flex_mask;
9465 struct rte_port *port;
9466 uint32_t flow_type_mask;
9470 if (res->port_id > nb_ports) {
9471 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9475 port = &ports[res->port_id];
9476 /** Check if the port is not started **/
9477 if (port->port_status != RTE_PORT_STOPPED) {
9478 printf("Please stop port %d first\n", res->port_id);
9482 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9483 ret = parse_flexbytes(res->mask,
9485 RTE_ETH_FDIR_MAX_FLEXLEN);
9487 printf("error: Cannot parse mask input.\n");
9491 memset(&fdir_info, 0, sizeof(fdir_info));
9492 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9493 RTE_ETH_FILTER_INFO, &fdir_info);
9495 printf("Cannot get FDir filter info\n");
9499 if (!strcmp(res->flow_type, "none")) {
9500 /* means don't specify the flow type */
9501 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9502 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9503 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9504 0, sizeof(struct rte_eth_fdir_flex_mask));
9505 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9506 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9508 sizeof(struct rte_eth_fdir_flex_mask));
9509 cmd_reconfig_device_queue(res->port_id, 1, 1);
9512 flow_type_mask = fdir_info.flow_types_mask[0];
9513 if (!strcmp(res->flow_type, "all")) {
9514 if (!flow_type_mask) {
9515 printf("No flow type supported\n");
9518 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9519 if (flow_type_mask & (1 << i)) {
9520 flex_mask.flow_type = i;
9521 fdir_set_flex_mask(res->port_id, &flex_mask);
9524 cmd_reconfig_device_queue(res->port_id, 1, 1);
9527 flex_mask.flow_type = str2flowtype(res->flow_type);
9528 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9529 printf("Flow type %s not supported on port %d\n",
9530 res->flow_type, res->port_id);
9533 fdir_set_flex_mask(res->port_id, &flex_mask);
9534 cmd_reconfig_device_queue(res->port_id, 1, 1);
9537 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9538 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9539 flow_director_flexmask,
9540 "flow_director_flex_mask");
9541 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9542 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9544 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9545 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9547 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9548 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9549 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9550 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9551 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9552 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9555 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9556 .f = cmd_flow_director_flex_mask_parsed,
9558 .help_str = "flow_director_flex_mask ... : "
9559 "Set flow director's flex mask on NIC",
9561 (void *)&cmd_flow_director_flexmask,
9562 (void *)&cmd_flow_director_flexmask_port_id,
9563 (void *)&cmd_flow_director_flexmask_flow,
9564 (void *)&cmd_flow_director_flexmask_flow_type,
9565 (void *)&cmd_flow_director_flexmask_mask,
9570 /* *** deal with flow director flexible payload configuration *** */
9571 struct cmd_flow_director_flexpayload_result {
9572 cmdline_fixed_string_t flow_director_flexpayload;
9574 cmdline_fixed_string_t payload_layer;
9575 cmdline_fixed_string_t payload_cfg;
9579 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9582 const char *p, *p0 = q_arg;
9584 unsigned long int_fld;
9585 char *str_fld[max_num];
9590 p = strchr(p0, '(');
9594 p0 = strchr(p, ')');
9599 if (size >= sizeof(s))
9602 snprintf(s, sizeof(s), "%.*s", size, p);
9603 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9604 if (ret < 0 || ret > max_num)
9606 for (i = 0; i < ret; i++) {
9608 int_fld = strtoul(str_fld[i], &end, 0);
9609 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9611 offsets[i] = (uint16_t)int_fld;
9617 cmd_flow_director_flxpld_parsed(void *parsed_result,
9618 __attribute__((unused)) struct cmdline *cl,
9619 __attribute__((unused)) void *data)
9621 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9622 struct rte_eth_flex_payload_cfg flex_cfg;
9623 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 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9640 if (!strcmp(res->payload_layer, "raw"))
9641 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9642 else if (!strcmp(res->payload_layer, "l2"))
9643 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9644 else if (!strcmp(res->payload_layer, "l3"))
9645 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9646 else if (!strcmp(res->payload_layer, "l4"))
9647 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9649 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9650 RTE_ETH_FDIR_MAX_FLEXLEN);
9652 printf("error: Cannot parse flex payload input.\n");
9656 fdir_set_flex_payload(res->port_id, &flex_cfg);
9657 cmd_reconfig_device_queue(res->port_id, 1, 1);
9660 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9661 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9662 flow_director_flexpayload,
9663 "flow_director_flex_payload");
9664 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9665 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9667 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9668 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9669 payload_layer, "raw#l2#l3#l4");
9670 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9671 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9674 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9675 .f = cmd_flow_director_flxpld_parsed,
9677 .help_str = "flow_director_flexpayload ... : "
9678 "Set flow director's flex payload on NIC",
9680 (void *)&cmd_flow_director_flexpayload,
9681 (void *)&cmd_flow_director_flexpayload_port_id,
9682 (void *)&cmd_flow_director_flexpayload_payload_layer,
9683 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9688 /* Generic flow interface command. */
9689 extern cmdline_parse_inst_t cmd_flow;
9691 /* *** Classification Filters Control *** */
9692 /* *** Get symmetric hash enable per port *** */
9693 struct cmd_get_sym_hash_ena_per_port_result {
9694 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9699 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9700 __rte_unused struct cmdline *cl,
9701 __rte_unused void *data)
9703 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9704 struct rte_eth_hash_filter_info info;
9707 if (rte_eth_dev_filter_supported(res->port_id,
9708 RTE_ETH_FILTER_HASH) < 0) {
9709 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9714 memset(&info, 0, sizeof(info));
9715 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9716 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9717 RTE_ETH_FILTER_GET, &info);
9720 printf("Cannot get symmetric hash enable per port "
9721 "on port %u\n", res->port_id);
9725 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9726 "enabled" : "disabled", res->port_id);
9729 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9730 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9731 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9732 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9733 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9736 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9737 .f = cmd_get_sym_hash_per_port_parsed,
9739 .help_str = "get_sym_hash_ena_per_port <port_id>",
9741 (void *)&cmd_get_sym_hash_ena_per_port_all,
9742 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9747 /* *** Set symmetric hash enable per port *** */
9748 struct cmd_set_sym_hash_ena_per_port_result {
9749 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9750 cmdline_fixed_string_t enable;
9755 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9756 __rte_unused struct cmdline *cl,
9757 __rte_unused void *data)
9759 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9760 struct rte_eth_hash_filter_info info;
9763 if (rte_eth_dev_filter_supported(res->port_id,
9764 RTE_ETH_FILTER_HASH) < 0) {
9765 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9770 memset(&info, 0, sizeof(info));
9771 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9772 if (!strcmp(res->enable, "enable"))
9773 info.info.enable = 1;
9774 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9775 RTE_ETH_FILTER_SET, &info);
9777 printf("Cannot set symmetric hash enable per port on "
9778 "port %u\n", res->port_id);
9781 printf("Symmetric hash has been set to %s on port %u\n",
9782 res->enable, res->port_id);
9785 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9786 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9787 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9788 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9789 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9791 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9792 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9793 enable, "enable#disable");
9795 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9796 .f = cmd_set_sym_hash_per_port_parsed,
9798 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9800 (void *)&cmd_set_sym_hash_ena_per_port_all,
9801 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9802 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9807 /* Get global config of hash function */
9808 struct cmd_get_hash_global_config_result {
9809 cmdline_fixed_string_t get_hash_global_config;
9814 flowtype_to_str(uint16_t ftype)
9821 {"ipv4", RTE_ETH_FLOW_IPV4},
9822 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9823 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9824 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9825 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9826 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9827 {"ipv6", RTE_ETH_FLOW_IPV6},
9828 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9829 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9830 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9831 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9832 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9833 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9834 {"port", RTE_ETH_FLOW_PORT},
9835 {"vxlan", RTE_ETH_FLOW_VXLAN},
9836 {"geneve", RTE_ETH_FLOW_GENEVE},
9837 {"nvgre", RTE_ETH_FLOW_NVGRE},
9840 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9841 if (ftype_table[i].ftype == ftype)
9842 return ftype_table[i].str;
9849 cmd_get_hash_global_config_parsed(void *parsed_result,
9850 __rte_unused struct cmdline *cl,
9851 __rte_unused void *data)
9853 struct cmd_get_hash_global_config_result *res = parsed_result;
9854 struct rte_eth_hash_filter_info info;
9855 uint32_t idx, offset;
9860 if (rte_eth_dev_filter_supported(res->port_id,
9861 RTE_ETH_FILTER_HASH) < 0) {
9862 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9867 memset(&info, 0, sizeof(info));
9868 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9869 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9870 RTE_ETH_FILTER_GET, &info);
9872 printf("Cannot get hash global configurations by port %d\n",
9877 switch (info.info.global_conf.hash_func) {
9878 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9879 printf("Hash function is Toeplitz\n");
9881 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9882 printf("Hash function is Simple XOR\n");
9885 printf("Unknown hash function\n");
9889 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9890 idx = i / UINT32_BIT;
9891 offset = i % UINT32_BIT;
9892 if (!(info.info.global_conf.valid_bit_mask[idx] &
9895 str = flowtype_to_str(i);
9898 printf("Symmetric hash is %s globally for flow type %s "
9900 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9901 (1UL << offset)) ? "enabled" : "disabled"), str,
9906 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9907 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9908 get_hash_global_config, "get_hash_global_config");
9909 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9910 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9913 cmdline_parse_inst_t cmd_get_hash_global_config = {
9914 .f = cmd_get_hash_global_config_parsed,
9916 .help_str = "get_hash_global_config <port_id>",
9918 (void *)&cmd_get_hash_global_config_all,
9919 (void *)&cmd_get_hash_global_config_port_id,
9924 /* Set global config of hash function */
9925 struct cmd_set_hash_global_config_result {
9926 cmdline_fixed_string_t set_hash_global_config;
9928 cmdline_fixed_string_t hash_func;
9929 cmdline_fixed_string_t flow_type;
9930 cmdline_fixed_string_t enable;
9934 cmd_set_hash_global_config_parsed(void *parsed_result,
9935 __rte_unused struct cmdline *cl,
9936 __rte_unused void *data)
9938 struct cmd_set_hash_global_config_result *res = parsed_result;
9939 struct rte_eth_hash_filter_info info;
9940 uint32_t ftype, idx, offset;
9943 if (rte_eth_dev_filter_supported(res->port_id,
9944 RTE_ETH_FILTER_HASH) < 0) {
9945 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9949 memset(&info, 0, sizeof(info));
9950 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9951 if (!strcmp(res->hash_func, "toeplitz"))
9952 info.info.global_conf.hash_func =
9953 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9954 else if (!strcmp(res->hash_func, "simple_xor"))
9955 info.info.global_conf.hash_func =
9956 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9957 else if (!strcmp(res->hash_func, "default"))
9958 info.info.global_conf.hash_func =
9959 RTE_ETH_HASH_FUNCTION_DEFAULT;
9961 ftype = str2flowtype(res->flow_type);
9962 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9963 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9964 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9965 if (!strcmp(res->enable, "enable"))
9966 info.info.global_conf.sym_hash_enable_mask[idx] |=
9968 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9969 RTE_ETH_FILTER_SET, &info);
9971 printf("Cannot set global hash configurations by port %d\n",
9974 printf("Global hash configurations have been set "
9975 "succcessfully by port %d\n", res->port_id);
9978 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9979 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9980 set_hash_global_config, "set_hash_global_config");
9981 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9982 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9984 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9985 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9986 hash_func, "toeplitz#simple_xor#default");
9987 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9988 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9990 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9991 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9992 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9993 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9994 enable, "enable#disable");
9996 cmdline_parse_inst_t cmd_set_hash_global_config = {
9997 .f = cmd_set_hash_global_config_parsed,
9999 .help_str = "set_hash_global_config <port_id> "
10000 "toeplitz|simple_xor|default "
10001 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10002 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10003 "l2_payload enable|disable",
10005 (void *)&cmd_set_hash_global_config_all,
10006 (void *)&cmd_set_hash_global_config_port_id,
10007 (void *)&cmd_set_hash_global_config_hash_func,
10008 (void *)&cmd_set_hash_global_config_flow_type,
10009 (void *)&cmd_set_hash_global_config_enable,
10014 /* Set hash input set */
10015 struct cmd_set_hash_input_set_result {
10016 cmdline_fixed_string_t set_hash_input_set;
10018 cmdline_fixed_string_t flow_type;
10019 cmdline_fixed_string_t inset_field;
10020 cmdline_fixed_string_t select;
10023 static enum rte_eth_input_set_field
10024 str2inset(char *string)
10028 static const struct {
10030 enum rte_eth_input_set_field inset;
10031 } inset_table[] = {
10032 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10033 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10034 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10035 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10036 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10037 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10038 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10039 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10040 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10041 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10042 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10043 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10044 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10045 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10046 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10047 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10048 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10049 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10050 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10051 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10052 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10053 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10054 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10055 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10056 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10057 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10058 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10059 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10060 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10061 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10062 {"none", RTE_ETH_INPUT_SET_NONE},
10065 for (i = 0; i < RTE_DIM(inset_table); i++) {
10066 if (!strcmp(string, inset_table[i].str))
10067 return inset_table[i].inset;
10070 return RTE_ETH_INPUT_SET_UNKNOWN;
10074 cmd_set_hash_input_set_parsed(void *parsed_result,
10075 __rte_unused struct cmdline *cl,
10076 __rte_unused void *data)
10078 struct cmd_set_hash_input_set_result *res = parsed_result;
10079 struct rte_eth_hash_filter_info info;
10081 memset(&info, 0, sizeof(info));
10082 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10083 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10084 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10085 info.info.input_set_conf.inset_size = 1;
10086 if (!strcmp(res->select, "select"))
10087 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10088 else if (!strcmp(res->select, "add"))
10089 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10090 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10091 RTE_ETH_FILTER_SET, &info);
10094 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10095 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10096 set_hash_input_set, "set_hash_input_set");
10097 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10098 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10100 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10101 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10103 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10104 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10105 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10106 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10108 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10109 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10110 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10111 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10112 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10114 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10115 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10116 select, "select#add");
10118 cmdline_parse_inst_t cmd_set_hash_input_set = {
10119 .f = cmd_set_hash_input_set_parsed,
10121 .help_str = "set_hash_input_set <port_id> "
10122 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10123 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10124 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10125 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10126 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10127 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10128 "fld-7th|fld-8th|none select|add",
10130 (void *)&cmd_set_hash_input_set_cmd,
10131 (void *)&cmd_set_hash_input_set_port_id,
10132 (void *)&cmd_set_hash_input_set_flow_type,
10133 (void *)&cmd_set_hash_input_set_field,
10134 (void *)&cmd_set_hash_input_set_select,
10139 /* Set flow director input set */
10140 struct cmd_set_fdir_input_set_result {
10141 cmdline_fixed_string_t set_fdir_input_set;
10143 cmdline_fixed_string_t flow_type;
10144 cmdline_fixed_string_t inset_field;
10145 cmdline_fixed_string_t select;
10149 cmd_set_fdir_input_set_parsed(void *parsed_result,
10150 __rte_unused struct cmdline *cl,
10151 __rte_unused void *data)
10153 struct cmd_set_fdir_input_set_result *res = parsed_result;
10154 struct rte_eth_fdir_filter_info info;
10156 memset(&info, 0, sizeof(info));
10157 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10158 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10159 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10160 info.info.input_set_conf.inset_size = 1;
10161 if (!strcmp(res->select, "select"))
10162 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10163 else if (!strcmp(res->select, "add"))
10164 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10165 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10166 RTE_ETH_FILTER_SET, &info);
10169 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10170 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10171 set_fdir_input_set, "set_fdir_input_set");
10172 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10173 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10175 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10176 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10178 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10179 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10180 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10181 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10183 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10184 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10185 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10186 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10187 "sctp-veri-tag#none");
10188 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10189 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10190 select, "select#add");
10192 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10193 .f = cmd_set_fdir_input_set_parsed,
10195 .help_str = "set_fdir_input_set <port_id> "
10196 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10197 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10198 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10199 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10200 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10201 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10202 "sctp-veri-tag|none select|add",
10204 (void *)&cmd_set_fdir_input_set_cmd,
10205 (void *)&cmd_set_fdir_input_set_port_id,
10206 (void *)&cmd_set_fdir_input_set_flow_type,
10207 (void *)&cmd_set_fdir_input_set_field,
10208 (void *)&cmd_set_fdir_input_set_select,
10213 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10214 struct cmd_mcast_addr_result {
10215 cmdline_fixed_string_t mcast_addr_cmd;
10216 cmdline_fixed_string_t what;
10218 struct ether_addr mc_addr;
10221 static void cmd_mcast_addr_parsed(void *parsed_result,
10222 __attribute__((unused)) struct cmdline *cl,
10223 __attribute__((unused)) void *data)
10225 struct cmd_mcast_addr_result *res = parsed_result;
10227 if (!is_multicast_ether_addr(&res->mc_addr)) {
10228 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10229 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10230 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10231 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10234 if (strcmp(res->what, "add") == 0)
10235 mcast_addr_add(res->port_num, &res->mc_addr);
10237 mcast_addr_remove(res->port_num, &res->mc_addr);
10240 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10241 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10242 mcast_addr_cmd, "mcast_addr");
10243 cmdline_parse_token_string_t cmd_mcast_addr_what =
10244 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10246 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10247 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10248 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10249 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10251 cmdline_parse_inst_t cmd_mcast_addr = {
10252 .f = cmd_mcast_addr_parsed,
10254 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10255 "Add/Remove multicast MAC address on port_id",
10257 (void *)&cmd_mcast_addr_cmd,
10258 (void *)&cmd_mcast_addr_what,
10259 (void *)&cmd_mcast_addr_portnum,
10260 (void *)&cmd_mcast_addr_addr,
10265 /* l2 tunnel config
10266 * only support E-tag now.
10269 /* Ether type config */
10270 struct cmd_config_l2_tunnel_eth_type_result {
10271 cmdline_fixed_string_t port;
10272 cmdline_fixed_string_t config;
10273 cmdline_fixed_string_t all;
10275 cmdline_fixed_string_t l2_tunnel;
10276 cmdline_fixed_string_t l2_tunnel_type;
10277 cmdline_fixed_string_t eth_type;
10278 uint16_t eth_type_val;
10281 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10282 TOKEN_STRING_INITIALIZER
10283 (struct cmd_config_l2_tunnel_eth_type_result,
10285 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10286 TOKEN_STRING_INITIALIZER
10287 (struct cmd_config_l2_tunnel_eth_type_result,
10289 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10290 TOKEN_STRING_INITIALIZER
10291 (struct cmd_config_l2_tunnel_eth_type_result,
10293 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10294 TOKEN_NUM_INITIALIZER
10295 (struct cmd_config_l2_tunnel_eth_type_result,
10297 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10298 TOKEN_STRING_INITIALIZER
10299 (struct cmd_config_l2_tunnel_eth_type_result,
10300 l2_tunnel, "l2-tunnel");
10301 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10302 TOKEN_STRING_INITIALIZER
10303 (struct cmd_config_l2_tunnel_eth_type_result,
10304 l2_tunnel_type, "E-tag");
10305 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10306 TOKEN_STRING_INITIALIZER
10307 (struct cmd_config_l2_tunnel_eth_type_result,
10308 eth_type, "ether-type");
10309 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10310 TOKEN_NUM_INITIALIZER
10311 (struct cmd_config_l2_tunnel_eth_type_result,
10312 eth_type_val, UINT16);
10314 static enum rte_eth_tunnel_type
10315 str2fdir_l2_tunnel_type(char *string)
10319 static const struct {
10321 enum rte_eth_tunnel_type type;
10322 } l2_tunnel_type_str[] = {
10323 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10326 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10327 if (!strcmp(l2_tunnel_type_str[i].str, string))
10328 return l2_tunnel_type_str[i].type;
10330 return RTE_TUNNEL_TYPE_NONE;
10333 /* ether type config for all ports */
10335 cmd_config_l2_tunnel_eth_type_all_parsed
10336 (void *parsed_result,
10337 __attribute__((unused)) struct cmdline *cl,
10338 __attribute__((unused)) void *data)
10340 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10341 struct rte_eth_l2_tunnel_conf entry;
10344 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10345 entry.ether_type = res->eth_type_val;
10347 FOREACH_PORT(pid, ports) {
10348 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10352 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10353 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10355 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10357 (void *)&cmd_config_l2_tunnel_eth_type_port,
10358 (void *)&cmd_config_l2_tunnel_eth_type_config,
10359 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10360 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10361 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10362 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10363 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10368 /* ether type config for a specific port */
10370 cmd_config_l2_tunnel_eth_type_specific_parsed(
10371 void *parsed_result,
10372 __attribute__((unused)) struct cmdline *cl,
10373 __attribute__((unused)) void *data)
10375 struct cmd_config_l2_tunnel_eth_type_result *res =
10377 struct rte_eth_l2_tunnel_conf entry;
10379 if (port_id_is_invalid(res->id, ENABLED_WARN))
10382 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10383 entry.ether_type = res->eth_type_val;
10385 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10388 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10389 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10391 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10393 (void *)&cmd_config_l2_tunnel_eth_type_port,
10394 (void *)&cmd_config_l2_tunnel_eth_type_config,
10395 (void *)&cmd_config_l2_tunnel_eth_type_id,
10396 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10397 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10398 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10399 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10404 /* Enable/disable l2 tunnel */
10405 struct cmd_config_l2_tunnel_en_dis_result {
10406 cmdline_fixed_string_t port;
10407 cmdline_fixed_string_t config;
10408 cmdline_fixed_string_t all;
10410 cmdline_fixed_string_t l2_tunnel;
10411 cmdline_fixed_string_t l2_tunnel_type;
10412 cmdline_fixed_string_t en_dis;
10415 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10416 TOKEN_STRING_INITIALIZER
10417 (struct cmd_config_l2_tunnel_en_dis_result,
10419 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10420 TOKEN_STRING_INITIALIZER
10421 (struct cmd_config_l2_tunnel_en_dis_result,
10423 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10424 TOKEN_STRING_INITIALIZER
10425 (struct cmd_config_l2_tunnel_en_dis_result,
10427 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10428 TOKEN_NUM_INITIALIZER
10429 (struct cmd_config_l2_tunnel_en_dis_result,
10431 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10432 TOKEN_STRING_INITIALIZER
10433 (struct cmd_config_l2_tunnel_en_dis_result,
10434 l2_tunnel, "l2-tunnel");
10435 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10436 TOKEN_STRING_INITIALIZER
10437 (struct cmd_config_l2_tunnel_en_dis_result,
10438 l2_tunnel_type, "E-tag");
10439 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10440 TOKEN_STRING_INITIALIZER
10441 (struct cmd_config_l2_tunnel_en_dis_result,
10442 en_dis, "enable#disable");
10444 /* enable/disable l2 tunnel for all ports */
10446 cmd_config_l2_tunnel_en_dis_all_parsed(
10447 void *parsed_result,
10448 __attribute__((unused)) struct cmdline *cl,
10449 __attribute__((unused)) void *data)
10451 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10452 struct rte_eth_l2_tunnel_conf entry;
10456 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10458 if (!strcmp("enable", res->en_dis))
10463 FOREACH_PORT(pid, ports) {
10464 rte_eth_dev_l2_tunnel_offload_set(pid,
10466 ETH_L2_TUNNEL_ENABLE_MASK,
10471 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10472 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10474 .help_str = "port config all l2-tunnel E-tag enable|disable",
10476 (void *)&cmd_config_l2_tunnel_en_dis_port,
10477 (void *)&cmd_config_l2_tunnel_en_dis_config,
10478 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10479 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10480 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10481 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10486 /* enable/disable l2 tunnel for a port */
10488 cmd_config_l2_tunnel_en_dis_specific_parsed(
10489 void *parsed_result,
10490 __attribute__((unused)) struct cmdline *cl,
10491 __attribute__((unused)) void *data)
10493 struct cmd_config_l2_tunnel_en_dis_result *res =
10495 struct rte_eth_l2_tunnel_conf entry;
10497 if (port_id_is_invalid(res->id, ENABLED_WARN))
10500 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10502 if (!strcmp("enable", res->en_dis))
10503 rte_eth_dev_l2_tunnel_offload_set(res->id,
10505 ETH_L2_TUNNEL_ENABLE_MASK,
10508 rte_eth_dev_l2_tunnel_offload_set(res->id,
10510 ETH_L2_TUNNEL_ENABLE_MASK,
10514 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10515 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10517 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10519 (void *)&cmd_config_l2_tunnel_en_dis_port,
10520 (void *)&cmd_config_l2_tunnel_en_dis_config,
10521 (void *)&cmd_config_l2_tunnel_en_dis_id,
10522 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10523 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10524 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10529 /* E-tag configuration */
10531 /* Common result structure for all E-tag configuration */
10532 struct cmd_config_e_tag_result {
10533 cmdline_fixed_string_t e_tag;
10534 cmdline_fixed_string_t set;
10535 cmdline_fixed_string_t insertion;
10536 cmdline_fixed_string_t stripping;
10537 cmdline_fixed_string_t forwarding;
10538 cmdline_fixed_string_t filter;
10539 cmdline_fixed_string_t add;
10540 cmdline_fixed_string_t del;
10541 cmdline_fixed_string_t on;
10542 cmdline_fixed_string_t off;
10543 cmdline_fixed_string_t on_off;
10544 cmdline_fixed_string_t port_tag_id;
10545 uint32_t port_tag_id_val;
10546 cmdline_fixed_string_t e_tag_id;
10547 uint16_t e_tag_id_val;
10548 cmdline_fixed_string_t dst_pool;
10549 uint8_t dst_pool_val;
10550 cmdline_fixed_string_t port;
10552 cmdline_fixed_string_t vf;
10556 /* Common CLI fields for all E-tag configuration */
10557 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10558 TOKEN_STRING_INITIALIZER
10559 (struct cmd_config_e_tag_result,
10561 cmdline_parse_token_string_t cmd_config_e_tag_set =
10562 TOKEN_STRING_INITIALIZER
10563 (struct cmd_config_e_tag_result,
10565 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10566 TOKEN_STRING_INITIALIZER
10567 (struct cmd_config_e_tag_result,
10568 insertion, "insertion");
10569 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10570 TOKEN_STRING_INITIALIZER
10571 (struct cmd_config_e_tag_result,
10572 stripping, "stripping");
10573 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10574 TOKEN_STRING_INITIALIZER
10575 (struct cmd_config_e_tag_result,
10576 forwarding, "forwarding");
10577 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10578 TOKEN_STRING_INITIALIZER
10579 (struct cmd_config_e_tag_result,
10581 cmdline_parse_token_string_t cmd_config_e_tag_add =
10582 TOKEN_STRING_INITIALIZER
10583 (struct cmd_config_e_tag_result,
10585 cmdline_parse_token_string_t cmd_config_e_tag_del =
10586 TOKEN_STRING_INITIALIZER
10587 (struct cmd_config_e_tag_result,
10589 cmdline_parse_token_string_t cmd_config_e_tag_on =
10590 TOKEN_STRING_INITIALIZER
10591 (struct cmd_config_e_tag_result,
10593 cmdline_parse_token_string_t cmd_config_e_tag_off =
10594 TOKEN_STRING_INITIALIZER
10595 (struct cmd_config_e_tag_result,
10597 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10598 TOKEN_STRING_INITIALIZER
10599 (struct cmd_config_e_tag_result,
10601 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10602 TOKEN_STRING_INITIALIZER
10603 (struct cmd_config_e_tag_result,
10604 port_tag_id, "port-tag-id");
10605 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10606 TOKEN_NUM_INITIALIZER
10607 (struct cmd_config_e_tag_result,
10608 port_tag_id_val, UINT32);
10609 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10610 TOKEN_STRING_INITIALIZER
10611 (struct cmd_config_e_tag_result,
10612 e_tag_id, "e-tag-id");
10613 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10614 TOKEN_NUM_INITIALIZER
10615 (struct cmd_config_e_tag_result,
10616 e_tag_id_val, UINT16);
10617 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10618 TOKEN_STRING_INITIALIZER
10619 (struct cmd_config_e_tag_result,
10620 dst_pool, "dst-pool");
10621 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10622 TOKEN_NUM_INITIALIZER
10623 (struct cmd_config_e_tag_result,
10624 dst_pool_val, UINT8);
10625 cmdline_parse_token_string_t cmd_config_e_tag_port =
10626 TOKEN_STRING_INITIALIZER
10627 (struct cmd_config_e_tag_result,
10629 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10630 TOKEN_NUM_INITIALIZER
10631 (struct cmd_config_e_tag_result,
10633 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10634 TOKEN_STRING_INITIALIZER
10635 (struct cmd_config_e_tag_result,
10637 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10638 TOKEN_NUM_INITIALIZER
10639 (struct cmd_config_e_tag_result,
10642 /* E-tag insertion configuration */
10644 cmd_config_e_tag_insertion_en_parsed(
10645 void *parsed_result,
10646 __attribute__((unused)) struct cmdline *cl,
10647 __attribute__((unused)) void *data)
10649 struct cmd_config_e_tag_result *res =
10651 struct rte_eth_l2_tunnel_conf entry;
10653 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10656 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10657 entry.tunnel_id = res->port_tag_id_val;
10658 entry.vf_id = res->vf_id;
10659 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10661 ETH_L2_TUNNEL_INSERTION_MASK,
10666 cmd_config_e_tag_insertion_dis_parsed(
10667 void *parsed_result,
10668 __attribute__((unused)) struct cmdline *cl,
10669 __attribute__((unused)) void *data)
10671 struct cmd_config_e_tag_result *res =
10673 struct rte_eth_l2_tunnel_conf entry;
10675 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10678 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10679 entry.vf_id = res->vf_id;
10681 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10683 ETH_L2_TUNNEL_INSERTION_MASK,
10687 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10688 .f = cmd_config_e_tag_insertion_en_parsed,
10690 .help_str = "E-tag ... : E-tag insertion enable",
10692 (void *)&cmd_config_e_tag_e_tag,
10693 (void *)&cmd_config_e_tag_set,
10694 (void *)&cmd_config_e_tag_insertion,
10695 (void *)&cmd_config_e_tag_on,
10696 (void *)&cmd_config_e_tag_port_tag_id,
10697 (void *)&cmd_config_e_tag_port_tag_id_val,
10698 (void *)&cmd_config_e_tag_port,
10699 (void *)&cmd_config_e_tag_port_id,
10700 (void *)&cmd_config_e_tag_vf,
10701 (void *)&cmd_config_e_tag_vf_id,
10706 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10707 .f = cmd_config_e_tag_insertion_dis_parsed,
10709 .help_str = "E-tag ... : E-tag insertion disable",
10711 (void *)&cmd_config_e_tag_e_tag,
10712 (void *)&cmd_config_e_tag_set,
10713 (void *)&cmd_config_e_tag_insertion,
10714 (void *)&cmd_config_e_tag_off,
10715 (void *)&cmd_config_e_tag_port,
10716 (void *)&cmd_config_e_tag_port_id,
10717 (void *)&cmd_config_e_tag_vf,
10718 (void *)&cmd_config_e_tag_vf_id,
10723 /* E-tag stripping configuration */
10725 cmd_config_e_tag_stripping_parsed(
10726 void *parsed_result,
10727 __attribute__((unused)) struct cmdline *cl,
10728 __attribute__((unused)) void *data)
10730 struct cmd_config_e_tag_result *res =
10732 struct rte_eth_l2_tunnel_conf entry;
10734 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10737 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10739 if (!strcmp(res->on_off, "on"))
10740 rte_eth_dev_l2_tunnel_offload_set
10743 ETH_L2_TUNNEL_STRIPPING_MASK,
10746 rte_eth_dev_l2_tunnel_offload_set
10749 ETH_L2_TUNNEL_STRIPPING_MASK,
10753 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10754 .f = cmd_config_e_tag_stripping_parsed,
10756 .help_str = "E-tag ... : E-tag stripping enable/disable",
10758 (void *)&cmd_config_e_tag_e_tag,
10759 (void *)&cmd_config_e_tag_set,
10760 (void *)&cmd_config_e_tag_stripping,
10761 (void *)&cmd_config_e_tag_on_off,
10762 (void *)&cmd_config_e_tag_port,
10763 (void *)&cmd_config_e_tag_port_id,
10768 /* E-tag forwarding configuration */
10770 cmd_config_e_tag_forwarding_parsed(
10771 void *parsed_result,
10772 __attribute__((unused)) struct cmdline *cl,
10773 __attribute__((unused)) void *data)
10775 struct cmd_config_e_tag_result *res = parsed_result;
10776 struct rte_eth_l2_tunnel_conf entry;
10778 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10781 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10783 if (!strcmp(res->on_off, "on"))
10784 rte_eth_dev_l2_tunnel_offload_set
10787 ETH_L2_TUNNEL_FORWARDING_MASK,
10790 rte_eth_dev_l2_tunnel_offload_set
10793 ETH_L2_TUNNEL_FORWARDING_MASK,
10797 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10798 .f = cmd_config_e_tag_forwarding_parsed,
10800 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10802 (void *)&cmd_config_e_tag_e_tag,
10803 (void *)&cmd_config_e_tag_set,
10804 (void *)&cmd_config_e_tag_forwarding,
10805 (void *)&cmd_config_e_tag_on_off,
10806 (void *)&cmd_config_e_tag_port,
10807 (void *)&cmd_config_e_tag_port_id,
10812 /* E-tag filter configuration */
10814 cmd_config_e_tag_filter_add_parsed(
10815 void *parsed_result,
10816 __attribute__((unused)) struct cmdline *cl,
10817 __attribute__((unused)) void *data)
10819 struct cmd_config_e_tag_result *res = parsed_result;
10820 struct rte_eth_l2_tunnel_conf entry;
10823 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10826 if (res->e_tag_id_val > 0x3fff) {
10827 printf("e-tag-id must be equal or less than 0x3fff.\n");
10831 ret = rte_eth_dev_filter_supported(res->port_id,
10832 RTE_ETH_FILTER_L2_TUNNEL);
10834 printf("E-tag filter is not supported on port %u.\n",
10839 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10840 entry.tunnel_id = res->e_tag_id_val;
10841 entry.pool = res->dst_pool_val;
10843 ret = rte_eth_dev_filter_ctrl(res->port_id,
10844 RTE_ETH_FILTER_L2_TUNNEL,
10845 RTE_ETH_FILTER_ADD,
10848 printf("E-tag filter programming error: (%s)\n",
10852 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10853 .f = cmd_config_e_tag_filter_add_parsed,
10855 .help_str = "E-tag ... : E-tag filter add",
10857 (void *)&cmd_config_e_tag_e_tag,
10858 (void *)&cmd_config_e_tag_set,
10859 (void *)&cmd_config_e_tag_filter,
10860 (void *)&cmd_config_e_tag_add,
10861 (void *)&cmd_config_e_tag_e_tag_id,
10862 (void *)&cmd_config_e_tag_e_tag_id_val,
10863 (void *)&cmd_config_e_tag_dst_pool,
10864 (void *)&cmd_config_e_tag_dst_pool_val,
10865 (void *)&cmd_config_e_tag_port,
10866 (void *)&cmd_config_e_tag_port_id,
10872 cmd_config_e_tag_filter_del_parsed(
10873 void *parsed_result,
10874 __attribute__((unused)) struct cmdline *cl,
10875 __attribute__((unused)) void *data)
10877 struct cmd_config_e_tag_result *res = parsed_result;
10878 struct rte_eth_l2_tunnel_conf entry;
10881 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10884 if (res->e_tag_id_val > 0x3fff) {
10885 printf("e-tag-id must be less than 0x3fff.\n");
10889 ret = rte_eth_dev_filter_supported(res->port_id,
10890 RTE_ETH_FILTER_L2_TUNNEL);
10892 printf("E-tag filter is not supported on port %u.\n",
10897 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10898 entry.tunnel_id = res->e_tag_id_val;
10900 ret = rte_eth_dev_filter_ctrl(res->port_id,
10901 RTE_ETH_FILTER_L2_TUNNEL,
10902 RTE_ETH_FILTER_DELETE,
10905 printf("E-tag filter programming error: (%s)\n",
10909 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10910 .f = cmd_config_e_tag_filter_del_parsed,
10912 .help_str = "E-tag ... : E-tag filter delete",
10914 (void *)&cmd_config_e_tag_e_tag,
10915 (void *)&cmd_config_e_tag_set,
10916 (void *)&cmd_config_e_tag_filter,
10917 (void *)&cmd_config_e_tag_del,
10918 (void *)&cmd_config_e_tag_e_tag_id,
10919 (void *)&cmd_config_e_tag_e_tag_id_val,
10920 (void *)&cmd_config_e_tag_port,
10921 (void *)&cmd_config_e_tag_port_id,
10926 /* vf vlan anti spoof configuration */
10928 /* Common result structure for vf vlan anti spoof */
10929 struct cmd_vf_vlan_anti_spoof_result {
10930 cmdline_fixed_string_t set;
10931 cmdline_fixed_string_t vf;
10932 cmdline_fixed_string_t vlan;
10933 cmdline_fixed_string_t antispoof;
10936 cmdline_fixed_string_t on_off;
10939 /* Common CLI fields for vf vlan anti spoof enable disable */
10940 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10941 TOKEN_STRING_INITIALIZER
10942 (struct cmd_vf_vlan_anti_spoof_result,
10944 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10945 TOKEN_STRING_INITIALIZER
10946 (struct cmd_vf_vlan_anti_spoof_result,
10948 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10949 TOKEN_STRING_INITIALIZER
10950 (struct cmd_vf_vlan_anti_spoof_result,
10952 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10953 TOKEN_STRING_INITIALIZER
10954 (struct cmd_vf_vlan_anti_spoof_result,
10955 antispoof, "antispoof");
10956 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10957 TOKEN_NUM_INITIALIZER
10958 (struct cmd_vf_vlan_anti_spoof_result,
10960 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10961 TOKEN_NUM_INITIALIZER
10962 (struct cmd_vf_vlan_anti_spoof_result,
10964 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10965 TOKEN_STRING_INITIALIZER
10966 (struct cmd_vf_vlan_anti_spoof_result,
10970 cmd_set_vf_vlan_anti_spoof_parsed(
10971 void *parsed_result,
10972 __attribute__((unused)) struct cmdline *cl,
10973 __attribute__((unused)) void *data)
10975 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10976 int ret = -ENOTSUP;
10978 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10980 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10983 #ifdef RTE_LIBRTE_IXGBE_PMD
10984 if (ret == -ENOTSUP)
10985 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10986 res->vf_id, is_on);
10988 #ifdef RTE_LIBRTE_I40E_PMD
10989 if (ret == -ENOTSUP)
10990 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10991 res->vf_id, is_on);
10998 printf("invalid vf_id %d\n", res->vf_id);
11001 printf("invalid port_id %d\n", res->port_id);
11004 printf("function not implemented\n");
11007 printf("programming error: (%s)\n", strerror(-ret));
11011 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11012 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11014 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11016 (void *)&cmd_vf_vlan_anti_spoof_set,
11017 (void *)&cmd_vf_vlan_anti_spoof_vf,
11018 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11019 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11020 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11021 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11022 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11027 /* vf mac anti spoof configuration */
11029 /* Common result structure for vf mac anti spoof */
11030 struct cmd_vf_mac_anti_spoof_result {
11031 cmdline_fixed_string_t set;
11032 cmdline_fixed_string_t vf;
11033 cmdline_fixed_string_t mac;
11034 cmdline_fixed_string_t antispoof;
11037 cmdline_fixed_string_t on_off;
11040 /* Common CLI fields for vf mac anti spoof enable disable */
11041 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11042 TOKEN_STRING_INITIALIZER
11043 (struct cmd_vf_mac_anti_spoof_result,
11045 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11046 TOKEN_STRING_INITIALIZER
11047 (struct cmd_vf_mac_anti_spoof_result,
11049 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11050 TOKEN_STRING_INITIALIZER
11051 (struct cmd_vf_mac_anti_spoof_result,
11053 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11054 TOKEN_STRING_INITIALIZER
11055 (struct cmd_vf_mac_anti_spoof_result,
11056 antispoof, "antispoof");
11057 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11058 TOKEN_NUM_INITIALIZER
11059 (struct cmd_vf_mac_anti_spoof_result,
11061 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11062 TOKEN_NUM_INITIALIZER
11063 (struct cmd_vf_mac_anti_spoof_result,
11065 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11066 TOKEN_STRING_INITIALIZER
11067 (struct cmd_vf_mac_anti_spoof_result,
11071 cmd_set_vf_mac_anti_spoof_parsed(
11072 void *parsed_result,
11073 __attribute__((unused)) struct cmdline *cl,
11074 __attribute__((unused)) void *data)
11076 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11077 int ret = -ENOTSUP;
11079 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11081 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11084 #ifdef RTE_LIBRTE_IXGBE_PMD
11085 if (ret == -ENOTSUP)
11086 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11087 res->vf_id, is_on);
11089 #ifdef RTE_LIBRTE_I40E_PMD
11090 if (ret == -ENOTSUP)
11091 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11092 res->vf_id, is_on);
11099 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11102 printf("invalid port_id %d\n", res->port_id);
11105 printf("function not implemented\n");
11108 printf("programming error: (%s)\n", strerror(-ret));
11112 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11113 .f = cmd_set_vf_mac_anti_spoof_parsed,
11115 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11117 (void *)&cmd_vf_mac_anti_spoof_set,
11118 (void *)&cmd_vf_mac_anti_spoof_vf,
11119 (void *)&cmd_vf_mac_anti_spoof_mac,
11120 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11121 (void *)&cmd_vf_mac_anti_spoof_port_id,
11122 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11123 (void *)&cmd_vf_mac_anti_spoof_on_off,
11128 /* vf vlan strip queue configuration */
11130 /* Common result structure for vf mac anti spoof */
11131 struct cmd_vf_vlan_stripq_result {
11132 cmdline_fixed_string_t set;
11133 cmdline_fixed_string_t vf;
11134 cmdline_fixed_string_t vlan;
11135 cmdline_fixed_string_t stripq;
11138 cmdline_fixed_string_t on_off;
11141 /* Common CLI fields for vf vlan strip enable disable */
11142 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11143 TOKEN_STRING_INITIALIZER
11144 (struct cmd_vf_vlan_stripq_result,
11146 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11147 TOKEN_STRING_INITIALIZER
11148 (struct cmd_vf_vlan_stripq_result,
11150 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11151 TOKEN_STRING_INITIALIZER
11152 (struct cmd_vf_vlan_stripq_result,
11154 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11155 TOKEN_STRING_INITIALIZER
11156 (struct cmd_vf_vlan_stripq_result,
11158 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11159 TOKEN_NUM_INITIALIZER
11160 (struct cmd_vf_vlan_stripq_result,
11162 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11163 TOKEN_NUM_INITIALIZER
11164 (struct cmd_vf_vlan_stripq_result,
11166 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11167 TOKEN_STRING_INITIALIZER
11168 (struct cmd_vf_vlan_stripq_result,
11172 cmd_set_vf_vlan_stripq_parsed(
11173 void *parsed_result,
11174 __attribute__((unused)) struct cmdline *cl,
11175 __attribute__((unused)) void *data)
11177 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11178 int ret = -ENOTSUP;
11180 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11182 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11185 #ifdef RTE_LIBRTE_IXGBE_PMD
11186 if (ret == -ENOTSUP)
11187 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11188 res->vf_id, is_on);
11190 #ifdef RTE_LIBRTE_I40E_PMD
11191 if (ret == -ENOTSUP)
11192 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11193 res->vf_id, is_on);
11200 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11203 printf("invalid port_id %d\n", res->port_id);
11206 printf("function not implemented\n");
11209 printf("programming error: (%s)\n", strerror(-ret));
11213 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11214 .f = cmd_set_vf_vlan_stripq_parsed,
11216 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11218 (void *)&cmd_vf_vlan_stripq_set,
11219 (void *)&cmd_vf_vlan_stripq_vf,
11220 (void *)&cmd_vf_vlan_stripq_vlan,
11221 (void *)&cmd_vf_vlan_stripq_stripq,
11222 (void *)&cmd_vf_vlan_stripq_port_id,
11223 (void *)&cmd_vf_vlan_stripq_vf_id,
11224 (void *)&cmd_vf_vlan_stripq_on_off,
11229 /* vf vlan insert configuration */
11231 /* Common result structure for vf vlan insert */
11232 struct cmd_vf_vlan_insert_result {
11233 cmdline_fixed_string_t set;
11234 cmdline_fixed_string_t vf;
11235 cmdline_fixed_string_t vlan;
11236 cmdline_fixed_string_t insert;
11242 /* Common CLI fields for vf vlan insert enable disable */
11243 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11244 TOKEN_STRING_INITIALIZER
11245 (struct cmd_vf_vlan_insert_result,
11247 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11248 TOKEN_STRING_INITIALIZER
11249 (struct cmd_vf_vlan_insert_result,
11251 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11252 TOKEN_STRING_INITIALIZER
11253 (struct cmd_vf_vlan_insert_result,
11255 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11256 TOKEN_STRING_INITIALIZER
11257 (struct cmd_vf_vlan_insert_result,
11259 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11260 TOKEN_NUM_INITIALIZER
11261 (struct cmd_vf_vlan_insert_result,
11263 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11264 TOKEN_NUM_INITIALIZER
11265 (struct cmd_vf_vlan_insert_result,
11267 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11268 TOKEN_NUM_INITIALIZER
11269 (struct cmd_vf_vlan_insert_result,
11273 cmd_set_vf_vlan_insert_parsed(
11274 void *parsed_result,
11275 __attribute__((unused)) struct cmdline *cl,
11276 __attribute__((unused)) void *data)
11278 struct cmd_vf_vlan_insert_result *res = parsed_result;
11279 int ret = -ENOTSUP;
11281 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11284 #ifdef RTE_LIBRTE_IXGBE_PMD
11285 if (ret == -ENOTSUP)
11286 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11289 #ifdef RTE_LIBRTE_I40E_PMD
11290 if (ret == -ENOTSUP)
11291 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11299 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11302 printf("invalid port_id %d\n", res->port_id);
11305 printf("function not implemented\n");
11308 printf("programming error: (%s)\n", strerror(-ret));
11312 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11313 .f = cmd_set_vf_vlan_insert_parsed,
11315 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11317 (void *)&cmd_vf_vlan_insert_set,
11318 (void *)&cmd_vf_vlan_insert_vf,
11319 (void *)&cmd_vf_vlan_insert_vlan,
11320 (void *)&cmd_vf_vlan_insert_insert,
11321 (void *)&cmd_vf_vlan_insert_port_id,
11322 (void *)&cmd_vf_vlan_insert_vf_id,
11323 (void *)&cmd_vf_vlan_insert_vlan_id,
11328 /* tx loopback configuration */
11330 /* Common result structure for tx loopback */
11331 struct cmd_tx_loopback_result {
11332 cmdline_fixed_string_t set;
11333 cmdline_fixed_string_t tx;
11334 cmdline_fixed_string_t loopback;
11336 cmdline_fixed_string_t on_off;
11339 /* Common CLI fields for tx loopback enable disable */
11340 cmdline_parse_token_string_t cmd_tx_loopback_set =
11341 TOKEN_STRING_INITIALIZER
11342 (struct cmd_tx_loopback_result,
11344 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11345 TOKEN_STRING_INITIALIZER
11346 (struct cmd_tx_loopback_result,
11348 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11349 TOKEN_STRING_INITIALIZER
11350 (struct cmd_tx_loopback_result,
11351 loopback, "loopback");
11352 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11353 TOKEN_NUM_INITIALIZER
11354 (struct cmd_tx_loopback_result,
11356 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11357 TOKEN_STRING_INITIALIZER
11358 (struct cmd_tx_loopback_result,
11362 cmd_set_tx_loopback_parsed(
11363 void *parsed_result,
11364 __attribute__((unused)) struct cmdline *cl,
11365 __attribute__((unused)) void *data)
11367 struct cmd_tx_loopback_result *res = parsed_result;
11368 int ret = -ENOTSUP;
11370 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11372 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11375 #ifdef RTE_LIBRTE_IXGBE_PMD
11376 if (ret == -ENOTSUP)
11377 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11379 #ifdef RTE_LIBRTE_I40E_PMD
11380 if (ret == -ENOTSUP)
11381 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11388 printf("invalid is_on %d\n", is_on);
11391 printf("invalid port_id %d\n", res->port_id);
11394 printf("function not implemented\n");
11397 printf("programming error: (%s)\n", strerror(-ret));
11401 cmdline_parse_inst_t cmd_set_tx_loopback = {
11402 .f = cmd_set_tx_loopback_parsed,
11404 .help_str = "set tx loopback <port_id> on|off",
11406 (void *)&cmd_tx_loopback_set,
11407 (void *)&cmd_tx_loopback_tx,
11408 (void *)&cmd_tx_loopback_loopback,
11409 (void *)&cmd_tx_loopback_port_id,
11410 (void *)&cmd_tx_loopback_on_off,
11415 #ifdef RTE_LIBRTE_IXGBE_PMD
11416 /* all queues drop enable configuration */
11418 /* Common result structure for all queues drop enable */
11419 struct cmd_all_queues_drop_en_result {
11420 cmdline_fixed_string_t set;
11421 cmdline_fixed_string_t all;
11422 cmdline_fixed_string_t queues;
11423 cmdline_fixed_string_t drop;
11425 cmdline_fixed_string_t on_off;
11428 /* Common CLI fields for tx loopback enable disable */
11429 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11430 TOKEN_STRING_INITIALIZER
11431 (struct cmd_all_queues_drop_en_result,
11433 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11434 TOKEN_STRING_INITIALIZER
11435 (struct cmd_all_queues_drop_en_result,
11437 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11438 TOKEN_STRING_INITIALIZER
11439 (struct cmd_all_queues_drop_en_result,
11441 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11442 TOKEN_STRING_INITIALIZER
11443 (struct cmd_all_queues_drop_en_result,
11445 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11446 TOKEN_NUM_INITIALIZER
11447 (struct cmd_all_queues_drop_en_result,
11449 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11450 TOKEN_STRING_INITIALIZER
11451 (struct cmd_all_queues_drop_en_result,
11455 cmd_set_all_queues_drop_en_parsed(
11456 void *parsed_result,
11457 __attribute__((unused)) struct cmdline *cl,
11458 __attribute__((unused)) void *data)
11460 struct cmd_all_queues_drop_en_result *res = parsed_result;
11462 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11464 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11467 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11472 printf("invalid is_on %d\n", is_on);
11475 printf("invalid port_id %d\n", res->port_id);
11478 printf("function not implemented\n");
11481 printf("programming error: (%s)\n", strerror(-ret));
11485 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11486 .f = cmd_set_all_queues_drop_en_parsed,
11488 .help_str = "set all queues drop <port_id> on|off",
11490 (void *)&cmd_all_queues_drop_en_set,
11491 (void *)&cmd_all_queues_drop_en_all,
11492 (void *)&cmd_all_queues_drop_en_queues,
11493 (void *)&cmd_all_queues_drop_en_drop,
11494 (void *)&cmd_all_queues_drop_en_port_id,
11495 (void *)&cmd_all_queues_drop_en_on_off,
11500 /* vf split drop enable configuration */
11502 /* Common result structure for vf split drop enable */
11503 struct cmd_vf_split_drop_en_result {
11504 cmdline_fixed_string_t set;
11505 cmdline_fixed_string_t vf;
11506 cmdline_fixed_string_t split;
11507 cmdline_fixed_string_t drop;
11510 cmdline_fixed_string_t on_off;
11513 /* Common CLI fields for vf split drop enable disable */
11514 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11515 TOKEN_STRING_INITIALIZER
11516 (struct cmd_vf_split_drop_en_result,
11518 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11519 TOKEN_STRING_INITIALIZER
11520 (struct cmd_vf_split_drop_en_result,
11522 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11523 TOKEN_STRING_INITIALIZER
11524 (struct cmd_vf_split_drop_en_result,
11526 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11527 TOKEN_STRING_INITIALIZER
11528 (struct cmd_vf_split_drop_en_result,
11530 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11531 TOKEN_NUM_INITIALIZER
11532 (struct cmd_vf_split_drop_en_result,
11534 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11535 TOKEN_NUM_INITIALIZER
11536 (struct cmd_vf_split_drop_en_result,
11538 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11539 TOKEN_STRING_INITIALIZER
11540 (struct cmd_vf_split_drop_en_result,
11544 cmd_set_vf_split_drop_en_parsed(
11545 void *parsed_result,
11546 __attribute__((unused)) struct cmdline *cl,
11547 __attribute__((unused)) void *data)
11549 struct cmd_vf_split_drop_en_result *res = parsed_result;
11551 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11553 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11556 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11562 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11565 printf("invalid port_id %d\n", res->port_id);
11568 printf("programming error: (%s)\n", strerror(-ret));
11572 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11573 .f = cmd_set_vf_split_drop_en_parsed,
11575 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11577 (void *)&cmd_vf_split_drop_en_set,
11578 (void *)&cmd_vf_split_drop_en_vf,
11579 (void *)&cmd_vf_split_drop_en_split,
11580 (void *)&cmd_vf_split_drop_en_drop,
11581 (void *)&cmd_vf_split_drop_en_port_id,
11582 (void *)&cmd_vf_split_drop_en_vf_id,
11583 (void *)&cmd_vf_split_drop_en_on_off,
11589 /* vf mac address configuration */
11591 /* Common result structure for vf mac address */
11592 struct cmd_set_vf_mac_addr_result {
11593 cmdline_fixed_string_t set;
11594 cmdline_fixed_string_t vf;
11595 cmdline_fixed_string_t mac;
11596 cmdline_fixed_string_t addr;
11599 struct ether_addr mac_addr;
11603 /* Common CLI fields for vf split drop enable disable */
11604 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11605 TOKEN_STRING_INITIALIZER
11606 (struct cmd_set_vf_mac_addr_result,
11608 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11609 TOKEN_STRING_INITIALIZER
11610 (struct cmd_set_vf_mac_addr_result,
11612 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11613 TOKEN_STRING_INITIALIZER
11614 (struct cmd_set_vf_mac_addr_result,
11616 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11617 TOKEN_STRING_INITIALIZER
11618 (struct cmd_set_vf_mac_addr_result,
11620 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11621 TOKEN_NUM_INITIALIZER
11622 (struct cmd_set_vf_mac_addr_result,
11624 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11625 TOKEN_NUM_INITIALIZER
11626 (struct cmd_set_vf_mac_addr_result,
11628 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11629 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11633 cmd_set_vf_mac_addr_parsed(
11634 void *parsed_result,
11635 __attribute__((unused)) struct cmdline *cl,
11636 __attribute__((unused)) void *data)
11638 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11639 int ret = -ENOTSUP;
11641 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11644 #ifdef RTE_LIBRTE_IXGBE_PMD
11645 if (ret == -ENOTSUP)
11646 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11649 #ifdef RTE_LIBRTE_I40E_PMD
11650 if (ret == -ENOTSUP)
11651 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11659 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11662 printf("invalid port_id %d\n", res->port_id);
11665 printf("function not implemented\n");
11668 printf("programming error: (%s)\n", strerror(-ret));
11672 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11673 .f = cmd_set_vf_mac_addr_parsed,
11675 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11677 (void *)&cmd_set_vf_mac_addr_set,
11678 (void *)&cmd_set_vf_mac_addr_vf,
11679 (void *)&cmd_set_vf_mac_addr_mac,
11680 (void *)&cmd_set_vf_mac_addr_addr,
11681 (void *)&cmd_set_vf_mac_addr_port_id,
11682 (void *)&cmd_set_vf_mac_addr_vf_id,
11683 (void *)&cmd_set_vf_mac_addr_mac_addr,
11688 #ifdef RTE_LIBRTE_IXGBE_PMD
11689 /* MACsec configuration */
11691 /* Common result structure for MACsec offload enable */
11692 struct cmd_macsec_offload_on_result {
11693 cmdline_fixed_string_t set;
11694 cmdline_fixed_string_t macsec;
11695 cmdline_fixed_string_t offload;
11697 cmdline_fixed_string_t on;
11698 cmdline_fixed_string_t encrypt;
11699 cmdline_fixed_string_t en_on_off;
11700 cmdline_fixed_string_t replay_protect;
11701 cmdline_fixed_string_t rp_on_off;
11704 /* Common CLI fields for MACsec offload disable */
11705 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11706 TOKEN_STRING_INITIALIZER
11707 (struct cmd_macsec_offload_on_result,
11709 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11710 TOKEN_STRING_INITIALIZER
11711 (struct cmd_macsec_offload_on_result,
11713 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11714 TOKEN_STRING_INITIALIZER
11715 (struct cmd_macsec_offload_on_result,
11716 offload, "offload");
11717 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11718 TOKEN_NUM_INITIALIZER
11719 (struct cmd_macsec_offload_on_result,
11721 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11722 TOKEN_STRING_INITIALIZER
11723 (struct cmd_macsec_offload_on_result,
11725 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11726 TOKEN_STRING_INITIALIZER
11727 (struct cmd_macsec_offload_on_result,
11728 encrypt, "encrypt");
11729 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11730 TOKEN_STRING_INITIALIZER
11731 (struct cmd_macsec_offload_on_result,
11732 en_on_off, "on#off");
11733 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11734 TOKEN_STRING_INITIALIZER
11735 (struct cmd_macsec_offload_on_result,
11736 replay_protect, "replay-protect");
11737 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11738 TOKEN_STRING_INITIALIZER
11739 (struct cmd_macsec_offload_on_result,
11740 rp_on_off, "on#off");
11743 cmd_set_macsec_offload_on_parsed(
11744 void *parsed_result,
11745 __attribute__((unused)) struct cmdline *cl,
11746 __attribute__((unused)) void *data)
11748 struct cmd_macsec_offload_on_result *res = parsed_result;
11750 portid_t port_id = res->port_id;
11751 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11752 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11754 if (port_id_is_invalid(port_id, ENABLED_WARN))
11757 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11758 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11764 printf("invalid port_id %d\n", port_id);
11767 printf("programming error: (%s)\n", strerror(-ret));
11771 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11772 .f = cmd_set_macsec_offload_on_parsed,
11774 .help_str = "set macsec offload <port_id> on "
11775 "encrypt on|off replay-protect on|off",
11777 (void *)&cmd_macsec_offload_on_set,
11778 (void *)&cmd_macsec_offload_on_macsec,
11779 (void *)&cmd_macsec_offload_on_offload,
11780 (void *)&cmd_macsec_offload_on_port_id,
11781 (void *)&cmd_macsec_offload_on_on,
11782 (void *)&cmd_macsec_offload_on_encrypt,
11783 (void *)&cmd_macsec_offload_on_en_on_off,
11784 (void *)&cmd_macsec_offload_on_replay_protect,
11785 (void *)&cmd_macsec_offload_on_rp_on_off,
11790 /* Common result structure for MACsec offload disable */
11791 struct cmd_macsec_offload_off_result {
11792 cmdline_fixed_string_t set;
11793 cmdline_fixed_string_t macsec;
11794 cmdline_fixed_string_t offload;
11796 cmdline_fixed_string_t off;
11799 /* Common CLI fields for MACsec offload disable */
11800 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11801 TOKEN_STRING_INITIALIZER
11802 (struct cmd_macsec_offload_off_result,
11804 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11805 TOKEN_STRING_INITIALIZER
11806 (struct cmd_macsec_offload_off_result,
11808 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11809 TOKEN_STRING_INITIALIZER
11810 (struct cmd_macsec_offload_off_result,
11811 offload, "offload");
11812 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11813 TOKEN_NUM_INITIALIZER
11814 (struct cmd_macsec_offload_off_result,
11816 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11817 TOKEN_STRING_INITIALIZER
11818 (struct cmd_macsec_offload_off_result,
11822 cmd_set_macsec_offload_off_parsed(
11823 void *parsed_result,
11824 __attribute__((unused)) struct cmdline *cl,
11825 __attribute__((unused)) void *data)
11827 struct cmd_macsec_offload_off_result *res = parsed_result;
11829 portid_t port_id = res->port_id;
11831 if (port_id_is_invalid(port_id, ENABLED_WARN))
11834 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11835 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11841 printf("invalid port_id %d\n", port_id);
11844 printf("programming error: (%s)\n", strerror(-ret));
11848 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11849 .f = cmd_set_macsec_offload_off_parsed,
11851 .help_str = "set macsec offload <port_id> off",
11853 (void *)&cmd_macsec_offload_off_set,
11854 (void *)&cmd_macsec_offload_off_macsec,
11855 (void *)&cmd_macsec_offload_off_offload,
11856 (void *)&cmd_macsec_offload_off_port_id,
11857 (void *)&cmd_macsec_offload_off_off,
11862 /* Common result structure for MACsec secure connection configure */
11863 struct cmd_macsec_sc_result {
11864 cmdline_fixed_string_t set;
11865 cmdline_fixed_string_t macsec;
11866 cmdline_fixed_string_t sc;
11867 cmdline_fixed_string_t tx_rx;
11869 struct ether_addr mac;
11873 /* Common CLI fields for MACsec secure connection configure */
11874 cmdline_parse_token_string_t cmd_macsec_sc_set =
11875 TOKEN_STRING_INITIALIZER
11876 (struct cmd_macsec_sc_result,
11878 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11879 TOKEN_STRING_INITIALIZER
11880 (struct cmd_macsec_sc_result,
11882 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11883 TOKEN_STRING_INITIALIZER
11884 (struct cmd_macsec_sc_result,
11886 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11887 TOKEN_STRING_INITIALIZER
11888 (struct cmd_macsec_sc_result,
11890 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11891 TOKEN_NUM_INITIALIZER
11892 (struct cmd_macsec_sc_result,
11894 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11895 TOKEN_ETHERADDR_INITIALIZER
11896 (struct cmd_macsec_sc_result,
11898 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11899 TOKEN_NUM_INITIALIZER
11900 (struct cmd_macsec_sc_result,
11904 cmd_set_macsec_sc_parsed(
11905 void *parsed_result,
11906 __attribute__((unused)) struct cmdline *cl,
11907 __attribute__((unused)) void *data)
11909 struct cmd_macsec_sc_result *res = parsed_result;
11911 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11914 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11915 res->mac.addr_bytes) :
11916 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11917 res->mac.addr_bytes, res->pi);
11922 printf("invalid port_id %d\n", res->port_id);
11925 printf("programming error: (%s)\n", strerror(-ret));
11929 cmdline_parse_inst_t cmd_set_macsec_sc = {
11930 .f = cmd_set_macsec_sc_parsed,
11932 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11934 (void *)&cmd_macsec_sc_set,
11935 (void *)&cmd_macsec_sc_macsec,
11936 (void *)&cmd_macsec_sc_sc,
11937 (void *)&cmd_macsec_sc_tx_rx,
11938 (void *)&cmd_macsec_sc_port_id,
11939 (void *)&cmd_macsec_sc_mac,
11940 (void *)&cmd_macsec_sc_pi,
11945 /* Common result structure for MACsec secure connection configure */
11946 struct cmd_macsec_sa_result {
11947 cmdline_fixed_string_t set;
11948 cmdline_fixed_string_t macsec;
11949 cmdline_fixed_string_t sa;
11950 cmdline_fixed_string_t tx_rx;
11955 cmdline_fixed_string_t key;
11958 /* Common CLI fields for MACsec secure connection configure */
11959 cmdline_parse_token_string_t cmd_macsec_sa_set =
11960 TOKEN_STRING_INITIALIZER
11961 (struct cmd_macsec_sa_result,
11963 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11964 TOKEN_STRING_INITIALIZER
11965 (struct cmd_macsec_sa_result,
11967 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11968 TOKEN_STRING_INITIALIZER
11969 (struct cmd_macsec_sa_result,
11971 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11972 TOKEN_STRING_INITIALIZER
11973 (struct cmd_macsec_sa_result,
11975 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11976 TOKEN_NUM_INITIALIZER
11977 (struct cmd_macsec_sa_result,
11979 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11980 TOKEN_NUM_INITIALIZER
11981 (struct cmd_macsec_sa_result,
11983 cmdline_parse_token_num_t cmd_macsec_sa_an =
11984 TOKEN_NUM_INITIALIZER
11985 (struct cmd_macsec_sa_result,
11987 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11988 TOKEN_NUM_INITIALIZER
11989 (struct cmd_macsec_sa_result,
11991 cmdline_parse_token_string_t cmd_macsec_sa_key =
11992 TOKEN_STRING_INITIALIZER
11993 (struct cmd_macsec_sa_result,
11997 cmd_set_macsec_sa_parsed(
11998 void *parsed_result,
11999 __attribute__((unused)) struct cmdline *cl,
12000 __attribute__((unused)) void *data)
12002 struct cmd_macsec_sa_result *res = parsed_result;
12004 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12005 uint8_t key[16] = { 0 };
12011 key_len = strlen(res->key) / 2;
12015 for (i = 0; i < key_len; i++) {
12016 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12019 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12022 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12026 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12027 res->idx, res->an, res->pn, key) :
12028 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12029 res->idx, res->an, res->pn, key);
12034 printf("invalid idx %d or an %d\n", res->idx, res->an);
12037 printf("invalid port_id %d\n", res->port_id);
12040 printf("programming error: (%s)\n", strerror(-ret));
12044 cmdline_parse_inst_t cmd_set_macsec_sa = {
12045 .f = cmd_set_macsec_sa_parsed,
12047 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12049 (void *)&cmd_macsec_sa_set,
12050 (void *)&cmd_macsec_sa_macsec,
12051 (void *)&cmd_macsec_sa_sa,
12052 (void *)&cmd_macsec_sa_tx_rx,
12053 (void *)&cmd_macsec_sa_port_id,
12054 (void *)&cmd_macsec_sa_idx,
12055 (void *)&cmd_macsec_sa_an,
12056 (void *)&cmd_macsec_sa_pn,
12057 (void *)&cmd_macsec_sa_key,
12063 /* VF unicast promiscuous mode configuration */
12065 /* Common result structure for VF unicast promiscuous mode */
12066 struct cmd_vf_promisc_result {
12067 cmdline_fixed_string_t set;
12068 cmdline_fixed_string_t vf;
12069 cmdline_fixed_string_t promisc;
12072 cmdline_fixed_string_t on_off;
12075 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12076 cmdline_parse_token_string_t cmd_vf_promisc_set =
12077 TOKEN_STRING_INITIALIZER
12078 (struct cmd_vf_promisc_result,
12080 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12081 TOKEN_STRING_INITIALIZER
12082 (struct cmd_vf_promisc_result,
12084 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12085 TOKEN_STRING_INITIALIZER
12086 (struct cmd_vf_promisc_result,
12087 promisc, "promisc");
12088 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12089 TOKEN_NUM_INITIALIZER
12090 (struct cmd_vf_promisc_result,
12092 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12093 TOKEN_NUM_INITIALIZER
12094 (struct cmd_vf_promisc_result,
12096 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12097 TOKEN_STRING_INITIALIZER
12098 (struct cmd_vf_promisc_result,
12102 cmd_set_vf_promisc_parsed(
12103 void *parsed_result,
12104 __attribute__((unused)) struct cmdline *cl,
12105 __attribute__((unused)) void *data)
12107 struct cmd_vf_promisc_result *res = parsed_result;
12108 int ret = -ENOTSUP;
12110 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12112 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12115 #ifdef RTE_LIBRTE_I40E_PMD
12116 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12117 res->vf_id, is_on);
12124 printf("invalid vf_id %d\n", res->vf_id);
12127 printf("invalid port_id %d\n", res->port_id);
12130 printf("function not implemented\n");
12133 printf("programming error: (%s)\n", strerror(-ret));
12137 cmdline_parse_inst_t cmd_set_vf_promisc = {
12138 .f = cmd_set_vf_promisc_parsed,
12140 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12141 "Set unicast promiscuous mode for a VF from the PF",
12143 (void *)&cmd_vf_promisc_set,
12144 (void *)&cmd_vf_promisc_vf,
12145 (void *)&cmd_vf_promisc_promisc,
12146 (void *)&cmd_vf_promisc_port_id,
12147 (void *)&cmd_vf_promisc_vf_id,
12148 (void *)&cmd_vf_promisc_on_off,
12153 /* VF multicast promiscuous mode configuration */
12155 /* Common result structure for VF multicast promiscuous mode */
12156 struct cmd_vf_allmulti_result {
12157 cmdline_fixed_string_t set;
12158 cmdline_fixed_string_t vf;
12159 cmdline_fixed_string_t allmulti;
12162 cmdline_fixed_string_t on_off;
12165 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12166 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12167 TOKEN_STRING_INITIALIZER
12168 (struct cmd_vf_allmulti_result,
12170 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12171 TOKEN_STRING_INITIALIZER
12172 (struct cmd_vf_allmulti_result,
12174 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12175 TOKEN_STRING_INITIALIZER
12176 (struct cmd_vf_allmulti_result,
12177 allmulti, "allmulti");
12178 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12179 TOKEN_NUM_INITIALIZER
12180 (struct cmd_vf_allmulti_result,
12182 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12183 TOKEN_NUM_INITIALIZER
12184 (struct cmd_vf_allmulti_result,
12186 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12187 TOKEN_STRING_INITIALIZER
12188 (struct cmd_vf_allmulti_result,
12192 cmd_set_vf_allmulti_parsed(
12193 void *parsed_result,
12194 __attribute__((unused)) struct cmdline *cl,
12195 __attribute__((unused)) void *data)
12197 struct cmd_vf_allmulti_result *res = parsed_result;
12198 int ret = -ENOTSUP;
12200 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12202 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12205 #ifdef RTE_LIBRTE_I40E_PMD
12206 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12207 res->vf_id, is_on);
12214 printf("invalid vf_id %d\n", res->vf_id);
12217 printf("invalid port_id %d\n", res->port_id);
12220 printf("function not implemented\n");
12223 printf("programming error: (%s)\n", strerror(-ret));
12227 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12228 .f = cmd_set_vf_allmulti_parsed,
12230 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12231 "Set multicast promiscuous mode for a VF from the PF",
12233 (void *)&cmd_vf_allmulti_set,
12234 (void *)&cmd_vf_allmulti_vf,
12235 (void *)&cmd_vf_allmulti_allmulti,
12236 (void *)&cmd_vf_allmulti_port_id,
12237 (void *)&cmd_vf_allmulti_vf_id,
12238 (void *)&cmd_vf_allmulti_on_off,
12243 /* vf broadcast mode configuration */
12245 /* Common result structure for vf broadcast */
12246 struct cmd_set_vf_broadcast_result {
12247 cmdline_fixed_string_t set;
12248 cmdline_fixed_string_t vf;
12249 cmdline_fixed_string_t broadcast;
12252 cmdline_fixed_string_t on_off;
12255 /* Common CLI fields for vf broadcast enable disable */
12256 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12257 TOKEN_STRING_INITIALIZER
12258 (struct cmd_set_vf_broadcast_result,
12260 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12261 TOKEN_STRING_INITIALIZER
12262 (struct cmd_set_vf_broadcast_result,
12264 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12265 TOKEN_STRING_INITIALIZER
12266 (struct cmd_set_vf_broadcast_result,
12267 broadcast, "broadcast");
12268 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12269 TOKEN_NUM_INITIALIZER
12270 (struct cmd_set_vf_broadcast_result,
12272 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12273 TOKEN_NUM_INITIALIZER
12274 (struct cmd_set_vf_broadcast_result,
12276 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12277 TOKEN_STRING_INITIALIZER
12278 (struct cmd_set_vf_broadcast_result,
12282 cmd_set_vf_broadcast_parsed(
12283 void *parsed_result,
12284 __attribute__((unused)) struct cmdline *cl,
12285 __attribute__((unused)) void *data)
12287 struct cmd_set_vf_broadcast_result *res = parsed_result;
12288 int ret = -ENOTSUP;
12290 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12292 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12295 #ifdef RTE_LIBRTE_I40E_PMD
12296 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12297 res->vf_id, is_on);
12304 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12307 printf("invalid port_id %d\n", res->port_id);
12310 printf("function not implemented\n");
12313 printf("programming error: (%s)\n", strerror(-ret));
12317 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12318 .f = cmd_set_vf_broadcast_parsed,
12320 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12322 (void *)&cmd_set_vf_broadcast_set,
12323 (void *)&cmd_set_vf_broadcast_vf,
12324 (void *)&cmd_set_vf_broadcast_broadcast,
12325 (void *)&cmd_set_vf_broadcast_port_id,
12326 (void *)&cmd_set_vf_broadcast_vf_id,
12327 (void *)&cmd_set_vf_broadcast_on_off,
12332 /* vf vlan tag configuration */
12334 /* Common result structure for vf vlan tag */
12335 struct cmd_set_vf_vlan_tag_result {
12336 cmdline_fixed_string_t set;
12337 cmdline_fixed_string_t vf;
12338 cmdline_fixed_string_t vlan;
12339 cmdline_fixed_string_t tag;
12342 cmdline_fixed_string_t on_off;
12345 /* Common CLI fields for vf vlan tag enable disable */
12346 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12347 TOKEN_STRING_INITIALIZER
12348 (struct cmd_set_vf_vlan_tag_result,
12350 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12351 TOKEN_STRING_INITIALIZER
12352 (struct cmd_set_vf_vlan_tag_result,
12354 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12355 TOKEN_STRING_INITIALIZER
12356 (struct cmd_set_vf_vlan_tag_result,
12358 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12359 TOKEN_STRING_INITIALIZER
12360 (struct cmd_set_vf_vlan_tag_result,
12362 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12363 TOKEN_NUM_INITIALIZER
12364 (struct cmd_set_vf_vlan_tag_result,
12366 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12367 TOKEN_NUM_INITIALIZER
12368 (struct cmd_set_vf_vlan_tag_result,
12370 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12371 TOKEN_STRING_INITIALIZER
12372 (struct cmd_set_vf_vlan_tag_result,
12376 cmd_set_vf_vlan_tag_parsed(
12377 void *parsed_result,
12378 __attribute__((unused)) struct cmdline *cl,
12379 __attribute__((unused)) void *data)
12381 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12382 int ret = -ENOTSUP;
12384 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12386 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12389 #ifdef RTE_LIBRTE_I40E_PMD
12390 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12391 res->vf_id, is_on);
12398 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12401 printf("invalid port_id %d\n", res->port_id);
12404 printf("function not implemented\n");
12407 printf("programming error: (%s)\n", strerror(-ret));
12411 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12412 .f = cmd_set_vf_vlan_tag_parsed,
12414 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12416 (void *)&cmd_set_vf_vlan_tag_set,
12417 (void *)&cmd_set_vf_vlan_tag_vf,
12418 (void *)&cmd_set_vf_vlan_tag_vlan,
12419 (void *)&cmd_set_vf_vlan_tag_tag,
12420 (void *)&cmd_set_vf_vlan_tag_port_id,
12421 (void *)&cmd_set_vf_vlan_tag_vf_id,
12422 (void *)&cmd_set_vf_vlan_tag_on_off,
12427 /* Common definition of VF and TC TX bandwidth configuration */
12428 struct cmd_vf_tc_bw_result {
12429 cmdline_fixed_string_t set;
12430 cmdline_fixed_string_t vf;
12431 cmdline_fixed_string_t tc;
12432 cmdline_fixed_string_t tx;
12433 cmdline_fixed_string_t min_bw;
12434 cmdline_fixed_string_t max_bw;
12435 cmdline_fixed_string_t strict_link_prio;
12440 cmdline_fixed_string_t bw_list;
12444 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12445 TOKEN_STRING_INITIALIZER
12446 (struct cmd_vf_tc_bw_result,
12448 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12449 TOKEN_STRING_INITIALIZER
12450 (struct cmd_vf_tc_bw_result,
12452 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12453 TOKEN_STRING_INITIALIZER
12454 (struct cmd_vf_tc_bw_result,
12456 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12457 TOKEN_STRING_INITIALIZER
12458 (struct cmd_vf_tc_bw_result,
12460 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12461 TOKEN_STRING_INITIALIZER
12462 (struct cmd_vf_tc_bw_result,
12463 strict_link_prio, "strict-link-priority");
12464 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12465 TOKEN_STRING_INITIALIZER
12466 (struct cmd_vf_tc_bw_result,
12467 min_bw, "min-bandwidth");
12468 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12469 TOKEN_STRING_INITIALIZER
12470 (struct cmd_vf_tc_bw_result,
12471 max_bw, "max-bandwidth");
12472 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12473 TOKEN_NUM_INITIALIZER
12474 (struct cmd_vf_tc_bw_result,
12476 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12477 TOKEN_NUM_INITIALIZER
12478 (struct cmd_vf_tc_bw_result,
12480 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12481 TOKEN_NUM_INITIALIZER
12482 (struct cmd_vf_tc_bw_result,
12484 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12485 TOKEN_NUM_INITIALIZER
12486 (struct cmd_vf_tc_bw_result,
12488 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12489 TOKEN_STRING_INITIALIZER
12490 (struct cmd_vf_tc_bw_result,
12492 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12493 TOKEN_NUM_INITIALIZER
12494 (struct cmd_vf_tc_bw_result,
12497 /* VF max bandwidth setting */
12499 cmd_vf_max_bw_parsed(
12500 void *parsed_result,
12501 __attribute__((unused)) struct cmdline *cl,
12502 __attribute__((unused)) void *data)
12504 struct cmd_vf_tc_bw_result *res = parsed_result;
12505 int ret = -ENOTSUP;
12507 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12510 #ifdef RTE_LIBRTE_I40E_PMD
12511 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12512 res->vf_id, res->bw);
12519 printf("invalid vf_id %d or bandwidth %d\n",
12520 res->vf_id, res->bw);
12523 printf("invalid port_id %d\n", res->port_id);
12526 printf("function not implemented\n");
12529 printf("programming error: (%s)\n", strerror(-ret));
12533 cmdline_parse_inst_t cmd_vf_max_bw = {
12534 .f = cmd_vf_max_bw_parsed,
12536 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12538 (void *)&cmd_vf_tc_bw_set,
12539 (void *)&cmd_vf_tc_bw_vf,
12540 (void *)&cmd_vf_tc_bw_tx,
12541 (void *)&cmd_vf_tc_bw_max_bw,
12542 (void *)&cmd_vf_tc_bw_port_id,
12543 (void *)&cmd_vf_tc_bw_vf_id,
12544 (void *)&cmd_vf_tc_bw_bw,
12550 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12555 const char *p, *p0 = str;
12562 p = strchr(p0, '(');
12564 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12568 p0 = strchr(p, ')');
12570 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12574 if (size >= sizeof(s)) {
12575 printf("The string size exceeds the internal buffer size\n");
12578 snprintf(s, sizeof(s), "%.*s", size, p);
12579 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12581 printf("Failed to get the bandwidth list. ");
12585 for (i = 0; i < ret; i++)
12586 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12591 /* TC min bandwidth setting */
12593 cmd_vf_tc_min_bw_parsed(
12594 void *parsed_result,
12595 __attribute__((unused)) struct cmdline *cl,
12596 __attribute__((unused)) void *data)
12598 struct cmd_vf_tc_bw_result *res = parsed_result;
12601 int ret = -ENOTSUP;
12603 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12606 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12610 #ifdef RTE_LIBRTE_I40E_PMD
12611 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12619 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12622 printf("invalid port_id %d\n", res->port_id);
12625 printf("function not implemented\n");
12628 printf("programming error: (%s)\n", strerror(-ret));
12632 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12633 .f = cmd_vf_tc_min_bw_parsed,
12635 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12636 " <bw1, bw2, ...>",
12638 (void *)&cmd_vf_tc_bw_set,
12639 (void *)&cmd_vf_tc_bw_vf,
12640 (void *)&cmd_vf_tc_bw_tc,
12641 (void *)&cmd_vf_tc_bw_tx,
12642 (void *)&cmd_vf_tc_bw_min_bw,
12643 (void *)&cmd_vf_tc_bw_port_id,
12644 (void *)&cmd_vf_tc_bw_vf_id,
12645 (void *)&cmd_vf_tc_bw_bw_list,
12651 cmd_tc_min_bw_parsed(
12652 void *parsed_result,
12653 __attribute__((unused)) struct cmdline *cl,
12654 __attribute__((unused)) void *data)
12656 struct cmd_vf_tc_bw_result *res = parsed_result;
12657 struct rte_port *port;
12660 int ret = -ENOTSUP;
12662 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12665 port = &ports[res->port_id];
12666 /** Check if the port is not started **/
12667 if (port->port_status != RTE_PORT_STOPPED) {
12668 printf("Please stop port %d first\n", res->port_id);
12672 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12676 #ifdef RTE_LIBRTE_IXGBE_PMD
12677 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12684 printf("invalid bandwidth\n");
12687 printf("invalid port_id %d\n", res->port_id);
12690 printf("function not implemented\n");
12693 printf("programming error: (%s)\n", strerror(-ret));
12697 cmdline_parse_inst_t cmd_tc_min_bw = {
12698 .f = cmd_tc_min_bw_parsed,
12700 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12702 (void *)&cmd_vf_tc_bw_set,
12703 (void *)&cmd_vf_tc_bw_tc,
12704 (void *)&cmd_vf_tc_bw_tx,
12705 (void *)&cmd_vf_tc_bw_min_bw,
12706 (void *)&cmd_vf_tc_bw_port_id,
12707 (void *)&cmd_vf_tc_bw_bw_list,
12712 /* TC max bandwidth setting */
12714 cmd_vf_tc_max_bw_parsed(
12715 void *parsed_result,
12716 __attribute__((unused)) struct cmdline *cl,
12717 __attribute__((unused)) void *data)
12719 struct cmd_vf_tc_bw_result *res = parsed_result;
12720 int ret = -ENOTSUP;
12722 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12725 #ifdef RTE_LIBRTE_I40E_PMD
12726 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12727 res->tc_no, res->bw);
12734 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12735 res->vf_id, res->tc_no, res->bw);
12738 printf("invalid port_id %d\n", res->port_id);
12741 printf("function not implemented\n");
12744 printf("programming error: (%s)\n", strerror(-ret));
12748 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12749 .f = cmd_vf_tc_max_bw_parsed,
12751 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12754 (void *)&cmd_vf_tc_bw_set,
12755 (void *)&cmd_vf_tc_bw_vf,
12756 (void *)&cmd_vf_tc_bw_tc,
12757 (void *)&cmd_vf_tc_bw_tx,
12758 (void *)&cmd_vf_tc_bw_max_bw,
12759 (void *)&cmd_vf_tc_bw_port_id,
12760 (void *)&cmd_vf_tc_bw_vf_id,
12761 (void *)&cmd_vf_tc_bw_tc_no,
12762 (void *)&cmd_vf_tc_bw_bw,
12767 /* Strict link priority scheduling mode setting */
12769 cmd_strict_link_prio_parsed(
12770 void *parsed_result,
12771 __attribute__((unused)) struct cmdline *cl,
12772 __attribute__((unused)) void *data)
12774 struct cmd_vf_tc_bw_result *res = parsed_result;
12775 int ret = -ENOTSUP;
12777 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12780 #ifdef RTE_LIBRTE_I40E_PMD
12781 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
12788 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
12791 printf("invalid port_id %d\n", res->port_id);
12794 printf("function not implemented\n");
12797 printf("programming error: (%s)\n", strerror(-ret));
12801 cmdline_parse_inst_t cmd_strict_link_prio = {
12802 .f = cmd_strict_link_prio_parsed,
12804 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
12806 (void *)&cmd_vf_tc_bw_set,
12807 (void *)&cmd_vf_tc_bw_tx,
12808 (void *)&cmd_vf_tc_bw_strict_link_prio,
12809 (void *)&cmd_vf_tc_bw_port_id,
12810 (void *)&cmd_vf_tc_bw_tc_map,
12815 /* Load dynamic device personalization*/
12816 struct cmd_ddp_add_result {
12817 cmdline_fixed_string_t ddp;
12818 cmdline_fixed_string_t add;
12823 cmdline_parse_token_string_t cmd_ddp_add_ddp =
12824 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
12825 cmdline_parse_token_string_t cmd_ddp_add_add =
12826 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
12827 cmdline_parse_token_num_t cmd_ddp_add_port_id =
12828 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
12829 cmdline_parse_token_string_t cmd_ddp_add_filepath =
12830 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
12833 cmd_ddp_add_parsed(
12834 void *parsed_result,
12835 __attribute__((unused)) struct cmdline *cl,
12836 __attribute__((unused)) void *data)
12838 struct cmd_ddp_add_result *res = parsed_result;
12841 int ret = -ENOTSUP;
12843 if (res->port_id > nb_ports) {
12844 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12848 if (!all_ports_stopped()) {
12849 printf("Please stop all ports first\n");
12853 buff = open_ddp_package_file(res->filepath, &size);
12857 #ifdef RTE_LIBRTE_I40E_PMD
12858 if (ret == -ENOTSUP)
12859 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
12861 RTE_PMD_I40E_PKG_OP_WR_ADD);
12865 printf("Failed to load profile.\n");
12867 printf("Profile has already existed.\n");
12869 close_ddp_package_file(buff);
12872 cmdline_parse_inst_t cmd_ddp_add = {
12873 .f = cmd_ddp_add_parsed,
12875 .help_str = "ddp add <port_id> <profile_path>",
12877 (void *)&cmd_ddp_add_ddp,
12878 (void *)&cmd_ddp_add_add,
12879 (void *)&cmd_ddp_add_port_id,
12880 (void *)&cmd_ddp_add_filepath,
12885 /* Get dynamic device personalization profile info list*/
12886 #define PROFILE_INFO_SIZE 48
12887 #define MAX_PROFILE_NUM 16
12889 struct cmd_ddp_get_list_result {
12890 cmdline_fixed_string_t ddp;
12891 cmdline_fixed_string_t get;
12892 cmdline_fixed_string_t list;
12896 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
12897 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
12898 cmdline_parse_token_string_t cmd_ddp_get_list_get =
12899 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
12900 cmdline_parse_token_string_t cmd_ddp_get_list_list =
12901 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
12902 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
12903 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
12906 cmd_ddp_get_list_parsed(
12907 void *parsed_result,
12908 __attribute__((unused)) struct cmdline *cl,
12909 __attribute__((unused)) void *data)
12911 struct cmd_ddp_get_list_result *res = parsed_result;
12912 #ifdef RTE_LIBRTE_I40E_PMD
12913 struct rte_pmd_i40e_profile_list *p_list;
12914 struct rte_pmd_i40e_profile_info *p_info;
12919 int ret = -ENOTSUP;
12921 if (res->port_id > nb_ports) {
12922 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12926 #ifdef RTE_LIBRTE_I40E_PMD
12927 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
12928 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
12930 printf("%s: Failed to malloc buffer\n", __func__);
12932 if (ret == -ENOTSUP)
12933 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
12934 (uint8_t *)p_list, size);
12937 p_num = p_list->p_count;
12938 printf("Profile number is: %d\n\n", p_num);
12940 for (i = 0; i < p_num; i++) {
12941 p_info = &p_list->p_info[i];
12942 printf("Profile %d:\n", i);
12943 printf("Track id: 0x%x\n", p_info->track_id);
12944 printf("Version: %d.%d.%d.%d\n",
12945 p_info->version.major,
12946 p_info->version.minor,
12947 p_info->version.update,
12948 p_info->version.draft);
12949 printf("Profile name: %s\n\n", p_info->name);
12957 printf("Failed to get ddp list\n");
12960 cmdline_parse_inst_t cmd_ddp_get_list = {
12961 .f = cmd_ddp_get_list_parsed,
12963 .help_str = "ddp get list <port_id>",
12965 (void *)&cmd_ddp_get_list_ddp,
12966 (void *)&cmd_ddp_get_list_get,
12967 (void *)&cmd_ddp_get_list_list,
12968 (void *)&cmd_ddp_get_list_port_id,
12972 /* ******************************************************************************** */
12974 /* list of instructions */
12975 cmdline_parse_ctx_t main_ctx[] = {
12976 (cmdline_parse_inst_t *)&cmd_help_brief,
12977 (cmdline_parse_inst_t *)&cmd_help_long,
12978 (cmdline_parse_inst_t *)&cmd_quit,
12979 (cmdline_parse_inst_t *)&cmd_showport,
12980 (cmdline_parse_inst_t *)&cmd_showqueue,
12981 (cmdline_parse_inst_t *)&cmd_showportall,
12982 (cmdline_parse_inst_t *)&cmd_showcfg,
12983 (cmdline_parse_inst_t *)&cmd_start,
12984 (cmdline_parse_inst_t *)&cmd_start_tx_first,
12985 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
12986 (cmdline_parse_inst_t *)&cmd_set_link_up,
12987 (cmdline_parse_inst_t *)&cmd_set_link_down,
12988 (cmdline_parse_inst_t *)&cmd_reset,
12989 (cmdline_parse_inst_t *)&cmd_set_numbers,
12990 (cmdline_parse_inst_t *)&cmd_set_txpkts,
12991 (cmdline_parse_inst_t *)&cmd_set_txsplit,
12992 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
12993 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
12994 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
12995 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
12996 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
12997 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
12998 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
12999 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
13000 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
13001 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
13002 (cmdline_parse_inst_t *)&cmd_set_link_check,
13003 #ifdef RTE_NIC_BYPASS
13004 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
13005 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
13006 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
13007 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
13009 #ifdef RTE_LIBRTE_PMD_BOND
13010 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
13011 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
13012 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
13013 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
13014 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
13015 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
13016 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
13017 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
13018 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
13020 (cmdline_parse_inst_t *)&cmd_vlan_offload,
13021 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
13022 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
13023 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
13024 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
13025 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
13026 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
13027 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
13028 (cmdline_parse_inst_t *)&cmd_csum_set,
13029 (cmdline_parse_inst_t *)&cmd_csum_show,
13030 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
13031 (cmdline_parse_inst_t *)&cmd_tso_set,
13032 (cmdline_parse_inst_t *)&cmd_tso_show,
13033 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
13034 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
13035 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
13036 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
13037 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
13038 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
13039 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
13040 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
13041 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
13042 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
13043 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
13044 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
13045 (cmdline_parse_inst_t *)&cmd_config_dcb,
13046 (cmdline_parse_inst_t *)&cmd_read_reg,
13047 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
13048 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
13049 (cmdline_parse_inst_t *)&cmd_write_reg,
13050 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
13051 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
13052 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
13053 (cmdline_parse_inst_t *)&cmd_stop,
13054 (cmdline_parse_inst_t *)&cmd_mac_addr,
13055 (cmdline_parse_inst_t *)&cmd_set_qmap,
13056 (cmdline_parse_inst_t *)&cmd_operate_port,
13057 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
13058 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
13059 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
13060 (cmdline_parse_inst_t *)&cmd_config_speed_all,
13061 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
13062 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
13063 (cmdline_parse_inst_t *)&cmd_config_mtu,
13064 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
13065 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
13066 (cmdline_parse_inst_t *)&cmd_config_rss,
13067 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13068 (cmdline_parse_inst_t *)&cmd_config_txqflags,
13069 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
13070 (cmdline_parse_inst_t *)&cmd_showport_reta,
13071 (cmdline_parse_inst_t *)&cmd_config_burst,
13072 (cmdline_parse_inst_t *)&cmd_config_thresh,
13073 (cmdline_parse_inst_t *)&cmd_config_threshold,
13074 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13075 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13076 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13077 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
13078 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13079 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
13080 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13081 (cmdline_parse_inst_t *)&cmd_global_config,
13082 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
13083 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
13084 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
13085 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
13086 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
13087 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
13088 (cmdline_parse_inst_t *)&cmd_dump,
13089 (cmdline_parse_inst_t *)&cmd_dump_one,
13090 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
13091 (cmdline_parse_inst_t *)&cmd_syn_filter,
13092 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
13093 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
13094 (cmdline_parse_inst_t *)&cmd_flex_filter,
13095 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
13096 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
13097 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
13098 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
13099 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
13100 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
13101 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
13102 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
13103 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
13104 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
13105 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
13106 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
13107 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
13108 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
13109 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
13110 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
13111 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
13112 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
13113 (cmdline_parse_inst_t *)&cmd_flow,
13114 (cmdline_parse_inst_t *)&cmd_mcast_addr,
13115 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
13116 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
13117 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
13118 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
13119 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
13120 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
13121 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
13122 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
13123 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
13124 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
13125 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
13126 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
13127 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
13128 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
13129 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
13130 #ifdef RTE_LIBRTE_IXGBE_PMD
13131 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
13132 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
13133 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
13134 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
13135 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
13136 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
13137 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
13138 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
13139 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
13141 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
13142 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
13143 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
13144 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
13145 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
13146 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
13147 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
13148 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
13149 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
13150 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
13151 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
13152 (cmdline_parse_inst_t *)&cmd_ddp_add,
13153 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
13157 /* prompt function, called from main on MASTER lcore */
13161 /* initialize non-constant commands */
13162 cmd_set_fwd_mode_init();
13163 cmd_set_fwd_retry_mode_init();
13165 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
13166 if (testpmd_cl == NULL)
13168 cmdline_interact(testpmd_cl);
13169 cmdline_stdin_exit(testpmd_cl);
13175 if (testpmd_cl != NULL)
13176 cmdline_quit(testpmd_cl);
13180 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
13182 if (id == (portid_t)RTE_PORT_ALL) {
13185 FOREACH_PORT(pid, ports) {
13186 /* check if need_reconfig has been set to 1 */
13187 if (ports[pid].need_reconfig == 0)
13188 ports[pid].need_reconfig = dev;
13189 /* check if need_reconfig_queues has been set to 1 */
13190 if (ports[pid].need_reconfig_queues == 0)
13191 ports[pid].need_reconfig_queues = queue;
13193 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
13194 /* check if need_reconfig has been set to 1 */
13195 if (ports[id].need_reconfig == 0)
13196 ports[id].need_reconfig = dev;
13197 /* check if need_reconfig_queues has been set to 1 */
13198 if (ports[id].need_reconfig_queues == 0)
13199 ports[id].need_reconfig_queues = queue;