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"
220 if (show_all || !strcmp(res->section, "config")) {
226 "Configuration changes only become active when"
227 " forwarding is started/restarted.\n\n"
230 " Reset forwarding to the default configuration.\n\n"
232 "set verbose (level)\n"
233 " Set the debug verbosity level X.\n\n"
236 " Set number of ports.\n\n"
239 " Set number of cores.\n\n"
241 "set coremask (mask)\n"
242 " Set the forwarding cores hexadecimal mask.\n\n"
244 "set portmask (mask)\n"
245 " Set the forwarding ports hexadecimal mask.\n\n"
248 " Set number of packets per burst.\n\n"
250 "set burst tx delay (microseconds) retry (num)\n"
251 " Set the transmit delay time and number of retries,"
252 " effective when retry is enabled.\n\n"
254 "set txpkts (x[,y]*)\n"
255 " Set the length of each segment of TXONLY"
256 " and optionally CSUM packets.\n\n"
258 "set txsplit (off|on|rand)\n"
259 " Set the split policy for the TX packets."
260 " Right now only applicable for CSUM and TXONLY"
263 "set corelist (x[,y]*)\n"
264 " Set the list of forwarding cores.\n\n"
266 "set portlist (x[,y]*)\n"
267 " Set the list of forwarding ports.\n\n"
269 "set tx loopback (port_id) (on|off)\n"
270 " Enable or disable tx loopback.\n\n"
272 #ifdef RTE_LIBRTE_IXGBE_PMD
273 "set all queues drop (port_id) (on|off)\n"
274 " Set drop enable bit for all queues.\n\n"
276 "set vf split drop (port_id) (vf_id) (on|off)\n"
277 " Set split drop enable bit for a VF from the PF.\n\n"
280 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
281 " Set MAC antispoof for a VF from the PF.\n\n"
283 #ifdef RTE_LIBRTE_IXGBE_PMD
284 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
285 " Enable MACsec offload.\n\n"
287 "set macsec offload (port_id) off\n"
288 " Disable MACsec offload.\n\n"
290 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
291 " Configure MACsec secure connection (SC).\n\n"
293 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
294 " Configure MACsec secure association (SA).\n\n"
297 "set vf broadcast (port_id) (vf_id) (on|off)\n"
298 " Set VF broadcast for a VF from the PF.\n\n"
300 "vlan set strip (on|off) (port_id)\n"
301 " Set the VLAN strip on a port.\n\n"
303 "vlan set stripq (on|off) (port_id,queue_id)\n"
304 " Set the VLAN strip for a queue on a port.\n\n"
306 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
307 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
309 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
310 " Set VLAN insert for a VF from the PF.\n\n"
312 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
313 " Set VLAN antispoof for a VF from the PF.\n\n"
315 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
316 " Set VLAN tag for a VF from the PF.\n\n"
318 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
319 " Set a VF's max bandwidth(Mbps).\n\n"
321 "vlan set filter (on|off) (port_id)\n"
322 " Set the VLAN filter on a port.\n\n"
324 "vlan set qinq (on|off) (port_id)\n"
325 " Set the VLAN QinQ (extended queue in queue)"
328 "vlan set (inner|outer) tpid (value) (port_id)\n"
329 " Set the VLAN TPID for Packet Filtering on"
332 "rx_vlan add (vlan_id|all) (port_id)\n"
333 " Add a vlan_id, or all identifiers, to the set"
334 " of VLAN identifiers filtered by port_id.\n\n"
336 "rx_vlan rm (vlan_id|all) (port_id)\n"
337 " Remove a vlan_id, or all identifiers, from the set"
338 " of VLAN identifiers filtered by port_id.\n\n"
340 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
341 " Add a vlan_id, to the set of VLAN identifiers"
342 "filtered for VF(s) from port_id.\n\n"
344 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
345 " Remove a vlan_id, to the set of VLAN identifiers"
346 "filtered for VF(s) from port_id.\n\n"
348 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
349 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
350 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
351 " add a tunnel filter of a port.\n\n"
353 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
354 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
355 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
356 " remove a tunnel filter of a port.\n\n"
358 "rx_vxlan_port add (udp_port) (port_id)\n"
359 " Add an UDP port for VXLAN packet filter on a port\n\n"
361 "rx_vxlan_port rm (udp_port) (port_id)\n"
362 " Remove an UDP port for VXLAN packet filter on a port\n\n"
364 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
365 " Set hardware insertion of VLAN IDs (single or double VLAN "
366 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
368 "tx_vlan set pvid port_id vlan_id (on|off)\n"
369 " Set port based TX VLAN insertion.\n\n"
371 "tx_vlan reset (port_id)\n"
372 " Disable hardware insertion of a VLAN header in"
373 " packets sent on a port.\n\n"
375 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
376 " Select hardware or software calculation of the"
377 " checksum when transmitting a packet using the"
378 " csum forward engine.\n"
379 " ip|udp|tcp|sctp always concern the inner layer.\n"
380 " outer-ip concerns the outer IP layer in"
381 " case the packet is recognized as a tunnel packet by"
382 " the forward engine (vxlan, gre and ipip are supported)\n"
383 " Please check the NIC datasheet for HW limits.\n\n"
385 "csum parse-tunnel (on|off) (tx_port_id)\n"
386 " If disabled, treat tunnel packets as non-tunneled"
387 " packets (treat inner headers as payload). The port\n"
388 " argument is the port used for TX in csum forward"
391 "csum show (port_id)\n"
392 " Display tx checksum offload configuration\n\n"
394 "tso set (segsize) (portid)\n"
395 " Enable TCP Segmentation Offload in csum forward"
397 " Please check the NIC datasheet for HW limits.\n\n"
400 " Display the status of TCP Segmentation Offload.\n\n"
403 " Set packet forwarding mode.\n\n"
405 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
406 " Add a MAC address on port_id.\n\n"
408 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
409 " Remove a MAC address from port_id.\n\n"
411 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
412 " Set the default MAC address for port_id.\n\n"
414 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
415 " Add a MAC address for a VF on the port.\n\n"
417 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
418 " Set the MAC address for a VF from the PF.\n\n"
420 "set port (port_id) uta (mac_address|all) (on|off)\n"
421 " Add/Remove a or all unicast hash filter(s)"
424 "set promisc (port_id|all) (on|off)\n"
425 " Set the promiscuous mode on port_id, or all.\n\n"
427 "set allmulti (port_id|all) (on|off)\n"
428 " Set the allmulti mode on port_id, or all.\n\n"
430 "set vf promisc (port_id) (vf_id) (on|off)\n"
431 " Set unicast promiscuous mode for a VF from the PF.\n\n"
433 "set vf allmulti (port_id) (vf_id) (on|off)\n"
434 " Set multicast promiscuous mode for a VF from the PF.\n\n"
436 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
437 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
438 " (on|off) autoneg (on|off) (port_id)\n"
439 "set flow_ctrl rx (on|off) (portid)\n"
440 "set flow_ctrl tx (on|off) (portid)\n"
441 "set flow_ctrl high_water (high_water) (portid)\n"
442 "set flow_ctrl low_water (low_water) (portid)\n"
443 "set flow_ctrl pause_time (pause_time) (portid)\n"
444 "set flow_ctrl send_xon (send_xon) (portid)\n"
445 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
446 "set flow_ctrl autoneg (on|off) (port_id)\n"
447 " Set the link flow control parameter on a port.\n\n"
449 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
450 " (low_water) (pause_time) (priority) (port_id)\n"
451 " Set the priority flow control parameter on a"
454 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
455 " Set statistics mapping (qmapping 0..15) for RX/TX"
457 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
458 " on port 0 to mapping 5.\n\n"
460 "set port (port_id) vf (vf_id) rx|tx on|off\n"
461 " Enable/Disable a VF receive/tranmit from a port\n\n"
463 "set port (port_id) vf (vf_id) (mac_addr)"
464 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
465 " Add/Remove unicast or multicast MAC addr filter"
468 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
470 " AUPE:accepts untagged VLAN;"
471 "ROPE:accept unicast hash\n\n"
472 " BAM:accepts broadcast packets;"
473 "MPE:accepts all multicast packets\n\n"
474 " Enable/Disable a VF receive mode of a port\n\n"
476 "set port (port_id) queue (queue_id) rate (rate_num)\n"
477 " Set rate limit for a queue of a port\n\n"
479 "set port (port_id) vf (vf_id) rate (rate_num) "
480 "queue_mask (queue_mask_value)\n"
481 " Set rate limit for queues in VF of a port\n\n"
483 "set port (port_id) mirror-rule (rule_id)"
484 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
485 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
486 " Set pool or vlan type mirror rule on a port.\n"
487 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
488 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
491 "set port (port_id) mirror-rule (rule_id)"
492 " (uplink-mirror|downlink-mirror) dst-pool"
493 " (pool_id) (on|off)\n"
494 " Set uplink or downlink type mirror rule on a port.\n"
495 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
496 " 0 on' enable mirror income traffic to pool 0.\n\n"
498 "reset port (port_id) mirror-rule (rule_id)\n"
499 " Reset a mirror rule.\n\n"
501 "set flush_rx (on|off)\n"
502 " Flush (default) or don't flush RX streams before"
503 " forwarding. Mainly used with PCAP drivers.\n\n"
505 #ifdef RTE_NIC_BYPASS
506 "set bypass mode (normal|bypass|isolate) (port_id)\n"
507 " Set the bypass mode for the lowest port on bypass enabled"
510 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
511 "mode (normal|bypass|isolate) (port_id)\n"
512 " Set the event required to initiate specified bypass mode for"
513 " the lowest port on a bypass enabled NIC where:\n"
514 " timeout = enable bypass after watchdog timeout.\n"
515 " os_on = enable bypass when OS/board is powered on.\n"
516 " os_off = enable bypass when OS/board is powered off.\n"
517 " power_on = enable bypass when power supply is turned on.\n"
518 " power_off = enable bypass when power supply is turned off."
521 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
522 " Set the bypass watchdog timeout to 'n' seconds"
523 " where 0 = instant.\n\n"
525 "show bypass config (port_id)\n"
526 " Show the bypass configuration for a bypass enabled NIC"
527 " using the lowest port on the NIC.\n\n"
529 #ifdef RTE_LIBRTE_PMD_BOND
530 "create bonded device (mode) (socket)\n"
531 " Create a new bonded device with specific bonding mode and socket.\n\n"
533 "add bonding slave (slave_id) (port_id)\n"
534 " Add a slave device to a bonded device.\n\n"
536 "remove bonding slave (slave_id) (port_id)\n"
537 " Remove a slave device from a bonded device.\n\n"
539 "set bonding mode (value) (port_id)\n"
540 " Set the bonding mode on a bonded device.\n\n"
542 "set bonding primary (slave_id) (port_id)\n"
543 " Set the primary slave for a bonded device.\n\n"
545 "show bonding config (port_id)\n"
546 " Show the bonding config for port_id.\n\n"
548 "set bonding mac_addr (port_id) (address)\n"
549 " Set the MAC address of a bonded device.\n\n"
551 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
552 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
554 "set bonding mon_period (port_id) (value)\n"
555 " Set the bonding link status monitoring polling period in ms.\n\n"
557 "set link-up port (port_id)\n"
558 " Set link up for a port.\n\n"
560 "set link-down port (port_id)\n"
561 " Set link down for a port.\n\n"
563 "E-tag set insertion on port-tag-id (value)"
564 " port (port_id) vf (vf_id)\n"
565 " Enable E-tag insertion for a VF on a port\n\n"
567 "E-tag set insertion off port (port_id) vf (vf_id)\n"
568 " Disable E-tag insertion for a VF on a port\n\n"
570 "E-tag set stripping (on|off) port (port_id)\n"
571 " Enable/disable E-tag stripping on a port\n\n"
573 "E-tag set forwarding (on|off) port (port_id)\n"
574 " Enable/disable E-tag based forwarding"
577 "E-tag set filter add e-tag-id (value) dst-pool"
578 " (pool_id) port (port_id)\n"
579 " Add an E-tag forwarding filter on a port\n\n"
581 "E-tag set filter del e-tag-id (value) port (port_id)\n"
582 " Delete an E-tag forwarding filter on a port\n\n"
584 , list_pkt_forwarding_modes()
588 if (show_all || !strcmp(res->section, "ports")) {
594 "----------------\n\n"
596 "port start (port_id|all)\n"
597 " Start all ports or port_id.\n\n"
599 "port stop (port_id|all)\n"
600 " Stop all ports or port_id.\n\n"
602 "port close (port_id|all)\n"
603 " Close all ports or port_id.\n\n"
605 "port attach (ident)\n"
606 " Attach physical or virtual dev by pci address or virtual device name\n\n"
608 "port detach (port_id)\n"
609 " Detach physical or virtual dev by port_id\n\n"
611 "port config (port_id|all)"
612 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
613 " duplex (half|full|auto)\n"
614 " Set speed and duplex for all ports or port_id\n\n"
616 "port config all (rxq|txq|rxd|txd) (value)\n"
617 " Set number for rxq/txq/rxd/txd.\n\n"
619 "port config all max-pkt-len (value)\n"
620 " Set the max packet length.\n\n"
622 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
623 "hw-vlan-strip|hw-vlan-extend|drop-en)"
625 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
628 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
629 " Set the RSS mode.\n\n"
631 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
632 " Set the RSS redirection table.\n\n"
634 "port config (port_id) dcb vt (on|off) (traffic_class)"
636 " Set the DCB mode.\n\n"
638 "port config all burst (value)\n"
639 " Set the number of packets per burst.\n\n"
641 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
643 " Set the ring prefetch/host/writeback threshold"
644 " for tx/rx queue.\n\n"
646 "port config all (txfreet|txrst|rxfreet) (value)\n"
647 " Set free threshold for rx/tx, or set"
648 " tx rs bit threshold.\n\n"
649 "port config mtu X value\n"
650 " Set the MTU of port X to a given value\n\n"
652 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
653 " Start/stop a rx/tx queue of port X. Only take effect"
654 " when port X is started\n\n"
656 "port config (port_id|all) l2-tunnel E-tag ether-type"
658 " Set the value of E-tag ether-type.\n\n"
660 "port config (port_id|all) l2-tunnel E-tag"
661 " (enable|disable)\n"
662 " Enable/disable the E-tag support.\n\n"
666 if (show_all || !strcmp(res->section, "registers")) {
674 "read reg (port_id) (address)\n"
675 " Display value of a port register.\n\n"
677 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
678 " Display a port register bit field.\n\n"
680 "read regbit (port_id) (address) (bit_x)\n"
681 " Display a single port register bit.\n\n"
683 "write reg (port_id) (address) (value)\n"
684 " Set value of a port register.\n\n"
686 "write regfield (port_id) (address) (bit_x) (bit_y)"
688 " Set bit field of a port register.\n\n"
690 "write regbit (port_id) (address) (bit_x) (value)\n"
691 " Set single bit value of a port register.\n\n"
694 if (show_all || !strcmp(res->section, "filters")) {
702 "ethertype_filter (port_id) (add|del)"
703 " (mac_addr|mac_ignr) (mac_address) ethertype"
704 " (ether_type) (drop|fwd) queue (queue_id)\n"
705 " Add/Del an ethertype filter.\n\n"
707 "2tuple_filter (port_id) (add|del)"
708 " dst_port (dst_port_value) protocol (protocol_value)"
709 " mask (mask_value) tcp_flags (tcp_flags_value)"
710 " priority (prio_value) queue (queue_id)\n"
711 " Add/Del a 2tuple filter.\n\n"
713 "5tuple_filter (port_id) (add|del)"
714 " dst_ip (dst_address) src_ip (src_address)"
715 " dst_port (dst_port_value) src_port (src_port_value)"
716 " protocol (protocol_value)"
717 " mask (mask_value) tcp_flags (tcp_flags_value)"
718 " priority (prio_value) queue (queue_id)\n"
719 " Add/Del a 5tuple filter.\n\n"
721 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
722 " Add/Del syn filter.\n\n"
724 "flex_filter (port_id) (add|del) len (len_value)"
725 " bytes (bytes_value) mask (mask_value)"
726 " priority (prio_value) queue (queue_id)\n"
727 " Add/Del a flex filter.\n\n"
729 "flow_director_filter (port_id) mode IP (add|del|update)"
730 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
731 " src (src_ip_address) dst (dst_ip_address)"
732 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
733 " vlan (vlan_value) flexbytes (flexbytes_value)"
734 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
735 " fd_id (fd_id_value)\n"
736 " Add/Del an IP type flow director filter.\n\n"
738 "flow_director_filter (port_id) mode IP (add|del|update)"
739 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
740 " src (src_ip_address) (src_port)"
741 " dst (dst_ip_address) (dst_port)"
742 " tos (tos_value) ttl (ttl_value)"
743 " vlan (vlan_value) flexbytes (flexbytes_value)"
744 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
745 " fd_id (fd_id_value)\n"
746 " Add/Del an UDP/TCP type flow director filter.\n\n"
748 "flow_director_filter (port_id) mode IP (add|del|update)"
749 " flow (ipv4-sctp|ipv6-sctp)"
750 " src (src_ip_address) (src_port)"
751 " dst (dst_ip_address) (dst_port)"
752 " tag (verification_tag) "
753 " tos (tos_value) ttl (ttl_value)"
755 " flexbytes (flexbytes_value) (drop|fwd)"
756 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
757 " Add/Del a SCTP type flow director filter.\n\n"
759 "flow_director_filter (port_id) mode IP (add|del|update)"
760 " flow l2_payload ether (ethertype)"
761 " flexbytes (flexbytes_value) (drop|fwd)"
762 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
763 " Add/Del a l2 payload type flow director filter.\n\n"
765 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
766 " mac (mac_address) vlan (vlan_value)"
767 " flexbytes (flexbytes_value) (drop|fwd)"
768 " queue (queue_id) fd_id (fd_id_value)\n"
769 " Add/Del a MAC-VLAN flow director filter.\n\n"
771 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
772 " mac (mac_address) vlan (vlan_value)"
773 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
774 " flexbytes (flexbytes_value) (drop|fwd)"
775 " queue (queue_id) fd_id (fd_id_value)\n"
776 " Add/Del a Tunnel flow director filter.\n\n"
778 "flush_flow_director (port_id)\n"
779 " Flush all flow director entries of a device.\n\n"
781 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
782 " src_mask (ipv4_src) (ipv6_src) (src_port)"
783 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
784 " Set flow director IP mask.\n\n"
786 "flow_director_mask (port_id) mode MAC-VLAN"
787 " vlan (vlan_value)\n"
788 " Set flow director MAC-VLAN mask.\n\n"
790 "flow_director_mask (port_id) mode Tunnel"
791 " vlan (vlan_value) mac (mac_value)"
792 " tunnel-type (tunnel_type_value)"
793 " tunnel-id (tunnel_id_value)\n"
794 " Set flow director Tunnel mask.\n\n"
796 "flow_director_flex_mask (port_id)"
797 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
798 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
800 " Configure mask of flex payload.\n\n"
802 "flow_director_flex_payload (port_id)"
803 " (raw|l2|l3|l4) (config)\n"
804 " Configure flex payload selection.\n\n"
806 "get_sym_hash_ena_per_port (port_id)\n"
807 " get symmetric hash enable configuration per port.\n\n"
809 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
810 " set symmetric hash enable configuration per port"
811 " to enable or disable.\n\n"
813 "get_hash_global_config (port_id)\n"
814 " Get the global configurations of hash filters.\n\n"
816 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
817 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
818 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
819 " (enable|disable)\n"
820 " Set the global configurations of hash filters.\n\n"
822 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
823 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
824 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
825 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
826 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
827 "ipv6-next-header|udp-src-port|udp-dst-port|"
828 "tcp-src-port|tcp-dst-port|sctp-src-port|"
829 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
830 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
831 "fld-8th|none) (select|add)\n"
832 " Set the input set for hash.\n\n"
834 "set_fdir_input_set (port_id) "
835 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
836 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
837 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
838 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
839 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
840 "udp-dst-port|tcp-src-port|tcp-dst-port|"
841 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
843 " Set the input set for FDir.\n\n"
845 "flow validate {port_id}"
846 " [group {group_id}] [priority {level}]"
847 " [ingress] [egress]"
848 " pattern {item} [/ {item} [...]] / end"
849 " actions {action} [/ {action} [...]] / end\n"
850 " Check whether a flow rule can be created.\n\n"
852 "flow create {port_id}"
853 " [group {group_id}] [priority {level}]"
854 " [ingress] [egress]"
855 " pattern {item} [/ {item} [...]] / end"
856 " actions {action} [/ {action} [...]] / end\n"
857 " Create a flow rule.\n\n"
859 "flow destroy {port_id} rule {rule_id} [...]\n"
860 " Destroy specific flow rules.\n\n"
862 "flow flush {port_id}\n"
863 " Destroy all flow rules.\n\n"
865 "flow query {port_id} {rule_id} {action}\n"
866 " Query an existing flow rule.\n\n"
868 "flow list {port_id} [group {group_id}] [...]\n"
869 " List existing flow rules sorted by priority,"
870 " filtered by group identifiers.\n\n"
875 cmdline_parse_token_string_t cmd_help_long_help =
876 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
878 cmdline_parse_token_string_t cmd_help_long_section =
879 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
880 "all#control#display#config#"
881 "ports#registers#filters");
883 cmdline_parse_inst_t cmd_help_long = {
884 .f = cmd_help_long_parsed,
886 .help_str = "help all|control|display|config|ports|register|filters: "
889 (void *)&cmd_help_long_help,
890 (void *)&cmd_help_long_section,
896 /* *** start/stop/close all ports *** */
897 struct cmd_operate_port_result {
898 cmdline_fixed_string_t keyword;
899 cmdline_fixed_string_t name;
900 cmdline_fixed_string_t value;
903 static void cmd_operate_port_parsed(void *parsed_result,
904 __attribute__((unused)) struct cmdline *cl,
905 __attribute__((unused)) void *data)
907 struct cmd_operate_port_result *res = parsed_result;
909 if (!strcmp(res->name, "start"))
910 start_port(RTE_PORT_ALL);
911 else if (!strcmp(res->name, "stop"))
912 stop_port(RTE_PORT_ALL);
913 else if (!strcmp(res->name, "close"))
914 close_port(RTE_PORT_ALL);
916 printf("Unknown parameter\n");
919 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
920 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
922 cmdline_parse_token_string_t cmd_operate_port_all_port =
923 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
925 cmdline_parse_token_string_t cmd_operate_port_all_all =
926 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
928 cmdline_parse_inst_t cmd_operate_port = {
929 .f = cmd_operate_port_parsed,
931 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
933 (void *)&cmd_operate_port_all_cmd,
934 (void *)&cmd_operate_port_all_port,
935 (void *)&cmd_operate_port_all_all,
940 /* *** start/stop/close specific port *** */
941 struct cmd_operate_specific_port_result {
942 cmdline_fixed_string_t keyword;
943 cmdline_fixed_string_t name;
947 static void cmd_operate_specific_port_parsed(void *parsed_result,
948 __attribute__((unused)) struct cmdline *cl,
949 __attribute__((unused)) void *data)
951 struct cmd_operate_specific_port_result *res = parsed_result;
953 if (!strcmp(res->name, "start"))
954 start_port(res->value);
955 else if (!strcmp(res->name, "stop"))
956 stop_port(res->value);
957 else if (!strcmp(res->name, "close"))
958 close_port(res->value);
960 printf("Unknown parameter\n");
963 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
964 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
966 cmdline_parse_token_string_t cmd_operate_specific_port_port =
967 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
968 name, "start#stop#close");
969 cmdline_parse_token_num_t cmd_operate_specific_port_id =
970 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
973 cmdline_parse_inst_t cmd_operate_specific_port = {
974 .f = cmd_operate_specific_port_parsed,
976 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
978 (void *)&cmd_operate_specific_port_cmd,
979 (void *)&cmd_operate_specific_port_port,
980 (void *)&cmd_operate_specific_port_id,
985 /* *** attach a specified port *** */
986 struct cmd_operate_attach_port_result {
987 cmdline_fixed_string_t port;
988 cmdline_fixed_string_t keyword;
989 cmdline_fixed_string_t identifier;
992 static void cmd_operate_attach_port_parsed(void *parsed_result,
993 __attribute__((unused)) struct cmdline *cl,
994 __attribute__((unused)) void *data)
996 struct cmd_operate_attach_port_result *res = parsed_result;
998 if (!strcmp(res->keyword, "attach"))
999 attach_port(res->identifier);
1001 printf("Unknown parameter\n");
1004 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1005 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1007 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1008 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1010 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1011 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1014 cmdline_parse_inst_t cmd_operate_attach_port = {
1015 .f = cmd_operate_attach_port_parsed,
1017 .help_str = "port attach <identifier>: "
1018 "(identifier: pci address or virtual dev name)",
1020 (void *)&cmd_operate_attach_port_port,
1021 (void *)&cmd_operate_attach_port_keyword,
1022 (void *)&cmd_operate_attach_port_identifier,
1027 /* *** detach a specified port *** */
1028 struct cmd_operate_detach_port_result {
1029 cmdline_fixed_string_t port;
1030 cmdline_fixed_string_t keyword;
1034 static void cmd_operate_detach_port_parsed(void *parsed_result,
1035 __attribute__((unused)) struct cmdline *cl,
1036 __attribute__((unused)) void *data)
1038 struct cmd_operate_detach_port_result *res = parsed_result;
1040 if (!strcmp(res->keyword, "detach"))
1041 detach_port(res->port_id);
1043 printf("Unknown parameter\n");
1046 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1047 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1049 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1050 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1052 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1053 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1056 cmdline_parse_inst_t cmd_operate_detach_port = {
1057 .f = cmd_operate_detach_port_parsed,
1059 .help_str = "port detach <port_id>",
1061 (void *)&cmd_operate_detach_port_port,
1062 (void *)&cmd_operate_detach_port_keyword,
1063 (void *)&cmd_operate_detach_port_port_id,
1068 /* *** configure speed for all ports *** */
1069 struct cmd_config_speed_all {
1070 cmdline_fixed_string_t port;
1071 cmdline_fixed_string_t keyword;
1072 cmdline_fixed_string_t all;
1073 cmdline_fixed_string_t item1;
1074 cmdline_fixed_string_t item2;
1075 cmdline_fixed_string_t value1;
1076 cmdline_fixed_string_t value2;
1080 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1085 if (!strcmp(duplexstr, "half")) {
1086 duplex = ETH_LINK_HALF_DUPLEX;
1087 } else if (!strcmp(duplexstr, "full")) {
1088 duplex = ETH_LINK_FULL_DUPLEX;
1089 } else if (!strcmp(duplexstr, "auto")) {
1090 duplex = ETH_LINK_FULL_DUPLEX;
1092 printf("Unknown duplex parameter\n");
1096 if (!strcmp(speedstr, "10")) {
1097 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1098 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1099 } else if (!strcmp(speedstr, "100")) {
1100 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1101 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1103 if (duplex != ETH_LINK_FULL_DUPLEX) {
1104 printf("Invalid speed/duplex parameters\n");
1107 if (!strcmp(speedstr, "1000")) {
1108 *speed = ETH_LINK_SPEED_1G;
1109 } else if (!strcmp(speedstr, "10000")) {
1110 *speed = ETH_LINK_SPEED_10G;
1111 } else if (!strcmp(speedstr, "25000")) {
1112 *speed = ETH_LINK_SPEED_25G;
1113 } else if (!strcmp(speedstr, "40000")) {
1114 *speed = ETH_LINK_SPEED_40G;
1115 } else if (!strcmp(speedstr, "50000")) {
1116 *speed = ETH_LINK_SPEED_50G;
1117 } else if (!strcmp(speedstr, "100000")) {
1118 *speed = ETH_LINK_SPEED_100G;
1119 } else if (!strcmp(speedstr, "auto")) {
1120 *speed = ETH_LINK_SPEED_AUTONEG;
1122 printf("Unknown speed parameter\n");
1131 cmd_config_speed_all_parsed(void *parsed_result,
1132 __attribute__((unused)) struct cmdline *cl,
1133 __attribute__((unused)) void *data)
1135 struct cmd_config_speed_all *res = parsed_result;
1136 uint32_t link_speed;
1139 if (!all_ports_stopped()) {
1140 printf("Please stop all ports first\n");
1144 if (parse_and_check_speed_duplex(res->value1, res->value2,
1148 FOREACH_PORT(pid, ports) {
1149 ports[pid].dev_conf.link_speeds = link_speed;
1152 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1155 cmdline_parse_token_string_t cmd_config_speed_all_port =
1156 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1157 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1158 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1160 cmdline_parse_token_string_t cmd_config_speed_all_all =
1161 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1162 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1163 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1164 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1165 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1166 "10#100#1000#10000#25000#40000#50000#100000#auto");
1167 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1168 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1169 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1170 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1173 cmdline_parse_inst_t cmd_config_speed_all = {
1174 .f = cmd_config_speed_all_parsed,
1176 .help_str = "port config all speed "
1177 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1180 (void *)&cmd_config_speed_all_port,
1181 (void *)&cmd_config_speed_all_keyword,
1182 (void *)&cmd_config_speed_all_all,
1183 (void *)&cmd_config_speed_all_item1,
1184 (void *)&cmd_config_speed_all_value1,
1185 (void *)&cmd_config_speed_all_item2,
1186 (void *)&cmd_config_speed_all_value2,
1191 /* *** configure speed for specific port *** */
1192 struct cmd_config_speed_specific {
1193 cmdline_fixed_string_t port;
1194 cmdline_fixed_string_t keyword;
1196 cmdline_fixed_string_t item1;
1197 cmdline_fixed_string_t item2;
1198 cmdline_fixed_string_t value1;
1199 cmdline_fixed_string_t value2;
1203 cmd_config_speed_specific_parsed(void *parsed_result,
1204 __attribute__((unused)) struct cmdline *cl,
1205 __attribute__((unused)) void *data)
1207 struct cmd_config_speed_specific *res = parsed_result;
1208 uint32_t link_speed;
1210 if (!all_ports_stopped()) {
1211 printf("Please stop all ports first\n");
1215 if (port_id_is_invalid(res->id, ENABLED_WARN))
1218 if (parse_and_check_speed_duplex(res->value1, res->value2,
1222 ports[res->id].dev_conf.link_speeds = link_speed;
1224 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1228 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1229 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1231 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1232 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1234 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1235 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1236 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1237 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1239 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1240 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1241 "10#100#1000#10000#25000#40000#50000#100000#auto");
1242 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1243 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1245 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1246 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1249 cmdline_parse_inst_t cmd_config_speed_specific = {
1250 .f = cmd_config_speed_specific_parsed,
1252 .help_str = "port config <port_id> speed "
1253 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1256 (void *)&cmd_config_speed_specific_port,
1257 (void *)&cmd_config_speed_specific_keyword,
1258 (void *)&cmd_config_speed_specific_id,
1259 (void *)&cmd_config_speed_specific_item1,
1260 (void *)&cmd_config_speed_specific_value1,
1261 (void *)&cmd_config_speed_specific_item2,
1262 (void *)&cmd_config_speed_specific_value2,
1267 /* *** configure txq/rxq, txd/rxd *** */
1268 struct cmd_config_rx_tx {
1269 cmdline_fixed_string_t port;
1270 cmdline_fixed_string_t keyword;
1271 cmdline_fixed_string_t all;
1272 cmdline_fixed_string_t name;
1277 cmd_config_rx_tx_parsed(void *parsed_result,
1278 __attribute__((unused)) struct cmdline *cl,
1279 __attribute__((unused)) void *data)
1281 struct cmd_config_rx_tx *res = parsed_result;
1283 if (!all_ports_stopped()) {
1284 printf("Please stop all ports first\n");
1287 if (!strcmp(res->name, "rxq")) {
1288 if (!res->value && !nb_txq) {
1289 printf("Warning: Either rx or tx queues should be non zero\n");
1292 nb_rxq = res->value;
1294 else if (!strcmp(res->name, "txq")) {
1295 if (!res->value && !nb_rxq) {
1296 printf("Warning: Either rx or tx queues should be non zero\n");
1299 nb_txq = res->value;
1301 else if (!strcmp(res->name, "rxd")) {
1302 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1303 printf("rxd %d invalid - must be > 0 && <= %d\n",
1304 res->value, RTE_TEST_RX_DESC_MAX);
1307 nb_rxd = res->value;
1308 } else if (!strcmp(res->name, "txd")) {
1309 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1310 printf("txd %d invalid - must be > 0 && <= %d\n",
1311 res->value, RTE_TEST_TX_DESC_MAX);
1314 nb_txd = res->value;
1316 printf("Unknown parameter\n");
1324 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1327 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1328 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1329 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1330 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1331 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1332 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1333 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1334 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1336 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1337 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1339 cmdline_parse_inst_t cmd_config_rx_tx = {
1340 .f = cmd_config_rx_tx_parsed,
1342 .help_str = "port config all rxq|txq|rxd|txd <value>",
1344 (void *)&cmd_config_rx_tx_port,
1345 (void *)&cmd_config_rx_tx_keyword,
1346 (void *)&cmd_config_rx_tx_all,
1347 (void *)&cmd_config_rx_tx_name,
1348 (void *)&cmd_config_rx_tx_value,
1353 /* *** config max packet length *** */
1354 struct cmd_config_max_pkt_len_result {
1355 cmdline_fixed_string_t port;
1356 cmdline_fixed_string_t keyword;
1357 cmdline_fixed_string_t all;
1358 cmdline_fixed_string_t name;
1363 cmd_config_max_pkt_len_parsed(void *parsed_result,
1364 __attribute__((unused)) struct cmdline *cl,
1365 __attribute__((unused)) void *data)
1367 struct cmd_config_max_pkt_len_result *res = parsed_result;
1369 if (!all_ports_stopped()) {
1370 printf("Please stop all ports first\n");
1374 if (!strcmp(res->name, "max-pkt-len")) {
1375 if (res->value < ETHER_MIN_LEN) {
1376 printf("max-pkt-len can not be less than %d\n",
1380 if (res->value == rx_mode.max_rx_pkt_len)
1383 rx_mode.max_rx_pkt_len = res->value;
1384 if (res->value > ETHER_MAX_LEN)
1385 rx_mode.jumbo_frame = 1;
1387 rx_mode.jumbo_frame = 0;
1389 printf("Unknown parameter\n");
1395 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1398 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1401 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1402 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1404 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1405 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1407 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1408 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1410 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1411 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1414 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1415 .f = cmd_config_max_pkt_len_parsed,
1417 .help_str = "port config all max-pkt-len <value>",
1419 (void *)&cmd_config_max_pkt_len_port,
1420 (void *)&cmd_config_max_pkt_len_keyword,
1421 (void *)&cmd_config_max_pkt_len_all,
1422 (void *)&cmd_config_max_pkt_len_name,
1423 (void *)&cmd_config_max_pkt_len_value,
1428 /* *** configure port MTU *** */
1429 struct cmd_config_mtu_result {
1430 cmdline_fixed_string_t port;
1431 cmdline_fixed_string_t keyword;
1432 cmdline_fixed_string_t mtu;
1438 cmd_config_mtu_parsed(void *parsed_result,
1439 __attribute__((unused)) struct cmdline *cl,
1440 __attribute__((unused)) void *data)
1442 struct cmd_config_mtu_result *res = parsed_result;
1444 if (res->value < ETHER_MIN_LEN) {
1445 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1448 port_mtu_set(res->port_id, res->value);
1451 cmdline_parse_token_string_t cmd_config_mtu_port =
1452 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1454 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1455 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1457 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1460 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1461 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1462 cmdline_parse_token_num_t cmd_config_mtu_value =
1463 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1465 cmdline_parse_inst_t cmd_config_mtu = {
1466 .f = cmd_config_mtu_parsed,
1468 .help_str = "port config mtu <port_id> <value>",
1470 (void *)&cmd_config_mtu_port,
1471 (void *)&cmd_config_mtu_keyword,
1472 (void *)&cmd_config_mtu_mtu,
1473 (void *)&cmd_config_mtu_port_id,
1474 (void *)&cmd_config_mtu_value,
1479 /* *** configure rx mode *** */
1480 struct cmd_config_rx_mode_flag {
1481 cmdline_fixed_string_t port;
1482 cmdline_fixed_string_t keyword;
1483 cmdline_fixed_string_t all;
1484 cmdline_fixed_string_t name;
1485 cmdline_fixed_string_t value;
1489 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1490 __attribute__((unused)) struct cmdline *cl,
1491 __attribute__((unused)) void *data)
1493 struct cmd_config_rx_mode_flag *res = parsed_result;
1495 if (!all_ports_stopped()) {
1496 printf("Please stop all ports first\n");
1500 if (!strcmp(res->name, "crc-strip")) {
1501 if (!strcmp(res->value, "on"))
1502 rx_mode.hw_strip_crc = 1;
1503 else if (!strcmp(res->value, "off"))
1504 rx_mode.hw_strip_crc = 0;
1506 printf("Unknown parameter\n");
1509 } else if (!strcmp(res->name, "scatter")) {
1510 if (!strcmp(res->value, "on"))
1511 rx_mode.enable_scatter = 1;
1512 else if (!strcmp(res->value, "off"))
1513 rx_mode.enable_scatter = 0;
1515 printf("Unknown parameter\n");
1518 } else if (!strcmp(res->name, "rx-cksum")) {
1519 if (!strcmp(res->value, "on"))
1520 rx_mode.hw_ip_checksum = 1;
1521 else if (!strcmp(res->value, "off"))
1522 rx_mode.hw_ip_checksum = 0;
1524 printf("Unknown parameter\n");
1527 } else if (!strcmp(res->name, "hw-vlan")) {
1528 if (!strcmp(res->value, "on")) {
1529 rx_mode.hw_vlan_filter = 1;
1530 rx_mode.hw_vlan_strip = 1;
1532 else if (!strcmp(res->value, "off")) {
1533 rx_mode.hw_vlan_filter = 0;
1534 rx_mode.hw_vlan_strip = 0;
1537 printf("Unknown parameter\n");
1540 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1541 if (!strcmp(res->value, "on"))
1542 rx_mode.hw_vlan_filter = 1;
1543 else if (!strcmp(res->value, "off"))
1544 rx_mode.hw_vlan_filter = 0;
1546 printf("Unknown parameter\n");
1549 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1550 if (!strcmp(res->value, "on"))
1551 rx_mode.hw_vlan_strip = 1;
1552 else if (!strcmp(res->value, "off"))
1553 rx_mode.hw_vlan_strip = 0;
1555 printf("Unknown parameter\n");
1558 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1559 if (!strcmp(res->value, "on"))
1560 rx_mode.hw_vlan_extend = 1;
1561 else if (!strcmp(res->value, "off"))
1562 rx_mode.hw_vlan_extend = 0;
1564 printf("Unknown parameter\n");
1567 } else if (!strcmp(res->name, "drop-en")) {
1568 if (!strcmp(res->value, "on"))
1570 else if (!strcmp(res->value, "off"))
1573 printf("Unknown parameter\n");
1577 printf("Unknown parameter\n");
1583 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1586 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1587 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1588 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1589 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1591 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1592 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1593 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1594 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1595 "crc-strip#scatter#rx-cksum#hw-vlan#"
1596 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1597 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1598 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1601 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1602 .f = cmd_config_rx_mode_flag_parsed,
1604 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1605 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1607 (void *)&cmd_config_rx_mode_flag_port,
1608 (void *)&cmd_config_rx_mode_flag_keyword,
1609 (void *)&cmd_config_rx_mode_flag_all,
1610 (void *)&cmd_config_rx_mode_flag_name,
1611 (void *)&cmd_config_rx_mode_flag_value,
1616 /* *** configure rss *** */
1617 struct cmd_config_rss {
1618 cmdline_fixed_string_t port;
1619 cmdline_fixed_string_t keyword;
1620 cmdline_fixed_string_t all;
1621 cmdline_fixed_string_t name;
1622 cmdline_fixed_string_t value;
1626 cmd_config_rss_parsed(void *parsed_result,
1627 __attribute__((unused)) struct cmdline *cl,
1628 __attribute__((unused)) void *data)
1630 struct cmd_config_rss *res = parsed_result;
1631 struct rte_eth_rss_conf rss_conf;
1635 if (!strcmp(res->value, "all"))
1636 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1637 ETH_RSS_UDP | ETH_RSS_SCTP |
1639 else if (!strcmp(res->value, "ip"))
1640 rss_conf.rss_hf = ETH_RSS_IP;
1641 else if (!strcmp(res->value, "udp"))
1642 rss_conf.rss_hf = ETH_RSS_UDP;
1643 else if (!strcmp(res->value, "tcp"))
1644 rss_conf.rss_hf = ETH_RSS_TCP;
1645 else if (!strcmp(res->value, "sctp"))
1646 rss_conf.rss_hf = ETH_RSS_SCTP;
1647 else if (!strcmp(res->value, "ether"))
1648 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1649 else if (!strcmp(res->value, "port"))
1650 rss_conf.rss_hf = ETH_RSS_PORT;
1651 else if (!strcmp(res->value, "vxlan"))
1652 rss_conf.rss_hf = ETH_RSS_VXLAN;
1653 else if (!strcmp(res->value, "geneve"))
1654 rss_conf.rss_hf = ETH_RSS_GENEVE;
1655 else if (!strcmp(res->value, "nvgre"))
1656 rss_conf.rss_hf = ETH_RSS_NVGRE;
1657 else if (!strcmp(res->value, "none"))
1658 rss_conf.rss_hf = 0;
1660 printf("Unknown parameter\n");
1663 rss_conf.rss_key = NULL;
1664 for (i = 0; i < rte_eth_dev_count(); i++) {
1665 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1667 printf("Configuration of RSS hash at ethernet port %d "
1668 "failed with error (%d): %s.\n",
1669 i, -diag, strerror(-diag));
1673 cmdline_parse_token_string_t cmd_config_rss_port =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1675 cmdline_parse_token_string_t cmd_config_rss_keyword =
1676 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1677 cmdline_parse_token_string_t cmd_config_rss_all =
1678 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1679 cmdline_parse_token_string_t cmd_config_rss_name =
1680 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1681 cmdline_parse_token_string_t cmd_config_rss_value =
1682 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1683 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1685 cmdline_parse_inst_t cmd_config_rss = {
1686 .f = cmd_config_rss_parsed,
1688 .help_str = "port config all rss "
1689 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1691 (void *)&cmd_config_rss_port,
1692 (void *)&cmd_config_rss_keyword,
1693 (void *)&cmd_config_rss_all,
1694 (void *)&cmd_config_rss_name,
1695 (void *)&cmd_config_rss_value,
1700 /* *** configure rss hash key *** */
1701 struct cmd_config_rss_hash_key {
1702 cmdline_fixed_string_t port;
1703 cmdline_fixed_string_t config;
1705 cmdline_fixed_string_t rss_hash_key;
1706 cmdline_fixed_string_t rss_type;
1707 cmdline_fixed_string_t key;
1711 hexa_digit_to_value(char hexa_digit)
1713 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1714 return (uint8_t) (hexa_digit - '0');
1715 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1716 return (uint8_t) ((hexa_digit - 'a') + 10);
1717 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1718 return (uint8_t) ((hexa_digit - 'A') + 10);
1719 /* Invalid hexa digit */
1724 parse_and_check_key_hexa_digit(char *key, int idx)
1728 hexa_v = hexa_digit_to_value(key[idx]);
1730 printf("invalid key: character %c at position %d is not a "
1731 "valid hexa digit\n", key[idx], idx);
1736 cmd_config_rss_hash_key_parsed(void *parsed_result,
1737 __attribute__((unused)) struct cmdline *cl,
1738 __attribute__((unused)) void *data)
1740 struct cmd_config_rss_hash_key *res = parsed_result;
1741 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1745 struct rte_eth_dev_info dev_info;
1746 uint8_t hash_key_size;
1749 memset(&dev_info, 0, sizeof(dev_info));
1750 rte_eth_dev_info_get(res->port_id, &dev_info);
1751 if (dev_info.hash_key_size > 0 &&
1752 dev_info.hash_key_size <= sizeof(hash_key))
1753 hash_key_size = dev_info.hash_key_size;
1755 printf("dev_info did not provide a valid hash key size\n");
1758 /* Check the length of the RSS hash key */
1759 key_len = strlen(res->key);
1760 if (key_len != (hash_key_size * 2)) {
1761 printf("key length: %d invalid - key must be a string of %d"
1762 " hexa-decimal numbers\n",
1763 (int) key_len, hash_key_size * 2);
1766 /* Translate RSS hash key into binary representation */
1767 for (i = 0; i < hash_key_size; i++) {
1768 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1771 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1774 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1776 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1780 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1781 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1782 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1783 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1785 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1786 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1787 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1788 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1789 rss_hash_key, "rss-hash-key");
1790 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1791 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1792 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1793 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1794 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1795 "ipv6-tcp-ex#ipv6-udp-ex");
1796 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1797 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1799 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1800 .f = cmd_config_rss_hash_key_parsed,
1802 .help_str = "port config <port_id> rss-hash-key "
1803 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1804 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1805 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1806 "<string of hex digits (variable length, NIC dependent)>",
1808 (void *)&cmd_config_rss_hash_key_port,
1809 (void *)&cmd_config_rss_hash_key_config,
1810 (void *)&cmd_config_rss_hash_key_port_id,
1811 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1812 (void *)&cmd_config_rss_hash_key_rss_type,
1813 (void *)&cmd_config_rss_hash_key_value,
1818 /* *** configure port rxq/txq start/stop *** */
1819 struct cmd_config_rxtx_queue {
1820 cmdline_fixed_string_t port;
1822 cmdline_fixed_string_t rxtxq;
1824 cmdline_fixed_string_t opname;
1828 cmd_config_rxtx_queue_parsed(void *parsed_result,
1829 __attribute__((unused)) struct cmdline *cl,
1830 __attribute__((unused)) void *data)
1832 struct cmd_config_rxtx_queue *res = parsed_result;
1837 if (test_done == 0) {
1838 printf("Please stop forwarding first\n");
1842 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1845 if (port_is_started(res->portid) != 1) {
1846 printf("Please start port %u first\n", res->portid);
1850 if (!strcmp(res->rxtxq, "rxq"))
1852 else if (!strcmp(res->rxtxq, "txq"))
1855 printf("Unknown parameter\n");
1859 if (isrx && rx_queue_id_is_invalid(res->qid))
1861 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1864 if (!strcmp(res->opname, "start"))
1866 else if (!strcmp(res->opname, "stop"))
1869 printf("Unknown parameter\n");
1873 if (isstart && isrx)
1874 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1875 else if (!isstart && isrx)
1876 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1877 else if (isstart && !isrx)
1878 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1880 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1882 if (ret == -ENOTSUP)
1883 printf("Function not supported in PMD driver\n");
1886 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1887 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1888 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1889 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1890 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1891 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1892 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1893 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1894 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1895 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1898 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1899 .f = cmd_config_rxtx_queue_parsed,
1901 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1903 (void *)&cmd_config_speed_all_port,
1904 (void *)&cmd_config_rxtx_queue_portid,
1905 (void *)&cmd_config_rxtx_queue_rxtxq,
1906 (void *)&cmd_config_rxtx_queue_qid,
1907 (void *)&cmd_config_rxtx_queue_opname,
1912 /* *** Configure RSS RETA *** */
1913 struct cmd_config_rss_reta {
1914 cmdline_fixed_string_t port;
1915 cmdline_fixed_string_t keyword;
1917 cmdline_fixed_string_t name;
1918 cmdline_fixed_string_t list_name;
1919 cmdline_fixed_string_t list_of_items;
1923 parse_reta_config(const char *str,
1924 struct rte_eth_rss_reta_entry64 *reta_conf,
1925 uint16_t nb_entries)
1929 uint16_t hash_index, idx, shift;
1932 const char *p, *p0 = str;
1939 unsigned long int_fld[_NUM_FLD];
1940 char *str_fld[_NUM_FLD];
1942 while ((p = strchr(p0,'(')) != NULL) {
1944 if((p0 = strchr(p,')')) == NULL)
1948 if(size >= sizeof(s))
1951 snprintf(s, sizeof(s), "%.*s", size, p);
1952 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1954 for (i = 0; i < _NUM_FLD; i++) {
1956 int_fld[i] = strtoul(str_fld[i], &end, 0);
1957 if (errno != 0 || end == str_fld[i] ||
1962 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1963 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1965 if (hash_index >= nb_entries) {
1966 printf("Invalid RETA hash index=%d\n", hash_index);
1970 idx = hash_index / RTE_RETA_GROUP_SIZE;
1971 shift = hash_index % RTE_RETA_GROUP_SIZE;
1972 reta_conf[idx].mask |= (1ULL << shift);
1973 reta_conf[idx].reta[shift] = nb_queue;
1980 cmd_set_rss_reta_parsed(void *parsed_result,
1981 __attribute__((unused)) struct cmdline *cl,
1982 __attribute__((unused)) void *data)
1985 struct rte_eth_dev_info dev_info;
1986 struct rte_eth_rss_reta_entry64 reta_conf[8];
1987 struct cmd_config_rss_reta *res = parsed_result;
1989 memset(&dev_info, 0, sizeof(dev_info));
1990 rte_eth_dev_info_get(res->port_id, &dev_info);
1991 if (dev_info.reta_size == 0) {
1992 printf("Redirection table size is 0 which is "
1993 "invalid for RSS\n");
1996 printf("The reta size of port %d is %u\n",
1997 res->port_id, dev_info.reta_size);
1998 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1999 printf("Currently do not support more than %u entries of "
2000 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2004 memset(reta_conf, 0, sizeof(reta_conf));
2005 if (!strcmp(res->list_name, "reta")) {
2006 if (parse_reta_config(res->list_of_items, reta_conf,
2007 dev_info.reta_size)) {
2008 printf("Invalid RSS Redirection Table "
2009 "config entered\n");
2012 ret = rte_eth_dev_rss_reta_update(res->port_id,
2013 reta_conf, dev_info.reta_size);
2015 printf("Bad redirection table parameter, "
2016 "return code = %d \n", ret);
2020 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2021 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2022 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2023 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2024 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2025 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2026 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2027 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2028 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2029 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2030 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2031 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2033 cmdline_parse_inst_t cmd_config_rss_reta = {
2034 .f = cmd_set_rss_reta_parsed,
2036 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2038 (void *)&cmd_config_rss_reta_port,
2039 (void *)&cmd_config_rss_reta_keyword,
2040 (void *)&cmd_config_rss_reta_port_id,
2041 (void *)&cmd_config_rss_reta_name,
2042 (void *)&cmd_config_rss_reta_list_name,
2043 (void *)&cmd_config_rss_reta_list_of_items,
2048 /* *** SHOW PORT RETA INFO *** */
2049 struct cmd_showport_reta {
2050 cmdline_fixed_string_t show;
2051 cmdline_fixed_string_t port;
2053 cmdline_fixed_string_t rss;
2054 cmdline_fixed_string_t reta;
2056 cmdline_fixed_string_t list_of_items;
2060 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2061 uint16_t nb_entries,
2065 const char *p, *p0 = str;
2069 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2072 p = strchr(p0, '(');
2076 p0 = strchr(p, ')');
2080 if (size >= sizeof(s)) {
2081 printf("The string size exceeds the internal buffer size\n");
2084 snprintf(s, sizeof(s), "%.*s", size, p);
2085 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2086 if (ret <= 0 || ret != num) {
2087 printf("The bits of masks do not match the number of "
2088 "reta entries: %u\n", num);
2091 for (i = 0; i < ret; i++)
2092 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2098 cmd_showport_reta_parsed(void *parsed_result,
2099 __attribute__((unused)) struct cmdline *cl,
2100 __attribute__((unused)) void *data)
2102 struct cmd_showport_reta *res = parsed_result;
2103 struct rte_eth_rss_reta_entry64 reta_conf[8];
2104 struct rte_eth_dev_info dev_info;
2106 memset(&dev_info, 0, sizeof(dev_info));
2107 rte_eth_dev_info_get(res->port_id, &dev_info);
2108 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2109 res->size > ETH_RSS_RETA_SIZE_512) {
2110 printf("Invalid redirection table size: %u\n", res->size);
2114 memset(reta_conf, 0, sizeof(reta_conf));
2115 if (showport_parse_reta_config(reta_conf, res->size,
2116 res->list_of_items) < 0) {
2117 printf("Invalid string: %s for reta masks\n",
2118 res->list_of_items);
2121 port_rss_reta_info(res->port_id, reta_conf, res->size);
2124 cmdline_parse_token_string_t cmd_showport_reta_show =
2125 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2126 cmdline_parse_token_string_t cmd_showport_reta_port =
2127 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2128 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2129 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2130 cmdline_parse_token_string_t cmd_showport_reta_rss =
2131 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2132 cmdline_parse_token_string_t cmd_showport_reta_reta =
2133 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2134 cmdline_parse_token_num_t cmd_showport_reta_size =
2135 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2136 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2137 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2138 list_of_items, NULL);
2140 cmdline_parse_inst_t cmd_showport_reta = {
2141 .f = cmd_showport_reta_parsed,
2143 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2145 (void *)&cmd_showport_reta_show,
2146 (void *)&cmd_showport_reta_port,
2147 (void *)&cmd_showport_reta_port_id,
2148 (void *)&cmd_showport_reta_rss,
2149 (void *)&cmd_showport_reta_reta,
2150 (void *)&cmd_showport_reta_size,
2151 (void *)&cmd_showport_reta_list_of_items,
2156 /* *** Show RSS hash configuration *** */
2157 struct cmd_showport_rss_hash {
2158 cmdline_fixed_string_t show;
2159 cmdline_fixed_string_t port;
2161 cmdline_fixed_string_t rss_hash;
2162 cmdline_fixed_string_t rss_type;
2163 cmdline_fixed_string_t key; /* optional argument */
2166 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2167 __attribute__((unused)) struct cmdline *cl,
2170 struct cmd_showport_rss_hash *res = parsed_result;
2172 port_rss_hash_conf_show(res->port_id, res->rss_type,
2173 show_rss_key != NULL);
2176 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2177 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2178 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2179 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2180 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2181 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2182 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2183 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2185 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2186 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2187 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2188 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2189 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2190 "ipv6-tcp-ex#ipv6-udp-ex");
2191 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2192 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2194 cmdline_parse_inst_t cmd_showport_rss_hash = {
2195 .f = cmd_showport_rss_hash_parsed,
2197 .help_str = "show port <port_id> rss-hash "
2198 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2199 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2200 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2202 (void *)&cmd_showport_rss_hash_show,
2203 (void *)&cmd_showport_rss_hash_port,
2204 (void *)&cmd_showport_rss_hash_port_id,
2205 (void *)&cmd_showport_rss_hash_rss_hash,
2206 (void *)&cmd_showport_rss_hash_rss_hash_info,
2211 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2212 .f = cmd_showport_rss_hash_parsed,
2214 .help_str = "show port <port_id> rss-hash "
2215 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2216 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2217 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2219 (void *)&cmd_showport_rss_hash_show,
2220 (void *)&cmd_showport_rss_hash_port,
2221 (void *)&cmd_showport_rss_hash_port_id,
2222 (void *)&cmd_showport_rss_hash_rss_hash,
2223 (void *)&cmd_showport_rss_hash_rss_hash_info,
2224 (void *)&cmd_showport_rss_hash_rss_key,
2229 /* *** Configure DCB *** */
2230 struct cmd_config_dcb {
2231 cmdline_fixed_string_t port;
2232 cmdline_fixed_string_t config;
2234 cmdline_fixed_string_t dcb;
2235 cmdline_fixed_string_t vt;
2236 cmdline_fixed_string_t vt_en;
2238 cmdline_fixed_string_t pfc;
2239 cmdline_fixed_string_t pfc_en;
2243 cmd_config_dcb_parsed(void *parsed_result,
2244 __attribute__((unused)) struct cmdline *cl,
2245 __attribute__((unused)) void *data)
2247 struct cmd_config_dcb *res = parsed_result;
2248 portid_t port_id = res->port_id;
2249 struct rte_port *port;
2253 port = &ports[port_id];
2254 /** Check if the port is not started **/
2255 if (port->port_status != RTE_PORT_STOPPED) {
2256 printf("Please stop port %d first\n", port_id);
2260 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2261 printf("The invalid number of traffic class,"
2262 " only 4 or 8 allowed.\n");
2266 if (nb_fwd_lcores < res->num_tcs) {
2267 printf("nb_cores shouldn't be less than number of TCs.\n");
2270 if (!strncmp(res->pfc_en, "on", 2))
2275 /* DCB in VT mode */
2276 if (!strncmp(res->vt_en, "on", 2))
2277 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2278 (enum rte_eth_nb_tcs)res->num_tcs,
2281 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2282 (enum rte_eth_nb_tcs)res->num_tcs,
2287 printf("Cannot initialize network ports.\n");
2291 cmd_reconfig_device_queue(port_id, 1, 1);
2294 cmdline_parse_token_string_t cmd_config_dcb_port =
2295 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2296 cmdline_parse_token_string_t cmd_config_dcb_config =
2297 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2298 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2299 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2300 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2301 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2302 cmdline_parse_token_string_t cmd_config_dcb_vt =
2303 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2304 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2305 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2306 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2307 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2308 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2309 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2310 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2311 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2313 cmdline_parse_inst_t cmd_config_dcb = {
2314 .f = cmd_config_dcb_parsed,
2316 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2318 (void *)&cmd_config_dcb_port,
2319 (void *)&cmd_config_dcb_config,
2320 (void *)&cmd_config_dcb_port_id,
2321 (void *)&cmd_config_dcb_dcb,
2322 (void *)&cmd_config_dcb_vt,
2323 (void *)&cmd_config_dcb_vt_en,
2324 (void *)&cmd_config_dcb_num_tcs,
2325 (void *)&cmd_config_dcb_pfc,
2326 (void *)&cmd_config_dcb_pfc_en,
2331 /* *** configure number of packets per burst *** */
2332 struct cmd_config_burst {
2333 cmdline_fixed_string_t port;
2334 cmdline_fixed_string_t keyword;
2335 cmdline_fixed_string_t all;
2336 cmdline_fixed_string_t name;
2341 cmd_config_burst_parsed(void *parsed_result,
2342 __attribute__((unused)) struct cmdline *cl,
2343 __attribute__((unused)) void *data)
2345 struct cmd_config_burst *res = parsed_result;
2347 if (!all_ports_stopped()) {
2348 printf("Please stop all ports first\n");
2352 if (!strcmp(res->name, "burst")) {
2353 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2354 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2357 nb_pkt_per_burst = res->value;
2359 printf("Unknown parameter\n");
2365 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2368 cmdline_parse_token_string_t cmd_config_burst_port =
2369 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2370 cmdline_parse_token_string_t cmd_config_burst_keyword =
2371 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2372 cmdline_parse_token_string_t cmd_config_burst_all =
2373 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2374 cmdline_parse_token_string_t cmd_config_burst_name =
2375 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2376 cmdline_parse_token_num_t cmd_config_burst_value =
2377 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2379 cmdline_parse_inst_t cmd_config_burst = {
2380 .f = cmd_config_burst_parsed,
2382 .help_str = "port config all burst <value>",
2384 (void *)&cmd_config_burst_port,
2385 (void *)&cmd_config_burst_keyword,
2386 (void *)&cmd_config_burst_all,
2387 (void *)&cmd_config_burst_name,
2388 (void *)&cmd_config_burst_value,
2393 /* *** configure rx/tx queues *** */
2394 struct cmd_config_thresh {
2395 cmdline_fixed_string_t port;
2396 cmdline_fixed_string_t keyword;
2397 cmdline_fixed_string_t all;
2398 cmdline_fixed_string_t name;
2403 cmd_config_thresh_parsed(void *parsed_result,
2404 __attribute__((unused)) struct cmdline *cl,
2405 __attribute__((unused)) void *data)
2407 struct cmd_config_thresh *res = parsed_result;
2409 if (!all_ports_stopped()) {
2410 printf("Please stop all ports first\n");
2414 if (!strcmp(res->name, "txpt"))
2415 tx_pthresh = res->value;
2416 else if(!strcmp(res->name, "txht"))
2417 tx_hthresh = res->value;
2418 else if(!strcmp(res->name, "txwt"))
2419 tx_wthresh = res->value;
2420 else if(!strcmp(res->name, "rxpt"))
2421 rx_pthresh = res->value;
2422 else if(!strcmp(res->name, "rxht"))
2423 rx_hthresh = res->value;
2424 else if(!strcmp(res->name, "rxwt"))
2425 rx_wthresh = res->value;
2427 printf("Unknown parameter\n");
2433 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2436 cmdline_parse_token_string_t cmd_config_thresh_port =
2437 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2438 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2439 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2440 cmdline_parse_token_string_t cmd_config_thresh_all =
2441 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2442 cmdline_parse_token_string_t cmd_config_thresh_name =
2443 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2444 "txpt#txht#txwt#rxpt#rxht#rxwt");
2445 cmdline_parse_token_num_t cmd_config_thresh_value =
2446 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2448 cmdline_parse_inst_t cmd_config_thresh = {
2449 .f = cmd_config_thresh_parsed,
2451 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2453 (void *)&cmd_config_thresh_port,
2454 (void *)&cmd_config_thresh_keyword,
2455 (void *)&cmd_config_thresh_all,
2456 (void *)&cmd_config_thresh_name,
2457 (void *)&cmd_config_thresh_value,
2462 /* *** configure free/rs threshold *** */
2463 struct cmd_config_threshold {
2464 cmdline_fixed_string_t port;
2465 cmdline_fixed_string_t keyword;
2466 cmdline_fixed_string_t all;
2467 cmdline_fixed_string_t name;
2472 cmd_config_threshold_parsed(void *parsed_result,
2473 __attribute__((unused)) struct cmdline *cl,
2474 __attribute__((unused)) void *data)
2476 struct cmd_config_threshold *res = parsed_result;
2478 if (!all_ports_stopped()) {
2479 printf("Please stop all ports first\n");
2483 if (!strcmp(res->name, "txfreet"))
2484 tx_free_thresh = res->value;
2485 else if (!strcmp(res->name, "txrst"))
2486 tx_rs_thresh = res->value;
2487 else if (!strcmp(res->name, "rxfreet"))
2488 rx_free_thresh = res->value;
2490 printf("Unknown parameter\n");
2496 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2499 cmdline_parse_token_string_t cmd_config_threshold_port =
2500 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2501 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2502 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2504 cmdline_parse_token_string_t cmd_config_threshold_all =
2505 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2506 cmdline_parse_token_string_t cmd_config_threshold_name =
2507 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2508 "txfreet#txrst#rxfreet");
2509 cmdline_parse_token_num_t cmd_config_threshold_value =
2510 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2512 cmdline_parse_inst_t cmd_config_threshold = {
2513 .f = cmd_config_threshold_parsed,
2515 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2517 (void *)&cmd_config_threshold_port,
2518 (void *)&cmd_config_threshold_keyword,
2519 (void *)&cmd_config_threshold_all,
2520 (void *)&cmd_config_threshold_name,
2521 (void *)&cmd_config_threshold_value,
2527 struct cmd_stop_result {
2528 cmdline_fixed_string_t stop;
2531 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2532 __attribute__((unused)) struct cmdline *cl,
2533 __attribute__((unused)) void *data)
2535 stop_packet_forwarding();
2538 cmdline_parse_token_string_t cmd_stop_stop =
2539 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2541 cmdline_parse_inst_t cmd_stop = {
2542 .f = cmd_stop_parsed,
2544 .help_str = "stop: Stop packet forwarding",
2546 (void *)&cmd_stop_stop,
2551 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2554 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2555 unsigned int *parsed_items, int check_unique_values)
2557 unsigned int nb_item;
2565 * First parse all items in the list and store their value.
2570 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2572 if ((c >= '0') && (c <= '9')) {
2573 value = (unsigned int) (value * 10 + (c - '0'));
2578 printf("character %c is not a decimal digit\n", c);
2582 printf("No valid value before comma\n");
2585 if (nb_item < max_items) {
2586 parsed_items[nb_item] = value;
2592 if (nb_item >= max_items) {
2593 printf("Number of %s = %u > %u (maximum items)\n",
2594 item_name, nb_item + 1, max_items);
2597 parsed_items[nb_item++] = value;
2598 if (! check_unique_values)
2602 * Then, check that all values in the list are differents.
2603 * No optimization here...
2605 for (i = 0; i < nb_item; i++) {
2606 for (j = i + 1; j < nb_item; j++) {
2607 if (parsed_items[j] == parsed_items[i]) {
2608 printf("duplicated %s %u at index %u and %u\n",
2609 item_name, parsed_items[i], i, j);
2617 struct cmd_set_list_result {
2618 cmdline_fixed_string_t cmd_keyword;
2619 cmdline_fixed_string_t list_name;
2620 cmdline_fixed_string_t list_of_items;
2623 static void cmd_set_list_parsed(void *parsed_result,
2624 __attribute__((unused)) struct cmdline *cl,
2625 __attribute__((unused)) void *data)
2627 struct cmd_set_list_result *res;
2629 unsigned int lcorelist[RTE_MAX_LCORE];
2630 unsigned int portlist[RTE_MAX_ETHPORTS];
2632 unsigned int nb_item;
2634 if (test_done == 0) {
2635 printf("Please stop forwarding first\n");
2639 res = parsed_result;
2640 if (!strcmp(res->list_name, "corelist")) {
2641 nb_item = parse_item_list(res->list_of_items, "core",
2643 parsed_items.lcorelist, 1);
2645 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2650 if (!strcmp(res->list_name, "portlist")) {
2651 nb_item = parse_item_list(res->list_of_items, "port",
2653 parsed_items.portlist, 1);
2655 set_fwd_ports_list(parsed_items.portlist, nb_item);
2661 cmdline_parse_token_string_t cmd_set_list_keyword =
2662 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2664 cmdline_parse_token_string_t cmd_set_list_name =
2665 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2666 "corelist#portlist");
2667 cmdline_parse_token_string_t cmd_set_list_of_items =
2668 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2671 cmdline_parse_inst_t cmd_set_fwd_list = {
2672 .f = cmd_set_list_parsed,
2674 .help_str = "set corelist|portlist <list0[,list1]*>",
2676 (void *)&cmd_set_list_keyword,
2677 (void *)&cmd_set_list_name,
2678 (void *)&cmd_set_list_of_items,
2683 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2685 struct cmd_setmask_result {
2686 cmdline_fixed_string_t set;
2687 cmdline_fixed_string_t mask;
2691 static void cmd_set_mask_parsed(void *parsed_result,
2692 __attribute__((unused)) struct cmdline *cl,
2693 __attribute__((unused)) void *data)
2695 struct cmd_setmask_result *res = parsed_result;
2697 if (test_done == 0) {
2698 printf("Please stop forwarding first\n");
2701 if (!strcmp(res->mask, "coremask")) {
2702 set_fwd_lcores_mask(res->hexavalue);
2704 } else if (!strcmp(res->mask, "portmask")) {
2705 set_fwd_ports_mask(res->hexavalue);
2710 cmdline_parse_token_string_t cmd_setmask_set =
2711 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2712 cmdline_parse_token_string_t cmd_setmask_mask =
2713 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2714 "coremask#portmask");
2715 cmdline_parse_token_num_t cmd_setmask_value =
2716 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2718 cmdline_parse_inst_t cmd_set_fwd_mask = {
2719 .f = cmd_set_mask_parsed,
2721 .help_str = "set coremask|portmask <hexadecimal value>",
2723 (void *)&cmd_setmask_set,
2724 (void *)&cmd_setmask_mask,
2725 (void *)&cmd_setmask_value,
2731 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2733 struct cmd_set_result {
2734 cmdline_fixed_string_t set;
2735 cmdline_fixed_string_t what;
2739 static void cmd_set_parsed(void *parsed_result,
2740 __attribute__((unused)) struct cmdline *cl,
2741 __attribute__((unused)) void *data)
2743 struct cmd_set_result *res = parsed_result;
2744 if (!strcmp(res->what, "nbport")) {
2745 set_fwd_ports_number(res->value);
2747 } else if (!strcmp(res->what, "nbcore")) {
2748 set_fwd_lcores_number(res->value);
2750 } else if (!strcmp(res->what, "burst"))
2751 set_nb_pkt_per_burst(res->value);
2752 else if (!strcmp(res->what, "verbose"))
2753 set_verbose_level(res->value);
2756 cmdline_parse_token_string_t cmd_set_set =
2757 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2758 cmdline_parse_token_string_t cmd_set_what =
2759 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2760 "nbport#nbcore#burst#verbose");
2761 cmdline_parse_token_num_t cmd_set_value =
2762 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2764 cmdline_parse_inst_t cmd_set_numbers = {
2765 .f = cmd_set_parsed,
2767 .help_str = "set nbport|nbcore|burst|verbose <value>",
2769 (void *)&cmd_set_set,
2770 (void *)&cmd_set_what,
2771 (void *)&cmd_set_value,
2776 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2778 struct cmd_set_txpkts_result {
2779 cmdline_fixed_string_t cmd_keyword;
2780 cmdline_fixed_string_t txpkts;
2781 cmdline_fixed_string_t seg_lengths;
2785 cmd_set_txpkts_parsed(void *parsed_result,
2786 __attribute__((unused)) struct cmdline *cl,
2787 __attribute__((unused)) void *data)
2789 struct cmd_set_txpkts_result *res;
2790 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2791 unsigned int nb_segs;
2793 res = parsed_result;
2794 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2795 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2797 set_tx_pkt_segments(seg_lengths, nb_segs);
2800 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2801 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2802 cmd_keyword, "set");
2803 cmdline_parse_token_string_t cmd_set_txpkts_name =
2804 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2806 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2807 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2810 cmdline_parse_inst_t cmd_set_txpkts = {
2811 .f = cmd_set_txpkts_parsed,
2813 .help_str = "set txpkts <len0[,len1]*>",
2815 (void *)&cmd_set_txpkts_keyword,
2816 (void *)&cmd_set_txpkts_name,
2817 (void *)&cmd_set_txpkts_lengths,
2822 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2824 struct cmd_set_txsplit_result {
2825 cmdline_fixed_string_t cmd_keyword;
2826 cmdline_fixed_string_t txsplit;
2827 cmdline_fixed_string_t mode;
2831 cmd_set_txsplit_parsed(void *parsed_result,
2832 __attribute__((unused)) struct cmdline *cl,
2833 __attribute__((unused)) void *data)
2835 struct cmd_set_txsplit_result *res;
2837 res = parsed_result;
2838 set_tx_pkt_split(res->mode);
2841 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2842 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2843 cmd_keyword, "set");
2844 cmdline_parse_token_string_t cmd_set_txsplit_name =
2845 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2846 txsplit, "txsplit");
2847 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2848 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2851 cmdline_parse_inst_t cmd_set_txsplit = {
2852 .f = cmd_set_txsplit_parsed,
2854 .help_str = "set txsplit on|off|rand",
2856 (void *)&cmd_set_txsplit_keyword,
2857 (void *)&cmd_set_txsplit_name,
2858 (void *)&cmd_set_txsplit_mode,
2863 /* *** CONFIG TX QUEUE FLAGS *** */
2865 struct cmd_config_txqflags_result {
2866 cmdline_fixed_string_t port;
2867 cmdline_fixed_string_t config;
2868 cmdline_fixed_string_t all;
2869 cmdline_fixed_string_t what;
2873 static void cmd_config_txqflags_parsed(void *parsed_result,
2874 __attribute__((unused)) struct cmdline *cl,
2875 __attribute__((unused)) void *data)
2877 struct cmd_config_txqflags_result *res = parsed_result;
2879 if (!all_ports_stopped()) {
2880 printf("Please stop all ports first\n");
2884 if (strcmp(res->what, "txqflags")) {
2885 printf("Unknown parameter\n");
2889 if (res->hexvalue >= 0) {
2890 txq_flags = res->hexvalue;
2892 printf("txqflags must be >= 0\n");
2898 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2901 cmdline_parse_token_string_t cmd_config_txqflags_port =
2902 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2904 cmdline_parse_token_string_t cmd_config_txqflags_config =
2905 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2907 cmdline_parse_token_string_t cmd_config_txqflags_all =
2908 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2910 cmdline_parse_token_string_t cmd_config_txqflags_what =
2911 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2913 cmdline_parse_token_num_t cmd_config_txqflags_value =
2914 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2917 cmdline_parse_inst_t cmd_config_txqflags = {
2918 .f = cmd_config_txqflags_parsed,
2920 .help_str = "port config all txqflags <value>",
2922 (void *)&cmd_config_txqflags_port,
2923 (void *)&cmd_config_txqflags_config,
2924 (void *)&cmd_config_txqflags_all,
2925 (void *)&cmd_config_txqflags_what,
2926 (void *)&cmd_config_txqflags_value,
2931 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2932 struct cmd_rx_vlan_filter_all_result {
2933 cmdline_fixed_string_t rx_vlan;
2934 cmdline_fixed_string_t what;
2935 cmdline_fixed_string_t all;
2940 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2941 __attribute__((unused)) struct cmdline *cl,
2942 __attribute__((unused)) void *data)
2944 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2946 if (!strcmp(res->what, "add"))
2947 rx_vlan_all_filter_set(res->port_id, 1);
2949 rx_vlan_all_filter_set(res->port_id, 0);
2952 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2953 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2954 rx_vlan, "rx_vlan");
2955 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2956 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2958 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2959 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2961 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2962 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2965 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2966 .f = cmd_rx_vlan_filter_all_parsed,
2968 .help_str = "rx_vlan add|rm all <port_id>: "
2969 "Add/Remove all identifiers to/from the set of VLAN "
2970 "identifiers filtered by a port",
2972 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2973 (void *)&cmd_rx_vlan_filter_all_what,
2974 (void *)&cmd_rx_vlan_filter_all_all,
2975 (void *)&cmd_rx_vlan_filter_all_portid,
2980 /* *** VLAN OFFLOAD SET ON A PORT *** */
2981 struct cmd_vlan_offload_result {
2982 cmdline_fixed_string_t vlan;
2983 cmdline_fixed_string_t set;
2984 cmdline_fixed_string_t vlan_type;
2985 cmdline_fixed_string_t what;
2986 cmdline_fixed_string_t on;
2987 cmdline_fixed_string_t port_id;
2991 cmd_vlan_offload_parsed(void *parsed_result,
2992 __attribute__((unused)) struct cmdline *cl,
2993 __attribute__((unused)) void *data)
2996 struct cmd_vlan_offload_result *res = parsed_result;
2999 portid_t port_id = 0;
3003 len = strnlen(str, STR_TOKEN_SIZE);
3005 /* Get port_id first */
3013 tmp = strtoul(str, NULL, 0);
3014 /* If port_id greater that what portid_t can represent, return */
3015 if(tmp >= RTE_MAX_ETHPORTS)
3017 port_id = (portid_t)tmp;
3019 if (!strcmp(res->on, "on"))
3024 if (!strcmp(res->what, "strip"))
3025 rx_vlan_strip_set(port_id, on);
3026 else if(!strcmp(res->what, "stripq")){
3027 uint16_t queue_id = 0;
3029 /* No queue_id, return */
3031 printf("must specify (port,queue_id)\n");
3034 tmp = strtoul(str + i + 1, NULL, 0);
3035 /* If queue_id greater that what 16-bits can represent, return */
3039 queue_id = (uint16_t)tmp;
3040 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3042 else if (!strcmp(res->what, "filter"))
3043 rx_vlan_filter_set(port_id, on);
3045 vlan_extend_set(port_id, on);
3050 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3051 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3053 cmdline_parse_token_string_t cmd_vlan_offload_set =
3054 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3056 cmdline_parse_token_string_t cmd_vlan_offload_what =
3057 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3058 what, "strip#filter#qinq#stripq");
3059 cmdline_parse_token_string_t cmd_vlan_offload_on =
3060 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3062 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3063 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3066 cmdline_parse_inst_t cmd_vlan_offload = {
3067 .f = cmd_vlan_offload_parsed,
3069 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3070 "<port_id[,queue_id]>: "
3071 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3073 (void *)&cmd_vlan_offload_vlan,
3074 (void *)&cmd_vlan_offload_set,
3075 (void *)&cmd_vlan_offload_what,
3076 (void *)&cmd_vlan_offload_on,
3077 (void *)&cmd_vlan_offload_portid,
3082 /* *** VLAN TPID SET ON A PORT *** */
3083 struct cmd_vlan_tpid_result {
3084 cmdline_fixed_string_t vlan;
3085 cmdline_fixed_string_t set;
3086 cmdline_fixed_string_t vlan_type;
3087 cmdline_fixed_string_t what;
3093 cmd_vlan_tpid_parsed(void *parsed_result,
3094 __attribute__((unused)) struct cmdline *cl,
3095 __attribute__((unused)) void *data)
3097 struct cmd_vlan_tpid_result *res = parsed_result;
3098 enum rte_vlan_type vlan_type;
3100 if (!strcmp(res->vlan_type, "inner"))
3101 vlan_type = ETH_VLAN_TYPE_INNER;
3102 else if (!strcmp(res->vlan_type, "outer"))
3103 vlan_type = ETH_VLAN_TYPE_OUTER;
3105 printf("Unknown vlan type\n");
3108 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3111 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3112 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3114 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3115 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3117 cmdline_parse_token_string_t cmd_vlan_type =
3118 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3119 vlan_type, "inner#outer");
3120 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3121 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3123 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3124 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3126 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3127 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3130 cmdline_parse_inst_t cmd_vlan_tpid = {
3131 .f = cmd_vlan_tpid_parsed,
3133 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3134 "Set the VLAN Ether type",
3136 (void *)&cmd_vlan_tpid_vlan,
3137 (void *)&cmd_vlan_tpid_set,
3138 (void *)&cmd_vlan_type,
3139 (void *)&cmd_vlan_tpid_what,
3140 (void *)&cmd_vlan_tpid_tpid,
3141 (void *)&cmd_vlan_tpid_portid,
3146 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3147 struct cmd_rx_vlan_filter_result {
3148 cmdline_fixed_string_t rx_vlan;
3149 cmdline_fixed_string_t what;
3155 cmd_rx_vlan_filter_parsed(void *parsed_result,
3156 __attribute__((unused)) struct cmdline *cl,
3157 __attribute__((unused)) void *data)
3159 struct cmd_rx_vlan_filter_result *res = parsed_result;
3161 if (!strcmp(res->what, "add"))
3162 rx_vft_set(res->port_id, res->vlan_id, 1);
3164 rx_vft_set(res->port_id, res->vlan_id, 0);
3167 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3168 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3169 rx_vlan, "rx_vlan");
3170 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3171 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3173 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3174 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3176 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3177 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3180 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3181 .f = cmd_rx_vlan_filter_parsed,
3183 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3184 "Add/Remove a VLAN identifier to/from the set of VLAN "
3185 "identifiers filtered by a port",
3187 (void *)&cmd_rx_vlan_filter_rx_vlan,
3188 (void *)&cmd_rx_vlan_filter_what,
3189 (void *)&cmd_rx_vlan_filter_vlanid,
3190 (void *)&cmd_rx_vlan_filter_portid,
3195 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3196 struct cmd_tx_vlan_set_result {
3197 cmdline_fixed_string_t tx_vlan;
3198 cmdline_fixed_string_t set;
3204 cmd_tx_vlan_set_parsed(void *parsed_result,
3205 __attribute__((unused)) struct cmdline *cl,
3206 __attribute__((unused)) void *data)
3208 struct cmd_tx_vlan_set_result *res = parsed_result;
3210 tx_vlan_set(res->port_id, res->vlan_id);
3213 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3214 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3215 tx_vlan, "tx_vlan");
3216 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3217 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3219 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3220 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3222 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3223 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3226 cmdline_parse_inst_t cmd_tx_vlan_set = {
3227 .f = cmd_tx_vlan_set_parsed,
3229 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3230 "Enable hardware insertion of a single VLAN header "
3231 "with a given TAG Identifier in packets sent on a port",
3233 (void *)&cmd_tx_vlan_set_tx_vlan,
3234 (void *)&cmd_tx_vlan_set_set,
3235 (void *)&cmd_tx_vlan_set_portid,
3236 (void *)&cmd_tx_vlan_set_vlanid,
3241 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3242 struct cmd_tx_vlan_set_qinq_result {
3243 cmdline_fixed_string_t tx_vlan;
3244 cmdline_fixed_string_t set;
3247 uint16_t vlan_id_outer;
3251 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3252 __attribute__((unused)) struct cmdline *cl,
3253 __attribute__((unused)) void *data)
3255 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3257 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3260 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3261 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3262 tx_vlan, "tx_vlan");
3263 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3264 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3266 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3267 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3269 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3270 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3272 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3273 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3274 vlan_id_outer, UINT16);
3276 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3277 .f = cmd_tx_vlan_set_qinq_parsed,
3279 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3280 "Enable hardware insertion of double VLAN header "
3281 "with given TAG Identifiers in packets sent on a port",
3283 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3284 (void *)&cmd_tx_vlan_set_qinq_set,
3285 (void *)&cmd_tx_vlan_set_qinq_portid,
3286 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3287 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3292 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3293 struct cmd_tx_vlan_set_pvid_result {
3294 cmdline_fixed_string_t tx_vlan;
3295 cmdline_fixed_string_t set;
3296 cmdline_fixed_string_t pvid;
3299 cmdline_fixed_string_t mode;
3303 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3304 __attribute__((unused)) struct cmdline *cl,
3305 __attribute__((unused)) void *data)
3307 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3309 if (strcmp(res->mode, "on") == 0)
3310 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3312 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3315 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3316 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3317 tx_vlan, "tx_vlan");
3318 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3319 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3321 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3322 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3324 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3325 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3327 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3328 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3330 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3331 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3334 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3335 .f = cmd_tx_vlan_set_pvid_parsed,
3337 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3339 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3340 (void *)&cmd_tx_vlan_set_pvid_set,
3341 (void *)&cmd_tx_vlan_set_pvid_pvid,
3342 (void *)&cmd_tx_vlan_set_pvid_port_id,
3343 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3344 (void *)&cmd_tx_vlan_set_pvid_mode,
3349 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3350 struct cmd_tx_vlan_reset_result {
3351 cmdline_fixed_string_t tx_vlan;
3352 cmdline_fixed_string_t reset;
3357 cmd_tx_vlan_reset_parsed(void *parsed_result,
3358 __attribute__((unused)) struct cmdline *cl,
3359 __attribute__((unused)) void *data)
3361 struct cmd_tx_vlan_reset_result *res = parsed_result;
3363 tx_vlan_reset(res->port_id);
3366 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3367 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3368 tx_vlan, "tx_vlan");
3369 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3370 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3372 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3373 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3376 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3377 .f = cmd_tx_vlan_reset_parsed,
3379 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3380 "VLAN header in packets sent on a port",
3382 (void *)&cmd_tx_vlan_reset_tx_vlan,
3383 (void *)&cmd_tx_vlan_reset_reset,
3384 (void *)&cmd_tx_vlan_reset_portid,
3390 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3391 struct cmd_csum_result {
3392 cmdline_fixed_string_t csum;
3393 cmdline_fixed_string_t mode;
3394 cmdline_fixed_string_t proto;
3395 cmdline_fixed_string_t hwsw;
3400 csum_show(int port_id)
3402 struct rte_eth_dev_info dev_info;
3405 ol_flags = ports[port_id].tx_ol_flags;
3406 printf("Parse tunnel is %s\n",
3407 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3408 printf("IP checksum offload is %s\n",
3409 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3410 printf("UDP checksum offload is %s\n",
3411 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3412 printf("TCP checksum offload is %s\n",
3413 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3414 printf("SCTP checksum offload is %s\n",
3415 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3416 printf("Outer-Ip checksum offload is %s\n",
3417 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3419 /* display warnings if configuration is not supported by the NIC */
3420 rte_eth_dev_info_get(port_id, &dev_info);
3421 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3422 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3423 printf("Warning: hardware IP checksum enabled but not "
3424 "supported by port %d\n", port_id);
3426 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3427 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3428 printf("Warning: hardware UDP checksum enabled but not "
3429 "supported by port %d\n", port_id);
3431 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3432 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3433 printf("Warning: hardware TCP checksum enabled but not "
3434 "supported by port %d\n", port_id);
3436 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3437 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3438 printf("Warning: hardware SCTP checksum enabled but not "
3439 "supported by port %d\n", port_id);
3441 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3442 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3443 printf("Warning: hardware outer IP checksum enabled but not "
3444 "supported by port %d\n", port_id);
3449 cmd_csum_parsed(void *parsed_result,
3450 __attribute__((unused)) struct cmdline *cl,
3451 __attribute__((unused)) void *data)
3453 struct cmd_csum_result *res = parsed_result;
3457 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3458 printf("invalid port %d\n", res->port_id);
3462 if (!strcmp(res->mode, "set")) {
3464 if (!strcmp(res->hwsw, "hw"))
3467 if (!strcmp(res->proto, "ip")) {
3468 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3469 } else if (!strcmp(res->proto, "udp")) {
3470 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3471 } else if (!strcmp(res->proto, "tcp")) {
3472 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3473 } else if (!strcmp(res->proto, "sctp")) {
3474 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3475 } else if (!strcmp(res->proto, "outer-ip")) {
3476 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3480 ports[res->port_id].tx_ol_flags |= mask;
3482 ports[res->port_id].tx_ol_flags &= (~mask);
3484 csum_show(res->port_id);
3487 cmdline_parse_token_string_t cmd_csum_csum =
3488 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3490 cmdline_parse_token_string_t cmd_csum_mode =
3491 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3493 cmdline_parse_token_string_t cmd_csum_proto =
3494 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3495 proto, "ip#tcp#udp#sctp#outer-ip");
3496 cmdline_parse_token_string_t cmd_csum_hwsw =
3497 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3499 cmdline_parse_token_num_t cmd_csum_portid =
3500 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3503 cmdline_parse_inst_t cmd_csum_set = {
3504 .f = cmd_csum_parsed,
3506 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3507 "Enable/Disable hardware calculation of L3/L4 checksum when "
3508 "using csum forward engine",
3510 (void *)&cmd_csum_csum,
3511 (void *)&cmd_csum_mode,
3512 (void *)&cmd_csum_proto,
3513 (void *)&cmd_csum_hwsw,
3514 (void *)&cmd_csum_portid,
3519 cmdline_parse_token_string_t cmd_csum_mode_show =
3520 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3523 cmdline_parse_inst_t cmd_csum_show = {
3524 .f = cmd_csum_parsed,
3526 .help_str = "csum show <port_id>: Show checksum offload configuration",
3528 (void *)&cmd_csum_csum,
3529 (void *)&cmd_csum_mode_show,
3530 (void *)&cmd_csum_portid,
3535 /* Enable/disable tunnel parsing */
3536 struct cmd_csum_tunnel_result {
3537 cmdline_fixed_string_t csum;
3538 cmdline_fixed_string_t parse;
3539 cmdline_fixed_string_t onoff;
3544 cmd_csum_tunnel_parsed(void *parsed_result,
3545 __attribute__((unused)) struct cmdline *cl,
3546 __attribute__((unused)) void *data)
3548 struct cmd_csum_tunnel_result *res = parsed_result;
3550 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3553 if (!strcmp(res->onoff, "on"))
3554 ports[res->port_id].tx_ol_flags |=
3555 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3557 ports[res->port_id].tx_ol_flags &=
3558 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3560 csum_show(res->port_id);
3563 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3564 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3566 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3567 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3568 parse, "parse_tunnel");
3569 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3570 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3572 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3573 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3576 cmdline_parse_inst_t cmd_csum_tunnel = {
3577 .f = cmd_csum_tunnel_parsed,
3579 .help_str = "csum parse_tunnel on|off <port_id>: "
3580 "Enable/Disable parsing of tunnels for csum engine",
3582 (void *)&cmd_csum_tunnel_csum,
3583 (void *)&cmd_csum_tunnel_parse,
3584 (void *)&cmd_csum_tunnel_onoff,
3585 (void *)&cmd_csum_tunnel_portid,
3590 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3591 struct cmd_tso_set_result {
3592 cmdline_fixed_string_t tso;
3593 cmdline_fixed_string_t mode;
3599 cmd_tso_set_parsed(void *parsed_result,
3600 __attribute__((unused)) struct cmdline *cl,
3601 __attribute__((unused)) void *data)
3603 struct cmd_tso_set_result *res = parsed_result;
3604 struct rte_eth_dev_info dev_info;
3606 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3609 if (!strcmp(res->mode, "set"))
3610 ports[res->port_id].tso_segsz = res->tso_segsz;
3612 if (ports[res->port_id].tso_segsz == 0)
3613 printf("TSO for non-tunneled packets is disabled\n");
3615 printf("TSO segment size for non-tunneled packets is %d\n",
3616 ports[res->port_id].tso_segsz);
3618 /* display warnings if configuration is not supported by the NIC */
3619 rte_eth_dev_info_get(res->port_id, &dev_info);
3620 if ((ports[res->port_id].tso_segsz != 0) &&
3621 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3622 printf("Warning: TSO enabled but not "
3623 "supported by port %d\n", res->port_id);
3627 cmdline_parse_token_string_t cmd_tso_set_tso =
3628 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3630 cmdline_parse_token_string_t cmd_tso_set_mode =
3631 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3633 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3634 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3636 cmdline_parse_token_num_t cmd_tso_set_portid =
3637 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3640 cmdline_parse_inst_t cmd_tso_set = {
3641 .f = cmd_tso_set_parsed,
3643 .help_str = "tso set <tso_segsz> <port_id>: "
3644 "Set TSO segment size of non-tunneled packets for csum engine "
3647 (void *)&cmd_tso_set_tso,
3648 (void *)&cmd_tso_set_mode,
3649 (void *)&cmd_tso_set_tso_segsz,
3650 (void *)&cmd_tso_set_portid,
3655 cmdline_parse_token_string_t cmd_tso_show_mode =
3656 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3660 cmdline_parse_inst_t cmd_tso_show = {
3661 .f = cmd_tso_set_parsed,
3663 .help_str = "tso show <port_id>: "
3664 "Show TSO segment size of non-tunneled packets for csum engine",
3666 (void *)&cmd_tso_set_tso,
3667 (void *)&cmd_tso_show_mode,
3668 (void *)&cmd_tso_set_portid,
3673 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3674 struct cmd_tunnel_tso_set_result {
3675 cmdline_fixed_string_t tso;
3676 cmdline_fixed_string_t mode;
3682 check_tunnel_tso_nic_support(uint8_t port_id)
3684 struct rte_eth_dev_info dev_info;
3686 rte_eth_dev_info_get(port_id, &dev_info);
3687 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3688 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3689 "supported by port %d\n", port_id);
3690 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3691 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3692 "supported by port %d\n", port_id);
3693 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3694 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3695 "supported by port %d\n", port_id);
3696 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3697 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3698 "supported by port %d\n", port_id);
3702 cmd_tunnel_tso_set_parsed(void *parsed_result,
3703 __attribute__((unused)) struct cmdline *cl,
3704 __attribute__((unused)) void *data)
3706 struct cmd_tunnel_tso_set_result *res = parsed_result;
3708 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3711 if (!strcmp(res->mode, "set"))
3712 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3714 if (ports[res->port_id].tunnel_tso_segsz == 0)
3715 printf("TSO for tunneled packets is disabled\n");
3717 printf("TSO segment size for tunneled packets is %d\n",
3718 ports[res->port_id].tunnel_tso_segsz);
3720 /* Below conditions are needed to make it work:
3721 * (1) tunnel TSO is supported by the NIC;
3722 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3724 * (3) for tunneled pkts with outer L3 of IPv4,
3725 * "csum set outer-ip" must be set to hw, because after tso,
3726 * total_len of outer IP header is changed, and the checksum
3727 * of outer IP header calculated by sw should be wrong; that
3728 * is not necessary for IPv6 tunneled pkts because there's no
3729 * checksum in IP header anymore.
3731 check_tunnel_tso_nic_support(res->port_id);
3733 if (!(ports[res->port_id].tx_ol_flags &
3734 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3735 printf("Warning: csum parse_tunnel must be set "
3736 "so that tunneled packets are recognized\n");
3737 if (!(ports[res->port_id].tx_ol_flags &
3738 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3739 printf("Warning: csum set outer-ip must be set to hw "
3740 "if outer L3 is IPv4; not necessary for IPv6\n");
3744 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3745 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3747 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3748 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3750 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3751 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3753 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3754 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3757 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3758 .f = cmd_tunnel_tso_set_parsed,
3760 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3761 "Set TSO segment size of tunneled packets for csum engine "
3764 (void *)&cmd_tunnel_tso_set_tso,
3765 (void *)&cmd_tunnel_tso_set_mode,
3766 (void *)&cmd_tunnel_tso_set_tso_segsz,
3767 (void *)&cmd_tunnel_tso_set_portid,
3772 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3773 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3777 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3778 .f = cmd_tunnel_tso_set_parsed,
3780 .help_str = "tunnel_tso show <port_id> "
3781 "Show TSO segment size of tunneled packets for csum engine",
3783 (void *)&cmd_tunnel_tso_set_tso,
3784 (void *)&cmd_tunnel_tso_show_mode,
3785 (void *)&cmd_tunnel_tso_set_portid,
3790 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3791 struct cmd_set_flush_rx {
3792 cmdline_fixed_string_t set;
3793 cmdline_fixed_string_t flush_rx;
3794 cmdline_fixed_string_t mode;
3798 cmd_set_flush_rx_parsed(void *parsed_result,
3799 __attribute__((unused)) struct cmdline *cl,
3800 __attribute__((unused)) void *data)
3802 struct cmd_set_flush_rx *res = parsed_result;
3803 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3806 cmdline_parse_token_string_t cmd_setflushrx_set =
3807 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3809 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3810 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3811 flush_rx, "flush_rx");
3812 cmdline_parse_token_string_t cmd_setflushrx_mode =
3813 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3817 cmdline_parse_inst_t cmd_set_flush_rx = {
3818 .f = cmd_set_flush_rx_parsed,
3819 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3822 (void *)&cmd_setflushrx_set,
3823 (void *)&cmd_setflushrx_flush_rx,
3824 (void *)&cmd_setflushrx_mode,
3829 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3830 struct cmd_set_link_check {
3831 cmdline_fixed_string_t set;
3832 cmdline_fixed_string_t link_check;
3833 cmdline_fixed_string_t mode;
3837 cmd_set_link_check_parsed(void *parsed_result,
3838 __attribute__((unused)) struct cmdline *cl,
3839 __attribute__((unused)) void *data)
3841 struct cmd_set_link_check *res = parsed_result;
3842 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3845 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3846 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3848 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3849 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3850 link_check, "link_check");
3851 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3852 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3856 cmdline_parse_inst_t cmd_set_link_check = {
3857 .f = cmd_set_link_check_parsed,
3858 .help_str = "set link_check on|off: Enable/Disable link status check "
3859 "when starting/stopping a port",
3862 (void *)&cmd_setlinkcheck_set,
3863 (void *)&cmd_setlinkcheck_link_check,
3864 (void *)&cmd_setlinkcheck_mode,
3869 #ifdef RTE_NIC_BYPASS
3870 /* *** SET NIC BYPASS MODE *** */
3871 struct cmd_set_bypass_mode_result {
3872 cmdline_fixed_string_t set;
3873 cmdline_fixed_string_t bypass;
3874 cmdline_fixed_string_t mode;
3875 cmdline_fixed_string_t value;
3880 cmd_set_bypass_mode_parsed(void *parsed_result,
3881 __attribute__((unused)) struct cmdline *cl,
3882 __attribute__((unused)) void *data)
3884 struct cmd_set_bypass_mode_result *res = parsed_result;
3885 portid_t port_id = res->port_id;
3886 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3888 if (!strcmp(res->value, "bypass"))
3889 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3890 else if (!strcmp(res->value, "isolate"))
3891 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3893 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3895 /* Set the bypass mode for the relevant port. */
3896 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3897 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3901 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3902 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3904 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3905 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3907 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3908 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3910 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3911 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3912 value, "normal#bypass#isolate");
3913 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3914 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3917 cmdline_parse_inst_t cmd_set_bypass_mode = {
3918 .f = cmd_set_bypass_mode_parsed,
3919 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3920 "Set the NIC bypass mode for port_id",
3923 (void *)&cmd_setbypass_mode_set,
3924 (void *)&cmd_setbypass_mode_bypass,
3925 (void *)&cmd_setbypass_mode_mode,
3926 (void *)&cmd_setbypass_mode_value,
3927 (void *)&cmd_setbypass_mode_port,
3932 /* *** SET NIC BYPASS EVENT *** */
3933 struct cmd_set_bypass_event_result {
3934 cmdline_fixed_string_t set;
3935 cmdline_fixed_string_t bypass;
3936 cmdline_fixed_string_t event;
3937 cmdline_fixed_string_t event_value;
3938 cmdline_fixed_string_t mode;
3939 cmdline_fixed_string_t mode_value;
3944 cmd_set_bypass_event_parsed(void *parsed_result,
3945 __attribute__((unused)) struct cmdline *cl,
3946 __attribute__((unused)) void *data)
3949 struct cmd_set_bypass_event_result *res = parsed_result;
3950 portid_t port_id = res->port_id;
3951 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3952 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3954 if (!strcmp(res->event_value, "timeout"))
3955 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3956 else if (!strcmp(res->event_value, "os_on"))
3957 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3958 else if (!strcmp(res->event_value, "os_off"))
3959 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3960 else if (!strcmp(res->event_value, "power_on"))
3961 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3962 else if (!strcmp(res->event_value, "power_off"))
3963 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3965 bypass_event = RTE_BYPASS_EVENT_NONE;
3967 if (!strcmp(res->mode_value, "bypass"))
3968 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3969 else if (!strcmp(res->mode_value, "isolate"))
3970 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3972 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3974 /* Set the watchdog timeout. */
3975 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3978 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3979 (rc = rte_eth_dev_wd_timeout_store(port_id,
3980 bypass_timeout)) != 0) {
3981 printf("Failed to set timeout value %u "
3982 "for port %d, errto code: %d.\n",
3983 bypass_timeout, port_id, rc);
3987 /* Set the bypass event to transition to bypass mode. */
3988 if (0 != rte_eth_dev_bypass_event_store(port_id,
3989 bypass_event, bypass_mode)) {
3990 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3995 cmdline_parse_token_string_t cmd_setbypass_event_set =
3996 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3998 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3999 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4001 cmdline_parse_token_string_t cmd_setbypass_event_event =
4002 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4004 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4005 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4006 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4007 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4008 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4010 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4011 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4012 mode_value, "normal#bypass#isolate");
4013 cmdline_parse_token_num_t cmd_setbypass_event_port =
4014 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4017 cmdline_parse_inst_t cmd_set_bypass_event = {
4018 .f = cmd_set_bypass_event_parsed,
4019 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4020 "power_off mode normal|bypass|isolate <port_id>: "
4021 "Set the NIC bypass event mode for port_id",
4024 (void *)&cmd_setbypass_event_set,
4025 (void *)&cmd_setbypass_event_bypass,
4026 (void *)&cmd_setbypass_event_event,
4027 (void *)&cmd_setbypass_event_event_value,
4028 (void *)&cmd_setbypass_event_mode,
4029 (void *)&cmd_setbypass_event_mode_value,
4030 (void *)&cmd_setbypass_event_port,
4036 /* *** SET NIC BYPASS TIMEOUT *** */
4037 struct cmd_set_bypass_timeout_result {
4038 cmdline_fixed_string_t set;
4039 cmdline_fixed_string_t bypass;
4040 cmdline_fixed_string_t timeout;
4041 cmdline_fixed_string_t value;
4045 cmd_set_bypass_timeout_parsed(void *parsed_result,
4046 __attribute__((unused)) struct cmdline *cl,
4047 __attribute__((unused)) void *data)
4049 struct cmd_set_bypass_timeout_result *res = parsed_result;
4051 if (!strcmp(res->value, "1.5"))
4052 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4053 else if (!strcmp(res->value, "2"))
4054 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4055 else if (!strcmp(res->value, "3"))
4056 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4057 else if (!strcmp(res->value, "4"))
4058 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4059 else if (!strcmp(res->value, "8"))
4060 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4061 else if (!strcmp(res->value, "16"))
4062 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4063 else if (!strcmp(res->value, "32"))
4064 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4066 bypass_timeout = RTE_BYPASS_TMT_OFF;
4069 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4070 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4072 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4073 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4075 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4076 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4077 timeout, "timeout");
4078 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4079 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4080 value, "0#1.5#2#3#4#8#16#32");
4082 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4083 .f = cmd_set_bypass_timeout_parsed,
4084 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4085 "Set the NIC bypass watchdog timeout in seconds",
4088 (void *)&cmd_setbypass_timeout_set,
4089 (void *)&cmd_setbypass_timeout_bypass,
4090 (void *)&cmd_setbypass_timeout_timeout,
4091 (void *)&cmd_setbypass_timeout_value,
4096 /* *** SHOW NIC BYPASS MODE *** */
4097 struct cmd_show_bypass_config_result {
4098 cmdline_fixed_string_t show;
4099 cmdline_fixed_string_t bypass;
4100 cmdline_fixed_string_t config;
4105 cmd_show_bypass_config_parsed(void *parsed_result,
4106 __attribute__((unused)) struct cmdline *cl,
4107 __attribute__((unused)) void *data)
4109 struct cmd_show_bypass_config_result *res = parsed_result;
4110 uint32_t event_mode;
4111 uint32_t bypass_mode;
4112 portid_t port_id = res->port_id;
4113 uint32_t timeout = bypass_timeout;
4116 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4117 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4118 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4119 {"UNKNOWN", "normal", "bypass", "isolate"};
4120 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4127 int num_events = (sizeof events) / (sizeof events[0]);
4129 /* Display the bypass mode.*/
4130 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4131 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4135 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4136 bypass_mode = RTE_BYPASS_MODE_NONE;
4138 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4141 /* Display the bypass timeout.*/
4142 if (!RTE_BYPASS_TMT_VALID(timeout))
4143 timeout = RTE_BYPASS_TMT_OFF;
4145 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4147 /* Display the bypass events and associated modes. */
4148 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4150 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4151 printf("\tFailed to get bypass mode for event = %s\n",
4154 if (!RTE_BYPASS_MODE_VALID(event_mode))
4155 event_mode = RTE_BYPASS_MODE_NONE;
4157 printf("\tbypass event: %-16s = %s\n", events[i],
4163 cmdline_parse_token_string_t cmd_showbypass_config_show =
4164 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4166 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4167 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4169 cmdline_parse_token_string_t cmd_showbypass_config_config =
4170 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4172 cmdline_parse_token_num_t cmd_showbypass_config_port =
4173 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4176 cmdline_parse_inst_t cmd_show_bypass_config = {
4177 .f = cmd_show_bypass_config_parsed,
4178 .help_str = "show bypass config <port_id>: "
4179 "Show the NIC bypass config for port_id",
4182 (void *)&cmd_showbypass_config_show,
4183 (void *)&cmd_showbypass_config_bypass,
4184 (void *)&cmd_showbypass_config_config,
4185 (void *)&cmd_showbypass_config_port,
4191 #ifdef RTE_LIBRTE_PMD_BOND
4192 /* *** SET BONDING MODE *** */
4193 struct cmd_set_bonding_mode_result {
4194 cmdline_fixed_string_t set;
4195 cmdline_fixed_string_t bonding;
4196 cmdline_fixed_string_t mode;
4201 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4202 __attribute__((unused)) struct cmdline *cl,
4203 __attribute__((unused)) void *data)
4205 struct cmd_set_bonding_mode_result *res = parsed_result;
4206 portid_t port_id = res->port_id;
4208 /* Set the bonding mode for the relevant port. */
4209 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4210 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4213 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4214 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4216 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4217 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4218 bonding, "bonding");
4219 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4220 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4222 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4223 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4225 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4226 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4229 cmdline_parse_inst_t cmd_set_bonding_mode = {
4230 .f = cmd_set_bonding_mode_parsed,
4231 .help_str = "set bonding mode <mode_value> <port_id>: "
4232 "Set the bonding mode for port_id",
4235 (void *) &cmd_setbonding_mode_set,
4236 (void *) &cmd_setbonding_mode_bonding,
4237 (void *) &cmd_setbonding_mode_mode,
4238 (void *) &cmd_setbonding_mode_value,
4239 (void *) &cmd_setbonding_mode_port,
4244 /* *** SET BALANCE XMIT POLICY *** */
4245 struct cmd_set_bonding_balance_xmit_policy_result {
4246 cmdline_fixed_string_t set;
4247 cmdline_fixed_string_t bonding;
4248 cmdline_fixed_string_t balance_xmit_policy;
4250 cmdline_fixed_string_t policy;
4253 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4254 __attribute__((unused)) struct cmdline *cl,
4255 __attribute__((unused)) void *data)
4257 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4258 portid_t port_id = res->port_id;
4261 if (!strcmp(res->policy, "l2")) {
4262 policy = BALANCE_XMIT_POLICY_LAYER2;
4263 } else if (!strcmp(res->policy, "l23")) {
4264 policy = BALANCE_XMIT_POLICY_LAYER23;
4265 } else if (!strcmp(res->policy, "l34")) {
4266 policy = BALANCE_XMIT_POLICY_LAYER34;
4268 printf("\t Invalid xmit policy selection");
4272 /* Set the bonding mode for the relevant port. */
4273 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4274 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4279 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4280 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4282 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4283 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4284 bonding, "bonding");
4285 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4286 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4287 balance_xmit_policy, "balance_xmit_policy");
4288 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4289 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4291 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4292 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4293 policy, "l2#l23#l34");
4295 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4296 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4297 .help_str = "set bonding balance_xmit_policy <port_id> "
4299 "Set the bonding balance_xmit_policy for port_id",
4302 (void *)&cmd_setbonding_balance_xmit_policy_set,
4303 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4304 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4305 (void *)&cmd_setbonding_balance_xmit_policy_port,
4306 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4311 /* *** SHOW NIC BONDING CONFIGURATION *** */
4312 struct cmd_show_bonding_config_result {
4313 cmdline_fixed_string_t show;
4314 cmdline_fixed_string_t bonding;
4315 cmdline_fixed_string_t config;
4319 static void cmd_show_bonding_config_parsed(void *parsed_result,
4320 __attribute__((unused)) struct cmdline *cl,
4321 __attribute__((unused)) void *data)
4323 struct cmd_show_bonding_config_result *res = parsed_result;
4325 uint8_t slaves[RTE_MAX_ETHPORTS];
4326 int num_slaves, num_active_slaves;
4329 portid_t port_id = res->port_id;
4331 /* Display the bonding mode.*/
4332 bonding_mode = rte_eth_bond_mode_get(port_id);
4333 if (bonding_mode < 0) {
4334 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4337 printf("\tBonding mode: %d\n", bonding_mode);
4339 if (bonding_mode == BONDING_MODE_BALANCE) {
4340 int balance_xmit_policy;
4342 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4343 if (balance_xmit_policy < 0) {
4344 printf("\tFailed to get balance xmit policy for port = %d\n",
4348 printf("\tBalance Xmit Policy: ");
4350 switch (balance_xmit_policy) {
4351 case BALANCE_XMIT_POLICY_LAYER2:
4352 printf("BALANCE_XMIT_POLICY_LAYER2");
4354 case BALANCE_XMIT_POLICY_LAYER23:
4355 printf("BALANCE_XMIT_POLICY_LAYER23");
4357 case BALANCE_XMIT_POLICY_LAYER34:
4358 printf("BALANCE_XMIT_POLICY_LAYER34");
4365 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4367 if (num_slaves < 0) {
4368 printf("\tFailed to get slave list for port = %d\n", port_id);
4371 if (num_slaves > 0) {
4372 printf("\tSlaves (%d): [", num_slaves);
4373 for (i = 0; i < num_slaves - 1; i++)
4374 printf("%d ", slaves[i]);
4376 printf("%d]\n", slaves[num_slaves - 1]);
4378 printf("\tSlaves: []\n");
4382 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4385 if (num_active_slaves < 0) {
4386 printf("\tFailed to get active slave list for port = %d\n", port_id);
4389 if (num_active_slaves > 0) {
4390 printf("\tActive Slaves (%d): [", num_active_slaves);
4391 for (i = 0; i < num_active_slaves - 1; i++)
4392 printf("%d ", slaves[i]);
4394 printf("%d]\n", slaves[num_active_slaves - 1]);
4397 printf("\tActive Slaves: []\n");
4401 primary_id = rte_eth_bond_primary_get(port_id);
4402 if (primary_id < 0) {
4403 printf("\tFailed to get primary slave for port = %d\n", port_id);
4406 printf("\tPrimary: [%d]\n", primary_id);
4410 cmdline_parse_token_string_t cmd_showbonding_config_show =
4411 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4413 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4414 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4415 bonding, "bonding");
4416 cmdline_parse_token_string_t cmd_showbonding_config_config =
4417 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4419 cmdline_parse_token_num_t cmd_showbonding_config_port =
4420 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4423 cmdline_parse_inst_t cmd_show_bonding_config = {
4424 .f = cmd_show_bonding_config_parsed,
4425 .help_str = "show bonding config <port_id>: "
4426 "Show the bonding config for port_id",
4429 (void *)&cmd_showbonding_config_show,
4430 (void *)&cmd_showbonding_config_bonding,
4431 (void *)&cmd_showbonding_config_config,
4432 (void *)&cmd_showbonding_config_port,
4437 /* *** SET BONDING PRIMARY *** */
4438 struct cmd_set_bonding_primary_result {
4439 cmdline_fixed_string_t set;
4440 cmdline_fixed_string_t bonding;
4441 cmdline_fixed_string_t primary;
4446 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4447 __attribute__((unused)) struct cmdline *cl,
4448 __attribute__((unused)) void *data)
4450 struct cmd_set_bonding_primary_result *res = parsed_result;
4451 portid_t master_port_id = res->port_id;
4452 portid_t slave_port_id = res->slave_id;
4454 /* Set the primary slave for a bonded device. */
4455 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4456 printf("\t Failed to set primary slave for port = %d.\n",
4463 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4464 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4466 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4467 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4468 bonding, "bonding");
4469 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4470 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4471 primary, "primary");
4472 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4473 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4475 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4476 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4479 cmdline_parse_inst_t cmd_set_bonding_primary = {
4480 .f = cmd_set_bonding_primary_parsed,
4481 .help_str = "set bonding primary <slave_id> <port_id>: "
4482 "Set the primary slave for port_id",
4485 (void *)&cmd_setbonding_primary_set,
4486 (void *)&cmd_setbonding_primary_bonding,
4487 (void *)&cmd_setbonding_primary_primary,
4488 (void *)&cmd_setbonding_primary_slave,
4489 (void *)&cmd_setbonding_primary_port,
4494 /* *** ADD SLAVE *** */
4495 struct cmd_add_bonding_slave_result {
4496 cmdline_fixed_string_t add;
4497 cmdline_fixed_string_t bonding;
4498 cmdline_fixed_string_t slave;
4503 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4504 __attribute__((unused)) struct cmdline *cl,
4505 __attribute__((unused)) void *data)
4507 struct cmd_add_bonding_slave_result *res = parsed_result;
4508 portid_t master_port_id = res->port_id;
4509 portid_t slave_port_id = res->slave_id;
4511 /* Set the primary slave for a bonded device. */
4512 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4513 printf("\t Failed to add slave %d to master port = %d.\n",
4514 slave_port_id, master_port_id);
4518 set_port_slave_flag(slave_port_id);
4521 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4522 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4524 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4525 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4526 bonding, "bonding");
4527 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4528 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4530 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4531 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4533 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4534 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4537 cmdline_parse_inst_t cmd_add_bonding_slave = {
4538 .f = cmd_add_bonding_slave_parsed,
4539 .help_str = "add bonding slave <slave_id> <port_id>: "
4540 "Add a slave device to a bonded device",
4543 (void *)&cmd_addbonding_slave_add,
4544 (void *)&cmd_addbonding_slave_bonding,
4545 (void *)&cmd_addbonding_slave_slave,
4546 (void *)&cmd_addbonding_slave_slaveid,
4547 (void *)&cmd_addbonding_slave_port,
4552 /* *** REMOVE SLAVE *** */
4553 struct cmd_remove_bonding_slave_result {
4554 cmdline_fixed_string_t remove;
4555 cmdline_fixed_string_t bonding;
4556 cmdline_fixed_string_t slave;
4561 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4562 __attribute__((unused)) struct cmdline *cl,
4563 __attribute__((unused)) void *data)
4565 struct cmd_remove_bonding_slave_result *res = parsed_result;
4566 portid_t master_port_id = res->port_id;
4567 portid_t slave_port_id = res->slave_id;
4569 /* Set the primary slave for a bonded device. */
4570 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4571 printf("\t Failed to remove slave %d from master port = %d.\n",
4572 slave_port_id, master_port_id);
4576 clear_port_slave_flag(slave_port_id);
4579 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4580 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4582 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4583 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4584 bonding, "bonding");
4585 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4586 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4588 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4589 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4591 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4592 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4595 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4596 .f = cmd_remove_bonding_slave_parsed,
4597 .help_str = "remove bonding slave <slave_id> <port_id>: "
4598 "Remove a slave device from a bonded device",
4601 (void *)&cmd_removebonding_slave_remove,
4602 (void *)&cmd_removebonding_slave_bonding,
4603 (void *)&cmd_removebonding_slave_slave,
4604 (void *)&cmd_removebonding_slave_slaveid,
4605 (void *)&cmd_removebonding_slave_port,
4610 /* *** CREATE BONDED DEVICE *** */
4611 struct cmd_create_bonded_device_result {
4612 cmdline_fixed_string_t create;
4613 cmdline_fixed_string_t bonded;
4614 cmdline_fixed_string_t device;
4619 static int bond_dev_num = 0;
4621 static void cmd_create_bonded_device_parsed(void *parsed_result,
4622 __attribute__((unused)) struct cmdline *cl,
4623 __attribute__((unused)) void *data)
4625 struct cmd_create_bonded_device_result *res = parsed_result;
4626 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4629 if (test_done == 0) {
4630 printf("Please stop forwarding first\n");
4634 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4637 /* Create a new bonded device. */
4638 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4640 printf("\t Failed to create bonded device.\n");
4643 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4646 /* Update number of ports */
4647 nb_ports = rte_eth_dev_count();
4648 reconfig(port_id, res->socket);
4649 rte_eth_promiscuous_enable(port_id);
4650 ports[port_id].enabled = 1;
4655 cmdline_parse_token_string_t cmd_createbonded_device_create =
4656 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4658 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4659 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4661 cmdline_parse_token_string_t cmd_createbonded_device_device =
4662 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4664 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4665 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4667 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4668 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4671 cmdline_parse_inst_t cmd_create_bonded_device = {
4672 .f = cmd_create_bonded_device_parsed,
4673 .help_str = "create bonded device <mode> <socket>: "
4674 "Create a new bonded device with specific bonding mode and socket",
4677 (void *)&cmd_createbonded_device_create,
4678 (void *)&cmd_createbonded_device_bonded,
4679 (void *)&cmd_createbonded_device_device,
4680 (void *)&cmd_createbonded_device_mode,
4681 (void *)&cmd_createbonded_device_socket,
4686 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4687 struct cmd_set_bond_mac_addr_result {
4688 cmdline_fixed_string_t set;
4689 cmdline_fixed_string_t bonding;
4690 cmdline_fixed_string_t mac_addr;
4692 struct ether_addr address;
4695 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4696 __attribute__((unused)) struct cmdline *cl,
4697 __attribute__((unused)) void *data)
4699 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4702 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4705 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4707 /* check the return value and print it if is < 0 */
4709 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4712 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4713 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4714 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4715 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4717 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4718 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4720 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4721 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4722 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4723 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4725 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4726 .f = cmd_set_bond_mac_addr_parsed,
4728 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4730 (void *)&cmd_set_bond_mac_addr_set,
4731 (void *)&cmd_set_bond_mac_addr_bonding,
4732 (void *)&cmd_set_bond_mac_addr_mac,
4733 (void *)&cmd_set_bond_mac_addr_portnum,
4734 (void *)&cmd_set_bond_mac_addr_addr,
4740 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4741 struct cmd_set_bond_mon_period_result {
4742 cmdline_fixed_string_t set;
4743 cmdline_fixed_string_t bonding;
4744 cmdline_fixed_string_t mon_period;
4749 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4750 __attribute__((unused)) struct cmdline *cl,
4751 __attribute__((unused)) void *data)
4753 struct cmd_set_bond_mon_period_result *res = parsed_result;
4756 if (res->port_num >= nb_ports) {
4757 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4761 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4763 /* check the return value and print it if is < 0 */
4765 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4768 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4769 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4771 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4772 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4773 bonding, "bonding");
4774 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4775 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4776 mon_period, "mon_period");
4777 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4778 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4780 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4781 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4784 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4785 .f = cmd_set_bond_mon_period_parsed,
4787 .help_str = "set bonding mon_period <port_id> <period_ms>",
4789 (void *)&cmd_set_bond_mon_period_set,
4790 (void *)&cmd_set_bond_mon_period_bonding,
4791 (void *)&cmd_set_bond_mon_period_mon_period,
4792 (void *)&cmd_set_bond_mon_period_portnum,
4793 (void *)&cmd_set_bond_mon_period_period_ms,
4798 #endif /* RTE_LIBRTE_PMD_BOND */
4800 /* *** SET FORWARDING MODE *** */
4801 struct cmd_set_fwd_mode_result {
4802 cmdline_fixed_string_t set;
4803 cmdline_fixed_string_t fwd;
4804 cmdline_fixed_string_t mode;
4807 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4808 __attribute__((unused)) struct cmdline *cl,
4809 __attribute__((unused)) void *data)
4811 struct cmd_set_fwd_mode_result *res = parsed_result;
4814 set_pkt_forwarding_mode(res->mode);
4817 cmdline_parse_token_string_t cmd_setfwd_set =
4818 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4819 cmdline_parse_token_string_t cmd_setfwd_fwd =
4820 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4821 cmdline_parse_token_string_t cmd_setfwd_mode =
4822 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4823 "" /* defined at init */);
4825 cmdline_parse_inst_t cmd_set_fwd_mode = {
4826 .f = cmd_set_fwd_mode_parsed,
4828 .help_str = NULL, /* defined at init */
4830 (void *)&cmd_setfwd_set,
4831 (void *)&cmd_setfwd_fwd,
4832 (void *)&cmd_setfwd_mode,
4837 static void cmd_set_fwd_mode_init(void)
4840 static char token[128];
4841 static char help[256];
4842 cmdline_parse_token_string_t *token_struct;
4844 modes = list_pkt_forwarding_modes();
4845 snprintf(help, sizeof(help), "set fwd %s: "
4846 "Set packet forwarding mode", modes);
4847 cmd_set_fwd_mode.help_str = help;
4849 /* string token separator is # */
4850 for (c = token; *modes != '\0'; modes++)
4855 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4856 token_struct->string_data.str = token;
4859 /* *** SET RETRY FORWARDING MODE *** */
4860 struct cmd_set_fwd_retry_mode_result {
4861 cmdline_fixed_string_t set;
4862 cmdline_fixed_string_t fwd;
4863 cmdline_fixed_string_t mode;
4864 cmdline_fixed_string_t retry;
4867 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4868 __attribute__((unused)) struct cmdline *cl,
4869 __attribute__((unused)) void *data)
4871 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4874 set_pkt_forwarding_mode(res->mode);
4877 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4878 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4880 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4881 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4883 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4884 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4886 "" /* defined at init */);
4887 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4888 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4891 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4892 .f = cmd_set_fwd_retry_mode_parsed,
4894 .help_str = NULL, /* defined at init */
4896 (void *)&cmd_setfwd_retry_set,
4897 (void *)&cmd_setfwd_retry_fwd,
4898 (void *)&cmd_setfwd_retry_mode,
4899 (void *)&cmd_setfwd_retry_retry,
4904 static void cmd_set_fwd_retry_mode_init(void)
4907 static char token[128];
4908 static char help[256];
4909 cmdline_parse_token_string_t *token_struct;
4911 modes = list_pkt_forwarding_retry_modes();
4912 snprintf(help, sizeof(help), "set fwd %s retry: "
4913 "Set packet forwarding mode with retry", modes);
4914 cmd_set_fwd_retry_mode.help_str = help;
4916 /* string token separator is # */
4917 for (c = token; *modes != '\0'; modes++)
4922 token_struct = (cmdline_parse_token_string_t *)
4923 cmd_set_fwd_retry_mode.tokens[2];
4924 token_struct->string_data.str = token;
4927 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4928 struct cmd_set_burst_tx_retry_result {
4929 cmdline_fixed_string_t set;
4930 cmdline_fixed_string_t burst;
4931 cmdline_fixed_string_t tx;
4932 cmdline_fixed_string_t delay;
4934 cmdline_fixed_string_t retry;
4938 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4939 __attribute__((unused)) struct cmdline *cl,
4940 __attribute__((unused)) void *data)
4942 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4944 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4945 && !strcmp(res->tx, "tx")) {
4946 if (!strcmp(res->delay, "delay"))
4947 burst_tx_delay_time = res->time;
4948 if (!strcmp(res->retry, "retry"))
4949 burst_tx_retry_num = res->retry_num;
4954 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4955 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4956 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4957 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4959 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4960 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4961 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4962 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4963 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4964 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4965 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4966 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4967 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4968 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4970 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4971 .f = cmd_set_burst_tx_retry_parsed,
4972 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4974 (void *)&cmd_set_burst_tx_retry_set,
4975 (void *)&cmd_set_burst_tx_retry_burst,
4976 (void *)&cmd_set_burst_tx_retry_tx,
4977 (void *)&cmd_set_burst_tx_retry_delay,
4978 (void *)&cmd_set_burst_tx_retry_time,
4979 (void *)&cmd_set_burst_tx_retry_retry,
4980 (void *)&cmd_set_burst_tx_retry_retry_num,
4985 /* *** SET PROMISC MODE *** */
4986 struct cmd_set_promisc_mode_result {
4987 cmdline_fixed_string_t set;
4988 cmdline_fixed_string_t promisc;
4989 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4990 uint8_t port_num; /* valid if "allports" argument == 0 */
4991 cmdline_fixed_string_t mode;
4994 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4995 __attribute__((unused)) struct cmdline *cl,
4998 struct cmd_set_promisc_mode_result *res = parsed_result;
5002 if (!strcmp(res->mode, "on"))
5009 FOREACH_PORT(i, ports) {
5011 rte_eth_promiscuous_enable(i);
5013 rte_eth_promiscuous_disable(i);
5018 rte_eth_promiscuous_enable(res->port_num);
5020 rte_eth_promiscuous_disable(res->port_num);
5024 cmdline_parse_token_string_t cmd_setpromisc_set =
5025 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5026 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5027 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5029 cmdline_parse_token_string_t cmd_setpromisc_portall =
5030 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5032 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5033 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5035 cmdline_parse_token_string_t cmd_setpromisc_mode =
5036 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5039 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5040 .f = cmd_set_promisc_mode_parsed,
5042 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5044 (void *)&cmd_setpromisc_set,
5045 (void *)&cmd_setpromisc_promisc,
5046 (void *)&cmd_setpromisc_portall,
5047 (void *)&cmd_setpromisc_mode,
5052 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5053 .f = cmd_set_promisc_mode_parsed,
5055 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5057 (void *)&cmd_setpromisc_set,
5058 (void *)&cmd_setpromisc_promisc,
5059 (void *)&cmd_setpromisc_portnum,
5060 (void *)&cmd_setpromisc_mode,
5065 /* *** SET ALLMULTI MODE *** */
5066 struct cmd_set_allmulti_mode_result {
5067 cmdline_fixed_string_t set;
5068 cmdline_fixed_string_t allmulti;
5069 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5070 uint8_t port_num; /* valid if "allports" argument == 0 */
5071 cmdline_fixed_string_t mode;
5074 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5075 __attribute__((unused)) struct cmdline *cl,
5078 struct cmd_set_allmulti_mode_result *res = parsed_result;
5082 if (!strcmp(res->mode, "on"))
5089 FOREACH_PORT(i, ports) {
5091 rte_eth_allmulticast_enable(i);
5093 rte_eth_allmulticast_disable(i);
5098 rte_eth_allmulticast_enable(res->port_num);
5100 rte_eth_allmulticast_disable(res->port_num);
5104 cmdline_parse_token_string_t cmd_setallmulti_set =
5105 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5106 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5107 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5109 cmdline_parse_token_string_t cmd_setallmulti_portall =
5110 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5112 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5113 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5115 cmdline_parse_token_string_t cmd_setallmulti_mode =
5116 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5119 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5120 .f = cmd_set_allmulti_mode_parsed,
5122 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5124 (void *)&cmd_setallmulti_set,
5125 (void *)&cmd_setallmulti_allmulti,
5126 (void *)&cmd_setallmulti_portall,
5127 (void *)&cmd_setallmulti_mode,
5132 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5133 .f = cmd_set_allmulti_mode_parsed,
5135 .help_str = "set allmulti <port_id> on|off: "
5136 "Set allmulti mode on port_id",
5138 (void *)&cmd_setallmulti_set,
5139 (void *)&cmd_setallmulti_allmulti,
5140 (void *)&cmd_setallmulti_portnum,
5141 (void *)&cmd_setallmulti_mode,
5146 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5147 struct cmd_link_flow_ctrl_set_result {
5148 cmdline_fixed_string_t set;
5149 cmdline_fixed_string_t flow_ctrl;
5150 cmdline_fixed_string_t rx;
5151 cmdline_fixed_string_t rx_lfc_mode;
5152 cmdline_fixed_string_t tx;
5153 cmdline_fixed_string_t tx_lfc_mode;
5154 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5155 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5156 cmdline_fixed_string_t autoneg_str;
5157 cmdline_fixed_string_t autoneg;
5158 cmdline_fixed_string_t hw_str;
5159 uint32_t high_water;
5160 cmdline_fixed_string_t lw_str;
5162 cmdline_fixed_string_t pt_str;
5163 uint16_t pause_time;
5164 cmdline_fixed_string_t xon_str;
5169 cmdline_parse_token_string_t cmd_lfc_set_set =
5170 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5172 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5173 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5174 flow_ctrl, "flow_ctrl");
5175 cmdline_parse_token_string_t cmd_lfc_set_rx =
5176 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5178 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5179 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5180 rx_lfc_mode, "on#off");
5181 cmdline_parse_token_string_t cmd_lfc_set_tx =
5182 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5184 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5185 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5186 tx_lfc_mode, "on#off");
5187 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5188 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5189 hw_str, "high_water");
5190 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5191 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5192 high_water, UINT32);
5193 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5194 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5195 lw_str, "low_water");
5196 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5197 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5199 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5200 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5201 pt_str, "pause_time");
5202 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5203 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5204 pause_time, UINT16);
5205 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5206 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5207 xon_str, "send_xon");
5208 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5209 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5211 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5212 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5213 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5214 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5215 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5216 mac_ctrl_frame_fwd_mode, "on#off");
5217 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5218 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5219 autoneg_str, "autoneg");
5220 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5221 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5223 cmdline_parse_token_num_t cmd_lfc_set_portid =
5224 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5227 /* forward declaration */
5229 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5232 cmdline_parse_inst_t cmd_link_flow_control_set = {
5233 .f = cmd_link_flow_ctrl_set_parsed,
5235 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5236 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5237 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5239 (void *)&cmd_lfc_set_set,
5240 (void *)&cmd_lfc_set_flow_ctrl,
5241 (void *)&cmd_lfc_set_rx,
5242 (void *)&cmd_lfc_set_rx_mode,
5243 (void *)&cmd_lfc_set_tx,
5244 (void *)&cmd_lfc_set_tx_mode,
5245 (void *)&cmd_lfc_set_high_water,
5246 (void *)&cmd_lfc_set_low_water,
5247 (void *)&cmd_lfc_set_pause_time,
5248 (void *)&cmd_lfc_set_send_xon,
5249 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5250 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5251 (void *)&cmd_lfc_set_autoneg_str,
5252 (void *)&cmd_lfc_set_autoneg,
5253 (void *)&cmd_lfc_set_portid,
5258 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5259 .f = cmd_link_flow_ctrl_set_parsed,
5260 .data = (void *)&cmd_link_flow_control_set_rx,
5261 .help_str = "set flow_ctrl rx on|off <port_id>: "
5262 "Change rx flow control parameter",
5264 (void *)&cmd_lfc_set_set,
5265 (void *)&cmd_lfc_set_flow_ctrl,
5266 (void *)&cmd_lfc_set_rx,
5267 (void *)&cmd_lfc_set_rx_mode,
5268 (void *)&cmd_lfc_set_portid,
5273 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5274 .f = cmd_link_flow_ctrl_set_parsed,
5275 .data = (void *)&cmd_link_flow_control_set_tx,
5276 .help_str = "set flow_ctrl tx on|off <port_id>: "
5277 "Change tx flow control parameter",
5279 (void *)&cmd_lfc_set_set,
5280 (void *)&cmd_lfc_set_flow_ctrl,
5281 (void *)&cmd_lfc_set_tx,
5282 (void *)&cmd_lfc_set_tx_mode,
5283 (void *)&cmd_lfc_set_portid,
5288 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5289 .f = cmd_link_flow_ctrl_set_parsed,
5290 .data = (void *)&cmd_link_flow_control_set_hw,
5291 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5292 "Change high water flow control parameter",
5294 (void *)&cmd_lfc_set_set,
5295 (void *)&cmd_lfc_set_flow_ctrl,
5296 (void *)&cmd_lfc_set_high_water_str,
5297 (void *)&cmd_lfc_set_high_water,
5298 (void *)&cmd_lfc_set_portid,
5303 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5304 .f = cmd_link_flow_ctrl_set_parsed,
5305 .data = (void *)&cmd_link_flow_control_set_lw,
5306 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5307 "Change low water flow control parameter",
5309 (void *)&cmd_lfc_set_set,
5310 (void *)&cmd_lfc_set_flow_ctrl,
5311 (void *)&cmd_lfc_set_low_water_str,
5312 (void *)&cmd_lfc_set_low_water,
5313 (void *)&cmd_lfc_set_portid,
5318 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5319 .f = cmd_link_flow_ctrl_set_parsed,
5320 .data = (void *)&cmd_link_flow_control_set_pt,
5321 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5322 "Change pause time flow control parameter",
5324 (void *)&cmd_lfc_set_set,
5325 (void *)&cmd_lfc_set_flow_ctrl,
5326 (void *)&cmd_lfc_set_pause_time_str,
5327 (void *)&cmd_lfc_set_pause_time,
5328 (void *)&cmd_lfc_set_portid,
5333 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5334 .f = cmd_link_flow_ctrl_set_parsed,
5335 .data = (void *)&cmd_link_flow_control_set_xon,
5336 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5337 "Change send_xon flow control parameter",
5339 (void *)&cmd_lfc_set_set,
5340 (void *)&cmd_lfc_set_flow_ctrl,
5341 (void *)&cmd_lfc_set_send_xon_str,
5342 (void *)&cmd_lfc_set_send_xon,
5343 (void *)&cmd_lfc_set_portid,
5348 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5349 .f = cmd_link_flow_ctrl_set_parsed,
5350 .data = (void *)&cmd_link_flow_control_set_macfwd,
5351 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5352 "Change mac ctrl fwd flow control parameter",
5354 (void *)&cmd_lfc_set_set,
5355 (void *)&cmd_lfc_set_flow_ctrl,
5356 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5357 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5358 (void *)&cmd_lfc_set_portid,
5363 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5364 .f = cmd_link_flow_ctrl_set_parsed,
5365 .data = (void *)&cmd_link_flow_control_set_autoneg,
5366 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5367 "Change autoneg flow control parameter",
5369 (void *)&cmd_lfc_set_set,
5370 (void *)&cmd_lfc_set_flow_ctrl,
5371 (void *)&cmd_lfc_set_autoneg_str,
5372 (void *)&cmd_lfc_set_autoneg,
5373 (void *)&cmd_lfc_set_portid,
5379 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5380 __attribute__((unused)) struct cmdline *cl,
5383 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5384 cmdline_parse_inst_t *cmd = data;
5385 struct rte_eth_fc_conf fc_conf;
5391 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5392 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5393 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5394 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5396 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5397 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5400 /* Partial command line, retrieve current configuration */
5402 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5404 printf("cannot get current flow ctrl parameters, return"
5405 "code = %d\n", ret);
5409 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5410 (fc_conf.mode == RTE_FC_FULL))
5412 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5413 (fc_conf.mode == RTE_FC_FULL))
5417 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5418 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5420 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5421 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5423 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5425 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5426 fc_conf.high_water = res->high_water;
5428 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5429 fc_conf.low_water = res->low_water;
5431 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5432 fc_conf.pause_time = res->pause_time;
5434 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5435 fc_conf.send_xon = res->send_xon;
5437 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5438 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5439 fc_conf.mac_ctrl_frame_fwd = 1;
5441 fc_conf.mac_ctrl_frame_fwd = 0;
5444 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5445 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5447 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5449 printf("bad flow contrl parameter, return code = %d \n", ret);
5452 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5453 struct cmd_priority_flow_ctrl_set_result {
5454 cmdline_fixed_string_t set;
5455 cmdline_fixed_string_t pfc_ctrl;
5456 cmdline_fixed_string_t rx;
5457 cmdline_fixed_string_t rx_pfc_mode;
5458 cmdline_fixed_string_t tx;
5459 cmdline_fixed_string_t tx_pfc_mode;
5460 uint32_t high_water;
5462 uint16_t pause_time;
5468 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5469 __attribute__((unused)) struct cmdline *cl,
5470 __attribute__((unused)) void *data)
5472 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5473 struct rte_eth_pfc_conf pfc_conf;
5474 int rx_fc_enable, tx_fc_enable;
5478 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5479 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5480 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5481 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5483 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5484 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5487 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5488 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5489 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5490 pfc_conf.fc.high_water = res->high_water;
5491 pfc_conf.fc.low_water = res->low_water;
5492 pfc_conf.fc.pause_time = res->pause_time;
5493 pfc_conf.priority = res->priority;
5495 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5497 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5500 cmdline_parse_token_string_t cmd_pfc_set_set =
5501 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5503 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5504 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5505 pfc_ctrl, "pfc_ctrl");
5506 cmdline_parse_token_string_t cmd_pfc_set_rx =
5507 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5509 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5510 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5511 rx_pfc_mode, "on#off");
5512 cmdline_parse_token_string_t cmd_pfc_set_tx =
5513 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5515 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5516 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5517 tx_pfc_mode, "on#off");
5518 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5519 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5520 high_water, UINT32);
5521 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5522 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5524 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5525 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5526 pause_time, UINT16);
5527 cmdline_parse_token_num_t cmd_pfc_set_priority =
5528 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5530 cmdline_parse_token_num_t cmd_pfc_set_portid =
5531 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5534 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5535 .f = cmd_priority_flow_ctrl_set_parsed,
5537 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5538 "<pause_time> <priority> <port_id>: "
5539 "Configure the Ethernet priority flow control",
5541 (void *)&cmd_pfc_set_set,
5542 (void *)&cmd_pfc_set_flow_ctrl,
5543 (void *)&cmd_pfc_set_rx,
5544 (void *)&cmd_pfc_set_rx_mode,
5545 (void *)&cmd_pfc_set_tx,
5546 (void *)&cmd_pfc_set_tx_mode,
5547 (void *)&cmd_pfc_set_high_water,
5548 (void *)&cmd_pfc_set_low_water,
5549 (void *)&cmd_pfc_set_pause_time,
5550 (void *)&cmd_pfc_set_priority,
5551 (void *)&cmd_pfc_set_portid,
5556 /* *** RESET CONFIGURATION *** */
5557 struct cmd_reset_result {
5558 cmdline_fixed_string_t reset;
5559 cmdline_fixed_string_t def;
5562 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5564 __attribute__((unused)) void *data)
5566 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5567 set_def_fwd_config();
5570 cmdline_parse_token_string_t cmd_reset_set =
5571 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5572 cmdline_parse_token_string_t cmd_reset_def =
5573 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5576 cmdline_parse_inst_t cmd_reset = {
5577 .f = cmd_reset_parsed,
5579 .help_str = "set default: Reset default forwarding configuration",
5581 (void *)&cmd_reset_set,
5582 (void *)&cmd_reset_def,
5587 /* *** START FORWARDING *** */
5588 struct cmd_start_result {
5589 cmdline_fixed_string_t start;
5592 cmdline_parse_token_string_t cmd_start_start =
5593 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5595 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5596 __attribute__((unused)) struct cmdline *cl,
5597 __attribute__((unused)) void *data)
5599 start_packet_forwarding(0);
5602 cmdline_parse_inst_t cmd_start = {
5603 .f = cmd_start_parsed,
5605 .help_str = "start: Start packet forwarding",
5607 (void *)&cmd_start_start,
5612 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5613 struct cmd_start_tx_first_result {
5614 cmdline_fixed_string_t start;
5615 cmdline_fixed_string_t tx_first;
5619 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5620 __attribute__((unused)) struct cmdline *cl,
5621 __attribute__((unused)) void *data)
5623 start_packet_forwarding(1);
5626 cmdline_parse_token_string_t cmd_start_tx_first_start =
5627 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5629 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5630 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5631 tx_first, "tx_first");
5633 cmdline_parse_inst_t cmd_start_tx_first = {
5634 .f = cmd_start_tx_first_parsed,
5636 .help_str = "start tx_first: Start packet forwarding, "
5637 "after sending 1 burst of packets",
5639 (void *)&cmd_start_tx_first_start,
5640 (void *)&cmd_start_tx_first_tx_first,
5645 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5646 struct cmd_start_tx_first_n_result {
5647 cmdline_fixed_string_t start;
5648 cmdline_fixed_string_t tx_first;
5653 cmd_start_tx_first_n_parsed(void *parsed_result,
5654 __attribute__((unused)) struct cmdline *cl,
5655 __attribute__((unused)) void *data)
5657 struct cmd_start_tx_first_n_result *res = parsed_result;
5659 start_packet_forwarding(res->tx_num);
5662 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5663 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5665 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5666 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5667 tx_first, "tx_first");
5668 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5669 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5672 cmdline_parse_inst_t cmd_start_tx_first_n = {
5673 .f = cmd_start_tx_first_n_parsed,
5675 .help_str = "start tx_first <num>: "
5676 "packet forwarding, after sending <num> bursts of packets",
5678 (void *)&cmd_start_tx_first_n_start,
5679 (void *)&cmd_start_tx_first_n_tx_first,
5680 (void *)&cmd_start_tx_first_n_tx_num,
5685 /* *** SET LINK UP *** */
5686 struct cmd_set_link_up_result {
5687 cmdline_fixed_string_t set;
5688 cmdline_fixed_string_t link_up;
5689 cmdline_fixed_string_t port;
5693 cmdline_parse_token_string_t cmd_set_link_up_set =
5694 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5695 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5696 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5698 cmdline_parse_token_string_t cmd_set_link_up_port =
5699 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5700 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5701 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5703 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5704 __attribute__((unused)) struct cmdline *cl,
5705 __attribute__((unused)) void *data)
5707 struct cmd_set_link_up_result *res = parsed_result;
5708 dev_set_link_up(res->port_id);
5711 cmdline_parse_inst_t cmd_set_link_up = {
5712 .f = cmd_set_link_up_parsed,
5714 .help_str = "set link-up port <port id>",
5716 (void *)&cmd_set_link_up_set,
5717 (void *)&cmd_set_link_up_link_up,
5718 (void *)&cmd_set_link_up_port,
5719 (void *)&cmd_set_link_up_port_id,
5724 /* *** SET LINK DOWN *** */
5725 struct cmd_set_link_down_result {
5726 cmdline_fixed_string_t set;
5727 cmdline_fixed_string_t link_down;
5728 cmdline_fixed_string_t port;
5732 cmdline_parse_token_string_t cmd_set_link_down_set =
5733 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5734 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5735 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5737 cmdline_parse_token_string_t cmd_set_link_down_port =
5738 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5739 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5740 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5742 static void cmd_set_link_down_parsed(
5743 __attribute__((unused)) void *parsed_result,
5744 __attribute__((unused)) struct cmdline *cl,
5745 __attribute__((unused)) void *data)
5747 struct cmd_set_link_down_result *res = parsed_result;
5748 dev_set_link_down(res->port_id);
5751 cmdline_parse_inst_t cmd_set_link_down = {
5752 .f = cmd_set_link_down_parsed,
5754 .help_str = "set link-down port <port id>",
5756 (void *)&cmd_set_link_down_set,
5757 (void *)&cmd_set_link_down_link_down,
5758 (void *)&cmd_set_link_down_port,
5759 (void *)&cmd_set_link_down_port_id,
5764 /* *** SHOW CFG *** */
5765 struct cmd_showcfg_result {
5766 cmdline_fixed_string_t show;
5767 cmdline_fixed_string_t cfg;
5768 cmdline_fixed_string_t what;
5771 static void cmd_showcfg_parsed(void *parsed_result,
5772 __attribute__((unused)) struct cmdline *cl,
5773 __attribute__((unused)) void *data)
5775 struct cmd_showcfg_result *res = parsed_result;
5776 if (!strcmp(res->what, "rxtx"))
5777 rxtx_config_display();
5778 else if (!strcmp(res->what, "cores"))
5779 fwd_lcores_config_display();
5780 else if (!strcmp(res->what, "fwd"))
5781 pkt_fwd_config_display(&cur_fwd_config);
5782 else if (!strcmp(res->what, "txpkts"))
5783 show_tx_pkt_segments();
5786 cmdline_parse_token_string_t cmd_showcfg_show =
5787 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5788 cmdline_parse_token_string_t cmd_showcfg_port =
5789 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5790 cmdline_parse_token_string_t cmd_showcfg_what =
5791 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5792 "rxtx#cores#fwd#txpkts");
5794 cmdline_parse_inst_t cmd_showcfg = {
5795 .f = cmd_showcfg_parsed,
5797 .help_str = "show config rxtx|cores|fwd|txpkts",
5799 (void *)&cmd_showcfg_show,
5800 (void *)&cmd_showcfg_port,
5801 (void *)&cmd_showcfg_what,
5806 /* *** SHOW ALL PORT INFO *** */
5807 struct cmd_showportall_result {
5808 cmdline_fixed_string_t show;
5809 cmdline_fixed_string_t port;
5810 cmdline_fixed_string_t what;
5811 cmdline_fixed_string_t all;
5814 static void cmd_showportall_parsed(void *parsed_result,
5815 __attribute__((unused)) struct cmdline *cl,
5816 __attribute__((unused)) void *data)
5820 struct cmd_showportall_result *res = parsed_result;
5821 if (!strcmp(res->show, "clear")) {
5822 if (!strcmp(res->what, "stats"))
5823 FOREACH_PORT(i, ports)
5825 else if (!strcmp(res->what, "xstats"))
5826 FOREACH_PORT(i, ports)
5827 nic_xstats_clear(i);
5828 } else if (!strcmp(res->what, "info"))
5829 FOREACH_PORT(i, ports)
5830 port_infos_display(i);
5831 else if (!strcmp(res->what, "stats"))
5832 FOREACH_PORT(i, ports)
5833 nic_stats_display(i);
5834 else if (!strcmp(res->what, "xstats"))
5835 FOREACH_PORT(i, ports)
5836 nic_xstats_display(i);
5837 else if (!strcmp(res->what, "fdir"))
5838 FOREACH_PORT(i, ports)
5840 else if (!strcmp(res->what, "stat_qmap"))
5841 FOREACH_PORT(i, ports)
5842 nic_stats_mapping_display(i);
5843 else if (!strcmp(res->what, "dcb_tc"))
5844 FOREACH_PORT(i, ports)
5845 port_dcb_info_display(i);
5846 else if (!strcmp(res->what, "cap"))
5847 FOREACH_PORT(i, ports)
5848 port_offload_cap_display(i);
5851 cmdline_parse_token_string_t cmd_showportall_show =
5852 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5854 cmdline_parse_token_string_t cmd_showportall_port =
5855 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5856 cmdline_parse_token_string_t cmd_showportall_what =
5857 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5858 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5859 cmdline_parse_token_string_t cmd_showportall_all =
5860 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5861 cmdline_parse_inst_t cmd_showportall = {
5862 .f = cmd_showportall_parsed,
5864 .help_str = "show|clear port "
5865 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5867 (void *)&cmd_showportall_show,
5868 (void *)&cmd_showportall_port,
5869 (void *)&cmd_showportall_what,
5870 (void *)&cmd_showportall_all,
5875 /* *** SHOW PORT INFO *** */
5876 struct cmd_showport_result {
5877 cmdline_fixed_string_t show;
5878 cmdline_fixed_string_t port;
5879 cmdline_fixed_string_t what;
5883 static void cmd_showport_parsed(void *parsed_result,
5884 __attribute__((unused)) struct cmdline *cl,
5885 __attribute__((unused)) void *data)
5887 struct cmd_showport_result *res = parsed_result;
5888 if (!strcmp(res->show, "clear")) {
5889 if (!strcmp(res->what, "stats"))
5890 nic_stats_clear(res->portnum);
5891 else if (!strcmp(res->what, "xstats"))
5892 nic_xstats_clear(res->portnum);
5893 } else if (!strcmp(res->what, "info"))
5894 port_infos_display(res->portnum);
5895 else if (!strcmp(res->what, "stats"))
5896 nic_stats_display(res->portnum);
5897 else if (!strcmp(res->what, "xstats"))
5898 nic_xstats_display(res->portnum);
5899 else if (!strcmp(res->what, "fdir"))
5900 fdir_get_infos(res->portnum);
5901 else if (!strcmp(res->what, "stat_qmap"))
5902 nic_stats_mapping_display(res->portnum);
5903 else if (!strcmp(res->what, "dcb_tc"))
5904 port_dcb_info_display(res->portnum);
5905 else if (!strcmp(res->what, "cap"))
5906 port_offload_cap_display(res->portnum);
5909 cmdline_parse_token_string_t cmd_showport_show =
5910 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5912 cmdline_parse_token_string_t cmd_showport_port =
5913 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5914 cmdline_parse_token_string_t cmd_showport_what =
5915 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5916 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5917 cmdline_parse_token_num_t cmd_showport_portnum =
5918 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5920 cmdline_parse_inst_t cmd_showport = {
5921 .f = cmd_showport_parsed,
5923 .help_str = "show|clear port "
5924 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5927 (void *)&cmd_showport_show,
5928 (void *)&cmd_showport_port,
5929 (void *)&cmd_showport_what,
5930 (void *)&cmd_showport_portnum,
5935 /* *** SHOW QUEUE INFO *** */
5936 struct cmd_showqueue_result {
5937 cmdline_fixed_string_t show;
5938 cmdline_fixed_string_t type;
5939 cmdline_fixed_string_t what;
5945 cmd_showqueue_parsed(void *parsed_result,
5946 __attribute__((unused)) struct cmdline *cl,
5947 __attribute__((unused)) void *data)
5949 struct cmd_showqueue_result *res = parsed_result;
5951 if (!strcmp(res->type, "rxq"))
5952 rx_queue_infos_display(res->portnum, res->queuenum);
5953 else if (!strcmp(res->type, "txq"))
5954 tx_queue_infos_display(res->portnum, res->queuenum);
5957 cmdline_parse_token_string_t cmd_showqueue_show =
5958 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5959 cmdline_parse_token_string_t cmd_showqueue_type =
5960 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5961 cmdline_parse_token_string_t cmd_showqueue_what =
5962 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5963 cmdline_parse_token_num_t cmd_showqueue_portnum =
5964 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5965 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5966 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5968 cmdline_parse_inst_t cmd_showqueue = {
5969 .f = cmd_showqueue_parsed,
5971 .help_str = "show rxq|txq info <port_id> <queue_id>",
5973 (void *)&cmd_showqueue_show,
5974 (void *)&cmd_showqueue_type,
5975 (void *)&cmd_showqueue_what,
5976 (void *)&cmd_showqueue_portnum,
5977 (void *)&cmd_showqueue_queuenum,
5982 /* *** READ PORT REGISTER *** */
5983 struct cmd_read_reg_result {
5984 cmdline_fixed_string_t read;
5985 cmdline_fixed_string_t reg;
5991 cmd_read_reg_parsed(void *parsed_result,
5992 __attribute__((unused)) struct cmdline *cl,
5993 __attribute__((unused)) void *data)
5995 struct cmd_read_reg_result *res = parsed_result;
5996 port_reg_display(res->port_id, res->reg_off);
5999 cmdline_parse_token_string_t cmd_read_reg_read =
6000 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6001 cmdline_parse_token_string_t cmd_read_reg_reg =
6002 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6003 cmdline_parse_token_num_t cmd_read_reg_port_id =
6004 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6005 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6006 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6008 cmdline_parse_inst_t cmd_read_reg = {
6009 .f = cmd_read_reg_parsed,
6011 .help_str = "read reg <port_id> <reg_off>",
6013 (void *)&cmd_read_reg_read,
6014 (void *)&cmd_read_reg_reg,
6015 (void *)&cmd_read_reg_port_id,
6016 (void *)&cmd_read_reg_reg_off,
6021 /* *** READ PORT REGISTER BIT FIELD *** */
6022 struct cmd_read_reg_bit_field_result {
6023 cmdline_fixed_string_t read;
6024 cmdline_fixed_string_t regfield;
6032 cmd_read_reg_bit_field_parsed(void *parsed_result,
6033 __attribute__((unused)) struct cmdline *cl,
6034 __attribute__((unused)) void *data)
6036 struct cmd_read_reg_bit_field_result *res = parsed_result;
6037 port_reg_bit_field_display(res->port_id, res->reg_off,
6038 res->bit1_pos, res->bit2_pos);
6041 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6042 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6044 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6045 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6046 regfield, "regfield");
6047 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6048 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6050 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6051 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6053 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6054 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6056 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6057 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6060 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6061 .f = cmd_read_reg_bit_field_parsed,
6063 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6064 "Read register bit field between bit_x and bit_y included",
6066 (void *)&cmd_read_reg_bit_field_read,
6067 (void *)&cmd_read_reg_bit_field_regfield,
6068 (void *)&cmd_read_reg_bit_field_port_id,
6069 (void *)&cmd_read_reg_bit_field_reg_off,
6070 (void *)&cmd_read_reg_bit_field_bit1_pos,
6071 (void *)&cmd_read_reg_bit_field_bit2_pos,
6076 /* *** READ PORT REGISTER BIT *** */
6077 struct cmd_read_reg_bit_result {
6078 cmdline_fixed_string_t read;
6079 cmdline_fixed_string_t regbit;
6086 cmd_read_reg_bit_parsed(void *parsed_result,
6087 __attribute__((unused)) struct cmdline *cl,
6088 __attribute__((unused)) void *data)
6090 struct cmd_read_reg_bit_result *res = parsed_result;
6091 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6094 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6095 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6096 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6097 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6099 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6100 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6101 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6102 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6103 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6104 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6106 cmdline_parse_inst_t cmd_read_reg_bit = {
6107 .f = cmd_read_reg_bit_parsed,
6109 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6111 (void *)&cmd_read_reg_bit_read,
6112 (void *)&cmd_read_reg_bit_regbit,
6113 (void *)&cmd_read_reg_bit_port_id,
6114 (void *)&cmd_read_reg_bit_reg_off,
6115 (void *)&cmd_read_reg_bit_bit_pos,
6120 /* *** WRITE PORT REGISTER *** */
6121 struct cmd_write_reg_result {
6122 cmdline_fixed_string_t write;
6123 cmdline_fixed_string_t reg;
6130 cmd_write_reg_parsed(void *parsed_result,
6131 __attribute__((unused)) struct cmdline *cl,
6132 __attribute__((unused)) void *data)
6134 struct cmd_write_reg_result *res = parsed_result;
6135 port_reg_set(res->port_id, res->reg_off, res->value);
6138 cmdline_parse_token_string_t cmd_write_reg_write =
6139 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6140 cmdline_parse_token_string_t cmd_write_reg_reg =
6141 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6142 cmdline_parse_token_num_t cmd_write_reg_port_id =
6143 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6144 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6145 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6146 cmdline_parse_token_num_t cmd_write_reg_value =
6147 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6149 cmdline_parse_inst_t cmd_write_reg = {
6150 .f = cmd_write_reg_parsed,
6152 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6154 (void *)&cmd_write_reg_write,
6155 (void *)&cmd_write_reg_reg,
6156 (void *)&cmd_write_reg_port_id,
6157 (void *)&cmd_write_reg_reg_off,
6158 (void *)&cmd_write_reg_value,
6163 /* *** WRITE PORT REGISTER BIT FIELD *** */
6164 struct cmd_write_reg_bit_field_result {
6165 cmdline_fixed_string_t write;
6166 cmdline_fixed_string_t regfield;
6175 cmd_write_reg_bit_field_parsed(void *parsed_result,
6176 __attribute__((unused)) struct cmdline *cl,
6177 __attribute__((unused)) void *data)
6179 struct cmd_write_reg_bit_field_result *res = parsed_result;
6180 port_reg_bit_field_set(res->port_id, res->reg_off,
6181 res->bit1_pos, res->bit2_pos, res->value);
6184 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6185 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6187 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6188 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6189 regfield, "regfield");
6190 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6191 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6193 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6194 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6196 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6197 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6199 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6200 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6202 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6203 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6206 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6207 .f = cmd_write_reg_bit_field_parsed,
6209 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6211 "Set register bit field between bit_x and bit_y included",
6213 (void *)&cmd_write_reg_bit_field_write,
6214 (void *)&cmd_write_reg_bit_field_regfield,
6215 (void *)&cmd_write_reg_bit_field_port_id,
6216 (void *)&cmd_write_reg_bit_field_reg_off,
6217 (void *)&cmd_write_reg_bit_field_bit1_pos,
6218 (void *)&cmd_write_reg_bit_field_bit2_pos,
6219 (void *)&cmd_write_reg_bit_field_value,
6224 /* *** WRITE PORT REGISTER BIT *** */
6225 struct cmd_write_reg_bit_result {
6226 cmdline_fixed_string_t write;
6227 cmdline_fixed_string_t regbit;
6235 cmd_write_reg_bit_parsed(void *parsed_result,
6236 __attribute__((unused)) struct cmdline *cl,
6237 __attribute__((unused)) void *data)
6239 struct cmd_write_reg_bit_result *res = parsed_result;
6240 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6243 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6244 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6246 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6247 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6249 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6250 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6251 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6252 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6253 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6254 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6255 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6256 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6258 cmdline_parse_inst_t cmd_write_reg_bit = {
6259 .f = cmd_write_reg_bit_parsed,
6261 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6264 (void *)&cmd_write_reg_bit_write,
6265 (void *)&cmd_write_reg_bit_regbit,
6266 (void *)&cmd_write_reg_bit_port_id,
6267 (void *)&cmd_write_reg_bit_reg_off,
6268 (void *)&cmd_write_reg_bit_bit_pos,
6269 (void *)&cmd_write_reg_bit_value,
6274 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6275 struct cmd_read_rxd_txd_result {
6276 cmdline_fixed_string_t read;
6277 cmdline_fixed_string_t rxd_txd;
6284 cmd_read_rxd_txd_parsed(void *parsed_result,
6285 __attribute__((unused)) struct cmdline *cl,
6286 __attribute__((unused)) void *data)
6288 struct cmd_read_rxd_txd_result *res = parsed_result;
6290 if (!strcmp(res->rxd_txd, "rxd"))
6291 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6292 else if (!strcmp(res->rxd_txd, "txd"))
6293 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6296 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6297 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6298 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6299 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6301 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6302 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6303 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6304 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6305 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6306 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6308 cmdline_parse_inst_t cmd_read_rxd_txd = {
6309 .f = cmd_read_rxd_txd_parsed,
6311 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6313 (void *)&cmd_read_rxd_txd_read,
6314 (void *)&cmd_read_rxd_txd_rxd_txd,
6315 (void *)&cmd_read_rxd_txd_port_id,
6316 (void *)&cmd_read_rxd_txd_queue_id,
6317 (void *)&cmd_read_rxd_txd_desc_id,
6323 struct cmd_quit_result {
6324 cmdline_fixed_string_t quit;
6327 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6329 __attribute__((unused)) void *data)
6335 cmdline_parse_token_string_t cmd_quit_quit =
6336 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6338 cmdline_parse_inst_t cmd_quit = {
6339 .f = cmd_quit_parsed,
6341 .help_str = "quit: Exit application",
6343 (void *)&cmd_quit_quit,
6348 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6349 struct cmd_mac_addr_result {
6350 cmdline_fixed_string_t mac_addr_cmd;
6351 cmdline_fixed_string_t what;
6353 struct ether_addr address;
6356 static void cmd_mac_addr_parsed(void *parsed_result,
6357 __attribute__((unused)) struct cmdline *cl,
6358 __attribute__((unused)) void *data)
6360 struct cmd_mac_addr_result *res = parsed_result;
6363 if (strcmp(res->what, "add") == 0)
6364 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6365 else if (strcmp(res->what, "set") == 0)
6366 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6369 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6371 /* check the return value and print it if is < 0 */
6373 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6377 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6378 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6380 cmdline_parse_token_string_t cmd_mac_addr_what =
6381 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6383 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6384 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6385 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6386 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6388 cmdline_parse_inst_t cmd_mac_addr = {
6389 .f = cmd_mac_addr_parsed,
6391 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6392 "Add/Remove/Set MAC address on port_id",
6394 (void *)&cmd_mac_addr_cmd,
6395 (void *)&cmd_mac_addr_what,
6396 (void *)&cmd_mac_addr_portnum,
6397 (void *)&cmd_mac_addr_addr,
6403 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6404 struct cmd_set_qmap_result {
6405 cmdline_fixed_string_t set;
6406 cmdline_fixed_string_t qmap;
6407 cmdline_fixed_string_t what;
6414 cmd_set_qmap_parsed(void *parsed_result,
6415 __attribute__((unused)) struct cmdline *cl,
6416 __attribute__((unused)) void *data)
6418 struct cmd_set_qmap_result *res = parsed_result;
6419 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6421 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6424 cmdline_parse_token_string_t cmd_setqmap_set =
6425 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6427 cmdline_parse_token_string_t cmd_setqmap_qmap =
6428 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6430 cmdline_parse_token_string_t cmd_setqmap_what =
6431 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6433 cmdline_parse_token_num_t cmd_setqmap_portid =
6434 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6436 cmdline_parse_token_num_t cmd_setqmap_queueid =
6437 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6439 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6440 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6443 cmdline_parse_inst_t cmd_set_qmap = {
6444 .f = cmd_set_qmap_parsed,
6446 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6447 "Set statistics mapping value on tx|rx queue_id of port_id",
6449 (void *)&cmd_setqmap_set,
6450 (void *)&cmd_setqmap_qmap,
6451 (void *)&cmd_setqmap_what,
6452 (void *)&cmd_setqmap_portid,
6453 (void *)&cmd_setqmap_queueid,
6454 (void *)&cmd_setqmap_mapvalue,
6459 /* *** CONFIGURE UNICAST HASH TABLE *** */
6460 struct cmd_set_uc_hash_table {
6461 cmdline_fixed_string_t set;
6462 cmdline_fixed_string_t port;
6464 cmdline_fixed_string_t what;
6465 struct ether_addr address;
6466 cmdline_fixed_string_t mode;
6470 cmd_set_uc_hash_parsed(void *parsed_result,
6471 __attribute__((unused)) struct cmdline *cl,
6472 __attribute__((unused)) void *data)
6475 struct cmd_set_uc_hash_table *res = parsed_result;
6477 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6479 if (strcmp(res->what, "uta") == 0)
6480 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6481 &res->address,(uint8_t)is_on);
6483 printf("bad unicast hash table parameter, return code = %d \n", ret);
6487 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6488 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6490 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6491 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6493 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6494 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6496 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6497 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6499 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6500 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6502 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6503 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6506 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6507 .f = cmd_set_uc_hash_parsed,
6509 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6511 (void *)&cmd_set_uc_hash_set,
6512 (void *)&cmd_set_uc_hash_port,
6513 (void *)&cmd_set_uc_hash_portid,
6514 (void *)&cmd_set_uc_hash_what,
6515 (void *)&cmd_set_uc_hash_mac,
6516 (void *)&cmd_set_uc_hash_mode,
6521 struct cmd_set_uc_all_hash_table {
6522 cmdline_fixed_string_t set;
6523 cmdline_fixed_string_t port;
6525 cmdline_fixed_string_t what;
6526 cmdline_fixed_string_t value;
6527 cmdline_fixed_string_t mode;
6531 cmd_set_uc_all_hash_parsed(void *parsed_result,
6532 __attribute__((unused)) struct cmdline *cl,
6533 __attribute__((unused)) void *data)
6536 struct cmd_set_uc_all_hash_table *res = parsed_result;
6538 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6540 if ((strcmp(res->what, "uta") == 0) &&
6541 (strcmp(res->value, "all") == 0))
6542 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6544 printf("bad unicast hash table parameter,"
6545 "return code = %d \n", ret);
6548 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6549 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6551 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6552 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6554 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6555 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6557 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6558 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6560 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6561 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6563 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6564 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6567 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6568 .f = cmd_set_uc_all_hash_parsed,
6570 .help_str = "set port <port_id> uta all on|off",
6572 (void *)&cmd_set_uc_all_hash_set,
6573 (void *)&cmd_set_uc_all_hash_port,
6574 (void *)&cmd_set_uc_all_hash_portid,
6575 (void *)&cmd_set_uc_all_hash_what,
6576 (void *)&cmd_set_uc_all_hash_value,
6577 (void *)&cmd_set_uc_all_hash_mode,
6582 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6583 struct cmd_set_vf_macvlan_filter {
6584 cmdline_fixed_string_t set;
6585 cmdline_fixed_string_t port;
6587 cmdline_fixed_string_t vf;
6589 struct ether_addr address;
6590 cmdline_fixed_string_t filter_type;
6591 cmdline_fixed_string_t mode;
6595 cmd_set_vf_macvlan_parsed(void *parsed_result,
6596 __attribute__((unused)) struct cmdline *cl,
6597 __attribute__((unused)) void *data)
6600 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6601 struct rte_eth_mac_filter filter;
6603 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6605 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6607 /* set VF MAC filter */
6611 filter.dst_id = res->vf_id;
6613 if (!strcmp(res->filter_type, "exact-mac"))
6614 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6615 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6616 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6617 else if (!strcmp(res->filter_type, "hashmac"))
6618 filter.filter_type = RTE_MAC_HASH_MATCH;
6619 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6620 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6622 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6625 ret = rte_eth_dev_filter_ctrl(res->port_id,
6626 RTE_ETH_FILTER_MACVLAN,
6630 ret = rte_eth_dev_filter_ctrl(res->port_id,
6631 RTE_ETH_FILTER_MACVLAN,
6632 RTE_ETH_FILTER_DELETE,
6636 printf("bad set MAC hash parameter, return code = %d\n", ret);
6640 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6641 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6643 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6644 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6646 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6647 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6649 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6650 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6652 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6653 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6655 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6656 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6658 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6659 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6660 filter_type, "exact-mac#exact-mac-vlan"
6661 "#hashmac#hashmac-vlan");
6662 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6663 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6666 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6667 .f = cmd_set_vf_macvlan_parsed,
6669 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6670 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6671 "Exact match rule: exact match of MAC or MAC and VLAN; "
6672 "hash match rule: hash match of MAC and exact match of VLAN",
6674 (void *)&cmd_set_vf_macvlan_set,
6675 (void *)&cmd_set_vf_macvlan_port,
6676 (void *)&cmd_set_vf_macvlan_portid,
6677 (void *)&cmd_set_vf_macvlan_vf,
6678 (void *)&cmd_set_vf_macvlan_vf_id,
6679 (void *)&cmd_set_vf_macvlan_mac,
6680 (void *)&cmd_set_vf_macvlan_filter_type,
6681 (void *)&cmd_set_vf_macvlan_mode,
6686 #ifdef RTE_LIBRTE_IXGBE_PMD
6687 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6688 struct cmd_set_vf_traffic {
6689 cmdline_fixed_string_t set;
6690 cmdline_fixed_string_t port;
6692 cmdline_fixed_string_t vf;
6694 cmdline_fixed_string_t what;
6695 cmdline_fixed_string_t mode;
6699 cmd_set_vf_traffic_parsed(void *parsed_result,
6700 __attribute__((unused)) struct cmdline *cl,
6701 __attribute__((unused)) void *data)
6703 struct cmd_set_vf_traffic *res = parsed_result;
6704 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6705 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6707 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6710 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6711 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6713 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6714 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6716 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6717 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6719 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6720 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6722 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6723 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6725 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6726 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6728 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6729 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6732 cmdline_parse_inst_t cmd_set_vf_traffic = {
6733 .f = cmd_set_vf_traffic_parsed,
6735 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6737 (void *)&cmd_setvf_traffic_set,
6738 (void *)&cmd_setvf_traffic_port,
6739 (void *)&cmd_setvf_traffic_portid,
6740 (void *)&cmd_setvf_traffic_vf,
6741 (void *)&cmd_setvf_traffic_vfid,
6742 (void *)&cmd_setvf_traffic_what,
6743 (void *)&cmd_setvf_traffic_mode,
6748 /* *** CONFIGURE VF RECEIVE MODE *** */
6749 struct cmd_set_vf_rxmode {
6750 cmdline_fixed_string_t set;
6751 cmdline_fixed_string_t port;
6753 cmdline_fixed_string_t vf;
6755 cmdline_fixed_string_t what;
6756 cmdline_fixed_string_t mode;
6757 cmdline_fixed_string_t on;
6761 cmd_set_vf_rxmode_parsed(void *parsed_result,
6762 __attribute__((unused)) struct cmdline *cl,
6763 __attribute__((unused)) void *data)
6766 uint16_t rx_mode = 0;
6767 struct cmd_set_vf_rxmode *res = parsed_result;
6769 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6770 if (!strcmp(res->what,"rxmode")) {
6771 if (!strcmp(res->mode, "AUPE"))
6772 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6773 else if (!strcmp(res->mode, "ROPE"))
6774 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6775 else if (!strcmp(res->mode, "BAM"))
6776 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6777 else if (!strncmp(res->mode, "MPE",3))
6778 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6781 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6783 printf("bad VF receive mode parameter, return code = %d \n",
6787 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6788 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6790 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6791 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6793 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6794 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6796 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6797 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6799 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6800 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6802 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6803 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6805 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6806 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6807 mode, "AUPE#ROPE#BAM#MPE");
6808 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6809 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6812 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6813 .f = cmd_set_vf_rxmode_parsed,
6815 .help_str = "set port <port_id> vf <vf_id> rxmode "
6816 "AUPE|ROPE|BAM|MPE on|off",
6818 (void *)&cmd_set_vf_rxmode_set,
6819 (void *)&cmd_set_vf_rxmode_port,
6820 (void *)&cmd_set_vf_rxmode_portid,
6821 (void *)&cmd_set_vf_rxmode_vf,
6822 (void *)&cmd_set_vf_rxmode_vfid,
6823 (void *)&cmd_set_vf_rxmode_what,
6824 (void *)&cmd_set_vf_rxmode_mode,
6825 (void *)&cmd_set_vf_rxmode_on,
6831 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6832 struct cmd_vf_mac_addr_result {
6833 cmdline_fixed_string_t mac_addr_cmd;
6834 cmdline_fixed_string_t what;
6835 cmdline_fixed_string_t port;
6837 cmdline_fixed_string_t vf;
6839 struct ether_addr address;
6842 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6843 __attribute__((unused)) struct cmdline *cl,
6844 __attribute__((unused)) void *data)
6846 struct cmd_vf_mac_addr_result *res = parsed_result;
6849 if (strcmp(res->what, "add") == 0)
6850 ret = rte_eth_dev_mac_addr_add(res->port_num,
6851 &res->address, res->vf_num);
6853 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6857 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6858 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6859 mac_addr_cmd,"mac_addr");
6860 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6861 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6863 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6864 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6866 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6867 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6869 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6870 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6872 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6873 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6875 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6876 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6879 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6880 .f = cmd_vf_mac_addr_parsed,
6882 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6883 "Add MAC address filtering for a VF on port_id",
6885 (void *)&cmd_vf_mac_addr_cmd,
6886 (void *)&cmd_vf_mac_addr_what,
6887 (void *)&cmd_vf_mac_addr_port,
6888 (void *)&cmd_vf_mac_addr_portnum,
6889 (void *)&cmd_vf_mac_addr_vf,
6890 (void *)&cmd_vf_mac_addr_vfnum,
6891 (void *)&cmd_vf_mac_addr_addr,
6896 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6897 struct cmd_vf_rx_vlan_filter {
6898 cmdline_fixed_string_t rx_vlan;
6899 cmdline_fixed_string_t what;
6901 cmdline_fixed_string_t port;
6903 cmdline_fixed_string_t vf;
6908 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6909 __attribute__((unused)) struct cmdline *cl,
6910 __attribute__((unused)) void *data)
6912 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6915 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6917 #ifdef RTE_LIBRTE_IXGBE_PMD
6918 if (ret == -ENOTSUP)
6919 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6920 res->vlan_id, res->vf_mask, is_add);
6922 #ifdef RTE_LIBRTE_I40E_PMD
6923 if (ret == -ENOTSUP)
6924 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6925 res->vlan_id, res->vf_mask, is_add);
6932 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
6933 res->vlan_id, res->vf_mask);
6936 printf("invalid port_id %d\n", res->port_id);
6939 printf("function not implemented or supported\n");
6942 printf("programming error: (%s)\n", strerror(-ret));
6946 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6947 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6948 rx_vlan, "rx_vlan");
6949 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6950 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6952 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6953 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6955 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6956 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6958 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6959 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6961 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6962 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6964 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6965 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6968 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6969 .f = cmd_vf_rx_vlan_filter_parsed,
6971 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6972 "(vf_mask = hexadecimal VF mask)",
6974 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6975 (void *)&cmd_vf_rx_vlan_filter_what,
6976 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6977 (void *)&cmd_vf_rx_vlan_filter_port,
6978 (void *)&cmd_vf_rx_vlan_filter_portid,
6979 (void *)&cmd_vf_rx_vlan_filter_vf,
6980 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6985 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6986 struct cmd_queue_rate_limit_result {
6987 cmdline_fixed_string_t set;
6988 cmdline_fixed_string_t port;
6990 cmdline_fixed_string_t queue;
6992 cmdline_fixed_string_t rate;
6996 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6997 __attribute__((unused)) struct cmdline *cl,
6998 __attribute__((unused)) void *data)
7000 struct cmd_queue_rate_limit_result *res = parsed_result;
7003 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7004 && (strcmp(res->queue, "queue") == 0)
7005 && (strcmp(res->rate, "rate") == 0))
7006 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7009 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7013 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7014 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7016 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7017 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7019 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7020 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7022 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7023 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7025 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7026 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7028 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7029 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7031 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7032 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7035 cmdline_parse_inst_t cmd_queue_rate_limit = {
7036 .f = cmd_queue_rate_limit_parsed,
7038 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7039 "Set rate limit for a queue on port_id",
7041 (void *)&cmd_queue_rate_limit_set,
7042 (void *)&cmd_queue_rate_limit_port,
7043 (void *)&cmd_queue_rate_limit_portnum,
7044 (void *)&cmd_queue_rate_limit_queue,
7045 (void *)&cmd_queue_rate_limit_queuenum,
7046 (void *)&cmd_queue_rate_limit_rate,
7047 (void *)&cmd_queue_rate_limit_ratenum,
7052 #ifdef RTE_LIBRTE_IXGBE_PMD
7053 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7054 struct cmd_vf_rate_limit_result {
7055 cmdline_fixed_string_t set;
7056 cmdline_fixed_string_t port;
7058 cmdline_fixed_string_t vf;
7060 cmdline_fixed_string_t rate;
7062 cmdline_fixed_string_t q_msk;
7066 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7067 __attribute__((unused)) struct cmdline *cl,
7068 __attribute__((unused)) void *data)
7070 struct cmd_vf_rate_limit_result *res = parsed_result;
7073 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7074 && (strcmp(res->vf, "vf") == 0)
7075 && (strcmp(res->rate, "rate") == 0)
7076 && (strcmp(res->q_msk, "queue_mask") == 0))
7077 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7078 res->rate_num, res->q_msk_val);
7080 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7084 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7085 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7087 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7088 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7090 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7091 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7093 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7094 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7096 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7097 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7099 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7100 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7102 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7103 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7105 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7106 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7107 q_msk, "queue_mask");
7108 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7109 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7112 cmdline_parse_inst_t cmd_vf_rate_limit = {
7113 .f = cmd_vf_rate_limit_parsed,
7115 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7116 "queue_mask <queue_mask_value>: "
7117 "Set rate limit for queues of VF on port_id",
7119 (void *)&cmd_vf_rate_limit_set,
7120 (void *)&cmd_vf_rate_limit_port,
7121 (void *)&cmd_vf_rate_limit_portnum,
7122 (void *)&cmd_vf_rate_limit_vf,
7123 (void *)&cmd_vf_rate_limit_vfnum,
7124 (void *)&cmd_vf_rate_limit_rate,
7125 (void *)&cmd_vf_rate_limit_ratenum,
7126 (void *)&cmd_vf_rate_limit_q_msk,
7127 (void *)&cmd_vf_rate_limit_q_msk_val,
7133 /* *** ADD TUNNEL FILTER OF A PORT *** */
7134 struct cmd_tunnel_filter_result {
7135 cmdline_fixed_string_t cmd;
7136 cmdline_fixed_string_t what;
7138 struct ether_addr outer_mac;
7139 struct ether_addr inner_mac;
7140 cmdline_ipaddr_t ip_value;
7141 uint16_t inner_vlan;
7142 cmdline_fixed_string_t tunnel_type;
7143 cmdline_fixed_string_t filter_type;
7149 cmd_tunnel_filter_parsed(void *parsed_result,
7150 __attribute__((unused)) struct cmdline *cl,
7151 __attribute__((unused)) void *data)
7153 struct cmd_tunnel_filter_result *res = parsed_result;
7154 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7157 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7159 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7160 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7161 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7163 if (res->ip_value.family == AF_INET) {
7164 tunnel_filter_conf.ip_addr.ipv4_addr =
7165 res->ip_value.addr.ipv4.s_addr;
7166 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7168 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7169 &(res->ip_value.addr.ipv6),
7170 sizeof(struct in6_addr));
7171 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7174 if (!strcmp(res->filter_type, "imac-ivlan"))
7175 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7176 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7177 tunnel_filter_conf.filter_type =
7178 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7179 else if (!strcmp(res->filter_type, "imac-tenid"))
7180 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7181 else if (!strcmp(res->filter_type, "imac"))
7182 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7183 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7184 tunnel_filter_conf.filter_type =
7185 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7186 else if (!strcmp(res->filter_type, "oip"))
7187 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7188 else if (!strcmp(res->filter_type, "iip"))
7189 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7191 printf("The filter type is not supported");
7195 if (!strcmp(res->tunnel_type, "vxlan"))
7196 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7197 else if (!strcmp(res->tunnel_type, "nvgre"))
7198 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7199 else if (!strcmp(res->tunnel_type, "ipingre"))
7200 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7202 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7206 tunnel_filter_conf.tenant_id = res->tenant_id;
7207 tunnel_filter_conf.queue_id = res->queue_num;
7208 if (!strcmp(res->what, "add"))
7209 ret = rte_eth_dev_filter_ctrl(res->port_id,
7210 RTE_ETH_FILTER_TUNNEL,
7212 &tunnel_filter_conf);
7214 ret = rte_eth_dev_filter_ctrl(res->port_id,
7215 RTE_ETH_FILTER_TUNNEL,
7216 RTE_ETH_FILTER_DELETE,
7217 &tunnel_filter_conf);
7219 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7223 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7224 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7225 cmd, "tunnel_filter");
7226 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7227 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7229 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7230 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7232 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7233 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7235 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7236 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7238 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7239 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7240 inner_vlan, UINT16);
7241 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7242 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7244 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7245 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7246 tunnel_type, "vxlan#nvgre#ipingre");
7248 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7249 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7250 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7251 "imac#omac-imac-tenid");
7252 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7253 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7255 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7256 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7259 cmdline_parse_inst_t cmd_tunnel_filter = {
7260 .f = cmd_tunnel_filter_parsed,
7262 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7263 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7264 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7265 "<queue_id>: Add/Rm tunnel filter of a port",
7267 (void *)&cmd_tunnel_filter_cmd,
7268 (void *)&cmd_tunnel_filter_what,
7269 (void *)&cmd_tunnel_filter_port_id,
7270 (void *)&cmd_tunnel_filter_outer_mac,
7271 (void *)&cmd_tunnel_filter_inner_mac,
7272 (void *)&cmd_tunnel_filter_ip_value,
7273 (void *)&cmd_tunnel_filter_innner_vlan,
7274 (void *)&cmd_tunnel_filter_tunnel_type,
7275 (void *)&cmd_tunnel_filter_filter_type,
7276 (void *)&cmd_tunnel_filter_tenant_id,
7277 (void *)&cmd_tunnel_filter_queue_num,
7282 /* *** CONFIGURE TUNNEL UDP PORT *** */
7283 struct cmd_tunnel_udp_config {
7284 cmdline_fixed_string_t cmd;
7285 cmdline_fixed_string_t what;
7291 cmd_tunnel_udp_config_parsed(void *parsed_result,
7292 __attribute__((unused)) struct cmdline *cl,
7293 __attribute__((unused)) void *data)
7295 struct cmd_tunnel_udp_config *res = parsed_result;
7296 struct rte_eth_udp_tunnel tunnel_udp;
7299 tunnel_udp.udp_port = res->udp_port;
7301 if (!strcmp(res->cmd, "rx_vxlan_port"))
7302 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7304 if (!strcmp(res->what, "add"))
7305 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7308 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7312 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7315 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7316 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7317 cmd, "rx_vxlan_port");
7318 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7319 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7321 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7322 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7324 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7325 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7328 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7329 .f = cmd_tunnel_udp_config_parsed,
7331 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7332 "Add/Remove a tunneling UDP port filter",
7334 (void *)&cmd_tunnel_udp_config_cmd,
7335 (void *)&cmd_tunnel_udp_config_what,
7336 (void *)&cmd_tunnel_udp_config_udp_port,
7337 (void *)&cmd_tunnel_udp_config_port_id,
7342 /* *** GLOBAL CONFIG *** */
7343 struct cmd_global_config_result {
7344 cmdline_fixed_string_t cmd;
7346 cmdline_fixed_string_t cfg_type;
7351 cmd_global_config_parsed(void *parsed_result,
7352 __attribute__((unused)) struct cmdline *cl,
7353 __attribute__((unused)) void *data)
7355 struct cmd_global_config_result *res = parsed_result;
7356 struct rte_eth_global_cfg conf;
7359 memset(&conf, 0, sizeof(conf));
7360 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7361 conf.cfg.gre_key_len = res->len;
7362 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7363 RTE_ETH_FILTER_SET, &conf);
7365 printf("Global config error\n");
7368 cmdline_parse_token_string_t cmd_global_config_cmd =
7369 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7371 cmdline_parse_token_num_t cmd_global_config_port_id =
7372 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7373 cmdline_parse_token_string_t cmd_global_config_type =
7374 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7375 cfg_type, "gre-key-len");
7376 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7377 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7380 cmdline_parse_inst_t cmd_global_config = {
7381 .f = cmd_global_config_parsed,
7382 .data = (void *)NULL,
7383 .help_str = "global_config <port_id> gre-key-len <key_len>",
7385 (void *)&cmd_global_config_cmd,
7386 (void *)&cmd_global_config_port_id,
7387 (void *)&cmd_global_config_type,
7388 (void *)&cmd_global_config_gre_key_len,
7393 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7394 struct cmd_set_mirror_mask_result {
7395 cmdline_fixed_string_t set;
7396 cmdline_fixed_string_t port;
7398 cmdline_fixed_string_t mirror;
7400 cmdline_fixed_string_t what;
7401 cmdline_fixed_string_t value;
7402 cmdline_fixed_string_t dstpool;
7404 cmdline_fixed_string_t on;
7407 cmdline_parse_token_string_t cmd_mirror_mask_set =
7408 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7410 cmdline_parse_token_string_t cmd_mirror_mask_port =
7411 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7413 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7414 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7416 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7417 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7418 mirror, "mirror-rule");
7419 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7420 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7422 cmdline_parse_token_string_t cmd_mirror_mask_what =
7423 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7424 what, "pool-mirror-up#pool-mirror-down"
7426 cmdline_parse_token_string_t cmd_mirror_mask_value =
7427 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7429 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7430 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7431 dstpool, "dst-pool");
7432 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7433 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7435 cmdline_parse_token_string_t cmd_mirror_mask_on =
7436 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7440 cmd_set_mirror_mask_parsed(void *parsed_result,
7441 __attribute__((unused)) struct cmdline *cl,
7442 __attribute__((unused)) void *data)
7445 struct cmd_set_mirror_mask_result *res = parsed_result;
7446 struct rte_eth_mirror_conf mr_conf;
7448 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7450 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7452 mr_conf.dst_pool = res->dstpool_id;
7454 if (!strcmp(res->what, "pool-mirror-up")) {
7455 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7456 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7457 } else if (!strcmp(res->what, "pool-mirror-down")) {
7458 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7459 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7460 } else if (!strcmp(res->what, "vlan-mirror")) {
7461 mr_conf.rule_type = ETH_MIRROR_VLAN;
7462 nb_item = parse_item_list(res->value, "vlan",
7463 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7467 for (i = 0; i < nb_item; i++) {
7468 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7469 printf("Invalid vlan_id: must be < 4096\n");
7473 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7474 mr_conf.vlan.vlan_mask |= 1ULL << i;
7478 if (!strcmp(res->on, "on"))
7479 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7482 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7485 printf("mirror rule add error: (%s)\n", strerror(-ret));
7488 cmdline_parse_inst_t cmd_set_mirror_mask = {
7489 .f = cmd_set_mirror_mask_parsed,
7491 .help_str = "set port <port_id> mirror-rule <rule_id> "
7492 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7493 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7495 (void *)&cmd_mirror_mask_set,
7496 (void *)&cmd_mirror_mask_port,
7497 (void *)&cmd_mirror_mask_portid,
7498 (void *)&cmd_mirror_mask_mirror,
7499 (void *)&cmd_mirror_mask_ruleid,
7500 (void *)&cmd_mirror_mask_what,
7501 (void *)&cmd_mirror_mask_value,
7502 (void *)&cmd_mirror_mask_dstpool,
7503 (void *)&cmd_mirror_mask_poolid,
7504 (void *)&cmd_mirror_mask_on,
7509 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7510 struct cmd_set_mirror_link_result {
7511 cmdline_fixed_string_t set;
7512 cmdline_fixed_string_t port;
7514 cmdline_fixed_string_t mirror;
7516 cmdline_fixed_string_t what;
7517 cmdline_fixed_string_t dstpool;
7519 cmdline_fixed_string_t on;
7522 cmdline_parse_token_string_t cmd_mirror_link_set =
7523 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7525 cmdline_parse_token_string_t cmd_mirror_link_port =
7526 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7528 cmdline_parse_token_num_t cmd_mirror_link_portid =
7529 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7531 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7532 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7533 mirror, "mirror-rule");
7534 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7535 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7537 cmdline_parse_token_string_t cmd_mirror_link_what =
7538 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7539 what, "uplink-mirror#downlink-mirror");
7540 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7541 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7542 dstpool, "dst-pool");
7543 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7544 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7546 cmdline_parse_token_string_t cmd_mirror_link_on =
7547 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7551 cmd_set_mirror_link_parsed(void *parsed_result,
7552 __attribute__((unused)) struct cmdline *cl,
7553 __attribute__((unused)) void *data)
7556 struct cmd_set_mirror_link_result *res = parsed_result;
7557 struct rte_eth_mirror_conf mr_conf;
7559 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7560 if (!strcmp(res->what, "uplink-mirror"))
7561 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7563 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7565 mr_conf.dst_pool = res->dstpool_id;
7567 if (!strcmp(res->on, "on"))
7568 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7571 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7574 /* check the return value and print it if is < 0 */
7576 printf("mirror rule add error: (%s)\n", strerror(-ret));
7580 cmdline_parse_inst_t cmd_set_mirror_link = {
7581 .f = cmd_set_mirror_link_parsed,
7583 .help_str = "set port <port_id> mirror-rule <rule_id> "
7584 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7586 (void *)&cmd_mirror_link_set,
7587 (void *)&cmd_mirror_link_port,
7588 (void *)&cmd_mirror_link_portid,
7589 (void *)&cmd_mirror_link_mirror,
7590 (void *)&cmd_mirror_link_ruleid,
7591 (void *)&cmd_mirror_link_what,
7592 (void *)&cmd_mirror_link_dstpool,
7593 (void *)&cmd_mirror_link_poolid,
7594 (void *)&cmd_mirror_link_on,
7599 /* *** RESET VM MIRROR RULE *** */
7600 struct cmd_rm_mirror_rule_result {
7601 cmdline_fixed_string_t reset;
7602 cmdline_fixed_string_t port;
7604 cmdline_fixed_string_t mirror;
7608 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7609 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7611 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7612 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7614 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7615 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7617 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7618 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7619 mirror, "mirror-rule");
7620 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7621 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7625 cmd_reset_mirror_rule_parsed(void *parsed_result,
7626 __attribute__((unused)) struct cmdline *cl,
7627 __attribute__((unused)) void *data)
7630 struct cmd_set_mirror_link_result *res = parsed_result;
7632 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7634 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7637 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7638 .f = cmd_reset_mirror_rule_parsed,
7640 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7642 (void *)&cmd_rm_mirror_rule_reset,
7643 (void *)&cmd_rm_mirror_rule_port,
7644 (void *)&cmd_rm_mirror_rule_portid,
7645 (void *)&cmd_rm_mirror_rule_mirror,
7646 (void *)&cmd_rm_mirror_rule_ruleid,
7651 /* ******************************************************************************** */
7653 struct cmd_dump_result {
7654 cmdline_fixed_string_t dump;
7658 dump_struct_sizes(void)
7660 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7661 DUMP_SIZE(struct rte_mbuf);
7662 DUMP_SIZE(struct rte_mempool);
7663 DUMP_SIZE(struct rte_ring);
7667 static void cmd_dump_parsed(void *parsed_result,
7668 __attribute__((unused)) struct cmdline *cl,
7669 __attribute__((unused)) void *data)
7671 struct cmd_dump_result *res = parsed_result;
7673 if (!strcmp(res->dump, "dump_physmem"))
7674 rte_dump_physmem_layout(stdout);
7675 else if (!strcmp(res->dump, "dump_memzone"))
7676 rte_memzone_dump(stdout);
7677 else if (!strcmp(res->dump, "dump_struct_sizes"))
7678 dump_struct_sizes();
7679 else if (!strcmp(res->dump, "dump_ring"))
7680 rte_ring_list_dump(stdout);
7681 else if (!strcmp(res->dump, "dump_mempool"))
7682 rte_mempool_list_dump(stdout);
7683 else if (!strcmp(res->dump, "dump_devargs"))
7684 rte_eal_devargs_dump(stdout);
7687 cmdline_parse_token_string_t cmd_dump_dump =
7688 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7691 "dump_struct_sizes#"
7696 cmdline_parse_inst_t cmd_dump = {
7697 .f = cmd_dump_parsed, /* function to call */
7698 .data = NULL, /* 2nd arg of func */
7699 .help_str = "Dump status",
7700 .tokens = { /* token list, NULL terminated */
7701 (void *)&cmd_dump_dump,
7706 /* ******************************************************************************** */
7708 struct cmd_dump_one_result {
7709 cmdline_fixed_string_t dump;
7710 cmdline_fixed_string_t name;
7713 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7714 __attribute__((unused)) void *data)
7716 struct cmd_dump_one_result *res = parsed_result;
7718 if (!strcmp(res->dump, "dump_ring")) {
7720 r = rte_ring_lookup(res->name);
7722 cmdline_printf(cl, "Cannot find ring\n");
7725 rte_ring_dump(stdout, r);
7726 } else if (!strcmp(res->dump, "dump_mempool")) {
7727 struct rte_mempool *mp;
7728 mp = rte_mempool_lookup(res->name);
7730 cmdline_printf(cl, "Cannot find mempool\n");
7733 rte_mempool_dump(stdout, mp);
7737 cmdline_parse_token_string_t cmd_dump_one_dump =
7738 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7739 "dump_ring#dump_mempool");
7741 cmdline_parse_token_string_t cmd_dump_one_name =
7742 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7744 cmdline_parse_inst_t cmd_dump_one = {
7745 .f = cmd_dump_one_parsed, /* function to call */
7746 .data = NULL, /* 2nd arg of func */
7747 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7748 .tokens = { /* token list, NULL terminated */
7749 (void *)&cmd_dump_one_dump,
7750 (void *)&cmd_dump_one_name,
7755 /* *** Add/Del syn filter *** */
7756 struct cmd_syn_filter_result {
7757 cmdline_fixed_string_t filter;
7759 cmdline_fixed_string_t ops;
7760 cmdline_fixed_string_t priority;
7761 cmdline_fixed_string_t high;
7762 cmdline_fixed_string_t queue;
7767 cmd_syn_filter_parsed(void *parsed_result,
7768 __attribute__((unused)) struct cmdline *cl,
7769 __attribute__((unused)) void *data)
7771 struct cmd_syn_filter_result *res = parsed_result;
7772 struct rte_eth_syn_filter syn_filter;
7775 ret = rte_eth_dev_filter_supported(res->port_id,
7776 RTE_ETH_FILTER_SYN);
7778 printf("syn filter is not supported on port %u.\n",
7783 memset(&syn_filter, 0, sizeof(syn_filter));
7785 if (!strcmp(res->ops, "add")) {
7786 if (!strcmp(res->high, "high"))
7787 syn_filter.hig_pri = 1;
7789 syn_filter.hig_pri = 0;
7791 syn_filter.queue = res->queue_id;
7792 ret = rte_eth_dev_filter_ctrl(res->port_id,
7797 ret = rte_eth_dev_filter_ctrl(res->port_id,
7799 RTE_ETH_FILTER_DELETE,
7803 printf("syn filter programming error: (%s)\n",
7807 cmdline_parse_token_string_t cmd_syn_filter_filter =
7808 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7809 filter, "syn_filter");
7810 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7811 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7813 cmdline_parse_token_string_t cmd_syn_filter_ops =
7814 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7816 cmdline_parse_token_string_t cmd_syn_filter_priority =
7817 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7818 priority, "priority");
7819 cmdline_parse_token_string_t cmd_syn_filter_high =
7820 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7822 cmdline_parse_token_string_t cmd_syn_filter_queue =
7823 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7825 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7826 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7829 cmdline_parse_inst_t cmd_syn_filter = {
7830 .f = cmd_syn_filter_parsed,
7832 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7833 "<queue_id>: Add/Delete syn filter",
7835 (void *)&cmd_syn_filter_filter,
7836 (void *)&cmd_syn_filter_port_id,
7837 (void *)&cmd_syn_filter_ops,
7838 (void *)&cmd_syn_filter_priority,
7839 (void *)&cmd_syn_filter_high,
7840 (void *)&cmd_syn_filter_queue,
7841 (void *)&cmd_syn_filter_queue_id,
7846 /* *** ADD/REMOVE A 2tuple FILTER *** */
7847 struct cmd_2tuple_filter_result {
7848 cmdline_fixed_string_t filter;
7850 cmdline_fixed_string_t ops;
7851 cmdline_fixed_string_t dst_port;
7852 uint16_t dst_port_value;
7853 cmdline_fixed_string_t protocol;
7854 uint8_t protocol_value;
7855 cmdline_fixed_string_t mask;
7857 cmdline_fixed_string_t tcp_flags;
7858 uint8_t tcp_flags_value;
7859 cmdline_fixed_string_t priority;
7860 uint8_t priority_value;
7861 cmdline_fixed_string_t queue;
7866 cmd_2tuple_filter_parsed(void *parsed_result,
7867 __attribute__((unused)) struct cmdline *cl,
7868 __attribute__((unused)) void *data)
7870 struct rte_eth_ntuple_filter filter;
7871 struct cmd_2tuple_filter_result *res = parsed_result;
7874 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7876 printf("ntuple filter is not supported on port %u.\n",
7881 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7883 filter.flags = RTE_2TUPLE_FLAGS;
7884 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7885 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7886 filter.proto = res->protocol_value;
7887 filter.priority = res->priority_value;
7888 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7889 printf("nonzero tcp_flags is only meaningful"
7890 " when protocol is TCP.\n");
7893 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7894 printf("invalid TCP flags.\n");
7898 if (res->tcp_flags_value != 0) {
7899 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7900 filter.tcp_flags = res->tcp_flags_value;
7903 /* need convert to big endian. */
7904 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7905 filter.queue = res->queue_id;
7907 if (!strcmp(res->ops, "add"))
7908 ret = rte_eth_dev_filter_ctrl(res->port_id,
7909 RTE_ETH_FILTER_NTUPLE,
7913 ret = rte_eth_dev_filter_ctrl(res->port_id,
7914 RTE_ETH_FILTER_NTUPLE,
7915 RTE_ETH_FILTER_DELETE,
7918 printf("2tuple filter programming error: (%s)\n",
7923 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7924 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7925 filter, "2tuple_filter");
7926 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7927 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7929 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7930 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7932 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7933 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7934 dst_port, "dst_port");
7935 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7936 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7937 dst_port_value, UINT16);
7938 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7939 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7940 protocol, "protocol");
7941 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7942 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7943 protocol_value, UINT8);
7944 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7945 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7947 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7948 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7950 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7951 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7952 tcp_flags, "tcp_flags");
7953 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7954 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7955 tcp_flags_value, UINT8);
7956 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7957 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7958 priority, "priority");
7959 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7960 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7961 priority_value, UINT8);
7962 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7963 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7965 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7966 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7969 cmdline_parse_inst_t cmd_2tuple_filter = {
7970 .f = cmd_2tuple_filter_parsed,
7972 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7973 "<value> mask <value> tcp_flags <value> priority <value> queue "
7974 "<queue_id>: Add a 2tuple filter",
7976 (void *)&cmd_2tuple_filter_filter,
7977 (void *)&cmd_2tuple_filter_port_id,
7978 (void *)&cmd_2tuple_filter_ops,
7979 (void *)&cmd_2tuple_filter_dst_port,
7980 (void *)&cmd_2tuple_filter_dst_port_value,
7981 (void *)&cmd_2tuple_filter_protocol,
7982 (void *)&cmd_2tuple_filter_protocol_value,
7983 (void *)&cmd_2tuple_filter_mask,
7984 (void *)&cmd_2tuple_filter_mask_value,
7985 (void *)&cmd_2tuple_filter_tcp_flags,
7986 (void *)&cmd_2tuple_filter_tcp_flags_value,
7987 (void *)&cmd_2tuple_filter_priority,
7988 (void *)&cmd_2tuple_filter_priority_value,
7989 (void *)&cmd_2tuple_filter_queue,
7990 (void *)&cmd_2tuple_filter_queue_id,
7995 /* *** ADD/REMOVE A 5tuple FILTER *** */
7996 struct cmd_5tuple_filter_result {
7997 cmdline_fixed_string_t filter;
7999 cmdline_fixed_string_t ops;
8000 cmdline_fixed_string_t dst_ip;
8001 cmdline_ipaddr_t dst_ip_value;
8002 cmdline_fixed_string_t src_ip;
8003 cmdline_ipaddr_t src_ip_value;
8004 cmdline_fixed_string_t dst_port;
8005 uint16_t dst_port_value;
8006 cmdline_fixed_string_t src_port;
8007 uint16_t src_port_value;
8008 cmdline_fixed_string_t protocol;
8009 uint8_t protocol_value;
8010 cmdline_fixed_string_t mask;
8012 cmdline_fixed_string_t tcp_flags;
8013 uint8_t tcp_flags_value;
8014 cmdline_fixed_string_t priority;
8015 uint8_t priority_value;
8016 cmdline_fixed_string_t queue;
8021 cmd_5tuple_filter_parsed(void *parsed_result,
8022 __attribute__((unused)) struct cmdline *cl,
8023 __attribute__((unused)) void *data)
8025 struct rte_eth_ntuple_filter filter;
8026 struct cmd_5tuple_filter_result *res = parsed_result;
8029 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8031 printf("ntuple filter is not supported on port %u.\n",
8036 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8038 filter.flags = RTE_5TUPLE_FLAGS;
8039 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8040 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8041 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8042 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8043 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8044 filter.proto = res->protocol_value;
8045 filter.priority = res->priority_value;
8046 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8047 printf("nonzero tcp_flags is only meaningful"
8048 " when protocol is TCP.\n");
8051 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8052 printf("invalid TCP flags.\n");
8056 if (res->tcp_flags_value != 0) {
8057 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8058 filter.tcp_flags = res->tcp_flags_value;
8061 if (res->dst_ip_value.family == AF_INET)
8062 /* no need to convert, already big endian. */
8063 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8065 if (filter.dst_ip_mask == 0) {
8066 printf("can not support ipv6 involved compare.\n");
8072 if (res->src_ip_value.family == AF_INET)
8073 /* no need to convert, already big endian. */
8074 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8076 if (filter.src_ip_mask == 0) {
8077 printf("can not support ipv6 involved compare.\n");
8082 /* need convert to big endian. */
8083 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8084 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8085 filter.queue = res->queue_id;
8087 if (!strcmp(res->ops, "add"))
8088 ret = rte_eth_dev_filter_ctrl(res->port_id,
8089 RTE_ETH_FILTER_NTUPLE,
8093 ret = rte_eth_dev_filter_ctrl(res->port_id,
8094 RTE_ETH_FILTER_NTUPLE,
8095 RTE_ETH_FILTER_DELETE,
8098 printf("5tuple filter programming error: (%s)\n",
8102 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8103 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8104 filter, "5tuple_filter");
8105 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8106 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8108 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8109 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8111 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8112 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8114 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8115 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8117 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8118 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8120 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8121 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8123 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8124 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8125 dst_port, "dst_port");
8126 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8127 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8128 dst_port_value, UINT16);
8129 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8130 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8131 src_port, "src_port");
8132 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8133 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8134 src_port_value, UINT16);
8135 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8136 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8137 protocol, "protocol");
8138 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8139 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8140 protocol_value, UINT8);
8141 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8142 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8144 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8145 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8147 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8148 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8149 tcp_flags, "tcp_flags");
8150 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8151 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8152 tcp_flags_value, UINT8);
8153 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8154 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8155 priority, "priority");
8156 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8157 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8158 priority_value, UINT8);
8159 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8160 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8162 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8163 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8166 cmdline_parse_inst_t cmd_5tuple_filter = {
8167 .f = cmd_5tuple_filter_parsed,
8169 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8170 "src_ip <value> dst_port <value> src_port <value> "
8171 "protocol <value> mask <value> tcp_flags <value> "
8172 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8174 (void *)&cmd_5tuple_filter_filter,
8175 (void *)&cmd_5tuple_filter_port_id,
8176 (void *)&cmd_5tuple_filter_ops,
8177 (void *)&cmd_5tuple_filter_dst_ip,
8178 (void *)&cmd_5tuple_filter_dst_ip_value,
8179 (void *)&cmd_5tuple_filter_src_ip,
8180 (void *)&cmd_5tuple_filter_src_ip_value,
8181 (void *)&cmd_5tuple_filter_dst_port,
8182 (void *)&cmd_5tuple_filter_dst_port_value,
8183 (void *)&cmd_5tuple_filter_src_port,
8184 (void *)&cmd_5tuple_filter_src_port_value,
8185 (void *)&cmd_5tuple_filter_protocol,
8186 (void *)&cmd_5tuple_filter_protocol_value,
8187 (void *)&cmd_5tuple_filter_mask,
8188 (void *)&cmd_5tuple_filter_mask_value,
8189 (void *)&cmd_5tuple_filter_tcp_flags,
8190 (void *)&cmd_5tuple_filter_tcp_flags_value,
8191 (void *)&cmd_5tuple_filter_priority,
8192 (void *)&cmd_5tuple_filter_priority_value,
8193 (void *)&cmd_5tuple_filter_queue,
8194 (void *)&cmd_5tuple_filter_queue_id,
8199 /* *** ADD/REMOVE A flex FILTER *** */
8200 struct cmd_flex_filter_result {
8201 cmdline_fixed_string_t filter;
8202 cmdline_fixed_string_t ops;
8204 cmdline_fixed_string_t len;
8206 cmdline_fixed_string_t bytes;
8207 cmdline_fixed_string_t bytes_value;
8208 cmdline_fixed_string_t mask;
8209 cmdline_fixed_string_t mask_value;
8210 cmdline_fixed_string_t priority;
8211 uint8_t priority_value;
8212 cmdline_fixed_string_t queue;
8216 static int xdigit2val(unsigned char c)
8221 else if (isupper(c))
8229 cmd_flex_filter_parsed(void *parsed_result,
8230 __attribute__((unused)) struct cmdline *cl,
8231 __attribute__((unused)) void *data)
8234 struct rte_eth_flex_filter filter;
8235 struct cmd_flex_filter_result *res = parsed_result;
8236 char *bytes_ptr, *mask_ptr;
8237 uint16_t len, i, j = 0;
8242 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8243 printf("the len exceed the max length 128\n");
8246 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8247 filter.len = res->len_value;
8248 filter.priority = res->priority_value;
8249 filter.queue = res->queue_id;
8250 bytes_ptr = res->bytes_value;
8251 mask_ptr = res->mask_value;
8253 /* translate bytes string to array. */
8254 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8255 (bytes_ptr[1] == 'X')))
8257 len = strnlen(bytes_ptr, res->len_value * 2);
8258 if (len == 0 || (len % 8 != 0)) {
8259 printf("please check len and bytes input\n");
8262 for (i = 0; i < len; i++) {
8264 if (isxdigit(c) == 0) {
8265 /* invalid characters. */
8266 printf("invalid input\n");
8269 val = xdigit2val(c);
8272 filter.bytes[j] = byte;
8273 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8280 /* translate mask string to uint8_t array. */
8281 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8282 (mask_ptr[1] == 'X')))
8284 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8286 printf("invalid input\n");
8291 for (i = 0; i < len; i++) {
8293 if (isxdigit(c) == 0) {
8294 /* invalid characters. */
8295 printf("invalid input\n");
8298 val = xdigit2val(c);
8301 filter.mask[j] = byte;
8302 printf("mask[%d]:%02x ", j, filter.mask[j]);
8310 if (!strcmp(res->ops, "add"))
8311 ret = rte_eth_dev_filter_ctrl(res->port_id,
8312 RTE_ETH_FILTER_FLEXIBLE,
8316 ret = rte_eth_dev_filter_ctrl(res->port_id,
8317 RTE_ETH_FILTER_FLEXIBLE,
8318 RTE_ETH_FILTER_DELETE,
8322 printf("flex filter setting error: (%s)\n", strerror(-ret));
8325 cmdline_parse_token_string_t cmd_flex_filter_filter =
8326 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8327 filter, "flex_filter");
8328 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8329 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8331 cmdline_parse_token_string_t cmd_flex_filter_ops =
8332 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8334 cmdline_parse_token_string_t cmd_flex_filter_len =
8335 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8337 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8338 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8340 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8341 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8343 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8344 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8346 cmdline_parse_token_string_t cmd_flex_filter_mask =
8347 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8349 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8350 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8352 cmdline_parse_token_string_t cmd_flex_filter_priority =
8353 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8354 priority, "priority");
8355 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8356 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8357 priority_value, UINT8);
8358 cmdline_parse_token_string_t cmd_flex_filter_queue =
8359 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8361 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8362 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8364 cmdline_parse_inst_t cmd_flex_filter = {
8365 .f = cmd_flex_filter_parsed,
8367 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8368 "<value> mask <value> priority <value> queue <queue_id>: "
8369 "Add/Del a flex filter",
8371 (void *)&cmd_flex_filter_filter,
8372 (void *)&cmd_flex_filter_port_id,
8373 (void *)&cmd_flex_filter_ops,
8374 (void *)&cmd_flex_filter_len,
8375 (void *)&cmd_flex_filter_len_value,
8376 (void *)&cmd_flex_filter_bytes,
8377 (void *)&cmd_flex_filter_bytes_value,
8378 (void *)&cmd_flex_filter_mask,
8379 (void *)&cmd_flex_filter_mask_value,
8380 (void *)&cmd_flex_filter_priority,
8381 (void *)&cmd_flex_filter_priority_value,
8382 (void *)&cmd_flex_filter_queue,
8383 (void *)&cmd_flex_filter_queue_id,
8388 /* *** Filters Control *** */
8390 /* *** deal with ethertype filter *** */
8391 struct cmd_ethertype_filter_result {
8392 cmdline_fixed_string_t filter;
8394 cmdline_fixed_string_t ops;
8395 cmdline_fixed_string_t mac;
8396 struct ether_addr mac_addr;
8397 cmdline_fixed_string_t ethertype;
8398 uint16_t ethertype_value;
8399 cmdline_fixed_string_t drop;
8400 cmdline_fixed_string_t queue;
8404 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8405 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8406 filter, "ethertype_filter");
8407 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8408 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8410 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8411 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8413 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8414 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8415 mac, "mac_addr#mac_ignr");
8416 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8417 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8419 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8420 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8421 ethertype, "ethertype");
8422 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8423 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8424 ethertype_value, UINT16);
8425 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8426 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8428 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8429 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8431 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8432 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8436 cmd_ethertype_filter_parsed(void *parsed_result,
8437 __attribute__((unused)) struct cmdline *cl,
8438 __attribute__((unused)) void *data)
8440 struct cmd_ethertype_filter_result *res = parsed_result;
8441 struct rte_eth_ethertype_filter filter;
8444 ret = rte_eth_dev_filter_supported(res->port_id,
8445 RTE_ETH_FILTER_ETHERTYPE);
8447 printf("ethertype filter is not supported on port %u.\n",
8452 memset(&filter, 0, sizeof(filter));
8453 if (!strcmp(res->mac, "mac_addr")) {
8454 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8455 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8456 sizeof(struct ether_addr));
8458 if (!strcmp(res->drop, "drop"))
8459 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8460 filter.ether_type = res->ethertype_value;
8461 filter.queue = res->queue_id;
8463 if (!strcmp(res->ops, "add"))
8464 ret = rte_eth_dev_filter_ctrl(res->port_id,
8465 RTE_ETH_FILTER_ETHERTYPE,
8469 ret = rte_eth_dev_filter_ctrl(res->port_id,
8470 RTE_ETH_FILTER_ETHERTYPE,
8471 RTE_ETH_FILTER_DELETE,
8474 printf("ethertype filter programming error: (%s)\n",
8478 cmdline_parse_inst_t cmd_ethertype_filter = {
8479 .f = cmd_ethertype_filter_parsed,
8481 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8482 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8483 "Add or delete an ethertype filter entry",
8485 (void *)&cmd_ethertype_filter_filter,
8486 (void *)&cmd_ethertype_filter_port_id,
8487 (void *)&cmd_ethertype_filter_ops,
8488 (void *)&cmd_ethertype_filter_mac,
8489 (void *)&cmd_ethertype_filter_mac_addr,
8490 (void *)&cmd_ethertype_filter_ethertype,
8491 (void *)&cmd_ethertype_filter_ethertype_value,
8492 (void *)&cmd_ethertype_filter_drop,
8493 (void *)&cmd_ethertype_filter_queue,
8494 (void *)&cmd_ethertype_filter_queue_id,
8499 /* *** deal with flow director filter *** */
8500 struct cmd_flow_director_result {
8501 cmdline_fixed_string_t flow_director_filter;
8503 cmdline_fixed_string_t mode;
8504 cmdline_fixed_string_t mode_value;
8505 cmdline_fixed_string_t ops;
8506 cmdline_fixed_string_t flow;
8507 cmdline_fixed_string_t flow_type;
8508 cmdline_fixed_string_t ether;
8509 uint16_t ether_type;
8510 cmdline_fixed_string_t src;
8511 cmdline_ipaddr_t ip_src;
8513 cmdline_fixed_string_t dst;
8514 cmdline_ipaddr_t ip_dst;
8516 cmdline_fixed_string_t verify_tag;
8517 uint32_t verify_tag_value;
8518 cmdline_ipaddr_t tos;
8520 cmdline_ipaddr_t proto;
8521 uint8_t proto_value;
8522 cmdline_ipaddr_t ttl;
8524 cmdline_fixed_string_t vlan;
8525 uint16_t vlan_value;
8526 cmdline_fixed_string_t flexbytes;
8527 cmdline_fixed_string_t flexbytes_value;
8528 cmdline_fixed_string_t pf_vf;
8529 cmdline_fixed_string_t drop;
8530 cmdline_fixed_string_t queue;
8532 cmdline_fixed_string_t fd_id;
8533 uint32_t fd_id_value;
8534 cmdline_fixed_string_t mac;
8535 struct ether_addr mac_addr;
8536 cmdline_fixed_string_t tunnel;
8537 cmdline_fixed_string_t tunnel_type;
8538 cmdline_fixed_string_t tunnel_id;
8539 uint32_t tunnel_id_value;
8543 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8546 const char *p, *p0 = q_arg;
8548 unsigned long int_fld;
8549 char *str_fld[max_num];
8554 p = strchr(p0, '(');
8558 p0 = strchr(p, ')');
8563 if (size >= sizeof(s))
8566 snprintf(s, sizeof(s), "%.*s", size, p);
8567 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8568 if (ret < 0 || ret > max_num)
8570 for (i = 0; i < ret; i++) {
8572 int_fld = strtoul(str_fld[i], &end, 0);
8573 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8575 flexbytes[i] = (uint8_t)int_fld;
8581 str2flowtype(char *string)
8584 static const struct {
8587 } flowtype_str[] = {
8588 {"raw", RTE_ETH_FLOW_RAW},
8589 {"ipv4", RTE_ETH_FLOW_IPV4},
8590 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8591 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8592 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8593 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8594 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8595 {"ipv6", RTE_ETH_FLOW_IPV6},
8596 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8597 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8598 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8599 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8600 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8601 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8604 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8605 if (!strcmp(flowtype_str[i].str, string))
8606 return flowtype_str[i].type;
8608 return RTE_ETH_FLOW_UNKNOWN;
8611 static enum rte_eth_fdir_tunnel_type
8612 str2fdir_tunneltype(char *string)
8616 static const struct {
8618 enum rte_eth_fdir_tunnel_type type;
8619 } tunneltype_str[] = {
8620 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8621 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8624 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8625 if (!strcmp(tunneltype_str[i].str, string))
8626 return tunneltype_str[i].type;
8628 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8631 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8633 if ((ip_addr).family == AF_INET) \
8634 (ip) = (ip_addr).addr.ipv4.s_addr; \
8636 printf("invalid parameter.\n"); \
8641 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8643 if ((ip_addr).family == AF_INET6) \
8644 (void)rte_memcpy(&(ip), \
8645 &((ip_addr).addr.ipv6), \
8646 sizeof(struct in6_addr)); \
8648 printf("invalid parameter.\n"); \
8654 cmd_flow_director_filter_parsed(void *parsed_result,
8655 __attribute__((unused)) struct cmdline *cl,
8656 __attribute__((unused)) void *data)
8658 struct cmd_flow_director_result *res = parsed_result;
8659 struct rte_eth_fdir_filter entry;
8660 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8662 unsigned long vf_id;
8665 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8667 printf("flow director is not supported on port %u.\n",
8671 memset(flexbytes, 0, sizeof(flexbytes));
8672 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8674 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8675 if (strcmp(res->mode_value, "MAC-VLAN")) {
8676 printf("Please set mode to MAC-VLAN.\n");
8679 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8680 if (strcmp(res->mode_value, "Tunnel")) {
8681 printf("Please set mode to Tunnel.\n");
8685 if (strcmp(res->mode_value, "IP")) {
8686 printf("Please set mode to IP.\n");
8689 entry.input.flow_type = str2flowtype(res->flow_type);
8692 ret = parse_flexbytes(res->flexbytes_value,
8694 RTE_ETH_FDIR_MAX_FLEXLEN);
8696 printf("error: Cannot parse flexbytes input.\n");
8700 switch (entry.input.flow_type) {
8701 case RTE_ETH_FLOW_FRAG_IPV4:
8702 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8703 entry.input.flow.ip4_flow.proto = res->proto_value;
8704 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8705 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8706 IPV4_ADDR_TO_UINT(res->ip_dst,
8707 entry.input.flow.ip4_flow.dst_ip);
8708 IPV4_ADDR_TO_UINT(res->ip_src,
8709 entry.input.flow.ip4_flow.src_ip);
8710 entry.input.flow.ip4_flow.tos = res->tos_value;
8711 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8712 /* need convert to big endian. */
8713 entry.input.flow.udp4_flow.dst_port =
8714 rte_cpu_to_be_16(res->port_dst);
8715 entry.input.flow.udp4_flow.src_port =
8716 rte_cpu_to_be_16(res->port_src);
8718 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8719 IPV4_ADDR_TO_UINT(res->ip_dst,
8720 entry.input.flow.sctp4_flow.ip.dst_ip);
8721 IPV4_ADDR_TO_UINT(res->ip_src,
8722 entry.input.flow.sctp4_flow.ip.src_ip);
8723 entry.input.flow.ip4_flow.tos = res->tos_value;
8724 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8725 /* need convert to big endian. */
8726 entry.input.flow.sctp4_flow.dst_port =
8727 rte_cpu_to_be_16(res->port_dst);
8728 entry.input.flow.sctp4_flow.src_port =
8729 rte_cpu_to_be_16(res->port_src);
8730 entry.input.flow.sctp4_flow.verify_tag =
8731 rte_cpu_to_be_32(res->verify_tag_value);
8733 case RTE_ETH_FLOW_FRAG_IPV6:
8734 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8735 entry.input.flow.ipv6_flow.proto = res->proto_value;
8736 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8737 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8738 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8739 entry.input.flow.ipv6_flow.dst_ip);
8740 IPV6_ADDR_TO_ARRAY(res->ip_src,
8741 entry.input.flow.ipv6_flow.src_ip);
8742 entry.input.flow.ipv6_flow.tc = res->tos_value;
8743 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8744 /* need convert to big endian. */
8745 entry.input.flow.udp6_flow.dst_port =
8746 rte_cpu_to_be_16(res->port_dst);
8747 entry.input.flow.udp6_flow.src_port =
8748 rte_cpu_to_be_16(res->port_src);
8750 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8751 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8752 entry.input.flow.sctp6_flow.ip.dst_ip);
8753 IPV6_ADDR_TO_ARRAY(res->ip_src,
8754 entry.input.flow.sctp6_flow.ip.src_ip);
8755 entry.input.flow.ipv6_flow.tc = res->tos_value;
8756 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8757 /* need convert to big endian. */
8758 entry.input.flow.sctp6_flow.dst_port =
8759 rte_cpu_to_be_16(res->port_dst);
8760 entry.input.flow.sctp6_flow.src_port =
8761 rte_cpu_to_be_16(res->port_src);
8762 entry.input.flow.sctp6_flow.verify_tag =
8763 rte_cpu_to_be_32(res->verify_tag_value);
8765 case RTE_ETH_FLOW_L2_PAYLOAD:
8766 entry.input.flow.l2_flow.ether_type =
8767 rte_cpu_to_be_16(res->ether_type);
8773 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8774 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8776 sizeof(struct ether_addr));
8778 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8779 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8781 sizeof(struct ether_addr));
8782 entry.input.flow.tunnel_flow.tunnel_type =
8783 str2fdir_tunneltype(res->tunnel_type);
8784 entry.input.flow.tunnel_flow.tunnel_id =
8785 rte_cpu_to_be_32(res->tunnel_id_value);
8788 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8790 RTE_ETH_FDIR_MAX_FLEXLEN);
8792 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8794 entry.action.flex_off = 0; /*use 0 by default */
8795 if (!strcmp(res->drop, "drop"))
8796 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8798 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8800 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8801 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8802 if (!strcmp(res->pf_vf, "pf"))
8803 entry.input.flow_ext.is_vf = 0;
8804 else if (!strncmp(res->pf_vf, "vf", 2)) {
8805 struct rte_eth_dev_info dev_info;
8807 memset(&dev_info, 0, sizeof(dev_info));
8808 rte_eth_dev_info_get(res->port_id, &dev_info);
8810 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8811 if (errno != 0 || *end != '\0' ||
8812 vf_id >= dev_info.max_vfs) {
8813 printf("invalid parameter %s.\n", res->pf_vf);
8816 entry.input.flow_ext.is_vf = 1;
8817 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8819 printf("invalid parameter %s.\n", res->pf_vf);
8824 /* set to report FD ID by default */
8825 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8826 entry.action.rx_queue = res->queue_id;
8827 entry.soft_id = res->fd_id_value;
8828 if (!strcmp(res->ops, "add"))
8829 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8830 RTE_ETH_FILTER_ADD, &entry);
8831 else if (!strcmp(res->ops, "del"))
8832 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8833 RTE_ETH_FILTER_DELETE, &entry);
8835 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8836 RTE_ETH_FILTER_UPDATE, &entry);
8838 printf("flow director programming error: (%s)\n",
8842 cmdline_parse_token_string_t cmd_flow_director_filter =
8843 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8844 flow_director_filter, "flow_director_filter");
8845 cmdline_parse_token_num_t cmd_flow_director_port_id =
8846 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8848 cmdline_parse_token_string_t cmd_flow_director_ops =
8849 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8850 ops, "add#del#update");
8851 cmdline_parse_token_string_t cmd_flow_director_flow =
8852 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8854 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8855 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8856 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8857 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8858 cmdline_parse_token_string_t cmd_flow_director_ether =
8859 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8861 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8862 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8863 ether_type, UINT16);
8864 cmdline_parse_token_string_t cmd_flow_director_src =
8865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8867 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8868 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8870 cmdline_parse_token_num_t cmd_flow_director_port_src =
8871 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8873 cmdline_parse_token_string_t cmd_flow_director_dst =
8874 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8876 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8877 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8879 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8880 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8882 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8883 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8884 verify_tag, "verify_tag");
8885 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8886 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8887 verify_tag_value, UINT32);
8888 cmdline_parse_token_string_t cmd_flow_director_tos =
8889 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8891 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8892 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8894 cmdline_parse_token_string_t cmd_flow_director_proto =
8895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8897 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8898 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8899 proto_value, UINT8);
8900 cmdline_parse_token_string_t cmd_flow_director_ttl =
8901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8903 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8904 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8906 cmdline_parse_token_string_t cmd_flow_director_vlan =
8907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8909 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8910 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8911 vlan_value, UINT16);
8912 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8913 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8914 flexbytes, "flexbytes");
8915 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8917 flexbytes_value, NULL);
8918 cmdline_parse_token_string_t cmd_flow_director_drop =
8919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8921 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8924 cmdline_parse_token_string_t cmd_flow_director_queue =
8925 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8927 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8928 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8930 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8933 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8934 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8935 fd_id_value, UINT32);
8937 cmdline_parse_token_string_t cmd_flow_director_mode =
8938 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8940 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8941 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8943 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8944 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8945 mode_value, "MAC-VLAN");
8946 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8947 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8948 mode_value, "Tunnel");
8949 cmdline_parse_token_string_t cmd_flow_director_mac =
8950 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8952 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8953 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8955 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8956 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8958 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8960 tunnel_type, "NVGRE#VxLAN");
8961 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8963 tunnel_id, "tunnel-id");
8964 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8965 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8966 tunnel_id_value, UINT32);
8968 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8969 .f = cmd_flow_director_filter_parsed,
8971 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8972 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8973 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8974 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8975 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8976 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8977 "fd_id <fd_id_value>: "
8978 "Add or delete an ip flow director entry on NIC",
8980 (void *)&cmd_flow_director_filter,
8981 (void *)&cmd_flow_director_port_id,
8982 (void *)&cmd_flow_director_mode,
8983 (void *)&cmd_flow_director_mode_ip,
8984 (void *)&cmd_flow_director_ops,
8985 (void *)&cmd_flow_director_flow,
8986 (void *)&cmd_flow_director_flow_type,
8987 (void *)&cmd_flow_director_src,
8988 (void *)&cmd_flow_director_ip_src,
8989 (void *)&cmd_flow_director_dst,
8990 (void *)&cmd_flow_director_ip_dst,
8991 (void *)&cmd_flow_director_tos,
8992 (void *)&cmd_flow_director_tos_value,
8993 (void *)&cmd_flow_director_proto,
8994 (void *)&cmd_flow_director_proto_value,
8995 (void *)&cmd_flow_director_ttl,
8996 (void *)&cmd_flow_director_ttl_value,
8997 (void *)&cmd_flow_director_vlan,
8998 (void *)&cmd_flow_director_vlan_value,
8999 (void *)&cmd_flow_director_flexbytes,
9000 (void *)&cmd_flow_director_flexbytes_value,
9001 (void *)&cmd_flow_director_drop,
9002 (void *)&cmd_flow_director_pf_vf,
9003 (void *)&cmd_flow_director_queue,
9004 (void *)&cmd_flow_director_queue_id,
9005 (void *)&cmd_flow_director_fd_id,
9006 (void *)&cmd_flow_director_fd_id_value,
9011 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9012 .f = cmd_flow_director_filter_parsed,
9014 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9015 "director entry on NIC",
9017 (void *)&cmd_flow_director_filter,
9018 (void *)&cmd_flow_director_port_id,
9019 (void *)&cmd_flow_director_mode,
9020 (void *)&cmd_flow_director_mode_ip,
9021 (void *)&cmd_flow_director_ops,
9022 (void *)&cmd_flow_director_flow,
9023 (void *)&cmd_flow_director_flow_type,
9024 (void *)&cmd_flow_director_src,
9025 (void *)&cmd_flow_director_ip_src,
9026 (void *)&cmd_flow_director_port_src,
9027 (void *)&cmd_flow_director_dst,
9028 (void *)&cmd_flow_director_ip_dst,
9029 (void *)&cmd_flow_director_port_dst,
9030 (void *)&cmd_flow_director_tos,
9031 (void *)&cmd_flow_director_tos_value,
9032 (void *)&cmd_flow_director_ttl,
9033 (void *)&cmd_flow_director_ttl_value,
9034 (void *)&cmd_flow_director_vlan,
9035 (void *)&cmd_flow_director_vlan_value,
9036 (void *)&cmd_flow_director_flexbytes,
9037 (void *)&cmd_flow_director_flexbytes_value,
9038 (void *)&cmd_flow_director_drop,
9039 (void *)&cmd_flow_director_pf_vf,
9040 (void *)&cmd_flow_director_queue,
9041 (void *)&cmd_flow_director_queue_id,
9042 (void *)&cmd_flow_director_fd_id,
9043 (void *)&cmd_flow_director_fd_id_value,
9048 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9049 .f = cmd_flow_director_filter_parsed,
9051 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9052 "director entry on NIC",
9054 (void *)&cmd_flow_director_filter,
9055 (void *)&cmd_flow_director_port_id,
9056 (void *)&cmd_flow_director_mode,
9057 (void *)&cmd_flow_director_mode_ip,
9058 (void *)&cmd_flow_director_ops,
9059 (void *)&cmd_flow_director_flow,
9060 (void *)&cmd_flow_director_flow_type,
9061 (void *)&cmd_flow_director_src,
9062 (void *)&cmd_flow_director_ip_src,
9063 (void *)&cmd_flow_director_port_dst,
9064 (void *)&cmd_flow_director_dst,
9065 (void *)&cmd_flow_director_ip_dst,
9066 (void *)&cmd_flow_director_port_dst,
9067 (void *)&cmd_flow_director_verify_tag,
9068 (void *)&cmd_flow_director_verify_tag_value,
9069 (void *)&cmd_flow_director_tos,
9070 (void *)&cmd_flow_director_tos_value,
9071 (void *)&cmd_flow_director_ttl,
9072 (void *)&cmd_flow_director_ttl_value,
9073 (void *)&cmd_flow_director_vlan,
9074 (void *)&cmd_flow_director_vlan_value,
9075 (void *)&cmd_flow_director_flexbytes,
9076 (void *)&cmd_flow_director_flexbytes_value,
9077 (void *)&cmd_flow_director_drop,
9078 (void *)&cmd_flow_director_pf_vf,
9079 (void *)&cmd_flow_director_queue,
9080 (void *)&cmd_flow_director_queue_id,
9081 (void *)&cmd_flow_director_fd_id,
9082 (void *)&cmd_flow_director_fd_id_value,
9087 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9088 .f = cmd_flow_director_filter_parsed,
9090 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9091 "director entry on NIC",
9093 (void *)&cmd_flow_director_filter,
9094 (void *)&cmd_flow_director_port_id,
9095 (void *)&cmd_flow_director_mode,
9096 (void *)&cmd_flow_director_mode_ip,
9097 (void *)&cmd_flow_director_ops,
9098 (void *)&cmd_flow_director_flow,
9099 (void *)&cmd_flow_director_flow_type,
9100 (void *)&cmd_flow_director_ether,
9101 (void *)&cmd_flow_director_ether_type,
9102 (void *)&cmd_flow_director_flexbytes,
9103 (void *)&cmd_flow_director_flexbytes_value,
9104 (void *)&cmd_flow_director_drop,
9105 (void *)&cmd_flow_director_pf_vf,
9106 (void *)&cmd_flow_director_queue,
9107 (void *)&cmd_flow_director_queue_id,
9108 (void *)&cmd_flow_director_fd_id,
9109 (void *)&cmd_flow_director_fd_id_value,
9114 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9115 .f = cmd_flow_director_filter_parsed,
9117 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9118 "director entry on NIC",
9120 (void *)&cmd_flow_director_filter,
9121 (void *)&cmd_flow_director_port_id,
9122 (void *)&cmd_flow_director_mode,
9123 (void *)&cmd_flow_director_mode_mac_vlan,
9124 (void *)&cmd_flow_director_ops,
9125 (void *)&cmd_flow_director_mac,
9126 (void *)&cmd_flow_director_mac_addr,
9127 (void *)&cmd_flow_director_vlan,
9128 (void *)&cmd_flow_director_vlan_value,
9129 (void *)&cmd_flow_director_flexbytes,
9130 (void *)&cmd_flow_director_flexbytes_value,
9131 (void *)&cmd_flow_director_drop,
9132 (void *)&cmd_flow_director_queue,
9133 (void *)&cmd_flow_director_queue_id,
9134 (void *)&cmd_flow_director_fd_id,
9135 (void *)&cmd_flow_director_fd_id_value,
9140 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9141 .f = cmd_flow_director_filter_parsed,
9143 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9144 "director entry on NIC",
9146 (void *)&cmd_flow_director_filter,
9147 (void *)&cmd_flow_director_port_id,
9148 (void *)&cmd_flow_director_mode,
9149 (void *)&cmd_flow_director_mode_tunnel,
9150 (void *)&cmd_flow_director_ops,
9151 (void *)&cmd_flow_director_mac,
9152 (void *)&cmd_flow_director_mac_addr,
9153 (void *)&cmd_flow_director_vlan,
9154 (void *)&cmd_flow_director_vlan_value,
9155 (void *)&cmd_flow_director_tunnel,
9156 (void *)&cmd_flow_director_tunnel_type,
9157 (void *)&cmd_flow_director_tunnel_id,
9158 (void *)&cmd_flow_director_tunnel_id_value,
9159 (void *)&cmd_flow_director_flexbytes,
9160 (void *)&cmd_flow_director_flexbytes_value,
9161 (void *)&cmd_flow_director_drop,
9162 (void *)&cmd_flow_director_queue,
9163 (void *)&cmd_flow_director_queue_id,
9164 (void *)&cmd_flow_director_fd_id,
9165 (void *)&cmd_flow_director_fd_id_value,
9170 struct cmd_flush_flow_director_result {
9171 cmdline_fixed_string_t flush_flow_director;
9175 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9176 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9177 flush_flow_director, "flush_flow_director");
9178 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9179 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9183 cmd_flush_flow_director_parsed(void *parsed_result,
9184 __attribute__((unused)) struct cmdline *cl,
9185 __attribute__((unused)) void *data)
9187 struct cmd_flow_director_result *res = parsed_result;
9190 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9192 printf("flow director is not supported on port %u.\n",
9197 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9198 RTE_ETH_FILTER_FLUSH, NULL);
9200 printf("flow director table flushing error: (%s)\n",
9204 cmdline_parse_inst_t cmd_flush_flow_director = {
9205 .f = cmd_flush_flow_director_parsed,
9207 .help_str = "flush_flow_director <port_id>: "
9208 "Flush all flow director entries of a device on NIC",
9210 (void *)&cmd_flush_flow_director_flush,
9211 (void *)&cmd_flush_flow_director_port_id,
9216 /* *** deal with flow director mask *** */
9217 struct cmd_flow_director_mask_result {
9218 cmdline_fixed_string_t flow_director_mask;
9220 cmdline_fixed_string_t mode;
9221 cmdline_fixed_string_t mode_value;
9222 cmdline_fixed_string_t vlan;
9224 cmdline_fixed_string_t src_mask;
9225 cmdline_ipaddr_t ipv4_src;
9226 cmdline_ipaddr_t ipv6_src;
9228 cmdline_fixed_string_t dst_mask;
9229 cmdline_ipaddr_t ipv4_dst;
9230 cmdline_ipaddr_t ipv6_dst;
9232 cmdline_fixed_string_t mac;
9233 uint8_t mac_addr_byte_mask;
9234 cmdline_fixed_string_t tunnel_id;
9235 uint32_t tunnel_id_mask;
9236 cmdline_fixed_string_t tunnel_type;
9237 uint8_t tunnel_type_mask;
9241 cmd_flow_director_mask_parsed(void *parsed_result,
9242 __attribute__((unused)) struct cmdline *cl,
9243 __attribute__((unused)) void *data)
9245 struct cmd_flow_director_mask_result *res = parsed_result;
9246 struct rte_eth_fdir_masks *mask;
9247 struct rte_port *port;
9249 if (res->port_id > nb_ports) {
9250 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9254 port = &ports[res->port_id];
9255 /** Check if the port is not started **/
9256 if (port->port_status != RTE_PORT_STOPPED) {
9257 printf("Please stop port %d first\n", res->port_id);
9261 mask = &port->dev_conf.fdir_conf.mask;
9263 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9264 if (strcmp(res->mode_value, "MAC-VLAN")) {
9265 printf("Please set mode to MAC-VLAN.\n");
9269 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9270 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9271 if (strcmp(res->mode_value, "Tunnel")) {
9272 printf("Please set mode to Tunnel.\n");
9276 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9277 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9278 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9279 mask->tunnel_type_mask = res->tunnel_type_mask;
9281 if (strcmp(res->mode_value, "IP")) {
9282 printf("Please set mode to IP.\n");
9286 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9287 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9288 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9289 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9290 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9291 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9292 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9295 cmd_reconfig_device_queue(res->port_id, 1, 1);
9298 cmdline_parse_token_string_t cmd_flow_director_mask =
9299 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9300 flow_director_mask, "flow_director_mask");
9301 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9302 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9304 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9305 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9307 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9308 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9310 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9311 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9312 src_mask, "src_mask");
9313 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9314 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9316 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9317 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9319 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9320 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9322 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9323 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9324 dst_mask, "dst_mask");
9325 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9326 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9328 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9329 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9331 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9332 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9335 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9336 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9338 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9341 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9342 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9343 mode_value, "MAC-VLAN");
9344 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9345 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9346 mode_value, "Tunnel");
9347 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9350 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9351 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9352 mac_addr_byte_mask, UINT8);
9353 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9354 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9355 tunnel_type, "tunnel-type");
9356 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9357 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9358 tunnel_type_mask, UINT8);
9359 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9360 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9361 tunnel_id, "tunnel-id");
9362 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9363 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9364 tunnel_id_mask, UINT32);
9366 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9367 .f = cmd_flow_director_mask_parsed,
9369 .help_str = "flow_director_mask ... : "
9370 "Set IP mode flow director's mask on NIC",
9372 (void *)&cmd_flow_director_mask,
9373 (void *)&cmd_flow_director_mask_port_id,
9374 (void *)&cmd_flow_director_mask_mode,
9375 (void *)&cmd_flow_director_mask_mode_ip,
9376 (void *)&cmd_flow_director_mask_vlan,
9377 (void *)&cmd_flow_director_mask_vlan_value,
9378 (void *)&cmd_flow_director_mask_src,
9379 (void *)&cmd_flow_director_mask_ipv4_src,
9380 (void *)&cmd_flow_director_mask_ipv6_src,
9381 (void *)&cmd_flow_director_mask_port_src,
9382 (void *)&cmd_flow_director_mask_dst,
9383 (void *)&cmd_flow_director_mask_ipv4_dst,
9384 (void *)&cmd_flow_director_mask_ipv6_dst,
9385 (void *)&cmd_flow_director_mask_port_dst,
9390 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9391 .f = cmd_flow_director_mask_parsed,
9393 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9394 "flow director's mask on NIC",
9396 (void *)&cmd_flow_director_mask,
9397 (void *)&cmd_flow_director_mask_port_id,
9398 (void *)&cmd_flow_director_mask_mode,
9399 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9400 (void *)&cmd_flow_director_mask_vlan,
9401 (void *)&cmd_flow_director_mask_vlan_value,
9406 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9407 .f = cmd_flow_director_mask_parsed,
9409 .help_str = "flow_director_mask ... : Set tunnel mode "
9410 "flow director's mask on NIC",
9412 (void *)&cmd_flow_director_mask,
9413 (void *)&cmd_flow_director_mask_port_id,
9414 (void *)&cmd_flow_director_mask_mode,
9415 (void *)&cmd_flow_director_mask_mode_tunnel,
9416 (void *)&cmd_flow_director_mask_vlan,
9417 (void *)&cmd_flow_director_mask_vlan_value,
9418 (void *)&cmd_flow_director_mask_mac,
9419 (void *)&cmd_flow_director_mask_mac_value,
9420 (void *)&cmd_flow_director_mask_tunnel_type,
9421 (void *)&cmd_flow_director_mask_tunnel_type_value,
9422 (void *)&cmd_flow_director_mask_tunnel_id,
9423 (void *)&cmd_flow_director_mask_tunnel_id_value,
9428 /* *** deal with flow director mask on flexible payload *** */
9429 struct cmd_flow_director_flex_mask_result {
9430 cmdline_fixed_string_t flow_director_flexmask;
9432 cmdline_fixed_string_t flow;
9433 cmdline_fixed_string_t flow_type;
9434 cmdline_fixed_string_t mask;
9438 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9439 __attribute__((unused)) struct cmdline *cl,
9440 __attribute__((unused)) void *data)
9442 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9443 struct rte_eth_fdir_info fdir_info;
9444 struct rte_eth_fdir_flex_mask flex_mask;
9445 struct rte_port *port;
9446 uint32_t flow_type_mask;
9450 if (res->port_id > nb_ports) {
9451 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9455 port = &ports[res->port_id];
9456 /** Check if the port is not started **/
9457 if (port->port_status != RTE_PORT_STOPPED) {
9458 printf("Please stop port %d first\n", res->port_id);
9462 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9463 ret = parse_flexbytes(res->mask,
9465 RTE_ETH_FDIR_MAX_FLEXLEN);
9467 printf("error: Cannot parse mask input.\n");
9471 memset(&fdir_info, 0, sizeof(fdir_info));
9472 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9473 RTE_ETH_FILTER_INFO, &fdir_info);
9475 printf("Cannot get FDir filter info\n");
9479 if (!strcmp(res->flow_type, "none")) {
9480 /* means don't specify the flow type */
9481 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9482 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9483 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9484 0, sizeof(struct rte_eth_fdir_flex_mask));
9485 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9486 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9488 sizeof(struct rte_eth_fdir_flex_mask));
9489 cmd_reconfig_device_queue(res->port_id, 1, 1);
9492 flow_type_mask = fdir_info.flow_types_mask[0];
9493 if (!strcmp(res->flow_type, "all")) {
9494 if (!flow_type_mask) {
9495 printf("No flow type supported\n");
9498 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9499 if (flow_type_mask & (1 << i)) {
9500 flex_mask.flow_type = i;
9501 fdir_set_flex_mask(res->port_id, &flex_mask);
9504 cmd_reconfig_device_queue(res->port_id, 1, 1);
9507 flex_mask.flow_type = str2flowtype(res->flow_type);
9508 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9509 printf("Flow type %s not supported on port %d\n",
9510 res->flow_type, res->port_id);
9513 fdir_set_flex_mask(res->port_id, &flex_mask);
9514 cmd_reconfig_device_queue(res->port_id, 1, 1);
9517 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9518 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9519 flow_director_flexmask,
9520 "flow_director_flex_mask");
9521 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9522 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9524 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9525 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9527 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9528 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9529 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9530 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9531 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9532 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9535 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9536 .f = cmd_flow_director_flex_mask_parsed,
9538 .help_str = "flow_director_flex_mask ... : "
9539 "Set flow director's flex mask on NIC",
9541 (void *)&cmd_flow_director_flexmask,
9542 (void *)&cmd_flow_director_flexmask_port_id,
9543 (void *)&cmd_flow_director_flexmask_flow,
9544 (void *)&cmd_flow_director_flexmask_flow_type,
9545 (void *)&cmd_flow_director_flexmask_mask,
9550 /* *** deal with flow director flexible payload configuration *** */
9551 struct cmd_flow_director_flexpayload_result {
9552 cmdline_fixed_string_t flow_director_flexpayload;
9554 cmdline_fixed_string_t payload_layer;
9555 cmdline_fixed_string_t payload_cfg;
9559 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9562 const char *p, *p0 = q_arg;
9564 unsigned long int_fld;
9565 char *str_fld[max_num];
9570 p = strchr(p0, '(');
9574 p0 = strchr(p, ')');
9579 if (size >= sizeof(s))
9582 snprintf(s, sizeof(s), "%.*s", size, p);
9583 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9584 if (ret < 0 || ret > max_num)
9586 for (i = 0; i < ret; i++) {
9588 int_fld = strtoul(str_fld[i], &end, 0);
9589 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9591 offsets[i] = (uint16_t)int_fld;
9597 cmd_flow_director_flxpld_parsed(void *parsed_result,
9598 __attribute__((unused)) struct cmdline *cl,
9599 __attribute__((unused)) void *data)
9601 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9602 struct rte_eth_flex_payload_cfg flex_cfg;
9603 struct rte_port *port;
9606 if (res->port_id > nb_ports) {
9607 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9611 port = &ports[res->port_id];
9612 /** Check if the port is not started **/
9613 if (port->port_status != RTE_PORT_STOPPED) {
9614 printf("Please stop port %d first\n", res->port_id);
9618 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9620 if (!strcmp(res->payload_layer, "raw"))
9621 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9622 else if (!strcmp(res->payload_layer, "l2"))
9623 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9624 else if (!strcmp(res->payload_layer, "l3"))
9625 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9626 else if (!strcmp(res->payload_layer, "l4"))
9627 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9629 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9630 RTE_ETH_FDIR_MAX_FLEXLEN);
9632 printf("error: Cannot parse flex payload input.\n");
9636 fdir_set_flex_payload(res->port_id, &flex_cfg);
9637 cmd_reconfig_device_queue(res->port_id, 1, 1);
9640 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9641 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9642 flow_director_flexpayload,
9643 "flow_director_flex_payload");
9644 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9645 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9647 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9648 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9649 payload_layer, "raw#l2#l3#l4");
9650 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9651 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9654 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9655 .f = cmd_flow_director_flxpld_parsed,
9657 .help_str = "flow_director_flexpayload ... : "
9658 "Set flow director's flex payload on NIC",
9660 (void *)&cmd_flow_director_flexpayload,
9661 (void *)&cmd_flow_director_flexpayload_port_id,
9662 (void *)&cmd_flow_director_flexpayload_payload_layer,
9663 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9668 /* Generic flow interface command. */
9669 extern cmdline_parse_inst_t cmd_flow;
9671 /* *** Classification Filters Control *** */
9672 /* *** Get symmetric hash enable per port *** */
9673 struct cmd_get_sym_hash_ena_per_port_result {
9674 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9679 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9680 __rte_unused struct cmdline *cl,
9681 __rte_unused void *data)
9683 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9684 struct rte_eth_hash_filter_info info;
9687 if (rte_eth_dev_filter_supported(res->port_id,
9688 RTE_ETH_FILTER_HASH) < 0) {
9689 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9694 memset(&info, 0, sizeof(info));
9695 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9696 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9697 RTE_ETH_FILTER_GET, &info);
9700 printf("Cannot get symmetric hash enable per port "
9701 "on port %u\n", res->port_id);
9705 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9706 "enabled" : "disabled", res->port_id);
9709 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9710 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9711 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9712 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9713 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9716 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9717 .f = cmd_get_sym_hash_per_port_parsed,
9719 .help_str = "get_sym_hash_ena_per_port <port_id>",
9721 (void *)&cmd_get_sym_hash_ena_per_port_all,
9722 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9727 /* *** Set symmetric hash enable per port *** */
9728 struct cmd_set_sym_hash_ena_per_port_result {
9729 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9730 cmdline_fixed_string_t enable;
9735 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9736 __rte_unused struct cmdline *cl,
9737 __rte_unused void *data)
9739 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9740 struct rte_eth_hash_filter_info info;
9743 if (rte_eth_dev_filter_supported(res->port_id,
9744 RTE_ETH_FILTER_HASH) < 0) {
9745 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9750 memset(&info, 0, sizeof(info));
9751 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9752 if (!strcmp(res->enable, "enable"))
9753 info.info.enable = 1;
9754 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9755 RTE_ETH_FILTER_SET, &info);
9757 printf("Cannot set symmetric hash enable per port on "
9758 "port %u\n", res->port_id);
9761 printf("Symmetric hash has been set to %s on port %u\n",
9762 res->enable, res->port_id);
9765 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9766 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9767 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9768 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9769 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9771 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9772 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9773 enable, "enable#disable");
9775 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9776 .f = cmd_set_sym_hash_per_port_parsed,
9778 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9780 (void *)&cmd_set_sym_hash_ena_per_port_all,
9781 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9782 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9787 /* Get global config of hash function */
9788 struct cmd_get_hash_global_config_result {
9789 cmdline_fixed_string_t get_hash_global_config;
9794 flowtype_to_str(uint16_t ftype)
9801 {"ipv4", RTE_ETH_FLOW_IPV4},
9802 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9803 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9804 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9805 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9806 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9807 {"ipv6", RTE_ETH_FLOW_IPV6},
9808 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9809 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9810 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9811 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9812 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9813 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9814 {"port", RTE_ETH_FLOW_PORT},
9815 {"vxlan", RTE_ETH_FLOW_VXLAN},
9816 {"geneve", RTE_ETH_FLOW_GENEVE},
9817 {"nvgre", RTE_ETH_FLOW_NVGRE},
9820 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9821 if (ftype_table[i].ftype == ftype)
9822 return ftype_table[i].str;
9829 cmd_get_hash_global_config_parsed(void *parsed_result,
9830 __rte_unused struct cmdline *cl,
9831 __rte_unused void *data)
9833 struct cmd_get_hash_global_config_result *res = parsed_result;
9834 struct rte_eth_hash_filter_info info;
9835 uint32_t idx, offset;
9840 if (rte_eth_dev_filter_supported(res->port_id,
9841 RTE_ETH_FILTER_HASH) < 0) {
9842 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9847 memset(&info, 0, sizeof(info));
9848 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9849 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9850 RTE_ETH_FILTER_GET, &info);
9852 printf("Cannot get hash global configurations by port %d\n",
9857 switch (info.info.global_conf.hash_func) {
9858 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9859 printf("Hash function is Toeplitz\n");
9861 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9862 printf("Hash function is Simple XOR\n");
9865 printf("Unknown hash function\n");
9869 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9870 idx = i / UINT32_BIT;
9871 offset = i % UINT32_BIT;
9872 if (!(info.info.global_conf.valid_bit_mask[idx] &
9875 str = flowtype_to_str(i);
9878 printf("Symmetric hash is %s globally for flow type %s "
9880 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9881 (1UL << offset)) ? "enabled" : "disabled"), str,
9886 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9887 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9888 get_hash_global_config, "get_hash_global_config");
9889 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9890 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9893 cmdline_parse_inst_t cmd_get_hash_global_config = {
9894 .f = cmd_get_hash_global_config_parsed,
9896 .help_str = "get_hash_global_config <port_id>",
9898 (void *)&cmd_get_hash_global_config_all,
9899 (void *)&cmd_get_hash_global_config_port_id,
9904 /* Set global config of hash function */
9905 struct cmd_set_hash_global_config_result {
9906 cmdline_fixed_string_t set_hash_global_config;
9908 cmdline_fixed_string_t hash_func;
9909 cmdline_fixed_string_t flow_type;
9910 cmdline_fixed_string_t enable;
9914 cmd_set_hash_global_config_parsed(void *parsed_result,
9915 __rte_unused struct cmdline *cl,
9916 __rte_unused void *data)
9918 struct cmd_set_hash_global_config_result *res = parsed_result;
9919 struct rte_eth_hash_filter_info info;
9920 uint32_t ftype, idx, offset;
9923 if (rte_eth_dev_filter_supported(res->port_id,
9924 RTE_ETH_FILTER_HASH) < 0) {
9925 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9929 memset(&info, 0, sizeof(info));
9930 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9931 if (!strcmp(res->hash_func, "toeplitz"))
9932 info.info.global_conf.hash_func =
9933 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9934 else if (!strcmp(res->hash_func, "simple_xor"))
9935 info.info.global_conf.hash_func =
9936 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9937 else if (!strcmp(res->hash_func, "default"))
9938 info.info.global_conf.hash_func =
9939 RTE_ETH_HASH_FUNCTION_DEFAULT;
9941 ftype = str2flowtype(res->flow_type);
9942 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9943 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9944 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9945 if (!strcmp(res->enable, "enable"))
9946 info.info.global_conf.sym_hash_enable_mask[idx] |=
9948 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9949 RTE_ETH_FILTER_SET, &info);
9951 printf("Cannot set global hash configurations by port %d\n",
9954 printf("Global hash configurations have been set "
9955 "succcessfully by port %d\n", res->port_id);
9958 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9959 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9960 set_hash_global_config, "set_hash_global_config");
9961 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9962 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9964 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9965 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9966 hash_func, "toeplitz#simple_xor#default");
9967 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9968 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9970 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9971 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9972 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9973 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9974 enable, "enable#disable");
9976 cmdline_parse_inst_t cmd_set_hash_global_config = {
9977 .f = cmd_set_hash_global_config_parsed,
9979 .help_str = "set_hash_global_config <port_id> "
9980 "toeplitz|simple_xor|default "
9981 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9982 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9983 "l2_payload enable|disable",
9985 (void *)&cmd_set_hash_global_config_all,
9986 (void *)&cmd_set_hash_global_config_port_id,
9987 (void *)&cmd_set_hash_global_config_hash_func,
9988 (void *)&cmd_set_hash_global_config_flow_type,
9989 (void *)&cmd_set_hash_global_config_enable,
9994 /* Set hash input set */
9995 struct cmd_set_hash_input_set_result {
9996 cmdline_fixed_string_t set_hash_input_set;
9998 cmdline_fixed_string_t flow_type;
9999 cmdline_fixed_string_t inset_field;
10000 cmdline_fixed_string_t select;
10003 static enum rte_eth_input_set_field
10004 str2inset(char *string)
10008 static const struct {
10010 enum rte_eth_input_set_field inset;
10011 } inset_table[] = {
10012 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10013 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10014 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10015 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10016 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10017 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10018 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10019 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10020 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10021 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10022 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10023 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10024 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10025 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10026 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10027 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10028 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10029 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10030 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10031 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10032 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10033 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10034 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10035 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10036 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10037 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10038 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10039 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10040 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10041 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10042 {"none", RTE_ETH_INPUT_SET_NONE},
10045 for (i = 0; i < RTE_DIM(inset_table); i++) {
10046 if (!strcmp(string, inset_table[i].str))
10047 return inset_table[i].inset;
10050 return RTE_ETH_INPUT_SET_UNKNOWN;
10054 cmd_set_hash_input_set_parsed(void *parsed_result,
10055 __rte_unused struct cmdline *cl,
10056 __rte_unused void *data)
10058 struct cmd_set_hash_input_set_result *res = parsed_result;
10059 struct rte_eth_hash_filter_info info;
10061 memset(&info, 0, sizeof(info));
10062 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10063 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10064 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10065 info.info.input_set_conf.inset_size = 1;
10066 if (!strcmp(res->select, "select"))
10067 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10068 else if (!strcmp(res->select, "add"))
10069 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10070 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10071 RTE_ETH_FILTER_SET, &info);
10074 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10075 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10076 set_hash_input_set, "set_hash_input_set");
10077 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10078 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10080 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10081 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10083 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10084 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10085 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10086 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10088 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10089 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10090 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10091 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10092 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10094 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10095 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10096 select, "select#add");
10098 cmdline_parse_inst_t cmd_set_hash_input_set = {
10099 .f = cmd_set_hash_input_set_parsed,
10101 .help_str = "set_hash_input_set <port_id> "
10102 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10103 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10104 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10105 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10106 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10107 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10108 "fld-7th|fld-8th|none select|add",
10110 (void *)&cmd_set_hash_input_set_cmd,
10111 (void *)&cmd_set_hash_input_set_port_id,
10112 (void *)&cmd_set_hash_input_set_flow_type,
10113 (void *)&cmd_set_hash_input_set_field,
10114 (void *)&cmd_set_hash_input_set_select,
10119 /* Set flow director input set */
10120 struct cmd_set_fdir_input_set_result {
10121 cmdline_fixed_string_t set_fdir_input_set;
10123 cmdline_fixed_string_t flow_type;
10124 cmdline_fixed_string_t inset_field;
10125 cmdline_fixed_string_t select;
10129 cmd_set_fdir_input_set_parsed(void *parsed_result,
10130 __rte_unused struct cmdline *cl,
10131 __rte_unused void *data)
10133 struct cmd_set_fdir_input_set_result *res = parsed_result;
10134 struct rte_eth_fdir_filter_info info;
10136 memset(&info, 0, sizeof(info));
10137 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10138 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10139 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10140 info.info.input_set_conf.inset_size = 1;
10141 if (!strcmp(res->select, "select"))
10142 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10143 else if (!strcmp(res->select, "add"))
10144 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10145 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10146 RTE_ETH_FILTER_SET, &info);
10149 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10150 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10151 set_fdir_input_set, "set_fdir_input_set");
10152 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10153 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10155 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10156 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10158 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10159 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10160 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10161 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10163 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10164 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10165 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10166 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10167 "sctp-veri-tag#none");
10168 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10169 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10170 select, "select#add");
10172 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10173 .f = cmd_set_fdir_input_set_parsed,
10175 .help_str = "set_fdir_input_set <port_id> "
10176 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10177 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10178 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10179 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10180 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10181 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10182 "sctp-veri-tag|none select|add",
10184 (void *)&cmd_set_fdir_input_set_cmd,
10185 (void *)&cmd_set_fdir_input_set_port_id,
10186 (void *)&cmd_set_fdir_input_set_flow_type,
10187 (void *)&cmd_set_fdir_input_set_field,
10188 (void *)&cmd_set_fdir_input_set_select,
10193 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10194 struct cmd_mcast_addr_result {
10195 cmdline_fixed_string_t mcast_addr_cmd;
10196 cmdline_fixed_string_t what;
10198 struct ether_addr mc_addr;
10201 static void cmd_mcast_addr_parsed(void *parsed_result,
10202 __attribute__((unused)) struct cmdline *cl,
10203 __attribute__((unused)) void *data)
10205 struct cmd_mcast_addr_result *res = parsed_result;
10207 if (!is_multicast_ether_addr(&res->mc_addr)) {
10208 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10209 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10210 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10211 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10214 if (strcmp(res->what, "add") == 0)
10215 mcast_addr_add(res->port_num, &res->mc_addr);
10217 mcast_addr_remove(res->port_num, &res->mc_addr);
10220 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10221 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10222 mcast_addr_cmd, "mcast_addr");
10223 cmdline_parse_token_string_t cmd_mcast_addr_what =
10224 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10226 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10227 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10228 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10229 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10231 cmdline_parse_inst_t cmd_mcast_addr = {
10232 .f = cmd_mcast_addr_parsed,
10234 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10235 "Add/Remove multicast MAC address on port_id",
10237 (void *)&cmd_mcast_addr_cmd,
10238 (void *)&cmd_mcast_addr_what,
10239 (void *)&cmd_mcast_addr_portnum,
10240 (void *)&cmd_mcast_addr_addr,
10245 /* l2 tunnel config
10246 * only support E-tag now.
10249 /* Ether type config */
10250 struct cmd_config_l2_tunnel_eth_type_result {
10251 cmdline_fixed_string_t port;
10252 cmdline_fixed_string_t config;
10253 cmdline_fixed_string_t all;
10255 cmdline_fixed_string_t l2_tunnel;
10256 cmdline_fixed_string_t l2_tunnel_type;
10257 cmdline_fixed_string_t eth_type;
10258 uint16_t eth_type_val;
10261 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10262 TOKEN_STRING_INITIALIZER
10263 (struct cmd_config_l2_tunnel_eth_type_result,
10265 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10266 TOKEN_STRING_INITIALIZER
10267 (struct cmd_config_l2_tunnel_eth_type_result,
10269 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10270 TOKEN_STRING_INITIALIZER
10271 (struct cmd_config_l2_tunnel_eth_type_result,
10273 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10274 TOKEN_NUM_INITIALIZER
10275 (struct cmd_config_l2_tunnel_eth_type_result,
10277 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10278 TOKEN_STRING_INITIALIZER
10279 (struct cmd_config_l2_tunnel_eth_type_result,
10280 l2_tunnel, "l2-tunnel");
10281 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10282 TOKEN_STRING_INITIALIZER
10283 (struct cmd_config_l2_tunnel_eth_type_result,
10284 l2_tunnel_type, "E-tag");
10285 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10286 TOKEN_STRING_INITIALIZER
10287 (struct cmd_config_l2_tunnel_eth_type_result,
10288 eth_type, "ether-type");
10289 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10290 TOKEN_NUM_INITIALIZER
10291 (struct cmd_config_l2_tunnel_eth_type_result,
10292 eth_type_val, UINT16);
10294 static enum rte_eth_tunnel_type
10295 str2fdir_l2_tunnel_type(char *string)
10299 static const struct {
10301 enum rte_eth_tunnel_type type;
10302 } l2_tunnel_type_str[] = {
10303 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10306 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10307 if (!strcmp(l2_tunnel_type_str[i].str, string))
10308 return l2_tunnel_type_str[i].type;
10310 return RTE_TUNNEL_TYPE_NONE;
10313 /* ether type config for all ports */
10315 cmd_config_l2_tunnel_eth_type_all_parsed
10316 (void *parsed_result,
10317 __attribute__((unused)) struct cmdline *cl,
10318 __attribute__((unused)) void *data)
10320 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10321 struct rte_eth_l2_tunnel_conf entry;
10324 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10325 entry.ether_type = res->eth_type_val;
10327 FOREACH_PORT(pid, ports) {
10328 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10332 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10333 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10335 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10337 (void *)&cmd_config_l2_tunnel_eth_type_port,
10338 (void *)&cmd_config_l2_tunnel_eth_type_config,
10339 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10340 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10341 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10342 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10343 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10348 /* ether type config for a specific port */
10350 cmd_config_l2_tunnel_eth_type_specific_parsed(
10351 void *parsed_result,
10352 __attribute__((unused)) struct cmdline *cl,
10353 __attribute__((unused)) void *data)
10355 struct cmd_config_l2_tunnel_eth_type_result *res =
10357 struct rte_eth_l2_tunnel_conf entry;
10359 if (port_id_is_invalid(res->id, ENABLED_WARN))
10362 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10363 entry.ether_type = res->eth_type_val;
10365 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10368 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10369 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10371 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10373 (void *)&cmd_config_l2_tunnel_eth_type_port,
10374 (void *)&cmd_config_l2_tunnel_eth_type_config,
10375 (void *)&cmd_config_l2_tunnel_eth_type_id,
10376 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10377 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10378 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10379 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10384 /* Enable/disable l2 tunnel */
10385 struct cmd_config_l2_tunnel_en_dis_result {
10386 cmdline_fixed_string_t port;
10387 cmdline_fixed_string_t config;
10388 cmdline_fixed_string_t all;
10390 cmdline_fixed_string_t l2_tunnel;
10391 cmdline_fixed_string_t l2_tunnel_type;
10392 cmdline_fixed_string_t en_dis;
10395 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10396 TOKEN_STRING_INITIALIZER
10397 (struct cmd_config_l2_tunnel_en_dis_result,
10399 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10400 TOKEN_STRING_INITIALIZER
10401 (struct cmd_config_l2_tunnel_en_dis_result,
10403 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10404 TOKEN_STRING_INITIALIZER
10405 (struct cmd_config_l2_tunnel_en_dis_result,
10407 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10408 TOKEN_NUM_INITIALIZER
10409 (struct cmd_config_l2_tunnel_en_dis_result,
10411 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10412 TOKEN_STRING_INITIALIZER
10413 (struct cmd_config_l2_tunnel_en_dis_result,
10414 l2_tunnel, "l2-tunnel");
10415 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10416 TOKEN_STRING_INITIALIZER
10417 (struct cmd_config_l2_tunnel_en_dis_result,
10418 l2_tunnel_type, "E-tag");
10419 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10420 TOKEN_STRING_INITIALIZER
10421 (struct cmd_config_l2_tunnel_en_dis_result,
10422 en_dis, "enable#disable");
10424 /* enable/disable l2 tunnel for all ports */
10426 cmd_config_l2_tunnel_en_dis_all_parsed(
10427 void *parsed_result,
10428 __attribute__((unused)) struct cmdline *cl,
10429 __attribute__((unused)) void *data)
10431 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10432 struct rte_eth_l2_tunnel_conf entry;
10436 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10438 if (!strcmp("enable", res->en_dis))
10443 FOREACH_PORT(pid, ports) {
10444 rte_eth_dev_l2_tunnel_offload_set(pid,
10446 ETH_L2_TUNNEL_ENABLE_MASK,
10451 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10452 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10454 .help_str = "port config all l2-tunnel E-tag enable|disable",
10456 (void *)&cmd_config_l2_tunnel_en_dis_port,
10457 (void *)&cmd_config_l2_tunnel_en_dis_config,
10458 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10459 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10460 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10461 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10466 /* enable/disable l2 tunnel for a port */
10468 cmd_config_l2_tunnel_en_dis_specific_parsed(
10469 void *parsed_result,
10470 __attribute__((unused)) struct cmdline *cl,
10471 __attribute__((unused)) void *data)
10473 struct cmd_config_l2_tunnel_en_dis_result *res =
10475 struct rte_eth_l2_tunnel_conf entry;
10477 if (port_id_is_invalid(res->id, ENABLED_WARN))
10480 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10482 if (!strcmp("enable", res->en_dis))
10483 rte_eth_dev_l2_tunnel_offload_set(res->id,
10485 ETH_L2_TUNNEL_ENABLE_MASK,
10488 rte_eth_dev_l2_tunnel_offload_set(res->id,
10490 ETH_L2_TUNNEL_ENABLE_MASK,
10494 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10495 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10497 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10499 (void *)&cmd_config_l2_tunnel_en_dis_port,
10500 (void *)&cmd_config_l2_tunnel_en_dis_config,
10501 (void *)&cmd_config_l2_tunnel_en_dis_id,
10502 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10503 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10504 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10509 /* E-tag configuration */
10511 /* Common result structure for all E-tag configuration */
10512 struct cmd_config_e_tag_result {
10513 cmdline_fixed_string_t e_tag;
10514 cmdline_fixed_string_t set;
10515 cmdline_fixed_string_t insertion;
10516 cmdline_fixed_string_t stripping;
10517 cmdline_fixed_string_t forwarding;
10518 cmdline_fixed_string_t filter;
10519 cmdline_fixed_string_t add;
10520 cmdline_fixed_string_t del;
10521 cmdline_fixed_string_t on;
10522 cmdline_fixed_string_t off;
10523 cmdline_fixed_string_t on_off;
10524 cmdline_fixed_string_t port_tag_id;
10525 uint32_t port_tag_id_val;
10526 cmdline_fixed_string_t e_tag_id;
10527 uint16_t e_tag_id_val;
10528 cmdline_fixed_string_t dst_pool;
10529 uint8_t dst_pool_val;
10530 cmdline_fixed_string_t port;
10532 cmdline_fixed_string_t vf;
10536 /* Common CLI fields for all E-tag configuration */
10537 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10538 TOKEN_STRING_INITIALIZER
10539 (struct cmd_config_e_tag_result,
10541 cmdline_parse_token_string_t cmd_config_e_tag_set =
10542 TOKEN_STRING_INITIALIZER
10543 (struct cmd_config_e_tag_result,
10545 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10546 TOKEN_STRING_INITIALIZER
10547 (struct cmd_config_e_tag_result,
10548 insertion, "insertion");
10549 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10550 TOKEN_STRING_INITIALIZER
10551 (struct cmd_config_e_tag_result,
10552 stripping, "stripping");
10553 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10554 TOKEN_STRING_INITIALIZER
10555 (struct cmd_config_e_tag_result,
10556 forwarding, "forwarding");
10557 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10558 TOKEN_STRING_INITIALIZER
10559 (struct cmd_config_e_tag_result,
10561 cmdline_parse_token_string_t cmd_config_e_tag_add =
10562 TOKEN_STRING_INITIALIZER
10563 (struct cmd_config_e_tag_result,
10565 cmdline_parse_token_string_t cmd_config_e_tag_del =
10566 TOKEN_STRING_INITIALIZER
10567 (struct cmd_config_e_tag_result,
10569 cmdline_parse_token_string_t cmd_config_e_tag_on =
10570 TOKEN_STRING_INITIALIZER
10571 (struct cmd_config_e_tag_result,
10573 cmdline_parse_token_string_t cmd_config_e_tag_off =
10574 TOKEN_STRING_INITIALIZER
10575 (struct cmd_config_e_tag_result,
10577 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10578 TOKEN_STRING_INITIALIZER
10579 (struct cmd_config_e_tag_result,
10581 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10582 TOKEN_STRING_INITIALIZER
10583 (struct cmd_config_e_tag_result,
10584 port_tag_id, "port-tag-id");
10585 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10586 TOKEN_NUM_INITIALIZER
10587 (struct cmd_config_e_tag_result,
10588 port_tag_id_val, UINT32);
10589 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10590 TOKEN_STRING_INITIALIZER
10591 (struct cmd_config_e_tag_result,
10592 e_tag_id, "e-tag-id");
10593 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10594 TOKEN_NUM_INITIALIZER
10595 (struct cmd_config_e_tag_result,
10596 e_tag_id_val, UINT16);
10597 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10598 TOKEN_STRING_INITIALIZER
10599 (struct cmd_config_e_tag_result,
10600 dst_pool, "dst-pool");
10601 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10602 TOKEN_NUM_INITIALIZER
10603 (struct cmd_config_e_tag_result,
10604 dst_pool_val, UINT8);
10605 cmdline_parse_token_string_t cmd_config_e_tag_port =
10606 TOKEN_STRING_INITIALIZER
10607 (struct cmd_config_e_tag_result,
10609 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10610 TOKEN_NUM_INITIALIZER
10611 (struct cmd_config_e_tag_result,
10613 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10614 TOKEN_STRING_INITIALIZER
10615 (struct cmd_config_e_tag_result,
10617 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10618 TOKEN_NUM_INITIALIZER
10619 (struct cmd_config_e_tag_result,
10622 /* E-tag insertion configuration */
10624 cmd_config_e_tag_insertion_en_parsed(
10625 void *parsed_result,
10626 __attribute__((unused)) struct cmdline *cl,
10627 __attribute__((unused)) void *data)
10629 struct cmd_config_e_tag_result *res =
10631 struct rte_eth_l2_tunnel_conf entry;
10633 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10636 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10637 entry.tunnel_id = res->port_tag_id_val;
10638 entry.vf_id = res->vf_id;
10639 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10641 ETH_L2_TUNNEL_INSERTION_MASK,
10646 cmd_config_e_tag_insertion_dis_parsed(
10647 void *parsed_result,
10648 __attribute__((unused)) struct cmdline *cl,
10649 __attribute__((unused)) void *data)
10651 struct cmd_config_e_tag_result *res =
10653 struct rte_eth_l2_tunnel_conf entry;
10655 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10658 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10659 entry.vf_id = res->vf_id;
10661 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10663 ETH_L2_TUNNEL_INSERTION_MASK,
10667 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10668 .f = cmd_config_e_tag_insertion_en_parsed,
10670 .help_str = "E-tag ... : E-tag insertion enable",
10672 (void *)&cmd_config_e_tag_e_tag,
10673 (void *)&cmd_config_e_tag_set,
10674 (void *)&cmd_config_e_tag_insertion,
10675 (void *)&cmd_config_e_tag_on,
10676 (void *)&cmd_config_e_tag_port_tag_id,
10677 (void *)&cmd_config_e_tag_port_tag_id_val,
10678 (void *)&cmd_config_e_tag_port,
10679 (void *)&cmd_config_e_tag_port_id,
10680 (void *)&cmd_config_e_tag_vf,
10681 (void *)&cmd_config_e_tag_vf_id,
10686 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10687 .f = cmd_config_e_tag_insertion_dis_parsed,
10689 .help_str = "E-tag ... : E-tag insertion disable",
10691 (void *)&cmd_config_e_tag_e_tag,
10692 (void *)&cmd_config_e_tag_set,
10693 (void *)&cmd_config_e_tag_insertion,
10694 (void *)&cmd_config_e_tag_off,
10695 (void *)&cmd_config_e_tag_port,
10696 (void *)&cmd_config_e_tag_port_id,
10697 (void *)&cmd_config_e_tag_vf,
10698 (void *)&cmd_config_e_tag_vf_id,
10703 /* E-tag stripping configuration */
10705 cmd_config_e_tag_stripping_parsed(
10706 void *parsed_result,
10707 __attribute__((unused)) struct cmdline *cl,
10708 __attribute__((unused)) void *data)
10710 struct cmd_config_e_tag_result *res =
10712 struct rte_eth_l2_tunnel_conf entry;
10714 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10717 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10719 if (!strcmp(res->on_off, "on"))
10720 rte_eth_dev_l2_tunnel_offload_set
10723 ETH_L2_TUNNEL_STRIPPING_MASK,
10726 rte_eth_dev_l2_tunnel_offload_set
10729 ETH_L2_TUNNEL_STRIPPING_MASK,
10733 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10734 .f = cmd_config_e_tag_stripping_parsed,
10736 .help_str = "E-tag ... : E-tag stripping enable/disable",
10738 (void *)&cmd_config_e_tag_e_tag,
10739 (void *)&cmd_config_e_tag_set,
10740 (void *)&cmd_config_e_tag_stripping,
10741 (void *)&cmd_config_e_tag_on_off,
10742 (void *)&cmd_config_e_tag_port,
10743 (void *)&cmd_config_e_tag_port_id,
10748 /* E-tag forwarding configuration */
10750 cmd_config_e_tag_forwarding_parsed(
10751 void *parsed_result,
10752 __attribute__((unused)) struct cmdline *cl,
10753 __attribute__((unused)) void *data)
10755 struct cmd_config_e_tag_result *res = parsed_result;
10756 struct rte_eth_l2_tunnel_conf entry;
10758 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10761 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10763 if (!strcmp(res->on_off, "on"))
10764 rte_eth_dev_l2_tunnel_offload_set
10767 ETH_L2_TUNNEL_FORWARDING_MASK,
10770 rte_eth_dev_l2_tunnel_offload_set
10773 ETH_L2_TUNNEL_FORWARDING_MASK,
10777 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10778 .f = cmd_config_e_tag_forwarding_parsed,
10780 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10782 (void *)&cmd_config_e_tag_e_tag,
10783 (void *)&cmd_config_e_tag_set,
10784 (void *)&cmd_config_e_tag_forwarding,
10785 (void *)&cmd_config_e_tag_on_off,
10786 (void *)&cmd_config_e_tag_port,
10787 (void *)&cmd_config_e_tag_port_id,
10792 /* E-tag filter configuration */
10794 cmd_config_e_tag_filter_add_parsed(
10795 void *parsed_result,
10796 __attribute__((unused)) struct cmdline *cl,
10797 __attribute__((unused)) void *data)
10799 struct cmd_config_e_tag_result *res = parsed_result;
10800 struct rte_eth_l2_tunnel_conf entry;
10803 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10806 if (res->e_tag_id_val > 0x3fff) {
10807 printf("e-tag-id must be equal or less than 0x3fff.\n");
10811 ret = rte_eth_dev_filter_supported(res->port_id,
10812 RTE_ETH_FILTER_L2_TUNNEL);
10814 printf("E-tag filter is not supported on port %u.\n",
10819 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10820 entry.tunnel_id = res->e_tag_id_val;
10821 entry.pool = res->dst_pool_val;
10823 ret = rte_eth_dev_filter_ctrl(res->port_id,
10824 RTE_ETH_FILTER_L2_TUNNEL,
10825 RTE_ETH_FILTER_ADD,
10828 printf("E-tag filter programming error: (%s)\n",
10832 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10833 .f = cmd_config_e_tag_filter_add_parsed,
10835 .help_str = "E-tag ... : E-tag filter add",
10837 (void *)&cmd_config_e_tag_e_tag,
10838 (void *)&cmd_config_e_tag_set,
10839 (void *)&cmd_config_e_tag_filter,
10840 (void *)&cmd_config_e_tag_add,
10841 (void *)&cmd_config_e_tag_e_tag_id,
10842 (void *)&cmd_config_e_tag_e_tag_id_val,
10843 (void *)&cmd_config_e_tag_dst_pool,
10844 (void *)&cmd_config_e_tag_dst_pool_val,
10845 (void *)&cmd_config_e_tag_port,
10846 (void *)&cmd_config_e_tag_port_id,
10852 cmd_config_e_tag_filter_del_parsed(
10853 void *parsed_result,
10854 __attribute__((unused)) struct cmdline *cl,
10855 __attribute__((unused)) void *data)
10857 struct cmd_config_e_tag_result *res = parsed_result;
10858 struct rte_eth_l2_tunnel_conf entry;
10861 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10864 if (res->e_tag_id_val > 0x3fff) {
10865 printf("e-tag-id must be less than 0x3fff.\n");
10869 ret = rte_eth_dev_filter_supported(res->port_id,
10870 RTE_ETH_FILTER_L2_TUNNEL);
10872 printf("E-tag filter is not supported on port %u.\n",
10877 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10878 entry.tunnel_id = res->e_tag_id_val;
10880 ret = rte_eth_dev_filter_ctrl(res->port_id,
10881 RTE_ETH_FILTER_L2_TUNNEL,
10882 RTE_ETH_FILTER_DELETE,
10885 printf("E-tag filter programming error: (%s)\n",
10889 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10890 .f = cmd_config_e_tag_filter_del_parsed,
10892 .help_str = "E-tag ... : E-tag filter delete",
10894 (void *)&cmd_config_e_tag_e_tag,
10895 (void *)&cmd_config_e_tag_set,
10896 (void *)&cmd_config_e_tag_filter,
10897 (void *)&cmd_config_e_tag_del,
10898 (void *)&cmd_config_e_tag_e_tag_id,
10899 (void *)&cmd_config_e_tag_e_tag_id_val,
10900 (void *)&cmd_config_e_tag_port,
10901 (void *)&cmd_config_e_tag_port_id,
10906 /* vf vlan anti spoof configuration */
10908 /* Common result structure for vf vlan anti spoof */
10909 struct cmd_vf_vlan_anti_spoof_result {
10910 cmdline_fixed_string_t set;
10911 cmdline_fixed_string_t vf;
10912 cmdline_fixed_string_t vlan;
10913 cmdline_fixed_string_t antispoof;
10916 cmdline_fixed_string_t on_off;
10919 /* Common CLI fields for vf vlan anti spoof enable disable */
10920 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10921 TOKEN_STRING_INITIALIZER
10922 (struct cmd_vf_vlan_anti_spoof_result,
10924 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10925 TOKEN_STRING_INITIALIZER
10926 (struct cmd_vf_vlan_anti_spoof_result,
10928 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10929 TOKEN_STRING_INITIALIZER
10930 (struct cmd_vf_vlan_anti_spoof_result,
10932 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10933 TOKEN_STRING_INITIALIZER
10934 (struct cmd_vf_vlan_anti_spoof_result,
10935 antispoof, "antispoof");
10936 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10937 TOKEN_NUM_INITIALIZER
10938 (struct cmd_vf_vlan_anti_spoof_result,
10940 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10941 TOKEN_NUM_INITIALIZER
10942 (struct cmd_vf_vlan_anti_spoof_result,
10944 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10945 TOKEN_STRING_INITIALIZER
10946 (struct cmd_vf_vlan_anti_spoof_result,
10950 cmd_set_vf_vlan_anti_spoof_parsed(
10951 void *parsed_result,
10952 __attribute__((unused)) struct cmdline *cl,
10953 __attribute__((unused)) void *data)
10955 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10956 int ret = -ENOTSUP;
10958 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10960 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10963 #ifdef RTE_LIBRTE_IXGBE_PMD
10964 if (ret == -ENOTSUP)
10965 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10966 res->vf_id, is_on);
10968 #ifdef RTE_LIBRTE_I40E_PMD
10969 if (ret == -ENOTSUP)
10970 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10971 res->vf_id, is_on);
10978 printf("invalid vf_id %d\n", res->vf_id);
10981 printf("invalid port_id %d\n", res->port_id);
10984 printf("function not implemented\n");
10987 printf("programming error: (%s)\n", strerror(-ret));
10991 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10992 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10994 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10996 (void *)&cmd_vf_vlan_anti_spoof_set,
10997 (void *)&cmd_vf_vlan_anti_spoof_vf,
10998 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10999 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11000 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11001 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11002 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11007 /* vf mac anti spoof configuration */
11009 /* Common result structure for vf mac anti spoof */
11010 struct cmd_vf_mac_anti_spoof_result {
11011 cmdline_fixed_string_t set;
11012 cmdline_fixed_string_t vf;
11013 cmdline_fixed_string_t mac;
11014 cmdline_fixed_string_t antispoof;
11017 cmdline_fixed_string_t on_off;
11020 /* Common CLI fields for vf mac anti spoof enable disable */
11021 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11022 TOKEN_STRING_INITIALIZER
11023 (struct cmd_vf_mac_anti_spoof_result,
11025 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11026 TOKEN_STRING_INITIALIZER
11027 (struct cmd_vf_mac_anti_spoof_result,
11029 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11030 TOKEN_STRING_INITIALIZER
11031 (struct cmd_vf_mac_anti_spoof_result,
11033 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11034 TOKEN_STRING_INITIALIZER
11035 (struct cmd_vf_mac_anti_spoof_result,
11036 antispoof, "antispoof");
11037 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11038 TOKEN_NUM_INITIALIZER
11039 (struct cmd_vf_mac_anti_spoof_result,
11041 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11042 TOKEN_NUM_INITIALIZER
11043 (struct cmd_vf_mac_anti_spoof_result,
11045 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11046 TOKEN_STRING_INITIALIZER
11047 (struct cmd_vf_mac_anti_spoof_result,
11051 cmd_set_vf_mac_anti_spoof_parsed(
11052 void *parsed_result,
11053 __attribute__((unused)) struct cmdline *cl,
11054 __attribute__((unused)) void *data)
11056 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11057 int ret = -ENOTSUP;
11059 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11061 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11064 #ifdef RTE_LIBRTE_IXGBE_PMD
11065 if (ret == -ENOTSUP)
11066 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11067 res->vf_id, is_on);
11069 #ifdef RTE_LIBRTE_I40E_PMD
11070 if (ret == -ENOTSUP)
11071 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11072 res->vf_id, is_on);
11079 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11082 printf("invalid port_id %d\n", res->port_id);
11085 printf("function not implemented\n");
11088 printf("programming error: (%s)\n", strerror(-ret));
11092 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11093 .f = cmd_set_vf_mac_anti_spoof_parsed,
11095 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11097 (void *)&cmd_vf_mac_anti_spoof_set,
11098 (void *)&cmd_vf_mac_anti_spoof_vf,
11099 (void *)&cmd_vf_mac_anti_spoof_mac,
11100 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11101 (void *)&cmd_vf_mac_anti_spoof_port_id,
11102 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11103 (void *)&cmd_vf_mac_anti_spoof_on_off,
11108 /* vf vlan strip queue configuration */
11110 /* Common result structure for vf mac anti spoof */
11111 struct cmd_vf_vlan_stripq_result {
11112 cmdline_fixed_string_t set;
11113 cmdline_fixed_string_t vf;
11114 cmdline_fixed_string_t vlan;
11115 cmdline_fixed_string_t stripq;
11118 cmdline_fixed_string_t on_off;
11121 /* Common CLI fields for vf vlan strip enable disable */
11122 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11123 TOKEN_STRING_INITIALIZER
11124 (struct cmd_vf_vlan_stripq_result,
11126 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11127 TOKEN_STRING_INITIALIZER
11128 (struct cmd_vf_vlan_stripq_result,
11130 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11131 TOKEN_STRING_INITIALIZER
11132 (struct cmd_vf_vlan_stripq_result,
11134 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11135 TOKEN_STRING_INITIALIZER
11136 (struct cmd_vf_vlan_stripq_result,
11138 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11139 TOKEN_NUM_INITIALIZER
11140 (struct cmd_vf_vlan_stripq_result,
11142 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11143 TOKEN_NUM_INITIALIZER
11144 (struct cmd_vf_vlan_stripq_result,
11146 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11147 TOKEN_STRING_INITIALIZER
11148 (struct cmd_vf_vlan_stripq_result,
11152 cmd_set_vf_vlan_stripq_parsed(
11153 void *parsed_result,
11154 __attribute__((unused)) struct cmdline *cl,
11155 __attribute__((unused)) void *data)
11157 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11158 int ret = -ENOTSUP;
11160 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11162 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11165 #ifdef RTE_LIBRTE_IXGBE_PMD
11166 if (ret == -ENOTSUP)
11167 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11168 res->vf_id, is_on);
11170 #ifdef RTE_LIBRTE_I40E_PMD
11171 if (ret == -ENOTSUP)
11172 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11173 res->vf_id, is_on);
11180 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11183 printf("invalid port_id %d\n", res->port_id);
11186 printf("function not implemented\n");
11189 printf("programming error: (%s)\n", strerror(-ret));
11193 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11194 .f = cmd_set_vf_vlan_stripq_parsed,
11196 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11198 (void *)&cmd_vf_vlan_stripq_set,
11199 (void *)&cmd_vf_vlan_stripq_vf,
11200 (void *)&cmd_vf_vlan_stripq_vlan,
11201 (void *)&cmd_vf_vlan_stripq_stripq,
11202 (void *)&cmd_vf_vlan_stripq_port_id,
11203 (void *)&cmd_vf_vlan_stripq_vf_id,
11204 (void *)&cmd_vf_vlan_stripq_on_off,
11209 /* vf vlan insert configuration */
11211 /* Common result structure for vf vlan insert */
11212 struct cmd_vf_vlan_insert_result {
11213 cmdline_fixed_string_t set;
11214 cmdline_fixed_string_t vf;
11215 cmdline_fixed_string_t vlan;
11216 cmdline_fixed_string_t insert;
11222 /* Common CLI fields for vf vlan insert enable disable */
11223 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11224 TOKEN_STRING_INITIALIZER
11225 (struct cmd_vf_vlan_insert_result,
11227 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11228 TOKEN_STRING_INITIALIZER
11229 (struct cmd_vf_vlan_insert_result,
11231 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11232 TOKEN_STRING_INITIALIZER
11233 (struct cmd_vf_vlan_insert_result,
11235 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11236 TOKEN_STRING_INITIALIZER
11237 (struct cmd_vf_vlan_insert_result,
11239 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11240 TOKEN_NUM_INITIALIZER
11241 (struct cmd_vf_vlan_insert_result,
11243 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11244 TOKEN_NUM_INITIALIZER
11245 (struct cmd_vf_vlan_insert_result,
11247 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11248 TOKEN_NUM_INITIALIZER
11249 (struct cmd_vf_vlan_insert_result,
11253 cmd_set_vf_vlan_insert_parsed(
11254 void *parsed_result,
11255 __attribute__((unused)) struct cmdline *cl,
11256 __attribute__((unused)) void *data)
11258 struct cmd_vf_vlan_insert_result *res = parsed_result;
11259 int ret = -ENOTSUP;
11261 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11264 #ifdef RTE_LIBRTE_IXGBE_PMD
11265 if (ret == -ENOTSUP)
11266 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11269 #ifdef RTE_LIBRTE_I40E_PMD
11270 if (ret == -ENOTSUP)
11271 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11279 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11282 printf("invalid port_id %d\n", res->port_id);
11285 printf("function not implemented\n");
11288 printf("programming error: (%s)\n", strerror(-ret));
11292 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11293 .f = cmd_set_vf_vlan_insert_parsed,
11295 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11297 (void *)&cmd_vf_vlan_insert_set,
11298 (void *)&cmd_vf_vlan_insert_vf,
11299 (void *)&cmd_vf_vlan_insert_vlan,
11300 (void *)&cmd_vf_vlan_insert_insert,
11301 (void *)&cmd_vf_vlan_insert_port_id,
11302 (void *)&cmd_vf_vlan_insert_vf_id,
11303 (void *)&cmd_vf_vlan_insert_vlan_id,
11308 /* tx loopback configuration */
11310 /* Common result structure for tx loopback */
11311 struct cmd_tx_loopback_result {
11312 cmdline_fixed_string_t set;
11313 cmdline_fixed_string_t tx;
11314 cmdline_fixed_string_t loopback;
11316 cmdline_fixed_string_t on_off;
11319 /* Common CLI fields for tx loopback enable disable */
11320 cmdline_parse_token_string_t cmd_tx_loopback_set =
11321 TOKEN_STRING_INITIALIZER
11322 (struct cmd_tx_loopback_result,
11324 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11325 TOKEN_STRING_INITIALIZER
11326 (struct cmd_tx_loopback_result,
11328 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11329 TOKEN_STRING_INITIALIZER
11330 (struct cmd_tx_loopback_result,
11331 loopback, "loopback");
11332 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11333 TOKEN_NUM_INITIALIZER
11334 (struct cmd_tx_loopback_result,
11336 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11337 TOKEN_STRING_INITIALIZER
11338 (struct cmd_tx_loopback_result,
11342 cmd_set_tx_loopback_parsed(
11343 void *parsed_result,
11344 __attribute__((unused)) struct cmdline *cl,
11345 __attribute__((unused)) void *data)
11347 struct cmd_tx_loopback_result *res = parsed_result;
11348 int ret = -ENOTSUP;
11350 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11352 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11355 #ifdef RTE_LIBRTE_IXGBE_PMD
11356 if (ret == -ENOTSUP)
11357 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11359 #ifdef RTE_LIBRTE_I40E_PMD
11360 if (ret == -ENOTSUP)
11361 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11368 printf("invalid is_on %d\n", is_on);
11371 printf("invalid port_id %d\n", res->port_id);
11374 printf("function not implemented\n");
11377 printf("programming error: (%s)\n", strerror(-ret));
11381 cmdline_parse_inst_t cmd_set_tx_loopback = {
11382 .f = cmd_set_tx_loopback_parsed,
11384 .help_str = "set tx loopback <port_id> on|off",
11386 (void *)&cmd_tx_loopback_set,
11387 (void *)&cmd_tx_loopback_tx,
11388 (void *)&cmd_tx_loopback_loopback,
11389 (void *)&cmd_tx_loopback_port_id,
11390 (void *)&cmd_tx_loopback_on_off,
11395 #ifdef RTE_LIBRTE_IXGBE_PMD
11396 /* all queues drop enable configuration */
11398 /* Common result structure for all queues drop enable */
11399 struct cmd_all_queues_drop_en_result {
11400 cmdline_fixed_string_t set;
11401 cmdline_fixed_string_t all;
11402 cmdline_fixed_string_t queues;
11403 cmdline_fixed_string_t drop;
11405 cmdline_fixed_string_t on_off;
11408 /* Common CLI fields for tx loopback enable disable */
11409 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11410 TOKEN_STRING_INITIALIZER
11411 (struct cmd_all_queues_drop_en_result,
11413 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11414 TOKEN_STRING_INITIALIZER
11415 (struct cmd_all_queues_drop_en_result,
11417 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11418 TOKEN_STRING_INITIALIZER
11419 (struct cmd_all_queues_drop_en_result,
11421 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11422 TOKEN_STRING_INITIALIZER
11423 (struct cmd_all_queues_drop_en_result,
11425 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11426 TOKEN_NUM_INITIALIZER
11427 (struct cmd_all_queues_drop_en_result,
11429 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11430 TOKEN_STRING_INITIALIZER
11431 (struct cmd_all_queues_drop_en_result,
11435 cmd_set_all_queues_drop_en_parsed(
11436 void *parsed_result,
11437 __attribute__((unused)) struct cmdline *cl,
11438 __attribute__((unused)) void *data)
11440 struct cmd_all_queues_drop_en_result *res = parsed_result;
11442 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11444 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11447 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11452 printf("invalid is_on %d\n", is_on);
11455 printf("invalid port_id %d\n", res->port_id);
11458 printf("function not implemented\n");
11461 printf("programming error: (%s)\n", strerror(-ret));
11465 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11466 .f = cmd_set_all_queues_drop_en_parsed,
11468 .help_str = "set all queues drop <port_id> on|off",
11470 (void *)&cmd_all_queues_drop_en_set,
11471 (void *)&cmd_all_queues_drop_en_all,
11472 (void *)&cmd_all_queues_drop_en_queues,
11473 (void *)&cmd_all_queues_drop_en_drop,
11474 (void *)&cmd_all_queues_drop_en_port_id,
11475 (void *)&cmd_all_queues_drop_en_on_off,
11480 /* vf split drop enable configuration */
11482 /* Common result structure for vf split drop enable */
11483 struct cmd_vf_split_drop_en_result {
11484 cmdline_fixed_string_t set;
11485 cmdline_fixed_string_t vf;
11486 cmdline_fixed_string_t split;
11487 cmdline_fixed_string_t drop;
11490 cmdline_fixed_string_t on_off;
11493 /* Common CLI fields for vf split drop enable disable */
11494 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11495 TOKEN_STRING_INITIALIZER
11496 (struct cmd_vf_split_drop_en_result,
11498 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11499 TOKEN_STRING_INITIALIZER
11500 (struct cmd_vf_split_drop_en_result,
11502 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11503 TOKEN_STRING_INITIALIZER
11504 (struct cmd_vf_split_drop_en_result,
11506 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11507 TOKEN_STRING_INITIALIZER
11508 (struct cmd_vf_split_drop_en_result,
11510 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11511 TOKEN_NUM_INITIALIZER
11512 (struct cmd_vf_split_drop_en_result,
11514 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11515 TOKEN_NUM_INITIALIZER
11516 (struct cmd_vf_split_drop_en_result,
11518 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11519 TOKEN_STRING_INITIALIZER
11520 (struct cmd_vf_split_drop_en_result,
11524 cmd_set_vf_split_drop_en_parsed(
11525 void *parsed_result,
11526 __attribute__((unused)) struct cmdline *cl,
11527 __attribute__((unused)) void *data)
11529 struct cmd_vf_split_drop_en_result *res = parsed_result;
11531 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11533 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11536 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11542 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11545 printf("invalid port_id %d\n", res->port_id);
11548 printf("programming error: (%s)\n", strerror(-ret));
11552 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11553 .f = cmd_set_vf_split_drop_en_parsed,
11555 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11557 (void *)&cmd_vf_split_drop_en_set,
11558 (void *)&cmd_vf_split_drop_en_vf,
11559 (void *)&cmd_vf_split_drop_en_split,
11560 (void *)&cmd_vf_split_drop_en_drop,
11561 (void *)&cmd_vf_split_drop_en_port_id,
11562 (void *)&cmd_vf_split_drop_en_vf_id,
11563 (void *)&cmd_vf_split_drop_en_on_off,
11569 /* vf mac address configuration */
11571 /* Common result structure for vf mac address */
11572 struct cmd_set_vf_mac_addr_result {
11573 cmdline_fixed_string_t set;
11574 cmdline_fixed_string_t vf;
11575 cmdline_fixed_string_t mac;
11576 cmdline_fixed_string_t addr;
11579 struct ether_addr mac_addr;
11583 /* Common CLI fields for vf split drop enable disable */
11584 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11585 TOKEN_STRING_INITIALIZER
11586 (struct cmd_set_vf_mac_addr_result,
11588 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11589 TOKEN_STRING_INITIALIZER
11590 (struct cmd_set_vf_mac_addr_result,
11592 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11593 TOKEN_STRING_INITIALIZER
11594 (struct cmd_set_vf_mac_addr_result,
11596 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11597 TOKEN_STRING_INITIALIZER
11598 (struct cmd_set_vf_mac_addr_result,
11600 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11601 TOKEN_NUM_INITIALIZER
11602 (struct cmd_set_vf_mac_addr_result,
11604 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11605 TOKEN_NUM_INITIALIZER
11606 (struct cmd_set_vf_mac_addr_result,
11608 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11609 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11613 cmd_set_vf_mac_addr_parsed(
11614 void *parsed_result,
11615 __attribute__((unused)) struct cmdline *cl,
11616 __attribute__((unused)) void *data)
11618 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11619 int ret = -ENOTSUP;
11621 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11624 #ifdef RTE_LIBRTE_IXGBE_PMD
11625 if (ret == -ENOTSUP)
11626 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11629 #ifdef RTE_LIBRTE_I40E_PMD
11630 if (ret == -ENOTSUP)
11631 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11639 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11642 printf("invalid port_id %d\n", res->port_id);
11645 printf("function not implemented\n");
11648 printf("programming error: (%s)\n", strerror(-ret));
11652 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11653 .f = cmd_set_vf_mac_addr_parsed,
11655 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11657 (void *)&cmd_set_vf_mac_addr_set,
11658 (void *)&cmd_set_vf_mac_addr_vf,
11659 (void *)&cmd_set_vf_mac_addr_mac,
11660 (void *)&cmd_set_vf_mac_addr_addr,
11661 (void *)&cmd_set_vf_mac_addr_port_id,
11662 (void *)&cmd_set_vf_mac_addr_vf_id,
11663 (void *)&cmd_set_vf_mac_addr_mac_addr,
11668 #ifdef RTE_LIBRTE_IXGBE_PMD
11669 /* MACsec configuration */
11671 /* Common result structure for MACsec offload enable */
11672 struct cmd_macsec_offload_on_result {
11673 cmdline_fixed_string_t set;
11674 cmdline_fixed_string_t macsec;
11675 cmdline_fixed_string_t offload;
11677 cmdline_fixed_string_t on;
11678 cmdline_fixed_string_t encrypt;
11679 cmdline_fixed_string_t en_on_off;
11680 cmdline_fixed_string_t replay_protect;
11681 cmdline_fixed_string_t rp_on_off;
11684 /* Common CLI fields for MACsec offload disable */
11685 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11686 TOKEN_STRING_INITIALIZER
11687 (struct cmd_macsec_offload_on_result,
11689 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11690 TOKEN_STRING_INITIALIZER
11691 (struct cmd_macsec_offload_on_result,
11693 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11694 TOKEN_STRING_INITIALIZER
11695 (struct cmd_macsec_offload_on_result,
11696 offload, "offload");
11697 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11698 TOKEN_NUM_INITIALIZER
11699 (struct cmd_macsec_offload_on_result,
11701 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11702 TOKEN_STRING_INITIALIZER
11703 (struct cmd_macsec_offload_on_result,
11705 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11706 TOKEN_STRING_INITIALIZER
11707 (struct cmd_macsec_offload_on_result,
11708 encrypt, "encrypt");
11709 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11710 TOKEN_STRING_INITIALIZER
11711 (struct cmd_macsec_offload_on_result,
11712 en_on_off, "on#off");
11713 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11714 TOKEN_STRING_INITIALIZER
11715 (struct cmd_macsec_offload_on_result,
11716 replay_protect, "replay-protect");
11717 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11718 TOKEN_STRING_INITIALIZER
11719 (struct cmd_macsec_offload_on_result,
11720 rp_on_off, "on#off");
11723 cmd_set_macsec_offload_on_parsed(
11724 void *parsed_result,
11725 __attribute__((unused)) struct cmdline *cl,
11726 __attribute__((unused)) void *data)
11728 struct cmd_macsec_offload_on_result *res = parsed_result;
11730 portid_t port_id = res->port_id;
11731 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11732 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11734 if (port_id_is_invalid(port_id, ENABLED_WARN))
11737 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11738 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11744 printf("invalid port_id %d\n", port_id);
11747 printf("programming error: (%s)\n", strerror(-ret));
11751 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11752 .f = cmd_set_macsec_offload_on_parsed,
11754 .help_str = "set macsec offload <port_id> on "
11755 "encrypt on|off replay-protect on|off",
11757 (void *)&cmd_macsec_offload_on_set,
11758 (void *)&cmd_macsec_offload_on_macsec,
11759 (void *)&cmd_macsec_offload_on_offload,
11760 (void *)&cmd_macsec_offload_on_port_id,
11761 (void *)&cmd_macsec_offload_on_on,
11762 (void *)&cmd_macsec_offload_on_encrypt,
11763 (void *)&cmd_macsec_offload_on_en_on_off,
11764 (void *)&cmd_macsec_offload_on_replay_protect,
11765 (void *)&cmd_macsec_offload_on_rp_on_off,
11770 /* Common result structure for MACsec offload disable */
11771 struct cmd_macsec_offload_off_result {
11772 cmdline_fixed_string_t set;
11773 cmdline_fixed_string_t macsec;
11774 cmdline_fixed_string_t offload;
11776 cmdline_fixed_string_t off;
11779 /* Common CLI fields for MACsec offload disable */
11780 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11781 TOKEN_STRING_INITIALIZER
11782 (struct cmd_macsec_offload_off_result,
11784 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11785 TOKEN_STRING_INITIALIZER
11786 (struct cmd_macsec_offload_off_result,
11788 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11789 TOKEN_STRING_INITIALIZER
11790 (struct cmd_macsec_offload_off_result,
11791 offload, "offload");
11792 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11793 TOKEN_NUM_INITIALIZER
11794 (struct cmd_macsec_offload_off_result,
11796 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11797 TOKEN_STRING_INITIALIZER
11798 (struct cmd_macsec_offload_off_result,
11802 cmd_set_macsec_offload_off_parsed(
11803 void *parsed_result,
11804 __attribute__((unused)) struct cmdline *cl,
11805 __attribute__((unused)) void *data)
11807 struct cmd_macsec_offload_off_result *res = parsed_result;
11809 portid_t port_id = res->port_id;
11811 if (port_id_is_invalid(port_id, ENABLED_WARN))
11814 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11815 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11821 printf("invalid port_id %d\n", port_id);
11824 printf("programming error: (%s)\n", strerror(-ret));
11828 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11829 .f = cmd_set_macsec_offload_off_parsed,
11831 .help_str = "set macsec offload <port_id> off",
11833 (void *)&cmd_macsec_offload_off_set,
11834 (void *)&cmd_macsec_offload_off_macsec,
11835 (void *)&cmd_macsec_offload_off_offload,
11836 (void *)&cmd_macsec_offload_off_port_id,
11837 (void *)&cmd_macsec_offload_off_off,
11842 /* Common result structure for MACsec secure connection configure */
11843 struct cmd_macsec_sc_result {
11844 cmdline_fixed_string_t set;
11845 cmdline_fixed_string_t macsec;
11846 cmdline_fixed_string_t sc;
11847 cmdline_fixed_string_t tx_rx;
11849 struct ether_addr mac;
11853 /* Common CLI fields for MACsec secure connection configure */
11854 cmdline_parse_token_string_t cmd_macsec_sc_set =
11855 TOKEN_STRING_INITIALIZER
11856 (struct cmd_macsec_sc_result,
11858 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11859 TOKEN_STRING_INITIALIZER
11860 (struct cmd_macsec_sc_result,
11862 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11863 TOKEN_STRING_INITIALIZER
11864 (struct cmd_macsec_sc_result,
11866 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11867 TOKEN_STRING_INITIALIZER
11868 (struct cmd_macsec_sc_result,
11870 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11871 TOKEN_NUM_INITIALIZER
11872 (struct cmd_macsec_sc_result,
11874 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11875 TOKEN_ETHERADDR_INITIALIZER
11876 (struct cmd_macsec_sc_result,
11878 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11879 TOKEN_NUM_INITIALIZER
11880 (struct cmd_macsec_sc_result,
11884 cmd_set_macsec_sc_parsed(
11885 void *parsed_result,
11886 __attribute__((unused)) struct cmdline *cl,
11887 __attribute__((unused)) void *data)
11889 struct cmd_macsec_sc_result *res = parsed_result;
11891 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11894 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11895 res->mac.addr_bytes) :
11896 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11897 res->mac.addr_bytes, res->pi);
11902 printf("invalid port_id %d\n", res->port_id);
11905 printf("programming error: (%s)\n", strerror(-ret));
11909 cmdline_parse_inst_t cmd_set_macsec_sc = {
11910 .f = cmd_set_macsec_sc_parsed,
11912 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11914 (void *)&cmd_macsec_sc_set,
11915 (void *)&cmd_macsec_sc_macsec,
11916 (void *)&cmd_macsec_sc_sc,
11917 (void *)&cmd_macsec_sc_tx_rx,
11918 (void *)&cmd_macsec_sc_port_id,
11919 (void *)&cmd_macsec_sc_mac,
11920 (void *)&cmd_macsec_sc_pi,
11925 /* Common result structure for MACsec secure connection configure */
11926 struct cmd_macsec_sa_result {
11927 cmdline_fixed_string_t set;
11928 cmdline_fixed_string_t macsec;
11929 cmdline_fixed_string_t sa;
11930 cmdline_fixed_string_t tx_rx;
11935 cmdline_fixed_string_t key;
11938 /* Common CLI fields for MACsec secure connection configure */
11939 cmdline_parse_token_string_t cmd_macsec_sa_set =
11940 TOKEN_STRING_INITIALIZER
11941 (struct cmd_macsec_sa_result,
11943 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11944 TOKEN_STRING_INITIALIZER
11945 (struct cmd_macsec_sa_result,
11947 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11948 TOKEN_STRING_INITIALIZER
11949 (struct cmd_macsec_sa_result,
11951 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11952 TOKEN_STRING_INITIALIZER
11953 (struct cmd_macsec_sa_result,
11955 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11956 TOKEN_NUM_INITIALIZER
11957 (struct cmd_macsec_sa_result,
11959 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11960 TOKEN_NUM_INITIALIZER
11961 (struct cmd_macsec_sa_result,
11963 cmdline_parse_token_num_t cmd_macsec_sa_an =
11964 TOKEN_NUM_INITIALIZER
11965 (struct cmd_macsec_sa_result,
11967 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11968 TOKEN_NUM_INITIALIZER
11969 (struct cmd_macsec_sa_result,
11971 cmdline_parse_token_string_t cmd_macsec_sa_key =
11972 TOKEN_STRING_INITIALIZER
11973 (struct cmd_macsec_sa_result,
11977 cmd_set_macsec_sa_parsed(
11978 void *parsed_result,
11979 __attribute__((unused)) struct cmdline *cl,
11980 __attribute__((unused)) void *data)
11982 struct cmd_macsec_sa_result *res = parsed_result;
11984 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11985 uint8_t key[16] = { 0 };
11991 key_len = strlen(res->key) / 2;
11995 for (i = 0; i < key_len; i++) {
11996 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11999 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12002 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12006 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12007 res->idx, res->an, res->pn, key) :
12008 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12009 res->idx, res->an, res->pn, key);
12014 printf("invalid idx %d or an %d\n", res->idx, res->an);
12017 printf("invalid port_id %d\n", res->port_id);
12020 printf("programming error: (%s)\n", strerror(-ret));
12024 cmdline_parse_inst_t cmd_set_macsec_sa = {
12025 .f = cmd_set_macsec_sa_parsed,
12027 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12029 (void *)&cmd_macsec_sa_set,
12030 (void *)&cmd_macsec_sa_macsec,
12031 (void *)&cmd_macsec_sa_sa,
12032 (void *)&cmd_macsec_sa_tx_rx,
12033 (void *)&cmd_macsec_sa_port_id,
12034 (void *)&cmd_macsec_sa_idx,
12035 (void *)&cmd_macsec_sa_an,
12036 (void *)&cmd_macsec_sa_pn,
12037 (void *)&cmd_macsec_sa_key,
12043 /* VF unicast promiscuous mode configuration */
12045 /* Common result structure for VF unicast promiscuous mode */
12046 struct cmd_vf_promisc_result {
12047 cmdline_fixed_string_t set;
12048 cmdline_fixed_string_t vf;
12049 cmdline_fixed_string_t promisc;
12052 cmdline_fixed_string_t on_off;
12055 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12056 cmdline_parse_token_string_t cmd_vf_promisc_set =
12057 TOKEN_STRING_INITIALIZER
12058 (struct cmd_vf_promisc_result,
12060 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12061 TOKEN_STRING_INITIALIZER
12062 (struct cmd_vf_promisc_result,
12064 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12065 TOKEN_STRING_INITIALIZER
12066 (struct cmd_vf_promisc_result,
12067 promisc, "promisc");
12068 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12069 TOKEN_NUM_INITIALIZER
12070 (struct cmd_vf_promisc_result,
12072 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12073 TOKEN_NUM_INITIALIZER
12074 (struct cmd_vf_promisc_result,
12076 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12077 TOKEN_STRING_INITIALIZER
12078 (struct cmd_vf_promisc_result,
12082 cmd_set_vf_promisc_parsed(
12083 void *parsed_result,
12084 __attribute__((unused)) struct cmdline *cl,
12085 __attribute__((unused)) void *data)
12087 struct cmd_vf_promisc_result *res = parsed_result;
12088 int ret = -ENOTSUP;
12090 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12092 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12095 #ifdef RTE_LIBRTE_I40E_PMD
12096 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12097 res->vf_id, is_on);
12104 printf("invalid vf_id %d\n", res->vf_id);
12107 printf("invalid port_id %d\n", res->port_id);
12110 printf("function not implemented\n");
12113 printf("programming error: (%s)\n", strerror(-ret));
12117 cmdline_parse_inst_t cmd_set_vf_promisc = {
12118 .f = cmd_set_vf_promisc_parsed,
12120 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12121 "Set unicast promiscuous mode for a VF from the PF",
12123 (void *)&cmd_vf_promisc_set,
12124 (void *)&cmd_vf_promisc_vf,
12125 (void *)&cmd_vf_promisc_promisc,
12126 (void *)&cmd_vf_promisc_port_id,
12127 (void *)&cmd_vf_promisc_vf_id,
12128 (void *)&cmd_vf_promisc_on_off,
12133 /* VF multicast promiscuous mode configuration */
12135 /* Common result structure for VF multicast promiscuous mode */
12136 struct cmd_vf_allmulti_result {
12137 cmdline_fixed_string_t set;
12138 cmdline_fixed_string_t vf;
12139 cmdline_fixed_string_t allmulti;
12142 cmdline_fixed_string_t on_off;
12145 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12146 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12147 TOKEN_STRING_INITIALIZER
12148 (struct cmd_vf_allmulti_result,
12150 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12151 TOKEN_STRING_INITIALIZER
12152 (struct cmd_vf_allmulti_result,
12154 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12155 TOKEN_STRING_INITIALIZER
12156 (struct cmd_vf_allmulti_result,
12157 allmulti, "allmulti");
12158 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12159 TOKEN_NUM_INITIALIZER
12160 (struct cmd_vf_allmulti_result,
12162 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12163 TOKEN_NUM_INITIALIZER
12164 (struct cmd_vf_allmulti_result,
12166 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12167 TOKEN_STRING_INITIALIZER
12168 (struct cmd_vf_allmulti_result,
12172 cmd_set_vf_allmulti_parsed(
12173 void *parsed_result,
12174 __attribute__((unused)) struct cmdline *cl,
12175 __attribute__((unused)) void *data)
12177 struct cmd_vf_allmulti_result *res = parsed_result;
12178 int ret = -ENOTSUP;
12180 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12182 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12185 #ifdef RTE_LIBRTE_I40E_PMD
12186 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12187 res->vf_id, is_on);
12194 printf("invalid vf_id %d\n", res->vf_id);
12197 printf("invalid port_id %d\n", res->port_id);
12200 printf("function not implemented\n");
12203 printf("programming error: (%s)\n", strerror(-ret));
12207 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12208 .f = cmd_set_vf_allmulti_parsed,
12210 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12211 "Set multicast promiscuous mode for a VF from the PF",
12213 (void *)&cmd_vf_allmulti_set,
12214 (void *)&cmd_vf_allmulti_vf,
12215 (void *)&cmd_vf_allmulti_allmulti,
12216 (void *)&cmd_vf_allmulti_port_id,
12217 (void *)&cmd_vf_allmulti_vf_id,
12218 (void *)&cmd_vf_allmulti_on_off,
12223 /* vf broadcast mode configuration */
12225 /* Common result structure for vf broadcast */
12226 struct cmd_set_vf_broadcast_result {
12227 cmdline_fixed_string_t set;
12228 cmdline_fixed_string_t vf;
12229 cmdline_fixed_string_t broadcast;
12232 cmdline_fixed_string_t on_off;
12235 /* Common CLI fields for vf broadcast enable disable */
12236 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12237 TOKEN_STRING_INITIALIZER
12238 (struct cmd_set_vf_broadcast_result,
12240 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12241 TOKEN_STRING_INITIALIZER
12242 (struct cmd_set_vf_broadcast_result,
12244 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12245 TOKEN_STRING_INITIALIZER
12246 (struct cmd_set_vf_broadcast_result,
12247 broadcast, "broadcast");
12248 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12249 TOKEN_NUM_INITIALIZER
12250 (struct cmd_set_vf_broadcast_result,
12252 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12253 TOKEN_NUM_INITIALIZER
12254 (struct cmd_set_vf_broadcast_result,
12256 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12257 TOKEN_STRING_INITIALIZER
12258 (struct cmd_set_vf_broadcast_result,
12262 cmd_set_vf_broadcast_parsed(
12263 void *parsed_result,
12264 __attribute__((unused)) struct cmdline *cl,
12265 __attribute__((unused)) void *data)
12267 struct cmd_set_vf_broadcast_result *res = parsed_result;
12268 int ret = -ENOTSUP;
12270 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12272 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12275 #ifdef RTE_LIBRTE_I40E_PMD
12276 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12277 res->vf_id, is_on);
12284 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12287 printf("invalid port_id %d\n", res->port_id);
12290 printf("function not implemented\n");
12293 printf("programming error: (%s)\n", strerror(-ret));
12297 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12298 .f = cmd_set_vf_broadcast_parsed,
12300 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12302 (void *)&cmd_set_vf_broadcast_set,
12303 (void *)&cmd_set_vf_broadcast_vf,
12304 (void *)&cmd_set_vf_broadcast_broadcast,
12305 (void *)&cmd_set_vf_broadcast_port_id,
12306 (void *)&cmd_set_vf_broadcast_vf_id,
12307 (void *)&cmd_set_vf_broadcast_on_off,
12312 /* vf vlan tag configuration */
12314 /* Common result structure for vf vlan tag */
12315 struct cmd_set_vf_vlan_tag_result {
12316 cmdline_fixed_string_t set;
12317 cmdline_fixed_string_t vf;
12318 cmdline_fixed_string_t vlan;
12319 cmdline_fixed_string_t tag;
12322 cmdline_fixed_string_t on_off;
12325 /* Common CLI fields for vf vlan tag enable disable */
12326 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12327 TOKEN_STRING_INITIALIZER
12328 (struct cmd_set_vf_vlan_tag_result,
12330 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12331 TOKEN_STRING_INITIALIZER
12332 (struct cmd_set_vf_vlan_tag_result,
12334 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12335 TOKEN_STRING_INITIALIZER
12336 (struct cmd_set_vf_vlan_tag_result,
12338 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12339 TOKEN_STRING_INITIALIZER
12340 (struct cmd_set_vf_vlan_tag_result,
12342 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12343 TOKEN_NUM_INITIALIZER
12344 (struct cmd_set_vf_vlan_tag_result,
12346 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12347 TOKEN_NUM_INITIALIZER
12348 (struct cmd_set_vf_vlan_tag_result,
12350 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12351 TOKEN_STRING_INITIALIZER
12352 (struct cmd_set_vf_vlan_tag_result,
12356 cmd_set_vf_vlan_tag_parsed(
12357 void *parsed_result,
12358 __attribute__((unused)) struct cmdline *cl,
12359 __attribute__((unused)) void *data)
12361 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12362 int ret = -ENOTSUP;
12364 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12366 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12369 #ifdef RTE_LIBRTE_I40E_PMD
12370 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12371 res->vf_id, is_on);
12378 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12381 printf("invalid port_id %d\n", res->port_id);
12384 printf("function not implemented\n");
12387 printf("programming error: (%s)\n", strerror(-ret));
12391 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12392 .f = cmd_set_vf_vlan_tag_parsed,
12394 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12396 (void *)&cmd_set_vf_vlan_tag_set,
12397 (void *)&cmd_set_vf_vlan_tag_vf,
12398 (void *)&cmd_set_vf_vlan_tag_vlan,
12399 (void *)&cmd_set_vf_vlan_tag_tag,
12400 (void *)&cmd_set_vf_vlan_tag_port_id,
12401 (void *)&cmd_set_vf_vlan_tag_vf_id,
12402 (void *)&cmd_set_vf_vlan_tag_on_off,
12407 /* Common definition of VF and TC TX bandwidth configuration */
12408 struct cmd_vf_tc_bw_result {
12409 cmdline_fixed_string_t set;
12410 cmdline_fixed_string_t vf;
12411 cmdline_fixed_string_t tx;
12412 cmdline_fixed_string_t max_bw;
12418 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12419 TOKEN_STRING_INITIALIZER
12420 (struct cmd_vf_tc_bw_result,
12422 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12423 TOKEN_STRING_INITIALIZER
12424 (struct cmd_vf_tc_bw_result,
12426 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12427 TOKEN_STRING_INITIALIZER
12428 (struct cmd_vf_tc_bw_result,
12430 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12431 TOKEN_STRING_INITIALIZER
12432 (struct cmd_vf_tc_bw_result,
12433 max_bw, "max-bandwidth");
12434 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12435 TOKEN_NUM_INITIALIZER
12436 (struct cmd_vf_tc_bw_result,
12438 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12439 TOKEN_NUM_INITIALIZER
12440 (struct cmd_vf_tc_bw_result,
12442 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12443 TOKEN_NUM_INITIALIZER
12444 (struct cmd_vf_tc_bw_result,
12447 /* VF max bandwidth setting */
12449 cmd_vf_max_bw_parsed(
12450 void *parsed_result,
12451 __attribute__((unused)) struct cmdline *cl,
12452 __attribute__((unused)) void *data)
12454 struct cmd_vf_tc_bw_result *res = parsed_result;
12455 int ret = -ENOTSUP;
12457 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12460 #ifdef RTE_LIBRTE_I40E_PMD
12461 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12462 res->vf_id, res->bw);
12469 printf("invalid vf_id %d or bandwidth %d\n",
12470 res->vf_id, res->bw);
12473 printf("invalid port_id %d\n", res->port_id);
12476 printf("function not implemented\n");
12479 printf("programming error: (%s)\n", strerror(-ret));
12483 cmdline_parse_inst_t cmd_vf_max_bw = {
12484 .f = cmd_vf_max_bw_parsed,
12486 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12488 (void *)&cmd_vf_tc_bw_set,
12489 (void *)&cmd_vf_tc_bw_vf,
12490 (void *)&cmd_vf_tc_bw_tx,
12491 (void *)&cmd_vf_tc_bw_max_bw,
12492 (void *)&cmd_vf_tc_bw_port_id,
12493 (void *)&cmd_vf_tc_bw_vf_id,
12494 (void *)&cmd_vf_tc_bw_bw,
12499 /* ******************************************************************************** */
12501 /* list of instructions */
12502 cmdline_parse_ctx_t main_ctx[] = {
12503 (cmdline_parse_inst_t *)&cmd_help_brief,
12504 (cmdline_parse_inst_t *)&cmd_help_long,
12505 (cmdline_parse_inst_t *)&cmd_quit,
12506 (cmdline_parse_inst_t *)&cmd_showport,
12507 (cmdline_parse_inst_t *)&cmd_showqueue,
12508 (cmdline_parse_inst_t *)&cmd_showportall,
12509 (cmdline_parse_inst_t *)&cmd_showcfg,
12510 (cmdline_parse_inst_t *)&cmd_start,
12511 (cmdline_parse_inst_t *)&cmd_start_tx_first,
12512 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
12513 (cmdline_parse_inst_t *)&cmd_set_link_up,
12514 (cmdline_parse_inst_t *)&cmd_set_link_down,
12515 (cmdline_parse_inst_t *)&cmd_reset,
12516 (cmdline_parse_inst_t *)&cmd_set_numbers,
12517 (cmdline_parse_inst_t *)&cmd_set_txpkts,
12518 (cmdline_parse_inst_t *)&cmd_set_txsplit,
12519 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
12520 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
12521 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
12522 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
12523 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
12524 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
12525 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
12526 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
12527 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
12528 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
12529 (cmdline_parse_inst_t *)&cmd_set_link_check,
12530 #ifdef RTE_NIC_BYPASS
12531 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
12532 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
12533 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
12534 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
12536 #ifdef RTE_LIBRTE_PMD_BOND
12537 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
12538 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
12539 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
12540 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
12541 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
12542 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
12543 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
12544 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
12545 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
12547 (cmdline_parse_inst_t *)&cmd_vlan_offload,
12548 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
12549 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
12550 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
12551 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
12552 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
12553 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
12554 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
12555 (cmdline_parse_inst_t *)&cmd_csum_set,
12556 (cmdline_parse_inst_t *)&cmd_csum_show,
12557 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
12558 (cmdline_parse_inst_t *)&cmd_tso_set,
12559 (cmdline_parse_inst_t *)&cmd_tso_show,
12560 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
12561 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
12562 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
12563 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
12564 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
12565 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
12566 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
12567 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
12568 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
12569 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
12570 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
12571 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
12572 (cmdline_parse_inst_t *)&cmd_config_dcb,
12573 (cmdline_parse_inst_t *)&cmd_read_reg,
12574 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
12575 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
12576 (cmdline_parse_inst_t *)&cmd_write_reg,
12577 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
12578 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
12579 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
12580 (cmdline_parse_inst_t *)&cmd_stop,
12581 (cmdline_parse_inst_t *)&cmd_mac_addr,
12582 (cmdline_parse_inst_t *)&cmd_set_qmap,
12583 (cmdline_parse_inst_t *)&cmd_operate_port,
12584 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
12585 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
12586 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
12587 (cmdline_parse_inst_t *)&cmd_config_speed_all,
12588 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
12589 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
12590 (cmdline_parse_inst_t *)&cmd_config_mtu,
12591 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
12592 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
12593 (cmdline_parse_inst_t *)&cmd_config_rss,
12594 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
12595 (cmdline_parse_inst_t *)&cmd_config_txqflags,
12596 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
12597 (cmdline_parse_inst_t *)&cmd_showport_reta,
12598 (cmdline_parse_inst_t *)&cmd_config_burst,
12599 (cmdline_parse_inst_t *)&cmd_config_thresh,
12600 (cmdline_parse_inst_t *)&cmd_config_threshold,
12601 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
12602 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
12603 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
12604 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
12605 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
12606 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
12607 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
12608 (cmdline_parse_inst_t *)&cmd_global_config,
12609 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
12610 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
12611 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
12612 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
12613 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
12614 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
12615 (cmdline_parse_inst_t *)&cmd_dump,
12616 (cmdline_parse_inst_t *)&cmd_dump_one,
12617 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
12618 (cmdline_parse_inst_t *)&cmd_syn_filter,
12619 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
12620 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
12621 (cmdline_parse_inst_t *)&cmd_flex_filter,
12622 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
12623 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
12624 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
12625 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
12626 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
12627 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
12628 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
12629 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
12630 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
12631 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
12632 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
12633 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
12634 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
12635 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
12636 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
12637 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
12638 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
12639 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
12640 (cmdline_parse_inst_t *)&cmd_flow,
12641 (cmdline_parse_inst_t *)&cmd_mcast_addr,
12642 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
12643 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
12644 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
12645 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
12646 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
12647 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
12648 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
12649 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
12650 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
12651 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
12652 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
12653 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
12654 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
12655 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
12656 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
12657 #ifdef RTE_LIBRTE_IXGBE_PMD
12658 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
12659 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
12660 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
12661 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
12662 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
12663 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
12664 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
12665 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
12666 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
12668 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
12669 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
12670 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
12671 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
12672 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
12673 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
12674 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
12678 /* prompt function, called from main on MASTER lcore */
12682 /* initialize non-constant commands */
12683 cmd_set_fwd_mode_init();
12684 cmd_set_fwd_retry_mode_init();
12686 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
12687 if (testpmd_cl == NULL)
12689 cmdline_interact(testpmd_cl);
12690 cmdline_stdin_exit(testpmd_cl);
12696 if (testpmd_cl != NULL)
12697 cmdline_quit(testpmd_cl);
12701 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
12703 if (id == (portid_t)RTE_PORT_ALL) {
12706 FOREACH_PORT(pid, ports) {
12707 /* check if need_reconfig has been set to 1 */
12708 if (ports[pid].need_reconfig == 0)
12709 ports[pid].need_reconfig = dev;
12710 /* check if need_reconfig_queues has been set to 1 */
12711 if (ports[pid].need_reconfig_queues == 0)
12712 ports[pid].need_reconfig_queues = queue;
12714 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
12715 /* check if need_reconfig has been set to 1 */
12716 if (ports[id].need_reconfig == 0)
12717 ports[id].need_reconfig = dev;
12718 /* check if need_reconfig_queues has been set to 1 */
12719 if (ports[id].need_reconfig_queues == 0)
12720 ports[id].need_reconfig_queues = queue;