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);
7705 else if (!strcmp(res->dump, "dump_log_types"))
7706 rte_log_dump(stdout);
7709 cmdline_parse_token_string_t cmd_dump_dump =
7710 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7713 "dump_struct_sizes#"
7719 cmdline_parse_inst_t cmd_dump = {
7720 .f = cmd_dump_parsed, /* function to call */
7721 .data = NULL, /* 2nd arg of func */
7722 .help_str = "Dump status",
7723 .tokens = { /* token list, NULL terminated */
7724 (void *)&cmd_dump_dump,
7729 /* ******************************************************************************** */
7731 struct cmd_dump_one_result {
7732 cmdline_fixed_string_t dump;
7733 cmdline_fixed_string_t name;
7736 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7737 __attribute__((unused)) void *data)
7739 struct cmd_dump_one_result *res = parsed_result;
7741 if (!strcmp(res->dump, "dump_ring")) {
7743 r = rte_ring_lookup(res->name);
7745 cmdline_printf(cl, "Cannot find ring\n");
7748 rte_ring_dump(stdout, r);
7749 } else if (!strcmp(res->dump, "dump_mempool")) {
7750 struct rte_mempool *mp;
7751 mp = rte_mempool_lookup(res->name);
7753 cmdline_printf(cl, "Cannot find mempool\n");
7756 rte_mempool_dump(stdout, mp);
7760 cmdline_parse_token_string_t cmd_dump_one_dump =
7761 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7762 "dump_ring#dump_mempool");
7764 cmdline_parse_token_string_t cmd_dump_one_name =
7765 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7767 cmdline_parse_inst_t cmd_dump_one = {
7768 .f = cmd_dump_one_parsed, /* function to call */
7769 .data = NULL, /* 2nd arg of func */
7770 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7771 .tokens = { /* token list, NULL terminated */
7772 (void *)&cmd_dump_one_dump,
7773 (void *)&cmd_dump_one_name,
7778 /* *** Add/Del syn filter *** */
7779 struct cmd_syn_filter_result {
7780 cmdline_fixed_string_t filter;
7782 cmdline_fixed_string_t ops;
7783 cmdline_fixed_string_t priority;
7784 cmdline_fixed_string_t high;
7785 cmdline_fixed_string_t queue;
7790 cmd_syn_filter_parsed(void *parsed_result,
7791 __attribute__((unused)) struct cmdline *cl,
7792 __attribute__((unused)) void *data)
7794 struct cmd_syn_filter_result *res = parsed_result;
7795 struct rte_eth_syn_filter syn_filter;
7798 ret = rte_eth_dev_filter_supported(res->port_id,
7799 RTE_ETH_FILTER_SYN);
7801 printf("syn filter is not supported on port %u.\n",
7806 memset(&syn_filter, 0, sizeof(syn_filter));
7808 if (!strcmp(res->ops, "add")) {
7809 if (!strcmp(res->high, "high"))
7810 syn_filter.hig_pri = 1;
7812 syn_filter.hig_pri = 0;
7814 syn_filter.queue = res->queue_id;
7815 ret = rte_eth_dev_filter_ctrl(res->port_id,
7820 ret = rte_eth_dev_filter_ctrl(res->port_id,
7822 RTE_ETH_FILTER_DELETE,
7826 printf("syn filter programming error: (%s)\n",
7830 cmdline_parse_token_string_t cmd_syn_filter_filter =
7831 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7832 filter, "syn_filter");
7833 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7834 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7836 cmdline_parse_token_string_t cmd_syn_filter_ops =
7837 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7839 cmdline_parse_token_string_t cmd_syn_filter_priority =
7840 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7841 priority, "priority");
7842 cmdline_parse_token_string_t cmd_syn_filter_high =
7843 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7845 cmdline_parse_token_string_t cmd_syn_filter_queue =
7846 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7848 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7849 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7852 cmdline_parse_inst_t cmd_syn_filter = {
7853 .f = cmd_syn_filter_parsed,
7855 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7856 "<queue_id>: Add/Delete syn filter",
7858 (void *)&cmd_syn_filter_filter,
7859 (void *)&cmd_syn_filter_port_id,
7860 (void *)&cmd_syn_filter_ops,
7861 (void *)&cmd_syn_filter_priority,
7862 (void *)&cmd_syn_filter_high,
7863 (void *)&cmd_syn_filter_queue,
7864 (void *)&cmd_syn_filter_queue_id,
7869 /* *** ADD/REMOVE A 2tuple FILTER *** */
7870 struct cmd_2tuple_filter_result {
7871 cmdline_fixed_string_t filter;
7873 cmdline_fixed_string_t ops;
7874 cmdline_fixed_string_t dst_port;
7875 uint16_t dst_port_value;
7876 cmdline_fixed_string_t protocol;
7877 uint8_t protocol_value;
7878 cmdline_fixed_string_t mask;
7880 cmdline_fixed_string_t tcp_flags;
7881 uint8_t tcp_flags_value;
7882 cmdline_fixed_string_t priority;
7883 uint8_t priority_value;
7884 cmdline_fixed_string_t queue;
7889 cmd_2tuple_filter_parsed(void *parsed_result,
7890 __attribute__((unused)) struct cmdline *cl,
7891 __attribute__((unused)) void *data)
7893 struct rte_eth_ntuple_filter filter;
7894 struct cmd_2tuple_filter_result *res = parsed_result;
7897 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7899 printf("ntuple filter is not supported on port %u.\n",
7904 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7906 filter.flags = RTE_2TUPLE_FLAGS;
7907 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7908 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7909 filter.proto = res->protocol_value;
7910 filter.priority = res->priority_value;
7911 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7912 printf("nonzero tcp_flags is only meaningful"
7913 " when protocol is TCP.\n");
7916 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7917 printf("invalid TCP flags.\n");
7921 if (res->tcp_flags_value != 0) {
7922 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7923 filter.tcp_flags = res->tcp_flags_value;
7926 /* need convert to big endian. */
7927 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7928 filter.queue = res->queue_id;
7930 if (!strcmp(res->ops, "add"))
7931 ret = rte_eth_dev_filter_ctrl(res->port_id,
7932 RTE_ETH_FILTER_NTUPLE,
7936 ret = rte_eth_dev_filter_ctrl(res->port_id,
7937 RTE_ETH_FILTER_NTUPLE,
7938 RTE_ETH_FILTER_DELETE,
7941 printf("2tuple filter programming error: (%s)\n",
7946 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7947 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7948 filter, "2tuple_filter");
7949 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7950 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7952 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7953 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7955 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7956 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7957 dst_port, "dst_port");
7958 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7959 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7960 dst_port_value, UINT16);
7961 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7962 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7963 protocol, "protocol");
7964 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7965 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7966 protocol_value, UINT8);
7967 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7968 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7970 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7971 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7973 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7974 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7975 tcp_flags, "tcp_flags");
7976 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7977 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7978 tcp_flags_value, UINT8);
7979 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7980 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7981 priority, "priority");
7982 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7983 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7984 priority_value, UINT8);
7985 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7986 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7988 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7989 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7992 cmdline_parse_inst_t cmd_2tuple_filter = {
7993 .f = cmd_2tuple_filter_parsed,
7995 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7996 "<value> mask <value> tcp_flags <value> priority <value> queue "
7997 "<queue_id>: Add a 2tuple filter",
7999 (void *)&cmd_2tuple_filter_filter,
8000 (void *)&cmd_2tuple_filter_port_id,
8001 (void *)&cmd_2tuple_filter_ops,
8002 (void *)&cmd_2tuple_filter_dst_port,
8003 (void *)&cmd_2tuple_filter_dst_port_value,
8004 (void *)&cmd_2tuple_filter_protocol,
8005 (void *)&cmd_2tuple_filter_protocol_value,
8006 (void *)&cmd_2tuple_filter_mask,
8007 (void *)&cmd_2tuple_filter_mask_value,
8008 (void *)&cmd_2tuple_filter_tcp_flags,
8009 (void *)&cmd_2tuple_filter_tcp_flags_value,
8010 (void *)&cmd_2tuple_filter_priority,
8011 (void *)&cmd_2tuple_filter_priority_value,
8012 (void *)&cmd_2tuple_filter_queue,
8013 (void *)&cmd_2tuple_filter_queue_id,
8018 /* *** ADD/REMOVE A 5tuple FILTER *** */
8019 struct cmd_5tuple_filter_result {
8020 cmdline_fixed_string_t filter;
8022 cmdline_fixed_string_t ops;
8023 cmdline_fixed_string_t dst_ip;
8024 cmdline_ipaddr_t dst_ip_value;
8025 cmdline_fixed_string_t src_ip;
8026 cmdline_ipaddr_t src_ip_value;
8027 cmdline_fixed_string_t dst_port;
8028 uint16_t dst_port_value;
8029 cmdline_fixed_string_t src_port;
8030 uint16_t src_port_value;
8031 cmdline_fixed_string_t protocol;
8032 uint8_t protocol_value;
8033 cmdline_fixed_string_t mask;
8035 cmdline_fixed_string_t tcp_flags;
8036 uint8_t tcp_flags_value;
8037 cmdline_fixed_string_t priority;
8038 uint8_t priority_value;
8039 cmdline_fixed_string_t queue;
8044 cmd_5tuple_filter_parsed(void *parsed_result,
8045 __attribute__((unused)) struct cmdline *cl,
8046 __attribute__((unused)) void *data)
8048 struct rte_eth_ntuple_filter filter;
8049 struct cmd_5tuple_filter_result *res = parsed_result;
8052 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8054 printf("ntuple filter is not supported on port %u.\n",
8059 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8061 filter.flags = RTE_5TUPLE_FLAGS;
8062 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8063 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8064 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8065 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8066 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8067 filter.proto = res->protocol_value;
8068 filter.priority = res->priority_value;
8069 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8070 printf("nonzero tcp_flags is only meaningful"
8071 " when protocol is TCP.\n");
8074 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8075 printf("invalid TCP flags.\n");
8079 if (res->tcp_flags_value != 0) {
8080 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8081 filter.tcp_flags = res->tcp_flags_value;
8084 if (res->dst_ip_value.family == AF_INET)
8085 /* no need to convert, already big endian. */
8086 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8088 if (filter.dst_ip_mask == 0) {
8089 printf("can not support ipv6 involved compare.\n");
8095 if (res->src_ip_value.family == AF_INET)
8096 /* no need to convert, already big endian. */
8097 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8099 if (filter.src_ip_mask == 0) {
8100 printf("can not support ipv6 involved compare.\n");
8105 /* need convert to big endian. */
8106 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8107 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8108 filter.queue = res->queue_id;
8110 if (!strcmp(res->ops, "add"))
8111 ret = rte_eth_dev_filter_ctrl(res->port_id,
8112 RTE_ETH_FILTER_NTUPLE,
8116 ret = rte_eth_dev_filter_ctrl(res->port_id,
8117 RTE_ETH_FILTER_NTUPLE,
8118 RTE_ETH_FILTER_DELETE,
8121 printf("5tuple filter programming error: (%s)\n",
8125 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8126 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8127 filter, "5tuple_filter");
8128 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8129 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8131 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8132 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8134 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8135 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8137 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8138 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8140 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8141 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8143 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8144 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8146 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8147 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8148 dst_port, "dst_port");
8149 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8150 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8151 dst_port_value, UINT16);
8152 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8153 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8154 src_port, "src_port");
8155 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8156 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8157 src_port_value, UINT16);
8158 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8159 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8160 protocol, "protocol");
8161 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8162 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8163 protocol_value, UINT8);
8164 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8165 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8167 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8168 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8170 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8171 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8172 tcp_flags, "tcp_flags");
8173 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8174 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8175 tcp_flags_value, UINT8);
8176 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8177 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8178 priority, "priority");
8179 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8180 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8181 priority_value, UINT8);
8182 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8183 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8185 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8186 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8189 cmdline_parse_inst_t cmd_5tuple_filter = {
8190 .f = cmd_5tuple_filter_parsed,
8192 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8193 "src_ip <value> dst_port <value> src_port <value> "
8194 "protocol <value> mask <value> tcp_flags <value> "
8195 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8197 (void *)&cmd_5tuple_filter_filter,
8198 (void *)&cmd_5tuple_filter_port_id,
8199 (void *)&cmd_5tuple_filter_ops,
8200 (void *)&cmd_5tuple_filter_dst_ip,
8201 (void *)&cmd_5tuple_filter_dst_ip_value,
8202 (void *)&cmd_5tuple_filter_src_ip,
8203 (void *)&cmd_5tuple_filter_src_ip_value,
8204 (void *)&cmd_5tuple_filter_dst_port,
8205 (void *)&cmd_5tuple_filter_dst_port_value,
8206 (void *)&cmd_5tuple_filter_src_port,
8207 (void *)&cmd_5tuple_filter_src_port_value,
8208 (void *)&cmd_5tuple_filter_protocol,
8209 (void *)&cmd_5tuple_filter_protocol_value,
8210 (void *)&cmd_5tuple_filter_mask,
8211 (void *)&cmd_5tuple_filter_mask_value,
8212 (void *)&cmd_5tuple_filter_tcp_flags,
8213 (void *)&cmd_5tuple_filter_tcp_flags_value,
8214 (void *)&cmd_5tuple_filter_priority,
8215 (void *)&cmd_5tuple_filter_priority_value,
8216 (void *)&cmd_5tuple_filter_queue,
8217 (void *)&cmd_5tuple_filter_queue_id,
8222 /* *** ADD/REMOVE A flex FILTER *** */
8223 struct cmd_flex_filter_result {
8224 cmdline_fixed_string_t filter;
8225 cmdline_fixed_string_t ops;
8227 cmdline_fixed_string_t len;
8229 cmdline_fixed_string_t bytes;
8230 cmdline_fixed_string_t bytes_value;
8231 cmdline_fixed_string_t mask;
8232 cmdline_fixed_string_t mask_value;
8233 cmdline_fixed_string_t priority;
8234 uint8_t priority_value;
8235 cmdline_fixed_string_t queue;
8239 static int xdigit2val(unsigned char c)
8244 else if (isupper(c))
8252 cmd_flex_filter_parsed(void *parsed_result,
8253 __attribute__((unused)) struct cmdline *cl,
8254 __attribute__((unused)) void *data)
8257 struct rte_eth_flex_filter filter;
8258 struct cmd_flex_filter_result *res = parsed_result;
8259 char *bytes_ptr, *mask_ptr;
8260 uint16_t len, i, j = 0;
8265 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8266 printf("the len exceed the max length 128\n");
8269 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8270 filter.len = res->len_value;
8271 filter.priority = res->priority_value;
8272 filter.queue = res->queue_id;
8273 bytes_ptr = res->bytes_value;
8274 mask_ptr = res->mask_value;
8276 /* translate bytes string to array. */
8277 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8278 (bytes_ptr[1] == 'X')))
8280 len = strnlen(bytes_ptr, res->len_value * 2);
8281 if (len == 0 || (len % 8 != 0)) {
8282 printf("please check len and bytes input\n");
8285 for (i = 0; i < len; i++) {
8287 if (isxdigit(c) == 0) {
8288 /* invalid characters. */
8289 printf("invalid input\n");
8292 val = xdigit2val(c);
8295 filter.bytes[j] = byte;
8296 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8303 /* translate mask string to uint8_t array. */
8304 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8305 (mask_ptr[1] == 'X')))
8307 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8309 printf("invalid input\n");
8314 for (i = 0; i < len; i++) {
8316 if (isxdigit(c) == 0) {
8317 /* invalid characters. */
8318 printf("invalid input\n");
8321 val = xdigit2val(c);
8324 filter.mask[j] = byte;
8325 printf("mask[%d]:%02x ", j, filter.mask[j]);
8333 if (!strcmp(res->ops, "add"))
8334 ret = rte_eth_dev_filter_ctrl(res->port_id,
8335 RTE_ETH_FILTER_FLEXIBLE,
8339 ret = rte_eth_dev_filter_ctrl(res->port_id,
8340 RTE_ETH_FILTER_FLEXIBLE,
8341 RTE_ETH_FILTER_DELETE,
8345 printf("flex filter setting error: (%s)\n", strerror(-ret));
8348 cmdline_parse_token_string_t cmd_flex_filter_filter =
8349 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8350 filter, "flex_filter");
8351 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8352 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8354 cmdline_parse_token_string_t cmd_flex_filter_ops =
8355 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8357 cmdline_parse_token_string_t cmd_flex_filter_len =
8358 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8360 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8361 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8363 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8364 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8366 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8367 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8369 cmdline_parse_token_string_t cmd_flex_filter_mask =
8370 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8372 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8373 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8375 cmdline_parse_token_string_t cmd_flex_filter_priority =
8376 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8377 priority, "priority");
8378 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8379 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8380 priority_value, UINT8);
8381 cmdline_parse_token_string_t cmd_flex_filter_queue =
8382 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8384 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8385 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8387 cmdline_parse_inst_t cmd_flex_filter = {
8388 .f = cmd_flex_filter_parsed,
8390 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8391 "<value> mask <value> priority <value> queue <queue_id>: "
8392 "Add/Del a flex filter",
8394 (void *)&cmd_flex_filter_filter,
8395 (void *)&cmd_flex_filter_port_id,
8396 (void *)&cmd_flex_filter_ops,
8397 (void *)&cmd_flex_filter_len,
8398 (void *)&cmd_flex_filter_len_value,
8399 (void *)&cmd_flex_filter_bytes,
8400 (void *)&cmd_flex_filter_bytes_value,
8401 (void *)&cmd_flex_filter_mask,
8402 (void *)&cmd_flex_filter_mask_value,
8403 (void *)&cmd_flex_filter_priority,
8404 (void *)&cmd_flex_filter_priority_value,
8405 (void *)&cmd_flex_filter_queue,
8406 (void *)&cmd_flex_filter_queue_id,
8411 /* *** Filters Control *** */
8413 /* *** deal with ethertype filter *** */
8414 struct cmd_ethertype_filter_result {
8415 cmdline_fixed_string_t filter;
8417 cmdline_fixed_string_t ops;
8418 cmdline_fixed_string_t mac;
8419 struct ether_addr mac_addr;
8420 cmdline_fixed_string_t ethertype;
8421 uint16_t ethertype_value;
8422 cmdline_fixed_string_t drop;
8423 cmdline_fixed_string_t queue;
8427 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8428 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8429 filter, "ethertype_filter");
8430 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8431 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8433 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8434 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8436 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8437 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8438 mac, "mac_addr#mac_ignr");
8439 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8440 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8442 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8443 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8444 ethertype, "ethertype");
8445 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8446 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8447 ethertype_value, UINT16);
8448 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8449 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8451 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8452 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8454 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8455 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8459 cmd_ethertype_filter_parsed(void *parsed_result,
8460 __attribute__((unused)) struct cmdline *cl,
8461 __attribute__((unused)) void *data)
8463 struct cmd_ethertype_filter_result *res = parsed_result;
8464 struct rte_eth_ethertype_filter filter;
8467 ret = rte_eth_dev_filter_supported(res->port_id,
8468 RTE_ETH_FILTER_ETHERTYPE);
8470 printf("ethertype filter is not supported on port %u.\n",
8475 memset(&filter, 0, sizeof(filter));
8476 if (!strcmp(res->mac, "mac_addr")) {
8477 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8478 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8479 sizeof(struct ether_addr));
8481 if (!strcmp(res->drop, "drop"))
8482 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8483 filter.ether_type = res->ethertype_value;
8484 filter.queue = res->queue_id;
8486 if (!strcmp(res->ops, "add"))
8487 ret = rte_eth_dev_filter_ctrl(res->port_id,
8488 RTE_ETH_FILTER_ETHERTYPE,
8492 ret = rte_eth_dev_filter_ctrl(res->port_id,
8493 RTE_ETH_FILTER_ETHERTYPE,
8494 RTE_ETH_FILTER_DELETE,
8497 printf("ethertype filter programming error: (%s)\n",
8501 cmdline_parse_inst_t cmd_ethertype_filter = {
8502 .f = cmd_ethertype_filter_parsed,
8504 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8505 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8506 "Add or delete an ethertype filter entry",
8508 (void *)&cmd_ethertype_filter_filter,
8509 (void *)&cmd_ethertype_filter_port_id,
8510 (void *)&cmd_ethertype_filter_ops,
8511 (void *)&cmd_ethertype_filter_mac,
8512 (void *)&cmd_ethertype_filter_mac_addr,
8513 (void *)&cmd_ethertype_filter_ethertype,
8514 (void *)&cmd_ethertype_filter_ethertype_value,
8515 (void *)&cmd_ethertype_filter_drop,
8516 (void *)&cmd_ethertype_filter_queue,
8517 (void *)&cmd_ethertype_filter_queue_id,
8522 /* *** deal with flow director filter *** */
8523 struct cmd_flow_director_result {
8524 cmdline_fixed_string_t flow_director_filter;
8526 cmdline_fixed_string_t mode;
8527 cmdline_fixed_string_t mode_value;
8528 cmdline_fixed_string_t ops;
8529 cmdline_fixed_string_t flow;
8530 cmdline_fixed_string_t flow_type;
8531 cmdline_fixed_string_t ether;
8532 uint16_t ether_type;
8533 cmdline_fixed_string_t src;
8534 cmdline_ipaddr_t ip_src;
8536 cmdline_fixed_string_t dst;
8537 cmdline_ipaddr_t ip_dst;
8539 cmdline_fixed_string_t verify_tag;
8540 uint32_t verify_tag_value;
8541 cmdline_ipaddr_t tos;
8543 cmdline_ipaddr_t proto;
8544 uint8_t proto_value;
8545 cmdline_ipaddr_t ttl;
8547 cmdline_fixed_string_t vlan;
8548 uint16_t vlan_value;
8549 cmdline_fixed_string_t flexbytes;
8550 cmdline_fixed_string_t flexbytes_value;
8551 cmdline_fixed_string_t pf_vf;
8552 cmdline_fixed_string_t drop;
8553 cmdline_fixed_string_t queue;
8555 cmdline_fixed_string_t fd_id;
8556 uint32_t fd_id_value;
8557 cmdline_fixed_string_t mac;
8558 struct ether_addr mac_addr;
8559 cmdline_fixed_string_t tunnel;
8560 cmdline_fixed_string_t tunnel_type;
8561 cmdline_fixed_string_t tunnel_id;
8562 uint32_t tunnel_id_value;
8566 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8569 const char *p, *p0 = q_arg;
8571 unsigned long int_fld;
8572 char *str_fld[max_num];
8577 p = strchr(p0, '(');
8581 p0 = strchr(p, ')');
8586 if (size >= sizeof(s))
8589 snprintf(s, sizeof(s), "%.*s", size, p);
8590 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8591 if (ret < 0 || ret > max_num)
8593 for (i = 0; i < ret; i++) {
8595 int_fld = strtoul(str_fld[i], &end, 0);
8596 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8598 flexbytes[i] = (uint8_t)int_fld;
8604 str2flowtype(char *string)
8607 static const struct {
8610 } flowtype_str[] = {
8611 {"raw", RTE_ETH_FLOW_RAW},
8612 {"ipv4", RTE_ETH_FLOW_IPV4},
8613 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8614 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8615 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8616 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8617 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8618 {"ipv6", RTE_ETH_FLOW_IPV6},
8619 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8620 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8621 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8622 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8623 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8624 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8627 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8628 if (!strcmp(flowtype_str[i].str, string))
8629 return flowtype_str[i].type;
8631 return RTE_ETH_FLOW_UNKNOWN;
8634 static enum rte_eth_fdir_tunnel_type
8635 str2fdir_tunneltype(char *string)
8639 static const struct {
8641 enum rte_eth_fdir_tunnel_type type;
8642 } tunneltype_str[] = {
8643 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8644 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8647 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8648 if (!strcmp(tunneltype_str[i].str, string))
8649 return tunneltype_str[i].type;
8651 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8654 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8656 if ((ip_addr).family == AF_INET) \
8657 (ip) = (ip_addr).addr.ipv4.s_addr; \
8659 printf("invalid parameter.\n"); \
8664 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8666 if ((ip_addr).family == AF_INET6) \
8667 (void)rte_memcpy(&(ip), \
8668 &((ip_addr).addr.ipv6), \
8669 sizeof(struct in6_addr)); \
8671 printf("invalid parameter.\n"); \
8677 cmd_flow_director_filter_parsed(void *parsed_result,
8678 __attribute__((unused)) struct cmdline *cl,
8679 __attribute__((unused)) void *data)
8681 struct cmd_flow_director_result *res = parsed_result;
8682 struct rte_eth_fdir_filter entry;
8683 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8685 unsigned long vf_id;
8688 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8690 printf("flow director is not supported on port %u.\n",
8694 memset(flexbytes, 0, sizeof(flexbytes));
8695 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8697 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8698 if (strcmp(res->mode_value, "MAC-VLAN")) {
8699 printf("Please set mode to MAC-VLAN.\n");
8702 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8703 if (strcmp(res->mode_value, "Tunnel")) {
8704 printf("Please set mode to Tunnel.\n");
8708 if (strcmp(res->mode_value, "IP")) {
8709 printf("Please set mode to IP.\n");
8712 entry.input.flow_type = str2flowtype(res->flow_type);
8715 ret = parse_flexbytes(res->flexbytes_value,
8717 RTE_ETH_FDIR_MAX_FLEXLEN);
8719 printf("error: Cannot parse flexbytes input.\n");
8723 switch (entry.input.flow_type) {
8724 case RTE_ETH_FLOW_FRAG_IPV4:
8725 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8726 entry.input.flow.ip4_flow.proto = res->proto_value;
8727 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8728 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8729 IPV4_ADDR_TO_UINT(res->ip_dst,
8730 entry.input.flow.ip4_flow.dst_ip);
8731 IPV4_ADDR_TO_UINT(res->ip_src,
8732 entry.input.flow.ip4_flow.src_ip);
8733 entry.input.flow.ip4_flow.tos = res->tos_value;
8734 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8735 /* need convert to big endian. */
8736 entry.input.flow.udp4_flow.dst_port =
8737 rte_cpu_to_be_16(res->port_dst);
8738 entry.input.flow.udp4_flow.src_port =
8739 rte_cpu_to_be_16(res->port_src);
8741 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8742 IPV4_ADDR_TO_UINT(res->ip_dst,
8743 entry.input.flow.sctp4_flow.ip.dst_ip);
8744 IPV4_ADDR_TO_UINT(res->ip_src,
8745 entry.input.flow.sctp4_flow.ip.src_ip);
8746 entry.input.flow.ip4_flow.tos = res->tos_value;
8747 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8748 /* need convert to big endian. */
8749 entry.input.flow.sctp4_flow.dst_port =
8750 rte_cpu_to_be_16(res->port_dst);
8751 entry.input.flow.sctp4_flow.src_port =
8752 rte_cpu_to_be_16(res->port_src);
8753 entry.input.flow.sctp4_flow.verify_tag =
8754 rte_cpu_to_be_32(res->verify_tag_value);
8756 case RTE_ETH_FLOW_FRAG_IPV6:
8757 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8758 entry.input.flow.ipv6_flow.proto = res->proto_value;
8759 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8760 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8761 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8762 entry.input.flow.ipv6_flow.dst_ip);
8763 IPV6_ADDR_TO_ARRAY(res->ip_src,
8764 entry.input.flow.ipv6_flow.src_ip);
8765 entry.input.flow.ipv6_flow.tc = res->tos_value;
8766 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8767 /* need convert to big endian. */
8768 entry.input.flow.udp6_flow.dst_port =
8769 rte_cpu_to_be_16(res->port_dst);
8770 entry.input.flow.udp6_flow.src_port =
8771 rte_cpu_to_be_16(res->port_src);
8773 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8774 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8775 entry.input.flow.sctp6_flow.ip.dst_ip);
8776 IPV6_ADDR_TO_ARRAY(res->ip_src,
8777 entry.input.flow.sctp6_flow.ip.src_ip);
8778 entry.input.flow.ipv6_flow.tc = res->tos_value;
8779 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8780 /* need convert to big endian. */
8781 entry.input.flow.sctp6_flow.dst_port =
8782 rte_cpu_to_be_16(res->port_dst);
8783 entry.input.flow.sctp6_flow.src_port =
8784 rte_cpu_to_be_16(res->port_src);
8785 entry.input.flow.sctp6_flow.verify_tag =
8786 rte_cpu_to_be_32(res->verify_tag_value);
8788 case RTE_ETH_FLOW_L2_PAYLOAD:
8789 entry.input.flow.l2_flow.ether_type =
8790 rte_cpu_to_be_16(res->ether_type);
8796 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8797 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8799 sizeof(struct ether_addr));
8801 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8802 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8804 sizeof(struct ether_addr));
8805 entry.input.flow.tunnel_flow.tunnel_type =
8806 str2fdir_tunneltype(res->tunnel_type);
8807 entry.input.flow.tunnel_flow.tunnel_id =
8808 rte_cpu_to_be_32(res->tunnel_id_value);
8811 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8813 RTE_ETH_FDIR_MAX_FLEXLEN);
8815 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8817 entry.action.flex_off = 0; /*use 0 by default */
8818 if (!strcmp(res->drop, "drop"))
8819 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8821 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8823 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8824 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8825 if (!strcmp(res->pf_vf, "pf"))
8826 entry.input.flow_ext.is_vf = 0;
8827 else if (!strncmp(res->pf_vf, "vf", 2)) {
8828 struct rte_eth_dev_info dev_info;
8830 memset(&dev_info, 0, sizeof(dev_info));
8831 rte_eth_dev_info_get(res->port_id, &dev_info);
8833 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8834 if (errno != 0 || *end != '\0' ||
8835 vf_id >= dev_info.max_vfs) {
8836 printf("invalid parameter %s.\n", res->pf_vf);
8839 entry.input.flow_ext.is_vf = 1;
8840 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8842 printf("invalid parameter %s.\n", res->pf_vf);
8847 /* set to report FD ID by default */
8848 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8849 entry.action.rx_queue = res->queue_id;
8850 entry.soft_id = res->fd_id_value;
8851 if (!strcmp(res->ops, "add"))
8852 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8853 RTE_ETH_FILTER_ADD, &entry);
8854 else if (!strcmp(res->ops, "del"))
8855 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8856 RTE_ETH_FILTER_DELETE, &entry);
8858 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8859 RTE_ETH_FILTER_UPDATE, &entry);
8861 printf("flow director programming error: (%s)\n",
8865 cmdline_parse_token_string_t cmd_flow_director_filter =
8866 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8867 flow_director_filter, "flow_director_filter");
8868 cmdline_parse_token_num_t cmd_flow_director_port_id =
8869 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8871 cmdline_parse_token_string_t cmd_flow_director_ops =
8872 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8873 ops, "add#del#update");
8874 cmdline_parse_token_string_t cmd_flow_director_flow =
8875 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8877 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8878 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8879 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8880 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8881 cmdline_parse_token_string_t cmd_flow_director_ether =
8882 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8884 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8885 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8886 ether_type, UINT16);
8887 cmdline_parse_token_string_t cmd_flow_director_src =
8888 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8890 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8891 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8893 cmdline_parse_token_num_t cmd_flow_director_port_src =
8894 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8896 cmdline_parse_token_string_t cmd_flow_director_dst =
8897 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8899 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8900 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8902 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8903 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8905 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8906 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8907 verify_tag, "verify_tag");
8908 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8909 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8910 verify_tag_value, UINT32);
8911 cmdline_parse_token_string_t cmd_flow_director_tos =
8912 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8914 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8915 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8917 cmdline_parse_token_string_t cmd_flow_director_proto =
8918 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8920 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8921 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8922 proto_value, UINT8);
8923 cmdline_parse_token_string_t cmd_flow_director_ttl =
8924 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8926 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8927 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8929 cmdline_parse_token_string_t cmd_flow_director_vlan =
8930 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8932 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8933 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8934 vlan_value, UINT16);
8935 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8936 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8937 flexbytes, "flexbytes");
8938 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8939 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8940 flexbytes_value, NULL);
8941 cmdline_parse_token_string_t cmd_flow_director_drop =
8942 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8944 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8945 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8947 cmdline_parse_token_string_t cmd_flow_director_queue =
8948 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8950 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8951 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8953 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8954 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8956 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8957 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8958 fd_id_value, UINT32);
8960 cmdline_parse_token_string_t cmd_flow_director_mode =
8961 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8963 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8964 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8966 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8967 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8968 mode_value, "MAC-VLAN");
8969 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8970 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8971 mode_value, "Tunnel");
8972 cmdline_parse_token_string_t cmd_flow_director_mac =
8973 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8975 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8976 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8978 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8979 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8981 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8982 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8983 tunnel_type, "NVGRE#VxLAN");
8984 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8985 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8986 tunnel_id, "tunnel-id");
8987 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8988 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8989 tunnel_id_value, UINT32);
8991 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8992 .f = cmd_flow_director_filter_parsed,
8994 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8995 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8996 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8997 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8998 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8999 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
9000 "fd_id <fd_id_value>: "
9001 "Add or delete an ip flow director entry on NIC",
9003 (void *)&cmd_flow_director_filter,
9004 (void *)&cmd_flow_director_port_id,
9005 (void *)&cmd_flow_director_mode,
9006 (void *)&cmd_flow_director_mode_ip,
9007 (void *)&cmd_flow_director_ops,
9008 (void *)&cmd_flow_director_flow,
9009 (void *)&cmd_flow_director_flow_type,
9010 (void *)&cmd_flow_director_src,
9011 (void *)&cmd_flow_director_ip_src,
9012 (void *)&cmd_flow_director_dst,
9013 (void *)&cmd_flow_director_ip_dst,
9014 (void *)&cmd_flow_director_tos,
9015 (void *)&cmd_flow_director_tos_value,
9016 (void *)&cmd_flow_director_proto,
9017 (void *)&cmd_flow_director_proto_value,
9018 (void *)&cmd_flow_director_ttl,
9019 (void *)&cmd_flow_director_ttl_value,
9020 (void *)&cmd_flow_director_vlan,
9021 (void *)&cmd_flow_director_vlan_value,
9022 (void *)&cmd_flow_director_flexbytes,
9023 (void *)&cmd_flow_director_flexbytes_value,
9024 (void *)&cmd_flow_director_drop,
9025 (void *)&cmd_flow_director_pf_vf,
9026 (void *)&cmd_flow_director_queue,
9027 (void *)&cmd_flow_director_queue_id,
9028 (void *)&cmd_flow_director_fd_id,
9029 (void *)&cmd_flow_director_fd_id_value,
9034 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9035 .f = cmd_flow_director_filter_parsed,
9037 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9038 "director entry on NIC",
9040 (void *)&cmd_flow_director_filter,
9041 (void *)&cmd_flow_director_port_id,
9042 (void *)&cmd_flow_director_mode,
9043 (void *)&cmd_flow_director_mode_ip,
9044 (void *)&cmd_flow_director_ops,
9045 (void *)&cmd_flow_director_flow,
9046 (void *)&cmd_flow_director_flow_type,
9047 (void *)&cmd_flow_director_src,
9048 (void *)&cmd_flow_director_ip_src,
9049 (void *)&cmd_flow_director_port_src,
9050 (void *)&cmd_flow_director_dst,
9051 (void *)&cmd_flow_director_ip_dst,
9052 (void *)&cmd_flow_director_port_dst,
9053 (void *)&cmd_flow_director_tos,
9054 (void *)&cmd_flow_director_tos_value,
9055 (void *)&cmd_flow_director_ttl,
9056 (void *)&cmd_flow_director_ttl_value,
9057 (void *)&cmd_flow_director_vlan,
9058 (void *)&cmd_flow_director_vlan_value,
9059 (void *)&cmd_flow_director_flexbytes,
9060 (void *)&cmd_flow_director_flexbytes_value,
9061 (void *)&cmd_flow_director_drop,
9062 (void *)&cmd_flow_director_pf_vf,
9063 (void *)&cmd_flow_director_queue,
9064 (void *)&cmd_flow_director_queue_id,
9065 (void *)&cmd_flow_director_fd_id,
9066 (void *)&cmd_flow_director_fd_id_value,
9071 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9072 .f = cmd_flow_director_filter_parsed,
9074 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9075 "director entry on NIC",
9077 (void *)&cmd_flow_director_filter,
9078 (void *)&cmd_flow_director_port_id,
9079 (void *)&cmd_flow_director_mode,
9080 (void *)&cmd_flow_director_mode_ip,
9081 (void *)&cmd_flow_director_ops,
9082 (void *)&cmd_flow_director_flow,
9083 (void *)&cmd_flow_director_flow_type,
9084 (void *)&cmd_flow_director_src,
9085 (void *)&cmd_flow_director_ip_src,
9086 (void *)&cmd_flow_director_port_dst,
9087 (void *)&cmd_flow_director_dst,
9088 (void *)&cmd_flow_director_ip_dst,
9089 (void *)&cmd_flow_director_port_dst,
9090 (void *)&cmd_flow_director_verify_tag,
9091 (void *)&cmd_flow_director_verify_tag_value,
9092 (void *)&cmd_flow_director_tos,
9093 (void *)&cmd_flow_director_tos_value,
9094 (void *)&cmd_flow_director_ttl,
9095 (void *)&cmd_flow_director_ttl_value,
9096 (void *)&cmd_flow_director_vlan,
9097 (void *)&cmd_flow_director_vlan_value,
9098 (void *)&cmd_flow_director_flexbytes,
9099 (void *)&cmd_flow_director_flexbytes_value,
9100 (void *)&cmd_flow_director_drop,
9101 (void *)&cmd_flow_director_pf_vf,
9102 (void *)&cmd_flow_director_queue,
9103 (void *)&cmd_flow_director_queue_id,
9104 (void *)&cmd_flow_director_fd_id,
9105 (void *)&cmd_flow_director_fd_id_value,
9110 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9111 .f = cmd_flow_director_filter_parsed,
9113 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9114 "director entry on NIC",
9116 (void *)&cmd_flow_director_filter,
9117 (void *)&cmd_flow_director_port_id,
9118 (void *)&cmd_flow_director_mode,
9119 (void *)&cmd_flow_director_mode_ip,
9120 (void *)&cmd_flow_director_ops,
9121 (void *)&cmd_flow_director_flow,
9122 (void *)&cmd_flow_director_flow_type,
9123 (void *)&cmd_flow_director_ether,
9124 (void *)&cmd_flow_director_ether_type,
9125 (void *)&cmd_flow_director_flexbytes,
9126 (void *)&cmd_flow_director_flexbytes_value,
9127 (void *)&cmd_flow_director_drop,
9128 (void *)&cmd_flow_director_pf_vf,
9129 (void *)&cmd_flow_director_queue,
9130 (void *)&cmd_flow_director_queue_id,
9131 (void *)&cmd_flow_director_fd_id,
9132 (void *)&cmd_flow_director_fd_id_value,
9137 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9138 .f = cmd_flow_director_filter_parsed,
9140 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9141 "director entry on NIC",
9143 (void *)&cmd_flow_director_filter,
9144 (void *)&cmd_flow_director_port_id,
9145 (void *)&cmd_flow_director_mode,
9146 (void *)&cmd_flow_director_mode_mac_vlan,
9147 (void *)&cmd_flow_director_ops,
9148 (void *)&cmd_flow_director_mac,
9149 (void *)&cmd_flow_director_mac_addr,
9150 (void *)&cmd_flow_director_vlan,
9151 (void *)&cmd_flow_director_vlan_value,
9152 (void *)&cmd_flow_director_flexbytes,
9153 (void *)&cmd_flow_director_flexbytes_value,
9154 (void *)&cmd_flow_director_drop,
9155 (void *)&cmd_flow_director_queue,
9156 (void *)&cmd_flow_director_queue_id,
9157 (void *)&cmd_flow_director_fd_id,
9158 (void *)&cmd_flow_director_fd_id_value,
9163 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9164 .f = cmd_flow_director_filter_parsed,
9166 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9167 "director entry on NIC",
9169 (void *)&cmd_flow_director_filter,
9170 (void *)&cmd_flow_director_port_id,
9171 (void *)&cmd_flow_director_mode,
9172 (void *)&cmd_flow_director_mode_tunnel,
9173 (void *)&cmd_flow_director_ops,
9174 (void *)&cmd_flow_director_mac,
9175 (void *)&cmd_flow_director_mac_addr,
9176 (void *)&cmd_flow_director_vlan,
9177 (void *)&cmd_flow_director_vlan_value,
9178 (void *)&cmd_flow_director_tunnel,
9179 (void *)&cmd_flow_director_tunnel_type,
9180 (void *)&cmd_flow_director_tunnel_id,
9181 (void *)&cmd_flow_director_tunnel_id_value,
9182 (void *)&cmd_flow_director_flexbytes,
9183 (void *)&cmd_flow_director_flexbytes_value,
9184 (void *)&cmd_flow_director_drop,
9185 (void *)&cmd_flow_director_queue,
9186 (void *)&cmd_flow_director_queue_id,
9187 (void *)&cmd_flow_director_fd_id,
9188 (void *)&cmd_flow_director_fd_id_value,
9193 struct cmd_flush_flow_director_result {
9194 cmdline_fixed_string_t flush_flow_director;
9198 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9199 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9200 flush_flow_director, "flush_flow_director");
9201 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9202 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9206 cmd_flush_flow_director_parsed(void *parsed_result,
9207 __attribute__((unused)) struct cmdline *cl,
9208 __attribute__((unused)) void *data)
9210 struct cmd_flow_director_result *res = parsed_result;
9213 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9215 printf("flow director is not supported on port %u.\n",
9220 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9221 RTE_ETH_FILTER_FLUSH, NULL);
9223 printf("flow director table flushing error: (%s)\n",
9227 cmdline_parse_inst_t cmd_flush_flow_director = {
9228 .f = cmd_flush_flow_director_parsed,
9230 .help_str = "flush_flow_director <port_id>: "
9231 "Flush all flow director entries of a device on NIC",
9233 (void *)&cmd_flush_flow_director_flush,
9234 (void *)&cmd_flush_flow_director_port_id,
9239 /* *** deal with flow director mask *** */
9240 struct cmd_flow_director_mask_result {
9241 cmdline_fixed_string_t flow_director_mask;
9243 cmdline_fixed_string_t mode;
9244 cmdline_fixed_string_t mode_value;
9245 cmdline_fixed_string_t vlan;
9247 cmdline_fixed_string_t src_mask;
9248 cmdline_ipaddr_t ipv4_src;
9249 cmdline_ipaddr_t ipv6_src;
9251 cmdline_fixed_string_t dst_mask;
9252 cmdline_ipaddr_t ipv4_dst;
9253 cmdline_ipaddr_t ipv6_dst;
9255 cmdline_fixed_string_t mac;
9256 uint8_t mac_addr_byte_mask;
9257 cmdline_fixed_string_t tunnel_id;
9258 uint32_t tunnel_id_mask;
9259 cmdline_fixed_string_t tunnel_type;
9260 uint8_t tunnel_type_mask;
9264 cmd_flow_director_mask_parsed(void *parsed_result,
9265 __attribute__((unused)) struct cmdline *cl,
9266 __attribute__((unused)) void *data)
9268 struct cmd_flow_director_mask_result *res = parsed_result;
9269 struct rte_eth_fdir_masks *mask;
9270 struct rte_port *port;
9272 if (res->port_id > nb_ports) {
9273 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9277 port = &ports[res->port_id];
9278 /** Check if the port is not started **/
9279 if (port->port_status != RTE_PORT_STOPPED) {
9280 printf("Please stop port %d first\n", res->port_id);
9284 mask = &port->dev_conf.fdir_conf.mask;
9286 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9287 if (strcmp(res->mode_value, "MAC-VLAN")) {
9288 printf("Please set mode to MAC-VLAN.\n");
9292 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9293 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9294 if (strcmp(res->mode_value, "Tunnel")) {
9295 printf("Please set mode to Tunnel.\n");
9299 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9300 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9301 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9302 mask->tunnel_type_mask = res->tunnel_type_mask;
9304 if (strcmp(res->mode_value, "IP")) {
9305 printf("Please set mode to IP.\n");
9309 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9310 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9311 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9312 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9313 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9314 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9315 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9318 cmd_reconfig_device_queue(res->port_id, 1, 1);
9321 cmdline_parse_token_string_t cmd_flow_director_mask =
9322 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9323 flow_director_mask, "flow_director_mask");
9324 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9325 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9327 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9330 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9331 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9333 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9334 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9335 src_mask, "src_mask");
9336 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9337 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9339 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9340 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9342 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9343 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9345 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9346 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9347 dst_mask, "dst_mask");
9348 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9349 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9351 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9352 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9354 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9355 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9358 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9359 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9361 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9364 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9366 mode_value, "MAC-VLAN");
9367 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9368 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9369 mode_value, "Tunnel");
9370 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9371 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9373 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9374 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9375 mac_addr_byte_mask, UINT8);
9376 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9377 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9378 tunnel_type, "tunnel-type");
9379 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9380 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9381 tunnel_type_mask, UINT8);
9382 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9383 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9384 tunnel_id, "tunnel-id");
9385 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9386 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9387 tunnel_id_mask, UINT32);
9389 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9390 .f = cmd_flow_director_mask_parsed,
9392 .help_str = "flow_director_mask ... : "
9393 "Set IP mode flow director's mask on NIC",
9395 (void *)&cmd_flow_director_mask,
9396 (void *)&cmd_flow_director_mask_port_id,
9397 (void *)&cmd_flow_director_mask_mode,
9398 (void *)&cmd_flow_director_mask_mode_ip,
9399 (void *)&cmd_flow_director_mask_vlan,
9400 (void *)&cmd_flow_director_mask_vlan_value,
9401 (void *)&cmd_flow_director_mask_src,
9402 (void *)&cmd_flow_director_mask_ipv4_src,
9403 (void *)&cmd_flow_director_mask_ipv6_src,
9404 (void *)&cmd_flow_director_mask_port_src,
9405 (void *)&cmd_flow_director_mask_dst,
9406 (void *)&cmd_flow_director_mask_ipv4_dst,
9407 (void *)&cmd_flow_director_mask_ipv6_dst,
9408 (void *)&cmd_flow_director_mask_port_dst,
9413 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9414 .f = cmd_flow_director_mask_parsed,
9416 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9417 "flow director's mask on NIC",
9419 (void *)&cmd_flow_director_mask,
9420 (void *)&cmd_flow_director_mask_port_id,
9421 (void *)&cmd_flow_director_mask_mode,
9422 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9423 (void *)&cmd_flow_director_mask_vlan,
9424 (void *)&cmd_flow_director_mask_vlan_value,
9429 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9430 .f = cmd_flow_director_mask_parsed,
9432 .help_str = "flow_director_mask ... : Set tunnel mode "
9433 "flow director's mask on NIC",
9435 (void *)&cmd_flow_director_mask,
9436 (void *)&cmd_flow_director_mask_port_id,
9437 (void *)&cmd_flow_director_mask_mode,
9438 (void *)&cmd_flow_director_mask_mode_tunnel,
9439 (void *)&cmd_flow_director_mask_vlan,
9440 (void *)&cmd_flow_director_mask_vlan_value,
9441 (void *)&cmd_flow_director_mask_mac,
9442 (void *)&cmd_flow_director_mask_mac_value,
9443 (void *)&cmd_flow_director_mask_tunnel_type,
9444 (void *)&cmd_flow_director_mask_tunnel_type_value,
9445 (void *)&cmd_flow_director_mask_tunnel_id,
9446 (void *)&cmd_flow_director_mask_tunnel_id_value,
9451 /* *** deal with flow director mask on flexible payload *** */
9452 struct cmd_flow_director_flex_mask_result {
9453 cmdline_fixed_string_t flow_director_flexmask;
9455 cmdline_fixed_string_t flow;
9456 cmdline_fixed_string_t flow_type;
9457 cmdline_fixed_string_t mask;
9461 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9462 __attribute__((unused)) struct cmdline *cl,
9463 __attribute__((unused)) void *data)
9465 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9466 struct rte_eth_fdir_info fdir_info;
9467 struct rte_eth_fdir_flex_mask flex_mask;
9468 struct rte_port *port;
9469 uint32_t flow_type_mask;
9473 if (res->port_id > nb_ports) {
9474 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9478 port = &ports[res->port_id];
9479 /** Check if the port is not started **/
9480 if (port->port_status != RTE_PORT_STOPPED) {
9481 printf("Please stop port %d first\n", res->port_id);
9485 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9486 ret = parse_flexbytes(res->mask,
9488 RTE_ETH_FDIR_MAX_FLEXLEN);
9490 printf("error: Cannot parse mask input.\n");
9494 memset(&fdir_info, 0, sizeof(fdir_info));
9495 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9496 RTE_ETH_FILTER_INFO, &fdir_info);
9498 printf("Cannot get FDir filter info\n");
9502 if (!strcmp(res->flow_type, "none")) {
9503 /* means don't specify the flow type */
9504 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9505 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9506 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9507 0, sizeof(struct rte_eth_fdir_flex_mask));
9508 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9509 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9511 sizeof(struct rte_eth_fdir_flex_mask));
9512 cmd_reconfig_device_queue(res->port_id, 1, 1);
9515 flow_type_mask = fdir_info.flow_types_mask[0];
9516 if (!strcmp(res->flow_type, "all")) {
9517 if (!flow_type_mask) {
9518 printf("No flow type supported\n");
9521 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9522 if (flow_type_mask & (1 << i)) {
9523 flex_mask.flow_type = i;
9524 fdir_set_flex_mask(res->port_id, &flex_mask);
9527 cmd_reconfig_device_queue(res->port_id, 1, 1);
9530 flex_mask.flow_type = str2flowtype(res->flow_type);
9531 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9532 printf("Flow type %s not supported on port %d\n",
9533 res->flow_type, res->port_id);
9536 fdir_set_flex_mask(res->port_id, &flex_mask);
9537 cmd_reconfig_device_queue(res->port_id, 1, 1);
9540 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9541 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9542 flow_director_flexmask,
9543 "flow_director_flex_mask");
9544 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9545 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9547 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9548 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9550 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9551 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9552 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9553 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9554 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9555 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9558 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9559 .f = cmd_flow_director_flex_mask_parsed,
9561 .help_str = "flow_director_flex_mask ... : "
9562 "Set flow director's flex mask on NIC",
9564 (void *)&cmd_flow_director_flexmask,
9565 (void *)&cmd_flow_director_flexmask_port_id,
9566 (void *)&cmd_flow_director_flexmask_flow,
9567 (void *)&cmd_flow_director_flexmask_flow_type,
9568 (void *)&cmd_flow_director_flexmask_mask,
9573 /* *** deal with flow director flexible payload configuration *** */
9574 struct cmd_flow_director_flexpayload_result {
9575 cmdline_fixed_string_t flow_director_flexpayload;
9577 cmdline_fixed_string_t payload_layer;
9578 cmdline_fixed_string_t payload_cfg;
9582 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9585 const char *p, *p0 = q_arg;
9587 unsigned long int_fld;
9588 char *str_fld[max_num];
9593 p = strchr(p0, '(');
9597 p0 = strchr(p, ')');
9602 if (size >= sizeof(s))
9605 snprintf(s, sizeof(s), "%.*s", size, p);
9606 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9607 if (ret < 0 || ret > max_num)
9609 for (i = 0; i < ret; i++) {
9611 int_fld = strtoul(str_fld[i], &end, 0);
9612 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9614 offsets[i] = (uint16_t)int_fld;
9620 cmd_flow_director_flxpld_parsed(void *parsed_result,
9621 __attribute__((unused)) struct cmdline *cl,
9622 __attribute__((unused)) void *data)
9624 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9625 struct rte_eth_flex_payload_cfg flex_cfg;
9626 struct rte_port *port;
9629 if (res->port_id > nb_ports) {
9630 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9634 port = &ports[res->port_id];
9635 /** Check if the port is not started **/
9636 if (port->port_status != RTE_PORT_STOPPED) {
9637 printf("Please stop port %d first\n", res->port_id);
9641 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9643 if (!strcmp(res->payload_layer, "raw"))
9644 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9645 else if (!strcmp(res->payload_layer, "l2"))
9646 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9647 else if (!strcmp(res->payload_layer, "l3"))
9648 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9649 else if (!strcmp(res->payload_layer, "l4"))
9650 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9652 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9653 RTE_ETH_FDIR_MAX_FLEXLEN);
9655 printf("error: Cannot parse flex payload input.\n");
9659 fdir_set_flex_payload(res->port_id, &flex_cfg);
9660 cmd_reconfig_device_queue(res->port_id, 1, 1);
9663 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9664 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9665 flow_director_flexpayload,
9666 "flow_director_flex_payload");
9667 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9668 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9670 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9671 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9672 payload_layer, "raw#l2#l3#l4");
9673 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9674 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9677 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9678 .f = cmd_flow_director_flxpld_parsed,
9680 .help_str = "flow_director_flexpayload ... : "
9681 "Set flow director's flex payload on NIC",
9683 (void *)&cmd_flow_director_flexpayload,
9684 (void *)&cmd_flow_director_flexpayload_port_id,
9685 (void *)&cmd_flow_director_flexpayload_payload_layer,
9686 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9691 /* Generic flow interface command. */
9692 extern cmdline_parse_inst_t cmd_flow;
9694 /* *** Classification Filters Control *** */
9695 /* *** Get symmetric hash enable per port *** */
9696 struct cmd_get_sym_hash_ena_per_port_result {
9697 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9702 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9703 __rte_unused struct cmdline *cl,
9704 __rte_unused void *data)
9706 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9707 struct rte_eth_hash_filter_info info;
9710 if (rte_eth_dev_filter_supported(res->port_id,
9711 RTE_ETH_FILTER_HASH) < 0) {
9712 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9717 memset(&info, 0, sizeof(info));
9718 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9719 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9720 RTE_ETH_FILTER_GET, &info);
9723 printf("Cannot get symmetric hash enable per port "
9724 "on port %u\n", res->port_id);
9728 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9729 "enabled" : "disabled", res->port_id);
9732 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9733 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9734 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9735 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9736 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9739 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9740 .f = cmd_get_sym_hash_per_port_parsed,
9742 .help_str = "get_sym_hash_ena_per_port <port_id>",
9744 (void *)&cmd_get_sym_hash_ena_per_port_all,
9745 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9750 /* *** Set symmetric hash enable per port *** */
9751 struct cmd_set_sym_hash_ena_per_port_result {
9752 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9753 cmdline_fixed_string_t enable;
9758 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9759 __rte_unused struct cmdline *cl,
9760 __rte_unused void *data)
9762 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9763 struct rte_eth_hash_filter_info info;
9766 if (rte_eth_dev_filter_supported(res->port_id,
9767 RTE_ETH_FILTER_HASH) < 0) {
9768 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9773 memset(&info, 0, sizeof(info));
9774 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9775 if (!strcmp(res->enable, "enable"))
9776 info.info.enable = 1;
9777 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9778 RTE_ETH_FILTER_SET, &info);
9780 printf("Cannot set symmetric hash enable per port on "
9781 "port %u\n", res->port_id);
9784 printf("Symmetric hash has been set to %s on port %u\n",
9785 res->enable, res->port_id);
9788 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9789 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9790 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9791 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9792 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9794 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9795 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9796 enable, "enable#disable");
9798 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9799 .f = cmd_set_sym_hash_per_port_parsed,
9801 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9803 (void *)&cmd_set_sym_hash_ena_per_port_all,
9804 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9805 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9810 /* Get global config of hash function */
9811 struct cmd_get_hash_global_config_result {
9812 cmdline_fixed_string_t get_hash_global_config;
9817 flowtype_to_str(uint16_t ftype)
9824 {"ipv4", RTE_ETH_FLOW_IPV4},
9825 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9826 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9827 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9828 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9829 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9830 {"ipv6", RTE_ETH_FLOW_IPV6},
9831 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9832 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9833 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9834 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9835 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9836 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9837 {"port", RTE_ETH_FLOW_PORT},
9838 {"vxlan", RTE_ETH_FLOW_VXLAN},
9839 {"geneve", RTE_ETH_FLOW_GENEVE},
9840 {"nvgre", RTE_ETH_FLOW_NVGRE},
9843 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9844 if (ftype_table[i].ftype == ftype)
9845 return ftype_table[i].str;
9852 cmd_get_hash_global_config_parsed(void *parsed_result,
9853 __rte_unused struct cmdline *cl,
9854 __rte_unused void *data)
9856 struct cmd_get_hash_global_config_result *res = parsed_result;
9857 struct rte_eth_hash_filter_info info;
9858 uint32_t idx, offset;
9863 if (rte_eth_dev_filter_supported(res->port_id,
9864 RTE_ETH_FILTER_HASH) < 0) {
9865 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9870 memset(&info, 0, sizeof(info));
9871 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9872 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9873 RTE_ETH_FILTER_GET, &info);
9875 printf("Cannot get hash global configurations by port %d\n",
9880 switch (info.info.global_conf.hash_func) {
9881 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9882 printf("Hash function is Toeplitz\n");
9884 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9885 printf("Hash function is Simple XOR\n");
9888 printf("Unknown hash function\n");
9892 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9893 idx = i / UINT32_BIT;
9894 offset = i % UINT32_BIT;
9895 if (!(info.info.global_conf.valid_bit_mask[idx] &
9898 str = flowtype_to_str(i);
9901 printf("Symmetric hash is %s globally for flow type %s "
9903 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9904 (1UL << offset)) ? "enabled" : "disabled"), str,
9909 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9910 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9911 get_hash_global_config, "get_hash_global_config");
9912 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9913 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9916 cmdline_parse_inst_t cmd_get_hash_global_config = {
9917 .f = cmd_get_hash_global_config_parsed,
9919 .help_str = "get_hash_global_config <port_id>",
9921 (void *)&cmd_get_hash_global_config_all,
9922 (void *)&cmd_get_hash_global_config_port_id,
9927 /* Set global config of hash function */
9928 struct cmd_set_hash_global_config_result {
9929 cmdline_fixed_string_t set_hash_global_config;
9931 cmdline_fixed_string_t hash_func;
9932 cmdline_fixed_string_t flow_type;
9933 cmdline_fixed_string_t enable;
9937 cmd_set_hash_global_config_parsed(void *parsed_result,
9938 __rte_unused struct cmdline *cl,
9939 __rte_unused void *data)
9941 struct cmd_set_hash_global_config_result *res = parsed_result;
9942 struct rte_eth_hash_filter_info info;
9943 uint32_t ftype, idx, offset;
9946 if (rte_eth_dev_filter_supported(res->port_id,
9947 RTE_ETH_FILTER_HASH) < 0) {
9948 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9952 memset(&info, 0, sizeof(info));
9953 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9954 if (!strcmp(res->hash_func, "toeplitz"))
9955 info.info.global_conf.hash_func =
9956 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9957 else if (!strcmp(res->hash_func, "simple_xor"))
9958 info.info.global_conf.hash_func =
9959 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9960 else if (!strcmp(res->hash_func, "default"))
9961 info.info.global_conf.hash_func =
9962 RTE_ETH_HASH_FUNCTION_DEFAULT;
9964 ftype = str2flowtype(res->flow_type);
9965 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9966 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9967 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9968 if (!strcmp(res->enable, "enable"))
9969 info.info.global_conf.sym_hash_enable_mask[idx] |=
9971 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9972 RTE_ETH_FILTER_SET, &info);
9974 printf("Cannot set global hash configurations by port %d\n",
9977 printf("Global hash configurations have been set "
9978 "succcessfully by port %d\n", res->port_id);
9981 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9982 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9983 set_hash_global_config, "set_hash_global_config");
9984 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9985 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9987 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9988 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9989 hash_func, "toeplitz#simple_xor#default");
9990 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9991 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9993 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9994 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9995 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9996 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9997 enable, "enable#disable");
9999 cmdline_parse_inst_t cmd_set_hash_global_config = {
10000 .f = cmd_set_hash_global_config_parsed,
10002 .help_str = "set_hash_global_config <port_id> "
10003 "toeplitz|simple_xor|default "
10004 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10005 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
10006 "l2_payload enable|disable",
10008 (void *)&cmd_set_hash_global_config_all,
10009 (void *)&cmd_set_hash_global_config_port_id,
10010 (void *)&cmd_set_hash_global_config_hash_func,
10011 (void *)&cmd_set_hash_global_config_flow_type,
10012 (void *)&cmd_set_hash_global_config_enable,
10017 /* Set hash input set */
10018 struct cmd_set_hash_input_set_result {
10019 cmdline_fixed_string_t set_hash_input_set;
10021 cmdline_fixed_string_t flow_type;
10022 cmdline_fixed_string_t inset_field;
10023 cmdline_fixed_string_t select;
10026 static enum rte_eth_input_set_field
10027 str2inset(char *string)
10031 static const struct {
10033 enum rte_eth_input_set_field inset;
10034 } inset_table[] = {
10035 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10036 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10037 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10038 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10039 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10040 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10041 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10042 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10043 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10044 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10045 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10046 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10047 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10048 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10049 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10050 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10051 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10052 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10053 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10054 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10055 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10056 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10057 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10058 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10059 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10060 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10061 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10062 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10063 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10064 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10065 {"none", RTE_ETH_INPUT_SET_NONE},
10068 for (i = 0; i < RTE_DIM(inset_table); i++) {
10069 if (!strcmp(string, inset_table[i].str))
10070 return inset_table[i].inset;
10073 return RTE_ETH_INPUT_SET_UNKNOWN;
10077 cmd_set_hash_input_set_parsed(void *parsed_result,
10078 __rte_unused struct cmdline *cl,
10079 __rte_unused void *data)
10081 struct cmd_set_hash_input_set_result *res = parsed_result;
10082 struct rte_eth_hash_filter_info info;
10084 memset(&info, 0, sizeof(info));
10085 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10086 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10087 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10088 info.info.input_set_conf.inset_size = 1;
10089 if (!strcmp(res->select, "select"))
10090 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10091 else if (!strcmp(res->select, "add"))
10092 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10093 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10094 RTE_ETH_FILTER_SET, &info);
10097 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10098 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10099 set_hash_input_set, "set_hash_input_set");
10100 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10101 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10103 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10104 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10106 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10107 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10108 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10109 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10111 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10112 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10113 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10114 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10115 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10117 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10118 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10119 select, "select#add");
10121 cmdline_parse_inst_t cmd_set_hash_input_set = {
10122 .f = cmd_set_hash_input_set_parsed,
10124 .help_str = "set_hash_input_set <port_id> "
10125 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10126 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10127 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10128 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10129 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10130 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10131 "fld-7th|fld-8th|none select|add",
10133 (void *)&cmd_set_hash_input_set_cmd,
10134 (void *)&cmd_set_hash_input_set_port_id,
10135 (void *)&cmd_set_hash_input_set_flow_type,
10136 (void *)&cmd_set_hash_input_set_field,
10137 (void *)&cmd_set_hash_input_set_select,
10142 /* Set flow director input set */
10143 struct cmd_set_fdir_input_set_result {
10144 cmdline_fixed_string_t set_fdir_input_set;
10146 cmdline_fixed_string_t flow_type;
10147 cmdline_fixed_string_t inset_field;
10148 cmdline_fixed_string_t select;
10152 cmd_set_fdir_input_set_parsed(void *parsed_result,
10153 __rte_unused struct cmdline *cl,
10154 __rte_unused void *data)
10156 struct cmd_set_fdir_input_set_result *res = parsed_result;
10157 struct rte_eth_fdir_filter_info info;
10159 memset(&info, 0, sizeof(info));
10160 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10161 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10162 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10163 info.info.input_set_conf.inset_size = 1;
10164 if (!strcmp(res->select, "select"))
10165 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10166 else if (!strcmp(res->select, "add"))
10167 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10168 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10169 RTE_ETH_FILTER_SET, &info);
10172 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10173 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10174 set_fdir_input_set, "set_fdir_input_set");
10175 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10176 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10178 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10179 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10181 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10182 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10183 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10184 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10186 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10187 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10188 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10189 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10190 "sctp-veri-tag#none");
10191 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10192 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10193 select, "select#add");
10195 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10196 .f = cmd_set_fdir_input_set_parsed,
10198 .help_str = "set_fdir_input_set <port_id> "
10199 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10200 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10201 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10202 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10203 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10204 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10205 "sctp-veri-tag|none select|add",
10207 (void *)&cmd_set_fdir_input_set_cmd,
10208 (void *)&cmd_set_fdir_input_set_port_id,
10209 (void *)&cmd_set_fdir_input_set_flow_type,
10210 (void *)&cmd_set_fdir_input_set_field,
10211 (void *)&cmd_set_fdir_input_set_select,
10216 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10217 struct cmd_mcast_addr_result {
10218 cmdline_fixed_string_t mcast_addr_cmd;
10219 cmdline_fixed_string_t what;
10221 struct ether_addr mc_addr;
10224 static void cmd_mcast_addr_parsed(void *parsed_result,
10225 __attribute__((unused)) struct cmdline *cl,
10226 __attribute__((unused)) void *data)
10228 struct cmd_mcast_addr_result *res = parsed_result;
10230 if (!is_multicast_ether_addr(&res->mc_addr)) {
10231 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10232 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10233 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10234 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10237 if (strcmp(res->what, "add") == 0)
10238 mcast_addr_add(res->port_num, &res->mc_addr);
10240 mcast_addr_remove(res->port_num, &res->mc_addr);
10243 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10244 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10245 mcast_addr_cmd, "mcast_addr");
10246 cmdline_parse_token_string_t cmd_mcast_addr_what =
10247 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10249 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10250 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10251 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10252 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10254 cmdline_parse_inst_t cmd_mcast_addr = {
10255 .f = cmd_mcast_addr_parsed,
10257 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10258 "Add/Remove multicast MAC address on port_id",
10260 (void *)&cmd_mcast_addr_cmd,
10261 (void *)&cmd_mcast_addr_what,
10262 (void *)&cmd_mcast_addr_portnum,
10263 (void *)&cmd_mcast_addr_addr,
10268 /* l2 tunnel config
10269 * only support E-tag now.
10272 /* Ether type config */
10273 struct cmd_config_l2_tunnel_eth_type_result {
10274 cmdline_fixed_string_t port;
10275 cmdline_fixed_string_t config;
10276 cmdline_fixed_string_t all;
10278 cmdline_fixed_string_t l2_tunnel;
10279 cmdline_fixed_string_t l2_tunnel_type;
10280 cmdline_fixed_string_t eth_type;
10281 uint16_t eth_type_val;
10284 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10285 TOKEN_STRING_INITIALIZER
10286 (struct cmd_config_l2_tunnel_eth_type_result,
10288 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10289 TOKEN_STRING_INITIALIZER
10290 (struct cmd_config_l2_tunnel_eth_type_result,
10292 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10293 TOKEN_STRING_INITIALIZER
10294 (struct cmd_config_l2_tunnel_eth_type_result,
10296 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10297 TOKEN_NUM_INITIALIZER
10298 (struct cmd_config_l2_tunnel_eth_type_result,
10300 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10301 TOKEN_STRING_INITIALIZER
10302 (struct cmd_config_l2_tunnel_eth_type_result,
10303 l2_tunnel, "l2-tunnel");
10304 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10305 TOKEN_STRING_INITIALIZER
10306 (struct cmd_config_l2_tunnel_eth_type_result,
10307 l2_tunnel_type, "E-tag");
10308 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10309 TOKEN_STRING_INITIALIZER
10310 (struct cmd_config_l2_tunnel_eth_type_result,
10311 eth_type, "ether-type");
10312 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10313 TOKEN_NUM_INITIALIZER
10314 (struct cmd_config_l2_tunnel_eth_type_result,
10315 eth_type_val, UINT16);
10317 static enum rte_eth_tunnel_type
10318 str2fdir_l2_tunnel_type(char *string)
10322 static const struct {
10324 enum rte_eth_tunnel_type type;
10325 } l2_tunnel_type_str[] = {
10326 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10329 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10330 if (!strcmp(l2_tunnel_type_str[i].str, string))
10331 return l2_tunnel_type_str[i].type;
10333 return RTE_TUNNEL_TYPE_NONE;
10336 /* ether type config for all ports */
10338 cmd_config_l2_tunnel_eth_type_all_parsed
10339 (void *parsed_result,
10340 __attribute__((unused)) struct cmdline *cl,
10341 __attribute__((unused)) void *data)
10343 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10344 struct rte_eth_l2_tunnel_conf entry;
10347 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10348 entry.ether_type = res->eth_type_val;
10350 FOREACH_PORT(pid, ports) {
10351 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10355 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10356 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10358 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10360 (void *)&cmd_config_l2_tunnel_eth_type_port,
10361 (void *)&cmd_config_l2_tunnel_eth_type_config,
10362 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10363 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10364 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10365 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10366 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10371 /* ether type config for a specific port */
10373 cmd_config_l2_tunnel_eth_type_specific_parsed(
10374 void *parsed_result,
10375 __attribute__((unused)) struct cmdline *cl,
10376 __attribute__((unused)) void *data)
10378 struct cmd_config_l2_tunnel_eth_type_result *res =
10380 struct rte_eth_l2_tunnel_conf entry;
10382 if (port_id_is_invalid(res->id, ENABLED_WARN))
10385 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10386 entry.ether_type = res->eth_type_val;
10388 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10391 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10392 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10394 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10396 (void *)&cmd_config_l2_tunnel_eth_type_port,
10397 (void *)&cmd_config_l2_tunnel_eth_type_config,
10398 (void *)&cmd_config_l2_tunnel_eth_type_id,
10399 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10400 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10401 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10402 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10407 /* Enable/disable l2 tunnel */
10408 struct cmd_config_l2_tunnel_en_dis_result {
10409 cmdline_fixed_string_t port;
10410 cmdline_fixed_string_t config;
10411 cmdline_fixed_string_t all;
10413 cmdline_fixed_string_t l2_tunnel;
10414 cmdline_fixed_string_t l2_tunnel_type;
10415 cmdline_fixed_string_t en_dis;
10418 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10419 TOKEN_STRING_INITIALIZER
10420 (struct cmd_config_l2_tunnel_en_dis_result,
10422 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10423 TOKEN_STRING_INITIALIZER
10424 (struct cmd_config_l2_tunnel_en_dis_result,
10426 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10427 TOKEN_STRING_INITIALIZER
10428 (struct cmd_config_l2_tunnel_en_dis_result,
10430 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10431 TOKEN_NUM_INITIALIZER
10432 (struct cmd_config_l2_tunnel_en_dis_result,
10434 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10435 TOKEN_STRING_INITIALIZER
10436 (struct cmd_config_l2_tunnel_en_dis_result,
10437 l2_tunnel, "l2-tunnel");
10438 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10439 TOKEN_STRING_INITIALIZER
10440 (struct cmd_config_l2_tunnel_en_dis_result,
10441 l2_tunnel_type, "E-tag");
10442 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10443 TOKEN_STRING_INITIALIZER
10444 (struct cmd_config_l2_tunnel_en_dis_result,
10445 en_dis, "enable#disable");
10447 /* enable/disable l2 tunnel for all ports */
10449 cmd_config_l2_tunnel_en_dis_all_parsed(
10450 void *parsed_result,
10451 __attribute__((unused)) struct cmdline *cl,
10452 __attribute__((unused)) void *data)
10454 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10455 struct rte_eth_l2_tunnel_conf entry;
10459 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10461 if (!strcmp("enable", res->en_dis))
10466 FOREACH_PORT(pid, ports) {
10467 rte_eth_dev_l2_tunnel_offload_set(pid,
10469 ETH_L2_TUNNEL_ENABLE_MASK,
10474 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10475 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10477 .help_str = "port config all l2-tunnel E-tag enable|disable",
10479 (void *)&cmd_config_l2_tunnel_en_dis_port,
10480 (void *)&cmd_config_l2_tunnel_en_dis_config,
10481 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10482 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10483 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10484 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10489 /* enable/disable l2 tunnel for a port */
10491 cmd_config_l2_tunnel_en_dis_specific_parsed(
10492 void *parsed_result,
10493 __attribute__((unused)) struct cmdline *cl,
10494 __attribute__((unused)) void *data)
10496 struct cmd_config_l2_tunnel_en_dis_result *res =
10498 struct rte_eth_l2_tunnel_conf entry;
10500 if (port_id_is_invalid(res->id, ENABLED_WARN))
10503 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10505 if (!strcmp("enable", res->en_dis))
10506 rte_eth_dev_l2_tunnel_offload_set(res->id,
10508 ETH_L2_TUNNEL_ENABLE_MASK,
10511 rte_eth_dev_l2_tunnel_offload_set(res->id,
10513 ETH_L2_TUNNEL_ENABLE_MASK,
10517 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10518 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10520 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10522 (void *)&cmd_config_l2_tunnel_en_dis_port,
10523 (void *)&cmd_config_l2_tunnel_en_dis_config,
10524 (void *)&cmd_config_l2_tunnel_en_dis_id,
10525 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10526 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10527 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10532 /* E-tag configuration */
10534 /* Common result structure for all E-tag configuration */
10535 struct cmd_config_e_tag_result {
10536 cmdline_fixed_string_t e_tag;
10537 cmdline_fixed_string_t set;
10538 cmdline_fixed_string_t insertion;
10539 cmdline_fixed_string_t stripping;
10540 cmdline_fixed_string_t forwarding;
10541 cmdline_fixed_string_t filter;
10542 cmdline_fixed_string_t add;
10543 cmdline_fixed_string_t del;
10544 cmdline_fixed_string_t on;
10545 cmdline_fixed_string_t off;
10546 cmdline_fixed_string_t on_off;
10547 cmdline_fixed_string_t port_tag_id;
10548 uint32_t port_tag_id_val;
10549 cmdline_fixed_string_t e_tag_id;
10550 uint16_t e_tag_id_val;
10551 cmdline_fixed_string_t dst_pool;
10552 uint8_t dst_pool_val;
10553 cmdline_fixed_string_t port;
10555 cmdline_fixed_string_t vf;
10559 /* Common CLI fields for all E-tag configuration */
10560 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10561 TOKEN_STRING_INITIALIZER
10562 (struct cmd_config_e_tag_result,
10564 cmdline_parse_token_string_t cmd_config_e_tag_set =
10565 TOKEN_STRING_INITIALIZER
10566 (struct cmd_config_e_tag_result,
10568 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10569 TOKEN_STRING_INITIALIZER
10570 (struct cmd_config_e_tag_result,
10571 insertion, "insertion");
10572 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10573 TOKEN_STRING_INITIALIZER
10574 (struct cmd_config_e_tag_result,
10575 stripping, "stripping");
10576 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10577 TOKEN_STRING_INITIALIZER
10578 (struct cmd_config_e_tag_result,
10579 forwarding, "forwarding");
10580 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10581 TOKEN_STRING_INITIALIZER
10582 (struct cmd_config_e_tag_result,
10584 cmdline_parse_token_string_t cmd_config_e_tag_add =
10585 TOKEN_STRING_INITIALIZER
10586 (struct cmd_config_e_tag_result,
10588 cmdline_parse_token_string_t cmd_config_e_tag_del =
10589 TOKEN_STRING_INITIALIZER
10590 (struct cmd_config_e_tag_result,
10592 cmdline_parse_token_string_t cmd_config_e_tag_on =
10593 TOKEN_STRING_INITIALIZER
10594 (struct cmd_config_e_tag_result,
10596 cmdline_parse_token_string_t cmd_config_e_tag_off =
10597 TOKEN_STRING_INITIALIZER
10598 (struct cmd_config_e_tag_result,
10600 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10601 TOKEN_STRING_INITIALIZER
10602 (struct cmd_config_e_tag_result,
10604 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10605 TOKEN_STRING_INITIALIZER
10606 (struct cmd_config_e_tag_result,
10607 port_tag_id, "port-tag-id");
10608 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10609 TOKEN_NUM_INITIALIZER
10610 (struct cmd_config_e_tag_result,
10611 port_tag_id_val, UINT32);
10612 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10613 TOKEN_STRING_INITIALIZER
10614 (struct cmd_config_e_tag_result,
10615 e_tag_id, "e-tag-id");
10616 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10617 TOKEN_NUM_INITIALIZER
10618 (struct cmd_config_e_tag_result,
10619 e_tag_id_val, UINT16);
10620 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10621 TOKEN_STRING_INITIALIZER
10622 (struct cmd_config_e_tag_result,
10623 dst_pool, "dst-pool");
10624 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10625 TOKEN_NUM_INITIALIZER
10626 (struct cmd_config_e_tag_result,
10627 dst_pool_val, UINT8);
10628 cmdline_parse_token_string_t cmd_config_e_tag_port =
10629 TOKEN_STRING_INITIALIZER
10630 (struct cmd_config_e_tag_result,
10632 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10633 TOKEN_NUM_INITIALIZER
10634 (struct cmd_config_e_tag_result,
10636 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10637 TOKEN_STRING_INITIALIZER
10638 (struct cmd_config_e_tag_result,
10640 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10641 TOKEN_NUM_INITIALIZER
10642 (struct cmd_config_e_tag_result,
10645 /* E-tag insertion configuration */
10647 cmd_config_e_tag_insertion_en_parsed(
10648 void *parsed_result,
10649 __attribute__((unused)) struct cmdline *cl,
10650 __attribute__((unused)) void *data)
10652 struct cmd_config_e_tag_result *res =
10654 struct rte_eth_l2_tunnel_conf entry;
10656 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10659 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10660 entry.tunnel_id = res->port_tag_id_val;
10661 entry.vf_id = res->vf_id;
10662 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10664 ETH_L2_TUNNEL_INSERTION_MASK,
10669 cmd_config_e_tag_insertion_dis_parsed(
10670 void *parsed_result,
10671 __attribute__((unused)) struct cmdline *cl,
10672 __attribute__((unused)) void *data)
10674 struct cmd_config_e_tag_result *res =
10676 struct rte_eth_l2_tunnel_conf entry;
10678 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10681 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10682 entry.vf_id = res->vf_id;
10684 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10686 ETH_L2_TUNNEL_INSERTION_MASK,
10690 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10691 .f = cmd_config_e_tag_insertion_en_parsed,
10693 .help_str = "E-tag ... : E-tag insertion enable",
10695 (void *)&cmd_config_e_tag_e_tag,
10696 (void *)&cmd_config_e_tag_set,
10697 (void *)&cmd_config_e_tag_insertion,
10698 (void *)&cmd_config_e_tag_on,
10699 (void *)&cmd_config_e_tag_port_tag_id,
10700 (void *)&cmd_config_e_tag_port_tag_id_val,
10701 (void *)&cmd_config_e_tag_port,
10702 (void *)&cmd_config_e_tag_port_id,
10703 (void *)&cmd_config_e_tag_vf,
10704 (void *)&cmd_config_e_tag_vf_id,
10709 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10710 .f = cmd_config_e_tag_insertion_dis_parsed,
10712 .help_str = "E-tag ... : E-tag insertion disable",
10714 (void *)&cmd_config_e_tag_e_tag,
10715 (void *)&cmd_config_e_tag_set,
10716 (void *)&cmd_config_e_tag_insertion,
10717 (void *)&cmd_config_e_tag_off,
10718 (void *)&cmd_config_e_tag_port,
10719 (void *)&cmd_config_e_tag_port_id,
10720 (void *)&cmd_config_e_tag_vf,
10721 (void *)&cmd_config_e_tag_vf_id,
10726 /* E-tag stripping configuration */
10728 cmd_config_e_tag_stripping_parsed(
10729 void *parsed_result,
10730 __attribute__((unused)) struct cmdline *cl,
10731 __attribute__((unused)) void *data)
10733 struct cmd_config_e_tag_result *res =
10735 struct rte_eth_l2_tunnel_conf entry;
10737 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10740 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10742 if (!strcmp(res->on_off, "on"))
10743 rte_eth_dev_l2_tunnel_offload_set
10746 ETH_L2_TUNNEL_STRIPPING_MASK,
10749 rte_eth_dev_l2_tunnel_offload_set
10752 ETH_L2_TUNNEL_STRIPPING_MASK,
10756 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10757 .f = cmd_config_e_tag_stripping_parsed,
10759 .help_str = "E-tag ... : E-tag stripping enable/disable",
10761 (void *)&cmd_config_e_tag_e_tag,
10762 (void *)&cmd_config_e_tag_set,
10763 (void *)&cmd_config_e_tag_stripping,
10764 (void *)&cmd_config_e_tag_on_off,
10765 (void *)&cmd_config_e_tag_port,
10766 (void *)&cmd_config_e_tag_port_id,
10771 /* E-tag forwarding configuration */
10773 cmd_config_e_tag_forwarding_parsed(
10774 void *parsed_result,
10775 __attribute__((unused)) struct cmdline *cl,
10776 __attribute__((unused)) void *data)
10778 struct cmd_config_e_tag_result *res = parsed_result;
10779 struct rte_eth_l2_tunnel_conf entry;
10781 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10784 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10786 if (!strcmp(res->on_off, "on"))
10787 rte_eth_dev_l2_tunnel_offload_set
10790 ETH_L2_TUNNEL_FORWARDING_MASK,
10793 rte_eth_dev_l2_tunnel_offload_set
10796 ETH_L2_TUNNEL_FORWARDING_MASK,
10800 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10801 .f = cmd_config_e_tag_forwarding_parsed,
10803 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10805 (void *)&cmd_config_e_tag_e_tag,
10806 (void *)&cmd_config_e_tag_set,
10807 (void *)&cmd_config_e_tag_forwarding,
10808 (void *)&cmd_config_e_tag_on_off,
10809 (void *)&cmd_config_e_tag_port,
10810 (void *)&cmd_config_e_tag_port_id,
10815 /* E-tag filter configuration */
10817 cmd_config_e_tag_filter_add_parsed(
10818 void *parsed_result,
10819 __attribute__((unused)) struct cmdline *cl,
10820 __attribute__((unused)) void *data)
10822 struct cmd_config_e_tag_result *res = parsed_result;
10823 struct rte_eth_l2_tunnel_conf entry;
10826 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10829 if (res->e_tag_id_val > 0x3fff) {
10830 printf("e-tag-id must be equal or less than 0x3fff.\n");
10834 ret = rte_eth_dev_filter_supported(res->port_id,
10835 RTE_ETH_FILTER_L2_TUNNEL);
10837 printf("E-tag filter is not supported on port %u.\n",
10842 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10843 entry.tunnel_id = res->e_tag_id_val;
10844 entry.pool = res->dst_pool_val;
10846 ret = rte_eth_dev_filter_ctrl(res->port_id,
10847 RTE_ETH_FILTER_L2_TUNNEL,
10848 RTE_ETH_FILTER_ADD,
10851 printf("E-tag filter programming error: (%s)\n",
10855 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10856 .f = cmd_config_e_tag_filter_add_parsed,
10858 .help_str = "E-tag ... : E-tag filter add",
10860 (void *)&cmd_config_e_tag_e_tag,
10861 (void *)&cmd_config_e_tag_set,
10862 (void *)&cmd_config_e_tag_filter,
10863 (void *)&cmd_config_e_tag_add,
10864 (void *)&cmd_config_e_tag_e_tag_id,
10865 (void *)&cmd_config_e_tag_e_tag_id_val,
10866 (void *)&cmd_config_e_tag_dst_pool,
10867 (void *)&cmd_config_e_tag_dst_pool_val,
10868 (void *)&cmd_config_e_tag_port,
10869 (void *)&cmd_config_e_tag_port_id,
10875 cmd_config_e_tag_filter_del_parsed(
10876 void *parsed_result,
10877 __attribute__((unused)) struct cmdline *cl,
10878 __attribute__((unused)) void *data)
10880 struct cmd_config_e_tag_result *res = parsed_result;
10881 struct rte_eth_l2_tunnel_conf entry;
10884 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10887 if (res->e_tag_id_val > 0x3fff) {
10888 printf("e-tag-id must be less than 0x3fff.\n");
10892 ret = rte_eth_dev_filter_supported(res->port_id,
10893 RTE_ETH_FILTER_L2_TUNNEL);
10895 printf("E-tag filter is not supported on port %u.\n",
10900 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10901 entry.tunnel_id = res->e_tag_id_val;
10903 ret = rte_eth_dev_filter_ctrl(res->port_id,
10904 RTE_ETH_FILTER_L2_TUNNEL,
10905 RTE_ETH_FILTER_DELETE,
10908 printf("E-tag filter programming error: (%s)\n",
10912 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10913 .f = cmd_config_e_tag_filter_del_parsed,
10915 .help_str = "E-tag ... : E-tag filter delete",
10917 (void *)&cmd_config_e_tag_e_tag,
10918 (void *)&cmd_config_e_tag_set,
10919 (void *)&cmd_config_e_tag_filter,
10920 (void *)&cmd_config_e_tag_del,
10921 (void *)&cmd_config_e_tag_e_tag_id,
10922 (void *)&cmd_config_e_tag_e_tag_id_val,
10923 (void *)&cmd_config_e_tag_port,
10924 (void *)&cmd_config_e_tag_port_id,
10929 /* vf vlan anti spoof configuration */
10931 /* Common result structure for vf vlan anti spoof */
10932 struct cmd_vf_vlan_anti_spoof_result {
10933 cmdline_fixed_string_t set;
10934 cmdline_fixed_string_t vf;
10935 cmdline_fixed_string_t vlan;
10936 cmdline_fixed_string_t antispoof;
10939 cmdline_fixed_string_t on_off;
10942 /* Common CLI fields for vf vlan anti spoof enable disable */
10943 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10944 TOKEN_STRING_INITIALIZER
10945 (struct cmd_vf_vlan_anti_spoof_result,
10947 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10948 TOKEN_STRING_INITIALIZER
10949 (struct cmd_vf_vlan_anti_spoof_result,
10951 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10952 TOKEN_STRING_INITIALIZER
10953 (struct cmd_vf_vlan_anti_spoof_result,
10955 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10956 TOKEN_STRING_INITIALIZER
10957 (struct cmd_vf_vlan_anti_spoof_result,
10958 antispoof, "antispoof");
10959 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10960 TOKEN_NUM_INITIALIZER
10961 (struct cmd_vf_vlan_anti_spoof_result,
10963 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10964 TOKEN_NUM_INITIALIZER
10965 (struct cmd_vf_vlan_anti_spoof_result,
10967 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10968 TOKEN_STRING_INITIALIZER
10969 (struct cmd_vf_vlan_anti_spoof_result,
10973 cmd_set_vf_vlan_anti_spoof_parsed(
10974 void *parsed_result,
10975 __attribute__((unused)) struct cmdline *cl,
10976 __attribute__((unused)) void *data)
10978 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10979 int ret = -ENOTSUP;
10981 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10983 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10986 #ifdef RTE_LIBRTE_IXGBE_PMD
10987 if (ret == -ENOTSUP)
10988 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10989 res->vf_id, is_on);
10991 #ifdef RTE_LIBRTE_I40E_PMD
10992 if (ret == -ENOTSUP)
10993 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10994 res->vf_id, is_on);
11001 printf("invalid vf_id %d\n", res->vf_id);
11004 printf("invalid port_id %d\n", res->port_id);
11007 printf("function not implemented\n");
11010 printf("programming error: (%s)\n", strerror(-ret));
11014 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11015 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11017 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11019 (void *)&cmd_vf_vlan_anti_spoof_set,
11020 (void *)&cmd_vf_vlan_anti_spoof_vf,
11021 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11022 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11023 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11024 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11025 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11030 /* vf mac anti spoof configuration */
11032 /* Common result structure for vf mac anti spoof */
11033 struct cmd_vf_mac_anti_spoof_result {
11034 cmdline_fixed_string_t set;
11035 cmdline_fixed_string_t vf;
11036 cmdline_fixed_string_t mac;
11037 cmdline_fixed_string_t antispoof;
11040 cmdline_fixed_string_t on_off;
11043 /* Common CLI fields for vf mac anti spoof enable disable */
11044 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11045 TOKEN_STRING_INITIALIZER
11046 (struct cmd_vf_mac_anti_spoof_result,
11048 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11049 TOKEN_STRING_INITIALIZER
11050 (struct cmd_vf_mac_anti_spoof_result,
11052 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11053 TOKEN_STRING_INITIALIZER
11054 (struct cmd_vf_mac_anti_spoof_result,
11056 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11057 TOKEN_STRING_INITIALIZER
11058 (struct cmd_vf_mac_anti_spoof_result,
11059 antispoof, "antispoof");
11060 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11061 TOKEN_NUM_INITIALIZER
11062 (struct cmd_vf_mac_anti_spoof_result,
11064 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11065 TOKEN_NUM_INITIALIZER
11066 (struct cmd_vf_mac_anti_spoof_result,
11068 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11069 TOKEN_STRING_INITIALIZER
11070 (struct cmd_vf_mac_anti_spoof_result,
11074 cmd_set_vf_mac_anti_spoof_parsed(
11075 void *parsed_result,
11076 __attribute__((unused)) struct cmdline *cl,
11077 __attribute__((unused)) void *data)
11079 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11080 int ret = -ENOTSUP;
11082 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11084 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11087 #ifdef RTE_LIBRTE_IXGBE_PMD
11088 if (ret == -ENOTSUP)
11089 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11090 res->vf_id, is_on);
11092 #ifdef RTE_LIBRTE_I40E_PMD
11093 if (ret == -ENOTSUP)
11094 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11095 res->vf_id, is_on);
11102 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11105 printf("invalid port_id %d\n", res->port_id);
11108 printf("function not implemented\n");
11111 printf("programming error: (%s)\n", strerror(-ret));
11115 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11116 .f = cmd_set_vf_mac_anti_spoof_parsed,
11118 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11120 (void *)&cmd_vf_mac_anti_spoof_set,
11121 (void *)&cmd_vf_mac_anti_spoof_vf,
11122 (void *)&cmd_vf_mac_anti_spoof_mac,
11123 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11124 (void *)&cmd_vf_mac_anti_spoof_port_id,
11125 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11126 (void *)&cmd_vf_mac_anti_spoof_on_off,
11131 /* vf vlan strip queue configuration */
11133 /* Common result structure for vf mac anti spoof */
11134 struct cmd_vf_vlan_stripq_result {
11135 cmdline_fixed_string_t set;
11136 cmdline_fixed_string_t vf;
11137 cmdline_fixed_string_t vlan;
11138 cmdline_fixed_string_t stripq;
11141 cmdline_fixed_string_t on_off;
11144 /* Common CLI fields for vf vlan strip enable disable */
11145 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11146 TOKEN_STRING_INITIALIZER
11147 (struct cmd_vf_vlan_stripq_result,
11149 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11150 TOKEN_STRING_INITIALIZER
11151 (struct cmd_vf_vlan_stripq_result,
11153 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11154 TOKEN_STRING_INITIALIZER
11155 (struct cmd_vf_vlan_stripq_result,
11157 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11158 TOKEN_STRING_INITIALIZER
11159 (struct cmd_vf_vlan_stripq_result,
11161 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11162 TOKEN_NUM_INITIALIZER
11163 (struct cmd_vf_vlan_stripq_result,
11165 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11166 TOKEN_NUM_INITIALIZER
11167 (struct cmd_vf_vlan_stripq_result,
11169 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11170 TOKEN_STRING_INITIALIZER
11171 (struct cmd_vf_vlan_stripq_result,
11175 cmd_set_vf_vlan_stripq_parsed(
11176 void *parsed_result,
11177 __attribute__((unused)) struct cmdline *cl,
11178 __attribute__((unused)) void *data)
11180 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11181 int ret = -ENOTSUP;
11183 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11185 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11188 #ifdef RTE_LIBRTE_IXGBE_PMD
11189 if (ret == -ENOTSUP)
11190 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11191 res->vf_id, is_on);
11193 #ifdef RTE_LIBRTE_I40E_PMD
11194 if (ret == -ENOTSUP)
11195 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11196 res->vf_id, is_on);
11203 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11206 printf("invalid port_id %d\n", res->port_id);
11209 printf("function not implemented\n");
11212 printf("programming error: (%s)\n", strerror(-ret));
11216 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11217 .f = cmd_set_vf_vlan_stripq_parsed,
11219 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11221 (void *)&cmd_vf_vlan_stripq_set,
11222 (void *)&cmd_vf_vlan_stripq_vf,
11223 (void *)&cmd_vf_vlan_stripq_vlan,
11224 (void *)&cmd_vf_vlan_stripq_stripq,
11225 (void *)&cmd_vf_vlan_stripq_port_id,
11226 (void *)&cmd_vf_vlan_stripq_vf_id,
11227 (void *)&cmd_vf_vlan_stripq_on_off,
11232 /* vf vlan insert configuration */
11234 /* Common result structure for vf vlan insert */
11235 struct cmd_vf_vlan_insert_result {
11236 cmdline_fixed_string_t set;
11237 cmdline_fixed_string_t vf;
11238 cmdline_fixed_string_t vlan;
11239 cmdline_fixed_string_t insert;
11245 /* Common CLI fields for vf vlan insert enable disable */
11246 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11247 TOKEN_STRING_INITIALIZER
11248 (struct cmd_vf_vlan_insert_result,
11250 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11251 TOKEN_STRING_INITIALIZER
11252 (struct cmd_vf_vlan_insert_result,
11254 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11255 TOKEN_STRING_INITIALIZER
11256 (struct cmd_vf_vlan_insert_result,
11258 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11259 TOKEN_STRING_INITIALIZER
11260 (struct cmd_vf_vlan_insert_result,
11262 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11263 TOKEN_NUM_INITIALIZER
11264 (struct cmd_vf_vlan_insert_result,
11266 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11267 TOKEN_NUM_INITIALIZER
11268 (struct cmd_vf_vlan_insert_result,
11270 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11271 TOKEN_NUM_INITIALIZER
11272 (struct cmd_vf_vlan_insert_result,
11276 cmd_set_vf_vlan_insert_parsed(
11277 void *parsed_result,
11278 __attribute__((unused)) struct cmdline *cl,
11279 __attribute__((unused)) void *data)
11281 struct cmd_vf_vlan_insert_result *res = parsed_result;
11282 int ret = -ENOTSUP;
11284 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11287 #ifdef RTE_LIBRTE_IXGBE_PMD
11288 if (ret == -ENOTSUP)
11289 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11292 #ifdef RTE_LIBRTE_I40E_PMD
11293 if (ret == -ENOTSUP)
11294 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11302 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11305 printf("invalid port_id %d\n", res->port_id);
11308 printf("function not implemented\n");
11311 printf("programming error: (%s)\n", strerror(-ret));
11315 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11316 .f = cmd_set_vf_vlan_insert_parsed,
11318 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11320 (void *)&cmd_vf_vlan_insert_set,
11321 (void *)&cmd_vf_vlan_insert_vf,
11322 (void *)&cmd_vf_vlan_insert_vlan,
11323 (void *)&cmd_vf_vlan_insert_insert,
11324 (void *)&cmd_vf_vlan_insert_port_id,
11325 (void *)&cmd_vf_vlan_insert_vf_id,
11326 (void *)&cmd_vf_vlan_insert_vlan_id,
11331 /* tx loopback configuration */
11333 /* Common result structure for tx loopback */
11334 struct cmd_tx_loopback_result {
11335 cmdline_fixed_string_t set;
11336 cmdline_fixed_string_t tx;
11337 cmdline_fixed_string_t loopback;
11339 cmdline_fixed_string_t on_off;
11342 /* Common CLI fields for tx loopback enable disable */
11343 cmdline_parse_token_string_t cmd_tx_loopback_set =
11344 TOKEN_STRING_INITIALIZER
11345 (struct cmd_tx_loopback_result,
11347 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11348 TOKEN_STRING_INITIALIZER
11349 (struct cmd_tx_loopback_result,
11351 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11352 TOKEN_STRING_INITIALIZER
11353 (struct cmd_tx_loopback_result,
11354 loopback, "loopback");
11355 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11356 TOKEN_NUM_INITIALIZER
11357 (struct cmd_tx_loopback_result,
11359 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11360 TOKEN_STRING_INITIALIZER
11361 (struct cmd_tx_loopback_result,
11365 cmd_set_tx_loopback_parsed(
11366 void *parsed_result,
11367 __attribute__((unused)) struct cmdline *cl,
11368 __attribute__((unused)) void *data)
11370 struct cmd_tx_loopback_result *res = parsed_result;
11371 int ret = -ENOTSUP;
11373 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11375 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11378 #ifdef RTE_LIBRTE_IXGBE_PMD
11379 if (ret == -ENOTSUP)
11380 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11382 #ifdef RTE_LIBRTE_I40E_PMD
11383 if (ret == -ENOTSUP)
11384 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11391 printf("invalid is_on %d\n", is_on);
11394 printf("invalid port_id %d\n", res->port_id);
11397 printf("function not implemented\n");
11400 printf("programming error: (%s)\n", strerror(-ret));
11404 cmdline_parse_inst_t cmd_set_tx_loopback = {
11405 .f = cmd_set_tx_loopback_parsed,
11407 .help_str = "set tx loopback <port_id> on|off",
11409 (void *)&cmd_tx_loopback_set,
11410 (void *)&cmd_tx_loopback_tx,
11411 (void *)&cmd_tx_loopback_loopback,
11412 (void *)&cmd_tx_loopback_port_id,
11413 (void *)&cmd_tx_loopback_on_off,
11418 #ifdef RTE_LIBRTE_IXGBE_PMD
11419 /* all queues drop enable configuration */
11421 /* Common result structure for all queues drop enable */
11422 struct cmd_all_queues_drop_en_result {
11423 cmdline_fixed_string_t set;
11424 cmdline_fixed_string_t all;
11425 cmdline_fixed_string_t queues;
11426 cmdline_fixed_string_t drop;
11428 cmdline_fixed_string_t on_off;
11431 /* Common CLI fields for tx loopback enable disable */
11432 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11433 TOKEN_STRING_INITIALIZER
11434 (struct cmd_all_queues_drop_en_result,
11436 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11437 TOKEN_STRING_INITIALIZER
11438 (struct cmd_all_queues_drop_en_result,
11440 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11441 TOKEN_STRING_INITIALIZER
11442 (struct cmd_all_queues_drop_en_result,
11444 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11445 TOKEN_STRING_INITIALIZER
11446 (struct cmd_all_queues_drop_en_result,
11448 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11449 TOKEN_NUM_INITIALIZER
11450 (struct cmd_all_queues_drop_en_result,
11452 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11453 TOKEN_STRING_INITIALIZER
11454 (struct cmd_all_queues_drop_en_result,
11458 cmd_set_all_queues_drop_en_parsed(
11459 void *parsed_result,
11460 __attribute__((unused)) struct cmdline *cl,
11461 __attribute__((unused)) void *data)
11463 struct cmd_all_queues_drop_en_result *res = parsed_result;
11465 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11467 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11470 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11475 printf("invalid is_on %d\n", is_on);
11478 printf("invalid port_id %d\n", res->port_id);
11481 printf("function not implemented\n");
11484 printf("programming error: (%s)\n", strerror(-ret));
11488 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11489 .f = cmd_set_all_queues_drop_en_parsed,
11491 .help_str = "set all queues drop <port_id> on|off",
11493 (void *)&cmd_all_queues_drop_en_set,
11494 (void *)&cmd_all_queues_drop_en_all,
11495 (void *)&cmd_all_queues_drop_en_queues,
11496 (void *)&cmd_all_queues_drop_en_drop,
11497 (void *)&cmd_all_queues_drop_en_port_id,
11498 (void *)&cmd_all_queues_drop_en_on_off,
11503 /* vf split drop enable configuration */
11505 /* Common result structure for vf split drop enable */
11506 struct cmd_vf_split_drop_en_result {
11507 cmdline_fixed_string_t set;
11508 cmdline_fixed_string_t vf;
11509 cmdline_fixed_string_t split;
11510 cmdline_fixed_string_t drop;
11513 cmdline_fixed_string_t on_off;
11516 /* Common CLI fields for vf split drop enable disable */
11517 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11518 TOKEN_STRING_INITIALIZER
11519 (struct cmd_vf_split_drop_en_result,
11521 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11522 TOKEN_STRING_INITIALIZER
11523 (struct cmd_vf_split_drop_en_result,
11525 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11526 TOKEN_STRING_INITIALIZER
11527 (struct cmd_vf_split_drop_en_result,
11529 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11530 TOKEN_STRING_INITIALIZER
11531 (struct cmd_vf_split_drop_en_result,
11533 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11534 TOKEN_NUM_INITIALIZER
11535 (struct cmd_vf_split_drop_en_result,
11537 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11538 TOKEN_NUM_INITIALIZER
11539 (struct cmd_vf_split_drop_en_result,
11541 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11542 TOKEN_STRING_INITIALIZER
11543 (struct cmd_vf_split_drop_en_result,
11547 cmd_set_vf_split_drop_en_parsed(
11548 void *parsed_result,
11549 __attribute__((unused)) struct cmdline *cl,
11550 __attribute__((unused)) void *data)
11552 struct cmd_vf_split_drop_en_result *res = parsed_result;
11554 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11556 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11559 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11565 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11568 printf("invalid port_id %d\n", res->port_id);
11571 printf("programming error: (%s)\n", strerror(-ret));
11575 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11576 .f = cmd_set_vf_split_drop_en_parsed,
11578 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11580 (void *)&cmd_vf_split_drop_en_set,
11581 (void *)&cmd_vf_split_drop_en_vf,
11582 (void *)&cmd_vf_split_drop_en_split,
11583 (void *)&cmd_vf_split_drop_en_drop,
11584 (void *)&cmd_vf_split_drop_en_port_id,
11585 (void *)&cmd_vf_split_drop_en_vf_id,
11586 (void *)&cmd_vf_split_drop_en_on_off,
11592 /* vf mac address configuration */
11594 /* Common result structure for vf mac address */
11595 struct cmd_set_vf_mac_addr_result {
11596 cmdline_fixed_string_t set;
11597 cmdline_fixed_string_t vf;
11598 cmdline_fixed_string_t mac;
11599 cmdline_fixed_string_t addr;
11602 struct ether_addr mac_addr;
11606 /* Common CLI fields for vf split drop enable disable */
11607 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11608 TOKEN_STRING_INITIALIZER
11609 (struct cmd_set_vf_mac_addr_result,
11611 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11612 TOKEN_STRING_INITIALIZER
11613 (struct cmd_set_vf_mac_addr_result,
11615 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11616 TOKEN_STRING_INITIALIZER
11617 (struct cmd_set_vf_mac_addr_result,
11619 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11620 TOKEN_STRING_INITIALIZER
11621 (struct cmd_set_vf_mac_addr_result,
11623 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11624 TOKEN_NUM_INITIALIZER
11625 (struct cmd_set_vf_mac_addr_result,
11627 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11628 TOKEN_NUM_INITIALIZER
11629 (struct cmd_set_vf_mac_addr_result,
11631 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11632 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11636 cmd_set_vf_mac_addr_parsed(
11637 void *parsed_result,
11638 __attribute__((unused)) struct cmdline *cl,
11639 __attribute__((unused)) void *data)
11641 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11642 int ret = -ENOTSUP;
11644 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11647 #ifdef RTE_LIBRTE_IXGBE_PMD
11648 if (ret == -ENOTSUP)
11649 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11652 #ifdef RTE_LIBRTE_I40E_PMD
11653 if (ret == -ENOTSUP)
11654 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11662 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11665 printf("invalid port_id %d\n", res->port_id);
11668 printf("function not implemented\n");
11671 printf("programming error: (%s)\n", strerror(-ret));
11675 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11676 .f = cmd_set_vf_mac_addr_parsed,
11678 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11680 (void *)&cmd_set_vf_mac_addr_set,
11681 (void *)&cmd_set_vf_mac_addr_vf,
11682 (void *)&cmd_set_vf_mac_addr_mac,
11683 (void *)&cmd_set_vf_mac_addr_addr,
11684 (void *)&cmd_set_vf_mac_addr_port_id,
11685 (void *)&cmd_set_vf_mac_addr_vf_id,
11686 (void *)&cmd_set_vf_mac_addr_mac_addr,
11691 #ifdef RTE_LIBRTE_IXGBE_PMD
11692 /* MACsec configuration */
11694 /* Common result structure for MACsec offload enable */
11695 struct cmd_macsec_offload_on_result {
11696 cmdline_fixed_string_t set;
11697 cmdline_fixed_string_t macsec;
11698 cmdline_fixed_string_t offload;
11700 cmdline_fixed_string_t on;
11701 cmdline_fixed_string_t encrypt;
11702 cmdline_fixed_string_t en_on_off;
11703 cmdline_fixed_string_t replay_protect;
11704 cmdline_fixed_string_t rp_on_off;
11707 /* Common CLI fields for MACsec offload disable */
11708 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11709 TOKEN_STRING_INITIALIZER
11710 (struct cmd_macsec_offload_on_result,
11712 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11713 TOKEN_STRING_INITIALIZER
11714 (struct cmd_macsec_offload_on_result,
11716 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11717 TOKEN_STRING_INITIALIZER
11718 (struct cmd_macsec_offload_on_result,
11719 offload, "offload");
11720 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11721 TOKEN_NUM_INITIALIZER
11722 (struct cmd_macsec_offload_on_result,
11724 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11725 TOKEN_STRING_INITIALIZER
11726 (struct cmd_macsec_offload_on_result,
11728 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11729 TOKEN_STRING_INITIALIZER
11730 (struct cmd_macsec_offload_on_result,
11731 encrypt, "encrypt");
11732 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11733 TOKEN_STRING_INITIALIZER
11734 (struct cmd_macsec_offload_on_result,
11735 en_on_off, "on#off");
11736 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11737 TOKEN_STRING_INITIALIZER
11738 (struct cmd_macsec_offload_on_result,
11739 replay_protect, "replay-protect");
11740 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11741 TOKEN_STRING_INITIALIZER
11742 (struct cmd_macsec_offload_on_result,
11743 rp_on_off, "on#off");
11746 cmd_set_macsec_offload_on_parsed(
11747 void *parsed_result,
11748 __attribute__((unused)) struct cmdline *cl,
11749 __attribute__((unused)) void *data)
11751 struct cmd_macsec_offload_on_result *res = parsed_result;
11753 portid_t port_id = res->port_id;
11754 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11755 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11757 if (port_id_is_invalid(port_id, ENABLED_WARN))
11760 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11761 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11767 printf("invalid port_id %d\n", port_id);
11770 printf("programming error: (%s)\n", strerror(-ret));
11774 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11775 .f = cmd_set_macsec_offload_on_parsed,
11777 .help_str = "set macsec offload <port_id> on "
11778 "encrypt on|off replay-protect on|off",
11780 (void *)&cmd_macsec_offload_on_set,
11781 (void *)&cmd_macsec_offload_on_macsec,
11782 (void *)&cmd_macsec_offload_on_offload,
11783 (void *)&cmd_macsec_offload_on_port_id,
11784 (void *)&cmd_macsec_offload_on_on,
11785 (void *)&cmd_macsec_offload_on_encrypt,
11786 (void *)&cmd_macsec_offload_on_en_on_off,
11787 (void *)&cmd_macsec_offload_on_replay_protect,
11788 (void *)&cmd_macsec_offload_on_rp_on_off,
11793 /* Common result structure for MACsec offload disable */
11794 struct cmd_macsec_offload_off_result {
11795 cmdline_fixed_string_t set;
11796 cmdline_fixed_string_t macsec;
11797 cmdline_fixed_string_t offload;
11799 cmdline_fixed_string_t off;
11802 /* Common CLI fields for MACsec offload disable */
11803 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11804 TOKEN_STRING_INITIALIZER
11805 (struct cmd_macsec_offload_off_result,
11807 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11808 TOKEN_STRING_INITIALIZER
11809 (struct cmd_macsec_offload_off_result,
11811 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11812 TOKEN_STRING_INITIALIZER
11813 (struct cmd_macsec_offload_off_result,
11814 offload, "offload");
11815 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11816 TOKEN_NUM_INITIALIZER
11817 (struct cmd_macsec_offload_off_result,
11819 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11820 TOKEN_STRING_INITIALIZER
11821 (struct cmd_macsec_offload_off_result,
11825 cmd_set_macsec_offload_off_parsed(
11826 void *parsed_result,
11827 __attribute__((unused)) struct cmdline *cl,
11828 __attribute__((unused)) void *data)
11830 struct cmd_macsec_offload_off_result *res = parsed_result;
11832 portid_t port_id = res->port_id;
11834 if (port_id_is_invalid(port_id, ENABLED_WARN))
11837 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11838 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11844 printf("invalid port_id %d\n", port_id);
11847 printf("programming error: (%s)\n", strerror(-ret));
11851 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11852 .f = cmd_set_macsec_offload_off_parsed,
11854 .help_str = "set macsec offload <port_id> off",
11856 (void *)&cmd_macsec_offload_off_set,
11857 (void *)&cmd_macsec_offload_off_macsec,
11858 (void *)&cmd_macsec_offload_off_offload,
11859 (void *)&cmd_macsec_offload_off_port_id,
11860 (void *)&cmd_macsec_offload_off_off,
11865 /* Common result structure for MACsec secure connection configure */
11866 struct cmd_macsec_sc_result {
11867 cmdline_fixed_string_t set;
11868 cmdline_fixed_string_t macsec;
11869 cmdline_fixed_string_t sc;
11870 cmdline_fixed_string_t tx_rx;
11872 struct ether_addr mac;
11876 /* Common CLI fields for MACsec secure connection configure */
11877 cmdline_parse_token_string_t cmd_macsec_sc_set =
11878 TOKEN_STRING_INITIALIZER
11879 (struct cmd_macsec_sc_result,
11881 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11882 TOKEN_STRING_INITIALIZER
11883 (struct cmd_macsec_sc_result,
11885 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11886 TOKEN_STRING_INITIALIZER
11887 (struct cmd_macsec_sc_result,
11889 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11890 TOKEN_STRING_INITIALIZER
11891 (struct cmd_macsec_sc_result,
11893 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11894 TOKEN_NUM_INITIALIZER
11895 (struct cmd_macsec_sc_result,
11897 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11898 TOKEN_ETHERADDR_INITIALIZER
11899 (struct cmd_macsec_sc_result,
11901 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11902 TOKEN_NUM_INITIALIZER
11903 (struct cmd_macsec_sc_result,
11907 cmd_set_macsec_sc_parsed(
11908 void *parsed_result,
11909 __attribute__((unused)) struct cmdline *cl,
11910 __attribute__((unused)) void *data)
11912 struct cmd_macsec_sc_result *res = parsed_result;
11914 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11917 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11918 res->mac.addr_bytes) :
11919 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11920 res->mac.addr_bytes, res->pi);
11925 printf("invalid port_id %d\n", res->port_id);
11928 printf("programming error: (%s)\n", strerror(-ret));
11932 cmdline_parse_inst_t cmd_set_macsec_sc = {
11933 .f = cmd_set_macsec_sc_parsed,
11935 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11937 (void *)&cmd_macsec_sc_set,
11938 (void *)&cmd_macsec_sc_macsec,
11939 (void *)&cmd_macsec_sc_sc,
11940 (void *)&cmd_macsec_sc_tx_rx,
11941 (void *)&cmd_macsec_sc_port_id,
11942 (void *)&cmd_macsec_sc_mac,
11943 (void *)&cmd_macsec_sc_pi,
11948 /* Common result structure for MACsec secure connection configure */
11949 struct cmd_macsec_sa_result {
11950 cmdline_fixed_string_t set;
11951 cmdline_fixed_string_t macsec;
11952 cmdline_fixed_string_t sa;
11953 cmdline_fixed_string_t tx_rx;
11958 cmdline_fixed_string_t key;
11961 /* Common CLI fields for MACsec secure connection configure */
11962 cmdline_parse_token_string_t cmd_macsec_sa_set =
11963 TOKEN_STRING_INITIALIZER
11964 (struct cmd_macsec_sa_result,
11966 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11967 TOKEN_STRING_INITIALIZER
11968 (struct cmd_macsec_sa_result,
11970 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11971 TOKEN_STRING_INITIALIZER
11972 (struct cmd_macsec_sa_result,
11974 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11975 TOKEN_STRING_INITIALIZER
11976 (struct cmd_macsec_sa_result,
11978 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11979 TOKEN_NUM_INITIALIZER
11980 (struct cmd_macsec_sa_result,
11982 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11983 TOKEN_NUM_INITIALIZER
11984 (struct cmd_macsec_sa_result,
11986 cmdline_parse_token_num_t cmd_macsec_sa_an =
11987 TOKEN_NUM_INITIALIZER
11988 (struct cmd_macsec_sa_result,
11990 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11991 TOKEN_NUM_INITIALIZER
11992 (struct cmd_macsec_sa_result,
11994 cmdline_parse_token_string_t cmd_macsec_sa_key =
11995 TOKEN_STRING_INITIALIZER
11996 (struct cmd_macsec_sa_result,
12000 cmd_set_macsec_sa_parsed(
12001 void *parsed_result,
12002 __attribute__((unused)) struct cmdline *cl,
12003 __attribute__((unused)) void *data)
12005 struct cmd_macsec_sa_result *res = parsed_result;
12007 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12008 uint8_t key[16] = { 0 };
12014 key_len = strlen(res->key) / 2;
12018 for (i = 0; i < key_len; i++) {
12019 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12022 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12025 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12029 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12030 res->idx, res->an, res->pn, key) :
12031 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12032 res->idx, res->an, res->pn, key);
12037 printf("invalid idx %d or an %d\n", res->idx, res->an);
12040 printf("invalid port_id %d\n", res->port_id);
12043 printf("programming error: (%s)\n", strerror(-ret));
12047 cmdline_parse_inst_t cmd_set_macsec_sa = {
12048 .f = cmd_set_macsec_sa_parsed,
12050 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12052 (void *)&cmd_macsec_sa_set,
12053 (void *)&cmd_macsec_sa_macsec,
12054 (void *)&cmd_macsec_sa_sa,
12055 (void *)&cmd_macsec_sa_tx_rx,
12056 (void *)&cmd_macsec_sa_port_id,
12057 (void *)&cmd_macsec_sa_idx,
12058 (void *)&cmd_macsec_sa_an,
12059 (void *)&cmd_macsec_sa_pn,
12060 (void *)&cmd_macsec_sa_key,
12066 /* VF unicast promiscuous mode configuration */
12068 /* Common result structure for VF unicast promiscuous mode */
12069 struct cmd_vf_promisc_result {
12070 cmdline_fixed_string_t set;
12071 cmdline_fixed_string_t vf;
12072 cmdline_fixed_string_t promisc;
12075 cmdline_fixed_string_t on_off;
12078 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12079 cmdline_parse_token_string_t cmd_vf_promisc_set =
12080 TOKEN_STRING_INITIALIZER
12081 (struct cmd_vf_promisc_result,
12083 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12084 TOKEN_STRING_INITIALIZER
12085 (struct cmd_vf_promisc_result,
12087 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12088 TOKEN_STRING_INITIALIZER
12089 (struct cmd_vf_promisc_result,
12090 promisc, "promisc");
12091 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12092 TOKEN_NUM_INITIALIZER
12093 (struct cmd_vf_promisc_result,
12095 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12096 TOKEN_NUM_INITIALIZER
12097 (struct cmd_vf_promisc_result,
12099 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12100 TOKEN_STRING_INITIALIZER
12101 (struct cmd_vf_promisc_result,
12105 cmd_set_vf_promisc_parsed(
12106 void *parsed_result,
12107 __attribute__((unused)) struct cmdline *cl,
12108 __attribute__((unused)) void *data)
12110 struct cmd_vf_promisc_result *res = parsed_result;
12111 int ret = -ENOTSUP;
12113 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12115 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12118 #ifdef RTE_LIBRTE_I40E_PMD
12119 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12120 res->vf_id, is_on);
12127 printf("invalid vf_id %d\n", res->vf_id);
12130 printf("invalid port_id %d\n", res->port_id);
12133 printf("function not implemented\n");
12136 printf("programming error: (%s)\n", strerror(-ret));
12140 cmdline_parse_inst_t cmd_set_vf_promisc = {
12141 .f = cmd_set_vf_promisc_parsed,
12143 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12144 "Set unicast promiscuous mode for a VF from the PF",
12146 (void *)&cmd_vf_promisc_set,
12147 (void *)&cmd_vf_promisc_vf,
12148 (void *)&cmd_vf_promisc_promisc,
12149 (void *)&cmd_vf_promisc_port_id,
12150 (void *)&cmd_vf_promisc_vf_id,
12151 (void *)&cmd_vf_promisc_on_off,
12156 /* VF multicast promiscuous mode configuration */
12158 /* Common result structure for VF multicast promiscuous mode */
12159 struct cmd_vf_allmulti_result {
12160 cmdline_fixed_string_t set;
12161 cmdline_fixed_string_t vf;
12162 cmdline_fixed_string_t allmulti;
12165 cmdline_fixed_string_t on_off;
12168 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12169 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12170 TOKEN_STRING_INITIALIZER
12171 (struct cmd_vf_allmulti_result,
12173 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12174 TOKEN_STRING_INITIALIZER
12175 (struct cmd_vf_allmulti_result,
12177 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12178 TOKEN_STRING_INITIALIZER
12179 (struct cmd_vf_allmulti_result,
12180 allmulti, "allmulti");
12181 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12182 TOKEN_NUM_INITIALIZER
12183 (struct cmd_vf_allmulti_result,
12185 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12186 TOKEN_NUM_INITIALIZER
12187 (struct cmd_vf_allmulti_result,
12189 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12190 TOKEN_STRING_INITIALIZER
12191 (struct cmd_vf_allmulti_result,
12195 cmd_set_vf_allmulti_parsed(
12196 void *parsed_result,
12197 __attribute__((unused)) struct cmdline *cl,
12198 __attribute__((unused)) void *data)
12200 struct cmd_vf_allmulti_result *res = parsed_result;
12201 int ret = -ENOTSUP;
12203 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12205 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12208 #ifdef RTE_LIBRTE_I40E_PMD
12209 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12210 res->vf_id, is_on);
12217 printf("invalid vf_id %d\n", res->vf_id);
12220 printf("invalid port_id %d\n", res->port_id);
12223 printf("function not implemented\n");
12226 printf("programming error: (%s)\n", strerror(-ret));
12230 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12231 .f = cmd_set_vf_allmulti_parsed,
12233 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12234 "Set multicast promiscuous mode for a VF from the PF",
12236 (void *)&cmd_vf_allmulti_set,
12237 (void *)&cmd_vf_allmulti_vf,
12238 (void *)&cmd_vf_allmulti_allmulti,
12239 (void *)&cmd_vf_allmulti_port_id,
12240 (void *)&cmd_vf_allmulti_vf_id,
12241 (void *)&cmd_vf_allmulti_on_off,
12246 /* vf broadcast mode configuration */
12248 /* Common result structure for vf broadcast */
12249 struct cmd_set_vf_broadcast_result {
12250 cmdline_fixed_string_t set;
12251 cmdline_fixed_string_t vf;
12252 cmdline_fixed_string_t broadcast;
12255 cmdline_fixed_string_t on_off;
12258 /* Common CLI fields for vf broadcast enable disable */
12259 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12260 TOKEN_STRING_INITIALIZER
12261 (struct cmd_set_vf_broadcast_result,
12263 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12264 TOKEN_STRING_INITIALIZER
12265 (struct cmd_set_vf_broadcast_result,
12267 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12268 TOKEN_STRING_INITIALIZER
12269 (struct cmd_set_vf_broadcast_result,
12270 broadcast, "broadcast");
12271 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12272 TOKEN_NUM_INITIALIZER
12273 (struct cmd_set_vf_broadcast_result,
12275 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12276 TOKEN_NUM_INITIALIZER
12277 (struct cmd_set_vf_broadcast_result,
12279 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12280 TOKEN_STRING_INITIALIZER
12281 (struct cmd_set_vf_broadcast_result,
12285 cmd_set_vf_broadcast_parsed(
12286 void *parsed_result,
12287 __attribute__((unused)) struct cmdline *cl,
12288 __attribute__((unused)) void *data)
12290 struct cmd_set_vf_broadcast_result *res = parsed_result;
12291 int ret = -ENOTSUP;
12293 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12295 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12298 #ifdef RTE_LIBRTE_I40E_PMD
12299 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12300 res->vf_id, is_on);
12307 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12310 printf("invalid port_id %d\n", res->port_id);
12313 printf("function not implemented\n");
12316 printf("programming error: (%s)\n", strerror(-ret));
12320 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12321 .f = cmd_set_vf_broadcast_parsed,
12323 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12325 (void *)&cmd_set_vf_broadcast_set,
12326 (void *)&cmd_set_vf_broadcast_vf,
12327 (void *)&cmd_set_vf_broadcast_broadcast,
12328 (void *)&cmd_set_vf_broadcast_port_id,
12329 (void *)&cmd_set_vf_broadcast_vf_id,
12330 (void *)&cmd_set_vf_broadcast_on_off,
12335 /* vf vlan tag configuration */
12337 /* Common result structure for vf vlan tag */
12338 struct cmd_set_vf_vlan_tag_result {
12339 cmdline_fixed_string_t set;
12340 cmdline_fixed_string_t vf;
12341 cmdline_fixed_string_t vlan;
12342 cmdline_fixed_string_t tag;
12345 cmdline_fixed_string_t on_off;
12348 /* Common CLI fields for vf vlan tag enable disable */
12349 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12350 TOKEN_STRING_INITIALIZER
12351 (struct cmd_set_vf_vlan_tag_result,
12353 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12354 TOKEN_STRING_INITIALIZER
12355 (struct cmd_set_vf_vlan_tag_result,
12357 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12358 TOKEN_STRING_INITIALIZER
12359 (struct cmd_set_vf_vlan_tag_result,
12361 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12362 TOKEN_STRING_INITIALIZER
12363 (struct cmd_set_vf_vlan_tag_result,
12365 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12366 TOKEN_NUM_INITIALIZER
12367 (struct cmd_set_vf_vlan_tag_result,
12369 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12370 TOKEN_NUM_INITIALIZER
12371 (struct cmd_set_vf_vlan_tag_result,
12373 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12374 TOKEN_STRING_INITIALIZER
12375 (struct cmd_set_vf_vlan_tag_result,
12379 cmd_set_vf_vlan_tag_parsed(
12380 void *parsed_result,
12381 __attribute__((unused)) struct cmdline *cl,
12382 __attribute__((unused)) void *data)
12384 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12385 int ret = -ENOTSUP;
12387 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12389 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12392 #ifdef RTE_LIBRTE_I40E_PMD
12393 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12394 res->vf_id, is_on);
12401 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12404 printf("invalid port_id %d\n", res->port_id);
12407 printf("function not implemented\n");
12410 printf("programming error: (%s)\n", strerror(-ret));
12414 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12415 .f = cmd_set_vf_vlan_tag_parsed,
12417 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12419 (void *)&cmd_set_vf_vlan_tag_set,
12420 (void *)&cmd_set_vf_vlan_tag_vf,
12421 (void *)&cmd_set_vf_vlan_tag_vlan,
12422 (void *)&cmd_set_vf_vlan_tag_tag,
12423 (void *)&cmd_set_vf_vlan_tag_port_id,
12424 (void *)&cmd_set_vf_vlan_tag_vf_id,
12425 (void *)&cmd_set_vf_vlan_tag_on_off,
12430 /* Common definition of VF and TC TX bandwidth configuration */
12431 struct cmd_vf_tc_bw_result {
12432 cmdline_fixed_string_t set;
12433 cmdline_fixed_string_t vf;
12434 cmdline_fixed_string_t tc;
12435 cmdline_fixed_string_t tx;
12436 cmdline_fixed_string_t min_bw;
12437 cmdline_fixed_string_t max_bw;
12438 cmdline_fixed_string_t strict_link_prio;
12443 cmdline_fixed_string_t bw_list;
12447 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12448 TOKEN_STRING_INITIALIZER
12449 (struct cmd_vf_tc_bw_result,
12451 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12452 TOKEN_STRING_INITIALIZER
12453 (struct cmd_vf_tc_bw_result,
12455 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12456 TOKEN_STRING_INITIALIZER
12457 (struct cmd_vf_tc_bw_result,
12459 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12460 TOKEN_STRING_INITIALIZER
12461 (struct cmd_vf_tc_bw_result,
12463 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12464 TOKEN_STRING_INITIALIZER
12465 (struct cmd_vf_tc_bw_result,
12466 strict_link_prio, "strict-link-priority");
12467 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12468 TOKEN_STRING_INITIALIZER
12469 (struct cmd_vf_tc_bw_result,
12470 min_bw, "min-bandwidth");
12471 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12472 TOKEN_STRING_INITIALIZER
12473 (struct cmd_vf_tc_bw_result,
12474 max_bw, "max-bandwidth");
12475 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12476 TOKEN_NUM_INITIALIZER
12477 (struct cmd_vf_tc_bw_result,
12479 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12480 TOKEN_NUM_INITIALIZER
12481 (struct cmd_vf_tc_bw_result,
12483 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12484 TOKEN_NUM_INITIALIZER
12485 (struct cmd_vf_tc_bw_result,
12487 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12488 TOKEN_NUM_INITIALIZER
12489 (struct cmd_vf_tc_bw_result,
12491 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12492 TOKEN_STRING_INITIALIZER
12493 (struct cmd_vf_tc_bw_result,
12495 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12496 TOKEN_NUM_INITIALIZER
12497 (struct cmd_vf_tc_bw_result,
12500 /* VF max bandwidth setting */
12502 cmd_vf_max_bw_parsed(
12503 void *parsed_result,
12504 __attribute__((unused)) struct cmdline *cl,
12505 __attribute__((unused)) void *data)
12507 struct cmd_vf_tc_bw_result *res = parsed_result;
12508 int ret = -ENOTSUP;
12510 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12513 #ifdef RTE_LIBRTE_I40E_PMD
12514 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12515 res->vf_id, res->bw);
12522 printf("invalid vf_id %d or bandwidth %d\n",
12523 res->vf_id, res->bw);
12526 printf("invalid port_id %d\n", res->port_id);
12529 printf("function not implemented\n");
12532 printf("programming error: (%s)\n", strerror(-ret));
12536 cmdline_parse_inst_t cmd_vf_max_bw = {
12537 .f = cmd_vf_max_bw_parsed,
12539 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12541 (void *)&cmd_vf_tc_bw_set,
12542 (void *)&cmd_vf_tc_bw_vf,
12543 (void *)&cmd_vf_tc_bw_tx,
12544 (void *)&cmd_vf_tc_bw_max_bw,
12545 (void *)&cmd_vf_tc_bw_port_id,
12546 (void *)&cmd_vf_tc_bw_vf_id,
12547 (void *)&cmd_vf_tc_bw_bw,
12553 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12558 const char *p, *p0 = str;
12565 p = strchr(p0, '(');
12567 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12571 p0 = strchr(p, ')');
12573 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12577 if (size >= sizeof(s)) {
12578 printf("The string size exceeds the internal buffer size\n");
12581 snprintf(s, sizeof(s), "%.*s", size, p);
12582 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12584 printf("Failed to get the bandwidth list. ");
12588 for (i = 0; i < ret; i++)
12589 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12594 /* TC min bandwidth setting */
12596 cmd_vf_tc_min_bw_parsed(
12597 void *parsed_result,
12598 __attribute__((unused)) struct cmdline *cl,
12599 __attribute__((unused)) void *data)
12601 struct cmd_vf_tc_bw_result *res = parsed_result;
12604 int ret = -ENOTSUP;
12606 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12609 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12613 #ifdef RTE_LIBRTE_I40E_PMD
12614 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12622 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12625 printf("invalid port_id %d\n", res->port_id);
12628 printf("function not implemented\n");
12631 printf("programming error: (%s)\n", strerror(-ret));
12635 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12636 .f = cmd_vf_tc_min_bw_parsed,
12638 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12639 " <bw1, bw2, ...>",
12641 (void *)&cmd_vf_tc_bw_set,
12642 (void *)&cmd_vf_tc_bw_vf,
12643 (void *)&cmd_vf_tc_bw_tc,
12644 (void *)&cmd_vf_tc_bw_tx,
12645 (void *)&cmd_vf_tc_bw_min_bw,
12646 (void *)&cmd_vf_tc_bw_port_id,
12647 (void *)&cmd_vf_tc_bw_vf_id,
12648 (void *)&cmd_vf_tc_bw_bw_list,
12654 cmd_tc_min_bw_parsed(
12655 void *parsed_result,
12656 __attribute__((unused)) struct cmdline *cl,
12657 __attribute__((unused)) void *data)
12659 struct cmd_vf_tc_bw_result *res = parsed_result;
12660 struct rte_port *port;
12663 int ret = -ENOTSUP;
12665 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12668 port = &ports[res->port_id];
12669 /** Check if the port is not started **/
12670 if (port->port_status != RTE_PORT_STOPPED) {
12671 printf("Please stop port %d first\n", res->port_id);
12675 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12679 #ifdef RTE_LIBRTE_IXGBE_PMD
12680 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12687 printf("invalid bandwidth\n");
12690 printf("invalid port_id %d\n", res->port_id);
12693 printf("function not implemented\n");
12696 printf("programming error: (%s)\n", strerror(-ret));
12700 cmdline_parse_inst_t cmd_tc_min_bw = {
12701 .f = cmd_tc_min_bw_parsed,
12703 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12705 (void *)&cmd_vf_tc_bw_set,
12706 (void *)&cmd_vf_tc_bw_tc,
12707 (void *)&cmd_vf_tc_bw_tx,
12708 (void *)&cmd_vf_tc_bw_min_bw,
12709 (void *)&cmd_vf_tc_bw_port_id,
12710 (void *)&cmd_vf_tc_bw_bw_list,
12715 /* TC max bandwidth setting */
12717 cmd_vf_tc_max_bw_parsed(
12718 void *parsed_result,
12719 __attribute__((unused)) struct cmdline *cl,
12720 __attribute__((unused)) void *data)
12722 struct cmd_vf_tc_bw_result *res = parsed_result;
12723 int ret = -ENOTSUP;
12725 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12728 #ifdef RTE_LIBRTE_I40E_PMD
12729 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12730 res->tc_no, res->bw);
12737 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12738 res->vf_id, res->tc_no, res->bw);
12741 printf("invalid port_id %d\n", res->port_id);
12744 printf("function not implemented\n");
12747 printf("programming error: (%s)\n", strerror(-ret));
12751 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12752 .f = cmd_vf_tc_max_bw_parsed,
12754 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12757 (void *)&cmd_vf_tc_bw_set,
12758 (void *)&cmd_vf_tc_bw_vf,
12759 (void *)&cmd_vf_tc_bw_tc,
12760 (void *)&cmd_vf_tc_bw_tx,
12761 (void *)&cmd_vf_tc_bw_max_bw,
12762 (void *)&cmd_vf_tc_bw_port_id,
12763 (void *)&cmd_vf_tc_bw_vf_id,
12764 (void *)&cmd_vf_tc_bw_tc_no,
12765 (void *)&cmd_vf_tc_bw_bw,
12770 /* Strict link priority scheduling mode setting */
12772 cmd_strict_link_prio_parsed(
12773 void *parsed_result,
12774 __attribute__((unused)) struct cmdline *cl,
12775 __attribute__((unused)) void *data)
12777 struct cmd_vf_tc_bw_result *res = parsed_result;
12778 int ret = -ENOTSUP;
12780 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12783 #ifdef RTE_LIBRTE_I40E_PMD
12784 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
12791 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
12794 printf("invalid port_id %d\n", res->port_id);
12797 printf("function not implemented\n");
12800 printf("programming error: (%s)\n", strerror(-ret));
12804 cmdline_parse_inst_t cmd_strict_link_prio = {
12805 .f = cmd_strict_link_prio_parsed,
12807 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
12809 (void *)&cmd_vf_tc_bw_set,
12810 (void *)&cmd_vf_tc_bw_tx,
12811 (void *)&cmd_vf_tc_bw_strict_link_prio,
12812 (void *)&cmd_vf_tc_bw_port_id,
12813 (void *)&cmd_vf_tc_bw_tc_map,
12818 /* Load dynamic device personalization*/
12819 struct cmd_ddp_add_result {
12820 cmdline_fixed_string_t ddp;
12821 cmdline_fixed_string_t add;
12826 cmdline_parse_token_string_t cmd_ddp_add_ddp =
12827 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
12828 cmdline_parse_token_string_t cmd_ddp_add_add =
12829 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
12830 cmdline_parse_token_num_t cmd_ddp_add_port_id =
12831 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT8);
12832 cmdline_parse_token_string_t cmd_ddp_add_filepath =
12833 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
12836 cmd_ddp_add_parsed(
12837 void *parsed_result,
12838 __attribute__((unused)) struct cmdline *cl,
12839 __attribute__((unused)) void *data)
12841 struct cmd_ddp_add_result *res = parsed_result;
12844 int ret = -ENOTSUP;
12846 if (res->port_id > nb_ports) {
12847 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12851 if (!all_ports_stopped()) {
12852 printf("Please stop all ports first\n");
12856 buff = open_ddp_package_file(res->filepath, &size);
12860 #ifdef RTE_LIBRTE_I40E_PMD
12861 if (ret == -ENOTSUP)
12862 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
12864 RTE_PMD_I40E_PKG_OP_WR_ADD);
12868 printf("Failed to load profile.\n");
12870 printf("Profile has already existed.\n");
12872 close_ddp_package_file(buff);
12875 cmdline_parse_inst_t cmd_ddp_add = {
12876 .f = cmd_ddp_add_parsed,
12878 .help_str = "ddp add <port_id> <profile_path>",
12880 (void *)&cmd_ddp_add_ddp,
12881 (void *)&cmd_ddp_add_add,
12882 (void *)&cmd_ddp_add_port_id,
12883 (void *)&cmd_ddp_add_filepath,
12888 /* Get dynamic device personalization profile info list*/
12889 #define PROFILE_INFO_SIZE 48
12890 #define MAX_PROFILE_NUM 16
12892 struct cmd_ddp_get_list_result {
12893 cmdline_fixed_string_t ddp;
12894 cmdline_fixed_string_t get;
12895 cmdline_fixed_string_t list;
12899 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
12900 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
12901 cmdline_parse_token_string_t cmd_ddp_get_list_get =
12902 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
12903 cmdline_parse_token_string_t cmd_ddp_get_list_list =
12904 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
12905 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
12906 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT8);
12909 cmd_ddp_get_list_parsed(
12910 void *parsed_result,
12911 __attribute__((unused)) struct cmdline *cl,
12912 __attribute__((unused)) void *data)
12914 struct cmd_ddp_get_list_result *res = parsed_result;
12915 #ifdef RTE_LIBRTE_I40E_PMD
12916 struct rte_pmd_i40e_profile_list *p_list;
12917 struct rte_pmd_i40e_profile_info *p_info;
12922 int ret = -ENOTSUP;
12924 if (res->port_id > nb_ports) {
12925 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
12929 #ifdef RTE_LIBRTE_I40E_PMD
12930 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
12931 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
12933 printf("%s: Failed to malloc buffer\n", __func__);
12935 if (ret == -ENOTSUP)
12936 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
12937 (uint8_t *)p_list, size);
12940 p_num = p_list->p_count;
12941 printf("Profile number is: %d\n\n", p_num);
12943 for (i = 0; i < p_num; i++) {
12944 p_info = &p_list->p_info[i];
12945 printf("Profile %d:\n", i);
12946 printf("Track id: 0x%x\n", p_info->track_id);
12947 printf("Version: %d.%d.%d.%d\n",
12948 p_info->version.major,
12949 p_info->version.minor,
12950 p_info->version.update,
12951 p_info->version.draft);
12952 printf("Profile name: %s\n\n", p_info->name);
12960 printf("Failed to get ddp list\n");
12963 cmdline_parse_inst_t cmd_ddp_get_list = {
12964 .f = cmd_ddp_get_list_parsed,
12966 .help_str = "ddp get list <port_id>",
12968 (void *)&cmd_ddp_get_list_ddp,
12969 (void *)&cmd_ddp_get_list_get,
12970 (void *)&cmd_ddp_get_list_list,
12971 (void *)&cmd_ddp_get_list_port_id,
12975 /* ******************************************************************************** */
12977 /* list of instructions */
12978 cmdline_parse_ctx_t main_ctx[] = {
12979 (cmdline_parse_inst_t *)&cmd_help_brief,
12980 (cmdline_parse_inst_t *)&cmd_help_long,
12981 (cmdline_parse_inst_t *)&cmd_quit,
12982 (cmdline_parse_inst_t *)&cmd_showport,
12983 (cmdline_parse_inst_t *)&cmd_showqueue,
12984 (cmdline_parse_inst_t *)&cmd_showportall,
12985 (cmdline_parse_inst_t *)&cmd_showcfg,
12986 (cmdline_parse_inst_t *)&cmd_start,
12987 (cmdline_parse_inst_t *)&cmd_start_tx_first,
12988 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
12989 (cmdline_parse_inst_t *)&cmd_set_link_up,
12990 (cmdline_parse_inst_t *)&cmd_set_link_down,
12991 (cmdline_parse_inst_t *)&cmd_reset,
12992 (cmdline_parse_inst_t *)&cmd_set_numbers,
12993 (cmdline_parse_inst_t *)&cmd_set_txpkts,
12994 (cmdline_parse_inst_t *)&cmd_set_txsplit,
12995 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
12996 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
12997 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
12998 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
12999 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
13000 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
13001 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
13002 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
13003 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
13004 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
13005 (cmdline_parse_inst_t *)&cmd_set_link_check,
13006 #ifdef RTE_NIC_BYPASS
13007 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
13008 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
13009 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
13010 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
13012 #ifdef RTE_LIBRTE_PMD_BOND
13013 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
13014 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
13015 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
13016 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
13017 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
13018 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
13019 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
13020 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
13021 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
13023 (cmdline_parse_inst_t *)&cmd_vlan_offload,
13024 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
13025 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
13026 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
13027 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
13028 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
13029 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
13030 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
13031 (cmdline_parse_inst_t *)&cmd_csum_set,
13032 (cmdline_parse_inst_t *)&cmd_csum_show,
13033 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
13034 (cmdline_parse_inst_t *)&cmd_tso_set,
13035 (cmdline_parse_inst_t *)&cmd_tso_show,
13036 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
13037 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
13038 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
13039 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
13040 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
13041 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
13042 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
13043 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
13044 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
13045 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
13046 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
13047 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
13048 (cmdline_parse_inst_t *)&cmd_config_dcb,
13049 (cmdline_parse_inst_t *)&cmd_read_reg,
13050 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
13051 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
13052 (cmdline_parse_inst_t *)&cmd_write_reg,
13053 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
13054 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
13055 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
13056 (cmdline_parse_inst_t *)&cmd_stop,
13057 (cmdline_parse_inst_t *)&cmd_mac_addr,
13058 (cmdline_parse_inst_t *)&cmd_set_qmap,
13059 (cmdline_parse_inst_t *)&cmd_operate_port,
13060 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
13061 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
13062 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
13063 (cmdline_parse_inst_t *)&cmd_config_speed_all,
13064 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
13065 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
13066 (cmdline_parse_inst_t *)&cmd_config_mtu,
13067 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
13068 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
13069 (cmdline_parse_inst_t *)&cmd_config_rss,
13070 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13071 (cmdline_parse_inst_t *)&cmd_config_txqflags,
13072 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
13073 (cmdline_parse_inst_t *)&cmd_showport_reta,
13074 (cmdline_parse_inst_t *)&cmd_config_burst,
13075 (cmdline_parse_inst_t *)&cmd_config_thresh,
13076 (cmdline_parse_inst_t *)&cmd_config_threshold,
13077 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13078 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13079 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13080 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
13081 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13082 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
13083 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13084 (cmdline_parse_inst_t *)&cmd_global_config,
13085 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
13086 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
13087 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
13088 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
13089 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
13090 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
13091 (cmdline_parse_inst_t *)&cmd_dump,
13092 (cmdline_parse_inst_t *)&cmd_dump_one,
13093 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
13094 (cmdline_parse_inst_t *)&cmd_syn_filter,
13095 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
13096 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
13097 (cmdline_parse_inst_t *)&cmd_flex_filter,
13098 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
13099 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
13100 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
13101 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
13102 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
13103 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
13104 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
13105 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
13106 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
13107 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
13108 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
13109 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
13110 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
13111 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
13112 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
13113 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
13114 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
13115 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
13116 (cmdline_parse_inst_t *)&cmd_flow,
13117 (cmdline_parse_inst_t *)&cmd_mcast_addr,
13118 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
13119 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
13120 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
13121 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
13122 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
13123 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
13124 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
13125 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
13126 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
13127 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
13128 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
13129 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
13130 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
13131 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
13132 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
13133 #ifdef RTE_LIBRTE_IXGBE_PMD
13134 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
13135 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
13136 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
13137 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
13138 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
13139 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
13140 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
13141 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
13142 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
13144 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
13145 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
13146 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
13147 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
13148 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
13149 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
13150 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
13151 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
13152 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
13153 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
13154 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
13155 (cmdline_parse_inst_t *)&cmd_ddp_add,
13156 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
13160 /* prompt function, called from main on MASTER lcore */
13164 /* initialize non-constant commands */
13165 cmd_set_fwd_mode_init();
13166 cmd_set_fwd_retry_mode_init();
13168 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
13169 if (testpmd_cl == NULL)
13171 cmdline_interact(testpmd_cl);
13172 cmdline_stdin_exit(testpmd_cl);
13178 if (testpmd_cl != NULL)
13179 cmdline_quit(testpmd_cl);
13183 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
13185 if (id == (portid_t)RTE_PORT_ALL) {
13188 FOREACH_PORT(pid, ports) {
13189 /* check if need_reconfig has been set to 1 */
13190 if (ports[pid].need_reconfig == 0)
13191 ports[pid].need_reconfig = dev;
13192 /* check if need_reconfig_queues has been set to 1 */
13193 if (ports[pid].need_reconfig_queues == 0)
13194 ports[pid].need_reconfig_queues = queue;
13196 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
13197 /* check if need_reconfig has been set to 1 */
13198 if (ports[id].need_reconfig == 0)
13199 ports[id].need_reconfig = dev;
13200 /* check if need_reconfig_queues has been set to 1 */
13201 if (ports[id].need_reconfig_queues == 0)
13202 ports[id].need_reconfig_queues = queue;