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 "vlan set filter (on|off) (port_id)\n"
319 " Set the VLAN filter on a port.\n\n"
321 "vlan set qinq (on|off) (port_id)\n"
322 " Set the VLAN QinQ (extended queue in queue)"
325 "vlan set (inner|outer) tpid (value) (port_id)\n"
326 " Set the VLAN TPID for Packet Filtering on"
329 "rx_vlan add (vlan_id|all) (port_id)\n"
330 " Add a vlan_id, or all identifiers, to the set"
331 " of VLAN identifiers filtered by port_id.\n\n"
333 "rx_vlan rm (vlan_id|all) (port_id)\n"
334 " Remove a vlan_id, or all identifiers, from the set"
335 " of VLAN identifiers filtered by port_id.\n\n"
337 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
338 " Add a vlan_id, to the set of VLAN identifiers"
339 "filtered for VF(s) from port_id.\n\n"
341 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
342 " Remove a vlan_id, to the set of VLAN identifiers"
343 "filtered for VF(s) from port_id.\n\n"
345 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
346 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
347 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
348 " add a tunnel filter of a port.\n\n"
350 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
351 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
352 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
353 " remove a tunnel filter of a port.\n\n"
355 "rx_vxlan_port add (udp_port) (port_id)\n"
356 " Add an UDP port for VXLAN packet filter on a port\n\n"
358 "rx_vxlan_port rm (udp_port) (port_id)\n"
359 " Remove an UDP port for VXLAN packet filter on a port\n\n"
361 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
362 " Set hardware insertion of VLAN IDs (single or double VLAN "
363 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
365 "tx_vlan set pvid port_id vlan_id (on|off)\n"
366 " Set port based TX VLAN insertion.\n\n"
368 "tx_vlan reset (port_id)\n"
369 " Disable hardware insertion of a VLAN header in"
370 " packets sent on a port.\n\n"
372 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
373 " Select hardware or software calculation of the"
374 " checksum when transmitting a packet using the"
375 " csum forward engine.\n"
376 " ip|udp|tcp|sctp always concern the inner layer.\n"
377 " outer-ip concerns the outer IP layer in"
378 " case the packet is recognized as a tunnel packet by"
379 " the forward engine (vxlan, gre and ipip are supported)\n"
380 " Please check the NIC datasheet for HW limits.\n\n"
382 "csum parse-tunnel (on|off) (tx_port_id)\n"
383 " If disabled, treat tunnel packets as non-tunneled"
384 " packets (treat inner headers as payload). The port\n"
385 " argument is the port used for TX in csum forward"
388 "csum show (port_id)\n"
389 " Display tx checksum offload configuration\n\n"
391 "tso set (segsize) (portid)\n"
392 " Enable TCP Segmentation Offload in csum forward"
394 " Please check the NIC datasheet for HW limits.\n\n"
397 " Display the status of TCP Segmentation Offload.\n\n"
400 " Set packet forwarding mode.\n\n"
402 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
403 " Add a MAC address on port_id.\n\n"
405 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
406 " Remove a MAC address from port_id.\n\n"
408 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
409 " Set the default MAC address for port_id.\n\n"
411 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
412 " Add a MAC address for a VF on the port.\n\n"
414 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
415 " Set the MAC address for a VF from the PF.\n\n"
417 "set port (port_id) uta (mac_address|all) (on|off)\n"
418 " Add/Remove a or all unicast hash filter(s)"
421 "set promisc (port_id|all) (on|off)\n"
422 " Set the promiscuous mode on port_id, or all.\n\n"
424 "set allmulti (port_id|all) (on|off)\n"
425 " Set the allmulti mode on port_id, or all.\n\n"
427 "set vf promisc (port_id) (vf_id) (on|off)\n"
428 " Set unicast promiscuous mode for a VF from the PF.\n\n"
430 "set vf allmulti (port_id) (vf_id) (on|off)\n"
431 " Set multicast promiscuous mode for a VF from the PF.\n\n"
433 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
434 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
435 " (on|off) autoneg (on|off) (port_id)\n"
436 "set flow_ctrl rx (on|off) (portid)\n"
437 "set flow_ctrl tx (on|off) (portid)\n"
438 "set flow_ctrl high_water (high_water) (portid)\n"
439 "set flow_ctrl low_water (low_water) (portid)\n"
440 "set flow_ctrl pause_time (pause_time) (portid)\n"
441 "set flow_ctrl send_xon (send_xon) (portid)\n"
442 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
443 "set flow_ctrl autoneg (on|off) (port_id)\n"
444 " Set the link flow control parameter on a port.\n\n"
446 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
447 " (low_water) (pause_time) (priority) (port_id)\n"
448 " Set the priority flow control parameter on a"
451 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
452 " Set statistics mapping (qmapping 0..15) for RX/TX"
454 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
455 " on port 0 to mapping 5.\n\n"
457 "set port (port_id) vf (vf_id) rx|tx on|off\n"
458 " Enable/Disable a VF receive/tranmit from a port\n\n"
460 "set port (port_id) vf (vf_id) (mac_addr)"
461 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
462 " Add/Remove unicast or multicast MAC addr filter"
465 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
467 " AUPE:accepts untagged VLAN;"
468 "ROPE:accept unicast hash\n\n"
469 " BAM:accepts broadcast packets;"
470 "MPE:accepts all multicast packets\n\n"
471 " Enable/Disable a VF receive mode of a port\n\n"
473 "set port (port_id) queue (queue_id) rate (rate_num)\n"
474 " Set rate limit for a queue of a port\n\n"
476 "set port (port_id) vf (vf_id) rate (rate_num) "
477 "queue_mask (queue_mask_value)\n"
478 " Set rate limit for queues in VF of a port\n\n"
480 "set port (port_id) mirror-rule (rule_id)"
481 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
482 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
483 " Set pool or vlan type mirror rule on a port.\n"
484 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
485 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
488 "set port (port_id) mirror-rule (rule_id)"
489 " (uplink-mirror|downlink-mirror) dst-pool"
490 " (pool_id) (on|off)\n"
491 " Set uplink or downlink type mirror rule on a port.\n"
492 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
493 " 0 on' enable mirror income traffic to pool 0.\n\n"
495 "reset port (port_id) mirror-rule (rule_id)\n"
496 " Reset a mirror rule.\n\n"
498 "set flush_rx (on|off)\n"
499 " Flush (default) or don't flush RX streams before"
500 " forwarding. Mainly used with PCAP drivers.\n\n"
502 #ifdef RTE_NIC_BYPASS
503 "set bypass mode (normal|bypass|isolate) (port_id)\n"
504 " Set the bypass mode for the lowest port on bypass enabled"
507 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
508 "mode (normal|bypass|isolate) (port_id)\n"
509 " Set the event required to initiate specified bypass mode for"
510 " the lowest port on a bypass enabled NIC where:\n"
511 " timeout = enable bypass after watchdog timeout.\n"
512 " os_on = enable bypass when OS/board is powered on.\n"
513 " os_off = enable bypass when OS/board is powered off.\n"
514 " power_on = enable bypass when power supply is turned on.\n"
515 " power_off = enable bypass when power supply is turned off."
518 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
519 " Set the bypass watchdog timeout to 'n' seconds"
520 " where 0 = instant.\n\n"
522 "show bypass config (port_id)\n"
523 " Show the bypass configuration for a bypass enabled NIC"
524 " using the lowest port on the NIC.\n\n"
526 #ifdef RTE_LIBRTE_PMD_BOND
527 "create bonded device (mode) (socket)\n"
528 " Create a new bonded device with specific bonding mode and socket.\n\n"
530 "add bonding slave (slave_id) (port_id)\n"
531 " Add a slave device to a bonded device.\n\n"
533 "remove bonding slave (slave_id) (port_id)\n"
534 " Remove a slave device from a bonded device.\n\n"
536 "set bonding mode (value) (port_id)\n"
537 " Set the bonding mode on a bonded device.\n\n"
539 "set bonding primary (slave_id) (port_id)\n"
540 " Set the primary slave for a bonded device.\n\n"
542 "show bonding config (port_id)\n"
543 " Show the bonding config for port_id.\n\n"
545 "set bonding mac_addr (port_id) (address)\n"
546 " Set the MAC address of a bonded device.\n\n"
548 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
549 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
551 "set bonding mon_period (port_id) (value)\n"
552 " Set the bonding link status monitoring polling period in ms.\n\n"
554 "set link-up port (port_id)\n"
555 " Set link up for a port.\n\n"
557 "set link-down port (port_id)\n"
558 " Set link down for a port.\n\n"
560 "E-tag set insertion on port-tag-id (value)"
561 " port (port_id) vf (vf_id)\n"
562 " Enable E-tag insertion for a VF on a port\n\n"
564 "E-tag set insertion off port (port_id) vf (vf_id)\n"
565 " Disable E-tag insertion for a VF on a port\n\n"
567 "E-tag set stripping (on|off) port (port_id)\n"
568 " Enable/disable E-tag stripping on a port\n\n"
570 "E-tag set forwarding (on|off) port (port_id)\n"
571 " Enable/disable E-tag based forwarding"
574 "E-tag set filter add e-tag-id (value) dst-pool"
575 " (pool_id) port (port_id)\n"
576 " Add an E-tag forwarding filter on a port\n\n"
578 "E-tag set filter del e-tag-id (value) port (port_id)\n"
579 " Delete an E-tag forwarding filter on a port\n\n"
581 , list_pkt_forwarding_modes()
585 if (show_all || !strcmp(res->section, "ports")) {
591 "----------------\n\n"
593 "port start (port_id|all)\n"
594 " Start all ports or port_id.\n\n"
596 "port stop (port_id|all)\n"
597 " Stop all ports or port_id.\n\n"
599 "port close (port_id|all)\n"
600 " Close all ports or port_id.\n\n"
602 "port attach (ident)\n"
603 " Attach physical or virtual dev by pci address or virtual device name\n\n"
605 "port detach (port_id)\n"
606 " Detach physical or virtual dev by port_id\n\n"
608 "port config (port_id|all)"
609 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
610 " duplex (half|full|auto)\n"
611 " Set speed and duplex for all ports or port_id\n\n"
613 "port config all (rxq|txq|rxd|txd) (value)\n"
614 " Set number for rxq/txq/rxd/txd.\n\n"
616 "port config all max-pkt-len (value)\n"
617 " Set the max packet length.\n\n"
619 "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
620 "hw-vlan-strip|hw-vlan-extend|drop-en)"
622 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
625 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n"
626 " Set the RSS mode.\n\n"
628 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
629 " Set the RSS redirection table.\n\n"
631 "port config (port_id) dcb vt (on|off) (traffic_class)"
633 " Set the DCB mode.\n\n"
635 "port config all burst (value)\n"
636 " Set the number of packets per burst.\n\n"
638 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
640 " Set the ring prefetch/host/writeback threshold"
641 " for tx/rx queue.\n\n"
643 "port config all (txfreet|txrst|rxfreet) (value)\n"
644 " Set free threshold for rx/tx, or set"
645 " tx rs bit threshold.\n\n"
646 "port config mtu X value\n"
647 " Set the MTU of port X to a given value\n\n"
649 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
650 " Start/stop a rx/tx queue of port X. Only take effect"
651 " when port X is started\n\n"
653 "port config (port_id|all) l2-tunnel E-tag ether-type"
655 " Set the value of E-tag ether-type.\n\n"
657 "port config (port_id|all) l2-tunnel E-tag"
658 " (enable|disable)\n"
659 " Enable/disable the E-tag support.\n\n"
663 if (show_all || !strcmp(res->section, "registers")) {
671 "read reg (port_id) (address)\n"
672 " Display value of a port register.\n\n"
674 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
675 " Display a port register bit field.\n\n"
677 "read regbit (port_id) (address) (bit_x)\n"
678 " Display a single port register bit.\n\n"
680 "write reg (port_id) (address) (value)\n"
681 " Set value of a port register.\n\n"
683 "write regfield (port_id) (address) (bit_x) (bit_y)"
685 " Set bit field of a port register.\n\n"
687 "write regbit (port_id) (address) (bit_x) (value)\n"
688 " Set single bit value of a port register.\n\n"
691 if (show_all || !strcmp(res->section, "filters")) {
699 "ethertype_filter (port_id) (add|del)"
700 " (mac_addr|mac_ignr) (mac_address) ethertype"
701 " (ether_type) (drop|fwd) queue (queue_id)\n"
702 " Add/Del an ethertype filter.\n\n"
704 "2tuple_filter (port_id) (add|del)"
705 " dst_port (dst_port_value) protocol (protocol_value)"
706 " mask (mask_value) tcp_flags (tcp_flags_value)"
707 " priority (prio_value) queue (queue_id)\n"
708 " Add/Del a 2tuple filter.\n\n"
710 "5tuple_filter (port_id) (add|del)"
711 " dst_ip (dst_address) src_ip (src_address)"
712 " dst_port (dst_port_value) src_port (src_port_value)"
713 " protocol (protocol_value)"
714 " mask (mask_value) tcp_flags (tcp_flags_value)"
715 " priority (prio_value) queue (queue_id)\n"
716 " Add/Del a 5tuple filter.\n\n"
718 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
719 " Add/Del syn filter.\n\n"
721 "flex_filter (port_id) (add|del) len (len_value)"
722 " bytes (bytes_value) mask (mask_value)"
723 " priority (prio_value) queue (queue_id)\n"
724 " Add/Del a flex filter.\n\n"
726 "flow_director_filter (port_id) mode IP (add|del|update)"
727 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
728 " src (src_ip_address) dst (dst_ip_address)"
729 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
730 " vlan (vlan_value) flexbytes (flexbytes_value)"
731 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
732 " fd_id (fd_id_value)\n"
733 " Add/Del an IP type flow director filter.\n\n"
735 "flow_director_filter (port_id) mode IP (add|del|update)"
736 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
737 " src (src_ip_address) (src_port)"
738 " dst (dst_ip_address) (dst_port)"
739 " tos (tos_value) ttl (ttl_value)"
740 " vlan (vlan_value) flexbytes (flexbytes_value)"
741 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
742 " fd_id (fd_id_value)\n"
743 " Add/Del an UDP/TCP type flow director filter.\n\n"
745 "flow_director_filter (port_id) mode IP (add|del|update)"
746 " flow (ipv4-sctp|ipv6-sctp)"
747 " src (src_ip_address) (src_port)"
748 " dst (dst_ip_address) (dst_port)"
749 " tag (verification_tag) "
750 " tos (tos_value) ttl (ttl_value)"
752 " flexbytes (flexbytes_value) (drop|fwd)"
753 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
754 " Add/Del a SCTP type flow director filter.\n\n"
756 "flow_director_filter (port_id) mode IP (add|del|update)"
757 " flow l2_payload ether (ethertype)"
758 " flexbytes (flexbytes_value) (drop|fwd)"
759 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
760 " Add/Del a l2 payload type flow director filter.\n\n"
762 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
763 " mac (mac_address) vlan (vlan_value)"
764 " flexbytes (flexbytes_value) (drop|fwd)"
765 " queue (queue_id) fd_id (fd_id_value)\n"
766 " Add/Del a MAC-VLAN flow director filter.\n\n"
768 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
769 " mac (mac_address) vlan (vlan_value)"
770 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
771 " flexbytes (flexbytes_value) (drop|fwd)"
772 " queue (queue_id) fd_id (fd_id_value)\n"
773 " Add/Del a Tunnel flow director filter.\n\n"
775 "flush_flow_director (port_id)\n"
776 " Flush all flow director entries of a device.\n\n"
778 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
779 " src_mask (ipv4_src) (ipv6_src) (src_port)"
780 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
781 " Set flow director IP mask.\n\n"
783 "flow_director_mask (port_id) mode MAC-VLAN"
784 " vlan (vlan_value)\n"
785 " Set flow director MAC-VLAN mask.\n\n"
787 "flow_director_mask (port_id) mode Tunnel"
788 " vlan (vlan_value) mac (mac_value)"
789 " tunnel-type (tunnel_type_value)"
790 " tunnel-id (tunnel_id_value)\n"
791 " Set flow director Tunnel mask.\n\n"
793 "flow_director_flex_mask (port_id)"
794 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
795 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
797 " Configure mask of flex payload.\n\n"
799 "flow_director_flex_payload (port_id)"
800 " (raw|l2|l3|l4) (config)\n"
801 " Configure flex payload selection.\n\n"
803 "get_sym_hash_ena_per_port (port_id)\n"
804 " get symmetric hash enable configuration per port.\n\n"
806 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
807 " set symmetric hash enable configuration per port"
808 " to enable or disable.\n\n"
810 "get_hash_global_config (port_id)\n"
811 " Get the global configurations of hash filters.\n\n"
813 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
814 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
815 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
816 " (enable|disable)\n"
817 " Set the global configurations of hash filters.\n\n"
819 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
820 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
821 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
822 "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
823 "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
824 "ipv6-next-header|udp-src-port|udp-dst-port|"
825 "tcp-src-port|tcp-dst-port|sctp-src-port|"
826 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
827 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
828 "fld-8th|none) (select|add)\n"
829 " Set the input set for hash.\n\n"
831 "set_fdir_input_set (port_id) "
832 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
833 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
834 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
835 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
836 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
837 "udp-dst-port|tcp-src-port|tcp-dst-port|"
838 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
840 " Set the input set for FDir.\n\n"
842 "flow validate {port_id}"
843 " [group {group_id}] [priority {level}]"
844 " [ingress] [egress]"
845 " pattern {item} [/ {item} [...]] / end"
846 " actions {action} [/ {action} [...]] / end\n"
847 " Check whether a flow rule can be created.\n\n"
849 "flow create {port_id}"
850 " [group {group_id}] [priority {level}]"
851 " [ingress] [egress]"
852 " pattern {item} [/ {item} [...]] / end"
853 " actions {action} [/ {action} [...]] / end\n"
854 " Create a flow rule.\n\n"
856 "flow destroy {port_id} rule {rule_id} [...]\n"
857 " Destroy specific flow rules.\n\n"
859 "flow flush {port_id}\n"
860 " Destroy all flow rules.\n\n"
862 "flow query {port_id} {rule_id} {action}\n"
863 " Query an existing flow rule.\n\n"
865 "flow list {port_id} [group {group_id}] [...]\n"
866 " List existing flow rules sorted by priority,"
867 " filtered by group identifiers.\n\n"
872 cmdline_parse_token_string_t cmd_help_long_help =
873 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
875 cmdline_parse_token_string_t cmd_help_long_section =
876 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
877 "all#control#display#config#"
878 "ports#registers#filters");
880 cmdline_parse_inst_t cmd_help_long = {
881 .f = cmd_help_long_parsed,
883 .help_str = "help all|control|display|config|ports|register|filters: "
886 (void *)&cmd_help_long_help,
887 (void *)&cmd_help_long_section,
893 /* *** start/stop/close all ports *** */
894 struct cmd_operate_port_result {
895 cmdline_fixed_string_t keyword;
896 cmdline_fixed_string_t name;
897 cmdline_fixed_string_t value;
900 static void cmd_operate_port_parsed(void *parsed_result,
901 __attribute__((unused)) struct cmdline *cl,
902 __attribute__((unused)) void *data)
904 struct cmd_operate_port_result *res = parsed_result;
906 if (!strcmp(res->name, "start"))
907 start_port(RTE_PORT_ALL);
908 else if (!strcmp(res->name, "stop"))
909 stop_port(RTE_PORT_ALL);
910 else if (!strcmp(res->name, "close"))
911 close_port(RTE_PORT_ALL);
913 printf("Unknown parameter\n");
916 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
917 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
919 cmdline_parse_token_string_t cmd_operate_port_all_port =
920 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
922 cmdline_parse_token_string_t cmd_operate_port_all_all =
923 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
925 cmdline_parse_inst_t cmd_operate_port = {
926 .f = cmd_operate_port_parsed,
928 .help_str = "port start|stop|close all: Start/Stop/Close all ports",
930 (void *)&cmd_operate_port_all_cmd,
931 (void *)&cmd_operate_port_all_port,
932 (void *)&cmd_operate_port_all_all,
937 /* *** start/stop/close specific port *** */
938 struct cmd_operate_specific_port_result {
939 cmdline_fixed_string_t keyword;
940 cmdline_fixed_string_t name;
944 static void cmd_operate_specific_port_parsed(void *parsed_result,
945 __attribute__((unused)) struct cmdline *cl,
946 __attribute__((unused)) void *data)
948 struct cmd_operate_specific_port_result *res = parsed_result;
950 if (!strcmp(res->name, "start"))
951 start_port(res->value);
952 else if (!strcmp(res->name, "stop"))
953 stop_port(res->value);
954 else if (!strcmp(res->name, "close"))
955 close_port(res->value);
957 printf("Unknown parameter\n");
960 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
961 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
963 cmdline_parse_token_string_t cmd_operate_specific_port_port =
964 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
965 name, "start#stop#close");
966 cmdline_parse_token_num_t cmd_operate_specific_port_id =
967 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
970 cmdline_parse_inst_t cmd_operate_specific_port = {
971 .f = cmd_operate_specific_port_parsed,
973 .help_str = "port start|stop|close <port_id>: Start/Stop/Close port_id",
975 (void *)&cmd_operate_specific_port_cmd,
976 (void *)&cmd_operate_specific_port_port,
977 (void *)&cmd_operate_specific_port_id,
982 /* *** attach a specified port *** */
983 struct cmd_operate_attach_port_result {
984 cmdline_fixed_string_t port;
985 cmdline_fixed_string_t keyword;
986 cmdline_fixed_string_t identifier;
989 static void cmd_operate_attach_port_parsed(void *parsed_result,
990 __attribute__((unused)) struct cmdline *cl,
991 __attribute__((unused)) void *data)
993 struct cmd_operate_attach_port_result *res = parsed_result;
995 if (!strcmp(res->keyword, "attach"))
996 attach_port(res->identifier);
998 printf("Unknown parameter\n");
1001 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1002 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1004 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1005 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1007 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1008 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1011 cmdline_parse_inst_t cmd_operate_attach_port = {
1012 .f = cmd_operate_attach_port_parsed,
1014 .help_str = "port attach <identifier>: "
1015 "(identifier: pci address or virtual dev name)",
1017 (void *)&cmd_operate_attach_port_port,
1018 (void *)&cmd_operate_attach_port_keyword,
1019 (void *)&cmd_operate_attach_port_identifier,
1024 /* *** detach a specified port *** */
1025 struct cmd_operate_detach_port_result {
1026 cmdline_fixed_string_t port;
1027 cmdline_fixed_string_t keyword;
1031 static void cmd_operate_detach_port_parsed(void *parsed_result,
1032 __attribute__((unused)) struct cmdline *cl,
1033 __attribute__((unused)) void *data)
1035 struct cmd_operate_detach_port_result *res = parsed_result;
1037 if (!strcmp(res->keyword, "detach"))
1038 detach_port(res->port_id);
1040 printf("Unknown parameter\n");
1043 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1044 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1046 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1047 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1049 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1050 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1053 cmdline_parse_inst_t cmd_operate_detach_port = {
1054 .f = cmd_operate_detach_port_parsed,
1056 .help_str = "port detach <port_id>",
1058 (void *)&cmd_operate_detach_port_port,
1059 (void *)&cmd_operate_detach_port_keyword,
1060 (void *)&cmd_operate_detach_port_port_id,
1065 /* *** configure speed for all ports *** */
1066 struct cmd_config_speed_all {
1067 cmdline_fixed_string_t port;
1068 cmdline_fixed_string_t keyword;
1069 cmdline_fixed_string_t all;
1070 cmdline_fixed_string_t item1;
1071 cmdline_fixed_string_t item2;
1072 cmdline_fixed_string_t value1;
1073 cmdline_fixed_string_t value2;
1077 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1082 if (!strcmp(duplexstr, "half")) {
1083 duplex = ETH_LINK_HALF_DUPLEX;
1084 } else if (!strcmp(duplexstr, "full")) {
1085 duplex = ETH_LINK_FULL_DUPLEX;
1086 } else if (!strcmp(duplexstr, "auto")) {
1087 duplex = ETH_LINK_FULL_DUPLEX;
1089 printf("Unknown duplex parameter\n");
1093 if (!strcmp(speedstr, "10")) {
1094 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1095 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1096 } else if (!strcmp(speedstr, "100")) {
1097 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1098 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1100 if (duplex != ETH_LINK_FULL_DUPLEX) {
1101 printf("Invalid speed/duplex parameters\n");
1104 if (!strcmp(speedstr, "1000")) {
1105 *speed = ETH_LINK_SPEED_1G;
1106 } else if (!strcmp(speedstr, "10000")) {
1107 *speed = ETH_LINK_SPEED_10G;
1108 } else if (!strcmp(speedstr, "25000")) {
1109 *speed = ETH_LINK_SPEED_25G;
1110 } else if (!strcmp(speedstr, "40000")) {
1111 *speed = ETH_LINK_SPEED_40G;
1112 } else if (!strcmp(speedstr, "50000")) {
1113 *speed = ETH_LINK_SPEED_50G;
1114 } else if (!strcmp(speedstr, "100000")) {
1115 *speed = ETH_LINK_SPEED_100G;
1116 } else if (!strcmp(speedstr, "auto")) {
1117 *speed = ETH_LINK_SPEED_AUTONEG;
1119 printf("Unknown speed parameter\n");
1128 cmd_config_speed_all_parsed(void *parsed_result,
1129 __attribute__((unused)) struct cmdline *cl,
1130 __attribute__((unused)) void *data)
1132 struct cmd_config_speed_all *res = parsed_result;
1133 uint32_t link_speed;
1136 if (!all_ports_stopped()) {
1137 printf("Please stop all ports first\n");
1141 if (parse_and_check_speed_duplex(res->value1, res->value2,
1145 FOREACH_PORT(pid, ports) {
1146 ports[pid].dev_conf.link_speeds = link_speed;
1149 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1152 cmdline_parse_token_string_t cmd_config_speed_all_port =
1153 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1154 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1155 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1157 cmdline_parse_token_string_t cmd_config_speed_all_all =
1158 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1159 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1160 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1161 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1162 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1163 "10#100#1000#10000#25000#40000#50000#100000#auto");
1164 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1165 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1166 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1167 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1170 cmdline_parse_inst_t cmd_config_speed_all = {
1171 .f = cmd_config_speed_all_parsed,
1173 .help_str = "port config all speed "
1174 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1177 (void *)&cmd_config_speed_all_port,
1178 (void *)&cmd_config_speed_all_keyword,
1179 (void *)&cmd_config_speed_all_all,
1180 (void *)&cmd_config_speed_all_item1,
1181 (void *)&cmd_config_speed_all_value1,
1182 (void *)&cmd_config_speed_all_item2,
1183 (void *)&cmd_config_speed_all_value2,
1188 /* *** configure speed for specific port *** */
1189 struct cmd_config_speed_specific {
1190 cmdline_fixed_string_t port;
1191 cmdline_fixed_string_t keyword;
1193 cmdline_fixed_string_t item1;
1194 cmdline_fixed_string_t item2;
1195 cmdline_fixed_string_t value1;
1196 cmdline_fixed_string_t value2;
1200 cmd_config_speed_specific_parsed(void *parsed_result,
1201 __attribute__((unused)) struct cmdline *cl,
1202 __attribute__((unused)) void *data)
1204 struct cmd_config_speed_specific *res = parsed_result;
1205 uint32_t link_speed;
1207 if (!all_ports_stopped()) {
1208 printf("Please stop all ports first\n");
1212 if (port_id_is_invalid(res->id, ENABLED_WARN))
1215 if (parse_and_check_speed_duplex(res->value1, res->value2,
1219 ports[res->id].dev_conf.link_speeds = link_speed;
1221 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1225 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1226 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1228 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1229 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1231 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1232 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1233 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1234 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1236 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1237 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1238 "10#100#1000#10000#25000#40000#50000#100000#auto");
1239 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1240 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1242 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1243 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1246 cmdline_parse_inst_t cmd_config_speed_specific = {
1247 .f = cmd_config_speed_specific_parsed,
1249 .help_str = "port config <port_id> speed "
1250 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1253 (void *)&cmd_config_speed_specific_port,
1254 (void *)&cmd_config_speed_specific_keyword,
1255 (void *)&cmd_config_speed_specific_id,
1256 (void *)&cmd_config_speed_specific_item1,
1257 (void *)&cmd_config_speed_specific_value1,
1258 (void *)&cmd_config_speed_specific_item2,
1259 (void *)&cmd_config_speed_specific_value2,
1264 /* *** configure txq/rxq, txd/rxd *** */
1265 struct cmd_config_rx_tx {
1266 cmdline_fixed_string_t port;
1267 cmdline_fixed_string_t keyword;
1268 cmdline_fixed_string_t all;
1269 cmdline_fixed_string_t name;
1274 cmd_config_rx_tx_parsed(void *parsed_result,
1275 __attribute__((unused)) struct cmdline *cl,
1276 __attribute__((unused)) void *data)
1278 struct cmd_config_rx_tx *res = parsed_result;
1280 if (!all_ports_stopped()) {
1281 printf("Please stop all ports first\n");
1284 if (!strcmp(res->name, "rxq")) {
1285 if (!res->value && !nb_txq) {
1286 printf("Warning: Either rx or tx queues should be non zero\n");
1289 nb_rxq = res->value;
1291 else if (!strcmp(res->name, "txq")) {
1292 if (!res->value && !nb_rxq) {
1293 printf("Warning: Either rx or tx queues should be non zero\n");
1296 nb_txq = res->value;
1298 else if (!strcmp(res->name, "rxd")) {
1299 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1300 printf("rxd %d invalid - must be > 0 && <= %d\n",
1301 res->value, RTE_TEST_RX_DESC_MAX);
1304 nb_rxd = res->value;
1305 } else if (!strcmp(res->name, "txd")) {
1306 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1307 printf("txd %d invalid - must be > 0 && <= %d\n",
1308 res->value, RTE_TEST_TX_DESC_MAX);
1311 nb_txd = res->value;
1313 printf("Unknown parameter\n");
1321 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1324 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1325 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1326 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1327 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1328 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1329 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1330 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1331 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1333 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1334 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1336 cmdline_parse_inst_t cmd_config_rx_tx = {
1337 .f = cmd_config_rx_tx_parsed,
1339 .help_str = "port config all rxq|txq|rxd|txd <value>",
1341 (void *)&cmd_config_rx_tx_port,
1342 (void *)&cmd_config_rx_tx_keyword,
1343 (void *)&cmd_config_rx_tx_all,
1344 (void *)&cmd_config_rx_tx_name,
1345 (void *)&cmd_config_rx_tx_value,
1350 /* *** config max packet length *** */
1351 struct cmd_config_max_pkt_len_result {
1352 cmdline_fixed_string_t port;
1353 cmdline_fixed_string_t keyword;
1354 cmdline_fixed_string_t all;
1355 cmdline_fixed_string_t name;
1360 cmd_config_max_pkt_len_parsed(void *parsed_result,
1361 __attribute__((unused)) struct cmdline *cl,
1362 __attribute__((unused)) void *data)
1364 struct cmd_config_max_pkt_len_result *res = parsed_result;
1366 if (!all_ports_stopped()) {
1367 printf("Please stop all ports first\n");
1371 if (!strcmp(res->name, "max-pkt-len")) {
1372 if (res->value < ETHER_MIN_LEN) {
1373 printf("max-pkt-len can not be less than %d\n",
1377 if (res->value == rx_mode.max_rx_pkt_len)
1380 rx_mode.max_rx_pkt_len = res->value;
1381 if (res->value > ETHER_MAX_LEN)
1382 rx_mode.jumbo_frame = 1;
1384 rx_mode.jumbo_frame = 0;
1386 printf("Unknown parameter\n");
1392 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1395 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1398 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1401 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1402 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1404 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1405 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1407 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1408 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1411 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1412 .f = cmd_config_max_pkt_len_parsed,
1414 .help_str = "port config all max-pkt-len <value>",
1416 (void *)&cmd_config_max_pkt_len_port,
1417 (void *)&cmd_config_max_pkt_len_keyword,
1418 (void *)&cmd_config_max_pkt_len_all,
1419 (void *)&cmd_config_max_pkt_len_name,
1420 (void *)&cmd_config_max_pkt_len_value,
1425 /* *** configure port MTU *** */
1426 struct cmd_config_mtu_result {
1427 cmdline_fixed_string_t port;
1428 cmdline_fixed_string_t keyword;
1429 cmdline_fixed_string_t mtu;
1435 cmd_config_mtu_parsed(void *parsed_result,
1436 __attribute__((unused)) struct cmdline *cl,
1437 __attribute__((unused)) void *data)
1439 struct cmd_config_mtu_result *res = parsed_result;
1441 if (res->value < ETHER_MIN_LEN) {
1442 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1445 port_mtu_set(res->port_id, res->value);
1448 cmdline_parse_token_string_t cmd_config_mtu_port =
1449 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1451 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1452 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1454 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1455 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1457 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1458 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1459 cmdline_parse_token_num_t cmd_config_mtu_value =
1460 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1462 cmdline_parse_inst_t cmd_config_mtu = {
1463 .f = cmd_config_mtu_parsed,
1465 .help_str = "port config mtu <port_id> <value>",
1467 (void *)&cmd_config_mtu_port,
1468 (void *)&cmd_config_mtu_keyword,
1469 (void *)&cmd_config_mtu_mtu,
1470 (void *)&cmd_config_mtu_port_id,
1471 (void *)&cmd_config_mtu_value,
1476 /* *** configure rx mode *** */
1477 struct cmd_config_rx_mode_flag {
1478 cmdline_fixed_string_t port;
1479 cmdline_fixed_string_t keyword;
1480 cmdline_fixed_string_t all;
1481 cmdline_fixed_string_t name;
1482 cmdline_fixed_string_t value;
1486 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1487 __attribute__((unused)) struct cmdline *cl,
1488 __attribute__((unused)) void *data)
1490 struct cmd_config_rx_mode_flag *res = parsed_result;
1492 if (!all_ports_stopped()) {
1493 printf("Please stop all ports first\n");
1497 if (!strcmp(res->name, "crc-strip")) {
1498 if (!strcmp(res->value, "on"))
1499 rx_mode.hw_strip_crc = 1;
1500 else if (!strcmp(res->value, "off"))
1501 rx_mode.hw_strip_crc = 0;
1503 printf("Unknown parameter\n");
1506 } else if (!strcmp(res->name, "scatter")) {
1507 if (!strcmp(res->value, "on"))
1508 rx_mode.enable_scatter = 1;
1509 else if (!strcmp(res->value, "off"))
1510 rx_mode.enable_scatter = 0;
1512 printf("Unknown parameter\n");
1515 } else if (!strcmp(res->name, "rx-cksum")) {
1516 if (!strcmp(res->value, "on"))
1517 rx_mode.hw_ip_checksum = 1;
1518 else if (!strcmp(res->value, "off"))
1519 rx_mode.hw_ip_checksum = 0;
1521 printf("Unknown parameter\n");
1524 } else if (!strcmp(res->name, "hw-vlan")) {
1525 if (!strcmp(res->value, "on")) {
1526 rx_mode.hw_vlan_filter = 1;
1527 rx_mode.hw_vlan_strip = 1;
1529 else if (!strcmp(res->value, "off")) {
1530 rx_mode.hw_vlan_filter = 0;
1531 rx_mode.hw_vlan_strip = 0;
1534 printf("Unknown parameter\n");
1537 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1538 if (!strcmp(res->value, "on"))
1539 rx_mode.hw_vlan_filter = 1;
1540 else if (!strcmp(res->value, "off"))
1541 rx_mode.hw_vlan_filter = 0;
1543 printf("Unknown parameter\n");
1546 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1547 if (!strcmp(res->value, "on"))
1548 rx_mode.hw_vlan_strip = 1;
1549 else if (!strcmp(res->value, "off"))
1550 rx_mode.hw_vlan_strip = 0;
1552 printf("Unknown parameter\n");
1555 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1556 if (!strcmp(res->value, "on"))
1557 rx_mode.hw_vlan_extend = 1;
1558 else if (!strcmp(res->value, "off"))
1559 rx_mode.hw_vlan_extend = 0;
1561 printf("Unknown parameter\n");
1564 } else if (!strcmp(res->name, "drop-en")) {
1565 if (!strcmp(res->value, "on"))
1567 else if (!strcmp(res->value, "off"))
1570 printf("Unknown parameter\n");
1574 printf("Unknown parameter\n");
1580 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1583 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1584 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1585 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1586 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1588 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1589 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1590 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1591 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1592 "crc-strip#scatter#rx-cksum#hw-vlan#"
1593 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1594 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1595 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1598 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1599 .f = cmd_config_rx_mode_flag_parsed,
1601 .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
1602 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1604 (void *)&cmd_config_rx_mode_flag_port,
1605 (void *)&cmd_config_rx_mode_flag_keyword,
1606 (void *)&cmd_config_rx_mode_flag_all,
1607 (void *)&cmd_config_rx_mode_flag_name,
1608 (void *)&cmd_config_rx_mode_flag_value,
1613 /* *** configure rss *** */
1614 struct cmd_config_rss {
1615 cmdline_fixed_string_t port;
1616 cmdline_fixed_string_t keyword;
1617 cmdline_fixed_string_t all;
1618 cmdline_fixed_string_t name;
1619 cmdline_fixed_string_t value;
1623 cmd_config_rss_parsed(void *parsed_result,
1624 __attribute__((unused)) struct cmdline *cl,
1625 __attribute__((unused)) void *data)
1627 struct cmd_config_rss *res = parsed_result;
1628 struct rte_eth_rss_conf rss_conf;
1632 if (!strcmp(res->value, "all"))
1633 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1634 ETH_RSS_UDP | ETH_RSS_SCTP |
1636 else if (!strcmp(res->value, "ip"))
1637 rss_conf.rss_hf = ETH_RSS_IP;
1638 else if (!strcmp(res->value, "udp"))
1639 rss_conf.rss_hf = ETH_RSS_UDP;
1640 else if (!strcmp(res->value, "tcp"))
1641 rss_conf.rss_hf = ETH_RSS_TCP;
1642 else if (!strcmp(res->value, "sctp"))
1643 rss_conf.rss_hf = ETH_RSS_SCTP;
1644 else if (!strcmp(res->value, "ether"))
1645 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1646 else if (!strcmp(res->value, "port"))
1647 rss_conf.rss_hf = ETH_RSS_PORT;
1648 else if (!strcmp(res->value, "vxlan"))
1649 rss_conf.rss_hf = ETH_RSS_VXLAN;
1650 else if (!strcmp(res->value, "geneve"))
1651 rss_conf.rss_hf = ETH_RSS_GENEVE;
1652 else if (!strcmp(res->value, "nvgre"))
1653 rss_conf.rss_hf = ETH_RSS_NVGRE;
1654 else if (!strcmp(res->value, "none"))
1655 rss_conf.rss_hf = 0;
1657 printf("Unknown parameter\n");
1660 rss_conf.rss_key = NULL;
1661 for (i = 0; i < rte_eth_dev_count(); i++) {
1662 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1664 printf("Configuration of RSS hash at ethernet port %d "
1665 "failed with error (%d): %s.\n",
1666 i, -diag, strerror(-diag));
1670 cmdline_parse_token_string_t cmd_config_rss_port =
1671 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1672 cmdline_parse_token_string_t cmd_config_rss_keyword =
1673 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1674 cmdline_parse_token_string_t cmd_config_rss_all =
1675 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1676 cmdline_parse_token_string_t cmd_config_rss_name =
1677 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1678 cmdline_parse_token_string_t cmd_config_rss_value =
1679 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value,
1680 "all#ip#tcp#udp#sctp#ether#port#vxlan#geneve#nvgre#none");
1682 cmdline_parse_inst_t cmd_config_rss = {
1683 .f = cmd_config_rss_parsed,
1685 .help_str = "port config all rss "
1686 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none",
1688 (void *)&cmd_config_rss_port,
1689 (void *)&cmd_config_rss_keyword,
1690 (void *)&cmd_config_rss_all,
1691 (void *)&cmd_config_rss_name,
1692 (void *)&cmd_config_rss_value,
1697 /* *** configure rss hash key *** */
1698 struct cmd_config_rss_hash_key {
1699 cmdline_fixed_string_t port;
1700 cmdline_fixed_string_t config;
1702 cmdline_fixed_string_t rss_hash_key;
1703 cmdline_fixed_string_t rss_type;
1704 cmdline_fixed_string_t key;
1708 hexa_digit_to_value(char hexa_digit)
1710 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1711 return (uint8_t) (hexa_digit - '0');
1712 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1713 return (uint8_t) ((hexa_digit - 'a') + 10);
1714 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1715 return (uint8_t) ((hexa_digit - 'A') + 10);
1716 /* Invalid hexa digit */
1721 parse_and_check_key_hexa_digit(char *key, int idx)
1725 hexa_v = hexa_digit_to_value(key[idx]);
1727 printf("invalid key: character %c at position %d is not a "
1728 "valid hexa digit\n", key[idx], idx);
1733 cmd_config_rss_hash_key_parsed(void *parsed_result,
1734 __attribute__((unused)) struct cmdline *cl,
1735 __attribute__((unused)) void *data)
1737 struct cmd_config_rss_hash_key *res = parsed_result;
1738 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1742 struct rte_eth_dev_info dev_info;
1743 uint8_t hash_key_size;
1746 memset(&dev_info, 0, sizeof(dev_info));
1747 rte_eth_dev_info_get(res->port_id, &dev_info);
1748 if (dev_info.hash_key_size > 0 &&
1749 dev_info.hash_key_size <= sizeof(hash_key))
1750 hash_key_size = dev_info.hash_key_size;
1752 printf("dev_info did not provide a valid hash key size\n");
1755 /* Check the length of the RSS hash key */
1756 key_len = strlen(res->key);
1757 if (key_len != (hash_key_size * 2)) {
1758 printf("key length: %d invalid - key must be a string of %d"
1759 " hexa-decimal numbers\n",
1760 (int) key_len, hash_key_size * 2);
1763 /* Translate RSS hash key into binary representation */
1764 for (i = 0; i < hash_key_size; i++) {
1765 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1768 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1771 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1773 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1777 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1778 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1779 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1780 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1782 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1783 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1784 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1785 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1786 rss_hash_key, "rss-hash-key");
1787 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1788 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1789 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1790 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1791 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1792 "ipv6-tcp-ex#ipv6-udp-ex");
1793 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1794 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1796 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1797 .f = cmd_config_rss_hash_key_parsed,
1799 .help_str = "port config <port_id> rss-hash-key "
1800 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1801 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1802 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1803 "<string of hex digits (variable length, NIC dependent)>",
1805 (void *)&cmd_config_rss_hash_key_port,
1806 (void *)&cmd_config_rss_hash_key_config,
1807 (void *)&cmd_config_rss_hash_key_port_id,
1808 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1809 (void *)&cmd_config_rss_hash_key_rss_type,
1810 (void *)&cmd_config_rss_hash_key_value,
1815 /* *** configure port rxq/txq start/stop *** */
1816 struct cmd_config_rxtx_queue {
1817 cmdline_fixed_string_t port;
1819 cmdline_fixed_string_t rxtxq;
1821 cmdline_fixed_string_t opname;
1825 cmd_config_rxtx_queue_parsed(void *parsed_result,
1826 __attribute__((unused)) struct cmdline *cl,
1827 __attribute__((unused)) void *data)
1829 struct cmd_config_rxtx_queue *res = parsed_result;
1834 if (test_done == 0) {
1835 printf("Please stop forwarding first\n");
1839 if (port_id_is_invalid(res->portid, ENABLED_WARN))
1842 if (port_is_started(res->portid) != 1) {
1843 printf("Please start port %u first\n", res->portid);
1847 if (!strcmp(res->rxtxq, "rxq"))
1849 else if (!strcmp(res->rxtxq, "txq"))
1852 printf("Unknown parameter\n");
1856 if (isrx && rx_queue_id_is_invalid(res->qid))
1858 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1861 if (!strcmp(res->opname, "start"))
1863 else if (!strcmp(res->opname, "stop"))
1866 printf("Unknown parameter\n");
1870 if (isstart && isrx)
1871 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1872 else if (!isstart && isrx)
1873 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1874 else if (isstart && !isrx)
1875 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1877 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1879 if (ret == -ENOTSUP)
1880 printf("Function not supported in PMD driver\n");
1883 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1884 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1885 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1886 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1887 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1888 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1889 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1890 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1891 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1892 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1895 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1896 .f = cmd_config_rxtx_queue_parsed,
1898 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
1900 (void *)&cmd_config_speed_all_port,
1901 (void *)&cmd_config_rxtx_queue_portid,
1902 (void *)&cmd_config_rxtx_queue_rxtxq,
1903 (void *)&cmd_config_rxtx_queue_qid,
1904 (void *)&cmd_config_rxtx_queue_opname,
1909 /* *** Configure RSS RETA *** */
1910 struct cmd_config_rss_reta {
1911 cmdline_fixed_string_t port;
1912 cmdline_fixed_string_t keyword;
1914 cmdline_fixed_string_t name;
1915 cmdline_fixed_string_t list_name;
1916 cmdline_fixed_string_t list_of_items;
1920 parse_reta_config(const char *str,
1921 struct rte_eth_rss_reta_entry64 *reta_conf,
1922 uint16_t nb_entries)
1926 uint16_t hash_index, idx, shift;
1929 const char *p, *p0 = str;
1936 unsigned long int_fld[_NUM_FLD];
1937 char *str_fld[_NUM_FLD];
1939 while ((p = strchr(p0,'(')) != NULL) {
1941 if((p0 = strchr(p,')')) == NULL)
1945 if(size >= sizeof(s))
1948 snprintf(s, sizeof(s), "%.*s", size, p);
1949 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1951 for (i = 0; i < _NUM_FLD; i++) {
1953 int_fld[i] = strtoul(str_fld[i], &end, 0);
1954 if (errno != 0 || end == str_fld[i] ||
1959 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1960 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
1962 if (hash_index >= nb_entries) {
1963 printf("Invalid RETA hash index=%d\n", hash_index);
1967 idx = hash_index / RTE_RETA_GROUP_SIZE;
1968 shift = hash_index % RTE_RETA_GROUP_SIZE;
1969 reta_conf[idx].mask |= (1ULL << shift);
1970 reta_conf[idx].reta[shift] = nb_queue;
1977 cmd_set_rss_reta_parsed(void *parsed_result,
1978 __attribute__((unused)) struct cmdline *cl,
1979 __attribute__((unused)) void *data)
1982 struct rte_eth_dev_info dev_info;
1983 struct rte_eth_rss_reta_entry64 reta_conf[8];
1984 struct cmd_config_rss_reta *res = parsed_result;
1986 memset(&dev_info, 0, sizeof(dev_info));
1987 rte_eth_dev_info_get(res->port_id, &dev_info);
1988 if (dev_info.reta_size == 0) {
1989 printf("Redirection table size is 0 which is "
1990 "invalid for RSS\n");
1993 printf("The reta size of port %d is %u\n",
1994 res->port_id, dev_info.reta_size);
1995 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1996 printf("Currently do not support more than %u entries of "
1997 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2001 memset(reta_conf, 0, sizeof(reta_conf));
2002 if (!strcmp(res->list_name, "reta")) {
2003 if (parse_reta_config(res->list_of_items, reta_conf,
2004 dev_info.reta_size)) {
2005 printf("Invalid RSS Redirection Table "
2006 "config entered\n");
2009 ret = rte_eth_dev_rss_reta_update(res->port_id,
2010 reta_conf, dev_info.reta_size);
2012 printf("Bad redirection table parameter, "
2013 "return code = %d \n", ret);
2017 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2018 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2019 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2020 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2021 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2022 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
2023 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2024 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2025 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2026 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2027 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2028 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2030 cmdline_parse_inst_t cmd_config_rss_reta = {
2031 .f = cmd_set_rss_reta_parsed,
2033 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2035 (void *)&cmd_config_rss_reta_port,
2036 (void *)&cmd_config_rss_reta_keyword,
2037 (void *)&cmd_config_rss_reta_port_id,
2038 (void *)&cmd_config_rss_reta_name,
2039 (void *)&cmd_config_rss_reta_list_name,
2040 (void *)&cmd_config_rss_reta_list_of_items,
2045 /* *** SHOW PORT RETA INFO *** */
2046 struct cmd_showport_reta {
2047 cmdline_fixed_string_t show;
2048 cmdline_fixed_string_t port;
2050 cmdline_fixed_string_t rss;
2051 cmdline_fixed_string_t reta;
2053 cmdline_fixed_string_t list_of_items;
2057 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2058 uint16_t nb_entries,
2062 const char *p, *p0 = str;
2066 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
2069 p = strchr(p0, '(');
2073 p0 = strchr(p, ')');
2077 if (size >= sizeof(s)) {
2078 printf("The string size exceeds the internal buffer size\n");
2081 snprintf(s, sizeof(s), "%.*s", size, p);
2082 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2083 if (ret <= 0 || ret != num) {
2084 printf("The bits of masks do not match the number of "
2085 "reta entries: %u\n", num);
2088 for (i = 0; i < ret; i++)
2089 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2095 cmd_showport_reta_parsed(void *parsed_result,
2096 __attribute__((unused)) struct cmdline *cl,
2097 __attribute__((unused)) void *data)
2099 struct cmd_showport_reta *res = parsed_result;
2100 struct rte_eth_rss_reta_entry64 reta_conf[8];
2101 struct rte_eth_dev_info dev_info;
2103 memset(&dev_info, 0, sizeof(dev_info));
2104 rte_eth_dev_info_get(res->port_id, &dev_info);
2105 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
2106 res->size > ETH_RSS_RETA_SIZE_512) {
2107 printf("Invalid redirection table size: %u\n", res->size);
2111 memset(reta_conf, 0, sizeof(reta_conf));
2112 if (showport_parse_reta_config(reta_conf, res->size,
2113 res->list_of_items) < 0) {
2114 printf("Invalid string: %s for reta masks\n",
2115 res->list_of_items);
2118 port_rss_reta_info(res->port_id, reta_conf, res->size);
2121 cmdline_parse_token_string_t cmd_showport_reta_show =
2122 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2123 cmdline_parse_token_string_t cmd_showport_reta_port =
2124 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2125 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2126 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
2127 cmdline_parse_token_string_t cmd_showport_reta_rss =
2128 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2129 cmdline_parse_token_string_t cmd_showport_reta_reta =
2130 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2131 cmdline_parse_token_num_t cmd_showport_reta_size =
2132 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2133 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2134 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2135 list_of_items, NULL);
2137 cmdline_parse_inst_t cmd_showport_reta = {
2138 .f = cmd_showport_reta_parsed,
2140 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2142 (void *)&cmd_showport_reta_show,
2143 (void *)&cmd_showport_reta_port,
2144 (void *)&cmd_showport_reta_port_id,
2145 (void *)&cmd_showport_reta_rss,
2146 (void *)&cmd_showport_reta_reta,
2147 (void *)&cmd_showport_reta_size,
2148 (void *)&cmd_showport_reta_list_of_items,
2153 /* *** Show RSS hash configuration *** */
2154 struct cmd_showport_rss_hash {
2155 cmdline_fixed_string_t show;
2156 cmdline_fixed_string_t port;
2158 cmdline_fixed_string_t rss_hash;
2159 cmdline_fixed_string_t rss_type;
2160 cmdline_fixed_string_t key; /* optional argument */
2163 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2164 __attribute__((unused)) struct cmdline *cl,
2167 struct cmd_showport_rss_hash *res = parsed_result;
2169 port_rss_hash_conf_show(res->port_id, res->rss_type,
2170 show_rss_key != NULL);
2173 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2174 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2175 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2176 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2177 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2178 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
2179 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2180 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2182 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2183 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2184 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2185 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2186 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2187 "ipv6-tcp-ex#ipv6-udp-ex");
2188 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2189 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2191 cmdline_parse_inst_t cmd_showport_rss_hash = {
2192 .f = cmd_showport_rss_hash_parsed,
2194 .help_str = "show port <port_id> rss-hash "
2195 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2196 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2197 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2199 (void *)&cmd_showport_rss_hash_show,
2200 (void *)&cmd_showport_rss_hash_port,
2201 (void *)&cmd_showport_rss_hash_port_id,
2202 (void *)&cmd_showport_rss_hash_rss_hash,
2203 (void *)&cmd_showport_rss_hash_rss_hash_info,
2208 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2209 .f = cmd_showport_rss_hash_parsed,
2211 .help_str = "show port <port_id> rss-hash "
2212 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2213 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2214 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2216 (void *)&cmd_showport_rss_hash_show,
2217 (void *)&cmd_showport_rss_hash_port,
2218 (void *)&cmd_showport_rss_hash_port_id,
2219 (void *)&cmd_showport_rss_hash_rss_hash,
2220 (void *)&cmd_showport_rss_hash_rss_hash_info,
2221 (void *)&cmd_showport_rss_hash_rss_key,
2226 /* *** Configure DCB *** */
2227 struct cmd_config_dcb {
2228 cmdline_fixed_string_t port;
2229 cmdline_fixed_string_t config;
2231 cmdline_fixed_string_t dcb;
2232 cmdline_fixed_string_t vt;
2233 cmdline_fixed_string_t vt_en;
2235 cmdline_fixed_string_t pfc;
2236 cmdline_fixed_string_t pfc_en;
2240 cmd_config_dcb_parsed(void *parsed_result,
2241 __attribute__((unused)) struct cmdline *cl,
2242 __attribute__((unused)) void *data)
2244 struct cmd_config_dcb *res = parsed_result;
2245 portid_t port_id = res->port_id;
2246 struct rte_port *port;
2250 port = &ports[port_id];
2251 /** Check if the port is not started **/
2252 if (port->port_status != RTE_PORT_STOPPED) {
2253 printf("Please stop port %d first\n", port_id);
2257 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2258 printf("The invalid number of traffic class,"
2259 " only 4 or 8 allowed.\n");
2263 if (nb_fwd_lcores < res->num_tcs) {
2264 printf("nb_cores shouldn't be less than number of TCs.\n");
2267 if (!strncmp(res->pfc_en, "on", 2))
2272 /* DCB in VT mode */
2273 if (!strncmp(res->vt_en, "on", 2))
2274 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2275 (enum rte_eth_nb_tcs)res->num_tcs,
2278 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2279 (enum rte_eth_nb_tcs)res->num_tcs,
2284 printf("Cannot initialize network ports.\n");
2288 cmd_reconfig_device_queue(port_id, 1, 1);
2291 cmdline_parse_token_string_t cmd_config_dcb_port =
2292 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2293 cmdline_parse_token_string_t cmd_config_dcb_config =
2294 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2295 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2296 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
2297 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2298 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2299 cmdline_parse_token_string_t cmd_config_dcb_vt =
2300 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2301 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2302 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2303 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2304 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2305 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2306 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2307 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2308 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2310 cmdline_parse_inst_t cmd_config_dcb = {
2311 .f = cmd_config_dcb_parsed,
2313 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2315 (void *)&cmd_config_dcb_port,
2316 (void *)&cmd_config_dcb_config,
2317 (void *)&cmd_config_dcb_port_id,
2318 (void *)&cmd_config_dcb_dcb,
2319 (void *)&cmd_config_dcb_vt,
2320 (void *)&cmd_config_dcb_vt_en,
2321 (void *)&cmd_config_dcb_num_tcs,
2322 (void *)&cmd_config_dcb_pfc,
2323 (void *)&cmd_config_dcb_pfc_en,
2328 /* *** configure number of packets per burst *** */
2329 struct cmd_config_burst {
2330 cmdline_fixed_string_t port;
2331 cmdline_fixed_string_t keyword;
2332 cmdline_fixed_string_t all;
2333 cmdline_fixed_string_t name;
2338 cmd_config_burst_parsed(void *parsed_result,
2339 __attribute__((unused)) struct cmdline *cl,
2340 __attribute__((unused)) void *data)
2342 struct cmd_config_burst *res = parsed_result;
2344 if (!all_ports_stopped()) {
2345 printf("Please stop all ports first\n");
2349 if (!strcmp(res->name, "burst")) {
2350 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2351 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2354 nb_pkt_per_burst = res->value;
2356 printf("Unknown parameter\n");
2362 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2365 cmdline_parse_token_string_t cmd_config_burst_port =
2366 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2367 cmdline_parse_token_string_t cmd_config_burst_keyword =
2368 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2369 cmdline_parse_token_string_t cmd_config_burst_all =
2370 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2371 cmdline_parse_token_string_t cmd_config_burst_name =
2372 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2373 cmdline_parse_token_num_t cmd_config_burst_value =
2374 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2376 cmdline_parse_inst_t cmd_config_burst = {
2377 .f = cmd_config_burst_parsed,
2379 .help_str = "port config all burst <value>",
2381 (void *)&cmd_config_burst_port,
2382 (void *)&cmd_config_burst_keyword,
2383 (void *)&cmd_config_burst_all,
2384 (void *)&cmd_config_burst_name,
2385 (void *)&cmd_config_burst_value,
2390 /* *** configure rx/tx queues *** */
2391 struct cmd_config_thresh {
2392 cmdline_fixed_string_t port;
2393 cmdline_fixed_string_t keyword;
2394 cmdline_fixed_string_t all;
2395 cmdline_fixed_string_t name;
2400 cmd_config_thresh_parsed(void *parsed_result,
2401 __attribute__((unused)) struct cmdline *cl,
2402 __attribute__((unused)) void *data)
2404 struct cmd_config_thresh *res = parsed_result;
2406 if (!all_ports_stopped()) {
2407 printf("Please stop all ports first\n");
2411 if (!strcmp(res->name, "txpt"))
2412 tx_pthresh = res->value;
2413 else if(!strcmp(res->name, "txht"))
2414 tx_hthresh = res->value;
2415 else if(!strcmp(res->name, "txwt"))
2416 tx_wthresh = res->value;
2417 else if(!strcmp(res->name, "rxpt"))
2418 rx_pthresh = res->value;
2419 else if(!strcmp(res->name, "rxht"))
2420 rx_hthresh = res->value;
2421 else if(!strcmp(res->name, "rxwt"))
2422 rx_wthresh = res->value;
2424 printf("Unknown parameter\n");
2430 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2433 cmdline_parse_token_string_t cmd_config_thresh_port =
2434 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2435 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2436 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2437 cmdline_parse_token_string_t cmd_config_thresh_all =
2438 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2439 cmdline_parse_token_string_t cmd_config_thresh_name =
2440 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2441 "txpt#txht#txwt#rxpt#rxht#rxwt");
2442 cmdline_parse_token_num_t cmd_config_thresh_value =
2443 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2445 cmdline_parse_inst_t cmd_config_thresh = {
2446 .f = cmd_config_thresh_parsed,
2448 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2450 (void *)&cmd_config_thresh_port,
2451 (void *)&cmd_config_thresh_keyword,
2452 (void *)&cmd_config_thresh_all,
2453 (void *)&cmd_config_thresh_name,
2454 (void *)&cmd_config_thresh_value,
2459 /* *** configure free/rs threshold *** */
2460 struct cmd_config_threshold {
2461 cmdline_fixed_string_t port;
2462 cmdline_fixed_string_t keyword;
2463 cmdline_fixed_string_t all;
2464 cmdline_fixed_string_t name;
2469 cmd_config_threshold_parsed(void *parsed_result,
2470 __attribute__((unused)) struct cmdline *cl,
2471 __attribute__((unused)) void *data)
2473 struct cmd_config_threshold *res = parsed_result;
2475 if (!all_ports_stopped()) {
2476 printf("Please stop all ports first\n");
2480 if (!strcmp(res->name, "txfreet"))
2481 tx_free_thresh = res->value;
2482 else if (!strcmp(res->name, "txrst"))
2483 tx_rs_thresh = res->value;
2484 else if (!strcmp(res->name, "rxfreet"))
2485 rx_free_thresh = res->value;
2487 printf("Unknown parameter\n");
2493 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2496 cmdline_parse_token_string_t cmd_config_threshold_port =
2497 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2498 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2499 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2501 cmdline_parse_token_string_t cmd_config_threshold_all =
2502 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2503 cmdline_parse_token_string_t cmd_config_threshold_name =
2504 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2505 "txfreet#txrst#rxfreet");
2506 cmdline_parse_token_num_t cmd_config_threshold_value =
2507 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2509 cmdline_parse_inst_t cmd_config_threshold = {
2510 .f = cmd_config_threshold_parsed,
2512 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2514 (void *)&cmd_config_threshold_port,
2515 (void *)&cmd_config_threshold_keyword,
2516 (void *)&cmd_config_threshold_all,
2517 (void *)&cmd_config_threshold_name,
2518 (void *)&cmd_config_threshold_value,
2524 struct cmd_stop_result {
2525 cmdline_fixed_string_t stop;
2528 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2529 __attribute__((unused)) struct cmdline *cl,
2530 __attribute__((unused)) void *data)
2532 stop_packet_forwarding();
2535 cmdline_parse_token_string_t cmd_stop_stop =
2536 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2538 cmdline_parse_inst_t cmd_stop = {
2539 .f = cmd_stop_parsed,
2541 .help_str = "stop: Stop packet forwarding",
2543 (void *)&cmd_stop_stop,
2548 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2551 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2552 unsigned int *parsed_items, int check_unique_values)
2554 unsigned int nb_item;
2562 * First parse all items in the list and store their value.
2567 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2569 if ((c >= '0') && (c <= '9')) {
2570 value = (unsigned int) (value * 10 + (c - '0'));
2575 printf("character %c is not a decimal digit\n", c);
2579 printf("No valid value before comma\n");
2582 if (nb_item < max_items) {
2583 parsed_items[nb_item] = value;
2589 if (nb_item >= max_items) {
2590 printf("Number of %s = %u > %u (maximum items)\n",
2591 item_name, nb_item + 1, max_items);
2594 parsed_items[nb_item++] = value;
2595 if (! check_unique_values)
2599 * Then, check that all values in the list are differents.
2600 * No optimization here...
2602 for (i = 0; i < nb_item; i++) {
2603 for (j = i + 1; j < nb_item; j++) {
2604 if (parsed_items[j] == parsed_items[i]) {
2605 printf("duplicated %s %u at index %u and %u\n",
2606 item_name, parsed_items[i], i, j);
2614 struct cmd_set_list_result {
2615 cmdline_fixed_string_t cmd_keyword;
2616 cmdline_fixed_string_t list_name;
2617 cmdline_fixed_string_t list_of_items;
2620 static void cmd_set_list_parsed(void *parsed_result,
2621 __attribute__((unused)) struct cmdline *cl,
2622 __attribute__((unused)) void *data)
2624 struct cmd_set_list_result *res;
2626 unsigned int lcorelist[RTE_MAX_LCORE];
2627 unsigned int portlist[RTE_MAX_ETHPORTS];
2629 unsigned int nb_item;
2631 if (test_done == 0) {
2632 printf("Please stop forwarding first\n");
2636 res = parsed_result;
2637 if (!strcmp(res->list_name, "corelist")) {
2638 nb_item = parse_item_list(res->list_of_items, "core",
2640 parsed_items.lcorelist, 1);
2642 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2647 if (!strcmp(res->list_name, "portlist")) {
2648 nb_item = parse_item_list(res->list_of_items, "port",
2650 parsed_items.portlist, 1);
2652 set_fwd_ports_list(parsed_items.portlist, nb_item);
2658 cmdline_parse_token_string_t cmd_set_list_keyword =
2659 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2661 cmdline_parse_token_string_t cmd_set_list_name =
2662 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2663 "corelist#portlist");
2664 cmdline_parse_token_string_t cmd_set_list_of_items =
2665 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2668 cmdline_parse_inst_t cmd_set_fwd_list = {
2669 .f = cmd_set_list_parsed,
2671 .help_str = "set corelist|portlist <list0[,list1]*>",
2673 (void *)&cmd_set_list_keyword,
2674 (void *)&cmd_set_list_name,
2675 (void *)&cmd_set_list_of_items,
2680 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2682 struct cmd_setmask_result {
2683 cmdline_fixed_string_t set;
2684 cmdline_fixed_string_t mask;
2688 static void cmd_set_mask_parsed(void *parsed_result,
2689 __attribute__((unused)) struct cmdline *cl,
2690 __attribute__((unused)) void *data)
2692 struct cmd_setmask_result *res = parsed_result;
2694 if (test_done == 0) {
2695 printf("Please stop forwarding first\n");
2698 if (!strcmp(res->mask, "coremask")) {
2699 set_fwd_lcores_mask(res->hexavalue);
2701 } else if (!strcmp(res->mask, "portmask")) {
2702 set_fwd_ports_mask(res->hexavalue);
2707 cmdline_parse_token_string_t cmd_setmask_set =
2708 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2709 cmdline_parse_token_string_t cmd_setmask_mask =
2710 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2711 "coremask#portmask");
2712 cmdline_parse_token_num_t cmd_setmask_value =
2713 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2715 cmdline_parse_inst_t cmd_set_fwd_mask = {
2716 .f = cmd_set_mask_parsed,
2718 .help_str = "set coremask|portmask <hexadecimal value>",
2720 (void *)&cmd_setmask_set,
2721 (void *)&cmd_setmask_mask,
2722 (void *)&cmd_setmask_value,
2728 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2730 struct cmd_set_result {
2731 cmdline_fixed_string_t set;
2732 cmdline_fixed_string_t what;
2736 static void cmd_set_parsed(void *parsed_result,
2737 __attribute__((unused)) struct cmdline *cl,
2738 __attribute__((unused)) void *data)
2740 struct cmd_set_result *res = parsed_result;
2741 if (!strcmp(res->what, "nbport")) {
2742 set_fwd_ports_number(res->value);
2744 } else if (!strcmp(res->what, "nbcore")) {
2745 set_fwd_lcores_number(res->value);
2747 } else if (!strcmp(res->what, "burst"))
2748 set_nb_pkt_per_burst(res->value);
2749 else if (!strcmp(res->what, "verbose"))
2750 set_verbose_level(res->value);
2753 cmdline_parse_token_string_t cmd_set_set =
2754 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2755 cmdline_parse_token_string_t cmd_set_what =
2756 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2757 "nbport#nbcore#burst#verbose");
2758 cmdline_parse_token_num_t cmd_set_value =
2759 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2761 cmdline_parse_inst_t cmd_set_numbers = {
2762 .f = cmd_set_parsed,
2764 .help_str = "set nbport|nbcore|burst|verbose <value>",
2766 (void *)&cmd_set_set,
2767 (void *)&cmd_set_what,
2768 (void *)&cmd_set_value,
2773 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2775 struct cmd_set_txpkts_result {
2776 cmdline_fixed_string_t cmd_keyword;
2777 cmdline_fixed_string_t txpkts;
2778 cmdline_fixed_string_t seg_lengths;
2782 cmd_set_txpkts_parsed(void *parsed_result,
2783 __attribute__((unused)) struct cmdline *cl,
2784 __attribute__((unused)) void *data)
2786 struct cmd_set_txpkts_result *res;
2787 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2788 unsigned int nb_segs;
2790 res = parsed_result;
2791 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2792 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2794 set_tx_pkt_segments(seg_lengths, nb_segs);
2797 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2798 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2799 cmd_keyword, "set");
2800 cmdline_parse_token_string_t cmd_set_txpkts_name =
2801 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2803 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2804 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2807 cmdline_parse_inst_t cmd_set_txpkts = {
2808 .f = cmd_set_txpkts_parsed,
2810 .help_str = "set txpkts <len0[,len1]*>",
2812 (void *)&cmd_set_txpkts_keyword,
2813 (void *)&cmd_set_txpkts_name,
2814 (void *)&cmd_set_txpkts_lengths,
2819 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2821 struct cmd_set_txsplit_result {
2822 cmdline_fixed_string_t cmd_keyword;
2823 cmdline_fixed_string_t txsplit;
2824 cmdline_fixed_string_t mode;
2828 cmd_set_txsplit_parsed(void *parsed_result,
2829 __attribute__((unused)) struct cmdline *cl,
2830 __attribute__((unused)) void *data)
2832 struct cmd_set_txsplit_result *res;
2834 res = parsed_result;
2835 set_tx_pkt_split(res->mode);
2838 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
2839 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2840 cmd_keyword, "set");
2841 cmdline_parse_token_string_t cmd_set_txsplit_name =
2842 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2843 txsplit, "txsplit");
2844 cmdline_parse_token_string_t cmd_set_txsplit_mode =
2845 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
2848 cmdline_parse_inst_t cmd_set_txsplit = {
2849 .f = cmd_set_txsplit_parsed,
2851 .help_str = "set txsplit on|off|rand",
2853 (void *)&cmd_set_txsplit_keyword,
2854 (void *)&cmd_set_txsplit_name,
2855 (void *)&cmd_set_txsplit_mode,
2860 /* *** CONFIG TX QUEUE FLAGS *** */
2862 struct cmd_config_txqflags_result {
2863 cmdline_fixed_string_t port;
2864 cmdline_fixed_string_t config;
2865 cmdline_fixed_string_t all;
2866 cmdline_fixed_string_t what;
2870 static void cmd_config_txqflags_parsed(void *parsed_result,
2871 __attribute__((unused)) struct cmdline *cl,
2872 __attribute__((unused)) void *data)
2874 struct cmd_config_txqflags_result *res = parsed_result;
2876 if (!all_ports_stopped()) {
2877 printf("Please stop all ports first\n");
2881 if (strcmp(res->what, "txqflags")) {
2882 printf("Unknown parameter\n");
2886 if (res->hexvalue >= 0) {
2887 txq_flags = res->hexvalue;
2889 printf("txqflags must be >= 0\n");
2895 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2898 cmdline_parse_token_string_t cmd_config_txqflags_port =
2899 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
2901 cmdline_parse_token_string_t cmd_config_txqflags_config =
2902 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
2904 cmdline_parse_token_string_t cmd_config_txqflags_all =
2905 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
2907 cmdline_parse_token_string_t cmd_config_txqflags_what =
2908 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
2910 cmdline_parse_token_num_t cmd_config_txqflags_value =
2911 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
2914 cmdline_parse_inst_t cmd_config_txqflags = {
2915 .f = cmd_config_txqflags_parsed,
2917 .help_str = "port config all txqflags <value>",
2919 (void *)&cmd_config_txqflags_port,
2920 (void *)&cmd_config_txqflags_config,
2921 (void *)&cmd_config_txqflags_all,
2922 (void *)&cmd_config_txqflags_what,
2923 (void *)&cmd_config_txqflags_value,
2928 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2929 struct cmd_rx_vlan_filter_all_result {
2930 cmdline_fixed_string_t rx_vlan;
2931 cmdline_fixed_string_t what;
2932 cmdline_fixed_string_t all;
2937 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2938 __attribute__((unused)) struct cmdline *cl,
2939 __attribute__((unused)) void *data)
2941 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2943 if (!strcmp(res->what, "add"))
2944 rx_vlan_all_filter_set(res->port_id, 1);
2946 rx_vlan_all_filter_set(res->port_id, 0);
2949 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2950 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2951 rx_vlan, "rx_vlan");
2952 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2953 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2955 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2956 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2958 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2959 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2962 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2963 .f = cmd_rx_vlan_filter_all_parsed,
2965 .help_str = "rx_vlan add|rm all <port_id>: "
2966 "Add/Remove all identifiers to/from the set of VLAN "
2967 "identifiers filtered by a port",
2969 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2970 (void *)&cmd_rx_vlan_filter_all_what,
2971 (void *)&cmd_rx_vlan_filter_all_all,
2972 (void *)&cmd_rx_vlan_filter_all_portid,
2977 /* *** VLAN OFFLOAD SET ON A PORT *** */
2978 struct cmd_vlan_offload_result {
2979 cmdline_fixed_string_t vlan;
2980 cmdline_fixed_string_t set;
2981 cmdline_fixed_string_t vlan_type;
2982 cmdline_fixed_string_t what;
2983 cmdline_fixed_string_t on;
2984 cmdline_fixed_string_t port_id;
2988 cmd_vlan_offload_parsed(void *parsed_result,
2989 __attribute__((unused)) struct cmdline *cl,
2990 __attribute__((unused)) void *data)
2993 struct cmd_vlan_offload_result *res = parsed_result;
2996 portid_t port_id = 0;
3000 len = strnlen(str, STR_TOKEN_SIZE);
3002 /* Get port_id first */
3010 tmp = strtoul(str, NULL, 0);
3011 /* If port_id greater that what portid_t can represent, return */
3012 if(tmp >= RTE_MAX_ETHPORTS)
3014 port_id = (portid_t)tmp;
3016 if (!strcmp(res->on, "on"))
3021 if (!strcmp(res->what, "strip"))
3022 rx_vlan_strip_set(port_id, on);
3023 else if(!strcmp(res->what, "stripq")){
3024 uint16_t queue_id = 0;
3026 /* No queue_id, return */
3028 printf("must specify (port,queue_id)\n");
3031 tmp = strtoul(str + i + 1, NULL, 0);
3032 /* If queue_id greater that what 16-bits can represent, return */
3036 queue_id = (uint16_t)tmp;
3037 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3039 else if (!strcmp(res->what, "filter"))
3040 rx_vlan_filter_set(port_id, on);
3042 vlan_extend_set(port_id, on);
3047 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3048 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3050 cmdline_parse_token_string_t cmd_vlan_offload_set =
3051 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3053 cmdline_parse_token_string_t cmd_vlan_offload_what =
3054 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3055 what, "strip#filter#qinq#stripq");
3056 cmdline_parse_token_string_t cmd_vlan_offload_on =
3057 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3059 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3060 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3063 cmdline_parse_inst_t cmd_vlan_offload = {
3064 .f = cmd_vlan_offload_parsed,
3066 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3067 "<port_id[,queue_id]>: "
3068 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3070 (void *)&cmd_vlan_offload_vlan,
3071 (void *)&cmd_vlan_offload_set,
3072 (void *)&cmd_vlan_offload_what,
3073 (void *)&cmd_vlan_offload_on,
3074 (void *)&cmd_vlan_offload_portid,
3079 /* *** VLAN TPID SET ON A PORT *** */
3080 struct cmd_vlan_tpid_result {
3081 cmdline_fixed_string_t vlan;
3082 cmdline_fixed_string_t set;
3083 cmdline_fixed_string_t vlan_type;
3084 cmdline_fixed_string_t what;
3090 cmd_vlan_tpid_parsed(void *parsed_result,
3091 __attribute__((unused)) struct cmdline *cl,
3092 __attribute__((unused)) void *data)
3094 struct cmd_vlan_tpid_result *res = parsed_result;
3095 enum rte_vlan_type vlan_type;
3097 if (!strcmp(res->vlan_type, "inner"))
3098 vlan_type = ETH_VLAN_TYPE_INNER;
3099 else if (!strcmp(res->vlan_type, "outer"))
3100 vlan_type = ETH_VLAN_TYPE_OUTER;
3102 printf("Unknown vlan type\n");
3105 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3108 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3109 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3111 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3112 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3114 cmdline_parse_token_string_t cmd_vlan_type =
3115 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3116 vlan_type, "inner#outer");
3117 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3118 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3120 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3121 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3123 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3124 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3127 cmdline_parse_inst_t cmd_vlan_tpid = {
3128 .f = cmd_vlan_tpid_parsed,
3130 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3131 "Set the VLAN Ether type",
3133 (void *)&cmd_vlan_tpid_vlan,
3134 (void *)&cmd_vlan_tpid_set,
3135 (void *)&cmd_vlan_type,
3136 (void *)&cmd_vlan_tpid_what,
3137 (void *)&cmd_vlan_tpid_tpid,
3138 (void *)&cmd_vlan_tpid_portid,
3143 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3144 struct cmd_rx_vlan_filter_result {
3145 cmdline_fixed_string_t rx_vlan;
3146 cmdline_fixed_string_t what;
3152 cmd_rx_vlan_filter_parsed(void *parsed_result,
3153 __attribute__((unused)) struct cmdline *cl,
3154 __attribute__((unused)) void *data)
3156 struct cmd_rx_vlan_filter_result *res = parsed_result;
3158 if (!strcmp(res->what, "add"))
3159 rx_vft_set(res->port_id, res->vlan_id, 1);
3161 rx_vft_set(res->port_id, res->vlan_id, 0);
3164 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3165 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3166 rx_vlan, "rx_vlan");
3167 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3168 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3170 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3171 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3173 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3174 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3177 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3178 .f = cmd_rx_vlan_filter_parsed,
3180 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3181 "Add/Remove a VLAN identifier to/from the set of VLAN "
3182 "identifiers filtered by a port",
3184 (void *)&cmd_rx_vlan_filter_rx_vlan,
3185 (void *)&cmd_rx_vlan_filter_what,
3186 (void *)&cmd_rx_vlan_filter_vlanid,
3187 (void *)&cmd_rx_vlan_filter_portid,
3192 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3193 struct cmd_tx_vlan_set_result {
3194 cmdline_fixed_string_t tx_vlan;
3195 cmdline_fixed_string_t set;
3201 cmd_tx_vlan_set_parsed(void *parsed_result,
3202 __attribute__((unused)) struct cmdline *cl,
3203 __attribute__((unused)) void *data)
3205 struct cmd_tx_vlan_set_result *res = parsed_result;
3207 tx_vlan_set(res->port_id, res->vlan_id);
3210 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3211 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3212 tx_vlan, "tx_vlan");
3213 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3214 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3216 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3217 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3219 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3220 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3223 cmdline_parse_inst_t cmd_tx_vlan_set = {
3224 .f = cmd_tx_vlan_set_parsed,
3226 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3227 "Enable hardware insertion of a single VLAN header "
3228 "with a given TAG Identifier in packets sent on a port",
3230 (void *)&cmd_tx_vlan_set_tx_vlan,
3231 (void *)&cmd_tx_vlan_set_set,
3232 (void *)&cmd_tx_vlan_set_portid,
3233 (void *)&cmd_tx_vlan_set_vlanid,
3238 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3239 struct cmd_tx_vlan_set_qinq_result {
3240 cmdline_fixed_string_t tx_vlan;
3241 cmdline_fixed_string_t set;
3244 uint16_t vlan_id_outer;
3248 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3249 __attribute__((unused)) struct cmdline *cl,
3250 __attribute__((unused)) void *data)
3252 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3254 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3257 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3258 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3259 tx_vlan, "tx_vlan");
3260 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3261 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3263 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3264 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3266 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3267 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3269 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3270 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3271 vlan_id_outer, UINT16);
3273 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3274 .f = cmd_tx_vlan_set_qinq_parsed,
3276 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3277 "Enable hardware insertion of double VLAN header "
3278 "with given TAG Identifiers in packets sent on a port",
3280 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3281 (void *)&cmd_tx_vlan_set_qinq_set,
3282 (void *)&cmd_tx_vlan_set_qinq_portid,
3283 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3284 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3289 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3290 struct cmd_tx_vlan_set_pvid_result {
3291 cmdline_fixed_string_t tx_vlan;
3292 cmdline_fixed_string_t set;
3293 cmdline_fixed_string_t pvid;
3296 cmdline_fixed_string_t mode;
3300 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3301 __attribute__((unused)) struct cmdline *cl,
3302 __attribute__((unused)) void *data)
3304 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3306 if (strcmp(res->mode, "on") == 0)
3307 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3309 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3312 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3313 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3314 tx_vlan, "tx_vlan");
3315 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3316 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3318 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3319 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3321 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3322 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3324 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3325 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3327 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3328 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3331 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3332 .f = cmd_tx_vlan_set_pvid_parsed,
3334 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3336 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3337 (void *)&cmd_tx_vlan_set_pvid_set,
3338 (void *)&cmd_tx_vlan_set_pvid_pvid,
3339 (void *)&cmd_tx_vlan_set_pvid_port_id,
3340 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3341 (void *)&cmd_tx_vlan_set_pvid_mode,
3346 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3347 struct cmd_tx_vlan_reset_result {
3348 cmdline_fixed_string_t tx_vlan;
3349 cmdline_fixed_string_t reset;
3354 cmd_tx_vlan_reset_parsed(void *parsed_result,
3355 __attribute__((unused)) struct cmdline *cl,
3356 __attribute__((unused)) void *data)
3358 struct cmd_tx_vlan_reset_result *res = parsed_result;
3360 tx_vlan_reset(res->port_id);
3363 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3364 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3365 tx_vlan, "tx_vlan");
3366 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3367 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3369 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3370 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3373 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3374 .f = cmd_tx_vlan_reset_parsed,
3376 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3377 "VLAN header in packets sent on a port",
3379 (void *)&cmd_tx_vlan_reset_tx_vlan,
3380 (void *)&cmd_tx_vlan_reset_reset,
3381 (void *)&cmd_tx_vlan_reset_portid,
3387 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3388 struct cmd_csum_result {
3389 cmdline_fixed_string_t csum;
3390 cmdline_fixed_string_t mode;
3391 cmdline_fixed_string_t proto;
3392 cmdline_fixed_string_t hwsw;
3397 csum_show(int port_id)
3399 struct rte_eth_dev_info dev_info;
3402 ol_flags = ports[port_id].tx_ol_flags;
3403 printf("Parse tunnel is %s\n",
3404 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3405 printf("IP checksum offload is %s\n",
3406 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3407 printf("UDP checksum offload is %s\n",
3408 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3409 printf("TCP checksum offload is %s\n",
3410 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3411 printf("SCTP checksum offload is %s\n",
3412 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3413 printf("Outer-Ip checksum offload is %s\n",
3414 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3416 /* display warnings if configuration is not supported by the NIC */
3417 rte_eth_dev_info_get(port_id, &dev_info);
3418 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3419 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3420 printf("Warning: hardware IP checksum enabled but not "
3421 "supported by port %d\n", port_id);
3423 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3424 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3425 printf("Warning: hardware UDP checksum enabled but not "
3426 "supported by port %d\n", port_id);
3428 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3429 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3430 printf("Warning: hardware TCP checksum enabled but not "
3431 "supported by port %d\n", port_id);
3433 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3434 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3435 printf("Warning: hardware SCTP checksum enabled but not "
3436 "supported by port %d\n", port_id);
3438 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3439 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3440 printf("Warning: hardware outer IP checksum enabled but not "
3441 "supported by port %d\n", port_id);
3446 cmd_csum_parsed(void *parsed_result,
3447 __attribute__((unused)) struct cmdline *cl,
3448 __attribute__((unused)) void *data)
3450 struct cmd_csum_result *res = parsed_result;
3454 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3455 printf("invalid port %d\n", res->port_id);
3459 if (!strcmp(res->mode, "set")) {
3461 if (!strcmp(res->hwsw, "hw"))
3464 if (!strcmp(res->proto, "ip")) {
3465 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3466 } else if (!strcmp(res->proto, "udp")) {
3467 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3468 } else if (!strcmp(res->proto, "tcp")) {
3469 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3470 } else if (!strcmp(res->proto, "sctp")) {
3471 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3472 } else if (!strcmp(res->proto, "outer-ip")) {
3473 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3477 ports[res->port_id].tx_ol_flags |= mask;
3479 ports[res->port_id].tx_ol_flags &= (~mask);
3481 csum_show(res->port_id);
3484 cmdline_parse_token_string_t cmd_csum_csum =
3485 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3487 cmdline_parse_token_string_t cmd_csum_mode =
3488 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3490 cmdline_parse_token_string_t cmd_csum_proto =
3491 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3492 proto, "ip#tcp#udp#sctp#outer-ip");
3493 cmdline_parse_token_string_t cmd_csum_hwsw =
3494 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3496 cmdline_parse_token_num_t cmd_csum_portid =
3497 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3500 cmdline_parse_inst_t cmd_csum_set = {
3501 .f = cmd_csum_parsed,
3503 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3504 "Enable/Disable hardware calculation of L3/L4 checksum when "
3505 "using csum forward engine",
3507 (void *)&cmd_csum_csum,
3508 (void *)&cmd_csum_mode,
3509 (void *)&cmd_csum_proto,
3510 (void *)&cmd_csum_hwsw,
3511 (void *)&cmd_csum_portid,
3516 cmdline_parse_token_string_t cmd_csum_mode_show =
3517 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3520 cmdline_parse_inst_t cmd_csum_show = {
3521 .f = cmd_csum_parsed,
3523 .help_str = "csum show <port_id>: Show checksum offload configuration",
3525 (void *)&cmd_csum_csum,
3526 (void *)&cmd_csum_mode_show,
3527 (void *)&cmd_csum_portid,
3532 /* Enable/disable tunnel parsing */
3533 struct cmd_csum_tunnel_result {
3534 cmdline_fixed_string_t csum;
3535 cmdline_fixed_string_t parse;
3536 cmdline_fixed_string_t onoff;
3541 cmd_csum_tunnel_parsed(void *parsed_result,
3542 __attribute__((unused)) struct cmdline *cl,
3543 __attribute__((unused)) void *data)
3545 struct cmd_csum_tunnel_result *res = parsed_result;
3547 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3550 if (!strcmp(res->onoff, "on"))
3551 ports[res->port_id].tx_ol_flags |=
3552 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3554 ports[res->port_id].tx_ol_flags &=
3555 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3557 csum_show(res->port_id);
3560 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3561 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3563 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3564 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3565 parse, "parse_tunnel");
3566 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3567 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3569 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3570 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3573 cmdline_parse_inst_t cmd_csum_tunnel = {
3574 .f = cmd_csum_tunnel_parsed,
3576 .help_str = "csum parse_tunnel on|off <port_id>: "
3577 "Enable/Disable parsing of tunnels for csum engine",
3579 (void *)&cmd_csum_tunnel_csum,
3580 (void *)&cmd_csum_tunnel_parse,
3581 (void *)&cmd_csum_tunnel_onoff,
3582 (void *)&cmd_csum_tunnel_portid,
3587 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3588 struct cmd_tso_set_result {
3589 cmdline_fixed_string_t tso;
3590 cmdline_fixed_string_t mode;
3596 cmd_tso_set_parsed(void *parsed_result,
3597 __attribute__((unused)) struct cmdline *cl,
3598 __attribute__((unused)) void *data)
3600 struct cmd_tso_set_result *res = parsed_result;
3601 struct rte_eth_dev_info dev_info;
3603 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3606 if (!strcmp(res->mode, "set"))
3607 ports[res->port_id].tso_segsz = res->tso_segsz;
3609 if (ports[res->port_id].tso_segsz == 0)
3610 printf("TSO for non-tunneled packets is disabled\n");
3612 printf("TSO segment size for non-tunneled packets is %d\n",
3613 ports[res->port_id].tso_segsz);
3615 /* display warnings if configuration is not supported by the NIC */
3616 rte_eth_dev_info_get(res->port_id, &dev_info);
3617 if ((ports[res->port_id].tso_segsz != 0) &&
3618 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3619 printf("Warning: TSO enabled but not "
3620 "supported by port %d\n", res->port_id);
3624 cmdline_parse_token_string_t cmd_tso_set_tso =
3625 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3627 cmdline_parse_token_string_t cmd_tso_set_mode =
3628 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3630 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3631 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3633 cmdline_parse_token_num_t cmd_tso_set_portid =
3634 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3637 cmdline_parse_inst_t cmd_tso_set = {
3638 .f = cmd_tso_set_parsed,
3640 .help_str = "tso set <tso_segsz> <port_id>: "
3641 "Set TSO segment size of non-tunneled packets for csum engine "
3644 (void *)&cmd_tso_set_tso,
3645 (void *)&cmd_tso_set_mode,
3646 (void *)&cmd_tso_set_tso_segsz,
3647 (void *)&cmd_tso_set_portid,
3652 cmdline_parse_token_string_t cmd_tso_show_mode =
3653 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3657 cmdline_parse_inst_t cmd_tso_show = {
3658 .f = cmd_tso_set_parsed,
3660 .help_str = "tso show <port_id>: "
3661 "Show TSO segment size of non-tunneled packets for csum engine",
3663 (void *)&cmd_tso_set_tso,
3664 (void *)&cmd_tso_show_mode,
3665 (void *)&cmd_tso_set_portid,
3670 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3671 struct cmd_tunnel_tso_set_result {
3672 cmdline_fixed_string_t tso;
3673 cmdline_fixed_string_t mode;
3679 check_tunnel_tso_nic_support(uint8_t port_id)
3681 struct rte_eth_dev_info dev_info;
3683 rte_eth_dev_info_get(port_id, &dev_info);
3684 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3685 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3686 "supported by port %d\n", port_id);
3687 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3688 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3689 "supported by port %d\n", port_id);
3690 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3691 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3692 "supported by port %d\n", port_id);
3693 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3694 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3695 "supported by port %d\n", port_id);
3699 cmd_tunnel_tso_set_parsed(void *parsed_result,
3700 __attribute__((unused)) struct cmdline *cl,
3701 __attribute__((unused)) void *data)
3703 struct cmd_tunnel_tso_set_result *res = parsed_result;
3705 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3708 if (!strcmp(res->mode, "set"))
3709 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3711 if (ports[res->port_id].tunnel_tso_segsz == 0)
3712 printf("TSO for tunneled packets is disabled\n");
3714 printf("TSO segment size for tunneled packets is %d\n",
3715 ports[res->port_id].tunnel_tso_segsz);
3717 /* Below conditions are needed to make it work:
3718 * (1) tunnel TSO is supported by the NIC;
3719 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3721 * (3) for tunneled pkts with outer L3 of IPv4,
3722 * "csum set outer-ip" must be set to hw, because after tso,
3723 * total_len of outer IP header is changed, and the checksum
3724 * of outer IP header calculated by sw should be wrong; that
3725 * is not necessary for IPv6 tunneled pkts because there's no
3726 * checksum in IP header anymore.
3728 check_tunnel_tso_nic_support(res->port_id);
3730 if (!(ports[res->port_id].tx_ol_flags &
3731 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3732 printf("Warning: csum parse_tunnel must be set "
3733 "so that tunneled packets are recognized\n");
3734 if (!(ports[res->port_id].tx_ol_flags &
3735 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3736 printf("Warning: csum set outer-ip must be set to hw "
3737 "if outer L3 is IPv4; not necessary for IPv6\n");
3741 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3742 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3744 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3745 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3747 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3748 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3750 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3751 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3754 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3755 .f = cmd_tunnel_tso_set_parsed,
3757 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3758 "Set TSO segment size of tunneled packets for csum engine "
3761 (void *)&cmd_tunnel_tso_set_tso,
3762 (void *)&cmd_tunnel_tso_set_mode,
3763 (void *)&cmd_tunnel_tso_set_tso_segsz,
3764 (void *)&cmd_tunnel_tso_set_portid,
3769 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3770 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3774 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3775 .f = cmd_tunnel_tso_set_parsed,
3777 .help_str = "tunnel_tso show <port_id> "
3778 "Show TSO segment size of tunneled packets for csum engine",
3780 (void *)&cmd_tunnel_tso_set_tso,
3781 (void *)&cmd_tunnel_tso_show_mode,
3782 (void *)&cmd_tunnel_tso_set_portid,
3787 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
3788 struct cmd_set_flush_rx {
3789 cmdline_fixed_string_t set;
3790 cmdline_fixed_string_t flush_rx;
3791 cmdline_fixed_string_t mode;
3795 cmd_set_flush_rx_parsed(void *parsed_result,
3796 __attribute__((unused)) struct cmdline *cl,
3797 __attribute__((unused)) void *data)
3799 struct cmd_set_flush_rx *res = parsed_result;
3800 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3803 cmdline_parse_token_string_t cmd_setflushrx_set =
3804 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3806 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
3807 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3808 flush_rx, "flush_rx");
3809 cmdline_parse_token_string_t cmd_setflushrx_mode =
3810 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
3814 cmdline_parse_inst_t cmd_set_flush_rx = {
3815 .f = cmd_set_flush_rx_parsed,
3816 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
3819 (void *)&cmd_setflushrx_set,
3820 (void *)&cmd_setflushrx_flush_rx,
3821 (void *)&cmd_setflushrx_mode,
3826 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
3827 struct cmd_set_link_check {
3828 cmdline_fixed_string_t set;
3829 cmdline_fixed_string_t link_check;
3830 cmdline_fixed_string_t mode;
3834 cmd_set_link_check_parsed(void *parsed_result,
3835 __attribute__((unused)) struct cmdline *cl,
3836 __attribute__((unused)) void *data)
3838 struct cmd_set_link_check *res = parsed_result;
3839 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
3842 cmdline_parse_token_string_t cmd_setlinkcheck_set =
3843 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3845 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
3846 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3847 link_check, "link_check");
3848 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
3849 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
3853 cmdline_parse_inst_t cmd_set_link_check = {
3854 .f = cmd_set_link_check_parsed,
3855 .help_str = "set link_check on|off: Enable/Disable link status check "
3856 "when starting/stopping a port",
3859 (void *)&cmd_setlinkcheck_set,
3860 (void *)&cmd_setlinkcheck_link_check,
3861 (void *)&cmd_setlinkcheck_mode,
3866 #ifdef RTE_NIC_BYPASS
3867 /* *** SET NIC BYPASS MODE *** */
3868 struct cmd_set_bypass_mode_result {
3869 cmdline_fixed_string_t set;
3870 cmdline_fixed_string_t bypass;
3871 cmdline_fixed_string_t mode;
3872 cmdline_fixed_string_t value;
3877 cmd_set_bypass_mode_parsed(void *parsed_result,
3878 __attribute__((unused)) struct cmdline *cl,
3879 __attribute__((unused)) void *data)
3881 struct cmd_set_bypass_mode_result *res = parsed_result;
3882 portid_t port_id = res->port_id;
3883 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3885 if (!strcmp(res->value, "bypass"))
3886 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3887 else if (!strcmp(res->value, "isolate"))
3888 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3890 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3892 /* Set the bypass mode for the relevant port. */
3893 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3894 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3898 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3899 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3901 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3902 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3904 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3905 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3907 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3908 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3909 value, "normal#bypass#isolate");
3910 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3911 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3914 cmdline_parse_inst_t cmd_set_bypass_mode = {
3915 .f = cmd_set_bypass_mode_parsed,
3916 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
3917 "Set the NIC bypass mode for port_id",
3920 (void *)&cmd_setbypass_mode_set,
3921 (void *)&cmd_setbypass_mode_bypass,
3922 (void *)&cmd_setbypass_mode_mode,
3923 (void *)&cmd_setbypass_mode_value,
3924 (void *)&cmd_setbypass_mode_port,
3929 /* *** SET NIC BYPASS EVENT *** */
3930 struct cmd_set_bypass_event_result {
3931 cmdline_fixed_string_t set;
3932 cmdline_fixed_string_t bypass;
3933 cmdline_fixed_string_t event;
3934 cmdline_fixed_string_t event_value;
3935 cmdline_fixed_string_t mode;
3936 cmdline_fixed_string_t mode_value;
3941 cmd_set_bypass_event_parsed(void *parsed_result,
3942 __attribute__((unused)) struct cmdline *cl,
3943 __attribute__((unused)) void *data)
3946 struct cmd_set_bypass_event_result *res = parsed_result;
3947 portid_t port_id = res->port_id;
3948 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3949 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3951 if (!strcmp(res->event_value, "timeout"))
3952 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3953 else if (!strcmp(res->event_value, "os_on"))
3954 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3955 else if (!strcmp(res->event_value, "os_off"))
3956 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3957 else if (!strcmp(res->event_value, "power_on"))
3958 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3959 else if (!strcmp(res->event_value, "power_off"))
3960 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3962 bypass_event = RTE_BYPASS_EVENT_NONE;
3964 if (!strcmp(res->mode_value, "bypass"))
3965 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3966 else if (!strcmp(res->mode_value, "isolate"))
3967 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3969 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3971 /* Set the watchdog timeout. */
3972 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3975 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3976 (rc = rte_eth_dev_wd_timeout_store(port_id,
3977 bypass_timeout)) != 0) {
3978 printf("Failed to set timeout value %u "
3979 "for port %d, errto code: %d.\n",
3980 bypass_timeout, port_id, rc);
3984 /* Set the bypass event to transition to bypass mode. */
3985 if (0 != rte_eth_dev_bypass_event_store(port_id,
3986 bypass_event, bypass_mode)) {
3987 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3992 cmdline_parse_token_string_t cmd_setbypass_event_set =
3993 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3995 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3996 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3998 cmdline_parse_token_string_t cmd_setbypass_event_event =
3999 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4001 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4002 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4003 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4004 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4005 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4007 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4008 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4009 mode_value, "normal#bypass#isolate");
4010 cmdline_parse_token_num_t cmd_setbypass_event_port =
4011 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4014 cmdline_parse_inst_t cmd_set_bypass_event = {
4015 .f = cmd_set_bypass_event_parsed,
4016 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4017 "power_off mode normal|bypass|isolate <port_id>: "
4018 "Set the NIC bypass event mode for port_id",
4021 (void *)&cmd_setbypass_event_set,
4022 (void *)&cmd_setbypass_event_bypass,
4023 (void *)&cmd_setbypass_event_event,
4024 (void *)&cmd_setbypass_event_event_value,
4025 (void *)&cmd_setbypass_event_mode,
4026 (void *)&cmd_setbypass_event_mode_value,
4027 (void *)&cmd_setbypass_event_port,
4033 /* *** SET NIC BYPASS TIMEOUT *** */
4034 struct cmd_set_bypass_timeout_result {
4035 cmdline_fixed_string_t set;
4036 cmdline_fixed_string_t bypass;
4037 cmdline_fixed_string_t timeout;
4038 cmdline_fixed_string_t value;
4042 cmd_set_bypass_timeout_parsed(void *parsed_result,
4043 __attribute__((unused)) struct cmdline *cl,
4044 __attribute__((unused)) void *data)
4046 struct cmd_set_bypass_timeout_result *res = parsed_result;
4048 if (!strcmp(res->value, "1.5"))
4049 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
4050 else if (!strcmp(res->value, "2"))
4051 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
4052 else if (!strcmp(res->value, "3"))
4053 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
4054 else if (!strcmp(res->value, "4"))
4055 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
4056 else if (!strcmp(res->value, "8"))
4057 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
4058 else if (!strcmp(res->value, "16"))
4059 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
4060 else if (!strcmp(res->value, "32"))
4061 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
4063 bypass_timeout = RTE_BYPASS_TMT_OFF;
4066 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4067 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4069 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4070 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4072 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4073 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4074 timeout, "timeout");
4075 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4076 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4077 value, "0#1.5#2#3#4#8#16#32");
4079 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4080 .f = cmd_set_bypass_timeout_parsed,
4081 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4082 "Set the NIC bypass watchdog timeout in seconds",
4085 (void *)&cmd_setbypass_timeout_set,
4086 (void *)&cmd_setbypass_timeout_bypass,
4087 (void *)&cmd_setbypass_timeout_timeout,
4088 (void *)&cmd_setbypass_timeout_value,
4093 /* *** SHOW NIC BYPASS MODE *** */
4094 struct cmd_show_bypass_config_result {
4095 cmdline_fixed_string_t show;
4096 cmdline_fixed_string_t bypass;
4097 cmdline_fixed_string_t config;
4102 cmd_show_bypass_config_parsed(void *parsed_result,
4103 __attribute__((unused)) struct cmdline *cl,
4104 __attribute__((unused)) void *data)
4106 struct cmd_show_bypass_config_result *res = parsed_result;
4107 uint32_t event_mode;
4108 uint32_t bypass_mode;
4109 portid_t port_id = res->port_id;
4110 uint32_t timeout = bypass_timeout;
4113 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
4114 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4115 static const char * const modes[RTE_BYPASS_MODE_NUM] =
4116 {"UNKNOWN", "normal", "bypass", "isolate"};
4117 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
4124 int num_events = (sizeof events) / (sizeof events[0]);
4126 /* Display the bypass mode.*/
4127 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
4128 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4132 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
4133 bypass_mode = RTE_BYPASS_MODE_NONE;
4135 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4138 /* Display the bypass timeout.*/
4139 if (!RTE_BYPASS_TMT_VALID(timeout))
4140 timeout = RTE_BYPASS_TMT_OFF;
4142 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4144 /* Display the bypass events and associated modes. */
4145 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
4147 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
4148 printf("\tFailed to get bypass mode for event = %s\n",
4151 if (!RTE_BYPASS_MODE_VALID(event_mode))
4152 event_mode = RTE_BYPASS_MODE_NONE;
4154 printf("\tbypass event: %-16s = %s\n", events[i],
4160 cmdline_parse_token_string_t cmd_showbypass_config_show =
4161 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4163 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4164 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4166 cmdline_parse_token_string_t cmd_showbypass_config_config =
4167 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4169 cmdline_parse_token_num_t cmd_showbypass_config_port =
4170 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4173 cmdline_parse_inst_t cmd_show_bypass_config = {
4174 .f = cmd_show_bypass_config_parsed,
4175 .help_str = "show bypass config <port_id>: "
4176 "Show the NIC bypass config for port_id",
4179 (void *)&cmd_showbypass_config_show,
4180 (void *)&cmd_showbypass_config_bypass,
4181 (void *)&cmd_showbypass_config_config,
4182 (void *)&cmd_showbypass_config_port,
4188 #ifdef RTE_LIBRTE_PMD_BOND
4189 /* *** SET BONDING MODE *** */
4190 struct cmd_set_bonding_mode_result {
4191 cmdline_fixed_string_t set;
4192 cmdline_fixed_string_t bonding;
4193 cmdline_fixed_string_t mode;
4198 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4199 __attribute__((unused)) struct cmdline *cl,
4200 __attribute__((unused)) void *data)
4202 struct cmd_set_bonding_mode_result *res = parsed_result;
4203 portid_t port_id = res->port_id;
4205 /* Set the bonding mode for the relevant port. */
4206 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4207 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4210 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4211 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4213 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4214 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4215 bonding, "bonding");
4216 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4217 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4219 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4220 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4222 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4223 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4226 cmdline_parse_inst_t cmd_set_bonding_mode = {
4227 .f = cmd_set_bonding_mode_parsed,
4228 .help_str = "set bonding mode <mode_value> <port_id>: "
4229 "Set the bonding mode for port_id",
4232 (void *) &cmd_setbonding_mode_set,
4233 (void *) &cmd_setbonding_mode_bonding,
4234 (void *) &cmd_setbonding_mode_mode,
4235 (void *) &cmd_setbonding_mode_value,
4236 (void *) &cmd_setbonding_mode_port,
4241 /* *** SET BALANCE XMIT POLICY *** */
4242 struct cmd_set_bonding_balance_xmit_policy_result {
4243 cmdline_fixed_string_t set;
4244 cmdline_fixed_string_t bonding;
4245 cmdline_fixed_string_t balance_xmit_policy;
4247 cmdline_fixed_string_t policy;
4250 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4251 __attribute__((unused)) struct cmdline *cl,
4252 __attribute__((unused)) void *data)
4254 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4255 portid_t port_id = res->port_id;
4258 if (!strcmp(res->policy, "l2")) {
4259 policy = BALANCE_XMIT_POLICY_LAYER2;
4260 } else if (!strcmp(res->policy, "l23")) {
4261 policy = BALANCE_XMIT_POLICY_LAYER23;
4262 } else if (!strcmp(res->policy, "l34")) {
4263 policy = BALANCE_XMIT_POLICY_LAYER34;
4265 printf("\t Invalid xmit policy selection");
4269 /* Set the bonding mode for the relevant port. */
4270 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4271 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4276 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4277 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4279 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4280 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4281 bonding, "bonding");
4282 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4283 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4284 balance_xmit_policy, "balance_xmit_policy");
4285 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4286 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4288 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4289 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4290 policy, "l2#l23#l34");
4292 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4293 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4294 .help_str = "set bonding balance_xmit_policy <port_id> "
4296 "Set the bonding balance_xmit_policy for port_id",
4299 (void *)&cmd_setbonding_balance_xmit_policy_set,
4300 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4301 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4302 (void *)&cmd_setbonding_balance_xmit_policy_port,
4303 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4308 /* *** SHOW NIC BONDING CONFIGURATION *** */
4309 struct cmd_show_bonding_config_result {
4310 cmdline_fixed_string_t show;
4311 cmdline_fixed_string_t bonding;
4312 cmdline_fixed_string_t config;
4316 static void cmd_show_bonding_config_parsed(void *parsed_result,
4317 __attribute__((unused)) struct cmdline *cl,
4318 __attribute__((unused)) void *data)
4320 struct cmd_show_bonding_config_result *res = parsed_result;
4322 uint8_t slaves[RTE_MAX_ETHPORTS];
4323 int num_slaves, num_active_slaves;
4326 portid_t port_id = res->port_id;
4328 /* Display the bonding mode.*/
4329 bonding_mode = rte_eth_bond_mode_get(port_id);
4330 if (bonding_mode < 0) {
4331 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4334 printf("\tBonding mode: %d\n", bonding_mode);
4336 if (bonding_mode == BONDING_MODE_BALANCE) {
4337 int balance_xmit_policy;
4339 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4340 if (balance_xmit_policy < 0) {
4341 printf("\tFailed to get balance xmit policy for port = %d\n",
4345 printf("\tBalance Xmit Policy: ");
4347 switch (balance_xmit_policy) {
4348 case BALANCE_XMIT_POLICY_LAYER2:
4349 printf("BALANCE_XMIT_POLICY_LAYER2");
4351 case BALANCE_XMIT_POLICY_LAYER23:
4352 printf("BALANCE_XMIT_POLICY_LAYER23");
4354 case BALANCE_XMIT_POLICY_LAYER34:
4355 printf("BALANCE_XMIT_POLICY_LAYER34");
4362 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4364 if (num_slaves < 0) {
4365 printf("\tFailed to get slave list for port = %d\n", port_id);
4368 if (num_slaves > 0) {
4369 printf("\tSlaves (%d): [", num_slaves);
4370 for (i = 0; i < num_slaves - 1; i++)
4371 printf("%d ", slaves[i]);
4373 printf("%d]\n", slaves[num_slaves - 1]);
4375 printf("\tSlaves: []\n");
4379 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4382 if (num_active_slaves < 0) {
4383 printf("\tFailed to get active slave list for port = %d\n", port_id);
4386 if (num_active_slaves > 0) {
4387 printf("\tActive Slaves (%d): [", num_active_slaves);
4388 for (i = 0; i < num_active_slaves - 1; i++)
4389 printf("%d ", slaves[i]);
4391 printf("%d]\n", slaves[num_active_slaves - 1]);
4394 printf("\tActive Slaves: []\n");
4398 primary_id = rte_eth_bond_primary_get(port_id);
4399 if (primary_id < 0) {
4400 printf("\tFailed to get primary slave for port = %d\n", port_id);
4403 printf("\tPrimary: [%d]\n", primary_id);
4407 cmdline_parse_token_string_t cmd_showbonding_config_show =
4408 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4410 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
4411 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4412 bonding, "bonding");
4413 cmdline_parse_token_string_t cmd_showbonding_config_config =
4414 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
4416 cmdline_parse_token_num_t cmd_showbonding_config_port =
4417 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
4420 cmdline_parse_inst_t cmd_show_bonding_config = {
4421 .f = cmd_show_bonding_config_parsed,
4422 .help_str = "show bonding config <port_id>: "
4423 "Show the bonding config for port_id",
4426 (void *)&cmd_showbonding_config_show,
4427 (void *)&cmd_showbonding_config_bonding,
4428 (void *)&cmd_showbonding_config_config,
4429 (void *)&cmd_showbonding_config_port,
4434 /* *** SET BONDING PRIMARY *** */
4435 struct cmd_set_bonding_primary_result {
4436 cmdline_fixed_string_t set;
4437 cmdline_fixed_string_t bonding;
4438 cmdline_fixed_string_t primary;
4443 static void cmd_set_bonding_primary_parsed(void *parsed_result,
4444 __attribute__((unused)) struct cmdline *cl,
4445 __attribute__((unused)) void *data)
4447 struct cmd_set_bonding_primary_result *res = parsed_result;
4448 portid_t master_port_id = res->port_id;
4449 portid_t slave_port_id = res->slave_id;
4451 /* Set the primary slave for a bonded device. */
4452 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
4453 printf("\t Failed to set primary slave for port = %d.\n",
4460 cmdline_parse_token_string_t cmd_setbonding_primary_set =
4461 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4463 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
4464 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4465 bonding, "bonding");
4466 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
4467 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
4468 primary, "primary");
4469 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
4470 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4472 cmdline_parse_token_num_t cmd_setbonding_primary_port =
4473 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
4476 cmdline_parse_inst_t cmd_set_bonding_primary = {
4477 .f = cmd_set_bonding_primary_parsed,
4478 .help_str = "set bonding primary <slave_id> <port_id>: "
4479 "Set the primary slave for port_id",
4482 (void *)&cmd_setbonding_primary_set,
4483 (void *)&cmd_setbonding_primary_bonding,
4484 (void *)&cmd_setbonding_primary_primary,
4485 (void *)&cmd_setbonding_primary_slave,
4486 (void *)&cmd_setbonding_primary_port,
4491 /* *** ADD SLAVE *** */
4492 struct cmd_add_bonding_slave_result {
4493 cmdline_fixed_string_t add;
4494 cmdline_fixed_string_t bonding;
4495 cmdline_fixed_string_t slave;
4500 static void cmd_add_bonding_slave_parsed(void *parsed_result,
4501 __attribute__((unused)) struct cmdline *cl,
4502 __attribute__((unused)) void *data)
4504 struct cmd_add_bonding_slave_result *res = parsed_result;
4505 portid_t master_port_id = res->port_id;
4506 portid_t slave_port_id = res->slave_id;
4508 /* Set the primary slave for a bonded device. */
4509 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
4510 printf("\t Failed to add slave %d to master port = %d.\n",
4511 slave_port_id, master_port_id);
4515 set_port_slave_flag(slave_port_id);
4518 cmdline_parse_token_string_t cmd_addbonding_slave_add =
4519 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4521 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
4522 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4523 bonding, "bonding");
4524 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
4525 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
4527 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
4528 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4530 cmdline_parse_token_num_t cmd_addbonding_slave_port =
4531 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
4534 cmdline_parse_inst_t cmd_add_bonding_slave = {
4535 .f = cmd_add_bonding_slave_parsed,
4536 .help_str = "add bonding slave <slave_id> <port_id>: "
4537 "Add a slave device to a bonded device",
4540 (void *)&cmd_addbonding_slave_add,
4541 (void *)&cmd_addbonding_slave_bonding,
4542 (void *)&cmd_addbonding_slave_slave,
4543 (void *)&cmd_addbonding_slave_slaveid,
4544 (void *)&cmd_addbonding_slave_port,
4549 /* *** REMOVE SLAVE *** */
4550 struct cmd_remove_bonding_slave_result {
4551 cmdline_fixed_string_t remove;
4552 cmdline_fixed_string_t bonding;
4553 cmdline_fixed_string_t slave;
4558 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
4559 __attribute__((unused)) struct cmdline *cl,
4560 __attribute__((unused)) void *data)
4562 struct cmd_remove_bonding_slave_result *res = parsed_result;
4563 portid_t master_port_id = res->port_id;
4564 portid_t slave_port_id = res->slave_id;
4566 /* Set the primary slave for a bonded device. */
4567 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
4568 printf("\t Failed to remove slave %d from master port = %d.\n",
4569 slave_port_id, master_port_id);
4573 clear_port_slave_flag(slave_port_id);
4576 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
4577 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4579 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
4580 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4581 bonding, "bonding");
4582 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
4583 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
4585 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
4586 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4588 cmdline_parse_token_num_t cmd_removebonding_slave_port =
4589 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
4592 cmdline_parse_inst_t cmd_remove_bonding_slave = {
4593 .f = cmd_remove_bonding_slave_parsed,
4594 .help_str = "remove bonding slave <slave_id> <port_id>: "
4595 "Remove a slave device from a bonded device",
4598 (void *)&cmd_removebonding_slave_remove,
4599 (void *)&cmd_removebonding_slave_bonding,
4600 (void *)&cmd_removebonding_slave_slave,
4601 (void *)&cmd_removebonding_slave_slaveid,
4602 (void *)&cmd_removebonding_slave_port,
4607 /* *** CREATE BONDED DEVICE *** */
4608 struct cmd_create_bonded_device_result {
4609 cmdline_fixed_string_t create;
4610 cmdline_fixed_string_t bonded;
4611 cmdline_fixed_string_t device;
4616 static int bond_dev_num = 0;
4618 static void cmd_create_bonded_device_parsed(void *parsed_result,
4619 __attribute__((unused)) struct cmdline *cl,
4620 __attribute__((unused)) void *data)
4622 struct cmd_create_bonded_device_result *res = parsed_result;
4623 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
4626 if (test_done == 0) {
4627 printf("Please stop forwarding first\n");
4631 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bond_testpmd_%d",
4634 /* Create a new bonded device. */
4635 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
4637 printf("\t Failed to create bonded device.\n");
4640 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
4643 /* Update number of ports */
4644 nb_ports = rte_eth_dev_count();
4645 reconfig(port_id, res->socket);
4646 rte_eth_promiscuous_enable(port_id);
4647 ports[port_id].enabled = 1;
4652 cmdline_parse_token_string_t cmd_createbonded_device_create =
4653 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4655 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
4656 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4658 cmdline_parse_token_string_t cmd_createbonded_device_device =
4659 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
4661 cmdline_parse_token_num_t cmd_createbonded_device_mode =
4662 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4664 cmdline_parse_token_num_t cmd_createbonded_device_socket =
4665 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
4668 cmdline_parse_inst_t cmd_create_bonded_device = {
4669 .f = cmd_create_bonded_device_parsed,
4670 .help_str = "create bonded device <mode> <socket>: "
4671 "Create a new bonded device with specific bonding mode and socket",
4674 (void *)&cmd_createbonded_device_create,
4675 (void *)&cmd_createbonded_device_bonded,
4676 (void *)&cmd_createbonded_device_device,
4677 (void *)&cmd_createbonded_device_mode,
4678 (void *)&cmd_createbonded_device_socket,
4683 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
4684 struct cmd_set_bond_mac_addr_result {
4685 cmdline_fixed_string_t set;
4686 cmdline_fixed_string_t bonding;
4687 cmdline_fixed_string_t mac_addr;
4689 struct ether_addr address;
4692 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
4693 __attribute__((unused)) struct cmdline *cl,
4694 __attribute__((unused)) void *data)
4696 struct cmd_set_bond_mac_addr_result *res = parsed_result;
4699 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
4702 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
4704 /* check the return value and print it if is < 0 */
4706 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4709 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
4710 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
4711 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
4712 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
4714 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
4715 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
4717 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
4718 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
4719 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
4720 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
4722 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
4723 .f = cmd_set_bond_mac_addr_parsed,
4725 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
4727 (void *)&cmd_set_bond_mac_addr_set,
4728 (void *)&cmd_set_bond_mac_addr_bonding,
4729 (void *)&cmd_set_bond_mac_addr_mac,
4730 (void *)&cmd_set_bond_mac_addr_portnum,
4731 (void *)&cmd_set_bond_mac_addr_addr,
4737 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
4738 struct cmd_set_bond_mon_period_result {
4739 cmdline_fixed_string_t set;
4740 cmdline_fixed_string_t bonding;
4741 cmdline_fixed_string_t mon_period;
4746 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
4747 __attribute__((unused)) struct cmdline *cl,
4748 __attribute__((unused)) void *data)
4750 struct cmd_set_bond_mon_period_result *res = parsed_result;
4753 if (res->port_num >= nb_ports) {
4754 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
4758 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
4760 /* check the return value and print it if is < 0 */
4762 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
4765 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
4766 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4768 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
4769 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4770 bonding, "bonding");
4771 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
4772 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
4773 mon_period, "mon_period");
4774 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
4775 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4777 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
4778 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
4781 cmdline_parse_inst_t cmd_set_bond_mon_period = {
4782 .f = cmd_set_bond_mon_period_parsed,
4784 .help_str = "set bonding mon_period <port_id> <period_ms>",
4786 (void *)&cmd_set_bond_mon_period_set,
4787 (void *)&cmd_set_bond_mon_period_bonding,
4788 (void *)&cmd_set_bond_mon_period_mon_period,
4789 (void *)&cmd_set_bond_mon_period_portnum,
4790 (void *)&cmd_set_bond_mon_period_period_ms,
4795 #endif /* RTE_LIBRTE_PMD_BOND */
4797 /* *** SET FORWARDING MODE *** */
4798 struct cmd_set_fwd_mode_result {
4799 cmdline_fixed_string_t set;
4800 cmdline_fixed_string_t fwd;
4801 cmdline_fixed_string_t mode;
4804 static void cmd_set_fwd_mode_parsed(void *parsed_result,
4805 __attribute__((unused)) struct cmdline *cl,
4806 __attribute__((unused)) void *data)
4808 struct cmd_set_fwd_mode_result *res = parsed_result;
4811 set_pkt_forwarding_mode(res->mode);
4814 cmdline_parse_token_string_t cmd_setfwd_set =
4815 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
4816 cmdline_parse_token_string_t cmd_setfwd_fwd =
4817 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
4818 cmdline_parse_token_string_t cmd_setfwd_mode =
4819 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
4820 "" /* defined at init */);
4822 cmdline_parse_inst_t cmd_set_fwd_mode = {
4823 .f = cmd_set_fwd_mode_parsed,
4825 .help_str = NULL, /* defined at init */
4827 (void *)&cmd_setfwd_set,
4828 (void *)&cmd_setfwd_fwd,
4829 (void *)&cmd_setfwd_mode,
4834 static void cmd_set_fwd_mode_init(void)
4837 static char token[128];
4838 static char help[256];
4839 cmdline_parse_token_string_t *token_struct;
4841 modes = list_pkt_forwarding_modes();
4842 snprintf(help, sizeof(help), "set fwd %s: "
4843 "Set packet forwarding mode", modes);
4844 cmd_set_fwd_mode.help_str = help;
4846 /* string token separator is # */
4847 for (c = token; *modes != '\0'; modes++)
4852 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
4853 token_struct->string_data.str = token;
4856 /* *** SET RETRY FORWARDING MODE *** */
4857 struct cmd_set_fwd_retry_mode_result {
4858 cmdline_fixed_string_t set;
4859 cmdline_fixed_string_t fwd;
4860 cmdline_fixed_string_t mode;
4861 cmdline_fixed_string_t retry;
4864 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
4865 __attribute__((unused)) struct cmdline *cl,
4866 __attribute__((unused)) void *data)
4868 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
4871 set_pkt_forwarding_mode(res->mode);
4874 cmdline_parse_token_string_t cmd_setfwd_retry_set =
4875 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4877 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
4878 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4880 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
4881 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4883 "" /* defined at init */);
4884 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
4885 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
4888 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
4889 .f = cmd_set_fwd_retry_mode_parsed,
4891 .help_str = NULL, /* defined at init */
4893 (void *)&cmd_setfwd_retry_set,
4894 (void *)&cmd_setfwd_retry_fwd,
4895 (void *)&cmd_setfwd_retry_mode,
4896 (void *)&cmd_setfwd_retry_retry,
4901 static void cmd_set_fwd_retry_mode_init(void)
4904 static char token[128];
4905 static char help[256];
4906 cmdline_parse_token_string_t *token_struct;
4908 modes = list_pkt_forwarding_retry_modes();
4909 snprintf(help, sizeof(help), "set fwd %s retry: "
4910 "Set packet forwarding mode with retry", modes);
4911 cmd_set_fwd_retry_mode.help_str = help;
4913 /* string token separator is # */
4914 for (c = token; *modes != '\0'; modes++)
4919 token_struct = (cmdline_parse_token_string_t *)
4920 cmd_set_fwd_retry_mode.tokens[2];
4921 token_struct->string_data.str = token;
4924 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
4925 struct cmd_set_burst_tx_retry_result {
4926 cmdline_fixed_string_t set;
4927 cmdline_fixed_string_t burst;
4928 cmdline_fixed_string_t tx;
4929 cmdline_fixed_string_t delay;
4931 cmdline_fixed_string_t retry;
4935 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
4936 __attribute__((unused)) struct cmdline *cl,
4937 __attribute__((unused)) void *data)
4939 struct cmd_set_burst_tx_retry_result *res = parsed_result;
4941 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
4942 && !strcmp(res->tx, "tx")) {
4943 if (!strcmp(res->delay, "delay"))
4944 burst_tx_delay_time = res->time;
4945 if (!strcmp(res->retry, "retry"))
4946 burst_tx_retry_num = res->retry_num;
4951 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4952 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4953 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4954 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4956 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4957 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4958 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4959 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4960 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4961 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4962 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4963 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4964 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4965 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4967 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4968 .f = cmd_set_burst_tx_retry_parsed,
4969 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
4971 (void *)&cmd_set_burst_tx_retry_set,
4972 (void *)&cmd_set_burst_tx_retry_burst,
4973 (void *)&cmd_set_burst_tx_retry_tx,
4974 (void *)&cmd_set_burst_tx_retry_delay,
4975 (void *)&cmd_set_burst_tx_retry_time,
4976 (void *)&cmd_set_burst_tx_retry_retry,
4977 (void *)&cmd_set_burst_tx_retry_retry_num,
4982 /* *** SET PROMISC MODE *** */
4983 struct cmd_set_promisc_mode_result {
4984 cmdline_fixed_string_t set;
4985 cmdline_fixed_string_t promisc;
4986 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4987 uint8_t port_num; /* valid if "allports" argument == 0 */
4988 cmdline_fixed_string_t mode;
4991 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4992 __attribute__((unused)) struct cmdline *cl,
4995 struct cmd_set_promisc_mode_result *res = parsed_result;
4999 if (!strcmp(res->mode, "on"))
5006 FOREACH_PORT(i, ports) {
5008 rte_eth_promiscuous_enable(i);
5010 rte_eth_promiscuous_disable(i);
5015 rte_eth_promiscuous_enable(res->port_num);
5017 rte_eth_promiscuous_disable(res->port_num);
5021 cmdline_parse_token_string_t cmd_setpromisc_set =
5022 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5023 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5024 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5026 cmdline_parse_token_string_t cmd_setpromisc_portall =
5027 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5029 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5030 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5032 cmdline_parse_token_string_t cmd_setpromisc_mode =
5033 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5036 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5037 .f = cmd_set_promisc_mode_parsed,
5039 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5041 (void *)&cmd_setpromisc_set,
5042 (void *)&cmd_setpromisc_promisc,
5043 (void *)&cmd_setpromisc_portall,
5044 (void *)&cmd_setpromisc_mode,
5049 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5050 .f = cmd_set_promisc_mode_parsed,
5052 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5054 (void *)&cmd_setpromisc_set,
5055 (void *)&cmd_setpromisc_promisc,
5056 (void *)&cmd_setpromisc_portnum,
5057 (void *)&cmd_setpromisc_mode,
5062 /* *** SET ALLMULTI MODE *** */
5063 struct cmd_set_allmulti_mode_result {
5064 cmdline_fixed_string_t set;
5065 cmdline_fixed_string_t allmulti;
5066 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5067 uint8_t port_num; /* valid if "allports" argument == 0 */
5068 cmdline_fixed_string_t mode;
5071 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5072 __attribute__((unused)) struct cmdline *cl,
5075 struct cmd_set_allmulti_mode_result *res = parsed_result;
5079 if (!strcmp(res->mode, "on"))
5086 FOREACH_PORT(i, ports) {
5088 rte_eth_allmulticast_enable(i);
5090 rte_eth_allmulticast_disable(i);
5095 rte_eth_allmulticast_enable(res->port_num);
5097 rte_eth_allmulticast_disable(res->port_num);
5101 cmdline_parse_token_string_t cmd_setallmulti_set =
5102 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5103 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5104 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5106 cmdline_parse_token_string_t cmd_setallmulti_portall =
5107 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5109 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5110 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5112 cmdline_parse_token_string_t cmd_setallmulti_mode =
5113 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5116 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5117 .f = cmd_set_allmulti_mode_parsed,
5119 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5121 (void *)&cmd_setallmulti_set,
5122 (void *)&cmd_setallmulti_allmulti,
5123 (void *)&cmd_setallmulti_portall,
5124 (void *)&cmd_setallmulti_mode,
5129 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5130 .f = cmd_set_allmulti_mode_parsed,
5132 .help_str = "set allmulti <port_id> on|off: "
5133 "Set allmulti mode on port_id",
5135 (void *)&cmd_setallmulti_set,
5136 (void *)&cmd_setallmulti_allmulti,
5137 (void *)&cmd_setallmulti_portnum,
5138 (void *)&cmd_setallmulti_mode,
5143 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5144 struct cmd_link_flow_ctrl_set_result {
5145 cmdline_fixed_string_t set;
5146 cmdline_fixed_string_t flow_ctrl;
5147 cmdline_fixed_string_t rx;
5148 cmdline_fixed_string_t rx_lfc_mode;
5149 cmdline_fixed_string_t tx;
5150 cmdline_fixed_string_t tx_lfc_mode;
5151 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5152 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5153 cmdline_fixed_string_t autoneg_str;
5154 cmdline_fixed_string_t autoneg;
5155 cmdline_fixed_string_t hw_str;
5156 uint32_t high_water;
5157 cmdline_fixed_string_t lw_str;
5159 cmdline_fixed_string_t pt_str;
5160 uint16_t pause_time;
5161 cmdline_fixed_string_t xon_str;
5166 cmdline_parse_token_string_t cmd_lfc_set_set =
5167 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5169 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5170 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5171 flow_ctrl, "flow_ctrl");
5172 cmdline_parse_token_string_t cmd_lfc_set_rx =
5173 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5175 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5176 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5177 rx_lfc_mode, "on#off");
5178 cmdline_parse_token_string_t cmd_lfc_set_tx =
5179 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5181 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5182 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5183 tx_lfc_mode, "on#off");
5184 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5185 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5186 hw_str, "high_water");
5187 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5188 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5189 high_water, UINT32);
5190 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5191 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5192 lw_str, "low_water");
5193 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5194 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5196 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5197 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5198 pt_str, "pause_time");
5199 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5200 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5201 pause_time, UINT16);
5202 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5203 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5204 xon_str, "send_xon");
5205 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5206 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5208 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5209 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5210 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5211 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5212 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5213 mac_ctrl_frame_fwd_mode, "on#off");
5214 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5215 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5216 autoneg_str, "autoneg");
5217 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5218 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5220 cmdline_parse_token_num_t cmd_lfc_set_portid =
5221 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5224 /* forward declaration */
5226 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5229 cmdline_parse_inst_t cmd_link_flow_control_set = {
5230 .f = cmd_link_flow_ctrl_set_parsed,
5232 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5233 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5234 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5236 (void *)&cmd_lfc_set_set,
5237 (void *)&cmd_lfc_set_flow_ctrl,
5238 (void *)&cmd_lfc_set_rx,
5239 (void *)&cmd_lfc_set_rx_mode,
5240 (void *)&cmd_lfc_set_tx,
5241 (void *)&cmd_lfc_set_tx_mode,
5242 (void *)&cmd_lfc_set_high_water,
5243 (void *)&cmd_lfc_set_low_water,
5244 (void *)&cmd_lfc_set_pause_time,
5245 (void *)&cmd_lfc_set_send_xon,
5246 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5247 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5248 (void *)&cmd_lfc_set_autoneg_str,
5249 (void *)&cmd_lfc_set_autoneg,
5250 (void *)&cmd_lfc_set_portid,
5255 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5256 .f = cmd_link_flow_ctrl_set_parsed,
5257 .data = (void *)&cmd_link_flow_control_set_rx,
5258 .help_str = "set flow_ctrl rx on|off <port_id>: "
5259 "Change rx flow control parameter",
5261 (void *)&cmd_lfc_set_set,
5262 (void *)&cmd_lfc_set_flow_ctrl,
5263 (void *)&cmd_lfc_set_rx,
5264 (void *)&cmd_lfc_set_rx_mode,
5265 (void *)&cmd_lfc_set_portid,
5270 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5271 .f = cmd_link_flow_ctrl_set_parsed,
5272 .data = (void *)&cmd_link_flow_control_set_tx,
5273 .help_str = "set flow_ctrl tx on|off <port_id>: "
5274 "Change tx flow control parameter",
5276 (void *)&cmd_lfc_set_set,
5277 (void *)&cmd_lfc_set_flow_ctrl,
5278 (void *)&cmd_lfc_set_tx,
5279 (void *)&cmd_lfc_set_tx_mode,
5280 (void *)&cmd_lfc_set_portid,
5285 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5286 .f = cmd_link_flow_ctrl_set_parsed,
5287 .data = (void *)&cmd_link_flow_control_set_hw,
5288 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5289 "Change high water flow control parameter",
5291 (void *)&cmd_lfc_set_set,
5292 (void *)&cmd_lfc_set_flow_ctrl,
5293 (void *)&cmd_lfc_set_high_water_str,
5294 (void *)&cmd_lfc_set_high_water,
5295 (void *)&cmd_lfc_set_portid,
5300 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5301 .f = cmd_link_flow_ctrl_set_parsed,
5302 .data = (void *)&cmd_link_flow_control_set_lw,
5303 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5304 "Change low water flow control parameter",
5306 (void *)&cmd_lfc_set_set,
5307 (void *)&cmd_lfc_set_flow_ctrl,
5308 (void *)&cmd_lfc_set_low_water_str,
5309 (void *)&cmd_lfc_set_low_water,
5310 (void *)&cmd_lfc_set_portid,
5315 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5316 .f = cmd_link_flow_ctrl_set_parsed,
5317 .data = (void *)&cmd_link_flow_control_set_pt,
5318 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5319 "Change pause time flow control parameter",
5321 (void *)&cmd_lfc_set_set,
5322 (void *)&cmd_lfc_set_flow_ctrl,
5323 (void *)&cmd_lfc_set_pause_time_str,
5324 (void *)&cmd_lfc_set_pause_time,
5325 (void *)&cmd_lfc_set_portid,
5330 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
5331 .f = cmd_link_flow_ctrl_set_parsed,
5332 .data = (void *)&cmd_link_flow_control_set_xon,
5333 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
5334 "Change send_xon flow control parameter",
5336 (void *)&cmd_lfc_set_set,
5337 (void *)&cmd_lfc_set_flow_ctrl,
5338 (void *)&cmd_lfc_set_send_xon_str,
5339 (void *)&cmd_lfc_set_send_xon,
5340 (void *)&cmd_lfc_set_portid,
5345 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
5346 .f = cmd_link_flow_ctrl_set_parsed,
5347 .data = (void *)&cmd_link_flow_control_set_macfwd,
5348 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
5349 "Change mac ctrl fwd flow control parameter",
5351 (void *)&cmd_lfc_set_set,
5352 (void *)&cmd_lfc_set_flow_ctrl,
5353 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5354 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5355 (void *)&cmd_lfc_set_portid,
5360 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
5361 .f = cmd_link_flow_ctrl_set_parsed,
5362 .data = (void *)&cmd_link_flow_control_set_autoneg,
5363 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
5364 "Change autoneg flow control parameter",
5366 (void *)&cmd_lfc_set_set,
5367 (void *)&cmd_lfc_set_flow_ctrl,
5368 (void *)&cmd_lfc_set_autoneg_str,
5369 (void *)&cmd_lfc_set_autoneg,
5370 (void *)&cmd_lfc_set_portid,
5376 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
5377 __attribute__((unused)) struct cmdline *cl,
5380 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
5381 cmdline_parse_inst_t *cmd = data;
5382 struct rte_eth_fc_conf fc_conf;
5388 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5389 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5390 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5391 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5393 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
5394 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
5397 /* Partial command line, retrieve current configuration */
5399 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5401 printf("cannot get current flow ctrl parameters, return"
5402 "code = %d\n", ret);
5406 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
5407 (fc_conf.mode == RTE_FC_FULL))
5409 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
5410 (fc_conf.mode == RTE_FC_FULL))
5414 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
5415 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
5417 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
5418 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
5420 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
5422 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
5423 fc_conf.high_water = res->high_water;
5425 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
5426 fc_conf.low_water = res->low_water;
5428 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
5429 fc_conf.pause_time = res->pause_time;
5431 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
5432 fc_conf.send_xon = res->send_xon;
5434 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
5435 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
5436 fc_conf.mac_ctrl_frame_fwd = 1;
5438 fc_conf.mac_ctrl_frame_fwd = 0;
5441 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
5442 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
5444 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
5446 printf("bad flow contrl parameter, return code = %d \n", ret);
5449 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
5450 struct cmd_priority_flow_ctrl_set_result {
5451 cmdline_fixed_string_t set;
5452 cmdline_fixed_string_t pfc_ctrl;
5453 cmdline_fixed_string_t rx;
5454 cmdline_fixed_string_t rx_pfc_mode;
5455 cmdline_fixed_string_t tx;
5456 cmdline_fixed_string_t tx_pfc_mode;
5457 uint32_t high_water;
5459 uint16_t pause_time;
5465 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5466 __attribute__((unused)) struct cmdline *cl,
5467 __attribute__((unused)) void *data)
5469 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5470 struct rte_eth_pfc_conf pfc_conf;
5471 int rx_fc_enable, tx_fc_enable;
5475 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5476 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5477 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5478 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5480 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5481 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5484 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5485 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5486 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5487 pfc_conf.fc.high_water = res->high_water;
5488 pfc_conf.fc.low_water = res->low_water;
5489 pfc_conf.fc.pause_time = res->pause_time;
5490 pfc_conf.priority = res->priority;
5492 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5494 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5497 cmdline_parse_token_string_t cmd_pfc_set_set =
5498 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5500 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5501 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5502 pfc_ctrl, "pfc_ctrl");
5503 cmdline_parse_token_string_t cmd_pfc_set_rx =
5504 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5506 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5507 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5508 rx_pfc_mode, "on#off");
5509 cmdline_parse_token_string_t cmd_pfc_set_tx =
5510 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5512 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5513 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5514 tx_pfc_mode, "on#off");
5515 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5516 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5517 high_water, UINT32);
5518 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5519 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5521 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5522 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5523 pause_time, UINT16);
5524 cmdline_parse_token_num_t cmd_pfc_set_priority =
5525 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5527 cmdline_parse_token_num_t cmd_pfc_set_portid =
5528 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5531 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5532 .f = cmd_priority_flow_ctrl_set_parsed,
5534 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
5535 "<pause_time> <priority> <port_id>: "
5536 "Configure the Ethernet priority flow control",
5538 (void *)&cmd_pfc_set_set,
5539 (void *)&cmd_pfc_set_flow_ctrl,
5540 (void *)&cmd_pfc_set_rx,
5541 (void *)&cmd_pfc_set_rx_mode,
5542 (void *)&cmd_pfc_set_tx,
5543 (void *)&cmd_pfc_set_tx_mode,
5544 (void *)&cmd_pfc_set_high_water,
5545 (void *)&cmd_pfc_set_low_water,
5546 (void *)&cmd_pfc_set_pause_time,
5547 (void *)&cmd_pfc_set_priority,
5548 (void *)&cmd_pfc_set_portid,
5553 /* *** RESET CONFIGURATION *** */
5554 struct cmd_reset_result {
5555 cmdline_fixed_string_t reset;
5556 cmdline_fixed_string_t def;
5559 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5561 __attribute__((unused)) void *data)
5563 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5564 set_def_fwd_config();
5567 cmdline_parse_token_string_t cmd_reset_set =
5568 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5569 cmdline_parse_token_string_t cmd_reset_def =
5570 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5573 cmdline_parse_inst_t cmd_reset = {
5574 .f = cmd_reset_parsed,
5576 .help_str = "set default: Reset default forwarding configuration",
5578 (void *)&cmd_reset_set,
5579 (void *)&cmd_reset_def,
5584 /* *** START FORWARDING *** */
5585 struct cmd_start_result {
5586 cmdline_fixed_string_t start;
5589 cmdline_parse_token_string_t cmd_start_start =
5590 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5592 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5593 __attribute__((unused)) struct cmdline *cl,
5594 __attribute__((unused)) void *data)
5596 start_packet_forwarding(0);
5599 cmdline_parse_inst_t cmd_start = {
5600 .f = cmd_start_parsed,
5602 .help_str = "start: Start packet forwarding",
5604 (void *)&cmd_start_start,
5609 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5610 struct cmd_start_tx_first_result {
5611 cmdline_fixed_string_t start;
5612 cmdline_fixed_string_t tx_first;
5616 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5617 __attribute__((unused)) struct cmdline *cl,
5618 __attribute__((unused)) void *data)
5620 start_packet_forwarding(1);
5623 cmdline_parse_token_string_t cmd_start_tx_first_start =
5624 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5626 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5627 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5628 tx_first, "tx_first");
5630 cmdline_parse_inst_t cmd_start_tx_first = {
5631 .f = cmd_start_tx_first_parsed,
5633 .help_str = "start tx_first: Start packet forwarding, "
5634 "after sending 1 burst of packets",
5636 (void *)&cmd_start_tx_first_start,
5637 (void *)&cmd_start_tx_first_tx_first,
5642 /* *** START FORWARDING WITH N TX BURST FIRST *** */
5643 struct cmd_start_tx_first_n_result {
5644 cmdline_fixed_string_t start;
5645 cmdline_fixed_string_t tx_first;
5650 cmd_start_tx_first_n_parsed(void *parsed_result,
5651 __attribute__((unused)) struct cmdline *cl,
5652 __attribute__((unused)) void *data)
5654 struct cmd_start_tx_first_n_result *res = parsed_result;
5656 start_packet_forwarding(res->tx_num);
5659 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
5660 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5662 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
5663 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
5664 tx_first, "tx_first");
5665 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
5666 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
5669 cmdline_parse_inst_t cmd_start_tx_first_n = {
5670 .f = cmd_start_tx_first_n_parsed,
5672 .help_str = "start tx_first <num>: "
5673 "packet forwarding, after sending <num> bursts of packets",
5675 (void *)&cmd_start_tx_first_n_start,
5676 (void *)&cmd_start_tx_first_n_tx_first,
5677 (void *)&cmd_start_tx_first_n_tx_num,
5682 /* *** SET LINK UP *** */
5683 struct cmd_set_link_up_result {
5684 cmdline_fixed_string_t set;
5685 cmdline_fixed_string_t link_up;
5686 cmdline_fixed_string_t port;
5690 cmdline_parse_token_string_t cmd_set_link_up_set =
5691 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5692 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5693 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5695 cmdline_parse_token_string_t cmd_set_link_up_port =
5696 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5697 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5698 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5700 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5701 __attribute__((unused)) struct cmdline *cl,
5702 __attribute__((unused)) void *data)
5704 struct cmd_set_link_up_result *res = parsed_result;
5705 dev_set_link_up(res->port_id);
5708 cmdline_parse_inst_t cmd_set_link_up = {
5709 .f = cmd_set_link_up_parsed,
5711 .help_str = "set link-up port <port id>",
5713 (void *)&cmd_set_link_up_set,
5714 (void *)&cmd_set_link_up_link_up,
5715 (void *)&cmd_set_link_up_port,
5716 (void *)&cmd_set_link_up_port_id,
5721 /* *** SET LINK DOWN *** */
5722 struct cmd_set_link_down_result {
5723 cmdline_fixed_string_t set;
5724 cmdline_fixed_string_t link_down;
5725 cmdline_fixed_string_t port;
5729 cmdline_parse_token_string_t cmd_set_link_down_set =
5730 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5731 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5732 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5734 cmdline_parse_token_string_t cmd_set_link_down_port =
5735 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5736 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5737 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5739 static void cmd_set_link_down_parsed(
5740 __attribute__((unused)) void *parsed_result,
5741 __attribute__((unused)) struct cmdline *cl,
5742 __attribute__((unused)) void *data)
5744 struct cmd_set_link_down_result *res = parsed_result;
5745 dev_set_link_down(res->port_id);
5748 cmdline_parse_inst_t cmd_set_link_down = {
5749 .f = cmd_set_link_down_parsed,
5751 .help_str = "set link-down port <port id>",
5753 (void *)&cmd_set_link_down_set,
5754 (void *)&cmd_set_link_down_link_down,
5755 (void *)&cmd_set_link_down_port,
5756 (void *)&cmd_set_link_down_port_id,
5761 /* *** SHOW CFG *** */
5762 struct cmd_showcfg_result {
5763 cmdline_fixed_string_t show;
5764 cmdline_fixed_string_t cfg;
5765 cmdline_fixed_string_t what;
5768 static void cmd_showcfg_parsed(void *parsed_result,
5769 __attribute__((unused)) struct cmdline *cl,
5770 __attribute__((unused)) void *data)
5772 struct cmd_showcfg_result *res = parsed_result;
5773 if (!strcmp(res->what, "rxtx"))
5774 rxtx_config_display();
5775 else if (!strcmp(res->what, "cores"))
5776 fwd_lcores_config_display();
5777 else if (!strcmp(res->what, "fwd"))
5778 pkt_fwd_config_display(&cur_fwd_config);
5779 else if (!strcmp(res->what, "txpkts"))
5780 show_tx_pkt_segments();
5783 cmdline_parse_token_string_t cmd_showcfg_show =
5784 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5785 cmdline_parse_token_string_t cmd_showcfg_port =
5786 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5787 cmdline_parse_token_string_t cmd_showcfg_what =
5788 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5789 "rxtx#cores#fwd#txpkts");
5791 cmdline_parse_inst_t cmd_showcfg = {
5792 .f = cmd_showcfg_parsed,
5794 .help_str = "show config rxtx|cores|fwd|txpkts",
5796 (void *)&cmd_showcfg_show,
5797 (void *)&cmd_showcfg_port,
5798 (void *)&cmd_showcfg_what,
5803 /* *** SHOW ALL PORT INFO *** */
5804 struct cmd_showportall_result {
5805 cmdline_fixed_string_t show;
5806 cmdline_fixed_string_t port;
5807 cmdline_fixed_string_t what;
5808 cmdline_fixed_string_t all;
5811 static void cmd_showportall_parsed(void *parsed_result,
5812 __attribute__((unused)) struct cmdline *cl,
5813 __attribute__((unused)) void *data)
5817 struct cmd_showportall_result *res = parsed_result;
5818 if (!strcmp(res->show, "clear")) {
5819 if (!strcmp(res->what, "stats"))
5820 FOREACH_PORT(i, ports)
5822 else if (!strcmp(res->what, "xstats"))
5823 FOREACH_PORT(i, ports)
5824 nic_xstats_clear(i);
5825 } else if (!strcmp(res->what, "info"))
5826 FOREACH_PORT(i, ports)
5827 port_infos_display(i);
5828 else if (!strcmp(res->what, "stats"))
5829 FOREACH_PORT(i, ports)
5830 nic_stats_display(i);
5831 else if (!strcmp(res->what, "xstats"))
5832 FOREACH_PORT(i, ports)
5833 nic_xstats_display(i);
5834 else if (!strcmp(res->what, "fdir"))
5835 FOREACH_PORT(i, ports)
5837 else if (!strcmp(res->what, "stat_qmap"))
5838 FOREACH_PORT(i, ports)
5839 nic_stats_mapping_display(i);
5840 else if (!strcmp(res->what, "dcb_tc"))
5841 FOREACH_PORT(i, ports)
5842 port_dcb_info_display(i);
5843 else if (!strcmp(res->what, "cap"))
5844 FOREACH_PORT(i, ports)
5845 port_offload_cap_display(i);
5848 cmdline_parse_token_string_t cmd_showportall_show =
5849 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5851 cmdline_parse_token_string_t cmd_showportall_port =
5852 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5853 cmdline_parse_token_string_t cmd_showportall_what =
5854 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5855 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5856 cmdline_parse_token_string_t cmd_showportall_all =
5857 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5858 cmdline_parse_inst_t cmd_showportall = {
5859 .f = cmd_showportall_parsed,
5861 .help_str = "show|clear port "
5862 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
5864 (void *)&cmd_showportall_show,
5865 (void *)&cmd_showportall_port,
5866 (void *)&cmd_showportall_what,
5867 (void *)&cmd_showportall_all,
5872 /* *** SHOW PORT INFO *** */
5873 struct cmd_showport_result {
5874 cmdline_fixed_string_t show;
5875 cmdline_fixed_string_t port;
5876 cmdline_fixed_string_t what;
5880 static void cmd_showport_parsed(void *parsed_result,
5881 __attribute__((unused)) struct cmdline *cl,
5882 __attribute__((unused)) void *data)
5884 struct cmd_showport_result *res = parsed_result;
5885 if (!strcmp(res->show, "clear")) {
5886 if (!strcmp(res->what, "stats"))
5887 nic_stats_clear(res->portnum);
5888 else if (!strcmp(res->what, "xstats"))
5889 nic_xstats_clear(res->portnum);
5890 } else if (!strcmp(res->what, "info"))
5891 port_infos_display(res->portnum);
5892 else if (!strcmp(res->what, "stats"))
5893 nic_stats_display(res->portnum);
5894 else if (!strcmp(res->what, "xstats"))
5895 nic_xstats_display(res->portnum);
5896 else if (!strcmp(res->what, "fdir"))
5897 fdir_get_infos(res->portnum);
5898 else if (!strcmp(res->what, "stat_qmap"))
5899 nic_stats_mapping_display(res->portnum);
5900 else if (!strcmp(res->what, "dcb_tc"))
5901 port_dcb_info_display(res->portnum);
5902 else if (!strcmp(res->what, "cap"))
5903 port_offload_cap_display(res->portnum);
5906 cmdline_parse_token_string_t cmd_showport_show =
5907 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5909 cmdline_parse_token_string_t cmd_showport_port =
5910 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5911 cmdline_parse_token_string_t cmd_showport_what =
5912 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5913 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
5914 cmdline_parse_token_num_t cmd_showport_portnum =
5915 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);
5917 cmdline_parse_inst_t cmd_showport = {
5918 .f = cmd_showport_parsed,
5920 .help_str = "show|clear port "
5921 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
5924 (void *)&cmd_showport_show,
5925 (void *)&cmd_showport_port,
5926 (void *)&cmd_showport_what,
5927 (void *)&cmd_showport_portnum,
5932 /* *** SHOW QUEUE INFO *** */
5933 struct cmd_showqueue_result {
5934 cmdline_fixed_string_t show;
5935 cmdline_fixed_string_t type;
5936 cmdline_fixed_string_t what;
5942 cmd_showqueue_parsed(void *parsed_result,
5943 __attribute__((unused)) struct cmdline *cl,
5944 __attribute__((unused)) void *data)
5946 struct cmd_showqueue_result *res = parsed_result;
5948 if (!strcmp(res->type, "rxq"))
5949 rx_queue_infos_display(res->portnum, res->queuenum);
5950 else if (!strcmp(res->type, "txq"))
5951 tx_queue_infos_display(res->portnum, res->queuenum);
5954 cmdline_parse_token_string_t cmd_showqueue_show =
5955 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
5956 cmdline_parse_token_string_t cmd_showqueue_type =
5957 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
5958 cmdline_parse_token_string_t cmd_showqueue_what =
5959 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
5960 cmdline_parse_token_num_t cmd_showqueue_portnum =
5961 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT8);
5962 cmdline_parse_token_num_t cmd_showqueue_queuenum =
5963 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
5965 cmdline_parse_inst_t cmd_showqueue = {
5966 .f = cmd_showqueue_parsed,
5968 .help_str = "show rxq|txq info <port_id> <queue_id>",
5970 (void *)&cmd_showqueue_show,
5971 (void *)&cmd_showqueue_type,
5972 (void *)&cmd_showqueue_what,
5973 (void *)&cmd_showqueue_portnum,
5974 (void *)&cmd_showqueue_queuenum,
5979 /* *** READ PORT REGISTER *** */
5980 struct cmd_read_reg_result {
5981 cmdline_fixed_string_t read;
5982 cmdline_fixed_string_t reg;
5988 cmd_read_reg_parsed(void *parsed_result,
5989 __attribute__((unused)) struct cmdline *cl,
5990 __attribute__((unused)) void *data)
5992 struct cmd_read_reg_result *res = parsed_result;
5993 port_reg_display(res->port_id, res->reg_off);
5996 cmdline_parse_token_string_t cmd_read_reg_read =
5997 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5998 cmdline_parse_token_string_t cmd_read_reg_reg =
5999 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6000 cmdline_parse_token_num_t cmd_read_reg_port_id =
6001 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
6002 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6003 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6005 cmdline_parse_inst_t cmd_read_reg = {
6006 .f = cmd_read_reg_parsed,
6008 .help_str = "read reg <port_id> <reg_off>",
6010 (void *)&cmd_read_reg_read,
6011 (void *)&cmd_read_reg_reg,
6012 (void *)&cmd_read_reg_port_id,
6013 (void *)&cmd_read_reg_reg_off,
6018 /* *** READ PORT REGISTER BIT FIELD *** */
6019 struct cmd_read_reg_bit_field_result {
6020 cmdline_fixed_string_t read;
6021 cmdline_fixed_string_t regfield;
6029 cmd_read_reg_bit_field_parsed(void *parsed_result,
6030 __attribute__((unused)) struct cmdline *cl,
6031 __attribute__((unused)) void *data)
6033 struct cmd_read_reg_bit_field_result *res = parsed_result;
6034 port_reg_bit_field_display(res->port_id, res->reg_off,
6035 res->bit1_pos, res->bit2_pos);
6038 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6039 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6041 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6042 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6043 regfield, "regfield");
6044 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6045 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6047 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6048 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6050 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6051 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6053 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6054 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6057 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6058 .f = cmd_read_reg_bit_field_parsed,
6060 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6061 "Read register bit field between bit_x and bit_y included",
6063 (void *)&cmd_read_reg_bit_field_read,
6064 (void *)&cmd_read_reg_bit_field_regfield,
6065 (void *)&cmd_read_reg_bit_field_port_id,
6066 (void *)&cmd_read_reg_bit_field_reg_off,
6067 (void *)&cmd_read_reg_bit_field_bit1_pos,
6068 (void *)&cmd_read_reg_bit_field_bit2_pos,
6073 /* *** READ PORT REGISTER BIT *** */
6074 struct cmd_read_reg_bit_result {
6075 cmdline_fixed_string_t read;
6076 cmdline_fixed_string_t regbit;
6083 cmd_read_reg_bit_parsed(void *parsed_result,
6084 __attribute__((unused)) struct cmdline *cl,
6085 __attribute__((unused)) void *data)
6087 struct cmd_read_reg_bit_result *res = parsed_result;
6088 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6091 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6092 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6093 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6094 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6096 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6097 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
6098 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6099 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6100 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6101 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6103 cmdline_parse_inst_t cmd_read_reg_bit = {
6104 .f = cmd_read_reg_bit_parsed,
6106 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6108 (void *)&cmd_read_reg_bit_read,
6109 (void *)&cmd_read_reg_bit_regbit,
6110 (void *)&cmd_read_reg_bit_port_id,
6111 (void *)&cmd_read_reg_bit_reg_off,
6112 (void *)&cmd_read_reg_bit_bit_pos,
6117 /* *** WRITE PORT REGISTER *** */
6118 struct cmd_write_reg_result {
6119 cmdline_fixed_string_t write;
6120 cmdline_fixed_string_t reg;
6127 cmd_write_reg_parsed(void *parsed_result,
6128 __attribute__((unused)) struct cmdline *cl,
6129 __attribute__((unused)) void *data)
6131 struct cmd_write_reg_result *res = parsed_result;
6132 port_reg_set(res->port_id, res->reg_off, res->value);
6135 cmdline_parse_token_string_t cmd_write_reg_write =
6136 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6137 cmdline_parse_token_string_t cmd_write_reg_reg =
6138 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6139 cmdline_parse_token_num_t cmd_write_reg_port_id =
6140 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
6141 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6142 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6143 cmdline_parse_token_num_t cmd_write_reg_value =
6144 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6146 cmdline_parse_inst_t cmd_write_reg = {
6147 .f = cmd_write_reg_parsed,
6149 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6151 (void *)&cmd_write_reg_write,
6152 (void *)&cmd_write_reg_reg,
6153 (void *)&cmd_write_reg_port_id,
6154 (void *)&cmd_write_reg_reg_off,
6155 (void *)&cmd_write_reg_value,
6160 /* *** WRITE PORT REGISTER BIT FIELD *** */
6161 struct cmd_write_reg_bit_field_result {
6162 cmdline_fixed_string_t write;
6163 cmdline_fixed_string_t regfield;
6172 cmd_write_reg_bit_field_parsed(void *parsed_result,
6173 __attribute__((unused)) struct cmdline *cl,
6174 __attribute__((unused)) void *data)
6176 struct cmd_write_reg_bit_field_result *res = parsed_result;
6177 port_reg_bit_field_set(res->port_id, res->reg_off,
6178 res->bit1_pos, res->bit2_pos, res->value);
6181 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6182 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6184 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6185 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6186 regfield, "regfield");
6187 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6188 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6190 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6191 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6193 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6194 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6196 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6197 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6199 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6200 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6203 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6204 .f = cmd_write_reg_bit_field_parsed,
6206 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6208 "Set register bit field between bit_x and bit_y included",
6210 (void *)&cmd_write_reg_bit_field_write,
6211 (void *)&cmd_write_reg_bit_field_regfield,
6212 (void *)&cmd_write_reg_bit_field_port_id,
6213 (void *)&cmd_write_reg_bit_field_reg_off,
6214 (void *)&cmd_write_reg_bit_field_bit1_pos,
6215 (void *)&cmd_write_reg_bit_field_bit2_pos,
6216 (void *)&cmd_write_reg_bit_field_value,
6221 /* *** WRITE PORT REGISTER BIT *** */
6222 struct cmd_write_reg_bit_result {
6223 cmdline_fixed_string_t write;
6224 cmdline_fixed_string_t regbit;
6232 cmd_write_reg_bit_parsed(void *parsed_result,
6233 __attribute__((unused)) struct cmdline *cl,
6234 __attribute__((unused)) void *data)
6236 struct cmd_write_reg_bit_result *res = parsed_result;
6237 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6240 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6241 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6243 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6244 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6246 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6247 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
6248 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6249 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6250 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6251 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6252 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6253 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6255 cmdline_parse_inst_t cmd_write_reg_bit = {
6256 .f = cmd_write_reg_bit_parsed,
6258 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6261 (void *)&cmd_write_reg_bit_write,
6262 (void *)&cmd_write_reg_bit_regbit,
6263 (void *)&cmd_write_reg_bit_port_id,
6264 (void *)&cmd_write_reg_bit_reg_off,
6265 (void *)&cmd_write_reg_bit_bit_pos,
6266 (void *)&cmd_write_reg_bit_value,
6271 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6272 struct cmd_read_rxd_txd_result {
6273 cmdline_fixed_string_t read;
6274 cmdline_fixed_string_t rxd_txd;
6281 cmd_read_rxd_txd_parsed(void *parsed_result,
6282 __attribute__((unused)) struct cmdline *cl,
6283 __attribute__((unused)) void *data)
6285 struct cmd_read_rxd_txd_result *res = parsed_result;
6287 if (!strcmp(res->rxd_txd, "rxd"))
6288 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6289 else if (!strcmp(res->rxd_txd, "txd"))
6290 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6293 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6294 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6295 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6296 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6298 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6299 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
6300 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6301 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6302 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6303 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6305 cmdline_parse_inst_t cmd_read_rxd_txd = {
6306 .f = cmd_read_rxd_txd_parsed,
6308 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6310 (void *)&cmd_read_rxd_txd_read,
6311 (void *)&cmd_read_rxd_txd_rxd_txd,
6312 (void *)&cmd_read_rxd_txd_port_id,
6313 (void *)&cmd_read_rxd_txd_queue_id,
6314 (void *)&cmd_read_rxd_txd_desc_id,
6320 struct cmd_quit_result {
6321 cmdline_fixed_string_t quit;
6324 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6326 __attribute__((unused)) void *data)
6332 cmdline_parse_token_string_t cmd_quit_quit =
6333 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
6335 cmdline_parse_inst_t cmd_quit = {
6336 .f = cmd_quit_parsed,
6338 .help_str = "quit: Exit application",
6340 (void *)&cmd_quit_quit,
6345 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
6346 struct cmd_mac_addr_result {
6347 cmdline_fixed_string_t mac_addr_cmd;
6348 cmdline_fixed_string_t what;
6350 struct ether_addr address;
6353 static void cmd_mac_addr_parsed(void *parsed_result,
6354 __attribute__((unused)) struct cmdline *cl,
6355 __attribute__((unused)) void *data)
6357 struct cmd_mac_addr_result *res = parsed_result;
6360 if (strcmp(res->what, "add") == 0)
6361 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
6362 else if (strcmp(res->what, "set") == 0)
6363 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
6366 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
6368 /* check the return value and print it if is < 0 */
6370 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
6374 cmdline_parse_token_string_t cmd_mac_addr_cmd =
6375 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
6377 cmdline_parse_token_string_t cmd_mac_addr_what =
6378 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
6380 cmdline_parse_token_num_t cmd_mac_addr_portnum =
6381 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
6382 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
6383 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
6385 cmdline_parse_inst_t cmd_mac_addr = {
6386 .f = cmd_mac_addr_parsed,
6388 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
6389 "Add/Remove/Set MAC address on port_id",
6391 (void *)&cmd_mac_addr_cmd,
6392 (void *)&cmd_mac_addr_what,
6393 (void *)&cmd_mac_addr_portnum,
6394 (void *)&cmd_mac_addr_addr,
6400 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
6401 struct cmd_set_qmap_result {
6402 cmdline_fixed_string_t set;
6403 cmdline_fixed_string_t qmap;
6404 cmdline_fixed_string_t what;
6411 cmd_set_qmap_parsed(void *parsed_result,
6412 __attribute__((unused)) struct cmdline *cl,
6413 __attribute__((unused)) void *data)
6415 struct cmd_set_qmap_result *res = parsed_result;
6416 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
6418 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
6421 cmdline_parse_token_string_t cmd_setqmap_set =
6422 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6424 cmdline_parse_token_string_t cmd_setqmap_qmap =
6425 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6427 cmdline_parse_token_string_t cmd_setqmap_what =
6428 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
6430 cmdline_parse_token_num_t cmd_setqmap_portid =
6431 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6433 cmdline_parse_token_num_t cmd_setqmap_queueid =
6434 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6436 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
6437 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
6440 cmdline_parse_inst_t cmd_set_qmap = {
6441 .f = cmd_set_qmap_parsed,
6443 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
6444 "Set statistics mapping value on tx|rx queue_id of port_id",
6446 (void *)&cmd_setqmap_set,
6447 (void *)&cmd_setqmap_qmap,
6448 (void *)&cmd_setqmap_what,
6449 (void *)&cmd_setqmap_portid,
6450 (void *)&cmd_setqmap_queueid,
6451 (void *)&cmd_setqmap_mapvalue,
6456 /* *** CONFIGURE UNICAST HASH TABLE *** */
6457 struct cmd_set_uc_hash_table {
6458 cmdline_fixed_string_t set;
6459 cmdline_fixed_string_t port;
6461 cmdline_fixed_string_t what;
6462 struct ether_addr address;
6463 cmdline_fixed_string_t mode;
6467 cmd_set_uc_hash_parsed(void *parsed_result,
6468 __attribute__((unused)) struct cmdline *cl,
6469 __attribute__((unused)) void *data)
6472 struct cmd_set_uc_hash_table *res = parsed_result;
6474 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6476 if (strcmp(res->what, "uta") == 0)
6477 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
6478 &res->address,(uint8_t)is_on);
6480 printf("bad unicast hash table parameter, return code = %d \n", ret);
6484 cmdline_parse_token_string_t cmd_set_uc_hash_set =
6485 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6487 cmdline_parse_token_string_t cmd_set_uc_hash_port =
6488 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6490 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
6491 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
6493 cmdline_parse_token_string_t cmd_set_uc_hash_what =
6494 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6496 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
6497 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
6499 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
6500 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
6503 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
6504 .f = cmd_set_uc_hash_parsed,
6506 .help_str = "set port <port_id> uta <mac_addr> on|off)",
6508 (void *)&cmd_set_uc_hash_set,
6509 (void *)&cmd_set_uc_hash_port,
6510 (void *)&cmd_set_uc_hash_portid,
6511 (void *)&cmd_set_uc_hash_what,
6512 (void *)&cmd_set_uc_hash_mac,
6513 (void *)&cmd_set_uc_hash_mode,
6518 struct cmd_set_uc_all_hash_table {
6519 cmdline_fixed_string_t set;
6520 cmdline_fixed_string_t port;
6522 cmdline_fixed_string_t what;
6523 cmdline_fixed_string_t value;
6524 cmdline_fixed_string_t mode;
6528 cmd_set_uc_all_hash_parsed(void *parsed_result,
6529 __attribute__((unused)) struct cmdline *cl,
6530 __attribute__((unused)) void *data)
6533 struct cmd_set_uc_all_hash_table *res = parsed_result;
6535 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6537 if ((strcmp(res->what, "uta") == 0) &&
6538 (strcmp(res->value, "all") == 0))
6539 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
6541 printf("bad unicast hash table parameter,"
6542 "return code = %d \n", ret);
6545 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
6546 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6548 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
6549 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6551 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
6552 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
6554 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
6555 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6557 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
6558 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6560 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
6561 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
6564 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
6565 .f = cmd_set_uc_all_hash_parsed,
6567 .help_str = "set port <port_id> uta all on|off",
6569 (void *)&cmd_set_uc_all_hash_set,
6570 (void *)&cmd_set_uc_all_hash_port,
6571 (void *)&cmd_set_uc_all_hash_portid,
6572 (void *)&cmd_set_uc_all_hash_what,
6573 (void *)&cmd_set_uc_all_hash_value,
6574 (void *)&cmd_set_uc_all_hash_mode,
6579 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6580 struct cmd_set_vf_macvlan_filter {
6581 cmdline_fixed_string_t set;
6582 cmdline_fixed_string_t port;
6584 cmdline_fixed_string_t vf;
6586 struct ether_addr address;
6587 cmdline_fixed_string_t filter_type;
6588 cmdline_fixed_string_t mode;
6592 cmd_set_vf_macvlan_parsed(void *parsed_result,
6593 __attribute__((unused)) struct cmdline *cl,
6594 __attribute__((unused)) void *data)
6597 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6598 struct rte_eth_mac_filter filter;
6600 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6602 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6604 /* set VF MAC filter */
6608 filter.dst_id = res->vf_id;
6610 if (!strcmp(res->filter_type, "exact-mac"))
6611 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6612 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6613 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6614 else if (!strcmp(res->filter_type, "hashmac"))
6615 filter.filter_type = RTE_MAC_HASH_MATCH;
6616 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6617 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6619 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6622 ret = rte_eth_dev_filter_ctrl(res->port_id,
6623 RTE_ETH_FILTER_MACVLAN,
6627 ret = rte_eth_dev_filter_ctrl(res->port_id,
6628 RTE_ETH_FILTER_MACVLAN,
6629 RTE_ETH_FILTER_DELETE,
6633 printf("bad set MAC hash parameter, return code = %d\n", ret);
6637 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6638 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6640 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6641 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6643 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6644 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6646 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6647 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6649 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6650 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6652 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6653 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6655 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6656 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6657 filter_type, "exact-mac#exact-mac-vlan"
6658 "#hashmac#hashmac-vlan");
6659 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6660 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6663 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6664 .f = cmd_set_vf_macvlan_parsed,
6666 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
6667 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
6668 "Exact match rule: exact match of MAC or MAC and VLAN; "
6669 "hash match rule: hash match of MAC and exact match of VLAN",
6671 (void *)&cmd_set_vf_macvlan_set,
6672 (void *)&cmd_set_vf_macvlan_port,
6673 (void *)&cmd_set_vf_macvlan_portid,
6674 (void *)&cmd_set_vf_macvlan_vf,
6675 (void *)&cmd_set_vf_macvlan_vf_id,
6676 (void *)&cmd_set_vf_macvlan_mac,
6677 (void *)&cmd_set_vf_macvlan_filter_type,
6678 (void *)&cmd_set_vf_macvlan_mode,
6683 #ifdef RTE_LIBRTE_IXGBE_PMD
6684 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6685 struct cmd_set_vf_traffic {
6686 cmdline_fixed_string_t set;
6687 cmdline_fixed_string_t port;
6689 cmdline_fixed_string_t vf;
6691 cmdline_fixed_string_t what;
6692 cmdline_fixed_string_t mode;
6696 cmd_set_vf_traffic_parsed(void *parsed_result,
6697 __attribute__((unused)) struct cmdline *cl,
6698 __attribute__((unused)) void *data)
6700 struct cmd_set_vf_traffic *res = parsed_result;
6701 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6702 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6704 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6707 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6708 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6710 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6711 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6713 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6714 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6716 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6717 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6719 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6720 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6722 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6723 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6725 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6726 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6729 cmdline_parse_inst_t cmd_set_vf_traffic = {
6730 .f = cmd_set_vf_traffic_parsed,
6732 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
6734 (void *)&cmd_setvf_traffic_set,
6735 (void *)&cmd_setvf_traffic_port,
6736 (void *)&cmd_setvf_traffic_portid,
6737 (void *)&cmd_setvf_traffic_vf,
6738 (void *)&cmd_setvf_traffic_vfid,
6739 (void *)&cmd_setvf_traffic_what,
6740 (void *)&cmd_setvf_traffic_mode,
6745 /* *** CONFIGURE VF RECEIVE MODE *** */
6746 struct cmd_set_vf_rxmode {
6747 cmdline_fixed_string_t set;
6748 cmdline_fixed_string_t port;
6750 cmdline_fixed_string_t vf;
6752 cmdline_fixed_string_t what;
6753 cmdline_fixed_string_t mode;
6754 cmdline_fixed_string_t on;
6758 cmd_set_vf_rxmode_parsed(void *parsed_result,
6759 __attribute__((unused)) struct cmdline *cl,
6760 __attribute__((unused)) void *data)
6763 uint16_t rx_mode = 0;
6764 struct cmd_set_vf_rxmode *res = parsed_result;
6766 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6767 if (!strcmp(res->what,"rxmode")) {
6768 if (!strcmp(res->mode, "AUPE"))
6769 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6770 else if (!strcmp(res->mode, "ROPE"))
6771 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6772 else if (!strcmp(res->mode, "BAM"))
6773 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6774 else if (!strncmp(res->mode, "MPE",3))
6775 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6778 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, rx_mode, (uint8_t)is_on);
6780 printf("bad VF receive mode parameter, return code = %d \n",
6784 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6785 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6787 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6788 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6790 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6791 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6793 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6794 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6796 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6797 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6799 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6800 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6802 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6803 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6804 mode, "AUPE#ROPE#BAM#MPE");
6805 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6806 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6809 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6810 .f = cmd_set_vf_rxmode_parsed,
6812 .help_str = "set port <port_id> vf <vf_id> rxmode "
6813 "AUPE|ROPE|BAM|MPE on|off",
6815 (void *)&cmd_set_vf_rxmode_set,
6816 (void *)&cmd_set_vf_rxmode_port,
6817 (void *)&cmd_set_vf_rxmode_portid,
6818 (void *)&cmd_set_vf_rxmode_vf,
6819 (void *)&cmd_set_vf_rxmode_vfid,
6820 (void *)&cmd_set_vf_rxmode_what,
6821 (void *)&cmd_set_vf_rxmode_mode,
6822 (void *)&cmd_set_vf_rxmode_on,
6828 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6829 struct cmd_vf_mac_addr_result {
6830 cmdline_fixed_string_t mac_addr_cmd;
6831 cmdline_fixed_string_t what;
6832 cmdline_fixed_string_t port;
6834 cmdline_fixed_string_t vf;
6836 struct ether_addr address;
6839 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6840 __attribute__((unused)) struct cmdline *cl,
6841 __attribute__((unused)) void *data)
6843 struct cmd_vf_mac_addr_result *res = parsed_result;
6846 if (strcmp(res->what, "add") == 0)
6847 ret = rte_eth_dev_mac_addr_add(res->port_num,
6848 &res->address, res->vf_num);
6850 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6854 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6855 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6856 mac_addr_cmd,"mac_addr");
6857 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6858 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6860 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6861 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6863 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6864 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6866 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6867 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6869 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6870 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6872 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6873 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6876 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6877 .f = cmd_vf_mac_addr_parsed,
6879 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
6880 "Add MAC address filtering for a VF on port_id",
6882 (void *)&cmd_vf_mac_addr_cmd,
6883 (void *)&cmd_vf_mac_addr_what,
6884 (void *)&cmd_vf_mac_addr_port,
6885 (void *)&cmd_vf_mac_addr_portnum,
6886 (void *)&cmd_vf_mac_addr_vf,
6887 (void *)&cmd_vf_mac_addr_vfnum,
6888 (void *)&cmd_vf_mac_addr_addr,
6893 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6894 struct cmd_vf_rx_vlan_filter {
6895 cmdline_fixed_string_t rx_vlan;
6896 cmdline_fixed_string_t what;
6898 cmdline_fixed_string_t port;
6900 cmdline_fixed_string_t vf;
6905 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6906 __attribute__((unused)) struct cmdline *cl,
6907 __attribute__((unused)) void *data)
6909 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6912 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
6914 #ifdef RTE_LIBRTE_IXGBE_PMD
6915 if (ret == -ENOTSUP)
6916 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
6917 res->vlan_id, res->vf_mask, is_add);
6919 #ifdef RTE_LIBRTE_I40E_PMD
6920 if (ret == -ENOTSUP)
6921 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
6922 res->vlan_id, res->vf_mask, is_add);
6929 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
6930 res->vlan_id, res->vf_mask);
6933 printf("invalid port_id %d\n", res->port_id);
6936 printf("function not implemented or supported\n");
6939 printf("programming error: (%s)\n", strerror(-ret));
6943 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6944 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6945 rx_vlan, "rx_vlan");
6946 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6947 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6949 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6950 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6952 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6953 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6955 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6956 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6958 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6959 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6961 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6962 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6965 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6966 .f = cmd_vf_rx_vlan_filter_parsed,
6968 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
6969 "(vf_mask = hexadecimal VF mask)",
6971 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6972 (void *)&cmd_vf_rx_vlan_filter_what,
6973 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6974 (void *)&cmd_vf_rx_vlan_filter_port,
6975 (void *)&cmd_vf_rx_vlan_filter_portid,
6976 (void *)&cmd_vf_rx_vlan_filter_vf,
6977 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6982 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6983 struct cmd_queue_rate_limit_result {
6984 cmdline_fixed_string_t set;
6985 cmdline_fixed_string_t port;
6987 cmdline_fixed_string_t queue;
6989 cmdline_fixed_string_t rate;
6993 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6994 __attribute__((unused)) struct cmdline *cl,
6995 __attribute__((unused)) void *data)
6997 struct cmd_queue_rate_limit_result *res = parsed_result;
7000 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7001 && (strcmp(res->queue, "queue") == 0)
7002 && (strcmp(res->rate, "rate") == 0))
7003 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7006 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7010 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7011 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7013 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7014 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7016 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7017 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7019 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7020 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7022 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7023 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7025 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7026 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7028 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7029 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7032 cmdline_parse_inst_t cmd_queue_rate_limit = {
7033 .f = cmd_queue_rate_limit_parsed,
7035 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7036 "Set rate limit for a queue on port_id",
7038 (void *)&cmd_queue_rate_limit_set,
7039 (void *)&cmd_queue_rate_limit_port,
7040 (void *)&cmd_queue_rate_limit_portnum,
7041 (void *)&cmd_queue_rate_limit_queue,
7042 (void *)&cmd_queue_rate_limit_queuenum,
7043 (void *)&cmd_queue_rate_limit_rate,
7044 (void *)&cmd_queue_rate_limit_ratenum,
7049 #ifdef RTE_LIBRTE_IXGBE_PMD
7050 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7051 struct cmd_vf_rate_limit_result {
7052 cmdline_fixed_string_t set;
7053 cmdline_fixed_string_t port;
7055 cmdline_fixed_string_t vf;
7057 cmdline_fixed_string_t rate;
7059 cmdline_fixed_string_t q_msk;
7063 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7064 __attribute__((unused)) struct cmdline *cl,
7065 __attribute__((unused)) void *data)
7067 struct cmd_vf_rate_limit_result *res = parsed_result;
7070 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7071 && (strcmp(res->vf, "vf") == 0)
7072 && (strcmp(res->rate, "rate") == 0)
7073 && (strcmp(res->q_msk, "queue_mask") == 0))
7074 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7075 res->rate_num, res->q_msk_val);
7077 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7081 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7082 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7084 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7085 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7087 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7088 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7090 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7091 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7093 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7094 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7096 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7097 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7099 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7100 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7102 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7103 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7104 q_msk, "queue_mask");
7105 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7106 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7109 cmdline_parse_inst_t cmd_vf_rate_limit = {
7110 .f = cmd_vf_rate_limit_parsed,
7112 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7113 "queue_mask <queue_mask_value>: "
7114 "Set rate limit for queues of VF on port_id",
7116 (void *)&cmd_vf_rate_limit_set,
7117 (void *)&cmd_vf_rate_limit_port,
7118 (void *)&cmd_vf_rate_limit_portnum,
7119 (void *)&cmd_vf_rate_limit_vf,
7120 (void *)&cmd_vf_rate_limit_vfnum,
7121 (void *)&cmd_vf_rate_limit_rate,
7122 (void *)&cmd_vf_rate_limit_ratenum,
7123 (void *)&cmd_vf_rate_limit_q_msk,
7124 (void *)&cmd_vf_rate_limit_q_msk_val,
7130 /* *** ADD TUNNEL FILTER OF A PORT *** */
7131 struct cmd_tunnel_filter_result {
7132 cmdline_fixed_string_t cmd;
7133 cmdline_fixed_string_t what;
7135 struct ether_addr outer_mac;
7136 struct ether_addr inner_mac;
7137 cmdline_ipaddr_t ip_value;
7138 uint16_t inner_vlan;
7139 cmdline_fixed_string_t tunnel_type;
7140 cmdline_fixed_string_t filter_type;
7146 cmd_tunnel_filter_parsed(void *parsed_result,
7147 __attribute__((unused)) struct cmdline *cl,
7148 __attribute__((unused)) void *data)
7150 struct cmd_tunnel_filter_result *res = parsed_result;
7151 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7154 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7156 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7157 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7158 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7160 if (res->ip_value.family == AF_INET) {
7161 tunnel_filter_conf.ip_addr.ipv4_addr =
7162 res->ip_value.addr.ipv4.s_addr;
7163 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7165 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7166 &(res->ip_value.addr.ipv6),
7167 sizeof(struct in6_addr));
7168 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7171 if (!strcmp(res->filter_type, "imac-ivlan"))
7172 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7173 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7174 tunnel_filter_conf.filter_type =
7175 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7176 else if (!strcmp(res->filter_type, "imac-tenid"))
7177 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7178 else if (!strcmp(res->filter_type, "imac"))
7179 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7180 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7181 tunnel_filter_conf.filter_type =
7182 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7183 else if (!strcmp(res->filter_type, "oip"))
7184 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7185 else if (!strcmp(res->filter_type, "iip"))
7186 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7188 printf("The filter type is not supported");
7192 if (!strcmp(res->tunnel_type, "vxlan"))
7193 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7194 else if (!strcmp(res->tunnel_type, "nvgre"))
7195 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7196 else if (!strcmp(res->tunnel_type, "ipingre"))
7197 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7199 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7203 tunnel_filter_conf.tenant_id = res->tenant_id;
7204 tunnel_filter_conf.queue_id = res->queue_num;
7205 if (!strcmp(res->what, "add"))
7206 ret = rte_eth_dev_filter_ctrl(res->port_id,
7207 RTE_ETH_FILTER_TUNNEL,
7209 &tunnel_filter_conf);
7211 ret = rte_eth_dev_filter_ctrl(res->port_id,
7212 RTE_ETH_FILTER_TUNNEL,
7213 RTE_ETH_FILTER_DELETE,
7214 &tunnel_filter_conf);
7216 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7220 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7221 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7222 cmd, "tunnel_filter");
7223 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7224 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7226 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7227 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7229 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7230 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7232 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7233 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7235 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7236 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7237 inner_vlan, UINT16);
7238 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7239 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7241 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7242 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7243 tunnel_type, "vxlan#nvgre#ipingre");
7245 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7246 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7247 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7248 "imac#omac-imac-tenid");
7249 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7250 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7252 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7253 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7256 cmdline_parse_inst_t cmd_tunnel_filter = {
7257 .f = cmd_tunnel_filter_parsed,
7259 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7260 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7261 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7262 "<queue_id>: Add/Rm tunnel filter of a port",
7264 (void *)&cmd_tunnel_filter_cmd,
7265 (void *)&cmd_tunnel_filter_what,
7266 (void *)&cmd_tunnel_filter_port_id,
7267 (void *)&cmd_tunnel_filter_outer_mac,
7268 (void *)&cmd_tunnel_filter_inner_mac,
7269 (void *)&cmd_tunnel_filter_ip_value,
7270 (void *)&cmd_tunnel_filter_innner_vlan,
7271 (void *)&cmd_tunnel_filter_tunnel_type,
7272 (void *)&cmd_tunnel_filter_filter_type,
7273 (void *)&cmd_tunnel_filter_tenant_id,
7274 (void *)&cmd_tunnel_filter_queue_num,
7279 /* *** CONFIGURE TUNNEL UDP PORT *** */
7280 struct cmd_tunnel_udp_config {
7281 cmdline_fixed_string_t cmd;
7282 cmdline_fixed_string_t what;
7288 cmd_tunnel_udp_config_parsed(void *parsed_result,
7289 __attribute__((unused)) struct cmdline *cl,
7290 __attribute__((unused)) void *data)
7292 struct cmd_tunnel_udp_config *res = parsed_result;
7293 struct rte_eth_udp_tunnel tunnel_udp;
7296 tunnel_udp.udp_port = res->udp_port;
7298 if (!strcmp(res->cmd, "rx_vxlan_port"))
7299 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7301 if (!strcmp(res->what, "add"))
7302 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7305 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
7309 printf("udp tunneling add error: (%s)\n", strerror(-ret));
7312 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
7313 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7314 cmd, "rx_vxlan_port");
7315 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
7316 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
7318 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
7319 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7321 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
7322 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
7325 cmdline_parse_inst_t cmd_tunnel_udp_config = {
7326 .f = cmd_tunnel_udp_config_parsed,
7328 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
7329 "Add/Remove a tunneling UDP port filter",
7331 (void *)&cmd_tunnel_udp_config_cmd,
7332 (void *)&cmd_tunnel_udp_config_what,
7333 (void *)&cmd_tunnel_udp_config_udp_port,
7334 (void *)&cmd_tunnel_udp_config_port_id,
7339 /* *** GLOBAL CONFIG *** */
7340 struct cmd_global_config_result {
7341 cmdline_fixed_string_t cmd;
7343 cmdline_fixed_string_t cfg_type;
7348 cmd_global_config_parsed(void *parsed_result,
7349 __attribute__((unused)) struct cmdline *cl,
7350 __attribute__((unused)) void *data)
7352 struct cmd_global_config_result *res = parsed_result;
7353 struct rte_eth_global_cfg conf;
7356 memset(&conf, 0, sizeof(conf));
7357 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
7358 conf.cfg.gre_key_len = res->len;
7359 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
7360 RTE_ETH_FILTER_SET, &conf);
7362 printf("Global config error\n");
7365 cmdline_parse_token_string_t cmd_global_config_cmd =
7366 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
7368 cmdline_parse_token_num_t cmd_global_config_port_id =
7369 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
7370 cmdline_parse_token_string_t cmd_global_config_type =
7371 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
7372 cfg_type, "gre-key-len");
7373 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
7374 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
7377 cmdline_parse_inst_t cmd_global_config = {
7378 .f = cmd_global_config_parsed,
7379 .data = (void *)NULL,
7380 .help_str = "global_config <port_id> gre-key-len <key_len>",
7382 (void *)&cmd_global_config_cmd,
7383 (void *)&cmd_global_config_port_id,
7384 (void *)&cmd_global_config_type,
7385 (void *)&cmd_global_config_gre_key_len,
7390 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
7391 struct cmd_set_mirror_mask_result {
7392 cmdline_fixed_string_t set;
7393 cmdline_fixed_string_t port;
7395 cmdline_fixed_string_t mirror;
7397 cmdline_fixed_string_t what;
7398 cmdline_fixed_string_t value;
7399 cmdline_fixed_string_t dstpool;
7401 cmdline_fixed_string_t on;
7404 cmdline_parse_token_string_t cmd_mirror_mask_set =
7405 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7407 cmdline_parse_token_string_t cmd_mirror_mask_port =
7408 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7410 cmdline_parse_token_num_t cmd_mirror_mask_portid =
7411 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7413 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
7414 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7415 mirror, "mirror-rule");
7416 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
7417 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7419 cmdline_parse_token_string_t cmd_mirror_mask_what =
7420 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7421 what, "pool-mirror-up#pool-mirror-down"
7423 cmdline_parse_token_string_t cmd_mirror_mask_value =
7424 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7426 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
7427 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7428 dstpool, "dst-pool");
7429 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
7430 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
7432 cmdline_parse_token_string_t cmd_mirror_mask_on =
7433 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
7437 cmd_set_mirror_mask_parsed(void *parsed_result,
7438 __attribute__((unused)) struct cmdline *cl,
7439 __attribute__((unused)) void *data)
7442 struct cmd_set_mirror_mask_result *res = parsed_result;
7443 struct rte_eth_mirror_conf mr_conf;
7445 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7447 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
7449 mr_conf.dst_pool = res->dstpool_id;
7451 if (!strcmp(res->what, "pool-mirror-up")) {
7452 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7453 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
7454 } else if (!strcmp(res->what, "pool-mirror-down")) {
7455 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
7456 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
7457 } else if (!strcmp(res->what, "vlan-mirror")) {
7458 mr_conf.rule_type = ETH_MIRROR_VLAN;
7459 nb_item = parse_item_list(res->value, "vlan",
7460 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
7464 for (i = 0; i < nb_item; i++) {
7465 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
7466 printf("Invalid vlan_id: must be < 4096\n");
7470 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
7471 mr_conf.vlan.vlan_mask |= 1ULL << i;
7475 if (!strcmp(res->on, "on"))
7476 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7479 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7482 printf("mirror rule add error: (%s)\n", strerror(-ret));
7485 cmdline_parse_inst_t cmd_set_mirror_mask = {
7486 .f = cmd_set_mirror_mask_parsed,
7488 .help_str = "set port <port_id> mirror-rule <rule_id> "
7489 "pool-mirror-up|pool-mirror-down|vlan-mirror "
7490 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
7492 (void *)&cmd_mirror_mask_set,
7493 (void *)&cmd_mirror_mask_port,
7494 (void *)&cmd_mirror_mask_portid,
7495 (void *)&cmd_mirror_mask_mirror,
7496 (void *)&cmd_mirror_mask_ruleid,
7497 (void *)&cmd_mirror_mask_what,
7498 (void *)&cmd_mirror_mask_value,
7499 (void *)&cmd_mirror_mask_dstpool,
7500 (void *)&cmd_mirror_mask_poolid,
7501 (void *)&cmd_mirror_mask_on,
7506 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
7507 struct cmd_set_mirror_link_result {
7508 cmdline_fixed_string_t set;
7509 cmdline_fixed_string_t port;
7511 cmdline_fixed_string_t mirror;
7513 cmdline_fixed_string_t what;
7514 cmdline_fixed_string_t dstpool;
7516 cmdline_fixed_string_t on;
7519 cmdline_parse_token_string_t cmd_mirror_link_set =
7520 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7522 cmdline_parse_token_string_t cmd_mirror_link_port =
7523 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7525 cmdline_parse_token_num_t cmd_mirror_link_portid =
7526 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7528 cmdline_parse_token_string_t cmd_mirror_link_mirror =
7529 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7530 mirror, "mirror-rule");
7531 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
7532 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7534 cmdline_parse_token_string_t cmd_mirror_link_what =
7535 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7536 what, "uplink-mirror#downlink-mirror");
7537 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
7538 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7539 dstpool, "dst-pool");
7540 cmdline_parse_token_num_t cmd_mirror_link_poolid =
7541 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
7543 cmdline_parse_token_string_t cmd_mirror_link_on =
7544 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
7548 cmd_set_mirror_link_parsed(void *parsed_result,
7549 __attribute__((unused)) struct cmdline *cl,
7550 __attribute__((unused)) void *data)
7553 struct cmd_set_mirror_link_result *res = parsed_result;
7554 struct rte_eth_mirror_conf mr_conf;
7556 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
7557 if (!strcmp(res->what, "uplink-mirror"))
7558 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
7560 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
7562 mr_conf.dst_pool = res->dstpool_id;
7564 if (!strcmp(res->on, "on"))
7565 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7568 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
7571 /* check the return value and print it if is < 0 */
7573 printf("mirror rule add error: (%s)\n", strerror(-ret));
7577 cmdline_parse_inst_t cmd_set_mirror_link = {
7578 .f = cmd_set_mirror_link_parsed,
7580 .help_str = "set port <port_id> mirror-rule <rule_id> "
7581 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
7583 (void *)&cmd_mirror_link_set,
7584 (void *)&cmd_mirror_link_port,
7585 (void *)&cmd_mirror_link_portid,
7586 (void *)&cmd_mirror_link_mirror,
7587 (void *)&cmd_mirror_link_ruleid,
7588 (void *)&cmd_mirror_link_what,
7589 (void *)&cmd_mirror_link_dstpool,
7590 (void *)&cmd_mirror_link_poolid,
7591 (void *)&cmd_mirror_link_on,
7596 /* *** RESET VM MIRROR RULE *** */
7597 struct cmd_rm_mirror_rule_result {
7598 cmdline_fixed_string_t reset;
7599 cmdline_fixed_string_t port;
7601 cmdline_fixed_string_t mirror;
7605 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
7606 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7608 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
7609 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7611 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
7612 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7614 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
7615 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
7616 mirror, "mirror-rule");
7617 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
7618 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
7622 cmd_reset_mirror_rule_parsed(void *parsed_result,
7623 __attribute__((unused)) struct cmdline *cl,
7624 __attribute__((unused)) void *data)
7627 struct cmd_set_mirror_link_result *res = parsed_result;
7629 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
7631 printf("mirror rule remove error: (%s)\n", strerror(-ret));
7634 cmdline_parse_inst_t cmd_reset_mirror_rule = {
7635 .f = cmd_reset_mirror_rule_parsed,
7637 .help_str = "reset port <port_id> mirror-rule <rule_id>",
7639 (void *)&cmd_rm_mirror_rule_reset,
7640 (void *)&cmd_rm_mirror_rule_port,
7641 (void *)&cmd_rm_mirror_rule_portid,
7642 (void *)&cmd_rm_mirror_rule_mirror,
7643 (void *)&cmd_rm_mirror_rule_ruleid,
7648 /* ******************************************************************************** */
7650 struct cmd_dump_result {
7651 cmdline_fixed_string_t dump;
7655 dump_struct_sizes(void)
7657 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
7658 DUMP_SIZE(struct rte_mbuf);
7659 DUMP_SIZE(struct rte_mempool);
7660 DUMP_SIZE(struct rte_ring);
7664 static void cmd_dump_parsed(void *parsed_result,
7665 __attribute__((unused)) struct cmdline *cl,
7666 __attribute__((unused)) void *data)
7668 struct cmd_dump_result *res = parsed_result;
7670 if (!strcmp(res->dump, "dump_physmem"))
7671 rte_dump_physmem_layout(stdout);
7672 else if (!strcmp(res->dump, "dump_memzone"))
7673 rte_memzone_dump(stdout);
7674 else if (!strcmp(res->dump, "dump_struct_sizes"))
7675 dump_struct_sizes();
7676 else if (!strcmp(res->dump, "dump_ring"))
7677 rte_ring_list_dump(stdout);
7678 else if (!strcmp(res->dump, "dump_mempool"))
7679 rte_mempool_list_dump(stdout);
7680 else if (!strcmp(res->dump, "dump_devargs"))
7681 rte_eal_devargs_dump(stdout);
7684 cmdline_parse_token_string_t cmd_dump_dump =
7685 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7688 "dump_struct_sizes#"
7693 cmdline_parse_inst_t cmd_dump = {
7694 .f = cmd_dump_parsed, /* function to call */
7695 .data = NULL, /* 2nd arg of func */
7696 .help_str = "Dump status",
7697 .tokens = { /* token list, NULL terminated */
7698 (void *)&cmd_dump_dump,
7703 /* ******************************************************************************** */
7705 struct cmd_dump_one_result {
7706 cmdline_fixed_string_t dump;
7707 cmdline_fixed_string_t name;
7710 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7711 __attribute__((unused)) void *data)
7713 struct cmd_dump_one_result *res = parsed_result;
7715 if (!strcmp(res->dump, "dump_ring")) {
7717 r = rte_ring_lookup(res->name);
7719 cmdline_printf(cl, "Cannot find ring\n");
7722 rte_ring_dump(stdout, r);
7723 } else if (!strcmp(res->dump, "dump_mempool")) {
7724 struct rte_mempool *mp;
7725 mp = rte_mempool_lookup(res->name);
7727 cmdline_printf(cl, "Cannot find mempool\n");
7730 rte_mempool_dump(stdout, mp);
7734 cmdline_parse_token_string_t cmd_dump_one_dump =
7735 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7736 "dump_ring#dump_mempool");
7738 cmdline_parse_token_string_t cmd_dump_one_name =
7739 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7741 cmdline_parse_inst_t cmd_dump_one = {
7742 .f = cmd_dump_one_parsed, /* function to call */
7743 .data = NULL, /* 2nd arg of func */
7744 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
7745 .tokens = { /* token list, NULL terminated */
7746 (void *)&cmd_dump_one_dump,
7747 (void *)&cmd_dump_one_name,
7752 /* *** Add/Del syn filter *** */
7753 struct cmd_syn_filter_result {
7754 cmdline_fixed_string_t filter;
7756 cmdline_fixed_string_t ops;
7757 cmdline_fixed_string_t priority;
7758 cmdline_fixed_string_t high;
7759 cmdline_fixed_string_t queue;
7764 cmd_syn_filter_parsed(void *parsed_result,
7765 __attribute__((unused)) struct cmdline *cl,
7766 __attribute__((unused)) void *data)
7768 struct cmd_syn_filter_result *res = parsed_result;
7769 struct rte_eth_syn_filter syn_filter;
7772 ret = rte_eth_dev_filter_supported(res->port_id,
7773 RTE_ETH_FILTER_SYN);
7775 printf("syn filter is not supported on port %u.\n",
7780 memset(&syn_filter, 0, sizeof(syn_filter));
7782 if (!strcmp(res->ops, "add")) {
7783 if (!strcmp(res->high, "high"))
7784 syn_filter.hig_pri = 1;
7786 syn_filter.hig_pri = 0;
7788 syn_filter.queue = res->queue_id;
7789 ret = rte_eth_dev_filter_ctrl(res->port_id,
7794 ret = rte_eth_dev_filter_ctrl(res->port_id,
7796 RTE_ETH_FILTER_DELETE,
7800 printf("syn filter programming error: (%s)\n",
7804 cmdline_parse_token_string_t cmd_syn_filter_filter =
7805 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7806 filter, "syn_filter");
7807 cmdline_parse_token_num_t cmd_syn_filter_port_id =
7808 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7810 cmdline_parse_token_string_t cmd_syn_filter_ops =
7811 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7813 cmdline_parse_token_string_t cmd_syn_filter_priority =
7814 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7815 priority, "priority");
7816 cmdline_parse_token_string_t cmd_syn_filter_high =
7817 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7819 cmdline_parse_token_string_t cmd_syn_filter_queue =
7820 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
7822 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7823 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
7826 cmdline_parse_inst_t cmd_syn_filter = {
7827 .f = cmd_syn_filter_parsed,
7829 .help_str = "syn_filter <port_id> add|del priority high|low queue "
7830 "<queue_id>: Add/Delete syn filter",
7832 (void *)&cmd_syn_filter_filter,
7833 (void *)&cmd_syn_filter_port_id,
7834 (void *)&cmd_syn_filter_ops,
7835 (void *)&cmd_syn_filter_priority,
7836 (void *)&cmd_syn_filter_high,
7837 (void *)&cmd_syn_filter_queue,
7838 (void *)&cmd_syn_filter_queue_id,
7843 /* *** ADD/REMOVE A 2tuple FILTER *** */
7844 struct cmd_2tuple_filter_result {
7845 cmdline_fixed_string_t filter;
7847 cmdline_fixed_string_t ops;
7848 cmdline_fixed_string_t dst_port;
7849 uint16_t dst_port_value;
7850 cmdline_fixed_string_t protocol;
7851 uint8_t protocol_value;
7852 cmdline_fixed_string_t mask;
7854 cmdline_fixed_string_t tcp_flags;
7855 uint8_t tcp_flags_value;
7856 cmdline_fixed_string_t priority;
7857 uint8_t priority_value;
7858 cmdline_fixed_string_t queue;
7863 cmd_2tuple_filter_parsed(void *parsed_result,
7864 __attribute__((unused)) struct cmdline *cl,
7865 __attribute__((unused)) void *data)
7867 struct rte_eth_ntuple_filter filter;
7868 struct cmd_2tuple_filter_result *res = parsed_result;
7871 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
7873 printf("ntuple filter is not supported on port %u.\n",
7878 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
7880 filter.flags = RTE_2TUPLE_FLAGS;
7881 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
7882 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
7883 filter.proto = res->protocol_value;
7884 filter.priority = res->priority_value;
7885 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
7886 printf("nonzero tcp_flags is only meaningful"
7887 " when protocol is TCP.\n");
7890 if (res->tcp_flags_value > TCP_FLAG_ALL) {
7891 printf("invalid TCP flags.\n");
7895 if (res->tcp_flags_value != 0) {
7896 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
7897 filter.tcp_flags = res->tcp_flags_value;
7900 /* need convert to big endian. */
7901 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7902 filter.queue = res->queue_id;
7904 if (!strcmp(res->ops, "add"))
7905 ret = rte_eth_dev_filter_ctrl(res->port_id,
7906 RTE_ETH_FILTER_NTUPLE,
7910 ret = rte_eth_dev_filter_ctrl(res->port_id,
7911 RTE_ETH_FILTER_NTUPLE,
7912 RTE_ETH_FILTER_DELETE,
7915 printf("2tuple filter programming error: (%s)\n",
7920 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
7921 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7922 filter, "2tuple_filter");
7923 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7924 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7926 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
7927 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7929 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7930 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7931 dst_port, "dst_port");
7932 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7933 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7934 dst_port_value, UINT16);
7935 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7936 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7937 protocol, "protocol");
7938 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7939 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7940 protocol_value, UINT8);
7941 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
7942 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7944 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
7945 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7947 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
7948 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7949 tcp_flags, "tcp_flags");
7950 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
7951 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7952 tcp_flags_value, UINT8);
7953 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7954 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7955 priority, "priority");
7956 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7957 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7958 priority_value, UINT8);
7959 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7960 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7962 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7963 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7966 cmdline_parse_inst_t cmd_2tuple_filter = {
7967 .f = cmd_2tuple_filter_parsed,
7969 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
7970 "<value> mask <value> tcp_flags <value> priority <value> queue "
7971 "<queue_id>: Add a 2tuple filter",
7973 (void *)&cmd_2tuple_filter_filter,
7974 (void *)&cmd_2tuple_filter_port_id,
7975 (void *)&cmd_2tuple_filter_ops,
7976 (void *)&cmd_2tuple_filter_dst_port,
7977 (void *)&cmd_2tuple_filter_dst_port_value,
7978 (void *)&cmd_2tuple_filter_protocol,
7979 (void *)&cmd_2tuple_filter_protocol_value,
7980 (void *)&cmd_2tuple_filter_mask,
7981 (void *)&cmd_2tuple_filter_mask_value,
7982 (void *)&cmd_2tuple_filter_tcp_flags,
7983 (void *)&cmd_2tuple_filter_tcp_flags_value,
7984 (void *)&cmd_2tuple_filter_priority,
7985 (void *)&cmd_2tuple_filter_priority_value,
7986 (void *)&cmd_2tuple_filter_queue,
7987 (void *)&cmd_2tuple_filter_queue_id,
7992 /* *** ADD/REMOVE A 5tuple FILTER *** */
7993 struct cmd_5tuple_filter_result {
7994 cmdline_fixed_string_t filter;
7996 cmdline_fixed_string_t ops;
7997 cmdline_fixed_string_t dst_ip;
7998 cmdline_ipaddr_t dst_ip_value;
7999 cmdline_fixed_string_t src_ip;
8000 cmdline_ipaddr_t src_ip_value;
8001 cmdline_fixed_string_t dst_port;
8002 uint16_t dst_port_value;
8003 cmdline_fixed_string_t src_port;
8004 uint16_t src_port_value;
8005 cmdline_fixed_string_t protocol;
8006 uint8_t protocol_value;
8007 cmdline_fixed_string_t mask;
8009 cmdline_fixed_string_t tcp_flags;
8010 uint8_t tcp_flags_value;
8011 cmdline_fixed_string_t priority;
8012 uint8_t priority_value;
8013 cmdline_fixed_string_t queue;
8018 cmd_5tuple_filter_parsed(void *parsed_result,
8019 __attribute__((unused)) struct cmdline *cl,
8020 __attribute__((unused)) void *data)
8022 struct rte_eth_ntuple_filter filter;
8023 struct cmd_5tuple_filter_result *res = parsed_result;
8026 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
8028 printf("ntuple filter is not supported on port %u.\n",
8033 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
8035 filter.flags = RTE_5TUPLE_FLAGS;
8036 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
8037 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
8038 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
8039 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
8040 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
8041 filter.proto = res->protocol_value;
8042 filter.priority = res->priority_value;
8043 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
8044 printf("nonzero tcp_flags is only meaningful"
8045 " when protocol is TCP.\n");
8048 if (res->tcp_flags_value > TCP_FLAG_ALL) {
8049 printf("invalid TCP flags.\n");
8053 if (res->tcp_flags_value != 0) {
8054 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
8055 filter.tcp_flags = res->tcp_flags_value;
8058 if (res->dst_ip_value.family == AF_INET)
8059 /* no need to convert, already big endian. */
8060 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
8062 if (filter.dst_ip_mask == 0) {
8063 printf("can not support ipv6 involved compare.\n");
8069 if (res->src_ip_value.family == AF_INET)
8070 /* no need to convert, already big endian. */
8071 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
8073 if (filter.src_ip_mask == 0) {
8074 printf("can not support ipv6 involved compare.\n");
8079 /* need convert to big endian. */
8080 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
8081 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
8082 filter.queue = res->queue_id;
8084 if (!strcmp(res->ops, "add"))
8085 ret = rte_eth_dev_filter_ctrl(res->port_id,
8086 RTE_ETH_FILTER_NTUPLE,
8090 ret = rte_eth_dev_filter_ctrl(res->port_id,
8091 RTE_ETH_FILTER_NTUPLE,
8092 RTE_ETH_FILTER_DELETE,
8095 printf("5tuple filter programming error: (%s)\n",
8099 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
8100 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8101 filter, "5tuple_filter");
8102 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
8103 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8105 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
8106 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8108 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
8109 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8111 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
8112 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8114 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
8115 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8117 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
8118 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
8120 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
8121 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8122 dst_port, "dst_port");
8123 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
8124 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8125 dst_port_value, UINT16);
8126 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
8127 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8128 src_port, "src_port");
8129 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
8130 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8131 src_port_value, UINT16);
8132 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
8133 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8134 protocol, "protocol");
8135 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
8136 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8137 protocol_value, UINT8);
8138 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
8139 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8141 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
8142 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8144 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
8145 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8146 tcp_flags, "tcp_flags");
8147 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
8148 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8149 tcp_flags_value, UINT8);
8150 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
8151 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8152 priority, "priority");
8153 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
8154 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8155 priority_value, UINT8);
8156 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
8157 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
8159 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
8160 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
8163 cmdline_parse_inst_t cmd_5tuple_filter = {
8164 .f = cmd_5tuple_filter_parsed,
8166 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
8167 "src_ip <value> dst_port <value> src_port <value> "
8168 "protocol <value> mask <value> tcp_flags <value> "
8169 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
8171 (void *)&cmd_5tuple_filter_filter,
8172 (void *)&cmd_5tuple_filter_port_id,
8173 (void *)&cmd_5tuple_filter_ops,
8174 (void *)&cmd_5tuple_filter_dst_ip,
8175 (void *)&cmd_5tuple_filter_dst_ip_value,
8176 (void *)&cmd_5tuple_filter_src_ip,
8177 (void *)&cmd_5tuple_filter_src_ip_value,
8178 (void *)&cmd_5tuple_filter_dst_port,
8179 (void *)&cmd_5tuple_filter_dst_port_value,
8180 (void *)&cmd_5tuple_filter_src_port,
8181 (void *)&cmd_5tuple_filter_src_port_value,
8182 (void *)&cmd_5tuple_filter_protocol,
8183 (void *)&cmd_5tuple_filter_protocol_value,
8184 (void *)&cmd_5tuple_filter_mask,
8185 (void *)&cmd_5tuple_filter_mask_value,
8186 (void *)&cmd_5tuple_filter_tcp_flags,
8187 (void *)&cmd_5tuple_filter_tcp_flags_value,
8188 (void *)&cmd_5tuple_filter_priority,
8189 (void *)&cmd_5tuple_filter_priority_value,
8190 (void *)&cmd_5tuple_filter_queue,
8191 (void *)&cmd_5tuple_filter_queue_id,
8196 /* *** ADD/REMOVE A flex FILTER *** */
8197 struct cmd_flex_filter_result {
8198 cmdline_fixed_string_t filter;
8199 cmdline_fixed_string_t ops;
8201 cmdline_fixed_string_t len;
8203 cmdline_fixed_string_t bytes;
8204 cmdline_fixed_string_t bytes_value;
8205 cmdline_fixed_string_t mask;
8206 cmdline_fixed_string_t mask_value;
8207 cmdline_fixed_string_t priority;
8208 uint8_t priority_value;
8209 cmdline_fixed_string_t queue;
8213 static int xdigit2val(unsigned char c)
8218 else if (isupper(c))
8226 cmd_flex_filter_parsed(void *parsed_result,
8227 __attribute__((unused)) struct cmdline *cl,
8228 __attribute__((unused)) void *data)
8231 struct rte_eth_flex_filter filter;
8232 struct cmd_flex_filter_result *res = parsed_result;
8233 char *bytes_ptr, *mask_ptr;
8234 uint16_t len, i, j = 0;
8239 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
8240 printf("the len exceed the max length 128\n");
8243 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
8244 filter.len = res->len_value;
8245 filter.priority = res->priority_value;
8246 filter.queue = res->queue_id;
8247 bytes_ptr = res->bytes_value;
8248 mask_ptr = res->mask_value;
8250 /* translate bytes string to array. */
8251 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
8252 (bytes_ptr[1] == 'X')))
8254 len = strnlen(bytes_ptr, res->len_value * 2);
8255 if (len == 0 || (len % 8 != 0)) {
8256 printf("please check len and bytes input\n");
8259 for (i = 0; i < len; i++) {
8261 if (isxdigit(c) == 0) {
8262 /* invalid characters. */
8263 printf("invalid input\n");
8266 val = xdigit2val(c);
8269 filter.bytes[j] = byte;
8270 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
8277 /* translate mask string to uint8_t array. */
8278 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
8279 (mask_ptr[1] == 'X')))
8281 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
8283 printf("invalid input\n");
8288 for (i = 0; i < len; i++) {
8290 if (isxdigit(c) == 0) {
8291 /* invalid characters. */
8292 printf("invalid input\n");
8295 val = xdigit2val(c);
8298 filter.mask[j] = byte;
8299 printf("mask[%d]:%02x ", j, filter.mask[j]);
8307 if (!strcmp(res->ops, "add"))
8308 ret = rte_eth_dev_filter_ctrl(res->port_id,
8309 RTE_ETH_FILTER_FLEXIBLE,
8313 ret = rte_eth_dev_filter_ctrl(res->port_id,
8314 RTE_ETH_FILTER_FLEXIBLE,
8315 RTE_ETH_FILTER_DELETE,
8319 printf("flex filter setting error: (%s)\n", strerror(-ret));
8322 cmdline_parse_token_string_t cmd_flex_filter_filter =
8323 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8324 filter, "flex_filter");
8325 cmdline_parse_token_num_t cmd_flex_filter_port_id =
8326 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8328 cmdline_parse_token_string_t cmd_flex_filter_ops =
8329 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8331 cmdline_parse_token_string_t cmd_flex_filter_len =
8332 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8334 cmdline_parse_token_num_t cmd_flex_filter_len_value =
8335 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8337 cmdline_parse_token_string_t cmd_flex_filter_bytes =
8338 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8340 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
8341 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8343 cmdline_parse_token_string_t cmd_flex_filter_mask =
8344 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8346 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
8347 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8349 cmdline_parse_token_string_t cmd_flex_filter_priority =
8350 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8351 priority, "priority");
8352 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
8353 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8354 priority_value, UINT8);
8355 cmdline_parse_token_string_t cmd_flex_filter_queue =
8356 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
8358 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
8359 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
8361 cmdline_parse_inst_t cmd_flex_filter = {
8362 .f = cmd_flex_filter_parsed,
8364 .help_str = "flex_filter <port_id> add|del len <value> bytes "
8365 "<value> mask <value> priority <value> queue <queue_id>: "
8366 "Add/Del a flex filter",
8368 (void *)&cmd_flex_filter_filter,
8369 (void *)&cmd_flex_filter_port_id,
8370 (void *)&cmd_flex_filter_ops,
8371 (void *)&cmd_flex_filter_len,
8372 (void *)&cmd_flex_filter_len_value,
8373 (void *)&cmd_flex_filter_bytes,
8374 (void *)&cmd_flex_filter_bytes_value,
8375 (void *)&cmd_flex_filter_mask,
8376 (void *)&cmd_flex_filter_mask_value,
8377 (void *)&cmd_flex_filter_priority,
8378 (void *)&cmd_flex_filter_priority_value,
8379 (void *)&cmd_flex_filter_queue,
8380 (void *)&cmd_flex_filter_queue_id,
8385 /* *** Filters Control *** */
8387 /* *** deal with ethertype filter *** */
8388 struct cmd_ethertype_filter_result {
8389 cmdline_fixed_string_t filter;
8391 cmdline_fixed_string_t ops;
8392 cmdline_fixed_string_t mac;
8393 struct ether_addr mac_addr;
8394 cmdline_fixed_string_t ethertype;
8395 uint16_t ethertype_value;
8396 cmdline_fixed_string_t drop;
8397 cmdline_fixed_string_t queue;
8401 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
8402 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8403 filter, "ethertype_filter");
8404 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
8405 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8407 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
8408 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8410 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
8411 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8412 mac, "mac_addr#mac_ignr");
8413 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
8414 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
8416 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
8417 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8418 ethertype, "ethertype");
8419 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
8420 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8421 ethertype_value, UINT16);
8422 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
8423 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8425 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
8426 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
8428 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
8429 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
8433 cmd_ethertype_filter_parsed(void *parsed_result,
8434 __attribute__((unused)) struct cmdline *cl,
8435 __attribute__((unused)) void *data)
8437 struct cmd_ethertype_filter_result *res = parsed_result;
8438 struct rte_eth_ethertype_filter filter;
8441 ret = rte_eth_dev_filter_supported(res->port_id,
8442 RTE_ETH_FILTER_ETHERTYPE);
8444 printf("ethertype filter is not supported on port %u.\n",
8449 memset(&filter, 0, sizeof(filter));
8450 if (!strcmp(res->mac, "mac_addr")) {
8451 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
8452 (void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
8453 sizeof(struct ether_addr));
8455 if (!strcmp(res->drop, "drop"))
8456 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
8457 filter.ether_type = res->ethertype_value;
8458 filter.queue = res->queue_id;
8460 if (!strcmp(res->ops, "add"))
8461 ret = rte_eth_dev_filter_ctrl(res->port_id,
8462 RTE_ETH_FILTER_ETHERTYPE,
8466 ret = rte_eth_dev_filter_ctrl(res->port_id,
8467 RTE_ETH_FILTER_ETHERTYPE,
8468 RTE_ETH_FILTER_DELETE,
8471 printf("ethertype filter programming error: (%s)\n",
8475 cmdline_parse_inst_t cmd_ethertype_filter = {
8476 .f = cmd_ethertype_filter_parsed,
8478 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
8479 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
8480 "Add or delete an ethertype filter entry",
8482 (void *)&cmd_ethertype_filter_filter,
8483 (void *)&cmd_ethertype_filter_port_id,
8484 (void *)&cmd_ethertype_filter_ops,
8485 (void *)&cmd_ethertype_filter_mac,
8486 (void *)&cmd_ethertype_filter_mac_addr,
8487 (void *)&cmd_ethertype_filter_ethertype,
8488 (void *)&cmd_ethertype_filter_ethertype_value,
8489 (void *)&cmd_ethertype_filter_drop,
8490 (void *)&cmd_ethertype_filter_queue,
8491 (void *)&cmd_ethertype_filter_queue_id,
8496 /* *** deal with flow director filter *** */
8497 struct cmd_flow_director_result {
8498 cmdline_fixed_string_t flow_director_filter;
8500 cmdline_fixed_string_t mode;
8501 cmdline_fixed_string_t mode_value;
8502 cmdline_fixed_string_t ops;
8503 cmdline_fixed_string_t flow;
8504 cmdline_fixed_string_t flow_type;
8505 cmdline_fixed_string_t ether;
8506 uint16_t ether_type;
8507 cmdline_fixed_string_t src;
8508 cmdline_ipaddr_t ip_src;
8510 cmdline_fixed_string_t dst;
8511 cmdline_ipaddr_t ip_dst;
8513 cmdline_fixed_string_t verify_tag;
8514 uint32_t verify_tag_value;
8515 cmdline_ipaddr_t tos;
8517 cmdline_ipaddr_t proto;
8518 uint8_t proto_value;
8519 cmdline_ipaddr_t ttl;
8521 cmdline_fixed_string_t vlan;
8522 uint16_t vlan_value;
8523 cmdline_fixed_string_t flexbytes;
8524 cmdline_fixed_string_t flexbytes_value;
8525 cmdline_fixed_string_t pf_vf;
8526 cmdline_fixed_string_t drop;
8527 cmdline_fixed_string_t queue;
8529 cmdline_fixed_string_t fd_id;
8530 uint32_t fd_id_value;
8531 cmdline_fixed_string_t mac;
8532 struct ether_addr mac_addr;
8533 cmdline_fixed_string_t tunnel;
8534 cmdline_fixed_string_t tunnel_type;
8535 cmdline_fixed_string_t tunnel_id;
8536 uint32_t tunnel_id_value;
8540 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
8543 const char *p, *p0 = q_arg;
8545 unsigned long int_fld;
8546 char *str_fld[max_num];
8551 p = strchr(p0, '(');
8555 p0 = strchr(p, ')');
8560 if (size >= sizeof(s))
8563 snprintf(s, sizeof(s), "%.*s", size, p);
8564 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8565 if (ret < 0 || ret > max_num)
8567 for (i = 0; i < ret; i++) {
8569 int_fld = strtoul(str_fld[i], &end, 0);
8570 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
8572 flexbytes[i] = (uint8_t)int_fld;
8578 str2flowtype(char *string)
8581 static const struct {
8584 } flowtype_str[] = {
8585 {"raw", RTE_ETH_FLOW_RAW},
8586 {"ipv4", RTE_ETH_FLOW_IPV4},
8587 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
8588 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
8589 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
8590 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
8591 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
8592 {"ipv6", RTE_ETH_FLOW_IPV6},
8593 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
8594 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
8595 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
8596 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
8597 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
8598 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
8601 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8602 if (!strcmp(flowtype_str[i].str, string))
8603 return flowtype_str[i].type;
8605 return RTE_ETH_FLOW_UNKNOWN;
8608 static enum rte_eth_fdir_tunnel_type
8609 str2fdir_tunneltype(char *string)
8613 static const struct {
8615 enum rte_eth_fdir_tunnel_type type;
8616 } tunneltype_str[] = {
8617 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
8618 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
8621 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
8622 if (!strcmp(tunneltype_str[i].str, string))
8623 return tunneltype_str[i].type;
8625 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
8628 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8630 if ((ip_addr).family == AF_INET) \
8631 (ip) = (ip_addr).addr.ipv4.s_addr; \
8633 printf("invalid parameter.\n"); \
8638 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8640 if ((ip_addr).family == AF_INET6) \
8641 (void)rte_memcpy(&(ip), \
8642 &((ip_addr).addr.ipv6), \
8643 sizeof(struct in6_addr)); \
8645 printf("invalid parameter.\n"); \
8651 cmd_flow_director_filter_parsed(void *parsed_result,
8652 __attribute__((unused)) struct cmdline *cl,
8653 __attribute__((unused)) void *data)
8655 struct cmd_flow_director_result *res = parsed_result;
8656 struct rte_eth_fdir_filter entry;
8657 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8659 unsigned long vf_id;
8662 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8664 printf("flow director is not supported on port %u.\n",
8668 memset(flexbytes, 0, sizeof(flexbytes));
8669 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8671 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
8672 if (strcmp(res->mode_value, "MAC-VLAN")) {
8673 printf("Please set mode to MAC-VLAN.\n");
8676 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8677 if (strcmp(res->mode_value, "Tunnel")) {
8678 printf("Please set mode to Tunnel.\n");
8682 if (strcmp(res->mode_value, "IP")) {
8683 printf("Please set mode to IP.\n");
8686 entry.input.flow_type = str2flowtype(res->flow_type);
8689 ret = parse_flexbytes(res->flexbytes_value,
8691 RTE_ETH_FDIR_MAX_FLEXLEN);
8693 printf("error: Cannot parse flexbytes input.\n");
8697 switch (entry.input.flow_type) {
8698 case RTE_ETH_FLOW_FRAG_IPV4:
8699 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
8700 entry.input.flow.ip4_flow.proto = res->proto_value;
8701 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
8702 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
8703 IPV4_ADDR_TO_UINT(res->ip_dst,
8704 entry.input.flow.ip4_flow.dst_ip);
8705 IPV4_ADDR_TO_UINT(res->ip_src,
8706 entry.input.flow.ip4_flow.src_ip);
8707 entry.input.flow.ip4_flow.tos = res->tos_value;
8708 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8709 /* need convert to big endian. */
8710 entry.input.flow.udp4_flow.dst_port =
8711 rte_cpu_to_be_16(res->port_dst);
8712 entry.input.flow.udp4_flow.src_port =
8713 rte_cpu_to_be_16(res->port_src);
8715 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
8716 IPV4_ADDR_TO_UINT(res->ip_dst,
8717 entry.input.flow.sctp4_flow.ip.dst_ip);
8718 IPV4_ADDR_TO_UINT(res->ip_src,
8719 entry.input.flow.sctp4_flow.ip.src_ip);
8720 entry.input.flow.ip4_flow.tos = res->tos_value;
8721 entry.input.flow.ip4_flow.ttl = res->ttl_value;
8722 /* need convert to big endian. */
8723 entry.input.flow.sctp4_flow.dst_port =
8724 rte_cpu_to_be_16(res->port_dst);
8725 entry.input.flow.sctp4_flow.src_port =
8726 rte_cpu_to_be_16(res->port_src);
8727 entry.input.flow.sctp4_flow.verify_tag =
8728 rte_cpu_to_be_32(res->verify_tag_value);
8730 case RTE_ETH_FLOW_FRAG_IPV6:
8731 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
8732 entry.input.flow.ipv6_flow.proto = res->proto_value;
8733 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
8734 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
8735 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8736 entry.input.flow.ipv6_flow.dst_ip);
8737 IPV6_ADDR_TO_ARRAY(res->ip_src,
8738 entry.input.flow.ipv6_flow.src_ip);
8739 entry.input.flow.ipv6_flow.tc = res->tos_value;
8740 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8741 /* need convert to big endian. */
8742 entry.input.flow.udp6_flow.dst_port =
8743 rte_cpu_to_be_16(res->port_dst);
8744 entry.input.flow.udp6_flow.src_port =
8745 rte_cpu_to_be_16(res->port_src);
8747 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
8748 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8749 entry.input.flow.sctp6_flow.ip.dst_ip);
8750 IPV6_ADDR_TO_ARRAY(res->ip_src,
8751 entry.input.flow.sctp6_flow.ip.src_ip);
8752 entry.input.flow.ipv6_flow.tc = res->tos_value;
8753 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
8754 /* need convert to big endian. */
8755 entry.input.flow.sctp6_flow.dst_port =
8756 rte_cpu_to_be_16(res->port_dst);
8757 entry.input.flow.sctp6_flow.src_port =
8758 rte_cpu_to_be_16(res->port_src);
8759 entry.input.flow.sctp6_flow.verify_tag =
8760 rte_cpu_to_be_32(res->verify_tag_value);
8762 case RTE_ETH_FLOW_L2_PAYLOAD:
8763 entry.input.flow.l2_flow.ether_type =
8764 rte_cpu_to_be_16(res->ether_type);
8770 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
8771 (void)rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
8773 sizeof(struct ether_addr));
8775 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
8776 (void)rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
8778 sizeof(struct ether_addr));
8779 entry.input.flow.tunnel_flow.tunnel_type =
8780 str2fdir_tunneltype(res->tunnel_type);
8781 entry.input.flow.tunnel_flow.tunnel_id =
8782 rte_cpu_to_be_32(res->tunnel_id_value);
8785 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8787 RTE_ETH_FDIR_MAX_FLEXLEN);
8789 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
8791 entry.action.flex_off = 0; /*use 0 by default */
8792 if (!strcmp(res->drop, "drop"))
8793 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8795 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8797 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
8798 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
8799 if (!strcmp(res->pf_vf, "pf"))
8800 entry.input.flow_ext.is_vf = 0;
8801 else if (!strncmp(res->pf_vf, "vf", 2)) {
8802 struct rte_eth_dev_info dev_info;
8804 memset(&dev_info, 0, sizeof(dev_info));
8805 rte_eth_dev_info_get(res->port_id, &dev_info);
8807 vf_id = strtoul(res->pf_vf + 2, &end, 10);
8808 if (errno != 0 || *end != '\0' ||
8809 vf_id >= dev_info.max_vfs) {
8810 printf("invalid parameter %s.\n", res->pf_vf);
8813 entry.input.flow_ext.is_vf = 1;
8814 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
8816 printf("invalid parameter %s.\n", res->pf_vf);
8821 /* set to report FD ID by default */
8822 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8823 entry.action.rx_queue = res->queue_id;
8824 entry.soft_id = res->fd_id_value;
8825 if (!strcmp(res->ops, "add"))
8826 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8827 RTE_ETH_FILTER_ADD, &entry);
8828 else if (!strcmp(res->ops, "del"))
8829 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8830 RTE_ETH_FILTER_DELETE, &entry);
8832 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8833 RTE_ETH_FILTER_UPDATE, &entry);
8835 printf("flow director programming error: (%s)\n",
8839 cmdline_parse_token_string_t cmd_flow_director_filter =
8840 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8841 flow_director_filter, "flow_director_filter");
8842 cmdline_parse_token_num_t cmd_flow_director_port_id =
8843 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8845 cmdline_parse_token_string_t cmd_flow_director_ops =
8846 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8847 ops, "add#del#update");
8848 cmdline_parse_token_string_t cmd_flow_director_flow =
8849 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8851 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8852 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8853 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
8854 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
8855 cmdline_parse_token_string_t cmd_flow_director_ether =
8856 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8858 cmdline_parse_token_num_t cmd_flow_director_ether_type =
8859 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8860 ether_type, UINT16);
8861 cmdline_parse_token_string_t cmd_flow_director_src =
8862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8864 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8865 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8867 cmdline_parse_token_num_t cmd_flow_director_port_src =
8868 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8870 cmdline_parse_token_string_t cmd_flow_director_dst =
8871 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8873 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8874 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8876 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8877 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8879 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8880 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8881 verify_tag, "verify_tag");
8882 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8883 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8884 verify_tag_value, UINT32);
8885 cmdline_parse_token_string_t cmd_flow_director_tos =
8886 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8888 cmdline_parse_token_num_t cmd_flow_director_tos_value =
8889 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8891 cmdline_parse_token_string_t cmd_flow_director_proto =
8892 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8894 cmdline_parse_token_num_t cmd_flow_director_proto_value =
8895 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8896 proto_value, UINT8);
8897 cmdline_parse_token_string_t cmd_flow_director_ttl =
8898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8900 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
8901 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8903 cmdline_parse_token_string_t cmd_flow_director_vlan =
8904 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8906 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
8907 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8908 vlan_value, UINT16);
8909 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8910 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8911 flexbytes, "flexbytes");
8912 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8913 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8914 flexbytes_value, NULL);
8915 cmdline_parse_token_string_t cmd_flow_director_drop =
8916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8918 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
8919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8921 cmdline_parse_token_string_t cmd_flow_director_queue =
8922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8924 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8925 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8927 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8930 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8931 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8932 fd_id_value, UINT32);
8934 cmdline_parse_token_string_t cmd_flow_director_mode =
8935 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8937 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
8938 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8940 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
8941 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8942 mode_value, "MAC-VLAN");
8943 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
8944 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8945 mode_value, "Tunnel");
8946 cmdline_parse_token_string_t cmd_flow_director_mac =
8947 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8949 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
8950 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
8952 cmdline_parse_token_string_t cmd_flow_director_tunnel =
8953 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8955 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
8956 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8957 tunnel_type, "NVGRE#VxLAN");
8958 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
8959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8960 tunnel_id, "tunnel-id");
8961 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
8962 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8963 tunnel_id_value, UINT32);
8965 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8966 .f = cmd_flow_director_filter_parsed,
8968 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
8969 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
8970 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
8971 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
8972 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
8973 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
8974 "fd_id <fd_id_value>: "
8975 "Add or delete an ip flow director entry on NIC",
8977 (void *)&cmd_flow_director_filter,
8978 (void *)&cmd_flow_director_port_id,
8979 (void *)&cmd_flow_director_mode,
8980 (void *)&cmd_flow_director_mode_ip,
8981 (void *)&cmd_flow_director_ops,
8982 (void *)&cmd_flow_director_flow,
8983 (void *)&cmd_flow_director_flow_type,
8984 (void *)&cmd_flow_director_src,
8985 (void *)&cmd_flow_director_ip_src,
8986 (void *)&cmd_flow_director_dst,
8987 (void *)&cmd_flow_director_ip_dst,
8988 (void *)&cmd_flow_director_tos,
8989 (void *)&cmd_flow_director_tos_value,
8990 (void *)&cmd_flow_director_proto,
8991 (void *)&cmd_flow_director_proto_value,
8992 (void *)&cmd_flow_director_ttl,
8993 (void *)&cmd_flow_director_ttl_value,
8994 (void *)&cmd_flow_director_vlan,
8995 (void *)&cmd_flow_director_vlan_value,
8996 (void *)&cmd_flow_director_flexbytes,
8997 (void *)&cmd_flow_director_flexbytes_value,
8998 (void *)&cmd_flow_director_drop,
8999 (void *)&cmd_flow_director_pf_vf,
9000 (void *)&cmd_flow_director_queue,
9001 (void *)&cmd_flow_director_queue_id,
9002 (void *)&cmd_flow_director_fd_id,
9003 (void *)&cmd_flow_director_fd_id_value,
9008 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
9009 .f = cmd_flow_director_filter_parsed,
9011 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
9012 "director entry on NIC",
9014 (void *)&cmd_flow_director_filter,
9015 (void *)&cmd_flow_director_port_id,
9016 (void *)&cmd_flow_director_mode,
9017 (void *)&cmd_flow_director_mode_ip,
9018 (void *)&cmd_flow_director_ops,
9019 (void *)&cmd_flow_director_flow,
9020 (void *)&cmd_flow_director_flow_type,
9021 (void *)&cmd_flow_director_src,
9022 (void *)&cmd_flow_director_ip_src,
9023 (void *)&cmd_flow_director_port_src,
9024 (void *)&cmd_flow_director_dst,
9025 (void *)&cmd_flow_director_ip_dst,
9026 (void *)&cmd_flow_director_port_dst,
9027 (void *)&cmd_flow_director_tos,
9028 (void *)&cmd_flow_director_tos_value,
9029 (void *)&cmd_flow_director_ttl,
9030 (void *)&cmd_flow_director_ttl_value,
9031 (void *)&cmd_flow_director_vlan,
9032 (void *)&cmd_flow_director_vlan_value,
9033 (void *)&cmd_flow_director_flexbytes,
9034 (void *)&cmd_flow_director_flexbytes_value,
9035 (void *)&cmd_flow_director_drop,
9036 (void *)&cmd_flow_director_pf_vf,
9037 (void *)&cmd_flow_director_queue,
9038 (void *)&cmd_flow_director_queue_id,
9039 (void *)&cmd_flow_director_fd_id,
9040 (void *)&cmd_flow_director_fd_id_value,
9045 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
9046 .f = cmd_flow_director_filter_parsed,
9048 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
9049 "director entry on NIC",
9051 (void *)&cmd_flow_director_filter,
9052 (void *)&cmd_flow_director_port_id,
9053 (void *)&cmd_flow_director_mode,
9054 (void *)&cmd_flow_director_mode_ip,
9055 (void *)&cmd_flow_director_ops,
9056 (void *)&cmd_flow_director_flow,
9057 (void *)&cmd_flow_director_flow_type,
9058 (void *)&cmd_flow_director_src,
9059 (void *)&cmd_flow_director_ip_src,
9060 (void *)&cmd_flow_director_port_dst,
9061 (void *)&cmd_flow_director_dst,
9062 (void *)&cmd_flow_director_ip_dst,
9063 (void *)&cmd_flow_director_port_dst,
9064 (void *)&cmd_flow_director_verify_tag,
9065 (void *)&cmd_flow_director_verify_tag_value,
9066 (void *)&cmd_flow_director_tos,
9067 (void *)&cmd_flow_director_tos_value,
9068 (void *)&cmd_flow_director_ttl,
9069 (void *)&cmd_flow_director_ttl_value,
9070 (void *)&cmd_flow_director_vlan,
9071 (void *)&cmd_flow_director_vlan_value,
9072 (void *)&cmd_flow_director_flexbytes,
9073 (void *)&cmd_flow_director_flexbytes_value,
9074 (void *)&cmd_flow_director_drop,
9075 (void *)&cmd_flow_director_pf_vf,
9076 (void *)&cmd_flow_director_queue,
9077 (void *)&cmd_flow_director_queue_id,
9078 (void *)&cmd_flow_director_fd_id,
9079 (void *)&cmd_flow_director_fd_id_value,
9084 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
9085 .f = cmd_flow_director_filter_parsed,
9087 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
9088 "director entry on NIC",
9090 (void *)&cmd_flow_director_filter,
9091 (void *)&cmd_flow_director_port_id,
9092 (void *)&cmd_flow_director_mode,
9093 (void *)&cmd_flow_director_mode_ip,
9094 (void *)&cmd_flow_director_ops,
9095 (void *)&cmd_flow_director_flow,
9096 (void *)&cmd_flow_director_flow_type,
9097 (void *)&cmd_flow_director_ether,
9098 (void *)&cmd_flow_director_ether_type,
9099 (void *)&cmd_flow_director_flexbytes,
9100 (void *)&cmd_flow_director_flexbytes_value,
9101 (void *)&cmd_flow_director_drop,
9102 (void *)&cmd_flow_director_pf_vf,
9103 (void *)&cmd_flow_director_queue,
9104 (void *)&cmd_flow_director_queue_id,
9105 (void *)&cmd_flow_director_fd_id,
9106 (void *)&cmd_flow_director_fd_id_value,
9111 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
9112 .f = cmd_flow_director_filter_parsed,
9114 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
9115 "director entry on NIC",
9117 (void *)&cmd_flow_director_filter,
9118 (void *)&cmd_flow_director_port_id,
9119 (void *)&cmd_flow_director_mode,
9120 (void *)&cmd_flow_director_mode_mac_vlan,
9121 (void *)&cmd_flow_director_ops,
9122 (void *)&cmd_flow_director_mac,
9123 (void *)&cmd_flow_director_mac_addr,
9124 (void *)&cmd_flow_director_vlan,
9125 (void *)&cmd_flow_director_vlan_value,
9126 (void *)&cmd_flow_director_flexbytes,
9127 (void *)&cmd_flow_director_flexbytes_value,
9128 (void *)&cmd_flow_director_drop,
9129 (void *)&cmd_flow_director_queue,
9130 (void *)&cmd_flow_director_queue_id,
9131 (void *)&cmd_flow_director_fd_id,
9132 (void *)&cmd_flow_director_fd_id_value,
9137 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
9138 .f = cmd_flow_director_filter_parsed,
9140 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
9141 "director entry on NIC",
9143 (void *)&cmd_flow_director_filter,
9144 (void *)&cmd_flow_director_port_id,
9145 (void *)&cmd_flow_director_mode,
9146 (void *)&cmd_flow_director_mode_tunnel,
9147 (void *)&cmd_flow_director_ops,
9148 (void *)&cmd_flow_director_mac,
9149 (void *)&cmd_flow_director_mac_addr,
9150 (void *)&cmd_flow_director_vlan,
9151 (void *)&cmd_flow_director_vlan_value,
9152 (void *)&cmd_flow_director_tunnel,
9153 (void *)&cmd_flow_director_tunnel_type,
9154 (void *)&cmd_flow_director_tunnel_id,
9155 (void *)&cmd_flow_director_tunnel_id_value,
9156 (void *)&cmd_flow_director_flexbytes,
9157 (void *)&cmd_flow_director_flexbytes_value,
9158 (void *)&cmd_flow_director_drop,
9159 (void *)&cmd_flow_director_queue,
9160 (void *)&cmd_flow_director_queue_id,
9161 (void *)&cmd_flow_director_fd_id,
9162 (void *)&cmd_flow_director_fd_id_value,
9167 struct cmd_flush_flow_director_result {
9168 cmdline_fixed_string_t flush_flow_director;
9172 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
9173 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
9174 flush_flow_director, "flush_flow_director");
9175 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
9176 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
9180 cmd_flush_flow_director_parsed(void *parsed_result,
9181 __attribute__((unused)) struct cmdline *cl,
9182 __attribute__((unused)) void *data)
9184 struct cmd_flow_director_result *res = parsed_result;
9187 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9189 printf("flow director is not supported on port %u.\n",
9194 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9195 RTE_ETH_FILTER_FLUSH, NULL);
9197 printf("flow director table flushing error: (%s)\n",
9201 cmdline_parse_inst_t cmd_flush_flow_director = {
9202 .f = cmd_flush_flow_director_parsed,
9204 .help_str = "flush_flow_director <port_id>: "
9205 "Flush all flow director entries of a device on NIC",
9207 (void *)&cmd_flush_flow_director_flush,
9208 (void *)&cmd_flush_flow_director_port_id,
9213 /* *** deal with flow director mask *** */
9214 struct cmd_flow_director_mask_result {
9215 cmdline_fixed_string_t flow_director_mask;
9217 cmdline_fixed_string_t mode;
9218 cmdline_fixed_string_t mode_value;
9219 cmdline_fixed_string_t vlan;
9221 cmdline_fixed_string_t src_mask;
9222 cmdline_ipaddr_t ipv4_src;
9223 cmdline_ipaddr_t ipv6_src;
9225 cmdline_fixed_string_t dst_mask;
9226 cmdline_ipaddr_t ipv4_dst;
9227 cmdline_ipaddr_t ipv6_dst;
9229 cmdline_fixed_string_t mac;
9230 uint8_t mac_addr_byte_mask;
9231 cmdline_fixed_string_t tunnel_id;
9232 uint32_t tunnel_id_mask;
9233 cmdline_fixed_string_t tunnel_type;
9234 uint8_t tunnel_type_mask;
9238 cmd_flow_director_mask_parsed(void *parsed_result,
9239 __attribute__((unused)) struct cmdline *cl,
9240 __attribute__((unused)) void *data)
9242 struct cmd_flow_director_mask_result *res = parsed_result;
9243 struct rte_eth_fdir_masks *mask;
9244 struct rte_port *port;
9246 if (res->port_id > nb_ports) {
9247 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9251 port = &ports[res->port_id];
9252 /** Check if the port is not started **/
9253 if (port->port_status != RTE_PORT_STOPPED) {
9254 printf("Please stop port %d first\n", res->port_id);
9258 mask = &port->dev_conf.fdir_conf.mask;
9260 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9261 if (strcmp(res->mode_value, "MAC-VLAN")) {
9262 printf("Please set mode to MAC-VLAN.\n");
9266 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9267 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9268 if (strcmp(res->mode_value, "Tunnel")) {
9269 printf("Please set mode to Tunnel.\n");
9273 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9274 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
9275 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
9276 mask->tunnel_type_mask = res->tunnel_type_mask;
9278 if (strcmp(res->mode_value, "IP")) {
9279 printf("Please set mode to IP.\n");
9283 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
9284 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
9285 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
9286 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
9287 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
9288 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
9289 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
9292 cmd_reconfig_device_queue(res->port_id, 1, 1);
9295 cmdline_parse_token_string_t cmd_flow_director_mask =
9296 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9297 flow_director_mask, "flow_director_mask");
9298 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
9299 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9301 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
9302 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9304 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
9305 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9307 cmdline_parse_token_string_t cmd_flow_director_mask_src =
9308 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9309 src_mask, "src_mask");
9310 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
9311 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9313 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
9314 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9316 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
9317 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9319 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
9320 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9321 dst_mask, "dst_mask");
9322 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
9323 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9325 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
9326 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
9328 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
9329 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9332 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
9333 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9335 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
9336 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9338 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
9339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9340 mode_value, "MAC-VLAN");
9341 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
9342 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9343 mode_value, "Tunnel");
9344 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
9345 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9347 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
9348 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9349 mac_addr_byte_mask, UINT8);
9350 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
9351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9352 tunnel_type, "tunnel-type");
9353 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
9354 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9355 tunnel_type_mask, UINT8);
9356 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
9357 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
9358 tunnel_id, "tunnel-id");
9359 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
9360 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
9361 tunnel_id_mask, UINT32);
9363 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
9364 .f = cmd_flow_director_mask_parsed,
9366 .help_str = "flow_director_mask ... : "
9367 "Set IP mode flow director's mask on NIC",
9369 (void *)&cmd_flow_director_mask,
9370 (void *)&cmd_flow_director_mask_port_id,
9371 (void *)&cmd_flow_director_mask_mode,
9372 (void *)&cmd_flow_director_mask_mode_ip,
9373 (void *)&cmd_flow_director_mask_vlan,
9374 (void *)&cmd_flow_director_mask_vlan_value,
9375 (void *)&cmd_flow_director_mask_src,
9376 (void *)&cmd_flow_director_mask_ipv4_src,
9377 (void *)&cmd_flow_director_mask_ipv6_src,
9378 (void *)&cmd_flow_director_mask_port_src,
9379 (void *)&cmd_flow_director_mask_dst,
9380 (void *)&cmd_flow_director_mask_ipv4_dst,
9381 (void *)&cmd_flow_director_mask_ipv6_dst,
9382 (void *)&cmd_flow_director_mask_port_dst,
9387 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
9388 .f = cmd_flow_director_mask_parsed,
9390 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
9391 "flow director's mask on NIC",
9393 (void *)&cmd_flow_director_mask,
9394 (void *)&cmd_flow_director_mask_port_id,
9395 (void *)&cmd_flow_director_mask_mode,
9396 (void *)&cmd_flow_director_mask_mode_mac_vlan,
9397 (void *)&cmd_flow_director_mask_vlan,
9398 (void *)&cmd_flow_director_mask_vlan_value,
9403 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
9404 .f = cmd_flow_director_mask_parsed,
9406 .help_str = "flow_director_mask ... : Set tunnel mode "
9407 "flow director's mask on NIC",
9409 (void *)&cmd_flow_director_mask,
9410 (void *)&cmd_flow_director_mask_port_id,
9411 (void *)&cmd_flow_director_mask_mode,
9412 (void *)&cmd_flow_director_mask_mode_tunnel,
9413 (void *)&cmd_flow_director_mask_vlan,
9414 (void *)&cmd_flow_director_mask_vlan_value,
9415 (void *)&cmd_flow_director_mask_mac,
9416 (void *)&cmd_flow_director_mask_mac_value,
9417 (void *)&cmd_flow_director_mask_tunnel_type,
9418 (void *)&cmd_flow_director_mask_tunnel_type_value,
9419 (void *)&cmd_flow_director_mask_tunnel_id,
9420 (void *)&cmd_flow_director_mask_tunnel_id_value,
9425 /* *** deal with flow director mask on flexible payload *** */
9426 struct cmd_flow_director_flex_mask_result {
9427 cmdline_fixed_string_t flow_director_flexmask;
9429 cmdline_fixed_string_t flow;
9430 cmdline_fixed_string_t flow_type;
9431 cmdline_fixed_string_t mask;
9435 cmd_flow_director_flex_mask_parsed(void *parsed_result,
9436 __attribute__((unused)) struct cmdline *cl,
9437 __attribute__((unused)) void *data)
9439 struct cmd_flow_director_flex_mask_result *res = parsed_result;
9440 struct rte_eth_fdir_info fdir_info;
9441 struct rte_eth_fdir_flex_mask flex_mask;
9442 struct rte_port *port;
9443 uint32_t flow_type_mask;
9447 if (res->port_id > nb_ports) {
9448 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9452 port = &ports[res->port_id];
9453 /** Check if the port is not started **/
9454 if (port->port_status != RTE_PORT_STOPPED) {
9455 printf("Please stop port %d first\n", res->port_id);
9459 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
9460 ret = parse_flexbytes(res->mask,
9462 RTE_ETH_FDIR_MAX_FLEXLEN);
9464 printf("error: Cannot parse mask input.\n");
9468 memset(&fdir_info, 0, sizeof(fdir_info));
9469 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9470 RTE_ETH_FILTER_INFO, &fdir_info);
9472 printf("Cannot get FDir filter info\n");
9476 if (!strcmp(res->flow_type, "none")) {
9477 /* means don't specify the flow type */
9478 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
9479 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
9480 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
9481 0, sizeof(struct rte_eth_fdir_flex_mask));
9482 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
9483 (void)rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
9485 sizeof(struct rte_eth_fdir_flex_mask));
9486 cmd_reconfig_device_queue(res->port_id, 1, 1);
9489 flow_type_mask = fdir_info.flow_types_mask[0];
9490 if (!strcmp(res->flow_type, "all")) {
9491 if (!flow_type_mask) {
9492 printf("No flow type supported\n");
9495 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
9496 if (flow_type_mask & (1 << i)) {
9497 flex_mask.flow_type = i;
9498 fdir_set_flex_mask(res->port_id, &flex_mask);
9501 cmd_reconfig_device_queue(res->port_id, 1, 1);
9504 flex_mask.flow_type = str2flowtype(res->flow_type);
9505 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
9506 printf("Flow type %s not supported on port %d\n",
9507 res->flow_type, res->port_id);
9510 fdir_set_flex_mask(res->port_id, &flex_mask);
9511 cmd_reconfig_device_queue(res->port_id, 1, 1);
9514 cmdline_parse_token_string_t cmd_flow_director_flexmask =
9515 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9516 flow_director_flexmask,
9517 "flow_director_flex_mask");
9518 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
9519 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9521 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
9522 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9524 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
9525 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9526 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9527 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
9528 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
9529 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
9532 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
9533 .f = cmd_flow_director_flex_mask_parsed,
9535 .help_str = "flow_director_flex_mask ... : "
9536 "Set flow director's flex mask on NIC",
9538 (void *)&cmd_flow_director_flexmask,
9539 (void *)&cmd_flow_director_flexmask_port_id,
9540 (void *)&cmd_flow_director_flexmask_flow,
9541 (void *)&cmd_flow_director_flexmask_flow_type,
9542 (void *)&cmd_flow_director_flexmask_mask,
9547 /* *** deal with flow director flexible payload configuration *** */
9548 struct cmd_flow_director_flexpayload_result {
9549 cmdline_fixed_string_t flow_director_flexpayload;
9551 cmdline_fixed_string_t payload_layer;
9552 cmdline_fixed_string_t payload_cfg;
9556 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
9559 const char *p, *p0 = q_arg;
9561 unsigned long int_fld;
9562 char *str_fld[max_num];
9567 p = strchr(p0, '(');
9571 p0 = strchr(p, ')');
9576 if (size >= sizeof(s))
9579 snprintf(s, sizeof(s), "%.*s", size, p);
9580 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9581 if (ret < 0 || ret > max_num)
9583 for (i = 0; i < ret; i++) {
9585 int_fld = strtoul(str_fld[i], &end, 0);
9586 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
9588 offsets[i] = (uint16_t)int_fld;
9594 cmd_flow_director_flxpld_parsed(void *parsed_result,
9595 __attribute__((unused)) struct cmdline *cl,
9596 __attribute__((unused)) void *data)
9598 struct cmd_flow_director_flexpayload_result *res = parsed_result;
9599 struct rte_eth_flex_payload_cfg flex_cfg;
9600 struct rte_port *port;
9603 if (res->port_id > nb_ports) {
9604 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
9608 port = &ports[res->port_id];
9609 /** Check if the port is not started **/
9610 if (port->port_status != RTE_PORT_STOPPED) {
9611 printf("Please stop port %d first\n", res->port_id);
9615 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
9617 if (!strcmp(res->payload_layer, "raw"))
9618 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
9619 else if (!strcmp(res->payload_layer, "l2"))
9620 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
9621 else if (!strcmp(res->payload_layer, "l3"))
9622 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
9623 else if (!strcmp(res->payload_layer, "l4"))
9624 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
9626 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
9627 RTE_ETH_FDIR_MAX_FLEXLEN);
9629 printf("error: Cannot parse flex payload input.\n");
9633 fdir_set_flex_payload(res->port_id, &flex_cfg);
9634 cmd_reconfig_device_queue(res->port_id, 1, 1);
9637 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
9638 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9639 flow_director_flexpayload,
9640 "flow_director_flex_payload");
9641 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
9642 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9644 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
9645 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9646 payload_layer, "raw#l2#l3#l4");
9647 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
9648 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
9651 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
9652 .f = cmd_flow_director_flxpld_parsed,
9654 .help_str = "flow_director_flexpayload ... : "
9655 "Set flow director's flex payload on NIC",
9657 (void *)&cmd_flow_director_flexpayload,
9658 (void *)&cmd_flow_director_flexpayload_port_id,
9659 (void *)&cmd_flow_director_flexpayload_payload_layer,
9660 (void *)&cmd_flow_director_flexpayload_payload_cfg,
9665 /* Generic flow interface command. */
9666 extern cmdline_parse_inst_t cmd_flow;
9668 /* *** Classification Filters Control *** */
9669 /* *** Get symmetric hash enable per port *** */
9670 struct cmd_get_sym_hash_ena_per_port_result {
9671 cmdline_fixed_string_t get_sym_hash_ena_per_port;
9676 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
9677 __rte_unused struct cmdline *cl,
9678 __rte_unused void *data)
9680 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
9681 struct rte_eth_hash_filter_info info;
9684 if (rte_eth_dev_filter_supported(res->port_id,
9685 RTE_ETH_FILTER_HASH) < 0) {
9686 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9691 memset(&info, 0, sizeof(info));
9692 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9693 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9694 RTE_ETH_FILTER_GET, &info);
9697 printf("Cannot get symmetric hash enable per port "
9698 "on port %u\n", res->port_id);
9702 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
9703 "enabled" : "disabled", res->port_id);
9706 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
9707 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9708 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
9709 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
9710 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
9713 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
9714 .f = cmd_get_sym_hash_per_port_parsed,
9716 .help_str = "get_sym_hash_ena_per_port <port_id>",
9718 (void *)&cmd_get_sym_hash_ena_per_port_all,
9719 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
9724 /* *** Set symmetric hash enable per port *** */
9725 struct cmd_set_sym_hash_ena_per_port_result {
9726 cmdline_fixed_string_t set_sym_hash_ena_per_port;
9727 cmdline_fixed_string_t enable;
9732 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
9733 __rte_unused struct cmdline *cl,
9734 __rte_unused void *data)
9736 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
9737 struct rte_eth_hash_filter_info info;
9740 if (rte_eth_dev_filter_supported(res->port_id,
9741 RTE_ETH_FILTER_HASH) < 0) {
9742 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
9747 memset(&info, 0, sizeof(info));
9748 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
9749 if (!strcmp(res->enable, "enable"))
9750 info.info.enable = 1;
9751 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9752 RTE_ETH_FILTER_SET, &info);
9754 printf("Cannot set symmetric hash enable per port on "
9755 "port %u\n", res->port_id);
9758 printf("Symmetric hash has been set to %s on port %u\n",
9759 res->enable, res->port_id);
9762 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
9763 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9764 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
9765 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
9766 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9768 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
9769 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
9770 enable, "enable#disable");
9772 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
9773 .f = cmd_set_sym_hash_per_port_parsed,
9775 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
9777 (void *)&cmd_set_sym_hash_ena_per_port_all,
9778 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
9779 (void *)&cmd_set_sym_hash_ena_per_port_enable,
9784 /* Get global config of hash function */
9785 struct cmd_get_hash_global_config_result {
9786 cmdline_fixed_string_t get_hash_global_config;
9791 flowtype_to_str(uint16_t ftype)
9798 {"ipv4", RTE_ETH_FLOW_IPV4},
9799 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9800 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9801 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9802 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9803 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9804 {"ipv6", RTE_ETH_FLOW_IPV6},
9805 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9806 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9807 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9808 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9809 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9810 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9811 {"port", RTE_ETH_FLOW_PORT},
9812 {"vxlan", RTE_ETH_FLOW_VXLAN},
9813 {"geneve", RTE_ETH_FLOW_GENEVE},
9814 {"nvgre", RTE_ETH_FLOW_NVGRE},
9817 for (i = 0; i < RTE_DIM(ftype_table); i++) {
9818 if (ftype_table[i].ftype == ftype)
9819 return ftype_table[i].str;
9826 cmd_get_hash_global_config_parsed(void *parsed_result,
9827 __rte_unused struct cmdline *cl,
9828 __rte_unused void *data)
9830 struct cmd_get_hash_global_config_result *res = parsed_result;
9831 struct rte_eth_hash_filter_info info;
9832 uint32_t idx, offset;
9837 if (rte_eth_dev_filter_supported(res->port_id,
9838 RTE_ETH_FILTER_HASH) < 0) {
9839 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9844 memset(&info, 0, sizeof(info));
9845 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9846 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9847 RTE_ETH_FILTER_GET, &info);
9849 printf("Cannot get hash global configurations by port %d\n",
9854 switch (info.info.global_conf.hash_func) {
9855 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
9856 printf("Hash function is Toeplitz\n");
9858 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
9859 printf("Hash function is Simple XOR\n");
9862 printf("Unknown hash function\n");
9866 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
9867 idx = i / UINT32_BIT;
9868 offset = i % UINT32_BIT;
9869 if (!(info.info.global_conf.valid_bit_mask[idx] &
9872 str = flowtype_to_str(i);
9875 printf("Symmetric hash is %s globally for flow type %s "
9877 ((info.info.global_conf.sym_hash_enable_mask[idx] &
9878 (1UL << offset)) ? "enabled" : "disabled"), str,
9883 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
9884 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
9885 get_hash_global_config, "get_hash_global_config");
9886 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
9887 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
9890 cmdline_parse_inst_t cmd_get_hash_global_config = {
9891 .f = cmd_get_hash_global_config_parsed,
9893 .help_str = "get_hash_global_config <port_id>",
9895 (void *)&cmd_get_hash_global_config_all,
9896 (void *)&cmd_get_hash_global_config_port_id,
9901 /* Set global config of hash function */
9902 struct cmd_set_hash_global_config_result {
9903 cmdline_fixed_string_t set_hash_global_config;
9905 cmdline_fixed_string_t hash_func;
9906 cmdline_fixed_string_t flow_type;
9907 cmdline_fixed_string_t enable;
9911 cmd_set_hash_global_config_parsed(void *parsed_result,
9912 __rte_unused struct cmdline *cl,
9913 __rte_unused void *data)
9915 struct cmd_set_hash_global_config_result *res = parsed_result;
9916 struct rte_eth_hash_filter_info info;
9917 uint32_t ftype, idx, offset;
9920 if (rte_eth_dev_filter_supported(res->port_id,
9921 RTE_ETH_FILTER_HASH) < 0) {
9922 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
9926 memset(&info, 0, sizeof(info));
9927 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
9928 if (!strcmp(res->hash_func, "toeplitz"))
9929 info.info.global_conf.hash_func =
9930 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9931 else if (!strcmp(res->hash_func, "simple_xor"))
9932 info.info.global_conf.hash_func =
9933 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9934 else if (!strcmp(res->hash_func, "default"))
9935 info.info.global_conf.hash_func =
9936 RTE_ETH_HASH_FUNCTION_DEFAULT;
9938 ftype = str2flowtype(res->flow_type);
9939 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
9940 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
9941 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
9942 if (!strcmp(res->enable, "enable"))
9943 info.info.global_conf.sym_hash_enable_mask[idx] |=
9945 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
9946 RTE_ETH_FILTER_SET, &info);
9948 printf("Cannot set global hash configurations by port %d\n",
9951 printf("Global hash configurations have been set "
9952 "succcessfully by port %d\n", res->port_id);
9955 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
9956 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9957 set_hash_global_config, "set_hash_global_config");
9958 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
9959 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
9961 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
9962 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9963 hash_func, "toeplitz#simple_xor#default");
9964 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
9965 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9967 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
9968 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
9969 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
9970 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
9971 enable, "enable#disable");
9973 cmdline_parse_inst_t cmd_set_hash_global_config = {
9974 .f = cmd_set_hash_global_config_parsed,
9976 .help_str = "set_hash_global_config <port_id> "
9977 "toeplitz|simple_xor|default "
9978 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
9979 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
9980 "l2_payload enable|disable",
9982 (void *)&cmd_set_hash_global_config_all,
9983 (void *)&cmd_set_hash_global_config_port_id,
9984 (void *)&cmd_set_hash_global_config_hash_func,
9985 (void *)&cmd_set_hash_global_config_flow_type,
9986 (void *)&cmd_set_hash_global_config_enable,
9991 /* Set hash input set */
9992 struct cmd_set_hash_input_set_result {
9993 cmdline_fixed_string_t set_hash_input_set;
9995 cmdline_fixed_string_t flow_type;
9996 cmdline_fixed_string_t inset_field;
9997 cmdline_fixed_string_t select;
10000 static enum rte_eth_input_set_field
10001 str2inset(char *string)
10005 static const struct {
10007 enum rte_eth_input_set_field inset;
10008 } inset_table[] = {
10009 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
10010 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
10011 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
10012 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
10013 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
10014 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
10015 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
10016 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
10017 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
10018 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
10019 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
10020 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
10021 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
10022 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
10023 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
10024 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
10025 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
10026 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
10027 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
10028 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
10029 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
10030 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
10031 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
10032 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
10033 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
10034 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
10035 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
10036 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
10037 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
10038 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
10039 {"none", RTE_ETH_INPUT_SET_NONE},
10042 for (i = 0; i < RTE_DIM(inset_table); i++) {
10043 if (!strcmp(string, inset_table[i].str))
10044 return inset_table[i].inset;
10047 return RTE_ETH_INPUT_SET_UNKNOWN;
10051 cmd_set_hash_input_set_parsed(void *parsed_result,
10052 __rte_unused struct cmdline *cl,
10053 __rte_unused void *data)
10055 struct cmd_set_hash_input_set_result *res = parsed_result;
10056 struct rte_eth_hash_filter_info info;
10058 memset(&info, 0, sizeof(info));
10059 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
10060 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10061 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10062 info.info.input_set_conf.inset_size = 1;
10063 if (!strcmp(res->select, "select"))
10064 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10065 else if (!strcmp(res->select, "add"))
10066 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10067 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10068 RTE_ETH_FILTER_SET, &info);
10071 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
10072 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10073 set_hash_input_set, "set_hash_input_set");
10074 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
10075 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
10077 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
10078 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10080 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10081 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10082 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
10083 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10085 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10086 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
10087 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
10088 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
10089 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
10091 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
10092 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
10093 select, "select#add");
10095 cmdline_parse_inst_t cmd_set_hash_input_set = {
10096 .f = cmd_set_hash_input_set_parsed,
10098 .help_str = "set_hash_input_set <port_id> "
10099 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10100 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10101 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
10102 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
10103 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
10104 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
10105 "fld-7th|fld-8th|none select|add",
10107 (void *)&cmd_set_hash_input_set_cmd,
10108 (void *)&cmd_set_hash_input_set_port_id,
10109 (void *)&cmd_set_hash_input_set_flow_type,
10110 (void *)&cmd_set_hash_input_set_field,
10111 (void *)&cmd_set_hash_input_set_select,
10116 /* Set flow director input set */
10117 struct cmd_set_fdir_input_set_result {
10118 cmdline_fixed_string_t set_fdir_input_set;
10120 cmdline_fixed_string_t flow_type;
10121 cmdline_fixed_string_t inset_field;
10122 cmdline_fixed_string_t select;
10126 cmd_set_fdir_input_set_parsed(void *parsed_result,
10127 __rte_unused struct cmdline *cl,
10128 __rte_unused void *data)
10130 struct cmd_set_fdir_input_set_result *res = parsed_result;
10131 struct rte_eth_fdir_filter_info info;
10133 memset(&info, 0, sizeof(info));
10134 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
10135 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
10136 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
10137 info.info.input_set_conf.inset_size = 1;
10138 if (!strcmp(res->select, "select"))
10139 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
10140 else if (!strcmp(res->select, "add"))
10141 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
10142 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10143 RTE_ETH_FILTER_SET, &info);
10146 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
10147 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10148 set_fdir_input_set, "set_fdir_input_set");
10149 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
10150 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
10152 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
10153 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10155 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
10156 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
10157 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
10158 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10160 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
10161 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
10162 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
10163 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
10164 "sctp-veri-tag#none");
10165 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
10166 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
10167 select, "select#add");
10169 cmdline_parse_inst_t cmd_set_fdir_input_set = {
10170 .f = cmd_set_fdir_input_set_parsed,
10172 .help_str = "set_fdir_input_set <port_id> "
10173 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
10174 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
10175 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
10176 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
10177 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
10178 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
10179 "sctp-veri-tag|none select|add",
10181 (void *)&cmd_set_fdir_input_set_cmd,
10182 (void *)&cmd_set_fdir_input_set_port_id,
10183 (void *)&cmd_set_fdir_input_set_flow_type,
10184 (void *)&cmd_set_fdir_input_set_field,
10185 (void *)&cmd_set_fdir_input_set_select,
10190 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10191 struct cmd_mcast_addr_result {
10192 cmdline_fixed_string_t mcast_addr_cmd;
10193 cmdline_fixed_string_t what;
10195 struct ether_addr mc_addr;
10198 static void cmd_mcast_addr_parsed(void *parsed_result,
10199 __attribute__((unused)) struct cmdline *cl,
10200 __attribute__((unused)) void *data)
10202 struct cmd_mcast_addr_result *res = parsed_result;
10204 if (!is_multicast_ether_addr(&res->mc_addr)) {
10205 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10206 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10207 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10208 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10211 if (strcmp(res->what, "add") == 0)
10212 mcast_addr_add(res->port_num, &res->mc_addr);
10214 mcast_addr_remove(res->port_num, &res->mc_addr);
10217 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10218 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10219 mcast_addr_cmd, "mcast_addr");
10220 cmdline_parse_token_string_t cmd_mcast_addr_what =
10221 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10223 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10224 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT8);
10225 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10226 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10228 cmdline_parse_inst_t cmd_mcast_addr = {
10229 .f = cmd_mcast_addr_parsed,
10231 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10232 "Add/Remove multicast MAC address on port_id",
10234 (void *)&cmd_mcast_addr_cmd,
10235 (void *)&cmd_mcast_addr_what,
10236 (void *)&cmd_mcast_addr_portnum,
10237 (void *)&cmd_mcast_addr_addr,
10242 /* l2 tunnel config
10243 * only support E-tag now.
10246 /* Ether type config */
10247 struct cmd_config_l2_tunnel_eth_type_result {
10248 cmdline_fixed_string_t port;
10249 cmdline_fixed_string_t config;
10250 cmdline_fixed_string_t all;
10252 cmdline_fixed_string_t l2_tunnel;
10253 cmdline_fixed_string_t l2_tunnel_type;
10254 cmdline_fixed_string_t eth_type;
10255 uint16_t eth_type_val;
10258 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10259 TOKEN_STRING_INITIALIZER
10260 (struct cmd_config_l2_tunnel_eth_type_result,
10262 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10263 TOKEN_STRING_INITIALIZER
10264 (struct cmd_config_l2_tunnel_eth_type_result,
10266 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10267 TOKEN_STRING_INITIALIZER
10268 (struct cmd_config_l2_tunnel_eth_type_result,
10270 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10271 TOKEN_NUM_INITIALIZER
10272 (struct cmd_config_l2_tunnel_eth_type_result,
10274 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10275 TOKEN_STRING_INITIALIZER
10276 (struct cmd_config_l2_tunnel_eth_type_result,
10277 l2_tunnel, "l2-tunnel");
10278 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10279 TOKEN_STRING_INITIALIZER
10280 (struct cmd_config_l2_tunnel_eth_type_result,
10281 l2_tunnel_type, "E-tag");
10282 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10283 TOKEN_STRING_INITIALIZER
10284 (struct cmd_config_l2_tunnel_eth_type_result,
10285 eth_type, "ether-type");
10286 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10287 TOKEN_NUM_INITIALIZER
10288 (struct cmd_config_l2_tunnel_eth_type_result,
10289 eth_type_val, UINT16);
10291 static enum rte_eth_tunnel_type
10292 str2fdir_l2_tunnel_type(char *string)
10296 static const struct {
10298 enum rte_eth_tunnel_type type;
10299 } l2_tunnel_type_str[] = {
10300 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10303 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10304 if (!strcmp(l2_tunnel_type_str[i].str, string))
10305 return l2_tunnel_type_str[i].type;
10307 return RTE_TUNNEL_TYPE_NONE;
10310 /* ether type config for all ports */
10312 cmd_config_l2_tunnel_eth_type_all_parsed
10313 (void *parsed_result,
10314 __attribute__((unused)) struct cmdline *cl,
10315 __attribute__((unused)) void *data)
10317 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10318 struct rte_eth_l2_tunnel_conf entry;
10321 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10322 entry.ether_type = res->eth_type_val;
10324 FOREACH_PORT(pid, ports) {
10325 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10329 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10330 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10332 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10334 (void *)&cmd_config_l2_tunnel_eth_type_port,
10335 (void *)&cmd_config_l2_tunnel_eth_type_config,
10336 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10337 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10338 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10339 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10340 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10345 /* ether type config for a specific port */
10347 cmd_config_l2_tunnel_eth_type_specific_parsed(
10348 void *parsed_result,
10349 __attribute__((unused)) struct cmdline *cl,
10350 __attribute__((unused)) void *data)
10352 struct cmd_config_l2_tunnel_eth_type_result *res =
10354 struct rte_eth_l2_tunnel_conf entry;
10356 if (port_id_is_invalid(res->id, ENABLED_WARN))
10359 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10360 entry.ether_type = res->eth_type_val;
10362 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10365 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10366 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10368 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10370 (void *)&cmd_config_l2_tunnel_eth_type_port,
10371 (void *)&cmd_config_l2_tunnel_eth_type_config,
10372 (void *)&cmd_config_l2_tunnel_eth_type_id,
10373 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10374 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10375 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10376 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10381 /* Enable/disable l2 tunnel */
10382 struct cmd_config_l2_tunnel_en_dis_result {
10383 cmdline_fixed_string_t port;
10384 cmdline_fixed_string_t config;
10385 cmdline_fixed_string_t all;
10387 cmdline_fixed_string_t l2_tunnel;
10388 cmdline_fixed_string_t l2_tunnel_type;
10389 cmdline_fixed_string_t en_dis;
10392 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10393 TOKEN_STRING_INITIALIZER
10394 (struct cmd_config_l2_tunnel_en_dis_result,
10396 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10397 TOKEN_STRING_INITIALIZER
10398 (struct cmd_config_l2_tunnel_en_dis_result,
10400 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10401 TOKEN_STRING_INITIALIZER
10402 (struct cmd_config_l2_tunnel_en_dis_result,
10404 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10405 TOKEN_NUM_INITIALIZER
10406 (struct cmd_config_l2_tunnel_en_dis_result,
10408 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10409 TOKEN_STRING_INITIALIZER
10410 (struct cmd_config_l2_tunnel_en_dis_result,
10411 l2_tunnel, "l2-tunnel");
10412 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10413 TOKEN_STRING_INITIALIZER
10414 (struct cmd_config_l2_tunnel_en_dis_result,
10415 l2_tunnel_type, "E-tag");
10416 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10417 TOKEN_STRING_INITIALIZER
10418 (struct cmd_config_l2_tunnel_en_dis_result,
10419 en_dis, "enable#disable");
10421 /* enable/disable l2 tunnel for all ports */
10423 cmd_config_l2_tunnel_en_dis_all_parsed(
10424 void *parsed_result,
10425 __attribute__((unused)) struct cmdline *cl,
10426 __attribute__((unused)) void *data)
10428 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10429 struct rte_eth_l2_tunnel_conf entry;
10433 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10435 if (!strcmp("enable", res->en_dis))
10440 FOREACH_PORT(pid, ports) {
10441 rte_eth_dev_l2_tunnel_offload_set(pid,
10443 ETH_L2_TUNNEL_ENABLE_MASK,
10448 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10449 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10451 .help_str = "port config all l2-tunnel E-tag enable|disable",
10453 (void *)&cmd_config_l2_tunnel_en_dis_port,
10454 (void *)&cmd_config_l2_tunnel_en_dis_config,
10455 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10456 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10457 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10458 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10463 /* enable/disable l2 tunnel for a port */
10465 cmd_config_l2_tunnel_en_dis_specific_parsed(
10466 void *parsed_result,
10467 __attribute__((unused)) struct cmdline *cl,
10468 __attribute__((unused)) void *data)
10470 struct cmd_config_l2_tunnel_en_dis_result *res =
10472 struct rte_eth_l2_tunnel_conf entry;
10474 if (port_id_is_invalid(res->id, ENABLED_WARN))
10477 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10479 if (!strcmp("enable", res->en_dis))
10480 rte_eth_dev_l2_tunnel_offload_set(res->id,
10482 ETH_L2_TUNNEL_ENABLE_MASK,
10485 rte_eth_dev_l2_tunnel_offload_set(res->id,
10487 ETH_L2_TUNNEL_ENABLE_MASK,
10491 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10492 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10494 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10496 (void *)&cmd_config_l2_tunnel_en_dis_port,
10497 (void *)&cmd_config_l2_tunnel_en_dis_config,
10498 (void *)&cmd_config_l2_tunnel_en_dis_id,
10499 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10500 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10501 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10506 /* E-tag configuration */
10508 /* Common result structure for all E-tag configuration */
10509 struct cmd_config_e_tag_result {
10510 cmdline_fixed_string_t e_tag;
10511 cmdline_fixed_string_t set;
10512 cmdline_fixed_string_t insertion;
10513 cmdline_fixed_string_t stripping;
10514 cmdline_fixed_string_t forwarding;
10515 cmdline_fixed_string_t filter;
10516 cmdline_fixed_string_t add;
10517 cmdline_fixed_string_t del;
10518 cmdline_fixed_string_t on;
10519 cmdline_fixed_string_t off;
10520 cmdline_fixed_string_t on_off;
10521 cmdline_fixed_string_t port_tag_id;
10522 uint32_t port_tag_id_val;
10523 cmdline_fixed_string_t e_tag_id;
10524 uint16_t e_tag_id_val;
10525 cmdline_fixed_string_t dst_pool;
10526 uint8_t dst_pool_val;
10527 cmdline_fixed_string_t port;
10529 cmdline_fixed_string_t vf;
10533 /* Common CLI fields for all E-tag configuration */
10534 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10535 TOKEN_STRING_INITIALIZER
10536 (struct cmd_config_e_tag_result,
10538 cmdline_parse_token_string_t cmd_config_e_tag_set =
10539 TOKEN_STRING_INITIALIZER
10540 (struct cmd_config_e_tag_result,
10542 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10543 TOKEN_STRING_INITIALIZER
10544 (struct cmd_config_e_tag_result,
10545 insertion, "insertion");
10546 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10547 TOKEN_STRING_INITIALIZER
10548 (struct cmd_config_e_tag_result,
10549 stripping, "stripping");
10550 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10551 TOKEN_STRING_INITIALIZER
10552 (struct cmd_config_e_tag_result,
10553 forwarding, "forwarding");
10554 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10555 TOKEN_STRING_INITIALIZER
10556 (struct cmd_config_e_tag_result,
10558 cmdline_parse_token_string_t cmd_config_e_tag_add =
10559 TOKEN_STRING_INITIALIZER
10560 (struct cmd_config_e_tag_result,
10562 cmdline_parse_token_string_t cmd_config_e_tag_del =
10563 TOKEN_STRING_INITIALIZER
10564 (struct cmd_config_e_tag_result,
10566 cmdline_parse_token_string_t cmd_config_e_tag_on =
10567 TOKEN_STRING_INITIALIZER
10568 (struct cmd_config_e_tag_result,
10570 cmdline_parse_token_string_t cmd_config_e_tag_off =
10571 TOKEN_STRING_INITIALIZER
10572 (struct cmd_config_e_tag_result,
10574 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10575 TOKEN_STRING_INITIALIZER
10576 (struct cmd_config_e_tag_result,
10578 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10579 TOKEN_STRING_INITIALIZER
10580 (struct cmd_config_e_tag_result,
10581 port_tag_id, "port-tag-id");
10582 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10583 TOKEN_NUM_INITIALIZER
10584 (struct cmd_config_e_tag_result,
10585 port_tag_id_val, UINT32);
10586 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10587 TOKEN_STRING_INITIALIZER
10588 (struct cmd_config_e_tag_result,
10589 e_tag_id, "e-tag-id");
10590 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10591 TOKEN_NUM_INITIALIZER
10592 (struct cmd_config_e_tag_result,
10593 e_tag_id_val, UINT16);
10594 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10595 TOKEN_STRING_INITIALIZER
10596 (struct cmd_config_e_tag_result,
10597 dst_pool, "dst-pool");
10598 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10599 TOKEN_NUM_INITIALIZER
10600 (struct cmd_config_e_tag_result,
10601 dst_pool_val, UINT8);
10602 cmdline_parse_token_string_t cmd_config_e_tag_port =
10603 TOKEN_STRING_INITIALIZER
10604 (struct cmd_config_e_tag_result,
10606 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10607 TOKEN_NUM_INITIALIZER
10608 (struct cmd_config_e_tag_result,
10610 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10611 TOKEN_STRING_INITIALIZER
10612 (struct cmd_config_e_tag_result,
10614 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10615 TOKEN_NUM_INITIALIZER
10616 (struct cmd_config_e_tag_result,
10619 /* E-tag insertion configuration */
10621 cmd_config_e_tag_insertion_en_parsed(
10622 void *parsed_result,
10623 __attribute__((unused)) struct cmdline *cl,
10624 __attribute__((unused)) void *data)
10626 struct cmd_config_e_tag_result *res =
10628 struct rte_eth_l2_tunnel_conf entry;
10630 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10633 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10634 entry.tunnel_id = res->port_tag_id_val;
10635 entry.vf_id = res->vf_id;
10636 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10638 ETH_L2_TUNNEL_INSERTION_MASK,
10643 cmd_config_e_tag_insertion_dis_parsed(
10644 void *parsed_result,
10645 __attribute__((unused)) struct cmdline *cl,
10646 __attribute__((unused)) void *data)
10648 struct cmd_config_e_tag_result *res =
10650 struct rte_eth_l2_tunnel_conf entry;
10652 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10655 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10656 entry.vf_id = res->vf_id;
10658 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10660 ETH_L2_TUNNEL_INSERTION_MASK,
10664 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10665 .f = cmd_config_e_tag_insertion_en_parsed,
10667 .help_str = "E-tag ... : E-tag insertion enable",
10669 (void *)&cmd_config_e_tag_e_tag,
10670 (void *)&cmd_config_e_tag_set,
10671 (void *)&cmd_config_e_tag_insertion,
10672 (void *)&cmd_config_e_tag_on,
10673 (void *)&cmd_config_e_tag_port_tag_id,
10674 (void *)&cmd_config_e_tag_port_tag_id_val,
10675 (void *)&cmd_config_e_tag_port,
10676 (void *)&cmd_config_e_tag_port_id,
10677 (void *)&cmd_config_e_tag_vf,
10678 (void *)&cmd_config_e_tag_vf_id,
10683 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
10684 .f = cmd_config_e_tag_insertion_dis_parsed,
10686 .help_str = "E-tag ... : E-tag insertion disable",
10688 (void *)&cmd_config_e_tag_e_tag,
10689 (void *)&cmd_config_e_tag_set,
10690 (void *)&cmd_config_e_tag_insertion,
10691 (void *)&cmd_config_e_tag_off,
10692 (void *)&cmd_config_e_tag_port,
10693 (void *)&cmd_config_e_tag_port_id,
10694 (void *)&cmd_config_e_tag_vf,
10695 (void *)&cmd_config_e_tag_vf_id,
10700 /* E-tag stripping configuration */
10702 cmd_config_e_tag_stripping_parsed(
10703 void *parsed_result,
10704 __attribute__((unused)) struct cmdline *cl,
10705 __attribute__((unused)) void *data)
10707 struct cmd_config_e_tag_result *res =
10709 struct rte_eth_l2_tunnel_conf entry;
10711 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10714 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10716 if (!strcmp(res->on_off, "on"))
10717 rte_eth_dev_l2_tunnel_offload_set
10720 ETH_L2_TUNNEL_STRIPPING_MASK,
10723 rte_eth_dev_l2_tunnel_offload_set
10726 ETH_L2_TUNNEL_STRIPPING_MASK,
10730 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
10731 .f = cmd_config_e_tag_stripping_parsed,
10733 .help_str = "E-tag ... : E-tag stripping enable/disable",
10735 (void *)&cmd_config_e_tag_e_tag,
10736 (void *)&cmd_config_e_tag_set,
10737 (void *)&cmd_config_e_tag_stripping,
10738 (void *)&cmd_config_e_tag_on_off,
10739 (void *)&cmd_config_e_tag_port,
10740 (void *)&cmd_config_e_tag_port_id,
10745 /* E-tag forwarding configuration */
10747 cmd_config_e_tag_forwarding_parsed(
10748 void *parsed_result,
10749 __attribute__((unused)) struct cmdline *cl,
10750 __attribute__((unused)) void *data)
10752 struct cmd_config_e_tag_result *res = parsed_result;
10753 struct rte_eth_l2_tunnel_conf entry;
10755 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10758 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10760 if (!strcmp(res->on_off, "on"))
10761 rte_eth_dev_l2_tunnel_offload_set
10764 ETH_L2_TUNNEL_FORWARDING_MASK,
10767 rte_eth_dev_l2_tunnel_offload_set
10770 ETH_L2_TUNNEL_FORWARDING_MASK,
10774 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
10775 .f = cmd_config_e_tag_forwarding_parsed,
10777 .help_str = "E-tag ... : E-tag forwarding enable/disable",
10779 (void *)&cmd_config_e_tag_e_tag,
10780 (void *)&cmd_config_e_tag_set,
10781 (void *)&cmd_config_e_tag_forwarding,
10782 (void *)&cmd_config_e_tag_on_off,
10783 (void *)&cmd_config_e_tag_port,
10784 (void *)&cmd_config_e_tag_port_id,
10789 /* E-tag filter configuration */
10791 cmd_config_e_tag_filter_add_parsed(
10792 void *parsed_result,
10793 __attribute__((unused)) struct cmdline *cl,
10794 __attribute__((unused)) void *data)
10796 struct cmd_config_e_tag_result *res = parsed_result;
10797 struct rte_eth_l2_tunnel_conf entry;
10800 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10803 if (res->e_tag_id_val > 0x3fff) {
10804 printf("e-tag-id must be equal or less than 0x3fff.\n");
10808 ret = rte_eth_dev_filter_supported(res->port_id,
10809 RTE_ETH_FILTER_L2_TUNNEL);
10811 printf("E-tag filter is not supported on port %u.\n",
10816 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10817 entry.tunnel_id = res->e_tag_id_val;
10818 entry.pool = res->dst_pool_val;
10820 ret = rte_eth_dev_filter_ctrl(res->port_id,
10821 RTE_ETH_FILTER_L2_TUNNEL,
10822 RTE_ETH_FILTER_ADD,
10825 printf("E-tag filter programming error: (%s)\n",
10829 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
10830 .f = cmd_config_e_tag_filter_add_parsed,
10832 .help_str = "E-tag ... : E-tag filter add",
10834 (void *)&cmd_config_e_tag_e_tag,
10835 (void *)&cmd_config_e_tag_set,
10836 (void *)&cmd_config_e_tag_filter,
10837 (void *)&cmd_config_e_tag_add,
10838 (void *)&cmd_config_e_tag_e_tag_id,
10839 (void *)&cmd_config_e_tag_e_tag_id_val,
10840 (void *)&cmd_config_e_tag_dst_pool,
10841 (void *)&cmd_config_e_tag_dst_pool_val,
10842 (void *)&cmd_config_e_tag_port,
10843 (void *)&cmd_config_e_tag_port_id,
10849 cmd_config_e_tag_filter_del_parsed(
10850 void *parsed_result,
10851 __attribute__((unused)) struct cmdline *cl,
10852 __attribute__((unused)) void *data)
10854 struct cmd_config_e_tag_result *res = parsed_result;
10855 struct rte_eth_l2_tunnel_conf entry;
10858 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10861 if (res->e_tag_id_val > 0x3fff) {
10862 printf("e-tag-id must be less than 0x3fff.\n");
10866 ret = rte_eth_dev_filter_supported(res->port_id,
10867 RTE_ETH_FILTER_L2_TUNNEL);
10869 printf("E-tag filter is not supported on port %u.\n",
10874 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10875 entry.tunnel_id = res->e_tag_id_val;
10877 ret = rte_eth_dev_filter_ctrl(res->port_id,
10878 RTE_ETH_FILTER_L2_TUNNEL,
10879 RTE_ETH_FILTER_DELETE,
10882 printf("E-tag filter programming error: (%s)\n",
10886 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
10887 .f = cmd_config_e_tag_filter_del_parsed,
10889 .help_str = "E-tag ... : E-tag filter delete",
10891 (void *)&cmd_config_e_tag_e_tag,
10892 (void *)&cmd_config_e_tag_set,
10893 (void *)&cmd_config_e_tag_filter,
10894 (void *)&cmd_config_e_tag_del,
10895 (void *)&cmd_config_e_tag_e_tag_id,
10896 (void *)&cmd_config_e_tag_e_tag_id_val,
10897 (void *)&cmd_config_e_tag_port,
10898 (void *)&cmd_config_e_tag_port_id,
10903 /* vf vlan anti spoof configuration */
10905 /* Common result structure for vf vlan anti spoof */
10906 struct cmd_vf_vlan_anti_spoof_result {
10907 cmdline_fixed_string_t set;
10908 cmdline_fixed_string_t vf;
10909 cmdline_fixed_string_t vlan;
10910 cmdline_fixed_string_t antispoof;
10913 cmdline_fixed_string_t on_off;
10916 /* Common CLI fields for vf vlan anti spoof enable disable */
10917 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10918 TOKEN_STRING_INITIALIZER
10919 (struct cmd_vf_vlan_anti_spoof_result,
10921 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10922 TOKEN_STRING_INITIALIZER
10923 (struct cmd_vf_vlan_anti_spoof_result,
10925 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10926 TOKEN_STRING_INITIALIZER
10927 (struct cmd_vf_vlan_anti_spoof_result,
10929 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10930 TOKEN_STRING_INITIALIZER
10931 (struct cmd_vf_vlan_anti_spoof_result,
10932 antispoof, "antispoof");
10933 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10934 TOKEN_NUM_INITIALIZER
10935 (struct cmd_vf_vlan_anti_spoof_result,
10937 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10938 TOKEN_NUM_INITIALIZER
10939 (struct cmd_vf_vlan_anti_spoof_result,
10941 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10942 TOKEN_STRING_INITIALIZER
10943 (struct cmd_vf_vlan_anti_spoof_result,
10947 cmd_set_vf_vlan_anti_spoof_parsed(
10948 void *parsed_result,
10949 __attribute__((unused)) struct cmdline *cl,
10950 __attribute__((unused)) void *data)
10952 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10953 int ret = -ENOTSUP;
10955 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10957 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10960 #ifdef RTE_LIBRTE_IXGBE_PMD
10961 if (ret == -ENOTSUP)
10962 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10963 res->vf_id, is_on);
10965 #ifdef RTE_LIBRTE_I40E_PMD
10966 if (ret == -ENOTSUP)
10967 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10968 res->vf_id, is_on);
10975 printf("invalid vf_id %d\n", res->vf_id);
10978 printf("invalid port_id %d\n", res->port_id);
10981 printf("function not implemented\n");
10984 printf("programming error: (%s)\n", strerror(-ret));
10988 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10989 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10991 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10993 (void *)&cmd_vf_vlan_anti_spoof_set,
10994 (void *)&cmd_vf_vlan_anti_spoof_vf,
10995 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10996 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10997 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10998 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10999 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11004 /* vf mac anti spoof configuration */
11006 /* Common result structure for vf mac anti spoof */
11007 struct cmd_vf_mac_anti_spoof_result {
11008 cmdline_fixed_string_t set;
11009 cmdline_fixed_string_t vf;
11010 cmdline_fixed_string_t mac;
11011 cmdline_fixed_string_t antispoof;
11014 cmdline_fixed_string_t on_off;
11017 /* Common CLI fields for vf mac anti spoof enable disable */
11018 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11019 TOKEN_STRING_INITIALIZER
11020 (struct cmd_vf_mac_anti_spoof_result,
11022 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11023 TOKEN_STRING_INITIALIZER
11024 (struct cmd_vf_mac_anti_spoof_result,
11026 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11027 TOKEN_STRING_INITIALIZER
11028 (struct cmd_vf_mac_anti_spoof_result,
11030 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11031 TOKEN_STRING_INITIALIZER
11032 (struct cmd_vf_mac_anti_spoof_result,
11033 antispoof, "antispoof");
11034 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11035 TOKEN_NUM_INITIALIZER
11036 (struct cmd_vf_mac_anti_spoof_result,
11038 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11039 TOKEN_NUM_INITIALIZER
11040 (struct cmd_vf_mac_anti_spoof_result,
11042 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11043 TOKEN_STRING_INITIALIZER
11044 (struct cmd_vf_mac_anti_spoof_result,
11048 cmd_set_vf_mac_anti_spoof_parsed(
11049 void *parsed_result,
11050 __attribute__((unused)) struct cmdline *cl,
11051 __attribute__((unused)) void *data)
11053 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11054 int ret = -ENOTSUP;
11056 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11058 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11061 #ifdef RTE_LIBRTE_IXGBE_PMD
11062 if (ret == -ENOTSUP)
11063 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11064 res->vf_id, is_on);
11066 #ifdef RTE_LIBRTE_I40E_PMD
11067 if (ret == -ENOTSUP)
11068 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11069 res->vf_id, is_on);
11076 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11079 printf("invalid port_id %d\n", res->port_id);
11082 printf("function not implemented\n");
11085 printf("programming error: (%s)\n", strerror(-ret));
11089 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11090 .f = cmd_set_vf_mac_anti_spoof_parsed,
11092 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11094 (void *)&cmd_vf_mac_anti_spoof_set,
11095 (void *)&cmd_vf_mac_anti_spoof_vf,
11096 (void *)&cmd_vf_mac_anti_spoof_mac,
11097 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11098 (void *)&cmd_vf_mac_anti_spoof_port_id,
11099 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11100 (void *)&cmd_vf_mac_anti_spoof_on_off,
11105 /* vf vlan strip queue configuration */
11107 /* Common result structure for vf mac anti spoof */
11108 struct cmd_vf_vlan_stripq_result {
11109 cmdline_fixed_string_t set;
11110 cmdline_fixed_string_t vf;
11111 cmdline_fixed_string_t vlan;
11112 cmdline_fixed_string_t stripq;
11115 cmdline_fixed_string_t on_off;
11118 /* Common CLI fields for vf vlan strip enable disable */
11119 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11120 TOKEN_STRING_INITIALIZER
11121 (struct cmd_vf_vlan_stripq_result,
11123 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11124 TOKEN_STRING_INITIALIZER
11125 (struct cmd_vf_vlan_stripq_result,
11127 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11128 TOKEN_STRING_INITIALIZER
11129 (struct cmd_vf_vlan_stripq_result,
11131 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11132 TOKEN_STRING_INITIALIZER
11133 (struct cmd_vf_vlan_stripq_result,
11135 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11136 TOKEN_NUM_INITIALIZER
11137 (struct cmd_vf_vlan_stripq_result,
11139 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11140 TOKEN_NUM_INITIALIZER
11141 (struct cmd_vf_vlan_stripq_result,
11143 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11144 TOKEN_STRING_INITIALIZER
11145 (struct cmd_vf_vlan_stripq_result,
11149 cmd_set_vf_vlan_stripq_parsed(
11150 void *parsed_result,
11151 __attribute__((unused)) struct cmdline *cl,
11152 __attribute__((unused)) void *data)
11154 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11155 int ret = -ENOTSUP;
11157 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11159 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11162 #ifdef RTE_LIBRTE_IXGBE_PMD
11163 if (ret == -ENOTSUP)
11164 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11165 res->vf_id, is_on);
11167 #ifdef RTE_LIBRTE_I40E_PMD
11168 if (ret == -ENOTSUP)
11169 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11170 res->vf_id, is_on);
11177 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11180 printf("invalid port_id %d\n", res->port_id);
11183 printf("function not implemented\n");
11186 printf("programming error: (%s)\n", strerror(-ret));
11190 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11191 .f = cmd_set_vf_vlan_stripq_parsed,
11193 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11195 (void *)&cmd_vf_vlan_stripq_set,
11196 (void *)&cmd_vf_vlan_stripq_vf,
11197 (void *)&cmd_vf_vlan_stripq_vlan,
11198 (void *)&cmd_vf_vlan_stripq_stripq,
11199 (void *)&cmd_vf_vlan_stripq_port_id,
11200 (void *)&cmd_vf_vlan_stripq_vf_id,
11201 (void *)&cmd_vf_vlan_stripq_on_off,
11206 /* vf vlan insert configuration */
11208 /* Common result structure for vf vlan insert */
11209 struct cmd_vf_vlan_insert_result {
11210 cmdline_fixed_string_t set;
11211 cmdline_fixed_string_t vf;
11212 cmdline_fixed_string_t vlan;
11213 cmdline_fixed_string_t insert;
11219 /* Common CLI fields for vf vlan insert enable disable */
11220 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11221 TOKEN_STRING_INITIALIZER
11222 (struct cmd_vf_vlan_insert_result,
11224 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11225 TOKEN_STRING_INITIALIZER
11226 (struct cmd_vf_vlan_insert_result,
11228 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11229 TOKEN_STRING_INITIALIZER
11230 (struct cmd_vf_vlan_insert_result,
11232 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11233 TOKEN_STRING_INITIALIZER
11234 (struct cmd_vf_vlan_insert_result,
11236 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11237 TOKEN_NUM_INITIALIZER
11238 (struct cmd_vf_vlan_insert_result,
11240 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11241 TOKEN_NUM_INITIALIZER
11242 (struct cmd_vf_vlan_insert_result,
11244 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11245 TOKEN_NUM_INITIALIZER
11246 (struct cmd_vf_vlan_insert_result,
11250 cmd_set_vf_vlan_insert_parsed(
11251 void *parsed_result,
11252 __attribute__((unused)) struct cmdline *cl,
11253 __attribute__((unused)) void *data)
11255 struct cmd_vf_vlan_insert_result *res = parsed_result;
11256 int ret = -ENOTSUP;
11258 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11261 #ifdef RTE_LIBRTE_IXGBE_PMD
11262 if (ret == -ENOTSUP)
11263 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11266 #ifdef RTE_LIBRTE_I40E_PMD
11267 if (ret == -ENOTSUP)
11268 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11276 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11279 printf("invalid port_id %d\n", res->port_id);
11282 printf("function not implemented\n");
11285 printf("programming error: (%s)\n", strerror(-ret));
11289 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11290 .f = cmd_set_vf_vlan_insert_parsed,
11292 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11294 (void *)&cmd_vf_vlan_insert_set,
11295 (void *)&cmd_vf_vlan_insert_vf,
11296 (void *)&cmd_vf_vlan_insert_vlan,
11297 (void *)&cmd_vf_vlan_insert_insert,
11298 (void *)&cmd_vf_vlan_insert_port_id,
11299 (void *)&cmd_vf_vlan_insert_vf_id,
11300 (void *)&cmd_vf_vlan_insert_vlan_id,
11305 /* tx loopback configuration */
11307 /* Common result structure for tx loopback */
11308 struct cmd_tx_loopback_result {
11309 cmdline_fixed_string_t set;
11310 cmdline_fixed_string_t tx;
11311 cmdline_fixed_string_t loopback;
11313 cmdline_fixed_string_t on_off;
11316 /* Common CLI fields for tx loopback enable disable */
11317 cmdline_parse_token_string_t cmd_tx_loopback_set =
11318 TOKEN_STRING_INITIALIZER
11319 (struct cmd_tx_loopback_result,
11321 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11322 TOKEN_STRING_INITIALIZER
11323 (struct cmd_tx_loopback_result,
11325 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11326 TOKEN_STRING_INITIALIZER
11327 (struct cmd_tx_loopback_result,
11328 loopback, "loopback");
11329 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11330 TOKEN_NUM_INITIALIZER
11331 (struct cmd_tx_loopback_result,
11333 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11334 TOKEN_STRING_INITIALIZER
11335 (struct cmd_tx_loopback_result,
11339 cmd_set_tx_loopback_parsed(
11340 void *parsed_result,
11341 __attribute__((unused)) struct cmdline *cl,
11342 __attribute__((unused)) void *data)
11344 struct cmd_tx_loopback_result *res = parsed_result;
11345 int ret = -ENOTSUP;
11347 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11349 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11352 #ifdef RTE_LIBRTE_IXGBE_PMD
11353 if (ret == -ENOTSUP)
11354 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11356 #ifdef RTE_LIBRTE_I40E_PMD
11357 if (ret == -ENOTSUP)
11358 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11365 printf("invalid is_on %d\n", is_on);
11368 printf("invalid port_id %d\n", res->port_id);
11371 printf("function not implemented\n");
11374 printf("programming error: (%s)\n", strerror(-ret));
11378 cmdline_parse_inst_t cmd_set_tx_loopback = {
11379 .f = cmd_set_tx_loopback_parsed,
11381 .help_str = "set tx loopback <port_id> on|off",
11383 (void *)&cmd_tx_loopback_set,
11384 (void *)&cmd_tx_loopback_tx,
11385 (void *)&cmd_tx_loopback_loopback,
11386 (void *)&cmd_tx_loopback_port_id,
11387 (void *)&cmd_tx_loopback_on_off,
11392 #ifdef RTE_LIBRTE_IXGBE_PMD
11393 /* all queues drop enable configuration */
11395 /* Common result structure for all queues drop enable */
11396 struct cmd_all_queues_drop_en_result {
11397 cmdline_fixed_string_t set;
11398 cmdline_fixed_string_t all;
11399 cmdline_fixed_string_t queues;
11400 cmdline_fixed_string_t drop;
11402 cmdline_fixed_string_t on_off;
11405 /* Common CLI fields for tx loopback enable disable */
11406 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11407 TOKEN_STRING_INITIALIZER
11408 (struct cmd_all_queues_drop_en_result,
11410 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11411 TOKEN_STRING_INITIALIZER
11412 (struct cmd_all_queues_drop_en_result,
11414 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11415 TOKEN_STRING_INITIALIZER
11416 (struct cmd_all_queues_drop_en_result,
11418 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11419 TOKEN_STRING_INITIALIZER
11420 (struct cmd_all_queues_drop_en_result,
11422 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11423 TOKEN_NUM_INITIALIZER
11424 (struct cmd_all_queues_drop_en_result,
11426 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11427 TOKEN_STRING_INITIALIZER
11428 (struct cmd_all_queues_drop_en_result,
11432 cmd_set_all_queues_drop_en_parsed(
11433 void *parsed_result,
11434 __attribute__((unused)) struct cmdline *cl,
11435 __attribute__((unused)) void *data)
11437 struct cmd_all_queues_drop_en_result *res = parsed_result;
11439 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11441 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11444 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11449 printf("invalid is_on %d\n", is_on);
11452 printf("invalid port_id %d\n", res->port_id);
11455 printf("function not implemented\n");
11458 printf("programming error: (%s)\n", strerror(-ret));
11462 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11463 .f = cmd_set_all_queues_drop_en_parsed,
11465 .help_str = "set all queues drop <port_id> on|off",
11467 (void *)&cmd_all_queues_drop_en_set,
11468 (void *)&cmd_all_queues_drop_en_all,
11469 (void *)&cmd_all_queues_drop_en_queues,
11470 (void *)&cmd_all_queues_drop_en_drop,
11471 (void *)&cmd_all_queues_drop_en_port_id,
11472 (void *)&cmd_all_queues_drop_en_on_off,
11477 /* vf split drop enable configuration */
11479 /* Common result structure for vf split drop enable */
11480 struct cmd_vf_split_drop_en_result {
11481 cmdline_fixed_string_t set;
11482 cmdline_fixed_string_t vf;
11483 cmdline_fixed_string_t split;
11484 cmdline_fixed_string_t drop;
11487 cmdline_fixed_string_t on_off;
11490 /* Common CLI fields for vf split drop enable disable */
11491 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11492 TOKEN_STRING_INITIALIZER
11493 (struct cmd_vf_split_drop_en_result,
11495 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11496 TOKEN_STRING_INITIALIZER
11497 (struct cmd_vf_split_drop_en_result,
11499 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11500 TOKEN_STRING_INITIALIZER
11501 (struct cmd_vf_split_drop_en_result,
11503 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11504 TOKEN_STRING_INITIALIZER
11505 (struct cmd_vf_split_drop_en_result,
11507 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11508 TOKEN_NUM_INITIALIZER
11509 (struct cmd_vf_split_drop_en_result,
11511 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11512 TOKEN_NUM_INITIALIZER
11513 (struct cmd_vf_split_drop_en_result,
11515 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11516 TOKEN_STRING_INITIALIZER
11517 (struct cmd_vf_split_drop_en_result,
11521 cmd_set_vf_split_drop_en_parsed(
11522 void *parsed_result,
11523 __attribute__((unused)) struct cmdline *cl,
11524 __attribute__((unused)) void *data)
11526 struct cmd_vf_split_drop_en_result *res = parsed_result;
11528 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11530 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11533 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11539 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11542 printf("invalid port_id %d\n", res->port_id);
11545 printf("programming error: (%s)\n", strerror(-ret));
11549 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11550 .f = cmd_set_vf_split_drop_en_parsed,
11552 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11554 (void *)&cmd_vf_split_drop_en_set,
11555 (void *)&cmd_vf_split_drop_en_vf,
11556 (void *)&cmd_vf_split_drop_en_split,
11557 (void *)&cmd_vf_split_drop_en_drop,
11558 (void *)&cmd_vf_split_drop_en_port_id,
11559 (void *)&cmd_vf_split_drop_en_vf_id,
11560 (void *)&cmd_vf_split_drop_en_on_off,
11566 /* vf mac address configuration */
11568 /* Common result structure for vf mac address */
11569 struct cmd_set_vf_mac_addr_result {
11570 cmdline_fixed_string_t set;
11571 cmdline_fixed_string_t vf;
11572 cmdline_fixed_string_t mac;
11573 cmdline_fixed_string_t addr;
11576 struct ether_addr mac_addr;
11580 /* Common CLI fields for vf split drop enable disable */
11581 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11582 TOKEN_STRING_INITIALIZER
11583 (struct cmd_set_vf_mac_addr_result,
11585 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11586 TOKEN_STRING_INITIALIZER
11587 (struct cmd_set_vf_mac_addr_result,
11589 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11590 TOKEN_STRING_INITIALIZER
11591 (struct cmd_set_vf_mac_addr_result,
11593 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11594 TOKEN_STRING_INITIALIZER
11595 (struct cmd_set_vf_mac_addr_result,
11597 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11598 TOKEN_NUM_INITIALIZER
11599 (struct cmd_set_vf_mac_addr_result,
11601 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11602 TOKEN_NUM_INITIALIZER
11603 (struct cmd_set_vf_mac_addr_result,
11605 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11606 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11610 cmd_set_vf_mac_addr_parsed(
11611 void *parsed_result,
11612 __attribute__((unused)) struct cmdline *cl,
11613 __attribute__((unused)) void *data)
11615 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11616 int ret = -ENOTSUP;
11618 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11621 #ifdef RTE_LIBRTE_IXGBE_PMD
11622 if (ret == -ENOTSUP)
11623 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11626 #ifdef RTE_LIBRTE_I40E_PMD
11627 if (ret == -ENOTSUP)
11628 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11636 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11639 printf("invalid port_id %d\n", res->port_id);
11642 printf("function not implemented\n");
11645 printf("programming error: (%s)\n", strerror(-ret));
11649 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11650 .f = cmd_set_vf_mac_addr_parsed,
11652 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11654 (void *)&cmd_set_vf_mac_addr_set,
11655 (void *)&cmd_set_vf_mac_addr_vf,
11656 (void *)&cmd_set_vf_mac_addr_mac,
11657 (void *)&cmd_set_vf_mac_addr_addr,
11658 (void *)&cmd_set_vf_mac_addr_port_id,
11659 (void *)&cmd_set_vf_mac_addr_vf_id,
11660 (void *)&cmd_set_vf_mac_addr_mac_addr,
11665 #ifdef RTE_LIBRTE_IXGBE_PMD
11666 /* MACsec configuration */
11668 /* Common result structure for MACsec offload enable */
11669 struct cmd_macsec_offload_on_result {
11670 cmdline_fixed_string_t set;
11671 cmdline_fixed_string_t macsec;
11672 cmdline_fixed_string_t offload;
11674 cmdline_fixed_string_t on;
11675 cmdline_fixed_string_t encrypt;
11676 cmdline_fixed_string_t en_on_off;
11677 cmdline_fixed_string_t replay_protect;
11678 cmdline_fixed_string_t rp_on_off;
11681 /* Common CLI fields for MACsec offload disable */
11682 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11683 TOKEN_STRING_INITIALIZER
11684 (struct cmd_macsec_offload_on_result,
11686 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11687 TOKEN_STRING_INITIALIZER
11688 (struct cmd_macsec_offload_on_result,
11690 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11691 TOKEN_STRING_INITIALIZER
11692 (struct cmd_macsec_offload_on_result,
11693 offload, "offload");
11694 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11695 TOKEN_NUM_INITIALIZER
11696 (struct cmd_macsec_offload_on_result,
11698 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11699 TOKEN_STRING_INITIALIZER
11700 (struct cmd_macsec_offload_on_result,
11702 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11703 TOKEN_STRING_INITIALIZER
11704 (struct cmd_macsec_offload_on_result,
11705 encrypt, "encrypt");
11706 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11707 TOKEN_STRING_INITIALIZER
11708 (struct cmd_macsec_offload_on_result,
11709 en_on_off, "on#off");
11710 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11711 TOKEN_STRING_INITIALIZER
11712 (struct cmd_macsec_offload_on_result,
11713 replay_protect, "replay-protect");
11714 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11715 TOKEN_STRING_INITIALIZER
11716 (struct cmd_macsec_offload_on_result,
11717 rp_on_off, "on#off");
11720 cmd_set_macsec_offload_on_parsed(
11721 void *parsed_result,
11722 __attribute__((unused)) struct cmdline *cl,
11723 __attribute__((unused)) void *data)
11725 struct cmd_macsec_offload_on_result *res = parsed_result;
11727 portid_t port_id = res->port_id;
11728 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11729 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11731 if (port_id_is_invalid(port_id, ENABLED_WARN))
11734 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
11735 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11741 printf("invalid port_id %d\n", port_id);
11744 printf("programming error: (%s)\n", strerror(-ret));
11748 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11749 .f = cmd_set_macsec_offload_on_parsed,
11751 .help_str = "set macsec offload <port_id> on "
11752 "encrypt on|off replay-protect on|off",
11754 (void *)&cmd_macsec_offload_on_set,
11755 (void *)&cmd_macsec_offload_on_macsec,
11756 (void *)&cmd_macsec_offload_on_offload,
11757 (void *)&cmd_macsec_offload_on_port_id,
11758 (void *)&cmd_macsec_offload_on_on,
11759 (void *)&cmd_macsec_offload_on_encrypt,
11760 (void *)&cmd_macsec_offload_on_en_on_off,
11761 (void *)&cmd_macsec_offload_on_replay_protect,
11762 (void *)&cmd_macsec_offload_on_rp_on_off,
11767 /* Common result structure for MACsec offload disable */
11768 struct cmd_macsec_offload_off_result {
11769 cmdline_fixed_string_t set;
11770 cmdline_fixed_string_t macsec;
11771 cmdline_fixed_string_t offload;
11773 cmdline_fixed_string_t off;
11776 /* Common CLI fields for MACsec offload disable */
11777 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11778 TOKEN_STRING_INITIALIZER
11779 (struct cmd_macsec_offload_off_result,
11781 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11782 TOKEN_STRING_INITIALIZER
11783 (struct cmd_macsec_offload_off_result,
11785 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11786 TOKEN_STRING_INITIALIZER
11787 (struct cmd_macsec_offload_off_result,
11788 offload, "offload");
11789 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11790 TOKEN_NUM_INITIALIZER
11791 (struct cmd_macsec_offload_off_result,
11793 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11794 TOKEN_STRING_INITIALIZER
11795 (struct cmd_macsec_offload_off_result,
11799 cmd_set_macsec_offload_off_parsed(
11800 void *parsed_result,
11801 __attribute__((unused)) struct cmdline *cl,
11802 __attribute__((unused)) void *data)
11804 struct cmd_macsec_offload_off_result *res = parsed_result;
11806 portid_t port_id = res->port_id;
11808 if (port_id_is_invalid(port_id, ENABLED_WARN))
11811 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
11812 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11818 printf("invalid port_id %d\n", port_id);
11821 printf("programming error: (%s)\n", strerror(-ret));
11825 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11826 .f = cmd_set_macsec_offload_off_parsed,
11828 .help_str = "set macsec offload <port_id> off",
11830 (void *)&cmd_macsec_offload_off_set,
11831 (void *)&cmd_macsec_offload_off_macsec,
11832 (void *)&cmd_macsec_offload_off_offload,
11833 (void *)&cmd_macsec_offload_off_port_id,
11834 (void *)&cmd_macsec_offload_off_off,
11839 /* Common result structure for MACsec secure connection configure */
11840 struct cmd_macsec_sc_result {
11841 cmdline_fixed_string_t set;
11842 cmdline_fixed_string_t macsec;
11843 cmdline_fixed_string_t sc;
11844 cmdline_fixed_string_t tx_rx;
11846 struct ether_addr mac;
11850 /* Common CLI fields for MACsec secure connection configure */
11851 cmdline_parse_token_string_t cmd_macsec_sc_set =
11852 TOKEN_STRING_INITIALIZER
11853 (struct cmd_macsec_sc_result,
11855 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11856 TOKEN_STRING_INITIALIZER
11857 (struct cmd_macsec_sc_result,
11859 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11860 TOKEN_STRING_INITIALIZER
11861 (struct cmd_macsec_sc_result,
11863 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11864 TOKEN_STRING_INITIALIZER
11865 (struct cmd_macsec_sc_result,
11867 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11868 TOKEN_NUM_INITIALIZER
11869 (struct cmd_macsec_sc_result,
11871 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11872 TOKEN_ETHERADDR_INITIALIZER
11873 (struct cmd_macsec_sc_result,
11875 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11876 TOKEN_NUM_INITIALIZER
11877 (struct cmd_macsec_sc_result,
11881 cmd_set_macsec_sc_parsed(
11882 void *parsed_result,
11883 __attribute__((unused)) struct cmdline *cl,
11884 __attribute__((unused)) void *data)
11886 struct cmd_macsec_sc_result *res = parsed_result;
11888 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11891 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11892 res->mac.addr_bytes) :
11893 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11894 res->mac.addr_bytes, res->pi);
11899 printf("invalid port_id %d\n", res->port_id);
11902 printf("programming error: (%s)\n", strerror(-ret));
11906 cmdline_parse_inst_t cmd_set_macsec_sc = {
11907 .f = cmd_set_macsec_sc_parsed,
11909 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11911 (void *)&cmd_macsec_sc_set,
11912 (void *)&cmd_macsec_sc_macsec,
11913 (void *)&cmd_macsec_sc_sc,
11914 (void *)&cmd_macsec_sc_tx_rx,
11915 (void *)&cmd_macsec_sc_port_id,
11916 (void *)&cmd_macsec_sc_mac,
11917 (void *)&cmd_macsec_sc_pi,
11922 /* Common result structure for MACsec secure connection configure */
11923 struct cmd_macsec_sa_result {
11924 cmdline_fixed_string_t set;
11925 cmdline_fixed_string_t macsec;
11926 cmdline_fixed_string_t sa;
11927 cmdline_fixed_string_t tx_rx;
11932 cmdline_fixed_string_t key;
11935 /* Common CLI fields for MACsec secure connection configure */
11936 cmdline_parse_token_string_t cmd_macsec_sa_set =
11937 TOKEN_STRING_INITIALIZER
11938 (struct cmd_macsec_sa_result,
11940 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11941 TOKEN_STRING_INITIALIZER
11942 (struct cmd_macsec_sa_result,
11944 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11945 TOKEN_STRING_INITIALIZER
11946 (struct cmd_macsec_sa_result,
11948 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11949 TOKEN_STRING_INITIALIZER
11950 (struct cmd_macsec_sa_result,
11952 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11953 TOKEN_NUM_INITIALIZER
11954 (struct cmd_macsec_sa_result,
11956 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11957 TOKEN_NUM_INITIALIZER
11958 (struct cmd_macsec_sa_result,
11960 cmdline_parse_token_num_t cmd_macsec_sa_an =
11961 TOKEN_NUM_INITIALIZER
11962 (struct cmd_macsec_sa_result,
11964 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11965 TOKEN_NUM_INITIALIZER
11966 (struct cmd_macsec_sa_result,
11968 cmdline_parse_token_string_t cmd_macsec_sa_key =
11969 TOKEN_STRING_INITIALIZER
11970 (struct cmd_macsec_sa_result,
11974 cmd_set_macsec_sa_parsed(
11975 void *parsed_result,
11976 __attribute__((unused)) struct cmdline *cl,
11977 __attribute__((unused)) void *data)
11979 struct cmd_macsec_sa_result *res = parsed_result;
11981 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11982 uint8_t key[16] = { 0 };
11988 key_len = strlen(res->key) / 2;
11992 for (i = 0; i < key_len; i++) {
11993 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11996 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11999 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12003 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12004 res->idx, res->an, res->pn, key) :
12005 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12006 res->idx, res->an, res->pn, key);
12011 printf("invalid idx %d or an %d\n", res->idx, res->an);
12014 printf("invalid port_id %d\n", res->port_id);
12017 printf("programming error: (%s)\n", strerror(-ret));
12021 cmdline_parse_inst_t cmd_set_macsec_sa = {
12022 .f = cmd_set_macsec_sa_parsed,
12024 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12026 (void *)&cmd_macsec_sa_set,
12027 (void *)&cmd_macsec_sa_macsec,
12028 (void *)&cmd_macsec_sa_sa,
12029 (void *)&cmd_macsec_sa_tx_rx,
12030 (void *)&cmd_macsec_sa_port_id,
12031 (void *)&cmd_macsec_sa_idx,
12032 (void *)&cmd_macsec_sa_an,
12033 (void *)&cmd_macsec_sa_pn,
12034 (void *)&cmd_macsec_sa_key,
12040 /* VF unicast promiscuous mode configuration */
12042 /* Common result structure for VF unicast promiscuous mode */
12043 struct cmd_vf_promisc_result {
12044 cmdline_fixed_string_t set;
12045 cmdline_fixed_string_t vf;
12046 cmdline_fixed_string_t promisc;
12049 cmdline_fixed_string_t on_off;
12052 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12053 cmdline_parse_token_string_t cmd_vf_promisc_set =
12054 TOKEN_STRING_INITIALIZER
12055 (struct cmd_vf_promisc_result,
12057 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12058 TOKEN_STRING_INITIALIZER
12059 (struct cmd_vf_promisc_result,
12061 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12062 TOKEN_STRING_INITIALIZER
12063 (struct cmd_vf_promisc_result,
12064 promisc, "promisc");
12065 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12066 TOKEN_NUM_INITIALIZER
12067 (struct cmd_vf_promisc_result,
12069 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12070 TOKEN_NUM_INITIALIZER
12071 (struct cmd_vf_promisc_result,
12073 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12074 TOKEN_STRING_INITIALIZER
12075 (struct cmd_vf_promisc_result,
12079 cmd_set_vf_promisc_parsed(
12080 void *parsed_result,
12081 __attribute__((unused)) struct cmdline *cl,
12082 __attribute__((unused)) void *data)
12084 struct cmd_vf_promisc_result *res = parsed_result;
12085 int ret = -ENOTSUP;
12087 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12089 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12092 #ifdef RTE_LIBRTE_I40E_PMD
12093 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12094 res->vf_id, is_on);
12101 printf("invalid vf_id %d\n", res->vf_id);
12104 printf("invalid port_id %d\n", res->port_id);
12107 printf("function not implemented\n");
12110 printf("programming error: (%s)\n", strerror(-ret));
12114 cmdline_parse_inst_t cmd_set_vf_promisc = {
12115 .f = cmd_set_vf_promisc_parsed,
12117 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12118 "Set unicast promiscuous mode for a VF from the PF",
12120 (void *)&cmd_vf_promisc_set,
12121 (void *)&cmd_vf_promisc_vf,
12122 (void *)&cmd_vf_promisc_promisc,
12123 (void *)&cmd_vf_promisc_port_id,
12124 (void *)&cmd_vf_promisc_vf_id,
12125 (void *)&cmd_vf_promisc_on_off,
12130 /* VF multicast promiscuous mode configuration */
12132 /* Common result structure for VF multicast promiscuous mode */
12133 struct cmd_vf_allmulti_result {
12134 cmdline_fixed_string_t set;
12135 cmdline_fixed_string_t vf;
12136 cmdline_fixed_string_t allmulti;
12139 cmdline_fixed_string_t on_off;
12142 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12143 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12144 TOKEN_STRING_INITIALIZER
12145 (struct cmd_vf_allmulti_result,
12147 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12148 TOKEN_STRING_INITIALIZER
12149 (struct cmd_vf_allmulti_result,
12151 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12152 TOKEN_STRING_INITIALIZER
12153 (struct cmd_vf_allmulti_result,
12154 allmulti, "allmulti");
12155 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12156 TOKEN_NUM_INITIALIZER
12157 (struct cmd_vf_allmulti_result,
12159 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12160 TOKEN_NUM_INITIALIZER
12161 (struct cmd_vf_allmulti_result,
12163 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12164 TOKEN_STRING_INITIALIZER
12165 (struct cmd_vf_allmulti_result,
12169 cmd_set_vf_allmulti_parsed(
12170 void *parsed_result,
12171 __attribute__((unused)) struct cmdline *cl,
12172 __attribute__((unused)) void *data)
12174 struct cmd_vf_allmulti_result *res = parsed_result;
12175 int ret = -ENOTSUP;
12177 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12179 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12182 #ifdef RTE_LIBRTE_I40E_PMD
12183 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12184 res->vf_id, is_on);
12191 printf("invalid vf_id %d\n", res->vf_id);
12194 printf("invalid port_id %d\n", res->port_id);
12197 printf("function not implemented\n");
12200 printf("programming error: (%s)\n", strerror(-ret));
12204 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12205 .f = cmd_set_vf_allmulti_parsed,
12207 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12208 "Set multicast promiscuous mode for a VF from the PF",
12210 (void *)&cmd_vf_allmulti_set,
12211 (void *)&cmd_vf_allmulti_vf,
12212 (void *)&cmd_vf_allmulti_allmulti,
12213 (void *)&cmd_vf_allmulti_port_id,
12214 (void *)&cmd_vf_allmulti_vf_id,
12215 (void *)&cmd_vf_allmulti_on_off,
12220 /* vf broadcast mode configuration */
12222 /* Common result structure for vf broadcast */
12223 struct cmd_set_vf_broadcast_result {
12224 cmdline_fixed_string_t set;
12225 cmdline_fixed_string_t vf;
12226 cmdline_fixed_string_t broadcast;
12229 cmdline_fixed_string_t on_off;
12232 /* Common CLI fields for vf broadcast enable disable */
12233 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12234 TOKEN_STRING_INITIALIZER
12235 (struct cmd_set_vf_broadcast_result,
12237 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12238 TOKEN_STRING_INITIALIZER
12239 (struct cmd_set_vf_broadcast_result,
12241 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12242 TOKEN_STRING_INITIALIZER
12243 (struct cmd_set_vf_broadcast_result,
12244 broadcast, "broadcast");
12245 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12246 TOKEN_NUM_INITIALIZER
12247 (struct cmd_set_vf_broadcast_result,
12249 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12250 TOKEN_NUM_INITIALIZER
12251 (struct cmd_set_vf_broadcast_result,
12253 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12254 TOKEN_STRING_INITIALIZER
12255 (struct cmd_set_vf_broadcast_result,
12259 cmd_set_vf_broadcast_parsed(
12260 void *parsed_result,
12261 __attribute__((unused)) struct cmdline *cl,
12262 __attribute__((unused)) void *data)
12264 struct cmd_set_vf_broadcast_result *res = parsed_result;
12265 int ret = -ENOTSUP;
12267 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12269 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12272 #ifdef RTE_LIBRTE_I40E_PMD
12273 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12274 res->vf_id, is_on);
12281 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12284 printf("invalid port_id %d\n", res->port_id);
12287 printf("function not implemented\n");
12290 printf("programming error: (%s)\n", strerror(-ret));
12294 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12295 .f = cmd_set_vf_broadcast_parsed,
12297 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12299 (void *)&cmd_set_vf_broadcast_set,
12300 (void *)&cmd_set_vf_broadcast_vf,
12301 (void *)&cmd_set_vf_broadcast_broadcast,
12302 (void *)&cmd_set_vf_broadcast_port_id,
12303 (void *)&cmd_set_vf_broadcast_vf_id,
12304 (void *)&cmd_set_vf_broadcast_on_off,
12309 /* vf vlan tag configuration */
12311 /* Common result structure for vf vlan tag */
12312 struct cmd_set_vf_vlan_tag_result {
12313 cmdline_fixed_string_t set;
12314 cmdline_fixed_string_t vf;
12315 cmdline_fixed_string_t vlan;
12316 cmdline_fixed_string_t tag;
12319 cmdline_fixed_string_t on_off;
12322 /* Common CLI fields for vf vlan tag enable disable */
12323 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12324 TOKEN_STRING_INITIALIZER
12325 (struct cmd_set_vf_vlan_tag_result,
12327 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12328 TOKEN_STRING_INITIALIZER
12329 (struct cmd_set_vf_vlan_tag_result,
12331 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12332 TOKEN_STRING_INITIALIZER
12333 (struct cmd_set_vf_vlan_tag_result,
12335 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12336 TOKEN_STRING_INITIALIZER
12337 (struct cmd_set_vf_vlan_tag_result,
12339 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12340 TOKEN_NUM_INITIALIZER
12341 (struct cmd_set_vf_vlan_tag_result,
12343 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12344 TOKEN_NUM_INITIALIZER
12345 (struct cmd_set_vf_vlan_tag_result,
12347 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12348 TOKEN_STRING_INITIALIZER
12349 (struct cmd_set_vf_vlan_tag_result,
12353 cmd_set_vf_vlan_tag_parsed(
12354 void *parsed_result,
12355 __attribute__((unused)) struct cmdline *cl,
12356 __attribute__((unused)) void *data)
12358 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12359 int ret = -ENOTSUP;
12361 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12363 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12366 #ifdef RTE_LIBRTE_I40E_PMD
12367 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12368 res->vf_id, is_on);
12375 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12378 printf("invalid port_id %d\n", res->port_id);
12381 printf("function not implemented\n");
12384 printf("programming error: (%s)\n", strerror(-ret));
12388 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12389 .f = cmd_set_vf_vlan_tag_parsed,
12391 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12393 (void *)&cmd_set_vf_vlan_tag_set,
12394 (void *)&cmd_set_vf_vlan_tag_vf,
12395 (void *)&cmd_set_vf_vlan_tag_vlan,
12396 (void *)&cmd_set_vf_vlan_tag_tag,
12397 (void *)&cmd_set_vf_vlan_tag_port_id,
12398 (void *)&cmd_set_vf_vlan_tag_vf_id,
12399 (void *)&cmd_set_vf_vlan_tag_on_off,
12404 /* ******************************************************************************** */
12406 /* list of instructions */
12407 cmdline_parse_ctx_t main_ctx[] = {
12408 (cmdline_parse_inst_t *)&cmd_help_brief,
12409 (cmdline_parse_inst_t *)&cmd_help_long,
12410 (cmdline_parse_inst_t *)&cmd_quit,
12411 (cmdline_parse_inst_t *)&cmd_showport,
12412 (cmdline_parse_inst_t *)&cmd_showqueue,
12413 (cmdline_parse_inst_t *)&cmd_showportall,
12414 (cmdline_parse_inst_t *)&cmd_showcfg,
12415 (cmdline_parse_inst_t *)&cmd_start,
12416 (cmdline_parse_inst_t *)&cmd_start_tx_first,
12417 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
12418 (cmdline_parse_inst_t *)&cmd_set_link_up,
12419 (cmdline_parse_inst_t *)&cmd_set_link_down,
12420 (cmdline_parse_inst_t *)&cmd_reset,
12421 (cmdline_parse_inst_t *)&cmd_set_numbers,
12422 (cmdline_parse_inst_t *)&cmd_set_txpkts,
12423 (cmdline_parse_inst_t *)&cmd_set_txsplit,
12424 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
12425 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
12426 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
12427 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
12428 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
12429 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
12430 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
12431 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
12432 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
12433 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
12434 (cmdline_parse_inst_t *)&cmd_set_link_check,
12435 #ifdef RTE_NIC_BYPASS
12436 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
12437 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
12438 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
12439 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
12441 #ifdef RTE_LIBRTE_PMD_BOND
12442 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
12443 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
12444 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
12445 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
12446 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
12447 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
12448 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
12449 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
12450 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
12452 (cmdline_parse_inst_t *)&cmd_vlan_offload,
12453 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
12454 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
12455 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
12456 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
12457 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
12458 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
12459 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
12460 (cmdline_parse_inst_t *)&cmd_csum_set,
12461 (cmdline_parse_inst_t *)&cmd_csum_show,
12462 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
12463 (cmdline_parse_inst_t *)&cmd_tso_set,
12464 (cmdline_parse_inst_t *)&cmd_tso_show,
12465 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
12466 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
12467 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
12468 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
12469 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
12470 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
12471 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
12472 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
12473 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
12474 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
12475 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
12476 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
12477 (cmdline_parse_inst_t *)&cmd_config_dcb,
12478 (cmdline_parse_inst_t *)&cmd_read_reg,
12479 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
12480 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
12481 (cmdline_parse_inst_t *)&cmd_write_reg,
12482 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
12483 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
12484 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
12485 (cmdline_parse_inst_t *)&cmd_stop,
12486 (cmdline_parse_inst_t *)&cmd_mac_addr,
12487 (cmdline_parse_inst_t *)&cmd_set_qmap,
12488 (cmdline_parse_inst_t *)&cmd_operate_port,
12489 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
12490 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
12491 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
12492 (cmdline_parse_inst_t *)&cmd_config_speed_all,
12493 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
12494 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
12495 (cmdline_parse_inst_t *)&cmd_config_mtu,
12496 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
12497 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
12498 (cmdline_parse_inst_t *)&cmd_config_rss,
12499 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
12500 (cmdline_parse_inst_t *)&cmd_config_txqflags,
12501 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
12502 (cmdline_parse_inst_t *)&cmd_showport_reta,
12503 (cmdline_parse_inst_t *)&cmd_config_burst,
12504 (cmdline_parse_inst_t *)&cmd_config_thresh,
12505 (cmdline_parse_inst_t *)&cmd_config_threshold,
12506 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
12507 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
12508 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
12509 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
12510 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
12511 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
12512 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
12513 (cmdline_parse_inst_t *)&cmd_global_config,
12514 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
12515 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
12516 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
12517 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
12518 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
12519 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
12520 (cmdline_parse_inst_t *)&cmd_dump,
12521 (cmdline_parse_inst_t *)&cmd_dump_one,
12522 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
12523 (cmdline_parse_inst_t *)&cmd_syn_filter,
12524 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
12525 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
12526 (cmdline_parse_inst_t *)&cmd_flex_filter,
12527 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
12528 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
12529 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
12530 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
12531 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
12532 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
12533 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
12534 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
12535 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
12536 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
12537 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
12538 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
12539 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
12540 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
12541 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
12542 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
12543 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
12544 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
12545 (cmdline_parse_inst_t *)&cmd_flow,
12546 (cmdline_parse_inst_t *)&cmd_mcast_addr,
12547 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
12548 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
12549 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
12550 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
12551 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
12552 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
12553 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
12554 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
12555 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
12556 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
12557 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
12558 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
12559 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
12560 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
12561 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
12562 #ifdef RTE_LIBRTE_IXGBE_PMD
12563 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
12564 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
12565 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
12566 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
12567 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
12568 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
12569 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
12570 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
12571 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
12573 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
12574 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
12575 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
12576 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
12577 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
12578 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
12582 /* prompt function, called from main on MASTER lcore */
12586 /* initialize non-constant commands */
12587 cmd_set_fwd_mode_init();
12588 cmd_set_fwd_retry_mode_init();
12590 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
12591 if (testpmd_cl == NULL)
12593 cmdline_interact(testpmd_cl);
12594 cmdline_stdin_exit(testpmd_cl);
12600 if (testpmd_cl != NULL)
12601 cmdline_quit(testpmd_cl);
12605 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
12607 if (id == (portid_t)RTE_PORT_ALL) {
12610 FOREACH_PORT(pid, ports) {
12611 /* check if need_reconfig has been set to 1 */
12612 if (ports[pid].need_reconfig == 0)
12613 ports[pid].need_reconfig = dev;
12614 /* check if need_reconfig_queues has been set to 1 */
12615 if (ports[pid].need_reconfig_queues == 0)
12616 ports[pid].need_reconfig_queues = queue;
12618 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
12619 /* check if need_reconfig has been set to 1 */
12620 if (ports[id].need_reconfig == 0)
12621 ports[id].need_reconfig = dev;
12622 /* check if need_reconfig_queues has been set to 1 */
12623 if (ports[id].need_reconfig_queues == 0)
12624 ports[id].need_reconfig_queues = queue;